polotno-node 2.15.18 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -15
- package/dist/assets/html2canvas-CfrNTgDn.js +5 -0
- package/dist/assets/index-oYy3TsOk.js +464 -0
- package/dist/assets/{index.es-BZlJTB_J.js → index.es-C7BBG6KT.js} +5 -5
- package/dist/assets/jspdf.es.min-D1g0nHTs.js +79 -0
- package/dist/assets/lib-U0NRl5MI.js +65 -0
- package/dist/assets/purify.es-DlxR2Lg_.js +3 -0
- package/dist/index.html +1 -2
- package/font-cache.js +109 -0
- package/index.d.ts +7 -0
- package/index.js +2 -0
- package/instance.js +205 -223
- package/package.json +21 -17
- package/dist/assets/chunk-CilyBKbf.js +0 -1
- package/dist/assets/html2canvas-CmxtTAk0.js +0 -5
- package/dist/assets/index-dqgNRWnn.js +0 -344
- package/dist/assets/jspdf.es.min-CMl2XfPr.js +0 -79
- package/dist/assets/lib-Y0AZVm_8.js +0 -65
- package/dist/assets/purify.es-DjJUbhsB.js +0 -2
- package/video-parallel.js +0 -414
- /package/dist/assets/{typeof-GPCnPm50.js → typeof-B5XbjTb1.js} +0 -0
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./jspdf.es.min-D1g0nHTs.js","./typeof-B5XbjTb1.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ee=/\/+/g;function A(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function j(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function te(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,te(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+A(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(ee,`$&/`)+`/`),te(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ee,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+A(a,u),c+=te(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+A(a,u++),c+=te(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return te(j(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function M(e,t,n){if(e==null)return e;var r=[],i=0;return te(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ne(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var N=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},P={map:M,forEach:function(e,t,n){M(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return M(e,function(){t++}),t},toArray:function(e){return M(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=P,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ne}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,N)}catch(e){N(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.7`})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&A(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&A(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,ee=k.port2;k.port1.onmessage=D,O=function(){ee.postMessage(null)}}else O=function(){_(D,0)};function A(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,A(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=d();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.7`})),h=o(((e,t)=>{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)}}n(),t.exports=m()})),g=o((e=>{var t=p(),n=d(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),ee=Symbol.for(`react.memo_cache_sentinel`),A=Symbol.iterator;function j(e){return typeof e!=`object`||!e?null:(e=A&&e[A]||e[`@@iterator`],typeof e==`function`?e:null)}var te=Symbol.for(`react.client.reference`);function M(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===te?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case k:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?M(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return M(e(t))}catch{}}return null}var ne=Array.isArray,N=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,P=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,re={pending:!1,data:null,method:null,action:null},ie=[],ae=-1;function F(e){return{current:e}}function oe(e){0>ae||(e.current=ie[ae],ie[ae]=null,ae--)}function se(e,t){ae++,ie[ae]=e.current,e.current=t}var ce=F(null),le=F(null),ue=F(null),de=F(null);function fe(e,t){switch(se(ue,t),se(le,e),se(ce,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Xd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Xd(t),e=Zd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}oe(ce),se(ce,e)}function pe(){oe(ce),oe(le),oe(ue)}function me(e){e.memoizedState!==null&&se(de,e);var t=ce.current,n=Zd(t,e.type);t!==n&&(se(le,e),se(ce,n))}function he(e){le.current===e&&(oe(ce),oe(le)),de.current===e&&(oe(de),sp._currentValue=re)}var ge,_e;function ve(e){if(ge===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ge=t&&t[1]||``,_e=-1<e.stack.indexOf(`
|
|
3
|
+
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
|
+
`+ge+e+_e}var ye=!1;function be(e,t){if(!e||ye)return``;ye=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
5
|
+
`),l=s.split(`
|
|
6
|
+
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
|
7
|
+
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{ye=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?ve(n):``}function xe(e,t){switch(e.tag){case 26:case 27:case 5:return ve(e.type);case 16:return ve(`Lazy`);case 13:return e.child!==t&&t!==null?ve(`Suspense Fallback`):ve(`Suspense`);case 19:return ve(`SuspenseList`);case 0:case 15:return be(e.type,!1);case 11:return be(e.type.render,!1);case 1:return be(e.type,!0);case 31:return ve(`Activity`);default:return``}}function Se(e){try{var t=``,n=null;do t+=xe(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
8
|
+
Error generating stack: `+e.message+`
|
|
9
|
+
`+e.stack}}var Ce=Object.prototype.hasOwnProperty,we=t.unstable_scheduleCallback,Te=t.unstable_cancelCallback,Ee=t.unstable_shouldYield,De=t.unstable_requestPaint,Oe=t.unstable_now,ke=t.unstable_getCurrentPriorityLevel,Ae=t.unstable_ImmediatePriority,je=t.unstable_UserBlockingPriority,Me=t.unstable_NormalPriority,Ne=t.unstable_LowPriority,Pe=t.unstable_IdlePriority,Fe=t.log,Ie=t.unstable_setDisableYieldValue,Le=null,Re=null;function ze(e){if(typeof Fe==`function`&&Ie(e),Re&&typeof Re.setStrictMode==`function`)try{Re.setStrictMode(Le,e)}catch{}}var I=Math.clz32?Math.clz32:He,Be=Math.log,Ve=Math.LN2;function He(e){return e>>>=0,e===0?32:31-(Be(e)/Ve|0)|0}var Ue=256,We=262144,Ge=4194304;function Ke(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function qe(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Ke(n))):i=Ke(o):i=Ke(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Ke(n))):i=Ke(o)):i=Ke(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Je(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ye(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Xe(){var e=Ge;return Ge<<=1,!(Ge&62914560)&&(Ge=4194304),e}function Ze(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Qe(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function $e(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-I(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&et(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function et(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-I(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function tt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-I(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function nt(e,t){var n=t&-t;return n=n&42?1:rt(n),(n&(e.suspendedLanes|t))===0?n:0}function rt(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function it(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function at(){var e=P.p;return e===0?(e=window.event,e===void 0?32:Cp(e.type)):e}function ot(e,t){var n=P.p;try{return P.p=e,t()}finally{P.p=n}}var st=Math.random().toString(36).slice(2),ct=`__reactFiber$`+st,lt=`__reactProps$`+st,ut=`__reactContainer$`+st,dt=`__reactEvents$`+st,ft=`__reactListeners$`+st,pt=`__reactHandles$`+st,mt=`__reactResources$`+st,ht=`__reactMarker$`+st;function gt(e){delete e[ct],delete e[lt],delete e[dt],delete e[ft],delete e[pt]}function _t(e){var t=e[ct];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ut]||n[ct]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=bf(e);e!==null;){if(n=e[ct])return n;e=bf(e)}return t}e=n,n=e.parentNode}return null}function vt(e){if(e=e[ct]||e[ut]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function yt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function bt(e){var t=e[mt];return t||=e[mt]={hoistableStyles:new Map,hoistableScripts:new Map},t}function xt(e){e[ht]=!0}var St=new Set,Ct={};function wt(e,t){Tt(e,t),Tt(e+`Capture`,t)}function Tt(e,t){for(Ct[e]=t,e=0;e<t.length;e++)St.add(t[e])}var Et=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),Dt={},Ot={};function kt(e){return Ce.call(Ot,e)?!0:Ce.call(Dt,e)?!1:Et.test(e)?Ot[e]=!0:(Dt[e]=!0,!1)}function At(e,t,n){if(kt(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function jt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function Mt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function Nt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Pt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Ft(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function It(e){if(!e._valueTracker){var t=Pt(e)?`checked`:`value`;e._valueTracker=Ft(e,t,``+e[t])}}function Lt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Pt(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function Rt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var zt=/[\n"\\]/g;function Bt(e){return e.replace(zt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Vt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Nt(t)):e.value!==``+Nt(t)&&(e.value=``+Nt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Ut(e,o,Nt(n)):Ut(e,o,Nt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Nt(s):e.removeAttribute(`name`)}function Ht(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){It(e);return}n=n==null?``:``+Nt(n),t=t==null?n:``+Nt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),It(e)}function Ut(e,t,n){t===`number`&&Rt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function Wt(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Nt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Gt(e,t,n){if(t!=null&&(t=``+Nt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Nt(n)}function Kt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(ne(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Nt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),It(e)}function qt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Jt=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Yt(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Jt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Xt(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Yt(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Yt(e,o,t[o])}function Zt(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Qt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),$t=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function en(e){return $t.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function tn(){}var nn=null;function rn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var an=null,on=null;function sn(e){var t=vt(e);if(t&&(e=t.stateNode)){var n=e[lt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Vt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Bt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[lt]||null;if(!a)throw Error(i(90));Vt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Lt(r)}break a;case`textarea`:Gt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&Wt(e,!!n.multiple,t,!1)}}}var cn=!1;function ln(e,t,n){if(cn)return e(t,n);cn=!0;try{return e(t)}finally{if(cn=!1,(an!==null||on!==null)&&(Du(),an&&(t=an,e=on,on=an=null,sn(t),e)))for(t=0;t<e.length;t++)sn(e[t])}}function un(e,t){var n=e.stateNode;if(n===null)return null;var r=n[lt]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var dn=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),fn=!1;if(dn)try{var pn={};Object.defineProperty(pn,"passive",{get:function(){fn=!0}}),window.addEventListener(`test`,pn,pn),window.removeEventListener(`test`,pn,pn)}catch{fn=!1}var mn=null,hn=null,gn=null;function _n(){if(gn)return gn;var e,t=hn,n=t.length,r,i=`value`in mn?mn.value:mn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return gn=i.slice(e,1<r?1-r:void 0)}function vn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function yn(){return!0}function bn(){return!1}function xn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?yn:bn,this.isPropagationStopped=bn,this}return m(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=yn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=yn)},persist:function(){},isPersistent:yn}),t}var Sn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Cn=xn(Sn),wn=m({},Sn,{view:0,detail:0}),Tn=xn(wn),En,Dn,L,On=m({},wn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:zn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==L&&(L&&e.type===`mousemove`?(En=e.screenX-L.screenX,Dn=e.screenY-L.screenY):Dn=En=0,L=e),En)},movementY:function(e){return`movementY`in e?e.movementY:Dn}}),kn=xn(On),An=xn(m({},On,{dataTransfer:0})),jn=xn(m({},wn,{relatedTarget:0})),Mn=xn(m({},Sn,{animationName:0,elapsedTime:0,pseudoElement:0})),Nn=xn(m({},Sn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Pn=xn(m({},Sn,{data:0})),Fn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},In={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`},Ln={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Rn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Ln[e])?!!t[e]:!1}function zn(){return Rn}var Bn=xn(m({},wn,{key:function(e){if(e.key){var t=Fn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=vn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?In[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:zn,charCode:function(e){return e.type===`keypress`?vn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?vn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Vn=xn(m({},On,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Hn=xn(m({},wn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:zn})),Un=xn(m({},Sn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Wn=xn(m({},On,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Gn=xn(m({},Sn,{newState:0,oldState:0})),Kn=[9,13,27,32],qn=dn&&`CompositionEvent`in window,Jn=null;dn&&`documentMode`in document&&(Jn=document.documentMode);var Yn=dn&&`TextEvent`in window&&!Jn,Xn=dn&&(!qn||Jn&&8<Jn&&11>=Jn),Zn=` `,Qn=!1;function $n(e,t){switch(e){case`keyup`:return Kn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function er(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var tr=!1;function nr(e,t){switch(e){case`compositionend`:return er(t);case`keypress`:return t.which===32?(Qn=!0,Zn):null;case`textInput`:return e=t.data,e===Zn&&Qn?null:e;default:return null}}function rr(e,t){if(tr)return e===`compositionend`||!qn&&$n(e,t)?(e=_n(),gn=hn=mn=null,tr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return Xn&&t.locale!==`ko`?null:t.data;default:return null}}var ir={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 ar(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!ir[e.type]:t===`textarea`}function or(e,t,n,r){an?on?on.push(r):on=[r]:an=r,t=Pd(t,`onChange`),0<t.length&&(n=new Cn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var sr=null,cr=null;function lr(e){Ed(e,0)}function ur(e){if(Lt(yt(e)))return e}function dr(e,t){if(e===`change`)return t}var fr=!1;if(dn){var pr;if(dn){var mr=`oninput`in document;if(!mr){var hr=document.createElement(`div`);hr.setAttribute(`oninput`,`return;`),mr=typeof hr.oninput==`function`}pr=mr}else pr=!1;fr=pr&&(!document.documentMode||9<document.documentMode)}function gr(){sr&&(sr.detachEvent(`onpropertychange`,_r),cr=sr=null)}function _r(e){if(e.propertyName===`value`&&ur(cr)){var t=[];or(t,cr,e,rn(e)),ln(lr,t)}}function vr(e,t,n){e===`focusin`?(gr(),sr=t,cr=n,sr.attachEvent(`onpropertychange`,_r)):e===`focusout`&&gr()}function yr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return ur(cr)}function br(e,t){if(e===`click`)return ur(t)}function xr(e,t){if(e===`input`||e===`change`)return ur(t)}function Sr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Cr=typeof Object.is==`function`?Object.is:Sr;function wr(e,t){if(Cr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Ce.call(t,i)||!Cr(e[i],t[i]))return!1}return!0}function Tr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Er(e,t){var n=Tr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Tr(n)}}function Dr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Dr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Or(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Rt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Rt(e.document)}return t}function kr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Ar=dn&&`documentMode`in document&&11>=document.documentMode,jr=null,Mr=null,Nr=null,Pr=!1;function Fr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Pr||jr==null||jr!==Rt(r)||(r=jr,`selectionStart`in r&&kr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Nr&&wr(Nr,r)||(Nr=r,r=Pd(Mr,`onSelect`),0<r.length&&(t=new Cn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=jr)))}function Ir(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Lr={animationend:Ir(`Animation`,`AnimationEnd`),animationiteration:Ir(`Animation`,`AnimationIteration`),animationstart:Ir(`Animation`,`AnimationStart`),transitionrun:Ir(`Transition`,`TransitionRun`),transitionstart:Ir(`Transition`,`TransitionStart`),transitioncancel:Ir(`Transition`,`TransitionCancel`),transitionend:Ir(`Transition`,`TransitionEnd`)},Rr={},zr={};dn&&(zr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Lr.animationend.animation,delete Lr.animationiteration.animation,delete Lr.animationstart.animation),`TransitionEvent`in window||delete Lr.transitionend.transition);function Br(e){if(Rr[e])return Rr[e];if(!Lr[e])return e;var t=Lr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in zr)return Rr[e]=t[n];return e}var Vr=Br(`animationend`),Hr=Br(`animationiteration`),Ur=Br(`animationstart`),Wr=Br(`transitionrun`),Gr=Br(`transitionstart`),Kr=Br(`transitioncancel`),qr=Br(`transitionend`),Jr=new Map,Yr=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Yr.push(`scrollEnd`);function Xr(e,t){Jr.set(e,t),wt(t,[e])}var Zr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Qr=[],$r=0,ei=0;function ti(){for(var e=$r,t=ei=$r=0;t<e;){var n=Qr[t];Qr[t++]=null;var r=Qr[t];Qr[t++]=null;var i=Qr[t];Qr[t++]=null;var a=Qr[t];if(Qr[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&ai(n,i,a)}}function ni(e,t,n,r){Qr[$r++]=e,Qr[$r++]=t,Qr[$r++]=n,Qr[$r++]=r,ei|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function ri(e,t,n,r){return ni(e,t,n,r),oi(e)}function ii(e,t){return ni(e,null,null,t),oi(e)}function ai(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-I(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function oi(e){if(50<vu)throw vu=0,yu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var si={};function ci(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function li(e,t,n,r){return new ci(e,t,n,r)}function ui(e){return e=e.prototype,!(!e||!e.isReactComponent)}function di(e,t){var n=e.alternate;return n===null?(n=li(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function fi(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function pi(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)ui(e)&&(s=1);else if(typeof e==`string`)s=Qf(e,n,ce.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case k:return e=li(31,n,t,a),e.elementType=k,e.lanes=o,e;case y:return mi(n.children,a,o,t);case b:s=8,a|=24;break;case x:return e=li(12,n,t,a|2),e.elementType=x,e.lanes=o,e;case T:return e=li(13,n,t,a),e.elementType=T,e.lanes=o,e;case E:return e=li(19,n,t,a),e.elementType=E,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case C:s=10;break a;case S:s=9;break a;case w:s=11;break a;case D:s=14;break a;case O:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=li(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function mi(e,t,n,r){return e=li(7,e,r,t),e.lanes=n,e}function hi(e,t,n){return e=li(6,e,null,t),e.lanes=n,e}function gi(e){var t=li(18,null,null,0);return t.stateNode=e,t}function _i(e,t,n){return t=li(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var vi=new WeakMap;function yi(e,t){if(typeof e==`object`&&e){var n=vi.get(e);return n===void 0?(t={value:e,source:t,stack:Se(t)},vi.set(e,t),t):n}return{value:e,source:t,stack:Se(t)}}var bi=[],xi=0,Si=null,Ci=0,wi=[],Ti=0,Ei=null,Di=1,Oi=``;function ki(e,t){bi[xi++]=Ci,bi[xi++]=Si,Si=e,Ci=t}function Ai(e,t,n){wi[Ti++]=Di,wi[Ti++]=Oi,wi[Ti++]=Ei,Ei=e;var r=Di;e=Oi;var i=32-I(r)-1;r&=~(1<<i),n+=1;var a=32-I(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Di=1<<32-I(t)+i|n<<i|r,Oi=a+e}else Di=1<<a|n<<i|r,Oi=e}function ji(e){e.return!==null&&(ki(e,1),Ai(e,1,0))}function Mi(e){for(;e===Si;)Si=bi[--xi],bi[xi]=null,Ci=bi[--xi],bi[xi]=null;for(;e===Ei;)Ei=wi[--Ti],wi[Ti]=null,Oi=wi[--Ti],wi[Ti]=null,Di=wi[--Ti],wi[Ti]=null}function Ni(e,t){wi[Ti++]=Di,wi[Ti++]=Oi,wi[Ti++]=Ei,Di=t.id,Oi=t.overflow,Ei=e}var Pi=null,Fi=null,Ii=!1,Li=null,Ri=!1,zi=Error(i(519));function Bi(e){throw Ki(yi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),zi}function Vi(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[ct]=e,t[lt]=r,n){case`dialog`:Dd(`cancel`,t),Dd(`close`,t);break;case`iframe`:case`object`:case`embed`:Dd(`load`,t);break;case`video`:case`audio`:for(n=0;n<wd.length;n++)Dd(wd[n],t);break;case`source`:Dd(`error`,t);break;case`img`:case`image`:case`link`:Dd(`error`,t),Dd(`load`,t);break;case`details`:Dd(`toggle`,t);break;case`input`:Dd(`invalid`,t),Ht(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Dd(`invalid`,t);break;case`textarea`:Dd(`invalid`,t),Kt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Bd(t.textContent,n)?(r.popover!=null&&(Dd(`beforetoggle`,t),Dd(`toggle`,t)),r.onScroll!=null&&Dd(`scroll`,t),r.onScrollEnd!=null&&Dd(`scrollend`,t),r.onClick!=null&&(t.onclick=tn),t=!0):t=!1,t||Bi(e,!0)}function Hi(e){for(Pi=e.return;Pi;)switch(Pi.tag){case 5:case 31:case 13:Ri=!1;return;case 27:case 3:Ri=!0;return;default:Pi=Pi.return}}function Ui(e){if(e!==Pi)return!1;if(!Ii)return Hi(e),Ii=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||Qd(e.type,e.memoizedProps)),n=!n),n&&Fi&&Bi(e),Hi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Fi=yf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Fi=yf(e)}else t===27?(t=Fi,sf(e.type)?(e=vf,vf=null,Fi=e):Fi=t):Fi=Pi?_f(e.stateNode.nextSibling):null;return!0}function Wi(){Fi=Pi=null,Ii=!1}function Gi(){var e=Li;return e!==null&&(iu===null?iu=e:iu.push.apply(iu,e),Li=null),e}function Ki(e){Li===null?Li=[e]:Li.push(e)}var qi=F(null),Ji=null,Yi=null;function Xi(e,t,n){se(qi,t._currentValue),t._currentValue=n}function Zi(e){e._currentValue=qi.current,oe(qi)}function Qi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function $i(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Qi(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),Qi(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function ea(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;Cr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===de.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[sp]:e.push(sp))}a=a.return}e!==null&&$i(t,e,n,r),t.flags|=262144}function ta(e){for(e=e.firstContext;e!==null;){if(!Cr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function na(e){Ji=e,Yi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function ra(e){return aa(Ji,e)}function ia(e,t){return Ji===null&&na(e),aa(e,t)}function aa(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Yi===null){if(e===null)throw Error(i(308));Yi=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Yi=Yi.next=t;return n}var oa=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},sa=t.unstable_scheduleCallback,ca=t.unstable_NormalPriority,la={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ua(){return{controller:new oa,data:new Map,refCount:0}}function da(e){e.refCount--,e.refCount===0&&sa(ca,function(){e.controller.abort()})}var fa=null,pa=0,ma=0,ha=null;function ga(e,t){if(fa===null){var n=fa=[];pa=0,ma=vd(),ha={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return pa++,t.then(_a,_a),t}function _a(){if(--pa===0&&fa!==null){ha!==null&&(ha.status=`fulfilled`);var e=fa;fa=null,ma=0,ha=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function va(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var ya=N.S;N.S=function(e,t){su=Oe(),typeof t==`object`&&t&&typeof t.then==`function`&&ga(e,t),ya!==null&&ya(e,t)};var ba=F(null);function xa(){var e=ba.current;return e===null?Hl.pooledCache:e}function Sa(e,t){t===null?se(ba,ba.current):se(ba,t.pool)}function Ca(){var e=xa();return e===null?null:{parent:la._currentValue,pool:e}}var wa=Error(i(460)),Ta=Error(i(474)),Ea=Error(i(542)),Da={then:function(){}};function Oa(e){return e=e.status,e===`fulfilled`||e===`rejected`}function ka(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(tn,tn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ma(e),e;default:if(typeof t.status==`string`)t.then(tn,tn);else{if(e=Hl,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ma(e),e}throw ja=t,wa}}function Aa(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(ja=e,wa):e}}var ja=null;function R(){if(ja===null)throw Error(i(459));var e=ja;return ja=null,e}function Ma(e){if(e===wa||e===Ea)throw Error(i(483))}var Na=null,Pa=0;function Fa(e){var t=Pa;return Pa+=1,Na===null&&(Na=[]),ka(Na,e,t)}function Ia(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function La(e,t){throw t.$$typeof===g?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Ra(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=di(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=hi(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===y?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===O&&Aa(i)===t.type)?(t=a(t,n.props),Ia(t,n),t.return=e,t):(t=pi(n.type,n.key,n.props,null,e.mode,r),Ia(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=_i(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=mi(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=hi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case _:return n=pi(t.type,t.key,t.props,null,e.mode,n),Ia(n,t),n.return=e,n;case v:return t=_i(t,e.mode,n),t.return=e,t;case O:return t=Aa(t),f(e,t,n)}if(ne(t)||j(t))return t=mi(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Fa(t),n);if(t.$$typeof===C)return f(e,ia(e,t),n);La(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case _:return n.key===i?l(e,t,n,r):null;case v:return n.key===i?u(e,t,n,r):null;case O:return n=Aa(n),p(e,t,n,r)}if(ne(n)||j(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Fa(n),r);if(n.$$typeof===C)return p(e,t,ia(e,n),r);La(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case _:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case v:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case O:return r=Aa(r),m(e,t,n,r,i)}if(ne(r)||j(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,Fa(r),i);if(r.$$typeof===C)return m(e,t,n,ia(t,r),i);La(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),Ii&&ki(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return Ii&&ki(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),Ii&&ki(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),Ii&&ki(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return Ii&&ki(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),Ii&&ki(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case _:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===O&&Aa(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ia(c,o),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}o.type===y?(c=mi(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=pi(o.type,o.key,o.props,null,e.mode,c),Ia(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=_i(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=Aa(o),b(e,r,o,c)}if(ne(o))return h(e,r,o,c);if(j(o)){if(l=j(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,Fa(o),c);if(o.$$typeof===C)return b(e,r,ia(e,o),c);La(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=hi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Pa=0;var i=b(e,t,n,r);return Na=null,i}catch(t){if(t===wa||t===Ea)throw t;var a=li(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var za=Ra(!0),Ba=Ra(!1),Va=!1;function Ha(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ua(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Wa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ga(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Vl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=oi(e),ai(e,null,n),t}return ni(e,r,t,n),oi(e)}function Ka(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,tt(e,n)}}function qa(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Ja=!1;function Ya(){if(Ja){var e=ha;if(e!==null)throw e}}function Xa(e,t,n,r){Ja=!1;var i=e.updateQueue;Va=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Wl&f)===f:(r&f)===f){f!==0&&f===ma&&(Ja=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,f);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,f=typeof h==`function`?h.call(_,d,f):h,f==null)break a;d=m({},d,f);break a;case 2:Va=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Ql|=o,e.lanes=o,e.memoizedState=d}}function Za(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Qa(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Za(n[e],t)}var z=F(null),$a=F(0);function eo(e,t){e=Xl,se($a,e),se(z,t),Xl=e|t.baseLanes}function to(){se($a,Xl),se(z,z.current)}function no(){Xl=$a.current,oe(z),oe($a)}var ro=F(null),io=null;function ao(e){var t=e.alternate;se(uo,uo.current&1),se(ro,e),io===null&&(t===null||z.current!==null||t.memoizedState!==null)&&(io=e)}function oo(e){se(uo,uo.current),se(ro,e),io===null&&(io=e)}function so(e){e.tag===22?(se(uo,uo.current),se(ro,e),io===null&&(io=e)):co(e)}function co(){se(uo,uo.current),se(ro,ro.current)}function lo(e){oe(ro),io===e&&(io=null),oe(uo)}var uo=F(0);function fo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||mf(n)||hf(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var po=0,mo=null,ho=null,go=null,_o=!1,vo=!1,yo=!1,bo=0,xo=0,So=null,Co=0;function wo(){throw Error(i(321))}function B(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Cr(e[n],t[n]))return!1;return!0}function To(e,t,n,r,i,a){return po=a,mo=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,N.H=e===null||e.memoizedState===null?Bs:Vs,yo=!1,a=n(r,i),yo=!1,vo&&(a=Do(t,n,r,i)),Eo(e),a}function Eo(e){N.H=zs;var t=ho!==null&&ho.next!==null;if(po=0,go=ho=mo=null,_o=!1,xo=0,So=null,t)throw Error(i(300));e===null||ic||(e=e.dependencies,e!==null&&ta(e)&&(ic=!0))}function Do(e,t,n,r){mo=e;var a=0;do{if(vo&&(So=null),xo=0,vo=!1,25<=a)throw Error(i(301));if(a+=1,go=ho=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}N.H=Hs,o=t(n,r)}while(vo);return o}function Oo(){var e=N.H,t=e.useState()[0];return t=typeof t.then==`function`?Po(t):t,e=e.useState()[0],(ho===null?null:ho.memoizedState)!==e&&(mo.flags|=1024),t}function ko(){var e=bo!==0;return bo=0,e}function Ao(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function jo(e){if(_o){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}_o=!1}po=0,go=ho=mo=null,vo=!1,xo=bo=0,So=null}function Mo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return go===null?mo.memoizedState=go=e:go=go.next=e,go}function No(){if(ho===null){var e=mo.alternate;e=e===null?null:e.memoizedState}else e=ho.next;var t=go===null?mo.memoizedState:go.next;if(t!==null)go=t,ho=e;else{if(e===null)throw mo.alternate===null?Error(i(467)):Error(i(310));ho=e,e={memoizedState:ho.memoizedState,baseState:ho.baseState,baseQueue:ho.baseQueue,queue:ho.queue,next:null},go===null?mo.memoizedState=go=e:go=go.next=e}return go}function V(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Po(e){var t=xo;return xo+=1,So===null&&(So=[]),e=ka(So,e,t),t=mo,(go===null?t.memoizedState:go.next)===null&&(t=t.alternate,N.H=t===null||t.memoizedState===null?Bs:Vs),e}function Fo(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Po(e);if(e.$$typeof===C)return ra(e)}throw Error(i(438,String(e)))}function Io(e){var t=null,n=mo.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=mo.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=V(),mo.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=ee;return t.index++,n}function Lo(e,t){return typeof t==`function`?t(e):t}function Ro(e){return zo(No(),ho,e)}function zo(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(po&f)===f:(Wl&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===ma&&(d=!0);else if((po&p)===p){u=u.next,p===ma&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,mo.lanes|=p,Ql|=p;f=u.action,yo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,mo.lanes|=f,Ql|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Cr(o,e.memoizedState)&&(ic=!0,d&&(n=ha,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Bo(e){var t=No(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Cr(o,t.memoizedState)||(ic=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Vo(e,t,n){var r=mo,a=No(),o=Ii;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!Cr((ho||a).memoizedState,n);if(s&&(a.memoizedState=n,ic=!0),a=a.queue,ds(Wo.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||go!==null&&go.memoizedState.tag&1){if(r.flags|=2048,os(9,{destroy:void 0},Uo.bind(null,r,a,n,t),null),Hl===null)throw Error(i(349));o||po&127||Ho(r,t,n)}return n}function Ho(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=mo.updateQueue,t===null?(t=V(),mo.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Uo(e,t,n,r){t.value=n,t.getSnapshot=r,Go(t)&&Ko(e)}function Wo(e,t,n){return n(function(){Go(t)&&Ko(e)})}function Go(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Cr(e,n)}catch{return!0}}function Ko(e){var t=ii(e,2);t!==null&&Su(t,e,2)}function qo(e){var t=Mo();if(typeof e==`function`){var n=e;if(e=n(),yo){ze(!0);try{n()}finally{ze(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:e},t}function Jo(e,t,n,r){return e.baseState=n,zo(e,ho,typeof r==`function`?r:Lo)}function Yo(e,t,n,r,a){if(Is(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};N.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Xo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Xo(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=N.T,o={};N.T=o;try{var s=n(i,r),c=N.S;c!==null&&c(o,s),Zo(e,t,s)}catch(n){$o(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),N.T=a}}else try{a=n(i,r),Zo(e,t,a)}catch(n){$o(e,t,n)}}function Zo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Qo(e,t,n)},function(n){return $o(e,t,n)}):Qo(e,t,n)}function Qo(e,t,n){t.status=`fulfilled`,t.value=n,es(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Xo(e,n)))}function $o(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,es(t),t=t.next;while(t!==r)}e.action=null}function es(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function ts(e,t){return t}function ns(e,t){if(Ii){var n=Hl.formState;if(n!==null){a:{var r=mo;if(Ii){if(Fi){b:{for(var i=Fi,a=Ri;i.nodeType!==8;){if(!a){i=null;break b}if(i=_f(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Fi=_f(i.nextSibling),r=i.data===`F!`;break a}}Bi(r)}r=!1}r&&(t=n[0])}}return n=Mo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ts,lastRenderedState:t},n.queue=r,n=Ns.bind(null,mo,r),r.dispatch=n,r=qo(!1),a=Fs.bind(null,mo,!1,r.queue),r=Mo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Yo.bind(null,mo,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function rs(e){return is(No(),ho,e)}function is(e,t,n){if(t=zo(e,t,ts)[0],e=Ro(Lo)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Po(t)}catch(e){throw e===wa?Ea:e}else r=t;t=No();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(mo.flags|=2048,os(9,{destroy:void 0},H.bind(null,i,n),null)),[r,a,e]}function H(e,t){e.action=t}function as(e){var t=No(),n=ho;if(n!==null)return is(t,n,e);No(),t=t.memoizedState,n=No();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function os(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=mo.updateQueue,t===null&&(t=V(),mo.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function ss(){return No().memoizedState}function cs(e,t,n,r){var i=Mo();mo.flags|=e,i.memoizedState=os(1|t,{destroy:void 0},n,r===void 0?null:r)}function ls(e,t,n,r){var i=No();r=r===void 0?null:r;var a=i.memoizedState.inst;ho!==null&&r!==null&&B(r,ho.memoizedState.deps)?i.memoizedState=os(t,a,n,r):(mo.flags|=e,i.memoizedState=os(1|t,a,n,r))}function us(e,t){cs(8390656,8,e,t)}function ds(e,t){ls(2048,8,e,t)}function fs(e){mo.flags|=4;var t=mo.updateQueue;if(t===null)t=V(),mo.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function ps(e){var t=No().memoizedState;return fs({ref:t,nextImpl:e}),function(){if(Vl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function ms(e,t){return ls(4,2,e,t)}function hs(e,t){return ls(4,4,e,t)}function gs(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function _s(e,t,n){n=n==null?null:n.concat([e]),ls(4,4,gs.bind(null,t,e),n)}function vs(){}function ys(e,t){var n=No();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&B(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function bs(e,t){var n=No();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&B(t,r[1]))return r[0];if(r=e(),yo){ze(!0);try{e()}finally{ze(!1)}}return n.memoizedState=[r,t],r}function xs(e,t,n){return n===void 0||po&1073741824&&!(Wl&261930)?e.memoizedState=t:(e.memoizedState=n,e=xu(),mo.lanes|=e,Ql|=e,n)}function Ss(e,t,n,r){return Cr(n,t)?n:z.current===null?!(po&42)||po&1073741824&&!(Wl&261930)?(ic=!0,e.memoizedState=n):(e=xu(),mo.lanes|=e,Ql|=e,t):(e=xs(e,n,r),Cr(e,t)||(ic=!0),e)}function Cs(e,t,n,r,i){var a=P.p;P.p=a!==0&&8>a?a:8;var o=N.T,s={};N.T=s,Fs(e,!1,t,n);try{var c=i(),l=N.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Ps(e,t,va(c,r),bu(e)):Ps(e,t,r,bu(e))}catch(n){Ps(e,t,{then:function(){},status:`rejected`,reason:n},bu())}finally{P.p=a,o!==null&&s.types!==null&&(o.types=s.types),N.T=o}}function ws(){}function Ts(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Es(e).queue;Cs(e,a,t,re,n===null?ws:function(){return Ds(e),n(r)})}function Es(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:re,baseState:re,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:re},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ds(e){var t=Es(e);t.next===null&&(t=e.alternate.memoizedState),Ps(e,t.next.queue,{},bu())}function Os(){return ra(sp)}function ks(){return No().memoizedState}function As(){return No().memoizedState}function js(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=bu();e=Wa(n);var r=Ga(t,e,n);r!==null&&(Su(r,t,n),Ka(r,t,n)),t={cache:ua()},e.payload=t;return}t=t.return}}function Ms(e,t,n){var r=bu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Is(e)?Ls(t,n):(n=ri(e,t,n,r),n!==null&&(Su(n,e,r),Rs(n,t,r)))}function Ns(e,t,n){Ps(e,t,n,bu())}function Ps(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Is(e))Ls(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Cr(s,o))return ni(e,t,i,0),Hl===null&&ti(),!1}catch{}if(n=ri(e,t,i,r),n!==null)return Su(n,e,r),Rs(n,t,r),!0}return!1}function Fs(e,t,n,r){if(r={lane:2,revertLane:vd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Is(e)){if(t)throw Error(i(479))}else t=ri(e,n,r,2),t!==null&&Su(t,e,2)}function Is(e){var t=e.alternate;return e===mo||t!==null&&t===mo}function Ls(e,t){vo=_o=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Rs(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,tt(e,n)}}var zs={readContext:ra,use:Fo,useCallback:wo,useContext:wo,useEffect:wo,useImperativeHandle:wo,useLayoutEffect:wo,useInsertionEffect:wo,useMemo:wo,useReducer:wo,useRef:wo,useState:wo,useDebugValue:wo,useDeferredValue:wo,useTransition:wo,useSyncExternalStore:wo,useId:wo,useHostTransitionStatus:wo,useFormState:wo,useActionState:wo,useOptimistic:wo,useMemoCache:wo,useCacheRefresh:wo};zs.useEffectEvent=wo;var Bs={readContext:ra,use:Fo,useCallback:function(e,t){return Mo().memoizedState=[e,t===void 0?null:t],e},useContext:ra,useEffect:us,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),cs(4194308,4,gs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return cs(4194308,4,e,t)},useInsertionEffect:function(e,t){cs(4,2,e,t)},useMemo:function(e,t){var n=Mo();t=t===void 0?null:t;var r=e();if(yo){ze(!0);try{e()}finally{ze(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Mo();if(n!==void 0){var i=n(t);if(yo){ze(!0);try{n(t)}finally{ze(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Ms.bind(null,mo,e),[r.memoizedState,e]},useRef:function(e){var t=Mo();return e={current:e},t.memoizedState=e},useState:function(e){e=qo(e);var t=e.queue,n=Ns.bind(null,mo,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:vs,useDeferredValue:function(e,t){return xs(Mo(),e,t)},useTransition:function(){var e=qo(!1);return e=Cs.bind(null,mo,e.queue,!0,!1),Mo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=mo,a=Mo();if(Ii){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Hl===null)throw Error(i(349));Wl&127||Ho(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,us(Wo.bind(null,r,o,e),[e]),r.flags|=2048,os(9,{destroy:void 0},Uo.bind(null,r,o,n,t),null),n},useId:function(){var e=Mo(),t=Hl.identifierPrefix;if(Ii){var n=Oi,r=Di;n=(r&~(1<<32-I(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=bo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=Co++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Os,useFormState:ns,useActionState:ns,useOptimistic:function(e){var t=Mo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Fs.bind(null,mo,!0,n),n.dispatch=t,[e,t]},useMemoCache:Io,useCacheRefresh:function(){return Mo().memoizedState=js.bind(null,mo)},useEffectEvent:function(e){var t=Mo(),n={impl:e};return t.memoizedState=n,function(){if(Vl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Vs={readContext:ra,use:Fo,useCallback:ys,useContext:ra,useEffect:ds,useImperativeHandle:_s,useInsertionEffect:ms,useLayoutEffect:hs,useMemo:bs,useReducer:Ro,useRef:ss,useState:function(){return Ro(Lo)},useDebugValue:vs,useDeferredValue:function(e,t){return Ss(No(),ho.memoizedState,e,t)},useTransition:function(){var e=Ro(Lo)[0],t=No().memoizedState;return[typeof e==`boolean`?e:Po(e),t]},useSyncExternalStore:Vo,useId:ks,useHostTransitionStatus:Os,useFormState:rs,useActionState:rs,useOptimistic:function(e,t){return Jo(No(),ho,e,t)},useMemoCache:Io,useCacheRefresh:As};Vs.useEffectEvent=ps;var Hs={readContext:ra,use:Fo,useCallback:ys,useContext:ra,useEffect:ds,useImperativeHandle:_s,useInsertionEffect:ms,useLayoutEffect:hs,useMemo:bs,useReducer:Bo,useRef:ss,useState:function(){return Bo(Lo)},useDebugValue:vs,useDeferredValue:function(e,t){var n=No();return ho===null?xs(n,e,t):Ss(n,ho.memoizedState,e,t)},useTransition:function(){var e=Bo(Lo)[0],t=No().memoizedState;return[typeof e==`boolean`?e:Po(e),t]},useSyncExternalStore:Vo,useId:ks,useHostTransitionStatus:Os,useFormState:as,useActionState:as,useOptimistic:function(e,t){var n=No();return ho===null?(n.baseState=e,[e,n.queue.dispatch]):Jo(n,ho,e,t)},useMemoCache:Io,useCacheRefresh:As};Hs.useEffectEvent=ps;function Us(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:m({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ws={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=bu(),i=Wa(r);i.payload=t,n!=null&&(i.callback=n),t=Ga(e,i,r),t!==null&&(Su(t,e,r),Ka(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=bu(),i=Wa(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Ga(e,i,r),t!==null&&(Su(t,e,r),Ka(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=bu(),r=Wa(n);r.tag=2,t!=null&&(r.callback=t),t=Ga(e,r,n),t!==null&&(Su(t,e,n),Ka(t,e,n))}};function Gs(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!wr(n,r)||!wr(i,a):!0}function Ks(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Ws.enqueueReplaceState(t,t.state,null)}function qs(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=m({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Js(e){Zr(e)}function Ys(e){console.error(e)}function Xs(e){Zr(e)}function Zs(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Qs(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function $s(e,t,n){return n=Wa(n),n.tag=3,n.payload={element:null},n.callback=function(){Zs(e,t)},n}function ec(e){return e=Wa(e),e.tag=3,e}function tc(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Qs(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Qs(t,n,r),typeof i!=`function`&&(uu===null?uu=new Set([this]):uu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function nc(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&ea(t,n,a,!0),n=ro.current,n!==null){switch(n.tag){case 31:case 13:return io===null?Pu():n.alternate===null&&Zl===0&&(Zl=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===Da?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Qu(e,r,a)),!1;case 22:return n.flags|=65536,r===Da?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Qu(e,r,a)),!1}throw Error(i(435,n.tag))}return Qu(e,r,a),Pu(),!1}if(Ii)return t=ro.current,t===null?(r!==zi&&(t=Error(i(423),{cause:r}),Ki(yi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=yi(r,n),a=$s(e.stateNode,r,a),qa(e,a),Zl!==4&&(Zl=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==zi&&(e=Error(i(422),{cause:r}),Ki(yi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=yi(o,n),ru===null?ru=[o]:ru.push(o),Zl!==4&&(Zl=2),t===null)return!0;r=yi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=$s(n.stateNode,r,e),qa(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(uu===null||!uu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=ec(a),tc(a,e,n,r),qa(n,a),!1}n=n.return}while(n!==null);return!1}var rc=Error(i(461)),ic=!1;function ac(e,t,n,r){t.child=e===null?Ba(t,null,n,r):za(t,e.child,n,r)}function oc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return na(t),r=To(e,t,n,o,a,i),s=ko(),e!==null&&!ic?(Ao(e,t,i),kc(e,t,i)):(Ii&&s&&ji(t),t.flags|=1,ac(e,t,r,i),t.child)}function sc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ui(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,cc(e,t,a,r,i)):(e=pi(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Ac(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?wr:n,n(o,r)&&e.ref===t.ref)return kc(e,t,i)}return t.flags|=1,e=di(a,r),e.ref=t.ref,e.return=t,t.child=e}function cc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(wr(a,r)&&e.ref===t.ref)if(ic=!1,t.pendingProps=r=a,Ac(e,i))e.flags&131072&&(ic=!0);else return t.lanes=e.lanes,kc(e,t,i)}return hc(e,t,n,r,i)}function lc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return U(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Sa(t,a===null?null:a.cachePool),a===null?to():eo(t,a),so(t);else return r=t.lanes=536870912,U(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Sa(t,null),to(),co(t)):(Sa(t,a.cachePool),eo(t,a),co(t),t.memoizedState=null);return ac(e,t,i,n),t.child}function uc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function U(e,t,n,r,i){var a=xa();return a=a===null?null:{parent:la._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Sa(t,null),to(),so(t),e!==null&&ea(e,t,r,!0),t.childLanes=i,null}function dc(e,t){return t=wc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function fc(e,t,n){return za(t,e.child,null,n),e=dc(t,t.pendingProps),e.flags|=2,lo(t),t.memoizedState=null,e}function pc(e,t,n){var r=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(Ii){if(r.mode===`hidden`)return e=dc(t,r),t.lanes=536870912,uc(null,e);if(oo(t),(e=Fi)?(e=pf(e,Ri),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Ei===null?null:{id:Di,overflow:Oi},retryLane:536870912,hydrationErrors:null},n=gi(e),n.return=t,t.child=n,Pi=t,Fi=null)):e=null,e===null)throw Bi(t);return t.lanes=536870912,null}return dc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(oo(t),a)if(t.flags&256)t.flags&=-257,t=fc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558));else if(ic||ea(e,t,n,!1),a=(n&e.childLanes)!==0,ic||a){if(r=Hl,r!==null&&(s=nt(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,ii(e,s),Su(r,e,s),rc;Pu(),t=fc(e,t,n)}else e=o.treeContext,Fi=_f(s.nextSibling),Pi=t,Ii=!0,Li=null,Ri=!1,e!==null&&Ni(t,e),t=dc(t,r),t.flags|=4096;return t}return e=di(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function mc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function hc(e,t,n,r,i){return na(t),n=To(e,t,n,r,void 0,i),r=ko(),e!==null&&!ic?(Ao(e,t,i),kc(e,t,i)):(Ii&&r&&ji(t),t.flags|=1,ac(e,t,n,i),t.child)}function gc(e,t,n,r,i,a){return na(t),t.updateQueue=null,n=Do(t,r,n,i),Eo(e),r=ko(),e!==null&&!ic?(Ao(e,t,a),kc(e,t,a)):(Ii&&r&&ji(t),t.flags|=1,ac(e,t,n,a),t.child)}function _c(e,t,n,r,i){if(na(t),t.stateNode===null){var a=si,o=n.contextType;typeof o==`object`&&o&&(a=ra(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Ws,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Ha(t),o=n.contextType,a.context=typeof o==`object`&&o?ra(o):si,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Us(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Ws.enqueueReplaceState(a,a.state,null),Xa(t,r,a,i),Ya(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=qs(n,s);a.props=c;var l=a.context,u=n.contextType;o=si,typeof u==`object`&&u&&(o=ra(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Ks(t,a,r,o),Va=!1;var f=t.memoizedState;a.state=f,Xa(t,r,a,i),Ya(),l=t.memoizedState,s||f!==l||Va?(typeof d==`function`&&(Us(t,n,d,r),l=t.memoizedState),(c=Va||Gs(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Ua(e,t),o=t.memoizedProps,u=qs(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=si,typeof l==`object`&&l&&(c=ra(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Ks(t,a,r,c),Va=!1,f=t.memoizedState,a.state=f,Xa(t,r,a,i),Ya();var p=t.memoizedState;o!==d||f!==p||Va||e!==null&&e.dependencies!==null&&ta(e.dependencies)?(typeof s==`function`&&(Us(t,n,s,r),p=t.memoizedState),(u=Va||Gs(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&ta(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,mc(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=za(t,e.child,null,i),t.child=za(t,null,n,i)):ac(e,t,n,i),t.memoizedState=a.state,e=t.child):e=kc(e,t,i),e}function vc(e,t,n,r){return Wi(),t.flags|=256,ac(e,t,n,r),t.child}var yc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function bc(e){return{baseLanes:e,cachePool:Ca()}}function xc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=tu),e}function Sc(e,t,n){var r=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(uo.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(Ii){if(a?ao(t):co(t),(e=Fi)?(e=pf(e,Ri),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Ei===null?null:{id:Di,overflow:Oi},retryLane:536870912,hydrationErrors:null},n=gi(e),n.return=t,t.child=n,Pi=t,Fi=null)):e=null,e===null)throw Bi(t);return hf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(co(t),a=t.mode,c=wc({mode:`hidden`,children:c},a),r=mi(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=bc(n),r.childLanes=xc(e,s,n),t.memoizedState=yc,uc(null,r)):(ao(t),Cc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(ao(t),t.flags&=-257,t=Tc(e,t,n)):t.memoizedState===null?(co(t),c=r.fallback,a=t.mode,r=wc({mode:`visible`,children:r.children},a),c=mi(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,za(t,e.child,null,n),r=t.child,r.memoizedState=bc(n),r.childLanes=xc(e,s,n),t.memoizedState=yc,t=uc(null,r)):(co(t),t.child=e.child,t.flags|=128,t=null);else if(ao(t),hf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Ki({value:r,source:null,stack:null}),t=Tc(e,t,n)}else if(ic||ea(e,t,n,!1),s=(n&e.childLanes)!==0,ic||s){if(s=Hl,s!==null&&(r=nt(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,ii(e,r),Su(s,e,r),rc;mf(c)||Pu(),t=Tc(e,t,n)}else mf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Fi=_f(c.nextSibling),Pi=t,Ii=!0,Li=null,Ri=!1,e!==null&&Ni(t,e),t=Cc(t,r.children),t.flags|=4096);return t}return a?(co(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=di(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=mi(c,a,n,null),c.flags|=2):c=di(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,uc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=bc(n):(a=c.cachePool,a===null?a=Ca():(l=la._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=xc(e,s,n),t.memoizedState=yc,uc(e.child,r)):(ao(t),n=e.child,e=n.sibling,n=di(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function Cc(e,t){return t=wc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function wc(e,t){return e=li(22,e,null,t),e.lanes=0,e}function Tc(e,t,n){return za(t,e.child,null,n),e=Cc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Ec(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Qi(e.return,t,n)}function Dc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function Oc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=uo.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,se(uo,o),ac(e,t,r,n),r=Ii?Ci:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Ec(e,n,t);else if(e.tag===19)Ec(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&fo(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Dc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&fo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Dc(t,!0,n,null,a,r);break;case`together`:Dc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function kc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Ql|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(ea(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=di(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=di(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Ac(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&ta(e))):!0}function jc(e,t,n){switch(t.tag){case 3:fe(t,t.stateNode.containerInfo),Xi(t,la,e.memoizedState.cache),Wi();break;case 27:case 5:me(t);break;case 4:fe(t,t.stateNode.containerInfo);break;case 10:Xi(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,oo(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(ao(t),e=kc(e,t,n),e===null?null:e.sibling):Sc(e,t,n):(ao(t),t.flags|=128,null);ao(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(ea(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return Oc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),se(uo,uo.current),r)break;return null;case 22:return t.lanes=0,lc(e,t,n,t.pendingProps);case 24:Xi(t,la,e.memoizedState.cache)}return kc(e,t,n)}function Mc(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)ic=!0;else{if(!Ac(e,n)&&!(t.flags&128))return ic=!1,jc(e,t,n);ic=!!(e.flags&131072)}else ic=!1,Ii&&t.flags&1048576&&Ai(t,Ci,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=Aa(t.elementType),t.type=e,typeof e==`function`)ui(e)?(r=qs(e,r),t.tag=1,t=_c(null,t,e,r,n)):(t.tag=0,t=hc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===w){t.tag=11,t=oc(null,t,e,r,n);break a}else if(a===D){t.tag=14,t=sc(null,t,e,r,n);break a}}throw t=M(e)||e,Error(i(306,t,``))}}return t;case 0:return hc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=qs(r,t.pendingProps),_c(e,t,r,a,n);case 3:a:{if(fe(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Ua(e,t),Xa(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Xi(t,la,r),r!==o.cache&&$i(t,[la],n,!0),Ya(),r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=vc(e,t,r,n);break a}else if(r!==a){a=yi(Error(i(424)),t),Ki(a),t=vc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Fi=_f(e.firstChild),Pi=t,Ii=!0,Li=null,Ri=!0,n=Ba(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Wi(),r===a){t=kc(e,t,n);break a}ac(e,t,r,n)}t=t.child}return t;case 26:return mc(e,t),e===null?(n=Rf(t.type,null,t.pendingProps,null))?t.memoizedState=n:Ii||(n=t.type,e=t.pendingProps,r=Yd(ue.current).createElement(n),r[ct]=t,r[lt]=e,Ud(r,n,e),xt(r),t.stateNode=r):t.memoizedState=Rf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return me(t),e===null&&Ii&&(r=t.stateNode=xf(t.type,t.pendingProps,ue.current),Pi=t,Ri=!0,a=Fi,sf(t.type)?(vf=a,Fi=_f(r.firstChild)):Fi=a),ac(e,t,t.pendingProps.children,n),mc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Ii&&((a=r=Fi)&&(r=df(r,t.type,t.pendingProps,Ri),r===null?a=!1:(t.stateNode=r,Pi=t,Fi=_f(r.firstChild),Ri=!1,a=!0)),a||Bi(t)),me(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,Qd(a,o)?r=null:s!==null&&Qd(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=To(e,t,Oo,null,null,n),sp._currentValue=a),mc(e,t),ac(e,t,r,n),t.child;case 6:return e===null&&Ii&&((e=n=Fi)&&(n=ff(n,t.pendingProps,Ri),n===null?e=!1:(t.stateNode=n,Pi=t,Fi=null,e=!0)),e||Bi(t)),null;case 13:return Sc(e,t,n);case 4:return fe(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=za(t,null,r,n):ac(e,t,r,n),t.child;case 11:return oc(e,t,t.type,t.pendingProps,n);case 7:return ac(e,t,t.pendingProps,n),t.child;case 8:return ac(e,t,t.pendingProps.children,n),t.child;case 12:return ac(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Xi(t,t.type,r.value),ac(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,na(t),a=ra(a),r=r(a),t.flags|=1,ac(e,t,r,n),t.child;case 14:return sc(e,t,t.type,t.pendingProps,n);case 15:return cc(e,t,t.type,t.pendingProps,n);case 19:return Oc(e,t,n);case 31:return pc(e,t,n);case 22:return lc(e,t,n,t.pendingProps);case 24:return na(t),r=ra(la),e===null?(a=xa(),a===null&&(a=Hl,o=ua(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Ha(t),Xi(t,la,a)):((e.lanes&n)!==0&&(Ua(e,t),Xa(t,null,null,n),Ya()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Xi(t,la,r),r!==a.cache&&$i(t,[la],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Xi(t,la,r))),ac(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Nc(e){e.flags|=4}function Pc(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(ju())e.flags|=8192;else throw ja=Da,Ta}else e.flags&=-16777217}function Fc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!$f(t))if(ju())e.flags|=8192;else throw ja=Da,Ta}function Ic(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Xe(),e.lanes|=t,nu|=t)}function Lc(e,t){if(!Ii)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Rc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function zc(e,t,n){var r=t.pendingProps;switch(Mi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Rc(t),null;case 1:return Rc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Zi(la),pe(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Ui(t)?Nc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Gi())),Rc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Nc(t),o===null?(Rc(t),Pc(t,a,null,r,n)):(Rc(t),Fc(t,o))):o?o===e.memoizedState?(Rc(t),t.flags&=-16777217):(Nc(t),Rc(t),Fc(t,o)):(e=e.memoizedProps,e!==r&&Nc(t),Rc(t),Pc(t,a,e,r,n)),null;case 27:if(he(t),n=ue.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Nc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Rc(t),null}e=ce.current,Ui(t)?Vi(t,e):(e=xf(a,r,n),t.stateNode=e,Nc(t))}return Rc(t),null;case 5:if(he(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Nc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Rc(t),null}if(o=ce.current,Ui(t))Vi(t,o);else{var s=Yd(ue.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[ct]=t,o[lt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Ud(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Nc(t)}}return Rc(t),Pc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Nc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=ue.current,Ui(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Pi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[ct]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Bd(e.nodeValue,n)),e||Bi(t,!0)}else e=Yd(e).createTextNode(r),e[ct]=t,t.stateNode=e}return Rc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Ui(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[ct]=t}else Wi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Rc(t),e=!1}else n=Gi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(lo(t),t):(lo(t),null);if(t.flags&128)throw Error(i(558))}return Rc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Ui(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[ct]=t}else Wi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Rc(t),a=!1}else a=Gi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(lo(t),t):(lo(t),null)}return lo(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Ic(t,t.updateQueue),Rc(t),null);case 4:return pe(),e===null&&Ad(t.stateNode.containerInfo),Rc(t),null;case 10:return Zi(t.type),Rc(t),null;case 19:if(oe(uo),r=t.memoizedState,r===null)return Rc(t),null;if(a=(t.flags&128)!=0,o=r.rendering,o===null)if(a)Lc(r,!1);else{if(Zl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=fo(e),o!==null){for(t.flags|=128,Lc(r,!1),e=o.updateQueue,t.updateQueue=e,Ic(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)fi(n,e),n=n.sibling;return se(uo,uo.current&1|2),Ii&&ki(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Oe()>cu&&(t.flags|=128,a=!0,Lc(r,!1),t.lanes=4194304)}else{if(!a)if(e=fo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Ic(t,e),Lc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!Ii)return Rc(t),null}else 2*Oe()-r.renderingStartTime>cu&&n!==536870912&&(t.flags|=128,a=!0,Lc(r,!1),t.lanes=4194304);r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Rc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Oe(),e.sibling=null,n=uo.current,se(uo,a?n&1|2:n&1),Ii&&ki(t,r.treeForkCount),e);case 22:case 23:return lo(t),no(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Rc(t),t.subtreeFlags&6&&(t.flags|=8192)):Rc(t),n=t.updateQueue,n!==null&&Ic(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&oe(ba),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Zi(la),Rc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Bc(e,t){switch(Mi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Zi(la),pe(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return he(t),null;case 31:if(t.memoizedState!==null){if(lo(t),t.alternate===null)throw Error(i(340));Wi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(lo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Wi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return oe(uo),null;case 4:return pe(),null;case 10:return Zi(t.type),null;case 22:case 23:return lo(t),no(),e!==null&&oe(ba),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Zi(la),null;case 25:return null;default:return null}}function Vc(e,t){switch(Mi(t),t.tag){case 3:Zi(la),pe();break;case 26:case 27:case 5:he(t);break;case 4:pe();break;case 31:t.memoizedState!==null&&lo(t);break;case 13:lo(t);break;case 19:oe(uo);break;case 10:Zi(t.type);break;case 22:case 23:lo(t),no(),e!==null&&oe(ba);break;case 24:Zi(la)}}function Hc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Zu(t,t.return,e)}}function Uc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Zu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Zu(t,t.return,e)}}function Wc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Qa(t,n)}catch(t){Zu(e,e.return,t)}}}function Gc(e,t,n){n.props=qs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Zu(e,t,n)}}function Kc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Zu(e,t,n)}}function qc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Zu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Zu(e,t,n)}else n.current=null}function Jc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Zu(e,e.return,t)}}function Yc(e,t,n){try{var r=e.stateNode;Wd(r,e.type,n,t),r[lt]=t}catch(t){Zu(e,e.return,t)}}function Xc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&sf(e.type)||e.tag===4}function Zc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Xc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&sf(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Qc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=tn));else if(r!==4&&(r===27&&sf(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Qc(e,t,n),e=e.sibling;e!==null;)Qc(e,t,n),e=e.sibling}function $c(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&sf(e.type)&&(n=e.stateNode),e=e.child,e!==null))for($c(e,t,n),e=e.sibling;e!==null;)$c(e,t,n),e=e.sibling}function el(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Ud(t,r,n),t[ct]=e,t[lt]=n}catch(t){Zu(e,e.return,t)}}var tl=!1,nl=!1,rl=!1,il=typeof WeakSet==`function`?WeakSet:Set,al=null;function ol(e,t){if(e=e.containerInfo,qd=gp,e=Or(e),kr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Jd={focusedElem:e,selectionRange:n},gp=!1,al=t;al!==null;)if(t=al,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,al=e;else for(;al!==null;){switch(t=al,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=qs(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Zu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)uf(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:uf(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,al=e;break}al=t.return}}function sl(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Sl(e,n),r&4&&Hc(5,n);break;case 1:if(Sl(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Zu(n,n.return,e)}else{var i=qs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Zu(n,n.return,e)}}r&64&&Wc(n),r&512&&Kc(n,n.return);break;case 3:if(Sl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Qa(e,t)}catch(e){Zu(n,n.return,e)}}break;case 27:t===null&&r&4&&el(n);case 26:case 5:Sl(e,n),t===null&&r&4&&Jc(n),r&512&&Kc(n,n.return);break;case 12:Sl(e,n);break;case 31:Sl(e,n),r&4&&pl(e,n);break;case 13:Sl(e,n),r&4&&ml(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=td.bind(null,n),gf(e,n))));break;case 22:if(r=n.memoizedState!==null||tl,!r){t=t!==null&&t.memoizedState!==null||nl,i=tl;var a=nl;tl=r,(nl=t)&&!a?wl(e,n,(n.subtreeFlags&8772)!=0):Sl(e,n),tl=i,nl=a}break;case 30:break;default:Sl(e,n)}}function cl(e){var t=e.alternate;t!==null&&(e.alternate=null,cl(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&>(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var ll=null,ul=!1;function dl(e,t,n){for(n=n.child;n!==null;)fl(e,t,n),n=n.sibling}function fl(e,t,n){if(Re&&typeof Re.onCommitFiberUnmount==`function`)try{Re.onCommitFiberUnmount(Le,n)}catch{}switch(n.tag){case 26:nl||qc(n,t),dl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:nl||qc(n,t);var r=ll,i=ul;sf(n.type)&&(ll=n.stateNode,ul=!1),dl(e,t,n),Sf(n.stateNode),ll=r,ul=i;break;case 5:nl||qc(n,t);case 6:if(r=ll,i=ul,ll=null,dl(e,t,n),ll=r,ul=i,ll!==null)if(ul)try{(ll.nodeType===9?ll.body:ll.nodeName===`HTML`?ll.ownerDocument.body:ll).removeChild(n.stateNode)}catch(e){Zu(n,t,e)}else try{ll.removeChild(n.stateNode)}catch(e){Zu(n,t,e)}break;case 18:ll!==null&&(ul?(e=ll,cf(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Hp(e)):cf(ll,n.stateNode));break;case 4:r=ll,i=ul,ll=n.stateNode.containerInfo,ul=!0,dl(e,t,n),ll=r,ul=i;break;case 0:case 11:case 14:case 15:Uc(2,n,t),nl||Uc(4,n,t),dl(e,t,n);break;case 1:nl||(qc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Gc(n,t,r)),dl(e,t,n);break;case 21:dl(e,t,n);break;case 22:nl=(r=nl)||n.memoizedState!==null,dl(e,t,n),nl=r;break;default:dl(e,t,n)}}function pl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Hp(e)}catch(e){Zu(t,t.return,e)}}}function ml(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Hp(e)}catch(e){Zu(t,t.return,e)}}function hl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new il),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new il),t;default:throw Error(i(435,e.tag))}}function gl(e,t){var n=hl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=nd.bind(null,e,t);t.then(r,r)}})}function _l(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(sf(c.type)){ll=c.stateNode,ul=!1;break a}break;case 5:ll=c.stateNode,ul=!1;break a;case 3:case 4:ll=c.stateNode.containerInfo,ul=!0;break a}c=c.return}if(ll===null)throw Error(i(160));fl(o,s,a),ll=null,ul=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)yl(t,e),t=t.sibling}var vl=null;function yl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:_l(t,e),bl(e),r&4&&(Uc(3,e,e.return),Hc(3,e),Uc(5,e,e.return));break;case 1:_l(t,e),bl(e),r&512&&(nl||n===null||qc(n,n.return)),r&64&&tl&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=vl;if(_l(t,e),bl(e),r&512&&(nl||n===null||qc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[ht]||o[ct]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Ud(o,r,n),o[ct]=e,xt(o),r=o;break a;case`link`:var s=Xf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Ud(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Xf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Ud(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[ct]=e,xt(o),r=o}e.stateNode=r}else Zf(a,e.type,e.stateNode);else e.stateNode=Gf(a,r,e.memoizedProps);else o===r?r===null&&e.stateNode!==null&&Yc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Zf(a,e.type,e.stateNode):Gf(a,r,e.memoizedProps))}break;case 27:_l(t,e),bl(e),r&512&&(nl||n===null||qc(n,n.return)),n!==null&&r&4&&Yc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(_l(t,e),bl(e),r&512&&(nl||n===null||qc(n,n.return)),e.flags&32){a=e.stateNode;try{qt(a,``)}catch(t){Zu(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,Yc(e,a,n===null?a:n.memoizedProps)),r&1024&&(rl=!0);break;case 6:if(_l(t,e),bl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Zu(e,e.return,t)}}break;case 3:if(Yf=null,a=vl,vl=Tf(t.containerInfo),_l(t,e),vl=a,bl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Hp(t.containerInfo)}catch(t){Zu(e,e.return,t)}rl&&(rl=!1,xl(e));break;case 4:r=vl,vl=Tf(e.stateNode.containerInfo),_l(t,e),bl(e),vl=r;break;case 12:_l(t,e),bl(e);break;case 31:_l(t,e),bl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,gl(e,r)));break;case 13:_l(t,e),bl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(ou=Oe()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,gl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=tl,d=nl;if(tl=u||a,nl=d||l,_l(t,e),nl=d,tl=u,bl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||tl||nl||Cl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Zu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Zu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?lf(m,!0):lf(l.stateNode,!1)}catch(e){Zu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,gl(e,n))));break;case 19:_l(t,e),bl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,gl(e,r)));break;case 30:break;case 21:break;default:_l(t,e),bl(e)}}function bl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Xc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;$c(e,Zc(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(qt(o,``),n.flags&=-33),$c(e,Zc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Qc(e,Zc(e),s);break;default:throw Error(i(161))}}catch(t){Zu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function xl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;xl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Sl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)sl(e,t.alternate,t),t=t.sibling}function Cl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Uc(4,t,t.return),Cl(t);break;case 1:qc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Gc(t,t.return,n),Cl(t);break;case 27:Sf(t.stateNode);case 26:case 5:qc(t,t.return),Cl(t);break;case 22:t.memoizedState===null&&Cl(t);break;case 30:Cl(t);break;default:Cl(t)}e=e.sibling}}function wl(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:wl(i,a,n),Hc(4,a);break;case 1:if(wl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Zu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Za(c[i],s)}catch(e){Zu(r,r.return,e)}}n&&o&64&&Wc(a),Kc(a,a.return);break;case 27:el(a);case 26:case 5:wl(i,a,n),n&&r===null&&o&4&&Jc(a),Kc(a,a.return);break;case 12:wl(i,a,n);break;case 31:wl(i,a,n),n&&o&4&&pl(i,a);break;case 13:wl(i,a,n),n&&o&4&&ml(i,a);break;case 22:a.memoizedState===null&&wl(i,a,n),Kc(a,a.return);break;case 30:break;default:wl(i,a,n)}t=t.sibling}}function Tl(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&da(n))}function El(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&da(e))}function Dl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Ol(e,t,n,r),t=t.sibling}function Ol(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:Dl(e,t,n,r),i&2048&&Hc(9,t);break;case 1:Dl(e,t,n,r);break;case 3:Dl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&da(e)));break;case 12:if(i&2048){Dl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Zu(t,t.return,e)}}else Dl(e,t,n,r);break;case 31:Dl(e,t,n,r);break;case 13:Dl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?Dl(e,t,n,r):(a._visibility|=2,kl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?Dl(e,t,n,r):Al(e,t),i&2048&&Tl(o,t);break;case 24:Dl(e,t,n,r),i&2048&&El(t.alternate,t);break;default:Dl(e,t,n,r)}}function kl(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:kl(a,o,s,c,i),Hc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,kl(a,o,s,c,i)):u._visibility&2?kl(a,o,s,c,i):Al(a,o),i&&l&2048&&Tl(o.alternate,o);break;case 24:kl(a,o,s,c,i),i&&l&2048&&El(o.alternate,o);break;default:kl(a,o,s,c,i)}t=t.sibling}}function Al(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Al(n,r),i&2048&&Tl(r.alternate,r);break;case 24:Al(n,r),i&2048&&El(r.alternate,r);break;default:Al(n,r)}t=t.sibling}}var jl=8192;function Ml(e,t,n){if(e.subtreeFlags&jl)for(e=e.child;e!==null;)Nl(e,t,n),e=e.sibling}function Nl(e,t,n){switch(e.tag){case 26:Ml(e,t,n),e.flags&jl&&e.memoizedState!==null&&ep(n,vl,e.memoizedState,e.memoizedProps);break;case 5:Ml(e,t,n);break;case 3:case 4:var r=vl;vl=Tf(e.stateNode.containerInfo),Ml(e,t,n),vl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=jl,jl=16777216,Ml(e,t,n),jl=r):Ml(e,t,n));break;default:Ml(e,t,n)}}function Pl(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Fl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];al=r,Rl(r,e)}Pl(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Il(e),e=e.sibling}function Il(e){switch(e.tag){case 0:case 11:case 15:Fl(e),e.flags&2048&&Uc(9,e,e.return);break;case 3:Fl(e);break;case 12:Fl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Ll(e)):Fl(e);break;default:Fl(e)}}function Ll(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];al=r,Rl(r,e)}Pl(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Uc(8,t,t.return),Ll(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Ll(t));break;default:Ll(t)}e=e.sibling}}function Rl(e,t){for(;al!==null;){var n=al;switch(n.tag){case 0:case 11:case 15:Uc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:da(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,al=r;else a:for(n=e;al!==null;){r=al;var i=r.sibling,a=r.return;if(cl(r),r===n){al=null;break a}if(i!==null){i.return=a,al=i;break a}al=a}}}var zl={getCacheForType:function(e){var t=ra(la),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return ra(la).controller.signal}},Bl=typeof WeakMap==`function`?WeakMap:Map,Vl=0,Hl=null,Ul=null,Wl=0,Gl=0,Kl=null,ql=!1,Jl=!1,Yl=!1,Xl=0,Zl=0,Ql=0,$l=0,eu=0,tu=0,nu=0,ru=null,iu=null,au=!1,ou=0,su=0,cu=1/0,lu=null,uu=null,du=0,fu=null,pu=null,mu=0,hu=0,gu=null,_u=null,vu=0,yu=null;function bu(){return Vl&2&&Wl!==0?Wl&-Wl:N.T===null?at():vd()}function xu(){if(tu===0)if(!(Wl&536870912)||Ii){var e=We;We<<=1,!(We&3932160)&&(We=262144),tu=e}else tu=536870912;return e=ro.current,e!==null&&(e.flags|=32),tu}function Su(e,t,n){(e===Hl&&(Gl===2||Gl===9)||e.cancelPendingCommit!==null)&&(ku(e,0),Eu(e,Wl,tu,!1)),Qe(e,n),(!(Vl&2)||e!==Hl)&&(e===Hl&&(!(Vl&2)&&($l|=n),Zl===4&&Eu(e,Wl,tu,!1)),ud(e))}function Cu(e,t,n){if(Vl&6)throw Error(i(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||Je(e,t),a=r?Lu(e,t):Fu(e,t,!0),o=r;do{if(a===0){Jl&&!r&&Eu(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!Tu(n)){a=Fu(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=ru;var l=c.current.memoizedState.isDehydrated;if(l&&(ku(c,s).flags|=256),s=Fu(c,s,!1),s!==2){if(Yl&&!l){c.errorRecoveryDisabledLanes|=o,$l|=o,a=4;break a}o=iu,iu=a,o!==null&&(iu===null?iu=o:iu.push.apply(iu,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){ku(e,0),Eu(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:Eu(r,t,tu,!ql);break a;case 2:iu=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=ou+300-Oe(),10<a)){if(Eu(r,t,tu,!ql),qe(r,0,!0)!==0)break a;mu=t,r.timeoutHandle=tf(wu.bind(null,r,n,iu,lu,au,t,tu,$l,nu,ql,o,`Throttled`,-0,0),a);break a}wu(r,n,iu,lu,au,t,tu,$l,nu,ql,o,null,-0,0)}}break}while(1);ud(e)}function wu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:tn},Nl(t,a,d);var m=(a&62914560)===a?ou-Oe():(a&4194048)===a?su-Oe():0;if(m=np(d,m),m!==null){mu=a,e.cancelPendingCommit=m(Wu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),Eu(e,a,o,!l);return}}Wu(e,t,a,n,r,i,o,s,c)}function Tu(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Cr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Eu(e,t,n,r){t&=~eu,t&=~$l,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-I(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&et(e,n,t)}function Du(){return Vl&6?!0:(dd(0,!1),!1)}function Ou(){if(Ul!==null){if(Gl===0)var e=Ul.return;else e=Ul,Yi=Ji=null,jo(e),Na=null,Pa=0,e=Ul;for(;e!==null;)Vc(e.alternate,e),e=e.return;Ul=null}}function ku(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,nf(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),mu=0,Ou(),Hl=e,Ul=n=di(e.current,null),Wl=t,Gl=0,Kl=null,ql=!1,Jl=Je(e,t),Yl=!1,nu=tu=eu=$l=Ql=Zl=0,iu=ru=null,au=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-I(r),a=1<<i;t|=e[i],r&=~a}return Xl=t,ti(),n}function Au(e,t){mo=null,N.H=zs,t===wa||t===Ea?(t=R(),Gl=3):t===Ta?(t=R(),Gl=4):Gl=t===rc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Kl=t,Ul===null&&(Zl=1,Zs(e,yi(t,e.current)))}function ju(){var e=ro.current;return e===null?!0:(Wl&4194048)===Wl?io===null:(Wl&62914560)===Wl||Wl&536870912?e===io:!1}function Mu(){var e=N.H;return N.H=zs,e===null?zs:e}function Nu(){var e=N.A;return N.A=zl,e}function Pu(){Zl=4,ql||(Wl&4194048)!==Wl&&ro.current!==null||(Jl=!0),!(Ql&134217727)&&!($l&134217727)||Hl===null||Eu(Hl,Wl,tu,!1)}function Fu(e,t,n){var r=Vl;Vl|=2;var i=Mu(),a=Nu();(Hl!==e||Wl!==t)&&(lu=null,ku(e,t)),t=!1;var o=Zl;a:do try{if(Gl!==0&&Ul!==null){var s=Ul,c=Kl;switch(Gl){case 8:Ou(),o=6;break a;case 3:case 2:case 9:case 6:ro.current===null&&(t=!0);var l=Gl;if(Gl=0,Kl=null,Vu(e,s,c,l),n&&Jl){o=0;break a}break;default:l=Gl,Gl=0,Kl=null,Vu(e,s,c,l)}}Iu(),o=Zl;break}catch(t){Au(e,t)}while(1);return t&&e.shellSuspendCounter++,Yi=Ji=null,Vl=r,N.H=i,N.A=a,Ul===null&&(Hl=null,Wl=0,ti()),o}function Iu(){for(;Ul!==null;)zu(Ul)}function Lu(e,t){var n=Vl;Vl|=2;var r=Mu(),a=Nu();Hl!==e||Wl!==t?(lu=null,cu=Oe()+500,ku(e,t)):Jl=Je(e,t);a:do try{if(Gl!==0&&Ul!==null){t=Ul;var o=Kl;b:switch(Gl){case 1:Gl=0,Kl=null,Vu(e,t,o,1);break;case 2:case 9:if(Oa(o)){Gl=0,Kl=null,Bu(t);break}t=function(){Gl!==2&&Gl!==9||Hl!==e||(Gl=7),ud(e)},o.then(t,t);break a;case 3:Gl=7;break a;case 4:Gl=5;break a;case 7:Oa(o)?(Gl=0,Kl=null,Bu(t)):(Gl=0,Kl=null,Vu(e,t,o,7));break;case 5:var s=null;switch(Ul.tag){case 26:s=Ul.memoizedState;case 5:case 27:var c=Ul;if(s?$f(s):c.stateNode.complete){Gl=0,Kl=null;var l=c.sibling;if(l!==null)Ul=l;else{var u=c.return;u===null?Ul=null:(Ul=u,Hu(u))}break b}}Gl=0,Kl=null,Vu(e,t,o,5);break;case 6:Gl=0,Kl=null,Vu(e,t,o,6);break;case 8:Ou(),Zl=6;break a;default:throw Error(i(462))}}Ru();break}catch(t){Au(e,t)}while(1);return Yi=Ji=null,N.H=r,N.A=a,Vl=n,Ul===null?(Hl=null,Wl=0,ti(),Zl):0}function Ru(){for(;Ul!==null&&!Ee();)zu(Ul)}function zu(e){var t=Mc(e.alternate,e,Xl);e.memoizedProps=e.pendingProps,t===null?Hu(e):Ul=t}function Bu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=gc(n,t,t.pendingProps,t.type,void 0,Wl);break;case 11:t=gc(n,t,t.pendingProps,t.type.render,t.ref,Wl);break;case 5:jo(t);default:Vc(n,t),t=Ul=fi(t,Xl),t=Mc(n,t,Xl)}e.memoizedProps=e.pendingProps,t===null?Hu(e):Ul=t}function Vu(e,t,n,r){Yi=Ji=null,jo(t),Na=null,Pa=0;var i=t.return;try{if(nc(e,i,t,n,Wl)){Zl=1,Zs(e,yi(n,e.current)),Ul=null;return}}catch(t){if(i!==null)throw Ul=i,t;Zl=1,Zs(e,yi(n,e.current)),Ul=null;return}t.flags&32768?(Ii||r===1?e=!0:Jl||Wl&536870912?e=!1:(ql=e=!0,(r===2||r===9||r===3||r===6)&&(r=ro.current,r!==null&&r.tag===13&&(r.flags|=16384))),Uu(t,e)):Hu(t)}function Hu(e){var t=e;do{if(t.flags&32768){Uu(t,ql);return}e=t.return;var n=zc(t.alternate,t,Xl);if(n!==null){Ul=n;return}if(t=t.sibling,t!==null){Ul=t;return}Ul=t=e}while(t!==null);Zl===0&&(Zl=5)}function Uu(e,t){do{var n=Bc(e.alternate,e);if(n!==null){n.flags&=32767,Ul=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Ul=e;return}Ul=e=n}while(e!==null);Zl=6,Ul=null}function Wu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do Ju();while(du!==0);if(Vl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=ei,$e(e,n,o,s,c,l),e===Hl&&(Ul=Hl=null,Wl=0),pu=t,fu=e,mu=n,hu=o,gu=a,_u=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,rd(Me,function(){return Yu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=N.T,N.T=null,a=P.p,P.p=2,s=Vl,Vl|=4;try{ol(e,t,n)}finally{Vl=s,P.p=a,N.T=r}}du=1,Gu(),W(),Ku()}}function Gu(){if(du===1){du=0;var e=fu,t=pu,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=N.T,N.T=null;var r=P.p;P.p=2;var i=Vl;Vl|=4;try{yl(t,e);var a=Jd,o=Or(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&Dr(s.ownerDocument.documentElement,s)){if(c!==null&&kr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=Er(s,h),v=Er(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}gp=!!qd,Jd=qd=null}finally{Vl=i,P.p=r,N.T=n}}e.current=t,du=2}}function W(){if(du===2){du=0;var e=fu,t=pu,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=N.T,N.T=null;var r=P.p;P.p=2;var i=Vl;Vl|=4;try{sl(e,t.alternate,t)}finally{Vl=i,P.p=r,N.T=n}}du=3}}function Ku(){if(du===4||du===3){du=0,De();var e=fu,t=pu,n=mu,r=_u;t.subtreeFlags&10256||t.flags&10256?du=5:(du=0,pu=fu=null,qu(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(uu=null),it(n),t=t.stateNode,Re&&typeof Re.onCommitFiberRoot==`function`)try{Re.onCommitFiberRoot(Le,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=N.T,i=P.p,P.p=2,N.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{N.T=t,P.p=i}}mu&3&&Ju(),ud(e),i=e.pendingLanes,n&261930&&i&42?e===yu?vu++:(vu=0,yu=e):vu=0,dd(0,!1)}}function qu(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,da(t)))}function Ju(){return Gu(),W(),Ku(),Yu()}function Yu(){if(du!==5)return!1;var e=fu,t=hu;hu=0;var n=it(mu),r=N.T,a=P.p;try{P.p=32>n?32:n,N.T=null,n=gu,gu=null;var o=fu,s=mu;if(du=0,pu=fu=null,mu=0,Vl&6)throw Error(i(331));var c=Vl;if(Vl|=4,Il(o.current),Ol(o,o.current,s,n),Vl=c,dd(0,!1),Re&&typeof Re.onPostCommitFiberRoot==`function`)try{Re.onPostCommitFiberRoot(Le,o)}catch{}return!0}finally{P.p=a,N.T=r,qu(e,t)}}function Xu(e,t,n){t=yi(n,t),t=$s(e.stateNode,t,2),e=Ga(e,t,2),e!==null&&(Qe(e,2),ud(e))}function Zu(e,t,n){if(e.tag===3)Xu(e,e,n);else for(;t!==null;){if(t.tag===3){Xu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(uu===null||!uu.has(r))){e=yi(n,e),n=ec(2),r=Ga(t,n,2),r!==null&&(tc(n,r,t,e),Qe(r,2),ud(r));break}}t=t.return}}function Qu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Bl;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Yl=!0,i.add(n),e=$u.bind(null,e,t,n),t.then(e,e))}function $u(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Hl===e&&(Wl&n)===n&&(Zl===4||Zl===3&&(Wl&62914560)===Wl&&300>Oe()-ou?!(Vl&2)&&ku(e,0):eu|=n,nu===Wl&&(nu=0)),ud(e)}function ed(e,t){t===0&&(t=Xe()),e=ii(e,t),e!==null&&(Qe(e,t),ud(e))}function td(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),ed(e,n)}function nd(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),ed(e,n)}function rd(e,t){return we(e,t)}var id=null,ad=null,od=!1,sd=!1,cd=!1,ld=0;function ud(e){e!==ad&&e.next===null&&(ad===null?id=ad=e:ad=ad.next=e),sd=!0,od||(od=!0,_d())}function dd(e,t){if(!cd&&sd){cd=!0;do for(var n=!1,r=id;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-I(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,gd(r,a))}else a=Wl,a=qe(r,r===Hl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Je(r,a)||(n=!0,gd(r,a));r=r.next}while(n);cd=!1}}function fd(){pd()}function pd(){sd=od=!1;var e=0;ld!==0&&ef()&&(e=ld);for(var t=Oe(),n=null,r=id;r!==null;){var i=r.next,a=md(r,t);a===0?(r.next=null,n===null?id=i:n.next=i,i===null&&(ad=n)):(n=r,(e!==0||a&3)&&(sd=!0)),r=i}du!==0&&du!==5||dd(e,!1),ld!==0&&(ld=0)}function md(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-I(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Ye(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Hl,n=Wl,n=qe(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Gl===2||Gl===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Te(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Je(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Te(r),it(n)){case 2:case 8:n=je;break;case 32:n=Me;break;case 268435456:n=Pe;break;default:n=Me}return r=hd.bind(null,e),n=we(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Te(r),e.callbackPriority=2,e.callbackNode=null,2}function hd(e,t){if(du!==0&&du!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Ju()&&e.callbackNode!==n)return null;var r=Wl;return r=qe(e,e===Hl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Cu(e,r,t),md(e,Oe()),e.callbackNode!=null&&e.callbackNode===n?hd.bind(null,e):null)}function gd(e,t){if(Ju())return null;Cu(e,t,!0)}function _d(){af(function(){Vl&6?we(Ae,fd):pd()})}function vd(){if(ld===0){var e=ma;e===0&&(e=Ue,Ue<<=1,!(Ue&261888)&&(Ue=256)),ld=e}return ld}function yd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:en(``+e)}function bd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function xd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=yd((i[lt]||null).action),o=r.submitter;o&&(t=(t=o[lt]||null)?yd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Cn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(ld!==0){var e=o?bd(i,o):new FormData(i);Ts(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?bd(i,o):new FormData(i),Ts(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var Sd=0;Sd<Yr.length;Sd++){var Cd=Yr[Sd];Xr(Cd.toLowerCase(),`on`+(Cd[0].toUpperCase()+Cd.slice(1)))}Xr(Vr,`onAnimationEnd`),Xr(Hr,`onAnimationIteration`),Xr(Ur,`onAnimationStart`),Xr(`dblclick`,`onDoubleClick`),Xr(`focusin`,`onFocus`),Xr(`focusout`,`onBlur`),Xr(Wr,`onTransitionRun`),Xr(Gr,`onTransitionStart`),Xr(Kr,`onTransitionCancel`),Xr(qr,`onTransitionEnd`),Tt(`onMouseEnter`,[`mouseout`,`mouseover`]),Tt(`onMouseLeave`,[`mouseout`,`mouseover`]),Tt(`onPointerEnter`,[`pointerout`,`pointerover`]),Tt(`onPointerLeave`,[`pointerout`,`pointerover`]),wt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),wt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),wt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),wt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),wt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),wt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var wd=`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(` `),Td=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(wd));function Ed(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Zr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Zr(e)}i.currentTarget=null,a=c}}}}function Dd(e,t){var n=t[dt];n===void 0&&(n=t[dt]=new Set);var r=e+`__bubble`;n.has(r)||(jd(t,e,2,!1),n.add(r))}function Od(e,t,n){var r=0;t&&(r|=4),jd(n,e,r,t)}var kd=`_reactListening`+Math.random().toString(36).slice(2);function Ad(e){if(!e[kd]){e[kd]=!0,St.forEach(function(t){t!==`selectionchange`&&(Td.has(t)||Od(t,!1,e),Od(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[kd]||(t[kd]=!0,Od(`selectionchange`,!1,t))}}function jd(e,t,n,r){switch(Cp(t)){case 2:var i=_p;break;case 8:i=vp;break;default:i=yp}n=i.bind(null,t,n,e),i=void 0,!fn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Md(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=_t(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}ln(function(){var r=a,i=rn(n),s=[];a:{var c=Jr.get(e);if(c!==void 0){var l=Cn,u=e;switch(e){case`keypress`:if(vn(n)===0)break a;case`keydown`:case`keyup`:l=Bn;break;case`focusin`:u=`focus`,l=jn;break;case`focusout`:u=`blur`,l=jn;break;case`beforeblur`:case`afterblur`:l=jn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=kn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=An;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Hn;break;case Vr:case Hr:case Ur:l=Mn;break;case qr:l=Un;break;case`scroll`:case`scrollend`:l=Tn;break;case`wheel`:l=Wn;break;case`copy`:case`cut`:case`paste`:l=Nn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Vn;break;case`toggle`:case`beforetoggle`:l=Gn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=un(m,p),g!=null&&d.push(Nd(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==nn&&(u=n.relatedTarget||n.fromElement)&&(_t(u)||u[ut]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?_t(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=kn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Vn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:yt(l),h=u==null?c:yt(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,_t(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Fd,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Id(s,c,l,d,!1),u!==null&&f!==null&&Id(s,f,u,d,!0)}}a:{if(c=r?yt(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=dr;else if(ar(c))if(fr)v=xr;else{v=yr;var y=vr}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&Zt(r.elementType)&&(v=dr):v=br;if(v&&=v(e,r)){or(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&Ut(c,`number`,c.value)}switch(y=r?yt(r):window,e){case`focusin`:(ar(y)||y.contentEditable===`true`)&&(jr=y,Mr=r,Nr=null);break;case`focusout`:Nr=Mr=jr=null;break;case`mousedown`:Pr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Pr=!1,Fr(s,n,i);break;case`selectionchange`:if(Ar)break;case`keydown`:case`keyup`:Fr(s,n,i)}var b;if(qn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else tr?$n(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Xn&&n.locale!==`ko`&&(tr||x!==`onCompositionStart`?x===`onCompositionEnd`&&tr&&(b=_n()):(mn=i,hn=`value`in mn?mn.value:mn.textContent,tr=!0)),y=Pd(r,x),0<y.length&&(x=new Pn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=er(n),b!==null&&(x.data=b)))),(b=Yn?nr(e,n):rr(e,n))&&(x=Pd(r,`onBeforeInput`),0<x.length&&(y=new Pn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),xd(s,e,r,n,i)}Ed(s,t)})}function Nd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Pd(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=un(e,n),i!=null&&r.unshift(Nd(e,i,a)),i=un(e,t),i!=null&&r.push(Nd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Fd(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Id(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=un(n,a),l!=null&&o.unshift(Nd(n,l,c))):i||(l=un(n,a),l!=null&&o.push(Nd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Ld=/\r\n?/g,Rd=/\u0000|\uFFFD/g;function zd(e){return(typeof e==`string`?e:``+e).replace(Ld,`
|
|
10
|
+
`).replace(Rd,``)}function Bd(e,t){return t=zd(t),zd(e)===t}function Vd(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||qt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&qt(e,``+r);break;case`className`:jt(e,`class`,r);break;case`tabIndex`:jt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:jt(e,n,r);break;case`style`:Xt(e,r,o);break;case`data`:if(t!==`object`){jt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=en(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&Vd(e,t,`name`,a.name,a,null),Vd(e,t,`formEncType`,a.formEncType,a,null),Vd(e,t,`formMethod`,a.formMethod,a,null),Vd(e,t,`formTarget`,a.formTarget,a,null)):(Vd(e,t,`encType`,a.encType,a,null),Vd(e,t,`method`,a.method,a,null),Vd(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=en(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=tn);break;case`onScroll`:r!=null&&Dd(`scroll`,e);break;case`onScrollEnd`:r!=null&&Dd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=en(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Dd(`beforetoggle`,e),Dd(`toggle`,e),At(e,`popover`,r);break;case`xlinkActuate`:Mt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Mt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Mt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Mt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Mt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Mt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Mt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Mt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Mt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:At(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Qt.get(n)||n,At(e,n,r))}}function Hd(e,t,n,r,a,o){switch(n){case`style`:Xt(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?qt(e,r):(typeof r==`number`||typeof r==`bigint`)&&qt(e,``+r);break;case`onScroll`:r!=null&&Dd(`scroll`,e);break;case`onScrollEnd`:r!=null&&Dd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=tn);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!Ct.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[lt]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):At(e,n,r)}}}function Ud(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Dd(`error`,e),Dd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Vd(e,t,o,s,n,null)}}a&&Vd(e,t,`srcSet`,n.srcSet,n,null),r&&Vd(e,t,`src`,n.src,n,null);return;case`input`:Dd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Vd(e,t,r,d,n,null)}}Ht(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Dd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Vd(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&Wt(e,!!r,n,!0):Wt(e,!!r,t,!1);return;case`textarea`:for(s in Dd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Vd(e,t,s,c,n,null)}Kt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Vd(e,t,l,r,n,null)}return;case`dialog`:Dd(`beforetoggle`,e),Dd(`toggle`,e),Dd(`cancel`,e),Dd(`close`,e);break;case`iframe`:case`object`:Dd(`load`,e);break;case`video`:case`audio`:for(r=0;r<wd.length;r++)Dd(wd[r],e);break;case`image`:Dd(`error`,e),Dd(`load`,e);break;case`details`:Dd(`toggle`,e);break;case`embed`:case`source`:case`link`:Dd(`error`,e),Dd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Vd(e,t,u,r,n,null)}return;default:if(Zt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Hd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Vd(e,t,c,r,n,null))}function Wd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Vd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Vd(e,t,p,m,r,f)}}Vt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Vd(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Vd(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Wt(e,!!n,n?[]:``,!1):Wt(e,!!n,t,!0)):Wt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Vd(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Vd(e,t,s,a,r,o)}Gt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Vd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Vd(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Vd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Vd(e,t,u,p,r,m)}return;default:if(Zt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Hd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Hd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Vd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Vd(e,t,f,p,r,m)}function Gd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Kd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Gd(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Gd(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var qd=null,Jd=null;function Yd(e){return e.nodeType===9?e:e.ownerDocument}function Xd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Zd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Qd(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var $d=null;function ef(){var e=window.event;return e&&e.type===`popstate`?e===$d?!1:($d=e,!0):($d=null,!1)}var tf=typeof setTimeout==`function`?setTimeout:void 0,nf=typeof clearTimeout==`function`?clearTimeout:void 0,rf=typeof Promise==`function`?Promise:void 0,af=typeof queueMicrotask==`function`?queueMicrotask:rf===void 0?tf:function(e){return rf.resolve(null).then(e).catch(of)};function of(e){setTimeout(function(){throw e})}function sf(e){return e===`head`}function cf(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Hp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)Sf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,Sf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[ht]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&Sf(e.ownerDocument.body);n=i}while(n);Hp(t)}function lf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function uf(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:uf(n),gt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function df(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[ht])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=_f(e.nextSibling),e===null)break}return null}function ff(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=_f(e.nextSibling),e===null))return null;return e}function pf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=_f(e.nextSibling),e===null))return null;return e}function mf(e){return e.data===`$?`||e.data===`$~`}function hf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function gf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function _f(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var vf=null;function yf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return _f(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function bf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function xf(e,t,n){switch(t=Yd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function Sf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);gt(e)}var Cf=new Map,wf=new Set;function Tf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Ef=P.d;P.d={f:Df,r:Of,D:jf,C:Mf,L:Nf,m:Pf,X:If,S:Ff,M:Lf};function Df(){var e=Ef.f(),t=Du();return e||t}function Of(e){var t=vt(e);t!==null&&t.tag===5&&t.type===`form`?Ds(t):Ef.r(e)}var kf=typeof document>`u`?null:document;function Af(e,t,n){var r=kf;if(r&&typeof t==`string`&&t){var i=Bt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),wf.has(i)||(wf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Ud(t,`link`,e),xt(t),r.head.appendChild(t)))}}function jf(e){Ef.D(e),Af(`dns-prefetch`,e,null)}function Mf(e,t){Ef.C(e,t),Af(`preconnect`,e,t)}function Nf(e,t,n){Ef.L(e,t,n);var r=kf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Bt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Bt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Bt(n.imageSizes)+`"]`)):i+=`[href="`+Bt(e)+`"]`;var a=i;switch(t){case`style`:a=zf(e);break;case`script`:a=Uf(e)}Cf.has(a)||(e=m({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),Cf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Bf(a))||t===`script`&&r.querySelector(Wf(a))||(t=r.createElement(`link`),Ud(t,`link`,e),xt(t),r.head.appendChild(t)))}}function Pf(e,t){Ef.m(e,t);var n=kf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Bt(r)+`"][href="`+Bt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Uf(e)}if(!Cf.has(a)&&(e=m({rel:`modulepreload`,href:e},t),Cf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Wf(a)))return}r=n.createElement(`link`),Ud(r,`link`,e),xt(r),n.head.appendChild(r)}}}function Ff(e,t,n){Ef.S(e,t,n);var r=kf;if(r&&e){var i=bt(r).hoistableStyles,a=zf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Bf(a)))s.loading=5;else{e=m({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=Cf.get(a))&&qf(e,n);var c=o=r.createElement(`link`);xt(c),Ud(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Kf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function If(e,t){Ef.X(e,t);var n=kf;if(n&&e){var r=bt(n).hoistableScripts,i=Uf(e),a=r.get(i);a||(a=n.querySelector(Wf(i)),a||(e=m({src:e,async:!0},t),(t=Cf.get(i))&&Jf(e,t),a=n.createElement(`script`),xt(a),Ud(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Lf(e,t){Ef.M(e,t);var n=kf;if(n&&e){var r=bt(n).hoistableScripts,i=Uf(e),a=r.get(i);a||(a=n.querySelector(Wf(i)),a||(e=m({src:e,async:!0,type:`module`},t),(t=Cf.get(i))&&Jf(e,t),a=n.createElement(`script`),xt(a),Ud(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Rf(e,t,n,r){var a=(a=ue.current)?Tf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=zf(n.href),n=bt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=zf(n.href);var o=bt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Bf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),Cf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Cf.set(e,n),o||Hf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Uf(n),n=bt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function zf(e){return`href="`+Bt(e)+`"`}function Bf(e){return`link[rel="stylesheet"][`+e+`]`}function Vf(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function Hf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Ud(t,`link`,n),xt(t),e.head.appendChild(t))}function Uf(e){return`[src="`+Bt(e)+`"]`}function Wf(e){return`script[async]`+e}function Gf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Bt(n.href)+`"]`);if(r)return t.instance=r,xt(r),r;var a=m({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),xt(r),Ud(r,`style`,a),Kf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=zf(n.href);var o=e.querySelector(Bf(a));if(o)return t.state.loading|=4,t.instance=o,xt(o),o;r=Vf(n),(a=Cf.get(a))&&qf(r,a),o=(e.ownerDocument||e).createElement(`link`),xt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Ud(o,`link`,r),t.state.loading|=4,Kf(o,n.precedence,e),t.instance=o;case`script`:return o=Uf(n.src),(a=e.querySelector(Wf(o)))?(t.instance=a,xt(a),a):(r=n,(a=Cf.get(o))&&(r=m({},n),Jf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),xt(a),Ud(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Kf(r,n.precedence,e));return t.instance}function Kf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function qf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Jf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Yf=null;function Xf(e,t,n){if(Yf===null){var r=new Map,i=Yf=new Map;i.set(n,r)}else i=Yf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[ht]||a[ct]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Zf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Qf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function $f(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function ep(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=zf(r.href),a=t.querySelector(Bf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=rp.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,xt(a);return}a=t.ownerDocument||t,r=Vf(r),(i=Cf.get(i))&&qf(r,i),a=a.createElement(`link`),xt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Ud(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=rp.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var tp=0;function np(e,t){return e.stylesheets&&e.count===0&&ap(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&ap(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&tp===0&&(tp=62500*Kd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&ap(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>tp?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function rp(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ap(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var ip=null;function ap(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ip=new Map,t.forEach(op,e),ip=null,rp.call(e))}function op(e,t){if(!(t.state.loading&4)){var n=ip.get(e);if(n)var r=n.get(null);else{n=new Map,ip.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=rp.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var sp={$$typeof:C,Provider:null,Consumer:null,_currentValue:re,_currentValue2:re,_threadCount:0};function cp(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ze(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ze(0),this.hiddenUpdates=Ze(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function lp(e,t,n,r,i,a,o,s,c,l,u,d){return e=new cp(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=li(3,null,null,t),e.current=a,a.stateNode=e,t=ua(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Ha(a),e}function up(e){return e?(e=si,e):si}function dp(e,t,n,r,i,a){i=up(i),r.context===null?r.context=i:r.pendingContext=i,r=Wa(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Ga(e,r,t),n!==null&&(Su(n,e,t),Ka(n,e,t))}function fp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function pp(e,t){fp(e,t),(e=e.alternate)&&fp(e,t)}function mp(e){if(e.tag===13||e.tag===31){var t=ii(e,67108864);t!==null&&Su(t,e,67108864),pp(e,67108864)}}function hp(e){if(e.tag===13||e.tag===31){var t=bu();t=rt(t);var n=ii(e,t);n!==null&&Su(n,e,t),pp(e,t)}}var gp=!0;function _p(e,t,n,r){var i=N.T;N.T=null;var a=P.p;try{P.p=2,yp(e,t,n,r)}finally{P.p=a,N.T=i}}function vp(e,t,n,r){var i=N.T;N.T=null;var a=P.p;try{P.p=8,yp(e,t,n,r)}finally{P.p=a,N.T=i}}function yp(e,t,n,r){if(gp){var i=bp(r);if(i===null)Md(e,t,r,xp,n),Mp(e,r);else if(Pp(i,e,t,n,r))r.stopPropagation();else if(Mp(e,r),t&4&&-1<jp.indexOf(e)){for(;i!==null;){var a=vt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Ke(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-I(o);s.entanglements[1]|=c,o&=~c}ud(a),!(Vl&6)&&(cu=Oe()+500,dd(0,!1))}}break;case 31:case 13:s=ii(a,2),s!==null&&Su(s,a,2),Du(),pp(a,2)}if(a=bp(r),a===null&&Md(e,t,r,xp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Md(e,t,r,null,n)}}function bp(e){return e=rn(e),Sp(e)}var xp=null;function Sp(e){if(xp=null,e=_t(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return xp=e,null}function Cp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(ke()){case Ae:return 2;case je:return 8;case Me:case Ne:return 32;case Pe:return 268435456;default:return 32}default:return 32}}var wp=!1,Tp=null,Ep=null,Dp=null,Op=new Map,kp=new Map,Ap=[],jp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Mp(e,t){switch(e){case`focusin`:case`focusout`:Tp=null;break;case`dragenter`:case`dragleave`:Ep=null;break;case`mouseover`:case`mouseout`:Dp=null;break;case`pointerover`:case`pointerout`:Op.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:kp.delete(t.pointerId)}}function Np(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=vt(t),t!==null&&mp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Pp(e,t,n,r,i){switch(t){case`focusin`:return Tp=Np(Tp,e,t,n,r,i),!0;case`dragenter`:return Ep=Np(Ep,e,t,n,r,i),!0;case`mouseover`:return Dp=Np(Dp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Op.set(a,Np(Op.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,kp.set(a,Np(kp.get(a)||null,e,t,n,r,i)),!0}return!1}function Fp(e){var t=_t(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,ot(e.priority,function(){hp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,ot(e.priority,function(){hp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Ip(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=bp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);nn=r,n.target.dispatchEvent(r),nn=null}else return t=vt(n),t!==null&&mp(t),e.blockedOn=n,!1;t.shift()}return!0}function Lp(e,t,n){Ip(e)&&n.delete(t)}function Rp(){wp=!1,Tp!==null&&Ip(Tp)&&(Tp=null),Ep!==null&&Ip(Ep)&&(Ep=null),Dp!==null&&Ip(Dp)&&(Dp=null),Op.forEach(Lp),kp.forEach(Lp)}function zp(e,n){e.blockedOn===n&&(e.blockedOn=null,wp||(wp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Rp)))}var Bp=null;function Vp(e){Bp!==e&&(Bp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Bp===e&&(Bp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Sp(r||n)===null)continue;break}var a=vt(n);a!==null&&(e.splice(t,3),t-=3,Ts(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Hp(e){function t(t){return zp(t,e)}Tp!==null&&zp(Tp,e),Ep!==null&&zp(Ep,e),Dp!==null&&zp(Dp,e),Op.forEach(t),kp.forEach(t);for(var n=0;n<Ap.length;n++){var r=Ap[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Ap.length&&(n=Ap[0],n.blockedOn===null);)Fp(n),n.blockedOn===null&&Ap.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[lt]||null;if(typeof a==`function`)o||Vp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[lt]||null)s=o.formAction;else if(Sp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Vp(n)}}}function Up(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Wp(e){this._internalRoot=e}Gp.prototype.render=Wp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;dp(n,bu(),e,t,null,null)},Gp.prototype.unmount=Wp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;dp(e.current,2,null,e,null,null),Du(),t[ut]=null}};function Gp(e){this._internalRoot=e}Gp.prototype.unstable_scheduleHydration=function(e){if(e){var t=at();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ap.length&&t!==0&&t<Ap[n].priority;n++);Ap.splice(n,0,e),n===0&&Fp(e)}};var Kp=n.version;if(Kp!==`19.2.7`)throw Error(i(527,Kp,`19.2.7`));P.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:f(e),e=e===null?null:e.stateNode,e};var qp={bundleType:0,version:`19.2.7`,rendererPackageName:`react-dom`,currentDispatcherRef:N,reconcilerVersion:`19.2.7`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Jp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Jp.isDisabled&&Jp.supportsFiber)try{Le=Jp.inject(qp),Re=Jp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Js,s=Ys,c=Xs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=lp(e,1,!1,null,null,n,r,null,o,s,c,Up),e[ut]=t.current,Ad(e),new Wp(t)}})),_=o(((e,t)=>{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)}}n(),t.exports=g()})),v=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),y=o(((e,t)=>{t.exports=v()})),b=l(d()),x=l(_()),S=y();function C(e){var t=[...arguments].slice(1);throw Error(typeof e==`number`?`[MobX] minified error nr: `+e+(t.length?` `+t.map(String).join(`,`):``)+`. Find the full error at: https://github.com/mobxjs/mobx/blob/main/packages/mobx/src/errors.ts`:`[MobX] `+e)}var w={};function T(){return typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:w}var E=Object.assign,D=Object.getOwnPropertyDescriptor,O=Object.defineProperty,k=Object.prototype,ee=[];Object.freeze(ee);var A={};Object.freeze(A);var j=typeof Proxy<`u`,te=Object.toString();function M(){j||C(`Proxy not available`)}function ne(e){var t=!1;return function(){if(!t)return t=!0,e.apply(this,arguments)}}var N=function(){};function P(e){return typeof e==`function`}function re(e){switch(typeof e){case`string`:case`symbol`:case`number`:return!0}return!1}function ie(e){return typeof e==`object`&&!!e}function ae(e){if(!ie(e))return!1;var t=Object.getPrototypeOf(e);if(t==null)return!0;var n=Object.hasOwnProperty.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n.toString()===te}function F(e){var t=e?.constructor;return t?t.name===`GeneratorFunction`||t.displayName===`GeneratorFunction`:!1}function oe(e,t,n){O(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}function se(e,t,n){O(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}function ce(e,t){var n=`isMobX`+e;return t.prototype[n]=!0,function(e){return ie(e)&&e[n]===!0}}function le(e){return e!=null&&Object.prototype.toString.call(e)===`[object Map]`}function ue(e){return Object.getPrototypeOf(Object.getPrototypeOf(Object.getPrototypeOf(e)))===null}function de(e){return e!=null&&Object.prototype.toString.call(e)===`[object Set]`}var fe=Object.getOwnPropertySymbols!==void 0;function pe(e){var t=Object.keys(e);if(!fe)return t;var n=Object.getOwnPropertySymbols(e);return n.length?[].concat(t,n.filter(function(t){return k.propertyIsEnumerable.call(e,t)})):t}var me=typeof Reflect<`u`&&Reflect.ownKeys?Reflect.ownKeys:fe?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames;function he(e){return e===null?null:typeof e==`object`?``+e:e}function ge(e,t){return k.hasOwnProperty.call(e,t)}var _e=Object.getOwnPropertyDescriptors||function(e){var t={};return me(e).forEach(function(n){t[n]=D(e,n)}),t};function ve(e,t){return!!(e&t)}function ye(e,t,n){return n?e|=t:e&=~t,e}function be(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function xe(e,t,n){if(ke())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&Ae(i,n.prototype),i}function Se(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,Me(r.key),r)}}function Ce(e,t,n){return t&&Se(e.prototype,t),n&&Se(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function we(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=Ne(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
|
|
11
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Te(){return Te=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Te.apply(null,arguments)}function Ee(e){return Ee=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Ee(e)}function De(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Ae(e,t)}function Oe(e){try{return Function.toString.call(e).indexOf(`[native code]`)!==-1}catch{return typeof e==`function`}}function ke(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(ke=function(){return!!e})()}function Ae(e,t){return Ae=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ae(e,t)}function je(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Me(e){var t=je(e,`string`);return typeof t==`symbol`?t:t+``}function Ne(e,t){if(e){if(typeof e==`string`)return be(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?be(e,t):void 0}}function Pe(e){var t=typeof Map==`function`?new Map:void 0;return Pe=function(e){if(e===null||!Oe(e))return e;if(typeof e!=`function`)throw TypeError(`Super expression must either be null or a function`);if(t!==void 0){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return xe(e,arguments,Ee(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),Ae(n,e)},Pe(e)}var Fe=Symbol(`mobx-stored-annotations`);function Ie(e){function t(t,n){if(ze(n))return e.decorate_20223_(t,n);Le(t,n,e)}return Object.assign(t,e)}function Le(e,t,n){ge(e,Fe)||oe(e,Fe,Te({},e[Fe])),$e(n)||(e[Fe][t]=n)}function Re(e){return ge(e,Fe)||oe(e,Fe,Te({},e[Fe])),e[Fe]}function ze(e){return typeof e==`object`&&typeof e.kind==`string`}var I=Symbol(`mobx administration`),Be=function(){function e(e){e===void 0&&(e=`Atom`),this.name_=void 0,this.flags_=0,this.observers_=new Set,this.lastAccessedBy_=0,this.lowestObserverState_=dn.NOT_TRACKING_,this.onBOL=void 0,this.onBUOL=void 0,this.name_=e}var t=e.prototype;return t.onBO=function(){this.onBOL&&this.onBOL.forEach(function(e){return e()})},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(e){return e()})},t.reportObserved=function(){return Fn(this)},t.reportChanged=function(){Nn(),In(this),Pn()},t.toString=function(){return this.name_},Ce(e,[{key:`isBeingObserved`,get:function(){return ve(this.flags_,e.isBeingObservedMask_)},set:function(t){this.flags_=ye(this.flags_,e.isBeingObservedMask_,t)}},{key:`isPendingUnobservation`,get:function(){return ve(this.flags_,e.isPendingUnobservationMask_)},set:function(t){this.flags_=ye(this.flags_,e.isPendingUnobservationMask_,t)}},{key:`diffValue`,get:function(){return+!!ve(this.flags_,e.diffValueMask_)},set:function(t){this.flags_=ye(this.flags_,e.diffValueMask_,t===1)}}])}();Be.isBeingObservedMask_=1,Be.isPendingUnobservationMask_=2,Be.diffValueMask_=4;var Ve=ce(`Atom`,Be);function He(e,t,n){t===void 0&&(t=N),n===void 0&&(n=N);var r=new Be(e);return t!==N&&hr(r,t),n!==N&&gr(r,n),r}function Ue(e,t){return e===t}function We(e,t){return ea(e,t)}function Ge(e,t){return ea(e,t,1)}function Ke(e,t){return Object.is?Object.is(e,t):e===t?e!==0||1/e==1/t:e!==e&&t!==t}var qe={identity:Ue,structural:We,default:Ke,shallow:Ge};function Je(e,t,n){return Rr(e)?e:Array.isArray(e)?Ut.array(e,{name:n}):ae(e)?Ut.object(e,void 0,{name:n}):le(e)?Ut.map(e,{name:n}):de(e)?Ut.set(e,{name:n}):typeof e==`function`&&!sr(e)&&!Mr(e)?F(e)?Ar(e):ar(n,e):e}function Ye(e,t,n){if(e==null||Li(e)||yi(e)||wi(e)||ki(e))return e;if(Array.isArray(e))return Ut.array(e,{name:n,deep:!1});if(ae(e))return Ut.object(e,void 0,{name:n,deep:!1});if(le(e))return Ut.map(e,{name:n,deep:!1});if(de(e))return Ut.set(e,{name:n,deep:!1})}function Xe(e){return e}function Ze(e,t){return ea(e,t)?t:e}var Qe=`override`;function $e(e){return e.annotationType_===Qe}function et(e,t){return{annotationType_:e,options_:t,make_:tt,extend_:nt,decorate_20223_:rt}}function tt(e,t,n,r){var i;return(i=this.options_)!=null&&i.bound?this.extend_(e,t,n,!1)===null?0:1:r===e.target_?this.extend_(e,t,n,!1)===null?0:2:sr(n.value)?1:(O(r,t,at(e,this,t,n,!1)),2)}function nt(e,t,n,r){var i=at(e,this,t,n);return e.defineProperty_(t,i,r)}function rt(e,t){var n=t.kind,r=t.name,i=t.addInitializer,a=this,o=function(e){return $t(a.options_?.name??r.toString(),e,a.options_?.autoAction??!1)};if(n==`field`)return function(e){var t,n=e;return sr(n)||(n=o(n)),(t=a.options_)!=null&&t.bound&&(n=n.bind(this),n.isMobxAction=!0),n};if(n==`method`){var s;return sr(e)||(e=o(e)),(s=this.options_)!=null&&s.bound&&i(function(){var e=this,t=e[r].bind(e);t.isMobxAction=!0,e[r]=t}),e}C(`Cannot apply '`+a.annotationType_+`' to '`+String(r)+`' (kind: `+n+`):`+(`
|
|
12
|
+
'`+a.annotationType_+`' can only be used on properties with a function value.`))}function it(e,t,n,r){t.annotationType_,r.value}function at(e,t,n,r,i){var a,o;i===void 0&&(i=L.safeDescriptors),it(e,t,n,r);var s=r.value;return(a=t.options_)!=null&&a.bound&&(s=s.bind(e.proxy_??e.target_)),{value:$t(t.options_?.name??n.toString(),s,t.options_?.autoAction??!1,(o=t.options_)!=null&&o.bound?e.proxy_??e.target_:void 0),configurable:i?e.isPlainObject_:!0,enumerable:!1,writable:!i}}function ot(e,t){return{annotationType_:e,options_:t,make_:st,extend_:ct,decorate_20223_:lt}}function st(e,t,n,r){var i;return r===e.target_?this.extend_(e,t,n,!1)===null?0:2:(i=this.options_)!=null&&i.bound&&(!ge(e.target_,t)||!Mr(e.target_[t]))&&this.extend_(e,t,n,!1)===null?0:Mr(n.value)?1:(O(r,t,dt(e,this,t,n,!1,!1)),2)}function ct(e,t,n,r){var i=dt(e,this,t,n,this.options_?.bound);return e.defineProperty_(t,i,r)}function lt(e,t){var n,r=t.name,i=t.addInitializer;return Mr(e)||(e=Ar(e)),(n=this.options_)!=null&&n.bound&&i(function(){var e=this,t=e[r].bind(e);t.isMobXFlow=!0,e[r]=t}),e}function ut(e,t,n,r){t.annotationType_,r.value}function dt(e,t,n,r,i,a){a===void 0&&(a=L.safeDescriptors),ut(e,t,n,r);var o=r.value;return Mr(o)||(o=Ar(o)),i&&(o=o.bind(e.proxy_??e.target_),o.isMobXFlow=!0),{value:o,configurable:a?e.isPlainObject_:!0,enumerable:!1,writable:!a}}function ft(e,t){return{annotationType_:e,options_:t,make_:pt,extend_:mt,decorate_20223_:ht}}function pt(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function mt(e,t,n,r){return gt(e,this,t,n),e.defineComputedProperty_(t,Te({},this.options_,{get:n.get,set:n.set}),r)}function ht(e,t){var n=this,r=t.name,i=t.addInitializer,a;function o(t,i){var a=Te({},n.options_,{get:e,context:t});return a.name||=`ObservableObject.`+r.toString(),new ln(a)}return i(function(){var t=Pi(this)[I],n=this,i=t.values_.get(r);i instanceof ln&&i.derivation!==e&&t.values_.delete(r),(t.lazyComputedKeys_??=new Map).set(r,function(){return o(n,t)})}),function(){var t=this[I],n=t.values_.get(r);if(n instanceof ln&&n.derivation!==e){var i=a?.get(this);return i||(i=o(this,t),(a??=new WeakMap).set(this,i)),i.get()}return t.getObservablePropValue_(r)}}function gt(e,t,n,r){t.annotationType_,r.get}function _t(e,t){return{annotationType_:e,options_:t,make_:vt,extend_:yt,decorate_20223_:bt}}function vt(e,t,n){return this.extend_(e,t,n,!1)===null?0:1}function yt(e,t,n,r){return xt(e,this,t,n),e.defineObservableProperty_(t,n.value,this.options_?.enhancer??Je,r)}function bt(e,t){var n=this,r=t.kind,i=t.name;if(r!==`accessor`)return;function a(e,t){var r=Pi(e)[I];return(r.lazyObservableKeys_??=new Map).set(i,function(){return new sn(t,n.options_?.enhancer??Je,`ObservableObject.`+i.toString(),!1)}),r}return{get:function(){return(this[I]??a(this,e.get.call(this))).getObservablePropValue_(i)},set:function(e){return(this[I]??a(this,e)).setObservablePropValue_(i,e)},init:function(e){return a(this,e),e}}}function xt(e,t,n,r){t.annotationType_}var St=`true`,Ct=wt();function wt(e){return{annotationType_:St,options_:e,make_:Tt,extend_:Et,decorate_20223_:Dt}}function Tt(e,t,n,r){var i;if(n.get)return Jt.make_(e,t,n,r);if(n.set){var a=sr(n.set)?n.set:$t(t.toString(),n.set);return r===e.target_?e.defineProperty_(t,{configurable:L.safeDescriptors?e.isPlainObject_:!0,set:a})===null?0:2:(O(r,t,{configurable:!0,set:a}),2)}if(r!==e.target_&&typeof n.value==`function`){var o;if(F(n.value)){var s;return((s=this.options_)!=null&&s.autoBind?Ar.bound:Ar).make_(e,t,n,r)}return((o=this.options_)!=null&&o.autoBind?ar.bound:ar).make_(e,t,n,r)}var c=this.options_?.deep===!1?Ut.ref:Ut;return typeof n.value==`function`&&(i=this.options_)!=null&&i.autoBind&&(n.value=n.value.bind(e.proxy_??e.target_)),c.make_(e,t,n,r)}function Et(e,t,n,r){var i;return n.get?Jt.extend_(e,t,n,r):n.set?e.defineProperty_(t,{configurable:L.safeDescriptors?e.isPlainObject_:!0,set:$t(t.toString(),n.set)},r):(typeof n.value==`function`&&(i=this.options_)!=null&&i.autoBind&&(n.value=n.value.bind(e.proxy_??e.target_)),(this.options_?.deep===!1?Ut.ref:Ut).extend_(e,t,n,r))}function Dt(e,t){C(`'`+this.annotationType_+`' cannot be used as a decorator`)}var Ot=`observable`,kt=`observable.ref`,At=`observable.shallow`,jt=`observable.struct`,Mt={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};Object.freeze(Mt);function Nt(e){return e||Mt}var Pt=_t(Ot),Ft=_t(kt,{enhancer:Xe}),It=_t(At,{enhancer:Ye}),Lt=_t(jt,{enhancer:Ze}),Rt=Ie(Pt);function zt(e){return e.deep===!0?Je:e.deep===!1?Xe:Vt(e.defaultDecorator)}function Bt(e){return e?e.defaultDecorator??wt(e):void 0}function Vt(e){return e?e.options_?.enhancer??Je:Je}function Ht(e,t,n){if(ze(t))return Pt.decorate_20223_(e,t);if(re(t)){Le(e,t,Pt);return}return Rr(e)?e:ae(e)?Ut.object(e,t,n):Array.isArray(e)?Ut.array(e,t):le(e)?Ut.map(e,t):de(e)?Ut.set(e,t):typeof e==`object`&&e?e:Ut.box(e,t)}E(Ht,Rt);var Ut=E(Ht,{box:function(e,t){var n=Nt(t);return new sn(e,zt(n),n.name,!0,n.equals)},array:function(e,t){var n=Nt(t);return(L.useProxies===!1||n.proxy===!1?Ji:fi)(e,zt(n),n.name)},map:function(e,t){var n=Nt(t);return new Ci(e,zt(n),n.name)},set:function(e,t){var n=Nt(t);return new Oi(e,zt(n),n.name)},object:function(e,t,n){return Qi(function(){return Sr(L.useProxies===!1||n?.proxy===!1?Pi({},n):$r({},n),e,t)})},ref:Ie(Ft),shallow:Ie(It),deep:Rt,struct:Ie(Lt)}),Wt=`computed`,Gt=`computed.struct`,Kt=ft(Wt),qt=ft(Gt,{equals:qe.structural}),Jt=function(e,t){if(ze(t))return Kt.decorate_20223_(e,t);if(re(t))return Le(e,t,Kt);if(ae(e))return Ie(ft(Wt,e));var n=ae(t)?t:{};return n.get=e,n.name||=e.name||``,new ln(n)};Object.assign(Jt,Kt),Jt.struct=Ie(qt);var Yt=0,Xt=1,Zt=D(function(){},`name`)?.configurable??!1,Qt={value:`action`,configurable:!0,writable:!1,enumerable:!1};function $t(e,t,n,r){n===void 0&&(n=!1);function i(){return en(e,n,t,r||this,arguments)}return i.isMobxAction=!0,i.toString=function(){return t.toString()},Zt&&(Qt.value=e,O(i,`name`,Qt)),i}function en(e,t,n,r,i){var a=tn(e,t,r,i);try{return n.apply(r,i)}catch(e){throw a.error_=e,e}finally{nn(a)}}function tn(e,t,n,r){var i=!1,a=0,o=L.trackingDerivation,s=!t||!o;Nn();var c=L.allowStateChanges;s&&(bn(),c=an(!0));var l=Sn(!0),u={runAsAction_:s,prevDerivation_:o,prevAllowStateChanges_:c,prevAllowStateReads_:l,notifySpy_:i,startTime_:a,actionId_:Xt++,parentActionId_:Yt};return Yt=u.actionId_,u}function nn(e){Yt!==e.actionId_&&C(30),Yt=e.parentActionId_,e.error_!==void 0&&(L.suppressReactionErrors=!0),on(e.prevAllowStateChanges_),Cn(e.prevAllowStateReads_),Pn(),e.runAsAction_&&xn(e.prevDerivation_),L.suppressReactionErrors=!1}function rn(e,t){var n=an(e);try{return t()}finally{on(n)}}function an(e){var t=L.allowStateChanges;return L.allowStateChanges=e,t}function on(e){L.allowStateChanges=e}var sn=function(e){function t(t,n,r,i,a){var o;return r===void 0&&(r=`ObservableValue`),i===void 0&&(i=!0),a===void 0&&(a=qe.default),o=e.call(this,r)||this,o.enhancer=void 0,o.name_=void 0,o.equals=void 0,o.hasUnreportedChange_=!1,o.interceptors_=void 0,o.changeListeners_=void 0,o.value_=void 0,o.dehancer=void 0,o.enhancer=n,o.name_=r,o.equals=a,o.value_=n(t,void 0,r),o}De(t,e);var n=t.prototype;return n.dehanceValue=function(e){return this.dehancer===void 0?e:this.dehancer(e)},n.set=function(e){this.value_,e=this.prepareNewValue_(e),e!==L.UNCHANGED&&this.setNewValue_(e)},n.prepareNewValue_=function(e){if(ei(this)){var t=ni(this,{object:this,type:ci,newValue:e});if(!t)return L.UNCHANGED;e=t.newValue}return e=this.enhancer(e,this.value_,this.name_),this.equals(this.value_,e)?L.UNCHANGED:e},n.setNewValue_=function(e){var t=this.value_;this.value_=e,this.reportChanged(),ri(this)&&ai(this,{type:ci,object:this,newValue:e,oldValue:t})},n.get=function(){return this.reportObserved(),this.dehanceValue(this.value_)},n.intercept_=function(e){return ti(this,e)},n.observe_=function(e,t){return t&&e({observableKind:`value`,debugObjectName:this.name_,object:this,type:ci,newValue:this.value_,oldValue:void 0}),ii(this,e)},n.raw=function(){return this.value_},n.toJSON=function(){return this.get()},n.toString=function(){return this.name_+`[`+this.value_+`]`},n.valueOf=function(){return he(this.get())},n[Symbol.toPrimitive]=function(){return this.valueOf()},t}(Be),cn=ce(`ObservableValue`,sn),ln=function(){function e(e){this.dependenciesState_=dn.NOT_TRACKING_,this.observing_=[],this.newObserving_=null,this.observers_=new Set,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=dn.UP_TO_DATE_,this.unboundDepsCount_=0,this.value_=new pn(null),this.name_=void 0,this.triggeredBy_=void 0,this.flags_=0,this.derivation=void 0,this.setter_=void 0,this.isTracing_=fn.NONE,this.scope_=void 0,this.equals_=void 0,this.requiresReaction_=void 0,this.keepAlive_=void 0,this.onBOL=void 0,this.onBUOL=void 0,e.get||C(31),this.derivation=e.get,this.name_=e.name||`ComputedValue`,e.set&&(this.setter_=$t(`ComputedValue-setter`,e.set)),this.equals_=e.equals||(e.compareStructural||e.struct?qe.structural:qe.default),this.scope_=e.context,this.requiresReaction_=e.requiresReaction,this.keepAlive_=!!e.keepAlive}var t=e.prototype;return t.onBecomeStale_=function(){Rn(this)},t.onBO=function(){this.onBOL&&this.onBOL.forEach(function(e){return e()})},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(e){return e()})},t.get=function(){if(this.isComputing&&C(32,this.name_,this.derivation),L.inBatch===0&&this.observers_.size===0&&!this.keepAlive_)hn(this)&&(this.warnAboutUntrackedRead_(),Nn(),this.value_=this.computeValue_(!1),Pn());else if(Fn(this),hn(this)){var e=L.trackingContext;this.keepAlive_&&!e&&(L.trackingContext=this),this.trackAndCompute()&&Ln(this),L.trackingContext=e}var t=this.value_;if(mn(t))throw t.cause;return t},t.set=function(e){if(this.setter_){this.isRunningSetter&&C(33,this.name_),this.isRunningSetter=!0;try{this.setter_.call(this.scope_,e)}finally{this.isRunningSetter=!1}}else C(34,this.name_)},t.trackAndCompute=function(){var e=this.value_,t=this.dependenciesState_===dn.NOT_TRACKING_,n=this.computeValue_(!0),r=t||mn(e)||mn(n)||!this.equals_(e,n);return r&&(this.value_=n),r},t.computeValue_=function(e){this.isComputing=!0;var t=an(!1),n;if(e)n=gn(this,this.derivation,this.scope_);else if(L.disableErrorBoundaries===!0)n=this.derivation.call(this.scope_);else try{n=this.derivation.call(this.scope_)}catch(e){n=new pn(e)}return on(t),this.isComputing=!1,n},t.suspend_=function(){this.keepAlive_||(vn(this),this.value_=void 0)},t.observe_=function(e,t){var n=this,r=!0,i=void 0;return cr(function(){var a=n.get();if(!r||t){var o=bn();e({observableKind:`computed`,debugObjectName:n.name_,type:ci,object:n,newValue:a,oldValue:i}),xn(o)}r=!1,i=a})},t.warnAboutUntrackedRead_=function(){},t.toString=function(){return this.name_+`[`+this.derivation.toString()+`]`},t.valueOf=function(){return he(this.get())},t[Symbol.toPrimitive]=function(){return this.valueOf()},Ce(e,[{key:`isComputing`,get:function(){return ve(this.flags_,e.isComputingMask_)},set:function(t){this.flags_=ye(this.flags_,e.isComputingMask_,t)}},{key:`isRunningSetter`,get:function(){return ve(this.flags_,e.isRunningSetterMask_)},set:function(t){this.flags_=ye(this.flags_,e.isRunningSetterMask_,t)}},{key:`isBeingObserved`,get:function(){return ve(this.flags_,e.isBeingObservedMask_)},set:function(t){this.flags_=ye(this.flags_,e.isBeingObservedMask_,t)}},{key:`isPendingUnobservation`,get:function(){return ve(this.flags_,e.isPendingUnobservationMask_)},set:function(t){this.flags_=ye(this.flags_,e.isPendingUnobservationMask_,t)}},{key:`diffValue`,get:function(){return+!!ve(this.flags_,e.diffValueMask_)},set:function(t){this.flags_=ye(this.flags_,e.diffValueMask_,t===1)}}])}();ln.isComputingMask_=1,ln.isRunningSetterMask_=2,ln.isBeingObservedMask_=4,ln.isPendingUnobservationMask_=8,ln.diffValueMask_=16;var un=ce(`ComputedValue`,ln),dn;(function(e){e[e.NOT_TRACKING_=-1]=`NOT_TRACKING_`,e[e.UP_TO_DATE_=0]=`UP_TO_DATE_`,e[e.POSSIBLY_STALE_=1]=`POSSIBLY_STALE_`,e[e.STALE_=2]=`STALE_`})(dn||={});var fn;(function(e){e[e.NONE=0]=`NONE`,e[e.LOG=1]=`LOG`,e[e.BREAK=2]=`BREAK`})(fn||={});var pn=function(e){this.cause=void 0,this.cause=e};function mn(e){return e instanceof pn}function hn(e){switch(e.dependenciesState_){case dn.UP_TO_DATE_:return!1;case dn.NOT_TRACKING_:case dn.STALE_:return!0;case dn.POSSIBLY_STALE_:for(var t=Sn(!0),n=bn(),r=e.observing_,i=r.length,a=0;a<i;a++){var o=r[a];if(un(o)){if(L.disableErrorBoundaries)o.get();else try{o.get()}catch{return xn(n),Cn(t),!0}if(e.dependenciesState_===dn.STALE_)return xn(n),Cn(t),!0}}return wn(e),xn(n),Cn(t),!1}}function gn(e,t,n){var r=Sn(!0);wn(e),e.newObserving_=Array(e.runId_===0?100:e.observing_.length),e.unboundDepsCount_=0,e.runId_=++L.runId;var i=L.trackingDerivation;L.trackingDerivation=e,L.inBatch++;var a;if(L.disableErrorBoundaries===!0)a=t.call(n);else try{a=t.call(n)}catch(e){a=new pn(e)}return L.inBatch--,L.trackingDerivation=i,_n(e),Cn(r),a}function _n(e){for(var t=e.observing_,n=e.observing_=e.newObserving_,r=dn.UP_TO_DATE_,i=0,a=e.unboundDepsCount_,o=0;o<a;o++){var s=n[o];s.diffValue===0&&(s.diffValue=1,i!==o&&(n[i]=s),i++),s.dependenciesState_>r&&(r=s.dependenciesState_)}for(n.length=i,e.newObserving_=null,a=t.length;a--;){var c=t[a];c.diffValue===0&&jn(c,e),c.diffValue=0}for(;i--;){var l=n[i];l.diffValue===1&&(l.diffValue=0,An(l,e))}r!==dn.UP_TO_DATE_&&(e.dependenciesState_=r,e.onBecomeStale_())}function vn(e){var t=e.observing_;e.observing_=[];for(var n=t.length;n--;)jn(t[n],e);e.dependenciesState_=dn.NOT_TRACKING_}function yn(e){var t=bn();try{return e()}finally{xn(t)}}function bn(){var e=L.trackingDerivation;return L.trackingDerivation=null,e}function xn(e){L.trackingDerivation=e}function Sn(e){var t=L.allowStateReads;return L.allowStateReads=e,t}function Cn(e){L.allowStateReads=e}function wn(e){if(e.dependenciesState_!==dn.UP_TO_DATE_){e.dependenciesState_=dn.UP_TO_DATE_;for(var t=e.observing_,n=t.length;n--;)t[n].lowestObserverState_=dn.UP_TO_DATE_}}var Tn=function(){this.version=6,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.useProxies=!0,this.verifyProxies=!1,this.safeDescriptors=!0},En=!0,Dn=!1,L=function(){var e=T();return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(En=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==new Tn().version&&(En=!1),En?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new Tn):(setTimeout(function(){Dn||C(35)},1),new Tn)}();function On(){if((L.pendingReactions.length||L.inBatch||L.isRunningReactions)&&C(36),Dn=!0,En){var e=T();--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),L=new Tn}}function kn(){return L}function An(e,t){e.observers_.add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function jn(e,t){e.observers_.delete(t),e.observers_.size===0&&Mn(e)}function Mn(e){e.isPendingUnobservation===!1&&(e.isPendingUnobservation=!0,L.pendingUnobservations.push(e))}function Nn(){L.inBatch++}function Pn(){if(--L.inBatch===0){Hn();for(var e=L.pendingUnobservations,t=0;t<e.length;t++){var n=e[t];n.isPendingUnobservation=!1,n.observers_.size===0&&(n.isBeingObserved&&(n.isBeingObserved=!1,n.onBUO()),n instanceof ln&&n.suspend_())}L.pendingUnobservations=[]}}function Fn(e){var t=L.trackingDerivation;return t===null?(e.observers_.size===0&&L.inBatch>0&&Mn(e),!1):(t.runId_!==e.lastAccessedBy_&&(e.lastAccessedBy_=t.runId_,t.newObserving_[t.unboundDepsCount_++]=e,!e.isBeingObserved&&L.trackingContext&&(e.isBeingObserved=!0,e.onBO())),e.isBeingObserved)}function In(e){e.lowestObserverState_!==dn.STALE_&&(e.lowestObserverState_=dn.STALE_,e.observers_.forEach(function(e){e.dependenciesState_===dn.UP_TO_DATE_&&e.onBecomeStale_(),e.dependenciesState_=dn.STALE_}))}function Ln(e){e.lowestObserverState_!==dn.STALE_&&(e.lowestObserverState_=dn.STALE_,e.observers_.forEach(function(t){t.dependenciesState_===dn.POSSIBLY_STALE_?t.dependenciesState_=dn.STALE_:t.dependenciesState_===dn.UP_TO_DATE_&&(e.lowestObserverState_=dn.UP_TO_DATE_)}))}function Rn(e){e.lowestObserverState_===dn.UP_TO_DATE_&&(e.lowestObserverState_=dn.POSSIBLY_STALE_,e.observers_.forEach(function(e){e.dependenciesState_===dn.UP_TO_DATE_&&(e.dependenciesState_=dn.POSSIBLY_STALE_,e.onBecomeStale_())}))}var zn=function(){function e(e,t,n,r){e===void 0&&(e=`Reaction`),this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=dn.NOT_TRACKING_,this.runId_=0,this.unboundDepsCount_=0,this.flags_=0,this.isTracing_=fn.NONE,this.name_=e,this.onInvalidate_=t,this.errorHandler_=n,this.requiresObservable_=r}var t=e.prototype;return t.onBecomeStale_=function(){this.schedule_()},t.schedule_=function(){this.isScheduled||(this.isScheduled=!0,L.pendingReactions.push(this),Hn())},t.runReaction_=function(){if(!this.isDisposed){Nn(),this.isScheduled=!1;var e=L.trackingContext;if(L.trackingContext=this,hn(this)){this.isTrackPending=!0;try{this.onInvalidate_()}catch(e){this.reportExceptionInDerivation_(e)}}L.trackingContext=e,Pn()}},t.track=function(e){if(!this.isDisposed){Nn(),this.isRunning=!0;var t=L.trackingContext;L.trackingContext=this;var n=gn(this,e,void 0);L.trackingContext=t,this.isRunning=!1,this.isTrackPending=!1,this.isDisposed&&vn(this),mn(n)&&this.reportExceptionInDerivation_(n.cause),Pn()}},t.reportExceptionInDerivation_=function(e){var t=this;if(this.errorHandler_){this.errorHandler_(e,this);return}if(L.disableErrorBoundaries)throw e;var n=`[mobx] uncaught error in '`+this+`'`;L.suppressReactionErrors||console.error(n,e),L.globalReactionErrorHandlers.forEach(function(n){return n(e,t)})},t.dispose=function(){this.isDisposed||(this.isDisposed=!0,this.isRunning||(Nn(),vn(this),Pn()))},t.getDisposer_=function(e){var t=this,n=function n(){t.dispose(),e==null||e.removeEventListener==null||e.removeEventListener(`abort`,n)};return e==null||e.addEventListener==null||e.addEventListener(`abort`,n),n[I]=this,`dispose`in Symbol&&typeof Symbol.dispose==`symbol`&&(n[Symbol.dispose]=n),n},t.toString=function(){return`Reaction[`+this.name_+`]`},t.trace=function(e){e===void 0&&(e=!1)},Ce(e,[{key:`isDisposed`,get:function(){return ve(this.flags_,e.isDisposedMask_)},set:function(t){this.flags_=ye(this.flags_,e.isDisposedMask_,t)}},{key:`isScheduled`,get:function(){return ve(this.flags_,e.isScheduledMask_)},set:function(t){this.flags_=ye(this.flags_,e.isScheduledMask_,t)}},{key:`isTrackPending`,get:function(){return ve(this.flags_,e.isTrackPendingMask_)},set:function(t){this.flags_=ye(this.flags_,e.isTrackPendingMask_,t)}},{key:`isRunning`,get:function(){return ve(this.flags_,e.isRunningMask_)},set:function(t){this.flags_=ye(this.flags_,e.isRunningMask_,t)}},{key:`diffValue`,get:function(){return+!!ve(this.flags_,e.diffValueMask_)},set:function(t){this.flags_=ye(this.flags_,e.diffValueMask_,t===1)}}])}();zn.isDisposedMask_=1,zn.isScheduledMask_=2,zn.isTrackPendingMask_=4,zn.isRunningMask_=8,zn.diffValueMask_=16;var Bn=100,Vn=function(e){return e()};function Hn(){L.inBatch>0||L.isRunningReactions||Vn(Un)}function Un(){L.isRunningReactions=!0;for(var e=L.pendingReactions,t=0;e.length>0;){++t===Bn&&(console.error(`[mobx] cycle in reaction: `+e[0]),e.splice(0));for(var n=e.splice(0),r=0,i=n.length;r<i;r++)n[r].runReaction_()}L.isRunningReactions=!1}var Wn=ce(`Reaction`,zn);function Gn(e){var t=Vn;Vn=function(n){return e(function(){return t(n)})}}function Kn(){return!1}function qn(e){return console.warn(`[mobx.spy] Is a no-op in production builds`),function(){}}var Jn=`action`,Yn=`action.bound`,Xn=`autoAction`,Zn=`autoAction.bound`,Qn=`<unnamed action>`,$n=et(Jn),er=et(Yn,{bound:!0}),tr=et(Xn,{autoAction:!0}),nr=et(Zn,{autoAction:!0,bound:!0});function rr(e){return function(t,n){if(P(t))return $t(t.name||Qn,t,e);if(P(n))return $t(t,n,e);if(ze(n))return(e?tr:$n).decorate_20223_(t,n);if(re(n))return Le(t,n,e?tr:$n);if(re(t))return Ie(et(e?Xn:Jn,{name:t,autoAction:e}))}}var ir=rr(!1);Object.assign(ir,$n);var ar=rr(!0);Object.assign(ar,tr),ir.bound=Ie(er),ar.bound=Ie(nr);function or(e){return en(e.name||Qn,!1,e,this,void 0)}function sr(e){return P(e)&&e.isMobxAction===!0}function cr(e,t){var n;t===void 0&&(t=A);var r=t?.name??`Autorun`,i=!t.scheduler&&!t.delay,a;if(i)a=new zn(r,function(){this.track(c)},t.onError,t.requiresObservable);else{var o=ur(t),s=!1;a=new zn(r,function(){s||(s=!0,o(function(){s=!1,a.isDisposed||a.track(c)}))},t.onError,t.requiresObservable)}function c(){e(a)}return(n=t)!=null&&(n=n.signal)!=null&&n.aborted||a.schedule_(),a.getDisposer_(t?.signal)}var lr=function(e){return e()};function ur(e){return e.scheduler?e.scheduler:e.delay?function(t){return setTimeout(t,e.delay)}:lr}function dr(e,t,n){var r;n===void 0&&(n=A);var i=n.name??`Reaction`,a=ir(i,n.onError?fr(n.onError,t):t),o=!n.scheduler&&!n.delay,s=ur(n),c=!0,l=!1,u,d=n.compareStructural?qe.structural:n.equals||qe.default,f=new zn(i,function(){c||o?p():l||(l=!0,s(p))},n.onError,n.requiresObservable);function p(){if(l=!1,!f.isDisposed){var t=!1,r=u;f.track(function(){var n=rn(!1,function(){return e(f)});t=c||!d(u,n),u=n}),(c&&n.fireImmediately||!c&&t)&&a(u,r,f),c=!1}}return(r=n)!=null&&(r=r.signal)!=null&&r.aborted||f.schedule_(),f.getDisposer_(n?.signal)}function fr(e,t){return function(){try{return t.apply(this,arguments)}catch(t){e.call(this,t)}}}var pr=`onBO`,mr=`onBUO`;function hr(e,t,n){return _r(pr,e,t,n)}function gr(e,t,n){return _r(mr,e,t,n)}function _r(e,t,n,r){var i=typeof r==`function`?Yi(t,n):Yi(t),a=P(r)?r:n,o=e+`L`;return i[o]?i[o].add(a):i[o]=new Set([a]),function(){var e=i[o];e&&(e.delete(a),e.size===0&&delete i[o])}}var vr=`never`,yr=`always`,br=`observed`;function xr(e){e.isolateGlobalState===!0&&On();var t=e.useProxies,n=e.enforceActions;if(t!==void 0&&(L.useProxies=t===yr?!0:t===vr?!1:typeof Proxy<`u`),t===`ifavailable`&&(L.verifyProxies=!0),n!==void 0){var r=n===yr?yr:n===br;L.enforceActions=r,L.allowStateChanges=!(r===!0||r===yr)}[`computedRequiresReaction`,`reactionRequiresObservable`,`observableRequiresReaction`,`disableErrorBoundaries`,`safeDescriptors`].forEach(function(t){t in e&&(L[t]=!!e[t])}),L.allowStateReads=!L.observableRequiresReaction,e.reactionScheduler&&Gn(e.reactionScheduler)}function Sr(e,t,n,r){var i=_e(t);return Qi(function(){var t=Pi(e,r)[I];me(i).forEach(function(e){t.extend_(e,i[e],n&&e in n?n[e]:!0)})}),e}function Cr(e,t){return wr(Yi(e,t))}function wr(e){var t={name:e.name_};return e.observing_&&e.observing_.length>0&&(t.dependencies=Tr(e.observing_).map(wr)),t}function Tr(e){return Array.from(new Set(e))}var Er=0,Dr=function(e){function t(){var n=e.call(this,`FLOW_CANCELLED`)||this;return Object.setPrototypeOf(n,(this instanceof t?this.constructor:void 0).prototype),n.name=`FlowCancellationError`,n}De(t,e);var n=t.prototype;return n.toString=function(){return`Error: `+this.message},t}(Pe(Error)),Or=ot(`flow`),kr=ot(`flow.bound`,{bound:!0}),Ar=Object.assign(function(e,t){if(ze(t))return Or.decorate_20223_(e,t);if(re(t))return Le(e,t,Or);var n=e,r=n.name||`<unnamed flow>`,i=function(){var e=this,t=arguments,i=++Er,a=ir(r+` - runid: `+i+` - init`,n).apply(e,t),o,s=void 0,c=new Promise(function(e,t){var n=0;o=t;function c(e){s=void 0;var o;try{o=ir(r+` - runid: `+i+` - yield `+ n++,a.next).call(a,e)}catch(e){return t(e)}u(o)}function l(e){s=void 0;var o;try{o=ir(r+` - runid: `+i+` - yield `+ n++,a.throw).call(a,e)}catch(e){return t(e)}u(o)}function u(n){if(P(n?.then)){n.then(u,t);return}return n.done?e(n.value):(s=Promise.resolve(n.value),s.then(c,l))}c(void 0)});return c.cancel=ir(r+` - runid: `+i+` - cancel`,function(){try{s&&jr(s);var e=a.return(void 0),t=Promise.resolve(e.value);t.then(N,N),jr(t),o(new Dr)}catch(e){o(e)}}),c};return i.isMobXFlow=!0,i},Or);Ar.bound=Ie(kr);function jr(e){P(e.cancel)&&e.cancel()}function Mr(e){return e?.isMobXFlow===!0}function Nr(e,t,n){var r;return wi(e)||yi(e)||cn(e)?r=Xi(e):Li(e)&&(r=Xi(e,t)),r.dehancer=typeof t==`function`?t:n,function(){r.dehancer=void 0}}function Pr(e,t,n){return P(n)?Ir(e,t,n):Fr(e,t)}function Fr(e,t){return Xi(e).intercept_(t)}function Ir(e,t,n){return Xi(e,t).intercept_(n)}function Lr(e,t){if(!e)return!1;if(t!==void 0){if(Li(e)){var n,r,i=e[I];return i.values_.has(t)||!!((n=i.lazyComputedKeys_)!=null&&n.has(t))||!!((r=i.lazyObservableKeys_)!=null&&r.has(t))}return!1}return Li(e)||!!e[I]||Ve(e)||Wn(e)||un(e)}function Rr(e){return Lr(e)}function zr(e){if(Li(e))return e[I].keys_();if(wi(e)||ki(e))return Array.from(e.keys());if(yi(e))return e.map(function(e,t){return t});C(5)}function Br(e){if(Li(e))return zr(e).map(function(t){return e[t]});if(wi(e))return zr(e).map(function(t){return e.get(t)});if(ki(e))return Array.from(e.values());if(yi(e))return e.slice();C(6)}function Vr(e){if(Li(e))return zr(e).map(function(t){return[t,e[t]]});if(wi(e))return zr(e).map(function(t){return[t,e.get(t)]});if(ki(e))return Array.from(e.entries());if(yi(e))return e.map(function(e,t){return[t,e]});C(7)}function Hr(e,t,n){if(arguments.length===2&&!ki(e)){Nn();var r=t;try{for(var i in r)Hr(e,i,r[i])}finally{Pn()}return}Li(e)?e[I].set_(t,n):wi(e)?e.set(t,n):ki(e)?e.add(t):yi(e)?(typeof t!=`number`&&(t=parseInt(t,10)),t<0&&C(`Invalid index: '`+t+`'`),Nn(),t>=e.length&&(e.length=t+1),e[t]=n,Pn()):C(8)}function Ur(e,t,n){if(Li(e))return e[I].defineProperty_(t,n);C(39)}function Wr(e,t,n,r){return P(n)?Kr(e,t,n,r):Gr(e,t,n)}function Gr(e,t,n){return Xi(e).observe_(t,n)}function Kr(e,t,n,r){return Xi(e,t).observe_(n,r)}function qr(e,t){t===void 0&&(t=void 0),Nn();try{return e.apply(t)}finally{Pn()}}function Jr(e,t,n){return arguments.length===1||t&&typeof t==`object`?Xr(e,t):Yr(e,t,n||{})}function Yr(e,t,n){var r;if(typeof n.timeout==`number`){var i=Error(`WHEN_TIMEOUT`);r=setTimeout(function(){if(!o[I].isDisposed)if(o(),n.onError)n.onError(i);else throw i},n.timeout)}n.name=`When`;var a=$t(`When-effect`,t),o=cr(function(t){rn(!1,e)&&(t.dispose(),r&&clearTimeout(r),a())},n);return o}function Xr(e,t){var n;if(t!=null&&(n=t.signal)!=null&&n.aborted)return Object.assign(Promise.reject(Error(`WHEN_ABORTED`)),{cancel:function(){return null}});var r,i,a=new Promise(function(n,a){var o,s=Yr(e,n,Te({},t,{onError:a}));r=function(){s(),a(Error(`WHEN_CANCELLED`))},i=function(){s(),a(Error(`WHEN_ABORTED`))},t==null||(o=t.signal)==null||o.addEventListener==null||o.addEventListener(`abort`,i)}).finally(function(){var e;return t==null||(e=t.signal)==null||e.removeEventListener==null?void 0:e.removeEventListener(`abort`,i)});return a.cancel=r,a}function Zr(e){return e[I]}var Qr={has:function(e,t){return Zr(e).has_(t)},get:function(e,t){return Zr(e).get_(t)},set:function(e,t,n){return re(t)?Zr(e).set_(t,n,!0)??!0:!1},deleteProperty:function(e,t){return re(t)?Zr(e).delete_(t,!0)??!0:!1},defineProperty:function(e,t,n){return Zr(e).defineProperty_(t,n)??!0},ownKeys:function(e){return Zr(e).ownKeys_()},preventExtensions:function(e){C(13)}};function $r(e,t){var n;return M(),e=Pi(e,t),(n=e[I]).proxy_??(n.proxy_=new Proxy(e,Qr))}function ei(e){return e.interceptors_!==void 0&&e.interceptors_.length>0}function ti(e,t){var n=e.interceptors_||=[];return n.push(t),ne(function(){var e=n.indexOf(t);e!==-1&&n.splice(e,1)})}function ni(e,t){var n=bn();try{for(var r=[].concat(e.interceptors_||[]),i=0,a=r.length;i<a&&(t=r[i](t),t&&!t.type&&C(14),t);i++);return t}finally{xn(n)}}function ri(e){return e.changeListeners_!==void 0&&e.changeListeners_.length>0}function ii(e,t){var n=e.changeListeners_||=[];return n.push(t),ne(function(){var e=n.indexOf(t);e!==-1&&n.splice(e,1)})}function ai(e,t){var n=bn(),r=e.changeListeners_;if(r){r=r.slice();for(var i=0,a=r.length;i<a;i++)r[i](t);xn(n)}}function oi(e,t,n){return Qi(function(){var r=Pi(e,n)[I];t??=Re(e),me(t).forEach(function(e){return r.make_(e,t[e])})}),e}var si=`splice`,ci=`update`,li=1e4,ui={get:function(e,t){var n=e[I];return t===I?n:t===`length`?n.getArrayLength_():typeof t==`string`&&!isNaN(t)?n.get_(parseInt(t)):ge(pi,t)?pi[t]:e[t]},set:function(e,t,n){var r=e[I];return t===`length`&&r.setArrayLength_(n),typeof t==`symbol`||isNaN(t)?e[t]=n:r.set_(parseInt(t),n),!0},preventExtensions:function(){C(15)}},di=function(){function e(e,t,n,r){e===void 0&&(e=`ObservableArray`),this.owned_=void 0,this.legacyMode_=void 0,this.atom_=void 0,this.values_=[],this.interceptors_=void 0,this.changeListeners_=void 0,this.enhancer_=void 0,this.dehancer=void 0,this.proxy_=void 0,this.lastKnownLength_=0,this.owned_=n,this.legacyMode_=r,this.atom_=new Be(e),this.enhancer_=function(e,n){return t(e,n,`ObservableArray[..]`)}}var t=e.prototype;return t.dehanceValue_=function(e){return this.dehancer===void 0?e:this.dehancer(e)},t.dehanceValues_=function(e){return this.dehancer!==void 0&&e.length>0?e.map(this.dehancer):e},t.intercept_=function(e){return ti(this,e)},t.observe_=function(e,t){return t===void 0&&(t=!1),t&&e({observableKind:`array`,object:this.proxy_,debugObjectName:this.atom_.name_,type:`splice`,index:0,added:this.values_.slice(),addedCount:this.values_.length,removed:[],removedCount:0}),ii(this,e)},t.getArrayLength_=function(){return this.atom_.reportObserved(),this.values_.length},t.setArrayLength_=function(e){(typeof e!=`number`||isNaN(e)||e<0)&&C(`Out of range: `+e);var t=this.values_.length;if(e!==t)if(e>t){for(var n=Array(e-t),r=0;r<e-t;r++)n[r]=void 0;this.spliceWithArray_(t,0,n)}else this.spliceWithArray_(e,t-e)},t.updateArrayLength_=function(e,t){e!==this.lastKnownLength_&&C(16),this.lastKnownLength_+=t,this.legacyMode_&&t>0&&qi(e+t+1)},t.spliceWithArray_=function(e,t,n){var r=this;this.atom_;var i=this.values_.length;if(e===void 0?e=0:e>i?e=i:e<0&&(e=Math.max(0,i+e)),t=arguments.length===1?i-e:t==null?0:Math.max(0,Math.min(t,i-e)),n===void 0&&(n=ee),ei(this)){var a=ni(this,{object:this.proxy_,type:si,index:e,removedCount:t,added:n});if(!a)return ee;t=a.removedCount,n=a.added}if(n=n.length===0?n:n.map(function(e){return r.enhancer_(e,void 0)}),this.legacyMode_){var o=n.length-t;this.updateArrayLength_(i,o)}var s=this.spliceItemsIntoValues_(e,t,n);return(t!==0||n.length!==0)&&this.notifyArraySplice_(e,n,s),this.dehanceValues_(s)},t.spliceItemsIntoValues_=function(e,t,n){if(n.length<li){var r;return(r=this.values_).splice.apply(r,[e,t].concat(n))}else{var i=this.values_.slice(e,e+t),a=this.values_.slice(e+t);this.values_.length+=n.length-t;for(var o=0;o<n.length;o++)this.values_[e+o]=n[o];for(var s=0;s<a.length;s++)this.values_[e+n.length+s]=a[s];return i}},t.notifyArrayChildUpdate_=function(e,t,n){var r=!this.owned_&&Kn(),i=ri(this),a=i||r?{observableKind:`array`,object:this.proxy_,type:ci,debugObjectName:this.atom_.name_,index:e,newValue:t,oldValue:n}:null;this.atom_.reportChanged(),i&&ai(this,a)},t.notifyArraySplice_=function(e,t,n){var r=!this.owned_&&Kn(),i=ri(this),a=i||r?{observableKind:`array`,object:this.proxy_,debugObjectName:this.atom_.name_,type:si,index:e,removed:n,added:t,removedCount:n.length,addedCount:t.length}:null;this.atom_.reportChanged(),i&&ai(this,a)},t.get_=function(e){if(this.legacyMode_&&e>=this.values_.length){console.warn(`[mobx] Out of bounds read: `+e);return}return this.atom_.reportObserved(),this.dehanceValue_(this.values_[e])},t.set_=function(e,t){var n=this.values_;if(this.legacyMode_&&e>n.length&&C(17,e,n.length),e<n.length){this.atom_;var r=n[e];if(ei(this)){var i=ni(this,{type:ci,object:this.proxy_,index:e,newValue:t});if(!i)return;t=i.newValue}t=this.enhancer_(t,r),t!==r&&(n[e]=t,this.notifyArrayChildUpdate_(e,t,r))}else{for(var a=Array(e+1-n.length),o=0;o<a.length-1;o++)a[o]=void 0;a[a.length-1]=t,this.spliceWithArray_(n.length,0,a)}},e}();function fi(e,t,n,r){return n===void 0&&(n=`ObservableArray`),r===void 0&&(r=!1),M(),Qi(function(){var i=new di(n,t,r,!1);se(i.values_,I,i);var a=new Proxy(i.values_,ui);return i.proxy_=a,e&&e.length&&i.spliceWithArray_(0,0,e),a})}var pi={clear:function(){return this.splice(0)},replace:function(e){var t=this[I];return t.spliceWithArray_(0,t.values_.length,e)},toJSON:function(){return this.slice()},splice:function(e,t){var n=[...arguments].slice(2),r=this[I];switch(arguments.length){case 0:return[];case 1:return r.spliceWithArray_(e);case 2:return r.spliceWithArray_(e,t)}return r.spliceWithArray_(e,t,n)},spliceWithArray:function(e,t,n){return this[I].spliceWithArray_(e,t,n)},push:function(){var e=this[I],t=[...arguments];return e.spliceWithArray_(e.values_.length,0,t),e.values_.length},pop:function(){return this.splice(Math.max(this[I].values_.length-1,0),1)[0]},shift:function(){return this.splice(0,1)[0]},unshift:function(){var e=this[I],t=[...arguments];return e.spliceWithArray_(0,0,t),e.values_.length},reverse:function(){return L.trackingDerivation&&C(37,`reverse`),this.replace(this.slice().reverse()),this},sort:function(){L.trackingDerivation&&C(37,`sort`);var e=this.slice();return e.sort.apply(e,arguments),this.replace(e),this},remove:function(e){var t=this[I],n=t.dehanceValues_(t.values_).indexOf(e);return n>-1?(this.splice(n,1),!0):!1}};mi(`at`,hi),mi(`concat`,hi),mi(`flat`,hi),mi(`includes`,hi),mi(`indexOf`,hi),mi(`join`,hi),mi(`lastIndexOf`,hi),mi(`slice`,hi),mi(`toString`,hi),mi(`toLocaleString`,hi),mi(`toSorted`,hi),mi(`toSpliced`,hi),mi(`with`,hi),mi(`every`,gi),mi(`filter`,gi),mi(`find`,gi),mi(`findIndex`,gi),mi(`findLast`,gi),mi(`findLastIndex`,gi),mi(`flatMap`,gi),mi(`forEach`,gi),mi(`map`,gi),mi(`some`,gi),mi(`toReversed`,gi),mi(`reduce`,_i),mi(`reduceRight`,_i);function mi(e,t){typeof Array.prototype[e]==`function`&&(pi[e]=t(e))}function hi(e){return function(){var t=this[I];t.atom_.reportObserved();var n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function gi(e){return function(t,n){var r=this,i=this[I];return i.atom_.reportObserved(),i.dehanceValues_(i.values_)[e](function(e,i){return t.call(n,e,i,r)})}}function _i(e){return function(){var t=this,n=this[I];n.atom_.reportObserved();var r=n.dehanceValues_(n.values_),i=arguments[0];return arguments[0]=function(e,n,r){return i(e,n,r,t)},r[e].apply(r,arguments)}}var vi=ce(`ObservableArrayAdministration`,di);function yi(e){return ie(e)&&vi(e[I])}var bi={},xi=`add`,Si=`delete`,Ci=function(){function e(e,t,n){var r=this;t===void 0&&(t=Je),n===void 0&&(n=`ObservableMap`),this.enhancer_=void 0,this.name_=void 0,this[I]=bi,this.data_=void 0,this.hasMap_=void 0,this.keysAtom_=void 0,this.interceptors_=void 0,this.changeListeners_=void 0,this.dehancer=void 0,this.enhancer_=t,this.name_=n,P(Map)||C(18),Qi(function(){r.keysAtom_=He(`ObservableMap.keys()`),r.data_=new Map,r.hasMap_=new Map,e&&r.merge(e)})}var t=e.prototype;return t.has_=function(e){return this.data_.has(e)},t.has=function(e){var t=this;if(!L.trackingDerivation)return this.has_(e);var n=this.hasMap_.get(e);if(!n){var r=n=new sn(this.has_(e),Xe,`ObservableMap.key?`,!1);this.hasMap_.set(e,r),gr(r,function(){return t.hasMap_.delete(e)})}return n.get()},t.set=function(e,t){var n=this.has_(e);if(ei(this)){var r=ni(this,{type:n?ci:xi,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.updateValue_(e,t):this.addValue_(e,t),this},t.delete=function(e){var t=this;if(this.keysAtom_,ei(this)&&!ni(this,{type:Si,object:this,name:e}))return!1;if(this.has_(e)){var n=Kn(),r=ri(this),i=r||n?{observableKind:`map`,debugObjectName:this.name_,type:Si,object:this,oldValue:this.data_.get(e).value_,name:e}:null;return qr(function(){var n;t.keysAtom_.reportChanged(),(n=t.hasMap_.get(e))==null||n.setNewValue_(!1),t.data_.get(e).setNewValue_(void 0),t.data_.delete(e)}),r&&ai(this,i),!0}return!1},t.updateValue_=function(e,t){var n=this.data_.get(e);if(t=n.prepareNewValue_(t),t!==L.UNCHANGED){var r=Kn(),i=ri(this),a=i||r?{observableKind:`map`,debugObjectName:this.name_,type:ci,object:this,oldValue:n.value_,name:e,newValue:t}:null;n.setNewValue_(t),i&&ai(this,a)}},t.addValue_=function(e,t){var n=this;this.keysAtom_,qr(function(){var r,i=new sn(t,n.enhancer_,`ObservableMap.key`,!1);n.data_.set(e,i),t=i.value_,(r=n.hasMap_.get(e))==null||r.setNewValue_(!0),n.keysAtom_.reportChanged()});var r=Kn(),i=ri(this),a=i||r?{observableKind:`map`,debugObjectName:this.name_,type:xi,object:this,name:e,newValue:t}:null;i&&ai(this,a)},t.get=function(e){return this.has(e)?this.dehanceValue_(this.data_.get(e).get()):this.dehanceValue_(void 0)},t.getOrInsert=function(e,t){return this.has(e)||this.set(e,t),this.get(e)},t.getOrInsertComputed=function(e,t){return this.has(e)||this.set(e,t(e)),this.get(e)},t.dehanceValue_=function(e){return this.dehancer===void 0?e:this.dehancer(e)},t.keys=function(){return this.keysAtom_.reportObserved(),this.data_.keys()},t.values=function(){var e=this,t=this.keys();return Ti({next:function(){var n=t.next(),r=n.done,i=n.value;return{done:r,value:r?void 0:e.get(i)}}})},t.entries=function(){var e=this,t=this.keys();return Ti({next:function(){var n=t.next(),r=n.done,i=n.value;return{done:r,value:r?void 0:[i,e.get(i)]}}})},t[Symbol.iterator]=function(){return this.entries()},t.forEach=function(e,t){for(var n=we(this),r;!(r=n()).done;){var i=r.value,a=i[0],o=i[1];e.call(t,o,a,this)}},t.merge=function(e){var t=this;return wi(e)&&(e=new Map(e)),qr(function(){ae(e)?pe(e).forEach(function(n){return t.set(n,e[n])}):Array.isArray(e)?e.forEach(function(e){var n=e[0],r=e[1];return t.set(n,r)}):le(e)?(ue(e)||C(19,e),e.forEach(function(e,n){return t.set(n,e)})):e!=null&&C(20,e)}),this},t.clear=function(){var e=this;qr(function(){yn(function(){for(var t=we(e.keys()),n;!(n=t()).done;){var r=n.value;e.delete(r)}})})},t.replace=function(e){var t=this;return qr(function(){for(var n=Ei(e),r=new Map,i=!1,a=we(t.data_.keys()),o;!(o=a()).done;){var s=o.value;if(!n.has(s))if(t.delete(s))i=!0;else{var c=t.data_.get(s);r.set(s,c)}}for(var l=we(n.entries()),u;!(u=l()).done;){var d=u.value,f=d[0],p=d[1],m=t.data_.has(f);if(t.set(f,p),t.data_.has(f)){var h=t.data_.get(f);r.set(f,h),m||(i=!0)}}if(!i)if(t.data_.size!==r.size)t.keysAtom_.reportChanged();else for(var g=t.data_.keys(),_=r.keys(),v=g.next(),y=_.next();!v.done;){if(v.value!==y.value){t.keysAtom_.reportChanged();break}v=g.next(),y=_.next()}t.data_=r}),this},t.toString=function(){return`[object ObservableMap]`},t.toJSON=function(){return Array.from(this)},t.observe_=function(e,t){return ii(this,e)},t.intercept_=function(e){return ti(this,e)},Ce(e,[{key:`size`,get:function(){return this.keysAtom_.reportObserved(),this.data_.size}},{key:Symbol.toStringTag,get:function(){return`Map`}}])}(),wi=ce(`ObservableMap`,Ci);function Ti(e){return e[Symbol.toStringTag]=`MapIterator`,ia(e)}function Ei(e){if(le(e)||wi(e))return e;if(Array.isArray(e))return new Map(e);if(ae(e)){var t=new Map;for(var n in e)t.set(n,e[n]);return t}else return C(21,e)}var Di={},Oi=function(){function e(e,t,n){var r=this;t===void 0&&(t=Je),n===void 0&&(n=`ObservableSet`),this.name_=void 0,this[I]=Di,this.data_=new Set,this.atom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.dehancer=void 0,this.enhancer_=void 0,this.name_=n,P(Set)||C(22),this.enhancer_=function(e,r){return t(e,r,n)},Qi(function(){r.atom_=He(r.name_),e&&r.replace(e)})}var t=e.prototype;return t.dehanceValue_=function(e){return this.dehancer===void 0?e:this.dehancer(e)},t.clear=function(){var e=this;qr(function(){yn(function(){for(var t=we(e.data_.values()),n;!(n=t()).done;){var r=n.value;e.delete(r)}})})},t.forEach=function(e,t){for(var n=we(this),r;!(r=n()).done;){var i=r.value;e.call(t,i,i,this)}},t.add=function(e){var t=this;if(this.atom_,ei(this)){var n=ni(this,{type:xi,object:this,newValue:e});if(!n)return this;e=n.newValue}if(!this.has(e)){qr(function(){t.data_.add(t.enhancer_(e,void 0)),t.atom_.reportChanged()});var r=!1,i=ri(this),a=i||r?{observableKind:`set`,debugObjectName:this.name_,type:xi,object:this,newValue:e}:null;i&&ai(this,a)}return this},t.delete=function(e){var t=this;if(ei(this)&&!ni(this,{type:Si,object:this,oldValue:e}))return!1;if(this.has(e)){var n=!1,r=ri(this),i=r||n?{observableKind:`set`,debugObjectName:this.name_,type:Si,object:this,oldValue:e}:null;return qr(function(){t.atom_.reportChanged(),t.data_.delete(e)}),r&&ai(this,i),!0}return!1},t.has=function(e){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(e))},t.entries=function(){var e=this.values();return Ai({next:function(){var t=e.next(),n=t.value,r=t.done;return r?{value:void 0,done:r}:{value:[n,n],done:r}}})},t.keys=function(){return this.values()},t.values=function(){this.atom_.reportObserved();var e=this,t=this.data_.values();return Ai({next:function(){var n=t.next(),r=n.value,i=n.done;return i?{value:void 0,done:i}:{value:e.dehanceValue_(r),done:i}}})},t.intersection=function(e){return de(e)&&!ki(e)?e.intersection(this):new Set(this).intersection(e)},t.union=function(e){return de(e)&&!ki(e)?e.union(this):new Set(this).union(e)},t.difference=function(e){return new Set(this).difference(e)},t.symmetricDifference=function(e){return de(e)&&!ki(e)?e.symmetricDifference(this):new Set(this).symmetricDifference(e)},t.isSubsetOf=function(e){return new Set(this).isSubsetOf(e)},t.isSupersetOf=function(e){return new Set(this).isSupersetOf(e)},t.isDisjointFrom=function(e){return de(e)&&!ki(e)?e.isDisjointFrom(this):new Set(this).isDisjointFrom(e)},t.replace=function(e){var t=this;return ki(e)&&(e=new Set(e)),qr(function(){Array.isArray(e)||de(e)?(t.clear(),e.forEach(function(e){return t.add(e)})):e!=null&&C(`Cannot initialize set from `+e)}),this},t.observe_=function(e,t){return ii(this,e)},t.intercept_=function(e){return ti(this,e)},t.toJSON=function(){return Array.from(this)},t.toString=function(){return`[object ObservableSet]`},t[Symbol.iterator]=function(){return this.values()},Ce(e,[{key:`size`,get:function(){return this.atom_.reportObserved(),this.data_.size}},{key:Symbol.toStringTag,get:function(){return`Set`}}])}(),ki=ce(`ObservableSet`,Oi);function Ai(e){return e[Symbol.toStringTag]=`SetIterator`,ia(e)}var ji=Object.create(null),Mi=`remove`,Ni=function(){function e(e,t,n,r){t===void 0&&(t=new Map),r===void 0&&(r=Ct),this.target_=void 0,this.values_=void 0,this.name_=void 0,this.defaultAnnotation_=void 0,this.keysAtom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.proxy_=void 0,this.isPlainObject_=void 0,this.appliedAnnotations_=void 0,this.pendingKeys_=void 0,this.lazyComputedKeys_=void 0,this.lazyObservableKeys_=void 0,this.target_=e,this.values_=t,this.name_=n,this.defaultAnnotation_=r,this.keysAtom_=new Be(`ObservableObject.keys`),this.isPlainObject_=ae(this.target_)}var t=e.prototype;return t.getObservablePropValue_=function(e){return(this.values_.get(e)??this.materializeLazyComputed_(e)??this.materializeLazyObservable_(e)).get()},t.materializeLazyComputed_=function(e){var t=this.lazyComputedKeys_?.get(e);if(t){this.lazyComputedKeys_.delete(e),this.lazyComputedKeys_.size===0&&(this.lazyComputedKeys_=void 0);var n=t();return this.values_.set(e,n),n}},t.materializeLazyObservable_=function(e){var t=this.lazyObservableKeys_?.get(e);if(t){this.lazyObservableKeys_.delete(e),this.lazyObservableKeys_.size===0&&(this.lazyObservableKeys_=void 0);var n=t();return this.values_.set(e,n),n}},t.setObservablePropValue_=function(e,t){var n=this.values_.get(e)??this.materializeLazyComputed_(e)??this.materializeLazyObservable_(e);if(n instanceof ln)return n.set(t),!0;if(ei(this)){var r=ni(this,{type:ci,object:this.proxy_||this.target_,name:e,newValue:t});if(!r)return null;t=r.newValue}if(t=n.prepareNewValue_(t),t!==L.UNCHANGED){var i=ri(this),a=i?{type:ci,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:n.value_,name:e,newValue:t}:null;n.setNewValue_(t),i&&ai(this,a)}return!0},t.get_=function(e){return L.trackingDerivation&&!ge(this.target_,e)&&this.has_(e),this.target_[e]},t.set_=function(e,t,n){return n===void 0&&(n=!1),ge(this.target_,e)?this.values_.has(e)?this.setObservablePropValue_(e,t):n?Reflect.set(this.target_,e,t):(this.target_[e]=t,!0):this.extend_(e,{value:t,enumerable:!0,writable:!0,configurable:!0},this.defaultAnnotation_,n)},t.has_=function(e){if(!L.trackingDerivation)return e in this.target_;this.pendingKeys_||=new Map;var t=this.pendingKeys_.get(e);return t||(t=new sn(e in this.target_,Xe,`ObservableObject.key?`,!1),this.pendingKeys_.set(e,t)),t.get()},t.make_=function(e,t){if(t===!0&&(t=this.defaultAnnotation_),t!==!1){if(!(e in this.target_)){var n;if((n=this.target_[Fe])!=null&&n[e])return;C(1,t.annotationType_,this.name_+`.`+e.toString())}for(var r=this.target_;r&&r!==k;){var i=D(r,e);if(i){var a=t.make_(this,e,i,r);if(a===0)return;if(a===1)break}r=Object.getPrototypeOf(r)}Ri(this,t,e)}},t.extend_=function(e,t,n,r){if(r===void 0&&(r=!1),n===!0&&(n=this.defaultAnnotation_),n===!1)return this.defineProperty_(e,t,r);var i=n.extend_(this,e,t,r);return i&&Ri(this,n,e),i},t.defineProperty_=function(e,t,n){n===void 0&&(n=!1),this.keysAtom_;try{Nn();var r=this.delete_(e);if(!r)return r;if(ei(this)){var i=ni(this,{object:this.proxy_||this.target_,name:e,type:xi,newValue:t.value});if(!i)return null;var a=i.newValue;t.value!==a&&(t=Te({},t,{value:a}))}if(n){if(!Reflect.defineProperty(this.target_,e,t))return!1}else O(this.target_,e,t);this.notifyPropertyAddition_(e,t.value)}finally{Pn()}return!0},t.defineObservableProperty_=function(e,t,n,r){r===void 0&&(r=!1),this.keysAtom_;try{Nn();var i=this.delete_(e);if(!i)return i;if(ei(this)){var a=ni(this,{object:this.proxy_||this.target_,name:e,type:xi,newValue:t});if(!a)return null;t=a.newValue}var o=Ii(e),s={configurable:L.safeDescriptors?this.isPlainObject_:!0,enumerable:!0,get:o.get,set:o.set};if(r){if(!Reflect.defineProperty(this.target_,e,s))return!1}else O(this.target_,e,s);var c=new sn(t,n,`ObservableObject.key`,!1);this.values_.set(e,c),this.notifyPropertyAddition_(e,c.value_)}finally{Pn()}return!0},t.defineComputedProperty_=function(e,t,n){n===void 0&&(n=!1),this.keysAtom_;try{Nn();var r=this.delete_(e);if(!r)return r;if(ei(this)&&!ni(this,{object:this.proxy_||this.target_,name:e,type:xi,newValue:void 0}))return null;t.name||=`ObservableObject.key`,t.context=this.proxy_||this.target_;var i=Ii(e),a={configurable:L.safeDescriptors?this.isPlainObject_:!0,enumerable:!1,get:i.get,set:i.set};if(n){if(!Reflect.defineProperty(this.target_,e,a))return!1}else O(this.target_,e,a);this.values_.set(e,new ln(t)),this.notifyPropertyAddition_(e,void 0)}finally{Pn()}return!0},t.delete_=function(e,t){if(t===void 0&&(t=!1),this.keysAtom_,!ge(this.target_,e))return!0;if(ei(this)&&!ni(this,{object:this.proxy_||this.target_,name:e,type:Mi}))return null;try{var n;Nn();var r=ri(this),i=!1,a=this.values_.get(e),o=void 0;if(!a&&(r||i)&&(o=D(this.target_,e)?.value),t){if(!Reflect.deleteProperty(this.target_,e))return!1}else delete this.target_[e];if(a&&(this.values_.delete(e),a instanceof sn&&(o=a.value_),In(a)),this.keysAtom_.reportChanged(),(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(e in this.target_),r||i){var s={type:Mi,observableKind:`object`,object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:o,name:e};r&&ai(this,s)}}finally{Pn()}return!0},t.observe_=function(e,t){return ii(this,e)},t.intercept_=function(e){return ti(this,e)},t.notifyPropertyAddition_=function(e,t){var n,r=ri(this),i=!1;if(r||i){var a=r||i?{type:xi,observableKind:`object`,debugObjectName:this.name_,object:this.proxy_||this.target_,name:e,newValue:t}:null;r&&ai(this,a)}(n=this.pendingKeys_)==null||(n=n.get(e))==null||n.set(!0),this.keysAtom_.reportChanged()},t.ownKeys_=function(){return this.keysAtom_.reportObserved(),me(this.target_)},t.keys_=function(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)},e}();function Pi(e,t){if(ge(e,I))return e;var n=t?.name??`ObservableObject`;return oe(e,I,new Ni(e,new Map,String(n),Bt(t))),e}var Fi=ce(`ObservableObjectAdministration`,Ni);function Ii(e){return ji[e]||(ji[e]={get:function(){return this[I].getObservablePropValue_(e)},set:function(t){return this[I].setObservablePropValue_(e,t)}})}function Li(e){return ie(e)?Fi(e[I]):!1}function Ri(e,t,n){var r;(r=e.target_[Fe])==null||delete r[n]}var zi=Gi(0),Bi=function(){var e=!1,t={};return Object.defineProperty(t,"0",{set:function(){e=!0}}),Object.create(t)[0]=1,e===!1}(),Vi=0,Hi=function(){};function Ui(e,t){Object.setPrototypeOf?Object.setPrototypeOf(e.prototype,t):e.prototype.__proto__===void 0?e.prototype=t:e.prototype.__proto__=t}Ui(Hi,Array.prototype);var Wi=function(e){function t(t,n,r,i){var a;return r===void 0&&(r=`ObservableArray`),i===void 0&&(i=!1),a=e.call(this)||this,Qi(function(){var e=new di(r,n,i,!0);e.proxy_=a,se(a,I,e),t&&t.length&&a.spliceWithArray(0,0,t),Bi&&Object.defineProperty(a,"0",zi)}),a}De(t,e);var n=t.prototype;return n.concat=function(){this[I].atom_.reportObserved();var e=[...arguments];return Array.prototype.concat.apply(this.slice(),e.map(function(e){return yi(e)?e.slice():e}))},n[Symbol.iterator]=function(){var e=this,t=0;return ia({next:function(){return t<e.length?{value:e[t++],done:!1}:{done:!0,value:void 0}}})},Ce(t,[{key:`length`,get:function(){return this[I].getArrayLength_()},set:function(e){this[I].setArrayLength_(e)}},{key:Symbol.toStringTag,get:function(){return`Array`}}])}(Hi);Object.entries(pi).forEach(function(e){var t=e[0],n=e[1];t!==`concat`&&oe(Wi.prototype,t,n)});function Gi(e){return{enumerable:!1,configurable:!0,get:function(){return this[I].get_(e)},set:function(t){this[I].set_(e,t)}}}function Ki(e){O(Wi.prototype,``+e,Gi(e))}function qi(e){if(e>Vi){for(var t=Vi;t<e+100;t++)Ki(t);Vi=e}}qi(1e3);function Ji(e,t,n){return new Wi(e,t,n)}function Yi(e,t){if(typeof e==`object`&&e){if(yi(e))return t!==void 0&&C(23),e[I].atom_;if(ki(e))return e.atom_;if(wi(e)){if(t===void 0)return e.keysAtom_;var n=e.data_.get(t)||e.hasMap_.get(t);return n||C(25,t,Zi(e)),n}if(Li(e)){if(!t)return C(26);var r=e[I],i=r.values_.get(t)??r.materializeLazyComputed_(t)??r.materializeLazyObservable_(t);return i||C(27,t,Zi(e)),i}if(Ve(e)||un(e)||Wn(e))return e}else if(P(e)&&Wn(e[I]))return e[I];C(28)}function Xi(e,t){if(e||C(29),t!==void 0)return Xi(Yi(e,t));if(Ve(e)||un(e)||Wn(e)||wi(e)||ki(e))return e;if(e[I])return e[I];C(24,e)}function Zi(e,t){var n;if(t!==void 0)n=Yi(e,t);else if(sr(e))return e.name;else n=Li(e)||wi(e)||ki(e)?Xi(e):Yi(e);return n.name_}function Qi(e){var t=bn(),n=an(!0);Nn();try{return e()}finally{Pn(),on(n),xn(t)}}var $i=k.toString;function ea(e,t,n){return n===void 0&&(n=-1),ta(e,t,n)}function ta(e,t,n,r,i){if(e===t)return e!==0||1/e==1/t;if(e==null||t==null)return!1;if(e!==e)return t!==t;var a=typeof e;if(a!==`function`&&a!==`object`&&typeof t!=`object`)return!1;var o=$i.call(e);if(o!==$i.call(t))return!1;switch(o){case`[object RegExp]`:case`[object String]`:return``+e==``+t;case`[object Number]`:return+e==+e?+e==0?1/e==1/t:+e==+t:+t!=+t;case`[object Date]`:case`[object Boolean]`:return+e==+t;case`[object Symbol]`:return typeof Symbol<`u`&&Symbol.valueOf.call(e)===Symbol.valueOf.call(t);case`[object Map]`:case`[object Set]`:n>=0&&n++;break}e=na(e),t=na(t);var s=o===`[object Array]`;if(!s){if(typeof e!=`object`||typeof t!=`object`)return!1;var c=e.constructor,l=t.constructor;if(c!==l&&!(P(c)&&c instanceof c&&P(l)&&l instanceof l)&&`constructor`in e&&`constructor`in t)return!1}if(n===0)return!1;n<0&&(n=-1),r||=[],i||=[];for(var u=r.length;u--;)if(r[u]===e)return i[u]===t;if(r.push(e),i.push(t),s){if(u=e.length,u!==t.length)return!1;for(;u--;)if(!ta(e[u],t[u],n-1,r,i))return!1}else{var d=Object.keys(e),f=d.length;if(Object.keys(t).length!==f)return!1;for(var p=0;p<f;p++){var m=d[p];if(!(ge(t,m)&&ta(e[m],t[m],n-1,r,i)))return!1}}return r.pop(),i.pop(),!0}function na(e){return yi(e)?e.slice():le(e)||wi(e)||de(e)||ki(e)?Array.from(e.entries()):e}var ra=T().Iterator?.prototype||{};function ia(e){return e[Symbol.iterator]=aa,Object.assign(Object.create(ra),e)}function aa(){return this}if([`Symbol`,`Map`,`Set`].forEach(function(e){T()[e]===void 0&&C(`MobX requires global '`+e+`' to be available or polyfilled`)}),typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__==`object`&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:qn,extras:{getDebugName:Zi},$mobx:I}),!b.useState)throw Error(`mobx-react-lite requires React with Hooks support`);if(!oi)throw Error(`mobx-react-lite@3 requires mobx at least version 6 to be available`);var oa=h();function sa(e){e()}function ca(e){e||=sa,xr({reactionScheduler:e})}function la(e){return Cr(e)}var ua=!1;function da(){return ua}var fa=1e4,pa=1e4,ma=function(){function e(e){var t=this;Object.defineProperty(this,"finalize",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"registrations",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"sweepTimeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sweep",{enumerable:!0,configurable:!0,writable:!0,value:function(e){e===void 0&&(e=fa),clearTimeout(t.sweepTimeout),t.sweepTimeout=void 0;var n=Date.now();t.registrations.forEach(function(r,i){n-r.registeredAt>=e&&(t.finalize(r.value),t.registrations.delete(i))}),t.registrations.size>0&&t.scheduleSweep()}}),Object.defineProperty(this,"finalizeAllImmediately",{enumerable:!0,configurable:!0,writable:!0,value:function(){t.sweep(0)}})}return Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){this.registrations.set(n,{value:t,registeredAt:Date.now()}),this.scheduleSweep()}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.registrations.delete(e)}}),Object.defineProperty(e.prototype,"scheduleSweep",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.sweepTimeout===void 0&&(this.sweepTimeout=setTimeout(this.sweep,pa))}}),e}(),ha=new(typeof FinalizationRegistry<`u`?FinalizationRegistry:ma)(function(e){var t;(t=e.reaction)==null||t.dispose(),e.reaction=null}),ga=o((e=>{var t=d();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),_a=o(((e,t)=>{t.exports=ga()}))();function va(e){e.reaction=new zn(`observer${e.name}`,function(){var t;e.stateVersion=Symbol(),(t=e.onStoreChange)==null||t.call(e)})}function ya(e,t){if(t===void 0&&(t=`observed`),da())return e();var n=b.useRef(null);if(!n.current){var r={reaction:null,onStoreChange:null,stateVersion:Symbol(),name:t,subscribe:function(e){return ha.unregister(r),r.onStoreChange=e,r.reaction||(va(r),r.stateVersion=Symbol()),function(){var e;r.onStoreChange=null,(e=r.reaction)==null||e.dispose(),r.reaction=null}},getSnapshot:function(){return r.stateVersion}};n.current=r}var i=n.current;i.reaction||(va(i),ha.register(n,i,i)),b.useDebugValue(i.reaction,la),(0,_a.useSyncExternalStore)(i.subscribe,i.getSnapshot,i.getSnapshot);var a,o;if(i.reaction.track(function(){try{a=e()}catch(e){o=e}}),o)throw o;return a}var ba=typeof Symbol==`function`&&Symbol.for,xa=Object.getOwnPropertyDescriptor(function(){},`name`)?.configurable??!1,Sa=ba?Symbol.for(`react.forward_ref`):typeof b.forwardRef==`function`&&(0,b.forwardRef)(function(e){return null}).$$typeof,Ca=ba?Symbol.for(`react.memo`):typeof b.memo==`function`&&(0,b.memo)(function(e){return null}).$$typeof;function wa(e,t){if(Ca&&e.$$typeof===Ca)throw Error("[mobx-react-lite] You are trying to use `observer` on a function component wrapped in either another `observer` or `React.memo`. The observer already applies 'React.memo' for you.");if(da())return e;var n=t?.forwardRef??!1,r=e,i=e.displayName||e.name;if(Sa&&e.$$typeof===Sa&&(n=!0,r=e.render,typeof r!=`function`))throw Error("[mobx-react-lite] `render` property of ForwardRef was not a function");var a=function(e,t){return ya(function(){return r(e,t)},i)};return a.displayName=e.displayName,xa&&Object.defineProperty(a,"name",{value:e.name,writable:!0,configurable:!0}),e.contextTypes&&(a.contextTypes=e.contextTypes),n&&(a=(0,b.forwardRef)(a)),a=(0,b.memo)(a),Ea(e,a),a}var Ta={$$typeof:!0,render:!0,compare:!0,type:!0,displayName:!0};function Ea(e,t){Object.keys(e).forEach(function(n){Ta[n]||Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))})}function Da(e){var t=e.children,n=e.render;t&&n&&console.error("MobX Observer: Do not use children and render in the same time in `Observer`");var r=t||n;return typeof r==`function`?ya(r):null}Da.displayName=`Observer`;function Oa(e,t){return(0,b.useState)(function(){return Ut(e(),t,{autoBind:!0})})[0]}ca(oa.unstable_batchedUpdates),ha.finalizeAllImmediately;var ka=Math.PI/180;function Aa(){return typeof window<`u`&&({}.toString.call(window)===`[object Window]`||{}.toString.call(window)===`[object global]`)}var ja=typeof global<`u`?global:typeof window<`u`?window:typeof WorkerGlobalScope<`u`?self:{},R={_global:ja,version:`10.3.0`,isBrowser:Aa(),isUnminified:/param/.test(function(e){}.toString()),dblClickWindow:400,getAngle(e){return R.angleDeg?e*ka:e},enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,_renderBackend:`web`,legacyTextRendering:!1,pixelRatio:typeof window<`u`&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return R.DD.isDragging},isTransforming(){return R.Transformer?.isTransforming()??!1},isDragReady(){return!!R.DD.node},releaseCanvasOnDestroy:!0,document:ja.document,_injectGlobal(e){ja.Konva!==void 0&&console.error(`Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.`),ja.Konva=e}},Ma=e=>{R[e.prototype.getClassName()]=e};R._injectGlobal(R);var Na=`Konva.js unsupported environment.
|
|
13
|
+
|
|
14
|
+
Looks like you are trying to use Konva.js in Node.js environment. because "document" object is undefined.
|
|
15
|
+
|
|
16
|
+
To use Konva.js in Node.js environment, you need to use the "canvas-backend" or "skia-backend" module.
|
|
17
|
+
|
|
18
|
+
bash: npm install canvas
|
|
19
|
+
js: import "konva/canvas-backend";
|
|
20
|
+
|
|
21
|
+
or
|
|
22
|
+
|
|
23
|
+
bash: npm install skia-canvas
|
|
24
|
+
js: import "konva/skia-backend";
|
|
25
|
+
`,Pa=()=>{if(typeof document>`u`)throw Error(Na)},Fa=class e{constructor(e=[1,0,0,1,0,0]){this.dirty=!1,this.m=e&&e.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new e(this.m)}copyInto(e){e.m[0]=this.m[0],e.m[1]=this.m[1],e.m[2]=this.m[2],e.m[3]=this.m[3],e.m[4]=this.m[4],e.m[5]=this.m[5]}point(e){let t=this.m;return{x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}translate(e,t){return this.m[4]+=this.m[0]*e+this.m[2]*t,this.m[5]+=this.m[1]*e+this.m[3]*t,this}scale(e,t){return this.m[0]*=e,this.m[1]*=e,this.m[2]*=t,this.m[3]*=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.m[0]*t+this.m[2]*n,i=this.m[1]*t+this.m[3]*n,a=this.m[0]*-n+this.m[2]*t,o=this.m[1]*-n+this.m[3]*t;return this.m[0]=r,this.m[1]=i,this.m[2]=a,this.m[3]=o,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(e,t){let n=this.m[0]+this.m[2]*t,r=this.m[1]+this.m[3]*t,i=this.m[2]+this.m[0]*e,a=this.m[3]+this.m[1]*e;return this.m[0]=n,this.m[1]=r,this.m[2]=i,this.m[3]=a,this}multiply(e){let t=this.m[0]*e.m[0]+this.m[2]*e.m[1],n=this.m[1]*e.m[0]+this.m[3]*e.m[1],r=this.m[0]*e.m[2]+this.m[2]*e.m[3],i=this.m[1]*e.m[2]+this.m[3]*e.m[3],a=this.m[0]*e.m[4]+this.m[2]*e.m[5]+this.m[4],o=this.m[1]*e.m[4]+this.m[3]*e.m[5]+this.m[5];return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=i,this.m[4]=a,this.m[5]=o,this}invert(){let e=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),t=this.m[3]*e,n=-this.m[1]*e,r=-this.m[2]*e,i=this.m[0]*e,a=e*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),o=e*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=i,this.m[4]=a,this.m[5]=o,this}getMatrix(){return this.m}decompose(){let e=this.m[0],t=this.m[1],n=this.m[2],r=this.m[3],i=this.m[4],a=this.m[5],o=e*r-t*n,s={x:i,y:a,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(e!=0||t!=0){let i=Math.sqrt(e*e+t*t);s.rotation=t>0?Math.acos(e/i):-Math.acos(e/i),s.scaleX=i,s.scaleY=o/i,s.skewX=(e*n+t*r)/o,s.skewY=0}else if(n!=0||r!=0){let i=Math.sqrt(n*n+r*r);s.rotation=Math.PI/2-(r>0?Math.acos(-n/i):-Math.acos(n/i)),s.scaleX=o/i,s.scaleY=i,s.skewX=0,s.skewY=(e*n+t*r)/o}return s.rotation=z._getRotation(s.rotation),s}},Ia=`[object Array]`,La=`[object Number]`,Ra=`[object String]`,za=`[object Boolean]`,Ba=Math.PI/180,Va=180/Math.PI,Ha=`#`,Ua=``,Wa=`0`,Ga=`Konva warning: `,Ka=`Konva error: `,qa=`rgb(`,Ja={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},Ya=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,Xa=[],Za=null,Qa=typeof requestAnimationFrame<`u`&&requestAnimationFrame||function(e){setTimeout(e,16)},z={_isElement(e){return!!(e&&e.nodeType==1)},_isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)},_isPlainObject(e){return!!e&&e.constructor===Object},_isArray(e){return Object.prototype.toString.call(e)===Ia},_isNumber(e){return Object.prototype.toString.call(e)===La&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===Ra},_isBoolean(e){return Object.prototype.toString.call(e)===za},isObject(e){return e instanceof Object},isValidSelector(e){if(typeof e!=`string`)return!1;let t=e[0];return t===`#`||t===`.`||t===t.toUpperCase()},_sign(e){return e===0||e>0?1:-1},requestAnimFrame(e){Xa.push(e),Xa.length===1&&Qa(function(){let e=Xa;Xa=[],e.forEach(function(e){e()})})},createCanvasElement(){Pa();let e=document.createElement(`canvas`);try{e.style=e.style||{}}catch{}return e},createImageElement(){return Pa(),document.createElement(`img`)},_isInDocument(e){for(;e=e.parentNode;)if(e==document)return!0;return!1},_urlToImage(e,t){let n=z.createImageElement();n.onload=function(){t(n)},n.src=e},_rgbToHex(e,t,n){return((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)},_hexToRgb(e){e=e.replace(Ha,Ua);let t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:t&255}},getRandomColor(){let e=(Math.random()*16777215<<0).toString(16);for(;e.length<6;)e=Wa+e;return Ha+e},isCanvasFarblingActive(){if(Za!==null)return Za;if(typeof document>`u`)return Za=!1,!1;let e=this.createCanvasElement();e.width=10,e.height=10;let t=e.getContext(`2d`,{willReadFrequently:!0});t.clearRect(0,0,10,10),t.fillStyle=`#282828`,t.fillRect(0,0,10,10);let n=t.getImageData(0,0,10,10).data,r=!1;for(let e=0;e<100;e++)if(n[e*4]!==40||n[e*4+1]!==40||n[e*4+2]!==40||n[e*4+3]!==255){r=!0;break}return Za=r,this.releaseCanvas(e),Za},getHitColor(){let e=this.getRandomColor();return this.isCanvasFarblingActive()?this.getSnappedHexColor(e):e},getHitColorKey(e,t,n){return this.isCanvasFarblingActive()&&(e=Math.round(e/5)*5,t=Math.round(t/5)*5,n=Math.round(n/5)*5),Ha+this._rgbToHex(e,t,n)},getSnappedHexColor(e){let t=this._hexToRgb(e);return Ha+this._rgbToHex(Math.round(t.r/5)*5,Math.round(t.g/5)*5,Math.round(t.b/5)*5)},getRGB(e){let t;return e in Ja?(t=Ja[e],{r:t[0],g:t[1],b:t[2]}):e[0]===Ha?this._hexToRgb(e.substring(1)):e.substr(0,4)===qa?(t=Ya.exec(e.replace(/ /g,``)),{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)}):{r:0,g:0,b:0}},colorToRGBA(e){return e||=`black`,z._namedColorToRBA(e)||z._hex3ColorToRGBA(e)||z._hex4ColorToRGBA(e)||z._hex6ColorToRGBA(e)||z._hex8ColorToRGBA(e)||z._rgbColorToRGBA(e)||z._rgbaColorToRGBA(e)||z._hslColorToRGBA(e)},_namedColorToRBA(e){let t=Ja[e.toLowerCase()];return t?{r:t[0],g:t[1],b:t[2],a:1}:null},_rgbColorToRGBA(e){if(e.indexOf(`rgb(`)===0){e=e.match(/rgb\(([^)]+)\)/)[1];let t=e.split(/ *, */).map(Number);return{r:t[0],g:t[1],b:t[2],a:1}}},_rgbaColorToRGBA(e){if(e.indexOf(`rgba(`)===0){e=e.match(/rgba\(([^)]+)\)/)[1];let t=e.split(/ *, */).map((e,t)=>e.slice(-1)===`%`?t===3?parseInt(e)/100:parseInt(e)/100*255:Number(e));return{r:t[0],g:t[1],b:t[2],a:t[3]}}},_hex8ColorToRGBA(e){if(e[0]===`#`&&e.length===9)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if(e[0]===`#`&&e.length===7)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if(e[0]===`#`&&e.length===5)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if(e[0]===`#`&&e.length===4)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(e)){let[t,...n]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e),r=Number(n[0])/360,i=Number(n[1])/100,a=Number(n[2])/100,o,s,c;if(i===0)return c=a*255,{r:Math.round(c),g:Math.round(c),b:Math.round(c),a:1};o=a<.5?a*(1+i):a+i-a*i;let l=2*a-o,u=[0,0,0];for(let e=0;e<3;e++)s=r+1/3*-(e-1),s<0&&s++,s>1&&s--,c=6*s<1?l+(o-l)*6*s:2*s<1?o:3*s<2?l+(o-l)*(2/3-s)*6:l,u[e]=c*255;return{r:Math.round(u[0]),g:Math.round(u[1]),b:Math.round(u[2]),a:1}}},haveIntersection(e,t){return!(t.x>e.x+e.width||t.x+t.width<e.x||t.y>e.y+e.height||t.y+t.height<e.y)},cloneObject(e){let t={};for(let n in e)this._isPlainObject(e[n])?t[n]=this.cloneObject(e[n]):this._isArray(e[n])?t[n]=this.cloneArray(e[n]):t[n]=e[n];return t},cloneArray(e){return e.slice(0)},degToRad(e){return e*Ba},radToDeg(e){return e*Va},_degToRad(e){return z.warn(`Util._degToRad is removed. Please use public Util.degToRad instead.`),z.degToRad(e)},_radToDeg(e){return z.warn(`Util._radToDeg is removed. Please use public Util.radToDeg instead.`),z.radToDeg(e)},_getRotation(e){return R.angleDeg?z.radToDeg(e):e},_capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)},throw(e){throw Error(Ka+e)},error(e){console.error(Ka+e)},warn(e){R.showWarnings&&console.warn(Ga+e)},each(e,t){for(let n in e)t(n,e[n])},_inRange(e,t,n){return t<=e&&e<n},_getProjectionToSegment(e,t,n,r,i,a){let o,s,c,l=(e-n)*(e-n)+(t-r)*(t-r);if(l==0)o=e,s=t,c=(i-n)*(i-n)+(a-r)*(a-r);else{let u=((i-e)*(n-e)+(a-t)*(r-t))/l;u<0?(o=e,s=t,c=(e-i)*(e-i)+(t-a)*(t-a)):u>1?(o=n,s=r,c=(n-i)*(n-i)+(r-a)*(r-a)):(o=e+u*(n-e),s=t+u*(r-t),c=(o-i)*(o-i)+(s-a)*(s-a))}return[o,s,c]},_getProjectionToLine(e,t,n){let r=z.cloneObject(e),i=Number.MAX_VALUE;return t.forEach(function(a,o){if(!n&&o===t.length-1)return;let s=t[(o+1)%t.length],c=z._getProjectionToSegment(a.x,a.y,s.x,s.y,e.x,e.y),l=c[0],u=c[1],d=c[2];d<i&&(r.x=l,r.y=u,i=d)}),r},_prepareArrayForTween(e,t,n){let r=[],i=[];if(e.length>t.length){let n=t;t=e,e=n}for(let t=0;t<e.length;t+=2)r.push({x:e[t],y:e[t+1]});for(let e=0;e<t.length;e+=2)i.push({x:t[e],y:t[e+1]});let a=[];return i.forEach(function(e){let t=z._getProjectionToLine(e,r,n);a.push(t.x),a.push(t.y)}),a},_prepareToStringify(e){let t;e.visitedByCircularReferenceRemoval=!0;for(let n in e)if(e.hasOwnProperty(n)&&e[n]&&typeof e[n]==`object`){if(t=Object.getOwnPropertyDescriptor(e,n),e[n].visitedByCircularReferenceRemoval||z._isElement(e[n]))if(t.configurable)delete e[n];else return null;else if(z._prepareToStringify(e[n])===null)if(t.configurable)delete e[n];else return null}return delete e.visitedByCircularReferenceRemoval,e},_assign(e,t){for(let n in t)e[n]=t[n];return e},_getFirstPointerId(e){return e.touches?e.changedTouches[0].identifier:e.pointerId||999},releaseCanvas(...e){R.releaseCanvasOnDestroy&&e.forEach(e=>{e.width=0,e.height=0})},drawRoundedRectPath(e,t,n,r){let i=t<0?t:0,a=n<0?n:0;t=Math.abs(t),n=Math.abs(n);let o=0,s=0,c=0,l=0;typeof r==`number`?o=s=c=l=Math.min(r,t/2,n/2):(o=Math.min(r[0]||0,t/2,n/2),s=Math.min(r[1]||0,t/2,n/2),l=Math.min(r[2]||0,t/2,n/2),c=Math.min(r[3]||0,t/2,n/2)),e.moveTo(i+o,a),e.lineTo(i+t-s,a),e.arc(i+t-s,a+s,s,Math.PI*3/2,0,!1),e.lineTo(i+t,a+n-l),e.arc(i+t-l,a+n-l,l,0,Math.PI/2,!1),e.lineTo(i+c,a+n),e.arc(i+c,a+n-c,c,Math.PI/2,Math.PI,!1),e.lineTo(i,a+o),e.arc(i+o,a+o,o,Math.PI,Math.PI*3/2,!1)},drawRoundedPolygonPath(e,t,n,r,i){r=Math.abs(r);for(let a=0;a<n;a++){let o=t[(a-1+n)%n],s=t[a],c=t[(a+1)%n],l={x:s.x-o.x,y:s.y-o.y},u={x:c.x-s.x,y:c.y-s.y},d=Math.hypot(l.x,l.y),f=Math.hypot(u.x,u.y),p;p=typeof i==`number`?i:a<i.length?i[a]:0,p=r*Math.cos(Math.PI/n)*Math.min(1,p/r*2);let m={x:l.x/d,y:l.y/d},h={x:u.x/f,y:u.y/f},g={x:s.x-m.x*p,y:s.y-m.y*p},_={x:s.x+h.x*p,y:s.y+h.y*p};a===0?e.moveTo(g.x,g.y):e.lineTo(g.x,g.y),e.arcTo(s.x,s.y,_.x,_.y,p)}}};function $a(e){let t=[],n=e.length,r=z;for(let i=0;i<n;i++){let n=e[i];r._isNumber(n)?n=Math.round(n*1e3)/1e3:r._isString(n)||(n+=``),t.push(n)}return t}var eo=`,`,to=`(`,no=`)`,ro=`([`,io=`])`,ao=`;`,oo=`()`,so=`=`,co=`arc.arcTo.beginPath.bezierCurveTo.clearRect.clip.closePath.createLinearGradient.createPattern.createRadialGradient.drawImage.ellipse.fill.fillText.getImageData.createImageData.lineTo.moveTo.putImageData.quadraticCurveTo.rect.roundRect.restore.rotate.save.scale.setLineDash.setTransform.stroke.strokeText.transform.translate`.split(`.`),lo=[`fillStyle`,`strokeStyle`,`shadowColor`,`shadowBlur`,`shadowOffsetX`,`shadowOffsetY`,`letterSpacing`,`lineCap`,`lineDashOffset`,`lineJoin`,`lineWidth`,`miterLimit`,`direction`,`font`,`textAlign`,`textBaseline`,`globalAlpha`,`globalCompositeOperation`,`imageSmoothingEnabled`,`filter`],uo=100,fo=null;function po(){if(fo!==null)return fo;try{let e=z.createCanvasElement().getContext(`2d`);return e?!!e&&`filter`in e:(fo=!1,!1)}catch{return fo=!1,!1}}var mo=class{constructor(e){this.canvas=e,R.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(e){e.fillEnabled()&&this._fill(e)}_fill(e){}strokeShape(e){e.hasStroke()&&this._stroke(e)}_stroke(e){}fillStrokeShape(e){e.attrs.fillAfterStrokeEnabled?(this.strokeShape(e),this.fillShape(e)):(this.fillShape(e),this.strokeShape(e))}getTrace(e,t){let n=this.traceArr,r=n.length,i=``,a,o,s,c;for(a=0;a<r;a++)o=n[a],s=o.method,s?(c=o.args,i+=s,e?i+=oo:z._isArray(c[0])?i+=ro+c.join(eo)+io:(t&&(c=c.map(e=>typeof e==`number`?Math.floor(e):e)),i+=to+c.join(eo)+no)):(i+=o.property,e||(i+=so+o.val)),i+=ao;return i}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=uo&&t.shift()}reset(){let e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){let t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_applyLineCap(e){let t=e.attrs.lineCap;t&&this.setAttr(`lineCap`,t)}_applyOpacity(e){let t=e.getAbsoluteOpacity();t!==1&&this.setAttr(`globalAlpha`,t)}_applyLineJoin(e){let t=e.attrs.lineJoin;t&&this.setAttr(`lineJoin`,t)}_applyMiterLimit(e){let t=e.attrs.miterLimit;t!=null&&this.setAttr(`miterLimit`,t)}setAttr(e,t){this._context[e]=t}arc(e,t,n,r,i,a){this._context.arc(e,t,n,r,i,a)}arcTo(e,t,n,r,i){this._context.arcTo(e,t,n,r,i)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,r,i,a){this._context.bezierCurveTo(e,t,n,r,i,a)}clearRect(e,t,n,r){this._context.clearRect(e,t,n,r)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,t){let n=arguments;if(n.length===2)return this._context.createImageData(e,t);if(n.length===1)return this._context.createImageData(e)}createLinearGradient(e,t,n,r){return this._context.createLinearGradient(e,t,n,r)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,n,r,i,a){return this._context.createRadialGradient(e,t,n,r,i,a)}drawImage(e,t,n,r,i,a,o,s,c){let l=arguments,u=this._context;l.length===3?u.drawImage(e,t,n):l.length===5?u.drawImage(e,t,n,r,i):l.length===9&&u.drawImage(e,t,n,r,i,a,o,s,c)}ellipse(e,t,n,r,i,a,o,s){this._context.ellipse(e,t,n,r,i,a,o,s)}isPointInPath(e,t,n,r){return n?this._context.isPointInPath(n,e,t,r):this._context.isPointInPath(e,t,r)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,t,n,r){this._context.fillRect(e,t,n,r)}strokeRect(e,t,n,r){this._context.strokeRect(e,t,n,r)}fillText(e,t,n,r){r?this._context.fillText(e,t,n,r):this._context.fillText(e,t,n)}measureText(e){return this._context.measureText(e)}getImageData(e,t,n,r){return this._context.getImageData(e,t,n,r)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,n,r){this._context.rect(e,t,n,r)}roundRect(e,t,n,r,i){this._context.roundRect(e,t,n,r,i)}putImageData(e,t,n){this._context.putImageData(e,t,n)}quadraticCurveTo(e,t,n,r){this._context.quadraticCurveTo(e,t,n,r)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):`mozDash`in this._context?this._context.mozDash=e:`webkitLineDash`in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,n,r,i,a){this._context.setTransform(e,t,n,r,i,a)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,n,r){this._context.strokeText(e,t,n,r)}transform(e,t,n,r,i,a){this._context.transform(e,t,n,r,i,a)}translate(e,t){this._context.translate(e,t)}_enableTrace(){let e=this,t=co.length,n=this.setAttr,r,i,a=function(t){let n=e[t],r;e[t]=function(){return i=$a(Array.prototype.slice.call(arguments,0)),r=n.apply(e,arguments),e._trace({method:t,args:i}),r}};for(r=0;r<t;r++)a(co[r]);e.setAttr=function(){n.apply(e,arguments);let t=arguments[0],r=arguments[1];(t===`shadowOffsetX`||t===`shadowOffsetY`||t===`shadowBlur`)&&(r/=this.canvas.getPixelRatio()),e._trace({property:t,val:r})}}_applyGlobalCompositeOperation(e){let t=e.attrs.globalCompositeOperation;!t||t===`source-over`||this.setAttr(`globalCompositeOperation`,t)}};lo.forEach(function(e){Object.defineProperty(mo.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})});var ho=class extends mo{constructor(e,{willReadFrequently:t=!1}={}){super(e),this._context=e._canvas.getContext(`2d`,{willReadFrequently:t})}_fillColor(e){let t=e.fill();this.setAttr(`fillStyle`,t),e._fillFunc(this)}_fillPattern(e){this.setAttr(`fillStyle`,e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){let t=e._getLinearGradient();t&&(this.setAttr(`fillStyle`,t),e._fillFunc(this))}_fillRadialGradient(e){let t=e._getRadialGradient();t&&(this.setAttr(`fillStyle`,t),e._fillFunc(this))}_fill(e){let t=e.fill(),n=e.getFillPriority();if(t&&n===`color`){this._fillColor(e);return}let r=e.getFillPatternImage();if(r&&n===`pattern`){this._fillPattern(e);return}let i=e.getFillLinearGradientColorStops();if(i&&n===`linear-gradient`){this._fillLinearGradient(e);return}let a=e.getFillRadialGradientColorStops();if(a&&n===`radial-gradient`){this._fillRadialGradient(e);return}t?this._fillColor(e):r?this._fillPattern(e):i?this._fillLinearGradient(e):a&&this._fillRadialGradient(e)}_strokeLinearGradient(e){let t=e.getStrokeLinearGradientStartPoint(),n=e.getStrokeLinearGradientEndPoint(),r=e.getStrokeLinearGradientColorStops(),i=this.createLinearGradient(t.x,t.y,n.x,n.y);if(r){for(let e=0;e<r.length;e+=2)i.addColorStop(r[e],r[e+1]);this.setAttr(`strokeStyle`,i)}}_stroke(e){let t=e.dash(),n=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!n){this.save();let e=this.getCanvas().getPixelRatio();this.setTransform(e,0,0,e,0,0)}this._applyLineCap(e),t&&e.dashEnabled()&&(this.setLineDash(t),this.setAttr(`lineDashOffset`,e.dashOffset())),this.setAttr(`lineWidth`,e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr(`shadowColor`,`rgba(0,0,0,0)`),e.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(e):this.setAttr(`strokeStyle`,e.stroke()),e._strokeFunc(this),n||this.restore()}}_applyShadow(e){let t=e.getShadowRGBA()??`black`,n=e.getShadowBlur()??5,r=e.getShadowOffset()??{x:0,y:0},i=e.getAbsoluteScale(),a=this.canvas.getPixelRatio(),o=i.x*a,s=i.y*a;this.setAttr(`shadowColor`,t),this.setAttr(`shadowBlur`,n*Math.min(Math.abs(o),Math.abs(s))),this.setAttr(`shadowOffsetX`,r.x*o),this.setAttr(`shadowOffsetY`,r.y*s)}},go=class extends mo{constructor(e){super(e),this._context=e._canvas.getContext(`2d`,{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr(`fillStyle`,e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){let t=e.getStrokeScaleEnabled();if(!t){this.save();let e=this.getCanvas().getPixelRatio();this.setTransform(e,0,0,e,0,0)}this._applyLineCap(e);let n=e.hitStrokeWidth(),r=n===`auto`?e.strokeWidth():n;this.setAttr(`lineWidth`,r),this.setAttr(`strokeStyle`,e.colorKey),e._strokeFuncHit(this),t||this.restore()}}},_o;function vo(){if(_o)return _o;let e=z.createCanvasElement(),t=e.getContext(`2d`);return _o=(function(){return(R._global.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)})(),z.releaseCanvas(e),_o}var yo=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;let t=(e||{}).pixelRatio||R.pixelRatio||vo();this.pixelRatio=t,this._canvas=z.createCanvasElement(),this._canvas.style.padding=`0`,this._canvas.style.margin=`0`,this._canvas.style.border=`0`,this._canvas.style.background=`transparent`,this._canvas.style.position=`absolute`,this._canvas.style.top=`0`,this._canvas.style.left=`0`}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){let t=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/t,this.getHeight()/t)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+`px`;let t=this.pixelRatio;this.getContext()._context.scale(t,t)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+`px`;let t=this.pixelRatio;this.getContext()._context.scale(t,t)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,t){this.setWidth(e||0),this.setHeight(t||0)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch{try{return this._canvas.toDataURL()}catch(e){return z.error(`Unable to get data URL. `+e.message+` For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html.`),``}}}},bo=class extends yo{constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this.context=new ho(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}},xo=class extends yo{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new go(this),this.setSize(e.width,e.height)}},So={get isDragging(){let e=!1;return So._dragElements.forEach(t=>{t.dragStatus===`dragging`&&(e=!0)}),e},justDragged:!1,get node(){let e;return So._dragElements.forEach(t=>{e=t.node}),e},_dragElements:new Map,_drag(e){let t=[];So._dragElements.forEach((n,r)=>{let{node:i}=n,a=i.getStage();a.setPointersPositions(e),n.pointerId===void 0&&(n.pointerId=z._getFirstPointerId(e));let o=a._changedPointerPositions.find(e=>e.id===n.pointerId);if(o){if(n.dragStatus!==`dragging`){let t=i.dragDistance();if(Math.max(Math.abs(o.x-n.startPointerPos.x),Math.abs(o.y-n.startPointerPos.y))<t||(i.startDrag({evt:e}),!i.isDragging()))return}i._setDragPosition(e,n),t.push(i)}}),t.forEach(t=>{t.getStage()&&t.fire(`dragmove`,{type:`dragmove`,target:t,evt:e},!0)})},_endDragBefore(e){let t=[];So._dragElements.forEach(n=>{let{node:r}=n,i=r.getStage();if(e&&i.setPointersPositions(e),!i._changedPointerPositions.find(e=>e.id===n.pointerId))return;(n.dragStatus===`dragging`||n.dragStatus===`stopped`)&&(So.justDragged=!0,R._mouseListenClick=!1,R._touchListenClick=!1,R._pointerListenClick=!1,n.dragStatus=`stopped`);let a=n.node.getLayer()||n.node instanceof R.Stage&&n.node;a&&t.indexOf(a)===-1&&t.push(a)}),t.forEach(e=>{e.draw()})},_endDragAfter(e){So._dragElements.forEach((t,n)=>{t.dragStatus===`stopped`&&t.node.fire(`dragend`,{type:`dragend`,target:t.node,evt:e},!0),t.dragStatus!==`dragging`&&So._dragElements.delete(n)})}};R.isBrowser&&(window.addEventListener(`mouseup`,So._endDragBefore,!0),window.addEventListener(`touchend`,So._endDragBefore,!0),window.addEventListener(`touchcancel`,So._endDragBefore,!0),window.addEventListener(`mousemove`,So._drag),window.addEventListener(`touchmove`,So._drag),window.addEventListener(`mouseup`,So._endDragAfter,!1),window.addEventListener(`touchend`,So._endDragAfter,!1),window.addEventListener(`touchcancel`,So._endDragAfter,!1));function Co(e){return z._isString(e)?`"`+e+`"`:Object.prototype.toString.call(e)===`[object Number]`||z._isBoolean(e)?e:Object.prototype.toString.call(e)}function wo(e){return e>255?255:e<0?0:Math.round(e)}function B(){if(R.isUnminified)return function(e,t){return z._isNumber(e)||z.warn(Co(e)+` is a not valid value for "`+t+`" attribute. The value should be a number.`),e}}function To(e){if(R.isUnminified)return function(t,n){let r=z._isNumber(t),i=z._isArray(t)&&t.length==e;return!r&&!i&&z.warn(Co(t)+` is a not valid value for "`+n+`" attribute. The value should be a number or Array<number>(`+e+`)`),t}}function Eo(){if(R.isUnminified)return function(e,t){return z._isNumber(e)||e===`auto`||z.warn(Co(e)+` is a not valid value for "`+t+`" attribute. The value should be a number or "auto".`),e}}function Do(){if(R.isUnminified)return function(e,t){return z._isString(e)||z.warn(Co(e)+` is a not valid value for "`+t+`" attribute. The value should be a string.`),e}}function Oo(){if(R.isUnminified)return function(e,t){let n=z._isString(e),r=Object.prototype.toString.call(e)===`[object CanvasGradient]`||e&&e.addColorStop;return n||r||z.warn(Co(e)+` is a not valid value for "`+t+`" attribute. The value should be a string or a native gradient.`),e}}function ko(){if(R.isUnminified)return function(e,t){let n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&e instanceof n||(z._isArray(e)?e.forEach(function(e){z._isNumber(e)||z.warn(`"`+t+`" attribute has non numeric element `+e+`. Make sure that all elements are numbers.`)}):z.warn(Co(e)+` is a not valid value for "`+t+`" attribute. The value should be a array of numbers.`)),e}}function Ao(){if(R.isUnminified)return function(e,t){return e===!0||e===!1||z.warn(Co(e)+` is a not valid value for "`+t+`" attribute. The value should be a boolean.`),e}}function jo(e){if(R.isUnminified)return function(t,n){return t==null||z.isObject(t)||z.warn(Co(t)+` is a not valid value for "`+n+`" attribute. The value should be an object with properties `+e),t}}var Mo=`get`,No=`set`,V={addGetterSetter(e,t,n,r,i){V.addGetter(e,t,n),V.addSetter(e,t,r,i),V.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){let r=Mo+z._capitalize(t);e.prototype[r]=e.prototype[r]||function(){let e=this.attrs[t];return e===void 0?n:e}},addSetter(e,t,n,r){let i=No+z._capitalize(t);e.prototype[i]||V.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){let i=No+z._capitalize(t);e.prototype[i]=function(e){return n&&e!=null&&(e=n.call(this,e,t)),this._setAttr(t,e),r&&r.call(this),this}},addComponentsGetterSetter(e,t,n,r,i){let a=n.length,o=z._capitalize,s=Mo+o(t),c=No+o(t);e.prototype[s]=function(){let e={};for(let r=0;r<a;r++){let i=n[r];e[i]=this.getAttr(t+o(i))}return e};let l=jo(n);e.prototype[c]=function(e){let a=this.attrs[t];r&&(e=r.call(this,e,t)),l&&l.call(this,e,t);for(let n in e)e.hasOwnProperty(n)&&this._setAttr(t+o(n),e[n]);return e||n.forEach(e=>{this._setAttr(t+o(e),void 0)}),this._fireChangeEvent(t,a,e),i&&i.call(this),this},V.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){let n=z._capitalize(t),r=No+n,i=Mo+n;e.prototype[t]=function(){return arguments.length?(this[r](arguments[0]),this):this[i]()}},addDeprecatedGetterSetter(e,t,n,r){z.error(`Adding deprecated `+t);let i=Mo+z._capitalize(t),a=t+` property is deprecated and will be removed soon. Look at Konva change log for more information.`;e.prototype[i]=function(){z.error(a);let e=this.attrs[t];return e===void 0?n:e},V.addSetter(e,t,r,function(){z.error(a)}),V.addOverloadedGetterSetter(e,t)},backCompat(e,t){z.each(t,function(t,n){let r=e.prototype[n],i=Mo+z._capitalize(t),a=No+z._capitalize(t);function o(){r.apply(this,arguments),z.error(`"`+t+`" method is deprecated and will be removed soon. Use ""`+n+`" instead.`)}e.prototype[t]=o,e.prototype[i]=o,e.prototype[a]=o})},afterSetFilter(){this._filterUpToDate=!1}};function Po(e){let t=/(\w+)\(([^)]+)\)/g,n;for(;(n=t.exec(e))!==null;){let[,e,t]=n;switch(e){case`blur`:{let e=parseFloat(t.replace(`px`,``));return function(t){this.blurRadius(e*.5);let n=R.Filters;n&&n.Blur&&n.Blur.call(this,t)}}case`brightness`:{let e=t.includes(`%`)?parseFloat(t)/100:parseFloat(t);return function(t){this.brightness(e);let n=R.Filters;n&&n.Brightness&&n.Brightness.call(this,t)}}case`contrast`:{let e=parseFloat(t);return function(t){let n=100*(Math.sqrt(e)-1);this.contrast(n);let r=R.Filters;r&&r.Contrast&&r.Contrast.call(this,t)}}case`grayscale`:return function(e){let t=R.Filters;t&&t.Grayscale&&t.Grayscale.call(this,e)};case`sepia`:return function(e){let t=R.Filters;t&&t.Sepia&&t.Sepia.call(this,e)};case`invert`:return function(e){let t=R.Filters;t&&t.Invert&&t.Invert.call(this,e)};default:z.warn(`CSS filter "${e}" is not supported in fallback mode. Consider using function filters for better compatibility.`);break}}return()=>{}}var Fo=`absoluteOpacity`,Io=`allEventListeners`,Lo=`absoluteTransform`,Ro=`absoluteScale`,zo=`canvas`,Bo=`Change`,Vo=`children`,Ho=`konva`,Uo=`listening`,Wo=`mouseenter`,Go=`mouseleave`,Ko=`pointerenter`,qo=`pointerleave`,Jo=`touchenter`,Yo=`touchleave`,Xo=`set`,Zo=`Shape`,Qo=` `,$o=`stage`,es=`transform`,ts=`Stage`,ns=`visible`,rs=[`xChange.konva`,`yChange.konva`,`scaleXChange.konva`,`scaleYChange.konva`,`skewXChange.konva`,`skewYChange.konva`,`rotationChange.konva`,`offsetXChange.konva`,`offsetYChange.konva`,`transformsEnabledChange.konva`].join(Qo),is=1,H=class e{constructor(e){this._id=is++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(e),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(e){(e===es||e===Lo)&&this._cache.get(e)?this._cache.get(e).dirty=!0:e?this._cache.delete(e):this._cache.clear()}_getCache(e,t){let n=this._cache.get(e);return(n===void 0||(e===es||e===Lo)&&n.dirty===!0)&&(n=t.call(this),this._cache.set(e,n)),n}_calculate(e,t,n){if(!this._attachedDepsListeners.get(e)){let n=t.map(e=>e+`Change.konva`).join(Qo);this.on(n,()=>{this._clearCache(e)}),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,n)}_getCanvasCache(){return this._cache.get(zo)}_clearSelfAndDescendantCache(e){this._clearCache(e),e===Lo&&this.fire(`absoluteTransformChange`)}clearCache(){if(this._cache.has(zo)){let{scene:e,filter:t,hit:n}=this._cache.get(zo);z.releaseCanvas(e._canvas,t._canvas,n._canvas),this._cache.delete(zo)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){let t=e||{},n={};(t.x===void 0||t.y===void 0||t.width===void 0||t.height===void 0)&&(n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let r=Math.ceil(t.width||n.width),i=Math.ceil(t.height||n.height),a=t.pixelRatio,o=t.x===void 0?Math.floor(n.x):t.x,s=t.y===void 0?Math.floor(n.y):t.y,c=t.offset||0,l=t.drawBorder||!1,u=t.hitCanvasPixelRatio||1;if(!r||!i){z.error(`Can not cache the node. Width or height of the node equals 0. Caching is skipped.`);return}let d=+(Math.abs(Math.round(n.x)-o)>.5),f=+(Math.abs(Math.round(n.y)-s)>.5);r+=c*2+d,i+=c*2+f,o-=c,s-=c;let p=new bo({pixelRatio:a,width:r,height:i}),m=new bo({pixelRatio:a,width:0,height:0,willReadFrequently:!0}),h=new xo({pixelRatio:u,width:r,height:i}),g=p.getContext(),_=h.getContext(),v=new bo({width:p.width/p.pixelRatio+Math.abs(o),height:p.height/p.pixelRatio+Math.abs(s),pixelRatio:p.pixelRatio}),y=v.getContext();return h.isCache=!0,p.isCache=!0,this._cache.delete(zo),this._filterUpToDate=!1,t.imageSmoothingEnabled===!1&&(p.getContext()._context.imageSmoothingEnabled=!1,m.getContext()._context.imageSmoothingEnabled=!1),g.save(),_.save(),y.save(),g.translate(-o,-s),_.translate(-o,-s),y.translate(-o,-s),v.x=o,v.y=s,this._isUnderCache=!0,this._clearSelfAndDescendantCache(Fo),this._clearSelfAndDescendantCache(Ro),this.drawScene(p,this,v),this.drawHit(h,this),this._isUnderCache=!1,g.restore(),_.restore(),l&&(g.save(),g.beginPath(),g.rect(0,0,r,i),g.closePath(),g.setAttr(`strokeStyle`,`red`),g.setAttr(`lineWidth`,5),g.stroke(),g.restore()),z.releaseCanvas(v._canvas),this._cache.set(zo,{scene:p,filter:m,hit:h,x:o,y:s}),this._requestDraw(),this}isCached(){return this._cache.has(zo)}getClientRect(e){throw Error(`abstract "getClientRect" method call`)}_transformedRect(e,t){let n=[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],r=1/0,i=1/0,a=-1/0,o=-1/0,s=this.getAbsoluteTransform(t);return n.forEach(function(e){let t=s.point(e);r===void 0&&(r=a=t.x,i=o=t.y),r=Math.min(r,t.x),i=Math.min(i,t.y),a=Math.max(a,t.x),o=Math.max(o,t.y)}),{x:r,y:i,width:a-r,height:o-i}}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);let t=this._getCanvasCache();e.translate(t.x,t.y);let n=this._getCachedSceneCanvas(),r=n.pixelRatio;e.drawImage(n._canvas,0,0,n.width/r,n.height/r),e.restore()}_drawCachedHitCanvas(e){let t=this._getCanvasCache(),n=t.hit;e.save(),e.translate(t.x,t.y),e.drawImage(n._canvas,0,0,n.width/n.pixelRatio,n.height/n.pixelRatio),e.restore()}_getCachedSceneCanvas(){let e=this.filters(),t=this._getCanvasCache(),n=t.scene,r=t.filter,i=r.getContext(),a,o,s,c;if(!e||e.length===0)return n;if(this._filterUpToDate)return r;let l=!0;for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&po(),typeof e[t]!=`string`||!po()){l=!1;break}let u=n.pixelRatio;if(r.setSize(n.width/n.pixelRatio,n.height/n.pixelRatio),l){let t=e.join(` `);return i.save(),i.setAttr(`filter`,t),i.drawImage(n._canvas,0,0,n.getWidth()/u,n.getHeight()/u),i.restore(),this._filterUpToDate=!0,r}try{for(a=e.length,i.clear(),i.drawImage(n._canvas,0,0,n.getWidth()/u,n.getHeight()/u),o=i.getImageData(0,0,r.getWidth(),r.getHeight()),s=0;s<a;s++)c=e[s],typeof c==`string`&&(c=Po(c)),c.call(this,o),i.putImageData(o,0,0)}catch(e){z.error(`Unable to apply filter. `+e.message+` This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.`)}return this._filterUpToDate=!0,r}on(...e){let t=e[0],n=e[1];if(e[2],this._cache&&this._cache.delete(Io),e.length===3)return this._delegate.apply(this,e);let r=t.split(Qo);for(let e=0;e<r.length;e++){let t=r[e].split(`.`),i=t[0],a=t[1]||``;this.eventListeners[i]||(this.eventListeners[i]=[]),this.eventListeners[i].push({name:a,handler:n})}return this}off(e,t){let n=(e||``).split(Qo),r=n.length,i,a,o,s,c,l;if(this._cache&&this._cache.delete(Io),!e)for(a in this.eventListeners)this._off(a);for(i=0;i<r;i++)if(o=n[i],s=o.split(`.`),c=s[0],l=s[1],c)this.eventListeners[c]&&this._off(c,l,t);else for(a in this.eventListeners)this._off(a,l,t);return this}dispatchEvent(e){let t={target:this,type:e.type,evt:e};return this.fire(e.type,t),this}addEventListener(e,t){return this.on(e,function(e){t.call(this,e.evt)}),this}removeEventListener(e){return this.off(e),this}_delegate(e,t,n){let r=this;return this.on(e,function(e){let i=e.target.findAncestors(t,!0,r);for(let t=0;t<i.length;t++)e=z.cloneObject(e),e.currentTarget=i[t],n.call(i[t],e)}),this}remove(){return this.isDragging()&&this.stopDrag(),So._dragElements.delete(this._id),So._dragElements.forEach((e,t)=>{this.isAncestorOf(e.node)&&So._dragElements.delete(t)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(Lo),this._clearSelfAndDescendantCache(Fo),this._clearSelfAndDescendantCache(Ro),this._clearSelfAndDescendantCache($o),this._clearSelfAndDescendantCache(ns),this._clearSelfAndDescendantCache(Uo)}_remove(){this._clearCaches();let e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){let t=`get`+z._capitalize(e);return z._isFunction(this[t])?this[t]():this.attrs[e]}getAncestors(){let e=this.getParent(),t=[];for(;e;)t.push(e),e=e.getParent();return t}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges(()=>{let t,n;if(!e)return this;for(t in e)t!==Vo&&(n=Xo+z._capitalize(t),z._isFunction(this[n])?this[n](e[t]):this._setAttr(t,e[t]))}),this}isListening(){return this._getCache(Uo,this._isListening)}_isListening(e){if(!this.listening())return!1;let t=this.getParent();return t&&t!==e&&this!==e?t._isListening(e):!0}isVisible(){return this._getCache(ns,this._isVisible)}_isVisible(e){if(!this.visible())return!1;let t=this.getParent();return t&&t!==e&&this!==e?t._isVisible(e):!0}shouldDrawHit(e,t=!1){if(e)return this._isVisible(e)&&this._isListening(e);let n=this.getLayer(),r=!1;So._dragElements.forEach(e=>{e.dragStatus===`dragging`&&(e.node.nodeType===`Stage`||e.node.getLayer()===n)&&(r=!0)});let i=!t&&!R.hitOnDragEnabled&&(r||R.isTransforming());return this.isListening()&&this.isVisible()&&!i}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let e=this.getDepth(),t=this,n=0,r,i,a,o;function s(c){for(r=[],i=c.length,a=0;a<i;a++)o=c[a],n++,o.nodeType!==Zo&&(r=r.concat(o.getChildren().slice())),o._id===t._id&&(a=i);r.length>0&&r[0].getDepth()<=e&&s(r)}let c=this.getStage();return t.nodeType!==ts&&c&&s(c.getChildren()),n}getDepth(){let e=0,t=this.parent;for(;t;)e++,t=t.parent;return e}_batchTransformChanges(e){this._batchingTransformChange=!0,e(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(es),this._clearSelfAndDescendantCache(Lo)),this._needClearTransformCache=!1}setPosition(e){return this._batchTransformChanges(()=>{this.x(e.x),this.y(e.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){let e=this.getStage();if(!e)return null;let t=e.getPointerPosition();if(!t)return null;let n=this.getAbsoluteTransform().copy();return n.invert(),n.point(t)}getAbsolutePosition(e){let t=!1,n=this.parent;for(;n;){if(n.isCached()){t=!0;break}n=n.parent}t&&!e&&(e=!0);let r=this.getAbsoluteTransform(e).getMatrix(),i=new Fa,a=this.offset();return i.m=r.slice(),i.translate(a.x,a.y),i.getTranslation()}setAbsolutePosition(e){let{x:t,y:n,...r}=this._clearTransform();this.attrs.x=t,this.attrs.y=n,this._clearCache(es);let i=this._getAbsoluteTransform().copy();return i.invert(),i.translate(e.x,e.y),e={x:this.attrs.x+i.getTranslation().x,y:this.attrs.y+i.getTranslation().y},this._setTransform(r),this.setPosition({x:e.x,y:e.y}),this._clearCache(es),this._clearSelfAndDescendantCache(Lo),this}_setTransform(e){let t;for(t in e)this.attrs[t]=e[t]}_clearTransform(){let e={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,e}move(e){let t=e.x,n=e.y,r=this.x(),i=this.y();return t!==void 0&&(r+=t),n!==void 0&&(i+=n),this.setPosition({x:r,y:i}),this}_eachAncestorReverse(e,t){let n=[],r=this.getParent(),i,a;if(!(t&&t._id===this._id)){for(n.unshift(this);r&&(!t||r._id!==t._id);)n.unshift(r),r=r.parent;for(i=n.length,a=0;a<i;a++)e(n[a])}}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return z.warn(`Node has no parent. moveToTop function is ignored.`),!1;let e=this.index;return e<this.parent.getChildren().length-1?(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0):!1}moveUp(){if(!this.parent)return z.warn(`Node has no parent. moveUp function is ignored.`),!1;let e=this.index;return e<this.parent.getChildren().length-1?(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0):!1}moveDown(){if(!this.parent)return z.warn(`Node has no parent. moveDown function is ignored.`),!1;let e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0):!1}moveToBottom(){if(!this.parent)return z.warn(`Node has no parent. moveToBottom function is ignored.`),!1;let e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1}setZIndex(e){if(!this.parent)return z.warn(`Node has no parent. zIndex parameter is ignored.`),this;(e<0||e>=this.parent.children.length)&&z.warn(`Unexpected value `+e+` for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to `+(this.parent.children.length-1)+`.`);let t=this.index;return this.parent.children.splice(t,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(Fo,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let e=this.opacity(),t=this.getParent();return t&&!t._isUnderCache&&(e*=t.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){let e=this.getAttrs(),t,n,r,i,a,o={attrs:{},className:this.getClassName()};for(t in e)n=e[t],a=z.isObject(n)&&!z._isPlainObject(n)&&!z._isArray(n),!a&&(r=typeof this[t]==`function`&&this[t],delete e[t],i=r?r.call(this):null,e[t]=n,i!==n&&(o.attrs[t]=n));return z._prepareToStringify(o)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,t,n){let r=[];t&&this._isMatch(e)&&r.push(this);let i=this.parent;for(;i;){if(i===n)return r;i._isMatch(e)&&r.push(i),i=i.parent}return r}isAncestorOf(e){return!1}findAncestor(e,t,n){return this.findAncestors(e,t,n)[0]}_isMatch(e){if(!e)return!1;if(typeof e==`function`)return e(this);let t=e.replace(/ /g,``).split(`,`),n=t.length,r,i;for(r=0;r<n;r++)if(i=t[r],z.isValidSelector(i)||(z.warn(`Selector "`+i+`" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".`),z.warn(`If you have a custom shape with such className, please change it to start with upper letter like "Triangle".`),z.warn(`Konva is awesome, right?`)),i.charAt(0)===`#`){if(this.id()===i.slice(1))return!0}else if(i.charAt(0)===`.`){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){let e=this.getParent();return e?e.getLayer():null}getStage(){return this._getCache($o,this._getStage)}_getStage(){let e=this.getParent();return e?e.getStage():null}fire(e,t={},n){return t.target=t.target||this,n?this._fireAndBubble(e,t):this._fire(e,t),this}getAbsoluteTransform(e){return e?this._getAbsoluteTransform(e):this._getCache(Lo,this._getAbsoluteTransform)}_getAbsoluteTransform(e){let t;if(e)return t=new Fa,this._eachAncestorReverse(function(e){let n=e.transformsEnabled();n===`all`?t.multiply(e.getTransform()):n===`position`&&t.translate(e.x()-e.offsetX(),e.y()-e.offsetY())},e),t;{t=this._cache.get(Lo)||new Fa,this.parent?this.parent.getAbsoluteTransform().copyInto(t):t.reset();let e=this.transformsEnabled();if(e===`all`)t.multiply(this.getTransform());else if(e===`position`){let e=this.attrs.x||0,n=this.attrs.y||0,r=this.attrs.offsetX||0,i=this.attrs.offsetY||0;t.translate(e-r,n-i)}return t.dirty=!1,t}}getAbsoluteScale(e){let t=this;for(;t;)t._isUnderCache&&(e=t),t=t.getParent();let n=this.getAbsoluteTransform(e).decompose();return{x:n.scaleX,y:n.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(es,this._getTransform)}_getTransform(){let e=this._cache.get(es)||new Fa;e.reset();let t=this.x(),n=this.y(),r=R.getAngle(this.rotation()),i=this.attrs.scaleX??1,a=this.attrs.scaleY??1,o=this.attrs.skewX||0,s=this.attrs.skewY||0,c=this.attrs.offsetX||0,l=this.attrs.offsetY||0;return(t!==0||n!==0)&&e.translate(t,n),r!==0&&e.rotate(r),(o!==0||s!==0)&&e.skew(o,s),(i!==1||a!==1)&&e.scale(i,a),(c!==0||l!==0)&&e.translate(-1*c,-1*l),e.dirty=!1,e}clone(e){let t=z.cloneObject(this.attrs),n,r,i,a,o;for(n in e)t[n]=e[n];let s=new this.constructor(t);for(n in this.eventListeners)for(r=this.eventListeners[n],i=r.length,a=0;a<i;a++)o=r[a],o.name.indexOf(Ho)<0&&(s.eventListeners[n]||(s.eventListeners[n]=[]),s.eventListeners[n].push(o));return s}_toKonvaCanvas(e){e||={};let t=this.getClientRect(),n=this.getStage(),r=e.x===void 0?Math.floor(t.x):e.x,i=e.y===void 0?Math.floor(t.y):e.y,a=e.pixelRatio||1,o=new bo({width:e.width||Math.ceil(t.width)||(n?n.width():0),height:e.height||Math.ceil(t.height)||(n?n.height():0),pixelRatio:a}),s=o.getContext(),c=new bo({width:o.width/o.pixelRatio+Math.abs(r),height:o.height/o.pixelRatio+Math.abs(i),pixelRatio:o.pixelRatio});return e.imageSmoothingEnabled===!1&&(s._context.imageSmoothingEnabled=!1),s.save(),(r||i)&&s.translate(-1*r,-1*i),this.drawScene(o,void 0,c),s.restore(),o}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){e||={};let t=e.mimeType||null,n=e.quality||null,r=this._toKonvaCanvas(e).toDataURL(t,n);return e.callback&&e.callback(r),r}toImage(e){return new Promise((t,n)=>{try{let n=e?.callback;n&&delete e.callback,z._urlToImage(this.toDataURL(e),function(e){t(e),n?.(e)})}catch(e){n(e)}})}toBlob(e){return new Promise((t,n)=>{try{let n=e?.callback;n&&delete e.callback,this.toCanvas(e).toBlob(e=>{t(e),n?.(e)},e?.mimeType,e?.quality)}catch(e){n(e)}})}setSize(e){return this.width(e.width),this.height(e.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance===void 0?this.parent?this.parent.getDragDistance():R.dragDistance:this.attrs.dragDistance}_off(e,t,n){let r=this.eventListeners[e],i,a,o;for(i=0;i<r.length;i++)if(a=r[i].name,o=r[i].handler,(a!==`konva`||t===`konva`)&&(!t||a===t)&&(!n||n===o)){if(r.splice(i,1),r.length===0){delete this.eventListeners[e];break}i--}}_fireChangeEvent(e,t,n){this._fire(e+Bo,{oldVal:t,newVal:n})}addName(e){if(!this.hasName(e)){let t=this.name(),n=t?t+` `+e:e;this.name(n)}return this}hasName(e){if(!e)return!1;let t=this.name();return t?(t||``).split(/\s/g).indexOf(e)!==-1:!1}removeName(e){let t=(this.name()||``).split(/\s/g),n=t.indexOf(e);return n!==-1&&(t.splice(n,1),this.name(t.join(` `))),this}setAttr(e,t){let n=this[Xo+z._capitalize(e)];return z._isFunction(n)?n.call(this,t):this._setAttr(e,t),this}_requestDraw(){R.autoDrawEnabled&&(this.getLayer()||this.getStage())?.batchDraw()}_setAttr(e,t){let n=this.attrs[e];n===t&&!z.isObject(t)||(t==null?delete this.attrs[e]:this.attrs[e]=t,this._shouldFireChangeEvents&&this._fireChangeEvent(e,n,t),this._requestDraw())}_setComponentAttr(e,t,n){let r;n!==void 0&&(r=this.attrs[e],r||(this.attrs[e]=this.getAttr(e)),this.attrs[e][t]=n,this._fireChangeEvent(e,r,n))}_fireAndBubble(e,t,n){t&&this.nodeType===Zo&&(t.target=this);let r=[Wo,Go,Ko,qo,Jo,Yo];if(!(r.indexOf(e)!==-1&&(n&&(this===n||this.isAncestorOf&&this.isAncestorOf(n))||this.nodeType===`Stage`&&!n))){this._fire(e,t);let i=r.indexOf(e)!==-1&&n&&n.isAncestorOf&&n.isAncestorOf(this)&&!n.isAncestorOf(this.parent);(t&&!t.cancelBubble||!t)&&this.parent&&this.parent.isListening()&&!i&&(n&&n.parent?this._fireAndBubble.call(this.parent,e,t,n):this._fireAndBubble.call(this.parent,e,t))}}_getProtoListeners(t){let{nodeType:n}=this,r=e.protoListenerMap.get(n)||{},i=r?.[t];if(i===void 0){i=[];let a=Object.getPrototypeOf(this);for(;a;){let e=a.eventListeners?.[t]??[];i.push(...e),a=Object.getPrototypeOf(a)}r[t]=i,e.protoListenerMap.set(n,r)}return i}_fire(e,t){t||={},t.currentTarget=this,t.type=e;let n=this._getProtoListeners(e);if(n){let e=n.slice();for(let n=0;n<e.length;n++)e[n].handler.call(this,t)}let r=this.eventListeners[e];if(r){let n=r.slice(),i=n.length;for(let e=0;e<n.length;e++)n[e].handler.call(this,t);let a=this.eventListeners[e];if(a)for(let e=i;e<a.length;e++)a[e].handler.call(this,t)}}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(e){let t=e?e.pointerId:void 0,n=this.getStage(),r=this.getAbsolutePosition();if(!n)return;let i=n._getPointerById(t)||n._changedPointerPositions[0]||r;So._dragElements.set(this._id,{node:this,startPointerPos:i,offset:{x:i.x-r.x,y:i.y-r.y},dragStatus:`ready`,pointerId:t,startEvent:e})}startDrag(e,t=!0){So._dragElements.has(this._id)||this._createDragElement(e);let n=So._dragElements.get(this._id);n.dragStatus=`dragging`,this.fire(`dragstart`,{type:`dragstart`,target:this,evt:n.startEvent&&n.startEvent.evt||e&&e.evt},t)}_setDragPosition(e,t){let n=this.getStage()._getPointerById(t.pointerId);if(!n)return;let r={x:n.x-t.offset.x,y:n.y-t.offset.y},i=this.dragBoundFunc();if(i!==void 0){let t=i.call(this,r,e);t?r=t:z.warn(`dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.`)}(!this._lastPos||this._lastPos.x!==r.x||this._lastPos.y!==r.y)&&(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}stopDrag(e){let t=So._dragElements.get(this._id);t&&(t.dragStatus=`stopped`),So._endDragBefore(e),So._endDragAfter(e)}setDraggable(e){this._setAttr(`draggable`,e),this._dragChange()}isDragging(){let e=So._dragElements.get(this._id);return e?e.dragStatus===`dragging`:!1}_listenDrag(){this._dragCleanup(),this.on(`mousedown.konva touchstart.konva`,function(e){if(!(e.evt.button===void 0||R.dragButtons.indexOf(e.evt.button)>=0)||this.isDragging())return;let t=!1;So._dragElements.forEach(e=>{this.isAncestorOf(e.node)&&(t=!0)}),t||this._createDragElement(e)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;let e=So._dragElements.get(this._id),t=e&&e.dragStatus===`dragging`,n=e&&e.dragStatus===`ready`;t?this.stopDrag():n&&So._dragElements.delete(this._id)}}_dragCleanup(){this.off(`mousedown.konva`),this.off(`touchstart.konva`)}isClientRectOnScreen(e={x:0,y:0}){let t=this.getStage();if(!t)return!1;let n={x:-e.x,y:-e.y,width:t.width()+2*e.x,height:t.height()+2*e.y};return z.haveIntersection(n,this.getClientRect())}static create(e,t){return z._isString(e)&&(e=JSON.parse(e)),this._createNode(e,t)}static _createNode(t,n){let r=e.prototype.getClassName.call(t),i=t.children,a,o,s;n&&(t.attrs.container=n),R[r]||(z.warn(`Can not find a node with class name "`+r+`". Fallback to "Shape".`),r=`Shape`);let c=R[r];if(a=new c(t.attrs),i)for(o=i.length,s=0;s<o;s++)a.add(e._createNode(i[s]));return a}};H.protoListenerMap=new Map,H.prototype.nodeType=`Node`,H.prototype._attrsAffectingSize=[],H.prototype.eventListeners={},H.prototype.on(rs,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(es),this._clearSelfAndDescendantCache(Lo)}),H.prototype.on(`visibleChange.konva`,function(){this._clearSelfAndDescendantCache(ns)}),H.prototype.on(`listeningChange.konva`,function(){this._clearSelfAndDescendantCache(Uo)}),H.prototype.on(`opacityChange.konva`,function(){this._clearSelfAndDescendantCache(Fo)});var as=V.addGetterSetter;as(H,`zIndex`),as(H,`absolutePosition`),as(H,`position`),as(H,`x`,0,B()),as(H,`y`,0,B()),as(H,`globalCompositeOperation`,`source-over`,Do()),as(H,`opacity`,1,B()),as(H,`name`,``,Do()),as(H,`id`,``,Do()),as(H,`rotation`,0,B()),V.addComponentsGetterSetter(H,`scale`,[`x`,`y`]),as(H,`scaleX`,1,B()),as(H,`scaleY`,1,B()),V.addComponentsGetterSetter(H,`skew`,[`x`,`y`]),as(H,`skewX`,0,B()),as(H,`skewY`,0,B()),V.addComponentsGetterSetter(H,`offset`,[`x`,`y`]),as(H,`offsetX`,0,B()),as(H,`offsetY`,0,B()),as(H,`dragDistance`,void 0,B()),as(H,`width`,0,B()),as(H,`height`,0,B()),as(H,`listening`,!0,Ao()),as(H,`preventDefault`,!0,Ao()),as(H,`filters`,void 0,function(e){return this._filterUpToDate=!1,e}),as(H,`visible`,!0,Ao()),as(H,`transformsEnabled`,`all`,Do()),as(H,`size`),as(H,`dragBoundFunc`),as(H,`draggable`,!1,Ao()),V.backCompat(H,{rotateDeg:`rotate`,setRotationDeg:`setRotation`,getRotationDeg:`getRotation`});var os=class extends H{constructor(){super(...arguments),this.children=[]}getChildren(e){let t=this.children||[];return e?t.filter(e):t}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._requestDraw(),this}add(...e){if(e.length===0)return this;if(e.length>1){for(let t=0;t<e.length;t++)this.add(e[t]);return this}let t=e[0];return t.getParent()?(t.moveTo(this),this):(this._validateAdd(t),t.index=this.getChildren().length,t.parent=this,t._clearCaches(),this.getChildren().push(t),this._fire(`add`,{child:t}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){let t=this._generalFind(e,!0);return t.length>0?t[0]:void 0}_generalFind(e,t){let n=[];return this._descendants(r=>{let i=r._isMatch(e);return i&&n.push(r),!!(i&&t)}),n}_descendants(e){let t=!1,n=this.getChildren();for(let r of n)if(t=e(r),t||r.hasChildren()&&(t=r._descendants(e),t))return!0;return!1}toObject(){let e=H.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(t=>{e.children.push(t.toObject())}),e}isAncestorOf(e){let t=e.getParent();for(;t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){let t=H.prototype.clone.call(this,e);return this.getChildren().forEach(function(e){t.add(e.clone())}),t}getAllIntersections(e){let t=[];return this.find(`Shape`).forEach(n=>{n.isVisible()&&n.intersects(e)&&t.push(n)}),t}_clearSelfAndDescendantCache(e){var t;super._clearSelfAndDescendantCache(e),!this.isCached()&&((t=this.children)==null||t.forEach(function(t){t._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)==null||e.forEach(function(e,t){e.index=t}),this._requestDraw()}drawScene(e,t,n){let r=this.getLayer(),i=e||r&&r.getCanvas(),a=i&&i.getContext(),o=this._getCanvasCache(),s=o&&o.scene,c=i&&i.isCache;if(!this.isVisible()&&!c)return this;if(s){a.save();let e=this.getAbsoluteTransform(t).getMatrix();a.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedSceneCanvas(a),a.restore()}else this._drawChildren(`drawScene`,i,t,n);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;let n=this.getLayer(),r=e||n&&n.hitCanvas,i=r&&r.getContext(),a=this._getCanvasCache();if(a&&a.hit){i.save();let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedHitCanvas(i),i.restore()}else this._drawChildren(`drawHit`,r,t);return this}_drawChildren(e,t,n,r){var i;let a=t&&t.getContext(),o=this.clipWidth(),s=this.clipHeight(),c=this.clipFunc(),l=typeof o==`number`&&typeof s==`number`||c,u=n===this;if(l){a.save();let e=this.getAbsoluteTransform(n),t=e.getMatrix();a.transform(t[0],t[1],t[2],t[3],t[4],t[5]),a.beginPath();let r;if(c)r=c.call(this,a,this);else{let e=this.clipX(),t=this.clipY();a.rect(e||0,t||0,o,s)}a.clip.apply(a,r),t=e.copy().invert().getMatrix(),a.transform(t[0],t[1],t[2],t[3],t[4],t[5])}let d=!u&&this.globalCompositeOperation()!==`source-over`&&e===`drawScene`;d&&(a.save(),a._applyGlobalCompositeOperation(this)),(i=this.children)==null||i.forEach(function(i){i[e](t,n,r)}),d&&a.restore(),l&&a.restore()}getClientRect(e={}){var t;let n=e.skipTransform,r=e.relativeTo,i,a,o,s,c={x:1/0,y:1/0,width:0,height:0},l=this;(t=this.children)==null||t.forEach(function(t){if(!t.visible())return;let n=t.getClientRect({relativeTo:l,skipShadow:e.skipShadow,skipStroke:e.skipStroke});n.width===0&&n.height===0||(i===void 0?(i=n.x,a=n.y,o=n.x+n.width,s=n.y+n.height):(i=Math.min(i,n.x),a=Math.min(a,n.y),o=Math.max(o,n.x+n.width),s=Math.max(s,n.y+n.height)))});let u=this.find(`Shape`),d=!1;for(let e=0;e<u.length;e++)if(u[e]._isVisible(this)){d=!0;break}return c=d&&i!==void 0?{x:i,y:a,width:o-i,height:s-a}:{x:0,y:0,width:0,height:0},n?c:this._transformedRect(c,r)}};V.addComponentsGetterSetter(os,`clip`,[`x`,`y`,`width`,`height`]),V.addGetterSetter(os,`clipX`,void 0,B()),V.addGetterSetter(os,`clipY`,void 0,B()),V.addGetterSetter(os,`clipWidth`,void 0,B()),V.addGetterSetter(os,`clipHeight`,void 0,B()),V.addGetterSetter(os,`clipFunc`);var ss=new Map,cs=R._global.PointerEvent!==void 0;function ls(e){return ss.get(e)}function us(e){return{evt:e,pointerId:e.pointerId}}function ds(e,t){return ss.get(e)===t}function fs(e,t){ps(e),t.getStage()&&(ss.set(e,t),cs&&t._fire(`gotpointercapture`,us(new PointerEvent(`gotpointercapture`))))}function ps(e,t){let n=ss.get(e);if(!n)return;let r=n.getStage();r&&r.content,ss.delete(e),cs&&n._fire(`lostpointercapture`,us(new PointerEvent(`lostpointercapture`)))}var ms=`Stage`,hs=`string`,gs=`px`,_s=`mouseout`,vs=`mouseleave`,ys=`mouseover`,bs=`mouseenter`,xs=`mousemove`,Ss=`mousedown`,Cs=`mouseup`,ws=`pointermove`,Ts=`pointerdown`,Es=`pointerup`,Ds=`pointercancel`,Os=`lostpointercapture`,ks=`pointerout`,As=`pointerleave`,js=`pointerover`,Ms=`pointerenter`,Ns=`contextmenu`,Ps=`touchstart`,Fs=`touchend`,Is=`touchmove`,Ls=`touchcancel`,Rs=`wheel`,zs=5,Bs=[[bs,`_pointerenter`],[Ss,`_pointerdown`],[xs,`_pointermove`],[Cs,`_pointerup`],[vs,`_pointerleave`],[Ps,`_pointerdown`],[Is,`_pointermove`],[Fs,`_pointerup`],[Ls,`_pointercancel`],[ys,`_pointerover`],[Rs,`_wheel`],[Ns,`_contextmenu`],[Ts,`_pointerdown`],[ws,`_pointermove`],[Es,`_pointerup`],[Ds,`_pointercancel`],[As,`_pointerleave`],[Os,`_lostpointercapture`]],Vs={mouse:{[ks]:_s,[As]:vs,[js]:ys,[Ms]:bs,[ws]:xs,[Ts]:Ss,[Es]:Cs,[Ds]:`mousecancel`,pointerclick:`click`,pointerdblclick:`dblclick`},touch:{[ks]:`touchout`,[As]:`touchleave`,[js]:`touchover`,[Ms]:`touchenter`,[ws]:Is,[Ts]:Ps,[Es]:Fs,[Ds]:Ls,pointerclick:`tap`,pointerdblclick:`dbltap`},pointer:{[ks]:ks,[As]:As,[js]:js,[Ms]:Ms,[ws]:ws,[Ts]:Ts,[Es]:Es,[Ds]:Ds,pointerclick:`pointerclick`,pointerdblclick:`pointerdblclick`}},Hs=e=>e.indexOf(`pointer`)>=0?`pointer`:e.indexOf(`touch`)>=0?`touch`:`mouse`,Us=e=>{let t=Hs(e);if(t===`pointer`)return R.pointerEventsEnabled&&Vs.pointer;if(t===`touch`)return Vs.touch;if(t===`mouse`)return Vs.mouse};function Ws(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&z.warn(`Stage does not support clipping. Please use clip for Layers or Groups.`),e}var Gs=`Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);`,Ks=[],qs=class extends os{constructor(e){super(Ws(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),Ks.push(this),this.on(`widthChange.konva heightChange.konva`,this._resizeDOM),this.on(`visibleChange.konva`,this._checkVisibility),this.on(`clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva`,()=>{Ws(this.attrs)}),this._checkVisibility()}_validateAdd(e){let t=e.getType()===`Layer`,n=e.getType()===`FastLayer`;t||n||z.throw(`You may only add layers to the stage.`)}_checkVisibility(){if(!this.content)return;let e=this.visible()?``:`none`;this.content.style.display=e}setContainer(e){if(typeof e===hs){let t;if(e.charAt(0)===`.`){let t=e.slice(1);e=document.getElementsByClassName(t)[0]}else t=e.charAt(0)===`#`?e.slice(1):e,e=document.getElementById(t);if(!e)throw`Can not find container in document with id `+t}return this._setAttr(`container`,e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){let e=this.children,t=e.length;for(let n=0;n<t;n++)e[n].clear();return this}clone(e){return e||={},e.container=typeof document<`u`&&document.createElement(`div`),os.prototype.clone.call(this,e)}destroy(){super.destroy();let e=this.content;e&&z._isInDocument(e)&&this.container().removeChild(e);let t=Ks.indexOf(this);return t>-1&&Ks.splice(t,1),z.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){let e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(z.warn(Gs),null)}_getPointerById(e){return this._pointerPositions.find(t=>t.id===e)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){e={...e},e.x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();let t=new bo({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),n=t.getContext()._context,r=this.children;return(e.x||e.y)&&n.translate(-1*e.x,-1*e.y),r.forEach(function(t){if(!t.isVisible())return;let r=t._toKonvaCanvas(e);n.drawImage(r._canvas,e.x,e.y,r.getWidth()/r.getPixelRatio(),r.getHeight()/r.getPixelRatio())}),t}getIntersection(e){if(!e)return null;let t=this.children,n=t.length-1;for(let r=n;r>=0;r--){let n=t[r].getIntersection(e);if(n)return n}return null}_resizeDOM(){let e=this.width(),t=this.height();this.content&&(this.content.style.width=e+gs,this.content.style.height=t+gs),this.bufferCanvas.setSize(e,t),this.bufferHitCanvas.setSize(e,t),this.children.forEach(n=>{n.setSize({width:e,height:t}),n.draw()})}add(e,...t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}super.add(e);let n=this.children.length;return n>zs&&z.warn(`The stage has `+n+` layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group.`),e.setSize({width:this.width(),height:this.height()}),e.draw(),R.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return ds(e,this)}setPointerCapture(e){fs(e,this)}releaseCapture(e){ps(e,this)}getLayers(){return this.children}_bindContentEvents(){R.isBrowser&&Bs.forEach(([e,t])=>{this.content.addEventListener(e,e=>{this[t](e)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);let t=Us(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);let t=Us(e.type);t&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let t=this[e+`targetShape`];return t&&!t.getStage()&&(t=null),t}_pointerleave(e){let t=Us(e.type),n=Hs(e.type);if(!t)return;this.setPointersPositions(e);let r=this._getTargetShape(n),i=!(R.isDragging()||R.isTransforming())||R.hitOnDragEnabled;r&&i?(r._fireAndBubble(t.pointerout,{evt:e}),r._fireAndBubble(t.pointerleave,{evt:e}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this[n+`targetShape`]=null):i&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(e){let t=Us(e.type),n=Hs(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(i=>{let a=this.getIntersection(i);if(So.justDragged=!1,R[`_`+n+`ListenClick`]=!0,!a||!a.isListening()){this[n+`ClickStartShape`]=void 0;return}R.capturePointerEventsEnabled&&a.setPointerCapture(i.id),this[n+`ClickStartShape`]=a,a._fireAndBubble(t.pointerdown,{evt:e,pointerId:i.id}),r=!0;let o=e.type.indexOf(`touch`)>=0;a.preventDefault()&&e.cancelable&&o&&e.preventDefault()}),r||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(e){let t=Us(e.type),n=Hs(e.type);if(!t)return;let r=e.type.indexOf(`touch`)>=0||e.pointerType===`touch`;if(R.isDragging()&&So.node.preventDefault()&&e.cancelable&&r&&e.preventDefault(),this.setPointersPositions(e),!(!(R.isDragging()||R.isTransforming())||R.hitOnDragEnabled))return;let i={},a=!1,o=this._getTargetShape(n);this._changedPointerPositions.forEach(r=>{let s=ls(r.id)||this.getIntersection(r),c=r.id,l={evt:e,pointerId:c},u=o!==s;if(u&&o&&(o._fireAndBubble(t.pointerout,{...l},s),o._fireAndBubble(t.pointerleave,{...l},s)),s){if(i[s._id])return;i[s._id]=!0}s&&s.isListening()?(a=!0,u&&(s._fireAndBubble(t.pointerover,{...l},o),s._fireAndBubble(t.pointerenter,{...l},o),this[n+`targetShape`]=s),s._fireAndBubble(t.pointermove,{...l})):o&&(this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:c}),this[n+`targetShape`]=null)}),a||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){let t=Us(e.type),n=Hs(e.type);if(!t)return;this.setPointersPositions(e);let r=this[n+`ClickStartShape`],i=this[n+`ClickEndShape`],a={},o=!1;this._changedPointerPositions.forEach(s=>{let c=ls(s.id)||this.getIntersection(s);if(c){if(c.releaseCapture(s.id),a[c._id])return;a[c._id]=!0}let l=s.id,u={evt:e,pointerId:l},d=!1;R[`_`+n+`InDblClickWindow`]?(d=!0,clearTimeout(this[n+`DblTimeout`])):So.justDragged||(R[`_`+n+`InDblClickWindow`]=!0,clearTimeout(this[n+`DblTimeout`])),this[n+`DblTimeout`]=setTimeout(function(){R[`_`+n+`InDblClickWindow`]=!1},R.dblClickWindow),c&&c.isListening()?(o=!0,this[n+`ClickEndShape`]=c,c._fireAndBubble(t.pointerup,{...u}),R[`_`+n+`ListenClick`]&&r&&r===c&&(c._fireAndBubble(t.pointerclick,{...u}),d&&i&&i===c&&c._fireAndBubble(t.pointerdblclick,{...u}))):(this[n+`ClickEndShape`]=null,o||=(this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),!0),R[`_`+n+`ListenClick`]&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:l}),d&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:l}))}),o||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),R[`_`+n+`ListenClick`]=!1,e.cancelable&&n!==`touch`&&n!==`pointer`&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);let t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(Ns,{evt:e}):this._fire(Ns,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);let t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(Rs,{evt:e}):this._fire(Rs,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);let t=ls(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(Es,us(e)),ps(e.pointerId)}_lostpointercapture(e){ps(e.pointerId)}setPointersPositions(e){let t=this._getContentPosition(),n=null,r=null;e||=window.event,e.touches===void 0?(n=(e.clientX-t.left)/t.scaleX,r=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:z._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:z._getFirstPointerId(e)}]):(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,e=>{this._pointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,e=>{this._changedPointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})}))}_setPointerPosition(e){z.warn(`Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.`),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};let e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new bo({width:this.width(),height:this.height()}),this.bufferHitCanvas=new xo({pixelRatio:1,width:this.width(),height:this.height()}),!R.isBrowser)return;let e=this.container();if(!e)throw`Stage has no container. A container is required.`;e.innerHTML=``,this.content=document.createElement(`div`),this.content.style.position=`relative`,this.content.style.userSelect=`none`,this.content.className=`konvajs-content`,this.content.setAttribute(`role`,`presentation`),e.appendChild(this.content),this._resizeDOM()}cache(){return z.warn(`Cache function is not allowed for stage. You may use cache only for layers, groups and shapes.`),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(e){e.batchDraw()}),this}};qs.prototype.nodeType=ms,Ma(qs),V.addGetterSetter(qs,`container`),R.isBrowser&&document.addEventListener(`visibilitychange`,()=>{Ks.forEach(e=>{e.batchDraw()})});var Js=`hasShadow`,Ys=`shadowRGBA`,Xs=`patternImage`,Zs=`linearGradient`,Qs=`radialGradient`,$s;function ec(){return $s||($s=z.createCanvasElement().getContext(`2d`),$s)}var tc={};function nc(e){let t=this.attrs.fillRule;t?e.fill(t):e.fill()}function rc(e){e.stroke()}function ic(e){let t=this.attrs.fillRule;t?e.fill(t):e.fill()}function ac(e){e.stroke()}function oc(){this._clearCache(Js)}function sc(){this._clearCache(Ys)}function cc(){this._clearCache(Xs)}function lc(){this._clearCache(Zs)}function uc(){this._clearCache(Qs)}var U=class extends H{constructor(e){super(e);let t,n=0;for(;t=z.getHitColor(),!(t&&!(t in tc));)if(n++,n>=1e4){z.warn(`Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it.`),t=z.getRandomColor();break}this.colorKey=t,tc[t]=this}getContext(){return z.warn(`shape.getContext() method is deprecated. Please do not use it.`),this.getLayer().getContext()}getCanvas(){return z.warn(`shape.getCanvas() method is deprecated. Please do not use it.`),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(Js,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(Xs,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){let e=ec().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||`repeat`);if(e&&e.setTransform){let t=new Fa;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(R.getAngle(this.fillPatternRotation())),t.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),t.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());let n=t.getMatrix(),r=typeof DOMMatrix>`u`?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);e.setTransform(r)}return e}}_getLinearGradient(){return this._getCache(Zs,this.__getLinearGradient)}__getLinearGradient(){let e=this.fillLinearGradientColorStops();if(e){let t=ec(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),i=t.createLinearGradient(n.x,n.y,r.x,r.y);for(let t=0;t<e.length;t+=2)i.addColorStop(e[t],e[t+1]);return i}}_getRadialGradient(){return this._getCache(Qs,this.__getRadialGradient)}__getRadialGradient(){let e=this.fillRadialGradientColorStops();if(e){let t=ec(),n=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),i=t.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius());for(let t=0;t<e.length;t+=2)i.addColorStop(e[t],e[t+1]);return i}}getShadowRGBA(){return this._getCache(Ys,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;let e=z.colorToRGBA(this.shadowColor());if(e)return`rgba(`+e.r+`,`+e.g+`,`+e.b+`,`+e.a*(this.shadowOpacity()||1)+`)`}hasFill(){return this._calculate(`hasFill`,[`fillEnabled`,`fill`,`fillPatternImage`,`fillLinearGradientColorStops`,`fillRadialGradientColorStops`],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate(`hasStroke`,[`strokeEnabled`,`strokeWidth`,`stroke`,`strokeLinearGradientColorStops`],()=>this.strokeEnabled()&&this.strokeWidth()&&!!(this.stroke()||this.strokeLinearGradientColorStops()))}hasHitStroke(){let e=this.hitStrokeWidth();return e===`auto`?this.hasStroke():this.strokeEnabled()&&!!e}intersects(e){let t=this.getStage();if(!t)return!1;let n=t.bufferHitCanvas;return n.getContext().clear(),this.drawHit(n,void 0,!0),n.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data[3]>0}destroy(){return H.prototype.destroy.call(this),delete tc[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){if(!(this.attrs.perfectDrawEnabled??!0))return!1;let t=e||this.hasFill(),n=this.hasStroke(),r=this.getAbsoluteOpacity()!==1;if(t&&n&&r)return!0;let i=this.hasShadow(),a=this.shadowForStrokeEnabled();return!!(t&&n&&i&&a)}setStrokeHitEnabled(e){z.warn(`strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead.`),e?this.hitStrokeWidth(`auto`):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){let e=this.size();return{x:this._centroid?-e.width/2:0,y:this._centroid?-e.height/2:0,width:e.width,height:e.height}}getClientRect(e={}){let t=!1,n=this.getParent();for(;n;){if(n.isCached()){t=!0;break}n=n.getParent()}let r=e.skipTransform,i=e.relativeTo||t&&this.getStage()||void 0,a=this.getSelfRect(),o=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,s=a.width+o,c=a.height+o,l=!e.skipShadow&&this.hasShadow(),u=l?this.shadowOffsetX():0,d=l?this.shadowOffsetY():0,f=s+Math.abs(u),p=c+Math.abs(d),m=l&&this.shadowBlur()||0,h={width:f+m*2,height:p+m*2,x:-(o/2+m)+Math.min(u,0)+a.x,y:-(o/2+m)+Math.min(d,0)+a.y};return r?h:this._transformedRect(h,i)}drawScene(e,t,n){let r=this.getLayer(),i=(e||r.getCanvas()).getContext(),a=this._getCanvasCache(),o=this.getSceneFunc(),s=this.hasShadow(),c,l=t===this;if(!this.isVisible()&&!l)return this;if(a){i.save();let e=this.getAbsoluteTransform(t).getMatrix();return i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedSceneCanvas(i),i.restore(),this}if(!o)return this;if(i.save(),this._useBufferCanvas()){c=this.getStage();let e=n||c.bufferCanvas,r=e.getContext();n?(r.save(),r.setTransform(1,0,0,1,0,0),r.clearRect(0,0,e.width,e.height),r.restore()):r.clear(),r.save(),r._applyLineJoin(this),r._applyMiterLimit(this);let a=this.getAbsoluteTransform(t).getMatrix();r.transform(a[0],a[1],a[2],a[3],a[4],a[5]),o.call(this,r,this),r.restore();let u=e.pixelRatio;s&&i._applyShadow(this),l||(i._applyOpacity(this),i._applyGlobalCompositeOperation(this)),i.drawImage(e._canvas,e.x||0,e.y||0,e.width/u,e.height/u)}else{if(i._applyLineJoin(this),i._applyMiterLimit(this),!l){let e=this.getAbsoluteTransform(t).getMatrix();i.transform(e[0],e[1],e[2],e[3],e[4],e[5]),i._applyOpacity(this),i._applyGlobalCompositeOperation(this)}s&&i._applyShadow(this),o.call(this,i,this)}return i.restore(),this}drawHit(e,t,n=!1){if(!this.shouldDrawHit(t,n))return this;let r=this.getLayer(),i=e||r.hitCanvas,a=i&&i.getContext(),o=this.hitFunc()||this.sceneFunc(),s=this._getCanvasCache(),c=s&&s.hit;if(this.colorKey||z.warn(`Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()`),c){a.save();let e=this.getAbsoluteTransform(t).getMatrix();return a.transform(e[0],e[1],e[2],e[3],e[4],e[5]),this._drawCachedHitCanvas(a),a.restore(),this}if(!o)return this;if(a.save(),a._applyLineJoin(this),a._applyMiterLimit(this),this!==t){let e=this.getAbsoluteTransform(t).getMatrix();a.transform(e[0],e[1],e[2],e[3],e[4],e[5])}return o.call(this,a,this),a.restore(),this}drawHitFromCache(e=0){let t=this._getCanvasCache(),n=this._getCachedSceneCanvas(),r=t.hit,i=r.getContext(),a=r.getWidth(),o=r.getHeight();i.clear(),i.drawImage(n._canvas,0,0,a,o);try{let t=i.getImageData(0,0,a,o),n=t.data,r=n.length,s=z._hexToRgb(this.colorKey);for(let t=0;t<r;t+=4)n[t+3]>e?(n[t]=s.r,n[t+1]=s.g,n[t+2]=s.b,n[t+3]=255):n[t+3]=0;i.putImageData(t,0,0)}catch(e){z.error(`Unable to draw hit graph from cached scene canvas. `+e.message)}return this}hasPointerCapture(e){return ds(e,this)}setPointerCapture(e){fs(e,this)}releaseCapture(e){ps(e,this)}};U.prototype._fillFunc=nc,U.prototype._strokeFunc=rc,U.prototype._fillFuncHit=ic,U.prototype._strokeFuncHit=ac,U.prototype._centroid=!1,U.prototype.nodeType=`Shape`,Ma(U),U.prototype.eventListeners={},U.prototype.on(`shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva`,oc),U.prototype.on(`shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva`,sc),U.prototype.on(`fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva`,cc),U.prototype.on(`fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva`,lc),U.prototype.on(`fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva`,uc),V.addGetterSetter(U,`stroke`,void 0,Oo()),V.addGetterSetter(U,`strokeWidth`,2,B()),V.addGetterSetter(U,`fillAfterStrokeEnabled`,!1),V.addGetterSetter(U,`hitStrokeWidth`,`auto`,Eo()),V.addGetterSetter(U,`strokeHitEnabled`,!0,Ao()),V.addGetterSetter(U,`perfectDrawEnabled`,!0,Ao()),V.addGetterSetter(U,`shadowForStrokeEnabled`,!0,Ao()),V.addGetterSetter(U,`lineJoin`),V.addGetterSetter(U,`lineCap`),V.addGetterSetter(U,`miterLimit`),V.addGetterSetter(U,`sceneFunc`),V.addGetterSetter(U,`hitFunc`),V.addGetterSetter(U,`dash`),V.addGetterSetter(U,`dashOffset`,0,B()),V.addGetterSetter(U,`shadowColor`,void 0,Do()),V.addGetterSetter(U,`shadowBlur`,0,B()),V.addGetterSetter(U,`shadowOpacity`,1,B()),V.addComponentsGetterSetter(U,`shadowOffset`,[`x`,`y`]),V.addGetterSetter(U,`shadowOffsetX`,0,B()),V.addGetterSetter(U,`shadowOffsetY`,0,B()),V.addGetterSetter(U,`fillPatternImage`),V.addGetterSetter(U,`fill`,void 0,Oo()),V.addGetterSetter(U,`fillPatternX`,0,B()),V.addGetterSetter(U,`fillPatternY`,0,B()),V.addGetterSetter(U,`fillLinearGradientColorStops`),V.addGetterSetter(U,`strokeLinearGradientColorStops`),V.addGetterSetter(U,`fillRadialGradientStartRadius`,0),V.addGetterSetter(U,`fillRadialGradientEndRadius`,0),V.addGetterSetter(U,`fillRadialGradientColorStops`),V.addGetterSetter(U,`fillPatternRepeat`,`repeat`),V.addGetterSetter(U,`fillEnabled`,!0),V.addGetterSetter(U,`strokeEnabled`,!0),V.addGetterSetter(U,`shadowEnabled`,!0),V.addGetterSetter(U,`dashEnabled`,!0),V.addGetterSetter(U,`strokeScaleEnabled`,!0),V.addGetterSetter(U,`fillPriority`,`color`),V.addComponentsGetterSetter(U,`fillPatternOffset`,[`x`,`y`]),V.addGetterSetter(U,`fillPatternOffsetX`,0,B()),V.addGetterSetter(U,`fillPatternOffsetY`,0,B()),V.addComponentsGetterSetter(U,`fillPatternScale`,[`x`,`y`]),V.addGetterSetter(U,`fillPatternScaleX`,1,B()),V.addGetterSetter(U,`fillPatternScaleY`,1,B()),V.addComponentsGetterSetter(U,`fillLinearGradientStartPoint`,[`x`,`y`]),V.addComponentsGetterSetter(U,`strokeLinearGradientStartPoint`,[`x`,`y`]),V.addGetterSetter(U,`fillLinearGradientStartPointX`,0),V.addGetterSetter(U,`strokeLinearGradientStartPointX`,0),V.addGetterSetter(U,`fillLinearGradientStartPointY`,0),V.addGetterSetter(U,`strokeLinearGradientStartPointY`,0),V.addComponentsGetterSetter(U,`fillLinearGradientEndPoint`,[`x`,`y`]),V.addComponentsGetterSetter(U,`strokeLinearGradientEndPoint`,[`x`,`y`]),V.addGetterSetter(U,`fillLinearGradientEndPointX`,0),V.addGetterSetter(U,`strokeLinearGradientEndPointX`,0),V.addGetterSetter(U,`fillLinearGradientEndPointY`,0),V.addGetterSetter(U,`strokeLinearGradientEndPointY`,0),V.addComponentsGetterSetter(U,`fillRadialGradientStartPoint`,[`x`,`y`]),V.addGetterSetter(U,`fillRadialGradientStartPointX`,0),V.addGetterSetter(U,`fillRadialGradientStartPointY`,0),V.addComponentsGetterSetter(U,`fillRadialGradientEndPoint`,[`x`,`y`]),V.addGetterSetter(U,`fillRadialGradientEndPointX`,0),V.addGetterSetter(U,`fillRadialGradientEndPointY`,0),V.addGetterSetter(U,`fillPatternRotation`,0),V.addGetterSetter(U,`fillRule`,void 0,Do()),V.backCompat(U,{dashArray:`dash`,getDashArray:`getDash`,setDashArray:`getDash`,drawFunc:`sceneFunc`,getDrawFunc:`getSceneFunc`,setDrawFunc:`setSceneFunc`,drawHitFunc:`hitFunc`,getDrawHitFunc:`getHitFunc`,setDrawHitFunc:`setHitFunc`});var dc=`beforeDraw`,fc=`draw`,pc=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],mc=pc.length,hc=class extends os{constructor(e){super(e),this.canvas=new bo,this.hitCanvas=new xo({pixelRatio:1}),this._waitingForDraw=!1,this.on(`visibleChange.konva`,this._checkVisibility),this._checkVisibility(),this.on(`imageSmoothingEnabledChange.konva`,this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);let t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),e<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[e+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){H.prototype.moveToTop.call(this);let e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!H.prototype.moveUp.call(this))return!1;let e=this.getStage();return!e||!e.content?!1:(e.content.removeChild(this.getNativeCanvasElement()),this.index<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[this.index+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(H.prototype.moveDown.call(this)){let e=this.getStage();if(e){let t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(H.prototype.moveToBottom.call(this)){let e=this.getStage();if(e){let t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){let e=this.getNativeCanvasElement();return H.prototype.remove.call(this),e&&e.parentNode&&z._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:t}){return this.canvas.setSize(e,t),this.hitCanvas.setSize(e,t),this._setSmoothEnabled(),this}_validateAdd(e){let t=e.getType();t!==`Group`&&t!==`Shape`&&z.throw(`You may only add groups and shapes to a layer.`)}_toKonvaCanvas(e){return e={...e},e.width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=e.x===void 0?this.x():e.x,e.y=e.y===void 0?this.y():e.y,H.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){this.visible()?this.canvas._canvas.style.display=`block`:this.canvas._canvas.style.display=`none`}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){z.warn(`Can not change width of layer. Use "stage.width(value)" function instead.`)}getHeight(){if(this.parent)return this.parent.height()}setHeight(){z.warn(`Can not change height of layer. Use "stage.height(value)" function instead.`)}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,z.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;let t=1,n=!1;for(;;){for(let r=0;r<mc;r++){let i=pc[r],a=this._getIntersection({x:e.x+i.x*t,y:e.y+i.y*t}),o=a.shape;if(o)return o;if(n=!!a.antialiased,!a.antialiased)break}if(n)t+=1;else return null}}_getIntersection(e){let t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.round(e.x*t),Math.round(e.y*t),1,1).data,r=n[3];if(r===255){let e=tc[z.getHitColorKey(n[0],n[1],n[2])];return e?{shape:e}:{antialiased:!0}}else if(r>0)return{antialiased:!0};return{}}drawScene(e,t,n){let r=this.getLayer(),i=e||r&&r.getCanvas();return this._fire(dc,{node:this}),this.clearBeforeDraw()&&i.getContext().clear(),os.prototype.drawScene.call(this,i,t,n),this._fire(fc,{node:this}),this}drawHit(e,t){let n=this.getLayer(),r=e||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),os.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){z.warn(`hitGraphEnabled method is deprecated. Please use layer.listening() instead.`),this.listening(e)}getHitGraphEnabled(e){return z.warn(`hitGraphEnabled method is deprecated. Please use layer.listening() instead.`),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;let e=this.parent;this.hitCanvas._canvas.parentNode?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}destroy(){return z.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};hc.prototype.nodeType=`Layer`,Ma(hc),V.addGetterSetter(hc,`imageSmoothingEnabled`,!0),V.addGetterSetter(hc,`clearBeforeDraw`,!0),V.addGetterSetter(hc,`hitGraphEnabled`,!0,Ao());var gc=class extends hc{constructor(e){super(e),this.listening(!1),z.warn(`Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.`)}};gc.prototype.nodeType=`FastLayer`,Ma(gc);var _c=class extends os{_validateAdd(e){let t=e.getType();t!==`Group`&&t!==`Shape`&&z.throw(`You may only add groups and shapes to groups.`)}};_c.prototype.nodeType=`Group`,Ma(_c);var vc=(function(){return ja.performance&&ja.performance.now?function(){return ja.performance.now()}:function(){return new Date().getTime()}})(),yc=class e{constructor(t,n){this.id=e.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:vc(),frameRate:0},this.func=t,this.setLayers(n)}setLayers(e){let t=[];return e&&(t=Array.isArray(e)?e:[e]),this.layers=t,this}getLayers(){return this.layers}addLayer(e){let t=this.layers,n=t.length;for(let r=0;r<n;r++)if(t[r]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){let t=e.animations,n=t.length;for(let e=0;e<n;e++)if(t[e].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=vc(),e._addAnimation(this),this}stop(){return e._removeAnimation(this),this}_updateFrameObject(e){this.frame.timeDiff=e-this.frame.lastTime,this.frame.lastTime=e,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(e){this.animations.push(e),this._handleAnimation()}static _removeAnimation(e){let t=e.id,n=this.animations,r=n.length;for(let e=0;e<r;e++)if(n[e].id===t){this.animations.splice(e,1);break}}static _runFrames(){let e={},t=this.animations;for(let n=0;n<t.length;n++){let r=t[n],i=r.layers,a=r.func;r._updateFrameObject(vc());let o=i.length,s;if(s=a?a.call(r,r.frame)!==!1:!0,s)for(let t=0;t<o;t++){let n=i[t];n._id!==void 0&&(e[n._id]=n)}}for(let t in e)e.hasOwnProperty(t)&&e[t].batchDraw()}static _animationLoop(){let t=e;t.animations.length?(t._runFrames(),z.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,z.requestAnimFrame(this._animationLoop))}};yc.animations=[],yc.animIdCounter=0,yc.animRunning=!1;var bc={node:1,duration:1,easing:1,onFinish:1,yoyo:1},xc=1,Sc=2,Cc=3,wc=[`fill`,`stroke`,`shadowColor`],Tc=0,Ec=class{constructor(e,t,n,r,i,a,o){this.prop=e,this.propFunc=t,this.begin=r,this._pos=r,this.duration=a,this._change=0,this.prevPos=0,this.yoyo=o,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=i-this.begin,this.pause()}fire(e){let t=this[e];t&&t()}setTime(e){e>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return e===void 0&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=Sc,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire(`onPlay`)}reverse(){this.state=Cc,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire(`onReverse`)}seek(e){this.pause(),this._time=e,this.update(),this.fire(`onSeek`)}reset(){this.pause(),this._time=0,this.update(),this.fire(`onReset`)}finish(){this.pause(),this._time=this.duration,this.update(),this.fire(`onFinish`)}update(){this.setPosition(this.getPosition(this._time)),this.fire(`onUpdate`)}onEnterFrame(){let e=this.getTimer()-this._startTime;this.state===Sc?this.setTime(e):this.state===Cc&&this.setTime(this.duration-e)}pause(){this.state=xc,this.fire(`onPause`)}getTimer(){return new Date().getTime()}},Dc=class e{constructor(t){let n=this,r=t.node,i=r._id,a=t.easing||Oc.Linear,o=!!t.yoyo,s,c;s=t.duration===void 0?.3:t.duration===0?.001:t.duration,this.node=r,this._id=Tc++;let l=r.getLayer()||(r instanceof R.Stage?r.getLayers():null);for(c in l||z.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new yc(function(){n.tween.onEnterFrame()},l),this.tween=new Ec(c,function(e){n._tweenFunc(e)},a,0,1,s*1e3,o),this._addListeners(),e.attrs[i]||(e.attrs[i]={}),e.attrs[i][this._id]||(e.attrs[i][this._id]={}),e.tweens[i]||(e.tweens[i]={}),t)bc[c]===void 0&&this._addAttr(c,t[c]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,n){let r=this.node,i=r._id,a,o,s,c,l,u=e.tweens[i][t];u&&delete e.attrs[i][u][t];let d=r.getAttr(t);if(z._isArray(n))if(a=[],o=Math.max(n.length,d.length),t===`points`&&n.length!==d.length&&(n.length>d.length?(c=d,d=z._prepareArrayForTween(d,n,r.closed())):(s=n,n=z._prepareArrayForTween(n,d,r.closed()))),t.indexOf(`fill`)===0)for(let e=0;e<o;e++)if(e%2==0)a.push(n[e]-d[e]);else{let t=z.colorToRGBA(d[e]);l=z.colorToRGBA(n[e]),d[e]=t,a.push({r:l.r-t.r,g:l.g-t.g,b:l.b-t.b,a:l.a-t.a})}else for(let e=0;e<o;e++)a.push(n[e]-d[e]);else wc.indexOf(t)===-1?a=n-d:(d=z.colorToRGBA(d),l=z.colorToRGBA(n),a={r:l.r-d.r,g:l.g-d.g,b:l.b-d.b,a:l.a-d.a});e.attrs[i][this._id][t]={start:d,diff:a,end:n,trueEnd:s,trueStart:c},e.tweens[i][t]=this._id}_tweenFunc(t){let n=this.node,r=e.attrs[n._id][this._id],i,a,o,s,c,l,u,d;for(i in r){if(a=r[i],o=a.start,s=a.diff,d=a.end,z._isArray(o))if(c=[],u=Math.max(o.length,d.length),i.indexOf(`fill`)===0)for(l=0;l<u;l++)l%2==0?c.push((o[l]||0)+s[l]*t):c.push(`rgba(`+Math.round(o[l].r+s[l].r*t)+`,`+Math.round(o[l].g+s[l].g*t)+`,`+Math.round(o[l].b+s[l].b*t)+`,`+(o[l].a+s[l].a*t)+`)`);else for(l=0;l<u;l++)c.push((o[l]||0)+s[l]*t);else c=wc.indexOf(i)===-1?o+s*t:`rgba(`+Math.round(o.r+s.r*t)+`,`+Math.round(o.g+s.g*t)+`,`+Math.round(o.b+s.b*t)+`,`+(o.a+s.a*t)+`)`;n.setAttr(i,c)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{let t=this.node,n=e.attrs[t._id][this._id];n.points&&n.points.trueEnd&&t.setAttr(`points`,n.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{let t=this.node,n=e.attrs[t._id][this._id];n.points&&n.points.trueStart&&t.points(n.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(e){return this.tween.seek(e*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){let t=this.node._id,n=this._id,r=e.tweens[t];this.pause(),this.anim&&this.anim.stop();for(let n in r)delete e.tweens[t][n];delete e.attrs[t][n],e.tweens[t]&&(Object.keys(e.tweens[t]).length===0&&delete e.tweens[t],Object.keys(e.attrs[t]).length===0&&delete e.attrs[t])}};Dc.attrs={},Dc.tweens={},H.prototype.to=function(e){let t=e.onFinish;e.node=this,e.onFinish=function(){this.destroy(),t&&t()},new Dc(e).play()};var Oc={BackEaseIn(e,t,n,r){return n*(e/=r)*e*(2.70158*e-1.70158)+t},BackEaseOut(e,t,n,r){return n*((e=e/r-1)*e*(2.70158*e+1.70158)+1)+t},BackEaseInOut(e,t,n,r){let i=1.70158;return(e/=r/2)<1?n/2*(e*e*(((i*=1.525)+1)*e-i))+t:n/2*((e-=2)*e*(((i*=1.525)+1)*e+i)+2)+t},ElasticEaseIn(e,t,n,r,i,a){let o=0;return e===0?t:(e/=r)===1?t+n:(a||=r*.3,!i||i<Math.abs(n)?(i=n,o=a/4):o=a/(2*Math.PI)*Math.asin(n/i),-(i*2**(10*--e)*Math.sin((e*r-o)*(2*Math.PI)/a))+t)},ElasticEaseOut(e,t,n,r,i,a){let o=0;return e===0?t:(e/=r)===1?t+n:(a||=r*.3,!i||i<Math.abs(n)?(i=n,o=a/4):o=a/(2*Math.PI)*Math.asin(n/i),i*2**(-10*e)*Math.sin((e*r-o)*(2*Math.PI)/a)+n+t)},ElasticEaseInOut(e,t,n,r,i,a){let o=0;return e===0?t:(e/=r/2)==2?t+n:(a||=.3*1.5*r,!i||i<Math.abs(n)?(i=n,o=a/4):o=a/(2*Math.PI)*Math.asin(n/i),e<1?-.5*(i*2**(10*--e)*Math.sin((e*r-o)*(2*Math.PI)/a))+t:i*2**(-10*--e)*Math.sin((e*r-o)*(2*Math.PI)/a)*.5+n+t)},BounceEaseOut(e,t,n,r){return(e/=r)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t},BounceEaseIn(e,t,n,r){return n-Oc.BounceEaseOut(r-e,0,n,r)+t},BounceEaseInOut(e,t,n,r){return e<r/2?Oc.BounceEaseIn(e*2,0,n,r)*.5+t:Oc.BounceEaseOut(e*2-r,0,n,r)*.5+n*.5+t},EaseIn(e,t,n,r){return n*(e/=r)*e+t},EaseOut(e,t,n,r){return-n*(e/=r)*(e-2)+t},EaseInOut(e,t,n,r){return(e/=r/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t},StrongEaseIn(e,t,n,r){return n*(e/=r)*e*e*e*e+t},StrongEaseOut(e,t,n,r){return n*((e=e/r-1)*e*e*e*e+1)+t},StrongEaseInOut(e,t,n,r){return(e/=r/2)<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t},Linear(e,t,n,r){return n*e/r+t}},kc=z._assign(R,{Util:z,Transform:Fa,Node:H,Container:os,Stage:qs,stages:Ks,Layer:hc,FastLayer:gc,Group:_c,DD:So,Shape:U,shapes:tc,Animation:yc,Tween:Dc,Easings:Oc,Context:mo,Canvas:yo}),Ac=class extends U{_sceneFunc(e){let t=R.getAngle(this.angle()),n=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,t,n),e.arc(0,0,this.innerRadius(),t,0,!n),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){let e=this.innerRadius(),t=this.outerRadius(),n=this.clockwise(),r=R.getAngle(n?360-this.angle():this.angle()),i=Math.cos(Math.min(r,Math.PI)),a=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),o=Math.sin(Math.min(r,Math.PI/2)),s=i*(i>0?e:t),c=1*t,l=a*(a>0?e:t),u=o*(o>0?t:e);return{x:s,y:n?-1*u:l,width:c-s,height:u-l}}};Ac.prototype._centroid=!0,Ac.prototype.className=`Arc`,Ac.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`,`angle`,`clockwise`],Ma(Ac),V.addGetterSetter(Ac,`innerRadius`,0,B()),V.addGetterSetter(Ac,`outerRadius`,0,B()),V.addGetterSetter(Ac,`angle`,0,B()),V.addGetterSetter(Ac,`clockwise`,!1,Ao());function jc(e,t,n,r,i,a,o){let s=Math.sqrt((n-e)**2+(r-t)**2),c=Math.sqrt((i-n)**2+(a-r)**2),l=o*s/(s+c),u=o*c/(s+c);return[n-l*(i-e),r-l*(a-t),n+u*(i-e),r+u*(a-t)]}function Mc(e,t){let n=e.length,r=[];for(let i=2;i<n-2;i+=2){let n=jc(e[i-2],e[i-1],e[i],e[i+1],e[i+2],e[i+3],t);isNaN(n[0])||(r.push(n[0]),r.push(n[1]),r.push(e[i]),r.push(e[i+1]),r.push(n[2]),r.push(n[3]))}return r}function Nc(e){let t=[[e[0],e[2],e[4],e[6]],[e[1],e[3],e[5],e[7]]],n=[];for(let e of t){let t=-3*e[0]+9*e[1]-9*e[2]+3*e[3];if(t!==0){let r=6*e[0]-12*e[1]+6*e[2],i=-3*e[0]+3*e[1],a=r*r-4*t*i;if(a>=0){let e=Math.sqrt(a);n.push((-r+e)/(2*t)),n.push((-r-e)/(2*t))}}}return n.filter(e=>e>0&&e<1).flatMap(e=>t.map(t=>{let n=1-e;return n*n*n*t[0]+3*n*n*e*t[1]+3*n*e*e*t[2]+e*e*e*t[3]}))}var Pc=class extends U{constructor(e){super(e),this.on(`pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva`,function(){this._clearCache(`tensionPoints`)})}_sceneFunc(e){let t=this.points(),n=t.length,r=this.tension(),i=this.closed(),a=this.bezier();if(!n)return;let o=0;if(e.beginPath(),e.moveTo(t[0],t[1]),r!==0&&n>4){let r=this.getTensionPoints(),a=r.length;for(o=i?0:4,i||e.quadraticCurveTo(r[0],r[1],r[2],r[3]);o<a-2;)e.bezierCurveTo(r[o++],r[o++],r[o++],r[o++],r[o++],r[o++]);i||e.quadraticCurveTo(r[a-2],r[a-1],t[n-2],t[n-1])}else if(a)for(o=2;o<n;)e.bezierCurveTo(t[o++],t[o++],t[o++],t[o++],t[o++],t[o++]);else for(o=2;o<n;o+=2)e.lineTo(t[o],t[o+1]);i?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}getTensionPoints(){return this._getCache(`tensionPoints`,this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():Mc(this.points(),this.tension())}_getTensionPointsClosed(){let e=this.points(),t=e.length,n=this.tension(),r=jc(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),i=jc(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),a=Mc(e,n);return[r[2],r[3]].concat(a,[i[0],i[1],e[t-2],e[t-1],i[2],i[3],r[0],r[1],e[0],e[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};e=this.tension()===0?this.bezier()?[e[0],e[1],...Nc(this.points()),e[e.length-2],e[e.length-1]]:this.points():[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]];let t=e[0],n=e[0],r=e[1],i=e[1],a,o;for(let s=0;s<e.length/2;s++)a=e[s*2],o=e[s*2+1],t=Math.min(t,a),n=Math.max(n,a),r=Math.min(r,o),i=Math.max(i,o);return{x:t,y:r,width:n-t,height:i-r}}};Pc.prototype.className=`Line`,Pc.prototype._attrsAffectingSize=[`points`,`bezier`,`tension`],Ma(Pc),V.addGetterSetter(Pc,`closed`,!1),V.addGetterSetter(Pc,`bezier`,!1),V.addGetterSetter(Pc,`tension`,0,B()),V.addGetterSetter(Pc,`points`,[],ko());var Fc=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],Ic=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],Lc=[[1],[1,1],[1,2,1],[1,3,3,1]],Rc=(e,t,n)=>{let r,i,a=n/2;r=0;for(let n=0;n<20;n++)i=a*Fc[20][n]+a,r+=Ic[20][n]*Bc(e,t,i);return a*r},zc=(e,t,n)=>{n===void 0&&(n=1);let r=e[0]-2*e[1]+e[2],i=t[0]-2*t[1]+t[2],a=2*e[1]-2*e[0],o=2*t[1]-2*t[0],s=4*(r*r+i*i),c=4*(r*a+i*o),l=a*a+o*o;if(s===0)return n*Math.sqrt((e[2]-e[0])**2+(t[2]-t[0])**2);let u=c/(2*s),d=l/s,f=n+u,p=d-u*u,m=f*f+p>0?Math.sqrt(f*f+p):0,h=u*u+p>0?Math.sqrt(u*u+p):0,g=u+Math.sqrt(u*u+p)===0?0:p*Math.log(Math.abs((f+m)/(u+h)));return Math.sqrt(s)/2*(f*m-u*h+g)};function Bc(e,t,n){let r=Vc(1,n,e),i=Vc(1,n,t),a=r*r+i*i;return Math.sqrt(a)}var Vc=(e,t,n)=>{let r=n.length-1,i,a;if(r===0)return 0;if(e===0){a=0;for(let e=0;e<=r;e++)a+=Lc[r][e]*(1-t)**(r-e)*t**+e*n[e];return a}else{i=Array(r);for(let e=0;e<r;e++)i[e]=r*(n[e+1]-n[e]);return Vc(e-1,t,i)}},Hc=(e,t,n)=>{let r=1,i=e/t,a=(e-n(i))/t,o=0;for(;r>.001;){let s=n(i+a),c=Math.abs(e-s)/t;if(c<r)r=c,i+=a;else{let o=n(i-a),s=Math.abs(e-o)/t;s<r?(r=s,i-=a):a/=2}if(o++,o>500)break}return i},Uc=class e extends U{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on(`dataChange.konva`,function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=e.parsePathData(this.data()),this.pathLength=e.getPathLength(this.dataArray)}_sceneFunc(e){let t=this.dataArray;e.beginPath();let n=!1;for(let r=0;r<t.length;r++){let i=t[r].command,a=t[r].points;switch(i){case`L`:e.lineTo(a[0],a[1]);break;case`M`:e.moveTo(a[0],a[1]);break;case`C`:e.bezierCurveTo(a[0],a[1],a[2],a[3],a[4],a[5]);break;case`Q`:e.quadraticCurveTo(a[0],a[1],a[2],a[3]);break;case`A`:let t=a[0],r=a[1],i=a[2],o=a[3],s=a[4],c=a[5],l=a[6],u=a[7],d=i>o?i:o,f=i>o?1:i/o,p=i>o?o/i:1;e.translate(t,r),e.rotate(l),e.scale(f,p),e.arc(0,0,d,s,s+c,1-u),e.scale(1/f,1/p),e.rotate(-l),e.translate(-t,-r);break;case`z`:n=!0,e.closePath();break}}!n&&!this.hasFill()?e.strokeShape(this):e.fillStrokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach(function(n){if(n.command===`A`){let r=n.points[4],i=n.points[5],a=n.points[4]+i,o=Math.PI/180;if(Math.abs(r-a)<o&&(o=Math.abs(r-a)),i<0)for(let i=r-o;i>a;i-=o){let r=e.getPointOnEllipticalArc(n.points[0],n.points[1],n.points[2],n.points[3],i,0);t.push(r.x,r.y)}else for(let i=r+o;i<a;i+=o){let r=e.getPointOnEllipticalArc(n.points[0],n.points[1],n.points[2],n.points[3],i,0);t.push(r.x,r.y)}}else if(n.command===`C`)for(let r=0;r<=1;r+=.01){let i=e.getPointOnCubicBezier(r,n.start.x,n.start.y,n.points[0],n.points[1],n.points[2],n.points[3],n.points[4],n.points[5]);t.push(i.x,i.y)}else t=t.concat(n.points)});let n=t[0],r=t[0],i=t[1],a=t[1],o,s;for(let e=0;e<t.length/2;e++)o=t[e*2],s=t[e*2+1],isNaN(o)||(n=Math.min(n,o),r=Math.max(r,o)),isNaN(s)||(i=Math.min(i,s),a=Math.max(a,s));return{x:n,y:i,width:r-n,height:a-i}}getLength(){return this.pathLength}getPointAtLength(t){return e.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(e,t,n,r){return Math.sqrt((n-e)*(n-e)+(r-t)*(r-t))}static getPathLength(e){let t=0;for(let n=0;n<e.length;++n)t+=e[n].pathLength;return t}static getPointAtLengthOfDataArray(t,n){let r,i=0,a=n.length;if(!a)return null;for(;i<a&&t>n[i].pathLength;)t-=n[i].pathLength,++i;if(i===a)return r=n[i-1].points.slice(-2),{x:r[0],y:r[1]};if(t<.01)return n[i].command===`M`?(r=n[i].points.slice(0,2),{x:r[0],y:r[1]}):{x:n[i].start.x,y:n[i].start.y};let o=n[i],s=o.points;switch(o.command){case`L`:return e.getPointOnLine(t,o.start.x,o.start.y,s[0],s[1]);case`C`:return e.getPointOnCubicBezier(Hc(t,e.getPathLength(n),e=>Rc([o.start.x,s[0],s[2],s[4]],[o.start.y,s[1],s[3],s[5]],e)),o.start.x,o.start.y,s[0],s[1],s[2],s[3],s[4],s[5]);case`Q`:return e.getPointOnQuadraticBezier(Hc(t,e.getPathLength(n),e=>zc([o.start.x,s[0],s[2]],[o.start.y,s[1],s[3]],e)),o.start.x,o.start.y,s[0],s[1],s[2],s[3]);case`A`:let r=s[0],i=s[1],a=s[2],c=s[3],l=s[5],u=s[6],d=s[4];return d+=l*t/o.pathLength,e.getPointOnEllipticalArc(r,i,a,c,d,u)}return null}static getPointOnLine(e,t,n,r,i,a,o){a??=t,o??=n;let s=this.getLineLength(t,n,r,i);if(s<1e-10)return{x:t,y:n};if(r===t)return{x:a,y:o+(i>n?e:-e)};let c=(i-n)/(r-t),l=Math.sqrt(e*e/(1+c*c))*(r<t?-1:1),u=c*l;if(Math.abs(o-n-c*(a-t))<1e-10)return{x:a+l,y:o+u};let d=((a-t)*(r-t)+(o-n)*(i-n))/(s*s),f=t+d*(r-t),p=n+d*(i-n),m=this.getLineLength(a,o,f,p),h=Math.sqrt(e*e-m*m),g=Math.sqrt(h*h/(1+c*c))*(r<t?-1:1),_=c*g;return{x:f+g,y:p+_}}static getPointOnCubicBezier(e,t,n,r,i,a,o,s,c){function l(e){return e*e*e}function u(e){return 3*e*e*(1-e)}function d(e){return 3*e*(1-e)*(1-e)}function f(e){return(1-e)*(1-e)*(1-e)}return{x:s*l(e)+a*u(e)+r*d(e)+t*f(e),y:c*l(e)+o*u(e)+i*d(e)+n*f(e)}}static getPointOnQuadraticBezier(e,t,n,r,i,a,o){function s(e){return e*e}function c(e){return 2*e*(1-e)}function l(e){return(1-e)*(1-e)}return{x:a*s(e)+r*c(e)+t*l(e),y:o*s(e)+i*c(e)+n*l(e)}}static getPointOnEllipticalArc(e,t,n,r,i,a){let o=Math.cos(a),s=Math.sin(a),c={x:n*Math.cos(i),y:r*Math.sin(i)};return{x:e+(c.x*o-c.y*s),y:t+(c.x*s+c.y*o)}}static parsePathData(e){if(!e)return[];let t=e,n=[`m`,`M`,`l`,`L`,`v`,`V`,`h`,`H`,`z`,`Z`,`c`,`C`,`q`,`Q`,`t`,`T`,`s`,`S`,`a`,`A`];t=t.replace(RegExp(` `,`g`),`,`);for(let e=0;e<n.length;e++)t=t.replace(new RegExp(n[e],`g`),`|`+n[e]);let r=t.split(`|`),i=[],a=[],o=0,s=0,c=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,l;for(let e=1;e<r.length;e++){let t=r[e],n=t.charAt(0);for(t=t.slice(1),a.length=0;l=c.exec(t);)a.push(l[0]);let u=[],d=n===`A`||n===`a`?0:-1;for(let e=0,t=a.length;e<t;e++){let t=a[e];if(t===`00`){u.push(0,0),d>=0&&(d+=2,d>=7&&(d-=7));continue}if(d>=0){if(d===3){if(/^[01]{2}\d+(?:\.\d+)?$/.test(t)){u.push(parseInt(t[0],10)),u.push(parseInt(t[1],10)),u.push(parseFloat(t.slice(2))),d+=3,d>=7&&(d-=7);continue}if(t===`11`||t===`10`||t===`01`){u.push(parseInt(t[0],10)),u.push(parseInt(t[1],10)),d+=2,d>=7&&(d-=7);continue}if(t===`0`||t===`1`){u.push(parseInt(t,10)),d+=1,d>=7&&(d-=7);continue}}else if(d===4){if(/^[01]\d+(?:\.\d+)?$/.test(t)){u.push(parseInt(t[0],10)),u.push(parseFloat(t.slice(1))),d+=2,d>=7&&(d-=7);continue}if(t===`0`||t===`1`){u.push(parseInt(t,10)),d+=1,d>=7&&(d-=7);continue}}let e=parseFloat(t);isNaN(e)?u.push(0):u.push(e),d+=1,d>=7&&(d-=7)}else{let e=parseFloat(t);isNaN(e)?u.push(0):u.push(e)}}for(;u.length>0&&!isNaN(u[0]);){let e=``,t=[],r=o,a=s,c,l,d,f,p,m,h,g,_,v;switch(n){case`l`:o+=u.shift(),s+=u.shift(),e=`L`,t.push(o,s);break;case`L`:o=u.shift(),s=u.shift(),t.push(o,s);break;case`m`:let r=u.shift(),a=u.shift();if(o+=r,s+=a,e=`M`,i.length>2&&i[i.length-1].command===`z`){for(let e=i.length-2;e>=0;e--)if(i[e].command===`M`){o=i[e].points[0]+r,s=i[e].points[1]+a;break}}t.push(o,s),n=`l`;break;case`M`:o=u.shift(),s=u.shift(),e=`M`,t.push(o,s),n=`L`;break;case`h`:o+=u.shift(),e=`L`,t.push(o,s);break;case`H`:o=u.shift(),e=`L`,t.push(o,s);break;case`v`:s+=u.shift(),e=`L`,t.push(o,s);break;case`V`:s=u.shift(),e=`L`,t.push(o,s);break;case`C`:t.push(u.shift(),u.shift(),u.shift(),u.shift()),o=u.shift(),s=u.shift(),t.push(o,s);break;case`c`:t.push(o+u.shift(),s+u.shift(),o+u.shift(),s+u.shift()),o+=u.shift(),s+=u.shift(),e=`C`,t.push(o,s);break;case`S`:l=o,d=s,c=i[i.length-1],c.command===`C`&&(l=o+(o-c.points[2]),d=s+(s-c.points[3])),t.push(l,d,u.shift(),u.shift()),o=u.shift(),s=u.shift(),e=`C`,t.push(o,s);break;case`s`:l=o,d=s,c=i[i.length-1],c.command===`C`&&(l=o+(o-c.points[2]),d=s+(s-c.points[3])),t.push(l,d,o+u.shift(),s+u.shift()),o+=u.shift(),s+=u.shift(),e=`C`,t.push(o,s);break;case`Q`:t.push(u.shift(),u.shift()),o=u.shift(),s=u.shift(),t.push(o,s);break;case`q`:t.push(o+u.shift(),s+u.shift()),o+=u.shift(),s+=u.shift(),e=`Q`,t.push(o,s);break;case`T`:l=o,d=s,c=i[i.length-1],c.command===`Q`&&(l=o+(o-c.points[0]),d=s+(s-c.points[1])),o=u.shift(),s=u.shift(),e=`Q`,t.push(l,d,o,s);break;case`t`:l=o,d=s,c=i[i.length-1],c.command===`Q`&&(l=o+(o-c.points[0]),d=s+(s-c.points[1])),o+=u.shift(),s+=u.shift(),e=`Q`,t.push(l,d,o,s);break;case`A`:f=u.shift(),p=u.shift(),m=u.shift(),h=u.shift(),g=u.shift(),_=o,v=s,o=u.shift(),s=u.shift(),e=`A`,t=this.convertEndpointToCenterParameterization(_,v,o,s,h,g,f,p,m);break;case`a`:f=u.shift(),p=u.shift(),m=u.shift(),h=u.shift(),g=u.shift(),_=o,v=s,o+=u.shift(),s+=u.shift(),e=`A`,t=this.convertEndpointToCenterParameterization(_,v,o,s,h,g,f,p,m);break}i.push({command:e||n,points:t,start:{x:r,y:a},pathLength:this.calcLength(r,a,e||n,t)})}(n===`z`||n===`Z`)&&i.push({command:`z`,points:[],start:void 0,pathLength:0})}return i}static calcLength(t,n,r,i){let a,o,s,c,l=e;switch(r){case`L`:return l.getLineLength(t,n,i[0],i[1]);case`C`:return Rc([t,i[0],i[2],i[4]],[n,i[1],i[3],i[5]],1);case`Q`:return zc([t,i[0],i[2]],[n,i[1],i[3]],1);case`A`:a=0;let e=i[4],r=i[5],u=i[4]+r,d=Math.PI/180;if(Math.abs(e-u)<d&&(d=Math.abs(e-u)),o=l.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],e,0),r<0)for(c=e-d;c>u;c-=d)s=l.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],c,0),a+=l.getLineLength(o.x,o.y,s.x,s.y),o=s;else for(c=e+d;c<u;c+=d)s=l.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],c,0),a+=l.getLineLength(o.x,o.y,s.x,s.y),o=s;return s=l.getPointOnEllipticalArc(i[0],i[1],i[2],i[3],u,0),a+=l.getLineLength(o.x,o.y,s.x,s.y),a}return 0}static convertEndpointToCenterParameterization(e,t,n,r,i,a,o,s,c){let l=Math.PI/180*c,u=Math.cos(l)*(e-n)/2+Math.sin(l)*(t-r)/2,d=-1*Math.sin(l)*(e-n)/2+Math.cos(l)*(t-r)/2,f=u*u/(o*o)+d*d/(s*s);f>1&&(o*=Math.sqrt(f),s*=Math.sqrt(f));let p=Math.sqrt((o*o*(s*s)-o*o*(d*d)-s*s*(u*u))/(o*o*(d*d)+s*s*(u*u)));i===a&&(p*=-1),isNaN(p)&&(p=0);let m=p*o*d/s,h=p*-s*u/o,g=(e+n)/2+Math.cos(l)*m-Math.sin(l)*h,_=(t+r)/2+Math.sin(l)*m+Math.cos(l)*h,v=function(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])},y=function(e,t){return(e[0]*t[0]+e[1]*t[1])/(v(e)*v(t))},b=function(e,t){return(e[0]*t[1]<e[1]*t[0]?-1:1)*Math.acos(y(e,t))},x=b([1,0],[(u-m)/o,(d-h)/s]),S=[(u-m)/o,(d-h)/s],C=[(-1*u-m)/o,(-1*d-h)/s],w=b(S,C);return y(S,C)<=-1&&(w=Math.PI),y(S,C)>=1&&(w=0),a===0&&w>0&&(w-=2*Math.PI),a===1&&w<0&&(w+=2*Math.PI),[g,_,o,s,x,w,l,a]}};Uc.prototype.className=`Path`,Uc.prototype._attrsAffectingSize=[`data`],Ma(Uc),V.addGetterSetter(Uc,`data`);var Wc=class extends Pc{_sceneFunc(e){super._sceneFunc(e);let t=Math.PI*2,n=this.points(),r=n,i=this.tension()!==0&&n.length>4;i&&(r=this.getTensionPoints());let a=this.pointerLength(),o=n.length,s,c;if(i){let e=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],n[o-2],n[o-1]],t=Uc.calcLength(r[r.length-4],r[r.length-3],`C`,e),i=Uc.getPointOnQuadraticBezier(Math.min(1,1-a/t),e[0],e[1],e[2],e[3],e[4],e[5]);s=n[o-2]-i.x,c=n[o-1]-i.y}else s=n[o-2]-n[o-4],c=n[o-1]-n[o-3];let l=(Math.atan2(c,s)+t)%t,u=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(n[o-2],n[o-1]),e.rotate(l),e.moveTo(0,0),e.lineTo(-a,u/2),e.lineTo(-a,-u/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(n[0],n[1]),i?(s=(r[0]+r[2])/2-n[0],c=(r[1]+r[3])/2-n[1]):(s=n[2]-n[0],c=n[3]-n[1]),e.rotate((Math.atan2(-c,-s)+t)%t),e.moveTo(0,0),e.lineTo(-a,u/2),e.lineTo(-a,-u/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){let t=this.dashEnabled();t&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),t&&(this.attrs.dashEnabled=!0)}getSelfRect(){let e=super.getSelfRect(),t=this.pointerWidth()/2;return{x:e.x,y:e.y-t,width:e.width,height:e.height+t*2}}};Wc.prototype.className=`Arrow`,Ma(Wc),V.addGetterSetter(Wc,`pointerLength`,10,B()),V.addGetterSetter(Wc,`pointerWidth`,10,B()),V.addGetterSetter(Wc,`pointerAtBeginning`,!1),V.addGetterSetter(Wc,`pointerAtEnding`,!0);var Gc=class extends U{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}};Gc.prototype._centroid=!0,Gc.prototype.className=`Circle`,Gc.prototype._attrsAffectingSize=[`radius`],Ma(Gc),V.addGetterSetter(Gc,`radius`,0,B());var Kc=class extends U{_sceneFunc(e){let t=this.radiusX(),n=this.radiusY();e.beginPath(),e.save(),t!==n&&e.scale(1,n/t),e.arc(0,0,t,0,Math.PI*2,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radiusX()*2}getHeight(){return this.radiusY()*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}};Kc.prototype.className=`Ellipse`,Kc.prototype._centroid=!0,Kc.prototype._attrsAffectingSize=[`radiusX`,`radiusY`],Ma(Kc),V.addComponentsGetterSetter(Kc,`radius`,[`x`,`y`]),V.addGetterSetter(Kc,`radiusX`,0,B()),V.addGetterSetter(Kc,`radiusY`,0,B());var qc=class e extends U{constructor(e){super(e),this._loadListener=()=>{this._requestDraw()},this.on(`imageChange.konva`,e=>{this._removeImageLoad(e.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){let e=this.image();e&&e.complete||e&&e.readyState===4||e&&e.addEventListener&&e.addEventListener(`load`,this._loadListener)}_removeImageLoad(e){e&&e.removeEventListener&&e.removeEventListener(`load`,this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){let e=!!this.cornerRadius(),t=this.hasShadow();return e&&t?!0:super._useBufferCanvas(!0)}_sceneFunc(e){let t=this.getWidth(),n=this.getHeight(),r=this.cornerRadius(),i=this.attrs.image,a;if(i){let e=this.attrs.cropWidth,r=this.attrs.cropHeight;a=e&&r?[i,this.cropX(),this.cropY(),e,r,0,0,t,n]:[i,0,0,t,n]}(this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?z.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)),i&&(r&&e.clip(),e.drawImage.apply(e,a))}_hitFunc(e){let t=this.width(),n=this.height(),r=this.cornerRadius();e.beginPath(),r?z.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.attrs.width??this.image()?.width??0}getHeight(){return this.attrs.height??this.image()?.height??0}static fromURL(t,n,r=null){let i=z.createImageElement();i.onload=function(){n(new e({image:i}))},i.onerror=r,i.crossOrigin=`Anonymous`,i.src=t}};qc.prototype.className=`Image`,qc.prototype._attrsAffectingSize=[`image`],Ma(qc),V.addGetterSetter(qc,`cornerRadius`,0,To(4)),V.addGetterSetter(qc,`image`),V.addComponentsGetterSetter(qc,`crop`,[`x`,`y`,`width`,`height`]),V.addGetterSetter(qc,`cropX`,0,B()),V.addGetterSetter(qc,`cropY`,0,B()),V.addGetterSetter(qc,`cropWidth`,0,B()),V.addGetterSetter(qc,`cropHeight`,0,B());var Jc=[`fontFamily`,`fontSize`,`fontStyle`,`padding`,`lineHeight`,`text`,`width`,`height`,`pointerDirection`,`pointerWidth`,`pointerHeight`],Yc=`Change.konva`,Xc=`none`,Zc=`up`,Qc=`right`,$c=`down`,el=`left`,tl=Jc.length,nl=class extends _c{constructor(e){super(e),this.on(`add.konva`,function(e){this._addListeners(e.child),this._sync()})}getText(){return this.find(`Text`)[0]}getTag(){return this.find(`Tag`)[0]}_addListeners(e){let t=this,n,r=function(){t._sync()};for(n=0;n<tl;n++)e.on(Jc[n]+Yc,r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let e=this.getText(),t=this.getTag(),n,r,i,a,o,s,c;if(e&&t){switch(n=e.width(),r=e.height(),i=t.pointerDirection(),a=t.pointerWidth(),c=t.pointerHeight(),o=0,s=0,i){case Zc:o=n/2,s=-1*c;break;case Qc:o=n+a,s=r/2;break;case $c:o=n/2,s=r+c;break;case el:o=-1*a,s=r/2;break}t.setAttrs({x:-1*o,y:-1*s,width:n,height:r}),e.setAttrs({x:-1*o,y:-1*s})}}};nl.prototype.className=`Label`,Ma(nl);var rl=class extends U{_sceneFunc(e){let t=this.width(),n=this.height(),r=this.pointerDirection(),i=this.pointerWidth(),a=this.pointerHeight(),o=this.cornerRadius(),s=0,c=0,l=0,u=0;typeof o==`number`?s=c=l=u=Math.min(o,t/2,n/2):(s=Math.min(o[0]||0,t/2,n/2),c=Math.min(o[1]||0,t/2,n/2),u=Math.min(o[2]||0,t/2,n/2),l=Math.min(o[3]||0,t/2,n/2)),e.beginPath(),e.moveTo(s,0),r===Zc&&(e.lineTo((t-i)/2,0),e.lineTo(t/2,-1*a),e.lineTo((t+i)/2,0)),e.lineTo(t-c,0),e.arc(t-c,c,c,Math.PI*3/2,0,!1),r===Qc&&(e.lineTo(t,(n-a)/2),e.lineTo(t+i,n/2),e.lineTo(t,(n+a)/2)),e.lineTo(t,n-u),e.arc(t-u,n-u,u,0,Math.PI/2,!1),r===$c&&(e.lineTo((t+i)/2,n),e.lineTo(t/2,n+a),e.lineTo((t-i)/2,n)),e.lineTo(l,n),e.arc(l,n-l,l,Math.PI/2,Math.PI,!1),r===el&&(e.lineTo(0,(n+a)/2),e.lineTo(-1*i,n/2),e.lineTo(0,(n-a)/2)),e.lineTo(0,s),e.arc(s,s,s,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=0,t=0,n=this.pointerWidth(),r=this.pointerHeight(),i=this.pointerDirection(),a=this.width(),o=this.height();return i===Zc?(t-=r,o+=r):i===$c?o+=r:i===el?(e-=n*1.5,a+=n):i===Qc&&(a+=n*1.5),{x:e,y:t,width:a,height:o}}};rl.prototype.className=`Tag`,Ma(rl),V.addGetterSetter(rl,`pointerDirection`,Xc),V.addGetterSetter(rl,`pointerWidth`,0,B()),V.addGetterSetter(rl,`pointerHeight`,0,B()),V.addGetterSetter(rl,`cornerRadius`,0,To(4));var il=class extends U{_sceneFunc(e){let t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?z.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};il.prototype.className=`Rect`,Ma(il),V.addGetterSetter(il,`cornerRadius`,0,To(4));var al=class extends U{_sceneFunc(e){let t=this._getPoints(),n=this.radius(),r=this.sides(),i=this.cornerRadius();if(e.beginPath(),i)z.drawRoundedPolygonPath(e,t,r,n,i);else{e.moveTo(t[0].x,t[0].y);for(let n=1;n<t.length;n++)e.lineTo(t[n].x,t[n].y)}e.closePath(),e.fillStrokeShape(this)}_getPoints(){let e=this.attrs.sides,t=this.attrs.radius||0,n=[];for(let r=0;r<e;r++)n.push({x:t*Math.sin(r*2*Math.PI/e),y:-1*t*Math.cos(r*2*Math.PI/e)});return n}getSelfRect(){let e=this._getPoints(),t=e[0].x,n=e[0].x,r=e[0].y,i=e[0].y;return e.forEach(e=>{t=Math.min(t,e.x),n=Math.max(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.y)}),{x:t,y:r,width:n-t,height:i-r}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};al.prototype.className=`RegularPolygon`,al.prototype._centroid=!0,al.prototype._attrsAffectingSize=[`radius`],Ma(al),V.addGetterSetter(al,`radius`,0,B()),V.addGetterSetter(al,`sides`,0,B()),V.addGetterSetter(al,`cornerRadius`,0,To(4));var ol=Math.PI*2,sl=class extends U{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,ol,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),ol,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};sl.prototype.className=`Ring`,sl.prototype._centroid=!0,sl.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`],Ma(sl),V.addGetterSetter(sl,`innerRadius`,0,B()),V.addGetterSetter(sl,`outerRadius`,0,B());var cl=class extends U{constructor(e){super(e),this._updated=!0,this.anim=new yc(()=>{let e=this._updated;return this._updated=!1,e}),this.on(`animationChange.konva`,function(){this.frameIndex(0)}),this.on(`frameIndexChange.konva`,function(){this._updated=!0}),this.on(`frameRateChange.konva`,function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(e){let t=this.animation(),n=this.frameIndex(),r=n*4,i=this.animations()[t],a=this.frameOffsets(),o=i[r+0],s=i[r+1],c=i[r+2],l=i[r+3],u=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,c,l),e.closePath(),e.fillStrokeShape(this)),u)if(a){let r=a[t],i=n*2;e.drawImage(u,o,s,c,l,r[i+0],r[i+1],c,l)}else e.drawImage(u,o,s,c,l,0,0,c,l)}_hitFunc(e){let t=this.animation(),n=this.frameIndex(),r=n*4,i=this.animations()[t],a=this.frameOffsets(),o=i[r+2],s=i[r+3];if(e.beginPath(),a){let r=a[t],i=n*2;e.rect(r[i+0],r[i+1],o,s)}else e.rect(0,0,o,s);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){let e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;let e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){let e=this.frameIndex(),t=this.animation();e<this.animations()[t].length/4-1?this.frameIndex(e+1):this.frameIndex(0)}};cl.prototype.className=`Sprite`,Ma(cl),V.addGetterSetter(cl,`animation`),V.addGetterSetter(cl,`animations`),V.addGetterSetter(cl,`frameOffsets`),V.addGetterSetter(cl,`image`),V.addGetterSetter(cl,`frameIndex`,0,B()),V.addGetterSetter(cl,`frameRate`,17,B()),V.backCompat(cl,{index:`frameIndex`,getIndex:`getFrameIndex`,setIndex:`setFrameIndex`});var ll=class extends U{_sceneFunc(e){let t=this.innerRadius(),n=this.outerRadius(),r=this.numPoints();e.beginPath(),e.moveTo(0,0-n);for(let i=1;i<r*2;i++){let a=i%2==0?n:t,o=a*Math.sin(i*Math.PI/r),s=-1*a*Math.cos(i*Math.PI/r);e.lineTo(o,s)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};ll.prototype.className=`Star`,ll.prototype._centroid=!0,ll.prototype._attrsAffectingSize=[`innerRadius`,`outerRadius`],Ma(ll),V.addGetterSetter(ll,`numPoints`,5,B()),V.addGetterSetter(ll,`innerRadius`,0,B()),V.addGetterSetter(ll,`outerRadius`,0,B());function ul(e){return[...e].reduce((e,t,n,r)=>{if(/\p{Emoji}/u.test(t)){let i=r[n+1];i&&/\p{Emoji_Modifier}|\u200D/u.test(i)?(e.push(t+i),r[n+1]=``):e.push(t)}else /\p{Regional_Indicator}{2}/u.test(t+(r[n+1]||``))?e.push(t+r[n+1]):n>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(t)?e[e.length-1]+=t:t&&e.push(t);return e},[])}var dl=`auto`,fl=`center`,pl=`inherit`,ml=`justify`,hl=`Change.konva`,gl=`2d`,_l=`-`,vl=`left`,yl=`text`,bl=`Text`,xl=`top`,Sl=`bottom`,Cl=`middle`,wl=`normal`,Tl=`px `,El=` `,Dl=`right`,Ol=`rtl`,kl=`word`,Al=`char`,jl=`none`,Ml=`…`,Nl=[`direction`,`fontFamily`,`fontSize`,`fontStyle`,`fontVariant`,`padding`,`align`,`verticalAlign`,`lineHeight`,`text`,`width`,`height`,`wrap`,`ellipsis`,`letterSpacing`],Pl=Nl.length,Fl=null;function Il(){if(Fl!==null)return Fl;Fl=!1;try{let e=document.createElement(`canvas`);e.width=10,e.height=10;let t=e.getContext(gl);if(t){t.globalAlpha=0,t.shadowColor=`black`,t.shadowBlur=5,t.shadowOffsetX=5,t.shadowOffsetY=5,t.fillStyle=`black`,t.font=`10px Arial`,t.fillText(`X`,0,10);let e=t.getImageData(0,0,10,10).data;for(let t=3;t<e.length;t+=4)if(e[t]>0){Fl=!0;break}}}catch{}return Fl}function Ll(e){return e.split(`,`).map(e=>{e=e.trim();let t=e.indexOf(` `)>=0,n=e.indexOf(`"`)>=0||e.indexOf(`'`)>=0;return t&&!n&&(e=`"${e}"`),e}).join(`, `)}var Rl;function zl(){return Rl||(Rl=z.createCanvasElement().getContext(gl),Rl)}function Bl(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function Vl(e){e.setAttr(`miterLimit`,2),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function Hl(e){return e||={},!e.fillLinearGradientColorStops&&!e.fillRadialGradientColorStops&&!e.fillPatternImage&&(e.fill=e.fill||`black`),e}var Ul=class extends U{constructor(e){super(Hl(e)),this._partialTextX=0,this._partialTextY=0;for(let e=0;e<Pl;e++)this.on(Nl[e]+hl,this._setTextData);this._setTextData()}_sceneFunc(e){let t=this.textArr,n=t.length;if(!this.text())return;let r=this.padding(),i=this.fontSize(),a=this.lineHeight()*i,o=this.verticalAlign(),s=this.direction(),c=0,l=this.align(),u=this.getWidth(),d=this.letterSpacing(),f=this.charRenderFunc(),p=this.fill(),m=this.textDecoration(),h=this.underlineOffset(),g=m.indexOf(`underline`)!==-1,_=m.indexOf(`line-through`)!==-1,v;s=s===pl?e.direction:s;let y=a/2,b=Cl;if(!R.legacyTextRendering){let e=this.measureSize(`M`);b=`alphabetic`,y=((e.fontBoundingBoxAscent??e.actualBoundingBoxAscent)-(e.fontBoundingBoxDescent??e.actualBoundingBoxDescent))/2+a/2}for(s===Ol&&e.setAttr(`direction`,s),e.setAttr(`font`,this._getContextFont()),e.setAttr(`textBaseline`,b),e.setAttr(`textAlign`,vl),o===Cl?c=(this.getHeight()-n*a-r*2)/2:o===Sl&&(c=this.getHeight()-n*a-r*2),e.translate(r,c+r),v=0;v<n;v++){let o=0,c=t[v],m=c.text,b=c.width,x=c.lastInParagraph;if(e.save(),l===Dl?o+=u-b-r*2:l===fl&&(o+=(u-b-r*2)/2),g){e.save(),e.beginPath();let t=h??(R.legacyTextRendering?Math.round(i/2):Math.round(i/4)),n=o,a=y+0+t;e.moveTo(n,a);let s=l===ml&&!x?u-r*2:b;e.lineTo(n+Math.round(s),a),e.lineWidth=i/15,e.strokeStyle=this._getLinearGradient()||p,e.stroke(),e.restore()}let S=o;if(s!==Ol&&(d!==0||l===ml||f)){let n=m.split(` `).length-1,i=ul(m);for(let a=0;a<i.length;a++){let s=i[a];if(s===` `&&!x&&l===ml&&(o+=(u-r*2-b)/n),this._partialTextX=o,this._partialTextY=y+0,this._partialText=s,f){e.save();let n=t.slice(0,v).reduce((e,t)=>e+ul(t.text).length,0);f({char:s,index:a+n,x:o,y:y+0,lineIndex:v,column:a,isLastInLine:x,width:this.measureSize(s).width,context:e})}e.fillStrokeShape(this),f&&e.restore(),o+=this.measureSize(s).width+d}}else d!==0&&e.setAttr(`letterSpacing`,`${d}px`),this._partialTextX=o,this._partialTextY=y+0,this._partialText=m,e.fillStrokeShape(this);if(_){e.save(),e.beginPath();let t=R.legacyTextRendering?0:-Math.round(i/4),n=S;e.moveTo(n,y+0+t);let a=l===ml&&!x?u-r*2:b;e.lineTo(n+Math.round(a),y+0+t),e.lineWidth=i/15,e.strokeStyle=this._getLinearGradient()||p,e.stroke(),e.restore()}e.restore(),n>1&&(y+=a)}}_hitFunc(e){let t=this.getWidth(),n=this.getHeight();e.beginPath(),e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}setText(e){let t=z._isString(e)?e:e==null?``:e+``;return this._setAttr(yl,t),this}getWidth(){return this.attrs.width===dl||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===dl||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return z.warn(`text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.`),this.textHeight}measureSize(e){let t=zl(),n=this.fontSize(),r;t.save(),t.font=this._getContextFont(),r=t.measureText(e),t.restore();let i=n/100;return{actualBoundingBoxAscent:r.actualBoundingBoxAscent??71.58203125*i,actualBoundingBoxDescent:r.actualBoundingBoxDescent??0,actualBoundingBoxLeft:r.actualBoundingBoxLeft??-7.421875*i,actualBoundingBoxRight:r.actualBoundingBoxRight??75.732421875*i,alphabeticBaseline:r.alphabeticBaseline??0,emHeightAscent:r.emHeightAscent??100*i,emHeightDescent:r.emHeightDescent??-20*i,fontBoundingBoxAscent:r.fontBoundingBoxAscent??91*i,fontBoundingBoxDescent:r.fontBoundingBoxDescent??21*i,hangingBaseline:r.hangingBaseline??72.80000305175781*i,ideographicBaseline:r.ideographicBaseline??-21*i,width:r.width,height:n}}_getContextFont(){return this.fontStyle()+El+this.fontVariant()+El+(this.fontSize()+Tl)+Ll(this.fontFamily())}_addTextLine(e){this.align()===ml&&(e=e.trim());let t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){let t=this.letterSpacing(),n=e.length;return zl().measureText(e).width+t*n}_setTextData(){let e=this.text().split(`
|
|
26
|
+
`),t=+this.fontSize(),n=0,r=this.lineHeight()*t,i=this.attrs.width,a=this.attrs.height,o=i!==dl&&i!==void 0,s=a!==dl&&a!==void 0,c=this.padding(),l=i-c*2,u=a-c*2,d=0,f=this.wrap(),p=f!==Al&&f!==jl,m=this.ellipsis();this.textArr=[],zl().font=this._getContextFont();let h=m?this._getTextWidth(Ml):0;for(let t=0,i=e.length;t<i;++t){let a=e[t],c=this._getTextWidth(a);if(o&&c>l)for(;a.length>0;){let e=0,t=ul(a).length,i=``,o=0;for(;e<t;){let n=e+t>>>1,c=ul(a).slice(0,n+1).join(``),f=this._getTextWidth(c);(m&&s&&d+r>u?f+h:f)<=l?(e=n+1,i=c,o=f):t=n}if(i){if(p){let t=ul(a),n=ul(i),r=t[n.length],s=r===El||r===_l,c;if(s&&o<=l)c=n.length;else{let e=n.lastIndexOf(El),t=n.lastIndexOf(_l);c=Math.max(e,t)+1}c>0&&(e=c,i=t.slice(0,e).join(``),o=this._getTextWidth(i))}if(i=i.trimRight(),this._addTextLine(i),n=Math.max(n,o),d+=r,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(a=ul(a).slice(e).join(``).trimLeft(),a.length>0&&(c=this._getTextWidth(a),c<=l)){this._addTextLine(a),d+=r,n=Math.max(n,c);break}}else break}else this._addTextLine(a),d+=r,n=Math.max(n,c),this._shouldHandleEllipsis(d)&&t<i-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),s&&d+r>u)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){let t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,i=r!==dl&&r!==void 0,a=r-this.padding()*2;return this.wrap()===jl||i&&e+n>a}_tryToAddEllipsisToLastLine(){let e=this.attrs.width,t=e!==dl&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),i=this.textArr[this.textArr.length-1];!i||!r||(t&&(this._getTextWidth(i.text+Ml)<n||(i.text=i.text.slice(0,i.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(i.text+Ml))}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){let e=this.textDecoration().indexOf(`underline`)!==-1||this.textDecoration().indexOf(`line-through`)!==-1,t=this.hasShadow();return e&&t||t&&this.getAbsoluteOpacity()!==1&&Il()?!0:super._useBufferCanvas()}};Ul.prototype._fillFunc=Bl,Ul.prototype._strokeFunc=Vl,Ul.prototype.className=bl,Ul.prototype._attrsAffectingSize=[`text`,`fontSize`,`padding`,`wrap`,`lineHeight`,`letterSpacing`],Ma(Ul),V.overWriteSetter(Ul,`width`,Eo()),V.overWriteSetter(Ul,`height`,Eo()),V.addGetterSetter(Ul,`direction`,pl),V.addGetterSetter(Ul,`fontFamily`,`Arial`),V.addGetterSetter(Ul,`fontSize`,12,B()),V.addGetterSetter(Ul,`fontStyle`,wl),V.addGetterSetter(Ul,`fontVariant`,wl),V.addGetterSetter(Ul,`padding`,0,B()),V.addGetterSetter(Ul,`align`,vl),V.addGetterSetter(Ul,`verticalAlign`,xl),V.addGetterSetter(Ul,`lineHeight`,1,B()),V.addGetterSetter(Ul,`wrap`,kl),V.addGetterSetter(Ul,`ellipsis`,!1,Ao()),V.addGetterSetter(Ul,`letterSpacing`,0,B()),V.addGetterSetter(Ul,`text`,``,Do()),V.addGetterSetter(Ul,`textDecoration`,``),V.addGetterSetter(Ul,`underlineOffset`,void 0,B()),V.addGetterSetter(Ul,`charRenderFunc`,void 0);var Wl=``,Gl=`normal`;function Kl(e){e.fillText(this.partialText,0,0)}function ql(e){e.strokeText(this.partialText,0,0)}var Jl=class extends U{constructor(e){super(e),this.dummyCanvas=z.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on(`dataChange.konva`,function(){this._readDataAttribute(),this._setTextData()}),this.on(`textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva directionChange.konva`,this._setTextData),this._setTextData()}_getTextPathLength(){return Uc.getPathLength(this.dataArray)}_getPointAtLength(e){return!this.attrs.data||e>this.pathLength?null:Uc.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=Uc.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr(`font`,this._getContextFont()),e.setAttr(`textBaseline`,this.textBaseline()),e.setAttr(`textAlign`,`left`),e.save();let t=this.textDecoration(),n=this.fill(),r=this.fontSize(),i=this.glyphInfo,a=t.indexOf(`underline`)!==-1,o=t.indexOf(`line-through`)!==-1;a&&e.beginPath();for(let t=0;t<i.length;t++){e.save();let n=i[t].p0;e.translate(n.x,n.y),e.rotate(i[t].rotation),this.partialText=i[t].text,e.fillStrokeShape(this),a&&(t===0&&e.moveTo(0,r/2+1),e.lineTo(i[t].width,r/2+1)),e.restore()}if(a&&(e.strokeStyle=n,e.lineWidth=r/20,e.stroke()),o){e.beginPath();for(let t=0;t<i.length;t++){e.save();let n=i[t].p0;e.translate(n.x,n.y),e.rotate(i[t].rotation),t===0&&e.moveTo(0,0),e.lineTo(i[t].width,0),e.restore()}e.strokeStyle=n,e.lineWidth=r/20,e.stroke()}e.restore()}_hitFunc(e){e.beginPath();let t=this.glyphInfo;if(t.length>=1){let n=t[0].p0;e.moveTo(n.x,n.y)}for(let n=0;n<t.length;n++){let r=t[n].p1;e.lineTo(r.x,r.y)}e.setAttr(`lineWidth`,this.fontSize()),e.setAttr(`strokeStyle`,this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return z.warn(`text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height.`),this.textHeight}setText(e){return Ul.prototype.setText.call(this,e)}_getContextFont(){return Ul.prototype._getContextFont.call(this)}_getTextSize(e){let t=this.dummyCanvas.getContext(`2d`);t.save(),t.font=this._getContextFont();let n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){let e=ul(this.text());this.direction()===`rtl`&&e.reverse();let t=[],n=0;for(let r=0;r<e.length;r++)t.push({char:e[r],width:this._getTextSize(e[r]).width}),n+=t[r].width;let{width:r,height:i}=this._getTextSize(this.attrs.text);if(this.textWidth=n,this.textHeight=i,this.glyphInfo=[],!this.attrs.data)return null;let a=this.letterSpacing(),o=this.align(),s=this.kerningFunc(),c=Math.max(0,n-r),l=Math.max(this.textWidth+((this.attrs.text||``).length-1)*a,0),u=0;o===`center`&&(u=Math.max(0,this.pathLength/2-l/2)),o===`right`&&(u=Math.max(0,this.pathLength-l));let d=u;for(let n=0;n<t.length;n++){let r=this._getPointAtLength(d);if(!r)return;let i=t[n].char,u=t[n].width+a;if(i===` `&&o===`justify`){let e=this.text().split(` `).length-1;u+=(this.pathLength-l)/e}let f=d+u,p=this._getPointAtLength(f>this.pathLength&&f-this.pathLength<=c?this.pathLength:f);if(!p)return;let m=Uc.getLineLength(r.x,r.y,p.x,p.y),h=0;if(s)try{h=s(t[n-1].char,i)*this.fontSize()}catch{h=0}r.x+=h,p.x+=h,this.textWidth+=h;let g=Uc.getPointOnLine(h+m/2,r.x,r.y,p.x,p.y),_=Math.atan2(p.y-r.y,p.x-r.x);this.glyphInfo.push({transposeX:g.x,transposeY:g.y,text:e[n],rotation:_,p0:r,p1:p,width:m}),d+=u}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};let e=[];this.glyphInfo.forEach(function(t){e.push(t.p0.x),e.push(t.p0.y),e.push(t.p1.x),e.push(t.p1.y)});let t=e[0]||0,n=e[0]||0,r=e[1]||0,i=e[1]||0,a,o;for(let s=0;s<e.length/2;s++)a=e[s*2],o=e[s*2+1],t=Math.min(t,a),n=Math.max(n,a),r=Math.min(r,o),i=Math.max(i,o);let s=this.fontSize();return{x:t-s/2,y:r-s/2,width:n-t+s,height:i-r+s}}destroy(){return z.releaseCanvas(this.dummyCanvas),super.destroy()}};Jl.prototype._fillFunc=Kl,Jl.prototype._strokeFunc=ql,Jl.prototype._fillFuncHit=Kl,Jl.prototype._strokeFuncHit=ql,Jl.prototype.className=`TextPath`,Jl.prototype._attrsAffectingSize=[`text`,`fontSize`,`data`],Ma(Jl),V.addGetterSetter(Jl,`data`),V.addGetterSetter(Jl,`fontFamily`,`Arial`),V.addGetterSetter(Jl,`fontSize`,12,B()),V.addGetterSetter(Jl,`fontStyle`,Gl),V.addGetterSetter(Jl,`align`,`left`),V.addGetterSetter(Jl,`letterSpacing`,0,B()),V.addGetterSetter(Jl,`textBaseline`,`middle`),V.addGetterSetter(Jl,`fontVariant`,Gl),V.addGetterSetter(Jl,`text`,Wl),V.addGetterSetter(Jl,`textDecoration`,``),V.addGetterSetter(Jl,`kerningFunc`,void 0),V.addGetterSetter(Jl,`direction`,`inherit`);var Yl=`tr-konva`,Xl=[`resizeEnabledChange`,`rotateAnchorOffsetChange`,`rotateAnchorAngleChange`,`rotateEnabledChange`,`enabledAnchorsChange`,`anchorSizeChange`,`borderEnabledChange`,`borderStrokeChange`,`borderStrokeWidthChange`,`borderDashChange`,`anchorStrokeChange`,`anchorStrokeWidthChange`,`anchorFillChange`,`anchorCornerRadiusChange`,`ignoreStrokeChange`,`anchorStyleFuncChange`].map(e=>e+`.${Yl}`).join(` `),Zl=`nodesRect`,Ql=[`widthChange`,`heightChange`,`scaleXChange`,`scaleYChange`,`skewXChange`,`skewYChange`,`rotationChange`,`offsetXChange`,`offsetYChange`,`transformsEnabledChange`,`strokeWidthChange`,`draggableChange`],$l={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},eu=`ontouchstart`in R._global;function tu(e,t,n){if(e===`rotater`)return n;t+=z.degToRad($l[e]||0);let r=(z.radToDeg(t)%360+360)%360;return z._inRange(r,337.5,360)||z._inRange(r,0,22.5)?`ns-resize`:z._inRange(r,22.5,67.5)?`nesw-resize`:z._inRange(r,67.5,112.5)?`ew-resize`:z._inRange(r,112.5,157.5)?`nwse-resize`:z._inRange(r,157.5,202.5)?`ns-resize`:z._inRange(r,202.5,247.5)?`nesw-resize`:z._inRange(r,247.5,292.5)?`ew-resize`:z._inRange(r,292.5,337.5)?`nwse-resize`:(z.error(`Transformer has unknown angle for cursor detection: `+r),`pointer`)}var nu=[`top-left`,`top-center`,`top-right`,`middle-right`,`middle-left`,`bottom-left`,`bottom-center`,`bottom-right`];function ru(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}function iu(e,t,n){let r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),i=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return{...e,rotation:e.rotation+t,x:r,y:i}}function au(e,t){return iu(e,t,ru(e))}function ou(e,t,n){let r=t;for(let i=0;i<e.length;i++){let a=R.getAngle(e[i]),o=Math.abs(a-t)%(Math.PI*2);Math.min(o,Math.PI*2-o)<n&&(r=a)}return r}var su=0,cu=class extends _c{constructor(e){super(e),this._movingAnchorName=null,this._transforming=!1,this._elementsCreated=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(Xl,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return z.warn(`tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead.`),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return Yl+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();let t=e.filter(e=>e.isAncestorOf(this)?(z.error(`Konva.Transformer cannot be an a child of the node you are trying to attach`),!1):!0);return this._nodes=e=t,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(e=>{let t=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()};if(e._attrsAffectingSize.length){let n=e._attrsAffectingSize.map(e=>e+`Change.`+this._getEventNamespace()).join(` `);e.on(n,t)}e.on(Ql.map(e=>e+`.${this._getEventNamespace()}`).join(` `),t),e.on(`absoluteTransformChange.${this._getEventNamespace()}`,t),this._proxyDrag(e)}),this._resetTransformCache(),this.findOne(`.top-left`)&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(`.back`)&&this.startDrag(n,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!t)return;let r=e.getAbsolutePosition(),i=r.x-t.x,a=r.y-t.y;this.nodes().forEach(t=>{if(t===e||t.isDragging())return;let r=t.getAbsolutePosition();t.setAbsolutePosition({x:r.x+i,y:r.y+a}),t.startDrag(n)}),t=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(e=>{e.off(`.`+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(Zl),this._clearCache(`transform`),this._clearSelfAndDescendantCache(`absoluteTransform`)}_getNodeRect(){return this._getCache(Zl,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),n){let r=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),i=e.getAbsoluteScale(n),a=e.getAbsolutePosition(n),o=r.x*i.x-e.offsetX()*i.x,s=r.y*i.y-e.offsetY()*i.y,c=(R.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2);return iu({x:a.x+o*Math.cos(c)+s*Math.sin(-c),y:a.y+s*Math.cos(c)+o*Math.sin(c),width:r.width*i.x,height:r.height*i.y,rotation:c},-R.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};let e=[];this.nodes().map(t=>{let n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),r=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x+n.width,y:n.y+n.height},{x:n.x,y:n.y+n.height}],i=t.getAbsoluteTransform();r.forEach(function(t){let n=i.point(t);e.push(n)})});let t=new Fa;t.rotate(-R.getAngle(this.rotation()));let n=1/0,r=1/0,i=-1/0,a=-1/0;e.forEach(function(e){let o=t.point(e);n===void 0&&(n=i=o.x,r=a=o.y),n=Math.min(n,o.x),r=Math.min(r,o.y),i=Math.max(i,o.x),a=Math.max(a,o.y)}),t.invert();let o=t.point({x:n,y:r});return{x:o.x,y:o.y,width:i-n,height:a-r,rotation:R.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),nu.forEach(e=>{this._createAnchor(e)}),this._createAnchor(`rotater`),this._elementsCreated=!0}_createAnchor(e){let t=new il({stroke:`rgb(0, 161, 255)`,fill:`white`,strokeWidth:1,name:e+` _anchor`,dragDistance:0,draggable:!0,hitStrokeWidth:eu?10:`auto`}),n=this;t.on(`mousedown touchstart`,function(e){n._handleMouseDown(e)}),t.on(`dragstart`,e=>{t.stopDrag(),e.cancelBubble=!0}),t.on(`dragend`,e=>{e.cancelBubble=!0}),t.on(`mouseenter`,()=>{let n=tu(e,R.getAngle(this.rotation()),this.rotateAnchorCursor());t.getStage().content&&(t.getStage().content.style.cursor=n),this._cursorChange=!0}),t.on(`mouseout`,()=>{t.getStage().content&&(t.getStage().content.style.cursor=``),this._cursorChange=!1}),this.add(t)}_createBack(){let e=new U({name:`back`,width:0,height:0,sceneFunc(e,t){let n=t.getParent(),r=n.padding(),i=t.width(),a=t.height();if(e.beginPath(),e.rect(-r,-r,i+r*2,a+r*2),n.rotateEnabled()&&n.rotateLineVisible()){let t=n.rotateAnchorAngle(),r=n.rotateAnchorOffset(),o=z.degToRad(t),s=Math.sin(o),c=-Math.cos(o),l=i/2,u=a/2,d=1/0;c<0?d=Math.min(d,-u/c):c>0&&(d=Math.min(d,(a-u)/c)),s<0?d=Math.min(d,-l/s):s>0&&(d=Math.min(d,(i-l)/s));let f=l+s*d,p=u+c*d,m=z._sign(a),h=f+s*r*m,g=p+c*r*m;e.moveTo(f,p),e.lineTo(h,g)}e.fillStrokeShape(t)},hitFunc:(e,t)=>{if(!this.shouldOverdrawWholeArea())return;let n=this.padding();e.beginPath(),e.rect(-n,-n,t.width()+n*2,t.height()+n*2),e.fillStrokeShape(t)}});this.add(e),this._proxyDrag(e),e.on(`dragstart`,e=>{e.cancelBubble=!0}),e.on(`dragmove`,e=>{e.cancelBubble=!0}),e.on(`dragend`,e=>{e.cancelBubble=!0}),this.on(`dragmove`,e=>{this.update()})}_handleMouseDown(e){if(this._transforming)return;this._movingAnchorName=e.target.name().split(` `)[0];let t=this._getNodeRect(),n=t.width,r=t.height,i=Math.sqrt(n**2+r**2);this.sin=Math.abs(r/i),this.cos=Math.abs(n/i),typeof window<`u`&&(window.addEventListener(`mousemove`,this._handleMouseMove),window.addEventListener(`touchmove`,this._handleMouseMove),window.addEventListener(`mouseup`,this._handleMouseUp,!0),window.addEventListener(`touchend`,this._handleMouseUp,!0)),this._transforming=!0;let a=e.target.getAbsolutePosition(),o=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:o.x-a.x,y:o.y-a.y},su++,this._fire(`transformstart`,{evt:e.evt,target:this.getNode()}),this._nodes.forEach(t=>{t._fire(`transformstart`,{evt:e.evt,target:t})})}_handleMouseMove(e){let t,n,r,i=this.findOne(`.`+this._movingAnchorName),a=i.getStage();a.setPointersPositions(e);let o=a.getPointerPosition(),s={x:o.x-this._anchorDragOffset.x,y:o.y-this._anchorDragOffset.y},c=i.getAbsolutePosition();this.anchorDragBoundFunc()&&(s=this.anchorDragBoundFunc()(c,s,e)),i.setAbsolutePosition(s);let l=i.getAbsolutePosition();if(c.x===l.x&&c.y===l.y)return;if(this._movingAnchorName===`rotater`){let r=this._getNodeRect();t=i.x()-r.width/2,n=-i.y()+r.height/2;let a=R.getAngle(this.rotateAnchorAngle()),o=Math.atan2(-n,t)+Math.PI/2-a;r.height<0&&(o-=Math.PI);let s=R.getAngle(this.rotation())+o,c=R.getAngle(this.rotationSnapTolerance()),l=au(r,ou(this.rotationSnaps(),s,c)-r.rotation);this._fitNodesInto(l,e);return}let u=this.shiftBehavior(),d;d=u===`inverted`?this.keepRatio()&&!e.shiftKey:u===`none`?this.keepRatio():this.keepRatio()||e.shiftKey;let f=this.centeredScaling()||e.altKey;if(this._movingAnchorName===`top-left`){if(d){let e=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(`.bottom-right`).x(),y:this.findOne(`.bottom-right`).y()};r=Math.sqrt((e.x-i.x())**2+(e.y-i.y())**2);let a=this.findOne(`.top-left`).x()>e.x?-1:1,o=this.findOne(`.top-left`).y()>e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this.findOne(`.top-left`).x(e.x-t),this.findOne(`.top-left`).y(e.y-n)}}else if(this._movingAnchorName===`top-center`)this.findOne(`.top-left`).y(i.y());else if(this._movingAnchorName===`top-right`){if(d){let e=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(`.bottom-left`).x(),y:this.findOne(`.bottom-left`).y()};r=Math.sqrt((i.x()-e.x)**2+(e.y-i.y())**2);let a=this.findOne(`.top-right`).x()<e.x?-1:1,o=this.findOne(`.top-right`).y()>e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this.findOne(`.top-right`).x(e.x+t),this.findOne(`.top-right`).y(e.y-n)}var p=i.position();this.findOne(`.top-left`).y(p.y),this.findOne(`.bottom-right`).x(p.x)}else if(this._movingAnchorName===`middle-left`)this.findOne(`.top-left`).x(i.x());else if(this._movingAnchorName===`middle-right`)this.findOne(`.bottom-right`).x(i.x());else if(this._movingAnchorName===`bottom-left`){if(d){let e=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(`.top-right`).x(),y:this.findOne(`.top-right`).y()};r=Math.sqrt((e.x-i.x())**2+(i.y()-e.y)**2);let a=e.x<i.x()?-1:1,o=i.y()<e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,i.x(e.x-t),i.y(e.y+n)}p=i.position(),this.findOne(`.top-left`).x(p.x),this.findOne(`.bottom-right`).y(p.y)}else if(this._movingAnchorName===`bottom-center`)this.findOne(`.bottom-right`).y(i.y());else if(this._movingAnchorName===`bottom-right`){if(d){let e=f?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(`.top-left`).x(),y:this.findOne(`.top-left`).y()};r=Math.sqrt((i.x()-e.x)**2+(i.y()-e.y)**2);let a=this.findOne(`.bottom-right`).x()<e.x?-1:1,o=this.findOne(`.bottom-right`).y()<e.y?-1:1;t=r*this.cos*a,n=r*this.sin*o,this.findOne(`.bottom-right`).x(e.x+t),this.findOne(`.bottom-right`).y(e.y+n)}}else console.error(Error(`Wrong position argument of selection resizer: `+this._movingAnchorName));if(f=this.centeredScaling()||e.altKey,f){let e=this.findOne(`.top-left`),t=this.findOne(`.bottom-right`),n=e.x(),r=e.y(),i=this.getWidth()-t.x(),a=this.getHeight()-t.y();t.move({x:-n,y:-r}),e.move({x:i,y:a})}let m=this.findOne(`.top-left`).getAbsolutePosition();t=m.x,n=m.y;let h=this.findOne(`.bottom-right`).x()-this.findOne(`.top-left`).x(),g=this.findOne(`.bottom-right`).y()-this.findOne(`.top-left`).y();this._fitNodesInto({x:t,y:n,width:h,height:g,rotation:R.getAngle(this.rotation())},e)}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){var t;if(this._transforming){this._transforming=!1,typeof window<`u`&&(window.removeEventListener(`mousemove`,this._handleMouseMove),window.removeEventListener(`touchmove`,this._handleMouseMove),window.removeEventListener(`mouseup`,this._handleMouseUp,!0),window.removeEventListener(`touchend`,this._handleMouseUp,!0));let n=this.getNode();su--,this._fire(`transformend`,{evt:e,target:n}),(t=this.getLayer())==null||t.batchDraw(),n&&this._nodes.forEach(t=>{var n;t._fire(`transformend`,{evt:e,target:t}),(n=t.getLayer())==null||n.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t){let n=this._getNodeRect();if(z._inRange(e.width,-this.padding()*2-1,1)){this.update();return}if(z._inRange(e.height,-this.padding()*2-1,1)){this.update();return}let r=new Fa;if(r.rotate(R.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`left`)>=0){let t=r.point({x:-this.padding()*2,y:0});e.x+=t.x,e.y+=t.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace(`left`,`right`),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf(`right`)>=0){let t=r.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace(`right`,`left`),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`top`)>=0){let t=r.point({x:0,y:-this.padding()*2});e.x+=t.x,e.y+=t.y,this._movingAnchorName=this._movingAnchorName.replace(`top`,`bottom`),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf(`bottom`)>=0){let t=r.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace(`bottom`,`top`),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){let t=this.boundBoxFunc()(n,e);t?e=t:z.warn(`boundBoxFunc returned falsy. You should return new bound rect from it!`)}let i=1e7,a=new Fa;a.translate(n.x,n.y),a.rotate(n.rotation),a.scale(n.width/i,n.height/i);let o=new Fa,s=e.width/i,c=e.height/i;this.flipEnabled()===!1?(o.translate(e.x,e.y),o.rotate(e.rotation),o.translate(e.width<0?e.width:0,e.height<0?e.height:0),o.scale(Math.abs(s),Math.abs(c))):(o.translate(e.x,e.y),o.rotate(e.rotation),o.scale(s,c));let l=o.multiply(a.invert());this._nodes.forEach(e=>{var t;if(!e.getStage())return;let n=e.getParent().getAbsoluteTransform(),r=e.getTransform().copy();r.translate(e.offsetX(),e.offsetY());let i=new Fa;i.multiply(n.copy().invert()).multiply(l).multiply(n).multiply(r);let a=i.decompose();e.setAttrs(a),(t=e.getLayer())==null||t.batchDraw()}),this.rotation(z._getRotation(e.rotation)),this._nodes.forEach(e=>{this._fire(`transform`,{evt:t,target:e}),e._fire(`transform`,{evt:t,target:e})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e;let t=this._getNodeRect();this.rotation(z._getRotation(t.rotation));let n=t.width,r=t.height,i=this.enabledAnchors(),a=this.resizeEnabled(),o=this.padding(),s=this.anchorSize(),c=this.find(`._anchor`);c.forEach(e=>{e.setAttrs({width:s,height:s,offsetX:s/2,offsetY:s/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(`.top-left`,{x:0,y:0,offsetX:s/2+o,offsetY:s/2+o,visible:a&&i.indexOf(`top-left`)>=0}),this._batchChangeChild(`.top-center`,{x:n/2,y:0,offsetY:s/2+o,visible:a&&i.indexOf(`top-center`)>=0}),this._batchChangeChild(`.top-right`,{x:n,y:0,offsetX:s/2-o,offsetY:s/2+o,visible:a&&i.indexOf(`top-right`)>=0}),this._batchChangeChild(`.middle-left`,{x:0,y:r/2,offsetX:s/2+o,visible:a&&i.indexOf(`middle-left`)>=0}),this._batchChangeChild(`.middle-right`,{x:n,y:r/2,offsetX:s/2-o,visible:a&&i.indexOf(`middle-right`)>=0}),this._batchChangeChild(`.bottom-left`,{x:0,y:r,offsetX:s/2+o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-left`)>=0}),this._batchChangeChild(`.bottom-center`,{x:n/2,y:r,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-center`)>=0}),this._batchChangeChild(`.bottom-right`,{x:n,y:r,offsetX:s/2-o,offsetY:s/2-o,visible:a&&i.indexOf(`bottom-right`)>=0});let l=this.rotateAnchorAngle(),u=this.rotateAnchorOffset(),d=z.degToRad(l),f=Math.sin(d),p=-Math.cos(d),m=n/2,h=r/2,g=1/0;p<0?g=Math.min(g,-h/p):p>0&&(g=Math.min(g,(r-h)/p)),f<0?g=Math.min(g,-m/f):f>0&&(g=Math.min(g,(n-m)/f));let _=m+f*g,v=h+p*g,y=z._sign(r);this._batchChangeChild(`.rotater`,{x:_+f*u*y,y:v+p*u*y-o*p,visible:this.rotateEnabled()}),this._batchChangeChild(`.back`,{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(e=>e.draggable()),x:0,y:0});let b=this.anchorStyleFunc();b&&c.forEach(e=>{b(e)}),(e=this.getLayer())==null||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();let e=this.findOne(`.`+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=``),_c.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(z.error(`You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead.`),this):super.add(...e)}toObject(){return H.prototype.toObject.call(this)}clone(e){return H.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};cu.isTransforming=()=>su>0;function lu(e){return e instanceof Array||z.warn(`enabledAnchors value should be an array`),e instanceof Array&&e.forEach(function(e){nu.indexOf(e)===-1&&z.warn(`Unknown anchor name: `+e+`. Available names are: `+nu.join(`, `))}),e||[]}cu.prototype.className=`Transformer`,Ma(cu),V.addGetterSetter(cu,`enabledAnchors`,nu,lu),V.addGetterSetter(cu,`flipEnabled`,!0,Ao()),V.addGetterSetter(cu,`resizeEnabled`,!0),V.addGetterSetter(cu,`anchorSize`,10,B()),V.addGetterSetter(cu,`rotateEnabled`,!0),V.addGetterSetter(cu,`rotateLineVisible`,!0),V.addGetterSetter(cu,`rotationSnaps`,[]),V.addGetterSetter(cu,`rotateAnchorOffset`,50,B()),V.addGetterSetter(cu,`rotateAnchorAngle`,0,B()),V.addGetterSetter(cu,`rotateAnchorCursor`,`crosshair`),V.addGetterSetter(cu,`rotationSnapTolerance`,5,B()),V.addGetterSetter(cu,`borderEnabled`,!0),V.addGetterSetter(cu,`anchorStroke`,`rgb(0, 161, 255)`),V.addGetterSetter(cu,`anchorStrokeWidth`,1,B()),V.addGetterSetter(cu,`anchorFill`,`white`),V.addGetterSetter(cu,`anchorCornerRadius`,0,B()),V.addGetterSetter(cu,`borderStroke`,`rgb(0, 161, 255)`),V.addGetterSetter(cu,`borderStrokeWidth`,1,B()),V.addGetterSetter(cu,`borderDash`),V.addGetterSetter(cu,`keepRatio`,!0),V.addGetterSetter(cu,`shiftBehavior`,`default`),V.addGetterSetter(cu,`centeredScaling`,!1),V.addGetterSetter(cu,`ignoreStroke`,!1),V.addGetterSetter(cu,`padding`,0,B()),V.addGetterSetter(cu,`nodes`),V.addGetterSetter(cu,`node`),V.addGetterSetter(cu,`boundBoxFunc`),V.addGetterSetter(cu,`anchorDragBoundFunc`),V.addGetterSetter(cu,`anchorStyleFunc`),V.addGetterSetter(cu,`shouldOverdrawWholeArea`,!1),V.addGetterSetter(cu,`useSingleNodeRotation`,!0),V.backCompat(cu,{lineEnabled:`borderEnabled`,rotateHandlerOffset:`rotateAnchorOffset`,enabledHandlers:`enabledAnchors`});var uu=class extends U{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,R.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};uu.prototype.className=`Wedge`,uu.prototype._centroid=!0,uu.prototype._attrsAffectingSize=[`radius`],Ma(uu),V.addGetterSetter(uu,`radius`,0,B()),V.addGetterSetter(uu,`angle`,0,B()),V.addGetterSetter(uu,`clockwise`,!1),V.backCompat(uu,{angleDeg:`angle`,getAngleDeg:`getAngle`,setAngleDeg:`setAngle`});function du(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var fu=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],pu=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function mu(e,t){let n=e.data,r=e.width,i=e.height,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T=t+t+1,E=r-1,D=i-1,O=t+1,k=O*(O+1)/2,ee=new du,A=fu[t],j=pu[t],te=null,M=ee,ne=null,N=null;for(let e=1;e<T;e++)M=M.next=new du,e===O&&(te=M);M.next=ee,s=o=0;for(let e=0;e<i;e++){g=_=v=y=c=l=u=d=0,f=O*(b=n[o]),p=O*(x=n[o+1]),m=O*(S=n[o+2]),h=O*(C=n[o+3]),c+=k*b,l+=k*x,u+=k*S,d+=k*C,M=ee;for(let e=0;e<O;e++)M.r=b,M.g=x,M.b=S,M.a=C,M=M.next;for(let e=1;e<O;e++)a=o+((E<e?E:e)<<2),c+=(M.r=b=n[a])*(w=O-e),l+=(M.g=x=n[a+1])*w,u+=(M.b=S=n[a+2])*w,d+=(M.a=C=n[a+3])*w,g+=b,_+=x,v+=S,y+=C,M=M.next;ne=ee,N=te;for(let e=0;e<r;e++)n[o+3]=C=d*A>>j,C===0?n[o]=n[o+1]=n[o+2]=0:(C=255/C,n[o]=(c*A>>j)*C,n[o+1]=(l*A>>j)*C,n[o+2]=(u*A>>j)*C),c-=f,l-=p,u-=m,d-=h,f-=ne.r,p-=ne.g,m-=ne.b,h-=ne.a,a=s+((a=e+t+1)<E?a:E)<<2,g+=ne.r=n[a],_+=ne.g=n[a+1],v+=ne.b=n[a+2],y+=ne.a=n[a+3],c+=g,l+=_,u+=v,d+=y,ne=ne.next,f+=b=N.r,p+=x=N.g,m+=S=N.b,h+=C=N.a,g-=b,_-=x,v-=S,y-=C,N=N.next,o+=4;s+=r}for(let e=0;e<r;e++){_=v=y=g=l=u=d=c=0,o=e<<2,f=O*(b=n[o]),p=O*(x=n[o+1]),m=O*(S=n[o+2]),h=O*(C=n[o+3]),c+=k*b,l+=k*x,u+=k*S,d+=k*C,M=ee;for(let e=0;e<O;e++)M.r=b,M.g=x,M.b=S,M.a=C,M=M.next;let s=r;for(let i=1;i<=t;i++)o=s+e<<2,c+=(M.r=b=n[o])*(w=O-i),l+=(M.g=x=n[o+1])*w,u+=(M.b=S=n[o+2])*w,d+=(M.a=C=n[o+3])*w,g+=b,_+=x,v+=S,y+=C,M=M.next,i<D&&(s+=r);o=e,ne=ee,N=te;for(let t=0;t<i;t++)a=o<<2,n[a+3]=C=d*A>>j,C>0?(C=255/C,n[a]=(c*A>>j)*C,n[a+1]=(l*A>>j)*C,n[a+2]=(u*A>>j)*C):n[a]=n[a+1]=n[a+2]=0,c-=f,l-=p,u-=m,d-=h,f-=ne.r,p-=ne.g,m-=ne.b,h-=ne.a,a=e+((a=t+O)<D?a:D)*r<<2,c+=g+=ne.r=n[a],l+=_+=ne.g=n[a+1],u+=v+=ne.b=n[a+2],d+=y+=ne.a=n[a+3],ne=ne.next,f+=b=N.r,p+=x=N.g,m+=S=N.b,h+=C=N.a,g-=b,_-=x,v-=S,y-=C,N=N.next,o+=r}}var hu=function(e){let t=Math.round(this.blurRadius());t>0&&mu(e,t)};V.addGetterSetter(H,`blurRadius`,0,B(),V.afterSetFilter);var gu=function(e){let t=this.brightness()*255,n=e.data,r=n.length;for(let e=0;e<r;e+=4)n[e]+=t,n[e+1]+=t,n[e+2]+=t};V.addGetterSetter(H,`brightness`,0,B(),V.afterSetFilter);var _u=function(e){let t=this.brightness(),n=e.data,r=n.length;for(let e=0;e<r;e+=4)n[e]=Math.min(255,n[e]*t),n[e+1]=Math.min(255,n[e+1]*t),n[e+2]=Math.min(255,n[e+2]*t)},vu=function(e){let t=((this.contrast()+100)/100)**2,n=e.data,r=n.length,i=150,a=150,o=150;for(let e=0;e<r;e+=4)i=n[e],a=n[e+1],o=n[e+2],i/=255,i-=.5,i*=t,i+=.5,i*=255,a/=255,a-=.5,a*=t,a+=.5,a*=255,o/=255,o-=.5,o*=t,o+=.5,o*=255,i=i<0?0:i>255?255:i,a=a<0?0:a>255?255:a,o=o<0?0:o>255?255:o,n[e]=i,n[e+1]=a,n[e+2]=o};V.addGetterSetter(H,`contrast`,0,B(),V.afterSetFilter);var yu=function(e){let t=e.data,n=e.width,r=e.height,i=Math.min(1,Math.max(0,this.embossStrength?.call(this)??.5)),a=Math.min(1,Math.max(0,this.embossWhiteLevel?.call(this)??.5)),o={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[this.embossDirection?.call(this)??`top-left`]??315,s=!!(this.embossBlend?.call(this)??!1),c=i*10,l=a*255,u=o*Math.PI/180,d=Math.cos(u),f=Math.sin(u),p=128/1020*c,m=new Uint8ClampedArray(t),h=new Float32Array(n*r);for(let e=0,n=0;n<t.length;n+=4,e++)h[e]=.2126*m[n]+.7152*m[n+1]+.0722*m[n+2];let g=[-1,0,1,-2,0,2,-1,0,1],_=[-1,-2,-1,0,0,0,1,2,1],v=[-n-1,-n,-n+1,-1,0,1,n-1,n,n+1],y=e=>e<0?0:e>255?255:e;for(let e=1;e<r-1;e++)for(let r=1;r<n-1;r++){let i=e*n+r,a=0,o=0;a+=h[i+v[0]]*g[0],o+=h[i+v[0]]*_[0],a+=h[i+v[1]]*g[1],o+=h[i+v[1]]*_[1],a+=h[i+v[2]]*g[2],o+=h[i+v[2]]*_[2],a+=h[i+v[3]]*g[3],o+=h[i+v[3]]*_[3],a+=h[i+v[5]]*g[5],o+=h[i+v[5]]*_[5],a+=h[i+v[6]]*g[6],o+=h[i+v[6]]*_[6],a+=h[i+v[7]]*g[7],o+=h[i+v[7]]*_[7],a+=h[i+v[8]]*g[8],o+=h[i+v[8]]*_[8];let c=y(l+(d*a+f*o)*p),u=i*4;if(s){let e=c-l;t[u]=y(m[u]+e),t[u+1]=y(m[u+1]+e),t[u+2]=y(m[u+2]+e),t[u+3]=m[u+3]}else t[u]=t[u+1]=t[u+2]=c,t[u+3]=m[u+3]}for(let e=0;e<n;e++){let i=e*4,a=((r-1)*n+e)*4;t[i]=m[i],t[i+1]=m[i+1],t[i+2]=m[i+2],t[i+3]=m[i+3],t[a]=m[a],t[a+1]=m[a+1],t[a+2]=m[a+2],t[a+3]=m[a+3]}for(let e=1;e<r-1;e++){let r=e*n*4,i=(e*n+(n-1))*4;t[r]=m[r],t[r+1]=m[r+1],t[r+2]=m[r+2],t[r+3]=m[r+3],t[i]=m[i],t[i+1]=m[i+1],t[i+2]=m[i+2],t[i+3]=m[i+3]}return e};V.addGetterSetter(H,`embossStrength`,.5,B(),V.afterSetFilter),V.addGetterSetter(H,`embossWhiteLevel`,.5,B(),V.afterSetFilter),V.addGetterSetter(H,`embossDirection`,`top-left`,void 0,V.afterSetFilter),V.addGetterSetter(H,`embossBlend`,!1,void 0,V.afterSetFilter);function bu(e,t,n,r,i){let a=n-t,o=i-r;if(a===0)return r+o/2;if(o===0)return r;let s=(e-t)/a;return s=o*s+r,s}var xu=function(e){let t=e.data,n=t.length,r=t[0],i=r,a,o=t[1],s=o,c,l=t[2],u=l,d,f=this.enhance();if(f===0)return;for(let e=0;e<n;e+=4)a=t[e+0],a<r?r=a:a>i&&(i=a),c=t[e+1],c<o?o=c:c>s&&(s=c),d=t[e+2],d<l?l=d:d>u&&(u=d);i===r&&(i=255,r=0),s===o&&(s=255,o=0),u===l&&(u=255,l=0);let p,m,h,g,_,v;if(f>0)p=i+f*(255-i),m=r-f*(r-0),h=s+f*(255-s),g=o-f*(o-0),_=u+f*(255-u),v=l-f*(l-0);else{let e=(i+r)*.5;p=i+f*(i-e),m=r+f*(r-e);let t=(s+o)*.5;h=s+f*(s-t),g=o+f*(o-t);let n=(u+l)*.5;_=u+f*(u-n),v=l+f*(l-n)}for(let e=0;e<n;e+=4)t[e+0]=bu(t[e+0],r,i,m,p),t[e+1]=bu(t[e+1],o,s,g,h),t[e+2]=bu(t[e+2],l,u,v,_)};V.addGetterSetter(H,`enhance`,0,B(),V.afterSetFilter);var Su=function(e){let t=e.data,n=t.length;for(let e=0;e<n;e+=4){let n=.34*t[e]+.5*t[e+1]+.16*t[e+2];t[e]=n,t[e+1]=n,t[e+2]=n}};V.addGetterSetter(H,`hue`,0,B(),V.afterSetFilter),V.addGetterSetter(H,`saturation`,0,B(),V.afterSetFilter),V.addGetterSetter(H,`luminance`,0,B(),V.afterSetFilter);var Cu=function(e){let t=e.data,n=t.length,r=2**this.saturation(),i=Math.abs(this.hue()+360)%360,a=this.luminance()*127,o=1*r*Math.cos(i*Math.PI/180),s=1*r*Math.sin(i*Math.PI/180),c=.299*1+.701*o+.167*s,l=.587*1-.587*o+.33*s,u=.114*1-.114*o-.497*s,d=.299*1-.299*o-.328*s,f=.587*1+.413*o+.035*s,p=.114*1-.114*o+.293*s,m=.299*1-.3*o+1.25*s,h=.587*1-.586*o-1.05*s,g=.114*1+.886*o-.2*s,_,v,y,b;for(let e=0;e<n;e+=4)_=t[e+0],v=t[e+1],y=t[e+2],b=t[e+3],t[e+0]=c*_+l*v+u*y+a,t[e+1]=d*_+f*v+p*y+a,t[e+2]=m*_+h*v+g*y+a,t[e+3]=b},wu=function(e){let t=e.data,n=t.length,r=2**this.value(),i=2**this.saturation(),a=Math.abs(this.hue()+360)%360,o=r*i*Math.cos(a*Math.PI/180),s=r*i*Math.sin(a*Math.PI/180),c=.299*r+.701*o+.167*s,l=.587*r-.587*o+.33*s,u=.114*r-.114*o-.497*s,d=.299*r-.299*o-.328*s,f=.587*r+.413*o+.035*s,p=.114*r-.114*o+.293*s,m=.299*r-.3*o+1.25*s,h=.587*r-.586*o-1.05*s,g=.114*r+.886*o-.2*s;for(let e=0;e<n;e+=4){let n=t[e+0],r=t[e+1],i=t[e+2],a=t[e+3];t[e+0]=c*n+l*r+u*i,t[e+1]=d*n+f*r+p*i,t[e+2]=m*n+h*r+g*i,t[e+3]=a}};V.addGetterSetter(H,`hue`,0,B(),V.afterSetFilter),V.addGetterSetter(H,`saturation`,0,B(),V.afterSetFilter),V.addGetterSetter(H,`value`,0,B(),V.afterSetFilter);var Tu=function(e){let t=e.data,n=t.length;for(let e=0;e<n;e+=4)t[e]=255-t[e],t[e+1]=255-t[e+1],t[e+2]=255-t[e+2]},Eu=function(e,t,n){let r=e.data,i=t.data,a=e.width,o=e.height,s=n.polarCenterX||a/2,c=n.polarCenterY||o/2,l=Math.sqrt(s*s+c*c),u=a-s,d=o-c,f=Math.sqrt(u*u+d*d);l=f>l?f:l;let p=o,m=a,h=360/m*Math.PI/180;for(let e=0;e<m;e+=1){let t=Math.sin(e*h),n=Math.cos(e*h);for(let o=0;o<p;o+=1){u=Math.floor(s+l*o/p*n),d=Math.floor(c+l*o/p*t);let f=(d*a+u)*4,m=r[f+0],h=r[f+1],g=r[f+2],_=r[f+3];f=(e+o*a)*4,i[f+0]=m,i[f+1]=h,i[f+2]=g,i[f+3]=_}}},Du=function(e,t,n){let r=e.data,i=t.data,a=e.width,o=e.height,s=n.polarCenterX||a/2,c=n.polarCenterY||o/2,l=Math.sqrt(s*s+c*c),u=a-s,d=o-c,f=Math.sqrt(u*u+d*d);l=f>l?f:l;let p=o,m=a,h=n.polarRotation||0,g,_;for(u=0;u<a;u+=1)for(d=0;d<o;d+=1){let e=u-s,t=d-c,n=Math.sqrt(e*e+t*t)*p/l,o=(Math.atan2(t,e)*180/Math.PI+360+h)%360;o=o*m/360,g=Math.floor(o),_=Math.floor(n);let f=(_*a+g)*4,v=r[f+0],y=r[f+1],b=r[f+2],x=r[f+3];f=(d*a+u)*4,i[f+0]=v,i[f+1]=y,i[f+2]=b,i[f+3]=x}},Ou=function(e){let t=e.width,n=e.height,r,i,a,o,s,c,l,u,d,f,p=Math.round(this.kaleidoscopePower()),m=Math.round(this.kaleidoscopeAngle()),h=Math.floor(m%360*t/360);if(p<1)return;let g=z.createCanvasElement();g.width=t,g.height=n;let _=g.getContext(`2d`).getImageData(0,0,t,n);z.releaseCanvas(g),Eu(e,_,{polarCenterX:t/2,polarCenterY:n/2});let v=t/2**p;for(;v<=8;)v*=2,--p;v=Math.ceil(v);let y=v,b=0,x=y,S=1;for(h+v>t&&(b=y,x=0,S=-1),i=0;i<n;i+=1)for(r=b;r!==x;r+=S)a=Math.round(r+h)%t,d=(t*i+a)*4,s=_.data[d+0],c=_.data[d+1],l=_.data[d+2],u=_.data[d+3],f=(t*i+r)*4,_.data[f+0]=s,_.data[f+1]=c,_.data[f+2]=l,_.data[f+3]=u;for(i=0;i<n;i+=1)for(y=Math.floor(v),o=0;o<p;o+=1){for(r=0;r<y+1;r+=1)d=(t*i+r)*4,s=_.data[d+0],c=_.data[d+1],l=_.data[d+2],u=_.data[d+3],f=(t*i+y*2-r-1)*4,_.data[f+0]=s,_.data[f+1]=c,_.data[f+2]=l,_.data[f+3]=u;y*=2}Du(_,e,{polarRotation:0})};V.addGetterSetter(H,`kaleidoscopePower`,2,B(),V.afterSetFilter),V.addGetterSetter(H,`kaleidoscopeAngle`,0,B(),V.afterSetFilter);function ku(e,t,n){let r=(n*e.width+t)*4,i=[];return i.push(e.data[r++],e.data[r++],e.data[r++],e.data[r++]),i}function Au(e,t){return Math.sqrt((e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2)}function ju(e){let t=[0,0,0];for(let n=0;n<e.length;n++)t[0]+=e[n][0],t[1]+=e[n][1],t[2]+=e[n][2];return t[0]/=e.length,t[1]/=e.length,t[2]/=e.length,t}function Mu(e,t){let n=ku(e,0,0),r=ku(e,e.width-1,0),i=ku(e,0,e.height-1),a=ku(e,e.width-1,e.height-1),o=t||10;if(Au(n,r)<o&&Au(r,a)<o&&Au(a,i)<o&&Au(i,n)<o){let t=ju([r,n,a,i]),s=[];for(let n=0;n<e.width*e.height;n++)s[n]=Au(t,[e.data[n*4],e.data[n*4+1],e.data[n*4+2]])<o?0:255;return s}}function Nu(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function Pu(e,t,n){let r=[1,1,1,1,0,1,1,1,1],i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=[];for(let s=0;s<n;s++)for(let c=0;c<t;c++){let l=s*t+c,u=0;for(let o=0;o<i;o++)for(let l=0;l<i;l++){let d=s+o-a,f=c+l-a;if(d>=0&&d<n&&f>=0&&f<t){let n=d*t+f,a=r[o*i+l];u+=e[n]*a}}o[l]=u===2040?255:0}return o}function Fu(e,t,n){let r=[1,1,1,1,1,1,1,1,1],i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=[];for(let s=0;s<n;s++)for(let c=0;c<t;c++){let l=s*t+c,u=0;for(let o=0;o<i;o++)for(let l=0;l<i;l++){let d=s+o-a,f=c+l-a;if(d>=0&&d<n&&f>=0&&f<t){let n=d*t+f,a=r[o*i+l];u+=e[n]*a}}o[l]=u>=1020?255:0}return o}function Iu(e,t,n){let r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],i=Math.round(Math.sqrt(r.length)),a=Math.floor(i/2),o=[];for(let s=0;s<n;s++)for(let c=0;c<t;c++){let l=s*t+c,u=0;for(let o=0;o<i;o++)for(let l=0;l<i;l++){let d=s+o-a,f=c+l-a;if(d>=0&&d<n&&f>=0&&f<t){let n=d*t+f,a=r[o*i+l];u+=e[n]*a}}o[l]=u}return o}var Lu=function(e){let t=Mu(e,this.threshold());return t&&(t=Pu(t,e.width,e.height),t=Fu(t,e.width,e.height),t=Iu(t,e.width,e.height),Nu(e,t)),e};V.addGetterSetter(H,`threshold`,0,B(),V.afterSetFilter);var Ru=function(e){let t=this.noise()*255,n=e.data,r=n.length,i=t/2;for(let e=0;e<r;e+=4)n[e+0]+=i-2*i*Math.random(),n[e+1]+=i-2*i*Math.random(),n[e+2]+=i-2*i*Math.random()};V.addGetterSetter(H,`noise`,.2,B(),V.afterSetFilter);var zu=function(e){let t=Math.ceil(this.pixelSize()),n=e.width,r=e.height,i=Math.ceil(n/t),a=Math.ceil(r/t),o=e.data;if(t<=0){z.error(`pixelSize value can not be <= 0`);return}for(let e=0;e<i;e+=1)for(let i=0;i<a;i+=1){let a=0,s=0,c=0,l=0,u=e*t,d=u+t,f=i*t,p=f+t,m=0;for(let e=u;e<d;e+=1)if(!(e>=n))for(let t=f;t<p;t+=1){if(t>=r)continue;let i=(n*t+e)*4;a+=o[i+0],s+=o[i+1],c+=o[i+2],l+=o[i+3],m+=1}a/=m,s/=m,c/=m,l/=m;for(let e=u;e<d;e+=1)if(!(e>=n))for(let t=f;t<p;t+=1){if(t>=r)continue;let i=(n*t+e)*4;o[i+0]=a,o[i+1]=s,o[i+2]=c,o[i+3]=l}}};V.addGetterSetter(H,`pixelSize`,8,B(),V.afterSetFilter);var Bu=function(e){let t=Math.round(this.levels()*254)+1,n=e.data,r=n.length,i=255/t;for(let e=0;e<r;e+=1)n[e]=Math.floor(n[e]/i)*i};V.addGetterSetter(H,`levels`,.5,B(),V.afterSetFilter);var Vu=function(e){let t=e.data,n=t.length,r=this.red(),i=this.green(),a=this.blue();for(let e=0;e<n;e+=4){let n=(.34*t[e]+.5*t[e+1]+.16*t[e+2])/255;t[e]=n*r,t[e+1]=n*i,t[e+2]=n*a,t[e+3]=t[e+3]}};V.addGetterSetter(H,`red`,0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),V.addGetterSetter(H,`green`,0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),V.addGetterSetter(H,`blue`,0,wo,V.afterSetFilter);var Hu=function(e){let t=e.data,n=t.length,r=this.red(),i=this.green(),a=this.blue(),o=this.alpha();for(let e=0;e<n;e+=4){let n=1-o;t[e]=r*o+t[e]*n,t[e+1]=i*o+t[e+1]*n,t[e+2]=a*o+t[e+2]*n}};V.addGetterSetter(H,`red`,0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),V.addGetterSetter(H,`green`,0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),V.addGetterSetter(H,`blue`,0,wo,V.afterSetFilter),V.addGetterSetter(H,`alpha`,1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});var Uu=function(e){let t=e.data,n=t.length;for(let e=0;e<n;e+=4){let n=t[e+0],r=t[e+1],i=t[e+2];t[e+0]=Math.min(255,n*.393+r*.769+i*.189),t[e+1]=Math.min(255,n*.349+r*.686+i*.168),t[e+2]=Math.min(255,n*.272+r*.534+i*.131)}},Wu=function(e){let t=e.data;for(let e=0;e<t.length;e+=4){let n=t[e],r=t[e+1],i=t[e+2];.2126*n+.7152*r+.0722*i>=128&&(t[e]=255-n,t[e+1]=255-r,t[e+2]=255-i)}return e},Gu=function(e){let t=this.threshold()*255,n=e.data,r=n.length;for(let e=0;e<r;e+=1)n[e]=n[e]<t?0:255};V.addGetterSetter(H,`threshold`,.5,B(),V.afterSetFilter);var W=kc.Util._assign(kc,{Arc:Ac,Arrow:Wc,Circle:Gc,Ellipse:Kc,Image:qc,Label:nl,Tag:rl,Line:Pc,Path:Uc,Rect:il,RegularPolygon:al,Ring:sl,Sprite:cl,Star:ll,Text:Ul,TextPath:Jl,Transformer:cu,Wedge:uu,Filters:{Blur:hu,Brightness:_u,Brighten:gu,Contrast:vu,Emboss:yu,Enhance:xu,Grayscale:Su,HSL:Cu,HSV:wu,Invert:Tu,Kaleidoscope:Ou,Mask:Lu,Noise:Ru,Pixelate:zu,Posterize:Bu,RGB:Vu,RGBA:Hu,Sepia:Uu,Solarize:Wu,Threshold:Gu}}),Ku=kc,qu=o(((e,t)=>{t.exports=function(e){function t(e,t,n,r){return new va(e,t,n,r)}function n(){}function r(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function i(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function a(e){if(i(e)!==e)throw Error(r(188))}function o(e){var t=e.alternate;if(!t){if(t=i(e),t===null)throw Error(r(188));return t===e?e:null}for(var n=e,o=t;;){var s=n.return;if(s===null)break;var c=s.alternate;if(c===null){if(o=s.return,o!==null){n=o;continue}break}if(s.child===c.child){for(c=s.child;c;){if(c===n)return a(s),e;if(c===o)return a(s),t;c=c.sibling}throw Error(r(188))}if(n.return!==o.return)n=s,o=c;else{for(var l=!1,u=s.child;u;){if(u===n){l=!0,n=s,o=c;break}if(u===o){l=!0,o=s,n=c;break}u=u.sibling}if(!l){for(u=c.child;u;){if(u===n){l=!0,n=c,o=s;break}if(u===o){l=!0,o=c,n=s;break}u=u.sibling}if(!l)throw Error(r(189))}}if(n.alternate!==o)throw Error(r(190))}if(n.tag!==3)throw Error(r(188));return n.stateNode.current===n?e:t}function s(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=s(e),t!==null)return t;e=e.sibling}return null}function c(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(e.tag!==4&&(t=c(e),t!==null))return t;e=e.sibling}return null}function l(e){return typeof e!=`object`||!e?null:(e=Qa&&e[Qa]||e[`@@iterator`],typeof e==`function`?e:null)}function u(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===z?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case Ba:return`Fragment`;case Ha:return`Profiler`;case Va:return`StrictMode`;case Ka:return`Suspense`;case qa:return`SuspenseList`;case Xa:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case za:return`Portal`;case Wa:return e.displayName||`Context`;case Ua:return(e._context.displayName||`Context`)+`.Consumer`;case Ga:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case Ja:return t=e.displayName||null,t===null?u(e.type)||`Memo`:t;case Ya:t=e._payload,e=e._init;try{return u(e(t))}catch{}}return null}function f(e){return{current:e}}function m(e){0>gc||(e.current=hc[gc],hc[gc]=null,gc--)}function h(e,t){gc++,hc[gc]=e.current,e.current=t}function g(e){return e>>>=0,e===0?32:31-(yc(e)/bc|0)|0}function _(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function v(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=_(n))):i=_(o):i=_(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=_(n))):i=_(o)):i=_(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function y(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function b(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function x(){var e=Cc;return Cc<<=1,!(Cc&62914560)&&(Cc=4194304),e}function S(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function C(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function w(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-vc(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&T(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function T(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-vc(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function E(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-vc(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function D(e,t){var n=t&-t;return n=n&42?1:O(n),(n&(e.suspendedLanes|t))===0?n:0}function O(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function k(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function ee(e){if(typeof Nc==`function`&&Pc(e),Ic&&typeof Ic.setStrictMode==`function`)try{Ic.setStrictMode(Fc,e)}catch{}}function A(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}function j(e){if(Bc===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Bc=t&&t[1]||``,Vc=-1<e.stack.indexOf(`
|
|
27
|
+
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
28
|
+
`+Bc+e+Vc}function te(e,t){if(!e||Hc)return``;Hc=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
29
|
+
`),l=s.split(`
|
|
30
|
+
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
|
31
|
+
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Hc=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?j(n):``}function M(e,t){switch(e.tag){case 26:case 27:case 5:return j(e.type);case 16:return j(`Lazy`);case 13:return e.child!==t&&t!==null?j(`Suspense Fallback`):j(`Suspense`);case 19:return j(`SuspenseList`);case 0:case 15:return te(e.type,!1);case 11:return te(e.type.render,!1);case 1:return te(e.type,!0);case 31:return j(`Activity`);default:return``}}function ne(e){try{var t=``,n=null;do t+=M(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
32
|
+
Error generating stack: `+e.message+`
|
|
33
|
+
`+e.stack}}function N(e,t){if(typeof e==`object`&&e){var n=Uc.get(e);return n===void 0?(t={value:e,source:t,stack:ne(t)},Uc.set(e,t),t):n}return{value:e,source:t,stack:ne(t)}}function P(e,t){Wc[Gc++]=qc,Wc[Gc++]=Kc,Kc=e,qc=t}function re(e,t,n){Jc[Yc++]=Zc,Jc[Yc++]=Qc,Jc[Yc++]=Xc,Xc=e;var r=Zc;e=Qc;var i=32-vc(r)-1;r&=~(1<<i),n+=1;var a=32-vc(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Zc=1<<32-vc(t)+i|n<<i|r,Qc=a+e}else Zc=1<<a|n<<i|r,Qc=e}function ie(e){e.return!==null&&(P(e,1),re(e,1,0))}function ae(e){for(;e===Kc;)Kc=Wc[--Gc],Wc[Gc]=null,qc=Wc[--Gc],Wc[Gc]=null;for(;e===Xc;)Xc=Jc[--Yc],Jc[Yc]=null,Qc=Jc[--Yc],Jc[Yc]=null,Zc=Jc[--Yc],Jc[Yc]=null}function F(e,t){Jc[Yc++]=Zc,Jc[Yc++]=Qc,Jc[Yc++]=Xc,Zc=t.id,Qc=t.overflow,Xc=e}function oe(e,t){h(tl,t),h(el,e),h($c,null),e=ao(t),m($c),h($c,e)}function se(){m($c),m(el),m(tl)}function ce(e){e.memoizedState!==null&&h(nl,e);var t=$c.current,n=oo(t,e.type);t!==n&&(h(el,e),h($c,n))}function le(e){el.current===e&&(m($c),m(el)),nl.current===e&&(m(nl),vo?Fo._currentValue=Po:Fo._currentValue2=Po)}function ue(e){throw ge(N(Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),cl}function de(e,t){if(!xo)throw Error(r(175));js(e.stateNode,e.type,e.memoizedProps,t,e)||ue(e,!0)}function fe(e){for(rl=e.return;rl;)switch(rl.tag){case 5:case 31:case 13:sl=!1;return;case 27:case 3:sl=!0;return;default:rl=rl.return}}function pe(e){if(!xo||e!==rl)return!1;if(!al)return fe(e),al=!0,!1;var t=e.tag;if(uc?t!==3&&t!==27&&(t!==5||qs(e.type)&&!po(e.type,e.memoizedProps))&&il&&ue(e):t!==3&&(t!==5||qs(e.type)&&!po(e.type,e.memoizedProps))&&il&&ue(e),fe(e),t===13){if(!xo)throw Error(r(316));if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(r(317));il=Is(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(r(317));il=Fs(e)}else il=uc&&t===27?xs(e.type,il):rl?bs(e.stateNode):null;return!0}function me(){xo&&(il=rl=null,al=!1)}function he(){var e=ol;return e!==null&&(W===null?W=e:W.push.apply(W,e),ol=null),e}function ge(e){ol===null?ol=[e]:ol.push(e)}function _e(e,t,n){vo?(h(ll,t._currentValue),t._currentValue=n):(h(ll,t._currentValue2),t._currentValue2=n)}function ve(e){var t=ll.current;vo?e._currentValue=t:e._currentValue2=t,m(ll)}function ye(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function be(e,t,n,i){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),ye(o.return,n,e),i||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(r(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),ye(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function xe(e,t,n,i){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(r(387));if(s=s.memoizedProps,s!==null){var c=a.type;Lc(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===nl.current){if(s=a.alternate,s===null)throw Error(r(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[Fo]:e.push(Fo))}a=a.return}e!==null&&be(t,e,n,i),t.flags|=262144}function Se(e){for(e=e.firstContext;e!==null;){var t=e.context;if(!Lc(vo?t._currentValue:t._currentValue2,e.memoizedValue))return!0;e=e.next}return!1}function Ce(e){ul=e,dl=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function we(e){return Ee(ul,e)}function Te(e,t){return ul===null&&Ce(e),Ee(e,t)}function Ee(e,t){var n=vo?t._currentValue:t._currentValue2;if(t={context:t,memoizedValue:n,next:null},dl===null){if(e===null)throw Error(r(308));dl=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else dl=dl.next=t;return n}function De(){return{controller:new fl,data:new Map,refCount:0}}function Oe(e){e.refCount--,e.refCount===0&&pl(ml,function(){e.controller.abort()})}function ke(){}function Ae(e){e!==_l&&e.next===null&&(_l===null?gl=_l=e:_l=_l.next=e),yl=!0,vl||(vl=!0,Le())}function je(e,t){if(!bl&&yl){bl=!0;do for(var n=!1,r=gl;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-vc(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Ie(r,a))}else a=Mu,a=v(r,r===Au?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==_o),!(a&3)||y(r,a)||(n=!0,Ie(r,a));r=r.next}while(n);bl=!1}}function Me(){Ne()}function Ne(){yl=vl=!1;var e=0;xl!==0&&Eo()&&(e=xl);for(var t=Oc(),n=null,r=gl;r!==null;){var i=r.next,a=Pe(r,t);a===0?(r.next=null,n===null?gl=i:n.next=i,i===null&&(_l=n)):(n=r,(e!==0||a&3)&&(yl=!0)),r=i}Qu!==0&&Qu!==5||je(e,!1),xl!==0&&(xl=0)}function Pe(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-vc(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=b(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Au,n=Mu,n=v(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==_o),r=e.callbackNode,n===0||e===t&&(Nu===2||Nu===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Tc(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||y(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Tc(r),k(n)){case 2:case 8:n=Ac;break;case 32:n=jc;break;case 268435456:n=Mc;break;default:n=jc}return r=Fe.bind(null,e),n=wc(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Tc(r),e.callbackPriority=2,e.callbackNode=null,2}function Fe(e,t){if(Qu!==0&&Qu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(ca()&&e.callbackNode!==n)return null;var r=Mu;return r=v(e,e===Au?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==_o),r===0?null:(Ii(e,r,t),Pe(e,Oc()),e.callbackNode!=null&&e.callbackNode===n?Fe.bind(null,e):null)}function Ie(e,t){if(ca())return null;Ii(e,t,!0)}function Le(){Lo?Ro(function(){ku&6?wc(kc,Me):Ne()}):wc(kc,Me)}function Re(){if(xl===0){var e=wl;e===0&&(e=xc,xc<<=1,!(xc&261888)&&(xc=256)),xl=e}return xl}function ze(e,t){if(Sl===null){var n=Sl=[];Cl=0,wl=Re(),Tl={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Cl++,t.then(I,I),t}function I(){if(--Cl===0&&Sl!==null){Tl!==null&&(Tl.status=`fulfilled`);var e=Sl;Sl=null,wl=0,Tl=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Be(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}function Ve(){var e=Dl.current;return e===null?Au.pooledCache:e}function He(e,t){t===null?h(Dl,Dl.current):h(Dl,t.pool)}function Ue(){var e=Ve();return e===null?null:{parent:vo?hl._currentValue:hl._currentValue2,pool:e}}function We(e,t){if(Lc(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!zc.call(t,i)||!Lc(e[i],t[i]))return!1}return!0}function Ge(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Ke(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(ke,ke),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ye(e),e;default:if(typeof t.status==`string`)t.then(ke,ke);else{if(e=Au,e!==null&&100<e.shellSuspendCounter)throw Error(r(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ye(e),e}throw Ml=t,Ol}}function qe(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Ml=e,Ol):e}}function Je(){if(Ml===null)throw Error(r(459));var e=Ml;return Ml=null,e}function Ye(e){if(e===Ol||e===Al)throw Error(r(483))}function Xe(e){var t=Pl;return Pl+=1,Nl===null&&(Nl=[]),Ke(Nl,e,t)}function Ze(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Qe(e,t){throw t.$$typeof===La?Error(r(525)):(e=Object.prototype.toString.call(t),Error(r(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function $e(e){function n(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function i(t,r){if(!e)return null;for(;r!==null;)n(t,r),r=r.sibling;return null}function a(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function o(e,t){return e=ba(e,t),e.index=0,e.sibling=null,e}function s(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function c(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function u(e,t,n,r){return t===null||t.tag!==6?(t=wa(n,e.mode,r),t.return=e,t):(t=o(t,n),t.return=e,t)}function d(e,t,n,r){var i=n.type;return i===Ba?p(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===Ya&&qe(i)===t.type)?(t=o(t,n.props),Ze(t,n),t.return=e,t):(t=Sa(n.type,n.key,n.props,null,e.mode,r),Ze(t,n),t.return=e,t)}function f(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=Ea(n,e.mode,r),t.return=e,t):(t=o(t,n.children||[]),t.return=e,t)}function p(e,t,n,r,i){return t===null||t.tag!==7?(t=Ca(n,e.mode,r,i),t.return=e,t):(t=o(t,n),t.return=e,t)}function m(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=wa(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case Ra:return n=Sa(t.type,t.key,t.props,null,e.mode,n),Ze(n,t),n.return=e,n;case za:return t=Ea(t,e.mode,n),t.return=e,t;case Ya:return t=qe(t),m(e,t,n)}if($a(t)||l(t))return t=Ca(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return m(e,Xe(t),n);if(t.$$typeof===Wa)return m(e,Te(e,t),n);Qe(e,t)}return null}function h(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?u(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case Ra:return n.key===i?d(e,t,n,r):null;case za:return n.key===i?f(e,t,n,r):null;case Ya:return n=qe(n),h(e,t,n,r)}if($a(n)||l(n))return i===null?p(e,t,n,r,null):null;if(typeof n.then==`function`)return h(e,t,Xe(n),r);if(n.$$typeof===Wa)return h(e,t,Te(e,n),r);Qe(e,n)}return null}function g(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,u(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case Ra:return e=e.get(r.key===null?n:r.key)||null,d(t,e,r,i);case za:return e=e.get(r.key===null?n:r.key)||null,f(t,e,r,i);case Ya:return r=qe(r),g(e,t,n,r,i)}if($a(r)||l(r))return e=e.get(n)||null,p(t,e,r,i,null);if(typeof r.then==`function`)return g(e,t,n,Xe(r),i);if(r.$$typeof===Wa)return g(e,t,n,Te(t,r),i);Qe(t,r)}return null}function _(t,r,o,c){for(var l=null,u=null,d=r,f=r=0,p=null;d!==null&&f<o.length;f++){d.index>f?(p=d,d=null):p=d.sibling;var _=h(t,d,o[f],c);if(_===null){d===null&&(d=p);break}e&&d&&_.alternate===null&&n(t,d),r=s(_,r,f),u===null?l=_:u.sibling=_,u=_,d=p}if(f===o.length)return i(t,d),al&&P(t,f),l;if(d===null){for(;f<o.length;f++)d=m(t,o[f],c),d!==null&&(r=s(d,r,f),u===null?l=d:u.sibling=d,u=d);return al&&P(t,f),l}for(d=a(d);f<o.length;f++)p=g(d,t,f,o[f],c),p!==null&&(e&&p.alternate!==null&&d.delete(p.key===null?f:p.key),r=s(p,r,f),u===null?l=p:u.sibling=p,u=p);return e&&d.forEach(function(e){return n(t,e)}),al&&P(t,f),l}function v(t,o,c,l){if(c==null)throw Error(r(151));for(var u=null,d=null,f=o,p=o=0,_=null,v=c.next();f!==null&&!v.done;p++,v=c.next()){f.index>p?(_=f,f=null):_=f.sibling;var y=h(t,f,v.value,l);if(y===null){f===null&&(f=_);break}e&&f&&y.alternate===null&&n(t,f),o=s(y,o,p),d===null?u=y:d.sibling=y,d=y,f=_}if(v.done)return i(t,f),al&&P(t,p),u;if(f===null){for(;!v.done;p++,v=c.next())v=m(t,v.value,l),v!==null&&(o=s(v,o,p),d===null?u=v:d.sibling=v,d=v);return al&&P(t,p),u}for(f=a(f);!v.done;p++,v=c.next())v=g(f,t,p,v.value,l),v!==null&&(e&&v.alternate!==null&&f.delete(v.key===null?p:v.key),o=s(v,o,p),d===null?u=v:d.sibling=v,d=v);return e&&f.forEach(function(e){return n(t,e)}),al&&P(t,p),u}function y(e,t,a,s){if(typeof a==`object`&&a&&a.type===Ba&&a.key===null&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case Ra:a:{for(var u=a.key;t!==null;){if(t.key===u){if(u=a.type,u===Ba){if(t.tag===7){i(e,t.sibling),s=o(t,a.props.children),s.return=e,e=s;break a}}else if(t.elementType===u||typeof u==`object`&&u&&u.$$typeof===Ya&&qe(u)===t.type){i(e,t.sibling),s=o(t,a.props),Ze(s,a),s.return=e,e=s;break a}i(e,t);break}else n(e,t);t=t.sibling}a.type===Ba?(s=Ca(a.props.children,e.mode,s,a.key),s.return=e,e=s):(s=Sa(a.type,a.key,a.props,null,e.mode,s),Ze(s,a),s.return=e,e=s)}return c(e);case za:a:{for(u=a.key;t!==null;){if(t.key===u)if(t.tag===4&&t.stateNode.containerInfo===a.containerInfo&&t.stateNode.implementation===a.implementation){i(e,t.sibling),s=o(t,a.children||[]),s.return=e,e=s;break a}else{i(e,t);break}else n(e,t);t=t.sibling}s=Ea(a,e.mode,s),s.return=e,e=s}return c(e);case Ya:return a=qe(a),y(e,t,a,s)}if($a(a))return _(e,t,a,s);if(l(a)){if(u=l(a),typeof u!=`function`)throw Error(r(150));return a=u.call(a),v(e,t,a,s)}if(typeof a.then==`function`)return y(e,t,Xe(a),s);if(a.$$typeof===Wa)return y(e,t,Te(e,a),s);Qe(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,t!==null&&t.tag===6?(i(e,t.sibling),s=o(t,a),s.return=e,e=s):(i(e,t),s=wa(a,e.mode,s),s.return=e,e=s),c(e)):i(e,t)}return function(e,n,r,i){try{Pl=0;var a=y(e,n,r,i);return Nl=null,a}catch(n){if(n===Ol||n===Al)throw n;var o=t(29,n,null,e.mode);return o.lanes=i,o.return=e,o}}}function et(){for(var e=Rl,t=zl=Rl=0;t<e;){var n=Ll[t];Ll[t++]=null;var r=Ll[t];Ll[t++]=null;var i=Ll[t];Ll[t++]=null;var a=Ll[t];if(Ll[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&it(n,i,a)}}function tt(e,t,n,r){Ll[Rl++]=e,Ll[Rl++]=t,Ll[Rl++]=n,Ll[Rl++]=r,zl|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function nt(e,t,n,r){return tt(e,t,n,r),at(e)}function rt(e,t){return tt(e,null,null,t),at(e)}function it(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-vc(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function at(e){if(50<ad)throw ad=0,od=null,Error(r(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}function ot(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function st(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function ct(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function lt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ku&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=at(e),it(e,null,n),t}return tt(e,r,t,n),at(e)}function ut(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,E(e,n)}}function dt(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ft(){if(Vl){var e=Tl;if(e!==null)throw e}}function pt(e,t,n,r){Vl=!1;var i=e.updateQueue;Bl=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Mu&f)===f:(r&f)===f){f!==0&&f===wl&&(Vl=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=Ia({},d,f);break a;case 2:Bl=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Bu|=o,e.lanes=o,e.memoizedState=d}}function mt(e,t){if(typeof e!=`function`)throw Error(r(191,e));e.call(t)}function ht(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)mt(n[e],t)}function gt(e,t){e=Ru,h(Ul,e),h(Hl,t),Ru=e|t.baseLanes}function _t(){h(Ul,Ru),h(Hl,Hl.current)}function vt(){Ru=Ul.current,m(Hl),m(Ul)}function yt(e){var t=e.alternate;h(Kl,Kl.current&1),h(Wl,e),Gl===null&&(t===null||Hl.current!==null||t.memoizedState!==null)&&(Gl=e)}function bt(e){h(Kl,Kl.current),h(Wl,e),Gl===null&&(Gl=e)}function xt(e){e.tag===22?(h(Kl,Kl.current),h(Wl,e),Gl===null&&(Gl=e)):St(e)}function St(){h(Kl,Kl.current),h(Wl,Wl.current)}function Ct(e){m(Wl),Gl===e&&(Gl=null),m(Kl)}function wt(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||ms(n)||hs(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}function Tt(){throw Error(r(321))}function Et(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Lc(e[n],t[n]))return!1;return!0}function Dt(e,t,n,r,i,a){return ql=a,Jl=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,eo.H=e===null||e.memoizedState===null?au:ou,$l=!1,a=n(r,i),$l=!1,Ql&&(a=kt(t,n,r,i)),Ot(e),a}function Ot(e){eo.H=iu;var t=Yl!==null&&Yl.next!==null;if(ql=0,Xl=Yl=Jl=null,Zl=!1,tu=0,nu=null,t)throw Error(r(300));e===null||uu||(e=e.dependencies,e!==null&&Se(e)&&(uu=!0))}function kt(e,t,n,i){Jl=e;var a=0;do{if(Ql&&(nu=null),tu=0,Ql=!1,25<=a)throw Error(r(301));if(a+=1,Xl=Yl=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}eo.H=su,o=t(n,i)}while(Ql);return o}function At(){var e=eo.H,t=e.useState()[0];return t=typeof t.then==`function`?Lt(t):t,e=e.useState()[0],(Yl===null?null:Yl.memoizedState)!==e&&(Jl.flags|=1024),t}function jt(){var e=eu!==0;return eu=0,e}function Mt(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Nt(e){if(Zl){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Zl=!1}ql=0,Xl=Yl=Jl=null,Ql=!1,tu=eu=0,nu=null}function Pt(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Xl===null?Jl.memoizedState=Xl=e:Xl=Xl.next=e,Xl}function Ft(){if(Yl===null){var e=Jl.alternate;e=e===null?null:e.memoizedState}else e=Yl.next;var t=Xl===null?Jl.memoizedState:Xl.next;if(t!==null)Xl=t,Yl=e;else{if(e===null)throw Jl.alternate===null?Error(r(467)):Error(r(310));Yl=e,e={memoizedState:Yl.memoizedState,baseState:Yl.baseState,baseQueue:Yl.baseQueue,queue:Yl.queue,next:null},Xl===null?Jl.memoizedState=Xl=e:Xl=Xl.next=e}return Xl}function It(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Lt(e){var t=tu;return tu+=1,nu===null&&(nu=[]),e=Ke(nu,e,t),t=Jl,(Xl===null?t.memoizedState:Xl.next)===null&&(t=t.alternate,eo.H=t===null||t.memoizedState===null?au:ou),e}function Rt(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Lt(e);if(e.$$typeof===Wa)return we(e)}throw Error(r(438,String(e)))}function zt(e){var t=null,n=Jl.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=Jl.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=It(),Jl.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=Za;return t.index++,n}function Bt(e,t){return typeof t==`function`?t(e):t}function Vt(e){return Ht(Ft(),Yl,e)}function Ht(e,t,n){var i=e.queue;if(i===null)throw Error(r(311));i.lastRenderedReducer=n;var a=e.baseQueue,o=i.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,i.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(ql&f)===f:(Mu&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===wl&&(d=!0);else if((ql&p)===p){u=u.next,p===wl&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,Jl.lanes|=p,Bu|=p;f=u.action,$l&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,Jl.lanes|=f,Bu|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Lc(o,e.memoizedState)&&(uu=!0,d&&(n=Tl,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,i.lastRenderedState=o}return a===null&&(i.lanes=0),[e.memoizedState,i.dispatch]}function Ut(e){var t=Ft(),n=t.queue;if(n===null)throw Error(r(311));n.lastRenderedReducer=e;var i=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);Lc(o,t.memoizedState)||(uu=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,i]}function Wt(e,t,n){var i=Jl,a=Ft(),o=al;if(o){if(n===void 0)throw Error(r(407));n=n()}else n=t();var s=!Lc((Yl||a).memoizedState,n);if(s&&(a.memoizedState=n,uu=!0),a=a.queue,gn(qt.bind(null,i,a,e),[e]),a.getSnapshot!==t||s||Xl!==null&&Xl.memoizedState.tag&1){if(i.flags|=2048,dn(9,{destroy:void 0},Kt.bind(null,i,a,n,t),null),Au===null)throw Error(r(349));o||ql&127||Gt(i,t,n)}return n}function Gt(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Jl.updateQueue,t===null?(t=It(),Jl.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Kt(e,t,n,r){t.value=n,t.getSnapshot=r,Jt(t)&&Yt(e)}function qt(e,t,n){return n(function(){Jt(t)&&Yt(e)})}function Jt(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Lc(e,n)}catch{return!0}}function Yt(e){var t=rt(e,2);t!==null&&Fi(t,e,2)}function Xt(e){var t=Pt();if(typeof e==`function`){var n=e;if(e=n(),$l){ee(!0);try{n()}finally{ee(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bt,lastRenderedState:e},t}function Zt(e,t,n,r){return e.baseState=n,Ht(e,Yl,typeof r==`function`?r:Bt)}function Qt(e,t,n,i,a){if(Ln(e))throw Error(r(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};eo.T===null?o.isTransition=!1:n(!0),i(o),n=t.pending,n===null?(o.next=t.pending=o,$t(t,o)):(o.next=n.next,t.pending=n.next=o)}}function $t(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=eo.T,o={};eo.T=o;try{var s=n(i,r),c=eo.S;c!==null&&c(o,s),en(e,t,s)}catch(n){nn(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),eo.T=a}}else try{a=n(i,r),en(e,t,a)}catch(n){nn(e,t,n)}}function en(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){tn(e,t,n)},function(n){return nn(e,t,n)}):tn(e,t,n)}function tn(e,t,n){t.status=`fulfilled`,t.value=n,rn(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,$t(e,n)))}function nn(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,rn(t),t=t.next;while(t!==r)}e.action=null}function rn(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function an(e,t){return t}function on(e,t){if(al){var n=Au.formState;if(n!==null){a:{var r=Jl;if(al){if(il){var i=vs(il,sl);if(i){il=bs(i),r=ys(i);break a}}ue(r)}r=!1}r&&(t=n[0])}}n=Pt(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:an,lastRenderedState:t},n.queue=r,n=Pn.bind(null,Jl,r),r.dispatch=n,r=Xt(!1);var a=In.bind(null,Jl,!1,r.queue);return r=Pt(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Qt.bind(null,Jl,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function sn(e){return cn(Ft(),Yl,e)}function cn(e,t,n){if(t=Ht(e,t,an)[0],e=Vt(Bt)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Lt(t)}catch(e){throw e===Ol?Al:e}else r=t;t=Ft();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(Jl.flags|=2048,dn(9,{destroy:void 0},ln.bind(null,i,n),null)),[r,a,e]}function ln(e,t){e.action=t}function un(e){var t=Ft(),n=Yl;if(n!==null)return cn(t,n,e);Ft(),t=t.memoizedState,n=Ft();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function dn(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=Jl.updateQueue,t===null&&(t=It(),Jl.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function fn(){return Ft().memoizedState}function pn(e,t,n,r){var i=Pt();Jl.flags|=e,i.memoizedState=dn(1|t,{destroy:void 0},n,r===void 0?null:r)}function mn(e,t,n,r){var i=Ft();r=r===void 0?null:r;var a=i.memoizedState.inst;Yl!==null&&r!==null&&Et(r,Yl.memoizedState.deps)?i.memoizedState=dn(t,a,n,r):(Jl.flags|=e,i.memoizedState=dn(1|t,a,n,r))}function hn(e,t){pn(8390656,8,e,t)}function gn(e,t){mn(2048,8,e,t)}function _n(e){Jl.flags|=4;var t=Jl.updateQueue;if(t===null)t=It(),Jl.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function vn(e){var t=Ft().memoizedState;return _n({ref:t,nextImpl:e}),function(){if(ku&2)throw Error(r(440));return t.impl.apply(void 0,arguments)}}function yn(e,t){return mn(4,2,e,t)}function bn(e,t){return mn(4,4,e,t)}function xn(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Sn(e,t,n){n=n==null?null:n.concat([e]),mn(4,4,xn.bind(null,t,e),n)}function Cn(){}function wn(e,t){var n=Ft();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&Et(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Tn(e,t){var n=Ft();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&Et(t,r[1]))return r[0];if(r=e(),$l){ee(!0);try{e()}finally{ee(!1)}}return n.memoizedState=[r,t],r}function En(e,t,n){return n===void 0||ql&1073741824&&!(Mu&261930)?e.memoizedState=t:(e.memoizedState=n,e=Pi(),Jl.lanes|=e,Bu|=e,n)}function Dn(e,t,n,r){return Lc(n,t)?n:Hl.current===null?!(ql&42)||ql&1073741824&&!(Mu&261930)?(uu=!0,e.memoizedState=n):(e=Pi(),Jl.lanes|=e,Bu|=e,t):(e=En(e,n,r),Lc(e,t)||(uu=!0),e)}function L(e,t,n,r,i){var a=B();wo(a!==0&&8>a?a:8);var o=eo.T,s={};eo.T=s,In(e,!1,t,n);try{var c=i(),l=eo.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Fn(e,t,Be(c,r),Ni(e)):Fn(e,t,r,Ni(e))}catch(n){Fn(e,t,{then:function(){},status:`rejected`,reason:n},Ni())}finally{wo(a),o!==null&&s.types!==null&&(o.types=s.types),eo.T=o}}function On(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Po,baseState:Po,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bt,lastRenderedState:Po},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Bt,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function kn(){return we(Fo)}function An(){return Ft().memoizedState}function jn(){return Ft().memoizedState}function Mn(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Ni();e=ct(n);var r=lt(t,e,n);r!==null&&(Fi(r,t,n),ut(r,t,n)),t={cache:De()},e.payload=t;return}t=t.return}}function Nn(e,t,n){var r=Ni();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ln(e)?Rn(t,n):(n=nt(e,t,n,r),n!==null&&(Fi(n,e,r),zn(n,t,r)))}function Pn(e,t,n){Fn(e,t,n,Ni())}function Fn(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ln(e))Rn(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Lc(s,o))return tt(e,t,i,0),Au===null&&et(),!1}catch{}if(n=nt(e,t,i,r),n!==null)return Fi(n,e,r),zn(n,t,r),!0}return!1}function In(e,t,n,i){if(i={lane:2,revertLane:Re(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Ln(e)){if(t)throw Error(r(479))}else t=nt(e,n,i,2),t!==null&&Fi(t,e,2)}function Ln(e){var t=e.alternate;return e===Jl||t!==null&&t===Jl}function Rn(e,t){Ql=Zl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function zn(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,E(e,n)}}function Bn(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Ia({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}function Vn(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!We(n,r)||!We(i,a):!0}function Hn(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&cu.enqueueReplaceState(t,t.state,null)}function Un(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=Ia({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Wn(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Gn(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Kn(e,t,n){return n=ct(n),n.tag=3,n.payload={element:null},n.callback=function(){Wn(e,t)},n}function qn(e){return e=ct(e),e.tag=3,e}function Jn(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Gn(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Gn(t,n,r),typeof i!=`function`&&(Zu===null?Zu=new Set([this]):Zu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Yn(e,t,n,i,a){if(n.flags|=32768,typeof i==`object`&&i&&typeof i.then==`function`){if(t=n.alternate,t!==null&&xe(t,n,a,!0),n=Wl.current,n!==null){switch(n.tag){case 31:case 13:return Gl===null?qi():n.alternate===null&&zu===0&&(zu=3),n.flags&=-257,n.flags|=65536,n.lanes=a,i===jl?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([i]):t.add(i),fa(e,i,a)),!1;case 22:return n.flags|=65536,i===jl?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([i])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([i]):n.add(i)),fa(e,i,a)),!1}throw Error(r(435,n.tag))}return fa(e,i,a),qi(),!1}if(al)return t=Wl.current,t===null?(i!==cl&&(t=Error(r(423),{cause:i}),ge(N(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,i=N(i,n),a=Kn(e.stateNode,i,a),dt(e,a),zu!==4&&(zu=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,i!==cl&&(e=Error(r(422),{cause:i}),ge(N(e,n)))),!1;var o=Error(r(520),{cause:i});if(o=N(o,n),Gu===null?Gu=[o]:Gu.push(o),zu!==4&&(zu=2),t===null)return!0;i=N(i,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Kn(n.stateNode,i,e),dt(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(Zu===null||!Zu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=qn(a),Jn(a,e,n,i),dt(n,a),!1}n=n.return}while(n!==null);return!1}function Xn(e,t,n,r){t.child=e===null?Il(t,null,n,r):Fl(t,e.child,n,r)}function Zn(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Ce(t),r=Dt(e,t,n,o,a,i),s=jt(),e!==null&&!uu?(Mt(e,t,i),br(e,t,i)):(al&&s&&ie(t),t.flags|=1,Xn(e,t,r,i),t.child)}function Qn(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ya(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,$n(e,t,a,r,i)):(e=Sa(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!xr(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?We:n,n(o,r)&&e.ref===t.ref)return br(e,t,i)}return t.flags|=1,e=ba(a,r),e.ref=t.ref,e.return=t,t.child=e}function $n(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(We(a,r)&&e.ref===t.ref)if(uu=!1,t.pendingProps=r=a,xr(e,i))e.flags&131072&&(uu=!0);else return t.lanes=e.lanes,br(e,t,i)}return sr(e,t,n,r,i)}function er(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return nr(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&He(t,a===null?null:a.cachePool),a===null?_t():gt(t,a),xt(t);else return r=t.lanes=536870912,nr(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&He(t,null),_t(),St(t)):(He(t,a.cachePool),gt(t,a),St(t),t.memoizedState=null);return Xn(e,t,i,n),t.child}function tr(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function nr(e,t,n,r,i){var a=Ve();return a=a===null?null:{parent:vo?hl._currentValue:hl._currentValue2,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&He(t,null),_t(),xt(t),e!==null&&xe(e,t,r,!0),t.childLanes=i,null}function rr(e,t){return t=hr({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function ir(e,t,n){return Fl(t,e.child,null,n),e=rr(t,t.pendingProps),e.flags|=2,Ct(t),t.memoizedState=null,e}function ar(e,t,n){var i=t.pendingProps,a=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(al){if(i.mode===`hidden`)return e=rr(t,i),t.lanes=536870912,tr(null,e);if(bt(t),(e=il)?(e=ks(e,sl),e!==null&&(t.memoizedState={dehydrated:e,treeContext:Xc===null?null:{id:Zc,overflow:Qc},retryLane:536870912,hydrationErrors:null},n=Ta(e),n.return=t,t.child=n,rl=t,il=null)):e=null,e===null)throw ue(t);return t.lanes=536870912,null}return rr(t,i)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(bt(t),a)if(t.flags&256)t.flags&=-257,t=ir(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(r(558));else if(uu||xe(e,t,n,!1),a=(n&e.childLanes)!==0,uu||a){if(i=Au,i!==null&&(s=D(i,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,rt(e,s),Fi(i,e,s),lu;qi(),t=ir(e,t,n)}else e=o.treeContext,xo&&(il=ws(s),rl=t,al=!0,ol=null,sl=!1,e!==null&&F(t,e)),t=rr(t,i),t.flags|=4096;return t}return e=ba(e.child,{mode:i.mode,children:i.children}),e.ref=t.ref,t.child=e,e.return=t,e}function or(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(r(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function sr(e,t,n,r,i){return Ce(t),n=Dt(e,t,n,r,void 0,i),r=jt(),e!==null&&!uu?(Mt(e,t,i),br(e,t,i)):(al&&r&&ie(t),t.flags|=1,Xn(e,t,n,i),t.child)}function cr(e,t,n,r,i,a){return Ce(t),t.updateQueue=null,n=kt(t,r,n,i),Ot(e),r=jt(),e!==null&&!uu?(Mt(e,t,a),br(e,t,a)):(al&&r&&ie(t),t.flags|=1,Xn(e,t,n,a),t.child)}function lr(e,t,n,r,i){if(Ce(t),t.stateNode===null){var a=_c,o=n.contextType;typeof o==`object`&&o&&(a=we(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=cu,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},ot(t),o=n.contextType,a.context=typeof o==`object`&&o?we(o):_c,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Bn(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&cu.enqueueReplaceState(a,a.state,null),pt(t,r,a,i),ft(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Un(n,s);a.props=c;var l=a.context,u=n.contextType;o=_c,typeof u==`object`&&u&&(o=we(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Hn(t,a,r,o),Bl=!1;var f=t.memoizedState;a.state=f,pt(t,r,a,i),ft(),l=t.memoizedState,s||f!==l||Bl?(typeof d==`function`&&(Bn(t,n,d,r),l=t.memoizedState),(c=Bl||Vn(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,st(e,t),o=t.memoizedProps,u=Un(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=_c,typeof l==`object`&&l&&(c=we(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Hn(t,a,r,c),Bl=!1,f=t.memoizedState,a.state=f,pt(t,r,a,i),ft();var p=t.memoizedState;o!==d||f!==p||Bl||e!==null&&e.dependencies!==null&&Se(e.dependencies)?(typeof s==`function`&&(Bn(t,n,s,r),p=t.memoizedState),(u=Bl||Vn(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Se(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,or(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Fl(t,e.child,null,i),t.child=Fl(t,null,n,i)):Xn(e,t,n,i),t.memoizedState=a.state,e=t.child):e=br(e,t,i),e}function ur(e,t,n,r){return me(),t.flags|=256,Xn(e,t,n,r),t.child}function dr(e){return{baseLanes:e,cachePool:Ue()}}function fr(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Uu),e}function pr(e,t,n){var i=t.pendingProps,a=!1,o=(t.flags&128)!=0,s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:(Kl.current&2)!=0),s&&(a=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(al){if(a?yt(t):St(t),(e=il)?(e=As(e,sl),e!==null&&(t.memoizedState={dehydrated:e,treeContext:Xc===null?null:{id:Zc,overflow:Qc},retryLane:536870912,hydrationErrors:null},n=Ta(e),n.return=t,t.child=n,rl=t,il=null)):e=null,e===null)throw ue(t);return hs(e)?t.lanes=32:t.lanes=536870912,null}var c=i.children;return i=i.fallback,a?(St(t),a=t.mode,c=hr({mode:`hidden`,children:c},a),i=Ca(i,a,n,null),c.return=t,i.return=t,c.sibling=i,t.child=c,i=t.child,i.memoizedState=dr(n),i.childLanes=fr(e,s,n),t.memoizedState=du,tr(null,i)):(yt(t),mr(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(yt(t),t.flags&=-257,t=gr(e,t,n)):t.memoizedState===null?(St(t),c=i.fallback,a=t.mode,i=hr({mode:`visible`,children:i.children},a),c=Ca(c,a,n,null),c.flags|=2,i.return=t,c.return=t,i.sibling=c,t.child=i,Fl(t,e.child,null,n),i=t.child,i.memoizedState=dr(n),i.childLanes=fr(e,s,n),t.memoizedState=du,t=tr(null,i)):(St(t),t.child=e.child,t.flags|=128,t=null);else if(yt(t),hs(c))s=gs(c).digest,i=Error(r(419)),i.stack=``,i.digest=s,ge({value:i,source:null,stack:null}),t=gr(e,t,n);else if(uu||xe(e,t,n,!1),s=(n&e.childLanes)!==0,uu||s){if(s=Au,s!==null&&(i=D(s,n),i!==0&&i!==l.retryLane))throw l.retryLane=i,rt(e,i),Fi(s,e,i),lu;ms(c)||qi(),t=gr(e,t,n)}else ms(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,xo&&(il=Ts(c),rl=t,al=!0,ol=null,sl=!1,e!==null&&F(t,e)),t=mr(t,i.children),t.flags|=4096);return t}return a?(St(t),c=i.fallback,a=t.mode,l=e.child,o=l.sibling,i=ba(l,{mode:`hidden`,children:i.children}),i.subtreeFlags=l.subtreeFlags&65011712,o===null?(c=Ca(c,a,n,null),c.flags|=2):c=ba(o,c),c.return=t,i.return=t,i.sibling=c,t.child=i,tr(null,i),i=t.child,c=e.child.memoizedState,c===null?c=dr(n):(a=c.cachePool,a===null?a=Ue():(l=vo?hl._currentValue:hl._currentValue2,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),i.memoizedState=c,i.childLanes=fr(e,s,n),t.memoizedState=du,tr(e.child,i)):(yt(t),n=e.child,e=n.sibling,n=ba(n,{mode:`visible`,children:i.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function mr(e,t){return t=hr({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function hr(e,n){return e=t(22,e,null,n),e.lanes=0,e}function gr(e,t,n){return Fl(t,e.child,null,n),e=mr(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function _r(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ye(e.return,t,n)}function vr(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function yr(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Kl.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,h(Kl,o),Xn(e,t,r,n),r=al?qc:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&_r(e,n,t);else if(e.tag===19)_r(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&wt(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),vr(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&wt(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}vr(t,!0,n,null,a,r);break;case`together`:vr(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function br(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Bu|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(xe(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(r(153));if(t.child!==null){for(e=t.child,n=ba(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ba(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function xr(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&Se(e))):!0}function Sr(e,t,n){switch(t.tag){case 3:oe(t,t.stateNode.containerInfo),_e(t,hl,e.memoizedState.cache),me();break;case 27:case 5:ce(t);break;case 4:oe(t,t.stateNode.containerInfo);break;case 10:_e(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,bt(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(yt(t),e=br(e,t,n),e===null?null:e.sibling):pr(e,t,n):(yt(t),t.flags|=128,null);yt(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(xe(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return yr(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),h(Kl,Kl.current),r)break;return null;case 22:return t.lanes=0,er(e,t,n,t.pendingProps);case 24:_e(t,hl,e.memoizedState.cache)}return br(e,t,n)}function Cr(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)uu=!0;else{if(!xr(e,n)&&!(t.flags&128))return uu=!1,Sr(e,t,n);uu=!!(e.flags&131072)}else uu=!1,al&&t.flags&1048576&&re(t,qc,t.index);switch(t.lanes=0,t.tag){case 16:a:{var i=t.pendingProps;if(e=qe(t.elementType),t.type=e,typeof e==`function`)ya(e)?(i=Un(e,i),t.tag=1,t=lr(null,t,e,i,n)):(t.tag=0,t=sr(null,t,e,i,n));else{if(e!=null){var a=e.$$typeof;if(a===Ga){t.tag=11,t=Zn(null,t,e,i,n);break a}else if(a===Ja){t.tag=14,t=Qn(null,t,e,i,n);break a}}throw t=u(e)||e,Error(r(306,t,``))}}return t;case 0:return sr(e,t,t.type,t.pendingProps,n);case 1:return i=t.type,a=Un(i,t.pendingProps),lr(e,t,i,a,n);case 3:a:{if(oe(t,t.stateNode.containerInfo),e===null)throw Error(r(387));var o=t.pendingProps;a=t.memoizedState,i=a.element,st(e,t),pt(t,o,null,n);var s=t.memoizedState;if(o=s.cache,_e(t,hl,o),o!==a.cache&&be(t,[hl],n,!0),ft(),o=s.element,xo&&a.isDehydrated)if(a={element:o,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){t=ur(e,t,o,n);break a}else if(o!==i){i=N(Error(r(424)),t),ge(i),t=ur(e,t,o,n);break a}else for(xo&&(il=Cs(t.stateNode.containerInfo),rl=t,al=!0,ol=null,sl=!0),n=Il(t,null,o,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(me(),o===i){t=br(e,t,n);break a}Xn(e,t,o,n)}t=t.child}return t;case 26:if(Xs)return or(e,t),e===null?(n=$s(t.type,null,t.pendingProps,null))?t.memoizedState=n:al||(t.stateNode=ac(t.type,t.pendingProps,tl.current,t)):t.memoizedState=$s(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:if(uc)return ce(t),e===null&&uc&&al&&(i=t.stateNode=U(t.type,t.pendingProps,tl.current,$c.current,!1),rl=t,sl=!0,il=Es(t.type,i,il)),Xn(e,t,t.pendingProps.children,n),or(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&al&&(Js(t.type,t.pendingProps,$c.current),(a=i=il)&&(i=Ds(i,t.type,t.pendingProps,sl),i===null?a=!1:(t.stateNode=i,rl=t,il=Ss(i),sl=!1,a=!0)),a||ue(t)),ce(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,i=o.children,po(a,o)?i=null:s!==null&&po(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=Dt(e,t,At,null,null,n),vo?Fo._currentValue=a:Fo._currentValue2=a),or(e,t),Xn(e,t,i,n),t.child;case 6:return e===null&&al&&(Ys(t.pendingProps,$c.current),(e=n=il)&&(n=Os(n,t.pendingProps,sl),n===null?e=!1:(t.stateNode=n,rl=t,il=null,e=!0)),e||ue(t)),null;case 13:return pr(e,t,n);case 4:return oe(t,t.stateNode.containerInfo),i=t.pendingProps,e===null?t.child=Fl(t,null,i,n):Xn(e,t,i,n),t.child;case 11:return Zn(e,t,t.type,t.pendingProps,n);case 7:return Xn(e,t,t.pendingProps,n),t.child;case 8:return Xn(e,t,t.pendingProps.children,n),t.child;case 12:return Xn(e,t,t.pendingProps.children,n),t.child;case 10:return i=t.pendingProps,_e(t,t.type,i.value),Xn(e,t,i.children,n),t.child;case 9:return a=t.type._context,i=t.pendingProps.children,Ce(t),a=we(a),i=i(a),t.flags|=1,Xn(e,t,i,n),t.child;case 14:return Qn(e,t,t.type,t.pendingProps,n);case 15:return $n(e,t,t.type,t.pendingProps,n);case 19:return yr(e,t,n);case 31:return ar(e,t,n);case 22:return er(e,t,n,t.pendingProps);case 24:return Ce(t),i=we(hl),e===null?(a=Ve(),a===null&&(a=Au,o=De(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:i,cache:a},ot(t),_e(t,hl,a)):((e.lanes&n)!==0&&(st(e,t),pt(t,null,null,n),ft()),a=e.memoizedState,o=t.memoizedState,a.parent===i?(i=o.cache,_e(t,hl,i),i!==a.cache&&be(t,[hl],n,!0)):(a={parent:i,cache:i},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),_e(t,hl,i))),Xn(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(r(156,t.tag))}function wr(e){e.flags|=4}function Tr(e){bo&&(e.flags|=8)}function Er(e,t){if(e!==null&&e.child===t.child)return!1;if(t.flags&16)return!0;for(e=t.child;e!==null;){if(e.flags&8218||e.subtreeFlags&8218)return!0;e=e.sibling}return!1}function Dr(e,t,n,r){if(yo)for(n=t.child;n!==null;){if(n.tag===5||n.tag===6)uo(e,n.stateNode);else if(!(n.tag===4||uc&&n.tag===27)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}else if(bo)for(var i=t.child;i!==null;){if(i.tag===5){var a=i.stateNode;n&&r&&(a=fs(a,i.type,i.memoizedProps)),uo(e,a)}else if(i.tag===6)a=i.stateNode,n&&r&&(a=ps(a,i.memoizedProps)),uo(e,a);else if(i.tag!==4){if(i.tag===22&&i.memoizedState!==null)a=i.child,a!==null&&(a.return=i),Dr(e,i,!0,!0);else if(i.child!==null){i.child.return=i,i=i.child;continue}}if(i===t)break;for(;i.sibling===null;){if(i.return===null||i.return===t)return;i=i.return}i.sibling.return=i.return,i=i.sibling}}function Or(e,t,n,r){var i=!1;if(bo)for(var a=t.child;a!==null;){if(a.tag===5){var o=a.stateNode;n&&r&&(o=fs(o,a.type,a.memoizedProps)),ls(e,o)}else if(a.tag===6)o=a.stateNode,n&&r&&(o=ps(o,a.memoizedProps)),ls(e,o);else if(a.tag!==4){if(a.tag===22&&a.memoizedState!==null)i=a.child,i!==null&&(i.return=a),Or(e,a,!0,!0),i=!0;else if(a.child!==null){a.child.return=a,a=a.child;continue}}if(a===t)break;for(;a.sibling===null;){if(a.return===null||a.return===t)return i;a=a.return}a.sibling.return=a.return,a=a.sibling}return i}function kr(e,t){if(bo&&Er(e,t)){e=t.stateNode;var n=e.containerInfo,r=cs();Or(r,t,!1,!1),e.pendingChildren=r,wr(t),us(n,r)}}function Ar(e,t,n,r){if(yo)e.memoizedProps!==r&&wr(t);else if(bo){var i=e.stateNode,a=e.memoizedProps;if((e=Er(e,t))||a!==r){var o=$c.current;a=ss(i,n,a,r,!e,null),a===i?t.stateNode=i:(Tr(t),fo(a,n,r,o)&&wr(t),t.stateNode=a,e&&Dr(a,t,!1,!1))}else t.stateNode=i}}function jr(e,t,n,r,i){if(e.mode&32&&(n===null?Oo(t,r):ko(t,n,r))){if(e.flags|=16777216,(i&335544128)===i||Ao(t,r))if(jo(e.stateNode,t,r))e.flags|=8192;else if(Wi())e.flags|=8192;else throw Ml=jl,kl}else e.flags&=-16777217}function Mr(e,t){if(sc(t)){if(e.flags|=16777216,!cc(t))if(Wi())e.flags|=8192;else throw Ml=jl,kl}else e.flags&=-16777217}function Nr(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:x(),e.lanes|=t,Wu|=t)}function Pr(e,t){if(!al)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Fr(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Ir(e,t,n){var i=t.pendingProps;switch(ae(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Fr(t),null;case 1:return Fr(t),null;case 3:return n=t.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),t.memoizedState.cache!==i&&(t.flags|=2048),ve(hl),se(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(pe(t)?wr(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,he())),kr(e,t),Fr(t),null;case 26:if(Xs){var a=t.type,o=t.memoizedState;return e===null?(wr(t),o===null?(Fr(t),jr(t,a,null,i,n)):(Fr(t),Mr(t,o))):o?o===e.memoizedState?(Fr(t),t.flags&=-16777217):(wr(t),Fr(t),Mr(t,o)):(o=e.memoizedProps,yo?o!==i&&wr(t):Ar(e,t,a,i),Fr(t),jr(t,a,o,i,n)),null}case 27:if(uc){if(le(t),n=tl.current,a=t.type,e!==null&&t.stateNode!=null)yo?e.memoizedProps!==i&&wr(t):Ar(e,t,a,i);else{if(!i){if(t.stateNode===null)throw Error(r(166));return Fr(t),null}e=$c.current,pe(t)?de(t,e):(e=U(a,i,n,e,!0),t.stateNode=e,wr(t))}return Fr(t),null}case 5:if(le(t),a=t.type,e!==null&&t.stateNode!=null)Ar(e,t,a,i);else{if(!i){if(t.stateNode===null)throw Error(r(166));return Fr(t),null}if(o=$c.current,pe(t))de(t,o),Vs(t.stateNode,a,i,o)&&(t.flags|=64);else{var s=lo(a,i,tl.current,o,t);Tr(t),Dr(s,t,!1,!1),t.stateNode=s,fo(s,a,i,o)&&wr(t)}}return Fr(t),jr(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)n=e.memoizedProps,yo?n!==i&&wr(t):bo&&(n===i?t.stateNode=e.stateNode:(e=tl.current,n=$c.current,Tr(t),t.stateNode=mo(i,e,n,t)));else{if(typeof i!=`string`&&t.stateNode===null)throw Error(r(166));if(e=tl.current,n=$c.current,pe(t)){if(!xo)throw Error(r(176));if(e=t.stateNode,n=t.memoizedProps,i=null,a=rl,a!==null)switch(a.tag){case 27:case 5:i=a.memoizedProps}Ms(e,n,t,i)||ue(t,!0)}else Tr(t),t.stateNode=mo(i,e,n,t)}return Fr(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(i=pe(t),n!==null){if(e===null){if(!i)throw Error(r(318));if(!xo)throw Error(r(556));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(r(557));Ns(e,t)}else me(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Fr(t),e=!1}else n=he(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Ct(t),t):(Ct(t),null);if(t.flags&128)throw Error(r(558))}return Fr(t),null;case 13:if(i=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=pe(t),i!==null&&i.dehydrated!==null){if(e===null){if(!a)throw Error(r(318));if(!xo)throw Error(r(344));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(r(317));Ps(a,t)}else me(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Fr(t),a=!1}else a=he(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Ct(t),t):(Ct(t),null)}return Ct(t),t.flags&128?(t.lanes=n,t):(n=i!==null,e=e!==null&&e.memoizedState!==null,n&&(i=t.child,a=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(a=i.alternate.memoizedState.cachePool.pool),o=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),o!==a&&(i.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Nr(t,t.updateQueue),Fr(t),null);case 4:return se(),kr(e,t),e===null&&Co(t.stateNode.containerInfo),Fr(t),null;case 10:return ve(t.type),Fr(t),null;case 19:if(m(Kl),i=t.memoizedState,i===null)return Fr(t),null;if(a=(t.flags&128)!=0,o=i.rendering,o===null)if(a)Pr(i,!1);else{if(zu!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=wt(e),o!==null){for(t.flags|=128,Pr(i,!1),e=o.updateQueue,t.updateQueue=e,Nr(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)xa(n,e),n=n.sibling;return h(Kl,Kl.current&1|2),al&&P(t,i.treeForkCount),t.child}e=e.sibling}i.tail!==null&&Oc()>Yu&&(t.flags|=128,a=!0,Pr(i,!1),t.lanes=4194304)}else{if(!a)if(e=wt(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Nr(t,e),Pr(i,!0),i.tail===null&&i.tailMode===`hidden`&&!o.alternate&&!al)return Fr(t),null}else 2*Oc()-i.renderingStartTime>Yu&&n!==536870912&&(t.flags|=128,a=!0,Pr(i,!1),t.lanes=4194304);i.isBackwards?(o.sibling=t.child,t.child=o):(e=i.last,e===null?t.child=o:e.sibling=o,i.last=o)}return i.tail===null?(Fr(t),null):(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Oc(),e.sibling=null,n=Kl.current,h(Kl,a?n&1|2:n&1),al&&P(t,i.treeForkCount),e);case 22:case 23:return Ct(t),vt(),i=t.memoizedState!==null,e===null?i&&(t.flags|=8192):e.memoizedState!==null!==i&&(t.flags|=8192),i?n&536870912&&!(t.flags&128)&&(Fr(t),t.subtreeFlags&6&&(t.flags|=8192)):Fr(t),n=t.updateQueue,n!==null&&Nr(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),i=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(i=t.memoizedState.cachePool.pool),i!==n&&(t.flags|=2048),e!==null&&m(Dl),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),ve(hl),Fr(t),null;case 25:return null;case 30:return null}throw Error(r(156,t.tag))}function Lr(e,t){switch(ae(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return ve(hl),se(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return le(t),null;case 31:if(t.memoizedState!==null){if(Ct(t),t.alternate===null)throw Error(r(340));me()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Ct(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));me()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return m(Kl),null;case 4:return se(),null;case 10:return ve(t.type),null;case 22:case 23:return Ct(t),vt(),e!==null&&m(Dl),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return ve(hl),null;case 25:return null;default:return null}}function Rr(e,t){switch(ae(t),t.tag){case 3:ve(hl),se();break;case 26:case 27:case 5:le(t);break;case 4:se();break;case 31:t.memoizedState!==null&&Ct(t);break;case 13:Ct(t);break;case 19:m(Kl);break;case 10:ve(t.type);break;case 22:case 23:Ct(t),vt(),e!==null&&m(Dl);break;case 24:ve(hl)}}function zr(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){da(t,t.return,e)}}function Br(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){da(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){da(t,t.return,e)}}function Vr(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{ht(t,n)}catch(t){da(e,e.return,t)}}}function Hr(e,t,n){n.props=Un(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){da(e,t,n)}}function Ur(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=io(e.stateNode);break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){da(e,t,n)}}function Wr(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){da(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){da(e,t,n)}else n.current=null}function Gr(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{Xo(r,t,n,e)}catch(t){da(e,e.return,t)}}function Kr(e,t,n){try{Zo(e.stateNode,e.type,n,t,e)}catch(t){da(e,e.return,t)}}function qr(e){return e.tag===5||e.tag===3||(Xs?e.tag===26:!1)||(uc?e.tag===27&&mc(e.type):!1)||e.tag===4}function Jr(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||qr(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(uc&&e.tag===27&&mc(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Yr(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?$o(n,e,t):Jo(n,e);else if(r!==4&&(uc&&r===27&&mc(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Yr(e,t,n),e=e.sibling;e!==null;)Yr(e,t,n),e=e.sibling}function Xr(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?Qo(n,e,t):qo(n,e);else if(r!==4&&(uc&&r===27&&mc(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Xr(e,t,n),e=e.sibling;e!==null;)Xr(e,t,n),e=e.sibling}function Zr(e,t,n){e=e.containerInfo;try{ds(e,n)}catch(e){da(t,t.return,e)}}function Qr(e){var t=e.stateNode,n=e.memoizedProps;try{dc(e.type,n,t,e)}catch(t){da(e,e.return,t)}}function $r(e,t){for(so(e.containerInfo),gu=t;gu!==null;)if(e=gu,t=e.child,e.subtreeFlags&1028&&t!==null)t.return=e,gu=t;else for(;gu!==null;){e=gu;var n=e.alternate;switch(t=e.flags,e.tag){case 0:if(t&4&&(t=e.updateQueue,t=t===null?null:t.events,t!==null))for(var i=0;i<t.length;i++){var a=t[i];a.ref.impl=a.nextImpl}break;case 11:case 15:break;case 1:if(t&1024&&n!==null){t=void 0,i=e,a=n.memoizedProps,n=n.memoizedState;var o=i.stateNode;try{var s=Un(i.type,a);t=o.getSnapshotBeforeUpdate(s,n),o.__reactInternalSnapshotBeforeUpdate=t}catch(e){da(i,i.return,e)}}break;case 3:t&1024&&yo&&os(e.stateNode.containerInfo);break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(t&1024)throw Error(r(163))}if(t=e.sibling,t!==null){t.return=e.return,gu=t;break}gu=e.return}}function ei(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:fi(e,n),r&4&&zr(5,n);break;case 1:if(fi(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){da(n,n.return,e)}else{var i=Un(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){da(n,n.return,e)}}r&64&&Vr(n),r&512&&Ur(n,n.return);break;case 3:if(fi(e,n),r&64&&(r=n.updateQueue,r!==null)){if(e=null,n.child!==null)switch(n.child.tag){case 27:case 5:e=io(n.child.stateNode);break;case 1:e=n.child.stateNode}try{ht(r,e)}catch(e){da(n,n.return,e)}}break;case 27:uc&&t===null&&r&4&&Qr(n);case 26:case 5:if(fi(e,n),t===null){if(r&4)Gr(n);else if(r&64){e=n.type,t=n.memoizedProps,i=n.stateNode;try{Ls(i,e,t,n)}catch(e){da(n,n.return,e)}}}r&512&&Ur(n,n.return);break;case 12:fi(e,n);break;case 31:fi(e,n),r&4&&ii(e,n);break;case 13:fi(e,n),r&4&&ai(e,n),r&64&&(r=n.memoizedState,r!==null&&(r=r.dehydrated,r!==null&&(n=ha.bind(null,n),_s(r,n))));break;case 22:if(r=n.memoizedState!==null||fu,!r){t=t!==null&&t.memoizedState!==null||pu,i=fu;var a=pu;fu=r,(pu=t)&&!a?mi(e,n,(n.subtreeFlags&8772)!=0):fi(e,n),fu=i,pu=a}break;case 30:break;default:fi(e,n)}}function ti(e){var t=e.alternate;t!==null&&(e.alternate=null,ti(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Do(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function ni(e,t,n){for(n=n.child;n!==null;)ri(e,t,n),n=n.sibling}function ri(e,t,n){if(Ic&&typeof Ic.onCommitFiberUnmount==`function`)try{Ic.onCommitFiberUnmount(Fc,n)}catch{}switch(n.tag){case 26:if(Xs){pu||Wr(n,t),ni(e,t,n),n.memoizedState?tc(n.memoizedState):n.stateNode&&ic(n.stateNode);break}case 27:if(uc){pu||Wr(n,t);var r=_u,i=vu;mc(n.type)&&(_u=n.stateNode,vu=!1),ni(e,t,n),fc(n.stateNode),_u=r,vu=i;break}case 5:pu||Wr(n,t);case 6:if(yo){if(r=_u,i=vu,_u=null,ni(e,t,n),_u=r,vu=i,_u!==null)if(vu)try{ts(_u,n.stateNode)}catch(e){da(n,t,e)}else try{es(_u,n.stateNode)}catch(e){da(n,t,e)}}else ni(e,t,n);break;case 18:yo&&_u!==null&&(vu?Ws(_u,n.stateNode):Us(_u,n.stateNode));break;case 4:yo?(r=_u,i=vu,_u=n.stateNode.containerInfo,vu=!0,ni(e,t,n),_u=r,vu=i):(bo&&Zr(n.stateNode,n,cs()),ni(e,t,n));break;case 0:case 11:case 14:case 15:Br(2,n,t),pu||Br(4,n,t),ni(e,t,n);break;case 1:pu||(Wr(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Hr(n,t,r)),ni(e,t,n);break;case 21:ni(e,t,n);break;case 22:pu=(r=pu)||n.memoizedState!==null,ni(e,t,n),pu=r;break;default:ni(e,t,n)}}function ii(e,t){if(xo&&t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{zs(e)}catch(e){da(t,t.return,e)}}}function ai(e,t){if(xo&&t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Bs(e)}catch(e){da(t,t.return,e)}}function oi(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new hu),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new hu),t;default:throw Error(r(435,e.tag))}}function si(e,t){var n=oi(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=ga.bind(null,e,t);t.then(r,r)}})}function ci(e,t){var n=t.deletions;if(n!==null)for(var i=0;i<n.length;i++){var a=n[i],o=e,s=t;if(yo){var c=s;a:for(;c!==null;){switch(c.tag){case 27:if(uc){if(mc(c.type)){_u=c.stateNode,vu=!1;break a}break}case 5:_u=c.stateNode,vu=!1;break a;case 3:case 4:_u=c.stateNode.containerInfo,vu=!0;break a}c=c.return}if(_u===null)throw Error(r(160));ri(o,s,a),_u=null,vu=!1}else ri(o,s,a);o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)li(t,e),t=t.sibling}function li(e,t){var n=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:ci(t,e),ui(e),i&4&&(Br(3,e,e.return),zr(3,e),Br(5,e,e.return));break;case 1:ci(t,e),ui(e),i&512&&(pu||n===null||Wr(n,n.return)),i&64&&fu&&(e=e.updateQueue,e!==null&&(i=e.callbacks,i!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?i:n.concat(i))));break;case 26:if(Xs){var a=yu;if(ci(t,e),ui(e),i&512&&(pu||n===null||Wr(n,n.return)),i&4){i=n===null?null:n.memoizedState;var o=e.memoizedState;n===null?o===null?e.stateNode===null?e.stateNode=nc(a,e.type,e.memoizedProps,e):rc(a,e.type,e.stateNode):e.stateNode=ec(a,o,e.memoizedProps):i===o?o===null&&e.stateNode!==null&&Kr(e,e.memoizedProps,n.memoizedProps):(i===null?n.stateNode!==null&&ic(n.stateNode):tc(i),o===null?rc(a,e.type,e.stateNode):ec(a,o,e.memoizedProps))}break}case 27:if(uc){ci(t,e),ui(e),i&512&&(pu||n===null||Wr(n,n.return)),n!==null&&i&4&&Kr(e,e.memoizedProps,n.memoizedProps);break}case 5:if(ci(t,e),ui(e),i&512&&(pu||n===null||Wr(n,n.return)),yo){if(e.flags&32){a=e.stateNode;try{ns(a)}catch(t){da(e,e.return,t)}}i&4&&e.stateNode!=null&&(a=e.memoizedProps,Kr(e,a,n===null?a:n.memoizedProps)),i&1024&&(mu=!0)}else bo&&e.alternate!==null&&(e.alternate.stateNode=e.stateNode);break;case 6:if(ci(t,e),ui(e),i&4&&yo){if(e.stateNode===null)throw Error(r(162));i=e.memoizedProps,n=n===null?i:n.memoizedProps,a=e.stateNode;try{Yo(a,n,i)}catch(t){da(e,e.return,t)}}break;case 3:if(Xs?(oc(),a=yu,yu=Qs(t.containerInfo),ci(t,e),yu=a):ci(t,e),ui(e),i&4){if(yo&&xo&&n!==null&&n.memoizedState.isDehydrated)try{Rs(t.containerInfo)}catch(t){da(e,e.return,t)}if(bo){i=t.containerInfo,n=t.pendingChildren;try{ds(i,n)}catch(t){da(e,e.return,t)}}}mu&&(mu=!1,di(e));break;case 4:Xs?(n=yu,yu=Qs(e.stateNode.containerInfo),ci(t,e),ui(e),yu=n):(ci(t,e),ui(e)),i&4&&bo&&Zr(e.stateNode,e,e.stateNode.pendingChildren);break;case 12:ci(t,e),ui(e);break;case 31:ci(t,e),ui(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,si(e,i)));break;case 13:ci(t,e),ui(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(qu=Oc()),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,si(e,i)));break;case 22:a=e.memoizedState!==null;var s=n!==null&&n.memoizedState!==null,c=fu,l=pu;if(fu=c||a,pu=l||s,ci(t,e),pu=l,fu=c,ui(e),i&8192&&(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||s||fu||pu||pi(e)),yo)){a:if(n=null,yo)for(t=e;;){if(t.tag===5||Xs&&t.tag===26){if(n===null){s=n=t;try{o=s.stateNode,a?rs(o):H(s.stateNode,s.memoizedProps)}catch(e){da(s,s.return,e)}}}else if(t.tag===6){if(n===null){s=t;try{var u=s.stateNode;a?is(u):as(u,s.memoizedProps)}catch(e){da(s,s.return,e)}}}else if(t.tag===18){if(n===null){s=t;try{var d=s.stateNode;a?Gs(d):Ks(s.stateNode)}catch(e){da(s,s.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}}i&4&&(i=e.updateQueue,i!==null&&(n=i.retryQueue,n!==null&&(i.retryQueue=null,si(e,n))));break;case 19:ci(t,e),ui(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,si(e,i)));break;case 30:break;case 21:break;default:ci(t,e),ui(e)}}function ui(e){var t=e.flags;if(t&2){try{for(var n,i=e.return;i!==null;){if(qr(i)){n=i;break}i=i.return}if(yo){if(n==null)throw Error(r(160));switch(n.tag){case 27:if(uc){var a=n.stateNode;Xr(e,Jr(e),a);break}case 5:var o=n.stateNode;n.flags&32&&(ns(o),n.flags&=-33),Xr(e,Jr(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Yr(e,Jr(e),s);break;default:throw Error(r(161))}}}catch(t){da(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function di(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;di(t),t.tag===5&&t.flags&1024&&Io(t.stateNode),e=e.sibling}}function fi(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)ei(e,t.alternate,t),t=t.sibling}function pi(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Br(4,t,t.return),pi(t);break;case 1:Wr(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Hr(t,t.return,n),pi(t);break;case 27:uc&&fc(t.stateNode);case 26:case 5:Wr(t,t.return),pi(t);break;case 22:t.memoizedState===null&&pi(t);break;case 30:pi(t);break;default:pi(t)}e=e.sibling}}function mi(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:mi(i,a,n),zr(4,a);break;case 1:if(mi(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){da(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)mt(c[i],s)}catch(e){da(r,r.return,e)}}n&&o&64&&Vr(a),Ur(a,a.return);break;case 27:uc&&Qr(a);case 26:case 5:mi(i,a,n),n&&r===null&&o&4&&Gr(a),Ur(a,a.return);break;case 12:mi(i,a,n);break;case 31:mi(i,a,n),n&&o&4&&ii(i,a);break;case 13:mi(i,a,n),n&&o&4&&ai(i,a);break;case 22:a.memoizedState===null&&mi(i,a,n),Ur(a,a.return);break;case 30:break;default:mi(i,a,n)}t=t.sibling}}function hi(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Oe(n))}function gi(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Oe(e))}function _i(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)vi(e,t,n,r),t=t.sibling}function vi(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:_i(e,t,n,r),i&2048&&zr(9,t);break;case 1:_i(e,t,n,r);break;case 3:_i(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Oe(e)));break;case 12:if(i&2048){_i(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){da(t,t.return,e)}}else _i(e,t,n,r);break;case 31:_i(e,t,n,r);break;case 13:_i(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?_i(e,t,n,r):(a._visibility|=2,yi(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?_i(e,t,n,r):bi(e,t),i&2048&&hi(o,t);break;case 24:_i(e,t,n,r),i&2048&&gi(t.alternate,t);break;default:_i(e,t,n,r)}}function yi(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:yi(a,o,s,c,i),zr(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,yi(a,o,s,c,i)):u._visibility&2?yi(a,o,s,c,i):bi(a,o),i&&l&2048&&hi(o.alternate,o);break;case 24:yi(a,o,s,c,i),i&&l&2048&&gi(o.alternate,o);break;default:yi(a,o,s,c,i)}t=t.sibling}}function bi(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:bi(n,r),i&2048&&hi(r.alternate,r);break;case 24:bi(n,r),i&2048&&gi(r.alternate,r);break;default:bi(n,r)}t=t.sibling}}function xi(e,t,n){if(e.subtreeFlags&bu)for(e=e.child;e!==null;)Si(e,t,n),e=e.sibling}function Si(e,t,n){switch(e.tag){case 26:if(xi(e,t,n),e.flags&bu)if(e.memoizedState!==null)lc(n,yu,e.memoizedState,e.memoizedProps);else{var r=e.stateNode,i=e.type;e=e.memoizedProps,((t&335544128)===t||Ao(i,e))&&No(n,r,i,e)}break;case 5:xi(e,t,n),e.flags&bu&&(r=e.stateNode,i=e.type,e=e.memoizedProps,((t&335544128)===t||Ao(i,e))&&No(n,r,i,e));break;case 3:case 4:Xs?(r=yu,yu=Qs(e.stateNode.containerInfo),xi(e,t,n),yu=r):xi(e,t,n);break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=bu,bu=16777216,xi(e,t,n),bu=r):xi(e,t,n));break;default:xi(e,t,n)}}function Ci(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function wi(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];gu=r,Di(r,e)}Ci(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Ti(e),e=e.sibling}function Ti(e){switch(e.tag){case 0:case 11:case 15:wi(e),e.flags&2048&&Br(9,e,e.return);break;case 3:wi(e);break;case 12:wi(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Ei(e)):wi(e);break;default:wi(e)}}function Ei(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];gu=r,Di(r,e)}Ci(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Br(8,t,t.return),Ei(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Ei(t));break;default:Ei(t)}e=e.sibling}}function Di(e,t){for(;gu!==null;){var n=gu;switch(n.tag){case 0:case 11:case 15:Br(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Oe(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,gu=r;else a:for(n=e;gu!==null;){r=gu;var i=r.sibling,a=r.return;if(ti(r),r===n){gu=null;break a}if(i!==null){i.return=a,gu=i;break a}gu=a}}}function Oi(e){var t=So(e);if(t!=null){if(typeof t.memoizedProps[`data-testname`]!=`string`)throw Error(r(364));return t}if(e=Bo(e),e===null)throw Error(r(362));return e.stateNode.current}function ki(e,t){var n=e.tag;switch(t.$$typeof){case Su:if(e.type===t.value)return!0;break;case Cu:a:{for(t=t.value,e=[e,0],n=0;n<e.length;){var i=e[n++],a=i.tag,o=e[n++],s=t[o];if(a!==5&&a!==26&&a!==27||!Uo(i)){for(;s!=null&&ki(i,s);)o++,s=t[o];if(o===t.length){t=!0;break a}else for(i=i.child;i!==null;)e.push(i,o),i=i.sibling}}t=!1}return t;case wu:if((n===5||n===26||n===27)&&Wo(e.stateNode,t.value))return!0;break;case Eu:if((n===5||n===6||n===26||n===27)&&(e=Ho(e),e!==null&&0<=e.indexOf(t.value)))return!0;break;case Tu:if((n===5||n===26||n===27)&&(e=e.memoizedProps[`data-testname`],typeof e==`string`&&e.toLowerCase()===t.value.toLowerCase()))return!0;break;default:throw Error(r(365))}return!1}function Ai(e){switch(e.$$typeof){case Su:return`<`+(u(e.value)||`Unknown`)+`>`;case Cu:return`:has(`+(Ai(e)||``)+`)`;case wu:return`[role="`+e.value+`"]`;case Eu:return`"`+e.value+`"`;case Tu:return`[data-testname="`+e.value+`"]`;default:throw Error(r(365))}}function ji(e,t){var n=[];e=[e,0];for(var r=0;r<e.length;){var i=e[r++],a=i.tag,o=e[r++],s=t[o];if(a!==5&&a!==26&&a!==27||!Uo(i)){for(;s!=null&&ki(i,s);)o++,s=t[o];if(o===t.length)n.push(i);else for(i=i.child;i!==null;)e.push(i,o),i=i.sibling}}return n}function Mi(e,t){if(!zo)throw Error(r(363));e=Oi(e),e=ji(e,t),t=[],e=Array.from(e);for(var n=0;n<e.length;){var i=e[n++],a=i.tag;if(a===5||a===26||a===27)Uo(i)||t.push(i.stateNode);else for(i=i.child;i!==null;)e.push(i),i=i.sibling}return t}function Ni(){return ku&2&&Mu!==0?Mu&-Mu:eo.T===null?To():Re()}function Pi(){if(Uu===0)if(!(Mu&536870912)||al){var e=Sc;Sc<<=1,!(Sc&3932160)&&(Sc=262144),Uu=e}else Uu=536870912;return e=Wl.current,e!==null&&(e.flags|=32),Uu}function Fi(e,t,n){(e===Au&&(Nu===2||Nu===9)||e.cancelPendingCommit!==null)&&(Hi(e,0),zi(e,Mu,Uu,!1)),C(e,n),(!(ku&2)||e!==Au)&&(e===Au&&(!(ku&2)&&(Vu|=n),zu===4&&zi(e,Mu,Uu,!1)),Ae(e))}function Ii(e,t,n){if(ku&6)throw Error(r(327));var i=!n&&(t&127)==0&&(t&e.expiredLanes)===0||y(e,t),a=i?Xi(e,t):Ji(e,t,!0),o=i;do{if(a===0){Iu&&!i&&zi(e,t,0,!1);break}else{if(n=e.current.alternate,o&&!Ri(n)){a=Ji(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=Gu;var l=xo&&c.current.memoizedState.isDehydrated;if(l&&(Hi(c,s).flags|=256),s=Ji(c,s,!1),s!==2){if(Lu&&!l){c.errorRecoveryDisabledLanes|=o,Vu|=o,a=4;break a}o=W,W=a,o!==null&&(W===null?W=o:W.push.apply(W,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){Hi(e,0),zi(e,t,0,!0);break}a:{switch(i=e,o=a,o){case 0:case 1:throw Error(r(345));case 4:if((t&4194048)!==t)break;case 6:zi(i,t,Uu,!Fu);break a;case 2:W=null;break;case 3:case 5:break;default:throw Error(r(329))}if((t&62914560)===t&&(a=qu+300-Oc(),10<a)){if(zi(i,t,Uu,!Fu),v(i,0,!0)!==0)break a;td=t,i.timeoutHandle=ho(Li.bind(null,i,n,W,Xu,Ku,t,Uu,Vu,Wu,Fu,o,`Throttled`,-0,0),a);break a}Li(i,n,W,Xu,Ku,t,Uu,Vu,Wu,Fu,o,null,-0,0)}}break}while(1);Ae(e)}function Li(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=_o,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d=Mo(),Si(t,a,d);var m=(a&62914560)===a?qu-Oc():(a&4194048)===a?Ju-Oc():0;if(m=V(d,m),m!==null){td=a,e.cancelPendingCommit=m(ra.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),zi(e,a,o,!l);return}}ra(e,t,a,n,r,i,o,s,c)}function Ri(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!Lc(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function zi(e,t,n,r){t&=~Hu,t&=~Vu,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-vc(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&T(e,n,t)}function Bi(){return ku&6?!0:(je(0,!1),!1)}function Vi(){if(ju!==null){if(Nu===0)var e=ju.return;else e=ju,dl=ul=null,Nt(e),Nl=null,Pl=0,e=ju;for(;e!==null;)Rr(e.alternate,e),e=e.return;ju=null}}function Hi(e,t){var n=e.timeoutHandle;n!==_o&&(e.timeoutHandle=_o,go(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),td=0,Vi(),Au=e,ju=n=ba(e.current,null),Mu=t,Nu=0,Pu=null,Fu=!1,Iu=y(e,t),Lu=!1,Wu=Uu=Hu=Vu=Bu=zu=0,W=Gu=null,Ku=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-vc(r),a=1<<i;t|=e[i],r&=~a}return Ru=t,et(),n}function Ui(e,t){Jl=null,eo.H=iu,t===Ol||t===Al?(t=Je(),Nu=3):t===kl?(t=Je(),Nu=4):Nu=t===lu?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Pu=t,ju===null&&(zu=1,Wn(e,N(t,e.current)))}function Wi(){var e=Wl.current;return e===null?!0:(Mu&4194048)===Mu?Gl===null:(Mu&62914560)===Mu||Mu&536870912?e===Gl:!1}function Gi(){var e=eo.H;return eo.H=iu,e===null?iu:e}function Ki(){var e=eo.A;return eo.A=xu,e}function qi(){zu=4,Fu||(Mu&4194048)!==Mu&&Wl.current!==null||(Iu=!0),!(Bu&134217727)&&!(Vu&134217727)||Au===null||zi(Au,Mu,Uu,!1)}function Ji(e,t,n){var r=ku;ku|=2;var i=Gi(),a=Ki();(Au!==e||Mu!==t)&&(Xu=null,Hi(e,t)),t=!1;var o=zu;a:do try{if(Nu!==0&&ju!==null){var s=ju,c=Pu;switch(Nu){case 8:Vi(),o=6;break a;case 3:case 2:case 9:case 6:Wl.current===null&&(t=!0);var l=Nu;if(Nu=0,Pu=null,ea(e,s,c,l),n&&Iu){o=0;break a}break;default:l=Nu,Nu=0,Pu=null,ea(e,s,c,l)}}Yi(),o=zu;break}catch(t){Ui(e,t)}while(1);return t&&e.shellSuspendCounter++,dl=ul=null,ku=r,eo.H=i,eo.A=a,ju===null&&(Au=null,Mu=0,et()),o}function Yi(){for(;ju!==null;)Qi(ju)}function Xi(e,t){var n=ku;ku|=2;var i=Gi(),a=Ki();Au!==e||Mu!==t?(Xu=null,Yu=Oc()+500,Hi(e,t)):Iu=y(e,t);a:do try{if(Nu!==0&&ju!==null){t=ju;var o=Pu;b:switch(Nu){case 1:Nu=0,Pu=null,ea(e,t,o,1);break;case 2:case 9:if(Ge(o)){Nu=0,Pu=null,$i(t);break}t=function(){Nu!==2&&Nu!==9||Au!==e||(Nu=7),Ae(e)},o.then(t,t);break a;case 3:Nu=7;break a;case 4:Nu=5;break a;case 7:Ge(o)?(Nu=0,Pu=null,$i(t)):(Nu=0,Pu=null,ea(e,t,o,7));break;case 5:var s=null;switch(ju.tag){case 26:s=ju.memoizedState;case 5:case 27:var c=ju,l=c.type,u=c.pendingProps;if(s?cc(s):jo(c.stateNode,l,u)){Nu=0,Pu=null;var d=c.sibling;if(d!==null)ju=d;else{var f=c.return;f===null?ju=null:(ju=f,ta(f))}break b}}Nu=0,Pu=null,ea(e,t,o,5);break;case 6:Nu=0,Pu=null,ea(e,t,o,6);break;case 8:Vi(),zu=6;break a;default:throw Error(r(462))}}Zi();break}catch(t){Ui(e,t)}while(1);return dl=ul=null,eo.H=i,eo.A=a,ku=n,ju===null?(Au=null,Mu=0,et(),zu):0}function Zi(){for(;ju!==null&&!Ec();)Qi(ju)}function Qi(e){var t=Cr(e.alternate,e,Ru);e.memoizedProps=e.pendingProps,t===null?ta(e):ju=t}function $i(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=cr(n,t,t.pendingProps,t.type,void 0,Mu);break;case 11:t=cr(n,t,t.pendingProps,t.type.render,t.ref,Mu);break;case 5:Nt(t);default:Rr(n,t),t=ju=xa(t,Ru),t=Cr(n,t,Ru)}e.memoizedProps=e.pendingProps,t===null?ta(e):ju=t}function ea(e,t,n,r){dl=ul=null,Nt(t),Nl=null,Pl=0;var i=t.return;try{if(Yn(e,i,t,n,Mu)){zu=1,Wn(e,N(n,e.current)),ju=null;return}}catch(t){if(i!==null)throw ju=i,t;zu=1,Wn(e,N(n,e.current)),ju=null;return}t.flags&32768?(al||r===1?e=!0:Iu||Mu&536870912?e=!1:(Fu=e=!0,(r===2||r===9||r===3||r===6)&&(r=Wl.current,r!==null&&r.tag===13&&(r.flags|=16384))),na(t,e)):ta(t)}function ta(e){var t=e;do{if(t.flags&32768){na(t,Fu);return}e=t.return;var n=Ir(t.alternate,t,Ru);if(n!==null){ju=n;return}if(t=t.sibling,t!==null){ju=t;return}ju=t=e}while(t!==null);zu===0&&(zu=5)}function na(e,t){do{var n=Lr(e.alternate,e);if(n!==null){n.flags&=32767,ju=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){ju=e;return}ju=e=n}while(e!==null);zu=6,ju=null}function ra(e,t,n,i,a,o,s,c,l){e.cancelPendingCommit=null;do ca();while(Qu!==0);if(ku&6)throw Error(r(327));if(t!==null){if(t===e.current)throw Error(r(177));if(o=t.lanes|t.childLanes,o|=zl,w(e,n,o,s,c,l),e===Au&&(ju=Au=null,Mu=0),ed=t,$u=e,td=n,nd=o,rd=a,id=i,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,_a(jc,function(){return la(),null})):(e.callbackNode=null,e.callbackPriority=0),i=(t.flags&13878)!=0,t.subtreeFlags&13878||i){i=eo.T,eo.T=null,a=B(),wo(2),s=ku,ku|=4;try{$r(e,t,n)}finally{ku=s,wo(a),eo.T=i}}Qu=1,ia(),aa(),oa()}}function ia(){if(Qu===1){Qu=0;var e=$u,t=ed,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=eo.T,eo.T=null;var r=B();wo(2);var i=ku;ku|=4;try{li(t,e),co(e.containerInfo)}finally{ku=i,wo(r),eo.T=n}}e.current=t,Qu=2}}function aa(){if(Qu===2){Qu=0;var e=$u,t=ed,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=eo.T,eo.T=null;var r=B();wo(2);var i=ku;ku|=4;try{ei(e,t.alternate,t)}finally{ku=i,wo(r),eo.T=n}}Qu=3}}function oa(){if(Qu===4||Qu===3){Qu=0,Dc();var e=$u,t=ed,n=td,r=id;t.subtreeFlags&10256||t.flags&10256?Qu=5:(Qu=0,ed=$u=null,sa(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(Zu=null),k(n),t=t.stateNode,Ic&&typeof Ic.onCommitFiberRoot==`function`)try{Ic.onCommitFiberRoot(Fc,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=eo.T,i=B(),wo(2),eo.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{eo.T=t,wo(i)}}td&3&&ca(),Ae(e),i=e.pendingLanes,n&261930&&i&42?e===od?ad++:(ad=0,od=e):ad=0,xo&&Hs(),je(0,!1)}}function sa(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Oe(t)))}function ca(){return ia(),aa(),oa(),la()}function la(){if(Qu!==5)return!1;var e=$u,t=nd;nd=0;var n=k(td),i=32>n?32:n;n=eo.T;var a=B();try{wo(i),eo.T=null,i=rd,rd=null;var o=$u,s=td;if(Qu=0,ed=$u=null,td=0,ku&6)throw Error(r(331));var c=ku;if(ku|=4,Ti(o.current),vi(o,o.current,s,i),ku=c,je(0,!1),Ic&&typeof Ic.onPostCommitFiberRoot==`function`)try{Ic.onPostCommitFiberRoot(Fc,o)}catch{}return!0}finally{wo(a),eo.T=n,sa(e,t)}}function ua(e,t,n){t=N(n,t),t=Kn(e.stateNode,t,2),e=lt(e,t,2),e!==null&&(C(e,2),Ae(e))}function da(e,t,n){if(e.tag===3)ua(e,e,n);else for(;t!==null;){if(t.tag===3){ua(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(Zu===null||!Zu.has(r))){e=N(n,e),n=qn(2),r=lt(t,n,2),r!==null&&(Jn(n,r,t,e),C(r,2),Ae(r));break}}t=t.return}}function fa(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ou;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Lu=!0,i.add(n),e=pa.bind(null,e,t,n),t.then(e,e))}function pa(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Au===e&&(Mu&n)===n&&(zu===4||zu===3&&(Mu&62914560)===Mu&&300>Oc()-qu?!(ku&2)&&Hi(e,0):Hu|=n,Wu===Mu&&(Wu=0)),Ae(e)}function ma(e,t){t===0&&(t=x()),e=rt(e,t),e!==null&&(C(e,t),Ae(e))}function ha(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),ma(e,n)}function ga(e,t){var n=0;switch(e.tag){case 31:case 13:var i=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(r(314))}i!==null&&i.delete(t),ma(e,n)}function _a(e,t){return wc(e,t)}function va(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ya(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ba(e,n){var r=e.alternate;return r===null?(r=t(e.tag,n,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=n,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&65011712,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,n=e.dependencies,r.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r.refCleanup=e.refCleanup,r}function xa(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Sa(e,n,i,a,o,s){var c=0;if(a=e,typeof e==`function`)ya(e)&&(c=1);else if(typeof e==`string`)c=Xs&&uc?Zs(e,i,$c.current)?26:pc(e)?27:5:Xs?Zs(e,i,$c.current)?26:5:uc&&pc(e)?27:5;else a:switch(e){case Xa:return e=t(31,i,n,o),e.elementType=Xa,e.lanes=s,e;case Ba:return Ca(i.children,o,s,n);case Va:c=8,o|=24;break;case Ha:return e=t(12,i,n,o|2),e.elementType=Ha,e.lanes=s,e;case Ka:return e=t(13,i,n,o),e.elementType=Ka,e.lanes=s,e;case qa:return e=t(19,i,n,o),e.elementType=qa,e.lanes=s,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case Wa:c=10;break a;case Ua:c=9;break a;case Ga:c=11;break a;case Ja:c=14;break a;case Ya:c=16,a=null;break a}c=29,i=Error(r(130,e===null?`null`:typeof e,``)),a=null}return n=t(c,i,n,o),n.elementType=e,n.type=a,n.lanes=s,n}function Ca(e,n,r,i){return e=t(7,e,i,n),e.lanes=r,e}function wa(e,n,r){return e=t(6,e,null,n),e.lanes=r,e}function Ta(e){var n=t(18,null,null,0);return n.stateNode=e,n}function Ea(e,n,r){return n=t(4,e.children===null?[]:e.children,e.key,n),n.lanes=r,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}function Da(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=_o,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=S(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=S(0),this.hiddenUpdates=S(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function Oa(e,n,r,i,a,o,s,c,l,u,d,f){return e=new Da(e,n,r,s,l,u,d,f,c),n=1,!0===o&&(n|=24),o=t(3,null,null,n),e.current=o,o.stateNode=e,n=De(),n.refCount++,e.pooledCache=n,n.refCount++,o.memoizedState={element:i,isDehydrated:r,cache:n},ot(o),e}function ka(e){return e?(e=_c,e):_c}function Aa(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(r(188)):(e=Object.keys(e).join(`,`),Error(r(268,e)));return e=o(t),e=e===null?null:s(e),e===null?null:io(e.stateNode)}function ja(e,t,n,r,i,a){i=ka(i),r.context===null?r.context=i:r.pendingContext=i,r=ct(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=lt(e,r,t),n!==null&&(Fi(n,e,t),ut(n,e,t))}function R(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Ma(e,t){R(e,t),(e=e.alternate)&&R(e,t)}var Na={},Pa=d(),Fa=p(),Ia=Object.assign,La=Symbol.for(`react.element`),Ra=Symbol.for(`react.transitional.element`),za=Symbol.for(`react.portal`),Ba=Symbol.for(`react.fragment`),Va=Symbol.for(`react.strict_mode`),Ha=Symbol.for(`react.profiler`),Ua=Symbol.for(`react.consumer`),Wa=Symbol.for(`react.context`),Ga=Symbol.for(`react.forward_ref`),Ka=Symbol.for(`react.suspense`),qa=Symbol.for(`react.suspense_list`),Ja=Symbol.for(`react.memo`),Ya=Symbol.for(`react.lazy`),Xa=Symbol.for(`react.activity`),Za=Symbol.for(`react.memo_cache_sentinel`),Qa=Symbol.iterator,z=Symbol.for(`react.client.reference`),$a=Array.isArray,eo=Pa.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,to=e.rendererVersion,no=e.rendererPackageName,ro=e.extraDevToolsConfig,io=e.getPublicInstance,ao=e.getRootHostContext,oo=e.getChildHostContext,so=e.prepareForCommit,co=e.resetAfterCommit,lo=e.createInstance;e.cloneMutableInstance;var uo=e.appendInitialChild,fo=e.finalizeInitialChildren,po=e.shouldSetTextContent,mo=e.createTextInstance;e.cloneMutableTextInstance;var ho=e.scheduleTimeout,go=e.cancelTimeout,_o=e.noTimeout,vo=e.isPrimaryRenderer;e.warnsIfNotActing;var yo=e.supportsMutation,bo=e.supportsPersistence,xo=e.supportsHydration,So=e.getInstanceFromNode;e.beforeActiveInstanceBlur;var Co=e.preparePortalMount;e.prepareScopeUpdate,e.getInstanceFromScope;var wo=e.setCurrentUpdatePriority,B=e.getCurrentUpdatePriority,To=e.resolveUpdatePriority;e.trackSchedulerEvent,e.resolveEventType,e.resolveEventTimeStamp;var Eo=e.shouldAttemptEagerTransition,Do=e.detachDeletedInstance;e.requestPostPaintCallback;var Oo=e.maySuspendCommit,ko=e.maySuspendCommitOnUpdate,Ao=e.maySuspendCommitInSyncRender,jo=e.preloadInstance,Mo=e.startSuspendingCommit,No=e.suspendInstance;e.suspendOnActiveViewTransition;var V=e.waitForCommitToBeReady;e.getSuspendedCommitReason;var Po=e.NotPendingTransition,Fo=e.HostTransitionContext,Io=e.resetFormInstance;e.bindToConsole;var Lo=e.supportsMicrotasks,Ro=e.scheduleMicrotask,zo=e.supportsTestSelectors,Bo=e.findFiberRoot,Vo=e.getBoundingRect,Ho=e.getTextContent,Uo=e.isHiddenSubtree,Wo=e.matchAccessibilityRole,Go=e.setFocusIfFocusable,Ko=e.setupIntersectionObserver,qo=e.appendChild,Jo=e.appendChildToContainer,Yo=e.commitTextUpdate,Xo=e.commitMount,Zo=e.commitUpdate,Qo=e.insertBefore,$o=e.insertInContainerBefore,es=e.removeChild,ts=e.removeChildFromContainer,ns=e.resetTextContent,rs=e.hideInstance,is=e.hideTextInstance,H=e.unhideInstance,as=e.unhideTextInstance;e.cancelViewTransitionName,e.cancelRootViewTransitionName,e.restoreRootViewTransitionName,e.cloneRootViewTransitionContainer,e.removeRootViewTransitionClone,e.measureClonedInstance,e.hasInstanceChanged,e.hasInstanceAffectedParent,e.startViewTransition,e.startGestureTransition,e.stopViewTransition,e.getCurrentGestureOffset,e.createViewTransitionInstance;var os=e.clearContainer;e.createFragmentInstance,e.updateFragmentInstanceFiber,e.commitNewChildToFragmentInstance,e.deleteChildFromFragmentInstance;var ss=e.cloneInstance,cs=e.createContainerChildSet,ls=e.appendChildToContainerChildSet,us=e.finalizeContainerChildren,ds=e.replaceContainerChildren,fs=e.cloneHiddenInstance,ps=e.cloneHiddenTextInstance,ms=e.isSuspenseInstancePending,hs=e.isSuspenseInstanceFallback,gs=e.getSuspenseInstanceFallbackErrorDetails,_s=e.registerSuspenseInstanceRetry,vs=e.canHydrateFormStateMarker,ys=e.isFormStateMarkerMatching,bs=e.getNextHydratableSibling,xs=e.getNextHydratableSiblingAfterSingleton,Ss=e.getFirstHydratableChild,Cs=e.getFirstHydratableChildWithinContainer,ws=e.getFirstHydratableChildWithinActivityInstance,Ts=e.getFirstHydratableChildWithinSuspenseInstance,Es=e.getFirstHydratableChildWithinSingleton,Ds=e.canHydrateInstance,Os=e.canHydrateTextInstance,ks=e.canHydrateActivityInstance,As=e.canHydrateSuspenseInstance,js=e.hydrateInstance,Ms=e.hydrateTextInstance,Ns=e.hydrateActivityInstance,Ps=e.hydrateSuspenseInstance,Fs=e.getNextHydratableInstanceAfterActivityInstance,Is=e.getNextHydratableInstanceAfterSuspenseInstance,Ls=e.commitHydratedInstance,Rs=e.commitHydratedContainer,zs=e.commitHydratedActivityInstance,Bs=e.commitHydratedSuspenseInstance,Vs=e.finalizeHydratedChildren,Hs=e.flushHydrationEvents;e.clearActivityBoundary;var Us=e.clearSuspenseBoundary;e.clearActivityBoundaryFromContainer;var Ws=e.clearSuspenseBoundaryFromContainer,Gs=e.hideDehydratedBoundary,Ks=e.unhideDehydratedBoundary,qs=e.shouldDeleteUnhydratedTailInstances;e.diffHydratedPropsForDevWarnings,e.diffHydratedTextForDevWarnings,e.describeHydratableInstanceForDevWarnings;var Js=e.validateHydratableInstance,Ys=e.validateHydratableTextInstance,Xs=e.supportsResources,Zs=e.isHostHoistableType,Qs=e.getHoistableRoot,$s=e.getResource,ec=e.acquireResource,tc=e.releaseResource,nc=e.hydrateHoistable,rc=e.mountHoistable,ic=e.unmountHoistable,ac=e.createHoistableInstance,oc=e.prepareToCommitHoistables,sc=e.mayResourceSuspendCommit,cc=e.preloadResource,lc=e.suspendResource,uc=e.supportsSingletons,U=e.resolveSingletonInstance,dc=e.acquireSingletonInstance,fc=e.releaseSingletonInstance,pc=e.isHostSingletonType,mc=e.isSingletonScope,hc=[],gc=-1,_c={},vc=Math.clz32?Math.clz32:g,yc=Math.log,bc=Math.LN2,xc=256,Sc=262144,Cc=4194304,wc=Fa.unstable_scheduleCallback,Tc=Fa.unstable_cancelCallback,Ec=Fa.unstable_shouldYield,Dc=Fa.unstable_requestPaint,Oc=Fa.unstable_now,kc=Fa.unstable_ImmediatePriority,Ac=Fa.unstable_UserBlockingPriority,jc=Fa.unstable_NormalPriority,Mc=Fa.unstable_IdlePriority,Nc=Fa.log,Pc=Fa.unstable_setDisableYieldValue,Fc=null,Ic=null,Lc=typeof Object.is==`function`?Object.is:A,Rc=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},zc=Object.prototype.hasOwnProperty,Bc,Vc,Hc=!1,Uc=new WeakMap,Wc=[],Gc=0,Kc=null,qc=0,Jc=[],Yc=0,Xc=null,Zc=1,Qc=``,$c=f(null),el=f(null),tl=f(null),nl=f(null),rl=null,il=null,al=!1,ol=null,sl=!1,cl=Error(r(519)),ll=f(null),ul=null,dl=null,fl=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},pl=Fa.unstable_scheduleCallback,ml=Fa.unstable_NormalPriority,hl={$$typeof:Wa,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0},gl=null,_l=null,vl=!1,yl=!1,bl=!1,xl=0,Sl=null,Cl=0,wl=0,Tl=null,El=eo.S;eo.S=function(e,t){Ju=Oc(),typeof t==`object`&&t&&typeof t.then==`function`&&ze(e,t),El!==null&&El(e,t)};var Dl=f(null),Ol=Error(r(460)),kl=Error(r(474)),Al=Error(r(542)),jl={then:function(){}},Ml=null,Nl=null,Pl=0,Fl=$e(!0),Il=$e(!1),Ll=[],Rl=0,zl=0,Bl=!1,Vl=!1,Hl=f(null),Ul=f(0),Wl=f(null),Gl=null,Kl=f(0),ql=0,Jl=null,Yl=null,Xl=null,Zl=!1,Ql=!1,$l=!1,eu=0,tu=0,nu=null,ru=0,iu={readContext:we,use:Rt,useCallback:Tt,useContext:Tt,useEffect:Tt,useImperativeHandle:Tt,useLayoutEffect:Tt,useInsertionEffect:Tt,useMemo:Tt,useReducer:Tt,useRef:Tt,useState:Tt,useDebugValue:Tt,useDeferredValue:Tt,useTransition:Tt,useSyncExternalStore:Tt,useId:Tt,useHostTransitionStatus:Tt,useFormState:Tt,useActionState:Tt,useOptimistic:Tt,useMemoCache:Tt,useCacheRefresh:Tt};iu.useEffectEvent=Tt;var au={readContext:we,use:Rt,useCallback:function(e,t){return Pt().memoizedState=[e,t===void 0?null:t],e},useContext:we,useEffect:hn,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),pn(4194308,4,xn.bind(null,t,e),n)},useLayoutEffect:function(e,t){return pn(4194308,4,e,t)},useInsertionEffect:function(e,t){pn(4,2,e,t)},useMemo:function(e,t){var n=Pt();t=t===void 0?null:t;var r=e();if($l){ee(!0);try{e()}finally{ee(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Pt();if(n!==void 0){var i=n(t);if($l){ee(!0);try{n(t)}finally{ee(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Nn.bind(null,Jl,e),[r.memoizedState,e]},useRef:function(e){var t=Pt();return e={current:e},t.memoizedState=e},useState:function(e){e=Xt(e);var t=e.queue,n=Pn.bind(null,Jl,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Cn,useDeferredValue:function(e,t){return En(Pt(),e,t)},useTransition:function(){var e=Xt(!1);return e=L.bind(null,Jl,e.queue,!0,!1),Pt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var i=Jl,a=Pt();if(al){if(n===void 0)throw Error(r(407));n=n()}else{if(n=t(),Au===null)throw Error(r(349));Mu&127||Gt(i,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,hn(qt.bind(null,i,o,e),[e]),i.flags|=2048,dn(9,{destroy:void 0},Kt.bind(null,i,o,n,t),null),n},useId:function(){var e=Pt(),t=Au.identifierPrefix;if(al){var n=Qc,r=Zc;n=(r&~(1<<32-vc(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=eu++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=ru++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:kn,useFormState:on,useActionState:on,useOptimistic:function(e){var t=Pt();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=In.bind(null,Jl,!0,n),n.dispatch=t,[e,t]},useMemoCache:zt,useCacheRefresh:function(){return Pt().memoizedState=Mn.bind(null,Jl)},useEffectEvent:function(e){var t=Pt(),n={impl:e};return t.memoizedState=n,function(){if(ku&2)throw Error(r(440));return n.impl.apply(void 0,arguments)}}},ou={readContext:we,use:Rt,useCallback:wn,useContext:we,useEffect:gn,useImperativeHandle:Sn,useInsertionEffect:yn,useLayoutEffect:bn,useMemo:Tn,useReducer:Vt,useRef:fn,useState:function(){return Vt(Bt)},useDebugValue:Cn,useDeferredValue:function(e,t){return Dn(Ft(),Yl.memoizedState,e,t)},useTransition:function(){var e=Vt(Bt)[0],t=Ft().memoizedState;return[typeof e==`boolean`?e:Lt(e),t]},useSyncExternalStore:Wt,useId:An,useHostTransitionStatus:kn,useFormState:sn,useActionState:sn,useOptimistic:function(e,t){return Zt(Ft(),Yl,e,t)},useMemoCache:zt,useCacheRefresh:jn};ou.useEffectEvent=vn;var su={readContext:we,use:Rt,useCallback:wn,useContext:we,useEffect:gn,useImperativeHandle:Sn,useInsertionEffect:yn,useLayoutEffect:bn,useMemo:Tn,useReducer:Ut,useRef:fn,useState:function(){return Ut(Bt)},useDebugValue:Cn,useDeferredValue:function(e,t){var n=Ft();return Yl===null?En(n,e,t):Dn(n,Yl.memoizedState,e,t)},useTransition:function(){var e=Ut(Bt)[0],t=Ft().memoizedState;return[typeof e==`boolean`?e:Lt(e),t]},useSyncExternalStore:Wt,useId:An,useHostTransitionStatus:kn,useFormState:un,useActionState:un,useOptimistic:function(e,t){var n=Ft();return Yl===null?(n.baseState=e,[e,n.queue.dispatch]):Zt(n,Yl,e,t)},useMemoCache:zt,useCacheRefresh:jn};su.useEffectEvent=vn;var cu={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Ni(),i=ct(r);i.payload=t,n!=null&&(i.callback=n),t=lt(e,i,r),t!==null&&(Fi(t,e,r),ut(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Ni(),i=ct(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=lt(e,i,r),t!==null&&(Fi(t,e,r),ut(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Ni(),r=ct(n);r.tag=2,t!=null&&(r.callback=t),t=lt(e,r,n),t!==null&&(Fi(t,e,n),ut(t,e,n))}},lu=Error(r(461)),uu=!1,du={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null},fu=!1,pu=!1,mu=!1,hu=typeof WeakSet==`function`?WeakSet:Set,gu=null,_u=null,vu=!1,yu=null,bu=8192,xu={getCacheForType:function(e){var t=we(hl),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return we(hl).controller.signal}},Su=0,Cu=1,wu=2,Tu=3,Eu=4;if(typeof Symbol==`function`&&Symbol.for){var Du=Symbol.for;Su=Du(`selector.component`),Cu=Du(`selector.has_pseudo_class`),wu=Du(`selector.role`),Tu=Du(`selector.test_id`),Eu=Du(`selector.text`)}var Ou=typeof WeakMap==`function`?WeakMap:Map,ku=0,Au=null,ju=null,Mu=0,Nu=0,Pu=null,Fu=!1,Iu=!1,Lu=!1,Ru=0,zu=0,Bu=0,Vu=0,Hu=0,Uu=0,Wu=0,Gu=null,W=null,Ku=!1,qu=0,Ju=0,Yu=1/0,Xu=null,Zu=null,Qu=0,$u=null,ed=null,td=0,nd=0,rd=null,id=null,ad=0,od=null;return Na.attemptContinuousHydration=function(e){if(e.tag===13||e.tag===31){var t=rt(e,67108864);t!==null&&Fi(t,e,67108864),Ma(e,67108864)}},Na.attemptHydrationAtCurrentPriority=function(e){if(e.tag===13||e.tag===31){var t=Ni();t=O(t);var n=rt(e,t);n!==null&&Fi(n,e,t),Ma(e,t)}},Na.attemptSynchronousHydration=function(e){switch(e.tag){case 3:if(e=e.stateNode,e.current.memoizedState.isDehydrated){var t=_(e.pendingLanes);if(t!==0){for(e.pendingLanes|=2,e.entangledLanes|=2;t;){var n=1<<31-vc(t);e.entanglements[1]|=n,t&=~n}Ae(e),!(ku&6)&&(Yu=Oc()+500,je(0,!1))}}break;case 31:case 13:t=rt(e,2),t!==null&&Fi(t,e,2),Bi(),Ma(e,2)}},Na.batchedUpdates=function(e,t){return e(t)},Na.createComponentSelector=function(e){return{$$typeof:Su,value:e}},Na.createContainer=function(e,t,n,r,i,a,o,s,c,l){return Oa(e,t,!1,null,n,r,a,null,o,s,c,l)},Na.createHasPseudoClassSelector=function(e){return{$$typeof:Cu,value:e}},Na.createHydrationContainer=function(e,t,n,r,i,a,o,s,c,l,u,d,f,p){return e=Oa(n,r,!0,e,i,a,s,p,c,l,u,d),e.context=ka(null),n=e.current,r=Ni(),r=O(r),i=ct(r),i.callback=t??null,lt(n,i,r),t=r,e.current.lanes=t,C(e,t),Ae(e),e},Na.createPortal=function(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:za,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}},Na.createRoleSelector=function(e){return{$$typeof:wu,value:e}},Na.createTestNameSelector=function(e){return{$$typeof:Tu,value:e}},Na.createTextSelector=function(e){return{$$typeof:Eu,value:e}},Na.defaultOnCaughtError=function(e){console.error(e)},Na.defaultOnRecoverableError=function(e){Rc(e)},Na.defaultOnUncaughtError=function(e){Rc(e)},Na.deferredUpdates=function(e){var t=eo.T,n=B();try{return wo(32),eo.T=null,e()}finally{wo(n),eo.T=t}},Na.discreteUpdates=function(e,t,n,r,i){var a=eo.T,o=B();try{return wo(2),eo.T=null,e(t,n,r,i)}finally{wo(o),eo.T=a,ku===0&&(Yu=Oc()+500)}},Na.findAllNodes=Mi,Na.findBoundingRects=function(e,t){if(!zo)throw Error(r(363));t=Mi(e,t),e=[];for(var n=0;n<t.length;n++)e.push(Vo(t[n]));for(t=e.length-1;0<t;t--){n=e[t];for(var i=n.x,a=i+n.width,o=n.y,s=o+n.height,c=t-1;0<=c;c--)if(t!==c){var l=e[c],u=l.x,d=u+l.width,f=l.y,p=f+l.height;if(i>=u&&o>=f&&a<=d&&s<=p){e.splice(t,1);break}else if(!(i!==u||n.width!==l.width||p<o||f>s)){f>o&&(l.height+=f-o,l.y=o),p<s&&(l.height=s-f),e.splice(t,1);break}else if(!(o!==f||n.height!==l.height||d<i||u>a)){u>i&&(l.width+=u-i,l.x=i),d<a&&(l.width=a-u),e.splice(t,1);break}}}return e},Na.findHostInstance=Aa,Na.findHostInstanceWithNoPortals=function(e){return e=o(e),e=e===null?null:c(e),e===null?null:io(e.stateNode)},Na.findHostInstanceWithWarning=function(e){return Aa(e)},Na.flushPassiveEffects=ca,Na.flushSyncFromReconciler=function(e){var t=ku;ku|=1;var n=eo.T,r=B();try{if(wo(2),eo.T=null,e)return e()}finally{wo(r),eo.T=n,ku=t,!(ku&6)&&je(0,!1)}},Na.flushSyncWork=Bi,Na.focusWithin=function(e,t){if(!zo)throw Error(r(363));for(e=Oi(e),t=ji(e,t),t=Array.from(t),e=0;e<t.length;){var n=t[e++],i=n.tag;if(!Uo(n)){if((i===5||i===26||i===27)&&Go(n.stateNode))return!0;for(n=n.child;n!==null;)t.push(n),n=n.sibling}}return!1},Na.getFindAllNodesFailureDescription=function(e,t){if(!zo)throw Error(r(363));var n=0,i=[];e=[Oi(e),0];for(var a=0;a<e.length;){var o=e[a++],s=o.tag,c=e[a++],l=t[c];if((s!==5&&s!==26&&s!==27||!Uo(o))&&(ki(o,l)&&(i.push(Ai(l)),c++,c>n&&(n=c)),c<t.length))for(o=o.child;o!==null;)e.push(o,c),o=o.sibling}if(n<t.length){for(e=[];n<t.length;n++)e.push(Ai(t[n]));return`findAllNodes was able to match part of the selector:
|
|
34
|
+
`+(i.join(` > `)+`
|
|
35
|
+
|
|
36
|
+
No matching component was found for:
|
|
37
|
+
`)+e.join(` > `)}return null},Na.getPublicRootInstance=function(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 27:case 5:return io(e.child.stateNode);default:return e.child.stateNode}},Na.injectIntoDevTools=function(){var e={bundleType:0,version:to,rendererPackageName:no,currentDispatcherRef:eo,reconcilerVersion:`19.2.0`};if(ro!==null&&(e.rendererConfig=ro),typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`)e=!1;else{var t=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(t.isDisabled||!t.supportsFiber)e=!0;else{try{Fc=t.inject(e),Ic=t}catch{}e=!!t.checkDCE}}return e},Na.isAlreadyRendering=function(){return(ku&6)!=0},Na.observeVisibleRects=function(e,t,n,i){if(!zo)throw Error(r(363));e=Mi(e,t);var a=Ko(e,n,i).disconnect;return{disconnect:function(){a()}}},Na.shouldError=function(){return null},Na.shouldSuspend=function(){return!1},Na.startHostTransition=function(e,t,i,a){if(e.tag!==5)throw Error(r(476));var o=On(e).queue;L(e,o,t,Po,i===null?n:function(){var t=On(e);return t.next===null&&(t=e.alternate.memoizedState),Fn(e,t.next.queue,{},Ni()),i(a)})},Na.updateContainer=function(e,t,n,r){var i=t.current,a=Ni();return ja(i,a,e,t,n,r),a},Na.updateContainerSync=function(e,t,n,r){return ja(t.current,2,e,t,n,r),2},Na},t.exports.default=t.exports,Object.defineProperty(t.exports,"__esModule",{value:!0})})),Ju=o(((e,t)=>{t.exports=qu()})),Yu=o((e=>{e.ConcurrentRoot=1,e.DefaultEventPriority=32,e.DiscreteEventPriority=2})),Xu=o(((e,t)=>{t.exports=Yu()})),Zu=l(Ju()),Qu=Xu(),$u={children:!0,ref:!0,key:!0,style:!0,forwardedRef:!0,unstable_applyCache:!0,unstable_applyDrawHitFromCache:!0},ed=!1,td=!1,nd=`.react-konva-event`,rd=!1,id=`ReactKonva: You have a Konva node with draggable = true and position defined but no onDragMove or onDragEnd events are handled.
|
|
38
|
+
Position of a node will be changed during drag&drop, so you should update state of the react app as well.
|
|
39
|
+
Consider to add onDragMove or onDragEnd events.
|
|
40
|
+
For more info see: https://github.com/konvajs/react-konva/issues/256
|
|
41
|
+
`,ad=`ReactKonva: You are using "zIndex" attribute for a Konva node.
|
|
42
|
+
react-konva may get confused with ordering. Just define correct order of elements in your render function of a component.
|
|
43
|
+
For more info see: https://github.com/konvajs/react-konva/issues/194
|
|
44
|
+
`,od={},sd=()=>{};function cd(e){sd=e}var ld=!1;function ud(e){return function(...t){let n=e.apply(this,t);if(!ld){ld=!0;try{sd()}finally{ld=!1}}return n}}function dd(e,t,n=od){if(!ed&&`zIndex`in t&&(console.warn(ad),ed=!0),!td&&t.draggable){var r=t.x!==void 0||t.y!==void 0,i=t.onDragEnd||t.onDragMove;r&&!i&&(console.warn(id),td=!0)}for(var a in n)if(!$u[a]){var o=a.slice(0,2)===`on`,s=n[a]!==t[a];if(o&&s){var c=a.substr(2).toLowerCase();c.substr(0,7)===`content`&&(c=`content`+c.substr(7,1).toUpperCase()+c.substr(8)),e.off(c+nd)}t.hasOwnProperty(a)||e.setAttr(a,void 0)}var l=rd||t._useStrictMode,u={},d=!1;let f={};for(var a in t)if(!$u[a]){var o=a.slice(0,2)===`on`,p=n[a]!==t[a];if(o&&p){var c=a.substr(2).toLowerCase();c.substr(0,7)===`content`&&(c=`content`+c.substr(7,1).toUpperCase()+c.substr(8)),t[a]&&(f[c]=t[a])}!o&&(t[a]!==n[a]||l&&t[a]!==e.getAttr(a))&&(d=!0,u[a]=t[a])}for(var c in d&&(e.setAttrs(u),fd(e)),f)e.off(c+nd),e.on(c+nd,ud(f[c]))}function fd(e){if(!R.autoDrawEnabled){var t=e.getLayer()||e.getStage();t&&t.batchDraw()}}var pd=s({HostTransitionContext:()=>gf,NotPendingTransition:()=>null,afterActiveInstanceBlur:()=>Qd,appendChild:()=>Fd,appendChildToContainer:()=>Id,appendInitialChild:()=>vd,beforeActiveInstanceBlur:()=>Zd,cancelTimeout:()=>Md,clearContainer:()=>Jd,commitMount:()=>Hd,commitTextUpdate:()=>Vd,commitUpdate:()=>Ud,createInstance:()=>yd,createTextInstance:()=>bd,detachDeletedInstance:()=>Yd,finalizeInitialChildren:()=>xd,getChildHostContext:()=>Ad,getCurrentEventPriority:()=>$d,getCurrentUpdatePriority:()=>rf,getInstanceFromNode:()=>Xd,getInstanceFromScope:()=>tf,getPublicInstance:()=>Sd,getRootHostContext:()=>kd,hideInstance:()=>Wd,hideTextInstance:()=>Gd,idlePriority:()=>md.unstable_IdlePriority,insertBefore:()=>Ld,insertInContainerBefore:()=>Rd,isPrimaryRenderer:()=>!1,maySuspendCommit:()=>df,noTimeout:()=>-1,now:()=>md.unstable_now,preloadInstance:()=>ff,prepareForCommit:()=>Cd,preparePortalMount:()=>wd,prepareScopeUpdate:()=>ef,prepareUpdate:()=>Td,removeChild:()=>zd,removeChildFromContainer:()=>Bd,requestPostPaintCallback:()=>uf,resetAfterCommit:()=>Ed,resetFormInstance:()=>_f,resetTextContent:()=>Dd,resolveEventTimeStamp:()=>lf,resolveEventType:()=>cf,resolveUpdatePriority:()=>af,run:()=>md.unstable_runWithPriority,scheduleMicrotask:()=>Nd,scheduleTimeout:()=>jd,setCurrentUpdatePriority:()=>nf,shouldAttemptEagerTransition:()=>of,shouldDeprioritizeSubtree:()=>Od,shouldSetTextContent:()=>Pd,startSuspendingCommit:()=>pf,supportsHydration:()=>!1,supportsMicrotasks:()=>!0,supportsMutation:()=>!0,supportsPersistence:()=>!1,suspendInstance:()=>mf,trackSchedulerEvent:()=>sf,unhideInstance:()=>Kd,unhideTextInstance:()=>qd,waitForCommitToBeReady:()=>hf,warnsIfNotActing:()=>!1}),md=p(),hd={},gd={};Ku.Node.prototype._applyProps=dd;var _d=Qu.DefaultEventPriority;function vd(e,t){if(typeof t==`string`){console.error(`Do not use plain text as child of Konva.Node. You are using text: ${t}`);return}e.add(t),fd(e)}function yd(e,t,n){let r=Ku[e];r||=(console.error(`Konva has no node with the type ${e}. Group will be used instead. If you use minimal version of react-konva, just import required nodes into Konva: "import "konva/lib/shapes/${e}" If you want to render DOM elements as part of canvas tree take a look into this demo: https://konvajs.github.io/docs/react/DOM_Portal.html`),Ku.Group);let i={},a={};for(var o in t)o!==`ref`&&(o.slice(0,2)===`on`?a[o]=t[o]:i[o]=t[o]);let s=new r(i);return dd(s,a),s}function bd(e,t,n){console.error(`Text components are not supported for now in ReactKonva. Your text is: "${e}"`)}function xd(e,t,n){return!1}function Sd(e){return e}function Cd(){return null}function wd(){return null}function Td(e,t,n,r){return gd}function Ed(){}function Dd(e){}function Od(e,t){return!1}function kd(){return hd}function Ad(){return hd}var jd=setTimeout,Md=clearTimeout,Nd=typeof queueMicrotask==`function`?queueMicrotask:e=>Promise.resolve(null).then(e);function Pd(e,t){return!1}function Fd(e,t){t.parent===e?t.moveToTop():e.add(t),fd(e)}function Id(e,t){t.parent===e?t.moveToTop():e.add(t),fd(e)}function Ld(e,t,n){t._remove(),e.add(t),t.setZIndex(n.getZIndex()),fd(e)}function Rd(e,t,n){Ld(e,t,n)}function zd(e,t){t.destroy(),t.off(nd),fd(e)}function Bd(e,t){t.destroy(),t.off(nd),fd(e)}function Vd(e,t,n){console.error(`Text components are not yet supported in ReactKonva. You text is: "${n}"`)}function Hd(e,t,n){}function Ud(e,t,n,r){dd(e,r,n)}function Wd(e){e.hide(),fd(e)}function Gd(e){}function Kd(e,t){(t.visible==null||t.visible)&&e.show()}function qd(e,t){}function Jd(e){}function Yd(){}function Xd(){return null}function Zd(){}function Qd(){}function $d(){return Qu.DefaultEventPriority}function ef(){}function tf(){return null}function nf(e){_d=e}function rf(){return _d}function af(){return Qu.DiscreteEventPriority}function of(){return!1}function sf(){}function cf(){return null}function lf(){return-1.1}function uf(){}function df(){return!1}function ff(){return!0}function pf(){}function mf(){}function hf(){return null}var gf=b.createContext(null);function _f(){}typeof window<`u`&&(window.document?.createElement||window.navigator?.product===`ReactNative`)?b.useLayoutEffect:b.useEffect;function vf(e,t,n){if(!e)return;if(n(e)===!0)return e;let r=t?e.return:e.child;for(;r;){let e=vf(r,t,n);if(e)return e;r=t?null:r.sibling}}function yf(e){try{return Object.defineProperties(e,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return e}}var bf=yf(b.createContext(null)),xf=class extends b.Component{render(){return b.createElement(bf.Provider,{value:this._reactInternals},this.props.children)}};function Sf(){let e=b.useContext(bf);if(e===null)throw Error(`its-fine: useFiber must be called within a <FiberProvider />!`);let t=b.useId();return b.useMemo(()=>{for(let n of[e,e?.alternate]){if(!n)continue;let e=vf(n,!1,e=>{let n=e.memoizedState;for(;n;){if(n.memoizedState===t)return!0;n=n.next}});if(e)return e}},[e,t])}var Cf=Symbol.for(`react.context`),wf=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Cf;function Tf(){let e=Sf(),[t]=b.useState(()=>new Map);t.clear();let n=e;for(;n;){let e=n.type;wf(e)&&e!==bf&&!t.has(e)&&t.set(e,b.use(yf(e))),n=n.return}return t}function Ef(){let e=Tf();return b.useMemo(()=>Array.from(e.keys()).reduce((t,n)=>r=>b.createElement(t,null,b.createElement(n.Provider,{...r,value:e.get(n)})),e=>b.createElement(xf,{...e})),[e])}function Df(e){let t=b.useRef({});return b.useLayoutEffect(()=>{t.current=e}),b.useLayoutEffect(()=>()=>{t.current={}},[]),t.current}var Of=()=>{let e=b.useRef(0);return b.useMemo(()=>{e.current++},[]),e.current>1},kf=e=>{let t=b.useRef(null),n=b.useRef(null),r=b.useRef(null),i=Df(e),a=Ef(),o=b.useRef(null),s=t=>{let{forwardedRef:n}=e;n&&(typeof n==`function`?n(t):n.current=t)},c=Of(),l=()=>{s(null),Vf.flushSyncFromReconciler(()=>{Vf.updateContainer(null,r.current,null)}),n.current?.destroy(),n.current=null};return b.useLayoutEffect(()=>(o.current&&=(clearTimeout(o.current),null),n.current?s(n.current):(n.current=new Ku.Stage({width:e.width,height:e.height,container:t.current}),s(n.current),r.current=Vf.createContainer(n.current,Qu.ConcurrentRoot,null,!1,null,``,console.error,console.error,console.error,null),Vf.updateContainer(b.createElement(a,{},e.children),r.current,null,()=>{})),()=>{c?o.current=setTimeout(l,0):l()}),[]),b.useLayoutEffect(()=>{s(n.current),dd(n.current,e,i),Vf.updateContainer(b.createElement(a,{},e.children),r.current,null),Vf.flushSyncWork()}),b.createElement(`div`,{ref:t,id:e.id,accessKey:e.accessKey,className:e.className,role:e.role,style:e.style,tabIndex:e.tabIndex,title:e.title})},Af=`Layer`,jf=`Group`,Mf=`Label`,Nf=`Rect`,Pf=`Line`,Ff=`Image`,If=`Text`,Lf=`TextPath`,Rf=`Path`,zf=`Shape`,Bf=`Transformer`,Vf=(0,Zu.default)(pd);cd(()=>Vf.flushSyncWork());var Hf=b.forwardRef((e,t)=>b.createElement(xf,{},b.createElement(kf,{...e,forwardedRef:t}))),Uf=l(o(((e,t)=>{var n=d();t.exports=function(e,t,r){let i=n.useRef(`loading`),a=n.useRef(),[o,s]=n.useState(0),c=n.useRef(),l=n.useRef(),u=n.useRef();return(c.current!==e||l.current!==t||u.current!==r)&&(i.current=`loading`,a.current=void 0,c.current=e,l.current=t,u.current=r),n.useLayoutEffect(function(){if(!e)return;var n=document.createElement(`img`);function o(){n.decode().catch(()=>{}).finally(()=>{i.current=`loaded`,a.current=n,s(Math.random())})}function c(){i.current=`failed`,a.current=void 0,s(Math.random())}return n.addEventListener(`load`,o),n.addEventListener(`error`,c),t&&(n.crossOrigin=t),r&&(n.referrerPolicy=r),n.src=e,function(){n.removeEventListener(`load`,o),n.removeEventListener(`error`,c)}},[e,t,r]),[a.current,i.current]}}))()),Wf=20,Gf=new W.Group;Gf.add(new W.Rect({width:Wf,height:Wf,fill:`white`})),Gf.add(new W.Path({scaleX:.8333333333333334,scaleY:.8333333333333334,data:`M4.98313549,11.0001422 C5.49589839,10.9914935 5.92501998,11.3703506 5.99116425,11.8666444 L5.99985778,11.9831355 L6.00348884,12.2068855 C6.11245031,15.4321748 8.76323537,17.9999971 11.9999971,17.9999971 C12.1869612,17.9999971 12.3726725,17.9914753 12.5567465,17.9745765 L12.2928932,17.7071068 C11.9023689,17.3165825 11.9023689,16.6834175 12.2928932,16.2928932 C12.6834175,15.9023689 13.3165825,15.9023689 13.7071068,16.2928932 L15.7071068,18.2928932 C16.0976311,18.6834175 16.0976311,19.3165825 15.7071068,19.7071068 L13.7071068,21.7071068 C13.3165825,22.0976311 12.6834175,22.0976311 12.2928932,21.7071068 C11.9023689,21.3165825 11.9023689,20.6834175 12.2928932,20.2928932 L12.6111505,19.9769552 C12.4086045,19.9922816 12.2047796,19.9999971 11.9999971,19.9999971 C7.7687005,19.9999971 4.28886152,16.7094374 4.01666425,12.5105203 L4.00420123,12.2575143 L4.00014222,12.0168645 C3.9908282,11.4646583 4.43092928,11.0094562 4.98313549,11.0001422 Z M11.7071068,2.29289322 C12.0675907,2.65337718 12.0953203,3.22060824 11.7902954,3.61289944 L11.7071068,3.70710678 L11.3891629,4.0230186 C11.5916051,4.00770767 11.7953244,4 12,4 C16.418278,4 20,7.581722 20,12 C20,12.5522847 19.5522847,13 19,13 C18.4477153,13 18,12.5522847 18,12 C18,8.6862915 15.3137085,6 12,6 C11.8129339,6 11.6271216,6.00853145 11.4429483,6.02544919 L11.7071068,6.29289322 C12.0976311,6.68341751 12.0976311,7.31658249 11.7071068,7.70710678 C11.3466228,8.06759074 10.7793918,8.09532028 10.3871006,7.79029539 L10.2928932,7.70710678 L8.29289322,5.70710678 C7.93240926,5.34662282 7.90467972,4.77939176 8.20970461,4.38710056 L8.29289322,4.29289322 L10.2928932,2.29289322 C10.6834175,1.90236893 11.3165825,1.90236893 11.7071068,2.29289322 Z`,fill:`black`}));var Kf=Gf.toCanvas({pixelRatio:2,width:Wf,height:Wf}),qf={borderEnabled:!0,anchorSize:10,anchorCornerRadius:0,anchorFill:`white`,anchorStroke:`rgb(0, 161, 255)`,anchorStrokeWidth:2,borderStrokeWidth:2,rotateAnchorOffset:30,anchorStyleFunc:e=>{e.hasName(`rotater`)&&e.setAttrs({width:20,height:20,cornerRadius:20/2,offsetX:20/2,offsetY:20/2,fillPatternImage:Kf,fillPatternScaleX:20/Wf/2,fillPatternScaleY:20/Wf/2,fillPriority:`pattern`,fillPatternRepeat:`no-repeat`})}},Jf={anchorFill:`rgb(240, 240, 240)`,anchorStrokeWidth:2,borderStrokeWidth:2},Yf={anchorSize:20,anchorCornerRadius:10,anchorStrokeWidth:2,borderStrokeWidth:2},Xf={stroke:`rgb(0, 161, 255)`,strokeWidth:2},Zf={stroke:`rgb(0, 161, 255)`,strokeWidth:1,dash:[4,6]},Qf={fill:`rgba(0, 161, 255, 0.3)`,stroke:`rgb(0, 161, 255)`,strokeWidth:1},$f={fill:`rgb(0, 161, 255)`,textFill:`white`},ep={stroke:`rgb(0, 161, 255)`,labelFill:`rgb(0, 161, 255)`,labelTextFill:`white`},tp={fill:`rgba(124, 173, 212, 0.8)`,textFill:`white`},np={fill:`rgba(223, 102, 102, 0.8)`,textFill:`white`},rp={stroke:`red`},ip={backgroundColor:`#e8e8e8`,textColor:`grey`,borderColor:`grey`,borderSize:1,tickColor:`grey`,tickSize:1},ap=`rgba(255, 0, 0, 0.1)`;function op(e,t){if(!t)return Object.assign({},e);let n=Object.assign({},e);for(let e in t){let r=t[e];r!==void 0&&(n[e]=r)}return n}function sp(e={}){return{editorAccentColor:`rgb(0, 161, 255)`,cropOverlayFill:e.cropOverlayFill??`rgba(0,0,0,0.3)`,workspaceBackgroundColor:e.workspaceBackgroundColor??`rgba(232, 232, 232, 0.9)`,pageBorderColor:e.pageBorderColor??`lightgrey`,activePageBorderColor:e.activePageBorderColor??`rgb(0, 161, 255)`,bleedColor:e.bleedColor??ap,transparencyBackgroundColor:e.transparencyBackgroundColor,transformerStyle:op(qf,e.transformerStyle),innerImageCropTransformerStyle:op(Jf,e.innerImageCropTransformerStyle),outerImageCropTransformerStyle:op(Yf,e.outerImageCropTransformerStyle),highlighterStyle:op(Xf,e.highlighterStyle),snapGuideStyle:op(Zf,{stroke:e.snapGuideStroke,strokeWidth:e.snapGuideStrokeWidth,dash:e.snapGuideDash}),selectionRectStyle:op(Qf,{fill:e.selectionRectFill,stroke:e.selectionRectStroke,strokeWidth:e.selectionRectStrokeWidth}),transformLabelStyle:op($f,{fill:e.transformLabelFill,textFill:e.transformLabelTextFill}),distanceGuideStyle:op(ep,{stroke:e.distanceGuideStroke,labelFill:e.distanceLabelFill,labelTextFill:e.distanceLabelTextFill}),mediaLoadingStyle:op(tp,e.mediaLoadingStyle),mediaErrorStyle:op(np,e.mediaErrorStyle),textOverflowIndicatorStyle:op(rp,e.textOverflowIndicatorStyle),rulerStyle:op(ip,{backgroundColor:e.rulerBackgroundColor,textColor:e.rulerTextColor,borderColor:e.rulerBorderColor,borderSize:e.rulerBorderSize,tickColor:e.rulerTickColor,tickSize:e.rulerTickSize})}}var cp=b.createContext(null),lp=cp.Provider;function up(){return b.useContext(cp)||sp()}var dp=0,fp=new Set;function pp(e){return fp.add(e),()=>{fp.delete(e)}}function mp(){return dp}function hp(e){let t=b.useSyncExternalStore(pp,mp,mp),n=b.useRef(null);return n.current&&n.current.revision===t&&function(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!gp(e[r],t[r]))return!1;return!0}(n.current.overrides,e)||(n.current={overrides:e,revision:t,resolved:sp(e)}),n.current.resolved}function gp(e,t){if(e===t)return!0;if(e==null||t==null)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}if(typeof e==`object`&&typeof t==`object`&&!Array.isArray(t)){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}return!1}var _p=`warn`;function vp(e){_p=e}function yp(){return _p}var bp;(function(e){e.afterCreate=`afterCreate`,e.afterAttach=`afterAttach`,e.afterCreationFinalization=`afterCreationFinalization`,e.beforeDetach=`beforeDetach`,e.beforeDestroy=`beforeDestroy`})(bp||={});var xp=function(e,t){return xp=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},xp(e,t)};function Sp(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);xp(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Cp=function(){return Cp=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Cp.apply(this,arguments)};function wp(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Tp(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function Ep(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function Dp(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function Op(e){return Im(e,1),Lm(e).type}function kp(e,t){return Im(e,1),vh(t,2),Lm(e).onSnapshot(t)}function Ap(e,t){Im(e,1),_h(t,function(e){return typeof e==`object`},`object or array`,2),Lm(e).applyPatches(Qm(t))}function jp(e,t){return Im(e,1),Lm(e).applySnapshot(t)}function Mp(e,t){t===void 0&&(t=!0),Im(e,1);var n=Lm(e);return t?n.snapshot:rh(n.type.getSnapshot(n,!1))}function Np(e,t){t===void 0&&(t=1),Im(e,1),yh(t,2,0);for(var n=t,r=Lm(e).parent;r;){if(--n===0)return r.storedValue;r=r.parent}throw new G(`Failed to find the parent of ${Lm(e)} at depth ${t}`)}function Pp(e,t){Im(e,1),cm(t,2);for(var n=Lm(e).parent;n;){if(t.is(n.storedValue))return!0;n=n.parent}return!1}function Fp(e,t){Im(e,1),cm(t,2);for(var n=Lm(e).parent;n;){if(t.is(n.storedValue))return n.storedValue;n=n.parent}throw new G(`Failed to find the parent of ${Lm(e)} of a given type`)}function Ip(e){return Im(e,1),Lm(e).root.storedValue}function Lp(e){return Im(e,1),Lm(e).path}function Rp(e,t){Im(e,1),bh(t,2);var n=Bm(Lm(e),t);return n?n.value:void 0}function zp(e){return Im(e,1),Lm(e).identifier}function Bp(e){return Im(e,1),Lm(e).detach(),e}function Vp(e){Im(e,1);var t=Lm(e);t.isRoot?t.die():t.parent.removeChild(t.subpath)}function Hp(e){return Im(e,1),Lm(e).observableIsAlive}function Up(e){return e}var Wp=function(){function e(e,t,n,r){Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"environment",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"_escapedSubpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storedValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"aliveAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_state",{enumerable:!0,configurable:!0,writable:!0,value:Pm.INITIALIZING}),Object.defineProperty(this,"_hookSubscribers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pathAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.environment=r,this.baseSetParent(t,n)}return Object.defineProperty(e.prototype,"subpath",{get:function(){return this._subpath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subpathUponDeath",{get:function(){return this._subpathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pathUponDeath",{get:function(){return this._pathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},set:function(e){var t=this.isAlive;this._state=e;var n=this.isAlive;this.aliveAtom&&t!==n&&this.aliveAtom.reportChanged()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fireInternalHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._hookSubscribers&&this._hookSubscribers.emit(e,this,e)}}),Object.defineProperty(e.prototype,"registerHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._hookSubscribers||=new uh,this._hookSubscribers.register(e,t)}}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getReconciliationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type}}),Object.defineProperty(e.prototype,"baseSetParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._parent=e,this._subpath=t,this._escapedSubpath=void 0,this.pathAtom&&this.pathAtom.reportChanged()}}),Object.defineProperty(e.prototype,"path",{get:function(){return this.getEscapedPath(!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getEscapedPath",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e&&(this.pathAtom||=He(`path`),this.pathAtom.reportObserved()),this.parent?(this._escapedSubpath===void 0&&(this._escapedSubpath=this._subpath?Eh(this._subpath):``),this.parent.getEscapedPath(e)+`/`+this._escapedSubpath):``}}),Object.defineProperty(e.prototype,"isRoot",{get:function(){return this.parent===null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isAlive",{get:function(){return this.state!==Pm.DEAD},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDetaching",{get:function(){return this.state===Pm.DETACHING},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"observableIsAlive",{get:function(){return this.aliveAtom||=He(`alive`),this.aliveAtom.reportObserved(),this.isAlive},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseFinalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(gh()&&!this.isAlive)throw new G(`assertion failed: cannot finalize the creation of a node that is already dead`);if(this.state===Pm.CREATED){if(this.parent){if(this.parent.state!==Pm.FINALIZED)return;this.fireHook(bp.afterAttach)}this.state=Pm.FINALIZED,e&&e()}}}),Object.defineProperty(e.prototype,"baseFinalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._hookSubscribers&&this._hookSubscribers.clearAll(),this._subpathUponDeath=this._subpath,this._pathUponDeath=this.getEscapedPath(!1),this.baseSetParent(null,``),this.state=Pm.DEAD}}),Object.defineProperty(e.prototype,"baseAboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.fireHook(bp.beforeDestroy)}}),e}(),Gp=function(e){Sp(t,e);function t(t,n,r,i,a){var o=e.call(this,t,n,r,i)||this;try{o.storedValue=t.createNewInstance(a)}catch(e){throw o.state=Pm.DEAD,e}return o.state=Pm.CREATED,o.finalizeCreation(),o}return Object.defineProperty(t.prototype,"root",{get:function(){if(!this.parent)throw new G(`This scalar node is not part of a tree`);return this.parent.root},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this.parent!==e,r=this.subpath!==t;if(!(!n&&!r)){if(gh()){if(!t)throw new G(`assertion failed: subpath expected`);if(!e)throw new G(`assertion failed: parent expected`);if(n)throw new G(`assertion failed: scalar nodes cannot change their parent`)}this.environment=void 0,this.baseSetParent(this.parent,t)}}}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return rh(this.getSnapshot())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(t.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=(this.isAlive?this.path:this.pathUponDeath)||`<root>`;return`${this.type.name}@${e}${this.isAlive?``:` [dead]`}`}}),Object.defineProperty(t.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){!this.isAlive||this.state===Pm.DETACHING||(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(t.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeCreation()}}),Object.defineProperty(t.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseAboutToDie()}}),Object.defineProperty(t.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeDeath()}}),Object.defineProperty(t.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.fireInternalHook(e)}}),t}(Wp);Gp.prototype.die=ir(Gp.prototype.die);var Kp=1,qp;(function(e){e[e.UNINITIALIZED=0]=`UNINITIALIZED`,e[e.CREATING=1]=`CREATING`,e[e.CREATED=2]=`CREATED`})(qp||={});var Jp;(function(e){e.Dispose=`dispose`,e.Patch=`patch`,e.Snapshot=`snapshot`})(Jp||={});var Yp={onError:function(e){throw e}},Xp=function(e){Sp(t,e);function t(t,n,r,i,a){var o=e.call(this,t,n,r,i)||this;if(Object.defineProperty(o,"nodeId",{enumerable:!0,configurable:!0,writable:!0,value:++Kp}),Object.defineProperty(o,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"unnormalizedIdentifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"identifierCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"isProtectionEnabled",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(o,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"hasSnapshotPostProcessor",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(o,"_applyPatches",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"_applySnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"_autoUnbox",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(o,"_isRunningAction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(o,"_hasSnapshotReaction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(o,"_endOfActionCallbacks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"_observableInstanceState",{enumerable:!0,configurable:!0,writable:!0,value:qp.UNINITIALIZED}),Object.defineProperty(o,"_childNodes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"_initialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"_cachedInitialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"_cachedInitialSnapshotCreated",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(o,"_snapshotComputed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"_snapshotUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(o,"_internalEvents",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),o._snapshotComputed=Jt(function(){return rh(o.getSnapshot())}),o.unbox=o.unbox.bind(o),o._initialSnapshot=rh(a),o.identifierAttribute=t.identifierAttribute,n||(o.identifierCache=new Am),o._childNodes=t.initializeChildNodes(o,o._initialSnapshot),o.identifier=null,o.unnormalizedIdentifier=null,o.identifierAttribute&&o._initialSnapshot){var s=o._initialSnapshot[o.identifierAttribute];if(s===void 0){var c=o._childNodes[o.identifierAttribute];c&&(s=c.value)}if(typeof s!=`string`&&typeof s!=`number`&&typeof s!=`bigint`)throw new G(`Instance identifier '${o.identifierAttribute}' for type '${o.type.name}' must be a string, a number or a bigint`);o.identifier=t_(s),o.unnormalizedIdentifier=s}return n?n.root.identifierCache.addNodeToCache(o):o.identifierCache.addNodeToCache(o),o}return Object.defineProperty(t.prototype,"applyPatches",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.createObservableInstanceIfNeeded(),this._applyPatches(e)}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.createObservableInstanceIfNeeded(),this._applySnapshot(e)}}),Object.defineProperty(t.prototype,"createObservableInstanceIfNeeded",{enumerable:!1,configurable:!0,writable:!0,value:function(e){e===void 0&&(e=!0),this._observableInstanceState===qp.UNINITIALIZED&&this.createObservableInstance(e)}}),Object.defineProperty(t.prototype,"createObservableInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t,n,r,i;if(e===void 0&&(e=!0),gh()&&this.state!==Pm.INITIALIZING)throw new G(`assertion failed: the creation of the observable instance must be done on the initializing phase`);this._observableInstanceState=qp.CREATING;for(var a=[],o=this.parent;o&&o._observableInstanceState===qp.UNINITIALIZED;)a.unshift(o),o=o.parent;try{for(var s=Tp(a),c=s.next();!c.done;c=s.next()){var l=c.value;l.createObservableInstanceIfNeeded(!1)}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}var u=this.type;try{this.storedValue=u.createNewInstance(this._childNodes),this.preboot(),this._isRunningAction=!0,u.finalizeNewInstance(this,this.storedValue)}catch(e){throw this.state=Pm.DEAD,e}finally{this._isRunningAction=!1}if(this._observableInstanceState=qp.CREATED,this._snapshotComputed.trackAndCompute(),this.isRoot&&this._addSnapshotReaction(),this._childNodes=Gm,this.state=Pm.CREATED,e){this.fireHook(bp.afterCreate),this.finalizeCreation();try{for(var d=Tp(a.reverse()),f=d.next();!f.done;f=d.next()){var l=f.value;l.fireHook(bp.afterCreate),l.finalizeCreation()}}catch(e){r={error:e}}finally{try{f&&!f.done&&(i=d.return)&&i.call(d)}finally{if(r)throw r.error}}}}}),Object.defineProperty(t.prototype,"root",{get:function(){var e=this.parent;return e?e.root:this},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"enqueueEndOfAction",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.root;t._endOfActionCallbacks||=[],t._endOfActionCallbacks.push(e)}}),Object.defineProperty(t.prototype,"flushEndOfActionCallbacks",{enumerable:!1,configurable:!0,writable:!0,value:function(){for(var e=this.root;e._endOfActionCallbacks&&e._endOfActionCallbacks.length>0;){var t=e._endOfActionCallbacks;e._endOfActionCallbacks=void 0,t.forEach(function(e){e()})}}}),Object.defineProperty(t.prototype,"clearParent",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.parent){this.fireHook(bp.beforeDetach);var e=this.state;this.state=Pm.DETACHING;var t=this.root,n=t.environment,r=t.identifierCache.splitCache(this);try{this.parent.removeChild(this.subpath),this.baseSetParent(null,``),this.environment=n,this.identifierCache=r}finally{this.state=e}}}}),Object.defineProperty(t.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=e!==this.parent,r=t!==this.subpath;if(!(!n&&!r)){if(gh()){if(!t)throw new G(`assertion failed: subpath expected`);if(!e)throw new G(`assertion failed: new parent expected`);if(this.parent&&n)throw new G(`A node cannot exists twice in the state tree. Failed to add ${this} to path '${e.path}/${t}'.`);if(!this.parent&&e.root===this)throw new G(`A state tree is not allowed to contain itself. Cannot assign ${this} to path '${e.path}/${t}'`);if(!this.parent&&this.environment&&this.environment!==e.root.environment)throw new G(`A state tree cannot be made part of another state tree as long as their environments are different.`)}n?(this.environment=void 0,e.root.identifierCache.mergeCache(this),this.baseSetParent(e,t),this.fireHook(bp.afterAttach)):r&&this.baseSetParent(this.parent,t)}}}),Object.defineProperty(t.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this.fireInternalHook(e);var n=this.storedValue&&typeof this.storedValue==`object`&&this.storedValue[e];typeof n==`function`&&(or?or(function(){n.apply(t.storedValue)}):n.apply(this.storedValue))}}),Object.defineProperty(t.prototype,"snapshot",{get:function(){return this.hasSnapshotPostProcessor&&this.createObservableInstanceIfNeeded(),this._snapshotComputed.get()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.isAlive?this._observableInstanceState===qp.CREATED?this._getActualSnapshot():this._getCachedInitialSnapshot():this._snapshotUponDeath}}),Object.defineProperty(t.prototype,"_getActualSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(t.prototype,"_getCachedInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this._cachedInitialSnapshotCreated){var e=this.type,t=this._childNodes,n=this._initialSnapshot;this._cachedInitialSnapshot=e.processInitialSnapshot(t,n),this._cachedInitialSnapshotCreated=!0}return this._cachedInitialSnapshot}}),Object.defineProperty(t.prototype,"isRunningAction",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isRunningAction?!0:this.isRoot?!1:this.parent.isRunningAction()}}),Object.defineProperty(t.prototype,"assertAlive",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=yp();if(!this.isAlive&&t!==`ignore`){var n=this._getAssertAliveError(e);switch(t){case`error`:throw new G(n);case`warn`:mh(n)}}}}),Object.defineProperty(t.prototype,"_getAssertAliveError",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.getEscapedPath(!1)||this.pathUponDeath||``,n=e.subpath&&Eh(e.subpath)||``,r=e.actionContext||dm();r&&r.type!==`action`&&r.parentActionEvent&&(r=r.parentActionEvent);var i=``;return r&&r.name!=null&&(i=`${r&&r.context&&Lp(r.context)||t}.${r.name}()`),`You are trying to read or write to an object that is no longer part of a state tree. (Object type: '${this.type.name}', Path upon death: '${t}', Subpath: '${n}', Action: '${i}'). Either detach nodes first, or don't use objects after removing / replacing them in the tree.`}}),Object.defineProperty(t.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.assertAlive({subpath:e}),this._autoUnbox=!1;try{return this._observableInstanceState===qp.CREATED?this.type.getChildNode(this,e):this._childNodes[e]}finally{this._autoUnbox=!0}}}),Object.defineProperty(t.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.assertAlive(Gm),this._autoUnbox=!1;try{return this._observableInstanceState===qp.CREATED?this.type.getChildren(this):Hm(this._childNodes)}finally{this._autoUnbox=!0}}}),Object.defineProperty(t.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.type.getChildType(e)}}),Object.defineProperty(t.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"assertWritable",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.assertAlive(e),!this.isRunningAction()&&this.isProtected)throw new G(`Cannot modify '${this}', the object is protected and can only be modified by using an action.`)}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.type.removeChild(this,e)}}),Object.defineProperty(t.prototype,"unbox",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e&&(this.assertAlive({subpath:e.subpath||e.subpathUponDeath}),this._autoUnbox?e.value:e)}}),Object.defineProperty(t.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=(this.isAlive?this.path:this.pathUponDeath)||`<root>`,t=this.identifier?`(id: ${this.identifier})`:``;return`${this.type.name}@${e}${t}${this.isAlive?``:` [dead]`}`}}),Object.defineProperty(t.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this.baseFinalizeCreation(function(){var t,n;try{for(var r=Tp(e.getChildren()),i=r.next();!i.done;i=r.next())i.value.finalizeCreation()}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}e.fireInternalHook(bp.afterCreationFinalization)})}}),Object.defineProperty(t.prototype,"detach",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this.isAlive)throw new G(`Error while detaching, node is not alive.`);this.clearParent()}}),Object.defineProperty(t.prototype,"preboot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;this._applyPatches=hm(this.storedValue,`@APPLY_PATCHES`,function(t){t.forEach(function(t){if(!t.path){e.type.applySnapshot(e,t.value);return}var n=kh(t.path);Vm(e,n.slice(0,-1)).applyPatchLocally(n[n.length-1],t)})}),this._applySnapshot=hm(this.storedValue,`@APPLY_SNAPSHOT`,function(t){if(t!==e.snapshot)return e.type.applySnapshot(e,t)}),sh(this.storedValue,`$treenode`,this),sh(this.storedValue,`toJSON`,zm)}}),Object.defineProperty(t.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){!this.isAlive||this.state===Pm.DETACHING||(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(t.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._observableInstanceState!==qp.UNINITIALIZED&&(this.getChildren().forEach(function(e){e.aboutToDie()}),this.baseAboutToDie(),this._internalEventsEmit(Jp.Dispose),this._internalEventsClear(Jp.Dispose))}}),Object.defineProperty(t.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.getChildren().forEach(function(e){e.finalizeDeath()}),this.root.identifierCache.notifyDied(this);var e=this.snapshot;this._snapshotUponDeath=e,this._internalEventsClearAll(),this.baseFinalizeDeath()}}),Object.defineProperty(t.prototype,"onSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._addSnapshotReaction(),this._internalEventsRegister(Jp.Snapshot,e)}}),Object.defineProperty(t.prototype,"emitSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._internalEventsEmit(Jp.Snapshot,e)}}),Object.defineProperty(t.prototype,"onPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._internalEventsRegister(Jp.Patch,e)}}),Object.defineProperty(t.prototype,"hasPatchSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._internalEventsHasSubscribers(Jp.Patch)?!0:this.parent?this.parent.hasPatchSubscribers():!1}}),Object.defineProperty(t.prototype,"emitPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this._internalEventsHasSubscribers(Jp.Patch)){var n=Ep(Sh($m({},e,{path:t.path.substr(this.path.length)+(e.path?`/`+e.path:``)})),2),r=n[0],i=n[1];this._internalEventsEmit(Jp.Patch,r,i)}this.parent&&this.parent.emitPatch(e,t)}}),Object.defineProperty(t.prototype,"hasDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._internalEventsHas(Jp.Dispose,e)}}),Object.defineProperty(t.prototype,"addDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this.hasDisposer(e)){this._internalEventsRegister(Jp.Dispose,e,!0);return}throw new G(`cannot add a disposer when it is already registered for execution`)}}),Object.defineProperty(t.prototype,"removeDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._internalEventsHas(Jp.Dispose,e))throw new G(`cannot remove a disposer which was never registered for execution`);this._internalEventsUnregister(Jp.Dispose,e)}}),Object.defineProperty(t.prototype,"removeMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(this.middlewares){var t=this.middlewares.indexOf(e);t>=0&&this.middlewares.splice(t,1)}}}),Object.defineProperty(t.prototype,"addMiddleWare",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this;t===void 0&&(t=!0);var r={handler:e,includeHooks:t};return this.middlewares?this.middlewares.push(r):this.middlewares=[r],function(){n.removeMiddleware(r)}}}),Object.defineProperty(t.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this.assertWritable({subpath:e}),this.createObservableInstanceIfNeeded(),this.type.applyPatchLocally(this,e,t)}}),Object.defineProperty(t.prototype,"_addSnapshotReaction",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;if(!this._hasSnapshotReaction){var t=dr(function(){return e.snapshot},function(t){return e.emitSnapshot(t)},Yp);this.addDisposer(t),this._hasSnapshotReaction=!0}}}),Object.defineProperty(t.prototype,"_internalEventsHasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return!!this._internalEvents&&this._internalEvents.hasSubscribers(e)}}),Object.defineProperty(t.prototype,"_internalEventsRegister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){return n===void 0&&(n=!1),this._internalEvents||=new uh,this._internalEvents.register(e,t,n)}}),Object.defineProperty(t.prototype,"_internalEventsHas",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!!this._internalEvents&&this._internalEvents.has(e,t)}}),Object.defineProperty(t.prototype,"_internalEventsUnregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){this._internalEvents&&this._internalEvents.unregister(e,t)}}),Object.defineProperty(t.prototype,"_internalEventsEmit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];this._internalEvents&&(t=this._internalEvents).emit.apply(t,Dp([e],Ep(n),!1))}}),Object.defineProperty(t.prototype,"_internalEventsClear",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this._internalEvents&&this._internalEvents.clear(e)}}),Object.defineProperty(t.prototype,"_internalEventsClearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._internalEvents&&this._internalEvents.clearAll()}}),t}(Wp);Xp.prototype.createObservableInstance=ir(Xp.prototype.createObservableInstance),Xp.prototype.detach=ir(Xp.prototype.detach),Xp.prototype.die=ir(Xp.prototype.die);var Zp,Qp;(function(e){e[e.String=1]=`String`,e[e.Number=2]=`Number`,e[e.Boolean=4]=`Boolean`,e[e.Date=8]=`Date`,e[e.Literal=16]=`Literal`,e[e.Array=32]=`Array`,e[e.Map=64]=`Map`,e[e.Object=128]=`Object`,e[e.Frozen=256]=`Frozen`,e[e.Optional=512]=`Optional`,e[e.Reference=1024]=`Reference`,e[e.Identifier=2048]=`Identifier`,e[e.Late=4096]=`Late`,e[e.Refinement=8192]=`Refinement`,e[e.Union=16384]=`Union`,e[e.Null=32768]=`Null`,e[e.Undefined=65536]=`Undefined`,e[e.Integer=131072]=`Integer`,e[e.Custom=262144]=`Custom`,e[e.SnapshotProcessor=524288]=`SnapshotProcessor`,e[e.Lazy=1048576]=`Lazy`,e[e.Finite=2097152]=`Finite`,e[e.Float=4194304]=`Float`,e[e.BigInt=8388608]=`BigInt`})(Qp||={});var $p=`cannotDetermine`,em=Symbol(`$type`),tm=function(){function e(e){Object.defineProperty(this,Zp,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"C",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"S",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"T",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"N",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isType",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e}return Object.defineProperty(e.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return Em(this,e),this.instantiate(null,``,t,e).value}}),Object.defineProperty(e.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){throw new G(`unimplemented method`)}}),Object.defineProperty(e.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e===this}}),Object.defineProperty(e.prototype,"validate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(Rm(e)){var n=Op(e);return this.isAssignableFrom(n)?Cm():wm(t,e)}return this.isValidSnapshot(e,t)}}),Object.defineProperty(e.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.validate(e,[{path:``,type:this}]).length===0}}),Object.defineProperty(e.prototype,"Type",{get:function(){throw new G("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"TypeWithoutSTN",{get:function(){throw new G("Factory.TypeWithoutSTN should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.TypeWithoutSTN`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"SnapshotType",{get:function(){throw new G("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"CreationType",{get:function(){throw new G("Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`")},enumerable:!1,configurable:!0}),e}();Zp=em,tm.prototype.create=ir(tm.prototype.create);var nm=function(e){Sp(t,e);function t(t){var n=e.call(this,t)||this;return Object.defineProperty(n,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n}return Object.defineProperty(t.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return t===void 0&&(t=this.getDefaultSnapshot()),e.prototype.create.call(this,t,n)}}),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.createObservableInstanceIfNeeded(),e.storedValue}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return!e.identifierAttribute||e.identifier===t_(t[e.identifierAttribute])}}),Object.defineProperty(t.prototype,"tryToReconcileNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return e.isDetaching?!1:e.snapshot===t||Fm(t)&&Lm(t)===e?!0:e.type===this&&th(t)&&!Fm(t)&&this.isMatchingSnapshotId(e,t)?(e.applySnapshot(t),!0):!1}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){if(this.tryToReconcileNode(e,t))return e.setParent(n,r),e;if(e.die(),Fm(t)&&this.isAssignableFrom(Op(t))){var i=Lm(t);return i.setParent(n,r),i}return this.instantiate(n,r,void 0,t)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),t}(tm);nm.prototype.create=ir(nm.prototype.create);var rm=function(e){Sp(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e}}),Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){if(!e.isDetaching&&e.type===this&&e.storedValue===t)return e;var i=this.instantiate(n,r,void 0,t);return e.die(),i}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),t}(tm);function im(e,t,n){var r=t.getReconciliationType(),i=r===am(e);return t instanceof Xp&&i&&r instanceof nm&&th(n)&&!Fm(n)&&r.isMatchingSnapshotId(t,n)}function am(e){var t=e.getSubTypes();return!t||Array.isArray(t)||t===$p||!om(e)?e:am(t)}function om(e){var t=Qp.Optional|Qp.Late,n=Qp.Refinement|Qp.SnapshotProcessor|Qp.Union;return(e.flags&t)>0&&(e.flags&n)===0}function sm(e){return typeof e==`object`&&e&&e.isType===!0}function cm(e,t){_h(e,sm,`mobx-state-tree type`,t)}(function(){function e(e,t){Object.defineProperty(this,"hooks",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"call",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"flowsPending",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"running",{enumerable:!0,configurable:!0,writable:!0,value:!0}),e&&e.onStart(t)}return Object.defineProperty(e.prototype,"finish",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.running&&(this.running=!1,this.hooks&&this.hooks.onFinish(this.call,e))}}),Object.defineProperty(e.prototype,"incFlowsPending",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.flowsPending++}}),Object.defineProperty(e.prototype,"decFlowsPending",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.flowsPending--}}),Object.defineProperty(e.prototype,"hasFlowsPending",{get:function(){return this.flowsPending>0},enumerable:!1,configurable:!0}),e})();var lm=1,um;function dm(){return um}function fm(){return lm++}function pm(e,t){var n=Lm(e.context);e.type===`action`&&n.assertAlive({actionContext:e});var r=n._isRunningAction;n._isRunningAction=!0;var i=um,a=!i;um=e;try{return _m(n,e,t,a)}finally{um=i,n._isRunningAction=r}}function mm(e){if(e)return e.type===`action`?e:e.parentActionEvent}function hm(e,t,n){var r=function(){var r=fm(),i=um,a=mm(i);return pm({type:`action`,name:t,id:r,args:dh(arguments),context:e,tree:Ip(e),rootId:i?i.rootId:r,parentId:i?i.id:0,allParentIds:i?Dp(Dp([],Ep(i.allParentIds),!1),[i.id],!1):[],parentEvent:i,parentActionEvent:a},n)};return r._isMSTAction=!0,r._isFlowAction=n._isFlowAction,r}var gm=function(){function e(e,t){Object.defineProperty(this,"arrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"inArrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:[]}),t.$mst_middleware&&this.middlewares.push(t.$mst_middleware);for(var n=e;n;)n.middlewares&&this.middlewares.push(n.middlewares),n=n.parent}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.middlewares.length<=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getNextMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.middlewares[this.arrayIndex];if(e)return e[this.inArrayIndex++]||(this.arrayIndex++,this.inArrayIndex=0,this.getNextMiddleware())}}),e}();function _m(e,t,n,r){function i(t,n){var i=function(){var i,a;try{i=n.apply(null,t.args)}catch(e){a=e}if(r||!t.parentActionEvent)try{e.root.flushEndOfActionCallbacks()}catch(e){a||=e}if(a)throw a;return i};return t.name?ir(t.name,i)():ir(i)()}var a=new gm(e,n);if(a.isEmpty)return i(t,n);var o=null;function s(e){var t=a.getNextMiddleware(),c=t&&t.handler;if(!c)return i(e,n);if(!t.includeHooks&&bp[e.name])return s(e);var l=!1;function u(e,t){l=!0,o=s(e),t&&(o=t(o))}var d=!1;function f(e){d=!0,o=e}if(c(e,u,f),gh()){if(!l&&!d){var p=Lm(e.tree);throw new G(`Neither the next() nor the abort() callback within the middleware ${c.name} for the action: "${e.name}" on the node: ${p.type.name} was invoked.`)}else if(l&&d){var p=Lm(e.tree);throw new G(`The next() and abort() callback within the middleware ${c.name} for the action: "${e.name}" on the node: ${p.type.name} were invoked.`)}}return d&&(r||!e.parentActionEvent)?i(e,function(){return o}):o}return s(t)}function vm(e){try{return JSON.stringify(e)}catch(e){return`<Unserializable: ${e}>`}}function ym(e){return typeof e==`function`?`<function${e.name?` `+e.name:``}>`:Fm(e)?`<${e}>`:`\`${vm(e)}\``}function bm(e){return e.length<280?e:`${e.substring(0,272)}......${e.substring(e.length-8)}`}function xm(e){var t=e.value,n=e.context[e.context.length-1].type,r=e.context.map(function(e){return e.path}).filter(function(e){return e.length>0}).join(`/`),i=r.length>0?`at path "/${r}" `:``,a=Fm(t)?`value of type ${Lm(t).type.name}:`:nh(t)?`value`:`snapshot`,o=n&&Fm(t)&&n.is(Lm(t).snapshot);return`${i}${a} ${ym(t)} is not assignable ${n?`to type: \`${n.name}\``:``}`+(e.message?` (${e.message})`:``)+(n?_g(n)||nh(t)?`.`:`, expected an instance of \`${n.name}\` or a snapshot like \`${n.describe()}\` instead.`+(o?` (Note that a snapshot of the provided value is compatible with the targeted type)`:``):`.`)}function Sm(e,t,n){return e.concat([{path:t,type:n}])}function Cm(){return Wm}function wm(e,t,n){return[{context:e,value:t,message:n}]}function Tm(e){return e.reduce(function(e,t){return e.concat(t)},[])}function Em(e,t){hh()&&Dm(e,t)}function Dm(e,t){var n=e.validate(t,[{path:``,type:e}]);if(n.length>0)throw new G(Om(e,t,n))}function Om(e,t,n){if(n.length!==0)return`Error while converting ${bm(ym(t))} to \`${e.name}\`:
|
|
45
|
+
|
|
46
|
+
`+n.map(xm).join(`
|
|
47
|
+
`)}var km=0,Am=function(){function e(){Object.defineProperty(this,"cacheId",{enumerable:!0,configurable:!0,writable:!0,value:km++}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:Ut.map()}),Object.defineProperty(this,"lastCacheModificationPerId",{enumerable:!0,configurable:!0,writable:!0,value:Ut.map()})}return Object.defineProperty(e.prototype,"updateLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.lastCacheModificationPerId.get(e);this.lastCacheModificationPerId.set(e,t===void 0?1:t+1)}}),Object.defineProperty(e.prototype,"getLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.lastCacheModificationPerId.get(e)||0;return`${this.cacheId}-${t}`}}),Object.defineProperty(e.prototype,"addNodeToCache",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(t===void 0&&(t=!0),e.identifierAttribute){var n=e.identifier;this.cache.has(n)||this.cache.set(n,Ut.array([],Km));var r=this.cache.get(n);if(r.indexOf(e)!==-1)throw new G(`Already registered`);r.push(e),t&&this.updateLastCacheModificationPerId(n)}}}),Object.defineProperty(e.prototype,"mergeCache",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;Br(e.identifierCache.cache).forEach(function(e){return e.forEach(function(e){t.addNodeToCache(e)})})}}),Object.defineProperty(e.prototype,"notifyDied",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.identifierAttribute){var t=e.identifier,n=this.cache.get(t);n&&(n.remove(e),n.length||this.cache.delete(t),this.updateLastCacheModificationPerId(e.identifier))}}}),Object.defineProperty(e.prototype,"splitCache",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this,r=new e,i=t.path+`/`;return Vr(this.cache).forEach(function(e){for(var a=Ep(e,2),o=a[0],s=a[1],c=!1,l=s.length-1;l>=0;l--){var u=s[l];(u===t||u.path.indexOf(i)===0)&&(r.addNodeToCache(u,!1),s.splice(l,1),s.length||n.cache.delete(o),c=!0)}c&&n.updateLastCacheModificationPerId(o)}),r}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this.cache.get(t);return n?n.some(function(t){return e.isAssignableFrom(t.type)}):!1}}),Object.defineProperty(e.prototype,"resolve",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this.cache.get(t);if(!n)return null;var r=n.filter(function(t){return e.isAssignableFrom(t.type)});switch(r.length){case 0:return null;case 1:return r[0];default:throw new G(`Cannot resolve a reference to type '${e.name}' with id: '${t}' unambigously, there are multiple candidates: ${r.map(function(e){return e.path}).join(`, `)}`)}}}),e}();function jm(e,t,n,r,i){var a=Rm(i);if(a){if(a.parent)throw new G(`Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '${t?t.path:``}/${n}', but it lives already at '${a.path}'`);return t&&a.setParent(t,n),a}return new Xp(e,t,n,r,i)}function Mm(e,t,n,r,i){return new Gp(e,t,n,r,i)}function Nm(e){return e instanceof Gp||e instanceof Xp}var Pm;(function(e){e[e.INITIALIZING=0]=`INITIALIZING`,e[e.CREATED=1]=`CREATED`,e[e.FINALIZED=2]=`FINALIZED`,e[e.DETACHING=3]=`DETACHING`,e[e.DEAD=4]=`DEAD`})(Pm||={});function Fm(e){return!!(e&&e.$treenode)}function Im(e,t){_h(e,Fm,`mobx-state-tree node`,t)}function Lm(e){if(!Fm(e))throw new G(`Value ${e} is no MST Node`);return e.$treenode}function Rm(e){return e&&e.$treenode||null}function zm(){return Lm(this).snapshot}function Bm(e,t,n){return n===void 0&&(n=!0),Vm(e,kh(t),n)}function Vm(e,t,n){n===void 0&&(n=!0);var r=e;try{for(var i=0;i<t.length;i++){var a=t[i];if(a===`..`){if(r=r.parent,r)continue}else if(a===`.`)continue;else if(r){if(r instanceof Gp){var o=r.value;Fm(o)&&(r=Lm(o))}if(r instanceof Xp&&r.getChildType(a)&&(r=r.getChildNode(a),r))continue}throw new G(`Could not resolve '${a}' in path '${Oh(t.slice(0,i))||`/`}' while resolving '${Oh(t)}'`)}}catch(e){if(!n)return;throw e}return r}function Hm(e){if(!e)return Wm;var t=Object.keys(e);if(!t.length)return Wm;var n=Array(t.length);return t.forEach(function(t,r){n[r]=e[t]}),n}var Um=Object.toString(),Wm=Object.freeze([]),Gm=Object.freeze({}),Km=kn().useProxies?{deep:!1}:{deep:!1,proxy:!1};Object.freeze(Km);var G=function(e){Sp(t,e);function t(t){return t===void 0&&(t=`Illegal state`),e.call(this,`[mobx-state-tree] ${t}`)||this}return t}(Error);function qm(e){return e}var Jm=Number.isInteger;function Ym(e){return Number(e)===e&&e%1!=0}function Xm(e){return Number.isFinite(e)}function Zm(e){return Array.isArray(e)||yi(e)}function Qm(e){return e?Zm(e)?e:[e]:Wm}function $m(e){for(var t=[...arguments].slice(1),n=0;n<t.length;n++){var r=t[n];for(var i in r)e[i]=r[i]}return e}function eh(e){if(typeof e!=`object`||!e)return!1;var t=Object.getPrototypeOf(e);return t==null?!0:t.constructor?.toString()===Um}function th(e){return typeof e==`object`&&!!e&&!(e instanceof Date)&&!(e instanceof RegExp)}function nh(e,t){return t===void 0&&(t=!0),e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`||t&&e instanceof Date}function rh(e){return gh()?nh(e)||yi(e)?e:Object.freeze(e):e}function ih(e){return gh()?(rh(e),eh(e)&&Object.keys(e).forEach(function(t){!nh(e[t])&&!Object.isFrozen(e[t])&&ih(e[t])}),e):e}function ah(e){return typeof e!=`function`}function oh(e,t,n){Li(e)?Ur(e,t,n):Object.defineProperty(e,t,n)}function sh(e,t,n){oh(e,t,{enumerable:!1,writable:!1,configurable:!0,value:n})}function ch(e,t,n){oh(e,t,{enumerable:!1,writable:!0,configurable:!0,value:n})}var lh=function(){function e(){Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:[]})}return Object.defineProperty(e.prototype,"hasSubscribers",{get:function(){return this.handlers.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this;return t===void 0&&(t=!1),t?this.handlers.unshift(e):this.handlers.push(e),function(){n.unregister(e)}}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.handlers.indexOf(e)>=0}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.handlers.indexOf(e);t>=0&&this.handlers.splice(t,1)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.handlers.length=0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=[...arguments];this.handlers.slice().forEach(function(t){return t.apply(void 0,Dp([],Ep(e),!1))})}}),e}(),uh=function(){function e(){Object.defineProperty(this,"eventHandlers",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}return Object.defineProperty(e.prototype,"hasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.eventHandlers&&this.eventHandlers[e];return!!t&&t.hasSubscribers}}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){n===void 0&&(n=!1),this.eventHandlers||={};var r=this.eventHandlers[e];return r||=this.eventHandlers[e]=new lh,r.register(t,n)}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this.eventHandlers&&this.eventHandlers[e];return!!n&&n.has(t)}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this.eventHandlers&&this.eventHandlers[e];n&&n.unregister(t)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(e){this.eventHandlers&&delete this.eventHandlers[e]}}),Object.defineProperty(e.prototype,"clearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.eventHandlers=void 0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=this.eventHandlers&&this.eventHandlers[e];i&&(t=i).emit.apply(t,Dp([],Ep(n),!1))}}),e}();function dh(e){for(var t=Array(e.length),n=0;n<e.length;n++)t[n]=e[n];return t}function fh(e,t){return e.indexOf(t)===0}var ph=function(e,t){gh()&&(ph.ids&&!ph.ids.hasOwnProperty(e)&&mh(`Deprecation warning: `+t),ph.ids&&(ph.ids[e]=!0))};ph.ids={};function mh(e){console.warn(Error(`[mobx-state-tree] ${e}`))}function hh(){return gh()||typeof process<`u`&&{}.ENABLE_TYPE_CHECK===`true`}function gh(){return!1}function _h(e,t,n,r){if(gh()&&!t(e))throw new G(`expected ${n} as argument ${Qm(r).join(` or `)}, got ${e} instead`)}function vh(e,t){_h(e,function(e){return typeof e==`function`},`function`,t)}function yh(e,t,n,r){_h(e,function(e){return typeof e==`number`},`number`,t),n!==void 0&&_h(e,function(e){return e>=n},`number greater than ${n}`,t),r!==void 0&&_h(e,function(e){return e<=r},`number lesser than ${r}`,t)}function bh(e,t,n){n===void 0&&(n=!0),_h(e,function(e){return typeof e==`string`},`string`,t),n||_h(e,function(e){return e!==``},`not empty string`,t)}function xh(e){typeof queueMicrotask==`function`?queueMicrotask(e):typeof setImmediate==`function`?setImmediate(e):setTimeout(e,1)}function Sh(e){if(!(`oldValue`in e))throw new G("Patches without `oldValue` field cannot be inversed");return[Ch(e),wh(e)]}function Ch(e){switch(e.op){case`add`:return{op:`add`,path:e.path,value:e.value};case`remove`:return{op:`remove`,path:e.path};case`replace`:return{op:`replace`,path:e.path,value:e.value}}}function wh(e){switch(e.op){case`add`:return{op:`remove`,path:e.path};case`remove`:return{op:`add`,path:e.path,value:e.oldValue};case`replace`:return{op:`replace`,path:e.path,value:e.oldValue}}}function Th(e){return typeof e==`number`}function Eh(e){return Th(e)===!0?``+e:e.indexOf(`/`)===-1&&e.indexOf(`~`)===-1?e:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Dh(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function Oh(e){if(e.length===0)return``;var t=function(e){return e.map(Eh).join(`/`)};return e[0]===`.`||e[0]===`..`?t(e):`/`+t(e)}function kh(e){var t=e.split(`/`).map(Dh);if(!(e===``||e===`.`||e===`..`||fh(e,`/`)||fh(e,`./`)||fh(e,`../`)))throw new G(`a json path must be either rooted, empty or relative, but got '${e}'`);return t[0]===``&&t.shift(),t}var Ah=Symbol(`$preProcessorFailed`),jh=function(e){Sp(t,e);function t(t,n,r){var i=e.call(this,r||t.name)||this;return Object.defineProperty(i,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_processors",{enumerable:!0,configurable:!0,writable:!0,value:n}),i}return Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|Qp.SnapshotProcessor},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return`snapshotProcessor(${this._subtype.describe()})`}}),Object.defineProperty(t.prototype,"preProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._processors.preProcessor?this._processors.preProcessor.call(null,e):e}}),Object.defineProperty(t.prototype,"preProcessSnapshotSafe",{enumerable:!1,configurable:!0,writable:!0,value:function(e){try{return this.preProcessSnapshot(e)}catch{return Ah}}}),Object.defineProperty(t.prototype,"postProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._processors.postProcessor?this._processors.postProcessor.call(null,e,t.storedValue):e}}),Object.defineProperty(t.prototype,"_fixNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;Mh(e.type,this,`create`),e instanceof Xp&&(e.hasSnapshotPostProcessor=!!this._processors.postProcessor);var n=e.getSnapshot;e.getSnapshot=function(){return t.postProcessSnapshot(n.call(e),e)},Tg(this._subtype)||(e.getReconciliationType=function(){return t})}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){var i=Fm(r)?r:this.preProcessSnapshot(r),a=this._subtype.instantiate(e,t,n,i);return this._fixNode(a),a}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){var i=this._subtype.reconcile(e,Fm(t)?t:this.preProcessSnapshot(t),n,r);return i!==e&&this._fixNode(i),i}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){t===void 0&&(t=!0);var n=this._subtype.getSnapshot(e);return t?this.postProcessSnapshot(n,e):n}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this.preProcessSnapshotSafe(e);return n===Ah?wm(t,e,`Failed to preprocess value`):this._subtype.validate(n,t)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),Object.defineProperty(t.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=sm(e)?this._subtype:Fm(e)?e:this.preProcessSnapshotSafe(e);return t===Ah?!1:this._subtype.validate(t,[{path:``,type:this._subtype}]).length===0}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!(this._subtype instanceof nm))return!1;var n=this.preProcessSnapshot(t);return this._subtype.isMatchingSnapshotId(e,n)}}),t}(tm);function Mh(e,t){for(var n,r,i=[],a=2;a<arguments.length;a++)i[a-2]=arguments[a];try{for(var o=Tp(i),s=o.next();!s.done;s=o.next()){var c=s.value;e[c]=t[c].bind(t)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}function Nh(e,t,n){if(cm(e,1),gh()){if(t.postProcessor&&typeof t.postProcessor!=`function`)throw new G(`postSnapshotProcessor must be a function`);if(t.preProcessor&&typeof t.preProcessor!=`function`)throw new G(`preSnapshotProcessor must be a function`)}return new jh(e,t,n)}var Ph=`Map.put can only be used to store complex values that have an identifier type attribute`;function Fh(e,t){var n,r,i=e.getSubTypes();if(i===$p)return!1;if(i){var a=Qm(i);try{for(var o=Tp(a),s=o.next();!s.done;s=o.next()){var c=s.value;if(!Fh(c,t))return!1}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}return e instanceof $h&&t.push(e),!0}var Ih;(function(e){e[e.UNKNOWN=0]=`UNKNOWN`,e[e.YES=1]=`YES`,e[e.NO=2]=`NO`})(Ih||={});var Lh=function(e){Sp(t,e);function t(t,n){return e.call(this,t,Ut.ref.enhancer,n)||this}return Object.defineProperty(t.prototype,"get",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.get.call(this,``+t)}}),Object.defineProperty(t.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.has.call(this,``+t)}}),Object.defineProperty(t.prototype,"delete",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.delete.call(this,``+t)}}),Object.defineProperty(t.prototype,"set",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return e.prototype.set.call(this,``+t,n)}}),Object.defineProperty(t.prototype,"put",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!e)throw new G(`Map.put cannot be used to set empty values`);if(Fm(e)){var t=Lm(e);if(gh()&&!t.identifierAttribute||t.identifier===null)throw new G(Ph);return this.set(t.identifier,e),e}else if(th(e)){var n=Lm(this),r=n.type;if(r.identifierMode!==Ih.YES)throw new G(Ph);var i=e[r.mapIdentifierAttribute];if(!n_(i)){var a=this.put(r.getChildType().create(e,n.environment));return this.put(Mp(a))}var o=t_(i);return this.set(o,e),this.get(o)}else throw new G(`Map.put can only be used to store complex values`)}}),t}(Ci),Rh=function(e){Sp(t,e);function t(t,n,r){r===void 0&&(r=[]);var i=e.call(this,t)||this;return Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"identifierMode",{enumerable:!0,configurable:!0,writable:!0,value:Ih.UNKNOWN}),Object.defineProperty(i,"mapIdentifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:Qp.Map}),Object.defineProperty(i,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),i._determineIdentifierMode(),i.hookInitializers=r,i}return Object.defineProperty(t.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=this.hookInitializers.length>0?this.hookInitializers.concat(e):[e];return new t(this.name,this._subType,n)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){return this._determineIdentifierMode(),jm(this,e,t,n,r)}}),Object.defineProperty(t.prototype,"_determineIdentifierMode",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.identifierMode===Ih.UNKNOWN){var e=[];if(Fh(this._subType,e)){var t=e.reduce(function(e,t){if(!t.identifierAttribute)return e;if(e&&e!==t.identifierAttribute)throw new G(`The objects in a map should all have the same identifier attribute, expected '${e}', but child of type '${t.name}' declared attribute '${t.identifierAttribute}' as identifier`);return t.identifierAttribute},void 0);t?(this.identifierMode=Ih.YES,this.mapIdentifierAttribute=t):this.identifierMode=Ih.NO}}}}),Object.defineProperty(t.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){t===void 0&&(t={});var n=e.type._subType,r={};return Object.keys(t).forEach(function(i){r[i]=n.instantiate(e,i,void 0,t[i])}),r}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return new Lh(e,this.name)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){Nr(t,e.unbox),e.type.hookInitializers.forEach(function(e){var n=e(t);Object.keys(n).forEach(function(e){var r=n[e],i=hm(t,e,r);(gh()?ch:sh)(t,e,i)})}),Pr(t,this.willChange),Wr(t,this.didChange)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return Br(e.storedValue)}}),Object.defineProperty(t.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=e.storedValue.get(``+t);if(!n)throw new G(`Not a child `+t);return n}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=Lm(e.object),n=e.name;t.assertWritable({subpath:n});var r=t.type,i=r._subType;switch(e.type){case`update`:var a=e.newValue;if(a===e.object.get(n))return null;Em(i,a),e.newValue=i.reconcile(t.getChildNode(n),e.newValue,t,n),r.processIdentifier(n,e.newValue);break;case`add`:Em(i,e.newValue),e.newValue=i.instantiate(t,n,void 0,e.newValue),r.processIdentifier(n,e.newValue);break}return e}}),Object.defineProperty(t.prototype,"processIdentifier",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this.identifierMode===Ih.YES&&t instanceof Xp){var n=t.identifier;if(n!==e)throw new G(`A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '${n}', but expected: '${e}'`)}}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return e.getChildren().forEach(function(e){t[e.subpath]=e.snapshot}),t}}),Object.defineProperty(t.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return Object.keys(e).forEach(function(n){t[n]=e[n].getSnapshot()}),t}}),Object.defineProperty(t.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=Lm(e.object);switch(e.type){case`update`:t.emitPatch({op:`replace`,path:Eh(e.name),value:e.newValue.snapshot,oldValue:e.oldValue?e.oldValue.snapshot:void 0},t);return;case`add`:t.emitPatch({op:`add`,path:Eh(e.name),value:e.newValue.snapshot,oldValue:void 0},t);return;case`delete`:var n=e.oldValue.snapshot;e.oldValue.die(),t.emitPatch({op:`remove`,path:Eh(e.name),oldValue:n},t);return}}}),Object.defineProperty(t.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){var r=e.storedValue;switch(n.op){case`add`:case`replace`:r.set(t,n.value);break;case`remove`:r.delete(t);break}}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!eh(t)){Em(this,t);return}var n=e.storedValue,r=this.getChildType();for(var i in Array.from(n.keys()).forEach(function(i){if(!Object.prototype.hasOwnProperty.call(t,i)){n.delete(i);return}var a=e.getChildNode(i),o=t[i];a.snapshot!==o&&(im(r,a,o)?a.applySnapshot(o):n.set(i,o))}),t)!Object.prototype.hasOwnProperty.call(t,i)||n.has(i)||n.set(i,t[i])}}),Object.defineProperty(t.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this;return eh(e)?Tm(Object.keys(e).map(function(r){return n._subType.validate(e[r],Sm(t,r,n._subType))})):wm(t,e,`Value is not a plain object`)}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Gm}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue.delete(t)}}),t}(nm);Rh.prototype.applySnapshot=ir(Rh.prototype.applySnapshot);function zh(e){return new Rh(`Map<string, ${e.name}>`,e)}var Bh=function(e){Sp(t,e);function t(t,n,r){r===void 0&&(r=[]);var i=e.call(this,t)||this;return Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:Qp.Array}),Object.defineProperty(i,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),i.hookInitializers=r,i}return Object.defineProperty(t.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var n=this.hookInitializers.length>0?this.hookInitializers.concat(e):[e];return new t(this.name,this._subType,n)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){return jm(this,e,t,n,r)}}),Object.defineProperty(t.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){t===void 0&&(t=[]);var n=e.type._subType,r={};return t.forEach(function(t,i){var a=``+i;r[a]=n.instantiate(e,a,void 0,t)}),r}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=Cp(Cp({},Km),{name:this.name});return Ut.array(Hm(e),t)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){Xi(t).dehancer=e.unbox,e.type.hookInitializers.forEach(function(e){var n=e(t);Object.keys(n).forEach(function(e){var r=n[e],i=hm(t,e,r);(gh()?ch:sh)(t,e,i)})}),Pr(t,this.willChange),Wr(t,this.didChange)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue.slice()}}),Object.defineProperty(t.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=Number(t);if(n<e.storedValue.length)return e.storedValue[n];throw new G(`Not a child: `+t)}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=Lm(e.object);t.assertWritable({subpath:``+e.index});var n=t.type._subType,r=t.getChildren();switch(e.type){case`update`:if(e.newValue===e.object[e.index])return null;var i=Gh(t,n,[r[e.index]],[e.newValue],[e.index]);if(!i)return null;e.newValue=i[0];break;case`splice`:var a=e.index,o=e.removedCount,s=e.added,c=Gh(t,n,r.slice(a,a+o),s,s.map(function(e,t){return a+t}));if(!c)return null;e.added=c;for(var l=a+o;l<r.length;l++)r[l].setParent(t,``+(l+s.length-o));break}return e}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.getChildren().map(function(e){return e.snapshot})}}),Object.defineProperty(t.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=[];return Object.keys(e).forEach(function(n){t.push(e[n].getSnapshot())}),t}}),Object.defineProperty(t.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=Lm(e.object);switch(e.type){case`update`:t.emitPatch({op:`replace`,path:``+e.index,value:e.newValue.snapshot,oldValue:e.oldValue?e.oldValue.snapshot:void 0},t);return;case`splice`:if(e.removedCount&&e.addedCount===e.object.length){t.emitPatch({op:`replace`,path:``,value:t.snapshot,oldValue:e.removed.map(function(e){return e.snapshot})},t);return}for(var n=e.removedCount-1;n>=0;n--)t.emitPatch({op:`remove`,path:``+(e.index+n),oldValue:e.removed[n].snapshot},t);for(var n=0;n<e.addedCount;n++)t.emitPatch({op:`add`,path:``+(e.index+n),value:e.added[n].snapshot,oldValue:void 0},t);return}}}),Object.defineProperty(t.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){var r=e.storedValue,i=t===`-`?r.length:Number(t);switch(n.op){case`replace`:r[i]=n.value;break;case`add`:r.splice(i,0,n.value);break;case`remove`:r.splice(i,1);break}}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!Zm(t)){Em(this,t);return}var n=e.storedValue,r=e.getChildren(),i=r.length,a=t.length,o=this.getChildType(),s=Hh(r,t,Math.min(i,a));if(!(s===i&&s===a)){if(i!==a||e.hasPatchSubscribers()){n.replace(t);return}if(Uh(o,r,t,s)){Wh(r,t,s);return}for(var c=i-1,l=a-1;c>=s&&l>=s&&r[c].snapshot===t[l];)c--,l--;var u=c>=s?c-s+1:0,d=l>=s?t.slice(s,l+1):Wm;if(u===1&&d.length===1){n[s]=d[0];return}n.splice.apply(n,Dp([s,u],Ep(d),!1))}}}),Object.defineProperty(t.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this;return Zm(e)?Tm(e.map(function(e,r){return n._subType.validate(e,Sm(t,``+r,n._subType))})):wm(t,e,`Value is not an array`)}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Wm}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue.splice(Number(t),1)}}),t}(nm);Bh.prototype.applySnapshot=ir(Bh.prototype.applySnapshot);function Vh(e){return cm(e,1),new Bh(`${e.name}[]`,e)}function Hh(e,t,n){for(var r=0;r<n&&e[r].snapshot===t[r];)r++;return r}function Uh(e,t,n,r){for(var i=r;i<t.length;i++)if(t[i].snapshot!==n[i]&&!im(e,t[i],n[i]))return!1;return!0}function Wh(e,t,n){for(var r=n;r<e.length;r++){var i=e[r];i.snapshot!==t[r]&&i.applySnapshot(t[r])}}function Gh(e,t,n,r,i){for(var a=!0,o=0;;o++){var s=o<=r.length-1,c=n[o],l=s?r[o]:void 0,u=``+i[o];if(Nm(l)&&(l=l.storedValue),!c&&!s)break;if(!s)a=!1,n.splice(o,1),c instanceof Xp&&c.createObservableInstanceIfNeeded(),c.die(),o--;else if(!c){if(Fm(l)&&Lm(l).parent===e)throw new G(`Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '${e.path}/${u}', but it lives already at '${Lm(l).path}'`);a=!1;var d=Kh(t,e,u,l);n.splice(o,0,d)}else if(qh(c,l))n[o]=Kh(t,e,u,l,c);else{for(var f=void 0,p=o;p<n.length;p++)if(qh(n[p],l)){f=n.splice(p,1)[0];break}a=!1;var d=Kh(t,e,u,l,f);n.splice(o,0,d)}}return a?null:n}function Kh(e,t,n,r,i){Em(e,r);function a(){if(Fm(r)){var a=Lm(r);if(a.assertAlive(Gm),a.parent!==null&&a.parent===t)return a.setParent(t,n),a}return i?e.reconcile(i,r,t,n):e.instantiate(t,n,void 0,r)}var o=a();return i&&i!==o&&(i instanceof Xp&&i.createObservableInstanceIfNeeded(),i.die()),o}function qh(e,t){if(!e.isAlive)return!1;if(Fm(t)){var n=Lm(t);return n.isAlive&&n===e}if(e.snapshot===t)return!0;if(!(e instanceof Xp))return!1;var r=e.getReconciliationType();return e.identifier!==null&&e.identifierAttribute&&eh(t)&&r.is(t)&&r.isMatchingSnapshotId(e,t)}var Jh=`preProcessSnapshot`,Yh=`postProcessSnapshot`;function Xh(){return Lm(this).toString()}var Zh={name:`AnonymousModel`,properties:{},initializers:Wm};function Qh(e){var t=Object.keys(e),n=new Set;return t.forEach(function(e){if(n.has(e))throw new G(`${e} is declared twice in the model. Model should not contain the same keys`);n.add(e)}),t.reduce(function(t,n){if(n in bp)throw new G(`Hook '${n}' was defined as property. Hooks should be defined as part of the actions`);var r=Object.getOwnPropertyDescriptor(e,n);if(`get`in r)throw new G(`Getters are not supported as properties. Please use views instead`);var i=r.value;if(i==null)throw new G("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if(nh(i))t[n]=Og(gg(i),i);else if(i instanceof Rh)t[n]=Og(i,{});else if(i instanceof Bh)t[n]=Og(i,[]);else if(!sm(i))throw gh()&&typeof i==`function`?new G(`Invalid type definition for property '${n}', it looks like you passed a function. Did you forget to invoke it, or did you intend to declare a view / action?`):gh()&&typeof i==`object`?new G(`Invalid type definition for property '${n}', it looks like you passed an object. Try passing another model type or a types.frozen.`):new G(`Invalid type definition for property '${n}', cannot infer a type from a value like '${i}' (${typeof i})`);return t},Cp({},e))}var $h=function(e){Sp(t,e);function t(t){var n=e.call(this,t.name||Zh.name)||this;return Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:Qp.Object}),Object.defineProperty(n,"initializers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"properties",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"preProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"postProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"propertyNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"named",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return n.cloneAndEnhance({name:e})}}),Object.defineProperty(n,"props",{enumerable:!0,configurable:!0,writable:!0,value:function(e){return n.cloneAndEnhance({properties:e})}}),Object.defineProperty(n,"preProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=n.preProcessor;return t?n.cloneAndEnhance({preProcessor:function(n){return t(e(n))}}):n.cloneAndEnhance({preProcessor:e})}}),Object.defineProperty(n,"postProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(e){var t=n.postProcessor;return t?n.cloneAndEnhance({postProcessor:function(n){return e(t(n))}}):n.cloneAndEnhance({postProcessor:e})}}),Object.assign(n,Zh,t),n.properties=Qh(n.properties),rh(n.properties),n.propertyNames=Object.keys(n.properties),n.identifierAttribute=n._getIdentifierAttribute(),n}return Object.defineProperty(t.prototype,"_getIdentifierAttribute",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=void 0;return this.forAllProps(function(t,n){if(n.flags&Qp.Identifier){if(e)throw new G(`Cannot define property '${t}' as object identifier, property '${e}' is already defined as identifier property`);e=t}}),e}}),Object.defineProperty(t.prototype,"cloneAndEnhance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return new t({name:e.name||this.name,properties:Object.assign({},this.properties,e.properties),initializers:this.initializers.concat(e.initializers||[]),preProcessor:e.preProcessor||this.preProcessor,postProcessor:e.postProcessor||this.postProcessor})}}),Object.defineProperty(t.prototype,"actions",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(n){return t.instantiateActions(n,e(n)),n}]})}}),Object.defineProperty(t.prototype,"instantiateActions",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this;if(!eh(t))throw new G(`actions initializer should return a plain object containing actions`);Object.getOwnPropertyNames(t).forEach(function(r){if(r in n.properties)throw new G(`'${r}' is a property and cannot be declared as an action`);if(r===Jh)throw new G(`Cannot define action '${Jh}', it should be defined using 'type.preProcessSnapshot(fn)' instead`);if(r===Yh)throw new G(`Cannot define action '${Yh}', it should be defined using 'type.postProcessSnapshot(fn)' instead`);var i=t[r],a=e[r];if(r in bp&&a){var o=i;i=function(){a.apply(null,arguments),o.apply(null,arguments)}}var s=i.$mst_middleware,c=i.bind(t);c._isFlowAction=i._isFlowAction||!1,c.$mst_middleware=s;var l=hm(e,r,c);t[r]=l,(gh()?ch:sh)(e,r,l)})}}),Object.defineProperty(t.prototype,"volatile",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;if(typeof e!=`function`)throw new G(`You passed an ${typeof e} to volatile state as an argument, when function is expected`);return this.cloneAndEnhance({initializers:[function(n){return t.instantiateVolatileState(n,e(n)),n}]})}}),Object.defineProperty(t.prototype,"instantiateVolatileState",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this;if(!eh(t))throw new G(`volatile state initializer should return a plain object containing state`);Object.getOwnPropertyNames(t).forEach(function(r){if(r in n.properties)throw new G(`'${r}' is a property and cannot be declared as volatile state`);Hr(e,r,t[r])})}}),Object.defineProperty(t.prototype,"extend",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(n){var r=e(n),i=r.actions,a=r.views,o=r.state;for(var s in wp(r,[`actions`,`views`,`state`]))throw new G(`The \`extend\` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '${s}'`);return o&&t.instantiateVolatileState(n,o),a&&t.instantiateViews(n,a),i&&t.instantiateActions(n,i),n}]})}}),Object.defineProperty(t.prototype,"views",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;return this.cloneAndEnhance({initializers:[function(n){return t.instantiateViews(n,e(n)),n}]})}}),Object.defineProperty(t.prototype,"instantiateViews",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this;if(!eh(t))throw new G(`views initializer should return a plain object containing views`);Object.getOwnPropertyNames(t).forEach(function(r){var i;if(r in n.properties)throw new G(`'${r}' is a property and cannot be declared as a view`);var a=Object.getOwnPropertyDescriptor(t,r);if(`get`in a)Ur(e,r,a),oi(e,(i={},i[r]=Jt,i));else if(typeof a.value==`function`)(gh()?ch:sh)(e,r,a.value);else throw new G(`A view member should either be a function or getter based property`)})}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){var i=Fm(r)?r:this.applySnapshotPreProcessor(r);return jm(this,e,t,n,i)}}),Object.defineProperty(t.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){t===void 0&&(t={});var n=e.type,r={};return n.forAllProps(function(n,i){r[n]=i.instantiate(e,n,void 0,t[n])}),r}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=Cp(Cp({},Km),{name:this.name});return Ut.object(e,Gm,t)}}),Object.defineProperty(t.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){sh(t,`toString`,Xh),this.forAllProps(function(n){Nr(t,n,e.unbox)}),this.initializers.reduce(function(e,t){return t(e)},t),Pr(t,this.willChange),Wr(t,this.didChange)}}),Object.defineProperty(t.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e,n=Lm(t.object),r=t.name;n.assertWritable({subpath:r});var i=n.type.properties[r];return i&&(Em(i,t.newValue),t.newValue=i.reconcile(n.getChildNode(r),t.newValue,n,r)),t}}),Object.defineProperty(t.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=e,n=Lm(t.object);if(n.type.properties[t.name]){var r=t.oldValue?t.oldValue.snapshot:void 0;n.emitPatch({op:`replace`,path:Eh(t.name),value:t.newValue.snapshot,oldValue:r},n)}}}),Object.defineProperty(t.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this,n=[];return this.forAllProps(function(r){n.push(t.getChildNode(e,r))}),n}}),Object.defineProperty(t.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(!(t in this.properties))throw new G(`Not a value property: `+t);var n=Xi(e.storedValue,t),r=n.raw?.call(n);if(!r)throw new G(`Node not available for property `+t);return r}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this;t===void 0&&(t=!0);var r={};return this.forAllProps(function(t,i){Yi(e.storedValue,t).reportObserved(),r[t]=n.getChildNode(e,t).snapshot}),t?this.applySnapshotPostProcessor(r):r}}),Object.defineProperty(t.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t={};return Object.keys(e).forEach(function(n){t[n]=e[n].getSnapshot()}),this.applySnapshotPostProcessor(t)}}),Object.defineProperty(t.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){if(!(n.op===`replace`||n.op===`add`))throw new G(`object does not support operation ${n.op}`);e.storedValue[t]=n.value}}),Object.defineProperty(t.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this.applySnapshotPreProcessor(t),r=!eh(n);(!eh(t)||r)&&(Em(this,t),r)||this.forAllProps(function(t,r){var i=e.getChildNode(t),a=n[t];if(i.snapshot!==a){if(im(r,i,a)){i.applySnapshot(a);return}e.storedValue[t]=a}})}}),Object.defineProperty(t.prototype,"applySnapshotPreProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.preProcessor;return t?t.call(null,e):e}}),Object.defineProperty(t.prototype,"applySnapshotPostProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.postProcessor;return t?t.call(null,e):e}}),Object.defineProperty(t.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return bh(e,1),this.properties[e]}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this,r=this.applySnapshotPreProcessor(e);return eh(r)?Tm(this.propertyNames.map(function(e){return n.properties[e].validate(r[e],Sm(t,e,n.properties[e]))})):wm(t,r,`Value is not a plain object`)}}),Object.defineProperty(t.prototype,"forAllProps",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this;this.propertyNames.forEach(function(n){return e(n,t.properties[n])})}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this;return`{ `+this.propertyNames.map(function(t){return t+`: `+e.properties[t].describe()}).join(`; `)+` }`}}),Object.defineProperty(t.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return Gm}}),Object.defineProperty(t.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){e.storedValue[t]=void 0}}),t}(nm);$h.prototype.applySnapshot=ir($h.prototype.applySnapshot);function eg(){var e=[...arguments];if(gh()&&typeof e[0]!=`string`&&e[1])throw new G(`Model creation failed. First argument must be a string when two arguments are provided`);return new $h({name:typeof e[0]==`string`?e.shift():`AnonymousModel`,properties:e.shift()||{}})}function tg(){var e=[...arguments],t=typeof e[0]==`string`,n=t?e[0]:`AnonymousModel`;return t&&e.shift(),gh()&&e.forEach(function(e,n){_h(e,ng,`mobx-state-tree model type`,t?n+2:n+1)}),e.reduce(function(e,t){return e.cloneAndEnhance({name:e.name+`_`+t.name,properties:t.properties,initializers:t.initializers,preProcessor:function(n){return t.applySnapshotPreProcessor(e.applySnapshotPreProcessor(n))},postProcessor:function(n){return t.applySnapshotPostProcessor(e.applySnapshotPostProcessor(n))}})}).named(n)}function ng(e){return sm(e)&&(e.flags&Qp.Object)>0}var rg=function(e){Sp(t,e);function t(t,n,r,i){i===void 0&&(i=qm);var a=e.call(this,t)||this;return Object.defineProperty(a,"flags",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"checker",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"initializer",{enumerable:!0,configurable:!0,writable:!0,value:i}),a.flags=n,a}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){return Mm(this,e,t,n,r)}}),Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.initializer(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return nh(e)&&this.checker(e)?Cm():wm(t,e,`Value is not a ${this.name===`Date`?`Date or a unix milliseconds timestamp`:this.name}`)}}),t}(rm),ig=new rg(`string`,Qp.String,function(e){return typeof e==`string`}),ag=new rg(`number`,Qp.Number,function(e){return typeof e==`number`}),og=new rg(`integer`,Qp.Integer,function(e){return Jm(e)}),sg=new rg(`float`,Qp.Float,function(e){return Ym(e)}),cg=new rg(`finite`,Qp.Finite,function(e){return Xm(e)}),lg=new rg(`bigint`,Qp.BigInt,function(e){if(typeof e==`bigint`)return!0;if(typeof e==`string`||typeof e==`number`)try{return BigInt(e),!0}catch{}return!1},function(e){return typeof e==`bigint`?e:BigInt(e)});lg.getSnapshot=function(e){return String(e.storedValue)};var ug=lg,dg=new rg(`boolean`,Qp.Boolean,function(e){return typeof e==`boolean`}),fg=new rg(`null`,Qp.Null,function(e){return e===null}),pg=new rg(`undefined`,Qp.Undefined,function(e){return e===void 0}),mg=new rg(`Date`,Qp.Date,function(e){return typeof e==`number`||e instanceof Date},function(e){return e instanceof Date?e:new Date(e)});mg.getSnapshot=function(e){return e.storedValue.getTime()};var hg=mg;function gg(e){switch(typeof e){case`string`:return ig;case`number`:return ag;case`boolean`:return dg;case`bigint`:return ug;case`object`:if(e instanceof Date)return hg}throw new G(`Cannot determine primitive type from value `+e)}function _g(e){return sm(e)&&(e.flags&(Qp.String|Qp.Number|Qp.Integer|Qp.Boolean|Qp.Date|Qp.BigInt))>0}var vg=function(e){Sp(t,e);function t(t){var n=e.call(this,JSON.stringify(t))||this;return Object.defineProperty(n,"value",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:Qp.Literal}),n.value=t,n}return Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){return Mm(this,e,t,n,r)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return JSON.stringify(this.value)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return nh(e)&&e===this.value?Cm():wm(t,e,`Value is not a literal ${JSON.stringify(this.value)}`)}}),t}(rm);function yg(e){return _h(e,nh,`primitive`,1),new vg(e)}var bg=function(e){Sp(t,e);function t(t,n,r,i){var a=e.call(this,t)||this;return Object.defineProperty(a,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_predicate",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(a,"_message",{enumerable:!0,configurable:!0,writable:!0,value:i}),a}return Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|Qp.Refinement},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){return this._subtype.instantiate(e,t,n,r)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this._subtype.validate(e,t);if(n.length>0)return n;var r=Fm(e)?Lm(e).snapshot:e;return this._predicate(r)?Cm():wm(t,e,this._message(e))}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){return this._subtype.reconcile(e,t,n,r)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t}(tm);function xg(){var e=[...arguments],t=typeof e[0]==`string`?e.shift():sm(e[0])?e[0].name:null,n=e[0],r=e[1],i=e[2]?e[2]:function(e){return`Value does not respect the refinement predicate`};return cm(n,[1,2]),bh(t,1),vh(r,[2,3]),vh(i,[3,4]),new bg(t,n,r,i)}function Sg(e,t){var n=typeof e==`string`?t:e;gh()&&n.forEach(function(e,t){bh(e,t+1)});var r=wg.apply(void 0,Dp([],Ep(n.map(function(e){return yg(``+e)})),!1));return typeof e==`string`&&(r.name=e),r}var Cg=function(e){Sp(t,e);function t(t,n,r){var i=e.call(this,t)||this;return Object.defineProperty(i,"_types",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"_dispatcher",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(i,"_eager",{enumerable:!0,configurable:!0,writable:!0,value:!0}),r=Cp({eager:!0,dispatcher:void 0},r),i._dispatcher=r.dispatcher,r.eager||(i._eager=!1),i}return Object.defineProperty(t.prototype,"flags",{get:function(){var e=Qp.Union;return this._types.forEach(function(t){e|=t.flags}),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._types.some(function(t){return t.isAssignableFrom(e)})}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return`(`+this._types.map(function(e){return e.describe()}).join(` | `)+`)`}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){var i=this.determineType(r,void 0);if(!i)throw new G(`No matching type for union `+this.describe());return i.instantiate(e,t,n,r)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){var i=this.determineType(t,e.getReconciliationType());if(!i)throw new G(`No matching type for union `+this.describe());return i.reconcile(e,t,n,r)}}),Object.defineProperty(t.prototype,"determineType",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this._dispatcher?this._dispatcher(e):t?t.is(e)?t:this._types.filter(function(e){return e!==t}).find(function(t){return t.is(e)}):this._types.find(function(t){return t.is(e)})}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this._dispatcher)return this._dispatcher(e).validate(e,t);for(var n=[],r=0,i=0;i<this._types.length;i++){var a=this._types[i].validate(e,t);if(a.length===0){if(this._eager)return Cm();r++}else n.push(a)}return r===1?Cm():wm(t,e,`No type is applicable for the union`).concat(Tm(n))}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._types}}),t}(tm);function wg(e){var t=[...arguments].slice(1),n=sm(e)?void 0:e,r=sm(e)?Dp([e],Ep(t),!1):t,i=`(`+r.map(function(e){return e.name}).join(` | `)+`)`;return gh()&&(n&&_h(n,function(e){return eh(e)},`object { eager?: boolean, dispatcher?: Function }`,1),r.forEach(function(e,t){cm(e,n?t+2:t+1)})),new Cg(i,r,n)}function Tg(e){return sm(e)&&(e.flags&Qp.Union)>0}var Eg=function(e){Sp(t,e);function t(t,n,r){var i=e.call(this,t.name)||this;return Object.defineProperty(i,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"_defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"optionalValues",{enumerable:!0,configurable:!0,writable:!0,value:r}),i}return Object.defineProperty(t.prototype,"flags",{get:function(){return this._subtype.flags|Qp.Optional},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype.describe()+`?`}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){if(this.optionalValues.indexOf(r)>=0){var i=this.getDefaultInstanceOrSnapshot();return this._subtype.instantiate(e,t,n,i)}return this._subtype.instantiate(e,t,n,r)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){return this._subtype.reconcile(e,this.optionalValues.indexOf(t)<0&&this._subtype.is(t)?t:this.getDefaultInstanceOrSnapshot(),n,r)}}),Object.defineProperty(t.prototype,"getDefaultInstanceOrSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=typeof this._defaultValue==`function`?this._defaultValue():this._defaultValue;return typeof this._defaultValue==`function`&&Em(this,e),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this.optionalValues.indexOf(e)>=0?Cm():this._subtype.validate(e,t)}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this._subtype.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),t}(tm);function Dg(e,t){if(typeof t!=`function`&&Fm(t))throw new G(`default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead`);cm(e,1),gh()&&typeof t!=`function`&&Em(e,t)}function Og(e,t,n){return Dg(e,t),new Eg(e,t,n||kg)}var kg=[void 0],Ag=Og(pg,void 0),jg=Og(fg,null);function Mg(e){return cm(e,1),wg(e,Ag)}function Ng(e){return cm(e,1),wg(e,jg)}var Pg=function(e){Sp(t,e);function t(t,n){var r=e.call(this,t)||this;return Object.defineProperty(r,"_definition",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(r,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),r}return Object.defineProperty(t.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|Qp.Late},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"getSubType",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(!this._subType){var t=void 0;try{t=this._definition()}catch(e){if(e instanceof ReferenceError)t=void 0;else throw e}if(e&&t===void 0)throw new G(`Late type seems to be used too early, the definition (still) returns undefined`);if(t){if(gh()&&!sm(t))throw new G(`Failed to determine subtype, make sure types.late returns a type definition.`);this._subType=t}}return this._subType}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){return this.getSubType(!0).instantiate(e,t,n,r)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){return this.getSubType(!0).reconcile(e,t,n,r)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var e=this.getSubType(!1);return e?e.name:`<uknown late type>`}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this.getSubType(!1);return n?n.validate(e,t):Cm()}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=this.getSubType(!1);return t?t.isAssignableFrom(e):!1}}),Object.defineProperty(t.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.getSubType(!1)||$p}}),t}(tm);function Fg(e,t){var n=typeof e==`string`?e:`late(${e.toString()})`,r=typeof e==`string`?t:e;if(gh()&&!(typeof r==`function`&&r.length===0))throw new G(`Invalid late type, expected a function with zero arguments that returns a type, got: `+r);return new Pg(n,r)}function Ig(e,t){return new Lg(e,t)}var Lg=function(e){Sp(t,e);function t(t,n){var r=e.call(this,t)||this;return Object.defineProperty(r,"options",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:Qp.Lazy}),Object.defineProperty(r,"loadedType",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(r,"pendingNodeList",{enumerable:!0,configurable:!0,writable:!0,value:Ut.array()}),Jr(function(){return r.pendingNodeList.length>0&&r.pendingNodeList.some(function(e){return e.isAlive&&r.options.shouldLoadPredicate(e.parent?e.parent.value:null)})},function(){r.options.loadType().then(ir(function(e){r.loadedType=e,r.pendingNodeList.forEach(function(e){e.parent&&r.loadedType&&e.parent.applyPatches([{op:`replace`,path:`/${e.subpath}`,value:e.snapshot}])})}))}),r}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return`<lazy ${this.name}>`}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){var i=this;if(this.loadedType)return this.loadedType.instantiate(e,t,n,r);var a=Mm(this,e,t,n,ih(r));return this.pendingNodeList.push(a),Jr(function(){return!a.isAlive},function(){return i.pendingNodeList.splice(i.pendingNodeList.indexOf(a),1)}),a}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return this.loadedType?this.loadedType.validate(e,t):ah(e)?Cm():wm(t,e,`Value is not serializable and cannot be lazy`)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,r,i){return this.loadedType?(t.die(),this.loadedType.instantiate(r,i,r.environment,n)):e.prototype.reconcile.call(this,t,n,r,i)}}),t}(rm),Rg=function(e){Sp(t,e);function t(t){var n=e.call(this,t?`frozen(${t.name})`:`frozen`)||this;return Object.defineProperty(n,"subType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:Qp.Frozen}),n}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return`<any immutable value>`}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){return Mm(this,e,t,n,ih(r))}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return ah(e)?this.subType?this.subType.validate(e,t):Cm():wm(t,e,`Value is not serializable and cannot be frozen`)}}),t}(rm),zg=new Rg;function Bg(e){return arguments.length===0?zg:sm(e)?new Rg(e):Og(zg,e)}function Vg(e){switch(e){case bp.beforeDestroy:return`destroy`;case bp.beforeDetach:return`detach`;default:return}}var Hg=function(){function e(e,t){if(Object.defineProperty(this,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"node",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"resolvedReference",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n_(e))this.identifier=e;else if(Fm(e)){var n=Lm(e);if(!n.identifierAttribute)throw new G(`Can only store references with a defined identifier attribute.`);var r=n.unnormalizedIdentifier;if(r==null)throw new G(`Can only store references to tree nodes with a defined identifier.`);this.identifier=r}else throw new G(`Can only store references to tree nodes or identifiers, got: '${e}'`)}return Object.defineProperty(e.prototype,"updateResolvedReference",{enumerable:!1,configurable:!0,writable:!0,value:function(e){var t=t_(this.identifier),n=e.root,r=n.identifierCache.getLastCacheModificationPerId(t);if(!this.resolvedReference||this.resolvedReference.lastCacheModification!==r){var i=this.targetType,a=n.identifierCache.resolve(i,t);if(!a)throw new Ug(`[mobx-state-tree] Failed to resolve reference '${this.identifier}' to type '${this.targetType.name}' (from node: ${e.path})`);this.resolvedReference={node:a,lastCacheModification:r}}}}),Object.defineProperty(e.prototype,"resolvedValue",{get:function(){return this.updateResolvedReference(this.node),this.resolvedReference.node.value},enumerable:!1,configurable:!0}),e}(),Ug=function(e){Sp(t,e);function t(n){var r=e.call(this,n)||this;return Object.setPrototypeOf(r,t.prototype),r}return t}(Error),Wg=function(e){Sp(t,e);function t(t,n){var r=e.call(this,`reference(${t.name})`)||this;return Object.defineProperty(r,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(r,"onInvalidated",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:Qp.Reference}),r}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.targetType.isAssignableFrom(e)}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return n_(e)?Cm():wm(t,e,`Value is not a valid identifier, which is a string, number or a bigint`)}}),Object.defineProperty(t.prototype,"fireInvalidated",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){var i=t.parent;if(!(!i||!i.isAlive)){var a=i.storedValue;a&&this.onInvalidated({cause:e,parent:a,invalidTarget:r?r.storedValue:void 0,invalidId:n,replaceRef:function(e){Ap(t.root.storedValue,{op:`replace`,value:e,path:t.path})},removeRef:function(){ng(i.type)?this.replaceRef(void 0):Ap(t.root.storedValue,{op:`remove`,path:t.path})}})}}}),Object.defineProperty(t.prototype,"addTargetNodeWatcher",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){var n=this,r=this.getValue(e);if(r){var i=Lm(r),a=function(r,a){var o=Vg(a);o&&n.fireInvalidated(o,e,t,i)},o=i.registerHook(bp.beforeDetach,a),s=i.registerHook(bp.beforeDestroy,a);return function(){o(),s()}}}}),Object.defineProperty(t.prototype,"watchTargetNodeForInvalidations",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n){var r=this;if(this.onInvalidated){var i;e.registerHook(bp.beforeDestroy,function(){i&&i()});var a=function(){var n=function(){e.isAlive&&r.getSnapshot(e)===t&&o(!1)};dm()?e.root.enqueueEndOfAction(n):xh(n)},o=function(o){i&&i();var s=e.parent,c=s&&s.storedValue;if(s&&s.isAlive&&c){var l=void 0;l=n?!!n.get(t,c):e.root.identifierCache.has(r.targetType,t_(t)),l?i=r.addTargetNodeWatcher(e,t):o?a():r.fireInvalidated(`invalidSnapshotReference`,e,t,null)}};e.state===Pm.FINALIZED?o(!0):(e.isRoot||e.root.registerHook(bp.afterCreationFinalization,function(){e.parent&&e.parent.createObservableInstanceIfNeeded()}),e.registerHook(bp.afterAttach,function(){o(!1)}))}}}),t}(rm),Gg=function(e){Sp(t,e);function t(t,n){return e.call(this,t,n)||this}return Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.isAlive)return e.storedValue.resolvedValue}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue.identifier}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){var i=Fm(r)?zp(r):r,a=new Hg(r,this.targetType),o=Mm(this,e,t,n,a);return a.node=o,this.watchTargetNodeForInvalidations(o,i,void 0),o}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){if(!e.isDetaching&&e.type===this){var i=Fm(t),a=e.storedValue;if(!i&&a.identifier===t||i&&a.resolvedValue===t)return e.setParent(n,r),e}var o=this.instantiate(n,r,void 0,t);return e.die(),o}}),t}(Wg),Kg=function(e){Sp(t,e);function t(t,n,r){var i=e.call(this,t,r)||this;return Object.defineProperty(i,"options",{enumerable:!0,configurable:!0,writable:!0,value:n}),i}return Object.defineProperty(t.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(e.isAlive)return this.options.get(e.storedValue,e.parent?e.parent.storedValue:null)}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){var i=Fm(r)?this.options.set(r,e?e.storedValue:null):r,a=Mm(this,e,t,n,i);return this.watchTargetNodeForInvalidations(a,i,this.options),a}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){var i=Fm(t)?this.options.set(t,e?e.storedValue:null):t;if(!e.isDetaching&&e.type===this&&e.storedValue===i)return e.setParent(n,r),e;var a=this.instantiate(n,r,void 0,i);return e.die(),a}}),t}(Wg);function qg(e,t){if(cm(e,1),gh()&&arguments.length===2&&typeof arguments[1]==`string`)throw new G(`References with base path are no longer supported. Please remove the base path.`);var n=t||void 0,r=t?t.onInvalidated:void 0;if(n&&(n.get||n.set)){if(gh()&&(!n.get||!n.set))throw new G(`reference options must either contain both a 'get' and a 'set' method or none of them`);return new Kg(e,{get:n.get,set:n.set},r)}else return new Gg(e,r)}function Jg(e,t){var n=qg(e,Cp(Cp({},t),{onInvalidated:function(e){t&&t.onInvalidated&&t.onInvalidated(e),e.removeRef()}}));return t&&t.acceptsUndefined===!1?n:Mg(n)}var Yg=function(e){Sp(t,e);function t(t,n){var r=e.call(this,t)||this;return Object.defineProperty(r,"validType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(r,"flags",{enumerable:!0,configurable:!0,writable:!0,value:Qp.Identifier}),r}return Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){if(!e||!(e.type instanceof $h))throw new G(`Identifier types can only be instantiated as direct child of a model type`);return Mm(this,e,t,n,r)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){if(e.storedValue!==t)throw new G(`Tried to change identifier from '${e.storedValue}' to '${t}'. Changing identifiers is not allowed.`);return e.setParent(n,r),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){return typeof e===this.validType?Cm():wm(t,e,`Value is not a valid ${this.describe()}, expected a ${this.validType}`)}}),t}(rm),Xg=function(e){Sp(t,e);function t(){var t=e.call(this,`identifier`,`string`)||this;return Object.defineProperty(t,"flags",{enumerable:!0,configurable:!0,writable:!0,value:Qp.Identifier}),t}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return`identifier`}}),t}(Yg),Zg=function(e){Sp(t,e);function t(){return e.call(this,`identifierNumber`,`number`)||this}return Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return e.storedValue}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return`identifierNumber`}}),t}(Yg),Qg=new Xg,$g=new Zg,e_=new(function(e){Sp(t,e);function t(){var t=e.call(this,`identifierBigint`)||this;return Object.defineProperty(t,"flags",{enumerable:!0,configurable:!0,writable:!0,value:Qp.Identifier}),t}return Object.defineProperty(t.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return typeof e==`bigint`?e:BigInt(e)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){if(!e||!(e.type instanceof $h))throw new G(`Identifier types can only be instantiated as direct child of a model type`);return Mm(this,e,t,n,r)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){var i=e.storedValue,a=typeof t==`bigint`?t:BigInt(t);if(i!==a)throw new G(`Tried to change identifier from '${i}' to '${a}'. Changing identifiers is not allowed.`);return e.setParent(n,r),e}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(typeof e==`bigint`)return Cm();if(typeof e==`string`||typeof e==`number`)try{return BigInt(e),Cm()}catch(r){var n=r instanceof Error?r.message:String(r);return wm(t,e,`Value is not a valid ${this.describe()}: ${n}`)}return wm(t,e,`Value is not a valid ${this.describe()}, expected a bigint, a string or a number`)}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return String(e.storedValue)}}),Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return`identifierBigint`}}),t}(rm));function t_(e){return``+e}function n_(e){return typeof e==`string`||typeof e==`number`||typeof e==`bigint`}function r_(e){return new i_(e)}var i_=function(e){Sp(t,e);function t(t){var n=e.call(this,t.name)||this;return Object.defineProperty(n,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:Qp.Custom}),n}return Object.defineProperty(t.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(t.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t){if(this.options.isTargetType(e))return Cm();var n=this.options.getValidationMessage(e);return n?wm(t,e,`Invalid value for type '${this.name}': ${n}`):Cm()}}),Object.defineProperty(t.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(e){return this.options.toSnapshot(e.storedValue)}}),Object.defineProperty(t.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){var i=this.options.isTargetType(r)?r:this.options.fromSnapshot(r,e&&e.root.environment);return Mm(this,e,t,n,i)}}),Object.defineProperty(t.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(e,t,n,r){var i=!this.options.isTargetType(t);if(!e.isDetaching&&e.type===this&&(i?t===e.snapshot:t===e.storedValue))return e.setParent(n,r),e;var a=i?this.options.fromSnapshot(t,n.root.environment):t,o=this.instantiate(n,r,void 0,a);return e.die(),o}}),t}(rm),K={enumeration:Sg,model:eg,compose:tg,custom:r_,reference:qg,safeReference:Jg,union:wg,optional:Og,literal:yg,maybe:Mg,maybeNull:Ng,refinement:xg,string:ig,boolean:dg,number:ag,integer:og,float:sg,finite:cg,bigint:ug,Date:hg,map:zh,array:Vh,frozen:Bg,identifier:Qg,identifierNumber:$g,identifierBigint:e_,late:Fg,lazy:Ig,undefined:pg,null:fg,snapshotProcessor:Nh},a_=function(e,t){if(e===t)return!0;if(typeof e==`object`&&e&&typeof t==`object`&&t){if(Object.keys(e).length!=Object.keys(t).length)return!1;for(var n in e)if(!t.hasOwnProperty(n)||!a_(e[n],t[n]))return!1;return!0}return!1};Object.assign(K);var o_=K.model(`UndoManager`,{history:K.array(K.frozen()),undoIdx:-1,targetPath:``}).views(e=>({get canUndo(){return e.undoIdx>0},get canRedo(){return e.undoIdx<e.history.length-1}})).actions(e=>{let t,n,r=!1,i=null,a=0,o=0,s=()=>o>0;function c(){let e=Mp(t);return{pages:e.pages,width:e.width,height:e.height,custom:e.custom,audios:e.audios}}function l(e){let n=!a_(t.pages.map(e=>e.id),e.pages.map(e=>e.id)),r=!a_(t.custom,e.custom);n?jp(t.pages,e.pages):t.pages.forEach((t,n)=>{jp(t,e.pages[n])}),r&&t.set({custom:e.custom}),t.setSize(e.width,e.height)}let u={startTransaction(){o++},endTransaction(e){o--,e||u.requestAddState(c())},async ignore(e,t=!1,n=!1){n&&await new Promise(e=>setTimeout(e,10));let r=!!a;a&&u.addUndoState();let i=s();u.startTransaction();let c=o;try{await e()}catch(e){setTimeout(()=>{throw e})}let l=c!==o,d=!l;u.endTransaction(d),t||i&&!r||u.replaceState(),l||(clearTimeout(a),a=0)},async transaction(e){await u.ignore(e,!0),u.addUndoState()},requestAddState(e){i=e,a||s()||(r?r=!1:a=setTimeout(()=>{a=0,clearTimeout(a),s()||u.addUndoState()},100))},addUndoState(){if(r){r=!1;return}let t=e.history[e.undoIdx];!a_(i,t)&&(clearTimeout(a),a=0,e.history.splice(e.undoIdx+1),e.history.push(i),e.undoIdx=e.history.length-1)},afterCreate(){if(t=Rp(e,`..`),!t)throw Error("Failed to find target store for UndoManager. Please provide `targetPath` property, or a `targetStore` in the environment");n=kp(t,()=>{u.requestAddState(c())}),e.history.length===0&&u.requestAddState(c())},clear(){clearTimeout(a),a=0,e.history.splice(0,e.history.length),e.undoIdx=-1,u.addUndoState()},beforeDestroy(){n()},undo(){a&&u.addUndoState(),s()?l(e.history[e.undoIdx]):e.canUndo?(e.undoIdx--,r=!0,l(e.history[e.undoIdx])):console.warn("No undo history. Please check `store.history.canUndo` before calling undo action.")},redo(){a&&u.addUndoState(),e.canRedo?(e.undoIdx++,r=!0,l(e.history[e.undoIdx])):console.warn("No redo history. Please check `store.history.canRedo` before calling redo action.")},replaceState(){e.history[e.undoIdx]=c()}};return u}),s_=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,c_=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=s_[n[e]&63];return t};async function l_(e,t){let n=await(await fetch(e)).blob(),r=document.createElement(`a`),i=URL.createObjectURL(n);r.href=i,r.download=t,document.body.appendChild(r),r.click(),setTimeout(function(){document.body.removeChild(r),window.URL.revokeObjectURL(i)},0)}var u_=null;function d_(){return window.jspdf?.jsPDF?Promise.resolve(window.jspdf.jsPDF):u_||(typeof window.__polotnoLoadJspdf==`function`?(u_=window.__polotnoLoadJspdf().then(e=>e?.jsPDF||e),u_):(u_=new Promise(e=>{var t=document.createElement(`script`);t.onload=function(){e(window.jspdf.jsPDF)},t.src=`https://cdnjs.cloudflare.com/ajax/libs/jspdf/3.0.1/jspdf.umd.min.js`,document.head.appendChild(t)}),u_))}function f_(){return window.GIF?Promise.resolve(window.GIF):new Promise(e=>{var t=document.createElement(`script`);t.onload=function(){e(window.GIF)},t.src=`https://cdnjs.cloudflare.com/ajax/libs/gif.js/0.2.0/gif.js`,document.head.appendChild(t)})}async function p_({width:e,height:t}){return new(await(f_()))({workers:4,width:e,height:t,workerScript:URL.createObjectURL(new Blob([`// gif.worker.js 0.2.0 - https://github.com/jnordberg/gif.js
|
|
48
|
+
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){var NeuQuant=require("./TypedNeuQuant.js");var LZWEncoder=require("./LZWEncoder.js");function ByteArray(){this.page=-1;this.pages=[];this.newPage()}ByteArray.pageSize=4096;ByteArray.charMap={};for(var i=0;i<256;i++)ByteArray.charMap[i]=String.fromCharCode(i);ByteArray.prototype.newPage=function(){this.pages[++this.page]=new Uint8Array(ByteArray.pageSize);this.cursor=0};ByteArray.prototype.getData=function(){var rv="";for(var p=0;p<this.pages.length;p++){for(var i=0;i<ByteArray.pageSize;i++){rv+=ByteArray.charMap[this.pages[p][i]]}}return rv};ByteArray.prototype.writeByte=function(val){if(this.cursor>=ByteArray.pageSize)this.newPage();this.pages[this.page][this.cursor++]=val};ByteArray.prototype.writeUTFBytes=function(string){for(var l=string.length,i=0;i<l;i++)this.writeByte(string.charCodeAt(i))};ByteArray.prototype.writeBytes=function(array,offset,length){for(var l=length||array.length,i=offset||0;i<l;i++)this.writeByte(array[i])};function GIFEncoder(width,height){this.width=~~width;this.height=~~height;this.transparent=null;this.transIndex=0;this.repeat=-1;this.delay=0;this.image=null;this.pixels=null;this.indexedPixels=null;this.colorDepth=null;this.colorTab=null;this.neuQuant=null;this.usedEntry=new Array;this.palSize=7;this.dispose=-1;this.firstFrame=true;this.sample=10;this.dither=false;this.globalPalette=false;this.out=new ByteArray}GIFEncoder.prototype.setDelay=function(milliseconds){this.delay=Math.round(milliseconds/10)};GIFEncoder.prototype.setFrameRate=function(fps){this.delay=Math.round(100/fps)};GIFEncoder.prototype.setDispose=function(disposalCode){if(disposalCode>=0)this.dispose=disposalCode};GIFEncoder.prototype.setRepeat=function(repeat){this.repeat=repeat};GIFEncoder.prototype.setTransparent=function(color){this.transparent=color};GIFEncoder.prototype.addFrame=function(imageData){this.image=imageData;this.colorTab=this.globalPalette&&this.globalPalette.slice?this.globalPalette:null;this.getImagePixels();this.analyzePixels();if(this.globalPalette===true)this.globalPalette=this.colorTab;if(this.firstFrame){this.writeLSD();this.writePalette();if(this.repeat>=0){this.writeNetscapeExt()}}this.writeGraphicCtrlExt();this.writeImageDesc();if(!this.firstFrame&&!this.globalPalette)this.writePalette();this.writePixels();this.firstFrame=false};GIFEncoder.prototype.finish=function(){this.out.writeByte(59)};GIFEncoder.prototype.setQuality=function(quality){if(quality<1)quality=1;this.sample=quality};GIFEncoder.prototype.setDither=function(dither){if(dither===true)dither="FloydSteinberg";this.dither=dither};GIFEncoder.prototype.setGlobalPalette=function(palette){this.globalPalette=palette};GIFEncoder.prototype.getGlobalPalette=function(){return this.globalPalette&&this.globalPalette.slice&&this.globalPalette.slice(0)||this.globalPalette};GIFEncoder.prototype.writeHeader=function(){this.out.writeUTFBytes("GIF89a")};GIFEncoder.prototype.analyzePixels=function(){if(!this.colorTab){this.neuQuant=new NeuQuant(this.pixels,this.sample);this.neuQuant.buildColormap();this.colorTab=this.neuQuant.getColormap()}if(this.dither){this.ditherPixels(this.dither.replace("-serpentine",""),this.dither.match(/-serpentine/)!==null)}else{this.indexPixels()}this.pixels=null;this.colorDepth=8;this.palSize=7;if(this.transparent!==null){this.transIndex=this.findClosest(this.transparent,true)}};GIFEncoder.prototype.indexPixels=function(imgq){var nPix=this.pixels.length/3;this.indexedPixels=new Uint8Array(nPix);var k=0;for(var j=0;j<nPix;j++){var index=this.findClosestRGB(this.pixels[k++]&255,this.pixels[k++]&255,this.pixels[k++]&255);this.usedEntry[index]=true;this.indexedPixels[j]=index}};GIFEncoder.prototype.ditherPixels=function(kernel,serpentine){var kernels={FalseFloydSteinberg:[[3/8,1,0],[3/8,0,1],[2/8,1,1]],FloydSteinberg:[[7/16,1,0],[3/16,-1,1],[5/16,0,1],[1/16,1,1]],Stucki:[[8/42,1,0],[4/42,2,0],[2/42,-2,1],[4/42,-1,1],[8/42,0,1],[4/42,1,1],[2/42,2,1],[1/42,-2,2],[2/42,-1,2],[4/42,0,2],[2/42,1,2],[1/42,2,2]],Atkinson:[[1/8,1,0],[1/8,2,0],[1/8,-1,1],[1/8,0,1],[1/8,1,1],[1/8,0,2]]};if(!kernel||!kernels[kernel]){throw"Unknown dithering kernel: "+kernel}var ds=kernels[kernel];var index=0,height=this.height,width=this.width,data=this.pixels;var direction=serpentine?-1:1;this.indexedPixels=new Uint8Array(this.pixels.length/3);for(var y=0;y<height;y++){if(serpentine)direction=direction*-1;for(var x=direction==1?0:width-1,xend=direction==1?width:0;x!==xend;x+=direction){index=y*width+x;var idx=index*3;var r1=data[idx];var g1=data[idx+1];var b1=data[idx+2];idx=this.findClosestRGB(r1,g1,b1);this.usedEntry[idx]=true;this.indexedPixels[index]=idx;idx*=3;var r2=this.colorTab[idx];var g2=this.colorTab[idx+1];var b2=this.colorTab[idx+2];var er=r1-r2;var eg=g1-g2;var eb=b1-b2;for(var i=direction==1?0:ds.length-1,end=direction==1?ds.length:0;i!==end;i+=direction){var x1=ds[i][1];var y1=ds[i][2];if(x1+x>=0&&x1+x<width&&y1+y>=0&&y1+y<height){var d=ds[i][0];idx=index+x1+y1*width;idx*=3;data[idx]=Math.max(0,Math.min(255,data[idx]+er*d));data[idx+1]=Math.max(0,Math.min(255,data[idx+1]+eg*d));data[idx+2]=Math.max(0,Math.min(255,data[idx+2]+eb*d))}}}}};GIFEncoder.prototype.findClosest=function(c,used){return this.findClosestRGB((c&16711680)>>16,(c&65280)>>8,c&255,used)};GIFEncoder.prototype.findClosestRGB=function(r,g,b,used){if(this.colorTab===null)return-1;if(this.neuQuant&&!used){return this.neuQuant.lookupRGB(r,g,b)}var c=b|g<<8|r<<16;var minpos=0;var dmin=256*256*256;var len=this.colorTab.length;for(var i=0,index=0;i<len;index++){var dr=r-(this.colorTab[i++]&255);var dg=g-(this.colorTab[i++]&255);var db=b-(this.colorTab[i++]&255);var d=dr*dr+dg*dg+db*db;if((!used||this.usedEntry[index])&&d<dmin){dmin=d;minpos=index}}return minpos};GIFEncoder.prototype.getImagePixels=function(){var w=this.width;var h=this.height;this.pixels=new Uint8Array(w*h*3);var data=this.image;var srcPos=0;var count=0;for(var i=0;i<h;i++){for(var j=0;j<w;j++){this.pixels[count++]=data[srcPos++];this.pixels[count++]=data[srcPos++];this.pixels[count++]=data[srcPos++];srcPos++}}};GIFEncoder.prototype.writeGraphicCtrlExt=function(){this.out.writeByte(33);this.out.writeByte(249);this.out.writeByte(4);var transp,disp;if(this.transparent===null){transp=0;disp=0}else{transp=1;disp=2}if(this.dispose>=0){disp=dispose&7}disp<<=2;this.out.writeByte(0|disp|0|transp);this.writeShort(this.delay);this.out.writeByte(this.transIndex);this.out.writeByte(0)};GIFEncoder.prototype.writeImageDesc=function(){this.out.writeByte(44);this.writeShort(0);this.writeShort(0);this.writeShort(this.width);this.writeShort(this.height);if(this.firstFrame||this.globalPalette){this.out.writeByte(0)}else{this.out.writeByte(128|0|0|0|this.palSize)}};GIFEncoder.prototype.writeLSD=function(){this.writeShort(this.width);this.writeShort(this.height);this.out.writeByte(128|112|0|this.palSize);this.out.writeByte(0);this.out.writeByte(0)};GIFEncoder.prototype.writeNetscapeExt=function(){this.out.writeByte(33);this.out.writeByte(255);this.out.writeByte(11);this.out.writeUTFBytes("NETSCAPE2.0");this.out.writeByte(3);this.out.writeByte(1);this.writeShort(this.repeat);this.out.writeByte(0)};GIFEncoder.prototype.writePalette=function(){this.out.writeBytes(this.colorTab);var n=3*256-this.colorTab.length;for(var i=0;i<n;i++)this.out.writeByte(0)};GIFEncoder.prototype.writeShort=function(pValue){this.out.writeByte(pValue&255);this.out.writeByte(pValue>>8&255)};GIFEncoder.prototype.writePixels=function(){var enc=new LZWEncoder(this.width,this.height,this.indexedPixels,this.colorDepth);enc.encode(this.out)};GIFEncoder.prototype.stream=function(){return this.out};module.exports=GIFEncoder},{"./LZWEncoder.js":2,"./TypedNeuQuant.js":3}],2:[function(require,module,exports){var EOF=-1;var BITS=12;var HSIZE=5003;var masks=[0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535];function LZWEncoder(width,height,pixels,colorDepth){var initCodeSize=Math.max(2,colorDepth);var accum=new Uint8Array(256);var htab=new Int32Array(HSIZE);var codetab=new Int32Array(HSIZE);var cur_accum,cur_bits=0;var a_count;var free_ent=0;var maxcode;var clear_flg=false;var g_init_bits,ClearCode,EOFCode;function char_out(c,outs){accum[a_count++]=c;if(a_count>=254)flush_char(outs)}function cl_block(outs){cl_hash(HSIZE);free_ent=ClearCode+2;clear_flg=true;output(ClearCode,outs)}function cl_hash(hsize){for(var i=0;i<hsize;++i)htab[i]=-1}function compress(init_bits,outs){var fcode,c,i,ent,disp,hsize_reg,hshift;g_init_bits=init_bits;clear_flg=false;n_bits=g_init_bits;maxcode=MAXCODE(n_bits);ClearCode=1<<init_bits-1;EOFCode=ClearCode+1;free_ent=ClearCode+2;a_count=0;ent=nextPixel();hshift=0;for(fcode=HSIZE;fcode<65536;fcode*=2)++hshift;hshift=8-hshift;hsize_reg=HSIZE;cl_hash(hsize_reg);output(ClearCode,outs);outer_loop:while((c=nextPixel())!=EOF){fcode=(c<<BITS)+ent;i=c<<hshift^ent;if(htab[i]===fcode){ent=codetab[i];continue}else if(htab[i]>=0){disp=hsize_reg-i;if(i===0)disp=1;do{if((i-=disp)<0)i+=hsize_reg;if(htab[i]===fcode){ent=codetab[i];continue outer_loop}}while(htab[i]>=0)}output(ent,outs);ent=c;if(free_ent<1<<BITS){codetab[i]=free_ent++;htab[i]=fcode}else{cl_block(outs)}}output(ent,outs);output(EOFCode,outs)}function encode(outs){outs.writeByte(initCodeSize);remaining=width*height;curPixel=0;compress(initCodeSize+1,outs);outs.writeByte(0)}function flush_char(outs){if(a_count>0){outs.writeByte(a_count);outs.writeBytes(accum,0,a_count);a_count=0}}function MAXCODE(n_bits){return(1<<n_bits)-1}function nextPixel(){if(remaining===0)return EOF;--remaining;var pix=pixels[curPixel++];return pix&255}function output(code,outs){cur_accum&=masks[cur_bits];if(cur_bits>0)cur_accum|=code<<cur_bits;else cur_accum=code;cur_bits+=n_bits;while(cur_bits>=8){char_out(cur_accum&255,outs);cur_accum>>=8;cur_bits-=8}if(free_ent>maxcode||clear_flg){if(clear_flg){maxcode=MAXCODE(n_bits=g_init_bits);clear_flg=false}else{++n_bits;if(n_bits==BITS)maxcode=1<<BITS;else maxcode=MAXCODE(n_bits)}}if(code==EOFCode){while(cur_bits>0){char_out(cur_accum&255,outs);cur_accum>>=8;cur_bits-=8}flush_char(outs)}}this.encode=encode}module.exports=LZWEncoder},{}],3:[function(require,module,exports){var ncycles=100;var netsize=256;var maxnetpos=netsize-1;var netbiasshift=4;var intbiasshift=16;var intbias=1<<intbiasshift;var gammashift=10;var gamma=1<<gammashift;var betashift=10;var beta=intbias>>betashift;var betagamma=intbias<<gammashift-betashift;var initrad=netsize>>3;var radiusbiasshift=6;var radiusbias=1<<radiusbiasshift;var initradius=initrad*radiusbias;var radiusdec=30;var alphabiasshift=10;var initalpha=1<<alphabiasshift;var alphadec;var radbiasshift=8;var radbias=1<<radbiasshift;var alpharadbshift=alphabiasshift+radbiasshift;var alpharadbias=1<<alpharadbshift;var prime1=499;var prime2=491;var prime3=487;var prime4=503;var minpicturebytes=3*prime4;function NeuQuant(pixels,samplefac){var network;var netindex;var bias;var freq;var radpower;function init(){network=[];netindex=new Int32Array(256);bias=new Int32Array(netsize);freq=new Int32Array(netsize);radpower=new Int32Array(netsize>>3);var i,v;for(i=0;i<netsize;i++){v=(i<<netbiasshift+8)/netsize;network[i]=new Float64Array([v,v,v,0]);freq[i]=intbias/netsize;bias[i]=0}}function unbiasnet(){for(var i=0;i<netsize;i++){network[i][0]>>=netbiasshift;network[i][1]>>=netbiasshift;network[i][2]>>=netbiasshift;network[i][3]=i}}function altersingle(alpha,i,b,g,r){network[i][0]-=alpha*(network[i][0]-b)/initalpha;network[i][1]-=alpha*(network[i][1]-g)/initalpha;network[i][2]-=alpha*(network[i][2]-r)/initalpha}function alterneigh(radius,i,b,g,r){var lo=Math.abs(i-radius);var hi=Math.min(i+radius,netsize);var j=i+1;var k=i-1;var m=1;var p,a;while(j<hi||k>lo){a=radpower[m++];if(j<hi){p=network[j++];p[0]-=a*(p[0]-b)/alpharadbias;p[1]-=a*(p[1]-g)/alpharadbias;p[2]-=a*(p[2]-r)/alpharadbias}if(k>lo){p=network[k--];p[0]-=a*(p[0]-b)/alpharadbias;p[1]-=a*(p[1]-g)/alpharadbias;p[2]-=a*(p[2]-r)/alpharadbias}}}function contest(b,g,r){var bestd=~(1<<31);var bestbiasd=bestd;var bestpos=-1;var bestbiaspos=bestpos;var i,n,dist,biasdist,betafreq;for(i=0;i<netsize;i++){n=network[i];dist=Math.abs(n[0]-b)+Math.abs(n[1]-g)+Math.abs(n[2]-r);if(dist<bestd){bestd=dist;bestpos=i}biasdist=dist-(bias[i]>>intbiasshift-netbiasshift);if(biasdist<bestbiasd){bestbiasd=biasdist;bestbiaspos=i}betafreq=freq[i]>>betashift;freq[i]-=betafreq;bias[i]+=betafreq<<gammashift}freq[bestpos]+=beta;bias[bestpos]-=betagamma;return bestbiaspos}function inxbuild(){var i,j,p,q,smallpos,smallval,previouscol=0,startpos=0;for(i=0;i<netsize;i++){p=network[i];smallpos=i;smallval=p[1];for(j=i+1;j<netsize;j++){q=network[j];if(q[1]<smallval){smallpos=j;smallval=q[1]}}q=network[smallpos];if(i!=smallpos){j=q[0];q[0]=p[0];p[0]=j;j=q[1];q[1]=p[1];p[1]=j;j=q[2];q[2]=p[2];p[2]=j;j=q[3];q[3]=p[3];p[3]=j}if(smallval!=previouscol){netindex[previouscol]=startpos+i>>1;for(j=previouscol+1;j<smallval;j++)netindex[j]=i;previouscol=smallval;startpos=i}}netindex[previouscol]=startpos+maxnetpos>>1;for(j=previouscol+1;j<256;j++)netindex[j]=maxnetpos}function inxsearch(b,g,r){var a,p,dist;var bestd=1e3;var best=-1;var i=netindex[g];var j=i-1;while(i<netsize||j>=0){if(i<netsize){p=network[i];dist=p[1]-g;if(dist>=bestd)i=netsize;else{i++;if(dist<0)dist=-dist;a=p[0]-b;if(a<0)a=-a;dist+=a;if(dist<bestd){a=p[2]-r;if(a<0)a=-a;dist+=a;if(dist<bestd){bestd=dist;best=p[3]}}}}if(j>=0){p=network[j];dist=g-p[1];if(dist>=bestd)j=-1;else{j--;if(dist<0)dist=-dist;a=p[0]-b;if(a<0)a=-a;dist+=a;if(dist<bestd){a=p[2]-r;if(a<0)a=-a;dist+=a;if(dist<bestd){bestd=dist;best=p[3]}}}}}return best}function learn(){var i;var lengthcount=pixels.length;var alphadec=30+(samplefac-1)/3;var samplepixels=lengthcount/(3*samplefac);var delta=~~(samplepixels/ncycles);var alpha=initalpha;var radius=initradius;var rad=radius>>radiusbiasshift;if(rad<=1)rad=0;for(i=0;i<rad;i++)radpower[i]=alpha*((rad*rad-i*i)*radbias/(rad*rad));var step;if(lengthcount<minpicturebytes){samplefac=1;step=3}else if(lengthcount%prime1!==0){step=3*prime1}else if(lengthcount%prime2!==0){step=3*prime2}else if(lengthcount%prime3!==0){step=3*prime3}else{step=3*prime4}var b,g,r,j;var pix=0;i=0;while(i<samplepixels){b=(pixels[pix]&255)<<netbiasshift;g=(pixels[pix+1]&255)<<netbiasshift;r=(pixels[pix+2]&255)<<netbiasshift;j=contest(b,g,r);altersingle(alpha,j,b,g,r);if(rad!==0)alterneigh(rad,j,b,g,r);pix+=step;if(pix>=lengthcount)pix-=lengthcount;i++;if(delta===0)delta=1;if(i%delta===0){alpha-=alpha/alphadec;radius-=radius/radiusdec;rad=radius>>radiusbiasshift;if(rad<=1)rad=0;for(j=0;j<rad;j++)radpower[j]=alpha*((rad*rad-j*j)*radbias/(rad*rad))}}}function buildColormap(){init();learn();unbiasnet();inxbuild()}this.buildColormap=buildColormap;function getColormap(){var map=[];var index=[];for(var i=0;i<netsize;i++)index[network[i][3]]=i;var k=0;for(var l=0;l<netsize;l++){var j=index[l];map[k++]=network[j][0];map[k++]=network[j][1];map[k++]=network[j][2]}return map}this.getColormap=getColormap;this.lookupRGB=inxsearch}module.exports=NeuQuant},{}],4:[function(require,module,exports){var GIFEncoder,renderFrame;GIFEncoder=require("./GIFEncoder.js");renderFrame=function(frame){var encoder,page,stream,transfer;encoder=new GIFEncoder(frame.width,frame.height);if(frame.index===0){encoder.writeHeader()}else{encoder.firstFrame=false}encoder.setTransparent(frame.transparent);encoder.setRepeat(frame.repeat);encoder.setDelay(frame.delay);encoder.setQuality(frame.quality);encoder.setDither(frame.dither);encoder.setGlobalPalette(frame.globalPalette);encoder.addFrame(frame.data);if(frame.last){encoder.finish()}if(frame.globalPalette===true){frame.globalPalette=encoder.getGlobalPalette()}stream=encoder.stream();frame.data=stream.pages;frame.cursor=stream.cursor;frame.pageSize=stream.constructor.pageSize;if(frame.canTransfer){transfer=function(){var i,len,ref,results;ref=frame.data;results=[];for(i=0,len=ref.length;i<len;i++){page=ref[i];results.push(page.buffer)}return results}();return self.postMessage(frame,transfer)}else{return self.postMessage(frame)}};self.onmessage=function(event){return renderFrame(event.data)}},{"./GIFEncoder.js":1}]},{},[4]);
|
|
49
|
+
`],{type:`application/javascript`}))})}var m_=()=>`https://api.polotno.com/api`,h_=Ut({imageDownScalingEnabled:!0,removeBackgroundEnabled:!1,htmlRenderEnabled:!1,renderTagTextEnabled:!0,forceTextFitEnabled:!1,textVerticalResizeEnabled:!1,textOverflow:`resize`,textSplitAllowed:!1,animationsEnabled:!1,aiTextEnabled:!1,autoDeleteEmptyText:!0}),g_=typeof window<`u`&&window.location.hostname===`localhost`||typeof process<`u`&&!1,__=ir(e=>{h_.textVerticalResizeEnabled=e}),v_=ir(e=>{h_.removeBackgroundEnabled=e});ir(e=>{g_&&console.warn(`useRemoveBackground is deprecated. Use setRemoveBackgroundEnabled instead.`),v_(e)}),ir(e=>{h_.aiTextEnabled=e}),ir(e=>{g_&&console.warn(`useHtmlTextRender is deprecated. Use setRichTextEnabled instead.`),h_.htmlRenderEnabled=e});var y_=e=>ir(t=>{g_&&console.warn(`${e}() is a no-op: the new text rendering engine is enabled by default.`)}),b_=e=>{or(()=>{h_.htmlRenderEnabled=!0,h_.renderTagTextEnabled=!1})},x_=y_(`setRichTextEnabled`),S_=y_(`setRenderTagTextEnabled`),C_=ir(e=>{h_.imageDownScalingEnabled=e});ir(e=>{console.warn(`useDownScaling is deprecated. Use setDownScalingEnabled instead.`),C_(e)}),ir(e=>{console.warn(`setForceTextFit is deprecated. Use setTextOverflow instead.`),h_.textOverflow=`change-font-size`});var w_=ir(e=>{h_.textOverflow=e}),T_=ir(e=>{h_.textSplitAllowed=e});ir(e=>{h_.animationsEnabled=e}),ir(e=>{h_.autoDeleteEmptyText=e});var E_=Ut({value:!1}),D_=Ut({value:`v1`}),O_=()=>D_.value,k_=Ut({value:0}),A_=()=>k_.value,j_=()=>E_.value,M_=ir(()=>{E_.value=!0}),N_=``,P_=e=>{N_=e||``},F_=typeof window<`u`?window.location.origin:``,I_=typeof navigator<`u`&&navigator.userAgent.indexOf(`Headless`)>-1,L_=typeof navigator<`u`&&navigator.userAgent.indexOf(`Electron`)>-1;F_===`file://`&&I_&&(F_=`headless`),F_===`file://`&&L_&&(F_=`electron`);var R_=`%cPolotno error! Current domain is not allowed. It may lead to unexpected behavior and stop working. Please add "${F_}" here: https://polotno.com/cabinet`,z_=fetch;async function B_(e){for(let t=0;t<5;t++)try{let t=await z_(m_()+`/validate-key`,{method:`POST`,body:JSON.stringify({key:e,site:location.host,skdVersion:`4.0.0`})});if(or(()=>{D_.value=t.headers.get(`x-api-version`)||``}),!e)return console.error(`Polotno API is initialized without API key. It may lead to unexpected behavior and stop working. Please create API key here: https://polotno.com/cabinet`),or(()=>{k_.value=1}),!1;if(t.status!==200){await new Promise(e=>setTimeout(e,3e3));continue}let n=await t.json();return n.is_valid||(console.error(`Polotno API key is not valid. Please get new API key here: https://polotno.com/cabinet`),or(()=>{k_.value=1})),n.is_paid||(console.log(`%cPolotno Free Version. For development usage only. https://polotno.com/`,`background: rgb(0, 161, 255); color: white; padding: 5px; margin: 5px;`),or(()=>{k_.value===0&&(k_.value=2)})),n.is_domain_valid||console.log(R_,`background: rgba(247, 101, 68, 1); color: white; padding: 5px; margin: 5px;`),v_(n.remove_background_enabled),n.is_paid||!1}catch{await new Promise(e=>setTimeout(e,3e3))}return console.error(`Can not validate Polotno API key. Please report to anton@polotno.com immediately.`),!0}async function V_(e){await B_(N_)&&!e||M_()}var H_=!1,U_=(e=!H_)=>{H_=e},W_=()=>H_;function G_(e,t){let n=b.useRef(void 0);b.useLayoutEffect(()=>{n.current&&n.current.destroy()},[t]),b.useLayoutEffect(()=>{if(!H_)return;let t=e.current.opacity();return t?(e.current.opacity(0),n.current=new W.Tween({node:e.current,opacity:t,onFinish:()=>{var e;(e=n.current)==null||e.destroy()}}),n.current.play(),()=>{var e;(e=n.current)==null||e.destroy()}):void 0},[])}var K_=0,q_=[],J_=3e4,Y_=e=>{J_=e},X_=6e3,Z_=e=>{X_=e},Q_=()=>X_;function $_(e){K_+=1;let t=!1,n=!1,r=setTimeout(()=>{t||(iv(`Timeout loading asset ${e}`),console.error(`Timeout triggered for loader. Some assets may not have loaded.`,e),t=!0,ev())},J_);return()=>{n?console.error(`Finish called twice! That is not expected. id: `,e):(n=!0,t||(clearTimeout(r),ev()))}}function ev(){--K_,K_===0&&(q_.forEach(e=>e()),q_=[])}function tv(){return new Promise(e=>{t=()=>{W_()?setTimeout(e,300):e(!0)},K_===0?t():q_.push(t);return;var t})}var nv=[];function rv(e){nv.push(e)}function iv(e){nv.forEach(t=>t(e))}var av={"ql-font-serif":`Georgia, Times New Roman, serif`,"ql-font-monospace":`Monaco, Courier New, monospace`,"ql-font-sans":`system-ui, -apple-system, BlinkMacSystemFont, sans-serif`},ov={"ql-size-small":.75,"ql-size-large":1.5,"ql-size-huge":2.5};function sv(e){return e.replace(/^ql-font-/,``).split(`-`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `)}function cv(e){return e.replace(/"/g,`"`).replace(/&/g,`&`).split(`,`)[0].trim().replace(/^["']|["']$/g,``)||null}function lv(e,t){if(!e)return;let n=e.trim(),r=n.match(/^(\d+(?:\.\d+)?)px$/i);if(r)return parseFloat(r[1]);let i=n.match(/^(\d+(?:\.\d+)?)em$/i);if(i)return t*parseFloat(i[1]);let a=n.match(/^(\d+(?:\.\d+)?)rem$/i);return a?t*parseFloat(a[1]):void 0}function uv(e){return new DOMParser().parseFromString(`<div id="polotno-rich-root">${e}</div>`,`text/html`).getElementById(`polotno-rich-root`)}function dv(e){for(let t of Array.from(e.classList))if(t.startsWith(`ql-indent-`)){let e=parseInt(t.slice(10),10);if(e>0)return e}return 0}var fv=new Set([`SPAN`,`STRONG`,`B`,`EM`,`I`,`U`,`S`,`DEL`,`SUB`,`SUP`]);function pv(e,t){if(e.attributes.length!==t.attributes.length)return!1;for(let n of Array.from(e.attributes))if(t.getAttribute(n.name)!==n.value)return!1;return!0}function mv(e){let t=e=>{for(let n of Array.from(e.children))t(n);if(function(e){if(e.tagName!==`SPAN`)return!1;for(let t of Array.from(e.attributes))if(t.value.trim())return!1;return!0}(e)&&e.parentNode){let t=e.parentNode;for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}};for(let n of Array.from(e.children))t(n);let n=e=>{for(let t of Array.from(e.children))n(t);let t=e.firstElementChild;for(;t;){let e=t.nextElementSibling;if(e&&t.nextSibling===e&&fv.has(t.tagName)&&t.tagName===e.tagName&&pv(t,e)){for(;e.firstChild;)t.appendChild(e.firstChild);e.remove(),n(t)}else t=e}};n(e)}function hv(e,t){if(!e||!e.includes(`<`))return e;let n=uv(e);if(!n)return e;let r=e=>{for(let t of Array.from(e.children))r(t);let n=e.getAttribute(`class`);if(n){let r=n.split(/\s+/).filter(Boolean),i=[];for(let n of r){if(n.startsWith(`ql-font-`)){if(!e.style.fontFamily){let t=av[n]||sv(n);e.style.fontFamily=t}continue}let r=ov[n];if(r==null){if(!n.startsWith(`ql-align-`)){if(n.startsWith(`ql-indent-`)){if(e.tagName===`LI`){i.push(n);continue}let t=parseInt(n.slice(10),10);t>0&&!e.style.getPropertyValue(`margin-inline-start`)&&e.style.setProperty(`margin-inline-start`,.5*t+`em`);continue}n===`ql-direction-rtl`?e.style.direction||(e.style.direction=`rtl`):i.push(n)}}else e.style.fontSize||(e.style.fontSize=t.fontSize*r+`px`)}i.length?e.setAttribute(`class`,i.join(` `)):e.removeAttribute(`class`)}let i=e.style.fontSize;if(i){let n=lv(i,t.fontSize);n!=null&&(e.style.fontSize=`${n}px`)}};r(n),mv(n),function(e){for(let t of Array.from(e.querySelectorAll(`span.ql-ui`)))t.remove();let t=e.ownerDocument,n=e=>{let t=e.children;for(let e=t.length-1;e>=0;e--)if(t[e].tagName.toLowerCase()===`li`)return t[e];return null};for(let r of Array.from(e.querySelectorAll(`ol, ul`))){let e=r.tagName.toLowerCase(),i=Array.from(r.children).filter(e=>e.tagName.toLowerCase()===`li`);if(i.length===0||!i.some(e=>e.hasAttribute(`data-list`)||dv(e)>0))continue;let a=t=>{let n=t.getAttribute(`data-list`);return n===`ordered`?`ol`:n===`bullet`||n===`checked`||n===`unchecked`?`ul`:e===`ol`?`ol`:`ul`},o=t.createDocumentFragment(),s=[{list:o,level:-1,type:``}];for(let e of i){let r=dv(e),i=a(e);e.removeAttribute(`data-list`);for(let t of Array.from(e.classList))t.startsWith(`ql-indent-`)&&e.classList.remove(t);for(e.getAttribute(`class`)||e.removeAttribute(`class`);s.length>1&&s[s.length-1].level>r;)s.pop();if(s[s.length-1].level===r&&s[s.length-1].type!==i&&s.pop(),s[s.length-1].level<r){let e=s[s.length-1],a=n(e.list)||e.list,o=t.createElement(i);a.appendChild(o),s.push({list:o,level:r,type:i})}s[s.length-1].list.appendChild(e)}r.replaceWith(o)}for(let t of Array.from(e.querySelectorAll(`ul, ol`))){let e=Array.from(t.children).filter(e=>e.tagName.toLowerCase()===`li`);e.length>0&&e.every(e=>e.style.direction===`rtl`||e.getAttribute(`dir`)===`rtl`)&&t.style.direction!==`rtl`&&(t.style.direction=`rtl`)}}(n);for(let e of Array.from(n.querySelectorAll(`p`))){let t=e,n=``,r=``,i=``;for(;t.childNodes.length===1&&t.firstChild!=null&&t.firstChild.nodeType===1;){let e=t.firstChild;e.style.fontFamily&&(n=e.style.fontFamily),e.style.fontWeight&&(r=e.style.fontWeight),e.tagName!==`STRONG`&&e.tagName!==`B`||(r=`bold`),e.tagName!==`EM`&&e.tagName!==`I`&&e.style?.fontStyle!==`italic`||(i=`italic`),t=e}n&&(e.style.fontFamily=n),r&&(e.style.fontWeight=r),i&&(e.style.fontStyle=i)}return n.innerHTML}function gv(e){if(!e||!e.includes(`<p`))return e;let t=uv(e);if(!t)return e;for(let e of Array.from(t.querySelectorAll(`p`))){let n=!1,r=[],i=t.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),a=i.nextNode();for(;a;){if((a.textContent||``).length>0){let t=a.parentElement,i=null;for(;t&&t!==e;){let e=t.style?.fontSize;if(e){let t=parseFloat(e);if(!Number.isNaN(t)){i=t;break}}t=t.parentElement}if(i==null){n=!0;break}r.push(i)}a=i.nextNode()}!n&&r.length>0&&(e.style.fontSize=`${Math.min(...r)}px`)}return t.innerHTML}function _v(e){let t=new Set;if(!e||!e.includes(`<`))return[];let n=uv(e);if(n){let e=n.querySelectorAll(`[style]`);for(let n of e)if(n.style.fontFamily){let e=cv(n.style.fontFamily);e&&t.add(e)}}for(let n of e.matchAll(/\bfont-family="([^"]+)"/g)){let e=cv(n[1]);e&&t.add(e)}for(let n of e.matchAll(/\bql-font-([a-z0-9_-]+)\b/gi)){let e=`ql-font-${n[1]}`,r=cv(av[e]||sv(e));r&&t.add(r)}return[...t]}function vv(e,t){if(!e||t===1||t<=0||!Number.isFinite(t))return e;let n=uv(e);if(!n)return e;let r=e=>{let n=e.style.fontSize;if(n){let r=n.match(/^(\d+(?:\.\d+)?)(px|em|rem)$/i);if(r){let n=Math.round(parseFloat(r[1])*t*1e3)/1e3;e.style.fontSize=`${n}${r[2].toLowerCase()}`}}for(let t of Array.from(e.children))r(t)};return r(n),n.innerHTML}var yv=Symbol(`unset`);function bv(e,t){let n=yv;for(let r of e.ops){if(typeof r.insert!=`string`||r.insert===`
|
|
50
|
+
`)continue;let e=r.attributes?.[t];if(n===yv)n=e;else if(e!==n)return!0}return!1}function xv(e){if(!e||!e.includes(`<`))return!1;let t=uv(e);if(!t)return!1;for(let e of t.querySelectorAll(`[style]`))if(e.style.fontSize)return!0;return!1}function Sv(e=``){return(e.match(/<\/p>/gi)||[]).length>1&&(e=e.replace(/<\/p>/gi,(e,t,n)=>(n.slice(t+e.length).match(/<\/p>/gi)||[]).length>0?`
|
|
51
|
+
`:e)),e.replace(/(<([^>]+)>)/gi,``).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`).replace(/ /g,` `)}function Cv(e,t){return!!e.bold==!!t.bold&&!!e.italic==!!t.italic&&!!e.underline==!!t.underline&&!!e.strike==!!t.strike&&(e.color||``)===(t.color||``)&&(e.fontFamily||``)===(t.fontFamily||``)&&(e.fontSize??-1)===(t.fontSize??-1)}function wv(e,t){if(!e)return[];let n=new DOMParser().parseFromString(e,`text/html`),r=[],i=n.body.querySelectorAll(`p`),a=t?.fontSize??14;function o(e,t){if(e.nodeType===Node.TEXT_NODE){let n=e.textContent||``;n&&r.push(function(e,t){let n={text:e};return t.bold&&(n.bold=!0),t.italic&&(n.italic=!0),t.underline&&(n.underline=!0),t.strike&&(n.strike=!0),t.color&&(n.color=t.color),t.fontFamily&&(n.fontFamily=t.fontFamily),t.fontSize!=null&&(n.fontSize=t.fontSize),n}(n,t));return}if(e.nodeType!==Node.ELEMENT_NODE)return;let n=e,i=n.tagName.toLowerCase(),s=Object.assign({},t);i!==`strong`&&i!==`b`||(s.bold=!0),i!==`em`&&i!==`i`||(s.italic=!0),i===`u`&&(s.underline=!0),i===`s`&&(s.strike=!0);let c=n.style;c.color&&(s.color=c.color),(c.fontWeight===`bold`||parseInt(c.fontWeight)>=700)&&(s.bold=!0),c.fontStyle===`italic`&&(s.italic=!0);let l=c.textDecoration||c.textDecorationLine||``;if(l.includes(`underline`)&&(s.underline=!0),l.includes(`line-through`)&&(s.strike=!0),c.fontFamily){let e=cv(c.fontFamily);e&&(s.fontFamily=e)}if(c.fontSize){let e=t.fontSize??a,n=lv(c.fontSize,e);n!=null&&(s.fontSize=n)}for(let e of Array.from(n.childNodes))o(e,s)}i.length>0?i.forEach((e,t)=>{o(e,{}),t<i.length-1&&r.push({text:`
|
|
52
|
+
`})}):o(n.body,{});let s=[];for(let e of r){if(!e.text)continue;let t=s[s.length-1];t&&Cv(t,e)?t.text+=e.text:s.push(e)}return s}function Tv(e){return e?/<[a-z][a-z0-9]*(\s[^>]*)?>[^<]*<\/[a-z][a-z0-9]*>/i.test(e)?e=(e=e.replace(/<(?![a-z/!])/gi,`<`)).replace(/([^a-z0-9"'\s/])>/gi,`$1>`):e.replace(/</g,`<`).replace(/>/g,`>`):``}Ut([`Roboto`,`Amatic SC`,`Press Start 2P`,`Marck Script`,`Rubik Mono One`]),Ut({value:!1});var Ev=Ut([]);function Dv(e){Ev.push(e)}var Ov=`BESbswy 0123456789 Il1Ww`,kv=[`sans-serif`,`serif`,`monospace`];function Av(e){let t=function(e=``){let t=Sv(e).replace(/\s+/g,` `).trim();return t?Array.from(t).slice(0,10).join(``):``}(e);return t?`${Ov} ${t}`:Ov}var jv;function Mv(e){return{width:e.width,actualBoundingBoxLeft:e.actualBoundingBoxLeft||0,actualBoundingBoxRight:e.actualBoundingBoxRight||0,actualBoundingBoxAscent:e.actualBoundingBoxAscent||0,actualBoundingBoxDescent:e.actualBoundingBoxDescent||0}}function Nv(e=`sans-serif`,t=`normal`,n=`normal`,r=Ov){jv||=document.createElement(`canvas`);let i=jv.getContext(`2d`);return i.font=`${t} ${n} 40px ${e}`,Mv(i.measureText(r))}function Pv(e,t,n,r,i){return kv.some(a=>function(e,t,n=.01){return Math.abs(e.width-t.width)>n||Math.abs(e.actualBoundingBoxLeft-t.actualBoundingBoxLeft)>n||Math.abs(e.actualBoundingBoxRight-t.actualBoundingBoxRight)>n||Math.abs(e.actualBoundingBoxAscent-t.actualBoundingBoxAscent)>n||Math.abs(e.actualBoundingBoxDescent-t.actualBoundingBoxDescent)>n}(function(e,t=`sans-serif`,n=`normal`,r=`normal`,i=Ov){jv||=document.createElement(`canvas`);let a=jv.getContext(`2d`);return a.font=`${n} ${r} 40px '${e}', ${t}`,Mv(a.measureText(i))}(e,a,t,n,r),i[a]))}var Fv={Arial:!0},Iv=(e,t,n)=>t&&n?!!Fv[`${e}_${t}_${n}`]:Object.keys(Fv).some(t=>t.startsWith(e+`_`))||!!Fv[e];async function Lv(e,t,n,r){let i=`${e}_${t}_${n}`;if(Fv[i])return;let a=!!document.fonts?.load,o=Av(r),s={"sans-serif":Nv(`sans-serif`,t,n,o),serif:Nv(`serif`,t,n,o),monospace:Nv(`monospace`,t,n,o)};if(a)try{if(await document.fonts.load(`${t} ${n} 16px '${e}'`,o),Pv(e,t,n,o,s)){Fv[i]=!0;return}}catch{}let c=Math.min(6e3,Q_())/60;for(let r=0;r<c;r++){if(e in Rv&&!Rv[e]&&Hv(e),a)try{await document.fonts.load(`${t} ${n} 16px '${e}'`,o)}catch{}if(Pv(e,t,n,o,s)){Fv[i]=!0;return}await new Promise(e=>setTimeout(e,60))}console.warn(`Timeout for loading font "${e}". Looks like polotno can't load it. Is it a correct font family?`),iv(`Timeout for loading font "${e}"`)}var Rv={},zv=`400,400italic,700,700italic`;function Bv(){return zv}function Vv(e){return`https://fonts.googleapis.com/css?family=${e.replace(/ /g,`+`)}:${zv}`}function Hv(e){if(Rv[e])return;let t=Vv(e),n=document.createElement(`link`);n.type=`text/css`,n.href=t,n.rel=`stylesheet`,n.onerror=()=>{n.remove(),Rv[e]=!1},document.getElementsByTagName(`head`)[0].appendChild(n),Rv[e]=!0}var Uv={},Wv;function Gv(e){let t=e.fontFamily;if(Uv[t]||!e.url&&!e.styles)return;let n=e.styles||(e.url?[{src:`url("${e.url}")`}]:[]),r=(Wv||(Wv=document.getElementById(`polotno-font-style`),Wv||(Wv=document.createElement(`style`),Wv.id=`polotno-font-style`,document.head.appendChild(Wv)),Wv)).sheet;n.forEach(e=>{r.insertRule(`\n @font-face{\n font-family:'${t}';\n src:${e.src};\n font-style:${e.fontStyle||`normal`};\n font-weight:${e.fontWeight||`normal`};\n font-display:swap; /* optional but recommended */\n }`,r.cssRules.length)}),Uv[e.fontFamily]=!0}var Kv=[112,72,89,115],qv=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)n=1&n?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})(),Jv=()=>typeof globalThis<`u`?globalThis.Buffer:void 0,Yv=(e,t,n)=>{e[t]=n>>>24&255,e[t+1]=n>>>16&255,e[t+2]=n>>>8&255,e[t+3]=255&n},Xv=(e,t,n)=>{let r=e.indexOf(`,`),i=(e=>{if(typeof atob==`function`){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}let t=Jv();if(t)return new Uint8Array(t.from(e,`base64`));throw Error(`No base64 decoder available`)})(r>=0?e.slice(r+1):e);return`data:${t};base64,${(e=>{if(typeof btoa==`function`){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}let t=Jv();if(t)return t.from(e).toString(`base64`);throw Error(`No base64 encoder available`)})(t===`image/png`?((e,t)=>{let n=(e=>{let t=new Uint8Array(9),n=new DataView(t.buffer);n.setUint32(0,e,!1),n.setUint32(4,e,!1),t[8]=1;let r=new Uint8Array(8+t.length+4);Yv(r,0,t.length),r.set(Kv,4),r.set(t,8);let i=new Uint8Array(4+t.length);return i.set(Kv,0),i.set(t,4),Yv(r,8+t.length,(e=>{let t=4294967295;for(let n=0;n<e.length;n++)t=qv[255&(t^e[n])]^t>>>8;return(4294967295^t)>>>0})(i)),r})(Math.round(t/.0254)),r=((e,t)=>{let n=8;for(;n+8<=e.length;){let r=e[n]<<24|e[n+1]<<16|e[n+2]<<8|e[n+3],i=n+4,a=e.subarray(i,i+4),o=8+r+4;if(t.every((e,t)=>a[t]===e))return{offset:n,totalLength:o};n+=o}return null})(e,Kv);if(r){let t=new Uint8Array(e.length-r.totalLength+n.length);return t.set(e.slice(0,r.offset),0),t.set(n,r.offset),t.set(e.slice(r.offset+r.totalLength),r.offset+n.length),t}let i=16+(e[8]<<24|e[9]<<16|e[10]<<8|e[11])+4;if(i>e.length)return e;let a=new Uint8Array(e.length+n.length);return a.set(e.slice(0,i),0),a.set(n,i),a.set(e.slice(i),i+n.length),a})(i,n):((e,t)=>{let n=(e=>{let t=2;for(;t+4<e.length;){if(e[t]!==255)return-1;let n=e[t+1];if(n===216||n===217){t+=2;continue}let r=e[t+2]<<8|e[t+3];if(r<2)return-1;if(n===224&&e[t+4]===74&&e[t+5]===70&&e[t+6]===73&&e[t+7]===70&&e[t+8]===0)return t;let i=t+2+r;if(i<=t||i>e.length)return-1;t=i}return-1})(e);if(n>=0){let r=new Uint8Array(e),i=n+11;return r[i]=1,r[i+1]=t>>8&255,r[i+2]=255&t,r[i+3]=t>>8&255,r[i+4]=255&t,r}let r=(e=>{let t=new Uint8Array(18);return t[0]=255,t[1]=224,t[2]=0,t[3]=16,t[4]=74,t[5]=70,t[6]=73,t[7]=70,t[8]=0,t[9]=1,t[10]=1,t[11]=1,t[12]=e>>8&255,t[13]=255&e,t[14]=e>>8&255,t[15]=255&e,t})(t),i=new Uint8Array(e.length+r.length);return i.set(e.subarray(0,2),0),i.set(r,2),i.set(e.subarray(2),2+r.length),i})(i,n))}`},Zv=(e,t,n)=>{let r=t,i=n,a=1;for(;r>0&&i>0;){if(e.width=r,e.height=i,r+i<4e3)return;let o=e.getContext(`2d`);if(!o)return;if(o.fillStyle=`rgba(0,0,0,0.1)`,o.fillRect(0,0,1,1),o.getImageData(0,0,1,1).data[3]!==0){o.clearRect(0,0,e.width,e.height);return}if(a*=.9,r=Math.floor(t*a),i=Math.floor(n*a),r=Math.max(r,1),i=Math.max(i,1),r<=1&&i<=1){e.width=1,e.height=1;return}}};function Qv(e,t){let n=t.x??0,r=t.y??0,i=t.pixelRatio||1,a=Math.round(t.width*i),o=Math.round(t.height*i),s=a/i,c=o/i,l=t.sceneCanvas;l?(l.width!==a||l.height!==o||l.pixelRatio!==i)&&(l.setSize(s,c),l.setPixelRatio(i)):l=new bo({width:s,height:c,pixelRatio:i});let u=l.getContext(),d=l.width/l.pixelRatio+Math.abs(n),f=l.height/l.pixelRatio+Math.abs(r),p=t.bufferCanvas;if(p){let e=Math.round(d*l.pixelRatio),t=Math.round(f*l.pixelRatio);(p.width!==e||p.height!==t||p.pixelRatio!==l.pixelRatio)&&(p.setSize(d,f),p.setPixelRatio(l.pixelRatio))}else p=new bo({width:d,height:f,pixelRatio:l.pixelRatio});return!1===t.imageSmoothingEnabled&&(u._context.imageSmoothingEnabled=!1),u.save(),(n||r)&&u.translate(-1*n,-1*r),e.drawScene(l,void 0,p),u.restore(),l}function $v(){return{sceneCanvas:new bo({width:1,height:1,pixelRatio:1}),bufferCanvas:new bo({width:1,height:1,pixelRatio:1})}}var ey=({px:e,unit:t=`px`,dpi:n})=>{switch(t){case`pt`:default:return e;case`mm`:return e/(n/25.4);case`cm`:return e/(n/2.54);case`in`:return e/n}},ty=({px:e,precious:t=2,dpi:n=72,unit:r=`px`})=>parseFloat(ey({px:e,dpi:n,unit:r}).toFixed(t)),ny=({unitVal:e,dpi:t,unit:n})=>e/ey({px:1,unit:n,dpi:t}),ry=e=>{let t=parseFloat(ey(e).toFixed(1));switch(e.unit){case`pt`:return`${Math.round(t)}pt`;case`mm`:return`${t}mm`;case`cm`:return`${t}cm`;case`in`:return`${t}in`;default:return`${Math.round(t)}px`}};async function iy(e){for(let t=0;t<30;t++){let t=await e();if(t)return t;await new Promise(e=>setTimeout(e,50))}}var ay=ay||{};ay.stringify=(function(){var e={"visit_linear-gradient":function(t){return e.visit_gradient(t)},"visit_repeating-linear-gradient":function(t){return e.visit_gradient(t)},"visit_radial-gradient":function(t){return e.visit_gradient(t)},"visit_repeating-radial-gradient":function(t){return e.visit_gradient(t)},"visit_conic-gradient":function(t){return e.visit_gradient(t)},"visit_repeating-conic-gradient":function(t){return e.visit_gradient(t)},visit_gradient:function(t){var n=e.visit(t.orientation);return n&&(n+=`, `),t.type+`(`+n+e.visit(t.colorStops)+`)`},visit_shape:function(t){var n=t.value,r=e.visit(t.at),i=e.visit(t.style);return i&&(n+=` `+i),r&&(n+=` at `+r),n},"visit_default-radial":function(t){var n=``,r=e.visit(t.at);return r&&(t.hasAtKeyword?n+=`at `+r:n+=r),n},"visit_extent-keyword":function(t){var n=t.value,r=e.visit(t.at);return r&&(n+=` at `+r),n},"visit_position-keyword":function(e){return e.value},visit_position:function(t){return e.visit(t.value.x)+` `+e.visit(t.value.y)},"visit_%":function(e){return e.value+`%`},visit_em:function(e){return e.value+`em`},visit_px:function(e){return e.value+`px`},visit_rem:function(e){return e.value+`rem`},visit_vw:function(e){return e.value+`vw`},visit_vh:function(e){return e.value+`vh`},visit_vmin:function(e){return e.value+`vmin`},visit_vmax:function(e){return e.value+`vmax`},visit_ch:function(e){return e.value+`ch`},visit_ex:function(e){return e.value+`ex`},visit_calc:function(e){return`calc(`+e.value+`)`},visit_literal:function(t){return e.visit_color(t.value,t)},visit_hex:function(t){return e.visit_color(`#`+t.value,t)},visit_rgb:function(t){return e.visit_color(`rgb(`+t.value.join(`, `)+`)`,t)},visit_rgba:function(t){return e.visit_color(`rgba(`+t.value.join(`, `)+`)`,t)},visit_hsl:function(t){return e.visit_color(`hsl(`+t.value[0]+`, `+t.value[1]+`%, `+t.value[2]+`%)`,t)},visit_hsla:function(t){return e.visit_color(`hsla(`+t.value[0]+`, `+t.value[1]+`%, `+t.value[2]+`%, `+t.value[3]+`)`,t)},visit_var:function(t){return e.visit_color(`var(`+t.value+`)`,t)},visit_color:function(t,n){var r=t,i=e.visit(n.length);i&&(r+=` `+i);var a=e.visit(n.length2);return a&&(r+=` `+a),r},visit_angular:function(e){return e.value+(e.unit||`deg`)},visit_directional:function(e){return`to `+e.value},visit_conic:function(t){var n=``;return t.angle&&(n+=`from `+e.visit(t.angle)),t.at&&(n&&(n+=` `),n+=`at `+e.visit(t.at)),n},visit_array:function(t){var n=``,r=t.length;return t.forEach(function(t,i){n+=e.visit(t),i<r-1&&(n+=`, `)}),n},visit_object:function(t){return t.width&&t.height?e.visit(t.width)+` `+e.visit(t.height):``},visit:function(t){if(!t)return``;if(t instanceof Array)return e.visit_array(t);if(typeof t==`object`&&!t.type)return e.visit_object(t);if(t.type){var n=e[`visit_`+t.type];if(n)return n(t);throw Error(`Missing visitor visit_`+t.type)}else throw Error(`Invalid node.`)}};return function(t){return e.visit(t)}})();var ay=ay||{};ay.parse=(function(){var e={linearGradient:/^(\-(webkit|o|ms|moz)\-)?(linear\-gradient)/i,repeatingLinearGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-linear\-gradient)/i,radialGradient:/^(\-(webkit|o|ms|moz)\-)?(radial\-gradient)/i,repeatingRadialGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-radial\-gradient)/i,conicGradient:/^(\-(webkit|o|ms|moz)\-)?(conic\-gradient)/i,repeatingConicGradient:/^(\-(webkit|o|ms|moz)\-)?(repeating\-conic\-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest\-side|closest\-corner|farthest\-side|farthest\-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))px/,percentageValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))\%/,emValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))em/,remValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))rem/,vwValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))vw/,vhValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))vh/,vminValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))vmin/,vmaxValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))vmax/,chValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))ch/,exValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))ex/,angleValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))deg/,radianValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))rad/,gradianValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))grad/,turnValue:/^(-?(([0-9]*\.[0-9]+)|([0-9]+\.?)))turn/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,slash:/^\//,hexColor:/^\#([0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{4}|[0-9a-fA-F]{3})(?![0-9a-fA-F])/,literalColor:/^([a-zA-Z]+)/,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,varColor:/^var/i,calcValue:/^calc/i,variableName:/^(--[a-zA-Z0-9-,\s\#]+)/,number:/^(([0-9]*\.[0-9]+)|([0-9]+\.?))/,hslColor:/^hsl/i,hslaColor:/^hsla/i},t=``;function n(e){var n=Error(t+`: `+e);throw n.source=t,n}function r(){var e=i();return t.length>0&&n(`Invalid input not EOF`),e}function i(){return S(a)}function a(){return o(`linear-gradient`,e.linearGradient,c)||o(`repeating-linear-gradient`,e.repeatingLinearGradient,c)||o(`radial-gradient`,e.radialGradient,m)||o(`repeating-radial-gradient`,e.repeatingRadialGradient,m)||o(`conic-gradient`,e.conicGradient,l)||o(`repeating-conic-gradient`,e.repeatingConicGradient,l)}function o(t,r,i){return s(r,function(r){var a=i();return a&&(F(e.comma)||n(`Missing comma before color stops`)),{type:t,orientation:a,colorStops:S(C)}})}function s(t,r){var i=F(t);if(i){F(e.startCall)||n(`Missing (`);var a=r(i);return F(e.endCall)||n(`Missing )`),a}}function c(){var t=d();if(t)return t;var n=ae(`position-keyword`,e.positionKeywords,1);return n?{type:`directional`,value:n.value}:f()}function l(){var e=u(),t=y();if(e||t)return{type:`conic`,angle:e||void 0,at:t||void 0}}function u(){if(ae(`from`,/^from/,0)){var e=f();return e||n(`Missing angle after "from" in conic-gradient`),e}}function d(){return ae(`directional`,e.sideOrCorner,1)}function f(){return p(`deg`,e.angleValue)||p(`rad`,e.radianValue)||p(`grad`,e.gradianValue)||p(`turn`,e.turnValue)}function p(e,t){var n=F(t);if(n)return{type:`angular`,value:n[1],unit:e}}function m(){var n,r=h(),i;return r&&(n=[],n.push(r),i=t,F(e.comma)&&(r=h(),r?n.push(r):t=i)),n}function h(){var e=g()||_();if(e)e.at=y();else{var t=v();if(t){e=t;var n=y();n&&(e.at=n)}else{var r=y();if(r)e={type:`default-radial`,at:r,hasAtKeyword:!0};else{var i=b();i&&(e={type:`default-radial`,at:i})}}}return e}function g(){var e=ae(`shape`,/^(circle)/i,0);return e&&(e.style=ie()||v()),e}function _(){var e=ae(`shape`,/^(ellipse)/i,0);return e&&(e.style=b()||N()||v()),e}function v(){return ae(`extent-keyword`,e.extentKeywords,1)}function y(){if(ae(`position`,/^at/,0)){var e=b();return e||n(`Missing positioning value`),e}}function b(){var e=x();if(e.x||e.y)return{type:`position`,value:e}}function x(){return{x:N(),y:N()}}function S(t){var r=t(),i=[];if(r)for(i.push(r);F(e.comma);)r=t(),r?i.push(r):n(`One extra comma`);return i}function C(){var e=w();return e||n(`Expected color definition`),e.length=N(),e.length&&(e.length2=N()),e}function w(){return E()||j()||A()||O()||D()||ee()||T()}function T(){return ae(`literal`,e.literalColor,0)}function E(){return ae(`hex`,e.hexColor,1)}function D(){return s(e.rgbColor,function(){return k(`rgb`)})}function O(){return s(e.rgbaColor,function(){return k(`rgba`)})}function k(t){var n=ne();if(F(e.comma)){var r=ne();F(e.comma);var i=ne(),a=[n,r,i];return F(e.comma)?(a.push(ne()),{type:`rgba`,value:a}):{type:t,value:a}}else{var r=ne(),i=ne(),a=[n,r,i];return F(e.slash)?(a.push(ne()),{type:`rgba`,value:a}):{type:t,value:a}}}function ee(){return s(e.varColor,function(){return{type:`var`,value:M()}})}function A(){return s(e.hslColor,function(){return te(`hsl`)})}function j(){return s(e.hslaColor,function(){return te(`hsla`)})}function te(t){F(e.percentageValue)&&n(`HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage`);var r=ne();if(F(e.comma)){var i=F(e.percentageValue),a=i?i[1]:null;F(e.comma),i=F(e.percentageValue);var o=i?i[1]:null;if((!a||!o)&&n(`Expected percentage value for saturation and lightness in HSL`),F(e.comma)){var s=ne();return{type:`hsla`,value:[r,a,o,s]}}return{type:t,value:[r,a,o]}}else{var i=F(e.percentageValue),a=i?i[1]:null;i=F(e.percentageValue);var o=i?i[1]:null;if((!a||!o)&&n(`Expected percentage value for saturation and lightness in HSL`),F(e.slash)){var s=ne();return{type:`hsla`,value:[r,a,o,s]}}return{type:t,value:[r,a,o]}}}function M(){return F(e.variableName)[1]}function ne(){return F(e.number)[1]}function N(){return ae(`%`,e.percentageValue,1)||P()||re()||ie()}function P(){return ae(`position-keyword`,e.positionKeywords,1)}function re(){return s(e.calcValue,function(){for(var e=1,r=0;e>0&&r<t.length;){var i=t.charAt(r);i===`(`?e++:i===`)`&&e--,r++}e>0&&n(`Missing closing parenthesis in calc() expression`);var a=t.substring(0,r-1);return oe(r-1),{type:`calc`,value:a}})}function ie(){return ae(`px`,e.pixelValue,1)||ae(`em`,e.emValue,1)||ae(`rem`,e.remValue,1)||ae(`vw`,e.vwValue,1)||ae(`vh`,e.vhValue,1)||ae(`vmin`,e.vminValue,1)||ae(`vmax`,e.vmaxValue,1)||ae(`ch`,e.chValue,1)||ae(`ex`,e.exValue,1)}function ae(e,t,n){var r=F(t);if(r)return{type:e,value:r[n]}}function F(e){var n,r=/^[\n\r\t\s]+/.exec(t);return r&&oe(r[0].length),n=e.exec(t),n&&oe(n[0].length),n}function oe(e){t=t.substring(e)}return function(e){return t=e.toString().trim(),t.endsWith(`;`)&&(t=t.slice(0,-1)),r()}})(),ay.parse,ay.stringify;var oy={parse:ay.parse,stringify:ay.stringify},sy=e=>e.indexOf(`linear-gradient`)>=0,cy=e=>e.type===`hex`?`#`+e.value:e.type===`literal`?e.value:`${e.type}(${e.value.join(`,`)})`,ly=e=>{if(!sy(e))return{rotation:0,stops:[{offset:0,color:e},{offset:1,color:e}]};let t=oy.parse(e)[0];return{rotation:t.orientation&&`value`in t.orientation?parseFloat(t.orientation.value):0,stops:t.colorStops.map((e,n)=>({color:cy(e),offset:e.length?parseFloat(e.length.value)/100:n/(t.colorStops.length-1)}))}},uy=o(((e,t)=>{e=t.exports=n;function n(e){return r.bind(null,e)}function r(e){var t=[].slice.call(arguments,1);t.unshift(`[`+e+`]`),process.stderr.write(t.join(` `)+`
|
|
53
|
+
`)}})),dy=o(((e,t)=>{var n=!1,r=!1,i=uy()(`lex`);e=t.exports=a;function a(e){var t,a=``,o,s=0,c=-1,l=0,u=1,d=`before-selector`,f=[d],p={},m=[],h=[`media`,`keyframes`,{name:`-webkit-keyframes`,type:`keyframes`,prefix:`-webkit-`},{name:`-moz-keyframes`,type:`keyframes`,prefix:`-moz-`},{name:`-ms-keyframes`,type:`keyframes`,prefix:`-ms-`},{name:`-o-keyframes`,type:`keyframes`,prefix:`-o-`},`font-face`,{name:`import`,state:`before-at-value`},{name:`charset`,state:`before-at-value`},`supports`,`viewport`,{name:`namespace`,state:`before-at-value`},`document`,{name:`-moz-document`,type:`document`,prefix:`-moz-`},`page`];function g(){return T(),e[c]}function _(e){return e?f[f.length-1-e]:d}function v(t){var n=c+1;return t===e.slice(n,n+t.length)}function y(t){var n=e.slice(c).indexOf(t);return n>0?n:!1}function b(e){return e===x(1)}function x(t){return e[c+(t||1)]}function S(){var e=f.pop();return d=f[f.length-1],e}function C(e){return d=e,f.push(d),f.length}function w(e){var t=d;return f[f.length-1]=d=e,t}function T(t){if((t||1)==1)e[c]==`
|
|
54
|
+
`?(u++,s=1):s++,c++;else{var n=e.slice(c,c+t).split(`
|
|
55
|
+
`);n.length>1&&(u+=n.length-1,s=1),s+=n[n.length-1].length,c+=t}}function E(){p.end={line:u,col:s},n&&i(`addToken:`,JSON.stringify(p,null,2)),m.push(p),a=``,p={}}function D(e){p={type:e,start:{line:u,col:s}}}for(r&&(t=Date.now());o=g();)switch(n&&i(o,_()),o){case` `:switch(_()){case`selector`:case`value`:case`value-paren`:case`at-group`:case`at-value`:case`comment`:case`double-string`:case`single-string`:a+=o;break}break;case`
|
|
56
|
+
`:case` `:case`\r`:case`\f`:switch(_()){case`value`:case`value-paren`:case`at-group`:case`comment`:case`single-string`:case`double-string`:case`selector`:a+=o;break;case`at-value`:o===`
|
|
57
|
+
`&&(p.value=a.trim(),E(),S());break}break;case`:`:switch(_()){case`name`:p.name=a.trim(),a=``,w(`before-value`);break;case`before-selector`:a+=o,D(`selector`),C(`selector`);break;case`before-value`:w(`value`),a+=o;break;default:a+=o;break}break;case`;`:switch(_()){case`name`:case`before-value`:case`value`:a.trim().length>0&&(p.value=a.trim(),E()),w(`before-name`);break;case`value-paren`:a+=o;break;case`at-value`:p.value=a.trim(),E(),S();break;case`before-name`:break;default:a+=o;break}break;case`{`:switch(_()){case`selector`:if(x(-1)===`\\`){a+=o;break}p.text=a.trim(),E(),w(`before-name`),l+=1;break;case`at-group`:switch(p.name=a.trim(),p.type){case`font-face`:case`viewport`:case`page`:C(`before-name`);break;default:C(`before-selector`)}E(),l+=1;break;case`name`:case`at-rule`:p.name=a.trim(),E(),C(`before-name`),l+=1;break;case`comment`:case`double-string`:case`single-string`:a+=o;break;case`before-value`:w(`value`),a+=o;break}break;case`}`:switch(_()){case`before-name`:case`name`:case`before-value`:case`value`:a&&(p.value=a.trim()),p.name&&p.value&&E(),D(`end`),E(),S(),_()===`at-group`&&(D(`at-group-end`),E(),S()),l>0&&--l;break;case`at-group`:case`before-selector`:case`selector`:if(x(-1)===`\\`){a+=o;break}l>0&&_(1)===`at-group`&&(D(`at-group-end`),E()),l>1&&S(),l>0&&--l;break;case`double-string`:case`single-string`:case`comment`:a+=o;break}break;case`"`:case`'`:switch(_()){case`double-string`:o===`"`&&x(-1)!==`\\`&&S();break;case`single-string`:o===`'`&&x(-1)!==`\\`&&S();break;case`before-at-value`:w(`at-value`),C(o===`"`?`double-string`:`single-string`);break;case`before-value`:w(`value`),C(o===`"`?`double-string`:`single-string`);break;case`comment`:break;default:x(-1)!==`\\`&&C(o===`"`?`double-string`:`single-string`)}a+=o;break;case`/`:switch(_()){case`comment`:case`double-string`:case`single-string`:a+=o;break;case`before-value`:case`selector`:case`name`:case`value`:if(b(`*`)){var O=y(`*/`);O&&T(O+1)}else _()==`before-value`&&w(`value`),a+=o;break;default:b(`*`)?(D(`comment`),C(`comment`),T()):a+=o;break}break;case`*`:switch(_()){case`comment`:b(`/`)?(p.text=a,T(),E(),S()):a+=o;break;case`before-selector`:a+=o,D(`selector`),C(`selector`);break;case`before-value`:w(`value`),a+=o;break;default:a+=o}break;case`@`:switch(_()){case`comment`:case`double-string`:case`single-string`:a+=o;break;case`before-value`:w(`value`),a+=o;break;default:for(var k=!1,ee,A,j=0,te=h.length;!k&&j<te;++j)A=h[j],ee=A.name||A,v(ee)&&(k=!0,D(ee),C(A.state||`at-group`),T(ee.length),A.prefix&&(p.prefix=A.prefix),A.type&&(p.type=A.type));k||(a+=o);break}break;case`(`:switch(_()){case`value`:C(`value-paren`);break;case`before-value`:w(`value`);break}a+=o;break;case`)`:switch(_()){case`value-paren`:S();break;case`before-value`:w(`value`);break}a+=o;break;default:switch(_()){case`before-selector`:D(`selector`),C(`selector`);break;case`before-name`:D(`property`),w(`name`);break;case`before-value`:w(`value`);break;case`before-at-value`:w(`at-value`);break}a+=o;break}return r&&i(`ran in`,Date.now()-t+`ms`),m}})),fy=o(((e,t)=>{var n=!1,r=!1,i=uy()(`parse`),a=dy();e=t.exports=u;var o,s,c,l;function u(e,t){var n;t||={},o=!!t.comments,c=!!t.position,s=0,l=Array.isArray(e)?e.slice():a(e);var u,d=[],p;for(r&&(n=Date.now());p=f();)u=b(p),u&&d.push(u);return r&&i(`ran in`,Date.now()-n+`ms`),{type:`stylesheet`,stylesheet:{rules:d}}}function d(e,t){t||={};for(var r,a=[`type`,`name`,`value`],o={},s=0;s<a.length;++s)r=a[s],e[r]&&(o[r]=t[r]||e[r]);for(a=Object.keys(t),s=0;s<a.length;++s)r=a[s],o[r]||(o[r]=t[r]);return c&&(o.position={start:e.start,end:e.end}),n&&i(`astNode:`,JSON.stringify(o,null,2)),o}function f(){var e=l.shift();return n&&i(`next:`,JSON.stringify(e,null,2)),e}function p(e){s+=1;var t={};switch(e.type){case`font-face`:case`viewport`:t.declarations=S();break;case`page`:t.prefix=e.prefix,t.declarations=S();break;default:t.prefix=e.prefix,t.rules=C()}return d(e,t)}function m(e){return d(e)}function h(e){return d(e)}function g(e){return d(e,{text:e.text})}function _(e){return d(e)}function v(e){return d(e)}function y(e){function t(e){return e.trim()}return d(e,{type:`rule`,selectors:e.text.split(`,`).map(t),declarations:S(e)})}function b(e){switch(e.type){case`property`:return v(e);case`selector`:return y(e);case`at-group-end`:--s;return;case`media`:case`keyframes`:return p(e);case`comment`:if(o)return g(e);break;case`charset`:return h(e);case`import`:return m(e);case`namespace`:return _(e);case`font-face`:case`supports`:case`viewport`:case`document`:case`page`:return p(e)}n&&i(`parseToken: unexpected token:`,JSON.stringify(e))}function x(e){for(var t,n=[],r;(r=f())&&e&&e(r);)t=b(r),t&&n.push(t);return r&&r.type!==`end`&&l.unshift(r),n}function S(){return x(function(e){return e.type===`property`||e.type===`comment`})}function C(){return x(function(){return s})}})),py=o(((e,t)=>{var n=!1,r=!1,i=uy()(`stringify`),a,o,s,c,l,u;e=t.exports=d;function d(e,t){var n;t||={},s=t.indentation||``,o=!!t.compress,a=!!t.comments,c=1,o?l=u=``:(l=`
|
|
58
|
+
`,u=` `),r&&(n=Date.now());var d=_(e.stylesheet.rules,x).join(`
|
|
59
|
+
`).trim();return r&&i(`ran in`,Date.now()-n+`ms`),d}function f(e){if(e){c+=e;return}return o?``:Array(c).join(s||``)}function p(e){return`@`+e.type+` `+e.value+`;`+l}function m(e){var t=``,n=e.prefix||``;e.name&&(t=` `+e.name);var r=e.type!==`page`;return`@`+n+e.type+t+u+v(e,r)+l}function h(e){return a?`/*`+(e.text||``)+`*/`+l:``}function g(e){var t;return e.selectors?t=e.selectors.join(`,`+l):(t=`@`+e.type,t+=e.name?` `+e.name:``),f()+t+u+v(e)+l}function _(e,t){return e.reduce(function(e,n){var r=n.type===`comment`?h(n):t(n);return r&&e.push(r),e},[])}function v(e,t){var n=e.declarations,r=b;return e.rules&&(n=e.rules,r=g),n=y(n,r),n&&=l+n+(t?``:l),`{`+n+f()+`}`}function y(e,t){if(!e)return``;f(1);var n=_(e,t);return f(-1),n.length?n.join(l):``}function b(e){if(e.type===`property`)return S(e);n&&i(`stringifyDeclaration: unexpected node:`,JSON.stringify(e))}function x(e){switch(e.type){case`rule`:return g(e);case`media`:case`keyframes`:return m(e);case`comment`:return h(e);case`import`:case`charset`:case`namespace`:return p(e);case`font-face`:case`supports`:case`viewport`:case`document`:case`page`:return m(e)}n&&i(`stringifyNode: unexpected node: `+JSON.stringify(e))}function S(e){var t=e.name?e.name+`:`+u:``;return f()+t+e.value+`;`}})),my=l(o(((e,t)=>{t.exports={lex:dy(),parse:fy(),stringify:py()}}))(),1);function hy(e){for(;e.parentNode;){if(e.nodeName===`defs`)return!0;e=e.parentNode}return!1}function gy(e){let t={};return e.querySelectorAll(`style`).forEach(e=>{let n=my.default.parse(e.textContent).stylesheet.rules;for(let e of n)e.selectors&&e.selectors.forEach(n=>{let r=t[n]||{};e.declarations.forEach(e=>{r[e.name]=e.value}),t[n]=r})}),t}function _y(e,t){let n={fill:``,stroke:``},r=e.getAttribute(`class`)?.split(` `)||[],i=e.getAttribute(`id`),a={};i&&t[`#${i}`]?a=t[`#${i}`]:r.forEach(e=>{t[`.${e}`]&&(a=Object.assign(Object.assign({},a),t[`.${e}`]))}),t[e.nodeName]&&(a=Object.assign(Object.assign({},a),t[e.nodeName]));let o=e.getAttribute(`fill`);o&&o!==`none`?n.fill=o:a.fill&&a.fill!==`none`&&(n.fill=a.fill);let s=e.getAttribute(`stroke`);if(s&&s!==`none`?n.stroke=s:a.stroke&&a.stroke!==`none`&&(n.stroke=a.stroke),!n.fill&&e.style.fill&&e.style.fill!==`none`&&(n.fill=e.style.fill),!n.stroke&&e.style.stroke&&e.style.stroke!==`none`&&(n.stroke=e.style.stroke),!n.stroke&&!n.fill){let r=e.ownerSVGElement,i=r&&r!==e?_y(r,t):null;i?.fill===`currentColor`||i?.stroke===`currentColor`||(n.fill=`black`)}return n}var vy=[`path`,`rect`,`circle`,`line`,`polygon`,`polyline`,`ellipse`,`text`];function yy(e){for(var t=[],n=e.getElementsByTagName(`*`),r=0,i=n.length;r<i;r++){let e=n[r];hy(e)||(e.getAttribute(`fill`)!==null&&t.push(e),(e.getAttribute(`stroke`)!==null||e.style&&e.style.fill||vy.indexOf(e.nodeName)>=0)&&t.push(e))}return t}async function by(e){return Sy(await(await fetch(e)).text())}async function xy(e){return await(await fetch(e,{mode:`cors`})).text()}function Sy(e){return`data:image/svg+xml;base64,`+window.btoa(unescape(encodeURIComponent(e)))}function Cy(e){var t=new DOMParser().parseFromString(e,`image/svg+xml`);let[n,r,i,a]=t.documentElement.getAttribute(`viewBox`)?.split(` `)||[],o=t.documentElement.getAttribute(`width`);!o&&t.documentElement.setAttribute(`width`,i+`px`);let s=t.documentElement.getAttribute(`height`);if((!s||s.indexOf(`%`)>=0)&&t.documentElement.setAttribute(`height`,a+`px`),o&&o.indexOf(`%`)>=0&&s&&s.indexOf(`%`)===-1){let e=parseFloat(s)/parseFloat(a);t.documentElement.setAttribute(`width`,e*parseFloat(i)+`px`)}if(s&&s.indexOf(`%`)>=0&&o&&o.indexOf(`%`)===-1){let e=parseFloat(o)/parseFloat(i);t.documentElement.setAttribute(`height`,e*parseFloat(a)+`px`)}return o===`100%`&&s===`100%`&&(t.documentElement.setAttribute(`width`,i+`px`),t.documentElement.setAttribute(`height`,a+`px`)),new XMLSerializer().serializeToString(t)}var wy=(e,t)=>{if(!e||!t)return!1;if(t===`currentColor`&&e===`black`)return!0;let n=W.Util.colorToRGBA(e),r=W.Util.colorToRGBA(t);return n&&r?n.r===r.r&&n.g===r.g&&n.b===r.b&&n.a===r.a:void 0};function Ty(e,t){var n=new DOMParser().parseFromString(e,`image/svg+xml`);let r=yy(n),i=Array.from(t.keys()),a=gy(n);return r.forEach(e=>{let{fill:r,stroke:o}=_y(e,a);[{prop:`fill`,color:r},{prop:`stroke`,color:o}].forEach(({prop:r,color:a})=>{let o=i.find(e=>wy(e,a));if(o){let i=t.get(o);if(sy(i)){let{rotation:t,stops:a}=ly(i),o=a.map(e=>({offset:100*e.offset+`%`,"stop-color":e.color})),s=`color`+Math.round(1e8*Math.random());(function(e,t,n,r){var i=e.namespaceURI,a=document.createElementNS(i,`linearGradient`);let o=W.Util.degToRad(n+90),s=(Math.cos(o)+1)/2,c=(Math.sin(o)+1)/2,l=(Math.cos(o+Math.PI)+1)/2,u=(Math.sin(o+Math.PI)+1)/2;a.setAttribute(`x1`,100*s+`%`),a.setAttribute(`y1`,100*c+`%`),a.setAttribute(`x2`,100*l+`%`),a.setAttribute(`y2`,100*u+`%`),a.setAttribute(`gradientUnits`,`userSpaceOnUse`),a.setAttribute(`id`,t);for(var d=0;d<r.length;d++){var f=r[d],p=document.createElementNS(i,`stop`);for(var m in f)f.hasOwnProperty(m)&&p.setAttribute(m,f[m]);a.appendChild(p)}(e.querySelector(`defs`)||e.insertBefore(document.createElementNS(i,`defs`),e.firstChild)).appendChild(a)})(n.children[0],s,t,o),e.style[r]=null,e.setAttribute(r,`url('#${s}')`)}else e.style[r]=t.get(o)}})}),Sy(new XMLSerializer().serializeToString(n))}function Ey(e){return new Promise((t,n)=>{let r=document.createElement(`img`);r.onload=()=>{t(r)},r.onerror=e=>{n(e)},r.crossOrigin=`anonymous`,r.src=e})}async function Dy(e,t){let n=await Ey(e),r=document.createElement(`canvas`);r.width=2*n.width,r.height=2*n.height,r.getContext(`2d`).drawImage(n,0,0,r.width,r.height);let i=document.createElement(`canvas`);i.width=t.width,i.height=t.height;let a=i.getContext(`2d`),{cropX:o,cropY:s}=t,c=r.width*t.cropWidth,l=r.height*t.cropHeight,u=t.width/t.height,d,f,p=c/l;return t.type===`svg`?(d=c,f=l):u>=p?(d=c,f=c/u):(d=l*u,f=l),a.drawImage(r,o*r.width,s*r.height,d,f,0,0,i.width,i.height),i.toDataURL(`image/png`)}function Oy(e,t){let{width:n,height:r}=e,i=n/r,a,o;i>=t.width/t.height?(a=t.width,o=t.width/i):(a=t.height*i,o=t.height);let s=(t.width-a)/2,c=(t.height-o)/2;return{cropX:s/t.width,cropY:c/t.height,cropWidth:a/t.width,cropHeight:o/t.height}}var ky=({width:e,height:t,cornerRadius:n})=>{if(n>0){let r=Math.min(n,e/2,t/2);return`M 0 ${r} A ${r} ${r} 0 0 1 ${r} 0 L ${e-r} 0 A ${r} ${r} 0 0 1 ${e} ${r} L ${e} ${t-r} A ${r} ${r} 0 0 1 ${e-r} ${t} L ${r} ${t} A ${r} ${r} 0 0 1 0 ${t-r} Z`}return`M 0 0 L ${e} 0 L ${e} ${t} L 0 ${t} Z`},Ay=({width:e,height:t})=>`M ${e/2} 0 L ${e} ${t} L 0 ${t} Z`,jy=({width:e,height:t})=>`M 0 0 L ${e} 0 L 0 ${t} Z`,My=({width:e,height:t})=>`M ${e/2} ${t/2} m -${e/2}, 0 a ${e/2},${t/2} 0 1,0 ${e},0 a ${e/2},${t/2} 0 1,0 -${e},0`;function Ny({width:e,height:t}){let n=e/2,r=t/2,i=e/2,a=t/2,o=i/2,s=a/2,c=``,l=Math.PI/5;for(let e=0;e<10;e++){let t=e%2==0?a:s,u=n+(e%2==0?i:o)*Math.sin(e*l),d=r-t*Math.cos(e*l);e===0?c=`M ${u} ${d}`:c+=` L ${u} ${d}`}return c+` Z`}function Py({width:e,height:t}){let n=e/2,r=t/2;return`M ${n} 0 L ${e} ${r} L ${n} ${t} L 0 ${r} Z`}function Fy({width:e,height:t}){let n=e/2,r=t/2,i=e/2,a=t/2,o=``,s=2*Math.PI/5;for(let e=0;e<5;e++){let t=a,c=n+i*Math.sin(e*s),l=r-t*Math.cos(e*s);e===0?o=`M ${c} ${l}`:o+=` L ${c} ${l}`}return o+` Z`}function Iy({width:e,height:t}){let n=e/2,r=t/2,i=e/2,a=t/2,o=``,s=2*Math.PI/6;for(let e=0;e<6;e++){let t=a,c=n+i*Math.sin(e*s),l=r-t*Math.cos(e*s);e===0?o=`M ${c} ${l}`:o+=` L ${c} ${l}`}return o+` Z`}function q({path:e,aspectRatio:t,width:n,height:r}){return{path:e,scaleX:n/t.width,scaleY:r/t.height}}function Ly({width:e,height:t}){let n=.1*Math.min(e,t),r=.2*e,i=.2*t,a=.5*e,o=`M ${n},0`;return o+=` H `+(e-n),o+=` A ${n},${n} 0 0 1 ${e},${n}`,o+=` V `+(t-n-i),o+=` A ${n},${n} 0 0 1 ${e-n},${t-i}`,o+=` H ${a+r/2}`,o+=` L ${a},${t}`,o+=` L ${a-r/2},${t-i}`,o+=` H ${n}`,o+=` A ${n},${n} 0 0 1 0,${t-n-i}`,o+=` V ${n}`,o+=` A ${n},${n} 0 0 1 ${n},0`,o+=` Z`,o}function Ry({width:e,height:t}){let n=.3*e,r=.3*t,i=e/2,a=t/2,o=i-n/2,s=i+n/2,c=a-r/2,l=a+r/2,u=`M ${o},0 `;return u+=`H ${s} `,u+=`V ${c} `,u+=`H ${e} `,u+=`V ${l} `,u+=`H ${s} `,u+=`V ${t} `,u+=`H ${o} `,u+=`V ${l} `,u+=`H 0 `,u+=`V ${c} `,u+=`H ${o} `,u+=`V 0 `,u+=`Z`,u}var zy={rect:ky,circle:My,star:Ny,triangle:Ay,rightTriangle:jy,diamond:Py,pentagon:Fy,hexagon:Iy,speechBubble:Ly,cross:Ry,arc:({width:e,height:t})=>q({path:`M234 117C234 85.97 221.673 56.21 199.731 34.269C177.79 12.327 148.03 0 117 0C85.97 0 56.2103 12.327 34.2685 34.268C12.3268 56.21 0 85.97 0 117H117H234Z`,aspectRatio:{width:234,height:117},width:e,height:t}),cloud:({width:e,height:t})=>q({path:`M216.41 57.006C216.961 54.084 217.249 51.069 217.249 47.986C217.249 21.4841 195.972 0 169.725 0C153.666 0 139.467 8.043 130.865 20.3575C122.606 13.3566 111.954 9.1402 100.327 9.1402C74.3322 9.1402 53.2123 30.2136 52.8094 56.364H52.8035C23.6407 56.364 0 80.235 0 109.682C0 139.129 23.6407 163 52.8035 163H208.197C237.359 163 261 139.129 261 109.682C261 83.056 241.672 60.99 216.41 57.006Z`,aspectRatio:{width:261,height:163},width:e,height:t}),rightArrow:({width:e,height:t})=>{let n=.6*e;return`M 0 ${t/4} L ${n} ${t/4} L ${n} 0 L ${e} ${t/2} L ${n} ${t} L ${n} ${.75*t} L 0 ${.75*t} Z`},leftArrow:({width:e,height:t})=>{let n=.4*e;return`M ${e} ${t/4} L ${n} ${t/4} L ${n} 0 L 0 ${t/2} L ${n} ${t} L ${n} ${.75*t} L ${e} ${.75*t} Z`},downArrow:({width:e,height:t})=>{let n=.6*t;return`M ${e/4} 0 L ${e/4} ${n} L 0 ${n} L ${e/2} ${t} L ${e} ${n} L ${.75*e} ${n} L ${.75*e} 0 Z`},upArrow:({width:e,height:t})=>{let n=.4*t;return`M ${e/4} ${t} L ${e/4} ${n} L 0 ${n} L ${e/2} 0 L ${e} ${n} L ${.75*e} ${n} L ${.75*e} ${t} Z`},asterisk1:({width:e,height:t})=>q({path:`M45.5265 218.498C51.5466 222.87 58.5359 224.98 65.4742 224.98C75.916 224.98 86.221 220.2 92.853 211.217C92.872 211.198 92.89 211.178 92.907 211.157C92.923 211.136 92.939 211.115 92.954 211.094L92.977 211.061C92.993 211.039 93.008 211.017 93.023 210.996L116.491 178.725L139.959 210.996C139.982 211.031 140.006 211.058 140.029 211.088C140.04 211.102 140.05 211.116 140.061 211.132C151.115 226.188 172.355 229.505 187.473 218.515C202.608 207.526 205.992 186.278 195.074 171.104L195.05 171.066C195.03 171.034 195.014 171.01 194.989 170.985L171.572 138.696L209.512 126.346C227.334 120.545 237.129 101.305 231.33 83.476C225.532 65.648 206.315 55.8493 188.476 61.6334L150.537 73.933L150.52 34.0064C150.502 15.2594 135.248 0 116.508 0C97.768 0 82.514 15.2594 82.497 34.0234L82.463 73.916L44.5233 61.6163C44.5083 61.6163 44.49 61.613 44.4716 61.6078C44.4477 61.6014 44.4232 61.5918 44.4041 61.5823C26.5992 55.8664 7.45076 65.665 1.66886 83.46C-4.11314 101.254 5.61427 120.426 23.3511 126.278C23.3675 126.283 23.3822 126.289 23.3963 126.295L23.4588 126.319L23.4873 126.329L61.4098 138.679L37.9929 170.968C37.9844 170.985 37.9718 171.002 37.9591 171.019C37.9462 171.036 37.9336 171.053 37.9251 171.07C26.9903 186.244 30.3915 207.509 45.5265 218.498Z`,aspectRatio:{width:233,height:225},width:e,height:t}),asterisk2:({width:e,height:t})=>q({path:`M46.0556 112L0 85.388L33.9456 26.6121L80.028 53.1781L80.054 0H147.946L147.972 53.1781L194.054 26.6121L228 85.388L181.944 112L228 138.612L194.054 197.388L147.972 170.822L147.946 224H80.054L80.028 170.822L33.9456 197.388L0 138.612L46.0556 112Z`,aspectRatio:{width:228,height:224},width:e,height:t}),bookmark:({width:e,height:t})=>q({path:`M0 0H199V238L99.5 142.8L0 238V0Z`,aspectRatio:{width:199,height:238},width:e,height:t}),butterfly:({width:e,height:t})=>q({path:`M94.5 100.713C91.935 150.916 50.703 190.909 0 191.493V0C50.703 0.5845 91.935 40.5767 94.5 90.78C97.031 41.2385 137.217 1.6407 187 0.0438004V191.45C137.217 189.853 97.031 150.255 94.5 100.713Z`,aspectRatio:{width:187,height:192},width:e,height:t}),cylinder:({width:e,height:t})=>q({path:`M169 36.8497V218.15C169 238.502 131.168 255 84.5 255C37.832 255 0 238.502 0 218.15V36.8497C0 16.4982 37.832 0 84.5 0C131.168 0 169 16.4982 169 36.8497Z`,aspectRatio:{width:169,height:255},width:e,height:t}),diamond2:({width:e,height:t})=>q({path:`M0 55.5L124 185L248 55.5L189.307 0H58.6933L0 55.5Z`,aspectRatio:{width:248,height:185},width:e,height:t}),door:({width:e,height:t})=>q({path:`M140 69.697C140 31.2044 108.66 0 70 0C31.34 0 0 31.2044 0 69.697V207H140V69.697Z`,aspectRatio:{width:140,height:207},width:e,height:t}),drop1:({width:e,height:t})=>q({path:`M167 150.687C167 196.328 129.407 234 83.139 234C37.593 234 0 196.328 0 150.687C0 100.7 51.329 36.9474 83.139 0C114.948 39.1207 167 98.526 167 150.687Z`,aspectRatio:{width:167,height:234},width:e,height:t}),drop2:({width:e,height:t})=>q({path:`M73 239C53.64 239 35.071 231.315 21.3812 217.634C7.691 203.954 0 185.4 0 166.054C0 136.091 13.8696 113.633 30.768 86.27C43.912 64.9877 58.888 40.7377 70.597 7.6816C71.281 5.7496 72.989 0 72.989 0C72.989 0 72.993 0.0124998 73 0.0363998C73.007 0.0124998 73.011 0 73.011 0C73.011 0 74.719 5.7496 75.403 7.6816C87.112 40.7377 102.088 64.9877 115.232 86.27C132.13 113.633 146 136.091 146 166.054C146 185.4 138.309 203.954 124.619 217.634C111.025 231.218 92.225 239 73 239Z`,aspectRatio:{width:146,height:239},width:e,height:t}),explosion:({width:e,height:t})=>q({path:`M165.802 184.465L118.997 260L125.343 182.079L34.9058 219.45L99.164 159.817L0 163.792L78.538 134.373L0 74.7401L86.471 89.052V0L118.997 89.052L165.802 10.3364L149.143 97.798L217.368 29.419L165.802 112.905L245.927 81.101L165.802 143.914H261L165.802 184.465Z`,aspectRatio:{width:261,height:260},width:e,height:t}),flag:({width:e,height:t})=>q({path:`M0 142.161C0 142.161 51.9956 118.626 103 137.469C159.992 158.525 206 141.31 206 141.31V11.1373C206 11.1373 160 28.3218 103.016 7.28273C52 -11.553 0 12.0974 0 12.0974V142.161Z`,aspectRatio:{width:206,height:148},width:e,height:t}),flower:({width:e,height:t})=>q({path:`M135.351 66.1893C196.683 -5.00591 256.536 100.304 164.908 117.361C256.536 135.16 195.944 239.728 135.351 168.532C166.386 257.526 45.9394 256.785 76.975 168.532C15.643 239.728 -44.2109 135.16 47.4173 117.361C-44.9498 100.304 15.643 -4.26431 76.975 66.1893C45.2005 -22.0631 166.386 -22.0631 135.351 66.1893ZM105.793 104.012C113.183 104.012 119.833 109.945 119.833 117.361C119.833 124.777 113.183 131.452 105.793 131.452C98.404 131.452 92.492 124.777 92.492 117.361C92.492 109.945 98.404 104.012 105.793 104.012Z`,aspectRatio:{width:212,height:235},width:e,height:t}),frame:({width:e,height:t})=>q({path:`M0 0H240L200 88L240 176H0L40 88L0 0Z`,aspectRatio:{width:240,height:176},width:e,height:t}),heart1:({width:e,height:t})=>q({path:`M215.886 56.157C215.886 24.729 191.112 0 160.584 0C135.933 0 115.08 16.983 107.937 39.93C100.788 16.986 79.935 0.591 55.284 0.591C24.75 0.591 0 24.615 0 56.055C0 71.919 6.321 83.127 16.494 95.121L107.988 189.447L199.377 95.121C209.559 83.127 215.886 72.009 215.886 56.157Z`,aspectRatio:{width:216,height:190},width:e,height:t}),home:({width:e,height:t})=>q({path:`M0 62.143L95.5 0L191 62.143V195H0V62.143Z`,aspectRatio:{width:191,height:195},width:e,height:t}),home2:({width:e,height:t})=>q({path:`M206 94.076L103 0L0 94.076H31.2377V189H175.607V94.076H206Z`,aspectRatio:{width:206,height:189},width:e,height:t}),hourglass:({width:e,height:t})=>q({path:`M0.392782 0H187.607C193.014 43.3688 140.804 53.797 140.804 97.5C140.804 141.203 193.014 151.631 187.607 195H0.392782C-5.01452 151.631 47.196 141.203 47.196 97.5C47.196 53.797 -5.01452 43.3688 0.392782 0Z`,aspectRatio:{width:188,height:195},width:e,height:t}),house:({width:e,height:t})=>q({path:`M0 92.367L95 0L190 92.367V223H0V92.367Z`,aspectRatio:{width:190,height:223},width:e,height:t}),keyhole:({width:e,height:t})=>q({path:`M115 57.0494C115 25.5387 89.416 0 57.863 0C26.311 0 0.726898 25.5414 0.726898 57.0494C0.726898 78.652 12.759 97.451 30.505 107.136L0 219H114.845L84.448 107.524C102.608 97.962 115 78.959 115 57.0494Z`,aspectRatio:{width:115,height:219},width:e,height:t}),kiss:({width:e,height:t})=>q({path:`M124.5 17.1468C80.036 -36.5162 0 52.9218 0 52.9218C0 52.9218 44.4643 120 124.5 120C204.536 120 249 52.9218 249 52.9218C249 52.9218 168.964 -36.5162 124.5 17.1468Z`,aspectRatio:{width:249,height:120},width:e,height:t}),leaf:({width:e,height:t})=>q({path:`M204.414 0.0151567C204.414 0.0151567 206.837 93.9509 150.394 150.394C93.9507 206.837 0.0151569 204.413 0.0151569 204.413C0.0151569 204.413 -2.40835 110.478 54.0347 54.0349C110.478 -2.40834 204.414 0.0151567 204.414 0.0151567Z`,aspectRatio:{width:205,height:205},width:e,height:t}),lightning1:({width:e,height:t})=>q({path:`M111.5 0L0 142H51.433L31.5 253L143 111H91.567L111.5 0Z`,aspectRatio:{width:143,height:253},width:e,height:t}),lightning2:({width:e,height:t})=>q({path:`M126 0H43L0 120.531H36L6 227L110 80.354H73L126 0Z`,aspectRatio:{width:126,height:227},width:e,height:t}),magnet:({width:e,height:t})=>q({path:`M88.402 0H0V67.669H88.402C105.271 67.669 118.957 81.308 118.957 98C118.957 114.689 105.271 128.331 88.402 128.331H0V196H88.402C142.747 196 187 152.072 187 98C187 43.9279 142.747 0 88.402 0Z`,aspectRatio:{width:187,height:196},width:e,height:t}),mithosis:({width:e,height:t})=>q({path:`M150.996 136.45C137.141 128.926 117.559 128.7 103.532 135.896C93.843 140.867 82.875 143.67 71.2577 143.67C31.9033 143.67 0 111.508 0 71.835C0 32.161 31.9033 0 71.2577 0C83.467 0 94.959 3.0955 105.004 8.5504C118.859 16.0745 138.441 16.3 152.467 9.1038C162.157 4.1328 173.125 1.3303 184.742 1.3303C224.097 1.3303 256 33.492 256 73.165C256 112.839 224.097 145 184.742 145C172.533 145 161.041 141.905 150.996 136.45Z`,aspectRatio:{width:256,height:145},width:e,height:t}),orangeRicky:({width:e,height:t})=>q({path:`M69 0H0V69V138V207H69H138V138H69V69V0Z`,aspectRatio:{width:138,height:207},width:e,height:t}),party:({width:e,height:t})=>q({path:`M134.622 0L144.682 68.2539L174.415 5.9977L163.91 74.1846L210.671 23.4578L180.535 85.519L240.169 50.8289L193.079 101.25L260.29 85.679L200.43 119.98L269.245 124.911L201.934 140.044L266.237 165.04L197.456 159.661L251.535 202.5L187.396 177.086L226.445 233.962L172.646 190.771L193.197 256.631L154.518 199.501L154.743 268.492L134.622 202.5L114.501 268.492L114.727 199.501L76.0482 256.631L96.5985 190.771L42.7992 233.962L81.8489 177.086L17.7091 202.5L71.7885 159.661L3.0072 165.04L67.3112 140.044L0 124.911L68.8149 119.98L8.9545 85.679L76.1658 101.25L29.0753 50.8289L88.7105 85.519L58.5743 23.4578L105.335 74.1846L94.8305 5.9977L124.562 68.2539L134.622 0Z`,aspectRatio:{width:270,height:269},width:e,height:t}),pillow:({width:e,height:t})=>q({path:`M176 0.00169945C157.812 16.9062 125.203 28.174 88.001 28.174C50.798 28.174 18.1881 16.9054 0 0V258.421C18.1882 241.516 50.798 230.248 88 230.248C125.202 230.248 157.812 241.516 176 258.421V0.00169945Z`,aspectRatio:{width:176,height:259},width:e,height:t}),polygon:({width:e,height:t})=>q({path:`M110 0L219.119 63V189L110 252L0.880798 189V63L110 0Z`,aspectRatio:{width:220,height:252},width:e,height:t}),rainbow:({width:e,height:t})=>q({path:`M186.907 141H282C282 63.128 218.872 0 141 0C63.1278 0 0 63.128 0 141H95.093C95.093 115.646 115.646 95.093 141 95.093C166.354 95.093 186.907 115.646 186.907 141Z`,aspectRatio:{width:282,height:141},width:e,height:t}),rhodeIsland:({width:e,height:t})=>q({path:`M69 0H0V69V138H69V207H138V138V69H69V0Z`,aspectRatio:{width:138,height:207},width:e,height:t}),shell:({width:e,height:t})=>q({path:`M109 0C169.199 0 218 48.743 218 108.87C185.392 108.87 158.958 135.273 158.958 167.842C158.958 179.736 158.958 191 158.958 191H59.042C59.042 191 59.042 179.736 59.042 167.842C59.042 135.273 32.6077 108.87 0 108.87C0 48.743 48.8007 0 109 0Z`,aspectRatio:{width:218,height:191},width:e,height:t}),shield1:({width:e,height:t})=>q({path:`M203.184 30.7277C142.457 30.7277 102.853 0 102.853 0C102.853 0 63.249 30.7277 3.05098 30.7277C3.05098 30.7277 -3.81372 128.209 3.05098 162.115C9.38758 193.902 102.853 249 102.853 249C102.853 249 196.319 193.902 203.184 162.115C209.52 128.738 203.184 30.7277 203.184 30.7277Z`,aspectRatio:{width:206,height:249},width:e,height:t}),shield2:({width:e,height:t})=>q({path:`M0 12.9585C64.624 -4.3195 136.376 -4.3195 201 12.9585C201 51.0564 201 89.154 201 127.252C201 184.396 100.498 240 100.498 240C100.498 240 0 184.406 0 127.252C0 89.154 0 51.0564 0 12.9585Z`,aspectRatio:{width:201,height:240},width:e,height:t}),skewedRectangle:({width:e,height:t})=>q({path:`M85.9799 0H290L204.02 141H0L85.9799 0Z`,aspectRatio:{width:290,height:141},width:e,height:t}),softFlower:({width:e,height:t})=>q({path:`M109 0C80.073 0 56.6234 23.4498 56.6234 52.3766C56.6234 54.722 54.722 56.6234 52.3766 56.6234C23.4498 56.6234 0 80.073 0 109C0 137.927 23.4498 161.377 52.3766 161.377C54.722 161.377 56.6234 163.278 56.6234 165.623C56.6234 194.55 80.073 218 109 218C137.927 218 161.377 194.55 161.377 165.623C161.377 163.278 163.278 161.377 165.623 161.377C194.55 161.377 218 137.927 218 109C218 80.073 194.55 56.6234 165.623 56.6234C163.278 56.6234 161.377 54.722 161.377 52.3766C161.377 23.4498 137.927 0 109 0Z`,aspectRatio:{width:218,height:218},width:e,height:t}),softStar:({width:e,height:t})=>q({path:`M130.424 3.17662C130.927 -1.05888 137.073 -1.05888 137.576 3.17662L141.792 38.7086C147.236 84.59 183.41 120.764 229.291 126.208L264.823 130.424C269.059 130.927 269.059 137.073 264.823 137.576L229.291 141.792C183.41 147.236 147.236 183.41 141.792 229.291L137.576 264.823C137.073 269.059 130.927 269.059 130.424 264.823L126.208 229.291C120.764 183.41 84.59 147.236 38.7086 141.792L3.17662 137.576C-1.05888 137.073 -1.05888 130.927 3.17662 130.424L38.7086 126.208C84.59 120.764 120.764 84.59 126.208 38.7086L130.424 3.17662Z`,aspectRatio:{width:268,height:268},width:e,height:t}),stairs1:({width:e,height:t})=>q({path:`M0 0H67.667V67.667H135.333V135.333H203V203H0V0Z`,aspectRatio:{width:203,height:203},width:e,height:t}),stairs2:({width:e,height:t})=>q({path:`M50 0H0V200H200V150H150V100H100V50H50V0Z`,aspectRatio:{width:200,height:200},width:e,height:t}),teewee:({width:e,height:t})=>q({path:`M69 0H138V69H207V138H138H69H0V69H69V0Z`,aspectRatio:{width:207,height:138},width:e,height:t}),blob1:({width:e,height:t})=>q({path:`M172.979 19.611C191.285 33.0858 204.505 54.442 210.861 78.5949C217.471 103.002 217.471 130.46 205.776 151.816C194.335 173.427 171.454 189.444 147.047 196.054C122.639 202.919 96.7069 200.631 75.3506 190.715C54.2486 180.546 37.7229 163.003 23.4855 142.155C9.5022 121.307 -2.19289 97.4087 0.349524 74.7813C3.14617 52.1538 19.9261 30.7976 40.2654 17.8313C60.6046 4.61077 84.5033 -0.474048 108.148 0.0344341C131.538 0.542916 154.928 6.13621 172.979 19.611Z`,aspectRatio:{width:216,height:200},width:e,height:t}),blob10:({width:e,height:t})=>q({path:`M188.684 8.95173C205.601 24.3309 200.988 63.0866 191.453 99.3816C182.225 135.677 168.076 169.511 146.238 175.355C124.399 181.507 94.871 159.668 66.5733 143.059C37.9679 126.449 10.5929 115.068 2.59569 95.0754C-5.4015 75.0824 5.97912 46.1694 24.4342 30.4826C42.8893 14.7958 68.4188 12.0276 100.715 6.79864C132.704 1.5697 171.767 -6.42749 188.684 8.95173Z`,aspectRatio:{width:200,height:177},width:e,height:t}),blob11:({width:e,height:t})=>q({path:`M137.368 29.4923C148.97 46.7605 146.542 72.1231 148.161 99.1046C149.779 126.086 155.715 154.956 144.113 174.383C132.781 193.81 103.911 203.793 80.4369 198.666C56.963 193.27 38.6156 173.034 28.3626 153.607C17.8398 134.181 15.4115 115.833 9.47555 91.5498C3.53961 67.2664 -5.63411 37.3169 4.61887 20.0488C15.1417 2.51078 45.0911 -1.80626 72.8821 0.622074C100.673 2.78059 126.036 12.2241 137.368 29.4923Z`,aspectRatio:{width:152,height:200},width:e,height:t}),blob12:({width:e,height:t})=>q({path:`M158.391 17.923C172.491 28.5703 180.261 48.1384 187.743 70.5842C194.937 93.3177 202.419 118.641 194.649 138.785C187.167 158.928 164.146 173.317 138.535 184.54C112.923 196.05 84.4347 204.108 58.8235 197.777C33.2123 191.446 10.191 170.439 2.99688 146.267C-4.48504 121.807 3.57241 94.181 10.4788 68.282C17.0974 42.0953 22.565 17.6352 37.8166 7.27563C53.0682 -3.37171 78.1038 0.081487 100.837 2.67138C123.859 5.26127 144.29 7.27563 158.391 17.923Z`,aspectRatio:{width:198,height:200},width:e,height:t}),blob13:({width:e,height:t})=>q({path:`M149.668 1.37595C170.663 5.22017 193.728 17.3442 198.755 34.7911C204.078 52.2379 191.363 75.3032 178.943 93.9329C166.819 112.563 154.99 126.757 140.501 145.386C126.011 164.312 108.86 187.673 92.5957 186.194C76.3317 185.011 60.9549 159.285 45.8737 140.655C30.4968 122.321 15.7114 110.788 7.43151 95.1157C-0.848339 79.4432 -2.32688 59.0392 3.5873 41.5924C9.50148 23.8498 23.1041 8.76868 38.7767 3.44592C54.745 -1.87685 73.3746 2.55879 91.7086 2.26308C110.338 2.26308 128.968 -2.17256 149.668 1.37595Z`,aspectRatio:{width:200,height:187},width:e,height:t}),blob14:({width:e,height:t})=>q({path:`M137.838 28.6426C150.711 40.5617 165.014 46.5213 178.363 58.2021C191.474 69.8828 203.87 87.0464 198.864 99.6807C193.858 112.315 171.689 120.42 157.862 135.676C144.275 151.171 139.269 173.579 126.873 182.161C114.477 190.505 94.9294 185.022 76.8123 178.109C58.4568 171.196 41.5316 163.091 28.1822 150.456C14.5943 137.822 4.58225 120.42 1.24488 101.826C-2.09248 83.2322 1.00651 62.9697 13.8792 52.4809C26.7519 41.992 49.1598 41.0385 65.6083 30.788C82.0567 20.5376 92.0688 0.990158 103.034 0.0366268C113.762 -0.916905 125.204 16.9618 137.838 28.6426Z`,aspectRatio:{width:200,height:187},width:e,height:t}),blob15:({width:e,height:t})=>q({path:`M185.203 1.52939C197.679 7.62217 200 32.2835 200 51.7223C200 71.1612 197.389 85.3777 197.679 100.175C198.259 114.681 201.741 129.768 198.259 143.114C194.778 156.46 184.623 168.356 171.567 173.868C158.801 179.671 143.134 179.091 130.368 174.739C117.312 170.387 106.867 162.263 86.8482 160.812C66.539 159.362 36.9454 164.294 18.9572 155.3C0.968966 146.306 -5.41395 123.095 5.03083 105.977C15.4756 88.5692 42.4579 77.5442 55.5139 59.5559C68.2798 41.8578 67.1192 17.4867 76.9837 9.6531C86.5581 2.10965 107.158 11.3939 128.627 9.6531C150.097 8.20244 172.728 -4.27327 185.203 1.52939Z`,aspectRatio:{width:200,height:179},width:e,height:t}),blob16:({width:e,height:t})=>q({path:`M158.441 55.3221C167.253 80.2399 160.264 105.462 147.501 134.938C134.738 164.717 116.81 199.055 97.0576 199.967C77.3057 201.182 55.7305 168.668 34.4592 133.722C13.1879 99.0802 -7.77953 62.3112 2.85612 36.4818C13.4918 10.6523 56.0344 -3.93369 90.0685 0.928322C123.799 6.09421 149.324 30.7081 158.441 55.3221Z`,aspectRatio:{width:163,height:200},width:e,height:t}),blob17:({width:e,height:t})=>q({path:`M168.917 36.7587C178.871 53.2457 175.138 76.5764 172.961 106.129C170.472 135.37 169.85 170.832 150.563 187.63C131.276 204.739 93.3252 203.495 65.0173 187.63C36.7095 172.077 18.0449 142.213 7.77943 107.373C-2.79714 72.2213 -4.35252 32.7147 14.312 14.0502C32.9765 -4.3033 72.1721 -1.50361 103.591 4.7179C135.32 10.6283 158.962 20.2717 168.917 36.7587Z`,aspectRatio:{width:176,height:200},width:e,height:t}),blob18:({width:e,height:t})=>q({path:`M178.188 21.1464C193.012 36.3069 196.381 62.9219 198.739 88.1893C200.76 113.12 201.771 136.366 190.316 149.168C178.862 162.307 155.279 164.665 135.065 167.697C115.188 170.73 99.0168 174.098 72.4018 177.131C46.1237 180.163 9.40176 182.521 1.65309 168.371C-6.09559 154.221 15.4659 123.564 23.5515 92.9059C31.6371 62.2481 26.2467 31.2534 38.3751 15.4192C50.1665 -0.0781831 79.8136 -1.08888 107.776 0.595609C136.076 1.9432 163.028 5.64909 178.188 21.1464Z`,aspectRatio:{width:200,height:180},width:e,height:t}),blob19:({width:e,height:t})=>q({path:`M148.621 13.3857C171.945 24.3818 194.937 41.3756 192.938 60.702C190.605 80.3615 163.282 101.687 149.953 123.346C136.958 145.005 137.958 166.664 128.295 174.661C118.631 182.325 98.3054 175.994 73.6476 181.991C48.9899 187.989 20.0004 205.983 11.0036 197.986C1.67366 189.989 12.6697 156.001 12.3365 131.343C12.0033 106.685 0.340809 91.0243 0.00759636 75.0301C-0.325616 59.0359 10.3372 42.3753 25.3318 28.7135C39.9931 15.0518 58.9863 4.05578 80.3119 1.05687C101.638 -2.27526 124.962 2.38972 148.621 13.3857Z`,aspectRatio:{width:194,height:200},width:e,height:t}),blob2:({width:e,height:t})=>q({path:`M140.464 18.6393C156.081 28.3718 169.887 39.9149 178.714 54.853C187.541 69.5649 191.389 87.6717 189.578 104.421C187.768 121.396 180.525 137.239 172.377 153.535C164.455 169.832 155.854 186.58 142.048 194.276C128.241 201.971 109.456 200.613 92.4804 197.671C75.2789 194.502 60.1144 189.749 45.1762 182.733C30.4644 175.716 16.2052 166.21 8.28346 153.083C0.361703 139.729 -1.44898 122.527 1.04072 106.91C3.30408 91.2931 9.64147 76.8076 15.9789 60.5114C22.0899 44.2153 28.201 26.1084 40.6495 14.7916C53.0979 3.24849 71.8838 -1.27823 89.7643 0.306124C107.871 1.66414 124.846 9.13322 140.464 18.6393Z`,aspectRatio:{width:191,height:200},width:e,height:t}),blob20:({width:e,height:t})=>q({path:`M150.035 13.2464C157.376 24.9386 153.026 48.323 157.92 65.7254C163.087 83.1277 177.498 94.2761 182.392 108.415C187.287 122.555 182.392 139.957 173.147 156.272C163.63 172.587 149.763 187.814 132.089 195.155C114.414 202.225 93.2053 201.137 73.6276 194.611C54.3219 188.357 36.9196 176.937 25.7712 161.438C14.8947 145.667 10.5441 126.09 5.92163 105.696C1.57105 85.0311 -3.05145 63.5501 2.65869 45.0601C8.64075 26.5701 24.6835 11.0711 43.1735 4.54524C61.6635 -1.98064 82.6007 0.194657 102.722 1.01039C122.844 1.82613 142.421 1.55421 150.035 13.2464Z`,aspectRatio:{width:185,height:200},width:e,height:t}),blob21:({width:e,height:t})=>q({path:`M152.611 0.184799C172.596 -0.723643 197.73 1.39606 199.85 13.8114C201.969 26.2268 181.075 48.9379 174.716 68.0151C168.357 87.0924 176.533 102.536 174.11 114.649C171.991 127.064 159.575 136.148 146.252 139.782C132.928 143.719 118.696 141.902 105.977 139.176C93.562 136.451 82.6606 132.212 63.2805 131.909C43.9004 131.606 16.0416 135.24 5.44306 125.853C-5.15543 116.465 1.50648 94.0572 10.2881 76.4939C18.7669 59.2335 29.6682 46.8182 38.7526 35.3112C48.1398 23.5015 56.3158 12.903 66.9143 8.36078C77.5128 4.12138 91.1394 6.24108 104.766 5.63546C118.696 4.72701 132.928 1.09324 152.611 0.184799Z`,aspectRatio:{width:200,height:143},width:e,height:t}),blob22:({width:e,height:t})=>q({path:`M195.507 15.5715C206.818 33.1668 193.622 69.3001 190.166 101.663C186.71 134.34 193.308 163.561 181.996 178.014C170.685 192.153 141.464 191.525 114.443 189.326C87.1072 187.44 62.2852 183.67 40.6052 169.531C19.2395 155.077 1.6441 130.255 0.0730908 103.862C-1.18372 77.4694 13.898 49.5054 35.2638 31.91C56.6296 14.0004 84.5936 6.45958 116.328 2.37494C148.063 -1.70969 184.196 -2.3381 195.507 15.5715Z`,aspectRatio:{width:200,height:191},width:e,height:t}),blob23:({width:e,height:t})=>q({path:`M135.742 9.14189C157.815 19.2326 179.258 38.4681 176.105 56.7576C172.951 74.7317 145.202 92.0751 127.858 109.734C110.83 127.077 104.523 145.052 87.4953 164.918C70.4672 184.468 42.7177 206.227 27.5816 198.343C12.4455 190.46 9.60747 153.566 6.45411 126.762C2.98542 100.274 -0.798607 84.1917 0.147399 67.1636C0.77807 50.4508 6.76944 32.4767 19.0675 20.8093C31.0503 9.14189 49.6551 3.78119 70.4672 1.2585C90.964 -1.26418 113.668 -0.633508 135.742 9.14189Z`,aspectRatio:{width:177,height:200},width:e,height:t}),blob24:({width:e,height:t})=>q({path:`M165.663 24.3715C171.555 44.4059 158.003 76.2254 151.816 96.2598C145.923 116.294 147.691 124.544 148.28 135.445C148.575 146.346 147.396 159.309 140.62 170.8C133.549 181.996 120.88 191.424 104.381 196.432C87.8821 201.441 67.553 202.03 54.8841 192.602C41.9207 183.469 36.6174 164.023 25.1271 143.105C13.3421 122.187 -4.33535 99.7953 0.967891 85.0641C6.27113 70.6275 34.2604 63.8511 56.0626 48.5307C77.5702 33.5048 92.8907 9.93489 113.22 2.56928C133.843 -4.79633 159.77 4.04241 165.663 24.3715Z`,aspectRatio:{width:168,height:200},width:e,height:t}),blob25:({width:e,height:t})=>q({path:`M180.115 1.256C192.651 2.1962 189.83 34.163 190.771 58.2947C191.711 82.4265 196.098 98.4099 198.606 117.214C201.113 136.018 201.426 157.642 189.204 165.791C177.294 173.626 153.163 167.671 135.299 163.91C117.749 159.836 106.466 157.956 85.7818 162.97C65.0974 168.298 35.3244 180.521 18.7143 174.253C1.79068 167.985 -1.97012 142.913 0.850478 120.975C3.67107 99.0367 13.0731 79.6059 18.4009 54.8473C23.7287 30.0888 24.9823 -0.310996 40.0254 0.00240332C54.7552 0.00240332 82.9612 31.029 111.167 31.029C139.373 31.029 167.579 0.315802 180.115 1.256Z`,aspectRatio:{width:200,height:176},width:e,height:t}),blob26:({width:e,height:t})=>q({path:`M142.571 0.586925C159.976 3.39414 176.258 15.1844 184.96 30.9048C193.662 46.6253 194.224 66.8372 189.171 83.6805C183.837 100.805 172.327 114.56 163.064 129.157C153.8 143.755 146.501 158.914 134.43 173.231C122.359 187.828 105.516 201.303 89.5146 199.899C73.2327 198.776 58.0738 182.775 42.9148 169.862C28.0366 157.23 13.7198 147.685 6.42103 134.491C-0.877729 121.297 -1.15845 103.892 1.64876 88.4528C4.45598 72.7324 10.0704 58.6963 18.4921 47.4674C27.1944 36.2386 38.4233 27.8169 50.4943 22.2025C62.846 16.3073 75.7592 13.5001 91.1989 8.72785C106.919 4.23631 125.166 -1.93957 142.571 0.586925Z`,aspectRatio:{width:193,height:200},width:e,height:t}),blob27:({width:e,height:t})=>q({path:`M112.602 54.9337C129.225 71.8646 155.391 78.9448 158.777 89.719C162.471 100.493 143.693 114.654 127.07 135.586C110.447 156.519 96.2866 184.224 71.0442 194.998C46.1096 205.465 10.4008 199.308 2.0893 178.375C-6.22223 157.443 12.5557 121.734 18.4045 92.1817C24.5612 62.6296 17.7889 38.9263 26.4082 21.9954C34.7197 5.06454 58.423 -5.40183 73.5069 2.9097C88.8986 10.9134 95.9788 38.0028 112.602 54.9337Z`,aspectRatio:{width:160,height:200},width:e,height:t}),blob28:({width:e,height:t})=>q({path:`M125.281 68.5835C142.15 82.9923 165.344 90.021 181.862 108.998C198.028 127.624 207.516 158.902 192.405 166.634C177.293 174.716 137.581 159.605 112.629 156.442C87.326 152.928 77.1344 161.713 59.9142 165.579C43.0453 169.445 19.1478 168.391 11.7677 157.496C4.73907 146.25 14.2278 124.813 11.4163 94.2382C8.2534 63.6634 -6.85825 23.9514 3.68476 8.48836C14.2278 -7.32615 50.4254 1.10826 73.9715 16.2199C97.5175 31.683 108.412 54.1747 125.281 68.5835Z`,aspectRatio:{width:200,height:169},width:e,height:t}),blob29:({width:e,height:t})=>q({path:`M162.987 10.2348C169.16 25.1809 154.864 58.6471 147.066 79.4417C139.268 100.236 138.293 108.359 134.719 114.532C131.47 120.706 125.297 124.93 119.448 143.45C113.6 161.97 107.426 194.461 98.004 199.335C88.5814 204.209 75.5849 181.14 55.7651 167.494C35.6203 153.522 8.65241 148.648 1.8292 135.327C-4.994 122.33 8.65241 100.561 20.0244 82.041C31.3964 63.5208 40.1691 48.2498 53.4906 35.5782C66.8122 22.9065 84.0326 13.159 106.452 6.33584C128.871 -0.812285 156.489 -4.71127 162.987 10.2348Z`,aspectRatio:{width:165,height:200},width:e,height:t}),blob3:({width:e,height:t})=>q({path:`M158.095 64.2637C176.543 95.19 192.277 129.1 181.697 155.686C171.117 182.001 133.951 201.533 99.4982 199.905C64.7739 198.549 33.0338 176.032 15.4004 145.377C-2.23296 114.994 -5.75963 76.2002 10.2461 46.6303C26.2518 17.0605 61.5185 -3.557 89.732 0.512241C118.217 4.58149 139.377 33.0662 158.095 64.2637Z`,aspectRatio:{width:186,height:200},width:e,height:t}),blob30:({width:e,height:t})=>q({path:`M146.076 34.4585C157.052 54.582 155.833 80.1936 164.675 100.622C173.212 121.355 191.201 136.905 189.372 149.711C187.542 162.212 165.285 171.969 146.99 175.018C129.001 178.372 114.671 174.713 103.39 175.018C92.1083 175.018 83.876 178.982 66.8015 186.299C49.7271 193.617 23.8105 204.288 14.3586 198.19C4.90665 191.787 11.6145 168.615 10.3949 147.882C8.87037 127.148 -0.581561 108.549 0.0282404 89.3407C0.638042 70.1319 11.6145 50.6182 28.384 32.934C44.8487 15.5546 67.4113 0.309578 89.974 0.00467694C112.537 -0.300224 135.099 14.335 146.076 34.4585Z`,aspectRatio:{width:190,height:200},width:e,height:t}),blob31:({width:e,height:t})=>q({path:`M134.218 44.0392C153.568 36.4264 184.97 26.9105 195.755 33.2544C206.222 39.9156 195.755 62.1194 181.481 76.3933C166.89 90.35 148.175 96.0596 145.638 116.36C143.1 136.661 156.74 171.235 151.664 183.923C146.589 196.928 123.434 187.413 105.036 178.531C86.6388 169.967 73.3165 161.72 52.0643 158.548C30.812 155.058 1.62986 156.644 0.0438693 145.225C-1.22492 133.806 25.4197 109.382 29.2261 86.8609C32.7152 64.3398 13.6834 44.0392 11.7802 26.9105C9.877 9.46461 24.7853 -4.80928 42.5484 1.53467C59.9942 7.87863 79.9777 34.5232 93.6172 45.308C107.257 56.4099 114.869 51.3347 134.218 44.0392Z`,aspectRatio:{width:200,height:191},width:e,height:t}),blob32:({width:e,height:t})=>q({path:`M200 100.339C200 149.831 145.763 197.966 95.5932 197.966C45.7627 197.966 0 149.831 0 100.339C0 50.8475 45.7627 0 95.5932 0C145.763 0 200 50.8475 200 100.339Z`,aspectRatio:{width:200,height:198},width:e,height:t}),blob4:({width:e,height:t})=>q({path:`M183.427 38.712C198.21 63.2519 196.141 95.1833 189.341 126.523C182.836 157.863 171.305 188.908 150.609 197.482C130.208 205.76 100.642 192.16 69.8936 177.968C39.4405 164.072 7.80478 150.176 1.30024 128.593C-5.2043 107.01 13.718 77.7393 35.3012 51.7211C56.5888 25.9986 81.1287 3.23272 108.921 0.276112C137.009 -2.38484 168.349 14.4678 183.427 38.712Z`,aspectRatio:{width:195,height:200},width:e,height:t}),blob5:({width:e,height:t})=>q({path:`M166.251 30.6913C183.816 48.5185 195.875 71.8512 199.021 98.8542C202.429 125.595 197.186 155.744 179.359 169.115C161.794 182.223 131.645 178.815 103.331 176.979C75.0171 175.144 48.8006 174.882 29.6625 161.512C10.7866 148.141 -0.748681 121.925 0.0378149 96.2326C0.824311 70.8025 14.1947 46.159 33.0706 28.3318C52.2087 10.5045 76.8522 -0.5064 100.971 0.0179307C125.091 0.804426 148.423 12.864 166.251 30.6913Z`,aspectRatio:{width:200,height:179},width:e,height:t}),blob6:({width:e,height:t})=>q({path:`M149.146 50.5452C161.911 68.0278 171.901 81.9028 176.619 97.9979C181.336 114.37 180.781 133.241 173.011 149.891C165.519 166.541 151.366 180.693 133.051 189.851C114.736 199.008 92.2586 202.893 71.446 197.621C50.6334 192.348 30.9308 177.918 18.1658 158.216C5.12323 138.791 -0.981801 113.815 0.128204 87.7304C1.51571 61.6453 10.6733 34.1726 29.2658 17.5226C48.1359 1.14999 76.996 -4.40004 98.9186 3.6475C120.841 11.695 136.381 32.7851 149.146 50.5452Z`,aspectRatio:{width:180,height:200},width:e,height:t}),blob7:({width:e,height:t})=>q({path:`M158.662 41.8295C178.593 57.8305 204.138 64.5677 213.402 79.7266C222.666 94.6047 215.367 118.466 203.015 135.028C190.383 151.871 172.698 161.977 156.416 168.434C140.134 174.89 124.975 177.697 104.483 185.277C83.9903 192.856 58.1642 205.208 44.9704 197.629C31.4959 190.33 31.2152 163.1 21.9514 138.116C12.9684 112.851 -4.71688 90.1132 1.17822 75.5158C7.35404 61.1991 36.8295 55.5847 58.7256 40.1452C80.9024 24.7056 95.4998 -0.278374 109.816 0.00234533C124.414 0.283064 138.45 25.8285 158.662 41.8295Z`,aspectRatio:{width:218,height:200},width:e,height:t}),blob8:({width:e,height:t})=>q({path:`M153.53 11.0108C168.179 18.1858 181.931 29.5461 192.993 44.4939C203.755 59.4417 212.425 78.2759 210.631 96.5122C209.136 114.748 197.477 132.088 182.529 142.252C167.581 152.716 148.747 156.004 128.717 168.262C108.687 180.22 87.1622 201.147 69.8228 199.951C52.7823 198.456 39.6283 174.54 32.4533 153.015C25.2784 131.49 24.0826 112.357 16.6087 91.131C9.13477 70.2041 -4.31825 46.8855 1.36191 31.9377C7.04207 16.691 31.8554 9.51607 52.7823 5.33069C73.4103 0.846349 90.4507 -0.648433 106.594 0.248435C123.037 1.1453 138.882 4.13486 153.53 11.0108Z`,aspectRatio:{width:211,height:200},width:e,height:t}),blob9:({width:e,height:t})=>q({path:`M140.289 20.2182C156.96 27.7956 176.661 32.0895 189.29 43.9608C201.667 55.5796 206.718 75.0283 202.424 91.6987C198.131 108.622 184.491 122.766 175.651 140.952C166.81 158.885 162.769 180.607 150.393 191.216C138.016 201.824 117.052 201.572 98.866 197.025C80.6802 192.479 65.2727 183.891 48.3497 175.808C31.4268 167.726 13.2409 160.148 5.1583 146.761C-2.67172 133.122 -0.398493 113.673 4.14797 96.7504C8.69444 80.08 15.5141 65.6828 23.3442 52.296C31.4268 38.6566 40.5197 25.775 52.6436 15.6717C65.0201 5.82101 80.6802 -1.50385 95.3299 0.264221C109.98 1.77971 123.619 12.6407 140.289 20.2182Z`,aspectRatio:{width:204,height:200},width:e,height:t})};function By(e){return zy[e]||ky}function Vy(e){let{subType:t}=e,n=e,r=By(t);return r?function(e,t){let{width:n,height:r,fill:i,stroke:a,strokeWidth:o,dash:s}=e,c=(s||[]).map(e=>e*o),l=t(e),u=1,d=1;typeof l!=`string`&&(u=l.scaleX,d=l.scaleY,l=l.path);let f=`clip-${e.id||Math.random()}`;return`\n <svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${r}">\n <defs>\n <clipPath id="${f}">\n <path d="${l}" />\n </clipPath>\n </defs>\n\n \x3c!-- Path for the fill --\x3e\n <path d="${l}" fill="${i}" transform="scale(${u}, ${d})"/>\n\n \x3c!-- Path for the stroke, clipped by the star path --\x3e\n <path d="${l}" fill="none" stroke="${a}" stroke-width="${2*o}" clip-path="url(#${f})" transform="scale(${u}, ${d})" stroke-dasharray="${c.join(` `)}"/>\n </svg>\n `}(n,r):(console.error(`Polotno error: Can not convert ${e.subType} figure to svg.`),ky(n))}var Hy=`
|
|
60
|
+
p {
|
|
61
|
+
margin: 0;
|
|
62
|
+
padding: 0;
|
|
63
|
+
overflow-wrap: break-word; /* Canonical CSS3 — Firefox honors it; render-tag's CSS resolver only parses this canonical form */
|
|
64
|
+
/* a text may have several spaces, we need to preserve them */
|
|
65
|
+
white-space: pre-wrap;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* Structural list reset. Native markers are intentionally LEFT ENABLED here
|
|
69
|
+
(no list-style:none) so the canonical export/canvas HTML renders the
|
|
70
|
+
browser's NATIVE markers.
|
|
71
|
+
|
|
72
|
+
The per-level indent is carried by the <ul>/<ol> padding (2.1em), NOT the
|
|
73
|
+
<li>. This matters for native markers: with list-style-position outside
|
|
74
|
+
the marker hangs just left of the <li> border box, so the indent must sit
|
|
75
|
+
on the list (the marker lands inside that padding, next to the text). If
|
|
76
|
+
the indent were on the <li> instead, the outside marker would hang at
|
|
77
|
+
x near 0 and be clipped off the element's left edge. render-tag computes
|
|
78
|
+
the same content-start either way (it accumulates block padding).
|
|
79
|
+
|
|
80
|
+
The live editor needs the opposite box model (indent on the <li>, so its
|
|
81
|
+
absolutely-positioned ::before marker has room) and overrides these two
|
|
82
|
+
paddings in rich-editor.tsx. */
|
|
83
|
+
ul, ol {
|
|
84
|
+
padding-inline-start: 2.1em; /* Per-level indent; native outside markers hang inside it */
|
|
85
|
+
margin: 0;
|
|
86
|
+
display: block; /* Use block instead of inline-block for better text wrapping */
|
|
87
|
+
width: 100%;
|
|
88
|
+
text-decoration: inherit;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
li {
|
|
92
|
+
padding-inline-start: 0;
|
|
93
|
+
margin: 0; /* Reset default li margins */
|
|
94
|
+
overflow-wrap: break-word; /* Canonical CSS3 — Firefox honors it; render-tag's CSS resolver only parses this canonical form */
|
|
95
|
+
white-space: pre-wrap; /* Preserve spaces and allow wrapping */
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* Paragraph block-indent (matches walk's <p> ql-indent → margin in
|
|
99
|
+
rich-text-html.ts). Small step, applied to non-list indented blocks.
|
|
100
|
+
Editor-only in practice: the export normalizer turns <p> ql-indent into an
|
|
101
|
+
inline margin, so canonical export HTML carries no ql-indent class. */
|
|
102
|
+
.ql-indent-1 {
|
|
103
|
+
margin-inline-start: 0.5em;
|
|
104
|
+
}
|
|
105
|
+
.ql-indent-2 {
|
|
106
|
+
margin-inline-start: 1em;
|
|
107
|
+
}
|
|
108
|
+
.ql-indent-3 {
|
|
109
|
+
margin-inline-start: 1.5em;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/* List nesting indent for the live Quill editor, which renders a list FLAT
|
|
113
|
+
(one container, depth via ql-indent on each <li>). Each level is indented
|
|
114
|
+
by the SAME 2.1em render-tag adds per nested <ul>/<ol>, to stay in sync
|
|
115
|
+
with the canvas. Stored/exported lists are canonical-nested and carry no
|
|
116
|
+
ql-indent (see canonicalizeLists), so these rules are editor/legacy-only
|
|
117
|
+
no-ops elsewhere. */
|
|
118
|
+
li.ql-indent-1 {
|
|
119
|
+
margin-inline-start: 2.1em;
|
|
120
|
+
}
|
|
121
|
+
li.ql-indent-2 {
|
|
122
|
+
margin-inline-start: 4.2em;
|
|
123
|
+
}
|
|
124
|
+
li.ql-indent-3 {
|
|
125
|
+
margin-inline-start: 6.3em;
|
|
126
|
+
}
|
|
127
|
+
`,Uy=`\n<style>\n html, body {\n padding: 0;\n margin: 0;\n }\n ${Hy}\n</style>\n`,Wy;(function(e){e.sepia=`sepia`,e.grayscale=`grayscale`,e.natural=`natural`,e.warm=`warm`,e.cold=`cold`,e.temperature=`temperature`,e.contrast=`contrast`,e.shadows=`shadows`,e.white=`white`,e.black=`black`,e.vibrance=`vibrance`,e.saturation=`saturation`})(Wy||={});function Gy(e,t){let n={filter:``,html:void 0};switch(e){case Wy.warm:{let e=Math.max(0,Math.min(1,t??.5)),r=1+.3*e,i=1+.15*e;return n.filter=`url(#warm-filter)`,n.html=`\n <svg xmlns="http://www.w3.org/2000/svg" style="display:none">\n <filter id="warm-filter" color-interpolation-filters="sRGB">\n <feColorMatrix type="matrix" values="\n ${r} 0 0 0 0\n 0 ${i} 0 0 0\n 0 0 1 0 0\n 0 0 0 1 0" />\n </filter>\n </svg>`,n}case Wy.cold:{let e=Math.max(0,Math.min(1,t??.5)),r=1-.15*e,i=1-.1*e,a=1+.15*e;return n.filter=`url(#cold-filter)`,n.html=`\n <svg xmlns="http://www.w3.org/2000/svg" style="display:none">\n <filter id="cold-filter" color-interpolation-filters="sRGB">\n <feColorMatrix type="matrix" values="\n ${r} 0 0 0 0\n 0 ${i} 0 0 0\n 0 0 ${a} 0 0\n 0 0 0 1 0" />\n </filter>\n </svg>`,n}case`natural`:{let e=Math.max(0,Math.min(1,t??.5)),r=1+.1*e;return n.filter=`saturate(${1+.3*e}) brightness(${r}) contrast(${1+.2*e})`,n}case Wy.temperature:{let e=Math.max(-1,Math.min(1,t??0)),r=1+.15*e,i=1-.15*e;return n.filter=`url(#temperature-filter)`,n.html=`\n <svg xmlns="http://www.w3.org/2000/svg" style="display:none">\n <filter id="temperature-filter" color-interpolation-filters="sRGB">\n <feColorMatrix type="matrix" values="\n ${r} 0 0 0 0\n 0 1 0 0 0\n 0 0 ${i} 0 0\n 0 0 0 1 0" />\n </filter>\n </svg>\n `,n}case Wy.contrast:{let e=100*Math.max(-1,Math.min(1,t??0)),r=259*(e+255)/(255*(259-e)),i=.5*(1-r);return n.filter=`url(#contrast-filter)`,n.html=`\n <svg xmlns="http://www.w3.org/2000/svg" style="display:none">\n <filter id="contrast-filter" color-interpolation-filters="sRGB">\n <feComponentTransfer>\n <feFuncR type="linear" slope="${r}" intercept="${i}" />\n <feFuncG type="linear" slope="${r}" intercept="${i}" />\n <feFuncB type="linear" slope="${r}" intercept="${i}" />\n </feComponentTransfer>\n </filter>\n </svg>\n `,n}case Wy.shadows:{let e=Math.min(Math.max(1-.6*Math.max(-1,Math.min(1,t??0)),.4),2.5);return n.filter=`url(#shadows-filter)`,n.html=`\n <svg xmlns="http://www.w3.org/2000/svg" style="display:none">\n <filter id="shadows-filter" color-interpolation-filters="sRGB">\n <feComponentTransfer>\n <feFuncR type="gamma" amplitude="1" exponent="${e}" offset="0" />\n <feFuncG type="gamma" amplitude="1" exponent="${e}" offset="0" />\n <feFuncB type="gamma" amplitude="1" exponent="${e}" offset="0" />\n </feComponentTransfer>\n </filter>\n </svg>\n `,n}case Wy.white:case Wy.black:return null;case Wy.vibrance:{let e=Math.max(-1,Math.min(1,t??0)),r=.299,i=.587,a=.114,o;o=e>=0?1+1.5*e:1+e;let s=1-o,c=s*r+o,l=s*i,u=s*a,d=s*r,f=s*i+o,p=s*a,m=s*r,h=s*i,g=s*a+o;return n.filter=`url(#vibrance-filter)`,n.html=`\n <svg xmlns="http://www.w3.org/2000/svg" style="display:none">\n <filter id="vibrance-filter" color-interpolation-filters="sRGB">\n <feColorMatrix type="matrix" values="\n ${c} ${l} ${u} 0 0\n ${d} ${f} ${p} 0 0\n ${m} ${h} ${g} 0 0\n 0 0 0 1 0" />\n </filter>\n </svg>\n `,n}case Wy.saturation:{let e=.2126,r=.7152,i=.0722,a=1+Math.max(-1,Math.min(1,t??0)),o=1-a,s=o*e+a,c=o*r,l=o*i,u=o*e,d=o*r+a,f=o*i,p=o*e,m=o*r,h=o*i+a;return n.filter=`url(#saturation-filter)`,n.html=`\n <svg xmlns="http://www.w3.org/2000/svg" style="display:none">\n <filter id="saturation-filter" color-interpolation-filters="sRGB">\n <feColorMatrix type="matrix" values="\n ${s} ${c} ${l} 0 0\n ${u} ${d} ${f} 0 0\n ${p} ${m} ${h} 0 0\n 0 0 0 1 0" />\n </filter>\n </svg>\n `,n}default:return null}}async function Ky(e){return new Promise((t,n)=>{let r=document.createElement(`video`);r.crossOrigin=`anonymous`,r.src=e,r.addEventListener(`loadedmetadata`,()=>{let{videoWidth:e,videoHeight:n}=r;t({width:e,height:n})}),r.addEventListener(`error`,t=>{let r=e.slice(0,100);n(Error(`Failed to load video: ${r}`))})})}function qy(e){return e/180*Math.PI}function Jy(e,t,n,r,i){let a=Math.sqrt(n*n+r*r);return i+=Math.atan2(r,n),{x:e+a*Math.cos(i),y:t+a*Math.sin(i)}}function Yy(e){let{x:t,y:n,width:r,height:i}=e,a=qy(e.rotation),o=Jy(t,n,0,0,a),s=Jy(t,n,r,0,a),c=Jy(t,n,r,i,a),l=Jy(t,n,0,i,a),u=Math.min(o.x,s.x,c.x,l.x),d=Math.min(o.y,s.y,c.y,l.y),f=Math.max(o.x,s.x,c.x,l.x),p=Math.max(o.y,s.y,c.y,l.y);return{x:u,y:d,width:f-u,height:p-d,minX:u,minY:d,maxX:f,maxY:p}}function Xy(e){let t=e.map(e=>Yy(e)),n=Math.min(...t.map(e=>e.minX)),r=Math.min(...t.map(e=>e.minY)),i=Math.max(...t.map(e=>e.maxX)),a=Math.max(...t.map(e=>e.maxY));return{x:n,y:r,width:i-n,height:a-r,minX:n,minY:r,maxX:i,maxY:a}}function Zy(e){let t=qy(e.rotation||0);return{x:e.x+e.width/2*Math.cos(t)+e.height/2*Math.sin(-t),y:e.y+e.height/2*Math.cos(t)+e.width/2*Math.sin(t)}}function Qy(e,t,n){let r=qy(t),i=n.x+(e.x-n.x)*Math.cos(r)-(e.y-n.y)*Math.sin(r),a=n.y+(e.x-n.x)*Math.sin(r)+(e.y-n.y)*Math.cos(r);return Object.assign(Object.assign({},e),{rotation:e.rotation+t,x:i,y:a})}function $y(e,t){return Qy(e,t,Zy(e))}var eb=K.model(`Page`,{id:K.identifier,children:K.array(K.late(()=>Hb)),width:K.optional(K.union(K.number,K.literal(`auto`)),`auto`),height:K.optional(K.union(K.number,K.literal(`auto`)),`auto`),background:`white`,bleed:0,custom:K.frozen(),duration:5e3,_exporting:!1,_rendering:!1,_forceMount:!1}).postProcessSnapshot(e=>{let t=Object.assign({},e),n={};for(var r in t)r[0]!==`_`&&(n[r]=e[r]);return n}).views(e=>({get store(){return Fp(e,fC)}})).views(e=>({get startTime(){let t=0;for(let n of e.store.pages){if(n.id===e.id)return t;t+=n.duration}return t},get _exportingOrRendering(){return e._exporting||e._rendering}})).views(e=>({get computedWidth(){return e.width===`auto`?e.store.width:e.width},get computedHeight(){return e.height===`auto`?e.store.height:e.height}})).actions(e=>({toJSON:()=>JSON.parse(JSON.stringify(Mp(e)))})).actions(e=>Object.assign(Object.assign({clone(t={}){let n=e.toJSON(),r=new Map;n.children.forEach(e=>{let t=e.id,n=c_(10);r.set(t,n),e.id=n,zb(e,e=>{let t=e.id,n=c_(10);r.set(t,n),e.id=n})}),n.children.forEach(e=>{e.cells&&e.cells.forEach(e=>{e.mergedInto&&r.has(e.mergedInto)&&(e.mergedInto=r.get(e.mergedInto))})});let i=Object.assign(Object.assign(Object.assign({},n),{id:c_(10)}),t),a=e.store.addPage(i),o=e.store.pages.indexOf(e);return a.setZIndex(o+1),a.select(),a},setZIndex(t){e.store.setPageZIndex(e.id,t)},set(t){Object.assign(e,t)},select(){e.store.selectPage(e.id)},addElement(t,{skipSelect:n=!1}={}){let r=Xb[t.type];if(!r){console.error(`Can not find model with type `+t.type);return}`children`in t&&Array.isArray(t.children)&&zb(t,e=>{e.id=e.id||c_(10)});let i=e.children.reduce((e,n)=>{if(n.type===`group`){let r=n.children.reduce((e,n)=>{let r=n.name?.match(RegExp(`${t.type}-(\\d+)`));if(r){let t=parseInt(r[1],10);return Math.max(e,t||0)}},0);return Math.max(e,r||0)}{let r=n.name.match(RegExp(`${t.type}-(\\d+)`));if(r){let t=parseInt(r[1],10);return Math.max(e,t||0)}}return e},0),a=r.create(Object.assign({id:c_(10),name:`${t.type}-${i+1}`},t));return e.children.push(a),a.selectable&&!n&&e.store.selectElements([a.id]),a}},Bb(e)),{setSize({width:t,height:n,useMagic:r,softChange:i}){if(r){let r=[],i=t=>t.type===`image`&&t.x<1&&t.y<1&&t.width>=e.computedWidth-2&&t.height>=e.computedHeight-2;Rb(e,e=>{e.type!==`group`&&(i(e)||r.push(e))});let a=r.length?Xy(r):{x:0,y:0,width:e.computedWidth,height:e.computedHeight},o=1/4,s=Math.max(0,Math.min(a.x,e.computedWidth-a.x-a.width)),c=e.computedWidth*o,l=Math.max(0,s-c),u=Math.max(0,Math.min(a.y,e.computedHeight-a.y-a.height)),d=e.computedHeight*o,f=Math.max(0,u-d),p=e.computedWidth-2*l,m=e.computedHeight-2*f,h=t/p,g=n/m,_=Math.min(h,g),v=(t-p*_)/2-l*_,y=(n-m*_)/2-f*_;Rb(e,e=>{if(e.type!==`group`){if(i(e))e.set({x:e.x*_,y:e.y*_,width:e.width*h,height:e.height*g,cropX:0,cropY:0,cropWidth:1,cropHeight:1});else if(e.set({x:v+e.x*_,y:y+e.y*_,width:e.width*_,height:e.height*_}),e.type===`text`)e.set({fontSize:e.fontSize*_});else if(e.type===`figure`)e.set({strokeWidth:e.strokeWidth*_});else if(e.type===`table`){e.set({borderWidth:e.borderWidth*_});for(let t of e.cells){let e={fontSize:t.fontSize*_,cellPadding:t.cellPadding*_};if(t.borders){let n=JSON.parse(JSON.stringify(t.borders));for(let e of[`top`,`right`,`bottom`,`left`])n[e]?.width!=null&&(n[e]=Object.assign(Object.assign({},n[e]),{width:n[e].width*_}));e.borders=n}t.set(e)}}}})}i||(e.width=t),i||(e.height=n)}})).actions(e=>({moveElementUp(t){console.warn(`page.moveElementUp(id) is deprecated. Please use page.moveElementsUp([id1, id2]) instead.`),e.moveElementsUp([t])},moveElementDown(t){console.warn(`page.moveElementDown(id) is deprecated. Please use page.moveElementsDown([id1, id2]) instead.`),e.moveElementsDown([t])},moveElementTop(t){console.warn(`page.moveElementTop(id) is deprecated. Please use page.moveElementsTop([id1, id2]) instead.`),e.moveElementsTop([t])},moveElementBottom(t){console.warn(`page.moveElementBottom(id) is deprecated. Please use page.moveElementsBottom([id1, id2]) instead.`),e.moveElementsBottom([t])},play(){e.store.play({startTime:e.startTime,endTime:e.startTime+e.duration})}})),tb=K.model(`Node`,{id:K.identifier,type:`none`,name:``,opacity:1,custom:K.frozen(),visible:!0,selectable:!0,removable:!0,alwaysOnTop:!1,showInExport:!0}).preProcessSnapshot(e=>{for(var t in e)e[t]===null&&(e[t]=void 0);return e}).postProcessSnapshot(e=>{let t=Object.assign({},e),n={};for(var r in t)r[0]!==`_`&&(n[r]=e[r]);return n}).views(e=>({get page(){return Hp(e)?Fp(e,eb):null},get store(){return Hp(e)?Fp(e,fC):null},get top(){if(!Hp(e))return e;let t=e;for(;;){if(!Pp(t,Jb))return t;t=Fp(t,Jb)}},get parent(){if(!Hp(e))return null;if(Pp(e,Jb)){let t=Fp(e,Jb);return t&&t.children&&t.children.length,t}if(Pp(e,eb)){let t=Fp(e,eb);return t&&t.children&&t.children.length,t}if(Pp(e,fC)){let t=Fp(e,fC);return t&&t.pages&&t.pages.length,t}return null},get zIndex(){return Hp(e)?e.parent.children.indexOf(e):-1}})).actions(e=>({toJSON:()=>Object.assign({},Mp(e))})).actions(e=>({clone(t={},{skipSelect:n=!1}={}){let r=JSON.parse(JSON.stringify(e.toJSON()));t.id=t.id||c_(10);let i=new Map;return zb(r,e=>{let t=e.id,n=c_(10);i.set(t,n),e.id=n}),zb(r,e=>{e.mergedInto&&i.has(e.mergedInto)&&(e.mergedInto=i.get(e.mergedInto))}),Object.assign(r,t),e.page.addElement(r,{skipSelect:n})},set(t){Object.assign(e,t)},moveUp(){var t;(t=e.parent)==null||t.moveElementsUp([e.id])},moveTop(){var t;(t=e.parent)==null||t.moveElementsTop([e.id])},moveDown(){var t;(t=e.parent)==null||t.moveElementsDown([e.id])},moveBottom(){var t;(t=e.parent)==null||t.moveElementsBottom([e.id])},setZIndex(t){e.parent.setElementZIndex(e.id,t)},beforeDestroy(){}})),nb={right:{from:{x:-200},to:{x:0}},left:{from:{x:200},to:{x:0}},up:{from:{y:200},to:{y:0}},down:{from:{y:-200},to:{y:0}},"bottom-right":{from:{x:-200,y:-200},to:{x:0,y:0}},"bottom-left":{from:{x:200,y:-200},to:{x:0,y:0}},"top-right":{from:{x:-200,y:200},to:{x:0,y:0}},"top-left":{from:{x:200,y:200},to:{x:0,y:0}}},rb={right:{cropX:-1},left:{cropX:1},up:{cropY:1},down:{cropY:-1}},ib={none:()=>({}),fade:({dTime:e,element:t,animation:n})=>{let r=e/n.duration;return n.type===`enter`?{opacity:r*t.opacity}:{opacity:(1-r)*t.opacity}},rotate:({dTime:e,element:t,animation:n})=>{let r=e/n.duration*360;return $y({x:t.x,y:t.y,width:t.width,height:t.height,rotation:t.rotation},r)},blink:({dTime:e,element:t,animation:n})=>{let r=n.duration,i=e%r/(r/2),a=i<=1?i:2-i;return{opacity:t.opacity*a}},bounce:({dTime:e,element:t,animation:n})=>{let r=n.duration,i=r/2,a=n.data.strength??1,o={},s={x:t.x+t.width/3*a,y:t.y+t.height/3*a,width:t.width/3*a,height:t.height/3*a,fontSize:t.fontSize/3*a},c={x:t.x,y:t.y,width:t.width,height:t.height,fontSize:t.fontSize},l=e%r/i,u=l<=1?l:2-l;for(let e in s){let t=s[e];o[e]=t+u*(c[e]-t)}return o},move:({dTime:e,element:t,animation:n})=>{let r=nb[n.data.direction]||nb.right,i=n.data.strength??1,a={};for(var o in r.from){let s=r.from[o],c=r.to[o];n.type===`exit`&&(s=r.to[o],c=-r.from[o]),s*=i,c*=i;let l=t[o]+s,u=t[o]+c-l;a[o]=l+e/n.duration*u}return a},zoom:({dTime:e,element:t,animation:n})=>{let r={},i=1+(((n.data.direction||`in`)===`in`?3/4:5/4)-1)*(n.data.strength??1),a=t.rotation*Math.PI/180,o=Math.cos(a),s=Math.sin(a),c=t.width*(1-i),l=t.height*(1-i),u=(c*o-l*s)/2,d=(c*s+l*o)/2,f={x:t.x+u,y:t.y+d,width:t.width*i,height:t.height*i,fontSize:t.fontSize*i},p={x:t.x,y:t.y,width:t.width,height:t.height,fontSize:t.fontSize};for(var m in f){let t=f[m],i=p[m];if(n.type===`exit`){let e=t;t=i,i=e}let a=i-t;r[m]=t+e/n.duration*a}return r},cameraZoom:({dTime:e,element:t,animation:n})=>{let r={},i=rb[n.data.direction||`right`]||rb.right,a=n.data.movementStrength??.1,o=n.data.shakeStrength??.015,s=n.data.zoomStrength??.6,c=e/n.duration,l=o*(1-c),u=Math.sin(12*c)*l*.7+Math.sin(8*c)*l*.3;if(n.type===`exit`){let e=Math.max(t.cropWidth||1,t.cropHeight||1);s=Math.min(s,1-e)}n.type;let d=1-(1-c)**2,f=t.cropX||0,p=t.cropY||0,m=t.cropWidth||1,h=t.cropHeight||1,g=m,_=h,v,y,b=0,x=0;if(i.cropX){let e=i.cropX>0?1-(f+m):f;b=Math.min(e,Math.abs(a))*i.cropX}if(i.cropY){let e=i.cropY>0?1-(p+h):p;x=Math.min(e,Math.abs(a))*i.cropY}return n.type===`enter`?(v=i.cropX?f+b*(1-d):f,y=i.cropY?p+x*(1-d):p):(v=i.cropX?f+b*d:f,y=i.cropY?p+x*d:p),r.cropX=Math.max(0,Math.min(1-g,v+u*g)),r.cropY=Math.max(0,Math.min(1-_,y+u*_)),r.cropWidth=g,r.cropHeight=_,r}},ab=({element:e,dTime:t,animation:n})=>{let r=ib[n.name];return r?r({element:e,dTime:t,animation:n}):(console.error(`Can not find animation type: `+n.name),{})},ob=K.model(`Animation`,{delay:0,duration:500,enabled:!0,type:K.enumeration(`Type`,[`enter`,`exit`,`loop`]),name:`none`,data:K.frozen({})}),sb=(e,t)=>{let n={};for(let r in t)if(typeof e[r]==`number`&&typeof t[r]==`number`){let i=t[r]-e[r];i!==0&&(n[r]=i)}return n},cb=K.model(`ShapeFilter`,{intensity:1}),lb=[`temperature`,`contrast`,`highlights`,`shadows`,`white`,`black`,`saturation`,`vibrance`],ub=tb.named(`Shape`).props({x:0,y:0,width:100,height:100,rotation:0,opacity:1,animations:K.array(ob),blurEnabled:!1,blurRadius:10,brightnessEnabled:!1,brightness:0,sepiaEnabled:!1,grayscaleEnabled:!1,filters:K.map(cb),shadowEnabled:!1,shadowBlur:5,shadowOffsetX:0,shadowOffsetY:0,shadowColor:`black`,shadowOpacity:1,visible:!0,draggable:!0,resizable:!0,selectable:!0,contentEditable:!0,styleEditable:!0,alwaysOnTop:!1,showInExport:!0}).preProcessSnapshot(e=>{let t=Object.assign(Object.assign({},e),{x:`x`in e&&e.x||0,y:`y`in e&&e.y||0,filters:`filters`in e?Array.isArray(e.filters)?{}:e.filters:void 0});return`width`in e&&(t.width=t.width||1),`height`in e&&(t.height=t.height||1),`locked`in e&&e.locked&&(t.draggable=!1,t.contentEditable=!1,t.styleEditable=!1,t.resizable=!1,t.removable=!1),t}).views(e=>{let t=[`x`,`y`,`width`,`height`,`rotation`,`opacity`,`color`,`fontSize`,`cropX`,`cropY`,`cropWidth`,`cropHeight`],n=e,r={x:n.x??0,y:n.y??0,width:n.width??0,height:n.height??0,rotation:n.rotation??0,opacity:n.opacity??1};for(let i of t)i in e&&(r[i]=n[i]);let i=Ut(r),a=ir(e=>{for(let t in e)i[t]=e[t]}),o=ir(e=>{Object.assign(i,e)}),s=ir(e=>{for(let t in e)typeof i[t]==`number`&&(i[t]=i[t]+e[t])});return{get locked(){return!(e.draggable||e.contentEditable||e.styleEditable||e.resizable)},get a(){if(!Hp(e))return i;let{currentTime:t}=e.store,r={};for(let e in i)r[e]=n[e];if(a(r),t===0)return i;let c=t-e.page.startTime;if(c>e.page.duration||c<0)return i;let l=e.store.animatedElementsIds;if(l.length&&!l.includes(e.id))return i;let u=e.animations.find(e=>e.type===`enter`),d=u?.enabled&&c<u.delay;d&&o({opacity:0});let f=u?.enabled&&c>=u.delay&&c<=u.delay+u.duration;f&&s(sb(e,ab({element:e,animation:u,dTime:c-u.delay})));let p=e.animations.find(e=>e.type===`exit`);!d&&!f&&p?.enabled&&c>=e.page.duration-p.duration-p.delay&&c<=e.page.duration-p.delay&&s(sb(e,ab({element:e,animation:p,dTime:c-(e.page.duration-p.duration-p.delay)}))),p!=null&&p.enabled&&c>=e.page.duration-p.delay&&o({opacity:0});let m=e.animations.find(e=>e.type===`loop`);return m?.enabled&&s(sb(e,ab({element:e,animation:m,dTime:c}))),i},animated(e){return this.a[e]},get isSelected(){return!!Hp(e)&&e.store.selectedShapes.indexOf(e)>=0&&e.selectable},get isSelectedDirectly(){return!!Hp(e)&&e.store.selectedElements.indexOf(e)>=0&&e.selectable}}}).actions(e=>({setAnimation(t,n){let r=e.animations.find(e=>e.type===t);r?Object.assign(r,n):e.animations.push(Object.assign({type:t},n))},setFilter(t,n){lb.includes(t)||e.filters.forEach((t,n)=>{lb.includes(n.toString())||e.filters.delete(n.toString())}),n==null?e.filters.delete(t):e.filters.set(t,{intensity:n})}})),db=ub.named(`Text`).props({type:`text`,text:``,placeholder:``,fontSize:14,fontFamily:`Roboto`,fontStyle:`normal`,fontWeight:`normal`,textDecoration:``,textTransform:`none`,fill:`black`,align:`center`,width:100,height:0,verticalAlign:`top`,strokeWidth:0,stroke:`black`,lineHeight:K.optional(K.union(K.number,K.string),1.2),letterSpacing:0,_editModeEnabled:!1,backgroundEnabled:!1,backgroundColor:`#7ED321`,backgroundOpacity:1,backgroundCornerRadius:.5,backgroundPadding:.5,legacyBackground:K.maybe(K.boolean),curveEnabled:!1,curvePower:.5}).preProcessSnapshot(e=>Object.assign(Object.assign({},e),{fontSize:e.fontSize!=null&&e.fontSize<1?1:e.fontSize})).actions(e=>{let t=e.set;return{set(e){e.fontSize!=null&&e.fontSize<1&&(e=Object.assign(Object.assign({},e),{fontSize:1})),t(e)},afterCreate(){if(!e.height){let t=e.lineHeight,n=typeof t==`number`?t:parseFloat(t)||1.2;e.height=Math.round(e.fontSize*n)}},toggleEditMode(t){let n=t??!e._editModeEnabled;n!==e._editModeEnabled&&(e._editModeEnabled=n,e._editModeEnabled?e.store.history.startTransaction():e.store.history.endTransaction())}}}),fb=ub.named(`Image`).props({type:`image`,width:100,height:100,src:``,cropX:0,cropY:0,cropWidth:1,cropHeight:1,cornerRadius:0,flipX:!1,flipY:!1,clipSrc:``,borderColor:`black`,borderSize:0,keepRatio:!1,stretchEnabled:!1}).extend(e=>{let t=Ut.box(!1),n=!1;return{views:{get _cropModeEnabled(){return t.get()}},actions:{toggleCropMode(r){let i=r??!t.get();t.set(i),i&&!n?(e.store.history.startTransaction(),n=!0):!i&&n&&(e.store.history.endTransaction(),n=!1)},beforeDestroy(){n&&=(e.store.history.endTransaction(),!1)}}}}),pb=fb.named(`Video`).props({type:`video`,duration:0,startTime:0,endTime:1,volume:1}),mb=ub.named(`Line`).props({type:`line`,width:400,height:10,color:`black`,dash:K.array(K.number),startHead:``,endHead:``}).actions(e=>({})),hb=ub.named(`SVG`).props({type:`svg`,src:``,maskSrc:``,cropX:0,cropY:0,cropWidth:1,cropHeight:1,keepRatio:!0,stretchEnabled:!0,flipX:!1,flipY:!1,width:100,height:100,borderColor:`black`,borderSize:0,cornerRadius:0,colorsReplace:K.map(K.string)}).preProcessSnapshot(e=>Object.assign(Object.assign({},e),{src:e.src||e.svgSource,colorsReplace:Array.isArray(e.colorsReplace)?{}:e.colorsReplace})).actions(e=>({replaceColor(t,n){e.colorsReplace.set(t,n)},resetColors(){e.colorsReplace.clear()}})),gb=ub.named(`Figure`).props({type:`figure`,subType:`rect`,fill:`rgb(0, 161, 255)`,dash:K.array(K.number),strokeWidth:0,stroke:`rgba(98, 197, 255, 1)`,cornerRadius:0}),_b=fb.named(`Gif`).props({type:`gif`,duration:0,keepRatio:!0}),vb=.05,yb=K.enumeration([`solid`,`dashed`,`dotted`,`none`]);function bb(e){return Np(e,2)}function xb(e,t,n){return e[`_${t}`]??(Hp(e)?bb(e)[t]:n)}function Sb(e){return Np(e,1)}var Cb=K.model(`BorderSide`,{color:K.maybe(K.string),width:K.maybe(K.number),style:K.maybe(yb)}).postProcessSnapshot(e=>{let t={};for(let[n,r]of Object.entries(e))r!=null&&(t[n]=r);return t}),wb=K.model(`CellBorders`,{top:K.maybe(Cb),right:K.maybe(Cb),bottom:K.maybe(Cb),left:K.maybe(Cb)}).postProcessSnapshot(e=>{let t={};for(let[n,r]of Object.entries(e))typeof r==`object`&&r&&Object.keys(r).length>0&&(t[n]=r);return t}),Tb=[`fontSize`,`fontFamily`,`fontWeight`,`fontStyle`,`textDecoration`,`textTransform`,`fill`,`align`,`verticalAlign`,`lineHeight`,`letterSpacing`,`strokeWidth`,`stroke`,`cellBackground`,`cellPadding`],Eb=new Set(Tb),Db=[`blurEnabled`,`blurRadius`,`brightnessEnabled`,`brightness`,`sepiaEnabled`,`grayscaleEnabled`,`filters`,`shadowEnabled`,`shadowBlur`,`shadowOffsetX`,`shadowOffsetY`,`shadowColor`,`shadowOpacity`],Ob=[`id`,`type`,`text`,`opacity`,`rowSpan`,`colSpan`,`mergedInto`,`name`,`custom`,`borders`],kb=new Set(`row.col.x.y.width.height.rotation.draggable.resizable.selectable.removable.contentEditable.visible.showInExport.alwaysOnTop.backgroundEnabled.backgroundOpacity.backgroundColor.backgroundCornerRadius.backgroundPadding.curveEnabled.curvePower.shadowEnabled.shadowBlur.shadowOffsetX.shadowOffsetY.shadowColor.shadowOpacity.blurEnabled.blurRadius.brightnessEnabled.brightness.sepiaEnabled.grayscaleEnabled.placeholder.animations.filters`.split(`.`)),Ab={opacity:1,rowSpan:1,colSpan:1,name:``},jb=[],Mb=K.model(`TableCell`,{id:K.identifier,type:K.optional(K.literal(`tablecell`),`tablecell`),text:``,_fontSize:K.maybe(K.number),_fontFamily:K.maybe(K.string),_fontWeight:K.maybe(K.string),_fontStyle:K.maybe(K.string),_textDecoration:K.maybe(K.string),_textTransform:K.maybe(K.string),_fill:K.maybe(K.string),_align:K.maybe(K.string),_verticalAlign:K.maybe(K.string),_lineHeight:K.maybe(K.union(K.number,K.string)),_letterSpacing:K.maybe(K.number),_strokeWidth:K.maybe(K.number),_stroke:K.maybe(K.string),_cellBackground:K.maybe(K.string),_cellPadding:K.maybe(K.number),opacity:1,rowSpan:1,colSpan:1,mergedInto:K.maybe(K.string),borders:K.maybe(wb),name:``,custom:K.frozen()}).volatile(()=>({_editModeEnabled:!1,filters:Ut.map()})).preProcessSnapshot(e=>{if(!e)return e;for(let t in e)e[t]===null&&(e[t]=void 0);let t={};for(let n of Ob)n in e&&(t[n]=e[n]);for(let n of Tb)e[n]!==void 0&&(t[`_${n}`]=e[n]);return t}).postProcessSnapshot(e=>{let t={};for(let[n,r]of Object.entries(e))if(n.startsWith(`_`))r!=null&&(t[n.slice(1)]=r);else if(n===`borders`)typeof r==`object`&&r&&Object.keys(r).length>0&&(t.borders=r);else{if(n in Ab&&r===Ab[n])continue;t[n]=r}return t}).views(e=>{let t={get row(){if(!Hp(e))return 0;let t=bb(e),n=Sb(e).indexOf(e);return n===-1?0:Math.floor(n/t.cols)},get col(){if(!Hp(e))return 0;let t=bb(e),n=Sb(e).indexOf(e);return n===-1?0:n%t.cols},get store(){return Hp(e)?Ip(e):null},get page(){if(!Hp(e))return null;try{return bb(e).page}catch{return null}},get fontSize(){return xb(e,`fontSize`,30)},get fontFamily(){return xb(e,`fontFamily`,`Roboto`)},get fontWeight(){return xb(e,`fontWeight`,`normal`)},get fontStyle(){return xb(e,`fontStyle`,`normal`)},get textDecoration(){return xb(e,`textDecoration`,``)},get textTransform(){return xb(e,`textTransform`,`none`)},get fill(){return xb(e,`fill`,`black`)},get align(){return xb(e,`align`,`left`)},get verticalAlign(){return xb(e,`verticalAlign`,`top`)},get lineHeight(){return xb(e,`lineHeight`,1.2)},get letterSpacing(){return xb(e,`letterSpacing`,0)},get strokeWidth(){return xb(e,`strokeWidth`,0)},get stroke(){return xb(e,`stroke`,`black`)},get cellBackground(){return xb(e,`cellBackground`,`transparent`)},get cellPadding(){return xb(e,`cellPadding`,4)},get width(){if(!Hp(e))return 100;try{return bb(e).getCellRect(t.row,t.col,e.rowSpan,e.colSpan).width}catch{return 100}},get height(){if(!Hp(e))return 100;try{return bb(e).getCellRect(t.row,t.col,e.rowSpan,e.colSpan).height}catch{return 100}},get borderInsets(){if(!Hp(e))return{top:0,right:0,bottom:0,left:0};let n=bb(e),r=(e,n)=>{let r=t.getEffectiveBorder(e);return r.style===`none`||r.width===0?0:n?r.width:r.width/2};return{top:r(`top`,t.row===0),bottom:r(`bottom`,t.row+e.rowSpan===n.rows),left:r(`left`,t.col===0),right:r(`right`,t.col+e.colSpan===n.cols)}},get a(){if(!Hp(e))return{x:0,y:0,width:100,height:100,rotation:0,opacity:1,fontSize:16};let n=bb(e).getCellRect(t.row,t.col,e.rowSpan,e.colSpan),r=t.cellPadding,{top:i,right:a,bottom:o,left:s}=t.borderInsets;return{x:n.x+s+r,y:n.y+i+r,width:Math.max(0,n.width-s-a-2*r),height:Math.max(0,n.height-i-o-2*r),rotation:0,opacity:e.opacity??1,fontSize:t.fontSize}},getEffectiveBorder(t){let n=Hp(e)?bb(e):null,r=e.borders?.[t];return{color:r?.color??n?.borderColor??`#000000`,width:r?.width??n?.borderWidth??1,style:r?.style??n?.borderStyle??`solid`}},get x(){return 0},get y(){return 0},get rotation(){return 0},get draggable(){return!1},get resizable(){return!1},get selectable(){return!1},get removable(){return!1},get contentEditable(){return!0},get visible(){return!0},get showInExport(){return!0},get alwaysOnTop(){return!1},get placeholder(){return``},get backgroundEnabled(){return!1},get backgroundOpacity(){return 1},get backgroundColor(){return`transparent`},get backgroundCornerRadius(){return 0},get backgroundPadding(){return 0},get curveEnabled(){return!1},get curvePower(){return 0},get shadowEnabled(){return!1},get shadowBlur(){return 0},get shadowOffsetX(){return 0},get shadowOffsetY(){return 0},get shadowColor(){return`black`},get shadowOpacity(){return 1},get blurEnabled(){return!1},get blurRadius(){return 0},get brightnessEnabled(){return!1},get brightness(){return 0},get sepiaEnabled(){return!1},get grayscaleEnabled(){return!1},get animations(){return jb}};return t}).actions(e=>({toJSON:()=>Object.assign({},Mp(e)),set(t){t.fontSize!=null&&t.fontSize<1&&(t=Object.assign(Object.assign({},t),{fontSize:1}));let n={};for(let[e,r]of Object.entries(t))Eb.has(e)?n[`_${e}`]=r:e===`borders`?n.borders=r&&JSON.parse(JSON.stringify(r)):kb.has(e)||(n[e]=r);Object.assign(e,n)},setBorder(t,n){let r=e.borders?Object.assign({},Mp(e.borders)):{},i=r[t]||{},a=Object.assign({},i);n.color!==void 0&&(a.color=n.color),n.width!==void 0&&(a.width=n.width),n.style!==void 0&&(a.style=n.style),r[t]=a,e.borders=Up(r)},toggleEditMode(t){let n=t??!e._editModeEnabled;n!==e._editModeEnabled&&(e._editModeEnabled=n,e._editModeEnabled?e.store.history.startTransaction():e.store.history.endTransaction())}}));function Nb(e,t){let n=[];for(let r of e){let e={id:c_(10),text:``};if(!r){n.push(e);continue}for(let t of Tb){let n=r[`_${t}`];n!=null&&(e[t]=n)}let i=r.borders;if(i){let n={},r=t?[`left`,`right`,`top`]:[`top`,`bottom`,`left`];for(let e of r){let t=i[e];t&&(n[e]=Mp(t))}Object.keys(n).length>0&&(e.borders=n)}n.push(e)}return n}function Pb(e){return Array.from({length:e},()=>1/e)}function Fb(e){let t=e.reduce((e,t)=>e+t,0);return t===0?Pb(e.length):e.map(e=>e/t)}var Ib=ub.named(`Table`).props({type:`table`,width:300,height:200,rows:3,cols:3,colWidths:K.array(K.number),rowHeights:K.array(K.number),cells:K.array(Mb),borderColor:`#000000`,borderWidth:1,borderStyle:K.optional(K.enumeration([`solid`,`dashed`,`dotted`,`none`]),`solid`),fontSize:30,fontFamily:`Roboto`,fontWeight:`normal`,fontStyle:`normal`,textDecoration:``,textTransform:`none`,fill:`black`,align:`center`,verticalAlign:`middle`,lineHeight:K.optional(K.union(K.number,K.string),1.2),letterSpacing:0,strokeWidth:0,stroke:`black`,cellBackground:`transparent`,cellPadding:4}).postProcessSnapshot(e=>{e.cells&&((e=Object.assign({},e)).cells=e.cells.map(t=>{let n={};for(let[r,i]of Object.entries(t))Eb.has(r)&&i===e[r]||(n[r]=i);return n}));for(let t of Db)delete e[t];return e}).volatile(()=>({_focusedCellIds:[],_editingCellId:void 0,_anchorCellId:void 0,_cellContentHeights:Ut.map(),_baseRowHeights:null,_baseHeight:null})).actions(e=>({afterCreate(){let t=e.rows*e.cols;if(e.cells.length===0)e.cells.replace(function(e,t){let n=[];for(let r=0;r<e*t;r++)n.push({id:c_(10),text:``});return n}(e.rows,e.cols));else if(e.cells.length<t)for(;e.cells.length<t;)e.cells.push(Up({id:c_(10),text:``}));else e.cells.length>t&&e.cells.splice(t);e.colWidths.length===0&&e.colWidths.replace(Pb(e.cols)),e.rowHeights.length===0&&e.rowHeights.replace(Pb(e.rows))}})).views(e=>({get _cellMap(){let t=new Map,n=e.cols;return e.cells.forEach((e,r)=>{t.set(`${Math.floor(r/n)}:${r%n}`,e)}),t},getActualRowHeight:t=>e.rowHeights[t]*e.height})).views(e=>{let t={getCell:(t,n)=>e._cellMap.get(`${t}:${n}`),get minWidth(){return 20*e.cols},getRowContentOuterHeight(n){let r=0;for(let i=0;i<e.cols;i++){let a=t.getCell(n,i);if(!a)continue;let o=e._cellContentHeights.get(a.id);if(o===void 0)continue;let s=a.borderInsets,c=o+2*a.cellPadding+s.top+s.bottom;c>r&&(r=c)}return r},get minHeight(){let n=20*e.rows;if(e._cellContentHeights.size===0)return n;let r=0;for(let n=0;n<e.rows;n++)r+=t.getRowContentOuterHeight(n);return Math.max(n,r)},get actualHeight(){let t=0;for(let n=0;n<e.rows;n++)t+=e.getActualRowHeight(n);return t},getCellRect(t,n,r=1,i=1){let a=0;for(let t=0;t<n;t++)a+=e.colWidths[t]*e.width;let o=0;for(let n=0;n<t;n++)o+=e.getActualRowHeight(n);let s=0;for(let t=n;t<n+i;t++)s+=(e.colWidths[t]||0)*e.width;let c=0;for(let n=t;n<t+r;n++)c+=e.getActualRowHeight(n);return{x:a,y:o,width:s,height:c}},get visibleCells(){return e.cells.filter(e=>!e.mergedInto)},get focusedCells(){return e.cells.filter(t=>e._focusedCellIds.includes(t.id))},get editingCell(){if(e._editingCellId)return e.cells.find(t=>t.id===e._editingCellId)},getFocusedCellRange(){if(e._focusedCellIds.length===0)return null;let t=1/0,n=-1/0,r=1/0,i=-1/0,a=new Set(e._focusedCellIds);for(let o of e.cells)a.has(o.id)&&(o.row<t&&(t=o.row),o.row>n&&(n=o.row),o.col<r&&(r=o.col),o.col>i&&(i=o.col));return t===1/0?null:{minRow:t,maxRow:n,minCol:r,maxCol:i}},get _fitRowsToContent(){if(e._cellContentHeights.size===0)return null;let n=e._baseHeight??e.height,r=e._baseRowHeights??[...e.rowHeights],i=!1,a=[];for(let o=0;o<e.rows;o++){let s=e.rowHeights[o]*e.height,c=r[o]*n,l=t.getRowContentOuterHeight(o),u=Math.max(l,c);Math.abs(u-s)>1?(a.push(u),i=!0):a.push(s)}if(!i)return null;let o=a.reduce((e,t)=>e+t,0);return{rowHeights:a.map(e=>e/o),height:o}}};return t}).actions(e=>{let t={setCellContentHeight(t,n){e._cellContentHeights.set(t,n)},_applyFitRowsToContent(){if(!Hp(e))return;e._baseRowHeights===null&&(e._baseRowHeights=[...e.rowHeights],e._baseHeight=e.height);let t=e._fitRowsToContent;t&&(e.height=t.height,e.rowHeights.replace(t.rowHeights))},focusCell(t,n=!1){n?e._focusedCellIds.includes(t)||(e._focusedCellIds=[...e._focusedCellIds,t]):(e._focusedCellIds=[t],e._anchorCellId=t)},selectRowRange(t,n){let r=Math.max(0,Math.min(t,n)),i=Math.min(e.rows-1,Math.max(t,n)),a=[];for(let t=r;t<=i;t++)for(let n=0;n<e.cols;n++){let r=e.getCell(t,n);r&&a.push(r.id)}e._focusedCellIds=a,e._anchorCellId=a[0]},selectColumnRange(t,n){let r=Math.max(0,Math.min(t,n)),i=Math.min(e.cols-1,Math.max(t,n)),a=[];for(let t=0;t<e.rows;t++)for(let n=r;n<=i;n++){let r=e.getCell(t,n);r&&a.push(r.id)}e._focusedCellIds=a,e._anchorCellId=a[0]},selectRow(e){t.selectRowRange(e,e)},selectColumn(e){t.selectColumnRange(e,e)},focusCellRange(t,n){let r=e.cells.find(t=>t.id===e._anchorCellId);if(!r)return;let i=Math.min(r.row,t),a=Math.max(r.row,t),o=Math.min(r.col,n),s=Math.max(r.col,n),c=[];for(let t of e.cells)t.row>=i&&t.row<=a&&t.col>=o&&t.col<=s&&c.push(t.id);e._focusedCellIds=c},clearCellFocus(){if(Hp(e)){if(e._editingCellId){let t=e.cells.find(t=>t.id===e._editingCellId);t&&t.toggleEditMode(!1)}e._focusedCellIds=[],e._editingCellId=void 0,e._anchorCellId=void 0}},enterCellEdit(t){e._editingCellId=t,e._focusedCellIds.includes(t)||(e._focusedCellIds=[t]);let n=e.cells.find(e=>e.id===t);n&&n.toggleEditMode(!0)},exitCellEdit(){if(e._editingCellId){let t=e.cells.find(t=>t.id===e._editingCellId);t&&t.toggleEditMode(!1)}e._editingCellId=void 0},_resetBaseRowHeights(){e._baseRowHeights=null,e._baseHeight=null},setHeightRedistribute(t){let n=e.rows;if(n===0||t<=0){e.height=t;return}let r=e.height;if(r<=0||t>=r){e.height=t;return}let i=[],a=[],o=0;for(let t=0;t<n;t++){i.push(e.rowHeights[t]*r);let n=e.getRowContentOuterHeight(t);a.push(n),o+=n}if(t<=o||o<=0){e.height=t;return}let s=t-o,c=0,l=[];for(let e=0;e<n;e++){let t=Math.max(0,i[e]-a[e]);l.push(t),c+=t}let u=[];if(c<=0){let e=t/r;for(let t=0;t<n;t++)u.push(i[t]*e)}else for(let e=0;e<n;e++)u.push(a[e]+l[e]/c*s);let d=u.map(e=>e/t);e.height=t,e.rowHeights.replace(d)},addRow(n){t._resetBaseRowHeights();let r=n>0?n-1:0,i=(e.rowHeights[r]||1/(e.rows+1))*e.height,a=e.height+i,o=[];for(let t=0;t<e.rows;t++)o.push(e.rowHeights[t]*e.height/a);o.splice(n,0,i/a);let s=n>0?n-1:0,c=[];for(let t=0;t<e.cols;t++)c.push(e.cells[s*e.cols+t]);let l=n*e.cols,u=Nb(c,!0);e.cells.splice(l,0,...u),e.rows+=1,e.height=a,e.rowHeights.replace(Fb(o))},removeRow(n){if(e.rows<=1)return;t._resetBaseRowHeights();let r=n*e.cols,i=[];for(let t=r;t<r+e.cols;t++)i.push(e.cells[t].id);if(e._editingCellId&&i.includes(e._editingCellId)){let t=e.cells.find(t=>t.id===e._editingCellId);t&&t.toggleEditMode(!1),e._editingCellId=void 0}e._focusedCellIds=e._focusedCellIds.filter(e=>!i.includes(e)),i.forEach(t=>e._cellContentHeights.delete(t)),e.cells.splice(r,e.cols);let a=[...e.rowHeights];a.splice(n,1),--e.rows,e.rowHeights.replace(Fb(a))},addColumn(t){let n=t>0?t-1:0,r=(e.colWidths[n]||1/(e.cols+1))*e.width,i=e.width+r,a=[];for(let t=0;t<e.cols;t++)a.push(e.colWidths[t]*e.width/i);a.splice(t,0,r/i);let o=e.cols,s=t>0?t-1:0,c=[];for(let t=0;t<e.rows;t++)c.push(e.cells[t*o+s]);let l=Nb(c,!1);for(let n=e.rows-1;n>=0;n--)e.cells.splice(n*o+t,0,Up(l[n]));e.cols+=1,e.width=i,e.colWidths.replace(Fb(a))},removeColumn(t){if(e.cols<=1)return;let n=e.cols,r=[];for(let i=0;i<e.rows;i++)r.push(e.cells[i*n+t].id);if(e._editingCellId&&r.includes(e._editingCellId)){let t=e.cells.find(t=>t.id===e._editingCellId);t&&t.toggleEditMode(!1),e._editingCellId=void 0}e._focusedCellIds=e._focusedCellIds.filter(e=>!r.includes(e)),r.forEach(t=>e._cellContentHeights.delete(t));for(let r=e.rows-1;r>=0;r--)e.cells.splice(r*n+t,1);let i=[...e.colWidths];i.splice(t,1),--e.cols,e.colWidths.replace(Fb(i))},removeRowRange(n,r){for(let i=r;i>=n&&!(e.rows<=1);i--)t.removeRow(i)},removeColumnRange(n,r){for(let i=r;i>=n&&!(e.cols<=1);i--)t.removeColumn(i)},distributeRowsEvenly(){let n=e.rows,r=20;for(let t=0;t<n;t++)r=Math.max(r,e.getRowContentOuterHeight(t));t._resetBaseRowHeights(),e.height=Math.max(e.height,r*n),e.rowHeights.replace(Pb(n))},distributeColumnsEvenly(){e.colWidths.replace(Pb(e.cols))},resizeColumn(t,n){if(t>=e.cols-1)return;let r=[...e.colWidths],i=r[t]+r[t+1],a=r[t]+n,o=r[t+1]-n;a<vb?(r[t]=vb,r[t+1]=i-vb):o<vb?(r[t+1]=vb,r[t]=i-vb):(r[t]=a,r[t+1]=o),e.colWidths.replace(r)},resizeRow(t,n){if(t>=e.rows-1)return;let r=[...e.rowHeights],i=r[t]+r[t+1],a=e.height,o=a>0?e.getRowContentOuterHeight(t)/a:0,s=a>0?e.getRowContentOuterHeight(t+1)/a:0,c=Math.max(vb,o),l=Math.max(vb,s),u=r[t]+n,d=r[t+1]-n;u<c?(r[t]=c,r[t+1]=i-c):d<l?(r[t+1]=l,r[t]=i-l):(r[t]=u,r[t+1]=d),e.rowHeights.replace(r)},setCellBorders(t,n,r){let i={top:{side:`bottom`,dr:-1,dc:0},bottom:{side:`top`,dr:1,dc:0},left:{side:`right`,dr:0,dc:-1},right:{side:`left`,dr:0,dc:1}};for(let a of t){let t=e.cells.find(e=>e.id===a);if(t)for(let a of n){t.setBorder(a,r);let n=i[a],o=t.row+n.dr,s=t.col+n.dc,c=e.getCell(o,s);c&&c.setBorder(n.side,r)}}},applyBorderMode(n,r){let i=function(e,t,n){let{minRow:r,maxRow:i,minCol:a,maxCol:o}=t,s=(e,t,r,i)=>{let a=[];for(let o=e;o<=t;o++)for(let e=r;e<=i;e++){let t=n(o,e);t&&a.push(t.id)}return a};if(e===`all`)return[{cellIds:s(r,i,a,o),sides:[`top`,`right`,`bottom`,`left`]}];let c=[],l=e===`outer`||e===`topOnly`||e===`topBottom`,u=e===`outer`||e===`bottomOnly`||e===`topBottom`,d=e===`outer`||e===`leftOnly`,f=e===`outer`||e===`rightOnly`;if(l){let e=s(r,r,a,o);e.length&&c.push({cellIds:e,sides:[`top`]})}if(u){let e=s(i,i,a,o);e.length&&c.push({cellIds:e,sides:[`bottom`]})}if(d){let e=s(r,i,a,a);e.length&&c.push({cellIds:e,sides:[`left`]})}if(f){let e=s(r,i,o,o);e.length&&c.push({cellIds:e,sides:[`right`]})}if(l||u||d||f)return c;if((e===`inner`||e===`innerHorizontal`)&&i>r){let e=s(r,i-1,a,o);e.length&&c.push({cellIds:e,sides:[`bottom`]})}if((e===`inner`||e===`innerVertical`)&&o>a){let e=s(r,i,a,o-1);e.length&&c.push({cellIds:e,sides:[`right`]})}return c}(n,e.getFocusedCellRange()??{minRow:0,maxRow:e.rows-1,minCol:0,maxCol:e.cols-1},(t,n)=>e.getCell(t,n));for(let{cellIds:e,sides:n}of i)t.setCellBorders(e,n,r)}};return t}).actions(e=>({clone(t={},{skipSelect:n=!1}={}){let r=JSON.parse(JSON.stringify(e.toJSON()));if(t.id=t.id||c_(10),r.cells){let e=new Map;r.cells.forEach(t=>{let n=t.id,r=c_(10);e.set(n,r),t.id=r}),r.cells.forEach(t=>{t.mergedInto&&e.has(t.mergedInto)&&(t.mergedInto=e.get(t.mergedInto))})}return Object.assign(r,t),e.page.addElement(r,{skipSelect:n})}})),Lb=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n},Rb=(e,t)=>{if(e.children)for(let n of e.children){if(!0===t(n))break;Rb(n,t)}},zb=(e,t)=>{if(e.children)for(let n of e.children){if(!0===t(n))break;zb(n,t)}if(e.cells){for(let n of e.cells)if(!0===t(n))break}};function Bb(e){let t=(t,n,r)=>{let i=t.map(t=>e.children.findIndex(e=>e.id===t)).filter(e=>e!==-1).sort((e,t)=>(t-e)*n);for(let a of i){let i=e.children[a+n];!i||t.indexOf(i.id)>=0||r(a)}},n=(e,n)=>{let r=!1;return t(e,n,()=>{r=!0}),r},r=(n,r)=>{t(n,r,t=>{let n=e.children[t];Bp(n),e.children.splice(t+r,0,n)})},i=(t,n)=>{let r=[],i=[];e.children.forEach(e=>{(t.indexOf(e.id)>=0?r:i).push(e)}),e.children.replace(n?i.concat(r):r.concat(i))};return{canMoveElementsUp:e=>n(e,1),canMoveElementsTop:e=>n(e,1),canMoveElementsDown:e=>n(e,-1),canMoveElementsBottom:e=>n(e,-1),moveElementsUp(e){r(e,1)},moveElementsDown(e){r(e,-1)},moveElementsTop(e){i(e,!0)},moveElementsBottom(e){i(e,!1)},setElementZIndex(t,n){let r=e.children.find(e=>e.id===t);r&&(Bp(r),e.children.remove(r),e.children.splice(n,0,r))}}}var Vb=[...Array(20)].map((e,t)=>K.late(()=>Yb[t])),Hb=K.union({dispatcher:e=>{let t=Xb[e.type];if(!t)throw Error(`Unknown element type: "${e.type}"`);return t}},hb,db,fb,mb,pb,gb,_b,Ib,K.late(()=>Jb),...Vb),Ub=Object.freeze({x:0,y:0,offsetX:0,offsetY:0,scaleX:1,scaleY:1,rotation:0,opacity:1});function Wb(e){return e===1?Ub:Object.assign(Object.assign({},Ub),{opacity:e})}var Gb={x:0,y:0,width:0,height:0,rotation:0,opacity:1,fontSize:0,cropX:0,cropY:0,cropWidth:1,cropHeight:1},Kb=(e,t)=>typeof e==`number`&&isFinite(e)?e:t;function qb(e,t,n,r){Gb.x=e.x,Gb.y=e.y,Gb.width=e.width,Gb.height=e.height,Gb.opacity=r;let i=ab({element:Gb,animation:t,dTime:n})||{},a=Kb(i.width,e.width),o=Kb(i.height,e.height);return{x:Kb(i.x,e.x),y:Kb(i.y,e.y),width:a>0?a:e.width,height:o>0?o:e.height,rotation:Kb(i.rotation,0),opacity:Kb(i.opacity,r)}}var Jb=tb.named(`Group`).props({type:`group`,children:K.array(Hb),animations:K.array(ob)}).views(e=>({get draggable(){let t=!0;return Rb(e,e=>{e.draggable||(t=!1)}),t},get resizable(){let t=!0;return Rb(e,e=>{e.resizable||(t=!1)}),t},get contentEditable(){let t=!0;return Rb(e,e=>{e.contentEditable||(t=!1)}),t},get styleEditable(){let t=!0;return Rb(e,e=>{e.styleEditable||(t=!1)}),t},get locked(){let t=!0;return Rb(e,e=>{e.locked||(t=!1)}),t},get _restingBbox(){let t=[];if(Rb(e,e=>{if(e.type===`group`)return;let n=e.width,r=e.height;!n||!r||n<=0||r<=0||t.push({x:e.x??0,y:e.y??0,width:n,height:r,rotation:e.rotation??0})}),!t.length)return null;let n=Xy(t);return n.width<=0||n.height<=0?null:{x:n.x,y:n.y,width:n.width,height:n.height}},get a(){if(!Hp(e))return Ub;let{currentTime:t}=e.store;if(t===0)return Wb(e.opacity);let n=e.page;if(!n)return Wb(e.opacity);let r=t-n.startTime;if(r<0||r>n.duration)return Wb(e.opacity);let i=e.store.animatedElementsIds;if(i.length&&!i.includes(e.id))return Wb(e.opacity);let a,o,s;for(let t of e.animations)t.enabled&&(t.type===`enter`?a=t:t.type===`exit`?o=t:t.type===`loop`&&(s=t));let c=!!a&&r<a.delay,l=!!a&&r>=a.delay&&r<=a.delay+a.duration,u=!c&&!l&&!!o&&r>=n.duration-o.duration-o.delay&&r<=n.duration-o.delay,d=!!o&&r>=n.duration-o.delay;if(!(c||l||u||d||s))return Wb(e.opacity);let f=this._restingBbox;if(!f)return Wb(e.opacity);let p={x:f.x,y:f.y,width:f.width,height:f.height,rotation:0,opacity:e.opacity};c&&(p.opacity=0),l&&(p=qb(f,a,r-a.delay,e.opacity)),u&&(p=qb(f,o,r-(n.duration-o.duration-o.delay),e.opacity)),d&&(p.opacity=0),s&&(p=qb(p,s,r,p.opacity));let m=Zy(p);return{x:m.x,y:m.y,offsetX:f.x+f.width/2,offsetY:f.y+f.height/2,scaleX:p.width/f.width,scaleY:p.height/f.height,rotation:p.rotation,opacity:p.opacity}}})).actions(e=>Object.assign(Object.assign({set(t){var{draggable:n,contentEditable:r,styleEditable:i,resizable:a}=t,o=Lb(t,[`draggable`,`contentEditable`,`styleEditable`,`resizable`]);n!==void 0&&Rb(e,e=>{e.set({draggable:n})}),r!==void 0&&Rb(e,e=>{e.set({contentEditable:r})}),i!==void 0&&Rb(e,e=>{e.set({styleEditable:i})}),a!==void 0&&Rb(e,e=>{e.set({resizable:a})}),Object.assign(e,o)},addElement(t,{skipSelect:n=!1}={}){let r=Xb[t.type];if(!r){console.error(`Can not find model with type `+t.type);return}t.children&&t.children.forEach(e=>{e.id=e.id||c_(10)});let i=r.create(Object.assign({id:c_(10)},t));return e.children.push(i),i.selectable&&!n&&e.store.selectElements([i.id]),i}},Bb(e)),{setAnimation(t,n){let r=e.animations.find(e=>e.type===t);r?Object.assign(r,n):e.animations.push(Object.assign({type:t},n))}})),Yb=[],Xb={svg:hb,text:db,image:fb,group:Jb,line:mb,video:pb,figure:gb,gif:_b,table:Ib},Zb=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},Qb=e=>{let t=window.getComputedStyle(e).position;return!(t===`absolute`||t===`relative`)};function $b(e=()=>{}){let t=b.useRef(e);return t.current=e,b.useCallback((...e)=>t.current.apply(null,e),[])}var ex=({children:e,groupProps:t,divProps:n,transform:r,transformFunc:i,parentNodeFunc:a})=>{let o=Ef(),s=b.useRef(null),[c]=b.useState(()=>document.createElement(`div`)),l=b.useMemo(()=>x.createRoot(c),[c]),u=r??!0,d=$b(()=>{if(u&&s.current){let e=s.current.getAbsoluteTransform().decompose();i&&(e=i(e)),c.style.position=`absolute`,c.style.zIndex=`10`,c.style.top=`0px`,c.style.left=`0px`,c.style.transform=`translate(${e.x}px, ${e.y}px) rotate(${e.rotation}deg) scaleX(${e.scaleX}) scaleY(${e.scaleY})`,c.style.transformOrigin=`top left`}else c.style.position=``,c.style.zIndex=``,c.style.top=``,c.style.left=``,c.style.transform=``,c.style.transformOrigin=``;let e=n||{},{style:t}=e,r=Zb(e,[`style`]);Object.assign(c.style,t),Object.assign(c,r)});return b.useLayoutEffect(()=>{let e=s.current;if(!e)return;let t=a?a({stage:e.getStage()}):e.getStage()?.container();if(t)return t.appendChild(c),u&&Qb(t)&&(t.style.position=`relative`),e.on(`absoluteTransformChange`,d),d(),()=>{var t;e.off(`absoluteTransformChange`,d),(t=c.parentNode)==null||t.removeChild(c)}},[u,a]),b.useLayoutEffect(()=>{d()},[n,i]),b.useLayoutEffect(()=>{queueMicrotask(()=>{(0,oa.flushSync)(()=>{l.render(b.createElement(o,null,e))})})}),b.useLayoutEffect(()=>()=>{setTimeout(()=>{l.unmount()})},[]),b.createElement(jf,Object.assign({ref:s},t))},tx=({selector:e,enabled:t,children:n})=>{let r=b.useRef(null),i=b.useRef(null),a=b.useRef(null),o=t??!0;return b.useLayoutEffect(()=>{if(!r.current||!i.current)return;a.current=i.current;let t=r.current.getStage().findOne(e);o&&t?i.current.moveTo(t):i.current.moveTo(r.current);let n=r.current.getLayer();if(n&&(n.batchDraw(),t)){let e=t.getLayer();if(!e)return;e.batchDraw()}},[e,o]),b.useEffect(()=>()=>{var e;(e=a.current)==null||e.destroy()},[]),b.createElement(jf,{name:`_outer_portal`,ref:r},b.createElement(jf,{name:`_inner_portal`,ref:i},n))};function nx(e,t){return Object.keys(e.values).forEach(n=>e.values[n]=e.values[n]&&parseFloat(e.values[n].toFixed(t))),e}function rx(e,t,n){let r=t-1,i=n[sx(r,n.length)];return i.marker===`Z`?rx(e,r,n):i}function ix(e,t,n){let r=t+1,i=n[sx(r,n.length)];return i.marker===`Z`?ix(e,r,n):i}function ax(e,t,n){let r=n[t-1]||{values:{x:0,y:0}};if(e.marker===e.marker.toLowerCase())switch(e.marker=e.marker.toUpperCase(),e.marker){case`M`:e.values.x+=r.values.x,e.values.y+=r.values.y;break;case`L`:case`A`:e.values.x+=r.values.x,e.values.y+=r.values.y;break;case`H`:e.marker=`L`,e.values.x+=r.values.x,e.values.y=r.values.y;break;case`V`:e.marker=`L`,e.values.x=r.values.x,e.values.y+=r.values.y;break;case`C`:e.values.x+=r.values.x,e.values.y+=r.values.y,e.values.x1+=r.values.x,e.values.y1+=r.values.y,e.values.x2+=r.values.x,e.values.y2+=r.values.y;break;case`S`:e.values.x+=r.values.x,e.values.y+=r.values.y,e.values.x2+=r.values.x,e.values.y2+=r.values.y;break;case`Q`:e.values.x+=r.values.x,e.values.y+=r.values.y,e.values.x1+=r.values.x,e.values.y1+=r.values.y;break;case`T`:e.values.x+=r.values.x,e.values.y+=r.values.y;break;case`Z`:break}else if(e.marker===e.marker.toUpperCase())switch(e.marker){case`H`:e.marker=`L`,e.values.y=r.values.y;break;case`V`:e.marker=`L`,e.values.x=r.values.x;break}if(e.marker===`Z`){function r(e,t){return e[t].marker===`M`?e[t]:r(e,t-1)}let i=r(n,t);e.values.x=i.values.x,e.values.y=i.values.y}return e}function ox(e,t){let n=[];switch(e.toUpperCase()){case`M`:for(let r=0;r<t.length;r+=2){let i;i=e===e.toUpperCase()?r===0?`M`:`L`:r===0?`m`:`l`,n.push({marker:i,values:{x:t[r],y:t[r+1]}})}break;case`L`:for(let r=0;r<t.length;r+=2)n.push({marker:e,values:{x:t[r],y:t[r+1]}});break;case`H`:for(let r=0;r<t.length;r++)n.push({marker:e,values:{x:t[r],y:0}});break;case`V`:for(let r=0;r<t.length;r++)n.push({marker:e,values:{x:0,y:t[r]}});break;case`C`:for(let r=0;r<t.length;r+=6)n.push({marker:e,values:{x1:t[r],y1:t[r+1],x2:t[r+2],y2:t[r+3],x:t[r+4],y:t[r+5]}});break;case`S`:for(let r=0;r<t.length;r+=4)n.push({marker:e,values:{x2:t[r],y2:t[r+1],x:t[r+2],y:t[r+3]}});break;case`Q`:for(let r=0;r<t.length;r+=4)n.push({marker:e,values:{x1:t[r],y1:t[r+1],x:t[r+2],y:t[r+3]}});break;case`T`:for(let r=0;r<t.length;r+=2)n.push({marker:e,values:{x:t[r],y:t[r+1]}});break;case`A`:for(let r=0;r<t.length;r+=7)n.push({marker:e,values:{radiusX:t[r],radiusY:t[r+1],rotation:t[r+2],largeArc:t[r+3],sweep:t[r+4],x:t[r+5],y:t[r+6]}});break;case`Z`:n.push({marker:e,values:{x:0,y:0}});break}return n}function sx(e,t){return(e%t+t)%t}function cx(e,t,n){if(t!==0&&e.marker===`L`){let r=n[t-1];[`x`,`y`].every(t=>Math.round(Math.abs(r.values[t]-e.values[t]))===0)&&(e.overlap=!0)}return e}function lx(e,t){let n=[`x`,`y`].every(n=>Math.round(Math.abs(e[t].values[n]-e[0].values[n]))===0);e[t].marker===`L`&&n&&(e[t].overlap=!0,lx(e,t-1)),e[t].marker===`Z`&&lx(e,t-1)}function ux(e,t,n){let r=fx(e.values,n.values),i=fx(t.values,e.values);return Math.min(i,r)}function dx(e,t){return Math.atan2(t.x-e.x,t.y-e.y)}function fx(e,t){let n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n**2+r**2)}function px(e,t){return Math.sin(e)*t}function mx(e,t){return Math.cos(e)*t}function hx(e,t){let n=t/Math.tan(e);return n===1/0||n===-1/0||isNaN(n)?t:n}function gx(e,t){return t*Math.tan(e)}function _x(e,t){let n,r=0,i=180/Math.PI*e;return i<0&&i>=-180||i>180&&i<360?n=hx(e/2,-t):(n=hx(e/2,t),r=1,n===1/0&&(n=t)),{offset:n,sweepFlag:r}}function vx(e){let t=[`radiusX`,`radiusY`,`rotation`,`largeArc`,`sweep`,`x1`,`y1`,`x2`,`y2`,`x`,`y`];return e.map(e=>{let n=``;if(e.marker!==`Z`){let r=Object.keys(e.values);n=t.filter(e=>r.indexOf(e)!==-1).map(t=>e.values[t]).join()}return`${e.marker}${n}`}).join(``).trim()}function yx(e){let t=/[MmLlSsQqLlHhVvCcSsQqTtAaZz]/g,n=/-?[0-9]*\.?\d+/g;return[...e.matchAll(t)].map(e=>({marker:e[0],index:e.index})).reduceRight((t,n)=>{let r=e.substring(n.index,t.length?t[t.length-1].index:e.length);return t.concat([{marker:n.marker,index:n.index,chunk:r.length>0?r.substr(1,r.length-1):r}])},[]).reverse().flatMap(e=>{let t=e.chunk.match(n),r=t?t.map(parseFloat):[];return ox(e.marker,r)}).map(ax)}function bx(e,t,n){let r=[],i=[];return n&&e.forEach(e=>nx(e,n)),e.forEach(e=>{e.marker===`M`&&r.push([]),r[r.length-1].push(e)}),r.forEach(e=>{e.map(cx),lx(e,e.length-1);let n=e[e.length-1].marker==`Z`;e.filter(e=>!e.overlap).map((e,r,a)=>{let o=rx(e,r,a),s=ix(e,r,a),c=dx(e.values,o.values),l=dx(e.values,s.values),u=l-c,d=180/Math.PI*u,f=ux(e,o,s),p=Math.abs(gx(u/2,f/2)),m=Math.min(t,p),h=_x(u,m),g=h.offset,_=h.sweepFlag,v=(r==0||r==a.length-1)&&!n;switch(e.marker){case`M`:case`L`:let t=[e.values.x+px(c,g),e.values.y+mx(c,g)],n=[e.values.x+px(l,g),e.values.y+mx(l,g)];v?i.push({marker:e.marker,values:e.values}):i.push({marker:e.marker,values:{x:parseFloat(t[0].toFixed(3)),y:parseFloat(t[1].toFixed(3))}}),!v&&(s.marker===`L`||s.marker===`M`)&&i.push({marker:`A`,radius:m,values:{radiusX:parseFloat(m.toFixed(3)),radiusY:parseFloat(m.toFixed(3)),rotation:d,largeArc:0,sweep:_,x:parseFloat(n[0].toFixed(3)),y:parseFloat(n[1].toFixed(3))}});break;case`C`:case`S`:case`Q`:case`T`:case`A`:case`Z`:i.push({marker:e.marker,values:e.values});break}})}),{path:vx(i),commands:i}}function xx({rects:e,padding:t=0,cornerRadius:n=0}){let r=function(e){if(e.length<2)return e;let t=[e[0]];for(let n=1;n<e.length;n++){let r=t[t.length-1],i=e[n];Math.abs(r.left-i.left)<.5&&Math.abs(r.right-i.right)<.5&&Math.abs(r.bottom-i.top)<.5?t[t.length-1]=Object.assign(Object.assign({},r),{bottom:i.bottom}):t.push(i)}return t}(function(e){if(e.length<2)return e;let t=[e[0]];for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];if(i.top-r.bottom>.5*Math.max(r.bottom-r.top,i.bottom-i.top)){let e=Math.max(r.left,i.left),n=Math.min(r.right,i.right);n>e&&t.push({left:e,right:n,top:r.bottom,bottom:i.top})}t.push(i)}return t}(e)),i=r.length;if(i===0)return``;let a=e=>e.right-e.left,o=e=>{let t=r[e-1],n=r[e];return t?n?(t.bottom+n.top)/2:t.bottom:n.top},s=`M ${(r[0].left+r[0].right)/2} ${r[0].top-t}`;for(let e=0;e<i;e++){let n=r[e],i=r[e-1],c=r[e+1],l=n.right+t;s+=` L ${l} ${i?a(i)>a(n)?o(e)+t:o(e)-t:n.top-t}`,s+=` L ${l} ${c?a(c)>a(n)?o(e+1)-t:o(e+1)+t:n.bottom+t}`}for(let e=i-1;e>=0;e--){let n=r[e],i=r[e-1],c=r[e+1],l=n.left-t;s+=` L ${l} ${c?a(c)>a(n)?o(e+1)-t:o(e+1)+t:n.bottom+t}`,s+=` L ${l} ${i?a(i)>a(n)?o(e)+t:o(e)-t:n.top-t}`}return s+=` Z`,bx(yx(s),n).path}function Sx({lines:e,lineHeight:t,width:n,align:r}){return e.flatMap((e,i)=>{if(e.width<=0)return[];let a,o,s=e.width;return r!==`justify`||e.lastInParagraph||(s=n),r===`right`?(o=n,a=n-s):r===`center`?(a=(n-s)/2,o=a+s):(a=0,o=s),[{left:a,right:o,top:i*t,bottom:(i+1)*t}]})}var Cx=(e,t,n)=>(t===void 0&&(t=e.fill??``),n===void 0&&(n=`fill`),b.useMemo(()=>{if(!sy(t))return{[n]:t};let{stops:r,rotation:i}=ly(t),a=e.a.width/2,o=e.a.height/2,s=(i%180+180)%180,c=s>45&&s<135?e.a.width:e.a.height,l=W.Util.degToRad(i)-Math.PI/2,u=[];return r.forEach(({offset:e,color:t})=>{u.push(e,t)}),n===`fill`?{fillLinearGradientStartPointX:a-c/2*Math.cos(l),fillLinearGradientStartPointY:o-c/2*Math.sin(l),fillLinearGradientColorStops:u,fillLinearGradientEndPointX:a+c/2*Math.cos(l),fillLinearGradientEndPointY:o+c/2*Math.sin(l),fill:r[1].color,fillPriority:`linear-gradient`}:{strokeLinearGradientStartPointX:a-c/2*Math.cos(l),strokeLinearGradientStartPointY:o-c/2*Math.sin(l),strokeLinearGradientColorStops:u,strokeLinearGradientEndPointX:a+c/2*Math.cos(l),strokeLinearGradientEndPointY:o+c/2*Math.sin(l)}},[t,e.width,e.height]));function wx(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var Tx={fontSize:14,fontFamily:`Roboto`,fontWeight:`normal`,fontStyle:`normal`,lineHeight:1.2,letterSpacing:0,textTransform:`none`,textDecoration:``,align:`center`,fill:`black`,stroke:`black`,strokeWidth:0,curveEnabled:!1,curvePower:.5};function Ex(e){return Object.assign(Object.assign({},Tx),e)}function Dx(e){var t=`֑-߿יִ-﷽ﹰ-ﻼ`;return RegExp(`^[^`+t+`]*?[`+t+`]`).test(e)}function Ox(e){return function(e){e=e.replace(/\s/g,``);let t=0;for(var n=0;n<e.length;n++)Dx(e[n])&&(t+=1);return t>e.length/2}(e)?`rtl`:`ltr`}function kx(e,t,n,r){let i=Math.max(-.9999,Math.min(.9999,n));if(Math.abs(i)<1e-4)return`M 0 ${t/2} L ${e} ${t/2}`;let a=5*r/(2*Math.abs(i))-r,o=e/2;if(i>0){let e=2*a+r/2;return[`M ${o} ${e}`,`A ${a} ${a} 0 1 1 ${o} ${e-2*a}`,`A ${a} ${a} 0 1 1 ${o} ${e}`].join(` `)}{let e=-(2*a-Math.round(t))-r/2;return[`M ${o} ${e}`,`A ${a} ${a} 0 1 0 ${o} ${e+2*a}`,`A ${a} ${a} 0 1 0 ${o} ${e}`].join(` `)}}function Ax(e,t,n,r){if(!sy(e))return``;let{stops:i,rotation:a}=ly(e),o=a*Math.PI/180;return`<linearGradient id="${t}" x1="${100*(.5-.5*Math.sin(o))}%" y1="${100*(.5+.5*Math.cos(o))}%" x2="${100*(.5+.5*Math.sin(o))}%" y2="${100*(.5-.5*Math.cos(o))}%">${i.map(({offset:e,color:t})=>`<stop offset="${100*e}%" stop-color="${t}" />`).join(``)}</linearGradient>`}var jx=null;function Mx(){return jx||=document.createElement(`canvas`).getContext(`2d`),jx}function Nx(e,t){let n=e.a?e.a:e,r=Ex(e),i=n.fontSize??r.fontSize,a=t?.normalizedText??hv(r.text,{fontSize:i,fontFamily:r.fontFamily}),o=t?.segments??wv(a,{fontSize:i,fontFamily:r.fontFamily}),s=Math.max(i,...o.map(e=>e.fontSize??i)),c=Sv(a),l=function(e,t,n,r,i,a){if(!e.some(e=>e.fontFamily&&e.fontFamily!==n)||t.length<=1)return 0;let o=function(e,t,n,r,i){let a=Mx(),o=0;for(let s of e){let e=s.fontFamily||t,c=s.bold?`bold`:n;a.font=`${s.italic?`italic`:r} ${c} ${s.fontSize??i}px '${e.replace(/'/g,``)}'`,o+=a.measureText(s.text).width}return o}(e,n,r,i,a),s=Mx();s.font=`${i} ${r} ${a}px '${n}'`;let c=o-s.measureText(t).width;return c<=0?0:c/(t.length-1)}(o,c,r.fontFamily,r.fontWeight||`normal`,r.fontStyle||`normal`,s),u=n.width??r.width,d=new W.TextPath({data:kx(u,n.height??r.height??0,r.curvePower,s),align:`center`,textBaseline:`middle`,text:c,fontSize:s,fontFamily:r.fontFamily,fontWeight:r.fontWeight,fontStyle:r.fontStyle,letterSpacing:r.letterSpacing*s+l,fill:r.fill}),f=d.getSelfRect();return d.destroy(),{width:f.width||u,height:f.height||s}}function Px(e){return Nx(e).height}function Fx(e,t,n){return e.map(e=>{let r=[];e.bold&&t.fontWeight!==`bold`&&r.push(`font-weight="bold"`),e.italic&&t.fontStyle!==`italic`&&r.push(`font-style="italic"`);let i=[];e.underline&&i.push(`underline`),e.strike&&i.push(`line-through`),i.length&&r.push(`text-decoration="${i.join(` `)}"`),!n?.omitColors&&e.color&&e.color!==t.fill&&r.push(`fill="${wx(e.color)}"`);let a=e.fontFamily||t.fontFamily;a!==t.fontFamily&&r.push(`font-family="${wx(a)}"`);let o=e.fontSize??t.fontSize;o!==t.fontSize&&r.push(`font-size="${o}"`);let s=wx(e.text);return r.length===0?s:`<tspan ${r.join(` `)}>${s}</tspan>`}).join(``)}function Ix(e,t){let n=Ex(e),r=t||n.fontFamily;return Tv(hv(n.text,{fontSize:n.fontSize,fontFamily:r})).replace(/\n/g,`<br/>`)}function Lx(e,{fontFamily:t=``,color:n=`black`,forEditor:r=!1}={}){let i=Ex(e),a=t||i.fontFamily,o=hv(i.text,{fontSize:i.fontSize,fontFamily:a}),s=sy(i.fill),c=sy(i.stroke)&&!!i.strokeWidth,l=h_.textOverflow===`ellipsis`&&!r&&!i.curveEnabled&&!!i.height,u=(()=>{if(!l)return[];let e=Math.max(1,Math.round(i.height)),t=typeof i.lineHeight==`number`?i.lineHeight:1.2,n=Math.max(1,t*i.fontSize),r=Math.max(1,Math.floor(e/n));return[`max-height: ${e}px`,`overflow: hidden`,`display: -webkit-box`,`-webkit-box-orient: vertical`,`-webkit-line-clamp: ${r}`,`line-clamp: ${r}`]})(),d=e=>`\n background-image: ${e};\n background-size: 100% 100%;\n background-repeat: repeat;\n -webkit-background-clip: text;\n -moz-background-clip: text;\n background-clip: text;\n -webkit-text-fill-color: transparent;\n color: transparent\n `.trim(),f=`color: ${n||i.fill}`,p=``;c&&i.strokeWidth?(f=`color: ${n||i.fill}; ${d(i.stroke)}`,p=`-webkit-text-stroke: ${i.strokeWidth}px transparent`):s&&(f=d(i.fill));let m=[`white-space: pre-wrap`,`overflow-wrap: break-word`,`width: ${Math.round(i.width||100)}px`,...u,f,`font-size: ${i.fontSize}px`,`font-family: '${a}'`,`text-align: ${i.align}`,`text-transform: ${i.textTransform}`,i.textDecoration?`text-decoration: ${i.textDecoration}; text-decoration-color: ${n||i.fill}; text-decoration-layer: over`:``,i.lineHeight?`line-height: ${i.lineHeight}`:``,i.letterSpacing?`letter-spacing: ${i.letterSpacing}em`:``,i.fontStyle?`font-style: ${i.fontStyle}`:``,i.fontWeight?`font-weight: ${i.fontWeight}`:``,p||(i.strokeWidth?`-webkit-text-stroke: ${i.strokeWidth}px ${i.stroke}`:``),i.strokeWidth&&!c?`paint-order: stroke fill`:``].filter(Boolean).join(`; `);if(i.curveEnabled&&!r){let t=wv(o,{fontSize:i.fontSize,fontFamily:a}),r=Nx(e,{normalizedText:o,segments:t}),l=Math.round(r.width),u=r.height,d=Math.max(i.fontSize,...t.map(e=>e.fontSize??i.fontSize)),f=kx(l,u,i.curvePower,d),p={fontWeight:i.fontWeight||`normal`,fontStyle:i.fontStyle||`normal`,fill:n||i.fill||`black`,fontFamily:a,fontSize:i.fontSize},m=Fx(t,p),h=Fx(t,p,{omitColors:!0}),g=wx(i.id||`temp`),_=`curve-${g}`,v=i.strokeWidth&&(c||s&&!c),y=`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${u}" overflow="visible">\n <defs>\n <path id="${_}" d="${f}" fill="none" />`;if(s){let e=`curve-fill-grad-${g}`;y+=Ax(i.fill,e,l,u)}if(c&&i.strokeWidth){let e=`curve-stroke-grad-${g}`;y+=Ax(i.stroke,e,l,u)}y+=`</defs>`;let b=wx(a),x=wx(i.fontWeight||`normal`),S=wx(i.fontStyle||`normal`);if(v){let e=`\n font-family="'${b}'"\n font-size="${i.fontSize}"\n font-weight="${x}"\n font-style="${S}"\n text-anchor="middle"\n dominant-baseline="central"\n letter-spacing="${i.letterSpacing*d}"${i.textDecoration?` text-decoration="${i.textDecoration}"`:``}`,t=c?`url(#curve-stroke-grad-${g})`:i.stroke;y+=`\n <text ${e} fill="${t}" stroke="${t}" stroke-width="${i.strokeWidth}">\n <textPath href="#${_}" startOffset="50%">${h}</textPath>\n </text>`,y+=`\n <text ${e} fill="${s?`url(#curve-fill-grad-${g})`:n}">\n <textPath href="#${_}" startOffset="50%">${m}</textPath>\n </text>`}else{let e=s?`url(#curve-fill-grad-${g})`:n,t=c?`url(#curve-stroke-grad-${g})`:i.stroke;y+=`\n <text\n font-family="'${b}'"\n font-size="${i.fontSize}"\n font-weight="${x}"\n font-style="${S}"\n fill="${e}"\n text-anchor="middle"\n dominant-baseline="central"\n letter-spacing="${i.letterSpacing*d}"${i.textDecoration?` text-decoration="${i.textDecoration}"`:``}${i.strokeWidth?` stroke="${t}" stroke-width="${i.strokeWidth}" paint-order="stroke fill"`:``}>\n <textPath href="#${_}" startOffset="50%">${m}</textPath>\n </text>`}return y+=`</svg>`,y}if(i.strokeWidth&&(c||s&&!c)&&!r){let e=Tv(o).replace(/\n/g,`<br/>`),t=Math.round(i.width||100),r=[`white-space: pre-wrap`,`overflow-wrap: break-word`,`width: ${t}px`,...u,`font-size: ${i.fontSize}px`,`font-family: '${a}'`,`text-align: ${i.align}`,`text-transform: ${i.textTransform}`,i.textDecoration?`text-decoration: ${i.textDecoration}; text-decoration-color: ${n||i.fill}; text-decoration-layer: over`:``,i.lineHeight?`line-height: ${i.lineHeight}`:``,i.letterSpacing?`letter-spacing: ${i.letterSpacing}em`:``,i.fontStyle?`font-style: ${i.fontStyle}`:``,i.fontWeight?`font-weight: ${i.fontWeight}`:``].filter(Boolean).join(`; `),l;l=c?`${r}; ${d(i.stroke)}; -webkit-text-stroke: ${i.strokeWidth}px transparent`:`${r}; color: transparent; -webkit-text-stroke: ${i.strokeWidth}px ${i.stroke}`;let f=`${r}; ${s?d(i.fill):`color: ${n||i.fill}`}`,p=``;if(s||c){let e=[];c&&i.strokeWidth&&e.push(`.stroke-layer li, .stroke-layer li::before { ${d(i.stroke)}; }`),s&&e.push(`.fill-layer li, .fill-layer li::before { ${d(i.fill)}; }`),e.length&&(p=`<style>${e.join(`
|
|
128
|
+
`)}</style>`)}return`\n <div style="position: relative; width: ${t}px;">\n <div class="stroke-layer" style="${l}; position: absolute; top: 0; left: 0; pointer-events: none;" aria-hidden="true">${e}</div>\n <div class="fill-layer" style="${f}; position: relative;" contentEditable dir="${Ox(Sv(o))}">${e}</div>\n </div>\n ${p}\n `}let h=``;return s&&!c&&(h=`<style>\n li, li::before {\n ${d(i.fill)};\n }\n </style>`),`<div style="${m}" contentEditable dir="${Ox(Sv(o))}">${Tv(o).replace(/\n/g,`<br/>`)}</div>${h}`}function Rx({fontFamily:e,fontSize:t,lineHeight:n}){if(typeof n==`number`)return n;let r=document.createElement(`div`);r.style.fontFamily=e,r.style.fontSize=t+`px`,r.style.lineHeight=n,r.innerText=`Test text`,document.body.appendChild(r);try{return r.offsetHeight/t}finally{document.body.removeChild(r)}}var zx={warm:e=>t=>{let n=t.data;e=Math.max(0,Math.min(1,e));for(let t=0;t<n.length;t+=4)n[t]=Math.min(n[t]+30*e,255),n[t+1]=Math.min(n[t+1]+15*e,255);return t},cold:e=>t=>{let n=t.data;e=Math.max(0,Math.min(1,e));for(let t=0;t<n.length;t+=4)n[t]=Math.min(n[t]-15*e,255),n[t+1]=Math.min(n[t+1]-10*e,255),n[t+2]=Math.min(n[t+2]+15*e,255);return t},natural:e=>t=>{let n=t.data;e=Math.max(0,Math.min(1,e));for(let t=0;t<n.length;t+=4){n[t]=Math.min(n[t]*(1+.1*e),255),n[t+1]=Math.min(n[t+1]*(1+.1*e),255),n[t+2]=Math.min(n[t+2]*(1+.1*e),255);let r=(n[t]+n[t+1]+n[t+2])/3;n[t]=Math.min((n[t]-r)*(1+.2*e)+r,255),n[t+1]=Math.min((n[t+1]-r)*(1+.2*e)+r,255),n[t+2]=Math.min((n[t+2]-r)*(1+.2*e)+r,255)}return t},temperature:e=>t=>{let n=t.data;e=Math.max(-1,Math.min(1,e));for(let t=0;t<n.length;t+=4){let r=n[t],i=(n[t+1],n[t+2]);n[t]=Math.min(Math.max(r+15*e,0),255),n[t+2]=Math.min(Math.max(i-15*e,0),255)}return t},contrast:e=>t=>{let n=t.data,r=100*(e=Math.max(-1,Math.min(1,e))),i=259*(r+255)/(255*(259-r));for(let e=0;e<n.length;e+=4)n[e]=Math.min(Math.max(i*(n[e]-128)+128,0),255),n[e+1]=Math.min(Math.max(i*(n[e+1]-128)+128,0),255),n[e+2]=Math.min(Math.max(i*(n[e+2]-128)+128,0),255);return t},shadows:e=>t=>{let n=t.data;e=Math.max(-1,Math.min(1,e));for(let t=0;t<n.length;t+=4){let r=(n[t]+n[t+1]+n[t+2])/3;if(r<128){let i=1+e*(1-r/128)*2;n[t]=Math.min(Math.max(n[t]*i,0),255),n[t+1]=Math.min(Math.max(n[t+1]*i,0),255),n[t+2]=Math.min(Math.max(n[t+2]*i,0),255)}}return t},white:e=>t=>{let n=t.data;e=Math.max(-1,Math.min(1,e));for(let t=0;t<n.length;t+=4){let r=n[t],i=n[t+1],a=n[t+2],o=(r+i+a)/3;if(o>128){let s=1+e*((o-128)/127);n[t]=Math.min(Math.max(r*s,0),255),n[t+1]=Math.min(Math.max(i*s,0),255),n[t+2]=Math.min(Math.max(a*s,0),255)}}return t},black:e=>t=>{let n=t.data;e=Math.max(-1,Math.min(1,e));for(let t=0;t<n.length;t+=4){let r=n[t],i=n[t+1],a=n[t+2],o=(r+i+a)/3;if(o<128){let s=1+e*((128-o)/128);n[t]=Math.min(Math.max(r*s,0),255),n[t+1]=Math.min(Math.max(i*s,0),255),n[t+2]=Math.min(Math.max(a*s,0),255)}}return t},vibrance:e=>t=>{let n=t.data;e=Math.max(-1,Math.min(1,e));for(let t=0;t<n.length;t+=4){let r=n[t],i=n[t+1],a=n[t+2],o=Math.max(r,i,a),s=e<0?(1-(o===0?0:(o-(r+i+a)/3)/o))*e*1.5:.5*e;n[t]=Math.min(Math.max(r-(o-r)*s,0),255),n[t+1]=Math.min(Math.max(i-(o-i)*s,0),255),n[t+2]=Math.min(Math.max(a-(o-a)*s,0),255)}return t},saturation:e=>t=>{let n=t.data;e=Math.max(-1,Math.min(1,e));for(let t=0;t<n.length;t+=4){let r=n[t],i=n[t+1],a=n[t+2],o=.2126*r+.7152*i+.0722*a;n[t]=Math.min(Math.max(o+(r-o)*(1+e),0),255),n[t+1]=Math.min(Math.max(o+(i-o)*(1+e),0),255),n[t+2]=Math.min(Math.max(o+(a-o)*(1+e),0),255)}return t}};function Bx(e,t){var n;if(!e||!Hp(t))return;let r={filters:[]},i={};t.brightnessEnabled&&(r.filters.push(W.Filters.Brighten),r.brightness=t.brightness),t.blurEnabled&&(r.filters.push(W.Filters.Blur),r.blurRadius=t.blurRadius,t.type===`text`&&t.lineHeight<1&&(i.offset=t.fontSize)),t.sepiaEnabled&&r.filters.push(W.Filters.Sepia),t.grayscaleEnabled&&r.filters.push(W.Filters.Grayscale),t.filters.forEach((e,t)=>{let n=zx[t];n&&r.filters.push(n(e.intensity))}),e.setAttrs(r),r.filters.length?e.cache(Object.assign(Object.assign({},i),{pixelRatio:t.store._elementsPixelRatio})):e.clearCache(),(n=e.getLayer())==null||n.batchDraw()}var Vx=()=>`ontouchstart`in window||navigator.maxTouchPoints>0;function Hx({oldText:e,newText:t,element:n}){if(!(t.length/Math.max(20,e.length)>=4))return n.fontSize;let r=n.width*n.page.computedHeight/t.length,i=1.5*Math.sqrt(r),a=n.fontSize;return Math.min(a,Math.max(5,Math.round(i)))}function Ux(e){try{let{stops:t}=ly(e);if(t.length===0)return 127.5;let n=0,r=0;for(let e of t)try{let t=W.Util.colorToRGBA(e.color);if(!t||t.a<.5)continue;n+=(299*t.r+587*t.g+114*t.b)/1e3,r++}catch{continue}return r===0?127.5:n/r}catch(e){return console.warn(`Error calculating gradient brightness:`,e),127.5}}function Wx(e){if(sy(e))return Ux(e);let t=W.Util.colorToRGBA(e);if(!t)return 127.5;let{r:n,g:r,b:i}=t;return(299*n+587*r+114*i)/1e3}function Gx(e){let{outlineSize:t,outlineColor:n}=function(e){let t=e.strokeWidth||0;return t>0?{outlineSize:t,outlineColor:e.stroke}:{outlineSize:e.shadowEnabled&&e.shadowBlur>0&&e.shadowOpacity>.1?e.shadowBlur*e.shadowOpacity:0,outlineColor:e.shadowColor}}(e);if(t<.001)return e.fill;let r=Wx(e.fill),i=Wx(n);return Math.abs(r-i)>=50?n:e.fill}var Kx;function qx(){return Kx||(Kx=document.getElementById(`polotno-text-style`),Kx||(Kx=document.createElement(`style`),Kx.id=`polotno-text-style`,document.head.appendChild(Kx)),Kx)}W._fixTextRendering=!0;var Jx={border:`none`,padding:`0px`,overflow:`hidden`,background:`none`,outline:`none`,resize:`none`,overflowWrap:`break-word`,whiteSpace:`pre-wrap`,userSelect:`text`,wordBreak:`normal`,textTransform:`none`},Yx=wa(({textNodeRef:e,element:t,onBlur:n,selectAll:r,cursorPosition:i})=>{let[a,o]=b.useState(Jx),s=e.current;b.useLayoutEffect(()=>{if(!s)return;let e={};e.width=s.width()-2*s.padding()+`px`,e.height=s.height()-2*s.padding()+s.fontSize()*s.lineHeight()+`px`,e.fontSize=s.fontSize()+`px`,e.lineHeight=s.lineHeight()+.01,e.fontFamily=s.fontFamily(),e.textAlign=s.align(),e.color=s.fill(),e.fontWeight=t.fontWeight,e.fontStyle=t.fontStyle,e.letterSpacing=t.letterSpacing+`em`,e.opacity=Math.max(t.a.opacity,.2),e.textTransform=t.textTransform,e.caretColor=Gx(t);let n=`\n .polotno-input::placeholder {\n color: ${a.color};\n opacity: 0.6;\n }\n `,r=qx();r.innerHTML=``,r.appendChild(document.createTextNode(n)),JSON.stringify(e)!==JSON.stringify(a)&&o(e)});let c=b.useRef(null);if(b.useLayoutEffect(()=>{var e;let t=c.current;t&&((e=c.current)==null||e.focus({preventScroll:!0}),t.selectionStart=t.selectionEnd=i||t.value.length,r&&(t?.select(),document.execCommand(`selectAll`,!1,void 0)))},[]),b.useEffect(()=>{window.addEventListener(`blur`,n);let e=e=>{var t;(t=c.current)!=null&&t.contains(e.target)||n()};return window.addEventListener(`touchstart`,e),()=>{window.removeEventListener(`blur`,n),window.removeEventListener(`touchstart`,e)}},[]),!s)return null;let l=0,u=s.textArr.length*s.lineHeight()*s.fontSize();t.verticalAlign===`middle`&&(l=(t.a.height-u)/2),t.verticalAlign===`bottom`&&(l=t.a.height-u);let d=Sv(t.text);return(0,S.jsx)(`textarea`,{className:`polotno-input`,ref:c,dir:Ox(d),style:Object.assign(Object.assign(Object.assign({},Jx),a),{paddingTop:l+`px`}),value:d,onChange:e=>{let n=Hx({oldText:t.text,newText:e.target.value,element:t});t.set({text:e.target.value,fontSize:n})},placeholder:t.placeholder,onBlur:n})}),Xx=e=>(0,S.jsx)(ex,{children:(0,S.jsx)(Yx,Object.assign({},e))}),Zx=(e,t,n,r,i)=>{let[a,o]=b.useReducer(e=>e+1,0),s=b.useRef(Iv(t,n,r)),c=b.useRef(null);return b.useLayoutEffect(()=>{if(s.current=Iv(t,n,r),s.current)return;let a=!0;return(async()=>{s.current=!1,o();let l=$_(`text ${t}`);await e.loadFont(t,n,r,i),a?(c.current=l,s.current=!0,o()):l()})(),()=>{c.current&&=(c.current(),null),a=!1}},[t,n,r]),b.useEffect(()=>{s.current&&setTimeout(()=>{c.current&&=(c.current(),null)})},[s.current]),[s.current]},Qx=(e,t,n,r,i)=>{let[a,o]=b.useReducer(e=>e+1,0),s=t.join(`\0`),c=b.useRef(t.every(e=>Iv(e,n,r))),l=b.useRef(null);return b.useLayoutEffect(()=>{if(c.current=t.every(e=>Iv(e,n,r)),c.current)return;let a=!0;return(async()=>{c.current=!1,o();let u=$_(`text fonts ${s}`);await Promise.all(t.map(t=>e.loadFont(t,n,r,i))),a?(l.current=u,c.current=!0,o()):u()})(),()=>{l.current&&=(l.current(),null),a=!1}},[s,n,r]),b.useEffect(()=>{c.current&&setTimeout(()=>{l.current&&=(l.current(),null)})},[c.current]),[c.current]},$x=({fontLoaded:e,fontFamily:t,fontSize:n,lineHeight:r})=>b.useMemo(()=>Rx({fontFamily:t,fontSize:n,lineHeight:r}),[e,t,n,r]);function eS(e){let t=b.useRef(e),n=b.useRef(e);return b.useMemo(()=>{n.current=t.current,t.current=e},[e]),n.current}function tS(e,t,n=!1){let r=e.fontSize(),i=e.height(),a=Sv(t.text),o=t.a.fontSize;e.height(void 0);let s=Math.round(2*t.a.fontSize)-1;for(let r=1;r<s;r++){let r=t.a.height&&e.height()>t.a.height,i=a.split(`
|
|
129
|
+
`).join(` `).split(/[\s-]+/).reduce((e,t)=>(t=t.toLowerCase(),/[\u3000-\u303F\u3040-\u309F\u30A0-\u30FF\uFF00-\uFFEF\u4E00-\u9FAF\uAC00-\uD7AF]/.test(t)?e.concat(t.split(``)):e.concat(t)),[]),s=e.textArr.map(e=>e.text.toLowerCase()).join(`;`),c=i.find(e=>!s.includes(e)||(s=s.replace(e,``),!1));if(!(r||c&&!n))break;o-=.5,e.fontSize(o)}return e.fontSize(r),e.height(i),o}var nS=wa(({element:e,store:t})=>{let{textOverflowIndicatorStyle:n}=up(),r=b.useRef(null),i=b.useRef(null),a=b.useRef(null),o=b.useRef([]),s=b.useRef(!0),[,c]=b.useReducer(e=>e+1,0),{editorEnabled:l,selectAll:u}=(e=>{let[t,n]=b.useState(!1),r=b.useRef(!1);return b.useEffect(()=>{var t=!0;return setTimeout(()=>{t&&(e._editModeEnabled&&(r.current=!0),n(!0),setTimeout(()=>{r.current=!1},50))},50),()=>{t=!1}},[]),{editorEnabled:t&&e._editModeEnabled,selectAll:r.current}})(e),[d,f]=b.useState(!1),[p,m]=b.useState(!1),h=b.useRef(e.a.height),g=b.useRef(0),_=b.useRef(``),v=b.useRef(0),y=e.isSelected,x=eS(y),{textVerticalResizeEnabled:C}=h_,w=h_.autoDeleteEmptyText,T=eS(e.fontFamily),[E,D]=b.useState([]);b.useEffect(()=>{let e=r.current?.textArr??[];JSON.stringify(e)!==JSON.stringify(E)&&D(e)}),b.useEffect(()=>{if(e.a.width||e.type===`tablecell`)return;let t=r.current;t.width(600),e.set({width:1.4*t.getTextWidth()})},[]),b.useEffect(()=>{x&&!y&&w&&e.text===``&&e.removable&&!e.placeholder&&t.deleteElements([e.id])},[w,e.placeholder,e.removable,e.text,y,x]);let O=()=>{if(e.curveEnabled){let t=r.current;t?.clearCache(),t?.setAttrs({filters:[]});let n=i.current;n&&Bx(n,e)}else{let t=r.current;t&&Bx(t,e)}};b.useLayoutEffect(()=>{if(!p)return cr(()=>{O()})}),b.useEffect(()=>{let e=o.current;e.length>0&&(o.current=[],e.forEach(e=>e()))}),b.useEffect(()=>()=>{s.current=!1;let e=o.current;e.length>0&&(o.current=[],e.forEach(e=>e()))},[]);let k=Sv(e.text);e.textTransform===`uppercase`&&(k=k.toUpperCase());let[ee]=Zx(t,e.fontFamily,e.fontStyle,e.fontWeight,e.text||e.placeholder),A=()=>{if(e.curveEnabled){let e=i.current;return e.getSelfRect().height||e.fontSize()}let t=r.current.clone({height:void 0}),n=Math.ceil(t.fontSize()*t.lineHeight()*t.textArr.length+1);return t.destroy(),n};b.useLayoutEffect(()=>{if(!ee)return;if(e.type===`tablecell`){let{textOverflow:n}=h_;if(n===`resize`){let t=A(),n=Hp(e)?Np(e,2):null;n!=null&&n.setCellContentHeight&&n.setCellContentHeight(e.id,t)}else if(n===`change-font-size`){let n=r.current;if(n){let r=tS(n,e,h_.textSplitAllowed);r!==e.fontSize&&t.history.ignore(()=>{e.set({fontSize:r})})}}return}let{textOverflow:n,textSplitAllowed:i}=h_,a=(n,r,i,a)=>{let l=$_(`text ${e.id}`),u=()=>{t.history.ignore(n,r,i).then(()=>{s.current?(o.current.push(l),c()):l()})};a?queueMicrotask(u):u()};if(!e.height){let t=A();a(()=>{e.height||e.set({height:t})},void 0,void 0,!0);return}if(!t.isPlaying)if(n!==`change-font-size`||d){if(n===`resize`){let t=A();C&&e.height<t&&!d&&a(()=>{var n;Hp(e)&&e.set({height:t}),(n=r.current)==null||n.height(t)},!1,!0),C||e.height===t||d||a(()=>{var n;Hp(e)&&e.set({height:t}),(n=r.current)==null||n.height(t)},!1,!0)}}else{let t=r.current,n=e.curveEnabled?e.fontSize:tS(t,e,i);if(n!==e.fontSize){a(()=>{e.set({fontSize:n})},!1,!0);return}let o=A();e.height===o||C||a(()=>{e.set({height:o})},!1,!0)}}),b.useLayoutEffect(()=>{if(ee&&e.curveEnabled){let t=i.current?.getSelfRect().width;if(t){let n=t-e.a.width,r=e.a.rotation*Math.PI/180,i=-n/2*Math.cos(r),a=-n/2*Math.sin(r);e.set({width:t,x:e.a.x+i,y:e.a.y+a})}}},[ee,e.curveEnabled,e.curvePower,e.text,e.fontSize,e.fontFamily,e.fontWeight,e.fontStyle,e.letterSpacing]),b.useLayoutEffect(()=>{let e=r.current;e&&(e.width(e.width()+1e-8),e.width(e.width()-1e-8),e._setTextData(),O())},[ee]);let j=b.useRef(null),te=b.useRef(0),M=n=>{n.evt.preventDefault(),t.selectedShapes.find(t=>t===e)&&e.contentEditable&&(te.current=function(e){let t=e.target,n=function(e){var t=e.getAbsoluteTransform().copy();t.invert();var n=e.getStage().getPointerPosition();return t.point(n)}(t),r=t.textArr,i=Math.floor(n.y/(t.fontSize()*t.lineHeight())),a=r.slice(0,i).reduce((e,t)=>e+t.text.length,i),o=r[i]??r[0],s=0;return t.align()===`right`?s=t.width()-o.width:t.align()===`center`&&(s=t.width()/2-o.width/2),a+Math.round((n.x-s)/o.width*o.text.length)}(n),e.toggleEditMode())},ne=!k&&e.placeholder?.6:e.a.opacity;G_(r,ne);let N=$x({fontLoaded:ee,fontFamily:e.fontFamily,fontSize:e.a.fontSize,lineHeight:e.lineHeight}),P=e.selectable||t.role===dC.ADMIN,re=Cx(e),ie=Cx(e,e.stroke,`stroke`),ae=b.useMemo(()=>e.backgroundEnabled?e.curveEnabled?function({width:e,height:t,padding:n=0,cornerRadius:r=0}){let i=-n,a=-n,o=e+n,s=t+n;return bx(yx(`M ${i} ${a} L ${o} ${a} L ${o} ${s} L ${i} ${s} Z`),r).path}({width:e.a.width,height:e.a.height,cornerRadius:e.backgroundCornerRadius*(e.a.fontSize*N*.5),padding:e.backgroundPadding*(e.a.fontSize*N*.5)}):function({lines:e,lineHeight:t,width:n,align:r=`left`,padding:i=0,cornerRadius:a=0}){return xx({rects:Sx({lines:e,lineHeight:t,width:n,align:r}),padding:i,cornerRadius:a})}({lines:JSON.parse(JSON.stringify(E)),cornerRadius:e.backgroundCornerRadius*(e.a.fontSize*N*.5),lineHeight:N*e.a.fontSize,padding:e.backgroundPadding*(e.a.fontSize*N*.5),width:e.a.width,align:e.align}):``,[e.backgroundEnabled,e.curveEnabled,e.backgroundCornerRadius,e.a.fontSize,e.a.height,N,e.backgroundPadding,e.a.width,e.align,E]),F=Vx(),oe=0;e.curveEnabled||(e.verticalAlign===`middle`?oe=(e.a.height-E.length*N*e.a.fontSize)/2:e.verticalAlign===`bottom`&&(oe=e.a.height-E.length*N*e.a.fontSize));let se=e.curveEnabled?kx(e.a.width,e.a.height,e.curvePower,e.a.fontSize):``,ce=ee?`"`+e.fontFamily+`"`:T===e.fontFamily?`Arial`:`"`+T+`"`,le=Ox(k);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Rf,{ref:a,x:e.a.x,y:e.a.y,rotation:e.a.rotation,hideInExport:!e.showInExport,listening:!1,visible:e.backgroundEnabled,opacity:e.backgroundOpacity*ne,data:ae,fill:e.backgroundColor,offsetY:-oe}),(0,S.jsx)(Rf,{data:se,stroke:n.stroke,strokeWidth:1,x:e.a.x,y:e.a.y,rotation:e.a.rotation,visible:!1}),(0,S.jsx)(Lf,Object.assign({ref:i,visible:e.curveEnabled,data:se,text:k||e.placeholder,listening:!1,align:`center`,textBaseline:`middle`,direction:le},re,ie,{strokeWidth:e.strokeWidth,lineJoin:`round`,fillAfterStrokeEnabled:!0,fontSize:e.a.fontSize,fontFamily:`"${e.fontFamily}", "${T}"`,fontStyle:e.fontStyle+` `+e.fontWeight,textDecoration:e.textDecoration.trim(),letterSpacing:e.letterSpacing*e.a.fontSize,x:e.a.x,y:e.a.y,rotation:e.a.rotation,opacity:e._editModeEnabled?.3:ne,hideInExport:!e.showInExport,shadowEnabled:e.shadowEnabled,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY,shadowColor:e.shadowColor,shadowOpacity:e.shadowOpacity})),(0,S.jsx)(If,Object.assign({ref:r,id:e.selectable?e.id:void 0,name:e.selectable?`element`:``,hideInExport:!e.showInExport,editModeEnabled:e._editModeEnabled,x:e.a.x,y:e.a.y,rotation:e.a.rotation,width:e.a.width,height:e.a.height,text:k||e.placeholder,direction:le},re,ie,{lineJoin:`round`,strokeWidth:e.strokeWidth,fillAfterStrokeEnabled:!0,fontSize:e.a.fontSize,fontFamily:ce,fontStyle:e.fontStyle+` `+e.fontWeight,textDecoration:e.textDecoration,align:e.align,verticalAlign:e.verticalAlign,draggable:F?e.draggable&&y:e.draggable,preventDefault:!F||y,opacity:e.curveEnabled?0:ne,visible:!e._editModeEnabled,ellipsis:h_.textOverflow===`ellipsis`,shadowEnabled:e.shadowEnabled,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY,shadowColor:e.shadowColor,shadowOpacity:e.shadowOpacity,lineHeight:N,letterSpacing:e.letterSpacing*e.a.fontSize,listening:!!e.selectable&&P,onDragStart:()=>{m(!0)},onDragMove:t=>{e.set({x:t.target.x(),y:t.target.y()})},onDragEnd:t=>{m(!1),e.set({x:t.target.x(),y:t.target.y()})},onClick:M,onTap:M,onTransformStart:()=>{f(!0);let e=r.current;h.current=e.height(),g.current=e.rotation(),v.current=e.height(),_.current=(e.getStage()?.findOne(`Transformer`))?.getActiveAnchor()??``},onTransform:t=>{var n,r;let i=t.target;(n=a.current)==null||n.setAttrs({x:i.x(),y:i.y(),rotation:i.rotation(),scale:i.scale()});let o=(i.getStage()?.findOne(`Transformer`)).getActiveAnchor();if(o===`middle-left`||o===`middle-right`){let t=i.scaleX(),n=i.width()*t,r=e.a.fontSize,a=n;n<r&&(a=r,j.current&&i.position(j.current)),i.width(a),i.scaleX(1),i.scaleY(1);let o=A();if(h_.textOverflow===`ellipsis`)o=h.current;else{let t=Math.max(o,h.current);i.height(t),e.set({height:i.height()})}let s=h_.textVerticalResizeEnabled?Math.max(o,h.current):A();e.set({x:i.x(),width:i.width(),rotation:i.rotation(),height:s}),i.skewX(0),i.skewY(0),O()}if(o===`top-center`||o===`bottom-center`){let n=h_.textOverflow===`resize`?A():N*e.a.fontSize,r=t.target.height()*t.target.scaleY();if(r<n){if(t.target.height(n),j.current)if(_.current===`top-center`){let e=g.current*Math.PI/180,r=v.current-n;t.target.x(j.current.x-r*Math.sin(e)),t.target.y(j.current.y+r*Math.cos(e))}else t.target.position(j.current)}else t.target.height(r);t.target.scaleY(1),t.target.scaleX(1),t.target.rotation(g.current),t.target.skewX(0),t.target.skewY(0),v.current=Math.max(n,r)}j.current=t.target.position();let s=t.target.scaleX();(r=a.current)==null||r.setAttrs({scaleX:1,scaleY:1}),t.target.scaleX(1),t.target.scaleY(1),e.set({fontSize:e.a.fontSize*s,width:t.target.width()*s,x:t.target.x(),y:t.target.y(),rotation:t.target.rotation(),height:t.target.height()*s,shadowBlur:e.shadowBlur*s,shadowOffsetX:e.shadowOffsetX*s,shadowOffsetY:e.shadowOffsetY*s,strokeWidth:e.strokeWidth*s})},onTransformEnd:t=>{var n;let r=t.target.scaleX();t.target.scaleX(1),t.target.scaleY(1),e.set({fontSize:Math.round(e.a.fontSize*r),width:Math.ceil(t.target.width()*r),x:t.target.x(),y:t.target.y(),rotation:t.target.rotation(),height:t.target.height()*r,shadowBlur:e.shadowBlur*r,shadowOffsetX:e.shadowOffsetX*r,shadowOffsetY:e.shadowOffsetY*r,strokeWidth:e.strokeWidth*r}),(n=a.current)==null||n.setAttrs({scaleX:1,scaleY:1}),f(!1)}})),l&&e.contentEditable&&(0,S.jsx)(`Group`,{x:e.a.x,y:e.a.y,rotation:e.a.rotation,children:(0,S.jsx)(Xx,{textNodeRef:r,element:e,selectAll:u,cursorPosition:te.current,onBlur:()=>{e.toggleEditMode(!1)}})})]})});function rS(e,t){if(!e.includes(`@font-face`))return``;let n=new Set,r=new Set;t&&((t.match(/font-weight:\s*(\d+|bold|normal)/gi)||[]).forEach(e=>{let t=e.split(`:`)[1].trim();t===`bold`?n.add(`700`):t===`normal`?n.add(`400`):/^\d+$/.test(t)&&n.add(t)}),(t.match(/font-style:\s*(italic|normal)/gi)||[]).forEach(e=>{e.split(`:`)[1].trim().toLowerCase()===`italic`&&r.add(`italic`)}),/<(b|strong)\b/i.test(t)&&n.add(`700`),/<(i|em)\b/i.test(t)&&r.add(`italic`));let i=Sv(t);i&&i.trim()&&n.add(`400`),n.size===0&&n.add(`400`);let a=n,o=r.has(`italic`),s=Array.from(new Set(i)).map(e=>e.codePointAt(0)).filter(e=>e!==void 0),c=e.split(/}\s*/).map(e=>e&&e+`}`).filter(e=>/@font-face/.test(e)&&(e=>{let t=(e.match(/font-weight:\s*(\d+)/)||[])[1];if(t&&!a.has(t)||/font-style:\s*italic/.test(e)&&!o)return!1;let n=e.match(/unicode-range:\s*([^;]+);/);if(!n)return!0;let r=n[1].split(`,`).map(e=>{let[t,n=t]=e.replace(`U+`,``).split(`-`).map(e=>parseInt(e,16));return[t,n]});return s.some(e=>r.some(([t,n])=>e>=t&&e<=n))})(e)).join(`
|
|
130
|
+
`);return c?`<style>${c}</style>`:``}var iS=new Map,aS=new Map,oS=/@font-face\s*\{[^}]*\}/g,sS=/url\(\s*(['"]?)(.*?)\1\s*\)/g,cS=/unicode-range:\s*([^;}]+)/i;function lS(e,t){if(!t)return!0;let n=e.match(cS);if(!n)return!0;let r=function(e){let t=[];for(let n of e.split(`,`)){let e=n.trim().match(/^U\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f]+))?$/i);if(e)if(e[2])t.push([parseInt(e[1],16),parseInt(e[2],16)]);else if(e[1].includes(`?`))t.push([parseInt(e[1].replace(/\?/g,`0`),16),parseInt(e[1].replace(/\?/g,`F`),16)]);else{let n=parseInt(e[1],16);t.push([n,n])}}return t}(n[1]);return r.length===0||function(e,t){for(let n of t)for(let[t,r]of e)if(n>=t&&n<=r)return!0;return!1}(r,t)}function uS(e,t){let n=new Set;for(let r of e.matchAll(oS))if(lS(r[0],t))for(let e of r[0].matchAll(sS)){let t=e[2];t&&!t.startsWith(`data:`)&&n.add(t)}return Array.from(n)}function dS(e){let t=iS.get(e);return t||(t=async function(e){try{let t=await fetch(e);if(!t.ok)return e;let n=t.headers.get(`Content-Type`)||`font/woff2`,r=await t.arrayBuffer(),i=new Uint8Array(r),a=``;for(let e=0;e<i.length;e++)a+=String.fromCharCode(i[e]);return`data:${n};base64,${btoa(a)}`}catch{return e}}(e),iS.set(e,t)),t}function fS(e,t){let n=function(e,t){let n=e.length,r=`${n}|${e.slice(0,500)}|${n>200?e.slice((n>>1)-50,50+(n>>1)):``}|${n>100?e.slice(-100):``}`;if(t&&t.size>0){let e=5381,n=[...t].sort((e,t)=>e-t);for(let t=0;t<n.length;t++)e=(e<<5)+e+n[t]|0;r+=`\0`+(e>>>0)}return r}(e,t),r=aS.get(n);if(r)return r;let i=async function(e,t){let n=uS(e,t);if(n.length===0&&!t)return e;let r=await Promise.all(n.map(async e=>[e,await dS(e)])),i=new Map(r);return e.replace(oS,e=>lS(e,t)?e.replace(sS,(e,t,n)=>{if(!n||n.startsWith(`data:`))return e;let r=i.get(n);return r?`url("${r}")`:e}):``)}(e,t);return aS.set(n,i),i}var pS=/<style[^>]*>([\s\S]*?)<\/style>/gi;function mS(e){let t=[],n=e.replace(pS,(e,n)=>(t.push(n),``));return{css:t.join(`
|
|
131
|
+
`),html:n}}var hS=class{constructor(e){this.map=new Map,this._maxEntries=e}get maxEntries(){return this._maxEntries}get size(){return this.map.size}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}set(e,t){if(this.map.has(e))this.map.delete(e);else if(this.map.size>=this._maxEntries){let e=this.map.keys().next().value;this.map.delete(e)}this.map.set(e,t)}setWithEviction(e,t,n){if(this.map.has(e))this.map.delete(e);else if(this.map.size>=this._maxEntries){let e=this.map.keys().next().value,t=this.map.get(e);this.map.delete(e),n(e,t)}this.map.set(e,t)}clear(){this.map.clear()}forEach(e){this.map.forEach(e)}resize(e){for(this._maxEntries=e;this.map.size>e;){let e=this.map.keys().next().value;this.map.delete(e)}}},gS;function _S(e,t){`close`in t.image&&typeof t.image.close==`function`&&t.image.close()}async function vS(e){let t=`data:image/svg+xml;charset=utf-8,`+encodeURIComponent(e),n=new Image;return n.src=t,await new Promise((e,t)=>{n.onload=()=>e(),n.onerror=()=>t(Error(`Failed to load SVG as image`))}),{image:n}}async function yS(e){var t;let n=!!e.cache,r=typeof e.cache==`object`&&(t=e.cache.maxEntries)!=null?t:50;if(n){let t=function(e){return gS?gS.maxEntries!==e&&gS.resize(e):gS=new hS(e),gS}(r),n=function(e){return`${e.html}\0${e.css??``}\0${e.width}\0${e.height}\0${e.pixelRatio??1}`}(e),i=t.get(n);if(i)return i.image;let a=await vS(await TS(e));return t.setWithEviction(n,a,_S),a.image}return(await vS(await TS(e))).image}var bS=RegExp(`[\0-\b\v\f-]`,`g`);function xS(e){let t=new DOMParser().parseFromString(e,`text/html`),n=new XMLSerializer,r=``;for(let e of Array.from(t.body.childNodes))r+=n.serializeToString(e);return r.replace(bS,``)}function SS({xhtml:e,css:t,width:n,height:r,pixelRatio:i=1}){let a=n*i,o=r*i,s=i===1?`margin: 0;`:`margin: 0; width: ${n}px; height: ${r}px; transform: scale(${i}); transform-origin: 0 0;`;return`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${o}"><foreignObject width="${a}" height="${o}" style="float: left;"><html xmlns="http://www.w3.org/1999/xhtml"><head><style>${function(e){return`<![CDATA[\n${e}\n]]>`}(t)}</style></head><body style="${s}">${e}</body></html></foreignObject></svg>`}var CS;async function wS({html:e,css:t=``,width:n,height:r,pixelRatio:i=1}){let a=mS(e),o=await fS([t,a.css].filter(Boolean).join(`
|
|
132
|
+
`),function(e){let t=new DOMParser().parseFromString(e,`text/html`).body.textContent||``,n=new Set;for(let e=0;e<t.length;e++){let r=t.codePointAt(e);n.add(r),r>65535&&e++}return n}(a.html));return SS({xhtml:xS(a.html),css:o,width:n,height:r,pixelRatio:i})}async function TS(e){var t,n;if(e.cache){let r=(n=typeof e.cache==`object`&&(t=e.cache.maxEntries)!=null?t:50,CS?CS.maxEntries!==n&&CS.resize(n):CS=new hS(n),CS),i=`${e.html}\0${e.css??``}\0${e.width}\0${e.height}\0${e.pixelRatio??1}`,a=r.get(i);if(a)return a;let o=await wS(e);return r.set(i,o),o}return wS(e)}var ES,DS=()=>(ES||(ES=document.createElement(`div`),ES.id=`polotno-hidden-do-not-touch`,ES.style.overflow=`hidden`,ES.style.position=`relative`,document.body.appendChild(ES),ES.innerHTML=`<style>#polotno-hidden-do-not-touch {
|
|
133
|
+
p {
|
|
134
|
+
margin: 0;
|
|
135
|
+
padding: 0;
|
|
136
|
+
overflow-wrap: break-word; /* Canonical CSS3 — Firefox honors it; render-tag's CSS resolver only parses this canonical form */
|
|
137
|
+
/* a text may have several spaces, we need to preserve them */
|
|
138
|
+
white-space: pre-wrap;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* Structural list reset. Native markers are intentionally LEFT ENABLED here
|
|
142
|
+
(no list-style:none) so the canonical export/canvas HTML renders the
|
|
143
|
+
browser's NATIVE markers.
|
|
144
|
+
|
|
145
|
+
The per-level indent is carried by the <ul>/<ol> padding (2.1em), NOT the
|
|
146
|
+
<li>. This matters for native markers: with list-style-position outside
|
|
147
|
+
the marker hangs just left of the <li> border box, so the indent must sit
|
|
148
|
+
on the list (the marker lands inside that padding, next to the text). If
|
|
149
|
+
the indent were on the <li> instead, the outside marker would hang at
|
|
150
|
+
x near 0 and be clipped off the element's left edge. render-tag computes
|
|
151
|
+
the same content-start either way (it accumulates block padding).
|
|
152
|
+
|
|
153
|
+
The live editor needs the opposite box model (indent on the <li>, so its
|
|
154
|
+
absolutely-positioned ::before marker has room) and overrides these two
|
|
155
|
+
paddings in rich-editor.tsx. */
|
|
156
|
+
ul, ol {
|
|
157
|
+
padding-inline-start: 2.1em; /* Per-level indent; native outside markers hang inside it */
|
|
158
|
+
margin: 0;
|
|
159
|
+
display: block; /* Use block instead of inline-block for better text wrapping */
|
|
160
|
+
width: 100%;
|
|
161
|
+
text-decoration: inherit;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
li {
|
|
165
|
+
padding-inline-start: 0;
|
|
166
|
+
margin: 0; /* Reset default li margins */
|
|
167
|
+
overflow-wrap: break-word; /* Canonical CSS3 — Firefox honors it; render-tag's CSS resolver only parses this canonical form */
|
|
168
|
+
white-space: pre-wrap; /* Preserve spaces and allow wrapping */
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* Paragraph block-indent (matches walk's <p> ql-indent → margin in
|
|
172
|
+
rich-text-html.ts). Small step, applied to non-list indented blocks.
|
|
173
|
+
Editor-only in practice: the export normalizer turns <p> ql-indent into an
|
|
174
|
+
inline margin, so canonical export HTML carries no ql-indent class. */
|
|
175
|
+
.ql-indent-1 {
|
|
176
|
+
margin-inline-start: 0.5em;
|
|
177
|
+
}
|
|
178
|
+
.ql-indent-2 {
|
|
179
|
+
margin-inline-start: 1em;
|
|
180
|
+
}
|
|
181
|
+
.ql-indent-3 {
|
|
182
|
+
margin-inline-start: 1.5em;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/* List nesting indent for the live Quill editor, which renders a list FLAT
|
|
186
|
+
(one container, depth via ql-indent on each <li>). Each level is indented
|
|
187
|
+
by the SAME 2.1em render-tag adds per nested <ul>/<ol>, to stay in sync
|
|
188
|
+
with the canvas. Stored/exported lists are canonical-nested and carry no
|
|
189
|
+
ql-indent (see canonicalizeLists), so these rules are editor/legacy-only
|
|
190
|
+
no-ops elsewhere. */
|
|
191
|
+
li.ql-indent-1 {
|
|
192
|
+
margin-inline-start: 2.1em;
|
|
193
|
+
}
|
|
194
|
+
li.ql-indent-2 {
|
|
195
|
+
margin-inline-start: 4.2em;
|
|
196
|
+
}
|
|
197
|
+
li.ql-indent-3 {
|
|
198
|
+
margin-inline-start: 6.3em;
|
|
199
|
+
}
|
|
200
|
+
}</style>`),ES);navigator.userAgent.includes(`Firefox`);function OS({html:e}){let t=document.createElement(`div`);t.innerHTML=e,t.style.display=`inline-block`,t.style.position=`fixed`,t.style.top=`0px`,t.style.left=`0px`,t.style.zIndex=`1000`,t.style.whiteSpace=`nowrap`,t.style.visibility=`hidden`;let n=DS();n.appendChild(t);let r=t.innerText,i=t.childNodes[0];i.style.whiteSpace=`nowrap`;let a=r?.split(/\s+/)||[],o=!1;for(let e=0;e<a.length;e++){let n=a[e];if(i&&(i.textContent=n,o=i.scrollWidth>t.clientWidth,o))break}return n.removeChild(t),o}function kS(e){let t=document.createElement(`div`);t.innerHTML=e,t.style.display=`inline-block`,t.style.position=`fixed`,t.style.top=`0px`,t.style.left=`0px`,t.style.zIndex=`1000`;let n=DS();n.appendChild(t);let r=t.getBoundingClientRect();return n.removeChild(t),{width:r.width,height:r.height}}function AS(e){let t=document.createElement(`div`);t.innerHTML=e,t.style.display=`inline-block`,t.style.position=`fixed`,t.style.top=`0px`,t.style.left=`0px`,t.style.zIndex=`1000`;let n=DS();n.appendChild(t);let r=t.getBoundingClientRect(),i=[],a=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),o=a.nextNode();for(;o;){let e=o.nodeValue||``;if(e.length>0){let t=document.createRange();t.setStart(o,0),t.setEnd(o,e.length);let n=t.getClientRects(),a=o.parentElement,s=0,c=!1;if(a){let e=window.getComputedStyle(a),t=parseFloat(e.letterSpacing);Number.isNaN(t)||(s=t),c=e.direction===`rtl`}for(let e=0;e<n.length;e++){let t=n[e];t.width===0&&t.height===0||i.push({left:t.left-r.left,right:t.right-r.left,top:t.top-r.top,bottom:t.bottom-r.top,letterSpacing:s,isRtl:c})}}o=a.nextNode()}if(n.removeChild(t),i.length===0)return[];i.sort((e,t)=>e.top-t.top||e.left-t.left);let s=[];for(let e of i){let t=s[s.length-1];if(t){let n=Math.min(t.bottom,e.bottom)-Math.max(t.top,e.top),r=Math.min(t.bottom-t.top,e.bottom-e.top);if(r>0&&n>.5*r){let n=!t.isRtl&&e.right>t.right,r=t.isRtl&&e.left<t.left;(n||r)&&(t.trailingLetterSpacing=e.letterSpacing),t.left=Math.min(t.left,e.left),t.right=Math.max(t.right,e.right),t.top=Math.min(t.top,e.top),t.bottom=Math.max(t.bottom,e.bottom);continue}}s.push({left:e.left,right:e.right,top:e.top,bottom:e.bottom,trailingLetterSpacing:e.letterSpacing,isRtl:e.isRtl})}return s.map(e=>{let{trailingLetterSpacing:t,isRtl:n}=e,{left:r,right:i,top:a,bottom:o}=e;if(t!==0)if(n){let e=r+t;r=t>0?Math.min(i,e):e}else{let e=i-t;i=t>0?Math.max(r,e):e}return{left:r,right:i,top:a,bottom:o}})}var jS={},MS=e=>{if(jS[e])return jS[e];let t=function(e){let t=[];for(let n=0;n<document.styleSheets.length;n++){let r=document.styleSheets[n];try{let n=r.cssRules;if(n)for(let r=0;r<n.length;r++){let i=n[r];i instanceof CSSFontFaceRule&&i.style.fontFamily.replace(/['"]/g,``)===e&&t.push(i)}}catch(e){console.warn(`Could not access stylesheet: ${r.href}`,e)}}return t}(e).filter(t=>t.style.fontFamily.replace(/['"]/g,``)===e).map(e=>({src:e.style.getPropertyValue(`src`),fontStyle:e.style.getPropertyValue(`font-style`)||`normal`,fontWeight:e.style.getPropertyValue(`font-weight`)||`normal`}));return jS[e]=t,t},NS=new Map;async function PS(e,t){let n=`${e}|${t}`;if(NS.has(n))return NS.get(n);let r=`https://fonts.googleapis.com/css?family=${encodeURIComponent(e)}:${t}&display=swap`;try{let e=await fetch(r);if(!e.ok)return NS.set(n,``),``;let t=await e.text();return NS.set(n,t),t}catch{return NS.set(n,``),``}}async function FS({html:e,width:t,height:n,fontFamily:r,fontFamilies:i,padding:a,font:o,resolveFont:s,pixelRatio:c}){e=gv(e);let l=await async function(e,t,n,r){let i=[...new Set(e.filter(Boolean))],a=``;for(let e of i){if(e===`Arial`)continue;let i=e===t&&n||r?.(e);if(i)(i.styles||(i.url?[{src:`url("${i.url}")`}]:MS(e))).forEach(t=>{a+=`\n @font-face {\n font-family: '${e.replace(/'/g,`\\'`)}';\n src: ${t.src};\n font-style: ${t.fontStyle||`normal`};\n font-weight: ${t.fontWeight||`normal`};\n }\n `});else{let t=Bv();a+=await PS(e,t)}}return a}(i?.length?[...new Set([r,...i])]:[r],r,o,s),u=``;return l&&(u=rS(l,e)),yS({html:`<div style="padding: ${a}px;" dir="auto">${e+=u+Uy}</div>`,width:t+2*a,height:n+2*a,cache:{maxEntries:100},pixelRatio:c})}var IS=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n},LS=(e,t,...n)=>({type:e,props:t,children:n||[]});function RS(e){return sy(e),e}function zS(e){var t=new DOMParser().parseFromString(e,`image/svg+xml`);return t.documentElement.setAttribute(`preserveAspectRatio`,`none`),new XMLSerializer().serializeToString(t)}var BS=async({element:e,page:t,store:n})=>{let{src:r}=e;if(e.type===`svg`){let t=await xy(r);t=zS(t),r=Object.keys(e.colorsReplace).length?Ty(t,new Map(Object.entries(e.colorsReplace))):Sy(t)}let i=``;e.flipX&&(i+=`scaleX(-1)`),e.flipY&&(i+=`scaleY(-1)`),i||=`none`;let a={};if(e.type===`svg`&&e.maskSrc){let t=await by(r);a[`mask-image`]=`url(${t})`,a[`mask-size`]=`100% 100%`,a[`mask-position`]=`0 0`,a[`mask-repeat`]=`no-repeat`,a[`-webkit-mask-image`]=`url(${t})`,a[`-webkit-mask-size`]=`100% 100%`,a[`-webkit-mask-position`]=`0 0`,a[`-webkit-mask-repeat`]=`no-repeat`,r=e.maskSrc}else if(e.clipSrc){let t=e.clipSrc,n=await by(t);a[`mask-image`]=`url(${n})`,a[`mask-size`]=`100% 100%`,a[`mask-position`]=`0 0`,a[`mask-repeat`]=`no-repeat`,a[`-webkit-mask-image`]=`url(${n})`,a[`-webkit-mask-size`]=`100% 100%`,a[`-webkit-mask-position`]=`0 0`,a[`-webkit-mask-repeat`]=`no-repeat`}let o=await Ey(r),s=o.width*e.cropWidth,c=o.height*e.cropHeight,l=e.width/e.height,u,d,f=s/c,p=e.type===`svg`||e.stretchEnabled;p?(u=s,d=c):l>=f?(u=s,d=s/l):(u=c*l,d=c);let m=u/o.width,h=d/o.height,g=u/d>e.width/e.height?e.height/d:e.width/u,_=p?e.width/u:g,v=p?e.height/d:g,y=u*_/m,b=d*v/h,x=e.cropX*_*o.width,S=e.cropY*v*o.height;e.flipX&&(x=(1-e.cropX-e.cropWidth)*_*o.width),e.flipY&&(S=(1-e.cropY-e.cropHeight)*v*o.height);let C=e.borderSize&&sy(e.borderColor),w=C?Math.max(0,e.cornerRadius-e.borderSize):e.cornerRadius,T=LS(`div`,{style:Object.assign(Object.assign({},a),{width:`100%`,height:`100%`,borderRadius:w+`px`,border:e.borderSize&&!C?`${e.borderSize}px solid ${e.borderColor}`:`none`,backgroundRepeat:`no-repeat`,backgroundImage:`url(${r})`,transform:i,backgroundSize:`${Math.round(y)}px ${Math.round(b)}px`,backgroundPositionX:-Math.round(x)+`px`,backgroundPositionY:-Math.round(S)+`px`})});return C?LS(`div`,{style:{width:`100%`,height:`100%`,borderRadius:e.cornerRadius+`px`,background:RS(e.borderColor),padding:e.borderSize+`px`,boxSizing:`border-box`}},T):T},VS=({element:e,type:t})=>{let n={"stroke-width":e.height,stroke:e.color,"stroke-linecap":`round`,"stroke-linejoin":`round`,opacity:e.opacity},r=Object.assign(Object.assign({},n),{fill:e.color}),i=Object.assign(Object.assign({},n),{fill:`none`});return t===`arrow`?LS(`polyline`,Object.assign({points:`${3*e.height},${2*-e.height} 0,0 ${3*e.height},${2*e.height}`},i)):t===`triangle`?LS(`polygon`,Object.assign({points:`${3*e.height},${2*-e.height} 0,0 ${3*e.height},${2*e.height}`},r)):t===`bar`?LS(`polyline`,Object.assign({points:`0,${2*-e.height} 0,${2*e.height}`},i)):t===`circle`?LS(`circle`,Object.assign({cx:2*e.height,cy:0,r:2*e.height},r)):t===`square`?LS(`polygon`,Object.assign({points:`0,${2*-e.height} ${4*e.height},${2*-e.height} ${4*e.height},${2*e.height} 0,${2*e.height}`},r)):null},HS={image:BS,svg:BS,text:async({element:e,page:t,store:n})=>{let r=sy(e.fill),i=sy(e.stroke);if(e.curveEnabled){let t=wv(hv(e.text,{fontSize:e.fontSize,fontFamily:e.fontFamily}),{fontSize:e.fontSize,fontFamily:e.fontFamily}),n=Math.max(e.fontSize,...t.map(t=>t.fontSize??e.fontSize)),a=kx(e.width,e.height,e.curvePower,n),o=Fx(t,{fontWeight:e.fontWeight||`normal`,fontStyle:e.fontStyle||`normal`,fill:e.fill||`black`,fontFamily:e.fontFamily,fontSize:e.fontSize}),s=`\n <svg xmlns="http://www.w3.org/2000/svg" width="${e.width}" height="${e.height}" style="display: block;">\n <defs>\n <path id="curve-${e.id}" d="${a}" fill="none" />`;if(r){let t=`curve-fill-grad-${e.id}`;s+=Ax(e.fill,t)}if(i&&e.strokeWidth){let t=`curve-stroke-grad-${e.id}`;s+=Ax(e.stroke,t)}s+=`</defs>\n <text\n font-family="'${e.fontFamily}'"\n font-size="${e.fontSize}"\n font-weight="${e.fontWeight}"\n font-style="${e.fontStyle}"\n fill="${r?`url(#curve-fill-grad-${e.id})`:e.fill}"\n text-anchor="middle"\n dominant-baseline="central"\n letter-spacing="${e.letterSpacing*n}"${e.textDecoration?` text-decoration="${e.textDecoration}"`:``}${e.strokeWidth?` stroke="${i?`url(#curve-stroke-grad-${e.id})`:e.stroke}" stroke-width="${e.strokeWidth}" paint-order="stroke fill"`:``}>\n <textPath href="#curve-${e.id}" startOffset="50%">${o}</textPath>\n </text>\n </svg>`;let c=e.backgroundPadding*(e.fontSize*e.lineHeight);return LS(`div`,{style:{position:`relative`,width:`100%`,height:`100%`}},e.backgroundEnabled&&LS(`div`,{style:{position:`absolute`,top:-c/2+`px`,left:-c/2+`px`,width:e.width+c+`px`,height:e.height+c+`px`,backgroundColor:e.backgroundColor,opacity:e.backgroundOpacity,borderRadius:e.backgroundCornerRadius*(e.fontSize*e.lineHeight*.5)+`px`}}),LS(`div`,{style:{width:`100%`,height:`100%`,position:`absolute`,top:0,left:0},innerHTML:s}))}let a=e=>({backgroundImage:e,backgroundSize:`100% 100%`,backgroundRepeat:`repeat`,WebkitBackgroundClip:`text`,MozBackgroundClip:`text`,backgroundClip:`text`,WebkitTextFillColor:`transparent`,MozTextFillColor:`transparent`,color:`transparent`}),o=e.verticalAlign===`middle`?{top:`50%`,transform:`translateY(-50%)`}:e.verticalAlign===`bottom`?{bottom:0}:{top:0},s=Object.assign(Object.assign({left:0},o),r?a(e.fill):{}),c=null;if(e.backgroundEnabled)if(e.legacyBackground){let t=e.backgroundPadding*(e.fontSize*e.lineHeight);c=LS(`div`,{style:{position:`absolute`,top:-t/2+`px`,left:-t/2+`px`,display:`block`,width:e.width+t+`px`,height:e.height+t+`px`,backgroundColor:e.backgroundColor,opacity:e.backgroundOpacity,borderRadius:e.backgroundCornerRadius*(e.fontSize*e.lineHeight*.5)+`px`}})}else{let t=Lx(e),n=[];try{n=AS(t)}catch{n=[]}if(n.length){let r=e.backgroundPadding*(e.fontSize*e.lineHeight*.5),i=e.backgroundCornerRadius*(e.fontSize*e.lineHeight*.5),a=xx({rects:n,padding:r,cornerRadius:i});if(a){let i=0;try{let{height:n}=kS(t);e.verticalAlign===`middle`?i=(e.height-n)/2:e.verticalAlign===`bottom`&&(i=e.height-n)}catch{}let o=Math.min(...n.map(e=>e.top)),s=Math.max(...n.map(e=>e.bottom)),l=Math.min(...n.map(e=>e.left)),u=l-r,d=o-r,f=Math.max(...n.map(e=>e.right))-l+2*r,p=s-o+2*r;c=LS(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:f,height:p,viewBox:`${u} ${d} ${f} ${p}`,style:{position:`absolute`,top:i+d+`px`,left:u+`px`,opacity:e.backgroundOpacity,pointerEvents:`none`},innerHTML:`<path d="${a}" fill="${e.backgroundColor}" />`})}}}else c=null;let l=/<[a-z][\s\S]*>/i.test(e.text),u=l?hv(e.text,{fontSize:e.fontSize,fontFamily:e.fontFamily}):e.text.split(`
|
|
201
|
+
`).join(`<br />`);if(e.strokeWidth&&(i||r&&!i)){let t={position:`absolute`,width:e.width+`px`,whiteSpace:`pre-wrap`,overflowWrap:`break-word`,fontSize:e.fontSize+`px`,textAlign:e.align,fontFamily:`'${e.fontFamily}'`,textDecoration:e.textDecoration||`none`,textDecorationColor:e.textDecoration?e.fill:void 0,textTransform:e.textTransform||`none`,lineHeight:e.lineHeight,letterSpacing:e.letterSpacing*e.fontSize+`px`,fontStyle:e.fontStyle,fontWeight:e.fontWeight},n=i?Object.assign(Object.assign(Object.assign({},t),a(e.stroke)),{WebkitTextStroke:`${e.strokeWidth}px transparent`}):Object.assign(Object.assign({},t),{color:`transparent`,WebkitTextStroke:`${e.strokeWidth}px ${e.stroke}`}),s=r?Object.assign(Object.assign({},t),a(e.fill)):Object.assign(Object.assign({},t),{color:e.fill}),d=`el-`+e.id,f=l?`<style>#${d} {${Hy}}</style>`:``,p=LS(`div`,{style:Object.assign(Object.assign({},n),{position:`absolute`,top:0,left:0,pointerEvents:`none`}),"aria-hidden":`true`,innerHTML:l?`${f}${u}`:u}),m=LS(`div`,Object.assign(Object.assign({style:Object.assign(Object.assign({},s),{position:`relative`})},l?{id:d}:{}),{innerHTML:l?`${f}${u}`:u}));return LS(`div`,{style:{position:`relative`,width:`100%`,height:`100%`}},c,LS(`div`,{style:Object.assign({position:`absolute`,width:e.width+`px`,left:0},o)},p,m))}let d=Object.assign(Object.assign({},s),{position:`absolute`,width:e.width+`px`,color:e.fill,whiteSpace:`pre-wrap`,overflowWrap:`break-word`,fontSize:e.fontSize+`px`,textAlign:e.align,fontFamily:`'${e.fontFamily}'`,textDecoration:e.textDecoration||`none`,textDecorationColor:e.textDecoration?e.fill:void 0,textTransform:e.textTransform||`none`,lineHeight:e.lineHeight,letterSpacing:e.letterSpacing*e.fontSize+`px`,fontStyle:e.fontStyle,fontWeight:e.fontWeight,WebkitTextStroke:e.strokeWidth?`${e.strokeWidth}px ${e.stroke}`:void 0,paintOrder:e.strokeWidth?`stroke fill`:void 0}),f=`el-`+e.id,p=l?{id:f}:{},m=`<style>#${f} {${Hy}}</style>`,h=LS(`div`,Object.assign(Object.assign({style:d},p),{innerHTML:l?`${m}${u}`:u}));return LS(`div`,{style:{position:`relative`,width:`100%`,height:`100%`}},c,h)},line:async({element:e,page:t,store:n})=>LS(`svg`,{style:{width:`100%`,height:`100%`,contain:`layout style size`,overflow:`visible`}},LS(`line`,{x1:0,y1:e.height/2,x2:e.width,y2:e.height/2,stroke:e.color,"stroke-width":e.height,"stroke-dasharray":e.dash&&e.dash.length?e.dash.map(t=>t*e.height).join(` `):void 0}),LS(`g`,{transform:`translate(0 ${e.height/2})`},VS({element:e,type:e.startHead})),LS(`g`,{transform:`translate(${e.width} ${e.height/2}) rotate(180)`},VS({element:e,type:e.endHead}))),figure:async({element:e,page:t,store:n,elementHook:r})=>{let i=Vy(e);if(e.strokeWidth&&sy(e.stroke)){let t=`figure-stroke-grad-${e.id}`,n=Ax(e.stroke,t);i=i.replace(RegExp(`stroke="${e.stroke.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}"`,`g`),`stroke="url(#${t})"`),i=i.replace(`</defs>`,`${n}</defs>`)}if(sy(e.fill)){let t=`figure-fill-grad-${e.id}`,n=Ax(e.fill,t);i=i.replace(RegExp(`fill="${e.fill.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}"`,`g`),`fill="url(#${t})"`),i=i.replace(`</defs>`,`${n}</defs>`)}let a=LS(`div`,{innerHTML:i});return r&&r({dom:a,element:e})||a},group:async({element:e,page:t,store:n,elementHook:r})=>{let i=await Promise.all(e.children.map(e=>US({element:e,page:t,store:n,elementHook:r}))),a=LS(`div`,{style:{transformOrigin:`top left`,opacity:e.opacity}},...i);return r&&r({dom:a,element:e})||a},video:async({element:e,page:t,store:n,elementHook:r})=>{let{cropX:i,cropY:a,cropWidth:o,cropHeight:s}=e,c=await Ky(e.src),l=c.width*o,u=c.height*s,d=e.width/e.height,f,p;d>=l/u?(f=l,p=l/d):(f=u*d,p=u);let m=f/o,h=p/s,g=i*c.width,_=a*c.height,v=Math.max(e.width/c.width,e.height/c.height),y={position:`absolute`,width:`${Math.round(m*v)}px`,height:`${Math.round(h*v)}px`,left:-Math.round(g*v)+`px`,top:-Math.round(_*v)+`px`,objectFit:`fill`},b=`video-${e.id}`,x=e.borderSize&&sy(e.borderColor),S=LS(`div`,{style:{position:`relative`,width:`100%`,height:`100%`,overflow:`hidden`,borderRadius:(x?Math.max(0,e.cornerRadius-e.borderSize):e.cornerRadius)+`px`,border:e.borderSize&&!x?`${e.borderSize}px solid ${e.borderColor}`:`none`}},LS(`video`,{id:b,src:e.src,style:y,controls:!0,playsInline:!0,muted:!0,volume:e.volume}));if(x){let t=LS(`div`,{style:{width:`100%`,height:`100%`,borderRadius:e.cornerRadius+`px`,background:RS(e.borderColor),padding:e.borderSize+`px`,boxSizing:`border-box`}},S);return r&&r({dom:t,element:e})||t}return r&&r({dom:S,element:e})||S},gif:BS,table:async({element:e})=>{let t=e.rows,n=e.cols,r=e.colWidths,i=e.rowHeights,a=[`fontSize`,`fontFamily`,`fontWeight`,`fontStyle`,`textDecoration`,`textTransform`,`fill`,`align`,`verticalAlign`,`lineHeight`,`letterSpacing`,`strokeWidth`,`stroke`,`cellBackground`,`cellPadding`],o=(e.cells||[]).map(t=>{if(!t)return t;let n=Object.assign({},t);for(let t of a)n[t]===void 0&&(n[t]=e[t]);return n}),s=[];for(let r=0;r<t;r++){let t=[];for(let a=0;a<n;a++){let s=o[r*n+a];if(!s||s.mergedInto)continue;let c=s.cellPadding||4,l=s.colSpan||1,u=s.rowSpan||1,d=t=>{let n=s.borders?.[t];return`${n?.width??e.borderWidth}px ${n?.style??e.borderStyle??`solid`} ${n?.color??e.borderColor}`},f={style:{padding:c+`px`,background:s.cellBackground||`transparent`,fontSize:(s.fontSize||12)+`px`,fontFamily:`'${s.fontFamily||`Roboto`}'`,fontWeight:s.fontWeight||`normal`,fontStyle:s.fontStyle||`normal`,color:s.fill||`black`,textAlign:s.align||`left`,verticalAlign:s.verticalAlign||`top`,lineHeight:String(s.lineHeight||1.2),letterSpacing:s.letterSpacing?s.letterSpacing*(s.fontSize||12)+`px`:void 0,textDecoration:s.textDecoration||`none`,textTransform:s.textTransform||`none`,borderTop:d(`top`),borderRight:d(`right`),borderBottom:d(`bottom`),borderLeft:d(`left`),overflow:`hidden`,overflowWrap:`break-word`,whiteSpace:`pre-wrap`,height:i[r]*e.height+`px`}};l>1&&(f.colspan=String(l)),u>1&&(f.rowspan=String(u)),t.push(LS(`td`,f,Sv(s.text||``)))}s.push(LS(`tr`,{},...t))}return LS(`table`,{style:{width:`100%`,height:`100%`,borderCollapse:`collapse`,tableLayout:`fixed`}},LS(`colgroup`,{},...r.map(e=>LS(`col`,{style:{width:100*e+`%`}}))),LS(`tbody`,{},...s))}};async function US({element:e,page:t,store:n,elementHook:r}){let i=await HS[e.type];if(i||(i=()=>LS(`div`,{}),console.error(`HTML export does not support ${e.type} type...`)),!e.visible)return null;let a=await i({element:e,page:t,store:n}),o=[],s=[];if(e.blurEnabled&&o.push(`blur(${e.blurRadius/2}px)`),e.brightnessEnabled&&o.push(`brightness(${100*e.brightness+100}%)`),e.sepiaEnabled&&o.push(`sepia()`),e.grayscaleEnabled&&o.push(`grayscale()`),e.filters)for(let[t,n]of Object.entries(e.filters)){let e=Gy(Wy[t],n.intensity);e&&(o.push(e.filter),e.html&&s.push(e.html))}if(e.shadowEnabled){let t=function(e,t){if(t===1)return e;let n=W.Util.colorToRGBA(e);return n?`rgba(${n.r}, ${n.g}, ${n.b}, ${n.a*t})`:e}(e.shadowColor,e.shadowOpacity??1);o.push(`drop-shadow(${e.shadowOffsetX}px ${e.shadowOffsetY}px ${e.shadowBlur/2}px ${t})`)}let c=LS(`div`,{id:e.id,style:{position:`absolute`,left:e.x+`px`,top:e.y+`px`,width:e.width+`px`,height:e.height+`px`,transform:`rotate(${e.rotation}deg)`,transformOrigin:`top left`,opacity:e.opacity,display:e.visible&&e.showInExport?`block`:`none`,filter:o.join(` `)||`none`}},a,...s);return r&&r({dom:c,element:e})||c}async function WS({json:e,elementHook:t}){let n=await Promise.all(e.pages.map(n=>async function({page:e,store:t,elementHook:n}){let r=await Promise.all(e.children.map(r=>US({element:r,page:e,store:t,elementHook:n}))),i=e.width===`auto`?t.width:e.width,a=e.height===`auto`?t.height:e.height,o={};if(e.background.indexOf(`url`)>=0||e.background.indexOf(`http`)>=0||e.background.indexOf(`.jpg`)>=0||e.background.indexOf(`.png`)>=0||e.background.indexOf(`.jpeg`)>=0){let{width:n,height:o}=await Ey(e.background),s=await BS({element:Object.assign({x:0,y:0,width:i,height:a,src:e.background,cornerRadius:0},Oy({width:i,height:a},{width:n,height:o})),page:e,store:t});r.unshift(s)}else o=sy(e.background)?Object.assign(Object.assign({},o),{backgroundImage:e.background}):Object.assign(Object.assign({},o),{backgroundColor:e.background});return LS(`div`,{className:`page`,id:e.id,style:Object.assign(Object.assign({},o),{width:i+`px`,height:a+`px`,overflow:`hidden`,position:`relative`})},...r)}({page:n,store:e,elementHook:t}))),r=[];return zb({children:e.pages},e=>{if((e.type===`text`||e.type===`tablecell`||e.type===`table`)&&(e.fontFamily&&r.indexOf(e.fontFamily)===-1&&r.push(e.fontFamily),e.text))for(let t of _v(e.text))r.indexOf(t)===-1&&r.push(t)}),LS(`div`,{className:`design`},...r.map(t=>{let n=e.fonts.find(e=>e.fontFamily===t);return n?LS(`style`,{},(n.styles||(n.url?[{src:`url("${n.url}")`}]:[])).map(e=>`\n @font-face {\n font-family: '${n.fontFamily}';\n src: ${e.src};\n font-style: ${e.fontStyle||`normal`};\n font-weight: ${e.fontWeight||`normal`};\n font-display: swap;\n }`).join(`
|
|
202
|
+
`)):LS(`link`,{href:Vv(t),rel:`stylesheet`})}),...n)}var GS=({dom:e})=>{if(typeof e==`string`)return e;if(!e)return``;let t=e.props,{innerHTML:n}=t,r=IS(t,[`innerHTML`]),i=Object.keys(r).map(e=>e===`style`&&typeof r[e]==`object`?`style="${Object.keys(r[e]).filter(t=>r[e][t]!=null).map(t=>`${t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}: ${r[e][t]}`).join(`; `)}"`:((e,t)=>t==null||t===``?``:typeof t==`object`?`${e}="${Object.keys(t).map(e=>`${e.replace(/-([a-z])/g,e=>e[1].toUpperCase())}:${t[e]};`).join(` `)}"`:`${e}="${t}"`)(e,r[e])).filter(e=>e&&e.trim().length>0).join(` `);return`<${e.type} ${i}>${n||e.children.map(e=>GS({dom:e})).join(``)}</${e.type}>`};async function KS({json:e,elementHook:t}){return GS({dom:await WS({json:e,elementHook:t})})}function qS(e,t,n){return{x:e-(7+n.ascent/3)-n.inkRight,y:t-n.ascent/3+(n.inkAscent-n.inkDescent)/2}}function JS(e,t,n){return{x:e-n.markerWidth-n.spaceWidth,y:t}}var YS=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n},XS=(e,t)=>{if(e.children)for(let n of e.children){if(!0===t(n))break;XS(n,t)}if(e.cells){for(let n of e.cells)if(!0===t(n))break}},J=(e,t,...n)=>({type:e,props:t,children:n||[]});function ZS(e,t){if(!sy(e))return null;let{stops:n,rotation:r}=ly(e),i=r*Math.PI/180,a=.5-.5*Math.sin(i),o=.5+.5*Math.cos(i),s=.5+.5*Math.sin(i),c=.5-.5*Math.cos(i),l=n.map(({offset:e,color:t})=>J(`stop`,{offset:100*e+`%`,"stop-color":t}));return J(`linearGradient`,{id:t,x1:100*a+`%`,y1:100*o+`%`,x2:100*s+`%`,y2:100*c+`%`},...l)}var QS=async e=>{try{let t=await fetch(e);if(typeof Buffer<`u`){let e=await t.arrayBuffer(),n=Buffer.from(e).toString(`base64`);return`data:${t.headers.get(`content-type`)||`image/png`};base64,${n}`}{let e=await t.blob();return new Promise((t,n)=>{let r=new FileReader;r.onloadend=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}}catch(t){return console.error(`Error converting URL to data URL:`,t),e}},$S=async({element:e,page:t,store:n})=>{let{src:r}=e;r=e.type===`svg`?Ty(await xy(r),new Map(Object.entries(e.colorsReplace))):await QS(r);let i,a,o,s,c=``;if(e.flipX||e.flipY){let t=e.flipX?-1:1,n=e.flipY?-1:1,r=e.width/2,i=e.height/2;c=`translate(${r}, ${i}) scale(${t}, ${n}) translate(${-r}, ${-i})`}e.clipSrc&&(i=`clip-img-mask-${e.id}`,a=await QS(e.clipSrc)),e.maskSrc&&(o=`mask-img-${e.id}`,s=await QS(e.maskSrc));let l=await Ey(r),u=l.width*e.cropWidth,d=l.height*e.cropHeight,f=e.width/e.height,p,m,h=u/d,g=typeof e.stretchEnabled==`boolean`&&e.stretchEnabled||e.type===`svg`;g?(p=u,m=d):f>=h?(p=u,m=u/f):(p=d*f,m=d);let _=p/l.width,v=m/l.height,y=p/m>e.width/e.height?e.height/m:e.width/p,b=g?e.width/p:y,x=g?e.height/m:y,S=p*b/_,C=m*x/v,w=e.cropX*l.width*b,T=e.cropY*l.height*x;e.flipX&&(w=(1-e.cropX-e.cropWidth)*l.width*b),e.flipY&&(T=(1-e.cropY-e.cropHeight)*l.height*x);let E=`clip-${e.id}`,D=e.cornerRadius||0,O=r.replace(/&/g,`&`),k={x:-w,y:-T,width:S,height:C,preserveAspectRatio:`none`,"clip-path":`url(#${E})`},ee=[J(`clipPath`,{id:E},J(`rect`,{x:0,y:0,width:e.width,height:e.height,rx:D||void 0,ry:D||void 0}))];i&&a&&ee.push(J(`mask`,{id:i,maskUnits:`userSpaceOnUse`,"mask-type":`alpha`},J(`image`,{href:a.replace(/&/g,`&`),x:0,y:0,width:e.width,height:e.height,preserveAspectRatio:`none`}))),o&&ee.push(J(`mask`,{id:o,maskUnits:`userSpaceOnUse`,"mask-type":`alpha`},J(`image`,Object.assign({href:O},k))));let A=O,j={};o&&s&&(A=s.replace(/&/g,`&`),j.mask=`url(#${o})`);let te={};i&&(te.mask=`url(#${i})`);let M=e.borderSize||0,ne=M>0&&sy(e.borderColor),N=ne?`border-grad-${e.id}`:null;if(ne){let t=ZS(e.borderColor,N);t&&ee.push(t)}let P=M>0?J(`rect`,{x:M/2,y:M/2,width:Math.max(0,e.width-M),height:Math.max(0,e.height-M),fill:`none`,stroke:ne?`url(#${N})`:e.borderColor,"stroke-width":M,rx:Math.max(0,D-M)||void 0,ry:Math.max(0,D-M)||void 0}):null,re=J(`g`,{},J(`defs`,{},...ee),J(`image`,Object.assign(Object.assign({href:A},k),j)),P);return J(`g`,te,c?J(`g`,{transform:c},re):re)},eC=({element:e,type:t})=>{let n={"stroke-width":e.height,stroke:e.color,"stroke-linecap":`round`,"stroke-linejoin":`round`},r=Object.assign(Object.assign({},n),{fill:e.color}),i=Object.assign(Object.assign({},n),{fill:`none`});return t===`arrow`?J(`polyline`,Object.assign({points:`${3*e.height},${2*-e.height} 0,0 ${3*e.height},${2*e.height}`},i)):t===`triangle`?J(`polygon`,Object.assign({points:`${3*e.height},${2*-e.height} 0,0 ${3*e.height},${2*e.height}`},r)):t===`bar`?J(`polyline`,Object.assign({points:`0,${2*-e.height} 0,${2*e.height}`},i)):t===`circle`?J(`circle`,Object.assign({cx:2*e.height,cy:0,r:2*e.height},r)):t===`square`?J(`polygon`,Object.assign({points:`0,${2*-e.height} ${4*e.height},${2*-e.height} ${4*e.height},${2*e.height} 0,${2*e.height}`},r)):null},tC={image:$S,svg:$S,text:async({element:e,page:t,store:n})=>{let r=sy(e.fill),i=sy(e.stroke);if(e.curveEnabled){let t=wv(hv(e.text,{fontSize:e.fontSize,fontFamily:e.fontFamily}),{fontSize:e.fontSize,fontFamily:e.fontFamily}),n=Math.max(e.fontSize,...t.map(t=>t.fontSize??e.fontSize)),a=kx(e.width,e.height,e.curvePower,n),o=aC(e.id||`temp`),s=`curve-path-${o}`,c={fontWeight:e.fontWeight||`normal`,fontStyle:e.fontStyle||`normal`,fill:e.fill||`black`,fontFamily:e.fontFamily,fontSize:e.fontSize},l=Fx(t,c),u=Fx(t,c,{omitColors:!0}),d=e.backgroundPadding*(e.fontSize*e.lineHeight*.5),f=e.backgroundEnabled?J(`rect`,{x:-d,y:-d,width:e.width+2*d,height:e.height+2*d,fill:e.backgroundColor,opacity:e.backgroundOpacity,rx:e.backgroundCornerRadius*(e.fontSize*e.lineHeight*.5),ry:e.backgroundCornerRadius*(e.fontSize*e.lineHeight*.5)}):null,p=[J(`path`,{id:s,d:a,fill:`none`})],m=e.strokeWidth&&(i||r&&!i);if(r){let t=`curve-fill-grad-${o}`,n=ZS(e.fill,t);n&&p.push(n)}if(i&&e.strokeWidth){let t=`curve-stroke-grad-${o}`,n=ZS(e.stroke,t);n&&p.push(n)}if(m){let t={"font-size":e.fontSize+`px`,"text-anchor":`middle`,"dominant-baseline":`central`,"font-family":e.fontFamily,"font-style":e.fontStyle,"font-weight":e.fontWeight,"text-decoration":e.textDecoration||void 0,"letter-spacing":e.letterSpacing*n},a=i?`url(#curve-stroke-grad-${o})`:e.stroke,c=J(`text`,Object.assign(Object.assign({},t),{fill:a,"stroke-width":e.strokeWidth,stroke:a}),J(`textPath`,{href:`#${s}`,startOffset:`50%`,innerHTML:u})),d=r?`url(#curve-fill-grad-${o})`:e.fill,m=J(`text`,Object.assign(Object.assign({},t),{fill:d}),J(`textPath`,{href:`#${s}`,startOffset:`50%`,innerHTML:l}));return J(`g`,{},f,J(`defs`,{},...p),c,m)}return J(`g`,{},f,J(`defs`,{},...p),J(`text`,{fill:r?`url(#curve-fill-grad-${o})`:e.fill,"font-size":e.fontSize+`px`,"text-anchor":`middle`,"dominant-baseline":`central`,"font-family":e.fontFamily,"font-style":e.fontStyle,"font-weight":e.fontWeight,"text-decoration":e.textDecoration||void 0,"letter-spacing":e.letterSpacing*n,"stroke-width":e.strokeWidth||void 0,stroke:e.strokeWidth?i?`url(#curve-stroke-grad-${o})`:e.stroke:void 0,"paint-order":e.strokeWidth?`stroke fill`:void 0},J(`textPath`,{href:`#${s}`,startOffset:`50%`,innerHTML:l})))}let a=null,o=()=>(a||=document.createElement(`canvas`).getContext(`2d`),a),s=(e,t,n,r,i,a=0)=>{let s=o();return s.font=`${i} ${r} ${t}px ${n}`,s.measureText(e).width+Math.max(0,(e?e.length:0)-1)*a*t},c=(t,n,r)=>{let i=n;t.fontSize!=null&&t.fontSize!==e.fontSize&&e.fontSize>0&&(i=t.fontSize*(n/e.fontSize));let a=t.fontFamily||e.fontFamily,o=t.bold?`bold`:e.fontWeight||`normal`,c=t.italic?`italic`:e.fontStyle||`normal`;return s(t.text,i,a,o,c,r)},l=/<[a-z][\s\S]*>/i.test(e.text),u=e.text;!l&&u.includes(`
|
|
203
|
+
`)&&(u=u.split(`
|
|
204
|
+
`).map(e=>`<p>${e}</p>`).join(``));let d=hv(u,{fontSize:e.fontSize,fontFamily:e.fontFamily}),f={fontSize:e.fontSize,fontFamily:e.fontFamily},p=[],m=new DOMParser().parseFromString(d,`text/html`),h=m.body.querySelectorAll(`p`);h.length>0?h.forEach((e,t)=>{let n=e.innerHTML,r=wv(n,f);p.push(...r),t<h.length-1&&p.push({text:`
|
|
205
|
+
`})}):p.push(...wv(d,f)),e.textTransform===`uppercase`&&p.forEach(e=>{e.text!==`
|
|
206
|
+
`&&(e.text=e.text.toUpperCase())});let g=e=>{let t=[],n=[];for(let r of e){if(r.text===`
|
|
207
|
+
`){n.length>0&&(t.push(n),n=[]),t.push([Object.assign(Object.assign({},r),{text:`
|
|
208
|
+
`})]);continue}let e=r.text.split(/( )/);for(let i of e)i!==``&&(i===` `?(n.length>0&&(t.push(n),n=[]),t.push([Object.assign(Object.assign({},r),{text:` `})])):n.push(Object.assign(Object.assign({},r),{text:i})))}return n.length>0&&t.push(n),t},_=(e,t,n,r)=>{let i=[[]],a=0;for(let o of e){if(o.length===1&&o[0].text===`
|
|
209
|
+
`){i.push([]),a=0;continue}let e=o.reduce((e,t)=>e+c(t,n,r),0);o.length!==1||o[0].text!==` `?(a+e>t+.5&&i[i.length-1].length>0&&(i.push([]),a=0),i[i.length-1].push(...o),a+=e):a+e<=t+.5&&(i[i.length-1].push(...o),a+=e)}return i},v=(e,t,n)=>e.reduce((e,r)=>e+c(r,t,n),0),y=(e,t)=>t===1?e:e.map(e=>e.map(e=>e.fontSize?Object.assign(Object.assign({},e),{fontSize:Math.round(e.fontSize*t*1e3)/1e3}):e));if(m.body.querySelector(`ul, ol`)){let t=[],n=t=>{let n=t.cloneNode(!0);n.querySelectorAll(`ul, ol`).forEach(e=>e.remove());let r=wv(n.innerHTML,f);return e.textTransform===`uppercase`&&r.forEach(e=>{e.text!==`
|
|
210
|
+
`&&(e.text=e.text.toUpperCase())}),r},a=(e,r)=>{for(let i of Array.from(e.children)){let e=i.tagName.toLowerCase();if(e===`ul`||e===`ol`){let o=e===`ol`,s=parseInt(i.getAttribute(`start`)||`1`,10)||1;for(let e of Array.from(i.children)){if(e.tagName.toLowerCase()!==`li`)continue;let i=e.getAttribute(`value`);i&&!Number.isNaN(parseInt(i,10))&&(s=parseInt(i,10));let c=o?{text:`${s}.`,isOrdered:!0}:{text:`•`,isOrdered:!1};t.push({segments:n(e),depth:r+1,marker:c}),o&&(s+=1),a(e,r+1)}}else e===`p`||e===`div`?t.push({segments:n(i),depth:0,marker:null}):t.push({segments:wv(i.outerHTML,f),depth:0,marker:null})}};a(m.body,0);let c=n=>{let r=[],i=[];for(let a of t){let t=a.depth*2.1*n,o=Math.max(1,e.width-t);(a.segments.length===0?[[]]:_(g(a.segments),o,n,e.letterSpacing)).forEach((e,n)=>{r.push(e),i.push({indent:t,marker:n===0?a.marker:null})})}return{L:r,M:i}},l=e.fontSize,u=[],d=[];for(;;){let t=c(l);u=t.L,d=t.M;let n=Math.max(0,...u.map((t,n)=>d[n].indent+v(t,l,e.letterSpacing))),r=u.length*l*e.lineHeight;if(n<=e.width&&(!e.height||r<=e.height)||(--l,l<4))break}u=y(u,l/e.fontSize);let p=l*e.lineHeight,h=u.length*p,b=0;e.verticalAlign===`middle`?b=(e.height-h)/2:e.verticalAlign===`bottom`&&(b=e.height-h);let x=l+b,S={fontWeight:e.fontWeight||`normal`,fontStyle:e.fontStyle||`normal`,fill:e.fill||`black`,fontFamily:e.fontFamily,fontSize:l},C=e=>{let t=e.length;for(;t>0&&e[t-1].text.trim()===``;)t--;return e.slice(0,t)},w=o(),T=e.fontWeight||`normal`,E=e.fontStyle||`normal`;w.font=`${E} ${T} ${l}px ${e.fontFamily}`;let D=w.measureText(` `).width,O=d.map((t,n)=>{if(!t.marker)return null;let r=x+n*p,i;if(t.marker.isOrdered){let n=s(t.marker.text,l,e.fontFamily,T,E,e.letterSpacing);i=JS(t.indent,r,{markerWidth:n,spaceWidth:D})}else{let e=w.measureText(t.marker.text);i=qS(t.indent,r,{ascent:e.fontBoundingBoxAscent??e.actualBoundingBoxAscent??.8*l,inkRight:e.actualBoundingBoxRight??0,inkAscent:e.actualBoundingBoxAscent??0,inkDescent:e.actualBoundingBoxDescent??0})}return J(`tspan`,{x:i.x,y:i.y,"letter-spacing":t.marker.isOrdered?e.letterSpacing*l+`px`:void 0,innerHTML:wx(t.marker.text)})}),k=e=>{let t=[];return u.forEach((n,r)=>{let i=C(n);i.length>0&&t.push(J(`tspan`,{x:d[r].indent,y:x+r*p,innerHTML:Fx(i,S,{omitColors:e})})),O[r]&&t.push(O[r])}),t},ee=null;if(e.backgroundEnabled){let t=e.backgroundPadding*(l*e.lineHeight*.5),n=e.backgroundCornerRadius*(l*e.lineHeight*.5);if(e.legacyBackground)ee=J(`rect`,{x:-t,y:-t,width:e.width+2*t,height:e.height+2*t,fill:e.backgroundColor,opacity:e.backgroundOpacity,rx:n,ry:n});else{let r=xx({rects:u.map((t,n)=>{let r=t.length?v(t,l,e.letterSpacing):0,i=n*p;return{left:d[n].indent,right:d[n].indent+r,top:i,bottom:i+p}}).filter(e=>e.right>e.left),padding:t,cornerRadius:n});r&&(ee=J(`path`,{d:r,fill:e.backgroundColor,opacity:e.backgroundOpacity,transform:b?`translate(0,${b})`:void 0}))}}let A=[];if(r){let t=ZS(e.fill,`text-fill-grad-${e.id}`);t&&A.push(t)}if(i&&e.strokeWidth){let t=ZS(e.stroke,`text-stroke-grad-${e.id}`);t&&A.push(t)}let j=e.strokeWidth&&(i||r&&!i),te={"font-size":l+`px`,"text-anchor":`start`,"font-family":e.fontFamily,"font-style":e.fontStyle,"font-weight":e.fontWeight,"text-decoration":e.textDecoration,"letter-spacing":e.letterSpacing*l+`px`};if(j){let t=k(!0),n=i?`url(#text-stroke-grad-${e.id})`:e.stroke,a=J(`text`,Object.assign(Object.assign({},te),{fill:n,"stroke-width":e.strokeWidth,stroke:n}),...t.map(e=>J(`tspan`,e.props,e.props.innerHTML))),o=r?`url(#text-fill-grad-${e.id})`:e.fill,s=r?t:k(!1),c=J(`text`,Object.assign(Object.assign({},te),{fill:o}),...s.map(e=>J(`tspan`,e.props,e.props.innerHTML)));return J(`g`,{},ee,A.length>0?J(`defs`,{},...A):null,a,c)}return J(`g`,{},ee,A.length>0?J(`defs`,{},...A):null,J(`text`,Object.assign(Object.assign({},te),{fill:r?`url(#text-fill-grad-${e.id})`:e.fill,"stroke-width":e.strokeWidth||void 0,stroke:e.strokeWidth?e.stroke:void 0,"paint-order":e.strokeWidth?`stroke fill`:void 0}),...k(!1)))}let b=e.fontSize,x=g(p),S=[];for(;;){S=_(x,e.width,b,e.letterSpacing);let t=Math.max(...S.map(t=>v(t,b,e.letterSpacing)),0),n=S.length*b*e.lineHeight;if(t<=e.width&&n<=e.height||(--b,b<4))break}S=y(S,b/e.fontSize);let C=b*e.lineHeight,w=S.length*C,T=b;e.verticalAlign===`middle`?T=(e.height-w)/2+b:e.verticalAlign===`bottom`&&(T=e.height-w+b);let E=e.align===`center`?`middle`:e.align===`right`?`end`:`start`,D={fontWeight:e.fontWeight||`normal`,fontStyle:e.fontStyle||`normal`,fill:e.fill||`black`,fontFamily:e.fontFamily,fontSize:b},O=e.align===`center`?e.width/2:e.align===`right`?e.width:0,k=e=>{let t=e.length;for(;t>0&&e[t-1].text.trim()===``;)t--;return e.slice(0,t)},ee=S.map((e,t)=>{let n=k(e),r=n.length===0?``:Fx(n,D);return J(`tspan`,{x:O,dy:t===0?0:C,innerHTML:r})}),A=e.backgroundPadding*(b*e.lineHeight*.5),j=e.backgroundCornerRadius*(b*e.lineHeight*.5),te=null;if(e.backgroundEnabled)if(e.legacyBackground)te=J(`rect`,{x:-A,y:-A,width:e.width+2*A,height:e.height+2*A,fill:e.backgroundColor,opacity:e.backgroundOpacity,rx:j,ry:j});else{let t=Sx({lines:S.map(t=>({width:t.length===0?0:v(t,b,e.letterSpacing)})),lineHeight:C,width:e.width,align:e.align===`justify`?`justify`:e.align}),n=0;e.verticalAlign===`middle`?n=(e.height-S.length*C)/2:e.verticalAlign===`bottom`&&(n=e.height-S.length*C);let r=xx({rects:t,padding:A,cornerRadius:j});r&&(te=J(`path`,{d:r,fill:e.backgroundColor,opacity:e.backgroundOpacity,transform:n?`translate(0,${n})`:void 0}))}let M=[],ne=e.strokeWidth&&(i||r&&!i);if(r){let t=`text-fill-grad-${e.id}`,n=ZS(e.fill,t);n&&M.push(n)}if(i&&e.strokeWidth){let t=`text-stroke-grad-${e.id}`,n=ZS(e.stroke,t);n&&M.push(n)}if(ne){let t=S.map((e,t)=>{let n=Fx(k(e),D,{omitColors:!0});return J(`tspan`,{x:O,dy:t===0?0:C,innerHTML:n})}),n={y:T,"font-size":b+`px`,"text-anchor":E,"font-family":e.fontFamily,"font-style":e.fontStyle,"font-weight":e.fontWeight,"text-decoration":e.textDecoration,"letter-spacing":e.letterSpacing*b+`px`},a=i?`url(#text-stroke-grad-${e.id})`:e.stroke,o=J(`text`,Object.assign(Object.assign({},n),{fill:a,"stroke-width":e.strokeWidth,stroke:a}),...t.map(e=>J(`tspan`,e.props,e.props.innerHTML))),s=r?`url(#text-fill-grad-${e.id})`:e.fill,c=r?t:ee,l=J(`text`,Object.assign(Object.assign({},n),{fill:s}),...c.map(e=>J(`tspan`,e.props,e.props.innerHTML)));return J(`g`,{},te,M.length>0?J(`defs`,{},...M):null,o,l)}return J(`g`,{},te,M.length>0?J(`defs`,{},...M):null,J(`text`,{fill:r?`url(#text-fill-grad-${e.id})`:e.fill,y:T,"font-size":b+`px`,"text-anchor":E,"font-family":e.fontFamily,"font-style":e.fontStyle,"font-weight":e.fontWeight,"text-decoration":e.textDecoration,"letter-spacing":e.letterSpacing*b+`px`,"stroke-width":e.strokeWidth||void 0,stroke:e.strokeWidth?e.stroke:void 0,"paint-order":e.strokeWidth?`stroke fill`:void 0},...ee))},line:async({element:e,page:t,store:n})=>J(`g`,{},J(`line`,{x1:0,y1:e.height/2,x2:e.width,y2:e.height/2,stroke:e.color,"stroke-width":e.height,"stroke-dasharray":e.dash&&e.dash.length?e.dash.map(t=>t*e.height).join(` `):void 0}),J(`g`,{transform:`translate(0 ${e.height/2})`},eC({element:e,type:e.startHead})),J(`g`,{transform:`translate(${e.width} ${e.height/2}) rotate(180)`},eC({element:e,type:e.endHead}))),figure:async({element:e,page:t,store:n,elementHook:r})=>{let i=function(e){let t=e.replace(/<svg[^>]*>/,``);return t=t.replace(/<\/svg>/,``),t}(Vy(e)),a=[];if(e.strokeWidth&&sy(e.stroke)){let t=`figure-stroke-grad-${e.id}`,n=ZS(e.stroke,t);if(n){a.push(n);let r=e.stroke.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);i=i.replace(RegExp(`stroke="${r}"`,`g`),`stroke="url(#${t})"`)}}if(sy(e.fill)){let t=`figure-fill-grad-${e.id}`,n=ZS(e.fill,t);if(n){a.push(n);let r=e.fill.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);i=i.replace(RegExp(`fill="${r}"`,`g`),`fill="url(#${t})"`)}}if(a.length>0){let t=J(`g`,{},J(`defs`,{},...a),J(`g`,{innerHTML:i}));return r&&r({dom:t,element:e})||t}let o=J(`g`,{innerHTML:i});return r&&r({dom:o,element:e})||o},group:async({element:e,page:t,store:n,elementHook:r})=>{let i=J(`g`,{style:{"transform-origin":`top left`}},...await Promise.all(e.children.map(e=>nC({element:e,page:t,store:n,elementHook:r}))));return r&&r({dom:i,element:e})||i},gif:$S,table:async({element:e})=>{e.rows;let t=e.cols,n=e.colWidths,r=e.rowHeights,i=[`fontSize`,`fontFamily`,`fontWeight`,`fontStyle`,`textDecoration`,`textTransform`,`fill`,`align`,`verticalAlign`,`lineHeight`,`letterSpacing`,`strokeWidth`,`stroke`,`cellBackground`,`cellPadding`],a=(e.cells||[]).map((n,r)=>{let a=Object.assign(Object.assign({},n),{row:Math.floor(r/t),col:r%t});for(let t of i)a[t]===void 0&&(a[t]=e[t]);return a}),o=[],s=(t,i,a,o)=>{let s=0;for(let t=0;t<i;t++)s+=n[t]*e.width;let c=0;for(let n=0;n<t;n++)c+=r[n]*e.height;let l=0;for(let t=i;t<i+o;t++)l+=(n[t]||0)*e.width;let u=0;for(let n=t;n<t+a;n++)u+=(r[n]||0)*e.height;return{x:s,y:c,width:l,height:u}};for(let e of a)if(!e.mergedInto&&e.cellBackground&&e.cellBackground!==`transparent`){s(e.row,e.col,e.colSpan||1,e.colSpan||1);let{x:t,y:n,width:r,height:i}=s(e.row,e.col,e.rowSpan||1,e.colSpan||1);o.push(J(`rect`,{x:t,y:n,width:r,height:i,fill:e.cellBackground}))}let c=(e,t)=>e===`dashed`?`${4*t},${2*t}`:e===`dotted`?`${t},${t}`:void 0,l=(t,n)=>{let r=t.borders?.[n];return{width:r?.width??e.borderWidth,style:r?.style??e.borderStyle??`solid`,color:r?.color??e.borderColor}};for(let e of a){if(e.mergedInto)continue;let t=s(e.row,e.col,e.rowSpan||1,e.colSpan||1);if(e.row===0){let n=l(e,`top`);n.style!==`none`&&n.width>0&&o.push(J(`line`,{x1:t.x,y1:t.y+n.width/2,x2:t.x+t.width,y2:t.y+n.width/2,stroke:n.color,"stroke-width":n.width,"stroke-dasharray":c(n.style,n.width)}))}if(e.col===0){let n=l(e,`left`);n.style!==`none`&&n.width>0&&o.push(J(`line`,{x1:t.x+n.width/2,y1:t.y,x2:t.x+n.width/2,y2:t.y+t.height,stroke:n.color,"stroke-width":n.width,"stroke-dasharray":c(n.style,n.width)}))}{let n=l(e,`bottom`);n.style!==`none`&&n.width>0&&o.push(J(`line`,{x1:t.x,y1:t.y+t.height-n.width/2,x2:t.x+t.width,y2:t.y+t.height-n.width/2,stroke:n.color,"stroke-width":n.width,"stroke-dasharray":c(n.style,n.width)}))}{let n=l(e,`right`);n.style!==`none`&&n.width>0&&o.push(J(`line`,{x1:t.x+t.width-n.width/2,y1:t.y,x2:t.x+t.width-n.width/2,y2:t.y+t.height,stroke:n.color,"stroke-width":n.width,"stroke-dasharray":c(n.style,n.width)}))}}for(let t of a){if(t.mergedInto)continue;let i=Sv(t.text||``);if(!i)continue;t.textTransform===`uppercase`&&(i=i.toUpperCase());let a=t.cellPadding||4,s=0;for(let r=0;r<t.col;r++)s+=n[r]*e.width;let c=0;for(let n=0;n<t.row;n++)c+=r[n]*e.height;let l=n[t.col]*e.width,u=r[t.row]*e.height,d=t.fontSize||12,f=t.align||`left`,p=s+a,m=`start`;f===`center`?(p=s+l/2,m=`middle`):f===`right`&&(p=s+l-a,m=`end`);let h=c+a+d,g=t.verticalAlign||`top`;g===`middle`?h=c+u/2+d/3:g===`bottom`&&(h=c+u-a),o.push(J(`text`,{x:p,y:h,"font-size":d,"font-family":t.fontFamily||`Roboto`,"font-weight":t.fontWeight||`normal`,"font-style":t.fontStyle||`normal`,fill:t.fill||`black`,"text-anchor":m,"text-decoration":t.textDecoration||`none`,"letter-spacing":t.letterSpacing?t.letterSpacing*d+`px`:void 0},wx(i)))}return J(`g`,{},...o)}};async function nC({element:e,page:t,store:n,elementHook:r}){var i;let a=await tC[e.type];a||(a=()=>J(`g`,{}),console.error(`SVG export does not support ${e.type} type...`));let o=await a({element:e,page:t,store:n}),s=[],c=[];if(e.blurEnabled&&s.push(`blur(${e.blurRadius/2}px)`),e.brightnessEnabled&&s.push(`brightness(${100*e.brightness+100}%)`),e.sepiaEnabled&&s.push(`sepia()`),e.grayscaleEnabled&&s.push(`grayscale()`),e.shadowEnabled&&s.push(`drop-shadow(${e.shadowOffsetX}px ${e.shadowOffsetY}px ${e.shadowBlur}px ${e.shadowColor})`),e.filters)for(let[t,n]of Object.entries(e.filters)){let e=Gy(Wy[t],n.intensity);if(e&&(s.push(e.filter),e.html)){let t=e.html.replace(/<svg([^>]*)>/,`<g$1>`).replace(/<\/svg>/,`</g>`);c.push(t)}}let l=J(`g`,{className:`element`,id:e.id,transform:e.type===`group`?void 0:`translate(${e.x}, ${e.y}) rotate(${e.rotation})`,display:(i=e.visible)==null||i?void 0:`none`,opacity:e.opacity,style:{"transform-origin":`top left`,filter:s.join(` `)}},o,...c);return r&&r({dom:l,element:e})||l}async function rC(e){try{let t=await fetch(e),n=t.headers.get(`content-type`)||`font/ttf`,r=await t.arrayBuffer();return`data:${n};base64,${typeof Buffer<`u`?Buffer.from(r).toString(`base64`):function(e){let t=new Uint8Array(e),n=``;for(let e=0;e<t.length;e+=32768){let r=t.subarray(e,e+32768);n+=String.fromCharCode(...r)}if(typeof btoa<`u`)return btoa(n);if(typeof Buffer<`u`)return Buffer.from(t).toString(`base64`);throw Error(`No base64 encoder available in this environment`)}(r)}`}catch(t){return console.error(`Error embedding font:`,t),e}}async function iC({json:e,elementHook:t,fontEmbedding:n=`inline`}){let r=[];XS({children:e.pages},e=>{if((e.type===`text`||e.type===`tablecell`||e.type===`table`)&&(e.fontFamily&&r.indexOf(e.fontFamily)===-1&&r.push(e.fontFamily),e.text))for(let t of _v(e.text))r.indexOf(t)===-1&&r.push(t)});let i=n===`inline`?await async function(e,t){return await Promise.all(e.map(async e=>{if(e===`Arial`)return null;let n=t.find(t=>t.fontFamily===e);if(n){let t=n.styles||(n.url?[{src:`url("${n.url}")`,fontStyle:`normal`,fontWeight:`normal`}]:[]);return J(`style`,{},(await Promise.all(t.map(async t=>{let r=await rC(t.src?.match(/url\("?(.*?)"?\)/)?.[1]||n.url);return`@font-face {\n font-family: '${e}';\n font-style: ${t.fontStyle||`normal`};\n font-weight: ${t.fontWeight||`normal`};\n src: url(${r});\n}`}))).join(`
|
|
211
|
+
`))}{let t=`https://fonts.googleapis.com/css?family=${encodeURIComponent(e)}:bi,normal,i,b`;try{let n=await(await fetch(t)).text(),r=(n.match(/url\((.*?)\)/g)?.map(e=>e.replace(/url\((.*?)\)/,`$1`)))?.filter(e=>e.startsWith(`https`));if(!r?.length)throw Error(`No font URLs found`);return J(`style`,{},(await Promise.all(r.map(async t=>{let r=await rC(t),i=(n.match(/@font-face\s*\{[^}]*?\}/g)||[]).find(e=>e.includes(t))||``,a=i.match(/font-style:\s*(.*?)[;\s}]/),o=i.match(/font-weight:\s*(.*?)[;\s}]/);return`@font-face {\n font-family: '${e}';\n font-style: ${a?a[1].trim():`normal`};\n font-weight: ${o?o[1].trim():`normal`};\n src: url(${r});\n}`}))).join(`
|
|
212
|
+
`))}catch(e){return console.error(`Error embedding Google Font:`,e),J(`defs`,{},J(`style`,{type:`text/css`,innerHTML:`@import url('${t}');`.replace(/&/g,`&`)}))}}}))}(r,e.fonts):[],a=await Promise.all(e.pages.map(n=>async function({page:e,store:t,elementHook:n}){let r=await Promise.all(e.children.map(r=>nC({element:r,page:e,store:t,elementHook:n}))),i=e.background.indexOf(`url`)>=0||e.background.indexOf(`http`)>=0||e.background.indexOf(`.jpg`)>=0||e.background.indexOf(`.png`)>=0||e.background.indexOf(`.jpeg`)>=0,a;if(i){let n=await Ey(e.background);a=await Dy(e.background,Object.assign({width:t.width,height:t.height,x:0,y:0},Oy({width:t.width,height:t.height},{width:n.width,height:n.height})))}return J(`g`,{className:`page`,style:{}},i?J(`image`,{"xlink:href":a,x:0,y:0,width:t.width,height:t.height,preserveAspectRatio:`none`}):J(`rect`,{x:0,y:0,width:t.width,height:t.height,fill:i?void 0:e.background}),...r)}({page:n,store:e,elementHook:t})));return J(`svg`,{xmlns:`http://www.w3.org/2000/svg`,"xmlns:xlink":`http://www.w3.org/1999/xlink`,viewBox:`0 0 ${e.width} ${e.height}`,width:e.width,height:e.height},...i,...a)}function aC(e){return String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var oC=({dom:e,nestLevel:t=0})=>{if(typeof e==`string`)return e;if(!e)return``;let n=e.props,{innerHTML:r}=n,i=YS(n,[`innerHTML`]),a=Object.keys(i).map(e=>((e,t)=>typeof t==`object`?`${e}="${Object.keys(t).map(e=>`${e}:${t[e]};`).join(` `)}"`:t==null||t===``?``:`${e}="${aC(String(t))}"`)(e,i[e])).filter(e=>e&&e.trim().length>0).join(` `),o=` `.repeat(t);return`${o}<${e.type}${a?` `+a:``}>${r||`
|
|
213
|
+
`+e.children.map(e=>oC({dom:e,nestLevel:t+1})).join(``)}${o}</${e.type}>\n`};async function sC({json:e,elementHook:t,fontEmbedding:n=`inline`}){return oC({dom:await iC({json:e,elementHook:t,fontEmbedding:n})})}var cC=K.model(`Audio`,{id:K.identifier,src:``,duration:0,startTime:0,endTime:1,volume:1,delay:0,custom:K.frozen()}).views(e=>({get visibleDuration(){return(e.endTime-e.startTime)*e.duration}})).actions(e=>({toJSON:()=>Object.assign({},Mp(e))})).actions(e=>({set(t){Object.assign(e,t)}})),lC=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n};vp(`ignore`);var uC=K.model(`Font`,{fontFamily:K.string,url:K.optional(K.string,``),styles:K.frozen()}).preProcessSnapshot(e=>Object.assign(Object.assign({},e),{fontFamily:e.fontFamily||e.name})),dC={ADMIN:`admin`,VIEWER:`viewer`},fC=K.model(`Store`,{role:``,pages:K.array(eb),fonts:K.array(uC),audios:K.array(cC),width:1080,height:1080,currentTime:0,isPlaying:!1,scale:1,scaleToFit:1,unit:K.optional(K.enumeration(`UnitType`,[`pt`,`mm`,`cm`,`in`,`px`]),`px`),dpi:72,schemaVersion:3,bleedVisible:!1,rulesVisible:!1,distanceGuidesVisible:!1,openedSidePanel:``,previousOpenedSidePanel:``,custom:K.frozen(),tool:K.optional(K.enumeration(`Tool`,[`selection`,`draw`,`pan`,`text`,`eraser`]),`selection`),toolOptions:K.optional(K.model({brushType:K.optional(K.enumeration(`BrushType`,[`brush`,`highlighter`]),`brush`),strokeWidth:K.optional(K.number,5),stroke:K.optional(K.string,`#000000`),opacity:K.optional(K.number,1)}),{}),selectedElementsIds:K.array(K.string),animatedElementsIds:K.array(K.string),history:K.optional(o_,{targetPath:`../pages`}),_elementsPixelRatio:Math.min(2,typeof window<`u`&&window.devicePixelRatio||1),_activePageId:``,_selectedPagesIds:K.array(K.string),_forceShowCredit:!1,_validated:!1}).views(e=>{let t=Jt(()=>{let t={};return zb({children:e.pages},e=>(t[e.id]=e,!1)),t},{keepAlive:!0});return{get _idsMap(){return t.get()}}}).views(e=>({get _bleedVisible(){return console.warn(`store._bleedVisible is deprecated. Please use store.bleedVisible instead.`),e.bleedVisible},get selectedElements(){return e.selectedElementsIds.map(t=>e._idsMap[t]).filter(e=>!!e)},get children(){return e.pages},get selectedShapes(){let e=[];return Rb({children:this.selectedElements},t=>{t.type!==`group`&&e.push(t)}),e},get activePage(){return e.pages.slice().find(t=>t.id===e._activePageId)||(e.pages.length?e.pages[0]:null)},get selectedPages(){return e._selectedPagesIds.map(t=>e.pages.find(e=>e.id===t))},get duration(){let t=0;return e.pages.forEach(e=>{t+=e.duration}),t},get _hasCroppedImages(){return this.find(e=>e.type===`image`&&e._cropModeEnabled)},find(t){let n;return zb({children:e.pages},e=>{if(!n&&t(e))return n=e,!0}),n},getElementById:t=>e._idsMap[t]})).actions(e=>{let t=0,n=null,r=!1,i={afterCreate(){e.history.canUndo},setCurrentTime(t){e.currentTime=t},_togglePlaying(t=!e.isPlaying){e.isPlaying=t},play({animatedElementsIds:a=[],startTime:o=0,currentTime:s=0,endTime:c=e.duration,repeat:l=!1}={}){s&&(console.warn(`currentTime property of store.play() is deprecated. Please use startTime instead.`),o=s),e.animatedElementsIds=Up(a),e.currentTime=o,e.isPlaying=!0,t=Date.now(),n=c,r=l,requestAnimationFrame(()=>i.seek())},checkActivePage(){let t=0;for(let n of e.pages){if(e.currentTime>=n.startTime&&e.currentTime<n.startTime+n.duration){i.selectPage(n.id);break}t+=n.duration}},seek(){if(!e.isPlaying)return;let a=Date.now(),o=a-t;t=a,e.currentTime+=o,i.checkActivePage();let s=n||e.duration;e.isPlaying&&e.currentTime<s?requestAnimationFrame(()=>i.seek()):e.isPlaying&&r?(e.currentTime=0,requestAnimationFrame(()=>i.seek())):i.stop()},stop(){e.isPlaying=!1,e.currentTime=0,e.animatedElementsIds=Up([]),i.checkActivePage()},__(){e._validated||=(V_(e._forceShowCredit),!0)},set(t){Object.assign(e,t)},setUnit({unit:t,dpi:n}){e.unit=t||e.unit,e.dpi=n||e.dpi},setRole(t){e.role=t},setTool(t){e.tool=t},setToolOptions(t){Object.assign(e.toolOptions,t)},addPage(t){let n=eb.create(Object.assign({id:c_(10)},t));return e.pages.push(n),e._activePageId=n.id,n},selectPage(t){e._activePageId=t,e._selectedPagesIds.length===1&&(e._selectedPagesIds=Up([t]))},selectPages(t){e._selectedPagesIds=Up(t),e._selectedPagesIds.length===1&&(e._activePageId=e._selectedPagesIds[0])},selectElements(t){let n=t.map(t=>e.getElementById(t)).filter(e=>!!e);n.sort((e,t)=>(e.parent?.children.indexOf(e)??0)-(t.parent?.children.indexOf(t)??0)),e.selectedElementsIds=Up(n.map(e=>e.id))},toggleBleed(t){e.bleedVisible=t??!e.bleedVisible},toggleRulers(t){e.rulesVisible=t??!e.rulesVisible},toggleDistanceGuides(t){e.distanceGuidesVisible=t??!e.distanceGuidesVisible},openSidePanel(t){e.openedSidePanel!==t&&(e.previousOpenedSidePanel=e.openedSidePanel,e.openedSidePanel=t)},restoreSidePanel(){let t=e.previousOpenedSidePanel;t&&t!==e.openedSidePanel?e.openedSidePanel=t:e.openedSidePanel=`photos`},setScale(t){e.scale=t},_setScaleToFit(t){e.scaleToFit=t},setElementsPixelRatio(t){e._elementsPixelRatio=t},setSize(t,n,r){e.pages.forEach(e=>{e.setSize({width:t,height:n,useMagic:r,softChange:!0})}),e.width=t,e.height=n},setPageZIndex(t,n){let r=e.pages.find(e=>e.id===t);r&&(Bp(r),e.pages.remove(r),e.pages.splice(n,0,r))},deletePages(t){let n=e.pages.indexOf(e.activePage);t.forEach(t=>{Vp(e.pages.find(e=>e.id===t))});let r=Math.min(e.pages.length-1,n),i=e.pages[r];i&&(e._activePageId=i.id),e.selectedElementsIds=Up(e.selectedElementsIds.filter(t=>e.getElementById(t)))},groupElements(t,n={}){let r=t.map(t=>e.getElementById(t)).filter(e=>!!e);if(!r.length)return;let i=r[0].parent;if(!i)return;if(!r.every(e=>e.parent===i)){console.warn(`store.groupElements: refusing to group elements that do not share a parent. Pass ids whose elements all live under the same page or the same group.`);return}r.forEach(e=>Bp(e));let a=i.children.reduce((e,t)=>{if(t.type===`group`){let n=t.name?.match(/group-(\d+)/);if(n){let t=parseInt(n[1],10);return Math.max(e,t)}}return e},0),o=Object.assign({id:c_(10),name:`group-${a+1}`,children:r,type:`group`},n);return i.children.push(o),e.selectedElementsIds=Up([o.id]),i.children.find(e=>e.id===o.id)},ungroupElements(t){let n=t.map(t=>e.getElementById(t)),r=[];n.forEach(e=>{if(e&&e.type===`group`){let t=e.parent;if(!t)return;let n=t.children.indexOf(e);e.children.forEach(e=>{r.push(e.id)}),e.children.slice().forEach(e=>{Bp(e),t.children.push(e)}),t.children.splice(n,1)}}),e.selectedElementsIds=Up(r)},deleteElements(t){let n=[];e.find(e=>(t.includes(e.id)&&n.push(e),!1)),n.forEach(e=>{Vp(e)}),e.selectedElementsIds=Up(e.selectedElementsIds.filter(t=>e.getElementById(t)))},on(t,n){if(t===`change`){let t=i.toJSON();return kp(e,e=>{let r=i.toJSON();!a_(t,r)&&(t=r,n(r))})}},async _toCanvas({pixelRatio:t,ignoreBackground:n,pageId:r,mimeType:a,includeBleed:o,_skipTimeout:s,quickMode:c=!1,_exportCanvases:l}={}){let u=t||1;r||=e.pages[0]?.id;let d=e.pages.find(e=>e.id===r);if(!d)throw Error(`No page for export with id ${r}`);let f=e._elementsPixelRatio;u>e._elementsPixelRatio&&i.setElementsPixelRatio(u),c?d?.set({_forceMount:!0}):d?.set({_exporting:!0});let p=await iy(()=>{let e=W.stages.filter(e=>e.getAttr(`pageId`)===r);return e.length===0?null:e});if(!p)throw d?.set({_forceMount:!1,_exporting:!1}),i.setElementsPixelRatio(f),Error(`Export is failed. Can not find stage for page ${r}. Looks like <Workspace /> component is not mounted, but it is required in order to process the export.`);p.length>1&&console.error(`Polotno error: Detected several canvas elements for page "${r}" in the document. This is not supported and will lead to incorrect export. Make sure to use unique ids for all pages and make sure you unmount <Workspace /> when it is not needed.`);let m=p[0];await i.waitLoading({_skipTimeout:s});let h=m.findOne(`.page-container`);if(!h)throw i.setElementsPixelRatio(f),d?.set({_forceMount:!1,_exporting:!1}),Error(`Export is failed. Canvas was unmounted.`);let g=m.position();m.position({x:0,y:0}),m.find(`Transformer`).forEach(e=>{e.setAttr(`oldVisible`,e.visible()),e.visible(!1)}),h.find(`.page-background`).forEach(e=>e.shadowEnabled(!1)),h.find(`.page-background`).forEach(e=>e.strokeEnabled(!1)),h.find(`.highlighter`).forEach(e=>e.visible(!1));let _=h.findOne(`.page-background-group`),v=_.clip();_.clip({x:null,y:null,width:null,height:null});let y=h.findOne(`.elements-container`),b=y.clip();y.clip({x:null,y:null,width:null,height:null});let x=h.find(e=>!e.visible()&&e.getAttr(`editModeEnabled`)&&!e.getAttr(`hideInExport`));x.forEach(e=>{e.setAttr(`oldVisible`,e.visible()),e.show()});let S=h.find(e=>e.getAttr(`hideInExport`));S.forEach(e=>{e.setAttr(`oldVisible`,e.visible()),e.hide()}),n&&h.find(`.page-background`).forEach(e=>e.hide());let C=o?d.bleed:0,w=C;!e.bleedVisible&&o||(e.bleedVisible||o?e.bleedVisible&&o?w=0:e.bleedVisible&&!o&&(w=-d.bleed):w=0);let T=d.computedWidth+2*C,E=d.computedHeight+2*C,D=h.scale();h.scale({x:1,y:1});let O=Qv(h,{x:h.x()-w,y:h.y()-w,width:T,height:E,pixelRatio:u,sceneCanvas:l?.sceneCanvas,bufferCanvas:l?.bufferCanvas});h.scale(D);let k=O._canvas;if(a===`image/jpeg`){let e=k.getContext(`2d`);e.save(),e.globalCompositeOperation=`destination-over`,e.fillStyle=`white`,e.fillRect(0,0,k.width,k.height),e.restore()}return n&&h.find(`.page-background`).forEach(e=>e.show()),S.forEach(e=>{e.visible(e.getAttr(`oldVisible`))}),x.forEach(e=>{e.visible(e.getAttr(`oldVisible`))}),h.find(`.page-background`).forEach(e=>e.shadowEnabled(!0)),h.find(`.page-background`).forEach(e=>e.strokeEnabled(!0)),m.find(`Transformer`).forEach(e=>{e.visible(e.getAttr(`oldVisible`))}),h.find(`.highlighter`).forEach(e=>e.visible(!0)),_.clip(v),y.clip(b),m.position(g),d?.set({_exporting:!1,_forceMount:!1}),await Promise.resolve(),i.setElementsPixelRatio(f),k},async toDataURL(t={}){var{mimeType:n,quality:r,dpi:a,dpiMetadata:o=`auto`}=t,s=lC(t,[`mimeType`,`quality`,`dpi`,`dpiMetadata`]);let c=await i._toCanvas(Object.assign({mimeType:n},s)),l=n||`image/png`,u=c.toDataURL(l,r);W.Util.releaseCanvas(c);let d=a??e.dpi;return l!==`image/png`&&l!==`image/jpeg`||o===`never`||o===`auto`&&d===72?u:Xv(u,l,d)},async toBlob(e={}){var{mimeType:t,quality:n}=e,r=lC(e,[`mimeType`,`quality`]);let a=await i._toCanvas(Object.assign({mimeType:t},r)),o=await new Promise(e=>{a.toBlob(e,t,n)});return W.Util.releaseCanvas(a),o},async saveAsImage(e={}){var{fileName:t}=e,n=lC(e,[`fileName`]);let r=(n.mimeType||`image/png`).split(`/`)[1];l_(await i.toDataURL(n),t||`polotno.`+r)},async _toPDF(t){let n=t.dpi||e.dpi,r=t.parallel||1,a=t.unit||(e.unit===`px`?`mm`:e.unit),o=t.pixelRatio||1,s=t.pageIds||(t.pageId?[t.pageId]:e.pages.map(e=>e.id)),c=e.pages.filter(e=>s.includes(e.id)),l=await d_(),u=e=>ey({px:e,unit:a,dpi:n}),d=t.cropMarkSize||0,f=u(d),p=c[0]||{},m=t.includeBleed?p.bleed:0,h=u(p.computedWidth+2*m+2*f),g=u(p.computedHeight+2*m+2*f);var _=new l({unit:a,orientation:h>g?`landscape`:`portrait`,format:[h,g],compress:!0,putOnlyUsedFonts:!0});_.deletePage(1);let v=((e,t)=>{let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n})(c,r),y=0;for(let e of v){let n=e.map(async e=>{let n=t.includeBleed?e.bleed:0,r=e.computedWidth+2*n+2*d,a=e.computedHeight+2*n+2*d,c=u(r),l=u(a),f=0,p=o;for(;f<10;){f+=1;let n=await i.toDataURL(Object.assign(Object.assign({},t),{pageId:e.id,pixelRatio:p,dpiMetadata:`never`}));if(n.length>20)return p!==o&&console.error(`Polotno can not export PDF with current settings. Quality is automatically reduced. pixelRatio was reduced to ${parseFloat(p.toFixed(3))}.`),t.onProgress&&t.onProgress(++y/s.length*.9),{url:n,width:c,height:l,widthPx:r,heightPx:a};p*=.8}});(await Promise.all(n)).filter(e=>e!==void 0).forEach(({url:e,width:t,height:n,widthPx:r,heightPx:i})=>{_.addPage([t,n],t>n?`landscape`:`portrait`);let o=_.getCurrentPageInfo();var s;switch(a){case`pt`:s=1;break;case`mm`:s=72/25.4;break;case`cm`:s=72/2.54;break;case`in`:s=72;break;case`px`:s=.75;break;default:throw`Invalid unit: `+a}if(o.pageContext.cropBox={bottomLeftX:0,bottomLeftY:0,topRightX:t*s,topRightY:n*s},o.pageContext.artBox={bottomLeftX:u(d+m)*s,bottomLeftY:u(d+m)*s,topRightX:u(r-d-m)*s,topRightY:u(i-d-m)*s},o.pageContext.bleedBox={bottomLeftX:u(d+m)*s,bottomLeftY:u(d+m)*s,topRightX:u(r-d-m)*s,topRightY:u(i-d-m)*s},f){_.setLineWidth(u(1));let e=f+u(m);_.line(e,0,e,f),_.line(0,e,f,e),_.line(t-e,0,t-e,f),_.line(t,e,t-f,e),_.line(0,n-e,f,n-e),_.line(e,n,e,n-f),_.line(t,n-e,t-f,n-e),_.line(t-e,n,t-e,n-f)}_.addImage(e,f,f,t-2*f,n-2*f,void 0,`FAST`)})}return _},toPDFDataURL:async e=>(await i._toPDF(Object.assign({mimeType:`image/jpeg`},e))).output(`datauristring`),async toGIFDataURL(t={}){let n=t.pixelRatio||1,r=t.pageIds||(t.pageId?[t.pageId]:e.pages.map(e=>e.id)),a=e.pages.filter(e=>r.includes(e.id));if(!a.length)throw Error(`No pages found for GIF export`);let o=a[0],s=await p_({width:o.computedWidth*n,height:o.computedHeight*n}),c=1e3/(t.fps||10);for(let t of a){let r=Math.max(1,Math.floor(t.duration/c));for(let a=0;a<r;a++){let r=t.startTime+a*c||1;i.setCurrentTime(r);for(let n of e.pages)n.set({_rendering:n.id===t.id});let o=await i._toCanvas({pixelRatio:n,pageId:t.id,_skipTimeout:!0});s.addFrame(o.getContext(`2d`),{delay:c,copy:!0})}}for(let t of e.pages)t.set({_rendering:!1});return i.stop(),s.render(),new Promise(e=>{s.on(`finished`,function(t){(function(e,t){var n=new FileReader;n.onload=function(e){t(e.target.result)},n.readAsDataURL(e)})(t,e)})})},async saveAsGIF(e={}){var{fileName:t}=e,n=lC(e,[`fileName`]);l_(await i.toGIFDataURL(n),t||`polotno.gif`)},async toHTML({elementHook:e}={}){return KS({json:i.toJSON(),elementHook:e})},async saveAsHTML({fileName:e,elementHook:t}={}){let n=await i.toHTML({elementHook:t});l_(`data:text/html;base64,`+window.btoa(unescape(encodeURIComponent(n))),e||`polotno.html`)},async toSVG({elementHook:e,pageId:t,fontEmbedding:n=`inline`}={fontEmbedding:`inline`}){let r=i.toJSON();t||=r.pages[0]?.id;let a=r.pages.find(e=>e.id===t);return sC({json:Object.assign(Object.assign({},r),{pages:a?[a]:[]}),elementHook:e,fontEmbedding:n})},async saveAsSVG({fileName:e,elementHook:t,pageId:n,fontEmbedding:r=`inline`}={}){let a=await i.toSVG({elementHook:t,pageId:n,fontEmbedding:r});l_(`data:text/svg;base64,`+window.btoa(unescape(encodeURIComponent(a))),e||`polotno.svg`)},async saveAsPDF(e={}){var{fileName:t}=e,n=lC(e,[`fileName`]);(await i._toPDF(Object.assign({mimeType:`image/jpeg`},n))).save(t||`polotno.pdf`)},async waitLoading({_skipTimeout:e=!1}={}){e||await new Promise(e=>setTimeout(e,50)),await tv()},toJSON:()=>({width:e.width,height:e.height,fonts:Mp(e.fonts),pages:Mp(e.pages),audios:Mp(e.audios),unit:e.unit,dpi:e.dpi,custom:e.custom,schemaVersion:e.schemaVersion}),loadJSON(t,n=!1){var r,i;let a=typeof n==`boolean`?n:(r=n?.keepHistory)!=null&&r,o=typeof n!=`boolean`&&(i=n?.modernizeTextBackground)!=null&&i,s=JSON.parse(JSON.stringify(t)),c=s.schemaVersion||0;c<1&&(h_.htmlRenderEnabled||h_.renderTagTextEnabled)&&zb({children:s.pages},e=>{e.type===`text`&&(e.letterSpacing=e.letterSpacing*16/e.fontSize)}),c<2&&zb({children:s.pages},e=>{e.filters&&Object.keys(e.filters).forEach(t=>{if([`warm`,`cold`,`natural`].includes(t))return;let n=e.filters[t];n&&typeof n.intensity==`number`&&(n.intensity/=100)})}),c<3&&(h_.htmlRenderEnabled||h_.renderTagTextEnabled)&&!o&&zb({children:s.pages},e=>{e.type===`text`&&e.backgroundEnabled&&(e.legacyBackground=!0)}),delete s.schemaVersion;let l=e.activePage?e.pages.indexOf(e.activePage):0;s._activePageId=(s.pages[l]||s.pages[0])?.id;let u=Object.assign({},Mp(e));Object.assign(u,s),u.history=a?Mp(e.history):{history:[],undoIdx:-1,targetPath:``},jp(e,u)},clear({keepHistory:t=!1}={}){let n=e.pages.map(e=>e.id);i.deletePages(n),e.custom=null,t||e.history.clear()},addFont(t){i.removeFont(t.fontFamily),e.fonts.push(t)},removeFont(t){e.fonts.filter(e=>e.fontFamily===t).forEach(e=>Vp(e))},addAudio(t){let n=cC.create(Object.assign({id:c_(10)},t));e.audios.push(n)},removeAudio(t){let n=e.audios.find(e=>e.id===t);n&&e.audios.remove(n)},async loadFont(t,n,r,i){let a=e.fonts.find(e=>e.fontFamily===t)||Ev.find(e=>e.fontFamily===t),o=[{fontStyle:`normal`,fontWeight:`normal`},{fontStyle:`normal`,fontWeight:`bold`}];return a?(a.styles&&(o=a.styles.map(e=>({fontStyle:e.fontStyle||`normal`,fontWeight:e.fontWeight||`normal`}))),Gv(a)):Hv(t),n&&r&&!o.some(e=>e.fontStyle===n&&e.fontWeight===r)&&o.push({fontStyle:n,fontWeight:r}),Promise.all(o.map(e=>Lv(t,e.fontStyle,e.fontWeight,i)))},validate:e=>fC.validate(e,[{path:``,type:fC}]).map(e=>({path:`store`+e.context.map(e=>e.path).join(`.`),message:e.message}))};return i});function pC({key:e,showCredit:t}={key:``,showCredit:!1}){return P_(e),fC.create({_forceShowCredit:t})}var mC=(e,t=100,n=!1,r)=>{let i=b.useRef(r??e),[,a]=b.useReducer(e=>e+1,0),o=b.useCallback(e=>{i.current!==e&&(i.current=e,a())},[i]),s=b.useRef(null);return e===n&&(s.current&&=(clearTimeout(s.current),null),i.current=n),b.useEffect(()=>(s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o(e),s.current=null},t),()=>{s.current&&clearTimeout(s.current)}),[e,t,n]),[i.current,o]};function hC(){return document.createElement(`canvas`)}var gC=e=>e.indexOf(`data:image/svg+xml`)>=0||e.indexOf(`.svg`)>=0,_C=e=>{let[t,n]=b.useState(e);return b.useEffect(()=>{(async()=>{let r=await async function(e){return gC(e)?Sy(Cy(await xy(e))):e}(e);r!==t&&n(r)})()},[e]),t};function vC(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}var yC=(e,t)=>t.width<5||t.height<5?e:t,bC={keepRatio:!1,rotateEnabled:!1,boundBoxFunc:yC},xC={enabledAnchors:[`top-left`,`top-right`,`bottom-left`,`bottom-right`],rotateEnabled:!1,borderEnabled:!1,boundBoxFunc:yC},SC=(e,t,n)=>Math.max(t,Math.min(n,e)),CC=(e,t,n,r,i=0,a=!1,o=!0)=>{let s=Math.floor(SC(e.a.width*r,1,1e4)),c=Math.floor(SC(e.a.height*r,1,1e4)),l=Math.min(i*r,s/2,c/2),u=Math.max(e.a.width/n.width,e.a.height/n.height)*r,d=e.page?._exportingOrRendering&&h_.imageDownScalingEnabled&&u<1&&!a,f=n.x===0&&n.y===0&&n.width===t?.width&&n.height===t?.height,p=b.useMemo(()=>{if(t&&t.width&&t.height)return f&&l===0&&!d?void 0:hC()},[t,l,d,f]);return b.useLayoutEffect(()=>{if(!p||!t)return;Zv(p,s,c);let e=p.getContext(`2d`);if(!e)return;l&&(e.beginPath(),e.moveTo(l,0),e.lineTo(s-l,0),e.arc(s-l,l,l,3*Math.PI/2,0,!1),e.lineTo(s,c-l),e.arc(s-l,c-l,l,0,Math.PI/2,!1),e.lineTo(l,c),e.arc(l,c-l,l,Math.PI/2,Math.PI,!1),e.lineTo(0,l),e.arc(l,l,l,Math.PI,3*Math.PI/2,!1),e.clip());let r=d?function(e,t){var n,r;let i=hC();i.width=e.width,i.height=e.height;let a=Math.max(1,Math.floor(i.width*t)),o=Math.max(1,Math.floor(i.height*t));(n=i.getContext(`2d`))==null||n.drawImage(e,0,0,i.width,i.height);let s=function(e,t,n,r,i,a,o){for(var s=new ImageData(t,n),c=new Int32Array(e.data.buffer),l=e.width,u=new Int32Array(s.data.buffer),d=s.width,f=t/a,p=n/o,m=Math.round(1/f),h=Math.round(1/p),g=m*h,_=0;_<s.height;_++)for(var v=0;v<d;v++){for(var y=0+Math.round(v/f)+(0+Math.round(_/p))*l,b=0,x=0,S=0,C=0,w=0;w<h;w++)for(var T=0;T<m;T++){var E=c[y+T+w*l];b+=E<<24>>>24,x+=E<<16>>>24,S+=E<<8>>>24,C+=E>>>24}b=Math.round(b/g),x=Math.round(x/g),S=Math.round(S/g),C=Math.round(C/g),u[v+_*d]=C<<24|S<<16|x<<8|b}return s}(i.getContext(`2d`).getImageData(0,0,i.width,i.height),a,o,0,0,i.width,i.height);return i.width=a,i.height=o,(r=i.getContext(`2d`))==null||r.putImageData(s,0,0),i}(t,u):t,i=d?{x:Math.floor(n.x*u),y:Math.floor(n.y*u),width:Math.floor(n.width*u),height:Math.floor(n.height*u)}:n;e.drawImage(r,i.x,i.y,i.width,i.height,0,0,p.width,p.height)},[p,e.a.width,e.a.height,n.x,n.y,n.width,n.height,i,r,a,e.page?._exportingOrRendering,d]),b.useEffect(()=>()=>{p&&p.nodeName===`CANVAS`&&W.Util.releaseCanvas(p)},[p]),p||t},wC=hC(),TC=wa(({element:e})=>{let t=Math.min(30,e.a.width/4,e.a.height/4),n=b.useRef(null);b.useEffect(()=>{let e=n.current;if(!e)return;let t=new W.Animation(t=>{e.rotate((t?.timeDiff||0)/2)},e.getLayer());return t.start(),()=>{t.stop()}});let{mediaLoadingStyle:r}=up();return(0,S.jsxs)(jf,{x:e.x,y:e.y,rotation:e.rotation,listening:!1,opacity:e.a.opacity,hideInExport:!e.showInExport,children:[(0,S.jsx)(Nf,{width:e.a.width,height:e.a.height,fill:r.fill}),(0,S.jsx)(`Arc`,{ref:n,x:e.a.width/2,y:e.a.height/2,fill:r.textFill,outerRadius:Math.abs(t),innerRadius:Math.max(1,t-5),angle:270})]})}),EC=wa(({element:e})=>{let{mediaErrorStyle:t}=up(),n=Math.max(10,Math.min(30,e.a.width/25));return(0,S.jsxs)(jf,{x:e.x,y:e.y,rotation:e.rotation,listening:!1,opacity:e.a.opacity,hideInExport:!e.showInExport,children:[(0,S.jsx)(Nf,{width:e.a.width,height:e.a.height,fill:t.fill}),(0,S.jsx)(If,{text:`Can not load the image...`,fontSize:n,width:e.a.width,height:e.a.height,align:`center`,fill:t.textFill,verticalAlign:`middle`,padding:5})]})}),DC=Uf.default,OC=(e,t=``,n=``)=>{let r=b.useRef(void 0),i=()=>{var e;(e=r.current)==null||e.call(r),r.current=void 0};b.useEffect(()=>i,[]),b.useLayoutEffect(()=>{let a=`image with id ${n} url: ${t.slice(0,200)}`;e!==`loading`||r.current||(r.current=$_(a)),e!==`loading`&&i(),e===`failed`&&iv(a)},[e])},kC=wa(({element:e,store:t})=>{let n=up(),[r,i]=b.useState(!1),a=b.useRef(null),o=b.useRef(null),s=e.isSelected,[c,l]=(e=>{let[t,n]=b.useReducer(e=>e+1,0),r=b.useRef(`loading`),i=b.useRef(e.src),a=b.useRef(e.src);a.current!==e.src&&(a.current=e.src,r.current=`loading`);let o=b.useMemo(()=>gC(e.src)||e.type===`svg`,[e.src,e.type]);return b.useEffect(()=>{if(!o||!e.src)return;let t=!1;return(async()=>{r.current=`loading`,n();let a=Cy(await xy(e.src)),o;o=e.colorsReplace?Ty(a,e.colorsReplace||new Map):Sy(a),t||(i.current=o,r.current=`loaded`,n())})(),()=>{t=!0}},[e.src,JSON.stringify(e.colorsReplace)]),o?[i.current,r.current]:[e.src,`loaded`]})(e),[u,d]=DC(c,`anonymous`);OC(e.type!==`svg`||l===`loaded`?d:`loading`,e.src,e.id);let f=e.page?._exportingOrRendering?1:Math.max(1,t.scale),p=t._elementsPixelRatio*f,m=(({image:e,status:t,type:n})=>{let r=b.useRef(void 0);return b.useEffect(()=>{r.current=e||r.current},[e]),t!==`failed`||t!==`failed`&&n===`svg`?r.current:void 0})({image:u,status:d,type:e.type}),h=((e,t)=>{let n=_C(e.maskSrc||``),[r,i]=DC(n,`anonymous`);return OC(n?i:`loaded`,n||``,e.id),b.useMemo(()=>{if(!r||!t||!t.width||!t.height)return t;let n=hC();n.width=Math.max(t.width,1),n.height=Math.max(t.height,1);let i=n.getContext(`2d`);if(!i)return t;i.drawImage(t,0,0),i.globalCompositeOperation=`source-in`;let a=function(e,t){let n=t.width/t.height,r,i;return n>=e.width/e.height?(r=e.width,i=e.width/n):(r=e.height*n,i=e.height),{x:(e.width-r)/2,y:(e.height-i)/2,width:r,height:i}}(r,e);return i.drawImage(r,a.x,a.y,a.width,a.height,0,0,t.width,t.height),n},[t,r,e.a.width,e.a.height])})(e,((e,t,n)=>{let r=b.useMemo(()=>{var r,i;let{flipX:a,flipY:o}=e,s=e.type===`svg`||e.src.indexOf(`data:image/svg+xml`)>=0||e.src.indexOf(`.svg`)>=0,c=navigator.userAgent.toLowerCase().indexOf(`firefox`)>-1,l=(/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||c)&&s||e.maskSrc;if(!a&&!o&&!l)return t;if(!t||!t.width||!t.height)return null;let u=hC(),d=1;e.type===`svg`&&(d=Math.max(e.a.width/t.width*n,e.a.height/t.height*n)),Zv(u,Math.max(t.width*d,1),Math.max(t.height*d,1));let f=a?-u.width:0,p=o?-u.height:0;return(r=u.getContext(`2d`))==null||r.scale(a?-1:1,o?-1:1),(i=u.getContext(`2d`))==null||i.drawImage(t,f,p,u.width,u.height),u},[e.maskSrc,e.flipX,e.flipY,t,e.a.width,e.a.height,n]);return b.useEffect(()=>()=>{r&&r.nodeName===`CANVAS`&&W.Util.releaseCanvas(r)},[r]),r})(e,u||m,p))||wC,{cropX:g,cropY:_,cropWidth:v,cropHeight:y}=e.a;d!==`loaded`&&(g=_=0,v=y=1);let x=h.width*v,C=h.height*y,w=e.a.width/e.a.height,T,E,D=x/C,O=e.stretchEnabled;O?(T=x,E=C):w>=D?(T=x,E=x/w):(T=C*w,E=C);let k={x:h.width*g,y:h.height*_,width:T,height:E},ee=e.cornerRadius??0,A=e.page?._exportingOrRendering?1:Math.min(2,t.scale),j=t._elementsPixelRatio*A,te=((e,t,n,r)=>{let[i,a]=DC(_C(e.clipSrc||``),`anonymous`);OC(e.clipSrc?a:`loaded`,e.clipSrc,e.id);let o=b.useMemo(()=>{if(t&&i)return hC()},[t,i]);return b.useLayoutEffect(()=>{var r;if(!i||!t||!t.width||!t.height||!i||!i.width||!i.height||!o)return;let a=hC(),s=Math.max(e.a.width/i.width*n,e.a.height/i.height*n);a.width=Math.max(i.width*s,1),a.height=Math.max(i.height*s,1),(r=a.getContext(`2d`))==null||r.drawImage(i,0,0,a.width,a.height),o.width=Math.max(t.width,1),o.height=Math.max(t.height,1);let c=o.getContext(`2d`);c&&(c.save(),c.drawImage(a,0,0,t.width,t.height),W.Util.releaseCanvas(a),c.globalCompositeOperation=`source-in`,c.drawImage(t,0,0,o.width,o.height),c.restore())},[o,t,i,e.a.width,e.a.height,n,...r]),e.clipSrc&&i?o:t})(e,CC(e,h,k,j,ee,r||e._cropModeEnabled||e.type===`svg`,!0),j,[k,ee,j]),M=Math.max(e.a.width/T,e.a.height/E);b.useEffect(()=>{if(!e._cropModeEnabled)return;let t=a.current?.getStage();function n(t){e._cropModeEnabled&&t.target!==o.current&&e.toggleCropMode(!1)}function r(n){e._cropModeEnabled&&n.target.parentNode!==t?.content&&e.toggleCropMode(!1)}return document.body.addEventListener(`click`,r),t?.on(`click`,n),t?.on(`tap`,n),()=>{document.body.removeEventListener(`click`,r),document.body.removeEventListener(`touchstart`,r),t?.off(`click`,n),t?.off(`click`,n)}},[e._cropModeEnabled]),b.useLayoutEffect(()=>{if(!r&&!e._cropModeEnabled)return Bx(a.current,e),cr(()=>{Bx(a.current,e)},{delay:100})},[te,e.page?._exportingOrRendering,r,v,y,e._cropModeEnabled]),b.useLayoutEffect(()=>{var t;r||e._cropModeEnabled?(t=a.current)==null||t.clearCache():Bx(a.current,e)},[r,e.a.width,e.a.height,e._cropModeEnabled]),b.useEffect(()=>{Bx(a.current,e)},[e.shadowEnabled,e.shadowBlur,e.cornerRadius,e.shadowColor,e.shadowOffsetX,e.shadowOffsetY,e.shadowOpacity]);let ne=b.useRef(null),N=b.useRef(null),P=b.useRef(null);b.useLayoutEffect(()=>{e._cropModeEnabled&&(N.current.nodes([ne.current]),P.current.nodes([o.current]))},[e._cropModeEnabled]);var re=b.useRef(null),ie=b.useRef(0),ae=b.useRef(!1);let F=t=>{t.evt.touches?.length>2&&t.target.stopDrag(),Math.round(t.target.x())>0&&(t.target.x(0),t.target.scaleX(1)),Math.round(t.target.y())>0&&(t.target.y(0),t.target.scaleY(1));let n=t.target.width()*t.target.scaleX(),r=t.target.height()*t.target.scaleY(),i=Math.min(1,T/n),a=Math.min(1,E/r),o=1-i,s=Math.min(o,Math.max(0,Math.round(-t.target.x())/n)),c=1-a,l=Math.min(c,Math.max(0,Math.round(-t.target.y())/r));t.target.setAttrs({x:-s*h.width,y:-l*h.height,scaleX:1,scaleY:1}),e.set({cropX:s,cropY:l,cropWidth:i,cropHeight:a})},oe=()=>{e.type!==`svg`&&e.contentEditable&&(e.stretchEnabled||setTimeout(()=>{e.toggleCropMode(!0)}))},se=e.type===`svg`&&m,[ce]=mC(d===`loading`&&!se,100,!1,!1),le=d===`failed`,ue=!ce&&!le,de=b.useRef({cropX:0,cropY:0,cropWidth:0,cropHeight:0}),fe=ue?e.a.opacity:0;G_(a,fe);let pe=e.selectable||t.role===dC.ADMIN,me=Vx(),he=Cx(e,e.borderColor,`stroke`);return(0,S.jsxs)(S.Fragment,{children:[ce&&(0,S.jsx)(TC,{element:e}),le&&(0,S.jsx)(EC,{element:e}),(0,S.jsx)(Ff,{ref:a,name:`element`,id:e.id,image:te,x:e.a.x,y:e.a.y,width:e.a.width||1,height:e.a.height||1,rotation:e.a.rotation,opacity:fe,shadowEnabled:e.shadowEnabled,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY,shadowColor:e.shadowColor,shadowOpacity:e.shadowOpacity,customCrop:k,listening:pe,draggable:me?e.draggable&&s:e.draggable,preventDefault:!me||s,hideInExport:!e.showInExport,onDragMove:t=>{e.set({x:t.target.x(),y:t.target.y()})},onDragEnd:t=>{e.set({x:t.target.x(),y:t.target.y()})},onDblClick:oe,onDblTap:oe,onTransformStart:()=>{i(!0),de.current={cropX:e.cropX,cropY:e.cropY,cropWidth:e.cropWidth,cropHeight:e.cropHeight}},onTransform:t=>{let n=t.currentTarget,r=Math.abs(n.scaleX()-1)<1e-7?1:n.scaleX(),i=Math.abs(n.scaleY()-1)<1e-7?1:n.scaleY();n.scaleX(1),n.scaleY(1);let a=t.target.getStage()?.findOne(`Transformer`),o=1-T/h.width,s=Math.min(o,Math.max(0,e.cropX)),c=1-E/h.height,l=Math.min(c,Math.max(0,e.cropY)),u=a.getActiveAnchor(),d=!(u.indexOf(`middle`)>=0||u.indexOf(`center`)>=0),f=!d&&r<1&&de.current.cropHeight>E/h.height,p=d?e.cropWidth:e.cropWidth*r;f&&(p=e.cropWidth);let m=!d&&i<1&&de.current.cropWidth>T/h.width,g=d?e.cropHeight:e.cropHeight*i;m&&(g=e.cropHeight),O&&(p=e.cropWidth,g=e.cropHeight),e.set({cropX:s,cropY:l,x:n.x(),y:n.y(),width:n.width()*r,height:n.height()*i,rotation:t.target.rotation(),cropWidth:Math.min(p,1-s),cropHeight:Math.min(g,1-l)})},onTransformEnd:t=>{let n=t.currentTarget;e.set({width:n.width(),height:n.height(),x:n.x(),y:n.y(),rotation:t.target.rotation(),cropWidth:T/h.width,cropHeight:E/h.height}),i(!1)}}),(0,S.jsx)(Nf,Object.assign({x:e.x,y:e.y,width:Math.max(e.a.width-e.borderSize,0),height:Math.max(e.a.height-e.borderSize,0),opacity:fe,offsetX:-e.borderSize/2,offsetY:-e.borderSize/2},he,{strokeWidth:e.borderSize,listening:!1,visible:!!e.borderSize,rotation:e.rotation,cornerRadius:Math.max(0,ee-e.borderSize),hideInExport:!e.showInExport})),e._cropModeEnabled&&(0,S.jsxs)(tx,{selector:`.page-abs-container`,enabled:!0,children:[(0,S.jsx)(`Rect`,{x:-window.innerWidth/t.scale,y:-window.innerWidth/t.scale,width:window.innerWidth/t.scale*3,height:window.innerWidth/t.scale*3,fill:n.cropOverlayFill}),(0,S.jsx)(`Image`,{listening:!1,image:te,x:e.x,y:e.y,width:e.a.width,height:e.a.height,rotation:e.rotation,shadowEnabled:e.shadowEnabled,shadowBlur:e.shadowBlur}),(0,S.jsxs)(`Group`,{x:e.x,y:e.y,rotation:e.rotation,scaleX:M,scaleY:M,children:[(0,S.jsx)(`Image`,{image:h,ref:o,opacity:.4,draggable:!0,x:-e.cropX*h.width,y:-e.cropY*h.height,onDragMove:F,onTransform:F,onTouchMove:e=>{e.evt.preventDefault();let t=e.target.getStage().getPointersPositions();var n=t[0],r=t[1];let i=e.target;if(n&&!r&&!i.isDragging()&&ae.current&&(i.startDrag(),ae.current=!1),n&&r){W.hitOnDragEnabled=!0,i.isDragging()&&(ae.current=!0,i.stopDrag());let t=e.target.getAbsoluteTransform().copy();t.invert();var a={x:n.x,y:n.y},o={x:r.x,y:r.y};if(!re.current){re.current=vC(a,o);return}var s=vC(a,o),c=function(e,t){return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)}(a,o);ie.current||=c;let m=i.position();var l={x:s.x-m.x,y:s.y-m.y},u=c/ie.current;i.scaleX(u),i.scaleY(u);let h=t.point(s),g=t.point(re.current);var d=h.x-g.x,f=h.y-g.y,p={x:Math.min(0,s.x-l.x*u+d),y:Math.min(0,s.y-l.y*u+f)};i.position(p),ie.current=c,re.current=s,F(e)}},onTouchEnd:e=>{ie.current=0,re.current=null,W.hitOnDragEnabled=!1}}),(0,S.jsx)(`Transformer`,Object.assign({ref:P},xC,n.outerImageCropTransformerStyle)),(0,S.jsx)(`Rect`,{width:T,height:E,ref:ne,listening:!1,onTransform:t=>{if(e.cropX<Math.abs(t.target.x()/h.width)&&t.target.x()<0&&e.cropX>0){let n=(e.cropWidth+e.cropX)*h.width;t.target.scaleX(1),t.target.width(n)}if(e.cropY<Math.abs(t.target.y()/h.height)&&t.target.y()<0&&e.cropY>0){let n=(e.cropHeight+e.cropY)*h.height;t.target.scaleY(1),t.target.height(n)}t.target.x()<-e.cropX*h.width-1e-9&&(t.target.x(-e.cropX*h.width),t.target.scaleX(1)),t.target.y()<-e.cropY*h.height-1e-9&&(t.target.y(-e.cropY*h.height),t.target.scaleY(1));let n=Math.min(1,Math.max(0,e.cropX+t.target.x()/h.width)),r=Math.min(1,Math.max(0,t.target.y()/h.height+e.cropY)),i=t.target.width()*t.target.scaleX(),a=t.target.height()*t.target.scaleY(),o=Math.min(1-n,i/h.width),s=Math.min(1-r,a/h.height),c=t.target.getAbsolutePosition(t.target.getParent().getParent());t.target.scale({x:1,y:1}),t.target.position({x:0,y:0}),e.set({x:c.x,y:c.y,cropX:n,cropY:r,cropWidth:o,cropHeight:s,width:Math.min(i*M,h.width*(1-n)*M),height:Math.min(a*M,h.height*(1-r)*M)})}}),(0,S.jsx)(`Transformer`,Object.assign({ref:N},bC,n.innerImageCropTransformerStyle,{visible:e.resizable}))]})]})]})}),AC=e=>kS(e).height;function jC(e,t,n=AC){if(xv(hv(e.text,{fontSize:e.fontSize,fontFamily:e.fontFamily})))return function(e,t,n=AC){let r=1;for(let i=1;i<50;i++){let i=vv(e.text,r),a=e.fontSize*r,o=Lx(Object.assign(Object.assign({},e.toJSON()),{fontSize:a,text:hv(i,{fontSize:a,fontFamily:e.fontFamily})}),t),s=n(o);if(!(e.height&&s>e.height||!h_.textSplitAllowed&&!e.curveEnabled&&OS({html:o})))break;if(r-=.02,r<.05){r=.05;break}}return r>=1?{fontSize:e.fontSize}:{fontSize:e.fontSize*r,text:vv(e.text,r)}}(e,t,n);let r=e.fontSize;for(let i=1;i<50;i++){let i=Lx(Object.assign(Object.assign({},e.toJSON()),{fontSize:r,text:hv(e.text,{fontSize:r,fontFamily:e.fontFamily})}),t),a=n(i);if(!(e.height&&a>e.height||!h_.textSplitAllowed&&!e.curveEnabled&&OS({html:i})))break;r-=.5}return{fontSize:r}}var MC=typeof global==`object`&&global&&global.Object===Object&&global,NC=typeof self==`object`&&self&&self.Object===Object&&self,PC=MC||NC||Function(`return this`)(),FC=PC.Symbol,IC=Object.prototype,LC=IC.hasOwnProperty,RC=IC.toString,zC=FC?FC.toStringTag:void 0;function BC(e){var t=LC.call(e,zC),n=e[zC];try{e[zC]=void 0;var r=!0}catch{}var i=RC.call(e);return r&&(t?e[zC]=n:delete e[zC]),i}var VC=Object.prototype.toString;function HC(e){return VC.call(e)}var UC=`[object Null]`,WC=`[object Undefined]`,GC=FC?FC.toStringTag:void 0;function KC(e){return e==null?e===void 0?WC:UC:GC&&GC in Object(e)?BC(e):HC(e)}function qC(e){return typeof e==`object`&&!!e}var JC=Array.isArray;function YC(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}function XC(e){return e}var ZC=`[object AsyncFunction]`,QC=`[object Function]`,$C=`[object GeneratorFunction]`,ew=`[object Proxy]`;function tw(e){if(!YC(e))return!1;var t=KC(e);return t==QC||t==$C||t==ZC||t==ew}var nw=PC[`__core-js_shared__`],rw=function(){var e=/[^.]+$/.exec(nw&&nw.keys&&nw.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function iw(e){return!!rw&&rw in e}var aw=Function.prototype.toString;function ow(e){if(e!=null){try{return aw.call(e)}catch{}try{return e+``}catch{}}return``}var sw=/[\\^$.*+?()[\]{}|]/g,cw=/^\[object .+?Constructor\]$/,lw=Function.prototype,uw=Object.prototype,dw=lw.toString,fw=uw.hasOwnProperty,pw=RegExp(`^`+dw.call(fw).replace(sw,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function mw(e){return!YC(e)||iw(e)?!1:(tw(e)?pw:cw).test(ow(e))}function hw(e,t){return e?.[t]}function gw(e,t){var n=hw(e,t);return mw(n)?n:void 0}var _w=gw(PC,`WeakMap`),vw=Object.create,yw=function(){function e(){}return function(t){if(!YC(t))return{};if(vw)return vw(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function bw(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function xw(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}var Sw=800,Cw=16,ww=Date.now;function Tw(e){var t=0,n=0;return function(){var r=ww(),i=Cw-(r-n);if(n=r,i>0){if(++t>=Sw)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function Ew(e){return function(){return e}}var Dw=function(){try{var e=gw(Object,`defineProperty`);return e({},``,{}),e}catch{}}(),Ow=Tw(Dw?function(e,t){return Dw(e,`toString`,{configurable:!0,enumerable:!1,value:Ew(t),writable:!0})}:XC);function kw(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}var Aw=9007199254740991,jw=/^(?:0|[1-9]\d*)$/;function Mw(e,t){var n=typeof e;return t??=Aw,!!t&&(n==`number`||n!=`symbol`&&jw.test(e))&&e>-1&&e%1==0&&e<t}function Nw(e,t,n){t==`__proto__`&&Dw?Dw(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n}function Pw(e,t){return e===t||e!==e&&t!==t}var Fw=Object.prototype.hasOwnProperty;function Iw(e,t,n){var r=e[t];(!(Fw.call(e,t)&&Pw(r,n))||n===void 0&&!(t in e))&&Nw(e,t,n)}function Lw(e,t,n,r){var i=!n;n||={};for(var a=-1,o=t.length;++a<o;){var s=t[a],c=r?r(n[s],e[s],s,n,e):void 0;c===void 0&&(c=e[s]),i?Nw(n,s,c):Iw(n,s,c)}return n}var Rw=Math.max;function zw(e,t,n){return t=Rw(t===void 0?e.length-1:t,0),function(){for(var r=arguments,i=-1,a=Rw(r.length-t,0),o=Array(a);++i<a;)o[i]=r[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=r[i];return s[t]=n(o),bw(e,this,s)}}function Bw(e,t){return Ow(zw(e,t,XC),e+``)}var Vw=9007199254740991;function Hw(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=Vw}function Uw(e){return e!=null&&Hw(e.length)&&!tw(e)}function Ww(e,t,n){if(!YC(n))return!1;var r=typeof t;return(r==`number`?Uw(n)&&Mw(t,n.length):r==`string`&&t in n)?Pw(n[t],e):!1}function Gw(e){return Bw(function(t,n){var r=-1,i=n.length,a=i>1?n[i-1]:void 0,o=i>2?n[2]:void 0;for(a=e.length>3&&typeof a==`function`?(i--,a):void 0,o&&Ww(n[0],n[1],o)&&(a=i<3?void 0:a,i=1),t=Object(t);++r<i;){var s=n[r];s&&e(t,s,r,a)}return t})}var Kw=Object.prototype;function qw(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||Kw)}function Jw(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var Yw=`[object Arguments]`;function Xw(e){return qC(e)&&KC(e)==Yw}var Zw=Object.prototype,Qw=Zw.hasOwnProperty,$w=Zw.propertyIsEnumerable,eT=Xw(function(){return arguments}())?Xw:function(e){return qC(e)&&Qw.call(e,`callee`)&&!$w.call(e,`callee`)};function tT(){return!1}var nT=typeof exports==`object`&&exports&&!exports.nodeType&&exports,rT=nT&&typeof module==`object`&&module&&!module.nodeType&&module,iT=rT&&rT.exports===nT?PC.Buffer:void 0,aT=(iT?iT.isBuffer:void 0)||tT,oT=`[object Arguments]`,sT=`[object Array]`,cT=`[object Boolean]`,lT=`[object Date]`,uT=`[object Error]`,dT=`[object Function]`,fT=`[object Map]`,pT=`[object Number]`,mT=`[object Object]`,hT=`[object RegExp]`,gT=`[object Set]`,_T=`[object String]`,vT=`[object WeakMap]`,yT=`[object ArrayBuffer]`,bT=`[object DataView]`,xT=`[object Float32Array]`,ST=`[object Float64Array]`,CT=`[object Int8Array]`,wT=`[object Int16Array]`,TT=`[object Int32Array]`,ET=`[object Uint8Array]`,DT=`[object Uint8ClampedArray]`,OT=`[object Uint16Array]`,kT=`[object Uint32Array]`,AT={};AT[xT]=AT[ST]=AT[CT]=AT[wT]=AT[TT]=AT[ET]=AT[DT]=AT[OT]=AT[kT]=!0,AT[oT]=AT[sT]=AT[yT]=AT[cT]=AT[bT]=AT[lT]=AT[uT]=AT[dT]=AT[fT]=AT[pT]=AT[mT]=AT[hT]=AT[gT]=AT[_T]=AT[vT]=!1;function jT(e){return qC(e)&&Hw(e.length)&&!!AT[KC(e)]}function MT(e){return function(t){return e(t)}}var NT=typeof exports==`object`&&exports&&!exports.nodeType&&exports,PT=NT&&typeof module==`object`&&module&&!module.nodeType&&module,FT=PT&&PT.exports===NT&&MC.process,IT=function(){try{return PT&&PT.require&&PT.require(`util`).types||FT&&FT.binding&&FT.binding(`util`)}catch{}}(),LT=IT&&IT.isTypedArray,RT=LT?MT(LT):jT,zT=Object.prototype.hasOwnProperty;function BT(e,t){var n=JC(e),r=!n&&eT(e),i=!n&&!r&&aT(e),a=!n&&!r&&!i&&RT(e),o=n||r||i||a,s=o?Jw(e.length,String):[],c=s.length;for(var l in e)(t||zT.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||Mw(l,c)))&&s.push(l);return s}function VT(e,t){return function(n){return e(t(n))}}var HT=VT(Object.keys,Object),UT=Object.prototype.hasOwnProperty;function WT(e){if(!qw(e))return HT(e);var t=[];for(var n in Object(e))UT.call(e,n)&&n!=`constructor`&&t.push(n);return t}function GT(e){return Uw(e)?BT(e):WT(e)}function KT(e){var t=[];if(e!=null)for(var n in Object(e))t.push(n);return t}var qT=Object.prototype.hasOwnProperty;function JT(e){if(!YC(e))return KT(e);var t=qw(e),n=[];for(var r in e)r==`constructor`&&(t||!qT.call(e,r))||n.push(r);return n}function YT(e){return Uw(e)?BT(e,!0):JT(e)}var XT=gw(Object,`create`);function ZT(){this.__data__=XT?XT(null):{},this.size=0}function QT(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}var $T=`__lodash_hash_undefined__`,eE=Object.prototype.hasOwnProperty;function tE(e){var t=this.__data__;if(XT){var n=t[e];return n===$T?void 0:n}return eE.call(t,e)?t[e]:void 0}var nE=Object.prototype.hasOwnProperty;function rE(e){var t=this.__data__;return XT?t[e]!==void 0:nE.call(t,e)}var iE=`__lodash_hash_undefined__`;function aE(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=XT&&t===void 0?iE:t,this}function oE(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}oE.prototype.clear=ZT,oE.prototype.delete=QT,oE.prototype.get=tE,oE.prototype.has=rE,oE.prototype.set=aE;function sE(){this.__data__=[],this.size=0}function cE(e,t){for(var n=e.length;n--;)if(Pw(e[n][0],t))return n;return-1}var lE=Array.prototype.splice;function uE(e){var t=this.__data__,n=cE(t,e);return n<0?!1:(n==t.length-1?t.pop():lE.call(t,n,1),--this.size,!0)}function dE(e){var t=this.__data__,n=cE(t,e);return n<0?void 0:t[n][1]}function fE(e){return cE(this.__data__,e)>-1}function pE(e,t){var n=this.__data__,r=cE(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}function mE(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}mE.prototype.clear=sE,mE.prototype.delete=uE,mE.prototype.get=dE,mE.prototype.has=fE,mE.prototype.set=pE;var hE=gw(PC,`Map`);function gE(){this.size=0,this.__data__={hash:new oE,map:new(hE||mE),string:new oE}}function _E(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function vE(e,t){var n=e.__data__;return _E(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function yE(e){var t=vE(this,e).delete(e);return this.size-=+!!t,t}function bE(e){return vE(this,e).get(e)}function xE(e){return vE(this,e).has(e)}function SE(e,t){var n=vE(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}function CE(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}CE.prototype.clear=gE,CE.prototype.delete=yE,CE.prototype.get=bE,CE.prototype.has=xE,CE.prototype.set=SE;function wE(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var TE=VT(Object.getPrototypeOf,Object),EE=`[object Object]`,DE=Function.prototype,OE=Object.prototype,kE=DE.toString,AE=OE.hasOwnProperty,jE=kE.call(Object);function ME(e){if(!qC(e)||KC(e)!=EE)return!1;var t=TE(e);if(t===null)return!0;var n=AE.call(t,`constructor`)&&t.constructor;return typeof n==`function`&&n instanceof n&&kE.call(n)==jE}function NE(){this.__data__=new mE,this.size=0}function PE(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function FE(e){return this.__data__.get(e)}function IE(e){return this.__data__.has(e)}var LE=200;function RE(e,t){var n=this.__data__;if(n instanceof mE){var r=n.__data__;if(!hE||r.length<LE-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new CE(r)}return n.set(e,t),this.size=n.size,this}function zE(e){var t=this.__data__=new mE(e);this.size=t.size}zE.prototype.clear=NE,zE.prototype.delete=PE,zE.prototype.get=FE,zE.prototype.has=IE,zE.prototype.set=RE;function BE(e,t){return e&&Lw(t,GT(t),e)}function VE(e,t){return e&&Lw(t,YT(t),e)}var HE=typeof exports==`object`&&exports&&!exports.nodeType&&exports,UE=HE&&typeof module==`object`&&module&&!module.nodeType&&module,WE=UE&&UE.exports===HE?PC.Buffer:void 0,GE=WE?WE.allocUnsafe:void 0;function KE(e,t){if(t)return e.slice();var n=e.length,r=GE?GE(n):new e.constructor(n);return e.copy(r),r}function qE(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function JE(){return[]}var YE=Object.prototype.propertyIsEnumerable,XE=Object.getOwnPropertySymbols,ZE=XE?function(e){return e==null?[]:(e=Object(e),qE(XE(e),function(t){return YE.call(e,t)}))}:JE;function QE(e,t){return Lw(e,ZE(e),t)}var $E=Object.getOwnPropertySymbols?function(e){for(var t=[];e;)wE(t,ZE(e)),e=TE(e);return t}:JE;function eD(e,t){return Lw(e,$E(e),t)}function tD(e,t,n){var r=t(e);return JC(e)?r:wE(r,n(e))}function nD(e){return tD(e,GT,ZE)}function rD(e){return tD(e,YT,$E)}var iD=gw(PC,`DataView`),aD=gw(PC,`Promise`),oD=gw(PC,`Set`),sD=`[object Map]`,cD=`[object Object]`,lD=`[object Promise]`,uD=`[object Set]`,dD=`[object WeakMap]`,fD=`[object DataView]`,pD=ow(iD),mD=ow(hE),hD=ow(aD),gD=ow(oD),_D=ow(_w),vD=KC;(iD&&vD(new iD(new ArrayBuffer(1)))!=fD||hE&&vD(new hE)!=sD||aD&&vD(aD.resolve())!=lD||oD&&vD(new oD)!=uD||_w&&vD(new _w)!=dD)&&(vD=function(e){var t=KC(e),n=t==cD?e.constructor:void 0,r=n?ow(n):``;if(r)switch(r){case pD:return fD;case mD:return sD;case hD:return lD;case gD:return uD;case _D:return dD}return t});var yD=vD,bD=Object.prototype.hasOwnProperty;function xD(e){var t=e.length,n=new e.constructor(t);return t&&typeof e[0]==`string`&&bD.call(e,`index`)&&(n.index=e.index,n.input=e.input),n}var SD=PC.Uint8Array;function CD(e){var t=new e.constructor(e.byteLength);return new SD(t).set(new SD(e)),t}function wD(e,t){var n=t?CD(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}var TD=/\w*$/;function ED(e){var t=new e.constructor(e.source,TD.exec(e));return t.lastIndex=e.lastIndex,t}var DD=FC?FC.prototype:void 0,OD=DD?DD.valueOf:void 0;function kD(e){return OD?Object(OD.call(e)):{}}function AD(e,t){var n=t?CD(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}var jD=`[object Boolean]`,MD=`[object Date]`,ND=`[object Map]`,PD=`[object Number]`,FD=`[object RegExp]`,ID=`[object Set]`,LD=`[object String]`,RD=`[object Symbol]`,zD=`[object ArrayBuffer]`,BD=`[object DataView]`,VD=`[object Float32Array]`,HD=`[object Float64Array]`,UD=`[object Int8Array]`,WD=`[object Int16Array]`,GD=`[object Int32Array]`,KD=`[object Uint8Array]`,qD=`[object Uint8ClampedArray]`,JD=`[object Uint16Array]`,YD=`[object Uint32Array]`;function XD(e,t,n){var r=e.constructor;switch(t){case zD:return CD(e);case jD:case MD:return new r(+e);case BD:return wD(e,n);case VD:case HD:case UD:case WD:case GD:case KD:case qD:case JD:case YD:return AD(e,n);case ND:return new r;case PD:case LD:return new r(e);case FD:return ED(e);case ID:return new r;case RD:return kD(e)}}function ZD(e){return typeof e.constructor==`function`&&!qw(e)?yw(TE(e)):{}}var QD=`[object Map]`;function $D(e){return qC(e)&&yD(e)==QD}var eO=IT&&IT.isMap,tO=eO?MT(eO):$D,nO=`[object Set]`;function rO(e){return qC(e)&&yD(e)==nO}var iO=IT&&IT.isSet,aO=iO?MT(iO):rO,oO=1,sO=2,cO=4,lO=`[object Arguments]`,uO=`[object Array]`,dO=`[object Boolean]`,fO=`[object Date]`,pO=`[object Error]`,mO=`[object Function]`,hO=`[object GeneratorFunction]`,gO=`[object Map]`,_O=`[object Number]`,vO=`[object Object]`,yO=`[object RegExp]`,bO=`[object Set]`,xO=`[object String]`,SO=`[object Symbol]`,CO=`[object WeakMap]`,wO=`[object ArrayBuffer]`,TO=`[object DataView]`,EO=`[object Float32Array]`,DO=`[object Float64Array]`,OO=`[object Int8Array]`,kO=`[object Int16Array]`,AO=`[object Int32Array]`,jO=`[object Uint8Array]`,MO=`[object Uint8ClampedArray]`,NO=`[object Uint16Array]`,PO=`[object Uint32Array]`,FO={};FO[lO]=FO[uO]=FO[wO]=FO[TO]=FO[dO]=FO[fO]=FO[EO]=FO[DO]=FO[OO]=FO[kO]=FO[AO]=FO[gO]=FO[_O]=FO[vO]=FO[yO]=FO[bO]=FO[xO]=FO[SO]=FO[jO]=FO[MO]=FO[NO]=FO[PO]=!0,FO[pO]=FO[mO]=FO[CO]=!1;function IO(e,t,n,r,i,a){var o,s=t&oO,c=t&sO,l=t&cO;if(n&&(o=i?n(e,r,i,a):n(e)),o!==void 0)return o;if(!YC(e))return e;var u=JC(e);if(u){if(o=xD(e),!s)return xw(e,o)}else{var d=yD(e),f=d==mO||d==hO;if(aT(e))return KE(e,s);if(d==vO||d==lO||f&&!i){if(o=c||f?{}:ZD(e),!s)return c?eD(e,VE(o,e)):QE(e,BE(o,e))}else{if(!FO[d])return i?e:{};o=XD(e,d,s)}}a||=new zE;var p=a.get(e);if(p)return p;a.set(e,o),aO(e)?e.forEach(function(r){o.add(IO(r,t,n,r,e,a))}):tO(e)&&e.forEach(function(r,i){o.set(i,IO(r,t,n,i,e,a))});var m=u?void 0:(l?c?rD:nD:c?YT:GT)(e);return kw(m||e,function(r,i){m&&(i=r,r=e[i]),Iw(o,i,IO(r,t,n,i,e,a))}),o}var LO=1,RO=4;function zO(e){return IO(e,LO|RO)}var BO=`__lodash_hash_undefined__`;function VO(e){return this.__data__.set(e,BO),this}function HO(e){return this.__data__.has(e)}function UO(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new CE;++t<n;)this.add(e[t])}UO.prototype.add=UO.prototype.push=VO,UO.prototype.has=HO;function WO(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function GO(e,t){return e.has(t)}var KO=1,qO=2;function JO(e,t,n,r,i,a){var o=n&KO,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=a.get(e),u=a.get(t);if(l&&u)return l==t&&u==e;var d=-1,f=!0,p=n&qO?new UO:void 0;for(a.set(e,t),a.set(t,e);++d<s;){var m=e[d],h=t[d];if(r)var g=o?r(h,m,d,t,e,a):r(m,h,d,e,t,a);if(g!==void 0){if(g)continue;f=!1;break}if(p){if(!WO(t,function(e,t){if(!GO(p,t)&&(m===e||i(m,e,n,r,a)))return p.push(t)})){f=!1;break}}else if(!(m===h||i(m,h,n,r,a))){f=!1;break}}return a.delete(e),a.delete(t),f}function YO(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function XO(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var ZO=1,QO=2,$O=`[object Boolean]`,ek=`[object Date]`,tk=`[object Error]`,nk=`[object Map]`,rk=`[object Number]`,ik=`[object RegExp]`,ak=`[object Set]`,ok=`[object String]`,sk=`[object Symbol]`,ck=`[object ArrayBuffer]`,lk=`[object DataView]`,uk=FC?FC.prototype:void 0,dk=uk?uk.valueOf:void 0;function fk(e,t,n,r,i,a,o){switch(n){case lk:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case ck:return!(e.byteLength!=t.byteLength||!a(new SD(e),new SD(t)));case $O:case ek:case rk:return Pw(+e,+t);case tk:return e.name==t.name&&e.message==t.message;case ik:case ok:return e==t+``;case nk:var s=YO;case ak:var c=r&ZO;if(s||=XO,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=QO,o.set(e,t);var u=JO(s(e),s(t),r,i,a,o);return o.delete(e),u;case sk:if(dk)return dk.call(e)==dk.call(t)}return!1}var pk=1,mk=Object.prototype.hasOwnProperty;function hk(e,t,n,r,i,a){var o=n&pk,s=nD(e),c=s.length;if(c!=nD(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:mk.call(t,u)))return!1}var d=a.get(e),f=a.get(t);if(d&&f)return d==t&&f==e;var p=!0;a.set(e,t),a.set(t,e);for(var m=o;++l<c;){u=s[l];var h=e[u],g=t[u];if(r)var _=o?r(g,h,u,t,e,a):r(h,g,u,e,t,a);if(!(_===void 0?h===g||i(h,g,n,r,a):_)){p=!1;break}m||=u==`constructor`}if(p&&!m){var v=e.constructor,y=t.constructor;v!=y&&`constructor`in e&&`constructor`in t&&!(typeof v==`function`&&v instanceof v&&typeof y==`function`&&y instanceof y)&&(p=!1)}return a.delete(e),a.delete(t),p}var gk=1,_k=`[object Arguments]`,vk=`[object Array]`,yk=`[object Object]`,bk=Object.prototype.hasOwnProperty;function xk(e,t,n,r,i,a){var o=JC(e),s=JC(t),c=o?vk:yD(e),l=s?vk:yD(t);c=c==_k?yk:c,l=l==_k?yk:l;var u=c==yk,d=l==yk,f=c==l;if(f&&aT(e)){if(!aT(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new zE,o||RT(e)?JO(e,t,n,r,i,a):fk(e,t,c,n,r,i,a);if(!(n&gk)){var p=u&&bk.call(e,`__wrapped__`),m=d&&bk.call(t,`__wrapped__`);if(p||m){var h=p?e.value():e,g=m?t.value():t;return a||=new zE,i(h,g,n,r,a)}}return f?(a||=new zE,hk(e,t,n,r,i,a)):!1}function Sk(e,t,n,r,i){return e===t?!0:e==null||t==null||!qC(e)&&!qC(t)?e!==e&&t!==t:xk(e,t,n,r,Sk,i)}function Ck(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}var wk=Ck();function Tk(e,t,n){(n!==void 0&&!Pw(e[t],n)||n===void 0&&!(t in e))&&Nw(e,t,n)}function Ek(e){return qC(e)&&Uw(e)}function Dk(e,t){if(!(t===`constructor`&&typeof e[t]==`function`)&&t!=`__proto__`)return e[t]}function Ok(e){return Lw(e,YT(e))}function kk(e,t,n,r,i,a,o){var s=Dk(e,n),c=Dk(t,n),l=o.get(c);if(l){Tk(e,n,l);return}var u=a?a(s,c,n+``,e,t,o):void 0,d=u===void 0;if(d){var f=JC(c),p=!f&&aT(c),m=!f&&!p&&RT(c);u=c,f||p||m?JC(s)?u=s:Ek(s)?u=xw(s):p?(d=!1,u=KE(c,!0)):m?(d=!1,u=AD(c,!0)):u=[]:ME(c)||eT(c)?(u=s,eT(s)?u=Ok(s):(!YC(s)||tw(s))&&(u=ZD(c))):d=!1}d&&(o.set(c,u),i(u,c,r,a,o),o.delete(c)),Tk(e,n,u)}function Ak(e,t,n,r,i){e!==t&&wk(t,function(a,o){if(i||=new zE,YC(a))kk(e,t,o,n,Ak,r,i);else{var s=r?r(Dk(e,o),a,o+``,e,t,i):void 0;s===void 0&&(s=a),Tk(e,o,s)}},YT)}function jk(e,t){return Sk(e,t)}var Mk=Gw(function(e,t,n){Ak(e,t,n)}),Nk=s({Attributor:()=>Fk,AttributorStore:()=>Uk,BlockBlot:()=>nA,ClassAttributor:()=>Bk,ContainerBlot:()=>iA,EmbedBlot:()=>aA,InlineBlot:()=>eA,LeafBlot:()=>qk,ParentBlot:()=>Zk,Registry:()=>Rk,Scope:()=>Pk,ScrollBlot:()=>lA,StyleAttributor:()=>Hk,TextBlot:()=>dA}),Pk=(e=>(e[e.TYPE=3]=`TYPE`,e[e.LEVEL=12]=`LEVEL`,e[e.ATTRIBUTE=13]=`ATTRIBUTE`,e[e.BLOT=14]=`BLOT`,e[e.INLINE=7]=`INLINE`,e[e.BLOCK=11]=`BLOCK`,e[e.BLOCK_BLOT=10]=`BLOCK_BLOT`,e[e.INLINE_BLOT=6]=`INLINE_BLOT`,e[e.BLOCK_ATTRIBUTE=9]=`BLOCK_ATTRIBUTE`,e[e.INLINE_ATTRIBUTE=5]=`INLINE_ATTRIBUTE`,e[e.ANY=15]=`ANY`,e))(Pk||{}),Fk=class{constructor(e,t,n={}){this.attrName=e,this.keyName=t;let r=Pk.TYPE&Pk.ATTRIBUTE;this.scope=n.scope==null?Pk.ATTRIBUTE:n.scope&Pk.LEVEL|r,n.whitelist!=null&&(this.whitelist=n.whitelist)}static keys(e){return Array.from(e.attributes).map(e=>e.name)}add(e,t){return this.canAdd(e,t)?(e.setAttribute(this.keyName,t),!0):!1}canAdd(e,t){return this.whitelist==null?!0:typeof t==`string`?this.whitelist.indexOf(t.replace(/["']/g,``))>-1:this.whitelist.indexOf(t)>-1}remove(e){e.removeAttribute(this.keyName)}value(e){let t=e.getAttribute(this.keyName);return this.canAdd(e,t)&&t?t:``}},Ik=class extends Error{constructor(e){e=`[Parchment] `+e,super(e),this.message=e,this.name=this.constructor.name}},Lk=class e{constructor(){this.attributes={},this.classes={},this.tags={},this.types={}}static find(e,t=!1){if(e==null)return null;if(this.blots.has(e))return this.blots.get(e)||null;if(t){let n=null;try{n=e.parentNode}catch{return null}return this.find(n,t)}return null}create(t,n,r){let i=this.query(n);if(i==null)throw new Ik(`Unable to create ${n} blot`);let a=i,o=new a(t,n instanceof Node||n.nodeType===Node.TEXT_NODE?n:a.create(r),r);return e.blots.set(o.domNode,o),o}find(t,n=!1){return e.find(t,n)}query(e,t=Pk.ANY){let n;return typeof e==`string`?n=this.types[e]||this.attributes[e]:e instanceof Text||e.nodeType===Node.TEXT_NODE?n=this.types.text:typeof e==`number`?e&Pk.LEVEL&Pk.BLOCK?n=this.types.block:e&Pk.LEVEL&Pk.INLINE&&(n=this.types.inline):e instanceof Element&&((e.getAttribute(`class`)||``).split(/\s+/).some(e=>(n=this.classes[e],!!n)),n||=this.tags[e.tagName]),n==null?null:`scope`in n&&t&Pk.LEVEL&n.scope&&t&Pk.TYPE&n.scope?n:null}register(...e){return e.map(e=>{let t=`blotName`in e,n=`attrName`in e;if(!t&&!n)throw new Ik(`Invalid definition`);if(t&&e.blotName===`abstract`)throw new Ik(`Cannot register abstract class`);let r=t?e.blotName:n?e.attrName:void 0;return this.types[r]=e,n?typeof e.keyName==`string`&&(this.attributes[e.keyName]=e):t&&(e.className&&(this.classes[e.className]=e),e.tagName&&(Array.isArray(e.tagName)?e.tagName=e.tagName.map(e=>e.toUpperCase()):e.tagName=e.tagName.toUpperCase(),(Array.isArray(e.tagName)?e.tagName:[e.tagName]).forEach(t=>{(this.tags[t]==null||e.className==null)&&(this.tags[t]=e)}))),e})}};Lk.blots=new WeakMap;var Rk=Lk;function zk(e,t){return(e.getAttribute(`class`)||``).split(/\s+/).filter(e=>e.indexOf(`${t}-`)===0)}var Bk=class extends Fk{static keys(e){return(e.getAttribute(`class`)||``).split(/\s+/).map(e=>e.split(`-`).slice(0,-1).join(`-`))}add(e,t){return this.canAdd(e,t)?(this.remove(e),e.classList.add(`${this.keyName}-${t}`),!0):!1}remove(e){zk(e,this.keyName).forEach(t=>{e.classList.remove(t)}),e.classList.length===0&&e.removeAttribute(`class`)}value(e){let t=(zk(e,this.keyName)[0]||``).slice(this.keyName.length+1);return this.canAdd(e,t)?t:``}};function Vk(e){let t=e.split(`-`),n=t.slice(1).map(e=>e[0].toUpperCase()+e.slice(1)).join(``);return t[0]+n}var Hk=class extends Fk{static keys(e){return(e.getAttribute(`style`)||``).split(`;`).map(e=>e.split(`:`)[0].trim())}add(e,t){return this.canAdd(e,t)?(e.style[Vk(this.keyName)]=t,!0):!1}remove(e){e.style[Vk(this.keyName)]=``,e.getAttribute(`style`)||e.removeAttribute(`style`)}value(e){let t=e.style[Vk(this.keyName)];return this.canAdd(e,t)?t:``}},Uk=class{constructor(e){this.attributes={},this.domNode=e,this.build()}attribute(e,t){t?e.add(this.domNode,t)&&(e.value(this.domNode)==null?delete this.attributes[e.attrName]:this.attributes[e.attrName]=e):(e.remove(this.domNode),delete this.attributes[e.attrName])}build(){this.attributes={};let e=Rk.find(this.domNode);if(e==null)return;let t=Fk.keys(this.domNode),n=Bk.keys(this.domNode),r=Hk.keys(this.domNode);t.concat(n).concat(r).forEach(t=>{let n=e.scroll.query(t,Pk.ATTRIBUTE);n instanceof Fk&&(this.attributes[n.attrName]=n)})}copy(e){Object.keys(this.attributes).forEach(t=>{let n=this.attributes[t].value(this.domNode);e.format(t,n)})}move(e){this.copy(e),Object.keys(this.attributes).forEach(e=>{this.attributes[e].remove(this.domNode)}),this.attributes={}}values(){return Object.keys(this.attributes).reduce((e,t)=>(e[t]=this.attributes[t].value(this.domNode),e),{})}},Wk=class{constructor(e,t){this.scroll=e,this.domNode=t,Rk.blots.set(t,this),this.prev=null,this.next=null}static create(e){if(this.tagName==null)throw new Ik(`Blot definition missing tagName`);let t,n;return Array.isArray(this.tagName)?(typeof e==`string`?(n=e.toUpperCase(),parseInt(n,10).toString()===n&&(n=parseInt(n,10))):typeof e==`number`&&(n=e),t=typeof n==`number`?document.createElement(this.tagName[n-1]):n&&this.tagName.indexOf(n)>-1?document.createElement(n):document.createElement(this.tagName[0])):t=document.createElement(this.tagName),this.className&&t.classList.add(this.className),t}get statics(){return this.constructor}attach(){}clone(){let e=this.domNode.cloneNode(!1);return this.scroll.create(e)}detach(){this.parent!=null&&this.parent.removeChild(this),Rk.blots.delete(this.domNode)}deleteAt(e,t){this.isolate(e,t).remove()}formatAt(e,t,n,r){let i=this.isolate(e,t);if(this.scroll.query(n,Pk.BLOT)!=null&&r)i.wrap(n,r);else if(this.scroll.query(n,Pk.ATTRIBUTE)!=null){let e=this.scroll.create(this.statics.scope);i.wrap(e),e.format(n,r)}}insertAt(e,t,n){let r=n==null?this.scroll.create(`text`,t):this.scroll.create(t,n),i=this.split(e);this.parent.insertBefore(r,i||void 0)}isolate(e,t){let n=this.split(e);if(n==null)throw Error(`Attempt to isolate at end`);return n.split(t),n}length(){return 1}offset(e=this.parent){return this.parent==null||this===e?0:this.parent.children.offset(this)+this.parent.offset(e)}optimize(e){this.statics.requiredContainer&&!(this.parent instanceof this.statics.requiredContainer)&&this.wrap(this.statics.requiredContainer.blotName)}remove(){this.domNode.parentNode!=null&&this.domNode.parentNode.removeChild(this.domNode),this.detach()}replaceWith(e,t){let n=typeof e==`string`?this.scroll.create(e,t):e;return this.parent!=null&&(this.parent.insertBefore(n,this.next||void 0),this.remove()),n}split(e,t){return e===0?this:this.next}update(e,t){}wrap(e,t){let n=typeof e==`string`?this.scroll.create(e,t):e;if(this.parent!=null&&this.parent.insertBefore(n,this.next||void 0),typeof n.appendChild!=`function`)throw new Ik(`Cannot wrap ${e}`);return n.appendChild(this),n}};Wk.blotName=`abstract`;var Gk=Wk,Kk=class extends Gk{static value(e){return!0}index(e,t){return this.domNode===e||this.domNode.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_CONTAINED_BY?Math.min(t,1):-1}position(e,t){let n=Array.from(this.parent.domNode.childNodes).indexOf(this.domNode);return e>0&&(n+=1),[this.parent.domNode,n]}value(){return{[this.statics.blotName]:this.statics.value(this.domNode)||!0}}};Kk.scope=Pk.INLINE_BLOT;var qk=Kk,Jk=class{constructor(){this.head=null,this.tail=null,this.length=0}append(...e){if(this.insertBefore(e[0],null),e.length>1){let t=e.slice(1);this.append(...t)}}at(e){let t=this.iterator(),n=t();for(;n&&e>0;)--e,n=t();return n}contains(e){let t=this.iterator(),n=t();for(;n;){if(n===e)return!0;n=t()}return!1}indexOf(e){let t=this.iterator(),n=t(),r=0;for(;n;){if(n===e)return r;r+=1,n=t()}return-1}insertBefore(e,t){e!=null&&(this.remove(e),e.next=t,t==null?this.tail==null?(e.prev=null,this.head=this.tail=e):(this.tail.next=e,e.prev=this.tail,this.tail=e):(e.prev=t.prev,t.prev!=null&&(t.prev.next=e),t.prev=e,t===this.head&&(this.head=e)),this.length+=1)}offset(e){let t=0,n=this.head;for(;n!=null;){if(n===e)return t;t+=n.length(),n=n.next}return-1}remove(e){this.contains(e)&&(e.prev!=null&&(e.prev.next=e.next),e.next!=null&&(e.next.prev=e.prev),e===this.head&&(this.head=e.next),e===this.tail&&(this.tail=e.prev),--this.length)}iterator(e=this.head){return()=>{let t=e;return e!=null&&(e=e.next),t}}find(e,t=!1){let n=this.iterator(),r=n();for(;r;){let i=r.length();if(e<i||t&&e===i&&(r.next==null||r.next.length()!==0))return[r,e];e-=i,r=n()}return[null,0]}forEach(e){let t=this.iterator(),n=t();for(;n;)e(n),n=t()}forEachAt(e,t,n){if(t<=0)return;let[r,i]=this.find(e),a=e-i,o=this.iterator(r),s=o();for(;s&&a<e+t;){let r=s.length();e>a?n(s,e-a,Math.min(t,a+r-e)):n(s,0,Math.min(r,e+t-a)),a+=r,s=o()}}map(e){return this.reduce((t,n)=>(t.push(e(n)),t),[])}reduce(e,t){let n=this.iterator(),r=n();for(;r;)t=e(t,r),r=n();return t}};function Yk(e,t){let n=t.find(e);if(n)return n;try{return t.create(e)}catch{let n=t.create(Pk.INLINE);return Array.from(e.childNodes).forEach(e=>{n.domNode.appendChild(e)}),e.parentNode&&e.parentNode.replaceChild(n.domNode,e),n.attach(),n}}var Xk=class e extends Gk{constructor(e,t){super(e,t),this.uiNode=null,this.build()}appendChild(e){this.insertBefore(e)}attach(){super.attach(),this.children.forEach(e=>{e.attach()})}attachUI(t){this.uiNode!=null&&this.uiNode.remove(),this.uiNode=t,e.uiClass&&this.uiNode.classList.add(e.uiClass),this.uiNode.setAttribute(`contenteditable`,`false`),this.domNode.insertBefore(this.uiNode,this.domNode.firstChild)}build(){this.children=new Jk,Array.from(this.domNode.childNodes).filter(e=>e!==this.uiNode).reverse().forEach(e=>{try{let t=Yk(e,this.scroll);this.insertBefore(t,this.children.head||void 0)}catch(e){if(e instanceof Ik)return;throw e}})}deleteAt(e,t){if(e===0&&t===this.length())return this.remove();this.children.forEachAt(e,t,(e,t,n)=>{e.deleteAt(t,n)})}descendant(t,n=0){let[r,i]=this.children.find(n);return t.blotName==null&&t(r)||t.blotName!=null&&r instanceof t?[r,i]:r instanceof e?r.descendant(t,i):[null,-1]}descendants(t,n=0,r=Number.MAX_VALUE){let i=[],a=r;return this.children.forEachAt(n,r,(n,r,o)=>{(t.blotName==null&&t(n)||t.blotName!=null&&n instanceof t)&&i.push(n),n instanceof e&&(i=i.concat(n.descendants(t,r,a))),a-=o}),i}detach(){this.children.forEach(e=>{e.detach()}),super.detach()}enforceAllowedChildren(){let t=!1;this.children.forEach(n=>{t||this.statics.allowedChildren.some(e=>n instanceof e)||(n.statics.scope===Pk.BLOCK_BLOT?(n.next!=null&&this.splitAfter(n),n.prev!=null&&this.splitAfter(n.prev),n.parent.unwrap(),t=!0):n instanceof e?n.unwrap():n.remove())})}formatAt(e,t,n,r){this.children.forEachAt(e,t,(e,t,i)=>{e.formatAt(t,i,n,r)})}insertAt(e,t,n){let[r,i]=this.children.find(e);if(r)r.insertAt(i,t,n);else{let e=n==null?this.scroll.create(`text`,t):this.scroll.create(t,n);this.appendChild(e)}}insertBefore(e,t){e.parent!=null&&e.parent.children.remove(e);let n=null;this.children.insertBefore(e,t||null),e.parent=this,t!=null&&(n=t.domNode),(this.domNode.parentNode!==e.domNode||this.domNode.nextSibling!==n)&&this.domNode.insertBefore(e.domNode,n),e.attach()}length(){return this.children.reduce((e,t)=>e+t.length(),0)}moveChildren(e,t){this.children.forEach(n=>{e.insertBefore(n,t)})}optimize(e){if(super.optimize(e),this.enforceAllowedChildren(),this.uiNode!=null&&this.uiNode!==this.domNode.firstChild&&this.domNode.insertBefore(this.uiNode,this.domNode.firstChild),this.children.length===0)if(this.statics.defaultChild!=null){let e=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(e)}else this.remove()}path(t,n=!1){let[r,i]=this.children.find(t,n),a=[[this,t]];return r instanceof e?a.concat(r.path(i,n)):(r!=null&&a.push([r,i]),a)}removeChild(e){this.children.remove(e)}replaceWith(t,n){let r=typeof t==`string`?this.scroll.create(t,n):t;return r instanceof e&&this.moveChildren(r),super.replaceWith(r)}split(e,t=!1){if(!t){if(e===0)return this;if(e===this.length())return this.next}let n=this.clone();return this.parent&&this.parent.insertBefore(n,this.next||void 0),this.children.forEachAt(e,this.length(),(e,r,i)=>{let a=e.split(r,t);a!=null&&n.appendChild(a)}),n}splitAfter(e){let t=this.clone();for(;e.next!=null;)t.appendChild(e.next);return this.parent&&this.parent.insertBefore(t,this.next||void 0),t}unwrap(){this.parent&&this.moveChildren(this.parent,this.next||void 0),this.remove()}update(e,t){let n=[],r=[];e.forEach(e=>{e.target===this.domNode&&e.type===`childList`&&(n.push(...e.addedNodes),r.push(...e.removedNodes))}),r.forEach(e=>{if(e.parentNode!=null&&e.tagName!==`IFRAME`&&document.body.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_CONTAINED_BY)return;let t=this.scroll.find(e);t!=null&&(t.domNode.parentNode==null||t.domNode.parentNode===this.domNode)&&t.detach()}),n.filter(e=>e.parentNode===this.domNode&&e!==this.uiNode).sort((e,t)=>e===t?0:e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?1:-1).forEach(e=>{let t=null;e.nextSibling!=null&&(t=this.scroll.find(e.nextSibling));let n=Yk(e,this.scroll);(n.next!==t||n.next==null)&&(n.parent!=null&&n.parent.removeChild(this),this.insertBefore(n,t||void 0))}),this.enforceAllowedChildren()}};Xk.uiClass=``;var Zk=Xk;function Qk(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}var $k=class e extends Zk{static create(e){return super.create(e)}static formats(t,n){let r=n.query(e.blotName);if(!(r!=null&&t.tagName===r.tagName)){if(typeof this.tagName==`string`)return!0;if(Array.isArray(this.tagName))return t.tagName.toLowerCase()}}constructor(e,t){super(e,t),this.attributes=new Uk(this.domNode)}format(t,n){if(t===this.statics.blotName&&!n)this.children.forEach(t=>{t instanceof e||(t=t.wrap(e.blotName,!0)),this.attributes.copy(t)}),this.unwrap();else{let e=this.scroll.query(t,Pk.INLINE);if(e==null)return;e instanceof Fk?this.attributes.attribute(e,n):n&&(t!==this.statics.blotName||this.formats()[t]!==n)&&this.replaceWith(t,n)}}formats(){let e=this.attributes.values(),t=this.statics.formats(this.domNode,this.scroll);return t!=null&&(e[this.statics.blotName]=t),e}formatAt(e,t,n,r){this.formats()[n]!=null||this.scroll.query(n,Pk.ATTRIBUTE)?this.isolate(e,t).format(n,r):super.formatAt(e,t,n,r)}optimize(t){super.optimize(t);let n=this.formats();if(Object.keys(n).length===0)return this.unwrap();let r=this.next;r instanceof e&&r.prev===this&&Qk(n,r.formats())&&(r.moveChildren(this),r.remove())}replaceWith(e,t){let n=super.replaceWith(e,t);return this.attributes.copy(n),n}update(e,t){super.update(e,t),e.some(e=>e.target===this.domNode&&e.type===`attributes`)&&this.attributes.build()}wrap(t,n){let r=super.wrap(t,n);return r instanceof e&&this.attributes.move(r),r}};$k.allowedChildren=[$k,qk],$k.blotName=`inline`,$k.scope=Pk.INLINE_BLOT,$k.tagName=`SPAN`;var eA=$k,tA=class e extends Zk{static create(e){return super.create(e)}static formats(t,n){let r=n.query(e.blotName);if(!(r!=null&&t.tagName===r.tagName)){if(typeof this.tagName==`string`)return!0;if(Array.isArray(this.tagName))return t.tagName.toLowerCase()}}constructor(e,t){super(e,t),this.attributes=new Uk(this.domNode)}format(t,n){let r=this.scroll.query(t,Pk.BLOCK);r!=null&&(r instanceof Fk?this.attributes.attribute(r,n):t===this.statics.blotName&&!n?this.replaceWith(e.blotName):n&&(t!==this.statics.blotName||this.formats()[t]!==n)&&this.replaceWith(t,n))}formats(){let e=this.attributes.values(),t=this.statics.formats(this.domNode,this.scroll);return t!=null&&(e[this.statics.blotName]=t),e}formatAt(e,t,n,r){this.scroll.query(n,Pk.BLOCK)==null?super.formatAt(e,t,n,r):this.format(n,r)}insertAt(e,t,n){if(n==null||this.scroll.query(t,Pk.INLINE)!=null)super.insertAt(e,t,n);else{let r=this.split(e);if(r!=null){let e=this.scroll.create(t,n);r.parent.insertBefore(e,r)}else throw Error(`Attempt to insertAt after block boundaries`)}}replaceWith(e,t){let n=super.replaceWith(e,t);return this.attributes.copy(n),n}update(e,t){super.update(e,t),e.some(e=>e.target===this.domNode&&e.type===`attributes`)&&this.attributes.build()}};tA.blotName=`block`,tA.scope=Pk.BLOCK_BLOT,tA.tagName=`P`,tA.allowedChildren=[eA,tA,qk];var nA=tA,rA=class extends Zk{checkMerge(){return this.next!==null&&this.next.statics.blotName===this.statics.blotName}deleteAt(e,t){super.deleteAt(e,t),this.enforceAllowedChildren()}formatAt(e,t,n,r){super.formatAt(e,t,n,r),this.enforceAllowedChildren()}insertAt(e,t,n){super.insertAt(e,t,n),this.enforceAllowedChildren()}optimize(e){super.optimize(e),this.children.length>0&&this.next!=null&&this.checkMerge()&&(this.next.moveChildren(this),this.next.remove())}};rA.blotName=`container`,rA.scope=Pk.BLOCK_BLOT;var iA=rA,aA=class extends qk{static formats(e,t){}format(e,t){super.formatAt(0,this.length(),e,t)}formatAt(e,t,n,r){e===0&&t===this.length()?this.format(n,r):super.formatAt(e,t,n,r)}formats(){return this.statics.formats(this.domNode,this.scroll)}},oA={attributes:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0},sA=100,cA=class extends Zk{constructor(e,t){super(null,t),this.registry=e,this.scroll=this,this.build(),this.observer=new MutationObserver(e=>{this.update(e)}),this.observer.observe(this.domNode,oA),this.attach()}create(e,t){return this.registry.create(this,e,t)}find(e,t=!1){let n=this.registry.find(e,t);return n?n.scroll===this?n:t?this.find(n.scroll.domNode.parentNode,!0):null:null}query(e,t=Pk.ANY){return this.registry.query(e,t)}register(...e){return this.registry.register(...e)}build(){this.scroll!=null&&super.build()}detach(){super.detach(),this.observer.disconnect()}deleteAt(e,t){this.update(),e===0&&t===this.length()?this.children.forEach(e=>{e.remove()}):super.deleteAt(e,t)}formatAt(e,t,n,r){this.update(),super.formatAt(e,t,n,r)}insertAt(e,t,n){this.update(),super.insertAt(e,t,n)}optimize(e=[],t={}){super.optimize(t);let n=t.mutationsMap||new WeakMap,r=Array.from(this.observer.takeRecords());for(;r.length>0;)e.push(r.pop());let i=(e,t=!0)=>{e==null||e===this||e.domNode.parentNode!=null&&(n.has(e.domNode)||n.set(e.domNode,[]),t&&i(e.parent))},a=e=>{n.has(e.domNode)&&(e instanceof Zk&&e.children.forEach(a),n.delete(e.domNode),e.optimize(t))},o=e;for(let t=0;o.length>0;t+=1){if(t>=sA)throw Error(`[Parchment] Maximum optimize iterations reached`);for(o.forEach(e=>{let t=this.find(e.target,!0);t!=null&&(t.domNode===e.target&&(e.type===`childList`?(i(this.find(e.previousSibling,!1)),Array.from(e.addedNodes).forEach(e=>{let t=this.find(e,!1);i(t,!1),t instanceof Zk&&t.children.forEach(e=>{i(e,!1)})})):e.type===`attributes`&&i(t.prev)),i(t))}),this.children.forEach(a),o=Array.from(this.observer.takeRecords()),r=o.slice();r.length>0;)e.push(r.pop())}}update(e,t={}){e||=this.observer.takeRecords();let n=new WeakMap;e.map(e=>{let t=this.find(e.target,!0);return t==null?null:n.has(t.domNode)?(n.get(t.domNode).push(e),null):(n.set(t.domNode,[e]),t)}).forEach(e=>{e!=null&&e!==this&&n.has(e.domNode)&&e.update(n.get(e.domNode)||[],t)}),t.mutationsMap=n,n.has(this.domNode)&&super.update(n.get(this.domNode),t),this.optimize(e,t)}};cA.blotName=`scroll`,cA.defaultChild=nA,cA.allowedChildren=[nA,iA],cA.scope=Pk.BLOCK_BLOT,cA.tagName=`DIV`;var lA=cA,uA=class e extends qk{static create(e){return document.createTextNode(e)}static value(e){return e.data}constructor(e,t){super(e,t),this.text=this.statics.value(this.domNode)}deleteAt(e,t){this.domNode.data=this.text=this.text.slice(0,e)+this.text.slice(e+t)}index(e,t){return this.domNode===e?t:-1}insertAt(e,t,n){n==null?(this.text=this.text.slice(0,e)+t+this.text.slice(e),this.domNode.data=this.text):super.insertAt(e,t,n)}length(){return this.text.length}optimize(t){super.optimize(t),this.text=this.statics.value(this.domNode),this.text.length===0?this.remove():this.next instanceof e&&this.next.prev===this&&(this.insertAt(this.length(),this.next.value()),this.next.remove())}position(e,t=!1){return[this.domNode,e]}split(e,t=!1){if(!t){if(e===0)return this;if(e===this.length())return this.next}let n=this.scroll.create(this.domNode.splitText(e));return this.parent.insertBefore(n,this.next||void 0),this.text=this.statics.value(this.domNode),n}update(e,t){e.some(e=>e.type===`characterData`&&e.target===this.domNode)&&(this.text=this.statics.value(this.domNode))}value(){return this.text}};uA.blotName=`text`,uA.scope=Pk.INLINE_BLOT;var dA=uA,fA=o(((e,t)=>{var n=-1,r=1,i=0;function a(e,t,n,r,a){if(e===t)return e?[[i,e]]:[];if(n!=null){var s=D(e,t,n);if(s)return s}var c=l(e,t),u=e.substring(0,c);e=e.substring(c),t=t.substring(c),c=d(e,t);var f=e.substring(e.length-c);e=e.substring(0,e.length-c),t=t.substring(0,t.length-c);var m=o(e,t);return u&&m.unshift([i,u]),f&&m.push([i,f]),b(m,a),r&&p(m),m}function o(e,t){var o;if(!e)return[[r,t]];if(!t)return[[n,e]];var c=e.length>t.length?e:t,l=e.length>t.length?t:e,u=c.indexOf(l);if(u!==-1)return o=[[r,c.substring(0,u)],[i,l],[r,c.substring(u+l.length)]],e.length>t.length&&(o[0][0]=o[2][0]=n),o;if(l.length===1)return[[n,e],[r,t]];var d=f(e,t);if(d){var p=d[0],m=d[1],h=d[2],g=d[3],_=d[4],v=a(p,h),y=a(m,g);return v.concat([[i,_]],y)}return s(e,t)}function s(e,t){for(var i=e.length,a=t.length,o=Math.ceil((i+a)/2),s=o,l=2*o,u=Array(l),d=Array(l),f=0;f<l;f++)u[f]=-1,d[f]=-1;u[s+1]=0,d[s+1]=0;for(var p=i-a,m=p%2!=0,h=0,g=0,_=0,v=0,y=0;y<o;y++){for(var b=-y+h;b<=y-g;b+=2){for(var x=s+b,S=b===-y||b!==y&&u[x-1]<u[x+1]?u[x+1]:u[x-1]+1,C=S-b;S<i&&C<a&&e.charAt(S)===t.charAt(C);)S++,C++;if(u[x]=S,S>i)g+=2;else if(C>a)h+=2;else if(m){var w=s+p-b;if(w>=0&&w<l&&d[w]!==-1){var T=i-d[w];if(S>=T)return c(e,t,S,C)}}}for(var E=-y+_;E<=y-v;E+=2){for(var w=s+E,T=E===-y||E!==y&&d[w-1]<d[w+1]?d[w+1]:d[w-1]+1,D=T-E;T<i&&D<a&&e.charAt(i-T-1)===t.charAt(a-D-1);)T++,D++;if(d[w]=T,T>i)v+=2;else if(D>a)_+=2;else if(!m){var x=s+p-E;if(x>=0&&x<l&&u[x]!==-1){var S=u[x],C=s+S-x;if(T=i-T,S>=T)return c(e,t,S,C)}}}}return[[n,e],[r,t]]}function c(e,t,n,r){var i=e.substring(0,n),o=t.substring(0,r),s=e.substring(n),c=t.substring(r),l=a(i,o),u=a(s,c);return l.concat(u)}function l(e,t){if(!e||!t||e.charAt(0)!==t.charAt(0))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(a,i)==t.substring(a,i)?(n=i,a=n):r=i,i=Math.floor((r-n)/2+n);return x(e.charCodeAt(i-1))&&i--,i}function u(e,t){var n=e.length,r=t.length;if(n==0||r==0)return 0;n>r?e=e.substring(n-r):n<r&&(t=t.substring(0,n));var i=Math.min(n,r);if(e==t)return i;for(var a=0,o=1;;){var s=e.substring(i-o),c=t.indexOf(s);if(c==-1)return a;o+=c,(c==0||e.substring(i-o)==t.substring(0,o))&&(a=o,o++)}}function d(e,t){if(!e||!t||e.slice(-1)!==t.slice(-1))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,a=0;n<i;)e.substring(e.length-i,e.length-a)==t.substring(t.length-i,t.length-a)?(n=i,a=n):r=i,i=Math.floor((r-n)/2+n);return S(e.charCodeAt(e.length-i))&&i--,i}function f(e,t){var n=e.length>t.length?e:t,r=e.length>t.length?t:e;if(n.length<4||r.length*2<n.length)return null;function i(e,t,n){for(var r=e.substring(n,n+Math.floor(e.length/4)),i=-1,a=``,o,s,c,u;(i=t.indexOf(r,i+1))!==-1;){var f=l(e.substring(n),t.substring(i)),p=d(e.substring(0,n),t.substring(0,i));a.length<p+f&&(a=t.substring(i-p,i)+t.substring(i,i+f),o=e.substring(0,n-p),s=e.substring(n+f),c=t.substring(0,i-p),u=t.substring(i+f))}return a.length*2>=e.length?[o,s,c,u,a]:null}var a=i(n,r,Math.ceil(n.length/4)),o=i(n,r,Math.ceil(n.length/2)),s;if(!a&&!o)return null;s=o?a&&a[4].length>o[4].length?a:o:a;var c,u,f,p;e.length>t.length?(c=s[0],u=s[1],f=s[2],p=s[3]):(f=s[0],p=s[1],c=s[2],u=s[3]);var m=s[4];return[c,u,f,p,m]}function p(e){for(var t=!1,a=[],o=0,s=null,c=0,l=0,d=0,f=0,p=0;c<e.length;)e[c][0]==i?(a[o++]=c,l=f,d=p,f=0,p=0,s=e[c][1]):(e[c][0]==r?f+=e[c][1].length:p+=e[c][1].length,s&&s.length<=Math.max(l,d)&&s.length<=Math.max(f,p)&&(e.splice(a[o-1],0,[n,s]),e[a[o-1]+1][0]=r,o--,o--,c=o>0?a[o-1]:-1,l=0,d=0,f=0,p=0,s=null,t=!0)),c++;for(t&&b(e),y(e),c=1;c<e.length;){if(e[c-1][0]==n&&e[c][0]==r){var m=e[c-1][1],h=e[c][1],g=u(m,h),_=u(h,m);g>=_?(g>=m.length/2||g>=h.length/2)&&(e.splice(c,0,[i,h.substring(0,g)]),e[c-1][1]=m.substring(0,m.length-g),e[c+1][1]=h.substring(g),c++):(_>=m.length/2||_>=h.length/2)&&(e.splice(c,0,[i,m.substring(0,_)]),e[c-1][0]=r,e[c-1][1]=h.substring(0,h.length-_),e[c+1][0]=n,e[c+1][1]=m.substring(_),c++),c++}c++}}var m=/[^a-zA-Z0-9]/,h=/\s/,g=/[\r\n]/,_=/\n\r?\n$/,v=/^\r?\n\r?\n/;function y(e){function t(e,t){if(!e||!t)return 6;var n=e.charAt(e.length-1),r=t.charAt(0),i=n.match(m),a=r.match(m),o=i&&n.match(h),s=a&&r.match(h),c=o&&n.match(g),l=s&&r.match(g),u=c&&e.match(_),d=l&&t.match(v);return u||d?5:c||l?4:i&&!o&&s?3:o||s?2:i||a?1:0}for(var n=1;n<e.length-1;){if(e[n-1][0]==i&&e[n+1][0]==i){var r=e[n-1][1],a=e[n][1],o=e[n+1][1],s=d(r,a);if(s){var c=a.substring(a.length-s);r=r.substring(0,r.length-s),a=c+a.substring(0,a.length-s),o=c+o}for(var l=r,u=a,f=o,p=t(r,a)+t(a,o);a.charAt(0)===o.charAt(0);){r+=a.charAt(0),a=a.substring(1)+o.charAt(0),o=o.substring(1);var y=t(r,a)+t(a,o);y>=p&&(p=y,l=r,u=a,f=o)}e[n-1][1]!=l&&(l?e[n-1][1]=l:(e.splice(n-1,1),n--),e[n][1]=u,f?e[n+1][1]=f:(e.splice(n+1,1),n--))}n++}}function b(e,t){e.push([i,``]);for(var a=0,o=0,s=0,c=``,u=``,f;a<e.length;){if(a<e.length-1&&!e[a][1]){e.splice(a,1);continue}switch(e[a][0]){case r:s++,u+=e[a][1],a++;break;case n:o++,c+=e[a][1],a++;break;case i:var p=a-s-o-1;if(t){if(p>=0&&w(e[p][1])){var m=e[p][1].slice(-1);if(e[p][1]=e[p][1].slice(0,-1),c=m+c,u=m+u,!e[p][1]){e.splice(p,1),a--;var h=p-1;e[h]&&e[h][0]===r&&(s++,u=e[h][1]+u,h--),e[h]&&e[h][0]===n&&(o++,c=e[h][1]+c,h--),p=h}}if(C(e[a][1])){var m=e[a][1].charAt(0);e[a][1]=e[a][1].slice(1),c+=m,u+=m}}if(a<e.length-1&&!e[a][1]){e.splice(a,1);break}if(c.length>0||u.length>0){c.length>0&&u.length>0&&(f=l(u,c),f!==0&&(p>=0?e[p][1]+=u.substring(0,f):(e.splice(0,0,[i,u.substring(0,f)]),a++),u=u.substring(f),c=c.substring(f)),f=d(u,c),f!==0&&(e[a][1]=u.substring(u.length-f)+e[a][1],u=u.substring(0,u.length-f),c=c.substring(0,c.length-f)));var g=s+o;c.length===0&&u.length===0?(e.splice(a-g,g),a-=g):c.length===0?(e.splice(a-g,g,[r,u]),a=a-g+1):u.length===0?(e.splice(a-g,g,[n,c]),a=a-g+1):(e.splice(a-g,g,[n,c],[r,u]),a=a-g+2)}a!==0&&e[a-1][0]===i?(e[a-1][1]+=e[a][1],e.splice(a,1)):a++,s=0,o=0,c=``,u=``;break}}e[e.length-1][1]===``&&e.pop();var _=!1;for(a=1;a<e.length-1;)e[a-1][0]===i&&e[a+1][0]===i&&(e[a][1].substring(e[a][1].length-e[a-1][1].length)===e[a-1][1]?(e[a][1]=e[a-1][1]+e[a][1].substring(0,e[a][1].length-e[a-1][1].length),e[a+1][1]=e[a-1][1]+e[a+1][1],e.splice(a-1,1),_=!0):e[a][1].substring(0,e[a+1][1].length)==e[a+1][1]&&(e[a-1][1]+=e[a+1][1],e[a][1]=e[a][1].substring(e[a+1][1].length)+e[a+1][1],e.splice(a+1,1),_=!0)),a++;_&&b(e,t)}function x(e){return e>=55296&&e<=56319}function S(e){return e>=56320&&e<=57343}function C(e){return S(e.charCodeAt(0))}function w(e){return x(e.charCodeAt(e.length-1))}function T(e){for(var t=[],n=0;n<e.length;n++)e[n][1].length>0&&t.push(e[n]);return t}function E(e,t,a,o){return w(e)||C(o)?null:T([[i,e],[n,t],[r,a],[i,o]])}function D(e,t,n){var r=typeof n==`number`?{index:n,length:0}:n.oldRange,i=typeof n==`number`?null:n.newRange,a=e.length,o=t.length;if(r.length===0&&(i===null||i.length===0)){var s=r.index,c=e.slice(0,s),l=e.slice(s),u=i?i.index:null;editBefore:{var d=s+o-a;if(u!==null&&u!==d||d<0||d>o)break editBefore;var f=t.slice(0,d),p=t.slice(d);if(p!==l)break editBefore;var m=Math.min(s,d),h=c.slice(0,m),g=f.slice(0,m);if(h!==g)break editBefore;var _=c.slice(m),v=f.slice(m);return E(h,_,v,l)}editAfter:{if(u!==null&&u!==s)break editAfter;var y=s,f=t.slice(0,y),p=t.slice(y);if(f!==c)break editAfter;var b=Math.min(a-y,o-y),x=l.slice(l.length-b),S=p.slice(p.length-b);if(x!==S)break editAfter;var _=l.slice(0,l.length-b),v=p.slice(0,p.length-b);return E(c,_,v,x)}}if(r.length>0&&i&&i.length===0)replaceRange:{var h=e.slice(0,r.index),x=e.slice(r.index+r.length),m=h.length,b=x.length;if(o<m+b)break replaceRange;var g=t.slice(0,m),S=t.slice(o-b);if(h!==g||x!==S)break replaceRange;var _=e.slice(m,a-b),v=t.slice(m,o-b);return E(h,_,v,x)}return null}function O(e,t,n,r){return a(e,t,n,r,!0)}O.INSERT=r,O.DELETE=n,O.EQUAL=i,t.exports=O})),pA=o(((e,t)=>{var n=200,r=`__lodash_hash_undefined__`,i=9007199254740991,a=`[object Arguments]`,o=`[object Array]`,s=`[object Boolean]`,c=`[object Date]`,l=`[object Error]`,u=`[object Function]`,d=`[object GeneratorFunction]`,f=`[object Map]`,p=`[object Number]`,m=`[object Object]`,h=`[object Promise]`,g=`[object RegExp]`,_=`[object Set]`,v=`[object String]`,y=`[object Symbol]`,b=`[object WeakMap]`,x=`[object ArrayBuffer]`,S=`[object DataView]`,C=`[object Float32Array]`,w=`[object Float64Array]`,T=`[object Int8Array]`,E=`[object Int16Array]`,D=`[object Int32Array]`,O=`[object Uint8Array]`,k=`[object Uint8ClampedArray]`,ee=`[object Uint16Array]`,A=`[object Uint32Array]`,j=/[\\^$.*+?()[\]{}|]/g,te=/\w*$/,M=/^\[object .+?Constructor\]$/,ne=/^(?:0|[1-9]\d*)$/,N={};N[a]=N[o]=N[x]=N[S]=N[s]=N[c]=N[C]=N[w]=N[T]=N[E]=N[D]=N[f]=N[p]=N[m]=N[g]=N[_]=N[v]=N[y]=N[O]=N[k]=N[ee]=N[A]=!0,N[l]=N[u]=N[b]=!1;var P=typeof global==`object`&&global&&global.Object===Object&&global,re=typeof self==`object`&&self&&self.Object===Object&&self,ie=P||re||Function(`return this`)(),ae=typeof e==`object`&&e&&!e.nodeType&&e,F=ae&&typeof t==`object`&&t&&!t.nodeType&&t,oe=F&&F.exports===ae;function se(e,t){return e.set(t[0],t[1]),e}function ce(e,t){return e.add(t),e}function le(e,t){for(var n=-1,r=e?e.length:0;++n<r&&t(e[n],n,e)!==!1;);return e}function ue(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function de(e,t,n,r){var i=-1,a=e?e.length:0;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}function fe(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function pe(e,t){return e?.[t]}function me(e){var t=!1;if(e!=null&&typeof e.toString!=`function`)try{t=!!(e+``)}catch{}return t}function he(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function ge(e,t){return function(n){return e(t(n))}}function _e(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var ve=Array.prototype,ye=Function.prototype,be=Object.prototype,xe=ie[`__core-js_shared__`],Se=function(){var e=/[^.]+$/.exec(xe&&xe.keys&&xe.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}(),Ce=ye.toString,we=be.hasOwnProperty,Te=be.toString,Ee=RegExp(`^`+Ce.call(we).replace(j,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`),De=oe?ie.Buffer:void 0,Oe=ie.Symbol,ke=ie.Uint8Array,Ae=ge(Object.getPrototypeOf,Object),je=Object.create,Me=be.propertyIsEnumerable,Ne=ve.splice,Pe=Object.getOwnPropertySymbols,Fe=De?De.isBuffer:void 0,Ie=ge(Object.keys,Object),Le=Ht(ie,`DataView`),Re=Ht(ie,`Map`),ze=Ht(ie,`Promise`),I=Ht(ie,`Set`),Be=Ht(ie,`WeakMap`),Ve=Ht(Object,`create`),He=Qt(Le),Ue=Qt(Re),We=Qt(ze),Ge=Qt(I),Ke=Qt(Be),qe=Oe?Oe.prototype:void 0,Je=qe?qe.valueOf:void 0;function Ye(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function Xe(){this.__data__=Ve?Ve(null):{}}function Ze(e){return this.has(e)&&delete this.__data__[e]}function Qe(e){var t=this.__data__;if(Ve){var n=t[e];return n===r?void 0:n}return we.call(t,e)?t[e]:void 0}function $e(e){var t=this.__data__;return Ve?t[e]!==void 0:we.call(t,e)}function et(e,t){var n=this.__data__;return n[e]=Ve&&t===void 0?r:t,this}Ye.prototype.clear=Xe,Ye.prototype.delete=Ze,Ye.prototype.get=Qe,Ye.prototype.has=$e,Ye.prototype.set=et;function tt(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function nt(){this.__data__=[]}function rt(e){var t=this.__data__,n=xt(t,e);return n<0?!1:(n==t.length-1?t.pop():Ne.call(t,n,1),!0)}function it(e){var t=this.__data__,n=xt(t,e);return n<0?void 0:t[n][1]}function at(e){return xt(this.__data__,e)>-1}function ot(e,t){var n=this.__data__,r=xt(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}tt.prototype.clear=nt,tt.prototype.delete=rt,tt.prototype.get=it,tt.prototype.has=at,tt.prototype.set=ot;function st(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ct(){this.__data__={hash:new Ye,map:new(Re||tt),string:new Ye}}function lt(e){return Vt(this,e).delete(e)}function ut(e){return Vt(this,e).get(e)}function dt(e){return Vt(this,e).has(e)}function ft(e,t){return Vt(this,e).set(e,t),this}st.prototype.clear=ct,st.prototype.delete=lt,st.prototype.get=ut,st.prototype.has=dt,st.prototype.set=ft;function pt(e){this.__data__=new tt(e)}function mt(){this.__data__=new tt}function ht(e){return this.__data__.delete(e)}function gt(e){return this.__data__.get(e)}function _t(e){return this.__data__.has(e)}function vt(e,t){var r=this.__data__;if(r instanceof tt){var i=r.__data__;if(!Re||i.length<n-1)return i.push([e,t]),this;r=this.__data__=new st(i)}return r.set(e,t),this}pt.prototype.clear=mt,pt.prototype.delete=ht,pt.prototype.get=gt,pt.prototype.has=_t,pt.prototype.set=vt;function yt(e,t){var n=nn(e)||tn(e)?fe(e.length,String):[],r=n.length,i=!!r;for(var a in e)(t||we.call(e,a))&&!(i&&(a==`length`||Jt(a,r)))&&n.push(a);return n}function bt(e,t,n){var r=e[t];(!(we.call(e,t)&&en(r,n))||n===void 0&&!(t in e))&&(e[t]=n)}function xt(e,t){for(var n=e.length;n--;)if(en(e[n][0],t))return n;return-1}function St(e,t){return e&&Rt(t,dn(t),e)}function Ct(e,t,n,r,i,o,s){var c;if(r&&(c=o?r(e,i,o,s):r(e)),c!==void 0)return c;if(!ln(e))return e;var l=nn(e);if(l){if(c=Gt(e),!t)return Lt(e,c)}else{var f=Wt(e),p=f==u||f==d;if(on(e))return kt(e,t);if(f==m||f==a||p&&!o){if(me(e))return o?e:{};if(c=Kt(p?{}:e),!t)return zt(e,St(c,e))}else{if(!N[f])return o?e:{};c=qt(e,f,Ct,t)}}s||=new pt;var h=s.get(e);if(h)return h;if(s.set(e,c),!l)var g=n?Bt(e):dn(e);return le(g||e,function(i,a){g&&(a=i,i=e[a]),bt(c,a,Ct(i,t,n,r,a,e,s))}),c}function wt(e){return ln(e)?je(e):{}}function Tt(e,t,n){var r=t(e);return nn(e)?r:ue(r,n(e))}function Et(e){return Te.call(e)}function Dt(e){return!ln(e)||Xt(e)?!1:(sn(e)||me(e)?Ee:M).test(Qt(e))}function Ot(e){if(!Zt(e))return Ie(e);var t=[];for(var n in Object(e))we.call(e,n)&&n!=`constructor`&&t.push(n);return t}function kt(e,t){if(t)return e.slice();var n=new e.constructor(e.length);return e.copy(n),n}function At(e){var t=new e.constructor(e.byteLength);return new ke(t).set(new ke(e)),t}function jt(e,t){var n=t?At(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}function Mt(e,t,n){return de(t?n(he(e),!0):he(e),se,new e.constructor)}function Nt(e){var t=new e.constructor(e.source,te.exec(e));return t.lastIndex=e.lastIndex,t}function Pt(e,t,n){return de(t?n(_e(e),!0):_e(e),ce,new e.constructor)}function Ft(e){return Je?Object(Je.call(e)):{}}function It(e,t){var n=t?At(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function Lt(e,t){var n=-1,r=e.length;for(t||=Array(r);++n<r;)t[n]=e[n];return t}function Rt(e,t,n,r){n||={};for(var i=-1,a=t.length;++i<a;){var o=t[i],s=r?r(n[o],e[o],o,n,e):void 0;bt(n,o,s===void 0?e[o]:s)}return n}function zt(e,t){return Rt(e,Ut(e),t)}function Bt(e){return Tt(e,dn,Ut)}function Vt(e,t){var n=e.__data__;return Yt(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function Ht(e,t){var n=pe(e,t);return Dt(n)?n:void 0}var Ut=Pe?ge(Pe,Object):fn,Wt=Et;(Le&&Wt(new Le(new ArrayBuffer(1)))!=S||Re&&Wt(new Re)!=f||ze&&Wt(ze.resolve())!=h||I&&Wt(new I)!=_||Be&&Wt(new Be)!=b)&&(Wt=function(e){var t=Te.call(e),n=t==m?e.constructor:void 0,r=n?Qt(n):void 0;if(r)switch(r){case He:return S;case Ue:return f;case We:return h;case Ge:return _;case Ke:return b}return t});function Gt(e){var t=e.length,n=e.constructor(t);return t&&typeof e[0]==`string`&&we.call(e,`index`)&&(n.index=e.index,n.input=e.input),n}function Kt(e){return typeof e.constructor==`function`&&!Zt(e)?wt(Ae(e)):{}}function qt(e,t,n,r){var i=e.constructor;switch(t){case x:return At(e);case s:case c:return new i(+e);case S:return jt(e,r);case C:case w:case T:case E:case D:case O:case k:case ee:case A:return It(e,r);case f:return Mt(e,r,n);case p:case v:return new i(e);case g:return Nt(e);case _:return Pt(e,r,n);case y:return Ft(e)}}function Jt(e,t){return t??=i,!!t&&(typeof e==`number`||ne.test(e))&&e>-1&&e%1==0&&e<t}function Yt(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function Xt(e){return!!Se&&Se in e}function Zt(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||be)}function Qt(e){if(e!=null){try{return Ce.call(e)}catch{}try{return e+``}catch{}}return``}function $t(e){return Ct(e,!0,!0)}function en(e,t){return e===t||e!==e&&t!==t}function tn(e){return an(e)&&we.call(e,`callee`)&&(!Me.call(e,`callee`)||Te.call(e)==a)}var nn=Array.isArray;function rn(e){return e!=null&&cn(e.length)&&!sn(e)}function an(e){return un(e)&&rn(e)}var on=Fe||pn;function sn(e){var t=ln(e)?Te.call(e):``;return t==u||t==d}function cn(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=i}function ln(e){var t=typeof e;return!!e&&(t==`object`||t==`function`)}function un(e){return!!e&&typeof e==`object`}function dn(e){return rn(e)?yt(e):Ot(e)}function fn(){return[]}function pn(){return!1}t.exports=$t})),mA=o(((e,t)=>{var n=200,r=`__lodash_hash_undefined__`,i=1,a=2,o=9007199254740991,s=`[object Arguments]`,c=`[object Array]`,l=`[object AsyncFunction]`,u=`[object Boolean]`,d=`[object Date]`,f=`[object Error]`,p=`[object Function]`,m=`[object GeneratorFunction]`,h=`[object Map]`,g=`[object Number]`,_=`[object Null]`,v=`[object Object]`,y=`[object Promise]`,b=`[object Proxy]`,x=`[object RegExp]`,S=`[object Set]`,C=`[object String]`,w=`[object Symbol]`,T=`[object Undefined]`,E=`[object WeakMap]`,D=`[object ArrayBuffer]`,O=`[object DataView]`,k=`[object Float32Array]`,ee=`[object Float64Array]`,A=`[object Int8Array]`,j=`[object Int16Array]`,te=`[object Int32Array]`,M=`[object Uint8Array]`,ne=`[object Uint8ClampedArray]`,N=`[object Uint16Array]`,P=`[object Uint32Array]`,re=/[\\^$.*+?()[\]{}|]/g,ie=/^\[object .+?Constructor\]$/,ae=/^(?:0|[1-9]\d*)$/,F={};F[k]=F[ee]=F[A]=F[j]=F[te]=F[M]=F[ne]=F[N]=F[P]=!0,F[s]=F[c]=F[D]=F[u]=F[O]=F[d]=F[f]=F[p]=F[h]=F[g]=F[v]=F[x]=F[S]=F[C]=F[E]=!1;var oe=typeof global==`object`&&global&&global.Object===Object&&global,se=typeof self==`object`&&self&&self.Object===Object&&self,ce=oe||se||Function(`return this`)(),le=typeof e==`object`&&e&&!e.nodeType&&e,ue=le&&typeof t==`object`&&t&&!t.nodeType&&t,de=ue&&ue.exports===le,fe=de&&oe.process,pe=function(){try{return fe&&fe.binding&&fe.binding(`util`)}catch{}}(),me=pe&&pe.isTypedArray;function he(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function ge(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}function _e(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function ve(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}function ye(e){return function(t){return e(t)}}function be(e,t){return e.has(t)}function xe(e,t){return e?.[t]}function Se(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function Ce(e,t){return function(n){return e(t(n))}}function we(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var Te=Array.prototype,Ee=Function.prototype,De=Object.prototype,Oe=ce[`__core-js_shared__`],ke=Ee.toString,Ae=De.hasOwnProperty,je=function(){var e=/[^.]+$/.exec(Oe&&Oe.keys&&Oe.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}(),Me=De.toString,Ne=RegExp(`^`+ke.call(Ae).replace(re,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`),Pe=de?ce.Buffer:void 0,Fe=ce.Symbol,Ie=ce.Uint8Array,Le=De.propertyIsEnumerable,Re=Te.splice,ze=Fe?Fe.toStringTag:void 0,I=Object.getOwnPropertySymbols,Be=Pe?Pe.isBuffer:void 0,Ve=Ce(Object.keys,Object),He=Ut(ce,`DataView`),Ue=Ut(ce,`Map`),We=Ut(ce,`Promise`),Ge=Ut(ce,`Set`),Ke=Ut(ce,`WeakMap`),qe=Ut(Object,`create`),Je=Qt(He),Ye=Qt(Ue),Xe=Qt(We),Ze=Qt(Ge),Qe=Qt(Ke),$e=Fe?Fe.prototype:void 0,et=$e?$e.valueOf:void 0;function tt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function nt(){this.__data__=qe?qe(null):{},this.size=0}function rt(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t}function it(e){var t=this.__data__;if(qe){var n=t[e];return n===r?void 0:n}return Ae.call(t,e)?t[e]:void 0}function at(e){var t=this.__data__;return qe?t[e]!==void 0:Ae.call(t,e)}function ot(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=qe&&t===void 0?r:t,this}tt.prototype.clear=nt,tt.prototype.delete=rt,tt.prototype.get=it,tt.prototype.has=at,tt.prototype.set=ot;function st(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function ct(){this.__data__=[],this.size=0}function lt(e){var t=this.__data__,n=kt(t,e);return n<0?!1:(n==t.length-1?t.pop():Re.call(t,n,1),--this.size,!0)}function ut(e){var t=this.__data__,n=kt(t,e);return n<0?void 0:t[n][1]}function dt(e){return kt(this.__data__,e)>-1}function ft(e,t){var n=this.__data__,r=kt(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}st.prototype.clear=ct,st.prototype.delete=lt,st.prototype.get=ut,st.prototype.has=dt,st.prototype.set=ft;function pt(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function mt(){this.size=0,this.__data__={hash:new tt,map:new(Ue||st),string:new tt}}function ht(e){var t=Ht(this,e).delete(e);return this.size-=+!!t,t}function gt(e){return Ht(this,e).get(e)}function _t(e){return Ht(this,e).has(e)}function vt(e,t){var n=Ht(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}pt.prototype.clear=mt,pt.prototype.delete=ht,pt.prototype.get=gt,pt.prototype.has=_t,pt.prototype.set=vt;function yt(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new pt;++t<n;)this.add(e[t])}function bt(e){return this.__data__.set(e,r),this}function xt(e){return this.__data__.has(e)}yt.prototype.add=yt.prototype.push=bt,yt.prototype.has=xt;function St(e){var t=this.__data__=new st(e);this.size=t.size}function Ct(){this.__data__=new st,this.size=0}function wt(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}function Tt(e){return this.__data__.get(e)}function Et(e){return this.__data__.has(e)}function Dt(e,t){var r=this.__data__;if(r instanceof st){var i=r.__data__;if(!Ue||i.length<n-1)return i.push([e,t]),this.size=++r.size,this;r=this.__data__=new pt(i)}return r.set(e,t),this.size=r.size,this}St.prototype.clear=Ct,St.prototype.delete=wt,St.prototype.get=Tt,St.prototype.has=Et,St.prototype.set=Dt;function Ot(e,t){var n=tn(e),r=!n&&en(e),i=!n&&!r&&rn(e),a=!n&&!r&&!i&&un(e),o=n||r||i||a,s=o?ve(e.length,String):[],c=s.length;for(var l in e)(t||Ae.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||qt(l,c)))&&s.push(l);return s}function kt(e,t){for(var n=e.length;n--;)if($t(e[n][0],t))return n;return-1}function At(e,t,n){var r=t(e);return tn(e)?r:ge(r,n(e))}function jt(e){return e==null?e===void 0?T:_:ze&&ze in Object(e)?Wt(e):Zt(e)}function Mt(e){return ln(e)&&jt(e)==s}function Nt(e,t,n,r,i){return e===t?!0:e==null||t==null||!ln(e)&&!ln(t)?e!==e&&t!==t:Pt(e,t,n,r,Nt,i)}function Pt(e,t,n,r,a,o){var l=tn(e),u=tn(t),d=l?c:Kt(e),f=u?c:Kt(t);d=d==s?v:d,f=f==s?v:f;var p=d==v,m=f==v,h=d==f;if(h&&rn(e)){if(!rn(t))return!1;l=!0,p=!1}if(h&&!p)return o||=new St,l||un(e)?Rt(e,t,n,r,a,o):zt(e,t,d,n,r,a,o);if(!(n&i)){var g=p&&Ae.call(e,`__wrapped__`),_=m&&Ae.call(t,`__wrapped__`);if(g||_){var y=g?e.value():e,b=_?t.value():t;return o||=new St,a(y,b,n,r,o)}}return h?(o||=new St,Bt(e,t,n,r,a,o)):!1}function Ft(e){return!cn(e)||Yt(e)?!1:(on(e)?Ne:ie).test(Qt(e))}function It(e){return ln(e)&&sn(e.length)&&!!F[jt(e)]}function Lt(e){if(!Xt(e))return Ve(e);var t=[];for(var n in Object(e))Ae.call(e,n)&&n!=`constructor`&&t.push(n);return t}function Rt(e,t,n,r,o,s){var c=n&i,l=e.length,u=t.length;if(l!=u&&!(c&&u>l))return!1;var d=s.get(e);if(d&&s.get(t))return d==t;var f=-1,p=!0,m=n&a?new yt:void 0;for(s.set(e,t),s.set(t,e);++f<l;){var h=e[f],g=t[f];if(r)var _=c?r(g,h,f,t,e,s):r(h,g,f,e,t,s);if(_!==void 0){if(_)continue;p=!1;break}if(m){if(!_e(t,function(e,t){if(!be(m,t)&&(h===e||o(h,e,n,r,s)))return m.push(t)})){p=!1;break}}else if(!(h===g||o(h,g,n,r,s))){p=!1;break}}return s.delete(e),s.delete(t),p}function zt(e,t,n,r,o,s,c){switch(n){case O:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case D:return!(e.byteLength!=t.byteLength||!s(new Ie(e),new Ie(t)));case u:case d:case g:return $t(+e,+t);case f:return e.name==t.name&&e.message==t.message;case x:case C:return e==t+``;case h:var l=Se;case S:var p=r&i;if(l||=we,e.size!=t.size&&!p)return!1;var m=c.get(e);if(m)return m==t;r|=a,c.set(e,t);var _=Rt(l(e),l(t),r,o,s,c);return c.delete(e),_;case w:if(et)return et.call(e)==et.call(t)}return!1}function Bt(e,t,n,r,a,o){var s=n&i,c=Vt(e),l=c.length;if(l!=Vt(t).length&&!s)return!1;for(var u=l;u--;){var d=c[u];if(!(s?d in t:Ae.call(t,d)))return!1}var f=o.get(e);if(f&&o.get(t))return f==t;var p=!0;o.set(e,t),o.set(t,e);for(var m=s;++u<l;){d=c[u];var h=e[d],g=t[d];if(r)var _=s?r(g,h,d,t,e,o):r(h,g,d,e,t,o);if(!(_===void 0?h===g||a(h,g,n,r,o):_)){p=!1;break}m||=d==`constructor`}if(p&&!m){var v=e.constructor,y=t.constructor;v!=y&&`constructor`in e&&`constructor`in t&&!(typeof v==`function`&&v instanceof v&&typeof y==`function`&&y instanceof y)&&(p=!1)}return o.delete(e),o.delete(t),p}function Vt(e){return At(e,dn,Gt)}function Ht(e,t){var n=e.__data__;return Jt(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function Ut(e,t){var n=xe(e,t);return Ft(n)?n:void 0}function Wt(e){var t=Ae.call(e,ze),n=e[ze];try{e[ze]=void 0;var r=!0}catch{}var i=Me.call(e);return r&&(t?e[ze]=n:delete e[ze]),i}var Gt=I?function(e){return e==null?[]:(e=Object(e),he(I(e),function(t){return Le.call(e,t)}))}:fn,Kt=jt;(He&&Kt(new He(new ArrayBuffer(1)))!=O||Ue&&Kt(new Ue)!=h||We&&Kt(We.resolve())!=y||Ge&&Kt(new Ge)!=S||Ke&&Kt(new Ke)!=E)&&(Kt=function(e){var t=jt(e),n=t==v?e.constructor:void 0,r=n?Qt(n):``;if(r)switch(r){case Je:return O;case Ye:return h;case Xe:return y;case Ze:return S;case Qe:return E}return t});function qt(e,t){return t??=o,!!t&&(typeof e==`number`||ae.test(e))&&e>-1&&e%1==0&&e<t}function Jt(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function Yt(e){return!!je&&je in e}function Xt(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||De)}function Zt(e){return Me.call(e)}function Qt(e){if(e!=null){try{return ke.call(e)}catch{}try{return e+``}catch{}}return``}function $t(e,t){return e===t||e!==e&&t!==t}var en=Mt(function(){return arguments}())?Mt:function(e){return ln(e)&&Ae.call(e,`callee`)&&!Le.call(e,`callee`)},tn=Array.isArray;function nn(e){return e!=null&&sn(e.length)&&!on(e)}var rn=Be||pn;function an(e,t){return Nt(e,t)}function on(e){if(!cn(e))return!1;var t=jt(e);return t==p||t==m||t==l||t==b}function sn(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=o}function cn(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}function ln(e){return typeof e==`object`&&!!e}var un=me?ye(me):It;function dn(e){return nn(e)?Ot(e):Lt(e)}function fn(){return[]}function pn(){return!1}t.exports=an})),hA=o((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=pA(),n=mA(),r;(function(e){function r(e={},n={},r=!1){typeof e!=`object`&&(e={}),typeof n!=`object`&&(n={});let i=t(n);r||(i=Object.keys(i).reduce((e,t)=>(i[t]!=null&&(e[t]=i[t]),e),{}));for(let t in e)e[t]!==void 0&&n[t]===void 0&&(i[t]=e[t]);return Object.keys(i).length>0?i:void 0}e.compose=r;function i(e={},t={}){typeof e!=`object`&&(e={}),typeof t!=`object`&&(t={});let r=Object.keys(e).concat(Object.keys(t)).reduce((r,i)=>(n(e[i],t[i])||(r[i]=t[i]===void 0?null:t[i]),r),{});return Object.keys(r).length>0?r:void 0}e.diff=i;function a(e={},t={}){e||={};let n=Object.keys(t).reduce((n,r)=>(t[r]!==e[r]&&e[r]!==void 0&&(n[r]=t[r]),n),{});return Object.keys(e).reduce((n,r)=>(e[r]!==t[r]&&t[r]===void 0&&(n[r]=null),n),n)}e.invert=a;function o(e,t,n=!1){if(typeof e!=`object`)return t;if(typeof t!=`object`)return;if(!n)return t;let r=Object.keys(t).reduce((n,r)=>(e[r]===void 0&&(n[r]=t[r]),n),{});return Object.keys(r).length>0?r:void 0}e.transform=o})(r||={}),e.default=r})),gA=o((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t;(function(e){function t(e){return typeof e.delete==`number`?e.delete:typeof e.retain==`number`?e.retain:typeof e.retain==`object`&&e.retain!==null?1:typeof e.insert==`string`?e.insert.length:1}e.length=t})(t||={}),e.default=t})),_A=o((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=gA();e.default=class{constructor(e){this.ops=e,this.index=0,this.offset=0}hasNext(){return this.peekLength()<1/0}next(e){e||=1/0;let n=this.ops[this.index];if(n){let r=this.offset,i=t.default.length(n);if(e>=i-r?(e=i-r,this.index+=1,this.offset=0):this.offset+=e,typeof n.delete==`number`)return{delete:e};{let t={};return n.attributes&&(t.attributes=n.attributes),typeof n.retain==`number`?t.retain=e:typeof n.retain==`object`&&n.retain!==null?t.retain=n.retain:typeof n.insert==`string`?t.insert=n.insert.substr(r,e):t.insert=n.insert,t}}else return{retain:1/0}}peek(){return this.ops[this.index]}peekLength(){return this.ops[this.index]?t.default.length(this.ops[this.index])-this.offset:1/0}peekType(){let e=this.ops[this.index];return e?typeof e.delete==`number`?`delete`:typeof e.retain==`number`||typeof e.retain==`object`&&e.retain!==null?`retain`:`insert`:`retain`}rest(){if(!this.hasNext())return[];if(this.offset===0)return this.ops.slice(this.index);{let e=this.offset,t=this.index,n=this.next(),r=this.ops.slice(this.index);return this.offset=e,this.index=t,[n].concat(r)}}}})),vA=l(o(((e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AttributeMap=e.OpIterator=e.Op=void 0;var n=fA(),r=pA(),i=mA(),a=hA();e.AttributeMap=a.default;var o=gA();e.Op=o.default;var s=_A();e.OpIterator=s.default;var c=`\0`,l=(e,t)=>{if(typeof e!=`object`||!e)throw Error(`cannot retain a ${typeof e}`);if(typeof t!=`object`||!t)throw Error(`cannot retain a ${typeof t}`);let n=Object.keys(e)[0];if(!n||n!==Object.keys(t)[0])throw Error(`embed types not matched: ${n} != ${Object.keys(t)[0]}`);return[n,e[n],t[n]]},u=class e{constructor(e){Array.isArray(e)?this.ops=e:e!=null&&Array.isArray(e.ops)?this.ops=e.ops:this.ops=[]}static registerEmbed(e,t){this.handlers[e]=t}static unregisterEmbed(e){delete this.handlers[e]}static getHandler(e){let t=this.handlers[e];if(!t)throw Error(`no handlers for embed type "${e}"`);return t}insert(e,t){let n={};return typeof e==`string`&&e.length===0?this:(n.insert=e,typeof t==`object`&&t&&Object.keys(t).length>0&&(n.attributes=t),this.push(n))}delete(e){return e<=0?this:this.push({delete:e})}retain(e,t){if(typeof e==`number`&&e<=0)return this;let n={retain:e};return typeof t==`object`&&t&&Object.keys(t).length>0&&(n.attributes=t),this.push(n)}push(e){let t=this.ops.length,n=this.ops[t-1];if(e=r(e),typeof n==`object`){if(typeof e.delete==`number`&&typeof n.delete==`number`)return this.ops[t-1]={delete:n.delete+e.delete},this;if(typeof n.delete==`number`&&e.insert!=null&&(--t,n=this.ops[t-1],typeof n!=`object`))return this.ops.unshift(e),this;if(i(e.attributes,n.attributes)){if(typeof e.insert==`string`&&typeof n.insert==`string`)return this.ops[t-1]={insert:n.insert+e.insert},typeof e.attributes==`object`&&(this.ops[t-1].attributes=e.attributes),this;if(typeof e.retain==`number`&&typeof n.retain==`number`)return this.ops[t-1]={retain:n.retain+e.retain},typeof e.attributes==`object`&&(this.ops[t-1].attributes=e.attributes),this}}return t===this.ops.length?this.ops.push(e):this.ops.splice(t,0,e),this}chop(){let e=this.ops[this.ops.length-1];return e&&typeof e.retain==`number`&&!e.attributes&&this.ops.pop(),this}filter(e){return this.ops.filter(e)}forEach(e){this.ops.forEach(e)}map(e){return this.ops.map(e)}partition(e){let t=[],n=[];return this.forEach(r=>{(e(r)?t:n).push(r)}),[t,n]}reduce(e,t){return this.ops.reduce(e,t)}changeLength(){return this.reduce((e,t)=>t.insert?e+o.default.length(t):t.delete?e-t.delete:e,0)}length(){return this.reduce((e,t)=>e+o.default.length(t),0)}slice(t=0,n=1/0){let r=[],i=new s.default(this.ops),a=0;for(;a<n&&i.hasNext();){let e;a<t?e=i.next(t-a):(e=i.next(n-a),r.push(e)),a+=o.default.length(e)}return new e(r)}compose(t){let n=new s.default(this.ops),r=new s.default(t.ops),o=[],c=r.peek();if(c!=null&&typeof c.retain==`number`&&c.attributes==null){let e=c.retain;for(;n.peekType()===`insert`&&n.peekLength()<=e;)e-=n.peekLength(),o.push(n.next());c.retain-e>0&&r.next(c.retain-e)}let u=new e(o);for(;n.hasNext()||r.hasNext();)if(r.peekType()===`insert`)u.push(r.next());else if(n.peekType()===`delete`)u.push(n.next());else{let t=Math.min(n.peekLength(),r.peekLength()),o=n.next(t),s=r.next(t);if(s.retain){let c={};if(typeof o.retain==`number`)c.retain=typeof s.retain==`number`?t:s.retain;else if(typeof s.retain==`number`)o.retain==null?c.insert=o.insert:c.retain=o.retain;else{let t=o.retain==null?`insert`:`retain`,[n,r,i]=l(o[t],s.retain),a=e.getHandler(n);c[t]={[n]:a.compose(r,i,t===`retain`)}}let d=a.default.compose(o.attributes,s.attributes,typeof o.retain==`number`);if(d&&(c.attributes=d),u.push(c),!r.hasNext()&&i(u.ops[u.ops.length-1],c)){let t=new e(n.rest());return u.concat(t).chop()}}else typeof s.delete==`number`&&(typeof o.retain==`number`||typeof o.retain==`object`&&o.retain!==null)&&u.push(s)}return u.chop()}concat(t){let n=new e(this.ops.slice());return t.ops.length>0&&(n.push(t.ops[0]),n.ops=n.ops.concat(t.ops.slice(1))),n}diff(t,r){if(this.ops===t.ops)return new e;let o=[this,t].map(e=>e.map(n=>{if(n.insert!=null)return typeof n.insert==`string`?n.insert:c;throw Error(`diff() called `+(e===t?`on`:`with`)+` non-document`)}).join(``)),l=new e,u=n(o[0],o[1],r,!0),d=new s.default(this.ops),f=new s.default(t.ops);return u.forEach(e=>{let t=e[1].length;for(;t>0;){let r=0;switch(e[0]){case n.INSERT:r=Math.min(f.peekLength(),t),l.push(f.next(r));break;case n.DELETE:r=Math.min(t,d.peekLength()),d.next(r),l.delete(r);break;case n.EQUAL:r=Math.min(d.peekLength(),f.peekLength(),t);let e=d.next(r),o=f.next(r);i(e.insert,o.insert)?l.retain(r,a.default.diff(e.attributes,o.attributes)):l.push(o).delete(r);break}t-=r}}),l.chop()}eachLine(t,n=`
|
|
214
|
+
`){let r=new s.default(this.ops),i=new e,a=0;for(;r.hasNext();){if(r.peekType()!==`insert`)return;let s=r.peek(),c=o.default.length(s)-r.peekLength(),l=typeof s.insert==`string`?s.insert.indexOf(n,c)-c:-1;if(l<0)i.push(r.next());else if(l>0)i.push(r.next(l));else{if(t(i,r.next(1).attributes||{},a)===!1)return;a+=1,i=new e}}i.length()>0&&t(i,{},a)}invert(t){let n=new e;return this.reduce((r,i)=>{if(i.insert)n.delete(o.default.length(i));else if(typeof i.retain==`number`&&i.attributes==null)return n.retain(i.retain),r+i.retain;else if(i.delete||typeof i.retain==`number`){let e=i.delete||i.retain;return t.slice(r,r+e).forEach(e=>{i.delete?n.push(e):i.retain&&i.attributes&&n.retain(o.default.length(e),a.default.invert(i.attributes,e.attributes))}),r+e}else if(typeof i.retain==`object`&&i.retain!==null){let o=t.slice(r,r+1),c=new s.default(o.ops).next(),[u,d,f]=l(i.retain,c.insert),p=e.getHandler(u);return n.retain({[u]:p.invert(d,f)},a.default.invert(i.attributes,c.attributes)),r+1}return r},0),n.chop()}transform(t,n=!1){if(n=!!n,typeof t==`number`)return this.transformPosition(t,n);let r=t,i=new s.default(this.ops),c=new s.default(r.ops),l=new e;for(;i.hasNext()||c.hasNext();)if(i.peekType()===`insert`&&(n||c.peekType()!==`insert`))l.retain(o.default.length(i.next()));else if(c.peekType()===`insert`)l.push(c.next());else{let t=Math.min(i.peekLength(),c.peekLength()),r=i.next(t),o=c.next(t);if(r.delete)continue;if(o.delete)l.push(o);else{let i=r.retain,s=o.retain,c=typeof s==`object`&&s?s:t;if(typeof i==`object`&&i&&typeof s==`object`&&s){let t=Object.keys(i)[0];if(t===Object.keys(s)[0]){let r=e.getHandler(t);r&&(c={[t]:r.transform(i[t],s[t],n)})}}l.retain(c,a.default.transform(r.attributes,o.attributes,n))}}return l.chop()}transformPosition(e,t=!1){t=!!t;let n=new s.default(this.ops),r=0;for(;n.hasNext()&&r<=e;){let i=n.peekLength(),a=n.peekType();if(n.next(),a===`delete`){e-=Math.min(i,e-r);continue}else a===`insert`&&(r<e||!t)&&(e+=i);r+=i}return e}};u.Op=o.default,u.OpIterator=s.default,u.AttributeMap=a.default,u.handlers={},e.default=u,typeof t==`object`&&(t.exports=u,t.exports.default=u)}))(),1),yA=class extends aA{static value(){}optimize(){(this.prev||this.next)&&this.remove()}length(){return 0}value(){return``}};yA.blotName=`break`,yA.tagName=`BR`;var bA=class extends dA{},xA={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`};function SA(e){return e.replace(/[&<>"']/g,e=>xA[e])}var CA=class e extends eA{static allowedChildren=[e,yA,aA,bA];static order=[`cursor`,`inline`,`link`,`underline`,`strike`,`italic`,`bold`,`script`,`code`];static compare(t,n){let r=e.order.indexOf(t),i=e.order.indexOf(n);return r>=0||i>=0?r-i:t===n?0:t<n?-1:1}formatAt(t,n,r,i){if(e.compare(this.statics.blotName,r)<0&&this.scroll.query(r,Pk.BLOT)){let e=this.isolate(t,n);i&&e.wrap(r,i)}else super.formatAt(t,n,r,i)}optimize(t){if(super.optimize(t),this.parent instanceof e&&e.compare(this.statics.blotName,this.parent.statics.blotName)>0){let e=this.parent.isolate(this.offset(),this.length());this.moveChildren(e),e.wrap(this)}}},wA=1,TA=class extends nA{cache={};delta(){return this.cache.delta??(this.cache.delta=DA(this)),this.cache.delta}deleteAt(e,t){super.deleteAt(e,t),this.cache={}}formatAt(e,t,n,r){t<=0||(this.scroll.query(n,Pk.BLOCK)?e+t===this.length()&&this.format(n,r):super.formatAt(e,Math.min(t,this.length()-e-1),n,r),this.cache={})}insertAt(e,t,n){if(n!=null){super.insertAt(e,t,n),this.cache={};return}if(t.length===0)return;let r=t.split(`
|
|
215
|
+
`),i=r.shift();i.length>0&&(e<this.length()-1||this.children.tail==null?super.insertAt(Math.min(e,this.length()-1),i):this.children.tail.insertAt(this.children.tail.length(),i),this.cache={});let a=this;r.reduce((e,t)=>(a=a.split(e,!0),a.insertAt(0,t),t.length),e+i.length)}insertBefore(e,t){let{head:n}=this.children;super.insertBefore(e,t),n instanceof yA&&n.remove(),this.cache={}}length(){return this.cache.length??(this.cache.length=super.length()+wA),this.cache.length}moveChildren(e,t){super.moveChildren(e,t),this.cache={}}optimize(e){super.optimize(e),this.cache={}}path(e){return super.path(e,!0)}removeChild(e){super.removeChild(e),this.cache={}}split(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(t&&(e===0||e>=this.length()-wA)){let t=this.clone();return e===0?(this.parent.insertBefore(t,this),this):(this.parent.insertBefore(t,this.next),t)}let n=super.split(e,t);return this.cache={},n}};TA.blotName=`block`,TA.tagName=`P`,TA.defaultChild=yA,TA.allowedChildren=[yA,CA,aA,bA];var EA=class extends aA{attach(){super.attach(),this.attributes=new Uk(this.domNode)}delta(){return new vA.default().insert(this.value(),{...this.formats(),...this.attributes.values()})}format(e,t){let n=this.scroll.query(e,Pk.BLOCK_ATTRIBUTE);n!=null&&this.attributes.attribute(n,t)}formatAt(e,t,n,r){this.format(n,r)}insertAt(e,t,n){if(n!=null){super.insertAt(e,t,n);return}let r=t.split(`
|
|
216
|
+
`),i=r.pop(),a=r.map(e=>{let t=this.scroll.create(TA.blotName);return t.insertAt(0,e),t}),o=this.split(e);a.forEach(e=>{this.parent.insertBefore(e,o)}),i&&this.parent.insertBefore(this.scroll.create(`text`,i),o)}};EA.scope=Pk.BLOCK_BLOT;function DA(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return e.descendants(qk).reduce((e,n)=>n.length()===0?e:e.insert(n.value(),OA(n,{},t)),new vA.default).insert(`
|
|
217
|
+
`,OA(e))}function OA(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e==null||(`formats`in e&&typeof e.formats==`function`&&(t={...t,...e.formats()},n&&delete t[`code-token`]),e.parent==null||e.parent.statics.blotName===`scroll`||e.parent.statics.scope!==e.statics.scope)?t:OA(e.parent,t,n)}var kA=class e extends aA{static blotName=`cursor`;static className=`ql-cursor`;static tagName=`span`;static CONTENTS=``;static value(){}constructor(t,n,r){super(t,n),this.selection=r,this.textNode=document.createTextNode(e.CONTENTS),this.domNode.appendChild(this.textNode),this.savedLength=0}detach(){this.parent!=null&&this.parent.removeChild(this)}format(t,n){if(this.savedLength!==0){super.format(t,n);return}let r=this,i=0;for(;r!=null&&r.statics.scope!==Pk.BLOCK_BLOT;)i+=r.offset(r.parent),r=r.parent;r!=null&&(this.savedLength=e.CONTENTS.length,r.optimize(),r.formatAt(i,e.CONTENTS.length,t,n),this.savedLength=0)}index(e,t){return e===this.textNode?0:super.index(e,t)}length(){return this.savedLength}position(){return[this.textNode,this.textNode.data.length]}remove(){super.remove(),this.parent=null}restore(){if(this.selection.composing||this.parent==null)return null;let t=this.selection.getNativeRange();for(;this.domNode.lastChild!=null&&this.domNode.lastChild!==this.textNode;)this.domNode.parentNode.insertBefore(this.domNode.lastChild,this.domNode);let n=this.prev instanceof bA?this.prev:null,r=n?n.length():0,i=this.next instanceof bA?this.next:null,a=i?i.text:``,{textNode:o}=this,s=o.data.split(e.CONTENTS).join(``);o.data=e.CONTENTS;let c;if(n)c=n,(s||i)&&(n.insertAt(n.length(),s+a),i&&i.remove());else if(i)c=i,i.insertAt(0,s);else{let e=document.createTextNode(s);c=this.scroll.create(e),this.parent.insertBefore(c,this)}if(this.remove(),t){let e=(e,t)=>n&&e===n.domNode?t:e===o?r+t-1:i&&e===i.domNode?r+s.length+t:null,a=e(t.start.node,t.start.offset),l=e(t.end.node,t.end.offset);if(a!==null&&l!==null)return{startNode:c.domNode,startOffset:a,endNode:c.domNode,endOffset:l}}return null}update(e,t){if(e.some(e=>e.type===`characterData`&&e.target===this.textNode)){let e=this.restore();e&&(t.range=e)}}optimize(t){super.optimize(t);let{parent:n}=this;for(;n;){if(n.domNode.tagName===`A`){this.savedLength=e.CONTENTS.length,n.isolate(this.offset(n),this.length()).unwrap(),this.savedLength=0;break}n=n.parent}}value(){return``}},AA=l(o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)}))(),1),jA=new WeakMap,MA=[`error`,`warn`,`log`,`info`],NA=`warn`;function PA(e){if(NA&&MA.indexOf(e)<=MA.indexOf(NA)){var t=[...arguments].slice(1);console[e](...t)}}function FA(e){return MA.reduce((t,n)=>(t[n]=PA.bind(console,n,e),t),{})}FA.level=e=>{NA=e},PA.level=FA.level;var IA=FA(`quill:events`);[`selectionchange`,`mousedown`,`mouseup`,`click`].forEach(e=>{document.addEventListener(e,function(){var e=[...arguments];Array.from(document.querySelectorAll(`.ql-container`)).forEach(t=>{let n=jA.get(t);n&&n.emitter&&n.emitter.handleDOM(...e)})})});var LA=class extends AA.default{static events={EDITOR_CHANGE:`editor-change`,SCROLL_BEFORE_UPDATE:`scroll-before-update`,SCROLL_BLOT_MOUNT:`scroll-blot-mount`,SCROLL_BLOT_UNMOUNT:`scroll-blot-unmount`,SCROLL_OPTIMIZE:`scroll-optimize`,SCROLL_UPDATE:`scroll-update`,SCROLL_EMBED_UPDATE:`scroll-embed-update`,SELECTION_CHANGE:`selection-change`,TEXT_CHANGE:`text-change`,COMPOSITION_BEFORE_START:`composition-before-start`,COMPOSITION_START:`composition-start`,COMPOSITION_BEFORE_END:`composition-before-end`,COMPOSITION_END:`composition-end`};static sources={API:`api`,SILENT:`silent`,USER:`user`};constructor(){super(),this.domListeners={},this.on(`error`,IA.error)}emit(){var e=[...arguments];return IA.log.call(IA,...e),super.emit(...e)}handleDOM(e){var t=[...arguments].slice(1);(this.domListeners[e.type]||[]).forEach(n=>{let{node:r,handler:i}=n;(e.target===r||r.contains(e.target))&&i(e,...t)})}listenDOM(e,t,n){this.domListeners[e]||(this.domListeners[e]=[]),this.domListeners[e].push({node:t,handler:n})}},RA=FA(`quill:selection`),zA=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;this.index=e,this.length=t}},BA=class{constructor(e,t){this.emitter=t,this.scroll=e,this.composing=!1,this.mouseDown=!1,this.root=this.scroll.domNode,this.cursor=this.scroll.create(`cursor`,this),this.savedRange=new zA(0,0),this.lastRange=this.savedRange,this.lastNative=null,this.handleComposition(),this.handleDragging(),this.emitter.listenDOM(`selectionchange`,document,()=>{!this.mouseDown&&!this.composing&&setTimeout(this.update.bind(this,LA.sources.USER),1)}),this.emitter.on(LA.events.SCROLL_BEFORE_UPDATE,()=>{if(!this.hasFocus())return;let e=this.getNativeRange();e!=null&&e.start.node!==this.cursor.textNode&&this.emitter.once(LA.events.SCROLL_UPDATE,(t,n)=>{try{this.root.contains(e.start.node)&&this.root.contains(e.end.node)&&this.setNativeRange(e.start.node,e.start.offset,e.end.node,e.end.offset);let r=n.some(e=>e.type===`characterData`||e.type===`childList`||e.type===`attributes`&&e.target===this.root);this.update(r?LA.sources.SILENT:t)}catch{}})}),this.emitter.on(LA.events.SCROLL_OPTIMIZE,(e,t)=>{if(t.range){let{startNode:e,startOffset:n,endNode:r,endOffset:i}=t.range;this.setNativeRange(e,n,r,i),this.update(LA.sources.SILENT)}}),this.update(LA.sources.SILENT)}handleComposition(){this.emitter.on(LA.events.COMPOSITION_BEFORE_START,()=>{this.composing=!0}),this.emitter.on(LA.events.COMPOSITION_END,()=>{if(this.composing=!1,this.cursor.parent){let e=this.cursor.restore();if(!e)return;setTimeout(()=>{this.setNativeRange(e.startNode,e.startOffset,e.endNode,e.endOffset)},1)}})}handleDragging(){this.emitter.listenDOM(`mousedown`,document.body,()=>{this.mouseDown=!0}),this.emitter.listenDOM(`mouseup`,document.body,()=>{this.mouseDown=!1,this.update(LA.sources.USER)})}focus(){this.hasFocus()||(this.root.focus({preventScroll:!0}),this.setRange(this.savedRange))}format(e,t){this.scroll.update();let n=this.getNativeRange();if(!(n==null||!n.native.collapsed||this.scroll.query(e,Pk.BLOCK))){if(n.start.node!==this.cursor.textNode){let e=this.scroll.find(n.start.node,!1);if(e==null)return;if(e instanceof qk){let t=e.split(n.start.offset);e.parent.insertBefore(this.cursor,t)}else e.insertBefore(this.cursor,n.start.node);this.cursor.attach()}this.cursor.format(e,t),this.scroll.optimize(),this.setNativeRange(this.cursor.textNode,this.cursor.textNode.data.length),this.update()}}getBounds(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=this.scroll.length();e=Math.min(e,n-1),t=Math.min(e+t,n-1)-e;let r,[i,a]=this.scroll.leaf(e);if(i==null)return null;if(t>0&&a===i.length()){let[t]=this.scroll.leaf(e+1);if(t){let[n]=this.scroll.line(e),[r]=this.scroll.line(e+1);n===r&&(i=t,a=0)}}[r,a]=i.position(a,!0);let o=document.createRange();if(t>0)return o.setStart(r,a),[i,a]=this.scroll.leaf(e+t),i==null?null:([r,a]=i.position(a,!0),o.setEnd(r,a),o.getBoundingClientRect());let s=`left`,c;if(r instanceof Text){if(!r.data.length)return null;a<r.data.length?(o.setStart(r,a),o.setEnd(r,a+1)):(o.setStart(r,a-1),o.setEnd(r,a),s=`right`),c=o.getBoundingClientRect()}else{if(!(i.domNode instanceof Element))return null;c=i.domNode.getBoundingClientRect(),a>0&&(s=`right`)}return{bottom:c.top+c.height,height:c.height,left:c[s],right:c[s],top:c.top,width:0}}getNativeRange(){let e=document.getSelection();if(e==null||e.rangeCount<=0)return null;let t=e.getRangeAt(0);if(t==null)return null;let n=this.normalizeNative(t);return RA.info(`getNativeRange`,n),n}getRange(){let e=this.scroll.domNode;if(`isConnected`in e&&!e.isConnected)return[null,null];let t=this.getNativeRange();return t==null?[null,null]:[this.normalizedToRange(t),t]}hasFocus(){return document.activeElement===this.root||document.activeElement!=null&&VA(this.root,document.activeElement)}normalizedToRange(e){let t=[[e.start.node,e.start.offset]];e.native.collapsed||t.push([e.end.node,e.end.offset]);let n=t.map(e=>{let[t,n]=e,r=this.scroll.find(t,!0),i=r.offset(this.scroll);return n===0?i:r instanceof qk?i+r.index(t,n):i+r.length()}),r=Math.min(Math.max(...n),this.scroll.length()-1),i=Math.min(r,...n);return new zA(i,r-i)}normalizeNative(e){if(!VA(this.root,e.startContainer)||!e.collapsed&&!VA(this.root,e.endContainer))return null;let t={start:{node:e.startContainer,offset:e.startOffset},end:{node:e.endContainer,offset:e.endOffset},native:e};return[t.start,t.end].forEach(e=>{let{node:t,offset:n}=e;for(;!(t instanceof Text)&&t.childNodes.length>0;)if(t.childNodes.length>n)t=t.childNodes[n],n=0;else if(t.childNodes.length===n)t=t.lastChild,n=t instanceof Text?t.data.length:t.childNodes.length>0?t.childNodes.length:t.childNodes.length+1;else break;e.node=t,e.offset=n}),t}rangeToNative(e){let t=this.scroll.length(),n=(e,n)=>{e=Math.min(t-1,e);let[r,i]=this.scroll.leaf(e);return r?r.position(i,n):[null,-1]};return[...n(e.index,!1),...n(e.index+e.length,!0)]}setNativeRange(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:t,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;if(RA.info(`setNativeRange`,e,t,n,r),e!=null&&(this.root.parentNode==null||e.parentNode==null||n.parentNode==null))return;let a=document.getSelection();if(a!=null)if(e!=null){this.hasFocus()||this.root.focus({preventScroll:!0});let{native:o}=this.getNativeRange()||{};if(o==null||i||e!==o.startContainer||t!==o.startOffset||n!==o.endContainer||r!==o.endOffset){e instanceof Element&&e.tagName===`BR`&&(t=Array.from(e.parentNode.childNodes).indexOf(e),e=e.parentNode),n instanceof Element&&n.tagName===`BR`&&(r=Array.from(n.parentNode.childNodes).indexOf(n),n=n.parentNode);let i=document.createRange();i.setStart(e,t),i.setEnd(n,r),a.removeAllRanges(),a.addRange(i)}}else a.removeAllRanges(),this.root.blur()}setRange(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:LA.sources.API;if(typeof t==`string`&&(n=t,t=!1),RA.info(`setRange`,e),e!=null){let n=this.rangeToNative(e);this.setNativeRange(...n,t)}else this.setNativeRange(null);this.update(n)}update(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:LA.sources.USER,t=this.lastRange,[n,r]=this.getRange();if(this.lastRange=n,this.lastNative=r,this.lastRange!=null&&(this.savedRange=this.lastRange),!jk(t,this.lastRange)){if(!this.composing&&r!=null&&r.native.collapsed&&r.start.node!==this.cursor.textNode){let e=this.cursor.restore();e&&this.setNativeRange(e.startNode,e.startOffset,e.endNode,e.endOffset)}let n=[LA.events.SELECTION_CHANGE,zO(this.lastRange),zO(t),e];this.emitter.emit(LA.events.EDITOR_CHANGE,...n),e!==LA.sources.SILENT&&this.emitter.emit(...n)}}};function VA(e,t){try{t.parentNode}catch{return!1}return e.contains(t)}var HA=/^[ -~]*$/,UA=class{constructor(e){this.scroll=e,this.delta=this.getDelta()}applyDelta(e){this.scroll.update();let t=this.scroll.length();this.scroll.batchStart();let n=JA(e),r=new vA.default;return XA(n.ops.slice()).reduce((e,n)=>{let i=vA.Op.length(n),a=n.attributes||{},o=!1,s=!1;if(n.insert!=null){if(r.retain(i),typeof n.insert==`string`){let r=n.insert;s=!r.endsWith(`
|
|
218
|
+
`)&&(t<=e||!!this.scroll.descendant(EA,e)[0]),this.scroll.insertAt(e,r);let[i,o]=this.scroll.line(e),c=Mk({},OA(i));if(i instanceof TA){let[e]=i.descendant(qk,o);e&&(c=Mk(c,OA(e)))}a=vA.AttributeMap.diff(c,a)||{}}else if(typeof n.insert==`object`){let r=Object.keys(n.insert)[0];if(r==null)return e;let i=this.scroll.query(r,Pk.INLINE)!=null;if(i)(t<=e||this.scroll.descendant(EA,e)[0])&&(s=!0);else if(e>0){let[t,n]=this.scroll.descendant(qk,e-1);t instanceof bA?t.value()[n]!==`
|
|
219
|
+
`&&(o=!0):t instanceof aA&&t.statics.scope===Pk.INLINE_BLOT&&(o=!0)}if(this.scroll.insertAt(e,r,n.insert[r]),i){let[t]=this.scroll.descendant(qk,e);if(t){let e=Mk({},OA(t));a=vA.AttributeMap.diff(e,a)||{}}}}t+=i}else if(r.push(n),n.retain!==null&&typeof n.retain==`object`){let t=Object.keys(n.retain)[0];if(t==null)return e;this.scroll.updateEmbedAt(e,t,n.retain[t])}Object.keys(a).forEach(t=>{this.scroll.formatAt(e,i,t,a[t])});let c=+!!o,l=+!!s;return t+=c+l,r.retain(c),r.delete(l),e+i+c+l},0),r.reduce((e,t)=>typeof t.delete==`number`?(this.scroll.deleteAt(e,t.delete),e):e+vA.Op.length(t),0),this.scroll.batchEnd(),this.scroll.optimize(),this.update(n)}deleteText(e,t){return this.scroll.deleteAt(e,t),this.update(new vA.default().retain(e).delete(t))}formatLine(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.scroll.update(),Object.keys(n).forEach(r=>{this.scroll.lines(e,Math.max(t,1)).forEach(e=>{e.format(r,n[r])})}),this.scroll.optimize();let r=new vA.default().retain(e).retain(t,zO(n));return this.update(r)}formatText(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.keys(n).forEach(r=>{this.scroll.formatAt(e,t,r,n[r])});let r=new vA.default().retain(e).retain(t,zO(n));return this.update(r)}getContents(e,t){return this.delta.slice(e,e+t)}getDelta(){return this.scroll.lines().reduce((e,t)=>e.concat(t.delta()),new vA.default)}getFormat(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=[],r=[];t===0?this.scroll.path(e).forEach(e=>{let[t]=e;t instanceof TA?n.push(t):t instanceof qk&&r.push(t)}):(n=this.scroll.lines(e,t),r=this.scroll.descendants(qk,e,t));let[i,a]=[n,r].map(e=>{let t=e.shift();if(t==null)return{};let n=OA(t);for(;Object.keys(n).length>0;){let t=e.shift();if(t==null)return n;n=KA(OA(t),n)}return n});return{...i,...a}}getHTML(e,t){let[n,r]=this.scroll.line(e);if(n){let i=n.length();return n.length()>=r+t&&!(r===0&&t===i)?GA(n,r,t,!0):GA(this.scroll,e,t,!0)}return``}getText(e,t){return this.getContents(e,t).filter(e=>typeof e.insert==`string`).map(e=>e.insert).join(``)}insertContents(e,t){let n=JA(t),r=new vA.default().retain(e).concat(n);return this.scroll.insertContents(e,n),this.update(r)}insertEmbed(e,t,n){return this.scroll.insertAt(e,t,n),this.update(new vA.default().retain(e).insert({[t]:n}))}insertText(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return t=t.replace(/\r\n/g,`
|
|
220
|
+
`).replace(/\r/g,`
|
|
221
|
+
`),this.scroll.insertAt(e,t),Object.keys(n).forEach(r=>{this.scroll.formatAt(e,t.length,r,n[r])}),this.update(new vA.default().retain(e).insert(t,zO(n)))}isBlank(){if(this.scroll.children.length===0)return!0;if(this.scroll.children.length>1)return!1;let e=this.scroll.children.head;if(e?.statics.blotName!==TA.blotName)return!1;let t=e;return t.children.length>1?!1:t.children.head instanceof yA}removeFormat(e,t){let n=this.getText(e,t),[r,i]=this.scroll.line(e+t),a=0,o=new vA.default;r!=null&&(a=r.length()-i,o=r.delta().slice(i,i+a-1).insert(`
|
|
222
|
+
`));let s=this.getContents(e,t+a).diff(new vA.default().insert(n).concat(o)),c=new vA.default().retain(e).concat(s);return this.applyDelta(c)}update(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,r=this.delta;if(t.length===1&&t[0].type===`characterData`&&t[0].target.data.match(HA)&&this.scroll.find(t[0].target)){let i=this.scroll.find(t[0].target),a=OA(i),o=i.offset(this.scroll),s=t[0].oldValue.replace(kA.CONTENTS,``),c=new vA.default().insert(s),l=new vA.default().insert(i.value()),u=n&&{oldRange:YA(n.oldRange,-o),newRange:YA(n.newRange,-o)};e=new vA.default().retain(o).concat(c.diff(l,u)).reduce((e,t)=>t.insert?e.insert(t.insert,a):e.push(t),new vA.default),this.delta=r.compose(e)}else this.delta=this.getDelta(),(!e||!jk(r.compose(e),this.delta))&&(e=r.diff(this.delta,n));return e}};function WA(e,t,n){if(e.length===0){let[e]=qA(n.pop());return t<=0?`</li></${e}>`:`</li></${e}>${WA([],t-1,n)}`}let[{child:r,offset:i,length:a,indent:o,type:s},...c]=e,[l,u]=qA(s);if(o>t)return n.push(s),o===t+1?`<${l}><li${u}>${GA(r,i,a)}${WA(c,o,n)}`:`<${l}><li>${WA(e,t+1,n)}`;let d=n[n.length-1];if(o===t&&s===d)return`</li><li${u}>${GA(r,i,a)}${WA(c,o,n)}`;let[f]=qA(n.pop());return`</li></${f}>${WA(e,t-1,n)}`}function GA(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(`html`in e&&typeof e.html==`function`)return e.html(t,n);if(e instanceof bA)return SA(e.value().slice(t,t+n)).replaceAll(` `,` `);if(e instanceof Zk){if(e.statics.blotName===`list-container`){let r=[];return e.children.forEachAt(t,n,(e,t,n)=>{let i=`formats`in e&&typeof e.formats==`function`?e.formats():{};r.push({child:e,offset:t,length:n,indent:i.indent||0,type:i.list})}),WA(r,-1,[])}let i=[];if(e.children.forEachAt(t,n,(e,t,n)=>{i.push(GA(e,t,n))}),r||e.statics.blotName===`list`)return i.join(``);let{outerHTML:a,innerHTML:o}=e.domNode,[s,c]=a.split(`>${o}<`);return s===`<table`?`<table style="border: 1px solid #000;">${i.join(``)}<${c}`:`${s}>${i.join(``)}<${c}`}return e.domNode instanceof Element?e.domNode.outerHTML:``}function KA(e,t){return Object.keys(t).reduce((n,r)=>{if(e[r]==null)return n;let i=t[r];return i===e[r]?n[r]=i:Array.isArray(i)?i.indexOf(e[r])<0?n[r]=i.concat([e[r]]):n[r]=i:n[r]=[i,e[r]],n},{})}function qA(e){let t=e===`ordered`?`ol`:`ul`;switch(e){case`checked`:return[t,` data-list="checked"`];case`unchecked`:return[t,` data-list="unchecked"`];default:return[t,``]}}function JA(e){return e.reduce((e,t)=>{if(typeof t.insert==`string`){let n=t.insert.replace(/\r\n/g,`
|
|
223
|
+
`).replace(/\r/g,`
|
|
224
|
+
`);return e.insert(n,t.attributes)}return e.push(t)},new vA.default)}function YA(e,t){let{index:n,length:r}=e;return new zA(n+t,r)}function XA(e){let t=[];return e.forEach(e=>{typeof e.insert==`string`?e.insert.split(`
|
|
225
|
+
`).forEach((n,r)=>{r&&t.push({insert:`
|
|
226
|
+
`,attributes:e.attributes}),n&&t.push({insert:n,attributes:e.attributes})}):t.push(e)}),t}var ZA=class{static DEFAULTS={};constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.quill=e,this.options=t}},QA=``,$A=class extends aA{constructor(e,t){super(e,t),this.contentNode=document.createElement(`span`),this.contentNode.setAttribute(`contenteditable`,`false`),Array.from(this.domNode.childNodes).forEach(e=>{this.contentNode.appendChild(e)}),this.leftGuard=document.createTextNode(QA),this.rightGuard=document.createTextNode(QA),this.domNode.appendChild(this.leftGuard),this.domNode.appendChild(this.contentNode),this.domNode.appendChild(this.rightGuard)}index(e,t){return e===this.leftGuard?0:e===this.rightGuard?1:super.index(e,t)}restore(e){let t=null,n,r=e.data.split(QA).join(``);if(e===this.leftGuard)if(this.prev instanceof bA){let e=this.prev.length();this.prev.insertAt(e,r),t={startNode:this.prev.domNode,startOffset:e+r.length}}else n=document.createTextNode(r),this.parent.insertBefore(this.scroll.create(n),this),t={startNode:n,startOffset:r.length};else e===this.rightGuard&&(this.next instanceof bA?(this.next.insertAt(0,r),t={startNode:this.next.domNode,startOffset:r.length}):(n=document.createTextNode(r),this.parent.insertBefore(this.scroll.create(n),this.next),t={startNode:n,startOffset:r.length}));return e.data=QA,t}update(e,t){e.forEach(e=>{if(e.type===`characterData`&&(e.target===this.leftGuard||e.target===this.rightGuard)){let n=this.restore(e.target);n&&(t.range=n)}})}},ej=class{isComposing=!1;constructor(e,t){this.scroll=e,this.emitter=t,this.setupListeners()}setupListeners(){this.scroll.domNode.addEventListener(`compositionstart`,e=>{this.isComposing||this.handleCompositionStart(e)}),this.scroll.domNode.addEventListener(`compositionend`,e=>{this.isComposing&&queueMicrotask(()=>{this.handleCompositionEnd(e)})})}handleCompositionStart(e){let t=e.target instanceof Node?this.scroll.find(e.target,!0):null;t&&!(t instanceof $A)&&(this.emitter.emit(LA.events.COMPOSITION_BEFORE_START,e),this.scroll.batchStart(),this.emitter.emit(LA.events.COMPOSITION_START,e),this.isComposing=!0)}handleCompositionEnd(e){this.emitter.emit(LA.events.COMPOSITION_BEFORE_END,e),this.scroll.batchEnd(),this.emitter.emit(LA.events.COMPOSITION_END,e),this.isComposing=!1}},tj=class e{static DEFAULTS={modules:{}};static themes={default:e};modules={};constructor(e,t){this.quill=e,this.options=t}init(){Object.keys(this.options.modules).forEach(e=>{this.modules[e]??this.addModule(e)})}addModule(e){let t=this.quill.constructor.import(`modules/${e}`);return this.modules[e]=new t(this.quill,this.options.modules[e]||{}),this.modules[e]}},nj=e=>e.parentElement||e.getRootNode().host||null,rj=e=>{let t=e.getBoundingClientRect(),n=`offsetWidth`in e&&Math.abs(t.width)/e.offsetWidth||1,r=`offsetHeight`in e&&Math.abs(t.height)/e.offsetHeight||1;return{top:t.top,right:t.left+e.clientWidth*n,bottom:t.top+e.clientHeight*r,left:t.left}},ij=e=>{let t=parseInt(e,10);return Number.isNaN(t)?0:t},aj=(e,t,n,r,i,a)=>e<n&&t>r?0:e<n?-(n-e+i):t>r?t-e>r-n?e+i-n:t-r+a:0,oj=(e,t)=>{let n=e.ownerDocument,r=t,i=e;for(;i;){let e=i===n.body,t=e?{top:0,right:window.visualViewport?.width??n.documentElement.clientWidth,bottom:window.visualViewport?.height??n.documentElement.clientHeight,left:0}:rj(i),a=getComputedStyle(i),o=aj(r.left,r.right,t.left,t.right,ij(a.scrollPaddingLeft),ij(a.scrollPaddingRight)),s=aj(r.top,r.bottom,t.top,t.bottom,ij(a.scrollPaddingTop),ij(a.scrollPaddingBottom));if(o||s)if(e)n.defaultView?.scrollBy(o,s);else{let{scrollLeft:e,scrollTop:t}=i;s&&(i.scrollTop+=s),o&&(i.scrollLeft+=o);let n=i.scrollLeft-e,a=i.scrollTop-t;r={left:r.left-n,top:r.top-a,right:r.right-n,bottom:r.bottom-a}}i=e||a.position===`fixed`?null:nj(i)}},sj=100,cj=[`block`,`break`,`cursor`,`inline`,`scroll`,`text`],lj=(e,t,n)=>{let r=new Rk;return cj.forEach(e=>{let n=t.query(e);n&&r.register(n)}),e.forEach(e=>{let i=t.query(e);i||n.error(`Cannot register "${e}" specified in "formats" config. Are you sure it was registered?`);let a=0;for(;i;)if(r.register(i),i=`blotName`in i?i.requiredContainer??null:null,a+=1,a>sj){n.error(`Cycle detected in registering blot requiredContainer: "${e}"`);break}}),r},uj=FA(`quill`),dj=new Rk;Zk.uiClass=`ql-ui`;var Y=class e{static DEFAULTS={bounds:null,modules:{clipboard:!0,keyboard:!0,history:!0,uploader:!0},placeholder:``,readOnly:!1,registry:dj,theme:`default`};static events=LA.events;static sources=LA.sources;static version=`2.0.3`;static imports={delta:vA.default,parchment:Nk,"core/module":ZA,"core/theme":tj};static debug(e){e===!0&&(e=`log`),FA.level(e)}static find(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return jA.get(e)||dj.find(e,t)}static import(e){return this.imports[e]??uj.error(`Cannot import ${e}. Are you sure it was registered?`),this.imports[e]}static register(){if(typeof(arguments.length<=0?void 0:arguments[0])!=`string`){let e=arguments.length<=0?void 0:arguments[0],t=!!(!(arguments.length<=1)&&arguments[1]),n=`attrName`in e?e.attrName:e.blotName;typeof n==`string`?this.register(`formats/${n}`,e,t):Object.keys(e).forEach(n=>{this.register(n,e[n],t)})}else{let e=arguments.length<=0?void 0:arguments[0],t=arguments.length<=1?void 0:arguments[1],n=!!(!(arguments.length<=2)&&arguments[2]);this.imports[e]!=null&&!n&&uj.warn(`Overwriting ${e} with`,t),this.imports[e]=t,(e.startsWith(`blots/`)||e.startsWith(`formats/`))&&t&&typeof t!=`boolean`&&t.blotName!==`abstract`&&dj.register(t),typeof t.register==`function`&&t.register(dj)}}constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.options=hj(t,n),this.container=this.options.container,this.container==null){uj.error(`Invalid Quill container`,t);return}this.options.debug&&e.debug(this.options.debug);let r=this.container.innerHTML.trim();this.container.classList.add(`ql-container`),this.container.innerHTML=``,jA.set(this.container,this),this.root=this.addContainer(`ql-editor`),this.root.classList.add(`ql-blank`),this.emitter=new LA;let i=lA.blotName,a=this.options.registry.query(i);if(!a||!(`blotName`in a))throw Error(`Cannot initialize Quill without "${i}" blot`);if(this.scroll=new a(this.options.registry,this.root,{emitter:this.emitter}),this.editor=new UA(this.scroll),this.selection=new BA(this.scroll,this.emitter),this.composition=new ej(this.scroll,this.emitter),this.theme=new this.options.theme(this,this.options),this.keyboard=this.theme.addModule(`keyboard`),this.clipboard=this.theme.addModule(`clipboard`),this.history=this.theme.addModule(`history`),this.uploader=this.theme.addModule(`uploader`),this.theme.addModule(`input`),this.theme.addModule(`uiNode`),this.theme.init(),this.emitter.on(LA.events.EDITOR_CHANGE,e=>{e===LA.events.TEXT_CHANGE&&this.root.classList.toggle(`ql-blank`,this.editor.isBlank())}),this.emitter.on(LA.events.SCROLL_UPDATE,(e,t)=>{let n=this.selection.lastRange,[r]=this.selection.getRange(),i=n&&r?{oldRange:n,newRange:r}:void 0;gj.call(this,()=>this.editor.update(null,t,i),e)}),this.emitter.on(LA.events.SCROLL_EMBED_UPDATE,(t,n)=>{let r=this.selection.lastRange,[i]=this.selection.getRange(),a=r&&i?{oldRange:r,newRange:i}:void 0;gj.call(this,()=>{let e=new vA.default().retain(t.offset(this)).retain({[t.statics.blotName]:n});return this.editor.update(e,[],a)},e.sources.USER)}),r){let e=this.clipboard.convert({html:`${r}<p><br></p>`,text:`
|
|
227
|
+
`});this.setContents(e)}this.history.clear(),this.options.placeholder&&this.root.setAttribute(`data-placeholder`,this.options.placeholder),this.options.readOnly&&this.disable(),this.allowReadOnlyEdits=!1}addContainer(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(typeof e==`string`){let t=e;e=document.createElement(`div`),e.classList.add(t)}return this.container.insertBefore(e,t),e}blur(){this.selection.setRange(null)}deleteText(e,t,n){return[e,t,,n]=_j(e,t,n),gj.call(this,()=>this.editor.deleteText(e,t),n,e,-1*t)}disable(){this.enable(!1)}editReadOnly(e){this.allowReadOnlyEdits=!0;let t=e();return this.allowReadOnlyEdits=!1,t}enable(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.scroll.enable(e),this.container.classList.toggle(`ql-disabled`,!e)}focus(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.selection.focus(),e.preventScroll||this.scrollSelectionIntoView()}format(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:LA.sources.API;return gj.call(this,()=>{let n=this.getSelection(!0),r=new vA.default;if(n==null)return r;if(this.scroll.query(e,Pk.BLOCK))r=this.editor.formatLine(n.index,n.length,{[e]:t});else if(n.length===0)return this.selection.format(e,t),r;else r=this.editor.formatText(n.index,n.length,{[e]:t});return this.setSelection(n,LA.sources.SILENT),r},n)}formatLine(e,t,n,r,i){let a;return[e,t,a,i]=_j(e,t,n,r,i),gj.call(this,()=>this.editor.formatLine(e,t,a),i,e,0)}formatText(e,t,n,r,i){let a;return[e,t,a,i]=_j(e,t,n,r,i),gj.call(this,()=>this.editor.formatText(e,t,a),i,e,0)}getBounds(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=null;if(n=typeof e==`number`?this.selection.getBounds(e,t):this.selection.getBounds(e.index,e.length),!n)return null;let r=this.container.getBoundingClientRect();return{bottom:n.bottom-r.top,height:n.height,left:n.left-r.left,right:n.right-r.left,top:n.top-r.top,width:n.width}}getContents(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getLength()-e;return[e,t]=_j(e,t),this.editor.getContents(e,t)}getFormat(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.getSelection(!0),t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return typeof e==`number`?this.editor.getFormat(e,t):this.editor.getFormat(e.index,e.length)}getIndex(e){return e.offset(this.scroll)}getLength(){return this.scroll.length()}getLeaf(e){return this.scroll.leaf(e)}getLine(e){return this.scroll.line(e)}getLines(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE;return typeof e==`number`?this.scroll.lines(e,t):this.scroll.lines(e.index,e.length)}getModule(e){return this.theme.modules[e]}getSelection(){return arguments.length>0&&arguments[0]!==void 0&&arguments[0]&&this.focus(),this.update(),this.selection.getRange()[0]}getSemanticHTML(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;return typeof e==`number`&&(t??=this.getLength()-e),[e,t]=_j(e,t),this.editor.getHTML(e,t)}getText(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;return typeof e==`number`&&(t??=this.getLength()-e),[e,t]=_j(e,t),this.editor.getText(e,t)}hasFocus(){return this.selection.hasFocus()}insertEmbed(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:e.sources.API;return gj.call(this,()=>this.editor.insertEmbed(t,n,r),i,t)}insertText(e,t,n,r,i){let a;return[e,,a,i]=_j(e,0,n,r,i),gj.call(this,()=>this.editor.insertText(e,t,a),i,e,t.length)}isEnabled(){return this.scroll.isEnabled()}off(){return this.emitter.off(...arguments)}on(){return this.emitter.on(...arguments)}once(){return this.emitter.once(...arguments)}removeFormat(e,t,n){return[e,t,,n]=_j(e,t,n),gj.call(this,()=>this.editor.removeFormat(e,t),n,e)}scrollRectIntoView(e){oj(this.root,e)}scrollIntoView(){console.warn(`Quill#scrollIntoView() has been deprecated and will be removed in the near future. Please use Quill#scrollSelectionIntoView() instead.`),this.scrollSelectionIntoView()}scrollSelectionIntoView(){let e=this.selection.lastRange,t=e&&this.selection.getBounds(e.index,e.length);t&&this.scrollRectIntoView(t)}setContents(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:LA.sources.API;return gj.call(this,()=>{e=new vA.default(e);let t=this.getLength(),n=this.editor.deleteText(0,t),r=this.editor.insertContents(0,e),i=this.editor.deleteText(this.getLength()-1,1);return n.compose(r).compose(i)},t)}setSelection(t,n,r){t==null?this.selection.setRange(null,n||e.sources.API):([t,n,,r]=_j(t,n,r),this.selection.setRange(new zA(Math.max(0,t),n),r),r!==LA.sources.SILENT&&this.scrollSelectionIntoView())}setText(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:LA.sources.API,n=new vA.default().insert(e);return this.setContents(n,t)}update(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:LA.sources.USER,t=this.scroll.update(e);return this.selection.update(e),t}updateContents(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:LA.sources.API;return gj.call(this,()=>(e=new vA.default(e),this.editor.applyDelta(e)),t,!0)}};function fj(e){return typeof e==`string`?document.querySelector(e):e}function pj(e){return Object.entries(e??{}).reduce((e,t)=>{let[n,r]=t;return{...e,[n]:r===!0?{}:r}},{})}function mj(e){return Object.fromEntries(Object.entries(e).filter(e=>e[1]!==void 0))}function hj(e,t){let n=fj(e);if(!n)throw Error(`Invalid Quill container`);let r=!t.theme||t.theme===Y.DEFAULTS.theme?tj:Y.import(`themes/${t.theme}`);if(!r)throw Error(`Invalid theme ${t.theme}. Did you register it?`);let{modules:i,...a}=Y.DEFAULTS,{modules:o,...s}=r.DEFAULTS,c=pj(t.modules);c!=null&&c.toolbar&&c.toolbar.constructor!==Object&&(c={...c,toolbar:{container:c.toolbar}});let l=Mk({},pj(i),pj(o),c),u={...a,...mj(s),...mj(t)},d=t.registry;return d?t.formats&&uj.warn(`Ignoring "formats" option because "registry" is specified`):d=t.formats?lj(t.formats,u.registry,uj):u.registry,{...u,registry:d,container:n,theme:r,modules:Object.entries(l).reduce((e,t)=>{let[n,r]=t;if(!r)return e;let i=Y.import(`modules/${n}`);return i==null?(uj.error(`Cannot load ${n} module. Are you sure you registered it?`),e):{...e,[n]:Mk({},i.DEFAULTS||{},r)}},{}),bounds:fj(u.bounds)}}function gj(e,t,n,r){if(!this.isEnabled()&&t===LA.sources.USER&&!this.allowReadOnlyEdits)return new vA.default;let i=n==null?null:this.getSelection(),a=this.editor.delta,o=e();if(i!=null&&(n===!0&&(n=i.index),r==null?i=vj(i,o,t):r!==0&&(i=vj(i,n,r,t)),this.setSelection(i,LA.sources.SILENT)),o.length()>0){let e=[LA.events.TEXT_CHANGE,o,a,t];this.emitter.emit(LA.events.EDITOR_CHANGE,...e),t!==LA.sources.SILENT&&this.emitter.emit(...e)}return o}function _j(e,t,n,r,i){let a={};return typeof e.index==`number`&&typeof e.length==`number`?typeof t==`number`?(t=e.length,e=e.index):(i=r,r=n,n=t,t=e.length,e=e.index):typeof t!=`number`&&(i=r,r=n,n=t,t=0),typeof n==`object`?(a=n,i=r):typeof n==`string`&&(r==null?i=n:a[n]=r),i||=LA.sources.API,[e,t,a,i]}function vj(e,t,n,r){let i=typeof n==`number`?n:0;if(e==null)return null;let a,o;return t&&typeof t.transformPosition==`function`?[a,o]=[e.index,e.index+e.length].map(e=>t.transformPosition(e,r!==LA.sources.USER)):[a,o]=[e.index,e.index+e.length].map(e=>e<t||e===t&&r===LA.sources.USER?e:i>=0?e+i:Math.max(t,e+i)),new zA(a,o-a)}var yj=class extends iA{};function bj(e){return e instanceof TA||e instanceof EA}function xj(e){return typeof e.updateContent==`function`}var Sj=class extends lA{static blotName=`scroll`;static className=`ql-editor`;static tagName=`DIV`;static defaultChild=TA;static allowedChildren=[TA,EA,yj];constructor(e,t,n){let{emitter:r}=n;super(e,t),this.emitter=r,this.batch=!1,this.optimize(),this.enable(),this.domNode.addEventListener(`dragstart`,e=>this.handleDragStart(e))}batchStart(){Array.isArray(this.batch)||(this.batch=[])}batchEnd(){if(!this.batch)return;let e=this.batch;this.batch=!1,this.update(e)}emitMount(e){this.emitter.emit(LA.events.SCROLL_BLOT_MOUNT,e)}emitUnmount(e){this.emitter.emit(LA.events.SCROLL_BLOT_UNMOUNT,e)}emitEmbedUpdate(e,t){this.emitter.emit(LA.events.SCROLL_EMBED_UPDATE,e,t)}deleteAt(e,t){let[n,r]=this.line(e),[i]=this.line(e+t);if(super.deleteAt(e,t),i!=null&&n!==i&&r>0){if(n instanceof EA||i instanceof EA){this.optimize();return}let e=i.children.head instanceof yA?null:i.children.head;n.moveChildren(i,e),n.remove()}this.optimize()}enable(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;this.domNode.setAttribute(`contenteditable`,e?`true`:`false`)}formatAt(e,t,n,r){super.formatAt(e,t,n,r),this.optimize()}insertAt(e,t,n){if(e>=this.length())if(n==null||this.scroll.query(t,Pk.BLOCK)==null){let e=this.scroll.create(this.statics.defaultChild.blotName);this.appendChild(e),n==null&&t.endsWith(`
|
|
228
|
+
`)?e.insertAt(0,t.slice(0,-1),n):e.insertAt(0,t,n)}else{let e=this.scroll.create(t,n);this.appendChild(e)}else super.insertAt(e,t,n);this.optimize()}insertBefore(e,t){if(e.statics.scope===Pk.INLINE_BLOT){let n=this.scroll.create(this.statics.defaultChild.blotName);n.appendChild(e),super.insertBefore(n,t)}else super.insertBefore(e,t)}insertContents(e,t){let n=this.deltaToRenderBlocks(t.concat(new vA.default().insert(`
|
|
229
|
+
`))),r=n.pop();if(r==null)return;this.batchStart();let i=n.shift();if(i){let t=i.type===`block`&&(i.delta.length()===0||!this.descendant(EA,e)[0]&&e<this.length()),n=i.type===`block`?i.delta:new vA.default().insert({[i.key]:i.value});Cj(this,e,n);let r=+(i.type===`block`),a=e+n.length()+r;t&&this.insertAt(a-1,`
|
|
230
|
+
`);let o=OA(this.line(e)[0]),s=vA.AttributeMap.diff(o,i.attributes)||{};Object.keys(s).forEach(e=>{this.formatAt(a-1,1,e,s[e])}),e=a}let[a,o]=this.children.find(e);if(n.length&&(a&&(a=a.split(o),o=0),n.forEach(e=>{if(e.type===`block`)Cj(this.createBlock(e.attributes,a||void 0),0,e.delta);else{let t=this.create(e.key,e.value);this.insertBefore(t,a||void 0),Object.keys(e.attributes).forEach(n=>{t.format(n,e.attributes[n])})}})),r.type===`block`&&r.delta.length()){let e=a?a.offset(a.scroll)+o:this.length();Cj(this,e,r.delta)}this.batchEnd(),this.optimize()}isEnabled(){return this.domNode.getAttribute(`contenteditable`)===`true`}leaf(e){let t=this.path(e).pop();if(!t)return[null,-1];let[n,r]=t;return n instanceof qk?[n,r]:[null,-1]}line(e){return e===this.length()?this.line(e-1):this.descendant(bj,e)}lines(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Number.MAX_VALUE,n=(e,t,r)=>{let i=[],a=r;return e.children.forEachAt(t,r,(e,t,r)=>{bj(e)?i.push(e):e instanceof iA&&(i=i.concat(n(e,t,a))),a-=r}),i};return n(this,e,t)}optimize(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.batch||(super.optimize(e,t),e.length>0&&this.emitter.emit(LA.events.SCROLL_OPTIMIZE,e,t))}path(e){return super.path(e).slice(1)}remove(){}update(e){if(this.batch){Array.isArray(e)&&(this.batch=this.batch.concat(e));return}let t=LA.sources.USER;typeof e==`string`&&(t=e),Array.isArray(e)||(e=this.observer.takeRecords()),e=e.filter(e=>{let{target:t}=e,n=this.find(t,!0);return n&&!xj(n)}),e.length>0&&this.emitter.emit(LA.events.SCROLL_BEFORE_UPDATE,t,e),super.update(e.concat([])),e.length>0&&this.emitter.emit(LA.events.SCROLL_UPDATE,t,e)}updateEmbedAt(e,t,n){let[r]=this.descendant(e=>e instanceof EA,e);r&&r.statics.blotName===t&&xj(r)&&r.updateContent(n)}handleDragStart(e){e.preventDefault()}deltaToRenderBlocks(e){let t=[],n=new vA.default;return e.forEach(e=>{let r=e?.insert;if(r)if(typeof r==`string`){let i=r.split(`
|
|
231
|
+
`);i.slice(0,-1).forEach(r=>{n.insert(r,e.attributes),t.push({type:`block`,delta:n,attributes:e.attributes??{}}),n=new vA.default});let a=i[i.length-1];a&&n.insert(a,e.attributes)}else{let i=Object.keys(r)[0];if(!i)return;this.query(i,Pk.INLINE)?n.push(e):(n.length()&&t.push({type:`block`,delta:n,attributes:{}}),n=new vA.default,t.push({type:`blockEmbed`,key:i,value:r[i],attributes:e.attributes??{}}))}}),n.length()&&t.push({type:`block`,delta:n,attributes:{}}),t}createBlock(e,t){let n,r={};Object.entries(e).forEach(e=>{let[t,i]=e;this.query(t,Pk.BLOCK&Pk.BLOT)==null?r[t]=i:n=t});let i=this.create(n||this.statics.defaultChild.blotName,n?e[n]:void 0);this.insertBefore(i,t||void 0);let a=i.length();return Object.entries(r).forEach(e=>{let[t,n]=e;i.formatAt(0,a,t,n)}),i}};function Cj(e,t,n){n.reduce((t,n)=>{let r=vA.Op.length(n),i=n.attributes||{};if(n.insert!=null){if(typeof n.insert==`string`){let r=n.insert;e.insertAt(t,r);let[a]=e.descendant(qk,t),o=OA(a);i=vA.AttributeMap.diff(o,i)||{}}else if(typeof n.insert==`object`){let r=Object.keys(n.insert)[0];if(r==null)return t;if(e.insertAt(t,r,n.insert[r]),e.scroll.query(r,Pk.INLINE)!=null){let[n]=e.descendant(qk,t),r=OA(n);i=vA.AttributeMap.diff(r,i)||{}}}}return Object.keys(i).forEach(n=>{e.formatAt(t,r,n,i[n])}),t+r},t)}var wj={scope:Pk.BLOCK,whitelist:[`right`,`center`,`justify`]},Tj=new Fk(`align`,`align`,wj),Ej=new Bk(`align`,`ql-align`,wj),Dj=new Hk(`align`,`text-align`,wj),Oj=class extends Hk{value(e){let t=super.value(e);return t.startsWith(`rgb(`)?(t=t.replace(/^[^\d]+/,``).replace(/[^\d]+$/,``),`#${t.split(`,`).map(e=>`00${parseInt(e,10).toString(16)}`.slice(-2)).join(``)}`):t}},kj=new Bk(`color`,`ql-color`,{scope:Pk.INLINE}),Aj=new Oj(`color`,`color`,{scope:Pk.INLINE}),jj=new Bk(`background`,`ql-bg`,{scope:Pk.INLINE}),Mj=new Oj(`background`,`background-color`,{scope:Pk.INLINE}),Nj=class extends yj{static create(e){let t=super.create(e);return t.setAttribute(`spellcheck`,`false`),t}code(e,t){return this.children.map(e=>e.length()<=1?``:e.domNode.innerText).join(`
|
|
232
|
+
`).slice(e,e+t)}html(e,t){return`<pre>\n${SA(this.code(e,t))}\n</pre>`}},Pj=class extends TA{static TAB=` `;static register(){Y.register(Nj)}},Fj=class extends CA{};Fj.blotName=`code`,Fj.tagName=`CODE`,Pj.blotName=`code-block`,Pj.className=`ql-code-block`,Pj.tagName=`DIV`,Nj.blotName=`code-block-container`,Nj.className=`ql-code-block-container`,Nj.tagName=`DIV`,Nj.allowedChildren=[Pj],Pj.allowedChildren=[bA,yA,kA],Pj.requiredContainer=Nj;var Ij={scope:Pk.BLOCK,whitelist:[`rtl`]},Lj=new Fk(`direction`,`dir`,Ij),Rj=new Bk(`direction`,`ql-direction`,Ij),zj=new Hk(`direction`,`direction`,Ij),Bj={scope:Pk.INLINE,whitelist:[`serif`,`monospace`]},Vj=new Bk(`font`,`ql-font`,Bj),Hj=new class extends Hk{value(e){return super.value(e).replace(/["']/g,``)}}(`font`,`font-family`,Bj),Uj=new Bk(`size`,`ql-size`,{scope:Pk.INLINE,whitelist:[`small`,`large`,`huge`]}),Wj=new Hk(`size`,`font-size`,{scope:Pk.INLINE,whitelist:[`10px`,`18px`,`32px`]}),Gj=FA(`quill:keyboard`),Kj=/Mac/i.test(navigator.platform)?`metaKey`:`ctrlKey`,qj=class e extends ZA{static match(e,t){return[`altKey`,`ctrlKey`,`metaKey`,`shiftKey`].some(n=>!!t[n]!==e[n]&&t[n]!==null)?!1:t.key===e.key||t.key===e.which}constructor(e,t){super(e,t),this.bindings={},Object.keys(this.options.bindings).forEach(e=>{this.options.bindings[e]&&this.addBinding(this.options.bindings[e])}),this.addBinding({key:`Enter`,shiftKey:null},this.handleEnter),this.addBinding({key:`Enter`,metaKey:null,ctrlKey:null,altKey:null},()=>{}),/Firefox/i.test(navigator.userAgent)?(this.addBinding({key:`Backspace`},{collapsed:!0},this.handleBackspace),this.addBinding({key:`Delete`},{collapsed:!0},this.handleDelete)):(this.addBinding({key:`Backspace`},{collapsed:!0,prefix:/^.?$/},this.handleBackspace),this.addBinding({key:`Delete`},{collapsed:!0,suffix:/^.?$/},this.handleDelete)),this.addBinding({key:`Backspace`},{collapsed:!1},this.handleDeleteRange),this.addBinding({key:`Delete`},{collapsed:!1},this.handleDeleteRange),this.addBinding({key:`Backspace`,altKey:null,ctrlKey:null,metaKey:null,shiftKey:null},{collapsed:!0,offset:0},this.handleBackspace),this.listen()}addBinding(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=Qj(e);if(r==null){Gj.warn(`Attempted to add invalid keyboard binding`,r);return}typeof t==`function`&&(t={handler:t}),typeof n==`function`&&(n={handler:n}),(Array.isArray(r.key)?r.key:[r.key]).forEach(e=>{let i={...r,key:e,...t,...n};this.bindings[i.key]=this.bindings[i.key]||[],this.bindings[i.key].push(i)})}listen(){this.quill.root.addEventListener(`keydown`,t=>{if(t.defaultPrevented||t.isComposing||t.keyCode===229&&(t.key===`Enter`||t.key===`Backspace`))return;let n=(this.bindings[t.key]||[]).concat(this.bindings[t.which]||[]).filter(n=>e.match(t,n));if(n.length===0)return;let r=Y.find(t.target,!0);if(r&&r.scroll!==this.quill.scroll)return;let i=this.quill.getSelection();if(i==null||!this.quill.hasFocus())return;let[a,o]=this.quill.getLine(i.index),[s,c]=this.quill.getLeaf(i.index),[l,u]=i.length===0?[s,c]:this.quill.getLeaf(i.index+i.length),d=s instanceof dA?s.value().slice(0,c):``,f=l instanceof dA?l.value().slice(u):``,p={collapsed:i.length===0,empty:i.length===0&&a.length()<=1,format:this.quill.getFormat(i),line:a,offset:o,prefix:d,suffix:f,event:t};n.some(e=>{if(e.collapsed!=null&&e.collapsed!==p.collapsed||e.empty!=null&&e.empty!==p.empty||e.offset!=null&&e.offset!==p.offset)return!1;if(Array.isArray(e.format)){if(e.format.every(e=>p.format[e]==null))return!1}else if(typeof e.format==`object`&&!Object.keys(e.format).every(t=>e.format[t]===!0?p.format[t]!=null:e.format[t]===!1?p.format[t]==null:jk(e.format[t],p.format[t])))return!1;return e.prefix!=null&&!e.prefix.test(p.prefix)||e.suffix!=null&&!e.suffix.test(p.suffix)?!1:e.handler.call(this,i,p,e)!==!0})&&t.preventDefault()})}handleBackspace(e,t){let n=/[\uD800-\uDBFF][\uDC00-\uDFFF]$/.test(t.prefix)?2:1;if(e.index===0||this.quill.getLength()<=1)return;let r={},[i]=this.quill.getLine(e.index),a=new vA.default().retain(e.index-n).delete(n);if(t.offset===0){let[t]=this.quill.getLine(e.index-1);if(t&&!(t.statics.blotName===`block`&&t.length()<=1)){let t=i.formats(),n=this.quill.getFormat(e.index-1,1);if(r=vA.AttributeMap.diff(t,n)||{},Object.keys(r).length>0){let t=new vA.default().retain(e.index+i.length()-2).retain(1,r);a=a.compose(t)}}}this.quill.updateContents(a,Y.sources.USER),this.quill.focus()}handleDelete(e,t){let n=/^[\uD800-\uDBFF][\uDC00-\uDFFF]/.test(t.suffix)?2:1;if(e.index>=this.quill.getLength()-n)return;let r={},[i]=this.quill.getLine(e.index),a=new vA.default().retain(e.index).delete(n);if(t.offset>=i.length()-1){let[t]=this.quill.getLine(e.index+1);if(t){let n=i.formats(),o=this.quill.getFormat(e.index,1);r=vA.AttributeMap.diff(n,o)||{},Object.keys(r).length>0&&(a=a.retain(t.length()-1).retain(1,r))}}this.quill.updateContents(a,Y.sources.USER),this.quill.focus()}handleDeleteRange(e){$j({range:e,quill:this.quill}),this.quill.focus()}handleEnter(e,t){let n=Object.keys(t.format).reduce((e,n)=>(this.quill.scroll.query(n,Pk.BLOCK)&&!Array.isArray(t.format[n])&&(e[n]=t.format[n]),e),{}),r=new vA.default().retain(e.index).delete(e.length).insert(`
|
|
233
|
+
`,n);this.quill.updateContents(r,Y.sources.USER),this.quill.setSelection(e.index+1,Y.sources.SILENT),this.quill.focus()}};qj.DEFAULTS={bindings:{bold:Xj(`bold`),italic:Xj(`italic`),underline:Xj(`underline`),indent:{key:`Tab`,format:[`blockquote`,`indent`,`list`],handler(e,t){return t.collapsed&&t.offset!==0?!0:(this.quill.format(`indent`,`+1`,Y.sources.USER),!1)}},outdent:{key:`Tab`,shiftKey:!0,format:[`blockquote`,`indent`,`list`],handler(e,t){return t.collapsed&&t.offset!==0?!0:(this.quill.format(`indent`,`-1`,Y.sources.USER),!1)}},"outdent backspace":{key:`Backspace`,collapsed:!0,shiftKey:null,metaKey:null,ctrlKey:null,altKey:null,format:[`indent`,`list`],offset:0,handler(e,t){t.format.indent==null?t.format.list!=null&&this.quill.format(`list`,!1,Y.sources.USER):this.quill.format(`indent`,`-1`,Y.sources.USER)}},"indent code-block":Jj(!0),"outdent code-block":Jj(!1),"remove tab":{key:`Tab`,shiftKey:!0,collapsed:!0,prefix:/\t$/,handler(e){this.quill.deleteText(e.index-1,1,Y.sources.USER)}},tab:{key:`Tab`,handler(e,t){if(t.format.table)return!0;this.quill.history.cutoff();let n=new vA.default().retain(e.index).delete(e.length).insert(` `);return this.quill.updateContents(n,Y.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(e.index+1,Y.sources.SILENT),!1}},"blockquote empty enter":{key:`Enter`,collapsed:!0,format:[`blockquote`],empty:!0,handler(){this.quill.format(`blockquote`,!1,Y.sources.USER)}},"list empty enter":{key:`Enter`,collapsed:!0,format:[`list`],empty:!0,handler(e,t){let n={list:!1};t.format.indent&&(n.indent=!1),this.quill.formatLine(e.index,e.length,n,Y.sources.USER)}},"checklist enter":{key:`Enter`,collapsed:!0,format:{list:`checked`},handler(e){let[t,n]=this.quill.getLine(e.index),r={...t.formats(),list:`checked`},i=new vA.default().retain(e.index).insert(`
|
|
234
|
+
`,r).retain(t.length()-n-1).retain(1,{list:`unchecked`});this.quill.updateContents(i,Y.sources.USER),this.quill.setSelection(e.index+1,Y.sources.SILENT),this.quill.scrollSelectionIntoView()}},"header enter":{key:`Enter`,collapsed:!0,format:[`header`],suffix:/^$/,handler(e,t){let[n,r]=this.quill.getLine(e.index),i=new vA.default().retain(e.index).insert(`
|
|
235
|
+
`,t.format).retain(n.length()-r-1).retain(1,{header:null});this.quill.updateContents(i,Y.sources.USER),this.quill.setSelection(e.index+1,Y.sources.SILENT),this.quill.scrollSelectionIntoView()}},"table backspace":{key:`Backspace`,format:[`table`],collapsed:!0,offset:0,handler(){}},"table delete":{key:`Delete`,format:[`table`],collapsed:!0,suffix:/^$/,handler(){}},"table enter":{key:`Enter`,shiftKey:null,format:[`table`],handler(e){let t=this.quill.getModule(`table`);if(t){let[n,r,i,a]=t.getTable(e),o=eM(n,r,i,a);if(o==null)return;let s=n.offset();if(o<0){let t=new vA.default().retain(s).insert(`
|
|
236
|
+
`);this.quill.updateContents(t,Y.sources.USER),this.quill.setSelection(e.index+1,e.length,Y.sources.SILENT)}else if(o>0){s+=n.length();let e=new vA.default().retain(s).insert(`
|
|
237
|
+
`);this.quill.updateContents(e,Y.sources.USER),this.quill.setSelection(s,Y.sources.USER)}}}},"table tab":{key:`Tab`,shiftKey:null,format:[`table`],handler(e,t){let{event:n,line:r}=t,i=r.offset(this.quill.scroll);n.shiftKey?this.quill.setSelection(i-1,Y.sources.USER):this.quill.setSelection(i+r.length(),Y.sources.USER)}},"list autofill":{key:` `,shiftKey:null,collapsed:!0,format:{"code-block":!1,blockquote:!1,table:!1},prefix:/^\s*?(\d+\.|-|\*|\[ ?\]|\[x\])$/,handler(e,t){if(this.quill.scroll.query(`list`)==null)return!0;let{length:n}=t.prefix,[r,i]=this.quill.getLine(e.index);if(i>n)return!0;let a;switch(t.prefix.trim()){case`[]`:case`[ ]`:a=`unchecked`;break;case`[x]`:a=`checked`;break;case`-`:case`*`:a=`bullet`;break;default:a=`ordered`}this.quill.insertText(e.index,` `,Y.sources.USER),this.quill.history.cutoff();let o=new vA.default().retain(e.index-i).delete(n+1).retain(r.length()-2-i).retain(1,{list:a});return this.quill.updateContents(o,Y.sources.USER),this.quill.history.cutoff(),this.quill.setSelection(e.index-n,Y.sources.SILENT),!1}},"code exit":{key:`Enter`,collapsed:!0,format:[`code-block`],prefix:/^$/,suffix:/^\s*$/,handler(e){let[t,n]=this.quill.getLine(e.index),r=2,i=t;for(;i!=null&&i.length()<=1&&i.formats()[`code-block`];)if(i=i.prev,--r,r<=0){let r=new vA.default().retain(e.index+t.length()-n-2).retain(1,{"code-block":null}).delete(1);return this.quill.updateContents(r,Y.sources.USER),this.quill.setSelection(e.index-1,Y.sources.SILENT),!1}return!0}},"embed left":Yj(`ArrowLeft`,!1),"embed left shift":Yj(`ArrowLeft`,!0),"embed right":Yj(`ArrowRight`,!1),"embed right shift":Yj(`ArrowRight`,!0),"table down":Zj(!1),"table up":Zj(!0)}};function Jj(e){return{key:`Tab`,shiftKey:!e,format:{"code-block":!0},handler(t,n){let{event:r}=n,{TAB:i}=this.quill.scroll.query(`code-block`);if(t.length===0&&!r.shiftKey){this.quill.insertText(t.index,i,Y.sources.USER),this.quill.setSelection(t.index+i.length,Y.sources.SILENT);return}let a=t.length===0?this.quill.getLines(t.index,1):this.quill.getLines(t),{index:o,length:s}=t;a.forEach((t,n)=>{e?(t.insertAt(0,i),n===0?o+=i.length:s+=i.length):t.domNode.textContent.startsWith(i)&&(t.deleteAt(0,i.length),n===0?o-=i.length:s-=i.length)}),this.quill.update(Y.sources.USER),this.quill.setSelection(o,s,Y.sources.SILENT)}}}function Yj(e,t){return{key:e,shiftKey:t,altKey:null,[e===`ArrowLeft`?`prefix`:`suffix`]:/^$/,handler(n){let{index:r}=n;e===`ArrowRight`&&(r+=n.length+1);let[i]=this.quill.getLeaf(r);return i instanceof aA?(e===`ArrowLeft`?t?this.quill.setSelection(n.index-1,n.length+1,Y.sources.USER):this.quill.setSelection(n.index-1,Y.sources.USER):t?this.quill.setSelection(n.index,n.length+1,Y.sources.USER):this.quill.setSelection(n.index+n.length+1,Y.sources.USER),!1):!0}}}function Xj(e){return{key:e[0],shortKey:!0,handler(t,n){this.quill.format(e,!n.format[e],Y.sources.USER)}}}function Zj(e){return{key:e?`ArrowUp`:`ArrowDown`,collapsed:!0,format:[`table`],handler(t,n){let r=e?`prev`:`next`,i=n.line,a=i.parent[r];if(a!=null){if(a.statics.blotName===`table-row`){let e=a.children.head,t=i;for(;t.prev!=null;)t=t.prev,e=e.next;let r=e.offset(this.quill.scroll)+Math.min(n.offset,e.length()-1);this.quill.setSelection(r,0,Y.sources.USER)}}else{let t=i.table()[r];t!=null&&(e?this.quill.setSelection(t.offset(this.quill.scroll)+t.length()-1,0,Y.sources.USER):this.quill.setSelection(t.offset(this.quill.scroll),0,Y.sources.USER))}return!1}}}function Qj(e){if(typeof e==`string`||typeof e==`number`)e={key:e};else if(typeof e==`object`)e=zO(e);else return null;return e.shortKey&&(e[Kj]=e.shortKey,delete e.shortKey),e}function $j(e){let{quill:t,range:n}=e,r=t.getLines(n),i={};if(r.length>1){let e=r[0].formats(),t=r[r.length-1].formats();i=vA.AttributeMap.diff(t,e)||{}}t.deleteText(n,Y.sources.USER),Object.keys(i).length>0&&t.formatLine(n.index,1,i,Y.sources.USER),t.setSelection(n.index,Y.sources.SILENT)}function eM(e,t,n,r){return t.prev==null&&t.next==null?n.prev==null&&n.next==null?r===0?-1:1:n.prev==null?-1:1:t.prev==null?-1:t.next==null?1:null}var tM=/font-weight:\s*normal/,nM=[`P`,`OL`,`UL`],rM=e=>e&&nM.includes(e.tagName),iM=e=>{Array.from(e.querySelectorAll(`br`)).filter(e=>rM(e.previousElementSibling)&&rM(e.nextElementSibling)).forEach(e=>{e.parentNode?.removeChild(e)})},aM=e=>{Array.from(e.querySelectorAll(`b[style*="font-weight"]`)).filter(e=>e.getAttribute(`style`)?.match(tM)).forEach(t=>{let n=e.createDocumentFragment();n.append(...t.childNodes),t.parentNode?.replaceChild(n,t)})};function oM(e){e.querySelector(`[id^="docs-internal-guid-"]`)&&(aM(e),iM(e))}var sM=/\bmso-list:[^;]*ignore/i,cM=/\bmso-list:[^;]*\bl(\d+)/i,lM=/\bmso-list:[^;]*\blevel(\d+)/i,uM=(e,t)=>{let n=e.getAttribute(`style`),r=n?.match(cM);if(!r)return null;let i=Number(r[1]),a=n?.match(lM),o=a?Number(a[1]):1,s=RegExp(`@list l${i}:level${o}\\s*\\{[^\\}]*mso-level-number-format:\\s*([\\w-]+)`,`i`),c=t.match(s);return{id:i,indent:o,type:c&&c[1]===`bullet`?`bullet`:`ordered`,element:e}},dM=e=>{let t=Array.from(e.querySelectorAll(`[style*=mso-list]`)),n=[],r=[];t.forEach(e=>{(e.getAttribute(`style`)||``).match(sM)?n.push(e):r.push(e)}),n.forEach(e=>e.parentNode?.removeChild(e));let i=e.documentElement.innerHTML,a=r.map(e=>uM(e,i)).filter(e=>e);for(;a.length;){let e=[],t=a.shift();for(;t;)e.push(t),t=a.length&&a[0]?.element===t.element.nextElementSibling&&a[0].id===t.id?a.shift():null;let n=document.createElement(`ul`);e.forEach(e=>{let t=document.createElement(`li`);t.setAttribute(`data-list`,e.type),e.indent>1&&t.setAttribute(`class`,`ql-indent-${e.indent-1}`),t.innerHTML=e.element.innerHTML,n.appendChild(t)});let r=e[0]?.element,{parentNode:i}=r??{};r&&i?.replaceChild(n,r),e.slice(1).forEach(e=>{let{element:t}=e;i?.removeChild(t)})}};function fM(e){e.documentElement.getAttribute(`xmlns:w`)===`urn:schemas-microsoft-com:office:word`&&dM(e)}var pM=[fM,oM],mM=e=>{e.documentElement&&pM.forEach(t=>{t(e)})},hM=FA(`quill:clipboard`),gM=[[Node.TEXT_NODE,RM],[Node.TEXT_NODE,FM],[`br`,AM],[Node.ELEMENT_NODE,FM],[Node.ELEMENT_NODE,kM],[Node.ELEMENT_NODE,OM],[Node.ELEMENT_NODE,IM],[`li`,NM],[`ol, ul`,PM],[`pre`,jM],[`tr`,LM],[`b`,DM(`bold`)],[`i`,DM(`italic`)],[`strike`,DM(`strike`)],[`style`,MM]],_M=[Tj,Lj].reduce((e,t)=>(e[t.keyName]=t,e),{}),vM=[Dj,Mj,Aj,zj,Hj,Wj].reduce((e,t)=>(e[t.keyName]=t,e),{}),yM=class extends ZA{static DEFAULTS={matchers:[]};constructor(e,t){super(e,t),this.quill.root.addEventListener(`copy`,e=>this.onCaptureCopy(e,!1)),this.quill.root.addEventListener(`cut`,e=>this.onCaptureCopy(e,!0)),this.quill.root.addEventListener(`paste`,this.onCapturePaste.bind(this)),this.matchers=[],gM.concat(this.options.matchers??[]).forEach(e=>{let[t,n]=e;this.addMatcher(t,n)})}addMatcher(e,t){this.matchers.push([e,t])}convert(e){let{html:t,text:n}=e,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(r[Pj.blotName])return new vA.default().insert(n||``,{[Pj.blotName]:r[Pj.blotName]});if(!t)return new vA.default().insert(n||``,r);let i=this.convertHTML(t);return xM(i,`
|
|
238
|
+
`)&&(i.ops[i.ops.length-1].attributes==null||r.table)?i.compose(new vA.default().retain(i.length()-1).delete(1)):i}normalizeHTML(e){mM(e)}convertHTML(e){let t=new DOMParser().parseFromString(e,`text/html`);this.normalizeHTML(t);let n=t.body,r=new WeakMap,[i,a]=this.prepareMatching(n,r);return EM(this.quill.scroll,n,i,a,r)}dangerouslyPasteHTML(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Y.sources.API;if(typeof e==`string`){let n=this.convert({html:e,text:``});this.quill.setContents(n,t),this.quill.setSelection(0,Y.sources.SILENT)}else{let r=this.convert({html:t,text:``});this.quill.updateContents(new vA.default().retain(e).concat(r),n),this.quill.setSelection(e+r.length(),Y.sources.SILENT)}}onCaptureCopy(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(e.defaultPrevented)return;e.preventDefault();let[n]=this.quill.selection.getRange();if(n==null)return;let{html:r,text:i}=this.onCopy(n,t);e.clipboardData?.setData(`text/plain`,i),e.clipboardData?.setData(`text/html`,r),t&&$j({range:n,quill:this.quill})}normalizeURIList(e){return e.split(/\r?\n/).filter(e=>e[0]!==`#`).join(`
|
|
239
|
+
`)}onCapturePaste(e){if(e.defaultPrevented||!this.quill.isEnabled())return;e.preventDefault();let t=this.quill.getSelection(!0);if(t==null)return;let n=e.clipboardData?.getData(`text/html`),r=e.clipboardData?.getData(`text/plain`);if(!n&&!r){let t=e.clipboardData?.getData(`text/uri-list`);t&&(r=this.normalizeURIList(t))}let i=Array.from(e.clipboardData?.files||[]);if(!n&&i.length>0){this.quill.uploader.upload(t,i);return}if(n&&i.length>0){let e=new DOMParser().parseFromString(n,`text/html`);if(e.body.childElementCount===1&&e.body.firstElementChild?.tagName===`IMG`){this.quill.uploader.upload(t,i);return}}this.onPaste(t,{html:n,text:r})}onCopy(e){let t=this.quill.getText(e);return{html:this.quill.getSemanticHTML(e),text:t}}onPaste(e,t){let{text:n,html:r}=t,i=this.quill.getFormat(e.index),a=this.convert({text:n,html:r},i);hM.log(`onPaste`,a,{text:n,html:r});let o=new vA.default().retain(e.index).delete(e.length).concat(a);this.quill.updateContents(o,Y.sources.USER),this.quill.setSelection(o.length()-e.length,Y.sources.SILENT),this.quill.scrollSelectionIntoView()}prepareMatching(e,t){let n=[],r=[];return this.matchers.forEach(i=>{let[a,o]=i;switch(a){case Node.TEXT_NODE:r.push(o);break;case Node.ELEMENT_NODE:n.push(o);break;default:Array.from(e.querySelectorAll(a)).forEach(e=>{t.has(e)?t.get(e)?.push(o):t.set(e,[o])});break}}),[n,r]}};function bM(e,t,n,r){return r.query(t)?e.reduce((e,r)=>{if(!r.insert)return e;if(r.attributes&&r.attributes[t])return e.push(r);let i=n?{[t]:n}:{};return e.insert(r.insert,{...i,...r.attributes})},new vA.default):e}function xM(e,t){let n=``;for(let r=e.ops.length-1;r>=0&&n.length<t.length;--r){let t=e.ops[r];if(typeof t.insert!=`string`)break;n=t.insert+n}return n.slice(-1*t.length)===t}function SM(e,t){if(!(e instanceof Element))return!1;let n=t.query(e);return n&&n.prototype instanceof aA?!1:`address.article.blockquote.canvas.dd.div.dl.dt.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.iframe.li.main.nav.ol.output.p.pre.section.table.td.tr.ul.video`.split(`.`).includes(e.tagName.toLowerCase())}function CM(e,t){return e.previousElementSibling&&e.nextElementSibling&&!SM(e.previousElementSibling,t)&&!SM(e.nextElementSibling,t)}var wM=new WeakMap;function TM(e){return e==null?!1:(wM.has(e)||(e.tagName===`PRE`?wM.set(e,!0):wM.set(e,TM(e.parentNode))),wM.get(e))}function EM(e,t,n,r,i){return t.nodeType===t.TEXT_NODE?r.reduce((n,r)=>r(t,n,e),new vA.default):t.nodeType===t.ELEMENT_NODE?Array.from(t.childNodes||[]).reduce((a,o)=>{let s=EM(e,o,n,r,i);return o.nodeType===t.ELEMENT_NODE&&(s=n.reduce((t,n)=>n(o,t,e),s),s=(i.get(o)||[]).reduce((t,n)=>n(o,t,e),s)),a.concat(s)},new vA.default):new vA.default}function DM(e){return(t,n,r)=>bM(n,e,!0,r)}function OM(e,t,n){let r=Fk.keys(e),i=Bk.keys(e),a=Hk.keys(e),o={};return r.concat(i).concat(a).forEach(t=>{let r=n.query(t,Pk.ATTRIBUTE);r!=null&&(o[r.attrName]=r.value(e),o[r.attrName])||(r=_M[t],r!=null&&(r.attrName===t||r.keyName===t)&&(o[r.attrName]=r.value(e)||void 0),r=vM[t],r!=null&&(r.attrName===t||r.keyName===t)&&(r=vM[t],o[r.attrName]=r.value(e)||void 0))}),Object.entries(o).reduce((e,t)=>{let[r,i]=t;return bM(e,r,i,n)},t)}function kM(e,t,n){let r=n.query(e);if(r==null)return t;if(r.prototype instanceof aA){let t={},i=r.value(e);if(i!=null)return t[r.blotName]=i,new vA.default().insert(t,r.formats(e,n))}else if(r.prototype instanceof nA&&!xM(t,`
|
|
240
|
+
`)&&t.insert(`
|
|
241
|
+
`),`blotName`in r&&`formats`in r&&typeof r.formats==`function`)return bM(t,r.blotName,r.formats(e,n),n);return t}function AM(e,t){return xM(t,`
|
|
242
|
+
`)||t.insert(`
|
|
243
|
+
`),t}function jM(e,t,n){let r=n.query(`code-block`);return bM(t,`code-block`,r&&`formats`in r&&typeof r.formats==`function`?r.formats(e,n):!0,n)}function MM(){return new vA.default}function NM(e,t,n){let r=n.query(e);if(r==null||r.blotName!==`list`||!xM(t,`
|
|
244
|
+
`))return t;let i=-1,a=e.parentNode;for(;a!=null;)[`OL`,`UL`].includes(a.tagName)&&(i+=1),a=a.parentNode;return i<=0?t:t.reduce((e,t)=>t.insert?t.attributes&&typeof t.attributes.indent==`number`?e.push(t):e.insert(t.insert,{indent:i,...t.attributes||{}}):e,new vA.default)}function PM(e,t,n){let r=e,i=r.tagName===`OL`?`ordered`:`bullet`,a=r.getAttribute(`data-checked`);return a&&(i=a===`true`?`checked`:`unchecked`),bM(t,`list`,i,n)}function FM(e,t,n){if(!xM(t,`
|
|
245
|
+
`)){if(SM(e,n)&&(e.childNodes.length>0||e instanceof HTMLParagraphElement))return t.insert(`
|
|
246
|
+
`);if(t.length()>0&&e.nextSibling){let r=e.nextSibling;for(;r!=null;){if(SM(r,n))return t.insert(`
|
|
247
|
+
`);let e=n.query(r);if(e&&e.prototype instanceof EA)return t.insert(`
|
|
248
|
+
`);r=r.firstChild}}}return t}function IM(e,t,n){let r={},i=e.style||{};return i.fontStyle===`italic`&&(r.italic=!0),i.textDecoration===`underline`&&(r.underline=!0),i.textDecoration===`line-through`&&(r.strike=!0),(i.fontWeight?.startsWith(`bold`)||parseInt(i.fontWeight,10)>=700)&&(r.bold=!0),t=Object.entries(r).reduce((e,t)=>{let[r,i]=t;return bM(e,r,i,n)},t),parseFloat(i.textIndent||0)>0?new vA.default().insert(` `).concat(t):t}function LM(e,t,n){let r=e.parentElement?.tagName===`TABLE`?e.parentElement:e.parentElement?.parentElement;return r==null?t:bM(t,`table`,Array.from(r.querySelectorAll(`tr`)).indexOf(e)+1,n)}function RM(e,t,n){let r=e.data;if(e.parentElement?.tagName===`O:P`)return t.insert(r.trim());if(!TM(e)){if(r.trim().length===0&&r.includes(`
|
|
249
|
+
`)&&!CM(e,n))return t;r=r.replace(/[^\S\u00a0]/g,` `),r=r.replace(/ {2,}/g,` `),(e.previousSibling==null&&e.parentElement!=null&&SM(e.parentElement,n)||e.previousSibling instanceof Element&&SM(e.previousSibling,n))&&(r=r.replace(/^ /,``)),(e.nextSibling==null&&e.parentElement!=null&&SM(e.parentElement,n)||e.nextSibling instanceof Element&&SM(e.nextSibling,n))&&(r=r.replace(/ $/,``)),r=r.replaceAll(`\xA0`,` `)}return t.insert(r)}var zM=class extends ZA{static DEFAULTS={delay:1e3,maxStack:100,userOnly:!1};lastRecorded=0;ignoreChange=!1;stack={undo:[],redo:[]};currentRange=null;constructor(e,t){super(e,t),this.quill.on(Y.events.EDITOR_CHANGE,(e,t,n,r)=>{e===Y.events.SELECTION_CHANGE?t&&r!==Y.sources.SILENT&&(this.currentRange=t):e===Y.events.TEXT_CHANGE&&(this.ignoreChange||(!this.options.userOnly||r===Y.sources.USER?this.record(t,n):this.transform(t)),this.currentRange=UM(this.currentRange,t))}),this.quill.keyboard.addBinding({key:`z`,shortKey:!0},this.undo.bind(this)),this.quill.keyboard.addBinding({key:[`z`,`Z`],shortKey:!0,shiftKey:!0},this.redo.bind(this)),/Win/i.test(navigator.platform)&&this.quill.keyboard.addBinding({key:`y`,shortKey:!0},this.redo.bind(this)),this.quill.root.addEventListener(`beforeinput`,e=>{e.inputType===`historyUndo`?(this.undo(),e.preventDefault()):e.inputType===`historyRedo`&&(this.redo(),e.preventDefault())})}change(e,t){if(this.stack[e].length===0)return;let n=this.stack[e].pop();if(!n)return;let r=this.quill.getContents(),i=n.delta.invert(r);this.stack[t].push({delta:i,range:UM(n.range,i)}),this.lastRecorded=0,this.ignoreChange=!0,this.quill.updateContents(n.delta,Y.sources.USER),this.ignoreChange=!1,this.restoreSelection(n)}clear(){this.stack={undo:[],redo:[]}}cutoff(){this.lastRecorded=0}record(e,t){if(e.ops.length===0)return;this.stack.redo=[];let n=e.invert(t),r=this.currentRange,i=Date.now();if(this.lastRecorded+this.options.delay>i&&this.stack.undo.length>0){let e=this.stack.undo.pop();e&&(n=n.compose(e.delta),r=e.range)}else this.lastRecorded=i;n.length()!==0&&(this.stack.undo.push({delta:n,range:r}),this.stack.undo.length>this.options.maxStack&&this.stack.undo.shift())}redo(){this.change(`redo`,`undo`)}transform(e){BM(this.stack.undo,e),BM(this.stack.redo,e)}undo(){this.change(`undo`,`redo`)}restoreSelection(e){if(e.range)this.quill.setSelection(e.range,Y.sources.USER);else{let t=HM(this.quill.scroll,e.delta);this.quill.setSelection(t,Y.sources.USER)}}};function BM(e,t){let n=t;for(let t=e.length-1;t>=0;--t){let r=e[t];e[t]={delta:n.transform(r.delta,!0),range:r.range&&UM(r.range,n)},n=r.delta.transform(n),e[t].delta.length()===0&&e.splice(t,1)}}function VM(e,t){let n=t.ops[t.ops.length-1];return n==null?!1:n.insert==null?n.attributes==null?!1:Object.keys(n.attributes).some(t=>e.query(t,Pk.BLOCK)!=null):typeof n.insert==`string`&&n.insert.endsWith(`
|
|
250
|
+
`)}function HM(e,t){let n=t.reduce((e,t)=>e+(t.delete||0),0),r=t.length()-n;return VM(e,t)&&--r,r}function UM(e,t){if(!e)return e;let n=t.transformPosition(e.index);return{index:n,length:t.transformPosition(e.index+e.length)-n}}var WM=class extends ZA{constructor(e,t){super(e,t),e.root.addEventListener(`drop`,t=>{t.preventDefault();let n=null;if(document.caretRangeFromPoint)n=document.caretRangeFromPoint(t.clientX,t.clientY);else if(document.caretPositionFromPoint){let e=document.caretPositionFromPoint(t.clientX,t.clientY);n=document.createRange(),n.setStart(e.offsetNode,e.offset),n.setEnd(e.offsetNode,e.offset)}let r=n&&e.selection.normalizeNative(n);if(r){let n=e.selection.normalizedToRange(r);t.dataTransfer?.files&&this.upload(n,t.dataTransfer.files)}})}upload(e,t){let n=[];Array.from(t).forEach(e=>{e&&this.options.mimetypes?.includes(e.type)&&n.push(e)}),n.length>0&&this.options.handler.call(this,e,n)}};WM.DEFAULTS={mimetypes:[`image/png`,`image/jpeg`],handler(e,t){if(!this.quill.scroll.query(`image`))return;let n=t.map(e=>new Promise(t=>{let n=new FileReader;n.onload=()=>{t(n.result)},n.readAsDataURL(e)}));Promise.all(n).then(t=>{let n=t.reduce((e,t)=>e.insert({image:t}),new vA.default().retain(e.index).delete(e.length));this.quill.updateContents(n,LA.sources.USER),this.quill.setSelection(e.index+t.length,LA.sources.SILENT)})}};var GM=[`insertText`,`insertReplacementText`],KM=class extends ZA{constructor(e,t){super(e,t),e.root.addEventListener(`beforeinput`,e=>{this.handleBeforeInput(e)}),/Android/i.test(navigator.userAgent)||e.on(Y.events.COMPOSITION_BEFORE_START,()=>{this.handleCompositionStart()})}deleteRange(e){$j({range:e,quill:this.quill})}replaceText(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:``;if(e.length===0)return!1;if(t){let n=this.quill.getFormat(e.index,1);this.deleteRange(e),this.quill.updateContents(new vA.default().retain(e.index).insert(t,n),Y.sources.USER)}else this.deleteRange(e);return this.quill.setSelection(e.index+t.length,0,Y.sources.SILENT),!0}handleBeforeInput(e){if(this.quill.composition.isComposing||e.defaultPrevented||!GM.includes(e.inputType))return;let t=e.getTargetRanges?e.getTargetRanges()[0]:null;if(!t||t.collapsed===!0)return;let n=qM(e);if(n==null)return;let r=this.quill.selection.normalizeNative(t),i=r?this.quill.selection.normalizedToRange(r):null;i&&this.replaceText(i,n)&&e.preventDefault()}handleCompositionStart(){let e=this.quill.getSelection();e&&this.replaceText(e)}};function qM(e){return typeof e.data==`string`?e.data:e.dataTransfer?.types.includes(`text/plain`)?e.dataTransfer.getData(`text/plain`):null}var JM=/Mac/i.test(navigator.platform),YM=e=>!!(e.key===`ArrowLeft`||e.key===`ArrowRight`||e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`Home`||JM&&e.key===`a`&&e.ctrlKey===!0),XM=class extends ZA{isListening=!1;selectionChangeDeadline=0;constructor(e,t){super(e,t),this.handleArrowKeys(),this.handleNavigationShortcuts()}handleArrowKeys(){this.quill.keyboard.addBinding({key:[`ArrowLeft`,`ArrowRight`],offset:0,shiftKey:null,handler(e,t){let{line:n,event:r}=t;if(!(n instanceof Zk)||!n.uiNode)return!0;let i=getComputedStyle(n.domNode).direction===`rtl`;return i&&r.key!==`ArrowRight`||!i&&r.key!==`ArrowLeft`?!0:(this.quill.setSelection(e.index-1,e.length+ +!!r.shiftKey,Y.sources.USER),!1)}})}handleNavigationShortcuts(){this.quill.root.addEventListener(`keydown`,e=>{!e.defaultPrevented&&YM(e)&&this.ensureListeningToSelectionChange()})}ensureListeningToSelectionChange(){this.selectionChangeDeadline=Date.now()+100,!this.isListening&&(this.isListening=!0,document.addEventListener(`selectionchange`,()=>{this.isListening=!1,Date.now()<=this.selectionChangeDeadline&&this.handleSelectionChange()},{once:!0}))}handleSelectionChange(){let e=document.getSelection();if(!e)return;let t=e.getRangeAt(0);if(t.collapsed!==!0||t.startOffset!==0)return;let n=this.quill.scroll.find(t.startContainer);if(!(n instanceof Zk)||!n.uiNode)return;let r=document.createRange();r.setStartAfter(n.uiNode),r.setEndAfter(n.uiNode),e.removeAllRanges(),e.addRange(r)}};Y.register({"blots/block":TA,"blots/block/embed":EA,"blots/break":yA,"blots/container":yj,"blots/cursor":kA,"blots/embed":$A,"blots/inline":CA,"blots/scroll":Sj,"blots/text":bA,"modules/clipboard":yM,"modules/history":zM,"modules/keyboard":qj,"modules/uploader":WM,"modules/input":KM,"modules/uiNode":XM});var ZM=Y,QM=new class extends Bk{add(e,t){let n=0;if(t===`+1`||t===`-1`){let r=this.value(e)||0;n=t===`+1`?r+1:r-1}else typeof t==`number`&&(n=t);return n===0?(this.remove(e),!0):super.add(e,n.toString())}canAdd(e,t){return super.canAdd(e,t)||super.canAdd(e,parseInt(t,10))}value(e){return parseInt(super.value(e),10)||void 0}}(`indent`,`ql-indent`,{scope:Pk.BLOCK,whitelist:[1,2,3,4,5,6,7,8]}),$M=class extends TA{static blotName=`blockquote`;static tagName=`blockquote`},eN=class extends TA{static blotName=`header`;static tagName=[`H1`,`H2`,`H3`,`H4`,`H5`,`H6`];static formats(e){return this.tagName.indexOf(e.tagName)+1}},tN=class extends yj{};tN.blotName=`list-container`,tN.tagName=`OL`;var nN=class extends TA{static create(e){let t=super.create();return t.setAttribute(`data-list`,e),t}static formats(e){return e.getAttribute(`data-list`)||void 0}static register(){Y.register(tN)}constructor(e,t){super(e,t);let n=t.ownerDocument.createElement(`span`),r=n=>{if(!e.isEnabled())return;let r=this.statics.formats(t,e);r===`checked`?(this.format(`list`,`unchecked`),n.preventDefault()):r===`unchecked`&&(this.format(`list`,`checked`),n.preventDefault())};n.addEventListener(`mousedown`,r),n.addEventListener(`touchstart`,r),this.attachUI(n)}format(e,t){e===this.statics.blotName&&t?this.domNode.setAttribute(`data-list`,t):super.format(e,t)}};nN.blotName=`list`,nN.tagName=`LI`,tN.allowedChildren=[nN],nN.requiredContainer=tN;var rN=class extends CA{static blotName=`bold`;static tagName=[`STRONG`,`B`];static create(){return super.create()}static formats(){return!0}optimize(e){super.optimize(e),this.domNode.tagName!==this.statics.tagName[0]&&this.replaceWith(this.statics.blotName)}},iN=class extends rN{static blotName=`italic`;static tagName=[`EM`,`I`]},aN=class extends CA{static blotName=`link`;static tagName=`A`;static SANITIZED_URL=`about:blank`;static PROTOCOL_WHITELIST=[`http`,`https`,`mailto`,`tel`,`sms`];static create(e){let t=super.create(e);return t.setAttribute(`href`,this.sanitize(e)),t.setAttribute(`rel`,`noopener noreferrer`),t.setAttribute(`target`,`_blank`),t}static formats(e){return e.getAttribute(`href`)}static sanitize(e){return oN(e,this.PROTOCOL_WHITELIST)?e:this.SANITIZED_URL}format(e,t){e!==this.statics.blotName||!t?super.format(e,t):this.domNode.setAttribute(`href`,this.constructor.sanitize(t))}};function oN(e,t){let n=document.createElement(`a`);n.href=e;let r=n.href.slice(0,n.href.indexOf(`:`));return t.indexOf(r)>-1}var sN=class extends CA{static blotName=`script`;static tagName=[`SUB`,`SUP`];static create(e){return e===`super`?document.createElement(`sup`):e===`sub`?document.createElement(`sub`):super.create(e)}static formats(e){if(e.tagName===`SUB`)return`sub`;if(e.tagName===`SUP`)return`super`}},cN=class extends rN{static blotName=`strike`;static tagName=[`S`,`STRIKE`]},lN=class extends CA{static blotName=`underline`;static tagName=`U`},uN=class extends $A{static blotName=`formula`;static className=`ql-formula`;static tagName=`SPAN`;static create(e){if(window.katex==null)throw Error(`Formula module requires KaTeX.`);let t=super.create(e);return typeof e==`string`&&(window.katex.render(e,t,{throwOnError:!1,errorColor:`#f00`}),t.setAttribute(`data-value`,e)),t}static value(e){return e.getAttribute(`data-value`)}html(){let{formula:e}=this.value();return`<span>${e}</span>`}},dN=[`alt`,`height`,`width`],fN=class extends aA{static blotName=`image`;static tagName=`IMG`;static create(e){let t=super.create(e);return typeof e==`string`&&t.setAttribute(`src`,this.sanitize(e)),t}static formats(e){return dN.reduce((t,n)=>(e.hasAttribute(n)&&(t[n]=e.getAttribute(n)),t),{})}static match(e){return/\.(jpe?g|gif|png)$/.test(e)||/^data:image\/.+;base64/.test(e)}static sanitize(e){return oN(e,[`http`,`https`,`data`])?e:`//:0`}static value(e){return e.getAttribute(`src`)}format(e,t){dN.indexOf(e)>-1?t?this.domNode.setAttribute(e,t):this.domNode.removeAttribute(e):super.format(e,t)}},pN=[`height`,`width`],mN=class extends EA{static blotName=`video`;static className=`ql-video`;static tagName=`IFRAME`;static create(e){let t=super.create(e);return t.setAttribute(`frameborder`,`0`),t.setAttribute(`allowfullscreen`,`true`),t.setAttribute(`src`,this.sanitize(e)),t}static formats(e){return pN.reduce((t,n)=>(e.hasAttribute(n)&&(t[n]=e.getAttribute(n)),t),{})}static sanitize(e){return aN.sanitize(e)}static value(e){return e.getAttribute(`src`)}format(e,t){pN.indexOf(e)>-1?t?this.domNode.setAttribute(e,t):this.domNode.removeAttribute(e):super.format(e,t)}html(){let{video:e}=this.value();return`<a href="${e}">${e}</a>`}},hN=new Bk(`code-token`,`hljs`,{scope:Pk.INLINE}),gN=class e extends CA{static formats(e,t){for(;e!=null&&e!==t.domNode;){if(e.classList&&e.classList.contains(Pj.className))return super.formats(e,t);e=e.parentNode}}constructor(e,t,n){super(e,t,n),hN.add(this.domNode,n)}format(t,n){t===e.blotName?n?hN.add(this.domNode,n):(hN.remove(this.domNode),this.domNode.classList.remove(this.statics.className)):super.format(t,n)}optimize(){super.optimize(...arguments),hN.value(this.domNode)||this.unwrap()}};gN.blotName=`code-token`,gN.className=`ql-token`;var _N=class extends Pj{static create(e){let t=super.create(e);return typeof e==`string`&&t.setAttribute(`data-language`,e),t}static formats(e){return e.getAttribute(`data-language`)||`plain`}static register(){}format(e,t){e===this.statics.blotName&&t?this.domNode.setAttribute(`data-language`,t):super.format(e,t)}replaceWith(e,t){return this.formatAt(0,this.length(),gN.blotName,!1),super.replaceWith(e,t)}},vN=class extends Nj{attach(){super.attach(),this.forceNext=!1,this.scroll.emitMount(this)}format(e,t){e===_N.blotName&&(this.forceNext=!0,this.children.forEach(n=>{n.format(e,t)}))}formatAt(e,t,n,r){n===_N.blotName&&(this.forceNext=!0),super.formatAt(e,t,n,r)}highlight(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(this.children.head==null)return;let n=`${Array.from(this.domNode.childNodes).filter(e=>e!==this.uiNode).map(e=>e.textContent).join(`
|
|
251
|
+
`)}\n`,r=_N.formats(this.children.head.domNode);if(t||this.forceNext||this.cachedText!==n){if(n.trim().length>0||this.cachedText==null){let t=this.children.reduce((e,t)=>e.concat(DA(t,!1)),new vA.default),i=e(n,r);t.diff(i).reduce((e,t)=>{let{retain:n,attributes:r}=t;return n?(r&&Object.keys(r).forEach(t=>{[_N.blotName,gN.blotName].includes(t)&&this.formatAt(e,n,t,r[t])}),e+n):e},0)}this.cachedText=n,this.forceNext=!1}}html(e,t){let[n]=this.children.find(e);return`<pre data-language="${n?_N.formats(n.domNode):`plain`}">\n${SA(this.code(e,t))}\n</pre>`}optimize(e){if(super.optimize(e),this.parent!=null&&this.children.head!=null&&this.uiNode!=null){let e=_N.formats(this.children.head.domNode);e!==this.uiNode.value&&(this.uiNode.value=e)}}};vN.allowedChildren=[_N],_N.requiredContainer=vN,_N.allowedChildren=[gN,kA,bA,yA];var yN=(e,t,n)=>{if(typeof e.versionString==`string`){let r=e.versionString.split(`.`)[0];if(parseInt(r,10)>=11)return e.highlight(n,{language:t}).value}return e.highlight(t,n).value},bN=class extends ZA{static register(){Y.register(gN,!0),Y.register(_N,!0),Y.register(vN,!0)}constructor(e,t){if(super(e,t),this.options.hljs==null)throw Error(`Syntax module requires highlight.js. Please include the library on the page before Quill.`);this.languages=this.options.languages.reduce((e,t)=>{let{key:n}=t;return e[n]=!0,e},{}),this.highlightBlot=this.highlightBlot.bind(this),this.initListener(),this.initTimer()}initListener(){this.quill.on(Y.events.SCROLL_BLOT_MOUNT,e=>{if(!(e instanceof vN))return;let t=this.quill.root.ownerDocument.createElement(`select`);this.options.languages.forEach(e=>{let{key:n,label:r}=e,i=t.ownerDocument.createElement(`option`);i.textContent=r,i.setAttribute(`value`,n),t.appendChild(i)}),t.addEventListener(`change`,()=>{e.format(_N.blotName,t.value),this.quill.root.focus(),this.highlight(e,!0)}),e.uiNode??(e.attachUI(t),e.children.head&&(t.value=_N.formats(e.children.head.domNode)))})}initTimer(){let e=null;this.quill.on(Y.events.SCROLL_OPTIMIZE,()=>{e&&clearTimeout(e),e=setTimeout(()=>{this.highlight(),e=null},this.options.interval)})}highlight(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(this.quill.selection.composing)return;this.quill.update(Y.sources.USER);let n=this.quill.getSelection();(e==null?this.quill.scroll.descendants(vN):[e]).forEach(e=>{e.highlight(this.highlightBlot,t)}),this.quill.update(Y.sources.SILENT),n!=null&&this.quill.setSelection(n,Y.sources.SILENT)}highlightBlot(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`plain`;if(t=this.languages[t]?t:`plain`,t===`plain`)return SA(e).split(`
|
|
252
|
+
`).reduce((e,n,r)=>(r!==0&&e.insert(`
|
|
253
|
+
`,{[Pj.blotName]:t}),e.insert(n)),new vA.default);let n=this.quill.root.ownerDocument.createElement(`div`);return n.classList.add(Pj.className),n.innerHTML=yN(this.options.hljs,t,e),EM(this.quill.scroll,n,[(e,t)=>{let n=hN.value(e);return n?t.compose(new vA.default().retain(t.length(),{[gN.blotName]:n})):t}],[(e,n)=>e.data.split(`
|
|
254
|
+
`).reduce((e,n,r)=>(r!==0&&e.insert(`
|
|
255
|
+
`,{[Pj.blotName]:t}),e.insert(n)),n)],new WeakMap)}};bN.DEFAULTS={hljs:window.hljs,interval:1e3,languages:[{key:`plain`,label:`Plain`},{key:`bash`,label:`Bash`},{key:`cpp`,label:`C++`},{key:`cs`,label:`C#`},{key:`css`,label:`CSS`},{key:`diff`,label:`Diff`},{key:`xml`,label:`HTML/XML`},{key:`java`,label:`Java`},{key:`javascript`,label:`JavaScript`},{key:`markdown`,label:`Markdown`},{key:`php`,label:`PHP`},{key:`python`,label:`Python`},{key:`ruby`,label:`Ruby`},{key:`sql`,label:`SQL`}]};var xN=class e extends TA{static blotName=`table`;static tagName=`TD`;static create(e){let t=super.create();return e?t.setAttribute(`data-row`,e):t.setAttribute(`data-row`,TN()),t}static formats(e){if(e.hasAttribute(`data-row`))return e.getAttribute(`data-row`)}cellOffset(){return this.parent?this.parent.children.indexOf(this):-1}format(t,n){t===e.blotName&&n?this.domNode.setAttribute(`data-row`,n):super.format(t,n)}row(){return this.parent}rowOffset(){return this.row()?this.row().rowOffset():-1}table(){return this.row()&&this.row().table()}},SN=class extends yj{static blotName=`table-row`;static tagName=`TR`;checkMerge(){if(super.checkMerge()&&this.next.children.head!=null){let e=this.children.head.formats(),t=this.children.tail.formats(),n=this.next.children.head.formats(),r=this.next.children.tail.formats();return e.table===t.table&&e.table===n.table&&e.table===r.table}return!1}optimize(e){super.optimize(e),this.children.forEach(e=>{if(e.next==null)return;let t=e.formats(),n=e.next.formats();if(t.table!==n.table){let t=this.splitAfter(e);t&&t.optimize(),this.prev&&this.prev.optimize()}})}rowOffset(){return this.parent?this.parent.children.indexOf(this):-1}table(){return this.parent&&this.parent.parent}},CN=class extends yj{static blotName=`table-body`;static tagName=`TBODY`},wN=class extends yj{static blotName=`table-container`;static tagName=`TABLE`;balanceCells(){let e=this.descendants(SN),t=e.reduce((e,t)=>Math.max(t.children.length,e),0);e.forEach(e=>{Array(t-e.children.length).fill(0).forEach(()=>{let t;e.children.head!=null&&(t=xN.formats(e.children.head.domNode));let n=this.scroll.create(xN.blotName,t);e.appendChild(n),n.optimize()})})}cells(e){return this.rows().map(t=>t.children.at(e))}deleteColumn(e){let[t]=this.descendant(CN);t==null||t.children.head==null||t.children.forEach(t=>{t.children.at(e)?.remove()})}insertColumn(e){let[t]=this.descendant(CN);t==null||t.children.head==null||t.children.forEach(t=>{let n=t.children.at(e),r=xN.formats(t.children.head.domNode),i=this.scroll.create(xN.blotName,r);t.insertBefore(i,n)})}insertRow(e){let[t]=this.descendant(CN);if(t==null||t.children.head==null)return;let n=TN(),r=this.scroll.create(SN.blotName);t.children.head.children.forEach(()=>{let e=this.scroll.create(xN.blotName,n);r.appendChild(e)});let i=t.children.at(e);t.insertBefore(r,i)}rows(){let e=this.children.head;return e==null?[]:e.children.map(e=>e)}};wN.allowedChildren=[CN],CN.requiredContainer=wN,CN.allowedChildren=[SN],SN.requiredContainer=CN,SN.allowedChildren=[xN],xN.requiredContainer=SN;function TN(){return`row-${Math.random().toString(36).slice(2,6)}`}var EN=class extends ZA{static register(){Y.register(xN),Y.register(SN),Y.register(CN),Y.register(wN)}constructor(){super(...arguments),this.listenBalanceCells()}balanceTables(){this.quill.scroll.descendants(wN).forEach(e=>{e.balanceCells()})}deleteColumn(){let[e,,t]=this.getTable();t!=null&&(e.deleteColumn(t.cellOffset()),this.quill.update(Y.sources.USER))}deleteRow(){let[,e]=this.getTable();e!=null&&(e.remove(),this.quill.update(Y.sources.USER))}deleteTable(){let[e]=this.getTable();if(e==null)return;let t=e.offset();e.remove(),this.quill.update(Y.sources.USER),this.quill.setSelection(t,Y.sources.SILENT)}getTable(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.quill.getSelection();if(e==null)return[null,null,null,-1];let[t,n]=this.quill.getLine(e.index);if(t==null||t.statics.blotName!==xN.blotName)return[null,null,null,-1];let r=t.parent;return[r.parent.parent,r,t,n]}insertColumn(e){let t=this.quill.getSelection();if(!t)return;let[n,r,i]=this.getTable(t);if(i==null)return;let a=i.cellOffset();n.insertColumn(a+e),this.quill.update(Y.sources.USER);let o=r.rowOffset();e===0&&(o+=1),this.quill.setSelection(t.index+o,t.length,Y.sources.SILENT)}insertColumnLeft(){this.insertColumn(0)}insertColumnRight(){this.insertColumn(1)}insertRow(e){let t=this.quill.getSelection();if(!t)return;let[n,r,i]=this.getTable(t);if(i==null)return;let a=r.rowOffset();n.insertRow(a+e),this.quill.update(Y.sources.USER),e>0?this.quill.setSelection(t,Y.sources.SILENT):this.quill.setSelection(t.index+r.children.length,t.length,Y.sources.SILENT)}insertRowAbove(){this.insertRow(0)}insertRowBelow(){this.insertRow(1)}insertTable(e,t){let n=this.quill.getSelection();if(n==null)return;let r=Array(e).fill(0).reduce(e=>{let n=Array(t).fill(`
|
|
256
|
+
`).join(``);return e.insert(n,{table:TN()})},new vA.default().retain(n.index));this.quill.updateContents(r,Y.sources.USER),this.quill.setSelection(n.index,Y.sources.SILENT),this.balanceTables()}listenBalanceCells(){this.quill.on(Y.events.SCROLL_OPTIMIZE,e=>{e.some(e=>[`TD`,`TR`,`TBODY`,`TABLE`].includes(e.target.tagName)?(this.quill.once(Y.events.TEXT_CHANGE,(e,t,n)=>{n===Y.sources.USER&&this.balanceTables()}),!0):!1)})}},DN=FA(`quill:toolbar`),ON=class extends ZA{constructor(e,t){if(super(e,t),Array.isArray(this.options.container)){let t=document.createElement(`div`);t.setAttribute(`role`,`toolbar`),AN(t,this.options.container),e.container?.parentNode?.insertBefore(t,e.container),this.container=t}else typeof this.options.container==`string`?this.container=document.querySelector(this.options.container):this.container=this.options.container;if(!(this.container instanceof HTMLElement)){DN.error(`Container required for toolbar`,this.options);return}this.container.classList.add(`ql-toolbar`),this.controls=[],this.handlers={},this.options.handlers&&Object.keys(this.options.handlers).forEach(e=>{let t=this.options.handlers?.[e];t&&this.addHandler(e,t)}),Array.from(this.container.querySelectorAll(`button, select`)).forEach(e=>{this.attach(e)}),this.quill.on(Y.events.EDITOR_CHANGE,()=>{let[e]=this.quill.selection.getRange();this.update(e)})}addHandler(e,t){this.handlers[e]=t}attach(e){let t=Array.from(e.classList).find(e=>e.indexOf(`ql-`)===0);if(!t)return;if(t=t.slice(3),e.tagName===`BUTTON`&&e.setAttribute(`type`,`button`),this.handlers[t]==null&&this.quill.scroll.query(t)==null){DN.warn(`ignoring attaching to nonexistent format`,t,e);return}let n=e.tagName===`SELECT`?`change`:`click`;e.addEventListener(n,n=>{let r;if(e.tagName===`SELECT`){if(e.selectedIndex<0)return;let t=e.options[e.selectedIndex];r=t.hasAttribute(`selected`)?!1:t.value||!1}else r=e.classList.contains(`ql-active`)?!1:e.value||!e.hasAttribute(`value`),n.preventDefault();this.quill.focus();let[i]=this.quill.selection.getRange();if(this.handlers[t]!=null)this.handlers[t].call(this,r);else if(this.quill.scroll.query(t).prototype instanceof aA){if(r=prompt(`Enter ${t}`),!r)return;this.quill.updateContents(new vA.default().retain(i.index).delete(i.length).insert({[t]:r}),Y.sources.USER)}else this.quill.format(t,r,Y.sources.USER);this.update(i)}),this.controls.push([t,e])}update(e){let t=e==null?{}:this.quill.getFormat(e);this.controls.forEach(n=>{let[r,i]=n;if(i.tagName===`SELECT`){let n=null;if(e==null)n=null;else if(t[r]==null)n=i.querySelector(`option[selected]`);else if(!Array.isArray(t[r])){let e=t[r];typeof e==`string`&&(e=e.replace(/"/g,`\\"`)),n=i.querySelector(`option[value="${e}"]`)}n==null?(i.value=``,i.selectedIndex=-1):n.selected=!0}else if(e==null)i.classList.remove(`ql-active`),i.setAttribute(`aria-pressed`,`false`);else if(i.hasAttribute(`value`)){let e=t[r],n=e===i.getAttribute(`value`)||e!=null&&e.toString()===i.getAttribute(`value`)||e==null&&!i.getAttribute(`value`);i.classList.toggle(`ql-active`,n),i.setAttribute(`aria-pressed`,n.toString())}else{let e=t[r]!=null;i.classList.toggle(`ql-active`,e),i.setAttribute(`aria-pressed`,e.toString())}})}};ON.DEFAULTS={};function kN(e,t,n){let r=document.createElement(`button`);r.setAttribute(`type`,`button`),r.classList.add(`ql-${t}`),r.setAttribute(`aria-pressed`,`false`),n==null?r.setAttribute(`aria-label`,t):(r.value=n,r.setAttribute(`aria-label`,`${t}: ${n}`)),e.appendChild(r)}function AN(e,t){Array.isArray(t[0])||(t=[t]),t.forEach(t=>{let n=document.createElement(`span`);n.classList.add(`ql-formats`),t.forEach(e=>{if(typeof e==`string`)kN(n,e);else{let t=Object.keys(e)[0],r=e[t];Array.isArray(r)?jN(n,t,r):kN(n,t,r)}}),e.appendChild(n)})}function jN(e,t,n){let r=document.createElement(`select`);r.classList.add(`ql-${t}`),n.forEach(e=>{let t=document.createElement(`option`);e===!1?t.setAttribute(`selected`,`selected`):t.setAttribute(`value`,String(e)),r.appendChild(t)}),e.appendChild(r)}ON.DEFAULTS={container:null,handlers:{clean(){let e=this.quill.getSelection();if(e!=null)if(e.length===0){let e=this.quill.getFormat();Object.keys(e).forEach(e=>{this.quill.scroll.query(e,Pk.INLINE)!=null&&this.quill.format(e,!1,Y.sources.USER)})}else this.quill.removeFormat(e.index,e.length,Y.sources.USER)},direction(e){let{align:t}=this.quill.getFormat();e===`rtl`&&t==null?this.quill.format(`align`,`right`,Y.sources.USER):!e&&t===`right`&&this.quill.format(`align`,!1,Y.sources.USER),this.quill.format(`direction`,e,Y.sources.USER)},indent(e){let t=this.quill.getSelection(),n=this.quill.getFormat(t),r=parseInt(n.indent||0,10);if(e===`+1`||e===`-1`){let t=e===`+1`?1:-1;n.direction===`rtl`&&(t*=-1),this.quill.format(`indent`,r+t,Y.sources.USER)}},link(e){e===!0&&(e=prompt(`Enter link URL:`)),this.quill.format(`link`,e,Y.sources.USER)},list(e){let t=this.quill.getSelection(),n=this.quill.getFormat(t);e===`check`?n.list===`checked`||n.list===`unchecked`?this.quill.format(`list`,!1,Y.sources.USER):this.quill.format(`list`,`unchecked`,Y.sources.USER):this.quill.format(`list`,e,Y.sources.USER)}}};var MN=`<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="3" x2="15" y1="9" y2="9"/><line class="ql-stroke" x1="3" x2="13" y1="14" y2="14"/><line class="ql-stroke" x1="3" x2="9" y1="4" y2="4"/></svg>`,NN=`<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="15" x2="3" y1="9" y2="9"/><line class="ql-stroke" x1="14" x2="4" y1="14" y2="14"/><line class="ql-stroke" x1="12" x2="6" y1="4" y2="4"/></svg>`,PN=`<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="15" x2="3" y1="9" y2="9"/><line class="ql-stroke" x1="15" x2="5" y1="14" y2="14"/><line class="ql-stroke" x1="15" x2="9" y1="4" y2="4"/></svg>`,FN=`<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="15" x2="3" y1="9" y2="9"/><line class="ql-stroke" x1="15" x2="3" y1="14" y2="14"/><line class="ql-stroke" x1="15" x2="3" y1="4" y2="4"/></svg>`,IN=`<svg viewbox="0 0 18 18"><g class="ql-fill ql-color-label"><polygon points="6 6.868 6 6 5 6 5 7 5.942 7 6 6.868"/><rect height="1" width="1" x="4" y="4"/><polygon points="6.817 5 6 5 6 6 6.38 6 6.817 5"/><rect height="1" width="1" x="2" y="6"/><rect height="1" width="1" x="3" y="5"/><rect height="1" width="1" x="4" y="7"/><polygon points="4 11.439 4 11 3 11 3 12 3.755 12 4 11.439"/><rect height="1" width="1" x="2" y="12"/><rect height="1" width="1" x="2" y="9"/><rect height="1" width="1" x="2" y="15"/><polygon points="4.63 10 4 10 4 11 4.192 11 4.63 10"/><rect height="1" width="1" x="3" y="8"/><path d="M10.832,4.2L11,4.582V4H10.708A1.948,1.948,0,0,1,10.832,4.2Z"/><path d="M7,4.582L7.168,4.2A1.929,1.929,0,0,1,7.292,4H7V4.582Z"/><path d="M8,13H7.683l-0.351.8a1.933,1.933,0,0,1-.124.2H8V13Z"/><rect height="1" width="1" x="12" y="2"/><rect height="1" width="1" x="11" y="3"/><path d="M9,3H8V3.282A1.985,1.985,0,0,1,9,3Z"/><rect height="1" width="1" x="2" y="3"/><rect height="1" width="1" x="6" y="2"/><rect height="1" width="1" x="3" y="2"/><rect height="1" width="1" x="5" y="3"/><rect height="1" width="1" x="9" y="2"/><rect height="1" width="1" x="15" y="14"/><polygon points="13.447 10.174 13.469 10.225 13.472 10.232 13.808 11 14 11 14 10 13.37 10 13.447 10.174"/><rect height="1" width="1" x="13" y="7"/><rect height="1" width="1" x="15" y="5"/><rect height="1" width="1" x="14" y="6"/><rect height="1" width="1" x="15" y="8"/><rect height="1" width="1" x="14" y="9"/><path d="M3.775,14H3v1H4V14.314A1.97,1.97,0,0,1,3.775,14Z"/><rect height="1" width="1" x="14" y="3"/><polygon points="12 6.868 12 6 11.62 6 12 6.868"/><rect height="1" width="1" x="15" y="2"/><rect height="1" width="1" x="12" y="5"/><rect height="1" width="1" x="13" y="4"/><polygon points="12.933 9 13 9 13 8 12.495 8 12.933 9"/><rect height="1" width="1" x="9" y="14"/><rect height="1" width="1" x="8" y="15"/><path d="M6,14.926V15H7V14.316A1.993,1.993,0,0,1,6,14.926Z"/><rect height="1" width="1" x="5" y="15"/><path d="M10.668,13.8L10.317,13H10v1h0.792A1.947,1.947,0,0,1,10.668,13.8Z"/><rect height="1" width="1" x="11" y="15"/><path d="M14.332,12.2a1.99,1.99,0,0,1,.166.8H15V12H14.245Z"/><rect height="1" width="1" x="14" y="15"/><rect height="1" width="1" x="15" y="11"/></g><polyline class="ql-stroke" points="5.5 13 9 5 12.5 13"/><line class="ql-stroke" x1="11.63" x2="6.38" y1="11" y2="11"/></svg>`,LN=`<svg viewbox="0 0 18 18"><rect class="ql-fill ql-stroke" height="3" width="3" x="4" y="5"/><rect class="ql-fill ql-stroke" height="3" width="3" x="11" y="5"/><path class="ql-even ql-fill ql-stroke" d="M7,8c0,4.031-3,5-3,5"/><path class="ql-even ql-fill ql-stroke" d="M14,8c0,4.031-3,5-3,5"/></svg>`,RN=`<svg viewbox="0 0 18 18"><path class="ql-stroke" d="M5,4H9.5A2.5,2.5,0,0,1,12,6.5v0A2.5,2.5,0,0,1,9.5,9H5A0,0,0,0,1,5,9V4A0,0,0,0,1,5,4Z"/><path class="ql-stroke" d="M5,9h5.5A2.5,2.5,0,0,1,13,11.5v0A2.5,2.5,0,0,1,10.5,14H5a0,0,0,0,1,0,0V9A0,0,0,0,1,5,9Z"/></svg>`,zN=`<svg class="" viewbox="0 0 18 18"><line class="ql-stroke" x1="5" x2="13" y1="3" y2="3"/><line class="ql-stroke" x1="6" x2="9.35" y1="12" y2="3"/><line class="ql-stroke" x1="11" x2="15" y1="11" y2="15"/><line class="ql-stroke" x1="15" x2="11" y1="11" y2="15"/><rect class="ql-fill" height="1" rx="0.5" ry="0.5" width="7" x="2" y="14"/></svg>`,BN=`<svg viewbox="0 0 18 18"><polyline class="ql-even ql-stroke" points="5 7 3 9 5 11"/><polyline class="ql-even ql-stroke" points="13 7 15 9 13 11"/><line class="ql-stroke" x1="10" x2="8" y1="5" y2="13"/></svg>`,VN={align:{"":MN,center:NN,right:PN,justify:FN},background:IN,blockquote:LN,bold:RN,clean:zN,code:BN,"code-block":BN,color:`<svg viewbox="0 0 18 18"><line class="ql-color-label ql-stroke ql-transparent" x1="3" x2="15" y1="15" y2="15"/><polyline class="ql-stroke" points="5.5 11 9 3 12.5 11"/><line class="ql-stroke" x1="11.63" x2="6.38" y1="9" y2="9"/></svg>`,direction:{"":`<svg viewbox="0 0 18 18"><polygon class="ql-stroke ql-fill" points="3 11 5 9 3 7 3 11"/><line class="ql-stroke ql-fill" x1="15" x2="11" y1="4" y2="4"/><path class="ql-fill" d="M11,3a3,3,0,0,0,0,6h1V3H11Z"/><rect class="ql-fill" height="11" width="1" x="11" y="4"/><rect class="ql-fill" height="11" width="1" x="13" y="4"/></svg>`,rtl:`<svg viewbox="0 0 18 18"><polygon class="ql-stroke ql-fill" points="15 12 13 10 15 8 15 12"/><line class="ql-stroke ql-fill" x1="9" x2="5" y1="4" y2="4"/><path class="ql-fill" d="M5,3A3,3,0,0,0,5,9H6V3H5Z"/><rect class="ql-fill" height="11" width="1" x="5" y="4"/><rect class="ql-fill" height="11" width="1" x="7" y="4"/></svg>`},formula:`<svg viewbox="0 0 18 18"><path class="ql-fill" d="M11.759,2.482a2.561,2.561,0,0,0-3.53.607A7.656,7.656,0,0,0,6.8,6.2C6.109,9.188,5.275,14.677,4.15,14.927a1.545,1.545,0,0,0-1.3-.933A0.922,0.922,0,0,0,2,15.036S1.954,16,4.119,16s3.091-2.691,3.7-5.553c0.177-.826.36-1.726,0.554-2.6L8.775,6.2c0.381-1.421.807-2.521,1.306-2.676a1.014,1.014,0,0,0,1.02.56A0.966,0.966,0,0,0,11.759,2.482Z"/><rect class="ql-fill" height="1.6" rx="0.8" ry="0.8" width="5" x="5.15" y="6.2"/><path class="ql-fill" d="M13.663,12.027a1.662,1.662,0,0,1,.266-0.276q0.193,0.069.456,0.138a2.1,2.1,0,0,0,.535.069,1.075,1.075,0,0,0,.767-0.3,1.044,1.044,0,0,0,.314-0.8,0.84,0.84,0,0,0-.238-0.619,0.8,0.8,0,0,0-.594-0.239,1.154,1.154,0,0,0-.781.3,4.607,4.607,0,0,0-.781,1q-0.091.15-.218,0.346l-0.246.38c-0.068-.288-0.137-0.582-0.212-0.885-0.459-1.847-2.494-.984-2.941-0.8-0.482.2-.353,0.647-0.094,0.529a0.869,0.869,0,0,1,1.281.585c0.217,0.751.377,1.436,0.527,2.038a5.688,5.688,0,0,1-.362.467,2.69,2.69,0,0,1-.264.271q-0.221-.08-0.471-0.147a2.029,2.029,0,0,0-.522-0.066,1.079,1.079,0,0,0-.768.3A1.058,1.058,0,0,0,9,15.131a0.82,0.82,0,0,0,.832.852,1.134,1.134,0,0,0,.787-0.3,5.11,5.11,0,0,0,.776-0.993q0.141-.219.215-0.34c0.046-.076.122-0.194,0.223-0.346a2.786,2.786,0,0,0,.918,1.726,2.582,2.582,0,0,0,2.376-.185c0.317-.181.212-0.565,0-0.494A0.807,0.807,0,0,1,14.176,15a5.159,5.159,0,0,1-.913-2.446l0,0Q13.487,12.24,13.663,12.027Z"/></svg>`,header:{1:`<svg viewBox="0 0 18 18"><path class="ql-fill" d="M10,4V14a1,1,0,0,1-2,0V10H3v4a1,1,0,0,1-2,0V4A1,1,0,0,1,3,4V8H8V4a1,1,0,0,1,2,0Zm6.06787,9.209H14.98975V7.59863a.54085.54085,0,0,0-.605-.60547h-.62744a1.01119,1.01119,0,0,0-.748.29688L11.645,8.56641a.5435.5435,0,0,0-.022.8584l.28613.30762a.53861.53861,0,0,0,.84717.0332l.09912-.08789a1.2137,1.2137,0,0,0,.2417-.35254h.02246s-.01123.30859-.01123.60547V13.209H12.041a.54085.54085,0,0,0-.605.60547v.43945a.54085.54085,0,0,0,.605.60547h4.02686a.54085.54085,0,0,0,.605-.60547v-.43945A.54085.54085,0,0,0,16.06787,13.209Z"/></svg>`,2:`<svg viewBox="0 0 18 18"><path class="ql-fill" d="M16.73975,13.81445v.43945a.54085.54085,0,0,1-.605.60547H11.855a.58392.58392,0,0,1-.64893-.60547V14.0127c0-2.90527,3.39941-3.42187,3.39941-4.55469a.77675.77675,0,0,0-.84717-.78125,1.17684,1.17684,0,0,0-.83594.38477c-.2749.26367-.561.374-.85791.13184l-.4292-.34082c-.30811-.24219-.38525-.51758-.1543-.81445a2.97155,2.97155,0,0,1,2.45361-1.17676,2.45393,2.45393,0,0,1,2.68408,2.40918c0,2.45312-3.1792,2.92676-3.27832,3.93848h2.79443A.54085.54085,0,0,1,16.73975,13.81445ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z"/></svg>`,3:`<svg viewBox="0 0 18 18"><path class="ql-fill" d="M16.65186,12.30664a2.6742,2.6742,0,0,1-2.915,2.68457,3.96592,3.96592,0,0,1-2.25537-.6709.56007.56007,0,0,1-.13232-.83594L11.64648,13c.209-.34082.48389-.36328.82471-.1543a2.32654,2.32654,0,0,0,1.12256.33008c.71484,0,1.12207-.35156,1.12207-.78125,0-.61523-.61621-.86816-1.46338-.86816H13.2085a.65159.65159,0,0,1-.68213-.41895l-.05518-.10937a.67114.67114,0,0,1,.14307-.78125l.71533-.86914a8.55289,8.55289,0,0,1,.68213-.7373V8.58887a3.93913,3.93913,0,0,1-.748.05469H11.9873a.54085.54085,0,0,1-.605-.60547V7.59863a.54085.54085,0,0,1,.605-.60547h3.75146a.53773.53773,0,0,1,.60547.59375v.17676a1.03723,1.03723,0,0,1-.27539.748L14.74854,10.0293A2.31132,2.31132,0,0,1,16.65186,12.30664ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z"/></svg>`,4:`<svg viewBox="0 0 18 18"><path class="ql-fill" d="M10,4V14a1,1,0,0,1-2,0V10H3v4a1,1,0,0,1-2,0V4A1,1,0,0,1,3,4V8H8V4a1,1,0,0,1,2,0Zm7.05371,7.96582v.38477c0,.39648-.165.60547-.46191.60547h-.47314v1.29785a.54085.54085,0,0,1-.605.60547h-.69336a.54085.54085,0,0,1-.605-.60547V12.95605H11.333a.5412.5412,0,0,1-.60547-.60547v-.15332a1.199,1.199,0,0,1,.22021-.748l2.56348-4.05957a.7819.7819,0,0,1,.72607-.39648h1.27637a.54085.54085,0,0,1,.605.60547v3.7627h.33008A.54055.54055,0,0,1,17.05371,11.96582ZM14.28125,8.7207h-.022a4.18969,4.18969,0,0,1-.38525.81348l-1.188,1.80469v.02246h1.5293V9.60059A7.04058,7.04058,0,0,1,14.28125,8.7207Z"/></svg>`,5:`<svg viewBox="0 0 18 18"><path class="ql-fill" d="M16.74023,12.18555a2.75131,2.75131,0,0,1-2.91553,2.80566,3.908,3.908,0,0,1-2.25537-.68164.54809.54809,0,0,1-.13184-.8252L11.73438,13c.209-.34082.48389-.36328.8252-.1543a2.23757,2.23757,0,0,0,1.1001.33008,1.01827,1.01827,0,0,0,1.1001-.96777c0-.61621-.53906-.97949-1.25439-.97949a2.15554,2.15554,0,0,0-.64893.09961,1.15209,1.15209,0,0,1-.814.01074l-.12109-.04395a.64116.64116,0,0,1-.45117-.71484l.231-3.00391a.56666.56666,0,0,1,.62744-.583H15.541a.54085.54085,0,0,1,.605.60547v.43945a.54085.54085,0,0,1-.605.60547H13.41748l-.04395.72559a1.29306,1.29306,0,0,1-.04395.30859h.022a2.39776,2.39776,0,0,1,.57227-.07715A2.53266,2.53266,0,0,1,16.74023,12.18555ZM9,3A.99974.99974,0,0,0,8,4V8H3V4A1,1,0,0,0,1,4V14a1,1,0,0,0,2,0V10H8v4a1,1,0,0,0,2,0V4A.99974.99974,0,0,0,9,3Z"/></svg>`,6:`<svg viewBox="0 0 18 18"><path class="ql-fill" d="M14.51758,9.64453a1.85627,1.85627,0,0,0-1.24316.38477H13.252a1.73532,1.73532,0,0,1,1.72754-1.4082,2.66491,2.66491,0,0,1,.5498.06641c.35254.05469.57227.01074.70508-.40723l.16406-.5166a.53393.53393,0,0,0-.373-.75977,4.83723,4.83723,0,0,0-1.17773-.14258c-2.43164,0-3.7627,2.17773-3.7627,4.43359,0,2.47559,1.60645,3.69629,3.19043,3.69629A2.70585,2.70585,0,0,0,16.96,12.19727,2.43861,2.43861,0,0,0,14.51758,9.64453Zm-.23047,3.58691c-.67187,0-1.22168-.81445-1.22168-1.45215,0-.47363.30762-.583.72559-.583.96875,0,1.27734.59375,1.27734,1.12207A.82182.82182,0,0,1,14.28711,13.23145ZM10,4V14a1,1,0,0,1-2,0V10H3v4a1,1,0,0,1-2,0V4A1,1,0,0,1,3,4V8H8V4a1,1,0,0,1,2,0Z"/></svg>`},italic:`<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="7" x2="13" y1="4" y2="4"/><line class="ql-stroke" x1="5" x2="11" y1="14" y2="14"/><line class="ql-stroke" x1="8" x2="10" y1="14" y2="4"/></svg>`,image:`<svg viewbox="0 0 18 18"><rect class="ql-stroke" height="10" width="12" x="3" y="4"/><circle class="ql-fill" cx="6" cy="7" r="1"/><polyline class="ql-even ql-fill" points="5 12 5 11 7 9 8 10 11 7 13 9 13 12 5 12"/></svg>`,indent:{"+1":`<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="3" x2="15" y1="14" y2="14"/><line class="ql-stroke" x1="3" x2="15" y1="4" y2="4"/><line class="ql-stroke" x1="9" x2="15" y1="9" y2="9"/><polyline class="ql-fill ql-stroke" points="3 7 3 11 5 9 3 7"/></svg>`,"-1":`<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="3" x2="15" y1="14" y2="14"/><line class="ql-stroke" x1="3" x2="15" y1="4" y2="4"/><line class="ql-stroke" x1="9" x2="15" y1="9" y2="9"/><polyline class="ql-stroke" points="5 7 5 11 3 9 5 7"/></svg>`},link:`<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="7" x2="11" y1="7" y2="11"/><path class="ql-even ql-stroke" d="M8.9,4.577a3.476,3.476,0,0,1,.36,4.679A3.476,3.476,0,0,1,4.577,8.9C3.185,7.5,2.035,6.4,4.217,4.217S7.5,3.185,8.9,4.577Z"/><path class="ql-even ql-stroke" d="M13.423,9.1a3.476,3.476,0,0,0-4.679-.36,3.476,3.476,0,0,0,.36,4.679c1.392,1.392,2.5,2.542,4.679.36S14.815,10.5,13.423,9.1Z"/></svg>`,list:{bullet:`<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="6" x2="15" y1="4" y2="4"/><line class="ql-stroke" x1="6" x2="15" y1="9" y2="9"/><line class="ql-stroke" x1="6" x2="15" y1="14" y2="14"/><line class="ql-stroke" x1="3" x2="3" y1="4" y2="4"/><line class="ql-stroke" x1="3" x2="3" y1="9" y2="9"/><line class="ql-stroke" x1="3" x2="3" y1="14" y2="14"/></svg>`,check:`<svg class="" viewbox="0 0 18 18"><line class="ql-stroke" x1="9" x2="15" y1="4" y2="4"/><polyline class="ql-stroke" points="3 4 4 5 6 3"/><line class="ql-stroke" x1="9" x2="15" y1="14" y2="14"/><polyline class="ql-stroke" points="3 14 4 15 6 13"/><line class="ql-stroke" x1="9" x2="15" y1="9" y2="9"/><polyline class="ql-stroke" points="3 9 4 10 6 8"/></svg>`,ordered:`<svg viewbox="0 0 18 18"><line class="ql-stroke" x1="7" x2="15" y1="4" y2="4"/><line class="ql-stroke" x1="7" x2="15" y1="9" y2="9"/><line class="ql-stroke" x1="7" x2="15" y1="14" y2="14"/><line class="ql-stroke ql-thin" x1="2.5" x2="4.5" y1="5.5" y2="5.5"/><path class="ql-fill" d="M3.5,6A0.5,0.5,0,0,1,3,5.5V3.085l-0.276.138A0.5,0.5,0,0,1,2.053,3c-0.124-.247-0.023-0.324.224-0.447l1-.5A0.5,0.5,0,0,1,4,2.5v3A0.5,0.5,0,0,1,3.5,6Z"/><path class="ql-stroke ql-thin" d="M4.5,10.5h-2c0-.234,1.85-1.076,1.85-2.234A0.959,0.959,0,0,0,2.5,8.156"/><path class="ql-stroke ql-thin" d="M2.5,14.846a0.959,0.959,0,0,0,1.85-.109A0.7,0.7,0,0,0,3.75,14a0.688,0.688,0,0,0,.6-0.736,0.959,0.959,0,0,0-1.85-.109"/></svg>`},script:{sub:`<svg viewbox="0 0 18 18"><path class="ql-fill" d="M15.5,15H13.861a3.858,3.858,0,0,0,1.914-2.975,1.8,1.8,0,0,0-1.6-1.751A1.921,1.921,0,0,0,12.021,11.7a0.50013,0.50013,0,1,0,.957.291h0a0.914,0.914,0,0,1,1.053-.725,0.81,0.81,0,0,1,.744.762c0,1.076-1.16971,1.86982-1.93971,2.43082A1.45639,1.45639,0,0,0,12,15.5a0.5,0.5,0,0,0,.5.5h3A0.5,0.5,0,0,0,15.5,15Z"/><path class="ql-fill" d="M9.65,5.241a1,1,0,0,0-1.409.108L6,7.964,3.759,5.349A1,1,0,0,0,2.192,6.59178Q2.21541,6.6213,2.241,6.649L4.684,9.5,2.241,12.35A1,1,0,0,0,3.71,13.70722q0.02557-.02768.049-0.05722L6,11.036,8.241,13.65a1,1,0,1,0,1.567-1.24277Q9.78459,12.3777,9.759,12.35L7.316,9.5,9.759,6.651A1,1,0,0,0,9.65,5.241Z"/></svg>`,super:`<svg viewbox="0 0 18 18"><path class="ql-fill" d="M15.5,7H13.861a4.015,4.015,0,0,0,1.914-2.975,1.8,1.8,0,0,0-1.6-1.751A1.922,1.922,0,0,0,12.021,3.7a0.5,0.5,0,1,0,.957.291,0.917,0.917,0,0,1,1.053-.725,0.81,0.81,0,0,1,.744.762c0,1.077-1.164,1.925-1.934,2.486A1.423,1.423,0,0,0,12,7.5a0.5,0.5,0,0,0,.5.5h3A0.5,0.5,0,0,0,15.5,7Z"/><path class="ql-fill" d="M9.651,5.241a1,1,0,0,0-1.41.108L6,7.964,3.759,5.349a1,1,0,1,0-1.519,1.3L4.683,9.5,2.241,12.35a1,1,0,1,0,1.519,1.3L6,11.036,8.241,13.65a1,1,0,0,0,1.519-1.3L7.317,9.5,9.759,6.651A1,1,0,0,0,9.651,5.241Z"/></svg>`},strike:`<svg viewbox="0 0 18 18"><line class="ql-stroke ql-thin" x1="15.5" x2="2.5" y1="8.5" y2="9.5"/><path class="ql-fill" d="M9.007,8C6.542,7.791,6,7.519,6,6.5,6,5.792,7.283,5,9,5c1.571,0,2.765.679,2.969,1.309a1,1,0,0,0,1.9-.617C13.356,4.106,11.354,3,9,3,6.2,3,4,4.538,4,6.5a3.2,3.2,0,0,0,.5,1.843Z"/><path class="ql-fill" d="M8.984,10C11.457,10.208,12,10.479,12,11.5c0,0.708-1.283,1.5-3,1.5-1.571,0-2.765-.679-2.969-1.309a1,1,0,1,0-1.9.617C4.644,13.894,6.646,15,9,15c2.8,0,5-1.538,5-3.5a3.2,3.2,0,0,0-.5-1.843Z"/></svg>`,table:`<svg viewbox="0 0 18 18"><rect class="ql-stroke" height="12" width="12" x="3" y="3"/><rect class="ql-fill" height="2" width="3" x="5" y="5"/><rect class="ql-fill" height="2" width="4" x="9" y="5"/><g class="ql-fill ql-transparent"><rect height="2" width="3" x="5" y="8"/><rect height="2" width="4" x="9" y="8"/><rect height="2" width="3" x="5" y="11"/><rect height="2" width="4" x="9" y="11"/></g></svg>`,underline:`<svg viewbox="0 0 18 18"><path class="ql-stroke" d="M5,3V9a4.012,4.012,0,0,0,4,4H9a4.012,4.012,0,0,0,4-4V3"/><rect class="ql-fill" height="1" rx="0.5" ry="0.5" width="12" x="3" y="15"/></svg>`,video:`<svg viewbox="0 0 18 18"><rect class="ql-stroke" height="12" width="12" x="3" y="3"/><rect class="ql-fill" height="12" width="1" x="5" y="3"/><rect class="ql-fill" height="12" width="1" x="12" y="3"/><rect class="ql-fill" height="2" width="8" x="5" y="8"/><rect class="ql-fill" height="1" width="3" x="3" y="5"/><rect class="ql-fill" height="1" width="3" x="3" y="7"/><rect class="ql-fill" height="1" width="3" x="3" y="10"/><rect class="ql-fill" height="1" width="3" x="3" y="12"/><rect class="ql-fill" height="1" width="3" x="12" y="5"/><rect class="ql-fill" height="1" width="3" x="12" y="7"/><rect class="ql-fill" height="1" width="3" x="12" y="10"/><rect class="ql-fill" height="1" width="3" x="12" y="12"/></svg>`},HN=`<svg viewbox="0 0 18 18"><polygon class="ql-stroke" points="7 11 9 13 11 11 7 11"/><polygon class="ql-stroke" points="7 7 9 5 11 7 7 7"/></svg>`,UN=0;function WN(e,t){e.setAttribute(t,`${e.getAttribute(t)!==`true`}`)}var GN=class{constructor(e){this.select=e,this.container=document.createElement(`span`),this.buildPicker(),this.select.style.display=`none`,this.select.parentNode.insertBefore(this.container,this.select),this.label.addEventListener(`mousedown`,()=>{this.togglePicker()}),this.label.addEventListener(`keydown`,e=>{switch(e.key){case`Enter`:this.togglePicker();break;case`Escape`:this.escape(),e.preventDefault();break;default:}}),this.select.addEventListener(`change`,this.update.bind(this))}togglePicker(){this.container.classList.toggle(`ql-expanded`),WN(this.label,`aria-expanded`),WN(this.options,`aria-hidden`)}buildItem(e){let t=document.createElement(`span`);t.tabIndex=`0`,t.setAttribute(`role`,`button`),t.classList.add(`ql-picker-item`);let n=e.getAttribute(`value`);return n&&t.setAttribute(`data-value`,n),e.textContent&&t.setAttribute(`data-label`,e.textContent),t.addEventListener(`click`,()=>{this.selectItem(t,!0)}),t.addEventListener(`keydown`,e=>{switch(e.key){case`Enter`:this.selectItem(t,!0),e.preventDefault();break;case`Escape`:this.escape(),e.preventDefault();break;default:}}),t}buildLabel(){let e=document.createElement(`span`);return e.classList.add(`ql-picker-label`),e.innerHTML=HN,e.tabIndex=`0`,e.setAttribute(`role`,`button`),e.setAttribute(`aria-expanded`,`false`),this.container.appendChild(e),e}buildOptions(){let e=document.createElement(`span`);e.classList.add(`ql-picker-options`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=`-1`,e.id=`ql-picker-options-${UN}`,UN+=1,this.label.setAttribute(`aria-controls`,e.id),this.options=e,Array.from(this.select.options).forEach(t=>{let n=this.buildItem(t);e.appendChild(n),t.selected===!0&&this.selectItem(n)}),this.container.appendChild(e)}buildPicker(){Array.from(this.select.attributes).forEach(e=>{this.container.setAttribute(e.name,e.value)}),this.container.classList.add(`ql-picker`),this.label=this.buildLabel(),this.buildOptions()}escape(){this.close(),setTimeout(()=>this.label.focus(),1)}close(){this.container.classList.remove(`ql-expanded`),this.label.setAttribute(`aria-expanded`,`false`),this.options.setAttribute(`aria-hidden`,`true`)}selectItem(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=this.container.querySelector(`.ql-selected`);e!==n&&(n?.classList.remove(`ql-selected`),e!=null&&(e.classList.add(`ql-selected`),this.select.selectedIndex=Array.from(e.parentNode.children).indexOf(e),e.hasAttribute(`data-value`)?this.label.setAttribute(`data-value`,e.getAttribute(`data-value`)):this.label.removeAttribute(`data-value`),e.hasAttribute(`data-label`)?this.label.setAttribute(`data-label`,e.getAttribute(`data-label`)):this.label.removeAttribute(`data-label`),t&&(this.select.dispatchEvent(new Event(`change`)),this.close())))}update(){let e;if(this.select.selectedIndex>-1){let t=this.container.querySelector(`.ql-picker-options`).children[this.select.selectedIndex];e=this.select.options[this.select.selectedIndex],this.selectItem(t)}else this.selectItem(null);let t=e!=null&&e!==this.select.querySelector(`option[selected]`);this.label.classList.toggle(`ql-active`,t)}},KN=class extends GN{constructor(e,t){super(e),this.label.innerHTML=t,this.container.classList.add(`ql-color-picker`),Array.from(this.container.querySelectorAll(`.ql-picker-item`)).slice(0,7).forEach(e=>{e.classList.add(`ql-primary`)})}buildItem(e){let t=super.buildItem(e);return t.style.backgroundColor=e.getAttribute(`value`)||``,t}selectItem(e,t){super.selectItem(e,t);let n=this.label.querySelector(`.ql-color-label`),r=e&&e.getAttribute(`data-value`)||``;n&&(n.tagName===`line`?n.style.stroke=r:n.style.fill=r)}},qN=class extends GN{constructor(e,t){super(e),this.container.classList.add(`ql-icon-picker`),Array.from(this.container.querySelectorAll(`.ql-picker-item`)).forEach(e=>{e.innerHTML=t[e.getAttribute(`data-value`)||``]}),this.defaultItem=this.container.querySelector(`.ql-selected`),this.selectItem(this.defaultItem)}selectItem(e,t){super.selectItem(e,t);let n=e||this.defaultItem;if(n!=null){if(this.label.innerHTML===n.innerHTML)return;this.label.innerHTML=n.innerHTML}}},JN=e=>{let{overflowY:t}=getComputedStyle(e,null);return t!==`visible`&&t!==`clip`},YN=class{constructor(e,t){this.quill=e,this.boundsContainer=t||document.body,this.root=e.addContainer(`ql-tooltip`),this.root.innerHTML=this.constructor.TEMPLATE,JN(this.quill.root)&&this.quill.root.addEventListener(`scroll`,()=>{this.root.style.marginTop=`${-1*this.quill.root.scrollTop}px`}),this.hide()}hide(){this.root.classList.add(`ql-hidden`)}position(e){let t=e.left+e.width/2-this.root.offsetWidth/2,n=e.bottom+this.quill.root.scrollTop;this.root.style.left=`${t}px`,this.root.style.top=`${n}px`,this.root.classList.remove(`ql-flip`);let r=this.boundsContainer.getBoundingClientRect(),i=this.root.getBoundingClientRect(),a=0;if(i.right>r.right&&(a=r.right-i.right,this.root.style.left=`${t+a}px`),i.left<r.left&&(a=r.left-i.left,this.root.style.left=`${t+a}px`),i.bottom>r.bottom){let t=i.bottom-i.top,r=e.bottom-e.top+t;this.root.style.top=`${n-r}px`,this.root.classList.add(`ql-flip`)}return a}show(){this.root.classList.remove(`ql-editing`),this.root.classList.remove(`ql-hidden`)}},XN=[!1,`center`,`right`,`justify`],ZN=`#000000.#e60000.#ff9900.#ffff00.#008a00.#0066cc.#9933ff.#ffffff.#facccc.#ffebcc.#ffffcc.#cce8cc.#cce0f5.#ebd6ff.#bbbbbb.#f06666.#ffc266.#ffff66.#66b966.#66a3e0.#c285ff.#888888.#a10000.#b26b00.#b2b200.#006100.#0047b2.#6b24b2.#444444.#5c0000.#663d00.#666600.#003700.#002966.#3d1466`.split(`.`),QN=[!1,`serif`,`monospace`],$N=[`1`,`2`,`3`,!1],eP=[`small`,!1,`large`,`huge`],tP=class extends tj{constructor(e,t){super(e,t);let n=t=>{if(!document.body.contains(e.root)){document.body.removeEventListener(`click`,n);return}this.tooltip!=null&&!this.tooltip.root.contains(t.target)&&document.activeElement!==this.tooltip.textbox&&!this.quill.hasFocus()&&this.tooltip.hide(),this.pickers!=null&&this.pickers.forEach(e=>{e.container.contains(t.target)||e.close()})};e.emitter.listenDOM(`click`,document.body,n)}addModule(e){let t=super.addModule(e);return e===`toolbar`&&this.extendToolbar(t),t}buildButtons(e,t){Array.from(e).forEach(e=>{(e.getAttribute(`class`)||``).split(/\s+/).forEach(n=>{if(n.startsWith(`ql-`)&&(n=n.slice(3),t[n]!=null))if(n===`direction`)e.innerHTML=t[n][``]+t[n].rtl;else if(typeof t[n]==`string`)e.innerHTML=t[n];else{let r=e.value||``;r!=null&&t[n][r]&&(e.innerHTML=t[n][r])}})})}buildPickers(e,t){this.pickers=Array.from(e).map(e=>{if(e.classList.contains(`ql-align`)&&(e.querySelector(`option`)??iP(e,XN),typeof t.align==`object`))return new qN(e,t.align);if(e.classList.contains(`ql-background`)||e.classList.contains(`ql-color`)){let n=e.classList.contains(`ql-background`)?`background`:`color`;return e.querySelector(`option`)??iP(e,ZN,n===`background`?`#ffffff`:`#000000`),new KN(e,t[n])}return e.querySelector(`option`)??(e.classList.contains(`ql-font`)?iP(e,QN):e.classList.contains(`ql-header`)?iP(e,$N):e.classList.contains(`ql-size`)&&iP(e,eP)),new GN(e)}),this.quill.on(LA.events.EDITOR_CHANGE,()=>{this.pickers.forEach(e=>{e.update()})})}};tP.DEFAULTS=Mk({},tj.DEFAULTS,{modules:{toolbar:{handlers:{formula(){this.quill.theme.tooltip.edit(`formula`)},image(){let e=this.container.querySelector(`input.ql-image[type=file]`);e??(e=document.createElement(`input`),e.setAttribute(`type`,`file`),e.setAttribute(`accept`,this.quill.uploader.options.mimetypes.join(`, `)),e.classList.add(`ql-image`),e.addEventListener(`change`,()=>{let t=this.quill.getSelection(!0);this.quill.uploader.upload(t,e.files),e.value=``}),this.container.appendChild(e)),e.click()},video(){this.quill.theme.tooltip.edit(`video`)}}}}});var nP=class extends YN{constructor(e,t){super(e,t),this.textbox=this.root.querySelector(`input[type="text"]`),this.listen()}listen(){this.textbox.addEventListener(`keydown`,e=>{e.key===`Enter`?(this.save(),e.preventDefault()):e.key===`Escape`&&(this.cancel(),e.preventDefault())})}cancel(){this.hide(),this.restoreFocus()}edit(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`link`,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(this.root.classList.remove(`ql-hidden`),this.root.classList.add(`ql-editing`),this.textbox==null)return;t==null?e!==this.root.getAttribute(`data-mode`)&&(this.textbox.value=``):this.textbox.value=t;let n=this.quill.getBounds(this.quill.selection.savedRange);n!=null&&this.position(n),this.textbox.select(),this.textbox.setAttribute(`placeholder`,this.textbox.getAttribute(`data-${e}`)||``),this.root.setAttribute(`data-mode`,e)}restoreFocus(){this.quill.focus({preventScroll:!0})}save(){let{value:e}=this.textbox;switch(this.root.getAttribute(`data-mode`)){case`link`:{let{scrollTop:t}=this.quill.root;this.linkRange?(this.quill.formatText(this.linkRange,`link`,e,LA.sources.USER),delete this.linkRange):(this.restoreFocus(),this.quill.format(`link`,e,LA.sources.USER)),this.quill.root.scrollTop=t;break}case`video`:e=rP(e);case`formula`:{if(!e)break;let t=this.quill.getSelection(!0);if(t!=null){let n=t.index+t.length;this.quill.insertEmbed(n,this.root.getAttribute(`data-mode`),e,LA.sources.USER),this.root.getAttribute(`data-mode`)===`formula`&&this.quill.insertText(n+1,` `,LA.sources.USER),this.quill.setSelection(n+2,LA.sources.USER)}break}default:}this.textbox.value=``,this.hide()}};function rP(e){let t=e.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtube\.com\/watch.*v=([a-zA-Z0-9_-]+)/)||e.match(/^(?:(https?):\/\/)?(?:(?:www|m)\.)?youtu\.be\/([a-zA-Z0-9_-]+)/);return t?`${t[1]||`https`}://www.youtube.com/embed/${t[2]}?showinfo=0`:(t=e.match(/^(?:(https?):\/\/)?(?:www\.)?vimeo\.com\/(\d+)/))?`${t[1]||`https`}://player.vimeo.com/video/${t[2]}/`:e}function iP(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;t.forEach(t=>{let r=document.createElement(`option`);t===n?r.setAttribute(`selected`,`selected`):r.setAttribute(`value`,String(t)),e.appendChild(r)})}var aP=[[`bold`,`italic`,`link`],[{header:1},{header:2},`blockquote`]],oP=class extends nP{static TEMPLATE=[`<span class="ql-tooltip-arrow"></span>`,`<div class="ql-tooltip-editor">`,`<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">`,`<a class="ql-close"></a>`,`</div>`].join(``);constructor(e,t){super(e,t),this.quill.on(LA.events.EDITOR_CHANGE,(e,t,n,r)=>{if(e===LA.events.SELECTION_CHANGE)if(t!=null&&t.length>0&&r===LA.sources.USER){this.show(),this.root.style.left=`0px`,this.root.style.width=``,this.root.style.width=`${this.root.offsetWidth}px`;let e=this.quill.getLines(t.index,t.length);if(e.length===1){let e=this.quill.getBounds(t);e!=null&&this.position(e)}else{let n=e[e.length-1],r=this.quill.getIndex(n),i=Math.min(n.length()-1,t.index+t.length-r),a=this.quill.getBounds(new zA(r,i));a!=null&&this.position(a)}}else document.activeElement!==this.textbox&&this.quill.hasFocus()&&this.hide()})}listen(){super.listen(),this.root.querySelector(`.ql-close`).addEventListener(`click`,()=>{this.root.classList.remove(`ql-editing`)}),this.quill.on(LA.events.SCROLL_OPTIMIZE,()=>{setTimeout(()=>{if(this.root.classList.contains(`ql-hidden`))return;let e=this.quill.getSelection();if(e!=null){let t=this.quill.getBounds(e);t!=null&&this.position(t)}},1)})}cancel(){this.show()}position(e){let t=super.position(e),n=this.root.querySelector(`.ql-tooltip-arrow`);return n.style.marginLeft=``,t!==0&&(n.style.marginLeft=`${-1*t-n.offsetWidth/2}px`),t}},sP=class extends tP{constructor(e,t){t.modules.toolbar!=null&&t.modules.toolbar.container==null&&(t.modules.toolbar.container=aP),super(e,t),this.quill.container.classList.add(`ql-bubble`)}extendToolbar(e){this.tooltip=new oP(this.quill,this.options.bounds),e.container!=null&&(this.tooltip.root.appendChild(e.container),this.buildButtons(e.container.querySelectorAll(`button`),VN),this.buildPickers(e.container.querySelectorAll(`select`),VN))}};sP.DEFAULTS=Mk({},tP.DEFAULTS,{modules:{toolbar:{handlers:{link(e){e?this.quill.theme.tooltip.edit():this.quill.format(`link`,!1,Y.sources.USER)}}}}});var cP=[[{header:[`1`,`2`,`3`,!1]}],[`bold`,`italic`,`underline`,`link`],[{list:`ordered`},{list:`bullet`}],[`clean`]],lP=class extends nP{static TEMPLATE=[`<a class="ql-preview" rel="noopener noreferrer" target="_blank" href="about:blank"></a>`,`<input type="text" data-formula="e=mc^2" data-link="https://quilljs.com" data-video="Embed URL">`,`<a class="ql-action"></a>`,`<a class="ql-remove"></a>`].join(``);preview=this.root.querySelector(`a.ql-preview`);listen(){super.listen(),this.root.querySelector(`a.ql-action`).addEventListener(`click`,e=>{this.root.classList.contains(`ql-editing`)?this.save():this.edit(`link`,this.preview.textContent),e.preventDefault()}),this.root.querySelector(`a.ql-remove`).addEventListener(`click`,e=>{if(this.linkRange!=null){let e=this.linkRange;this.restoreFocus(),this.quill.formatText(e,`link`,!1,LA.sources.USER),delete this.linkRange}e.preventDefault(),this.hide()}),this.quill.on(LA.events.SELECTION_CHANGE,(e,t,n)=>{if(e!=null){if(e.length===0&&n===LA.sources.USER){let[t,n]=this.quill.scroll.descendant(aN,e.index);if(t!=null){this.linkRange=new zA(e.index-n,t.length());let r=aN.formats(t.domNode);this.preview.textContent=r,this.preview.setAttribute(`href`,r),this.show();let i=this.quill.getBounds(this.linkRange);i!=null&&this.position(i);return}}else delete this.linkRange;this.hide()}})}show(){super.show(),this.root.removeAttribute(`data-mode`)}},uP=class extends tP{constructor(e,t){t.modules.toolbar!=null&&t.modules.toolbar.container==null&&(t.modules.toolbar.container=cP),super(e,t),this.quill.container.classList.add(`ql-snow`)}extendToolbar(e){e.container!=null&&(e.container.classList.add(`ql-snow`),this.buildButtons(e.container.querySelectorAll(`button`),VN),this.buildPickers(e.container.querySelectorAll(`select`),VN),this.tooltip=new lP(this.quill,this.options.bounds),e.container.querySelector(`.ql-link`)&&this.quill.keyboard.addBinding({key:`k`,shortKey:!0},(t,n)=>{e.handlers.link.call(e,!n.format.link)}))}};uP.DEFAULTS=Mk({},tP.DEFAULTS,{modules:{toolbar:{handlers:{link(e){if(e){let e=this.quill.getSelection();if(e==null||e.length===0)return;let t=this.quill.getText(e);/^\S+@\S+\.\S+$/.test(t)&&t.indexOf(`mailto:`)!==0&&(t=`mailto:${t}`);let{tooltip:n}=this.quill.theme;n.edit(`link`,t)}else this.quill.format(`link`,!1,Y.sources.USER)}}}}}),ZM.register({"attributors/attribute/direction":Lj,"attributors/class/align":Ej,"attributors/class/background":jj,"attributors/class/color":kj,"attributors/class/direction":Rj,"attributors/class/font":Vj,"attributors/class/size":Uj,"attributors/style/align":Dj,"attributors/style/background":Mj,"attributors/style/color":Aj,"attributors/style/direction":zj,"attributors/style/font":Hj,"attributors/style/size":Wj},!0),ZM.register({"formats/align":Ej,"formats/direction":Rj,"formats/indent":QM,"formats/background":Mj,"formats/color":Aj,"formats/font":Vj,"formats/size":Uj,"formats/blockquote":$M,"formats/code-block":Pj,"formats/header":eN,"formats/list":nN,"formats/bold":rN,"formats/code":Fj,"formats/italic":iN,"formats/link":aN,"formats/script":sN,"formats/strike":cN,"formats/underline":lN,"formats/formula":uN,"formats/image":fN,"formats/video":mN,"modules/syntax":bN,"modules/table":EN,"modules/toolbar":ON,"themes/bubble":sP,"themes/snow":uP,"ui/icons":VN,"ui/picker":GN,"ui/icon-picker":qN,"ui/color-picker":KN,"ui/tooltip":YN},!0);var dP=ZM,fP=!1;function pP(){if(fP)return;fP=!0;let e=dP.import(`attributors/style/size`),t=dP.import(`attributors/style/font`);e&&(delete e.whitelist,dP.register(e,!0)),t&&(delete t.whitelist,dP.register(t,!0))}var mP=[`fontSize`,`fontFamily`,`fill`,`fontWeight`,`fontStyle`,`textDecoration`],hP=Ut({active:null},{},{deep:!1});function gP(e){or(()=>{hP.active=Object.assign(Object.assign({},e),{currentFormat:{},mixedFormats:{},lastSelection:null})})}function _P(e,t,n){or(()=>{hP.active&&=Object.assign(Object.assign({},hP.active),{currentFormat:e,mixedFormats:t,lastSelection:n||hP.active.lastSelection})})}function vP(e){or(()=>{e&&hP.active?.instance!==e||(hP.active=null)})}var yP={fontSize:[`size`],fontFamily:[`font`],fill:[`color`],fontWeight:[`bold`],fontStyle:[`italic`],textDecoration:[`underline`,`strike`]},bP=Array.from(new Set(mP.flatMap(e=>yP[e]))),xP={data:``},SP=e=>typeof window==`object`?((e?e.querySelector(`#_goober`):window._goober)||Object.assign((e||document.head).appendChild(document.createElement(`style`)),{innerHTML:` `,id:`_goober`})).firstChild:e||xP,CP=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g,wP=/\/\*[^]*?\*\/|\s\s+|\n/g,TP=(e,t)=>{let n=``,r=``,i=``;for(let a in e){let o=e[a];a[0]==`@`?a[1]==`i`?n=a+` `+o+`;`:r+=a[1]==`f`?TP(o,a):a+`{`+TP(o,a[1]==`k`?``:t)+`}`:typeof o==`object`?r+=TP(o,t?t.replace(/([^,])+/g,e=>a.replace(/(^:.*)|([^,])+/g,t=>/&/.test(t)?t.replace(/&/g,e):e?e+` `+t:t)):a):o!=null&&(a=a.replace(/[A-Z]/g,`-$&`).toLowerCase(),i+=TP.p?TP.p(a,o):a+`:`+o+`;`)}return n+(t&&i?t+`{`+i+`}`:i)+r},EP={},DP=e=>{if(typeof e==`object`){let t=``;for(let n in e)t+=n+DP(e[n]);return t}return e},OP=(e,t,n,r,i)=>{let a=DP(e),o=EP[a]||(EP[a]=(e=>{let t=0,n=11;for(;t<e.length;)n=101*n+e.charCodeAt(t++)>>>0;return`go`+n})(a));if(!EP[o]){let t=a===e?(e=>{let t,n=[{}];for(;t=CP.exec(e.replace(wP,``));)t[4]?n.shift():t[3]?n.unshift(n[0][t[3]]=n[0][t[3]]||{}):n[0][t[1]]=t[2];return n[0]})(e):e;EP[o]=TP(i?{[`@keyframes `+o]:t}:t,n?``:`.`+o)}return((e,t,n)=>{t.data.indexOf(e)==-1&&(t.data=n?e+t.data:t.data+e)})(EP[o],t,r),o};function kP(e){let t=this||{},n=e.call?e(t.p):e;return OP(n.unshift?n.raw?((e,t,n)=>e.reduce((e,r,i)=>{let a=t[i];if(a&&a.call){let e=a(n),t=e&&e.props&&e.props.className||/^go/.test(e)&&e;a=t?`.`+t:e&&typeof e==`object`?e.props?``:TP(e,``):!1===e?``:e}return e+r+(a??``)},``))(n,[].slice.call(arguments,1),t.p):n.reduce((e,n)=>Object.assign(e,n&&n.call?n(t.p):n),{}):n,SP(t.target),t.g,t.o,t.k)}var AP,jP,MP;kP.bind({g:1}),kP.bind({k:1});function NP(e,t,n,r){TP.p=t,AP=e,jP=n,MP=r}function PP(e,t){let n=this||{};return function(){let r=arguments;function i(a,o){let s=Object.assign({},a),c=s.className||i.className;n.p=Object.assign({theme:jP&&jP()},s),n.o=/ *go\d+/.test(c),s.className=kP.apply(n,r)+(c?` `+c:``),t&&(s.ref=o);let l=e;return e[0]&&(l=s.as||e,delete s.as),MP&&l[0]&&MP(s),AP(l,s)}return t?t(i):i}}NP(b.createElement,void 0,void 0,void 0);var FP=e=>PP(e,b.forwardRef);function IP(e,t){if(t===1)return e;let n=W.Util.colorToRGBA(e);return n?`rgba(${n.r}, ${n.g}, ${n.b}, ${n.a*t})`:e}var LP=Ut({enabled:!1,currentFormat:{},lastSelection:null,pendingToolbarInteraction:!1,editor:Ut.object({instance:null},{},{deep:!1})}),RP=bP;function zP(e,t){let n=t?e.getFormat(t):{},r=function(e,t){let n={};if(!t||t.length<=0)return n;let r=e.getContents(t.index,t.length);for(let e of RP)bv(r,e)&&(n[e]=!0);return n}(e,t);or(()=>{LP.currentFormat=n}),_P(n,r,t)}var BP=`polotno-saved-selection`;function VP(){let e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed||typeof Highlight>`u`||!CSS.highlights)return;let t=e.getRangeAt(0).cloneRange();CSS.highlights.set(BP,new Highlight(t)),UP()}function HP(){typeof CSS<`u`&&CSS.highlights&&CSS.highlights.delete(BP)}function UP(e=20){setTimeout(()=>{typeof CSS<`u`&&CSS.highlights&&CSS.highlights.has(BP)&&(e>0&&(document.querySelector(`.polotno-portal`)||JP(document.activeElement))?UP(e-1):HP())},300)}if(typeof document<`u`&&typeof CSS<`u`&&CSS.highlights&&!document.querySelector(`[data-polotno-highlight]`)){let e=document.createElement(`style`);e.setAttribute(`data-polotno-highlight`,``),e.textContent=`::highlight(${BP}) { background-color: rgba(0, 100, 255, 0.3); }`,document.head.appendChild(e)}var WP=FP(`div`,b.forwardRef)`
|
|
257
|
+
.ql-editor {
|
|
258
|
+
outline: none;
|
|
259
|
+
/* Element-level underline/strike — text-decoration doesn't inherit, so it is
|
|
260
|
+
applied here on the editable root (mirrors the static getHtml render). */
|
|
261
|
+
text-decoration: var(--polotno-text-decoration, none);
|
|
262
|
+
}
|
|
263
|
+
.ql-clipboard {
|
|
264
|
+
pointer-events: none;
|
|
265
|
+
opacity: 0;
|
|
266
|
+
}
|
|
267
|
+
${Hy}
|
|
268
|
+
|
|
269
|
+
/* ===== Editor-only list markers (Quill flat-DOM hack) ======================
|
|
270
|
+
Quill emits a FLAT <ol> with per-item data-list + ql-indent classes (not
|
|
271
|
+
real nested <ul>/<ol>), so the browser's native markers can't render mixed
|
|
272
|
+
bullet/number items or nested numbering. The editor therefore disables
|
|
273
|
+
native markers and draws its own via ::before — but ONLY here, so it can't
|
|
274
|
+
leak into the export/canvas paths (which use native markers; see
|
|
275
|
+
reset-style.ts). These are tuned to match render-tag (the canvas
|
|
276
|
+
reference): marker sized at the item font, sitting just left of the text
|
|
277
|
+
inside the 2.1em indent. letter-spacing is intentionally NOT reset to
|
|
278
|
+
normal — numbered markers track it, like render-tag/native/Canva. */
|
|
279
|
+
.ql-editor ul,
|
|
280
|
+
.ql-editor ol {
|
|
281
|
+
list-style: none;
|
|
282
|
+
/* Editor box model is the inverse of the shared reset: the indent lives on
|
|
283
|
+
the <li> (not the list) so the absolutely-positioned ::before marker
|
|
284
|
+
below has room in the li's start-padding. (The export/canvas path puts
|
|
285
|
+
the indent on the list for native outside markers — see reset-style.ts.) */
|
|
286
|
+
padding-inline-start: 0;
|
|
287
|
+
}
|
|
288
|
+
.ql-editor .ql-ui {
|
|
289
|
+
display: none;
|
|
290
|
+
}
|
|
291
|
+
/* Per-LEVEL ordered counters (list-0..list-3), so a nested ordered list
|
|
292
|
+
restarts at 1 — matching canonical HTML and the canvas. Quill's flat DOM
|
|
293
|
+
expresses depth via ql-indent-N, so each ordered item increments its
|
|
294
|
+
level's counter and RESETS all deeper levels (counter-reset applies before
|
|
295
|
+
counter-increment on the same element). A single global counter would make
|
|
296
|
+
a nested "deep" item continue the outer numbering (e.g. show 3 instead of
|
|
297
|
+
1). All levels use decimal to match render-tag (which doesn't cycle
|
|
298
|
+
styles). Custom counter names avoid Safari's list-item counter bug. */
|
|
299
|
+
.ql-editor ol {
|
|
300
|
+
counter-reset: list-0 list-1 list-2 list-3;
|
|
301
|
+
}
|
|
302
|
+
.ql-editor li {
|
|
303
|
+
position: relative; /* anchor for the absolutely-positioned ::before */
|
|
304
|
+
padding-inline-start: 2.1em; /* marker space + per-level indent (start side) */
|
|
305
|
+
}
|
|
306
|
+
.ql-editor li[data-list='ordered'] {
|
|
307
|
+
counter-increment: list-0;
|
|
308
|
+
counter-reset: list-1 list-2 list-3;
|
|
309
|
+
}
|
|
310
|
+
.ql-editor li.ql-indent-1[data-list='ordered'] {
|
|
311
|
+
counter-increment: list-1;
|
|
312
|
+
counter-reset: list-2 list-3;
|
|
313
|
+
}
|
|
314
|
+
.ql-editor li.ql-indent-2[data-list='ordered'] {
|
|
315
|
+
counter-increment: list-2;
|
|
316
|
+
counter-reset: list-3;
|
|
317
|
+
}
|
|
318
|
+
.ql-editor li.ql-indent-3[data-list='ordered'] {
|
|
319
|
+
counter-increment: list-3;
|
|
320
|
+
}
|
|
321
|
+
/* Marker box spans the 2.1em indent and right-aligns the marker against the
|
|
322
|
+
text with a gap, so the marker's right edge ≈ render-tag's
|
|
323
|
+
(contentStart − gap). line-height is inherited so the marker sits on the
|
|
324
|
+
item's first-line baseline (matches render-tag's number baseline; bullets
|
|
325
|
+
are close). */
|
|
326
|
+
.ql-editor li::before {
|
|
327
|
+
position: absolute;
|
|
328
|
+
inset-inline-start: 0;
|
|
329
|
+
top: 0;
|
|
330
|
+
box-sizing: border-box;
|
|
331
|
+
width: 2.1em;
|
|
332
|
+
text-align: end;
|
|
333
|
+
font-weight: normal;
|
|
334
|
+
font-style: normal;
|
|
335
|
+
}
|
|
336
|
+
.ql-editor li[data-list='ordered']::before {
|
|
337
|
+
content: counter(list-0) '.';
|
|
338
|
+
padding-inline-end: 0.32em; /* ≈ render-tag's space-width gap for numbers */
|
|
339
|
+
}
|
|
340
|
+
.ql-editor li.ql-indent-1[data-list='ordered']::before {
|
|
341
|
+
content: counter(list-1) '.';
|
|
342
|
+
}
|
|
343
|
+
.ql-editor li.ql-indent-2[data-list='ordered']::before {
|
|
344
|
+
content: counter(list-2) '.';
|
|
345
|
+
}
|
|
346
|
+
.ql-editor li.ql-indent-3[data-list='ordered']::before {
|
|
347
|
+
content: counter(list-3) '.';
|
|
348
|
+
}
|
|
349
|
+
.ql-editor li[data-list='bullet']::before {
|
|
350
|
+
content: '•';
|
|
351
|
+
padding-inline-end: 0.5em; /* ≈ render-tag's wider bullet gap (7px + ascent/3) */
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
strong {
|
|
355
|
+
font-weight: 700;
|
|
356
|
+
}
|
|
357
|
+
.ql-direction-rtl {
|
|
358
|
+
direction: rtl;
|
|
359
|
+
}
|
|
360
|
+
/* Apply gradient fill to all text-bearing elements when --polotno-gradient is set */
|
|
361
|
+
&[style*='--polotno-gradient'] .ql-editor,
|
|
362
|
+
&[style*='--polotno-gradient'] .ql-editor p,
|
|
363
|
+
&[style*='--polotno-gradient'] .ql-editor li,
|
|
364
|
+
&[style*='--polotno-gradient'] .ql-editor li::before {
|
|
365
|
+
background-image: var(--polotno-gradient);
|
|
366
|
+
background-size: 100% 100%;
|
|
367
|
+
background-repeat: repeat;
|
|
368
|
+
-webkit-background-clip: text;
|
|
369
|
+
-moz-background-clip: text;
|
|
370
|
+
background-clip: text;
|
|
371
|
+
-webkit-text-fill-color: transparent;
|
|
372
|
+
color: transparent;
|
|
373
|
+
}
|
|
374
|
+
`,GP=[`background`,`bold`,`color`,`font`,`italic`,`size`,`strike`,`underline`,`indent`,`list`,`direction`],KP=(e,t)=>{var n=e.clipboard.convert({html:`<div class='ql-editor' style='outline: none;'>`+t+`<p><br></p></div>`,text:``});e.setContents(n),e.history.clear()},qP=({onBlur:e,onChange:t,element:n,clickCoords:r})=>{let i=b.useRef(null),a=b.useRef(!1);b.useLayoutEffect(()=>{let o,s=!1,c=null,l=null,u=null,d=null,f=null,p=()=>{if(!s&&i.current)try{p=i.current,pP(),o=new dP(p,{toolbar:!1,keyboard:!1,clipboard:{matchVisual:!1},formats:GP}),or(()=>{LP.editor.instance=o}),LP.pendingToolbarInteraction=!1,window.__polotnoQuill=o,gP({instance:o,store:n.store,element:n}),o.on(`text-change`,()=>{let e=o.getSelection();e&&(zP(o,e),or(()=>{LP.lastSelection={index:e.index,length:e.length}})),setTimeout(()=>{let e=o.root;if(!e||!e.isConnected||!Hp(n))return;let r=e.innerHTML;a.current=!0,t(hv(function(e){let t=(e||``).trim();if(t===`<p><br></p>`||t===`<p></p>`)return``;if(t.startsWith(`<p>`)&&t.endsWith(`</p>`)){let e=t.slice(3,-4);if(!/(<\/?(p|div|h[1-6]|ul|ol|li|table|thead|tbody|tr|td|blockquote)\b)/i.test(e))return e}return e}(r),{fontSize:n.fontSize,fontFamily:n.fontFamily}));let i=o.getContents(),s=n.fill,c=null,l=!0;for(let e of i.ops){if(typeof e.insert!=`string`||e.insert===`
|
|
375
|
+
`)continue;let t=e.attributes?.color||s;if(c===null)c=t;else if(t!==c){l=!1;break}}l&&c&&n.set({fill:c})},10)});let s=Ix(n,n.fontFamily);KP(o,s),a.current=!0;let m=i.current.closest(`.polotno-workspace-inner`),h=m?.scrollLeft,g=m?.scrollTop;r?YP(o,r):o.setSelection(0,0,`api`),m&&h!==void 0&&g!==void 0&&(m.scrollLeft=h,m.scrollTop=g),o.on(`selection-change`,(e,t,n)=>{e&&(zP(o,e),or(()=>{LP.lastSelection={index:e.index,length:e.length}}))});let _=o.root;d=t=>{let n=t.relatedTarget;n!=null&&n.classList.contains(`ql-clipboard`)||(JP(n)||LP.pendingToolbarInteraction?VP():setTimeout(()=>{LP.pendingToolbarInteraction||JP(document.activeElement)?VP():(HP(),e())},0))},f=()=>{HP()},_.addEventListener(`blur`,d),_.addEventListener(`focus`,f),c=_,l=e=>{var t,n;let r=o.getSelection();if(!r||r.length===0)return;let i=o.getText(r.index,r.length).replace(/\n$/,``),a=window.getSelection(),s=``;if(a&&a.rangeCount>0){let e=a.getRangeAt(0),t=e.cloneContents(),n=e.startContainer;n&&n.nodeType===Node.TEXT_NODE&&(n=n.parentNode);let r=e.endContainer;if(r&&r.nodeType===Node.TEXT_NODE&&(r=r.parentNode),n&&n===r){let e=n;for(;e&&e!==_&&e.nodeType===Node.ELEMENT_NODE;){let n=e.tagName;if(n!==`SPAN`&&n!==`EM`&&n!==`STRONG`&&n!==`U`&&n!==`S`&&n!==`A`)break;let r=e.cloneNode(!1);r.appendChild(t),t=r,e=e.parentNode}}let i=document.createElement(`div`);i.appendChild(t),s=i.innerHTML}if((t=e.clipboardData)==null||t.setData(`text/plain`,i),s){let t=`<!DOCTYPE html><html><head><meta charset="utf-8"></head><body><!--StartFragment--><div style="white-space: pre-wrap; overflow-wrap: break-word;">`+s+`</div><!--EndFragment--></body></html>`;(n=e.clipboardData)==null||n.setData(`text/html`,t)}e.preventDefault()},u=e=>{l&&l(e);let t=o.getSelection();t&&t.length>0&&o.deleteText(t.index,t.length)},c.addEventListener(`copy`,l),c.addEventListener(`cut`,u)}catch(e){console.error(`RichEditor init failed:`,e)}var p};return i.current?p():queueMicrotask(p),()=>{s=!0,c&&d&&c.removeEventListener(`blur`,d),c&&f&&c.removeEventListener(`focus`,f),HP(),c&&l&&u&&(c.removeEventListener(`copy`,l),c.removeEventListener(`cut`,u)),or(()=>{LP.editor.instance=null,LP.currentFormat={},LP.lastSelection=null}),vP(o),delete window.__polotnoQuill}},[]),b.useEffect(()=>dr(()=>Hp(n)?`${n.text}\0${n.fontSize}\0${n.fontFamily}`:``,()=>{if(!Hp(n))return;let e=LP.editor.instance;if(!e)return;if(a.current){a.current=!1;return}let t=e.getSelection();KP(e,Ix(n,n.fontFamily)),a.current=!0,t&&(e.setSelection(t.index,t.length),zP(e,e.getSelection()))},{fireImmediately:!0}),[]),b.useEffect(()=>{window.addEventListener(`blur`,e);let t=t=>{var n;(n=i.current)!=null&&n.contains(t.target)||JP(t.target)||LP.pendingToolbarInteraction||(HP(),e())};return window.addEventListener(`mousedown`,t),window.addEventListener(`touchstart`,t),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`mousedown`,t),window.removeEventListener(`touchstart`,t)}},[]);let o={color:n.fill};n.fill.indexOf(`gradient`)>=0&&(o[`--polotno-gradient`]=n.fill,o.color=`transparent`);let s=sy(n.fill)?ly(n.fill).stops[0]?.color??`#000000`:Gx(n);return(0,S.jsx)(WP,{ref:i,style:Object.assign(Object.assign({},o),{fontSize:n.fontSize,fontFamily:n.fontFamily,fontWeight:n.fontWeight,fontStyle:n.fontStyle,"--polotno-text-decoration":n.textDecoration||`none`,textTransform:n.textTransform,width:n.a.width,lineHeight:n.lineHeight,letterSpacing:n.letterSpacing*n.fontSize+`px`,textAlign:n.align,opacity:Math.max(n.a.opacity,.2),textShadow:n.shadowEnabled?`${n.shadowOffsetX}px ${n.shadowOffsetY}px ${n.shadowBlur}px ${IP(n.shadowColor,n.shadowOpacity??1)}`:void 0,caretColor:s}),dir:Ox(Sv(n.text))})};function JP(e){return!(!e||!e.closest(`.sketch-picker`)&&!e.closest(`[data-polotno-keep-focus]`)&&!e.closest(`.polotno-portal`)&&!e.closest(`.polotno-toolbar`))}function YP(e,t){if(!e||!t)return;let{x:n,y:r}=t;try{let t=null;if(document.caretRangeFromPoint)t=document.caretRangeFromPoint(n,r);else if(document.caretPositionFromPoint){let e=document.caretPositionFromPoint(n,r);e&&(t=document.createRange(),t.setStart(e.offsetNode,e.offset))}if(t){let n=dP.find(t.startContainer,!0);if(n){let r=n.offset(e.scroll)+t.startOffset;e.setSelection(r,0,`api`);return}}}catch{}e.setSelection(0,0,`api`)}function XP(e){let t=document.createElement(`canvas`);return t.getContext(`2d`)?.drawImage(e,0,0,t.width,t.height),function(e){return!function(e){let t=e.getContext(`2d`).getImageData(0,0,e.width,e.height).data;for(let e=0;e<t.length;e+=4)if(t[e+3]!==0)return!0;return!1}(e)}(t)}var ZP=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),QP=navigator.userAgent.includes(`Firefox`),$P=wa(({element:e,store:t})=>{let{textOverflowIndicatorStyle:n}=up(),r=b.useRef(null),[i,a]=b.useState(),[o,s]=b.useState(!1),[c,l]=b.useState(!1),u=b.useRef(e.height),d=e.isSelected,f=eS(d),p=e.fontSize/3,{textVerticalResizeEnabled:m}=h_,h=h_.autoDeleteEmptyText,g=eS(e.fontFamily),_=b.useMemo(()=>hv(e.text,{fontSize:e.fontSize,fontFamily:e.fontFamily}),[e.text,e.fontSize,e.fontFamily]),[v]=Qx(t,b.useMemo(()=>[...new Set([e.fontFamily,..._v(_)])].filter(Boolean),[e.fontFamily,_]),e.fontStyle,e.fontWeight,e.text||e.placeholder),y=e._editModeEnabled;G_(r);let x=v?e.fontFamily:g===e.fontFamily?`Arial`:g,C=Cx(e).fill,w=Lx(e,{fontFamily:x,color:C}),T=b.useRef([]),E=b.useRef(!0),[,D]=b.useReducer(e=>e+1,0);b.useEffect(()=>{let e=T.current;e.length>0&&(T.current=[],e.forEach(e=>e()))}),b.useEffect(()=>()=>{E.current=!1;let e=T.current;e.length>0&&(T.current=[],e.forEach(e=>e()))},[]);let{width:O,height:k}=function(e,t,n){return b.useMemo(()=>kS(e),[e,t.width,n])}(w,e,v);b.useEffect(()=>{if(!v)return;let n=(n,r,i,a)=>{let o=$_(`text ${e.id}`),s=()=>{t.history.ignore(n,r,i).then(()=>{E.current?(T.current.push(o),D()):o()})};a?queueMicrotask(s):s()};if(e.curveEnabled&&Math.abs(O-e.width)>1&&!o&&n(()=>{if(Hp(e)&&Math.abs(O-e.width)>1){let t=e.x+e.width/2;e.set({width:O,x:t-O/2})}},!1,!0),!e.height){n(()=>{Hp(e)&&(e.height||e.set({height:k}))},void 0,void 0,!0);return}let{textOverflow:r}=h_;if(r!==`change-font-size`||o||y||e.curveEnabled)r===`resize`&&(m&&e.height<k&&!o&&n(()=>{Hp(e)&&e.set({height:k})},!1,!0),m||e.height===k||o||n(()=>{Hp(e)&&e.set({height:k})},!1,!0));else{let t=jC(e,{fontFamily:e.fontFamily});t.fontSize===e.fontSize?e.height!==k&&(m&&e.height<k?n(()=>{Hp(e)&&e.set({height:k})},!1,!0):m||n(()=>{Hp(e)&&e.set({height:k})},!1,!0)):n(()=>{if(!Hp(e))return;let n={fontSize:t.fontSize};t.text!==void 0&&t.text!==e.text&&(n.text=t.text),e.set(n)},!1,!0)}});let ee=b.useMemo(()=>{let e={lastArgs:null,lastResult:null};return async function(t){return e.lastArgs&&e.lastResult&&(n=e.lastArgs,r=t,JSON.stringify(n)===JSON.stringify(r))||(e.lastResult=await FS(t),e.lastArgs=Object.assign({},t)),e.lastResult;var n,r}},[]),A=b.useRef(0),j=b.useRef(null);b.useEffect(()=>{o||y||(async()=>{A.current++;let n=A.current,r=$_(`text ${e.id} ${n}`);j.current&&j.current(),j.current=r,l(!0);let i=null,o=ZP?5:1;for(let r=0;r<o;r++){let a=r>0?ee:FS;try{if(i=await a({skipCache:r>0,html:w,width:O||e.width||1,height:e.height||k||1,fontFamily:x,fontFamilies:_v(w),resolveFont:e=>t.fonts.find(t=>t.fontFamily===e)||Ev.find(t=>t.fontFamily===e),padding:p,pixelRatio:t._elementsPixelRatio,font:t.fonts.find(e=>e.fontFamily===x)||Ev.find(e=>e.fontFamily===x)}),n!==A.current)return;if((ZP||QP)&&i&&XP(i)){await new Promise(e=>setTimeout(e,50*(r+1)));continue}break}catch(t){console.error(t),iv(`Error rendering rich text with id ${e.id}`);break}}i?a(i):r?(r(),r=null):console.error(`Finish function is called twice!`),l(!1)})()},[w,o,k,y,x,e.height,t._elementsPixelRatio,v]);let[te,M]=mC(c,300),[ne]=mC(o,300,!0),N=ne||te;b.useEffect(()=>{var t;if(!N)return cr(()=>{let t=r.current;Bx(t,e)});(t=r.current)==null||t.clearCache()},[i,N,e.shadowColor,e.shadowOffsetX,e.shadowOffsetY,e.shadowOpacity]),b.useEffect(()=>{i&&!c&&j.current&&(j.current(),j.current=null)},[i,c]),b.useLayoutEffect(()=>{if(!v||!e.curveEnabled)return;let t=new W.TextPath({data:kx(e.a.width,e.a.height,e.curvePower,e.a.fontSize),text:Sv(e.text),letterSpacing:e.letterSpacing*e.a.fontSize,fontSize:e.a.fontSize,fontFamily:e.fontFamily,fontWeight:e.fontWeight,fontStyle:e.fontStyle,align:`center`,textBaseline:`middle`,fill:e.fill}),n=t.getSelfRect().width;if(n){let t=n-e.a.width,r=e.a.rotation*Math.PI/180,i=-t/2*Math.cos(r),a=-t/2*Math.sin(r);queueMicrotask(()=>{Hp(e)&&e.set({width:n,x:e.a.x+i,y:e.a.y+a})})}t.destroy()},[v,e.curveEnabled,e.curvePower,e.text,e.fontSize,e.fontFamily,e.fontWeight,e.fontStyle,e.letterSpacing]),b.useEffect(()=>()=>{j.current&&j.current()},[]),b.useEffect(()=>{f&&!d&&h&&Sv(e.text)===``&&e.removable&&!e.placeholder&&t.deleteElements([e.id])},[h,e.placeholder,e.removable,e.text,d,f]);let P=0;e.verticalAlign===`middle`&&(P=(e.height-k)/2),e.verticalAlign===`bottom`&&(P=e.height-k);let re=$x({fontLoaded:v,fontFamily:e.fontFamily,fontSize:e.fontSize,lineHeight:e.lineHeight}),ie=e.backgroundPadding*(e.fontSize*re*.5),ae=e.backgroundCornerRadius*(e.fontSize*re*.5),F=b.useMemo(()=>{if(!e.backgroundEnabled||e.curveEnabled||e.legacyBackground)return``;let t=AS(w);return t.length===0?``:xx({rects:t.map(e=>({left:e.left+p,right:e.right+p,top:e.top+p,bottom:e.bottom+p})),padding:ie,cornerRadius:ae})},[e.backgroundEnabled,e.curveEnabled,e.legacyBackground,w,v,ie,ae,p]),oe=Vx(),se=kx(e.a.width,k,e.curvePower,e.fontSize),ce=b.useRef(null),le=b.useRef(null),ue=b.useRef(0),de=b.useRef(0),fe=b.useRef(null),pe=y&&e.strokeWidth>0&&!e.curveEnabled,me=O>0?(e.a.width+2*p)/(O+2*p):1;return(0,S.jsxs)(S.Fragment,{children:[e.curveEnabled||e.legacyBackground?(0,S.jsx)(Nf,{x:e.a.x,y:e.a.y,offsetX:ie/me,offsetY:ie/me,rotation:e.a.rotation,scaleX:me,scaleY:me,hideInExport:!e.showInExport,listening:!1,visible:e.backgroundEnabled,opacity:e.backgroundOpacity*e.a.opacity,fill:e.backgroundColor,width:e.width+2*ie,height:e.height+2*ie,cornerRadius:ae}):(0,S.jsx)(Rf,{name:`html-background`,x:e.a.x,y:e.a.y,offsetX:p/me,offsetY:(p-P)/me,rotation:e.a.rotation,scaleX:me,scaleY:me,hideInExport:!e.showInExport,listening:!1,visible:e.backgroundEnabled&&F.length>0,opacity:e.backgroundOpacity*e.a.opacity,fill:e.backgroundColor,data:F}),(0,S.jsx)(Rf,{x:e.a.x,y:e.a.y,rotation:e.a.rotation,data:se,stroke:n.stroke,strokeWidth:1,visible:!1}),(0,S.jsx)(Nf,{ref:r,name:`element`,x:e.a.x,y:e.a.y,listening:e.selectable,rotation:e.a.rotation,width:e.a.width,height:e.a.height,visible:!N,draggable:oe?e.draggable&&d:e.draggable,preventDefault:!oe||d,opacity:y?0:e.a.opacity,hideInExport:!e.showInExport,onDragMove:t=>{e.set({x:t.target.x(),y:t.target.y()})},onDragEnd:t=>{e.set({x:t.target.x(),y:t.target.y()})},id:e.id,onDblClick:t=>{e.contentEditable&&(fe.current={x:t.evt.clientX,y:t.evt.clientY},e.toggleEditMode(!0))},onDblTap:t=>{if(e.contentEditable){let n=t.evt.changedTouches?.[0];fe.current=n?{x:n.clientX,y:n.clientY}:null,e.toggleEditMode(!0)}},onTransformStart:t=>{s(!0),u.current=e.height,le.current=(t.target.getStage()?.findOne(`Transformer`))?.getActiveAnchor()??null,ue.current=e.a.rotation,de.current=e.height},onTransform:t=>{let n=t.target,r=(n.getStage()?.findOne(`Transformer`)).getActiveAnchor(),i=r===`middle-left`||r===`middle-right`,a=r===`top-center`||r===`bottom-center`,o=n.scaleX();if(i){let t=n.scaleX(),r=n.width()*t,i=e.fontSize,a=r;r<i&&(a=i,ce.current&&n.position(ce.current)),n.width(a),n.scaleX(1),n.scaleY(1);let o=kS(Lx(Object.assign(Object.assign({},e.toJSON()),{width:a}),{fontFamily:x,color:C})).height,s=h_.textVerticalResizeEnabled?Math.max(o,u.current):o;n.height(s),e.set({width:n.width(),height:s,x:n.x(),y:n.y()})}else if(a){let t=h_.textOverflow===`resize`,r=typeof e.lineHeight==`number`?e.lineHeight:1,i=t?k:r*e.fontSize,a=n.height()*n.scaleY();if(a<i){if(n.height(i),ce.current)if(le.current===`top-center`){let e=ue.current*Math.PI/180,t=de.current-i;n.x(ce.current.x-t*Math.sin(e)),n.y(ce.current.y+t*Math.cos(e))}else n.position(ce.current)}else n.height(a);n.scaleY(1),n.scaleX(1),de.current=Math.max(i,a),e.set({x:n.x(),y:n.y(),height:n.height(),rotation:n.rotation()})}else n.scaleX(1),n.scaleY(1),e.set({fontSize:e.fontSize*o,letterSpacing:e.letterSpacing,width:n.width()*o,x:n.x(),y:n.y(),rotation:n.rotation(),height:n.height()*o,text:vv(e.text,o)});ce.current=t.target.position()},onTransformEnd:t=>{s(!1),l(!0);let n=t.target.scaleX();t.target.scaleX(1),t.target.scaleY(1),e.set({fontSize:e.fontSize*n,width:t.target.width()*n,x:t.target.x(),y:t.target.y(),rotation:t.target.rotation(),shadowBlur:e.shadowBlur*n,shadowOffsetX:e.shadowOffsetX*n,shadowOffsetY:e.shadowOffsetY*n,strokeWidth:e.strokeWidth*n,text:vv(e.text,n)})}}),(0,S.jsx)(Ff,{ref:r,image:i,x:e.a.x,y:e.a.y,offsetX:p,offsetY:p-P,listening:!1,rotation:e.a.rotation,width:e.a.width+2*p,height:(e.a.width+2*p)*((i?.height??0)/(i?.width||1)||1),visible:!N&&!y,opacity:e.a.opacity,shadowEnabled:e.shadowEnabled,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY,shadowColor:e.shadowColor,shadowOpacity:e.shadowOpacity,hideInExport:!e.showInExport,editModeEnabled:e._editModeEnabled||o||N}),(N&&!y||pe)&&(0,S.jsx)(`Group`,{x:e.a.x,y:e.a.y,rotation:e.a.rotation,offsetY:-P,children:(0,S.jsx)(ex,{divProps:{style:{pointerEvents:`none`}},children:(0,S.jsx)(WP,{dangerouslySetInnerHTML:{__html:w},style:{pointerEvents:`none`,opacity:e.a.opacity,textShadow:e.shadowEnabled?`${e.shadowOffsetX}px ${e.shadowOffsetY}px ${e.shadowBlur}px ${IP(e.shadowColor,e.shadowOpacity??1)}`:void 0}})})}),y&&(0,S.jsx)(`Group`,{x:e.a.x,y:e.a.y,rotation:e.a.rotation,offsetY:-P,children:(0,S.jsx)(ex,{divProps:{style:{zIndex:20}},children:(0,S.jsx)(qP,{element:e,onChange:t=>{let n=Hx({oldText:Sv(e.text),newText:Sv(t),element:e});e.set({text:t,fontSize:n})},onBlur:t=>{Hp(e)&&(e.toggleEditMode(!1),M(!0))},clickCoords:fe.current})})})]})});function eF(e){let t=new DOMParser().parseFromString(e,`text/html`),n=t.querySelectorAll(`style`),r=``;for(let e of n)r+=e.textContent+`
|
|
376
|
+
`,e.remove();let i=document.createDocumentFragment();for(;t.body.firstChild;)i.appendChild(document.adoptNode(t.body.firstChild));return{fragment:i,css:r}}function tF(e){let t=[],n=[];e=e.replace(/\/\*[\s\S]*?\*\//g,``);let r=0;for(;r<e.length;){for(;r<e.length&&/\s/.test(e[r]);)r++;if(r>=e.length)break;if(e[r]===`@`){let t=r,i=0;for(;r<e.length;){if(e[r]===`{`&&i++,e[r]===`}`&&(i--,i<=0)){r++;break}r++}let a=e.slice(t,r);a.startsWith(`@font-face`)&&n.push(a);continue}let i=r;for(;r<e.length&&e[r]!==`{`;)r++;if(r>=e.length)break;let a=e.slice(i,r).trim();r++;let o=r;for(;r<e.length&&e[r]!==`}`;)r++;let s=e.slice(o,r).trim();if(r++,!a)continue;let c=a.split(`,`).map(e=>e.trim()).filter(Boolean),l=[];for(let e of s.split(`;`)){let t=e.indexOf(`:`);if(t===-1)continue;let n=e.slice(0,t).trim().toLowerCase(),r=e.slice(t+1).trim();n&&r&&l.push({property:n,value:r})}c.length>0&&l.length>0&&t.push({selectors:c,declarations:l})}return{rules:t,fontFaceRules:n}}function nF(e){let t=e.replace(/::[\w-]+/g,``).split(/\s*>\s*|\s+/),n=0,r=0,i=0;for(let e of t){let t=e.match(/#[\w-]+/g);t&&(n+=t.length);let a=e.match(/\.[\w-]+/g);a&&(r+=a.length);let o=e.replace(/[#.][\w-]+/g,``).replace(/:[\w-]+/g,``).trim();o&&o!==`*`&&i++}return[n,r,i]}function rF(e){let t=e.match(/\.[\w-]+/g)||[],n=e.replace(/\.[\w-]+/g,``).replace(/:[\w-]+/g,``).trim();return{tag:n&&n!==`*`?n:``,classes:t.map(e=>e.slice(1))}}function iF(e,t){if(e.tag&&e.tag!==t.tagName)return!1;for(let n of e.classes)if(!t.classes.has(n))return!1;return!0}function aF(e){let t;if(e.includes(`::`)){if(e.replace(/::marker\b/g,``).includes(`::`))return null;if(/::marker\b/.test(e))t=`marker`,e=e.replace(/(^|[\s>])::marker\b/g,`$1*`),e=e.replace(/::marker\b/g,``);else return null}if(/:(?:nth-|hover|focus|active|visited|first-child|last-child)/.test(e))return null;let n=[],r=[],i=e.trim().split(/\s+/);for(let e=0;e<i.length;e++)i[e]===`>`?r.push(`>`):(n.length>r.length+1&&r.push(` `),n.push(i[e]));for(;r.length<n.length-1;)r.push(` `);if(n.length===0)return null;let a=n.map(rF),o=a[a.length-1],s=o.tag;return{parts:a,combinators:r,rightmost:o,rightmostIsRoot:s===`html`||s===`body`,spec:nF(e),pseudoElement:t}}function oF(e,t){if(e.rightmostIsRoot){if(t.parent!==null)return!1}else if(!iF(e.rightmost,t))return!1;if(e.parts.length===1)return!0;let n=t.parent;for(let t=e.parts.length-2;t>=0;t--){if(!n)return!1;let r=e.parts[t];if(e.combinators[t]===`>`)if(n.parent===null&&(r.tag===`html`||r.tag===`body`))n=n.parent;else if(iF(r,n))n=n.parent;else return!1;else{let e=!1;for(;n;){if(n.parent===null&&(r.tag===`html`||r.tag===`body`)){n=n.parent,e=!0;break}if(iF(r,n)){n=n.parent,e=!0;break}n=n.parent}if(!e)return!1}}return!0}function sF(){return{fontFamily:`serif`,fontSize:16,fontWeight:400,fontStyle:`normal`,fontVariantCaps:`normal`,color:`rgb(0, 0, 0)`,textAlign:`start`,textAlignLast:`auto`,textIndent:0,textTransform:`none`,textDecorationLine:`none`,textDecorationStyle:`solid`,textDecorationColor:`rgb(0, 0, 0)`,textShadow:`none`,webkitTextStrokeWidth:0,webkitTextStrokeColor:``,webkitTextFillColor:``,paintOrder:`normal`,webkitBackgroundClip:``,backgroundImage:`none`,letterSpacing:0,wordSpacing:0,fontKerning:`auto`,lineHeight:0,verticalAlign:`baseline`,whiteSpace:`normal`,wordBreak:`normal`,overflowWrap:`normal`,unicodeBidi:`normal`,direction:`ltr`,display:`block`,width:0,minHeight:0,paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0,marginTop:0,marginRight:0,marginBottom:0,marginLeft:0,backgroundColor:`rgba(0, 0, 0, 0)`,borderTopWidth:0,borderTopColor:`rgb(0, 0, 0)`,borderTopStyle:`none`,borderRightWidth:0,borderRightColor:`rgb(0, 0, 0)`,borderRightStyle:`none`,borderBottomWidth:0,borderBottomColor:`rgb(0, 0, 0)`,borderBottomStyle:`none`,borderLeftWidth:0,borderLeftColor:`rgb(0, 0, 0)`,borderLeftStyle:`none`,flexDirection:`row`,gap:0,flexGrow:0,listStyleType:`disc`,lineClamp:0}}var cF={span:{display:`inline`},a:{display:`inline`},strong:{display:`inline`,fontWeight:700},b:{display:`inline`,fontWeight:700},em:{display:`inline`,fontStyle:`italic`},i:{display:`inline`,fontStyle:`italic`},u:{display:`inline`,textDecorationLine:`underline`},s:{display:`inline`,textDecorationLine:`line-through`},strike:{display:`inline`,textDecorationLine:`line-through`},del:{display:`inline`,textDecorationLine:`line-through`},sub:{display:`inline`,verticalAlign:`sub`,fontSize:.83},sup:{display:`inline`,verticalAlign:`super`,fontSize:.83},code:{display:`inline`,fontFamily:`monospace`},cite:{display:`inline`,fontStyle:`italic`},bdo:{display:`inline`,unicodeBidi:`bidi-override`},bdi:{display:`inline`,unicodeBidi:`isolate`},p:{display:`block`,marginTop:-1,marginBottom:-1},div:{display:`block`},h1:{display:`block`,fontSize:2,fontWeight:700,marginTop:-.67,marginBottom:-.67},h2:{display:`block`,fontSize:1.5,fontWeight:700,marginTop:-.83,marginBottom:-.83},h3:{display:`block`,fontSize:1.17,fontWeight:700,marginTop:-1,marginBottom:-1},h4:{display:`block`,fontSize:1,fontWeight:700,marginTop:-1.33,marginBottom:-1.33},h5:{display:`block`,fontSize:.83,fontWeight:700,marginTop:-1.67,marginBottom:-1.67},h6:{display:`block`,fontSize:.67,fontWeight:700,marginTop:-2.33,marginBottom:-2.33},ul:{display:`block`,listStyleType:`disc`,marginTop:-1,marginBottom:-1},ol:{display:`block`,listStyleType:`decimal`,marginTop:-1,marginBottom:-1},li:{display:`list-item`},blockquote:{display:`block`,marginTop:-1,marginBottom:-1,marginLeft:40,marginRight:40},pre:{display:`block`,whiteSpace:`pre`,fontFamily:`monospace`,marginTop:-1,marginBottom:-1},table:{display:`table`},tr:{display:`table-row`},td:{display:`table-cell`},th:{display:`table-cell`,fontWeight:700},br:{display:`inline`},hr:{display:`block`,borderTopWidth:1,borderTopStyle:`solid`,borderTopColor:`gray`,marginTop:-.5,marginBottom:-.5}};function lF(e,t,n){if(!e||e===`normal`||e===`auto`||e===`none`)return 0;let r=e.trim();if(r.endsWith(`em`)){let e=parseFloat(r);return isNaN(e)?0:e*t}if(r.endsWith(`%`)){let e=parseFloat(r);return isNaN(e)?0:e/100*n}if(r.endsWith(`px`)){let e=parseFloat(r);return isNaN(e)?0:e}let i=parseFloat(r);return isNaN(i)?0:i}function uF(e){if(e===`bold`)return 700;if(e===`normal`)return 400;let t=parseInt(e,10);return isNaN(t)?400:t}function dF(e){let t=e.trim().toLowerCase();if(!t||t===`normal`)return!1;let n=t.split(/\s+/).filter(e=>e===`fill`||e===`stroke`),r=n.indexOf(`stroke`),i=n.indexOf(`fill`);return r===-1?!1:i===-1?!0:r<i}function fF(e){let t=[],n=0,r=``;for(let i=0;i<e.length;i++){let a=e[i];a===`(`?(n++,r+=a):a===`)`?(n=Math.max(0,n-1),r+=a):n===0&&/\s/.test(a)?r&&=(t.push(r),``):r+=a}return r&&t.push(r),t}function pF(e,t){if(e===`margin`||e===`padding`){let n=t.trim().split(/\s+/),r,i,a,o;return n.length===1?r=i=a=o=n[0]:n.length===2?(r=a=n[0],i=o=n[1]):n.length===3?(r=n[0],i=o=n[1],a=n[2]):(r=n[0],i=n[1],a=n[2],o=n[3]),[{property:`${e}-top`,value:r},{property:`${e}-right`,value:i},{property:`${e}-bottom`,value:a},{property:`${e}-left`,value:o}]}if(e===`border`||e===`border-top`||e===`border-right`||e===`border-bottom`||e===`border-left`){let n=t.trim().split(/\s+/),r=[`solid`,`dashed`,`dotted`,`double`,`none`,`hidden`],i=n.find(e=>e.endsWith(`px`)||/^\d/.test(e))||`0`,a=n.find(e=>r.includes(e))||`none`,o=n.find(e=>!e.endsWith(`px`)&&!/^\d/.test(e)&&!r.includes(e))||`currentColor`,s=[],c=e===`border`?[`top`,`right`,`bottom`,`left`]:[e.replace(`border-`,``)];for(let e of c)s.push({property:`border-${e}-width`,value:i}),s.push({property:`border-${e}-style`,value:a}),s.push({property:`border-${e}-color`,value:o});return s}if(e===`list-style`)return t===`none`?[{property:`list-style-type`,value:`none`}]:[{property:`list-style-type`,value:t}];if(e===`text-decoration`){let e=t.trim();if(e===`inherit`||e===`none`)return[{property:`text-decoration-line`,value:`none`}];let n=``,r=e.replace(/\b(rgba?\([^)]*\)|hsla?\([^)]*\))/i,e=>(n=e,``)).split(/\s+/).filter(Boolean),i=[`underline`,`overline`,`line-through`],a=[`solid`,`double`,`dotted`,`dashed`,`wavy`],o=[],s=[];for(let e of r)i.includes(e)?s.push(e):a.includes(e)?o.push({property:`text-decoration-style`,value:e}):e.startsWith(`#`)&&o.push({property:`text-decoration-color`,value:e});return n&&o.push({property:`text-decoration-color`,value:n}),s.length>0&&o.unshift({property:`text-decoration-line`,value:s.join(` `)}),o}if(e===`-webkit-text-stroke`){let e=fF(t.trim()),n=e.find(e=>e.endsWith(`px`)||/^\d/.test(e))||`0`,r=e.find(e=>!e.endsWith(`px`)&&!/^\d/.test(e))||`currentColor`;return[{property:`-webkit-text-stroke-width`,value:n},{property:`-webkit-text-stroke-color`,value:r}]}if(e===`flex`){let e=t.trim().split(/\s+/),n=parseFloat(e[0]);return isNaN(n)?[]:[{property:`flex-grow`,value:String(n)}]}return e===`border-collapse`||e===`border-spacing`?[]:[{property:e,value:t}]}function mF(e,t,n,r,i,a){let o=e.fontSize||r;switch(t){case`font-family`:e.fontFamily=n.trim();break;case`font-size`:{let t=n.trim();t.endsWith(`em`)?e.fontSize=parseFloat(t)*r:t.endsWith(`%`)?e.fontSize=parseFloat(t)/100*r:e.fontSize=parseFloat(t)||r;break}case`font-weight`:e.fontWeight=uF(n);break;case`font-style`:e.fontStyle=n.trim();break;case`font-variant`:case`font-variant-caps`:e.fontVariantCaps=/\bsmall-caps\b/.test(n)?`small-caps`:`normal`;break;case`color`:e.color=n.trim();break;case`text-align`:e.textAlign=n.trim();break;case`text-align-last`:e.textAlignLast=n.trim();break;case`text-indent`:e.textIndent=lF(n,o,i);break;case`text-transform`:e.textTransform=n.trim();break;case`text-decoration-line`:e.textDecorationLine=n.trim();break;case`text-decoration`:break;case`text-decoration-style`:e.textDecorationStyle=n.trim();break;case`text-decoration-color`:e.textDecorationColor=n.trim();break;case`text-shadow`:e.textShadow=n.trim();break;case`-webkit-text-stroke-width`:e.webkitTextStrokeWidth=lF(n,o,i);break;case`-webkit-text-stroke-color`:e.webkitTextStrokeColor=n.trim();break;case`-webkit-text-fill-color`:e.webkitTextFillColor=n.trim();break;case`paint-order`:e.paintOrder=n.trim();break;case`-webkit-background-clip`:case`background-clip`:e.webkitBackgroundClip=n.trim();break;case`background-image`:e.backgroundImage=n.trim();break;case`letter-spacing`:e.letterSpacing=n.trim()===`normal`?0:lF(n,o,i);break;case`word-spacing`:e.wordSpacing=n.trim()===`normal`?0:lF(n,o,i);break;case`font-kerning`:e.fontKerning=n.trim();break;case`line-height`:{let t=n.trim();if(t===`normal`)e.lineHeight=0;else if(t.endsWith(`px`))e.lineHeight=parseFloat(t)||0;else if(t.endsWith(`em`))e.lineHeight=parseFloat(t)*o;else{let n=parseFloat(t);isNaN(n)||(e.lineHeight=n*o,e._lineHeightMultiplier=n)}break}case`-webkit-line-clamp`:case`line-clamp`:{let t=n.trim().toLowerCase();if(t===`none`||t===`auto`)e.lineClamp=0;else{let n=parseInt(t,10);e.lineClamp=Number.isFinite(n)&&n>0?n:0}break}case`vertical-align`:e.verticalAlign=n.trim();break;case`white-space`:e.whiteSpace=n.trim();break;case`word-break`:e.wordBreak=n.trim();break;case`overflow-wrap`:case`word-wrap`:e.overflowWrap=n.trim();break;case`direction`:e.direction=n.trim();break;case`unicode-bidi`:e.unicodeBidi=n.trim();break;case`display`:e.display=n.trim();break;case`width`:{let t=n.trim();t===`100%`?e.width=i:t!==`auto`&&(e.width=lF(t,o,i));break}case`min-height`:e.minHeight=lF(n,o,i);break;case`padding-top`:e.paddingTop=lF(n,o,i);break;case`padding-right`:e.paddingRight=lF(n,o,i);break;case`padding-bottom`:e.paddingBottom=lF(n,o,i);break;case`padding-left`:e.paddingLeft=lF(n,o,i);break;case`margin-top`:e.marginTop=lF(n,o,i);break;case`margin-right`:e.marginRight=lF(n,o,i);break;case`margin-bottom`:e.marginBottom=lF(n,o,i);break;case`margin-left`:e.marginLeft=lF(n,o,i);break;case`background-color`:e.backgroundColor=n.trim();break;case`background`:{let t=n.trim();t.includes(`gradient(`)?e.backgroundImage=t:(t.startsWith(`#`)||t.startsWith(`rgb`)||t.startsWith(`hsl`)||[`transparent`,`none`,`inherit`].includes(t)||/^[a-z]+$/.test(t))&&(e.backgroundColor=t);break}case`padding-inline-start`:a===`rtl`?e.paddingRight=lF(n,o,i):e.paddingLeft=lF(n,o,i);break;case`padding-inline-end`:a===`rtl`?e.paddingLeft=lF(n,o,i):e.paddingRight=lF(n,o,i);break;case`margin-inline-start`:a===`rtl`?e.marginRight=lF(n,o,i):e.marginLeft=lF(n,o,i);break;case`margin-inline-end`:a===`rtl`?e.marginLeft=lF(n,o,i):e.marginRight=lF(n,o,i);break;case`border-top-width`:e.borderTopWidth=lF(n,o,i);break;case`border-top-color`:e.borderTopColor=n.trim();break;case`border-top-style`:e.borderTopStyle=n.trim();break;case`border-right-width`:e.borderRightWidth=lF(n,o,i);break;case`border-right-color`:e.borderRightColor=n.trim();break;case`border-right-style`:e.borderRightStyle=n.trim();break;case`border-bottom-width`:e.borderBottomWidth=lF(n,o,i);break;case`border-bottom-color`:e.borderBottomColor=n.trim();break;case`border-bottom-style`:e.borderBottomStyle=n.trim();break;case`border-left-width`:e.borderLeftWidth=lF(n,o,i);break;case`border-left-color`:e.borderLeftColor=n.trim();break;case`border-left-style`:e.borderLeftStyle=n.trim();break;case`flex-direction`:e.flexDirection=n.trim();break;case`gap`:e.gap=lF(n,o,i);break;case`flex-grow`:e.flexGrow=parseFloat(n)||0;break;case`list-style-type`:e.listStyleType=n.trim();break;case`position`:case`top`:case`left`:case`right`:case`bottom`:case`inset-inline-start`:case`inset-inline-end`:case`content`:case`counter-reset`:case`counter-increment`:case`border-radius`:case`border-top-left-radius`:case`border-top-right-radius`:case`border-bottom-left-radius`:case`border-bottom-right-radius`:case`cursor`:case`opacity`:case`overflow`:case`box-sizing`:case`outline`:case`transition`:case`transform`:case`font-stretch`:case`font-display`:case`src`:case`unicode-range`:break}}var hF=[[`font-family`,`fontFamily`],[`font-size`,`fontSize`],[`font-weight`,`fontWeight`],[`font-style`,`fontStyle`],[`color`,`color`],[`text-align`,`textAlign`],[`text-align-last`,`textAlignLast`],[`text-indent`,`textIndent`],[`text-transform`,`textTransform`],[`white-space`,`whiteSpace`],[`word-break`,`wordBreak`],[`overflow-wrap`,`overflowWrap`],[`direction`,`direction`],[`letter-spacing`,`letterSpacing`],[`word-spacing`,`wordSpacing`],[`line-height`,`lineHeight`],[`text-shadow`,`textShadow`],[`font-kerning`,`fontKerning`],[`list-style-type`,`listStyleType`],[`vertical-align`,`verticalAlign`],[`paint-order`,`paintOrder`]];function gF(e,t,n){for(let[r,i]of hF)if(!n.has(r))if(i===`lineHeight`){let n=t._lineHeightMultiplier;n===void 0?e.lineHeight=t.lineHeight:(e.lineHeight=n*e.fontSize,e._lineHeightMultiplier=n)}else e[i]=t[i]}function _F(e){let t=new Map,n=new Map,r=[],i=0;for(let a of e){let e=[];for(let t of a.declarations){let n=t.value.includes(`!important`),r=n?t.value.replace(/\s*!important\s*/g,``).trim():t.value,i=pF(t.property,r);for(let t of i)e.push({property:t.property,value:t.value,important:n})}for(let o of a.selectors){let a=aF(o);if(!a)continue;let s={selector:a,declarations:e,orderBase:i++},c=a.rightmost;if(c.tag&&!a.rightmostIsRoot){let e=t.get(c.tag);e?e.push(s):t.set(c.tag,[s])}if(c.classes.length>0){let e=c.classes[0],t=n.get(e);t?t.push(s):n.set(e,[s])}!c.tag&&c.classes.length===0&&r.push(s),a.rightmostIsRoot&&r.push(s)}}return{byTag:t,byClass:n,universal:r}}function vF(e,t){switch(t){case`disc`:return`•`;case`circle`:return`○`;case`square`:return`■`;case`none`:return``;case`decimal-leading-zero`:return`${e<10&&e>=0?`0`+e:e}.`;case`lower-roman`:return`${yF(e).toLowerCase()}.`;case`upper-roman`:return`${yF(e)}.`;case`lower-alpha`:case`lower-latin`:return`${bF(e).toLowerCase()}.`;case`upper-alpha`:case`upper-latin`:return`${bF(e)}.`;default:return`${e}.`}}function yF(e){if(e<1||e>3999)return`${e}`;let t=[[1e3,`M`],[900,`CM`],[500,`D`],[400,`CD`],[100,`C`],[90,`XC`],[50,`L`],[40,`XL`],[10,`X`],[9,`IX`],[5,`V`],[4,`IV`],[1,`I`]],n=``;for(let[r,i]of t)for(;e>=r;)n+=i,e-=r;return n}function bF(e){if(e<1)return`${e}`;let t=``;for(;e>0;){let n=(e-1)%26;t=String.fromCharCode(65+n)+t,e=Math.floor((e-1)/26)}return t}function xF(e,t){if(e.tagName.toLowerCase()!==`li`)return;if(t===`none`)return``;let n=e.parentElement,r=n?.tagName.toLowerCase();if(t===`disc`||t===`circle`||t===`square`)return vF(0,t);if(r===`ol`||r===`ul`||!n){let r=n?Array.from(n.children).filter(e=>e.tagName.toLowerCase()===`li`):[e],i=n?.getAttribute(`start`),a=n?.hasAttribute(`reversed`)??!1,o=i?parseInt(i,10):a?r.length:1,s=a?-1:1,c=o;for(let n of r){let r=n.getAttribute(`value`);if(r){let e=parseInt(r,10);Number.isNaN(e)||(c=e)}if(n===e)return vF(c,t||`decimal`);c+=s}return vF(c,t||`decimal`)}}function SF(e){let t=[];for(let n of e.split(`;`)){let e=n.indexOf(`:`);if(e===-1)continue;let r=n.slice(0,e).trim().toLowerCase(),i=n.slice(e+1).trim();r&&i&&t.push({property:r,value:i})}return t}function CF(e,t,n){let{rules:r,fontFaceRules:i}=tF(t),a=null;i.length>0&&(a=document.createElement(`style`),a.textContent=i.join(`
|
|
377
|
+
`),document.head.appendChild(a));let o=_F(r),s=document.createElement(`div`);s.appendChild(e);function c(e,t){let n=new Set,r=e.getAttribute(`class`);if(r)for(let e of r.split(/\s+/))e&&n.add(e);return{tagName:e.tagName.toLowerCase(),classes:n,parent:t,el:e}}function l(e,t,r){let i=e.tagName.toLowerCase(),a=c(e,r),s=sF(),l=new Set,d=[],f=new Set,p=o.byTag.get(i);if(p)for(let e of p)f.add(e),d.push(e);for(let e of a.classes){let t=o.byClass.get(e);if(t)for(let e of t)f.has(e)||(f.add(e),d.push(e))}for(let e of o.universal)f.has(e)||(f.add(e),d.push(e));let m=[],h=[];for(let e of d)if(oF(e.selector,a)){let t=e.selector.pseudoElement===`marker`?h:m;for(let n of e.declarations)t.push({property:n.property,value:n.value,specificity:e.selector.spec,order:e.orderBase,important:n.important})}let g=cF[i],_=!1;if(g?.fontSize!==void 0){let e=g.fontSize;e<10?s.fontSize=e*t.fontSize:s.fontSize=e,_=!0,l.add(`font-size`)}m.length>1&&m.sort((e,t)=>{if(e.important!==t.important)return e.important?1:-1;let n=e.specificity,r=t.specificity;return n[0]===r[0]?n[1]===r[1]?n[2]===r[2]?e.order-t.order:n[2]-r[2]:n[1]-r[1]:n[0]-r[0]});for(let e of m)e.property===`font-size`&&(mF(s,e.property,e.value,t.fontSize,n,t.direction),_=!0);if(e instanceof HTMLElement&&e.style.cssText){let r=SF(e.style.cssText);for(let e of r)e.property===`font-size`&&(mF(s,e.property,e.value,t.fontSize,n,t.direction),_=!0)}_||(s.fontSize=t.fontSize);let v=s.fontSize;if(g){for(let[e,t]of Object.entries(g)){if(e===`fontSize`)continue;s[e]=t;let n=e.replace(/[A-Z]/g,e=>`-`+e.toLowerCase());l.add(n)}s.marginTop<0&&(s.marginTop=Math.abs(s.marginTop)*v),s.marginBottom<0&&(s.marginBottom=Math.abs(s.marginBottom)*v),(i===`ul`||i===`ol`)&&(t.direction===`rtl`?(s.paddingRight=40,l.add(`padding-right`)):(s.paddingLeft=40,l.add(`padding-left`)))}let y=t.direction,b={"word-wrap":`overflow-wrap`};for(let e of m)e.property!==`font-size`&&(mF(s,e.property,e.value,v,n,y),l.add(b[e.property]||e.property));let x=e instanceof HTMLElement&&!!e.style.width;if(e instanceof HTMLElement&&e.style.cssText){let t=SF(e.style.cssText);for(let e of t){if(e.property===`font-size`){l.add(`font-size`);continue}let t=pF(e.property,e.value);for(let e of t)mF(s,e.property,e.value,v,n,y),l.add(b[e.property]||e.property)}}x||(s.width=0);let S=e.getAttribute(`dir`);S&&(s.direction=S,l.add(`direction`)),l.add(`font-size`),gF(s,t,l),l.has(`text-decoration-color`)||(s.textDecorationColor=s.color),l.has(`-webkit-text-stroke-color`)?s.webkitTextStrokeColor===`currentColor`&&(s.webkitTextStrokeColor=s.color):(s.webkitTextStrokeColor===``||s.webkitTextStrokeColor===`currentColor`)&&(s.webkitTextStrokeColor=s.color);for(let e of[`Top`,`Right`,`Bottom`,`Left`]){let t=`border${e}Color`,n=`border-${e.toLowerCase()}-color`;l.has(n)?s[t]===`currentColor`&&(s[t]=s.color):s[t]=s.color}let C=new Set(s.textDecorationLine.split(/\s+/).filter(e=>e&&e!==`none`));if(t.textDecorationLine&&t.textDecorationLine!==`none`)for(let e of t.textDecorationLine.split(/\s+/))e&&e!==`none`&&C.add(e);C.size>0&&(s.textDecorationLine=[...C].join(` `));let w=xF(e,s.listStyleType),T,E=!1;if(i===`li`&&h.length>0){h.length>1&&h.sort((e,t)=>{if(e.important!==t.important)return e.important?1:-1;let n=e.specificity,r=t.specificity;return n[0]===r[0]?n[1]===r[1]?n[2]===r[2]?e.order-t.order:n[2]-r[2]:n[1]-r[1]:n[0]-r[0]});let e=[`paddingLeft`,`paddingRight`,`fontSize`,`fontFamily`,`fontWeight`,`fontStyle`,`color`,`letterSpacing`],t={...s},r=new Set;for(let i of h){if(i.property===`content`){let e=i.value.trim().toLowerCase();(e===`none`||e===`""`||e===`''`||e===`normal`)&&(E=e===`none`||e===`""`||e===`''`);continue}let a=e.map(e=>t[e]);mF(t,i.property,i.value,v,n,y),e.forEach((e,n)=>{t[e]!==a[n]&&r.add(e)})}if(r.size>0){T={};for(let e of r)T[e]=t[e]}}let D=[];for(let t of e.childNodes){let e=u(t,s,a);e&&D.push(e)}return{element:e,tagName:i,style:s,children:D,textContent:null,listMarker:w,markerStyle:T,markerHidden:E||void 0}}function u(e,t,n){if(e.nodeType===Node.TEXT_NODE){let n=e.textContent;if(!n)return null;if(n.trim()===``&&!n.includes(`\xA0`)){let r=t.whiteSpace,i=e.previousSibling,a=e.nextSibling,o=e=>{if(!e||e.nodeType!==Node.ELEMENT_NODE)return e?.nodeType===Node.TEXT_NODE;let t=cF[e.tagName.toLowerCase()]?.display||`block`;return t===`inline`||t===`inline-block`};if(i&&a&&!o(i)&&!o(a)&&!(r===`pre`||r===`pre-wrap`||r===`pre-line`)||r!==`pre`&&r!==`pre-wrap`&&r!==`pre-line`&&n.includes(`
|
|
378
|
+
`))return null}let r={...t},i=t.whiteSpace,a=n;return i!==`pre`&&i!==`pre-wrap`&&i!==`pre-line`&&i!==`break-spaces`&&(a=n.replace(/[\n\r]/g,` `)),{element:null,tagName:`#text`,style:r,children:[],textContent:a}}if(e.nodeType!==Node.ELEMENT_NODE)return null;let r=e,i=r.tagName.toLowerCase();return i===`style`||i===`script`?null:i===`br`?{element:null,tagName:`#text`,style:{...t},children:[],textContent:`
|
|
379
|
+
`}:l(r,t,n)}return{tree:l(s,sF(),null),cleanup:()=>{a&&a.remove()}}}var wF=!0,TF,EF=[],DF=new Map;function OF(e,t){let n=e.font+`\0`+(e.letterSpacing||``)+`\0`+t,r=DF.get(n);if(r!==void 0)return r;let i=e.measureText(t).width;return DF.set(n,i),i}function kF(e){let t=``;for(let n of e){if(!n.text||n.isSpace)continue;let e=NF(n.style);if(t&&e!==t)return!0;t=e}return!1}function AF(e,t){e.font=NF(t),e.fontKerning=t.fontKerning===`none`?`none`:`normal`}function jF(e){return Number.isFinite(e)&&e!==0?`${e}px`:`0px`}var MF=new Map;function NF(e){let t=`${e.fontStyle}|${e.fontVariantCaps}|${e.fontWeight}|${e.fontSize}|${e.fontFamily}`,n=MF.get(t);if(n)return n;let r=[];e.fontStyle!==`normal`&&r.push(e.fontStyle),e.fontVariantCaps===`small-caps`&&r.push(`small-caps`),e.fontWeight!==400&&r.push(String(e.fontWeight)),r.push(`${e.fontSize}px`),r.push(e.fontFamily);let i=r.join(` `);return MF.set(t,i),i}var PF=new Map,FF=null,IF=null,LF=null,RF=new Set([`disc`,`circle`,`square`]);function zF(e,t,n=!1){let r=`${e}|${t}|${n?`ul-li`:`block`}`,i=PF.get(r);if(i!==void 0)return i;let a;n?(IF||(IF=document.createElement(`ul`),IF.style.cssText=`position:absolute;top:-9999px;left:-9999px;visibility:hidden;padding:0;margin:0;border:0;list-style:disc;`,LF=document.createElement(`li`),LF.style.cssText=`white-space:nowrap;padding:0;margin:0;border:0;`,LF.textContent=`Mg`,IF.appendChild(LF),document.body.appendChild(IF)),a=LF):(FF||(FF=document.createElement(`div`),FF.style.cssText=`position:absolute;top:-9999px;left:-9999px;visibility:hidden;white-space:nowrap;padding:0;margin:0;border:0;`,FF.textContent=`Mg`,document.body.appendChild(FF)),a=FF),a.style.font=e,a.style.lineHeight=t;let o=a.getBoundingClientRect().height;return PF.set(r,o),o}function BF(e,t,n=!1){if(t.lineHeight>0)return wF?zF(NF(t),`${t.lineHeight}px`,n):t.lineHeight;if(wF)return zF(NF(t),`normal`,n);let{ascent:r,descent:i}=qF(e,t);return r+i}function VF(e,t,n){let{ascent:r,descent:i}=qF(e,t);return(r-i)/2+n/2}function HF(e,t){switch(t){case`uppercase`:return e.toUpperCase();case`lowercase`:return e.toLowerCase();case`capitalize`:return e.replace(/(^|[\s\p{P}])(\p{L})/gu,(e,t,n)=>t===`'`||t===`’`?e:t+n.toUpperCase());default:return e}}function UF(e){if(e.tagName===`#text`)return!0;let t=e.style.display;return t===`inline`||t===`inline-block`}function WF(e){return e.children.length>0&&e.children.every(UF)}function GF(e){return!e||e===`transparent`||e===`rgba(0, 0, 0, 0)`}var KF=new Map;function qF(e,t){let n=NF(t),r=KF.get(n);if(r)return r;e.font=n;let i=e.measureText(`M`),a={ascent:i.fontBoundingBoxAscent??i.actualBoundingBoxAscent,descent:i.fontBoundingBoxDescent??i.actualBoundingBoxDescent};return KF.set(n,a),a}function JF(e,t,n,r,i,a,o){switch(e){case`super`:return-r*.4;case`sub`:return r*.26;case`text-top`:return-(i-t);case`text-bottom`:return a-n;case`middle`:return-(r*.25)-(n-t)/2;default:{let t=parseFloat(e);return Number.isFinite(t)?e.endsWith(`%`)?-(t/100)*o:-t:0}}}function YF(e){return e!==`baseline`&&e!==`top`&&e!==`bottom`&&e!==``}function XF(e,t){return e.fontFamily===t.fontFamily&&e.fontSize===t.fontSize&&e.fontWeight===t.fontWeight&&e.fontStyle===t.fontStyle&&e.color===t.color&&e.textDecorationLine===t.textDecorationLine&&e.backgroundColor===t.backgroundColor}function ZF(e){return!GF(e.backgroundColor)||e.borderTopWidth>0&&e.borderTopStyle!==`none`||e.borderRightWidth>0&&e.borderRightStyle!==`none`||e.borderBottomWidth>0&&e.borderBottomStyle!==`none`||e.borderLeftWidth>0&&e.borderLeftStyle!==`none`}function QF(e){return!!(e.boxOpen&&e.boxClose&&e.text)}function $F(e,t,n){let r=t.words.length-1;for(;r>=0&&(t.words[r].text===``||QF(t.words[r]));)r--;if(r<0)return;let i=t.words[r].style,a=t.words[r].boxStyle;AF(e,i),e.letterSpacing=`${i.letterSpacing||0}px`;let o=OF(e,`…`),s=()=>{for(;t.words.length>0&&t.words[t.words.length-1].isSpace;){let e=t.words.pop();t.totalWidth-=e.width}};s();let c=e=>!e.isSpace&&e.text!==``&&!e.boxOpen&&!e.boxClose;for(;t.totalWidth+o>n&&t.words.length>0;){let e=t.words[t.words.length-1];if(!c(e)&&!QF(e))break;t.totalWidth-=e.width,t.words.pop(),s()}let l={text:`…`,width:o,style:i,isSpace:!1,boxStyle:a};t.words.push(l),t.totalWidth+=o}function eI(e){let t=[];function n(e,r){if(e.tagName===`#text`&&e.textContent){t.push({text:e.textContent,style:e.style,boxStyle:r});return}let i=e.style.display===`inline-block`,a=i||UF(e)&&ZF(e.style),o=a?e.style:r,s=a&&(e.style.paddingLeft>0||e.style.paddingRight>0||e.style.borderLeftWidth>0||e.style.borderRightWidth>0);if(i){let n=e.element?.textContent||``;t.push({text:n,style:e.style,boxStyle:o,boxOpen:e.style,boxClose:e.style});return}let c=e.style.unicodeBidi,l=(c===`bidi-override`||c===`isolate-override`)&&e.style.direction===`rtl`,u=t.length;s&&t.push({text:``,style:e.style,boxStyle:o,boxOpen:e.style});for(let t of e.children)n(t,a?o:r);if(s&&t.push({text:``,style:e.style,boxStyle:o,boxClose:e.style}),l&&t.length>u){let e=t.splice(u);for(let t of e)t.text&&(t.text=[...t.text].reverse().join(``),t.style={...t.style,direction:`ltr`});e.reverse(),t.push(...e)}}for(let t of e.children)n(t);return t}function tI(e){for(let t=0;t<e.length;t++){let n=e.codePointAt(t);if(n>=3584&&n<=3711||n>=3712&&n<=3839||n>=4096&&n<=4255||n>=6016&&n<=6143)return!0;n>65535&&t++}return!1}var nI;function rI(){return nI||(typeof Intl<`u`&&Intl.Segmenter?(nI=new Intl.Segmenter(void 0,{granularity:`word`}),nI):null)}function iI(e,t,n,r,i){if(t.includes(``)||t.includes(``)){let a=t.split(/(\u200B|\u00AD)/),o=i??{cumText:``,cumWidth:0},s=!1;for(let t of a){if(t===``){s=!0;continue}if(t===``||t===``){s=!1;continue}let i=r.length;iI(e,t,n,r,o),s&&i>0&&(r[i-1].isSoftHyphenBreak=!0),s=!1}s&&r.length>0&&(r[r.length-1].isSoftHyphenBreak=!0);return}if(n.style.whiteSpace===`pre`||n.style.whiteSpace===`pre-wrap`||n.style.whiteSpace===`break-spaces`){let i=t.split(/( +|\t)/),a=OF(e,` `)*8;for(let t of i){if(t===``)continue;if(t===` `){r.push({text:` `,width:a,style:n.style,isSpace:!0,isTab:!0,boxStyle:n.boxStyle});continue}let i=/^ +$/.test(t);r.push({text:t,width:OF(e,t),style:n.style,isSpace:i,boxStyle:n.boxStyle})}}else{let a=t.split(/([ \t\n\r\f\v]+)/).flatMap(e=>/^[ \t\n\r\f\v]+$/.test(e)?[e]:e.split(/(?<=\?)(?=.)/)),o=i?.cumText??``,s=i?.cumWidth??0;for(let t of a){if(t===``)continue;if(/^[ \t\n\r\f\v]+$/.test(t)){let t=s;o+=` `,s=e.measureText(o).width;let i=s-t+(n.style.wordSpacing||0);r.push({text:` `,width:i,style:n.style,isSpace:!0,boxStyle:n.boxStyle});continue}if(tI(t)){let i=rI();if(i){for(let a of i.segment(t)){let t=a.segment,i=s;o+=t,s=e.measureText(o).width,r.push({text:t,width:s-i,style:n.style,isSpace:!1,boxStyle:n.boxStyle})}continue}}let i=s;o+=t,s=e.measureText(o).width;let a=s-i,c=OF(e,t);TF&&TF({type:`measure-word`,message:`"${t}" delta=${a.toFixed(2)} direct=${c.toFixed(2)} diff=${(a-c).toFixed(2)} cumText="${o}"`,data:{text:t,deltaWidth:a,directWidth:c,cumWidth:s,prevCum:i,font:n.style.fontFamily,fontSize:n.style.fontSize}}),r.push({text:t,width:a,style:n.style,isSpace:!1,boxStyle:n.boxStyle})}i&&(i.cumText=o,i.cumWidth=s)}}function aI(e,t){let n=[];for(let r of t){if(r.text===``&&!r.boxOpen&&!r.boxClose){let e=r.style.display===`inline-block`&&(r.style.marginLeft||r.style.marginRight)||0;e>0&&n.push({text:``,width:e,style:r.style,isSpace:!1,boxStyle:r.boxStyle});continue}if(r.boxOpen&&r.boxClose&&r.text){AF(e,r.style),e.letterSpacing=jF(r.style.letterSpacing);let t=HF(r.text,r.style.textTransform),i=r.style,a=OF(e,t),o=i.marginLeft+i.borderLeftWidth+i.paddingLeft+a+i.paddingRight+i.borderRightWidth+i.marginRight;n.push({text:t,width:o,style:r.style,isSpace:!1,boxStyle:r.boxStyle,boxOpen:r.boxOpen,boxClose:r.boxClose});continue}if(r.boxOpen){let e=r.boxOpen.paddingLeft+r.boxOpen.borderLeftWidth;e>0&&n.push({text:``,width:e,style:r.style,isSpace:!1,boxStyle:r.boxStyle,boxOpen:r.boxOpen});continue}if(r.boxClose){let e=r.boxClose.paddingRight+r.boxClose.borderRightWidth;e>0&&n.push({text:``,width:e,style:r.style,isSpace:!1,boxStyle:r.boxStyle,boxClose:r.boxClose});continue}AF(e,r.style),e.letterSpacing=jF(r.style.letterSpacing);let t=HF(r.text,r.style.textTransform),i=e=>{let t=n[e];if(!t||t.isSpace||!t.text||t.text===`
|
|
380
|
+
`)return;let r=n[e-1];if(!r||r.isSpace||!r.text.trim()||r.boxOpen||r.boxClose)return;let i=[...t.text][0],a=[...r.text][r.text.length-1];oI(i)||oI(a)||tI(t.text)||tI(r.text)||(t.noBreakBefore=!0)};if(t.includes(`
|
|
381
|
+
`)){let a=t.split(`
|
|
382
|
+
`);for(let t=0;t<a.length;t++)if(t>0&&n.push({text:`
|
|
383
|
+
`,width:0,style:r.style,isSpace:!1,boxStyle:r.boxStyle}),a[t]){let o=n.length;iI(e,a[t],r,n),i(o)}}else{let a=n.length;iI(e,t,r,n),i(a)}}return n}function oI(e){let t=e.codePointAt(0)||0;return t>=19968&&t<=40959||t>=13312&&t<=19903||t>=12288&&t<=12351||t>=12352&&t<=12447||t>=12448&&t<=12543||t>=44032&&t<=55215||t>=65280&&t<=65519||t>=131072&&t<=173791}var sI;function cI(){return sI||(typeof Intl<`u`&&Intl.Segmenter?(sI=new Intl.Segmenter(void 0,{granularity:`grapheme`}),sI):null)}var lI=/\p{Extended_Pictographic}/u;function uI(e){for(let t of e)if(t.codePointAt(0)>=126976)return!0;return e.includes(``)||e.includes(`️`)?lI.test(e):!1}function dI(e,t,n,r){let i=[...t.text].some(oI),a=lI.test(t.text)&&!!cI(),o=t.width>n&&(t.style.overflowWrap===`break-word`||t.style.wordBreak===`break-all`);if(!i&&!a&&!o)return[t];if(o&&t.style.wordBreak!==`break-all`&&t.style.overflowWrap===`break-word`){let r=t.text.split(/(?<=-)(?!\d)|(?<=[^\d]-)/).filter(e=>e.length);if(r.length>1){e.font=NF(t.style),e.letterSpacing=jF(t.style.letterSpacing);let i=[];for(let a of r){let r=OF(e,a);r<=n?i.push({...t,text:a,width:r}):i.push(...dI(e,{...t,text:a,width:r},n,0))}return i}}e.font=NF(t.style),e.letterSpacing=jF(t.style.letterSpacing);let s=a?cI():null,c=s?[...s.segment(t.text)].map(e=>e.segment):[...t.text],l=[],u=``,d=0;for(let r of c){if(a&&uI(r)){u&&(l.push({...t,text:u,width:d}),u=``,d=0),l.push({...t,text:r,width:OF(e,r)});continue}if(oI(r)){u&&(l.push({...t,text:u,width:d}),u=``,d=0);let n=OF(e,r);l.push({...t,text:r,width:n});continue}let i=u+r,s=OF(e,i);if(o&&s>n&&u){l.push({...t,text:u,width:d}),u=r,d=OF(e,r);continue}u=i,d=s}return u&&l.push({...t,text:u,width:d}),l}var fI=/^[,.\;:!?\)\]\}'"»›]+$/;function pI(e,t,n,r,i=!1,a=0){let o=[],s={words:[],totalWidth:0,lineHeight:0},c=r===`nowrap`||r===`pre`,l=()=>n-(o.length===0?a:0),u=r===`pre-wrap`||r===`pre`||r===`pre-line`,d=r===`pre`||r===`pre-wrap`||r===`break-spaces`;function f(t=!1){let i=s.words.length>0;if(!(r===`break-spaces`||d&&!t))for(;s.words.length>0&&s.words[s.words.length-1].isSpace;)s.totalWidth-=s.words[s.words.length-1].width,s.words.pop();if(t&&s.words.length>0){let t=s.words[s.words.length-1];if(t.isSoftHyphenBreak){AF(e,t.style);let n=OF(e,`-`);s.words.push({text:`-`,width:n,style:t.style,isSpace:!1}),s.totalWidth+=n}}if(s.words.length>0||i&&u){if(TF){let e=s.words.map(e=>e.text).join(``);TF({type:`line-commit`,message:`Line ${o.length}: "${e}" width=${s.totalWidth.toFixed(2)} / ${n}`,data:{lineIndex:o.length,text:e,totalWidth:s.totalWidth,contentWidth:n}})}o.push(s)}s={words:[],totalWidth:0,lineHeight:0}}let p=!0;for(let r=0;r<t.length;r++){let a=t[r],u=BF(e,a.style,i);if(a.boxStyle&&a.boxStyle.display===`inline-block`){let e=a.boxStyle;u=Math.max(u,u+e.paddingTop+e.paddingBottom+e.marginTop+e.marginBottom+e.borderTopWidth+e.borderBottomWidth)}if(a.text===`
|
|
384
|
+
`){s.words.length===0?(s.lineHeight=u,s.endedByHardBreak=!0,o.push(s),s={words:[],totalWidth:0,lineHeight:0}):(s.endedByHardBreak=!0,f()),p=!0;continue}if(c){s.words.push(a),s.totalWidth+=a.width,s.lineHeight=Math.max(s.lineHeight,u);continue}if(!a.isSpace&&a.text&&!a.noBreakBefore&&!a.boxOpen&&!a.boxClose){let n=r;for(;n+1<t.length;){let e=t[n+1];if(!e.text||e.isSpace||e.boxOpen||e.boxClose||!e.noBreakBefore)break;n++}if(n>r){let o=a.style.overflowWrap===`break-word`||a.style.wordBreak===`break-all`,c=0;for(let e=r;e<=n;e++)c+=t[e].width;let u=[];for(let e=r;e<=n;e++)for(let n of[...t[e].text])u.push({ch:n,style:t[e].style});let d=u.map(e=>e.ch).join(``).split(/(?<=-)(?!\d)|(?<=[^\d]-)/).filter(e=>e.length),m=d.length>1;if(!(s.totalWidth+c<=l())&&(m||o&&c>l())){let t=[],a=0;for(let e of d){let n=[...e].length;t.push(u.slice(a,a+n)),a+=n}let c=(t,n)=>{let r=0;for(;r<t.length;){let a=t[r].style;AF(e,a),e.letterSpacing=jF(a.letterSpacing);let o=BF(e,a,i),c=``,u=0;for(;r<t.length&&t[r].style===a;){let i=t[r].ch,d=OF(e,c+i);n&&s.totalWidth+d>l()&&(s.words.length>0||c)?(c&&(s.words.push({text:c,width:u,style:a,isSpace:!1}),s.totalWidth+=u,s.lineHeight=Math.max(s.lineHeight,o)),f(!0),p=!1,c=i,u=OF(e,i)):(c+=i,u=d),r++}c&&(s.words.push({text:c,width:u,style:a,isSpace:!1}),s.totalWidth+=u,s.lineHeight=Math.max(s.lineHeight,o),p=!1)}},h=t=>{let n=0,r=0;for(;r<t.length;){let i=t[r].style,a=``;for(;r<t.length&&t[r].style===i;)a+=t[r].ch,r++;AF(e,i),e.letterSpacing=jF(i.letterSpacing),n+=OF(e,a)}return n};!m&&s.words.length>0&&(f(!0),p=!1);for(let e of t){let t=h(e);s.words.length>0&&s.totalWidth+t>l()&&(f(!0),p=!1),c(e,o&&t>l())}r=n;continue}}}let m=!a.isSpace&&a.text.length>1?dI(e,a,l(),s.totalWidth):[a],h=0;for(let e=r+1;e<t.length;e++){let n=t[e];if(n.isSpace||n.text===`
|
|
385
|
+
`)break;let r=!!n.text&&fI.test(n.text),i=!n.text&&!!n.boxClose,a=!!n.text&&!!n.noBreakBefore;if(r||i||a){h+=n.width;continue}break}for(let i of m){let a=i===m[m.length-1]?h:0,o=!i.isSpace&&i.text.length>0&&fI.test(i.text)&&s.words.length>0&&!s.words[s.words.length-1].isSpace,c=i===m[0]&&i.noBreakBefore&&s.words.length>0&&!s.words[s.words.length-1].isSpace,g=0;if(!i.text&&i.boxOpen){let n=t[r+1];n&&!n.isSpace&&n.text&&(g=(n.text.length>1?dI(e,n,l(),0):[n])[0].width)}let _=0;if(i.isSoftHyphenBreak&&(AF(e,i.style),e.letterSpacing=jF(i.style.letterSpacing),_=OF(e,`-`)),!i.isSpace&&!o&&!c&&s.words.length>0&&s.totalWidth+i.width+_+a+g>l()){let t=s.totalWidth+i.width+_+a+g-l(),r=!0;if(t<1&&!kF([...s.words,i])){AF(e,i.style);let t=s.words.map(e=>e.text).join(``)+i.text+(i.isSoftHyphenBreak?`-`:``),n=0;for(let e of s.words)e.text||(n+=e.width);i.text||(n+=i.width),OF(e,t)+n+a+g<=l()+.02&&(r=!1)}if(r&&i.text.includes(`-`)){let t=i.text.split(/(?<=-)(?!\d)|(?<=[^\d]-)/);if(t.length>1){AF(e,i.style);let n=``,r=0,a=0,o=l()-s.totalWidth;for(;a<t.length;a++){let i=n+t[a],s=OF(e,i);if(s>o)break;n=i,r=s}if(a>0&&a<t.length){s.words.push({...i,text:n,width:r}),s.totalWidth+=r,s.lineHeight=Math.max(s.lineHeight,u),f(!0),p=!1;let o=t.slice(a).join(``),c=OF(e,o);s.words.push({...i,text:o,width:c}),s.totalWidth+=c,s.lineHeight=Math.max(s.lineHeight,u);continue}}}if(r){if(TF){let e=s.words.map(e=>e.text).join(``);TF({type:`line-wrap`,message:`"${i.text}" overflow=${t.toFixed(2)} wrap=true lineWidth=${s.totalWidth.toFixed(2)} pieceWidth=${i.width.toFixed(2)} contentWidth=${n} line="${e}"`,data:{text:i.text,overflow:t,lineWidth:s.totalWidth,pieceWidth:i.width,contentWidth:n,lineText:e}})}f(!0),p=!1}}if(i.isSpace&&s.words.length===0&&(!p||!d))continue;let v=i.width;if(i.isTab){let e=i.width,t=s.totalWidth;v=Math.ceil((t+.1)/e)*e-t,i.width=v}if(s.words.length===0&&v>l()&&!i.isSpace&&i.text.includes(`-`)){let t=i.text.split(/(?<=-)(?!\d)|(?<=[^\d]-)/);if(t.length>1){AF(e,i.style);let n=t.filter(e=>e).map(t=>({...i,text:t,width:OF(e,t)})),r=!0;for(let e of n)r?(r=!1,s.words.push(e),s.totalWidth+=e.width,s.lineHeight=Math.max(s.lineHeight,u)):s.totalWidth+e.width>l()?(f(!0),p=!1,s.words.push(e),s.totalWidth+=e.width,s.lineHeight=Math.max(s.lineHeight,u)):(s.words.push(e),s.totalWidth+=e.width,s.lineHeight=Math.max(s.lineHeight,u));continue}}s.words.push(i),s.totalWidth+=v,s.lineHeight=Math.max(s.lineHeight,u),i.isSpace||(p=!1)}}return f(),o}function mI(e,t,n,r,i,a=!1,o){let s=[];if(o&&(o.exhausted||o.remaining<=0))return o.exhausted=!0,{nodes:s,height:0};let c=eI(t);if(c.length===0)return{nodes:s,height:0};let l=aI(e,c),u=t.style.textIndent||0,d=pI(e,l,i,t.style.whiteSpace,a,u),f=o?o.remaining:t.style.lineClamp;if(f>0&&d.length>f){d.length=f;let t=d[f-1];$F(e,t,i-(f===1?u:0)),t.endedByHardBreak=!0,o&&(o.remaining=0,o.exhausted=!0)}else o&&(o.remaining-=d.length);let p=t.style.direction===`rtl`,m=e=>e===`start`?p?`right`:`left`:e===`end`?p?`left`:`right`:e,h=m(t.style.textAlign),g=t.style.textAlignLast||`auto`;g=g===`auto`?t.style.textAlign===`justify`?p?`right`:`left`:h:m(g);let _=r;for(let t=0;t<d.length;t++){let r=d[t];if(r.words.length===0){_+=r.lineHeight;continue}let a=r.lineHeight,o=t===d.length-1,c=t===0,l=o||r.endedByHardBreak?g:h,f=c?u:0,m=i-f,v=0;if(l===`justify`&&r.totalWidth<m){let e=r.words.filter(e=>e.isSpace).length;e>0&&(v=(m-r.totalWidth)/e)}let y=r.totalWidth>m+.5,b=n+f;y?b=p?n+m-r.totalWidth:n+f:l===`center`?b=n+f+(m-r.totalWidth)/2:l===`right`?b=(p?n+m:n+f+m)-r.totalWidth:l===`justify`&&p&&(b=n+m-r.totalWidth);let x=b,S=0,C=0;for(let t of r.words){if(t.text===``||YF(t.style.verticalAlign))continue;let{ascent:n,descent:r}=qF(e,t.style);n>S&&(S=n),r>C&&(C=r)}if(S===0)for(let t of r.words){if(t.text===``)continue;let{ascent:n,descent:r}=qF(e,t.style);S=n,C=r;break}let w=S+C,T=_+(a-w)/2+S,E=r.words.filter(e=>e.text!==``&&!YF(e.style.verticalAlign)),D=E.length>0?Math.max(...E.map(e=>e.style.fontSize)):0,O=_,k=_+a;for(let t of r.words){if(t.text===``)continue;let n=t.style.verticalAlign;if(!YF(n))continue;if(D===0)break;let{ascent:r,descent:i}=qF(e,t.style),o=T+JF(n,r,i,D,S,C,a),s=o-r,c=o+i;s<O&&(O=s),c>k&&(k=c)}let ee=k-O,A=(t,n,r)=>{let{ascent:i,descent:a}=qF(e,t),o=t.paddingTop+t.borderTopWidth,c=t.paddingBottom+t.borderBottomWidth,l=i+a+o+c,u;u=t.display===`inline-block`?_+t.marginTop:T-i-o,s.push({type:`box`,style:t,x:n,y:u,width:r,height:l,tagName:`span`,children:[]})};if(!p){let e=b,t=e,n,i=!1;for(let a of r.words){if(a.boxOpen&&a.boxClose&&a.text){n&&(i&&A(n,t,e-t),n=void 0,i=!1);let r=a.style,o=a.width-r.marginLeft-r.borderLeftWidth-r.paddingLeft-r.paddingRight-r.borderRightWidth-r.marginRight;A(r,e+r.marginLeft,r.borderLeftWidth+r.paddingLeft+o+r.paddingRight+r.borderRightWidth),i=!1,e+=a.width;continue}a.boxStyle!==n&&(n&&i&&A(n,t,e-t),n=a.boxStyle,t=e,i=!1),a.text&&!a.isSpace&&(i=!0),e+=a.width+(a.isSpace?v:0)}n&&i&&A(n,t,e-t)}let j=r.words.filter(e=>e.text!==``),te=j.length>0&&j.every(e=>XF(e.style,j[0].style));if(p){let t=[],n=null,i=0;for(let e of r.words){if(e.text===``){n&&=(t.push(n),null),i+=e.width;continue}if(e.isSpace&&v>0){n&&=(t.push(n),null),i+=e.width+v;continue}n&&XF(n.style,e.style)?(n.text+=e.text,n.width+=e.width):(n&&t.push(n),n={text:e.text,style:e.style,width:e.width,boxStyle:e.boxStyle,x:0,padBefore:i},i=0)}n&&t.push(n);let a=b+r.totalWidth;for(let n of t){a-=n.padBefore,AF(e,n.style);let t=OF(e,n.text);a-=t,n.x=a,n.width=t}for(let e of t)if(e.boxStyle&&ZF(e.boxStyle)){let t=e.boxStyle,n=t.paddingLeft+t.borderLeftWidth,r=t.paddingRight+t.borderRightWidth;A(t,e.x-n,e.width+n+r)}for(let e of t)s.push({type:`text`,text:e.text,x:e.x+e.width,y:T,width:e.width,style:{...e.style,direction:`rtl`}})}else{let t=r.words.map(e=>e.text).join(``);if(te&&/[\u0590-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/.test(t)&&!r.words.some(e=>e.boxOpen||e.boxClose||e.style.verticalAlign===`super`||e.style.verticalAlign===`sub`)){AF(e,j[0].style);let n=OF(e,t);s.push({type:`text`,text:t,x:b,y:T,width:n,style:{...j[0].style,direction:`ltr`}})}else for(let t of r.words){if(t.text===``){b+=t.width;continue}if(t.boxOpen&&t.boxClose){let n=t.style,r=b+n.marginLeft+n.borderLeftWidth+n.paddingLeft;s.push({type:`text`,text:t.text,x:r,y:T,width:OF(e,t.text),style:t.style}),b+=t.width;continue}let n=T,r=t.style.verticalAlign;if(YF(r)){let i=D||t.style.fontSize,{ascent:o,descent:s}=qF(e,t.style);n+=JF(r,o,s,i,S,C,a)}let i=t.width+(t.isSpace?v:0);s.push({type:`text`,text:t.text,x:b,y:n,width:i,style:t.style}),b+=i}}let M=l===`justify`&&v>0?m:r.totalWidth;EF.push({y:Math.round(T),text:r.words.map(e=>e.text).join(``),bounds:{x,y:O,width:M,height:ee}}),_+=ee}return{nodes:s,height:_-r}}function hI(e,t){return e>=0&&t>=0?Math.max(e,t):e<0&&t<0?Math.min(e,t):e+t}function gI(e,t,n,r,i,a){let o=t.style;!a&&o.lineClamp>0&&(a={remaining:o.lineClamp,exhausted:!1});let s=o.marginLeft,c=o.marginRight,l=o.borderLeftWidth,u=o.borderRightWidth,d=o.borderTopWidth,f=o.borderBottomWidth,p=o.paddingLeft,m=o.paddingRight,h=o.paddingTop,g=o.paddingBottom,_=n+s,v=o.width>0?o.width:i-s-c,y=_+l+p,b=Math.max(0,v-l-u-p-m),x=r,S=x+d+h,C={type:`box`,style:o,x:_,y:x,width:v,height:0,tagName:t.tagName,children:[],listMarker:t.listMarker};if(o.display===`flex`){let n=vI(e,t,y,S,b);return C.children=n.children,C.height=d+h+n.height+g+f,{box:C,height:C.height,marginBottomOut:o.marginBottom}}if(o.display===`table`){let n=_I(e,t,y,S,b);return C.children=n.children,C.height=d+h+n.height+g+f,{box:C,height:C.height,marginBottomOut:o.marginBottom}}if(t.children.length===0)return C.height=d+h+g+f,o.minHeight>0&&(C.height=Math.max(C.height,o.minHeight)),{box:C,height:C.height,marginBottomOut:o.marginBottom};if(WF(t)){let{nodes:n,height:r}=mI(e,t,y,S,b,t.tagName===`li`&&RF.has(o.listStyleType),a);C.children=n,C.height=d+h+r+g+f}else{let n=S,r=0,i=!1,s=t.tagName===`li`||t.tagName===`ul`||t.tagName===`ol`||t.tagName===`dd`||t.tagName===`dt`;for(let c=0;c<t.children.length;c++){let l=t.children[c];if(a&&(a.exhausted||a.remaining<=0)){a.exhausted=!0,r=0;break}if(l.tagName===`#text`||UF(l)){let s=[l];for(;c+1<t.children.length;){let e=t.children[c+1];if(e.tagName===`#text`||UF(e))s.push(e),c++;else break}r>0&&(n+=r,r=0);let u={element:null,tagName:`div`,style:{...t.style,display:`block`,marginTop:0,marginBottom:0,paddingTop:0,paddingBottom:0,borderTopWidth:0,borderBottomWidth:0},children:s,textContent:null},d=t.tagName===`li`&&RF.has(o.listStyleType),{nodes:f,height:p}=mI(e,u,y,n,b,d,a);C.children.push(...f),n+=p,r=0,i=!0;continue}let u=l.style.marginTop;if(!(!i&&h===0&&d===0&&s)){let e=hI(r,u);n+=e}let{box:f,height:p,marginBottomOut:m}=gI(e,l,y,n,b,a);C.children.push(f),n+=p,r=a?.exhausted?0:m,i=!0}let c=o.marginBottom,l=g===0&&f===0&&s;l&&r>0&&(c=Math.max(o.marginBottom,r));let u=n-S;return!l&&r>0&&(u+=r),C.height=d+h+u+g+f,o.minHeight>0&&(C.height=Math.max(C.height,o.minHeight)),{box:C,height:C.height,marginBottomOut:c}}return o.minHeight>0&&(C.height=Math.max(C.height,o.minHeight)),{box:C,height:C.height,marginBottomOut:o.marginBottom}}function _I(e,t,n,r,i){let a=[],o=[];for(let e of t.children)if(e.tagName===`tr`)o.push(e);else if([`thead`,`tbody`,`tfoot`].includes(e.tagName))for(let t of e.children)t.tagName===`tr`&&o.push(t);if(o.length===0)return{children:a,height:0};let s=Math.max(...o.map(e=>e.children.filter(e=>e.tagName===`td`||e.tagName===`th`).length));if(s===0)return{children:a,height:0};let c=i/s,l=r;for(let t of o){let r=t.children.filter(e=>e.tagName===`td`||e.tagName===`th`),i=0,o=[];for(let t=0;t<r.length;t++){let a=r[t],{box:s,height:u}=gI(e,a,n+t*c,l,c);o.push(s),i=Math.max(i,u)}for(let e of o)e.height=i,a.push(e);l+=i}return{children:a,height:l-r}}function vI(e,t,n,r,i){let a=t.style,o=a.gap,s=[],c=t.children.filter(e=>e.tagName!==`#text`||e.textContent?.trim());if(c.length===0)return{children:s,height:0};if(a.flexDirection===`row`||a.flexDirection===``){let t=o*(c.length-1),a=c.reduce((e,t)=>e+(t.style.flexGrow||0),0),l=(i-t)/(a||c.length),u=n,d=0;for(let t of c){if(t.tagName===`#text`)continue;let n=l*(t.style.flexGrow||+(a===0)),{box:i,height:c}=gI(e,t,u,r,n);s.push(i),d=Math.max(d,c),u+=n+o}return{children:s,height:d}}let l=r;for(let t of c){if(t.tagName===`#text`)continue;let{box:r,height:a}=gI(e,t,n,l,i);s.push(r),l+=a+o}return{children:s,height:l-r}}function yI(e,t,n){if(!n.listMarker||n.markerHidden)return;let r=n.style,i=n.markerStyle,a=i?{...r,...i}:r;e.font=NF(a);let o=BF(e,r),s=t.y+r.borderTopWidth+r.paddingTop+VF(e,r,o),c=OF(e,n.listMarker),l=r.direction===`rtl`,u=RF.has(r.listStyleType),d=l?i?.paddingLeft:i?.paddingRight,f,p=s,m=`ltr`,h=t.x+r.borderLeftWidth+r.paddingLeft,g=t.x+t.width;if(u){let{ascent:t}=qF(e,a),r=e.measureText(n.listMarker),i=d===void 0?7+t/3:d;f=l?g+i+(r.actualBoundingBoxLeft??0):h-i-(r.actualBoundingBoxRight??c);let o=((r.actualBoundingBoxAscent??0)-(r.actualBoundingBoxDescent??0))/2;p=s-t/3+o}else{let t=d===void 0?OF(e,` `):d;l?/\d/.test(n.listMarker)?(m=`rtl`,f=g+t+c):f=g+t:f=h-c-t}t.children.unshift({type:`text`,text:n.listMarker,x:f,y:p,width:c,style:{...a,textDecorationLine:`none`,fontWeight:i?.fontWeight??400,fontStyle:i?.fontStyle??`normal`,direction:m}});let _=m===`rtl`?f-c:f;EF.push({y:Math.round(s),text:n.listMarker,bounds:{x:_,y:t.y+r.borderTopWidth+r.paddingTop,width:c,height:o}})}function bI(e,t,n,r=!0,i){wF=r,TF=i,PF.clear(),KF.clear(),MF.clear(),DF.clear(),EF=[];let{box:a,height:o}=gI(e,t,0,0,n);xI(e,a,t);let s=EF.slice().sort((e,t)=>e.y-t.y||e.bounds.x-t.bounds.x),c=[];for(let e of s){let t=c[c.length-1],n=e.bounds.height*.5;if(t&&Math.abs(e.y-t.y)<n){let n=t.text.length>0&&e.text.length>0&&!/\s$/.test(t.text)&&!/^\s/.test(e.text);t.text+=(n?` `:``)+e.text,t.y=Math.max(t.y,e.y);let r=Math.min(t.bounds.x,e.bounds.x),i=Math.min(t.bounds.y,e.bounds.y),a=Math.max(t.bounds.x+t.bounds.width,e.bounds.x+e.bounds.width),o=Math.max(t.bounds.y+t.bounds.height,e.bounds.y+e.bounds.height);t.bounds={x:r,y:i,width:a-r,height:o-i}}else c.push({y:e.y,text:e.text,bounds:{...e.bounds}})}return{root:a,height:o,lines:c}}function xI(e,t,n){yI(e,t,n);let r=0;for(let i of n.children)if(!(i.tagName===`#text`||UF(i)))for(;r<t.children.length;){let n=t.children[r];if(n.type===`box`&&n.tagName===i.tagName){xI(e,n,i),r++;break}r++}}function SI(e){if(!e||e===`none`)return[];let t=[],n=e.split(/,(?![^(]*\))/);for(let e of n){let n=e.trim(),r=n.match(/(rgb[a]?\([^)]+\)|#[0-9a-fA-F]+|\b[a-z]+\b)(?:\s|$)/i),i=n.match(/-?[\d.]+px/g);if(i&&i.length>=2){let e=i.map(e=>parseFloat(e));t.push({offsetX:e[0],offsetY:e[1],blur:e[2]||0,color:r?r[1]:`rgba(0,0,0,1)`})}}return t}function CI(e,t){return e[`border${t}Width`]>0&&e[`border${t}Style`]!==`none`}function wI(e,t,n,r,i,a,o){if(e.save(),e.strokeStyle=o,e.lineWidth=i,a===`double`){let a=Math.max(i,2);e.lineWidth=Math.max(.5,i*.5),e.beginPath(),e.moveTo(t,n-a/2),e.lineTo(t+r,n-a/2),e.moveTo(t,n+a/2),e.lineTo(t+r,n+a/2),e.stroke()}else if(a===`wavy`){let a=Math.max(1.5,i),o=a*4;e.beginPath(),e.moveTo(t,n);for(let i=t;i<t+r;i+=o)e.quadraticCurveTo(i+o/4,n-a,i+o/2,n),e.quadraticCurveTo(i+o*3/4,n+a,i+o,n);e.stroke()}else a===`dotted`?e.setLineDash([i,i*2]):a===`dashed`&&e.setLineDash([i*3,i*2]),e.beginPath(),e.moveTo(t,n),e.lineTo(t+r,n),e.stroke();e.setLineDash([]),e.restore()}function TI(e,t,n,r,i,a){let o=t.indexOf(`linear-gradient(`);if(o===-1)return null;let s=0,c=-1;for(let e=o+16;e<t.length;e++)if(t[e]===`(`)s++;else if(t[e]===`)`){if(s===0){c=e;break}s--}if(c===-1)return null;let l=t.slice(o+16,c),u=[];s=0;let d=0,f=l;for(let e=0;e<f.length;e++)f[e]===`(`?s++:f[e]===`)`?s--:f[e]===`,`&&s===0&&(u.push(f.slice(d,e).trim()),d=e+1);u.push(f.slice(d).trim());let p=180,m=0,h=u[0];h.endsWith(`deg`)?(p=parseFloat(h),m=1):h===`to right`?(p=90,m=1):h===`to left`?(p=270,m=1):h===`to bottom`?(p=180,m=1):h===`to top`&&(p=0,m=1);let g=(p-90)*Math.PI/180,_=n+r/2,v=i+a/2,y=Math.abs(r*Math.cos(g))+Math.abs(a*Math.sin(g)),b=Math.cos(g)*y/2,x=Math.sin(g)*y/2,S=e.createLinearGradient(_-b,v-x,_+b,v+x),C=u.slice(m);for(let e=0;e<C.length;e++){let t=C[e].trim(),n=t,r=e/Math.max(1,C.length-1),i=t.match(/\s+([\d.]+%)\s*$/);i&&(r=parseFloat(i[1])/100,n=t.slice(0,t.length-i[0].length).trim());try{S.addColorStop(r,n)}catch{}}return S}function EI(e){return e.webkitTextFillColor&&e.webkitTextFillColor!==`transparent`?e.webkitTextFillColor:e.color}function DI(e,t){e.strokeStyle=t.webkitTextStrokeColor||t.color,e.lineWidth=t.webkitTextStrokeWidth,e.lineJoin=`round`}function OI(e,t,n){let{style:r}=t;e.save(),e.font=NF(r),e.textBaseline=`alphabetic`,e.fontKerning=r.fontKerning===`none`?`none`:`normal`,Number.isFinite(r.letterSpacing)&&r.letterSpacing!==0&&(e.letterSpacing=`${r.letterSpacing}px`),r.wordSpacing&&(e.wordSpacing=`${r.wordSpacing}px`),r.direction===`rtl`&&(e.direction=`rtl`,e.textAlign=`right`);let i=r.webkitBackgroundClip===`text`&&r.backgroundImage&&r.backgroundImage!==`none`,a=r.webkitTextStrokeWidth>0,o=r.webkitTextFillColor===`transparent`||r.color===`transparent`,s=SI(r.textShadow);if(s.length>0){let c=i||!o;for(let o of s)e.save(),e.shadowOffsetX=o.offsetX,e.shadowOffsetY=o.offsetY,e.shadowBlur=o.blur,e.shadowColor=o.color,c&&(e.fillStyle=i&&n?n:EI(r),e.fillText(t.text,t.x,t.y)),a&&(DI(e,r),e.strokeText(t.text,t.x,t.y)),e.restore()}let c=()=>{if(i){if(e.save(),n)e.fillStyle=n;else{let{ascent:n,descent:i}=qF(e,r);e.fillStyle=TI(e,r.backgroundImage,t.x,t.width,t.y-n,n+i)||r.color}e.fillText(t.text,t.x,t.y),e.restore()}else (!o||!a)&&(e.fillStyle=EI(r),e.fillText(t.text,t.x,t.y))},l=()=>{a&&(e.save(),DI(e,r),e.strokeText(t.text,t.x,t.y),e.restore())};dF(r.paintOrder)?(l(),c()):(c(),l());let u=t.width,d=r.fontSize,f=r.textDecorationColor||r.color,p=r.textDecorationStyle||`solid`,m=Math.max(1,d/15),h=r.direction===`rtl`?t.x-u:t.x;if(r.textDecorationLine!==`none`){let{ascent:n}=qF(e,r);e.font=NF(r);let i=e.measureText(`x`).actualBoundingBoxAscent;if(r.textDecorationLine.includes(`underline`)){let n=d*.1;wI(e,h,t.y+n,u,m,p,f)}if(r.textDecorationLine.includes(`line-through`)){let n=-(i*.5);wI(e,h,t.y+n,u,m,p,f)}r.textDecorationLine.includes(`overline`)&&wI(e,h,t.y-n,u,m,p,f)}e.restore()}function kI(e,t){let{style:n}=t;GF(n.backgroundColor)||(e.fillStyle=n.backgroundColor,e.fillRect(t.x,t.y,t.width,t.height));let r=[[`Top`,t.x,t.y+n.borderTopWidth/2,t.x+t.width,t.y+n.borderTopWidth/2],[`Right`,t.x+t.width-n.borderRightWidth/2,t.y,t.x+t.width-n.borderRightWidth/2,t.y+t.height],[`Bottom`,t.x,t.y+t.height-n.borderBottomWidth/2,t.x+t.width,t.y+t.height-n.borderBottomWidth/2],[`Left`,t.x+n.borderLeftWidth/2,t.y,t.x+n.borderLeftWidth/2,t.y+t.height]];for(let[t,i,a,o,s]of r)CI(n,t)&&(e.strokeStyle=n[`border${t}Color`],e.lineWidth=n[`border${t}Width`],e.beginPath(),e.moveTo(i,a),e.lineTo(o,s),e.stroke());let i=null;n.webkitBackgroundClip===`text`&&n.backgroundImage&&n.backgroundImage!==`none`&&(i=TI(e,n.backgroundImage,t.x,t.width,t.y,t.height));for(let n of t.children)AI(e,n,i)}function AI(e,t,n){t.type===`text`?OI(e,t,n):kI(e,t)}function jI(e){let{html:t,width:n,height:r,accuracy:i=`performance`,debug:a}=e;if(!n||n<=0||Number.isNaN(n))throw TypeError(`layout: width must be a positive number, got ${n}`);let o=i===`balanced`,{fragment:s,css:c}=eF(t),{tree:l,cleanup:u}=CF(s,c,n),d=document.createElement(`canvas`).getContext(`2d`);d.fontKerning=`normal`;let{root:f,height:p,lines:m}=bI(d,l,n,o,a),h=r||p;return u(),{layoutRoot:f,height:h,lines:m}}function MI(e){let{layout:t,width:n,pixelRatio:r=globalThis.devicePixelRatio??1}=e;if(e.ctx&&e.canvas)throw TypeError(`drawLayout: ctx and canvas are mutually exclusive — provide one or neither`);let i=t.height,a,o;return e.ctx?(o=e.ctx,a=e.ctx.canvas):(a=e.canvas??document.createElement(`canvas`),a.width=Math.ceil(n*r),a.height=Math.ceil(i*r),`style`in a&&(a.style.width=`${n}px`,a.style.height=`${i}px`),o=a.getContext(`2d`),o.scale(r,r)),AI(o,t.layoutRoot),{canvas:a}}var NI=/[MmLlHhVvCcSsQqTtAaZz]/,PI=/-?(?:\d+\.\d+|\d+\.|\.\d+|\d+)(?:[eE][-+]?\d+)?/g;function FI(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(NI.test(r)){let i=n+1;for(;i<e.length&&!NI.test(e[i]);)i++;let a=e.slice(n+1,i),o=[],s;for(PI.lastIndex=0;s=PI.exec(a);)o.push(Number(s[0]));t.push({cmd:r,args:o}),n=i}else n++}return t}function II(e){let t=FI(e),n=[],r=0,i=0,a=0,o=0,s=null,c=null;for(let e of t){let t=e.cmd,l=t.toUpperCase(),u=t!==l,d=e.args,f=e=>u?r+e:e,p=e=>u?i+e:e,m=!0,h=!0;switch(l){case`M`:for(let e=0;e<d.length;e+=2){let t=u&&e>0?r+d[e]:f(d[e]),s=u&&e>0?i+d[e+1]:p(d[e+1]);e===0?(r=t,i=s,a=t,o=s):(n.push({type:`L`,x0:r,y0:i,x1:t,y1:s}),r=t,i=s)}break;case`L`:for(let e=0;e<d.length;e+=2){let t=f(d[e]),a=p(d[e+1]);n.push({type:`L`,x0:r,y0:i,x1:t,y1:a}),r=t,i=a}break;case`H`:for(let e=0;e<d.length;e++){let t=u?r+d[e]:d[e];n.push({type:`L`,x0:r,y0:i,x1:t,y1:i}),r=t}break;case`V`:for(let e=0;e<d.length;e++){let t=u?i+d[e]:d[e];n.push({type:`L`,x0:r,y0:i,x1:r,y1:t}),i=t}break;case`C`:for(let e=0;e<d.length;e+=6){let t=f(d[e]),a=p(d[e+1]),o=f(d[e+2]),c=p(d[e+3]),l=f(d[e+4]),u=p(d[e+5]);n.push({type:`C`,x0:r,y0:i,c1x:t,c1y:a,c2x:o,c2y:c,x1:l,y1:u}),s={x:o,y:c},r=l,i=u}m=!1;break;case`S`:for(let e=0;e<d.length;e+=4){let t=s?2*r-s.x:r,a=s?2*i-s.y:i,o=f(d[e]),c=p(d[e+1]),l=f(d[e+2]),u=p(d[e+3]);n.push({type:`C`,x0:r,y0:i,c1x:t,c1y:a,c2x:o,c2y:c,x1:l,y1:u}),s={x:o,y:c},r=l,i=u}m=!1;break;case`Q`:for(let e=0;e<d.length;e+=4){let t=f(d[e]),a=p(d[e+1]),o=f(d[e+2]),s=p(d[e+3]);n.push({type:`Q`,x0:r,y0:i,cx:t,cy:a,x1:o,y1:s}),c={x:t,y:a},r=o,i=s}h=!1;break;case`T`:for(let e=0;e<d.length;e+=2){let t=c?2*r-c.x:r,a=c?2*i-c.y:i,o=f(d[e]),s=p(d[e+1]);n.push({type:`Q`,x0:r,y0:i,cx:t,cy:a,x1:o,y1:s}),c={x:t,y:a},r=o,i=s}h=!1;break;case`A`:for(let e=0;e<d.length;e+=7){let t=d[e],a=d[e+1],o=d[e+2],s=d[e+3]!==0,c=d[e+4]!==0,l=f(d[e+5]),u=p(d[e+6]);t===0||a===0?(r!==l||i!==u)&&n.push({type:`L`,x0:r,y0:i,x1:l,y1:u}):r===l&&i===u||n.push({type:`A`,x0:r,y0:i,rx:t,ry:a,xAxisRotation:o,largeArc:s,sweep:c,x1:l,y1:u}),r=l,i=u}break;case`Z`:(r!==a||i!==o)&&n.push({type:`L`,x0:r,y0:i,x1:a,y1:o}),r=a,i=o;break;default:break}m&&(s=null),h&&(c=null)}return n}function LI(e,t){let n=1-t,r=n*n,i=t*t;return{x:n*r*e.x0+3*r*t*e.c1x+3*n*i*e.c2x+i*t*e.x1,y:n*r*e.y0+3*r*t*e.c1y+3*n*i*e.c2y+i*t*e.y1}}function RI(e,t){let n=1-t;return{x:n*n*e.x0+2*n*t*e.cx+t*t*e.x1,y:n*n*e.y0+2*n*t*e.cy+t*t*e.y1}}function zI(e){let t=Math.abs(e.rx),n=Math.abs(e.ry),r=e.xAxisRotation*Math.PI/180,i=Math.cos(r),a=Math.sin(r),o=(e.x0-e.x1)/2,s=(e.y0-e.y1)/2,c=i*o+a*s,l=-a*o+i*s,u=c*c/(t*t)+l*l/(n*n);if(u>1){let e=Math.sqrt(u);t*=e,n*=e}let d=e.largeArc===e.sweep?-1:1,f=t*t*n*n-t*t*l*l-n*n*c*c,p=t*t*l*l+n*n*c*c,m=Math.sqrt(Math.max(0,f/p)),h=d*m*(t*l/n),g=d*m*(-(n*c)/t),_=i*h-a*g+(e.x0+e.x1)/2,v=a*h+i*g+(e.y0+e.y1)/2,y=(e,t,n,r)=>{let i=e*n+t*r,a=Math.sqrt((e*e+t*t)*(n*n+r*r)),o=Math.acos(Math.min(1,Math.max(-1,i/a)));return e*r-t*n<0&&(o=-o),o},b=y(1,0,(c-h)/t,(l-g)/n),x=y((c-h)/t,(l-g)/n,(-c-h)/t,(-l-g)/n);return x%=2*Math.PI,!e.sweep&&x>0?x-=2*Math.PI:e.sweep&&x<0&&(x+=2*Math.PI),{cx:_,cy:v,rx:t,ry:n,phi:r,theta1:b,deltaTheta:x,cosPhi:i,sinPhi:a}}function BI(e,t){let{cx:n,cy:r,rx:i,ry:a,cosPhi:o,sinPhi:s,theta1:c,deltaTheta:l}=zI(e),u=c+t*l,d=i*Math.cos(u),f=a*Math.sin(u);return{x:o*d-s*f+n,y:s*d+o*f+r}}var VI=40;function HI(e){let t=[],n=0;for(let r of e){if(r.type===`L`){let e=Math.hypot(r.x1-r.x0,r.y1-r.y0);t.push({startLen:n,length:e,seg:r}),n+=e;continue}let e=[],i=0,a;a=r.type===`C`||r.type===`Q`?{x:r.x0,y:r.y0}:BI(r,0),e.push({t:0,len:0});for(let t=1;t<=VI;t++){let n=t/VI,o;o=r.type===`C`?LI(r,n):r.type===`Q`?RI(r,n):BI(r,n),i+=Math.hypot(o.x-a.x,o.y-a.y),e.push({t:n,len:i}),a=o}t.push({startLen:n,length:i,seg:r,samples:e}),n+=i}function r(e){if(!Number.isFinite(e)||e<0||e>n+1e-6)return null;if(e===0&&t.length>0){let e=t[0].seg;return e.type===`L`||e.type===`C`||e.type===`Q`?{x:e.x0,y:e.y0}:BI(e,0)}for(let n=0;n<t.length;n++){let r=t[n];if(e>r.startLen+r.length+1e-6)continue;let i=e-r.startLen;if(r.seg.type===`L`){let e=r.length===0?0:Math.max(0,Math.min(1,i/r.length));return{x:r.seg.x0+(r.seg.x1-r.seg.x0)*e,y:r.seg.y0+(r.seg.y1-r.seg.y0)*e}}let a=r.samples,o=0,s=a.length-1;for(;s-o>1;){let e=o+s>>1;a[e].len<=i?o=e:s=e}let c=a[o],l=a[s],u=l.len-c.len,d=u===0?0:(i-c.len)/u,f=Math.max(0,Math.min(1,c.t+(l.t-c.t)*d));return r.seg.type===`C`?LI(r.seg,f):r.seg.type===`Q`?RI(r.seg,f):BI(r.seg,f)}return null}return{length:n,getPointAtLength:r}}function UI(e){return HI(II(e))}var WI;function GI(){if(WI!==void 0)return WI;if(typeof Intl<`u`&&typeof Intl.Segmenter==`function`)try{WI=new Intl.Segmenter(void 0,{granularity:`grapheme`})}catch{WI=null}else WI=null;return WI}function KI(e){if(!e)return[];let t=GI();if(t){let n=[];for(let r of t.segment(e))n.push(r.segment);return n}return Array.from(e)}function qI(e,t,n){switch(e){case`alphabetic`:return 0;case`middle`:return(t-n)/2;case`top`:return t;case`bottom`:return-n;case`hanging`:return t*.8;case`ideographic`:return-n*.5}}function JI(e){let t=[];function n(e,r){let i=e.style.direction===`rtl`||r;if(e.tagName===`#text`&&e.textContent){t.push({text:e.textContent,style:e.style,rtl:i});return}for(let t of e.children)n(t,i)}return n(e,!1),t}var YI=RegExp(`[\\u0590-\\u05FF\\u0600-\\u06FF\\u0700-\\u074F\\u0750-\\u077F\\u0780-\\u07BF\\u07C0-\\u07FF\\u0800-\\u083F\\u0840-\\u085F\\u0860-\\u086F\\u08A0-\\u08FF\\u0900-\\u097F\\u0980-\\u09FF\\u0A00-\\u0A7F\\u0A80-\\u0AFF\\u0B00-\\u0B7F\\u0B80-\\u0BFF\\u0C00-\\u0C7F\\u0C80-\\u0CFF\\u0D00-\\u0D7F\\u0D80-\\u0DFF\\u0E00-\\u0E7F\\u0E80-\\u0EFF\\u0F00-\\u0FFF\\u1000-\\u109F\\u1780-\\u17FF\\u1800-\\u18AF\\uFB1D-\\uFB4F\\uFB50-\\uFDFF\\uFE70-\\uFEFF]`);function XI(e){return YI.test(e)}function ZI(e,t){let n=KI(t.text);if(n.length===0)return[];AF(e,t.style),e.letterSpacing=`${t.style.letterSpacing||0}px`;let{ascent:r,descent:i}=qF(e,t.style),a=[],o=``;for(let e of n){let t=e===` `;XI(e)&&!t?o+=e:(o&&=(a.push({text:o,shaped:!0,isSpace:!1}),``),a.push({text:e,shaped:!1,isSpace:t}))}o&&a.push({text:o,shaped:!0,isSpace:!1}),t.rtl&&a.reverse();let s=[];for(let n of a){let a=e.measureText(n.text).width;s.push({text:n.text,width:a,style:t.style,isSpace:n.isSpace,ascent:r,descent:i,shaped:n.shaped})}return s}function QI(e){let{segments:t,path:n,ctx:r,align:i,textBaseline:a}=e,o=[],s=0,c=0;for(let e of t){if(!e.text)continue;let t=e.style.lineHeight>0?e.style.lineHeight:e.style.fontSize;t>c&&(c=t);let n=ZI(r,e);n.length!==0&&(o.push(...n),s+=r.measureText(e.text).width)}let l=0;for(let e of o)l+=e.width+(e.style.letterSpacing||0);o.length>0&&(l-=o[o.length-1].style.letterSpacing||0);let u=Math.max(0,l-s),d=n.length,f=0,p=0;if(i===`center`)f=Math.max(0,(d-l)/2);else if(i===`right`)f=Math.max(0,d-l);else if(i===`justify`){let e=o.filter(e=>e.isSpace).length;e>0&&d>l&&(p=(d-l)/e)}let m=[],h=f,g=0;for(let e=0;e<o.length;e++){let t=o[e],r=t.width+(t.isSpace?p:0),i=n.getPointAtLength(h);if(!i)break;let a=h+r,s;if(a>d)if(a-d<=u+.5)s=n.getPointAtLength(d);else break;else s=n.getPointAtLength(a);if(!s)break;let c=Math.atan2(s.y-i.y,s.x-i.x);m.push({char:t.text,x:i.x,y:i.y,rotation:c,width:t.width,style:t.style,ascent:t.ascent,descent:t.descent,pathOffset:g,shaped:t.shaped}),h=a+(t.style.letterSpacing||0),g+=t.width+(t.style.letterSpacing||0)}let _=$I(m,a);return{glyphs:m,textWidth:l,pathLength:d,lineHeight:c,bounds:_,textBaseline:a}}function $I(e,t){if(e.length===0)return{x:0,y:0,width:0,height:0};let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let o of e){let e=o.style.lineHeight>0?o.style.lineHeight:o.style.fontSize,s=o.ascent+o.descent,c=s>0?o.ascent/s:.75,l=e*c,u=e*(1-c),d=qI(t,o.ascent,o.descent),f=d-l,p=d+u,m=Math.cos(o.rotation),h=Math.sin(o.rotation),g=[{x:o.x+-h*f,y:o.y+m*f},{x:o.x+m*o.width+-h*f,y:o.y+h*o.width+m*f},{x:o.x+m*o.width+-h*p,y:o.y+h*o.width+m*p},{x:o.x+-h*p,y:o.y+m*p}];for(let e of g)e.x<n&&(n=e.x),e.y<r&&(r=e.y),e.x>i&&(i=e.x),e.y>a&&(a=e.y)}return{x:n,y:r,width:i-n,height:a-r}}function eL(e){let{html:t,align:n=`left`,textBaseline:r=`alphabetic`}=e,i=typeof e.path==`string`?UI(e.path):e.path,a=e.ctx??nL(),o=e.ctx===void 0,{fragment:s,css:c}=eF(t),{tree:l,cleanup:u}=CF(s,c,2**53-1);o||a.save();try{return QI({segments:JI(l),path:i,ctx:a,align:n,textBaseline:r})}finally{o||a.restore(),u()}}function tL(e){let{layout:t,ctx:n}=e;if(t.glyphs.length===0)return;let r=t.textBaseline;n.save();try{aL(n,t.glyphs,r),cL(n,t.glyphs,t.textWidth,r),dL(n,t.glyphs,r)}finally{n.restore()}}function nL(){return(typeof OffscreenCanvas<`u`?new OffscreenCanvas(1,1):document.createElement(`canvas`)).getContext(`2d`)}var rL=new WeakMap;function iL(e,t){if(!t)return``;let n=rL.get(e);n||(n=new Map,rL.set(e,n));let r=n.get(t);if(r!==void 0)return r;let i=e.fillStyle;try{e.fillStyle=t;let r=typeof e.fillStyle==`string`?e.fillStyle:t;return n.set(t,r),r}catch{return n.set(t,t),t}finally{e.fillStyle=i}}function aL(e,t,n){let r=0;for(;r<t.length;){let i=t[r].style.backgroundColor;if(!i||GF(i)){r++;continue}let a=iL(e,i),o=r+1;for(;o<t.length&&iL(e,t[o].style.backgroundColor)===a;)o++;sL(e,t.slice(r,o),i,n),r=o}}function oL(e,t){let n=Math.cos(e.rotation),r=Math.sin(e.rotation),i=qI(t,e.ascent,e.descent),a=i-e.ascent,o=i+e.descent,s=e.width;return{tl:{x:e.x+-r*a,y:e.y+n*a},tr:{x:e.x+n*s+-r*a,y:e.y+r*s+n*a},br:{x:e.x+n*s+-r*o,y:e.y+r*s+n*o},bl:{x:e.x+-r*o,y:e.y+n*o}}}function sL(e,t,n,r){if(t.length===0)return;e.save(),e.fillStyle=n,e.beginPath();let i=oL(t[0],r);e.moveTo(i.tl.x,i.tl.y);for(let n=0;n<t.length;n++){let i=oL(t[n],r);e.lineTo(i.tl.x,i.tl.y),e.lineTo(i.tr.x,i.tr.y)}for(let n=t.length-1;n>=0;n--){let i=oL(t[n],r);e.lineTo(i.br.x,i.br.y),e.lineTo(i.bl.x,i.bl.y)}e.closePath(),e.fill(),e.restore()}function cL(e,t,n,r){for(let i of t){e.save(),e.translate(i.x,i.y),e.rotate(i.rotation),AF(e,i.style),e.textBaseline=`alphabetic`,e.letterSpacing=`${i.style.letterSpacing||0}px`;let t=qI(r,i.ascent,i.descent),a=SI(i.style.textShadow);if(a.length>0)for(let n=a.length-1;n>=0;n--){let r=a[n];e.save(),e.shadowOffsetX=r.offsetX,e.shadowOffsetY=r.offsetY,e.shadowBlur=r.blur,e.shadowColor=r.color,e.fillStyle=pL(i.style),e.fillText(i.char,0,t),e.restore()}lL(e,i,n,t),e.restore()}}function lL(e,t,n,r){let{style:i}=t,a=i.webkitTextFillColor===`transparent`||i.color===`transparent`||GF(pL(i)),o=i.webkitTextStrokeWidth>0,s=i.webkitBackgroundClip===`text`&&i.backgroundImage&&i.backgroundImage!==`none`,c=dF(i.paintOrder||``),l=()=>{if(s){uL(e,t,n,r);return}if(a){if(o)return;e.fillStyle=`transparent`,e.fillText(t.char,0,r);return}e.fillStyle=pL(i),e.fillText(t.char,0,r)},u=()=>{o&&(e.save(),e.lineJoin=`round`,e.lineWidth=i.webkitTextStrokeWidth,e.strokeStyle=i.webkitTextStrokeColor||i.color,e.strokeText(t.char,0,r),e.restore())};c?(u(),l()):(l(),u())}function uL(e,t,n,r){let i=TI(e,t.style.backgroundImage,-t.pathOffset,n,r-t.ascent,t.ascent+t.descent);if(!i){e.fillStyle=pL(t.style),e.fillText(t.char,0,r);return}e.fillStyle=i,e.fillText(t.char,0,r)}function dL(e,t,n){for(let r of[`underline`,`line-through`,`overline`]){let i=0;for(;i<t.length;){let a=t[i].style;if(!a.textDecorationLine||!a.textDecorationLine.includes(r)){i++;continue}let o=a.textDecorationColor||a.color,s=a.textDecorationStyle||`solid`,c=iL(e,o),l=i+1;for(;l<t.length&&t[l].style.textDecorationLine&&t[l].style.textDecorationLine.includes(r)&&iL(e,t[l].style.textDecorationColor||t[l].style.color)===c&&(t[l].style.textDecorationStyle||`solid`)===s;)l++;fL(e,t.slice(i,l),r,s,o,n),i=l}}}function fL(e,t,n,r,i,a){if(t.length===0)return;let o=Math.max(1,t[0].style.fontSize/15),s=e=>{let t=qI(a,e.ascent,e.descent);return n===`underline`?t+e.descent*.5:n===`line-through`?t-e.ascent*.3:t-e.ascent*.9};if(r===`double`||r===`wavy`){for(let n of t)e.save(),e.translate(n.x,n.y),e.rotate(n.rotation),wI(e,0,s(n),n.width,o,r,i),e.restore();return}e.save(),e.strokeStyle=i,e.lineWidth=o,r===`dotted`?e.setLineDash([o,o*2]):r===`dashed`&&e.setLineDash([o*3,o*2]),e.beginPath();for(let n=0;n<t.length;n++){let r=t[n],i=s(r),a=Math.cos(r.rotation),o=Math.sin(r.rotation),c={x:r.x+-o*i,y:r.y+a*i},l={x:r.x+a*r.width+-o*i,y:r.y+o*r.width+a*i};n===0?e.moveTo(c.x,c.y):e.lineTo(c.x,c.y),e.lineTo(l.x,l.y)}e.stroke(),e.setLineDash([]),e.restore()}function pL(e){return e.webkitTextFillColor&&e.webkitTextFillColor!==`transparent`?e.webkitTextFillColor:e.color}var mL=`<style>${Hy}\n/* render-tag draws list markers natively from the <ol>/<ul> tag + tree position\n (it ignores the polotno reset's ::before + counter() markers, which only work\n in real DOM — the Quill editor and the foreignObject rasterizer). The shared\n reset sets list-style:none for those ::before markers, which would suppress\n render-tag's native ones; restore the canonical marker types here so render-tag\n paints them. element.text is canonicalized to <ul>/<ol> upstream\n (normalizeRichTextHtml), so the tag alone selects bullet vs. number. */\nol { list-style-type: decimal; }\nul { list-style-type: disc; }\n/* Chrome's <code>/<pre> font-size UA quirk isn't reproducible on canvas — let\n them inherit so DOM and canvas line up. */\ncode, pre, kbd, samp { font-size: inherit; }</style>`;function hL(e){return mL+e}var gL=wa(({element:e,store:t})=>{let n=b.useRef(null),r=b.useRef(null),[i,a]=b.useState(!1),o=b.useRef(e.height),s=e.isSelected,c=eS(s),{textVerticalResizeEnabled:l}=h_,u=h_.autoDeleteEmptyText,d=eS(e.fontFamily),f=b.useMemo(()=>hv(e.text,{fontSize:e.fontSize,fontFamily:e.fontFamily}),[e.text,e.fontSize,e.fontFamily]),[p]=Qx(t,b.useMemo(()=>[...new Set([e.fontFamily,..._v(f)])].filter(Boolean),[e.fontFamily,f]),e.fontStyle,e.fontWeight,e.text||e.placeholder),m=e._editModeEnabled;G_(n);let h=p?e.fontFamily:d&&d!==e.fontFamily?d:`Arial`,g=Cx(e).fill,_=sy(e.fill),v=sy(e.stroke)&&!!e.strokeWidth,y=!!e.strokeWidth&&(v||_),x=Lx(e,{fontFamily:h,color:g,forEditor:!(h_.textOverflow===`ellipsis`&&!e.curveEnabled&&e.height&&!y)}),C=e.width||1,w=e.curveEnabled,T=function(e,t,n,r){return b.useMemo(()=>{if(r)return null;try{return jI({html:hL(e),width:Math.max(1,t),accuracy:`performance`})}catch(e){return console.error(`render-tag layout failed:`,e),null}},[e,t,n,r])}(x,C,p,w),E=function(e,t,n){return b.useMemo(()=>{if(!t.curveEnabled)return null;let n=kx(t.width||1,Px(t),t.curvePower,t.fontSize);try{return eL({html:hL(e),path:n,align:`center`,textBaseline:`middle`})}catch(e){return console.error(`render-tag/path layoutTextOnPath failed:`,e),null}},[n,t.curveEnabled,t.curvePower,t.fontSize,t.width,t.height,e])}(x,e,p),D=$x({fontLoaded:p,fontFamily:e.fontFamily,fontSize:e.fontSize,lineHeight:e.lineHeight}),O=w?0:Math.max(T?.height??0,e.fontSize*D),k=E?E.bounds:null,ee=b.useMemo(()=>T?T.lines.map(e=>({left:e.bounds.x,right:e.bounds.x+e.bounds.width,top:e.bounds.y,bottom:e.bounds.y+e.bounds.height})):[],[T]),A=b.useRef([]),j=b.useRef(!0),[,te]=b.useReducer(e=>e+1,0);b.useEffect(()=>{let e=A.current;e.length>0&&(A.current=[],e.forEach(e=>e()))});let M=b.useCallback((n,r,i,a)=>{let o=$_(`text ${e.id}`),s=()=>{t.history.ignore(n,r,i).then(()=>{j.current?(A.current.push(o),te()):o()})};a?queueMicrotask(s):s()},[e.id,t]);b.useEffect(()=>{if(!p||!T)return;if(!e.height){M(()=>{Hp(e)&&(e.height||e.set({height:O}))},void 0,void 0,!0);return}if(t.isPlaying)return;let{textOverflow:n}=h_,r=e.height!==O&&(!l||e.height<O),a=()=>M(()=>{Hp(e)&&e.set({height:O})},!1,!0);if(n!==`change-font-size`||i||m||e.curveEnabled)n===`resize`&&r&&!i&&a();else{let t=jC(e,{fontFamily:h,color:g,forEditor:!0},e=>{try{return jI({html:hL(e),width:C,accuracy:`performance`}).height}catch{return kS(e).height}});t.fontSize===e.fontSize?r&&a():M(()=>{if(!Hp(e))return;let n={fontSize:t.fontSize};t.text!==void 0&&t.text!==e.text&&(n.text=t.text),e.set(n)},!1,!0)}}),b.useEffect(()=>()=>{j.current=!1;let e=A.current;e.length>0&&(A.current=[],e.forEach(e=>e()))},[]),b.useLayoutEffect(()=>{if(!p||!e.curveEnabled||i||!k||!k.width)return;let t=e=>e&&l?Math.max(e,k.height):k.height;Math.abs(k.width-e.width)<1&&Math.abs(t(e.height)-e.height)<1||M(()=>{if(!Hp(e))return;let n=k.width-e.width,r=t(e.height),i=r-e.height;if(Math.abs(n)<1&&Math.abs(i)<1)return;let a=e.a.rotation*Math.PI/180,o=-n/2*Math.cos(a),s=-n/2*Math.sin(a);e.set({width:k.width,height:r,x:e.a.x+o,y:e.a.y+s})},!1,!0,!0)},[p,e.curveEnabled,k,i,l,M]),b.useEffect(()=>{c&&!s&&u&&Sv(e.text)===``&&e.removable&&!e.placeholder&&t.deleteElements([e.id])},[u,e.placeholder,e.removable,e.text,s,c]),b.useEffect(()=>cr(()=>{let t=n.current;t&&Bx(t,e)}),[T,E,e.a.width,e.a.height,e.shadowColor,e.shadowOffsetX,e.shadowOffsetY,e.shadowOpacity]);let ne=0;w||e.verticalAlign!==`middle`?w||e.verticalAlign!==`bottom`||(ne=e.height-O):ne=(e.height-O)/2;let N=e.backgroundPadding*(e.fontSize*D*.5),P=e.backgroundCornerRadius*(e.fontSize*D*.5),re=b.useMemo(()=>!e.backgroundEnabled||e.curveEnabled||e.legacyBackground||ee.length===0?``:xx({rects:ee,padding:N,cornerRadius:P}),[e.backgroundEnabled,e.curveEnabled,e.legacyBackground,ee,N,P]),ie=Vx(),ae=b.useRef(null),F=b.useRef(null),oe=b.useRef(null),se=b.useRef(0),ce=b.useRef(0),le=m&&e.strokeWidth>0&&!e.curveEnabled,ue=e.width>0?e.a.width/e.width:1;return(0,S.jsxs)(S.Fragment,{children:[e.curveEnabled||e.legacyBackground?(0,S.jsx)(Nf,{x:e.a.x,y:e.a.y,offsetX:N/ue,offsetY:N/ue,rotation:e.a.rotation,scaleX:ue,scaleY:ue,hideInExport:!e.showInExport,listening:!1,visible:e.backgroundEnabled,opacity:e.backgroundOpacity*e.a.opacity,fill:e.backgroundColor,width:e.width+2*N,height:e.height+2*N,cornerRadius:P}):(0,S.jsx)(Rf,{name:`rendertag-background`,x:e.a.x,y:e.a.y,offsetY:-ne/ue,rotation:e.a.rotation,scaleX:ue,scaleY:ue,hideInExport:!e.showInExport,listening:!1,visible:e.backgroundEnabled&&re.length>0,opacity:e.backgroundOpacity*e.a.opacity,fill:e.backgroundColor,data:re}),(0,S.jsx)(zf,{ref:n,name:`rendertag-text`,x:e.a.x,y:e.a.y,rotation:e.a.rotation,scaleX:ue,scaleY:ue,offsetY:ue>0?-ne/ue:0,width:e.width,height:Math.max(e.height,O),listening:!1,visible:(!m||le)&&!!(w?E:T),opacity:e.a.opacity,shadowEnabled:e.shadowEnabled,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY,shadowColor:e.shadowColor,shadowOpacity:e.shadowOpacity,hideInExport:!e.showInExport,sceneFunc:(t,n)=>{let r=t._context;if(r)try{if(w){if(!E||!k)return;let t=(e.width-k.width)/2-k.x;r.save(),r.translate(t,-k.y),tL({layout:E,ctx:r}),r.restore()}else{if(!T)return;MI({layout:T,width:C,ctx:r,pixelRatio:1})}}catch(e){console.error(`render-tag draw failed:`,e)}}}),(0,S.jsx)(Nf,{ref:r,name:`element`,x:e.a.x,y:e.a.y,listening:e.selectable,rotation:e.a.rotation,width:e.a.width,height:e.a.height,visible:!m,draggable:ie?e.draggable&&s:e.draggable,preventDefault:!ie||s,opacity:0,hideInExport:!0,id:e.id,onDragMove:t=>{e.set({x:t.target.x(),y:t.target.y()})},onDragEnd:t=>{e.set({x:t.target.x(),y:t.target.y()})},onDblClick:t=>{e.contentEditable&&(F.current={x:t.evt.clientX,y:t.evt.clientY},e.toggleEditMode(!0))},onDblTap:t=>{if(e.contentEditable){let n=t.evt.changedTouches?.[0];F.current=n?{x:n.clientX,y:n.clientY}:null,e.toggleEditMode(!0)}},onTransformStart:t=>{a(!0),o.current=e.height,oe.current=(t.target.getStage()?.findOne(`Transformer`))?.getActiveAnchor()??null,se.current=e.a.rotation,ce.current=e.height},onTransform:t=>{let n=t.target,r=(n.getStage()?.findOne(`Transformer`)).getActiveAnchor(),i=r===`middle-left`||r===`middle-right`,a=r===`top-center`||r===`bottom-center`,s=n.scaleX();if(i){let t=n.scaleX(),r=n.width()*t,i=e.fontSize,a=r;r<i&&(a=i,ae.current&&n.position(ae.current)),n.width(a),n.scaleX(1),n.scaleY(1);let s=0;if(e.curveEnabled)s=Px(Object.assign(Object.assign({},e.toJSON()),{width:a}));else{let t=Lx(Object.assign(Object.assign({},e.toJSON()),{width:a}),{fontFamily:h,color:g,forEditor:!0});try{s=jI({html:hL(t),width:a,accuracy:`performance`}).height}catch{s=kS(t).height}}let c=h_.textVerticalResizeEnabled?Math.max(s,o.current):s;h_.textOverflow===`ellipsis`&&(c=o.current),n.height(c),e.set({width:n.width(),height:c,x:n.x(),y:n.y()})}else if(a){let t=h_.textOverflow===`resize`?w?k?.height||e.fontSize:O:D*e.fontSize,r=n.height()*n.scaleY();if(r<t){if(n.height(t),ae.current)if(oe.current===`top-center`){let e=se.current*Math.PI/180,r=ce.current-t;n.x(ae.current.x-r*Math.sin(e)),n.y(ae.current.y+r*Math.cos(e))}else n.position(ae.current)}else n.height(r);n.scaleY(1),n.scaleX(1),ce.current=Math.max(t,r),e.set({x:n.x(),y:n.y(),height:n.height(),rotation:n.rotation()})}else n.scaleX(1),n.scaleY(1),e.set({fontSize:e.fontSize*s,letterSpacing:e.letterSpacing,width:n.width()*s,x:n.x(),y:n.y(),rotation:n.rotation(),height:n.height()*s,text:vv(e.text,s)});ae.current=t.target.position()},onTransformEnd:t=>{a(!1);let n=t.target.scaleX();t.target.scaleX(1),t.target.scaleY(1),e.set({fontSize:e.fontSize*n,width:t.target.width()*n,x:t.target.x(),y:t.target.y(),rotation:t.target.rotation(),shadowBlur:e.shadowBlur*n,shadowOffsetX:e.shadowOffsetX*n,shadowOffsetY:e.shadowOffsetY*n,strokeWidth:e.strokeWidth*n,text:vv(e.text,n)})}}),m&&(0,S.jsx)(`Group`,{x:e.a.x,y:e.a.y,rotation:e.a.rotation,offsetY:-ne,children:(0,S.jsx)(ex,{divProps:{style:{zIndex:20}},children:(0,S.jsx)(qP,{element:e,onChange:t=>{let n=Hx({oldText:Sv(e.text),newText:Sv(t),element:e});e.set({text:t,fontSize:n})},onBlur:()=>{Hp(e)&&e.toggleEditMode(!1)},clickCoords:F.current})})})]})}),_L=({targetKonvaNodes:e,guideKonvaNode:t,distance:n,snapDirection:r})=>n<5;function vL(e,t){var n=[],r=[];e.vertical.forEach(e=>{t.vertical.forEach(t=>{var r=Math.abs(e.offset-t.guide);_L({targetKonvaNodes:t.nodes,guideKonvaNode:e.node,distance:r,snapDirection:e.snap})&&n.push({lineGuide:e.offset,diff:r,snap:t.snap,offset:t.offset})})}),e.horizontal.forEach(e=>{t.horizontal.forEach(t=>{var n=Math.abs(e.offset-t.guide);_L({targetKonvaNodes:t.nodes,guideKonvaNode:e.node,distance:n,snapDirection:e.snap})&&r.push({lineGuide:e.offset,diff:n,snap:t.snap,offset:t.offset})})});var i=[];let a=n.sort((e,t)=>e.diff-t.diff),o=r.sort((e,t)=>e.diff-t.diff);var s=a[0],c=o[0];return s&&a.filter(e=>Math.abs(e.diff-s.diff)<.1).forEach(e=>{i.push(Object.assign({orientation:`V`},e))}),c&&o.filter(e=>Math.abs(e.diff-c.diff)<.1).forEach(e=>{i.push(Object.assign({orientation:`H`},e))}),i}var yL=()=>{if(W.DD._dragElements.size===0)return;let e=[...W.DD._dragElements.entries()],t=e.find(([e,t])=>t.node instanceof W.Transformer);t&&(e.splice(e.indexOf(t),1),e.unshift(t),W.DD._dragElements.clear(),e.forEach(([e,t])=>{W.DD._dragElements.set(e,t)}))};function bL(e,t){let n=b.useRef(null),{snapGuideStyle:r}=up(),i=b.useRef(r);i.current=r;let a=e=>e.hasName(`element`)||e.hasName(`page-background`)||!n.current&&e.hasName(`elements-area`);function o(t){let n=e.current?.getStage(),r=[],i=[];return n.find(a).forEach(e=>{if(!(t.indexOf(e)>=0)){var n=e.getClientRect({skipShadow:!0,skipStroke:!0});r.push({offset:n.x,node:e,snap:`start`},{offset:n.x+n.width,node:e,snap:`end`},{offset:n.x+n.width/2,node:e,snap:`center`}),i.push({offset:n.y,node:e,snap:`start`},{offset:n.y+n.height,node:e,snap:`end`},{offset:n.y+n.height/2,node:e,snap:`center`})}}),{vertical:r,horizontal:i}}function s(t){let n=e.current?.getLayer(),r=n?.children.find(e=>e.name()===`line-guides`);t.forEach(e=>{if(e.orientation===`H`){var t=new W.Line({x:-n.getStage().x(),y:-n.getStage().y(),points:[-6e3,e.lineGuide,6e3,e.lineGuide],stroke:i.current.stroke,strokeWidth:i.current.strokeWidth,name:`guid-line`,dash:i.current.dash});r?.add(t),n.batchDraw()}else e.orientation===`V`&&(t=new W.Line({x:-n.getStage().x(),y:-n.getStage().y(),points:[e.lineGuide,-6e3,e.lineGuide,6e3],stroke:i.current.stroke,strokeWidth:i.current.strokeWidth,name:`guid-line`,dash:i.current.dash}),r?.add(t))})}let c=e=>{e.target.getLayer().children.find(e=>e.name()===`line-guides`)?.destroyChildren();var t=vL(o(e.target.nodes()),function(e){let t=e.__getNodeRect(),n=Yy(Object.assign(Object.assign({},t),{rotation:W.Util.radToDeg(t.rotation)})),r=e.getAbsolutePosition();return{vertical:[{guide:n.x,offset:r.x-n.x,snap:`start`,nodes:e.nodes()},{guide:n.x+n.width/2,offset:r.x-n.x-n.width/2,snap:`center`,nodes:e.nodes()},{guide:n.x+n.width,offset:r.x-n.x-n.width,snap:`end`,nodes:e.nodes()}],horizontal:[{guide:n.y,offset:r.y-n.y,snap:`start`,nodes:e.nodes()},{guide:n.y+n.height/2,offset:r.y-n.y-n.height/2,snap:`center`,nodes:e.nodes()},{guide:n.y+n.height,offset:r.y-n.y-n.height,snap:`end`,nodes:e.nodes()}]}}(e.target));if(!t.length)return;s(t);let n=e.target.getAbsolutePosition(),r=(e.target.nodes().map(e=>e.getAbsolutePosition()),Object.assign({},n));t.forEach(e=>{switch(e.snap){case`start`:case`center`:case`end`:switch(e.orientation){case`V`:r.x=e.lineGuide+e.offset;break;case`H`:r.y=e.lineGuide+e.offset}}});let i=r.x-n.x,a=r.y-n.y;e.evt.ctrlKey||e.evt.metaKey||e.target.nodes().forEach(e=>{let t=e.getAbsolutePosition();e.setAbsolutePosition({x:t.x+i,y:t.y+a})})},l=(t,n,r)=>{let i=e.current;if(i.getLayer().children.find(e=>e.name()===`line-guides`)?.destroyChildren(),i.getActiveAnchor()===`rotater`)return n;let a=CL[i.getActiveAnchor()],c=i.findOne(`.${a}`)?.getAbsolutePosition();if(!c)return n;let l={x:t.x-c.x,y:t.y-c.y},u=function(e,t){let n=SL(e,t)/SL(t,t);return{x:n*t.x,y:n*t.y}}({x:n.x-t.x,y:n.y-t.y},l);if(Math.sqrt(u.x**2+u.y**2)>5)return n;let d={x:t.x+u.x,y:t.y+u.y};var f=vL(o(i.nodes()),{vertical:[{guide:d.x,offset:0,snap:`start`,nodes:i.nodes()}],horizontal:[{guide:d.y,offset:0,snap:`start`,nodes:i.nodes()}]});if(!f.length||(s(f),r.ctrlKey||r.metaKey))return n;let p=[];if(f.forEach(e=>{let t=function(e,t,n){if(n.orientation===`V`){let r=n.lineGuide;if(Math.abs(t.x-e.x)<1e-4)return null;let i=(t.y-e.y)/(t.x-e.x);return{x:r,y:i*r+(e.y-i*e.x)}}{let r=n.lineGuide;if(Math.abs(t.y-e.y)<1e-4)return null;let i=(t.y-e.y)/(t.x-e.x);return{x:(r-e.y)/i+e.x,y:r}}}(d,c,{orientation:e.orientation,lineGuide:e.lineGuide});t&&p.push(t)}),p.length>0){let e=p[0],t=Math.sqrt((d.x-e.x)**2+(d.y-e.y)**2);if(p.forEach(n=>{let r=Math.sqrt((d.x-n.x)**2+(d.y-n.y)**2);r<t&&(t=r,e=n)}),t<10)return e}return d},u=e=>{if(!e.target)return;let t=e.target.getLayer();t.children.find(e=>e.name()===`line-guides`)?.destroyChildren(),t.batchDraw()};b.useEffect(()=>{e.current&&(e.current.anchorDragBoundFunc(l),e.current.on(`dragstart`,e=>{setTimeout(()=>{yL()})}),e.current.on(`dragmove`,c),e.current.on(`dragend`,u),e.current.on(`transformend`,u),e.current.on(`transform`,t=>{var n,r;t.evt.ctrlKey||t.evt.metaKey?(n=e.current)==null||n.rotationSnapTolerance(0):(r=e.current)==null||r.rotationSnapTolerance(5)}))},[])}function xL(e,t,n){let{snapGuideStyle:r}=up(),i=b.useRef(r);i.current=r;let a=e=>e.hasName(`element`)||e.hasName(`line-anchor`)||e.hasName(`page-background`)||e.hasName(`elements-area`),o=n=>{n.target.getLayer().children.find(e=>e.name()===`line-guides`)?.destroyChildren();var r,o=vL(function(t){let n=e.current?.getStage();var r=[],i=[];return n.find(a).forEach(e=>{if(!(t.indexOf(e)>=0)){var n=e.getClientRect({skipShadow:!0,skipStroke:!0});e.hasName(`line-anchor`)&&(n={x:e.absolutePosition().x,y:e.absolutePosition().y,width:0,height:0}),r.push({offset:n.x,node:e,snap:`start`},{offset:n.x+n.width,node:e,snap:`end`},{offset:n.x+n.width/2,node:e,snap:`center`}),i.push({offset:n.y,node:e,snap:`start`},{offset:n.y+n.height,node:e,snap:`end`},{offset:n.y+n.height/2,node:e,snap:`center`})}}),{vertical:r,horizontal:i}}([n.target,...t.map(e=>e.current)]),{vertical:[{guide:(r=n.target).absolutePosition().x,offset:0,snap:`center`,nodes:[r]}],horizontal:[{guide:r.absolutePosition().y,offset:0,snap:`center`,nodes:[r]}]});if(!o.length)return;(function(t){let n=e.current?.getLayer(),r=n?.children.find(e=>e.name()===`line-guides`);t.forEach(e=>{if(e.orientation===`H`){var t=new W.Line({x:-n.getStage().x(),y:-n.getStage().y(),points:[-6e3,e.lineGuide,6e3,e.lineGuide],stroke:i.current.stroke,strokeWidth:i.current.strokeWidth,name:`guid-line`,dash:i.current.dash});r?.add(t),n.batchDraw()}else e.orientation===`V`&&(t=new W.Line({x:-n.getStage().x(),y:-n.getStage().y(),points:[e.lineGuide,-6e3,e.lineGuide,6e3],stroke:i.current.stroke,strokeWidth:i.current.strokeWidth,name:`guid-line`,dash:i.current.dash}),r?.add(t))})})(o);let s=n.target.getAbsolutePosition(),c=Object.assign({},s);o.forEach(e=>{switch(e.snap){case`start`:case`center`:case`end`:switch(e.orientation){case`V`:c.x=e.lineGuide+e.offset;break;case`H`:c.y=e.lineGuide+e.offset}}});let l=c.x-s.x,u=c.y-s.y;if(!n.evt.ctrlKey&&!n.evt.metaKey){let e=n.target.getAbsolutePosition();n.target.absolutePosition({x:e.x+l,y:e.y+u})}},s=e=>{if(!e.target)return;let t=e.target.getLayer();t.children.find(e=>e.name()===`line-guides`)?.destroyChildren(),t.batchDraw()};b.useEffect(()=>{e.current&&(e.current.on(`dragmove`,o),e.current.on(`dragend`,s))},n)}function SL(e,t){return e.x*t.x+e.y*t.y}var CL={"top-left":`bottom-right`,"top-center":`bottom-center`,"top-right":`bottom-left`,"middle-right":`middle-left`,"bottom-right":`top-left`,"bottom-center":`top-center`,"bottom-left":`top-right`,"middle-left":`middle-right`};function wL(e){let{x:t,y:n,width:r,height:i,rotation:a}=e.a,o=a*Math.PI/180,s={x:t+i/2*Math.cos(o+Math.PI/2),y:n+i/2*Math.sin(o+Math.PI/2)};return{middleLeft:s,middleRight:{x:s.x+r*Math.cos(o),y:s.y+r*Math.sin(o)}}}function TL(e,t,n){let r=Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),i=Math.atan2(t.y-e.y,t.x-e.x),a=180*i/Math.PI;return{x:e.x+Math.cos(i-Math.PI/2)*n/2,y:e.y+Math.sin(i-Math.PI/2)*n/2,width:r,height:n,rotation:a}}var EL=(e,t,n)=>{let r=n.anchorSize;return{offsetX:r/2/e,offsetY:r/2/e,width:r/e,height:r/e,cornerRadius:n.anchorCornerRadius/e,fill:n.anchorFill,stroke:n.anchorStroke,strokeWidth:n.anchorStrokeWidth,strokeScaleEnabled:!1,draggable:!0,dragDistance:0,onMouseEnter:e=>{e.target.getStage().container().style.cursor=`crosshair`},onMouseLeave:e=>{e.target.getStage().container().style.cursor=``},onDragStart:e=>{t.history.startTransaction()},onDragEnd:e=>{t.history.endTransaction()}}},DL=wa(({element:e,type:t})=>{let n=Cx(e,e.a.color,`fill`),r=Cx(e,e.a.color,`stroke`),i=Object.assign(Object.assign(Object.assign({strokeWidth:e.height,lineCap:`round`,lineJoin:`round`},r),n),{opacity:e.a.opacity,hideInExport:!e.showInExport});return(0,S.jsxs)(S.Fragment,{children:[t===`arrow`&&(0,S.jsx)(`Line`,Object.assign({points:[3*e.height,2*-e.height,0,0,3*e.height,2*e.height]},i)),t===`triangle`&&(0,S.jsx)(`Line`,Object.assign({points:[3*e.height,2*-e.height,0,0,3*e.height,2*e.height],closed:!0},i)),t===`bar`&&(0,S.jsx)(`Line`,Object.assign({points:[0,2*-e.height,0,2*e.height],closed:!0},i)),t===`square`&&(0,S.jsx)(`Line`,Object.assign({points:[0,2*-e.height,4*e.height,2*-e.height,4*e.height,2*e.height,0,2*e.height],closed:!0},i)),t===`circle`&&(0,S.jsx)(`Circle`,Object.assign({x:2*e.height,y:0,radius:2*e.height},i))]})}),OL=wa(({element:e,store:t})=>{let{transformerStyle:n}=up(),r=b.useRef(null),i=b.useRef(null),a=b.useRef(null),o=e.selectable||t.role===dC.ADMIN,s=Vx(),c=t.selectedElements.indexOf(e)>=0&&t.selectedElements.length===1,l=e.isSelected,{middleLeft:u,middleRight:d}=wL(e);xL(i,[r],[c]),xL(a,[r],[c]);let f=Cx(e,e.a.color,`stroke`);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Pf,Object.assign({ref:r,name:`element`,id:e.id,x:e.a.x,y:e.a.y,points:[0,0,e.a.width,0],offsetY:-e.a.height/2,strokeWidth:e.a.height,hitStrokeWidth:Math.max(e.a.height,20),dash:e.dash.map(t=>t*e.a.height)},f,{rotation:e.a.rotation,opacity:e.animated(`opacity`),shadowEnabled:e.shadowEnabled,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY,shadowColor:e.shadowColor,shadowOpacity:e.shadowOpacity,listening:o,draggable:s?e.draggable&&l:e.draggable,preventDefault:!s||l,hideInExport:!e.showInExport,onDragMove:t=>{e.set({x:t.target.x(),y:t.target.y()})},onDragEnd:t=>{e.set({x:t.target.x(),y:t.target.y()})},onTransform:t=>{let n=t.target.scaleX();t.target.scaleX(1),t.target.scaleY(1),e.set({height:e.height*n,width:e.width*n,x:t.target.x(),y:t.target.y(),rotation:t.target.rotation()})}})),(0,S.jsx)(jf,{x:u.x,y:u.y,rotation:e.rotation,hideInExport:!e.showInExport,onClick:e=>r.current?.fire(`click`,e),onTap:e=>r.current?.fire(`tap`,e),children:(0,S.jsx)(DL,{element:e,type:e.startHead})}),(0,S.jsx)(jf,{x:d.x,y:d.y,rotation:e.rotation+180,onClick:e=>r.current?.fire(`click`,e),onTap:e=>r.current?.fire(`tap`,e),children:(0,S.jsx)(DL,{element:e,type:e.endHead})}),c&&e.resizable&&(0,S.jsx)(tx,{selector:`.page-abs-container`,enabled:!0,children:(0,S.jsxs)(`Group`,{visible:c,children:[(0,S.jsx)(`Rect`,Object.assign({x:u.x,y:u.y,ref:i,name:`line-anchor`},EL(t.scale,t,n),{onDragMove:t=>{let n=TL(t.target.position(),d,e.height);e.set({x:n.x,y:n.y,width:n.width,rotation:n.rotation})}})),(0,S.jsx)(`Rect`,Object.assign({x:d.x,y:d.y,ref:a,name:`line-anchor`},EL(t.scale,t,n),{onDragMove:t=>{let n=TL(u,t.target.position(),e.height);e.set({x:n.x,y:n.y,width:n.width,rotation:n.rotation})}}))]})})]})});function X(e){if(!e)throw Error(`Assertion failed.`)}var kL=e=>{let t=(e%360+360)%360;if(t===0||t===90||t===180||t===270)return t;throw Error(`Invalid rotation ${e}.`)},AL=e=>e&&e[e.length-1],jL=e=>e>=0&&e<2**32,Z=e=>{let t=0;for(;e.readBits(1)===0&&t<32;)t++;if(t>=32)throw Error(`Invalid exponential-Golomb code.`);return(1<<t)-1+e.readBits(t)},ML=e=>{let t=Z(e);return t&1?t+1>>1:-(t>>1)},NL=e=>e.constructor===Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),PL=e=>e.constructor===DataView?e:ArrayBuffer.isView(e)?new DataView(e.buffer,e.byteOffset,e.byteLength):new DataView(e),FL=new TextDecoder,IL=new TextEncoder,LL=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e])),RL={bt709:1,bt470bg:5,smpte170m:6,bt2020:9,smpte432:12},zL=LL(RL),BL={bt709:1,smpte170m:6,linear:8,"iec61966-2-1":13,pq:16,hlg:18},VL=LL(BL),HL={rgb:0,bt709:1,bt470bg:5,smpte170m:6,"bt2020-ncl":9},UL=LL(HL),WL=e=>!!e&&!!e.primaries&&!!e.transfer&&!!e.matrix&&e.fullRange!==void 0,GL=e=>e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer||ArrayBuffer.isView(e),KL=class{constructor(){this.currentPromise=Promise.resolve(),this.pending=0}async acquire(){let e,t=new Promise(t=>{let n=!1;e=()=>{n||=(t(),this.pending--,!0)}}),n=this.currentPromise;return this.currentPromise=t,this.pending++,await n,e}},qL=/^[0-9a-fA-F]+$/,JL=e=>[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``),YL=e=>{X(e.length%2==0);let t=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)t[n/2]=parseInt(e.slice(n,n+2),16);return t},XL=e=>(e=e>>1&1431655765|(e&1431655765)<<1,e=e>>2&858993459|(e&858993459)<<2,e=e>>4&252645135|(e&252645135)<<4,e=e>>8&16711935|(e&16711935)<<8,e=e>>16&65535|(e&65535)<<16,e>>>0),ZL=(e,t,n)=>{let r=0,i=e.length-1,a=-1;for(;r<=i;){let o=r+i>>1,s=n(e[o]);s===t?(a=o,i=o-1):s<t?r=o+1:i=o-1}return a},QL=(e,t,n)=>{let r=0,i=e.length-1,a=-1;for(;r<=i;){let o=r+(i-r+1)/2|0;n(e[o])<=t?(a=o,r=o+1):i=o-1}return a},$L=(e,t,n)=>{let r=QL(e,n(t),n);e.splice(r+1,0,t)},eR=()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}},tR=(e,t)=>{let n=e.indexOf(t);n!==-1&&e.splice(n,1)},nR=(e,t)=>{for(let n=e.length-1;n>=0;n--)if(t(e[n]))return e[n]},rR=(e,t)=>{for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1},iR=async function*(e){Symbol.iterator in e?yield*e[Symbol.iterator]():yield*e[Symbol.asyncIterator]()},aR=e=>{if(!(Symbol.iterator in e)&&!(Symbol.asyncIterator in e))throw TypeError(`Argument must be an iterable or async iterable.`)},oR=e=>{throw Error(`Unexpected value: ${e}`)},sR=(e,t,n)=>{let r=e.getUint8(t),i=e.getUint8(t+1),a=e.getUint8(t+2);return n?r|i<<8|a<<16:r<<16|i<<8|a},cR=(e,t,n)=>sR(e,t,n)<<8>>8,lR=(e,t,n,r)=>{n>>>=0,n&=16777215,r?(e.setUint8(t,n&255),e.setUint8(t+1,n>>>8&255),e.setUint8(t+2,n>>>16&255)):(e.setUint8(t,n>>>16&255),e.setUint8(t+1,n>>>8&255),e.setUint8(t+2,n&255))},uR=(e,t,n,r)=>{n=fR(n,-8388608,8388607),n<0&&(n=n+16777216&16777215),lR(e,t,n,r)},dR=(e,t)=>({async next(){let n=await e.next();return n.done?{value:void 0,done:!0}:{value:t(n.value),done:!1}},return(){return e.return()},throw(t){return e.throw(t)},[Symbol.asyncIterator](){return this}}),fR=(e,t,n)=>Math.max(t,Math.min(n,e)),pR=e=>{let t=Math.round(e);return Math.abs(e/t-1)<10*2**-52?t:e},mR=(e,t)=>Math.round(e/t)*t,hR=(e,t)=>Math.round(e*t)/t,gR=(e,t)=>Math.floor(e/t)*t,_R=(e,t)=>Math.floor(e*t)/t,vR=e=>{let t=0;for(;e;)t++,e>>=1;return t},yR=/^[a-z]{3}$/,bR=e=>yR.test(e),xR=1e6*(1+2**-52),SR=(e,t)=>{let n={...e,...t};if(e.headers||t.headers){let r=e.headers?CR(e.headers):{},i=t.headers?CR(t.headers):{},a={...r};Object.entries(i).forEach(([e,t])=>{let n=Object.keys(a).find(t=>t.toLowerCase()===e.toLowerCase());n&&delete a[n],a[e]=t}),n.headers=a}return n},CR=e=>{if(e instanceof Headers){let t={};return e.forEach((e,n)=>{t[n]=e}),t}if(Array.isArray(e)){let t={};return e.forEach(([e,n])=>{t[e]=n}),t}return e},wR=async(e,t,n,r,i)=>{let a=0;for(;;)try{return await e(t,n)}catch(e){if(i())throw e;a++;let n=r(a,e,t);if(n===null)throw e;if(console.error(`Retrying failed fetch. Error:`,e),!Number.isFinite(n)||n<0)throw TypeError(`Retry delay must be a non-negative finite number.`);if(n>0&&await qR(1e3*n),i())throw e}},TR=(e,t)=>{let n=e<0?-1:1;e=Math.abs(e);let r=0,i=1,a=1,o=0,s=e;for(;;){let e=Math.floor(s),c=e*a+r,l=e*o+i;if(l>t)return{num:n*a,den:o};if(r=a,i=o,a=c,o=l,s=1/(s-e),!isFinite(s))break}return{num:n*a,den:o}},ER=class{constructor(){this.currentPromise=Promise.resolve()}call(e){return this.currentPromise=this.currentPromise.then(e)}},DR=null,OR=()=>DR===null?DR=!!(typeof navigator<`u`&&(navigator.vendor?.match(/apple/i)||/AppleWebKit/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)||/\b(iPad|iPhone|iPod)\b/.test(navigator.userAgent))):DR,kR=null,AR=()=>kR===null?kR=typeof navigator<`u`&&navigator.userAgent?.includes(`Firefox`):kR,jR=null,MR=()=>jR===null?jR=!!(typeof navigator<`u`&&(navigator.vendor?.includes(`Google Inc`)||/Chrome/.test(navigator.userAgent))):jR,NR=null,PR=()=>{if(NR!==null)return NR;if(typeof navigator>`u`)return null;let e=/\bChrome\/(\d+)/.exec(navigator.userAgent);return e?NR=Number(e[1]):null},FR=(e,t)=>e===-1?t:e,IR=(e,t,n,r)=>e<=r&&n<=t,LR=function*(e){for(let t in e){let n=e[t];n!==void 0&&(yield{key:t,value:n})}},RR=e=>{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n},zR=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},BR=()=>{Symbol.dispose??=Symbol(`Symbol.dispose`)},VR=e=>typeof e==`number`&&!Number.isNaN(e),HR=(e,t)=>{if(t.includes(`://`))return t;if(e.includes(`://`)){let t=e.indexOf(`?`);t!==-1&&(e=e.slice(0,t))}let n;if(t.startsWith(`/`)){let r=e.indexOf(`://`);if(r===-1)n=t;else{let i=e.indexOf(`/`,r+3);n=i===-1?e+t:e.slice(0,i)+t}}else{let r=e.lastIndexOf(`/`);n=r===-1?t:e.slice(0,r+1)+t}let r=``,i=n.indexOf(`://`);if(i!==-1){let e=n.indexOf(`/`,i+3);e!==-1&&(r=n.slice(0,e),n=n.slice(e))}let a=n.split(`/`),o=[];for(let e of a)e===`..`?o.pop():e!==`.`&&o.push(e);return r+o.join(`/`)},UR=(e,t)=>{let n=0;for(let r=0;r<e.length;r++)t(e[r])&&n++;return n},WR=(e,t)=>{let n=-1,r=1/0;for(let i=0;i<e.length;i++){let a=t(e[i]);a<r&&(r=a,n=i)}return n},GR=e=>{X(Number.isInteger(e.num)),X(Number.isInteger(e.den)),X(e.den!==0);let t=Math.abs(e.num),n=Math.abs(e.den);for(;n!==0;){let e=t%n;t=n,n=e}let r=t||1;return{num:e.num/r,den:e.den/r}},KR=(e,t)=>{if(typeof e!=`object`||!e)throw TypeError(`${t} must be an object.`);if(!Number.isInteger(e.left)||e.left<0)throw TypeError(`${t}.left must be a non-negative integer.`);if(!Number.isInteger(e.top)||e.top<0)throw TypeError(`${t}.top must be a non-negative integer.`);if(!Number.isInteger(e.width)||e.width<0)throw TypeError(`${t}.width must be a non-negative integer.`);if(!Number.isInteger(e.height)||e.height<0)throw TypeError(`${t}.height must be a non-negative integer.`)},qR=e=>new Promise(t=>setTimeout(t,e)),JR=e=>Array.isArray(e)?e:[e],YR=class{constructor(){this._listeners=new Map}on(e,t,n){this._listeners.has(e)||this._listeners.set(e,new Set);let r={fn:t,once:n?.once??!1};return this._listeners.get(e).add(r),()=>{this._listeners.get(e)?.delete(r)}}_emit(...e){let[t,n]=e,r=this._listeners.get(t);if(r)for(let e of r){try{e.fn(n)}catch(e){console.error(e)}e.once&&r.delete(e)}}},XR=e=>typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===Object.prototype&&Object.values(e).every(e=>typeof e==`string`),ZR=class{constructor(e,t){if(this.data=e,this.mimeType=t,!(e instanceof Uint8Array))throw TypeError(`data must be a Uint8Array.`);if(typeof t!=`string`)throw TypeError(`mimeType must be a string.`)}},QR=class{constructor(e,t,n,r){if(this.data=e,this.mimeType=t,this.name=n,this.description=r,!(e instanceof Uint8Array))throw TypeError(`data must be a Uint8Array.`);if(t!==void 0&&typeof t!=`string`)throw TypeError(`mimeType, when provided, must be a string.`);if(n!==void 0&&typeof n!=`string`)throw TypeError(`name, when provided, must be a string.`);if(r!==void 0&&typeof r!=`string`)throw TypeError(`description, when provided, must be a string.`)}},$R=e=>{if(!e||typeof e!=`object`)throw TypeError(`tags must be an object.`);if(e.title!==void 0&&typeof e.title!=`string`)throw TypeError(`tags.title, when provided, must be a string.`);if(e.description!==void 0&&typeof e.description!=`string`)throw TypeError(`tags.description, when provided, must be a string.`);if(e.artist!==void 0&&typeof e.artist!=`string`)throw TypeError(`tags.artist, when provided, must be a string.`);if(e.album!==void 0&&typeof e.album!=`string`)throw TypeError(`tags.album, when provided, must be a string.`);if(e.albumArtist!==void 0&&typeof e.albumArtist!=`string`)throw TypeError(`tags.albumArtist, when provided, must be a string.`);if(e.trackNumber!==void 0&&(!Number.isInteger(e.trackNumber)||e.trackNumber<=0))throw TypeError(`tags.trackNumber, when provided, must be a positive integer.`);if(e.tracksTotal!==void 0&&(!Number.isInteger(e.tracksTotal)||e.tracksTotal<=0))throw TypeError(`tags.tracksTotal, when provided, must be a positive integer.`);if(e.discNumber!==void 0&&(!Number.isInteger(e.discNumber)||e.discNumber<=0))throw TypeError(`tags.discNumber, when provided, must be a positive integer.`);if(e.discsTotal!==void 0&&(!Number.isInteger(e.discsTotal)||e.discsTotal<=0))throw TypeError(`tags.discsTotal, when provided, must be a positive integer.`);if(e.genre!==void 0&&typeof e.genre!=`string`)throw TypeError(`tags.genre, when provided, must be a string.`);if(e.date!==void 0&&(!(e.date instanceof Date)||Number.isNaN(e.date.getTime())))throw TypeError(`tags.date, when provided, must be a valid Date.`);if(e.lyrics!==void 0&&typeof e.lyrics!=`string`)throw TypeError(`tags.lyrics, when provided, must be a string.`);if(e.images!==void 0){if(!Array.isArray(e.images))throw TypeError(`tags.images, when provided, must be an array.`);for(let t of e.images){if(!t||typeof t!=`object`)throw TypeError(`Each image in tags.images must be an object.`);if(!(t.data instanceof Uint8Array))throw TypeError(`Each image.data must be a Uint8Array.`);if(typeof t.mimeType!=`string`)throw TypeError(`Each image.mimeType must be a string.`);if(![`coverFront`,`coverBack`,`unknown`].includes(t.kind))throw TypeError(`Each image.kind must be 'coverFront', 'coverBack', or 'unknown'.`)}}if(e.comment!==void 0&&typeof e.comment!=`string`)throw TypeError(`tags.comment, when provided, must be a string.`);if(e.raw!==void 0){if(!e.raw||typeof e.raw!=`object`)throw TypeError(`tags.raw, when provided, must be an object.`);for(let t of Object.values(e.raw))if(t!==null&&typeof t!=`string`&&!(t instanceof Uint8Array)&&!(t instanceof ZR)&&!(t instanceof QR)&&!XR(t))throw TypeError(`Each value in tags.raw must be a string, Uint8Array, RichImageData, AttachedFile, Record<string, string>, or null.`)}},ez={default:!0,primary:!0,forced:!1,original:!1,commentary:!1,hearingImpaired:!1,visuallyImpaired:!1},tz=e=>{if(!e||typeof e!=`object`)throw TypeError(`disposition must be an object.`);if(e.default!==void 0&&typeof e.default!=`boolean`)throw TypeError(`disposition.default must be a boolean.`);if(e.primary!==void 0&&typeof e.primary!=`boolean`)throw TypeError(`disposition.primary must be a boolean.`);if(e.forced!==void 0&&typeof e.forced!=`boolean`)throw TypeError(`disposition.forced must be a boolean.`);if(e.original!==void 0&&typeof e.original!=`boolean`)throw TypeError(`disposition.original must be a boolean.`);if(e.commentary!==void 0&&typeof e.commentary!=`boolean`)throw TypeError(`disposition.commentary must be a boolean.`);if(e.hearingImpaired!==void 0&&typeof e.hearingImpaired!=`boolean`)throw TypeError(`disposition.hearingImpaired must be a boolean.`);if(e.visuallyImpaired!==void 0&&typeof e.visuallyImpaired!=`boolean`)throw TypeError(`disposition.visuallyImpaired must be a boolean.`)},nz=class e{constructor(e){this.bytes=e,this.pos=0}seekToByte(e){this.pos=8*e}readBit(){let e=Math.floor(this.pos/8),t=this.bytes[e]??0,n=7-(this.pos&7),r=(t&1<<n)>>n;return this.pos++,r}readBits(e){if(e===1)return this.readBit();let t=0;for(let n=0;n<e;n++)t<<=1,t|=this.readBit();return t}writeBits(e,t){let n=this.pos+e;for(let e=this.pos;e<n;e++){let r=Math.floor(e/8),i=this.bytes[r],a=7-(e&7);i&=~(1<<a),i|=(t&1<<n-e-1)>>n-e-1<<a,this.bytes[r]=i}this.pos=n}readAlignedByte(){if(this.pos%8!=0)throw Error(`Bitstream is not byte-aligned.`);let e=this.pos/8,t=this.bytes[e]??0;return this.pos+=8,t}skipBits(e){this.pos+=e}getBitsLeft(){return this.bytes.length*8-this.pos}clone(){let t=new e(this.bytes);return t.pos=this.pos,t}},rz=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],iz=[-1,1,2,3,4,5,6,8],az=e=>{if(!e||e.byteLength<2)throw TypeError(`AAC description must be at least 2 bytes long.`);let t=new nz(e),n=t.readBits(5);n===31&&(n=32+t.readBits(6));let r=t.readBits(4),i=null;r===15?i=t.readBits(24):r<rz.length&&(i=rz[r]);let a=t.readBits(4),o=null;return a>=1&&a<=7&&(o=iz[a]),{objectType:n,frequencyIndex:r,sampleRate:i,channelConfiguration:a,numberOfChannels:o}},oz=e=>{let t=rz.indexOf(e.sampleRate),n=null;t===-1&&(t=15,n=e.sampleRate);let r=iz.indexOf(e.numberOfChannels);if(r===-1)throw TypeError(`Unsupported number of channels: ${e.numberOfChannels}`);let i=13;e.objectType>=32&&(i+=6),t===15&&(i+=24);let a=Math.ceil(i/8),o=new Uint8Array(a),s=new nz(o);return e.objectType<32?s.writeBits(5,e.objectType):(s.writeBits(5,31),s.writeBits(6,e.objectType-32)),s.writeBits(4,t),t===15&&s.writeBits(24,n),s.writeBits(4,r),o},sz=[`avc`,`hevc`,`vp9`,`av1`,`vp8`],cz=[`pcm-s16`,`pcm-s16be`,`pcm-s24`,`pcm-s24be`,`pcm-s32`,`pcm-s32be`,`pcm-f32`,`pcm-f32be`,`pcm-f64`,`pcm-f64be`,`pcm-u8`,`pcm-s8`,`ulaw`,`alaw`],lz=[`aac`,`opus`,`mp3`,`vorbis`,`flac`,`ac3`,`eac3`],uz=[...lz,...cz],dz=[`webvtt`],fz=[{maxMacroblocks:99,maxBitrate:64e3,maxDpbMbs:396,level:10},{maxMacroblocks:396,maxBitrate:192e3,maxDpbMbs:900,level:11},{maxMacroblocks:396,maxBitrate:384e3,maxDpbMbs:2376,level:12},{maxMacroblocks:396,maxBitrate:768e3,maxDpbMbs:2376,level:13},{maxMacroblocks:396,maxBitrate:2e6,maxDpbMbs:2376,level:20},{maxMacroblocks:792,maxBitrate:4e6,maxDpbMbs:4752,level:21},{maxMacroblocks:1620,maxBitrate:4e6,maxDpbMbs:8100,level:22},{maxMacroblocks:1620,maxBitrate:1e7,maxDpbMbs:8100,level:30},{maxMacroblocks:3600,maxBitrate:14e6,maxDpbMbs:18e3,level:31},{maxMacroblocks:5120,maxBitrate:2e7,maxDpbMbs:20480,level:32},{maxMacroblocks:8192,maxBitrate:2e7,maxDpbMbs:32768,level:40},{maxMacroblocks:8192,maxBitrate:5e7,maxDpbMbs:32768,level:41},{maxMacroblocks:8704,maxBitrate:5e7,maxDpbMbs:34816,level:42},{maxMacroblocks:22080,maxBitrate:135e6,maxDpbMbs:110400,level:50},{maxMacroblocks:36864,maxBitrate:24e7,maxDpbMbs:184320,level:51},{maxMacroblocks:36864,maxBitrate:24e7,maxDpbMbs:184320,level:52},{maxMacroblocks:139264,maxBitrate:24e7,maxDpbMbs:696320,level:60},{maxMacroblocks:139264,maxBitrate:48e7,maxDpbMbs:696320,level:61},{maxMacroblocks:139264,maxBitrate:8e8,maxDpbMbs:696320,level:62}],pz=[{maxPictureSize:36864,maxBitrate:128e3,tier:`L`,level:30},{maxPictureSize:122880,maxBitrate:15e5,tier:`L`,level:60},{maxPictureSize:245760,maxBitrate:3e6,tier:`L`,level:63},{maxPictureSize:552960,maxBitrate:6e6,tier:`L`,level:90},{maxPictureSize:983040,maxBitrate:1e7,tier:`L`,level:93},{maxPictureSize:2228224,maxBitrate:12e6,tier:`L`,level:120},{maxPictureSize:2228224,maxBitrate:3e7,tier:`H`,level:120},{maxPictureSize:2228224,maxBitrate:2e7,tier:`L`,level:123},{maxPictureSize:2228224,maxBitrate:5e7,tier:`H`,level:123},{maxPictureSize:8912896,maxBitrate:25e6,tier:`L`,level:150},{maxPictureSize:8912896,maxBitrate:1e8,tier:`H`,level:150},{maxPictureSize:8912896,maxBitrate:4e7,tier:`L`,level:153},{maxPictureSize:8912896,maxBitrate:16e7,tier:`H`,level:153},{maxPictureSize:8912896,maxBitrate:6e7,tier:`L`,level:156},{maxPictureSize:8912896,maxBitrate:24e7,tier:`H`,level:156},{maxPictureSize:35651584,maxBitrate:6e7,tier:`L`,level:180},{maxPictureSize:35651584,maxBitrate:24e7,tier:`H`,level:180},{maxPictureSize:35651584,maxBitrate:12e7,tier:`L`,level:183},{maxPictureSize:35651584,maxBitrate:48e7,tier:`H`,level:183},{maxPictureSize:35651584,maxBitrate:24e7,tier:`L`,level:186},{maxPictureSize:35651584,maxBitrate:8e8,tier:`H`,level:186}],mz=[{maxPictureSize:36864,maxBitrate:2e5,level:10},{maxPictureSize:73728,maxBitrate:8e5,level:11},{maxPictureSize:122880,maxBitrate:18e5,level:20},{maxPictureSize:245760,maxBitrate:36e5,level:21},{maxPictureSize:552960,maxBitrate:72e5,level:30},{maxPictureSize:983040,maxBitrate:12e6,level:31},{maxPictureSize:2228224,maxBitrate:18e6,level:40},{maxPictureSize:2228224,maxBitrate:3e7,level:41},{maxPictureSize:8912896,maxBitrate:6e7,level:50},{maxPictureSize:8912896,maxBitrate:12e7,level:51},{maxPictureSize:8912896,maxBitrate:18e7,level:52},{maxPictureSize:35651584,maxBitrate:18e7,level:60},{maxPictureSize:35651584,maxBitrate:24e7,level:61},{maxPictureSize:35651584,maxBitrate:48e7,level:62}],hz=[{maxPictureSize:147456,maxBitrate:15e5,tier:`M`,level:0},{maxPictureSize:278784,maxBitrate:3e6,tier:`M`,level:1},{maxPictureSize:665856,maxBitrate:6e6,tier:`M`,level:4},{maxPictureSize:1065024,maxBitrate:1e7,tier:`M`,level:5},{maxPictureSize:2359296,maxBitrate:12e6,tier:`M`,level:8},{maxPictureSize:2359296,maxBitrate:3e7,tier:`H`,level:8},{maxPictureSize:2359296,maxBitrate:2e7,tier:`M`,level:9},{maxPictureSize:2359296,maxBitrate:5e7,tier:`H`,level:9},{maxPictureSize:8912896,maxBitrate:3e7,tier:`M`,level:12},{maxPictureSize:8912896,maxBitrate:1e8,tier:`H`,level:12},{maxPictureSize:8912896,maxBitrate:4e7,tier:`M`,level:13},{maxPictureSize:8912896,maxBitrate:16e7,tier:`H`,level:13},{maxPictureSize:8912896,maxBitrate:6e7,tier:`M`,level:14},{maxPictureSize:8912896,maxBitrate:24e7,tier:`H`,level:14},{maxPictureSize:35651584,maxBitrate:6e7,tier:`M`,level:15},{maxPictureSize:35651584,maxBitrate:24e7,tier:`H`,level:15},{maxPictureSize:35651584,maxBitrate:6e7,tier:`M`,level:16},{maxPictureSize:35651584,maxBitrate:24e7,tier:`H`,level:16},{maxPictureSize:35651584,maxBitrate:1e8,tier:`M`,level:17},{maxPictureSize:35651584,maxBitrate:48e7,tier:`H`,level:17},{maxPictureSize:35651584,maxBitrate:16e7,tier:`M`,level:18},{maxPictureSize:35651584,maxBitrate:8e8,tier:`H`,level:18},{maxPictureSize:35651584,maxBitrate:16e7,tier:`M`,level:19},{maxPictureSize:35651584,maxBitrate:8e8,tier:`H`,level:19}],gz=`.01.01.01.01.00`,_z=`.0.110.01.01.01.0`,vz=(e,t,n,r)=>{if(e===`avc`){let e=Math.ceil(t/16)*Math.ceil(n/16),i=fz.find(t=>e<=t.maxMacroblocks&&r<=t.maxBitrate)??AL(fz),a=i?i.level:0;return`avc1.${`64`.padStart(2,`0`)}00${a.toString(16).padStart(2,`0`)}`}else if(e===`hevc`){let e=t*n,i=pz.find(t=>e<=t.maxPictureSize&&r<=t.maxBitrate)??AL(pz);return`hev1.1.6.${i.tier}${i.level}.B0`}else if(e===`vp8`)return`vp8`;else if(e===`vp9`){let e=t*n;return`vp09.00.${(mz.find(t=>e<=t.maxPictureSize&&r<=t.maxBitrate)??AL(mz)).level.toString().padStart(2,`0`)}.08`}else if(e===`av1`){let e=t*n,i=hz.find(t=>e<=t.maxPictureSize&&r<=t.maxBitrate)??AL(hz);return`av01.0.${i.level.toString().padStart(2,`0`)}${i.tier}.08`}throw TypeError(`Unhandled codec '${e}'.`)},yz=e=>{let t=e.split(`.`),n=Number(t[1]),r=t[2],i=Number(r.slice(0,-1)),a=(n<<5)+i,o=+(r.slice(-1)===`H`),s=Number(t[3])===8?0:1,c=t[4]?Number(t[4]):0,l=t[5]?Number(t[5][0]):1,u=t[5]?Number(t[5][1]):1,d=t[5]?Number(t[5][2]):0;return[129,a,(o<<7)+(s<<6)+0+(c<<4)+(l<<3)+(u<<2)+d,0]},bz=e=>{let{codec:t,codecDescription:n,colorSpace:r,avcCodecInfo:i,hevcCodecInfo:a,vp9CodecInfo:o,av1CodecInfo:s}=e;if(t===`avc`){if(X(e.avcType!==null),i){let t=new Uint8Array([i.avcProfileIndication,i.profileCompatibility,i.avcLevelIndication]);return`avc${e.avcType}.${JL(t)}`}if(!n||n.byteLength<4)throw TypeError(`AVC decoder description is not provided or is not at least 4 bytes long.`);return`avc${e.avcType}.${JL(n.subarray(1,4))}`}else if(t===`hevc`){let e,t,r,i,o,s;if(a)e=a.generalProfileSpace,t=a.generalProfileIdc,r=XL(a.generalProfileCompatibilityFlags),i=a.generalTierFlag,o=a.generalLevelIdc,s=[...a.generalConstraintIndicatorFlags];else{if(!n||n.byteLength<23)throw TypeError(`HEVC decoder description is not provided or is not at least 23 bytes long.`);let a=PL(n),c=a.getUint8(1);e=c>>6&3,t=c&31,r=XL(a.getUint32(2)),i=c>>5&1,o=a.getUint8(12),s=[];for(let e=0;e<6;e++)s.push(a.getUint8(6+e))}let c=`hev1.`;for(c+=[``,`A`,`B`,`C`][e]+t,c+=`.`,c+=r.toString(16).toUpperCase(),c+=`.`,c+=i===0?`L`:`H`,c+=o;s.length>0&&s[s.length-1]===0;)s.pop();return s.length>0&&(c+=`.`,c+=s.map(e=>e.toString(16).toUpperCase()).join(`.`)),c}else if(t===`vp8`)return`vp8`;else if(t===`vp9`){if(!o){let t=e.width*e.height,n=AL(mz).level;for(let e of mz)if(t<=e.maxPictureSize){n=e.level;break}return`vp09.00.${n.toString().padStart(2,`0`)}.08`}let t=o.profile.toString().padStart(2,`0`),n=o.level.toString().padStart(2,`0`),r=o.bitDepth.toString().padStart(2,`0`),i=o.chromaSubsampling.toString().padStart(2,`0`),a=o.colourPrimaries.toString().padStart(2,`0`),s=o.transferCharacteristics.toString().padStart(2,`0`),c=o.matrixCoefficients.toString().padStart(2,`0`),l=o.videoFullRangeFlag.toString().padStart(2,`0`),u=`vp09.${t}.${n}.${r}.${i}`;return u+=`.${a}.${s}.${c}.${l}`,u.endsWith(gz)&&(u=u.slice(0,-15)),u}else if(t===`av1`){if(!s){let t=e.width*e.height,n=AL(mz).level;for(let e of mz)if(t<=e.maxPictureSize){n=e.level;break}return`av01.0.${n.toString().padStart(2,`0`)}M.08`}let t=s.profile,n=s.level.toString().padStart(2,`0`),i=s.tier?`H`:`M`,a=s.bitDepth.toString().padStart(2,`0`),o=s.monochrome?`1`:`0`,c=100*s.chromaSubsamplingX+10*s.chromaSubsamplingY+1*(s.chromaSubsamplingX&&s.chromaSubsamplingY?s.chromaSamplePosition:0),l=r?.primaries?RL[r.primaries]:1,u=r?.transfer?BL[r.transfer]:1,d=r?.matrix?HL[r.matrix]:1,f=+!!r?.fullRange,p=`av01.${t}.${n}${i}.${a}`;return p+=`.${o}.${c.toString().padStart(3,`0`)}`,p+=`.${l.toString().padStart(2,`0`)}`,p+=`.${u.toString().padStart(2,`0`)}`,p+=`.${d.toString().padStart(2,`0`)}`,p+=`.${f}`,p.endsWith(_z)&&(p=p.slice(0,-17)),p}throw TypeError(`Unhandled codec '${t}'.`)},xz=(e,t,n)=>{if(e===`aac`)return t>=2&&n<=24e3?`mp4a.40.29`:n<=24e3?`mp4a.40.5`:`mp4a.40.2`;if(e===`mp3`)return`mp3`;if(e===`opus`)return`opus`;if(e===`vorbis`)return`vorbis`;if(e===`flac`)return`flac`;if(e===`ac3`)return`ac-3`;if(e===`eac3`)return`ec-3`;if(cz.includes(e))return e;throw TypeError(`Unhandled codec '${e}'.`)},Sz=e=>{let{codec:t,codecDescription:n,aacCodecInfo:r}=e;if(t===`aac`){if(!r)throw TypeError(`AAC codec info must be provided.`);if(r.isMpeg2)return`mp4a.67`;{let e;return e=r.objectType===null?az(n).objectType:r.objectType,`mp4a.40.${e}`}}else if(t===`mp3`)return`mp3`;else if(t===`opus`)return`opus`;else if(t===`vorbis`)return`vorbis`;else if(t===`flac`)return`flac`;else if(t===`ac3`)return`ac-3`;else if(t===`eac3`)return`ec-3`;else if(t&&cz.includes(t))return t;throw TypeError(`Unhandled codec '${t}'.`)},Cz=48e3,wz=/^pcm-([usf])(\d+)(be)?$/,Tz=e=>{if(X(cz.includes(e)),e===`ulaw`)return{dataType:`ulaw`,sampleSize:1,littleEndian:!0,silentValue:255};if(e===`alaw`)return{dataType:`alaw`,sampleSize:1,littleEndian:!0,silentValue:213};let t=wz.exec(e);X(t);let n;n=t[1]===`u`?`unsigned`:t[1]===`s`?`signed`:`float`;let r=Number(t[2])/8,i=t[3]!==`be`;return{dataType:n,sampleSize:r,littleEndian:i,silentValue:e===`pcm-u8`?2**7:0}},Ez=e=>e.startsWith(`avc1`)||e.startsWith(`avc3`)?`avc`:e.startsWith(`hev1`)||e.startsWith(`hvc1`)?`hevc`:e===`vp8`?`vp8`:e.startsWith(`vp09`)?`vp9`:e.startsWith(`av01`)?`av1`:e===`mp3`||e===`mp4a.69`||e===`mp4a.6B`||e===`mp4a.6b`||e===`mp4a.40.34`?`mp3`:e.startsWith(`mp4a.40.`)||e===`mp4a.67`?`aac`:e===`opus`?`opus`:e===`vorbis`?`vorbis`:e===`flac`?`flac`:e===`ac-3`||e===`ac3`?`ac3`:e===`ec-3`||e===`eac3`?`eac3`:e===`ulaw`?`ulaw`:e===`alaw`?`alaw`:wz.test(e)?e:e===`webvtt`?`webvtt`:null,Dz=e=>e===`avc`?{avc:{format:`avc`}}:e===`hevc`?{hevc:{format:`hevc`}}:{},Oz=e=>e===`aac`?{aac:{format:`aac`}}:e===`opus`?{opus:{format:`opus`}}:{},kz=[`avc1`,`avc3`,`hev1`,`hvc1`,`vp8`,`vp09`,`av01`],Az=/^(avc1|avc3)\.[0-9a-fA-F]{6}$/,jz=/^(hev1|hvc1)\.(?:[ABC]?\d+)\.[0-9a-fA-F]{1,8}\.[LH]\d+(?:\.[0-9a-fA-F]{1,2}){0,6}$/,Mz=/^vp09(?:\.\d{2}){3}(?:(?:\.\d{2}){5})?$/,Nz=/^av01\.\d\.\d{2}[MH]\.\d{2}(?:\.\d\.\d{3}\.\d{2}\.\d{2}\.\d{2}\.\d)?$/,Pz=e=>{if(!e)throw TypeError(`Video chunk metadata must be provided.`);if(typeof e!=`object`)throw TypeError(`Video chunk metadata must be an object.`);if(!e.decoderConfig)throw TypeError(`Video chunk metadata must include a decoder configuration.`);if(typeof e.decoderConfig!=`object`)throw TypeError(`Video chunk metadata decoder configuration must be an object.`);if(typeof e.decoderConfig.codec!=`string`)throw TypeError(`Video chunk metadata decoder configuration must specify a codec string.`);if(!kz.some(t=>e.decoderConfig.codec.startsWith(t)))throw TypeError(`Video chunk metadata decoder configuration codec string must be a valid video codec string as specified in the Mediabunny Codec Registry.`);if(!Number.isInteger(e.decoderConfig.codedWidth)||e.decoderConfig.codedWidth<=0)throw TypeError(`Video chunk metadata decoder configuration must specify a valid codedWidth (positive integer).`);if(!Number.isInteger(e.decoderConfig.codedHeight)||e.decoderConfig.codedHeight<=0)throw TypeError(`Video chunk metadata decoder configuration must specify a valid codedHeight (positive integer).`);if(e.decoderConfig.displayAspectWidth!==void 0&&(!Number.isInteger(e.decoderConfig.displayAspectWidth)||e.decoderConfig.displayAspectWidth<=0))throw TypeError(`Video chunk metadata decoder configuration displayAspectWidth, when defined, must be a positive integer.`);if(e.decoderConfig.displayAspectHeight!==void 0&&(!Number.isInteger(e.decoderConfig.displayAspectHeight)||e.decoderConfig.displayAspectHeight<=0))throw TypeError(`Video chunk metadata decoder configuration displayAspectHeight, when defined, must be a positive integer.`);if(e.decoderConfig.displayAspectWidth!==void 0!=(e.decoderConfig.displayAspectHeight!==void 0))throw TypeError(`Video chunk metadata decoder configuration must specify both displayAspectWidth and displayAspectHeight, or neither.`);if(e.decoderConfig.description!==void 0&&!GL(e.decoderConfig.description))throw TypeError(`Video chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.`);if(e.decoderConfig.colorSpace!==void 0){let{colorSpace:t}=e.decoderConfig;if(typeof t!=`object`)throw TypeError(`Video chunk metadata decoder configuration colorSpace, when provided, must be an object.`);let n=Object.keys(RL);if(t.primaries!=null&&!n.includes(t.primaries))throw TypeError(`Video chunk metadata decoder configuration colorSpace primaries, when defined, must be one of ${n.join(`, `)}.`);let r=Object.keys(BL);if(t.transfer!=null&&!r.includes(t.transfer))throw TypeError(`Video chunk metadata decoder configuration colorSpace transfer, when defined, must be one of ${r.join(`, `)}.`);let i=Object.keys(HL);if(t.matrix!=null&&!i.includes(t.matrix))throw TypeError(`Video chunk metadata decoder configuration colorSpace matrix, when defined, must be one of ${i.join(`, `)}.`);if(t.fullRange!=null&&typeof t.fullRange!=`boolean`)throw TypeError(`Video chunk metadata decoder configuration colorSpace fullRange, when defined, must be a boolean.`)}if(e.decoderConfig.codec.startsWith(`avc1`)||e.decoderConfig.codec.startsWith(`avc3`)){if(!Az.test(e.decoderConfig.codec))throw TypeError(`Video chunk metadata decoder configuration codec string for AVC must be a valid AVC codec string as specified in Section 3.4 of RFC 6381.`)}else if(e.decoderConfig.codec.startsWith(`hev1`)||e.decoderConfig.codec.startsWith(`hvc1`)){if(!jz.test(e.decoderConfig.codec))throw TypeError(`Video chunk metadata decoder configuration codec string for HEVC must be a valid HEVC codec string as specified in Section E.3 of ISO 14496-15.`)}else if(e.decoderConfig.codec.startsWith(`vp8`)){if(e.decoderConfig.codec!==`vp8`)throw TypeError(`Video chunk metadata decoder configuration codec string for VP8 must be "vp8".`)}else if(e.decoderConfig.codec.startsWith(`vp09`)){if(!Mz.test(e.decoderConfig.codec))throw TypeError(`Video chunk metadata decoder configuration codec string for VP9 must be a valid VP9 codec string as specified in Section "Codecs Parameter String" of https://www.webmproject.org/vp9/mp4/.`)}else if(e.decoderConfig.codec.startsWith(`av01`)&&!Nz.test(e.decoderConfig.codec))throw TypeError(`Video chunk metadata decoder configuration codec string for AV1 must be a valid AV1 codec string as specified in Section "Codecs Parameter String" of https://aomediacodec.github.io/av1-isobmff/.`)},Fz=[`mp4a`,`mp3`,`opus`,`vorbis`,`flac`,`ulaw`,`alaw`,`pcm`,`ac-3`,`ec-3`],Iz=e=>{if(!e)throw TypeError(`Audio chunk metadata must be provided.`);if(typeof e!=`object`)throw TypeError(`Audio chunk metadata must be an object.`);if(!e.decoderConfig)throw TypeError(`Audio chunk metadata must include a decoder configuration.`);if(typeof e.decoderConfig!=`object`)throw TypeError(`Audio chunk metadata decoder configuration must be an object.`);if(typeof e.decoderConfig.codec!=`string`)throw TypeError(`Audio chunk metadata decoder configuration must specify a codec string.`);if(!Fz.some(t=>e.decoderConfig.codec.startsWith(t)))throw TypeError(`Audio chunk metadata decoder configuration codec string must be a valid audio codec string as specified in the Mediabunny Codec Registry.`);if(!Number.isInteger(e.decoderConfig.sampleRate)||e.decoderConfig.sampleRate<=0)throw TypeError(`Audio chunk metadata decoder configuration must specify a valid sampleRate (positive integer).`);if(!Number.isInteger(e.decoderConfig.numberOfChannels)||e.decoderConfig.numberOfChannels<=0)throw TypeError(`Audio chunk metadata decoder configuration must specify a valid numberOfChannels (positive integer).`);if(e.decoderConfig.description!==void 0&&!GL(e.decoderConfig.description))throw TypeError(`Audio chunk metadata decoder configuration description, when defined, must be an ArrayBuffer or an ArrayBuffer view.`);if(e.decoderConfig.codec.startsWith(`mp4a`)&&e.decoderConfig.codec!==`mp4a.69`&&e.decoderConfig.codec!==`mp4a.6B`&&e.decoderConfig.codec!==`mp4a.6b`){if(![`mp4a.40.2`,`mp4a.40.02`,`mp4a.40.5`,`mp4a.40.05`,`mp4a.40.29`,`mp4a.67`].includes(e.decoderConfig.codec))throw TypeError(`Audio chunk metadata decoder configuration codec string for AAC must be a valid AAC codec string as specified in https://www.w3.org/TR/webcodecs-aac-codec-registration/.`)}else if(e.decoderConfig.codec.startsWith(`mp3`)||e.decoderConfig.codec.startsWith(`mp4a`)){if(e.decoderConfig.codec!==`mp3`&&e.decoderConfig.codec!==`mp4a.69`&&e.decoderConfig.codec!==`mp4a.6B`&&e.decoderConfig.codec!==`mp4a.6b`)throw TypeError(`Audio chunk metadata decoder configuration codec string for MP3 must be "mp3", "mp4a.69" or "mp4a.6B".`)}else if(e.decoderConfig.codec.startsWith(`opus`)){if(e.decoderConfig.codec!==`opus`)throw TypeError(`Audio chunk metadata decoder configuration codec string for Opus must be "opus".`);if(e.decoderConfig.description&&e.decoderConfig.description.byteLength<18)throw TypeError(`Audio chunk metadata decoder configuration description, when specified, is expected to be an Identification Header as specified in Section 5.1 of RFC 7845.`)}else if(e.decoderConfig.codec.startsWith(`vorbis`)){if(e.decoderConfig.codec!==`vorbis`)throw TypeError(`Audio chunk metadata decoder configuration codec string for Vorbis must be "vorbis".`);if(!e.decoderConfig.description)throw TypeError(`Audio chunk metadata decoder configuration for Vorbis must include a description, which is expected to adhere to the format described in https://www.w3.org/TR/webcodecs-vorbis-codec-registration/.`)}else if(e.decoderConfig.codec.startsWith(`flac`)){if(e.decoderConfig.codec!==`flac`)throw TypeError(`Audio chunk metadata decoder configuration codec string for FLAC must be "flac".`);if(!e.decoderConfig.description||e.decoderConfig.description.byteLength<42)throw TypeError(`Audio chunk metadata decoder configuration for FLAC must include a description, which is expected to adhere to the format described in https://www.w3.org/TR/webcodecs-flac-codec-registration/.`)}else if(e.decoderConfig.codec.startsWith(`ac-3`)||e.decoderConfig.codec.startsWith(`ac3`)){if(e.decoderConfig.codec!==`ac-3`)throw TypeError(`Audio chunk metadata decoder configuration codec string for AC-3 must be "ac-3".`)}else if(e.decoderConfig.codec.startsWith(`ec-3`)||e.decoderConfig.codec.startsWith(`eac3`)){if(e.decoderConfig.codec!==`ec-3`)throw TypeError(`Audio chunk metadata decoder configuration codec string for EC-3 must be "ec-3".`)}else if((e.decoderConfig.codec.startsWith(`pcm`)||e.decoderConfig.codec.startsWith(`ulaw`)||e.decoderConfig.codec.startsWith(`alaw`))&&!cz.includes(e.decoderConfig.codec))throw TypeError(`Audio chunk metadata decoder configuration codec string for PCM must be one of the supported PCM codecs (${cz.join(`, `)}).`)},Lz=e=>{if(!e)throw TypeError(`Subtitle metadata must be provided.`);if(typeof e!=`object`)throw TypeError(`Subtitle metadata must be an object.`);if(!e.config)throw TypeError(`Subtitle metadata must include a config object.`);if(typeof e.config!=`object`)throw TypeError(`Subtitle metadata config must be an object.`);if(typeof e.config.description!=`string`)throw TypeError(`Subtitle metadata config description must be a string.`)},Rz=[44100,48e3,32e3],zz=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1,-1,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1,-1,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,16,24,32,40,48,56,64,80,96,112,128,144,160,-1,-1,8,16,24,32,40,48,56,64,80,96,112,128,144,160,-1,-1,32,48,56,64,80,96,112,128,144,160,176,192,224,256,-1],Bz=(e,t,n,r,i)=>t===0?0:t===1?Math.floor(144*n/(r<<e))+i:t===2?Math.floor(144*n/r)+i:(Math.floor(12*n/r)+i)*4,Vz=(e,t,n,r)=>t===0?0:t===1?144*n/(r<<e):t===2?144*n/r:12*n/r*4,Hz=(e,t)=>e===3?t===3?21:36:t===3?13:21,Uz=(e,t)=>{let n=e>>>24,r=e>>>16&255,i=e>>>8&255,a=e&255;if(n!==255&&r!==255&&i!==255&&a!==255)return{header:null,bytesAdvanced:4};if(n!==255||(r&224)!=224)return{header:null,bytesAdvanced:1};let o=0,s=0;r&16?o=r&8?0:1:(o=1,s=1);let c=r>>3&3,l=r>>1&3,u=i>>4&15,d=(i>>2&3)%3,f=i>>1&1,p=a>>6&3,m=a>>4&3,h=a>>3&1,g=a>>2&1,_=a&3,v=zz[o*16*4+l*16+u];if(v===-1)return{header:null,bytesAdvanced:1};let y=v*1e3,b=Rz[d]>>o+s,x=Bz(o,l,y,b,f);if(t!==null&&t<x)return{header:null,bytesAdvanced:1};let S;return S=c===3?l===3?384:1152:l===3?384:l===2?1152:576,{header:{totalSize:x,mpegVersionId:c,lowSamplingFrequency:o,layer:l,bitrate:y,frequencyIndex:d,sampleRate:b,channel:p,modeExtension:m,copyright:h,original:g,emphasis:_,audioSamplesInFrame:S},bytesAdvanced:1}},Wz=e=>{let t=2130706432,n=0;for(;t!==0;)n>>=1,n|=e&t,t>>=8;return n},Gz;(function(e){e[e.FrameCount=1]=`FrameCount`,e[e.FileSize=2]=`FileSize`,e[e.Toc=4]=`Toc`})(Gz||={});var Kz=e=>e===3?1:2,qz=[48e3,44100,32e3],Jz=[24e3,22050,16e3],Yz;(function(e){e[e.NON_IDR_SLICE=1]=`NON_IDR_SLICE`,e[e.SLICE_DPA=2]=`SLICE_DPA`,e[e.SLICE_DPB=3]=`SLICE_DPB`,e[e.SLICE_DPC=4]=`SLICE_DPC`,e[e.IDR=5]=`IDR`,e[e.SEI=6]=`SEI`,e[e.SPS=7]=`SPS`,e[e.PPS=8]=`PPS`,e[e.AUD=9]=`AUD`,e[e.SPS_EXT=13]=`SPS_EXT`})(Yz||={});var Xz;(function(e){e[e.RASL_N=8]=`RASL_N`,e[e.RASL_R=9]=`RASL_R`,e[e.BLA_W_LP=16]=`BLA_W_LP`,e[e.RSV_IRAP_VCL23=23]=`RSV_IRAP_VCL23`,e[e.VPS_NUT=32]=`VPS_NUT`,e[e.SPS_NUT=33]=`SPS_NUT`,e[e.PPS_NUT=34]=`PPS_NUT`,e[e.AUD_NUT=35]=`AUD_NUT`,e[e.PREFIX_SEI_NUT=39]=`PREFIX_SEI_NUT`,e[e.SUFFIX_SEI_NUT=40]=`SUFFIX_SEI_NUT`})(Xz||={});var Zz=function*(e){let t=0,n=-1;for(;t<e.length-2;){let r=e.indexOf(0,t);if(r===-1||r>=e.length-2)break;t=r;let i=0;if(t+3<e.length&&e[t+1]===0&&e[t+2]===0&&e[t+3]===1?i=4:e[t+1]===0&&e[t+2]===1&&(i=3),i===0){t++;continue}n!==-1&&t>n&&(yield{offset:n,length:t-n}),n=t+i,t=n}n!==-1&&n<e.length&&(yield{offset:n,length:e.length-n})},Qz=function*(e,t){let n=0,r=new DataView(e.buffer,e.byteOffset,e.byteLength);for(;n+t<=e.length;){let e;t===1?e=r.getUint8(n):t===2?e=r.getUint16(n,!1):t===3?e=sR(r,n,!1):(X(t===4),e=r.getUint32(n,!1)),n+=t,yield{offset:n,length:e},n+=e}},$z=(e,t)=>t.description?Qz(e,(NL(t.description)[4]&3)+1):Zz(e),eB=e=>e&31,tB=e=>{let t=[],n=e.length;for(let r=0;r<n;r++)r+2<n&&e[r]===0&&e[r+1]===0&&e[r+2]===3?(t.push(0,0),r+=2):t.push(e[r]);return new Uint8Array(t)},nB=new Uint8Array([0,0,0,1]),rB=e=>{let t=e.reduce((e,t)=>e+nB.byteLength+t.byteLength,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(nB,r),r+=nB.byteLength,n.set(t,r),r+=t.byteLength;return n},iB=(e,t)=>{let n=e.reduce((e,n)=>e+t+n.byteLength,0),r=new Uint8Array(n),i=0;for(let n of e){let e=new DataView(r.buffer,r.byteOffset,r.byteLength);switch(t){case 1:e.setUint8(i,n.byteLength);break;case 2:e.setUint16(i,n.byteLength,!1);break;case 3:lR(e,i,n.byteLength,!1);break;case 4:e.setUint32(i,n.byteLength,!1);break}i+=t,r.set(n,i),i+=n.byteLength}return r},aB=(e,t)=>t.description?iB(e,(NL(t.description)[4]&3)+1):rB(e),oB=e=>{try{let t=[],n=[],r=[];for(let i of Zz(e)){let a=e.subarray(i.offset,i.offset+i.length),o=eB(a[0]);o===Yz.SPS?t.push(a):o===Yz.PPS?n.push(a):o===Yz.SPS_EXT&&r.push(a)}if(t.length===0||n.length===0)return null;let i=t[0],a=uB(i);X(a!==null);let o=a.profileIdc===100||a.profileIdc===110||a.profileIdc===122||a.profileIdc===144;return{configurationVersion:1,avcProfileIndication:a.profileIdc,profileCompatibility:a.constraintFlags,avcLevelIndication:a.levelIdc,lengthSizeMinusOne:3,sequenceParameterSets:t,pictureParameterSets:n,chromaFormat:o?a.chromaFormatIdc:null,bitDepthLumaMinus8:o?a.bitDepthLumaMinus8:null,bitDepthChromaMinus8:o?a.bitDepthChromaMinus8:null,sequenceParameterSetExt:o?r:null}}catch(e){return console.error(`Error building AVC Decoder Configuration Record:`,e),null}},sB=e=>{let t=[];t.push(e.configurationVersion),t.push(e.avcProfileIndication),t.push(e.profileCompatibility),t.push(e.avcLevelIndication),t.push(252|e.lengthSizeMinusOne&3),t.push(224|e.sequenceParameterSets.length&31);for(let n of e.sequenceParameterSets){let e=n.byteLength;t.push(e>>8),t.push(e&255);for(let r=0;r<e;r++)t.push(n[r])}t.push(e.pictureParameterSets.length);for(let n of e.pictureParameterSets){let e=n.byteLength;t.push(e>>8),t.push(e&255);for(let r=0;r<e;r++)t.push(n[r])}if(e.avcProfileIndication===100||e.avcProfileIndication===110||e.avcProfileIndication===122||e.avcProfileIndication===144){X(e.chromaFormat!==null),X(e.bitDepthLumaMinus8!==null),X(e.bitDepthChromaMinus8!==null),X(e.sequenceParameterSetExt!==null),t.push(252|e.chromaFormat&3),t.push(248|e.bitDepthLumaMinus8&7),t.push(248|e.bitDepthChromaMinus8&7),t.push(e.sequenceParameterSetExt.length);for(let n of e.sequenceParameterSetExt){let e=n.byteLength;t.push(e>>8),t.push(e&255);for(let r=0;r<e;r++)t.push(n[r])}}return new Uint8Array(t)},cB=e=>{try{let t=PL(e),n=0,r=t.getUint8(n++),i=t.getUint8(n++),a=t.getUint8(n++),o=t.getUint8(n++),s=t.getUint8(n++)&3,c=t.getUint8(n++)&31,l=[];for(let r=0;r<c;r++){let r=t.getUint16(n,!1);n+=2,l.push(e.subarray(n,n+r)),n+=r}let u=t.getUint8(n++),d=[];for(let r=0;r<u;r++){let r=t.getUint16(n,!1);n+=2,d.push(e.subarray(n,n+r)),n+=r}let f={configurationVersion:r,avcProfileIndication:i,profileCompatibility:a,avcLevelIndication:o,lengthSizeMinusOne:s,sequenceParameterSets:l,pictureParameterSets:d,chromaFormat:null,bitDepthLumaMinus8:null,bitDepthChromaMinus8:null,sequenceParameterSetExt:null};if((i===100||i===110||i===122||i===144)&&n+4<=e.length){let r=t.getUint8(n++)&3,i=t.getUint8(n++)&7,a=t.getUint8(n++)&7,o=t.getUint8(n++);f.chromaFormat=r,f.bitDepthLumaMinus8=i,f.bitDepthChromaMinus8=a;let s=[];for(let r=0;r<o;r++){let r=t.getUint16(n,!1);n+=2,s.push(e.subarray(n,n+r)),n+=r}f.sequenceParameterSetExt=s}return f}catch(e){return console.error(`Error deserializing AVC Decoder Configuration Record:`,e),null}},lB={1:{num:1,den:1},2:{num:12,den:11},3:{num:10,den:11},4:{num:16,den:11},5:{num:40,den:33},6:{num:24,den:11},7:{num:20,den:11},8:{num:32,den:11},9:{num:80,den:33},10:{num:18,den:11},11:{num:15,den:11},12:{num:64,den:33},13:{num:160,den:99},14:{num:4,den:3},15:{num:3,den:2},16:{num:2,den:1}},uB=e=>{try{let t=new nz(tB(e));if(t.skipBits(1),t.skipBits(2),t.readBits(5)!==7)return null;let n=t.readAlignedByte(),r=t.readAlignedByte(),i=t.readAlignedByte();Z(t);let a=1,o=0,s=0,c=0;if((n===100||n===110||n===122||n===244||n===44||n===83||n===86||n===118||n===128)&&(a=Z(t),a===3&&(c=t.readBits(1)),o=Z(t),s=Z(t),t.skipBits(1),t.readBits(1))){for(let e=0;e<(a===3?12:8);e++)if(t.readBits(1)){let n=e<6?16:64,r=8,i=8;for(let e=0;e<n;e++){if(i!==0){let e=ML(t);i=(r+e+256)%256}r=i===0?r:i}}}Z(t);let l=Z(t);if(l===0)Z(t);else if(l===1){t.skipBits(1),ML(t),ML(t);let e=Z(t);for(let n=0;n<e;n++)ML(t)}Z(t),t.skipBits(1);let u=Z(t),d=Z(t),f=16*(u+1),p=16*(d+1),m=f,h=p,g=t.readBits(1);if(g||t.skipBits(1),t.skipBits(1),t.readBits(1)){let e=Z(t),n=Z(t),r=Z(t),i=Z(t),o,s;if((c===0?a:0)===0)o=1,s=2-g;else{let e=a===3?1:2,t=a===1?2:1;o=e,s=t*(2-g)}m-=o*(e+n),h-=s*(r+i)}let _=2,v=2,y=2,b=0,x={num:1,den:1},S=null,C=null;if(t.readBits(1)){if(t.readBits(1)){let e=t.readBits(8);if(e===255)x={num:t.readBits(16),den:t.readBits(16)};else{let t=lB[e];t&&(x=t)}}t.readBits(1)&&t.skipBits(1),t.readBits(1)&&(t.skipBits(3),b=t.readBits(1),t.readBits(1)&&(_=t.readBits(8),v=t.readBits(8),y=t.readBits(8))),t.readBits(1)&&(Z(t),Z(t)),t.readBits(1)&&(t.skipBits(32),t.skipBits(32),t.skipBits(1));let e=t.readBits(1);e&&dB(t);let n=t.readBits(1);n&&dB(t),(e||n)&&t.skipBits(1),t.skipBits(1),t.readBits(1)&&(t.skipBits(1),Z(t),Z(t),Z(t),Z(t),S=Z(t),C=Z(t))}if(S===null){X(C===null);let e=r&16;if((n===44||n===86||n===100||n===110||n===122||n===244)&&e)S=0,C=0;else{let e=u+1,t=d+1,n=(2-g)*t,r=fz.find(e=>e.level>=i)??AL(fz),a=Math.min(Math.floor(r.maxDpbMbs/(e*n)),16);S=a,C=a}}return X(C!==null),{profileIdc:n,constraintFlags:r,levelIdc:i,frameMbsOnlyFlag:g,chromaFormatIdc:a,bitDepthLumaMinus8:o,bitDepthChromaMinus8:s,codedWidth:f,codedHeight:p,displayWidth:m,displayHeight:h,pixelAspectRatio:x,colourPrimaries:_,matrixCoefficients:y,transferCharacteristics:v,fullRangeFlag:b,numReorderFrames:S,maxDecFrameBuffering:C}}catch(e){return console.error(`Error parsing AVC SPS:`,e),null}},dB=e=>{let t=Z(e);e.skipBits(4),e.skipBits(4);for(let n=0;n<=t;n++)Z(e),Z(e),e.skipBits(1);e.skipBits(5),e.skipBits(5),e.skipBits(5),e.skipBits(5)},fB=(e,t)=>t.description?iB(e,(NL(t.description)[21]&3)+1):rB(e),pB=(e,t)=>t.description?Qz(e,(NL(t.description)[21]&3)+1):Zz(e),mB=e=>e>>1&63,hB=e=>{try{let t=new nz(tB(e));t.skipBits(16),t.readBits(4);let n=t.readBits(3),r=t.readBits(1),{general_profile_space:i,general_tier_flag:a,general_profile_idc:o,general_profile_compatibility_flags:s,general_constraint_indicator_flags:c,general_level_idc:l}=_B(t,n);Z(t);let u=Z(t),d=0;u===3&&(d=t.readBits(1));let f=Z(t),p=Z(t),m=f,h=p;if(t.readBits(1)){let e=Z(t),n=Z(t),r=Z(t),i=Z(t),a=1,o=1,s=d===0?u:0;s===1?(a=2,o=2):s===2&&(a=2,o=1),m-=(e+n)*a,h-=(r+i)*o}let g=Z(t),_=Z(t);Z(t);let v=t.readBits(1)?0:n,y=0;for(let e=v;e<=n;e++)Z(t),y=Z(t),Z(t);if(Z(t),Z(t),Z(t),Z(t),Z(t),Z(t),t.readBits(1)&&t.readBits(1)&&vB(t),t.skipBits(1),t.skipBits(1),t.readBits(1)&&(t.skipBits(4),t.skipBits(4),Z(t),Z(t),t.skipBits(1)),yB(t,Z(t)),t.readBits(1)){let e=Z(t);for(let n=0;n<e;n++)Z(t),t.skipBits(1)}t.skipBits(1),t.skipBits(1);let b=2,x=2,S=2,C=0,w=0,T={num:1,den:1};if(t.readBits(1)){let e=xB(t,n);T=e.pixelAspectRatio,b=e.colourPrimaries,x=e.transferCharacteristics,S=e.matrixCoefficients,C=e.fullRangeFlag,w=e.minSpatialSegmentationIdc}return{displayWidth:m,displayHeight:h,pixelAspectRatio:T,colourPrimaries:b,transferCharacteristics:x,matrixCoefficients:S,fullRangeFlag:C,maxDecFrameBuffering:y+1,spsMaxSubLayersMinus1:n,spsTemporalIdNestingFlag:r,generalProfileSpace:i,generalTierFlag:a,generalProfileIdc:o,generalProfileCompatibilityFlags:s,generalConstraintIndicatorFlags:c,generalLevelIdc:l,chromaFormatIdc:u,bitDepthLumaMinus8:g,bitDepthChromaMinus8:_,minSpatialSegmentationIdc:w}}catch(e){return console.error(`Error parsing HEVC SPS:`,e),null}},gB=e=>{try{let t=[],n=[],r=[],i=[];for(let a of Zz(e)){let o=e.subarray(a.offset,a.offset+a.length),s=mB(o[0]);s===Xz.VPS_NUT?t.push(o):s===Xz.SPS_NUT?n.push(o):s===Xz.PPS_NUT?r.push(o):(s===Xz.PREFIX_SEI_NUT||s===Xz.SUFFIX_SEI_NUT)&&i.push(o)}if(n.length===0||r.length===0)return null;let a=hB(n[0]);if(!a)return null;let o=0;if(r.length>0){let e=r[0],t=new nz(tB(e));t.skipBits(16),Z(t),Z(t),t.skipBits(1),t.skipBits(1),t.skipBits(3),t.skipBits(1),t.skipBits(1),Z(t),Z(t),ML(t),t.skipBits(1),t.skipBits(1),t.readBits(1)&&Z(t),ML(t),ML(t),t.skipBits(1),t.skipBits(1),t.skipBits(1),t.skipBits(1);let n=t.readBits(1),i=t.readBits(1);o=!n&&!i?0:n&&!i?2:!n&&i?3:0}let s=[...t.length?[{arrayCompleteness:1,nalUnitType:Xz.VPS_NUT,nalUnits:t}]:[],...n.length?[{arrayCompleteness:1,nalUnitType:Xz.SPS_NUT,nalUnits:n}]:[],...r.length?[{arrayCompleteness:1,nalUnitType:Xz.PPS_NUT,nalUnits:r}]:[],...i.length?[{arrayCompleteness:1,nalUnitType:mB(i[0][0]),nalUnits:i}]:[]];return{configurationVersion:1,generalProfileSpace:a.generalProfileSpace,generalTierFlag:a.generalTierFlag,generalProfileIdc:a.generalProfileIdc,generalProfileCompatibilityFlags:a.generalProfileCompatibilityFlags,generalConstraintIndicatorFlags:a.generalConstraintIndicatorFlags,generalLevelIdc:a.generalLevelIdc,minSpatialSegmentationIdc:a.minSpatialSegmentationIdc,parallelismType:o,chromaFormatIdc:a.chromaFormatIdc,bitDepthLumaMinus8:a.bitDepthLumaMinus8,bitDepthChromaMinus8:a.bitDepthChromaMinus8,avgFrameRate:0,constantFrameRate:0,numTemporalLayers:a.spsMaxSubLayersMinus1+1,temporalIdNested:a.spsTemporalIdNestingFlag,lengthSizeMinusOne:3,arrays:s}}catch(e){return console.error(`Error building HEVC Decoder Configuration Record:`,e),null}},_B=(e,t)=>{let n=e.readBits(2),r=e.readBits(1),i=e.readBits(5),a=0;for(let t=0;t<32;t++)a=a<<1|e.readBits(1);let o=new Uint8Array(6);for(let t=0;t<6;t++)o[t]=e.readBits(8);let s=e.readBits(8),c=[],l=[];for(let n=0;n<t;n++)c.push(e.readBits(1)),l.push(e.readBits(1));if(t>0)for(let n=t;n<8;n++)e.skipBits(2);for(let n=0;n<t;n++)c[n]&&e.skipBits(88),l[n]&&e.skipBits(8);return{general_profile_space:n,general_tier_flag:r,general_profile_idc:i,general_profile_compatibility_flags:a,general_constraint_indicator_flags:o,general_level_idc:s}},vB=e=>{for(let t=0;t<4;t++)for(let n=0;n<(t===3?2:6);n++)if(!e.readBits(1))Z(e);else{let n=Math.min(64,1<<4+(t<<1));t>1&&ML(e);for(let t=0;t<n;t++)ML(e)}},yB=(e,t)=>{let n=[];for(let r=0;r<t;r++)n[r]=bB(e,r,t,n)},bB=(e,t,n,r)=>{let i=0,a=0,o=0;if(t!==0&&(a=e.readBits(1)),a){o=t===n?t-(Z(e)+1):t-1,e.readBits(1),Z(e);let a=r[o]??0;for(let t=0;t<=a;t++)e.readBits(1)||e.readBits(1);i=r[o]}else{let t=Z(e),n=Z(e);for(let n=0;n<t;n++)Z(e),e.readBits(1);for(let t=0;t<n;t++)Z(e),e.readBits(1);i=t+n}return i},xB=(e,t)=>{let n=2,r=2,i=2,a=0,o=0,s={num:1,den:1};if(e.readBits(1)){let t=e.readBits(8);if(t===255)s={num:e.readBits(16),den:e.readBits(16)};else{let e=lB[t];e&&(s=e)}}return e.readBits(1)&&e.readBits(1),e.readBits(1)&&(e.readBits(3),a=e.readBits(1),e.readBits(1)&&(n=e.readBits(8),r=e.readBits(8),i=e.readBits(8))),e.readBits(1)&&(Z(e),Z(e)),e.readBits(1),e.readBits(1),e.readBits(1),e.readBits(1)&&(Z(e),Z(e),Z(e),Z(e)),e.readBits(1)&&(e.readBits(32),e.readBits(32),e.readBits(1)&&Z(e),e.readBits(1)&&SB(e,!0,t)),e.readBits(1)&&(e.readBits(1),e.readBits(1),e.readBits(1),o=Z(e),Z(e),Z(e),Z(e),Z(e)),{pixelAspectRatio:s,colourPrimaries:n,transferCharacteristics:r,matrixCoefficients:i,fullRangeFlag:a,minSpatialSegmentationIdc:o}},SB=(e,t,n)=>{let r=!1,i=!1,a=!1;t&&(r=e.readBits(1)===1,i=e.readBits(1)===1,(r||i)&&(a=e.readBits(1)===1,a&&(e.readBits(8),e.readBits(5),e.readBits(1),e.readBits(5)),e.readBits(4),e.readBits(4),a&&e.readBits(4),e.readBits(5),e.readBits(5),e.readBits(5)));for(let t=0;t<=n;t++){let t=e.readBits(1)===1,n=!0;t||(n=e.readBits(1)===1);let o=!1;n?Z(e):o=e.readBits(1)===1;let s=1;o||(s=Z(e)+1),r&&CB(e,s,a),i&&CB(e,s,a)}},CB=(e,t,n)=>{for(let r=0;r<t;r++)Z(e),Z(e),n&&(Z(e),Z(e)),e.readBits(1)},wB=e=>{let t=[];t.push(e.configurationVersion),t.push((e.generalProfileSpace&3)<<6|(e.generalTierFlag&1)<<5|e.generalProfileIdc&31),t.push(e.generalProfileCompatibilityFlags>>>24&255),t.push(e.generalProfileCompatibilityFlags>>>16&255),t.push(e.generalProfileCompatibilityFlags>>>8&255),t.push(e.generalProfileCompatibilityFlags&255),t.push(...e.generalConstraintIndicatorFlags),t.push(e.generalLevelIdc&255),t.push(240|e.minSpatialSegmentationIdc>>8&15),t.push(e.minSpatialSegmentationIdc&255),t.push(252|e.parallelismType&3),t.push(252|e.chromaFormatIdc&3),t.push(248|e.bitDepthLumaMinus8&7),t.push(248|e.bitDepthChromaMinus8&7),t.push(e.avgFrameRate>>8&255),t.push(e.avgFrameRate&255),t.push((e.constantFrameRate&3)<<6|(e.numTemporalLayers&7)<<3|(e.temporalIdNested&1)<<2|e.lengthSizeMinusOne&3),t.push(e.arrays.length&255);for(let n of e.arrays){t.push((n.arrayCompleteness&1)<<7|0|n.nalUnitType&63),t.push(n.nalUnits.length>>8&255),t.push(n.nalUnits.length&255);for(let e of n.nalUnits){t.push(e.length>>8&255),t.push(e.length&255);for(let n=0;n<e.length;n++)t.push(e[n])}}return new Uint8Array(t)},TB;(function(e){e[e.audAllowed=0]=`audAllowed`,e[e.beforeFirstVcl=1]=`beforeFirstVcl`,e[e.afterFirstVcl=2]=`afterFirstVcl`,e[e.eoBitstreamAllowed=3]=`eoBitstreamAllowed`,e[e.noMoreDataAllowed=4]=`noMoreDataAllowed`})(TB||={});var EB=(e,t)=>{let n=new Set,r=TB.audAllowed;for(let i of pB(e,t)){if(r===TB.noMoreDataAllowed){n.add(i.offset);continue}let t=mB(e[i.offset]);if(r===TB.eoBitstreamAllowed&&t!==37){n.add(i.offset);continue}let a=!1;t===35?r>TB.audAllowed?a=!0:r=TB.beforeFirstVcl:t<=31?r>TB.afterFirstVcl?a=!0:r=TB.afterFirstVcl:t===36?r===TB.afterFirstVcl?r=TB.eoBitstreamAllowed:a=!0:t===37?r<TB.afterFirstVcl?a=!0:r=TB.noMoreDataAllowed:t===32||t===33||t===34||t===39||t>=41&&t<=44||t>=48&&t<=55?r>TB.beforeFirstVcl?a=!0:r=TB.beforeFirstVcl:(t===38||t===40||t>=45&&t<=47||t>=56&&t<=63)&&r<TB.afterFirstVcl&&(a=!0),a&&n.add(i.offset)}if(n.size===0)return null;let i=[];for(let r of pB(e,t))n.has(r.offset)||i.push(e.subarray(r.offset,r.offset+r.length));return fB(i,t)},DB=e=>{let t=new nz(e);if(t.readBits(2)!==2)return null;let n=t.readBits(1),r=(t.readBits(1)<<1)+n;if(r===3&&t.skipBits(1),t.readBits(1)===1||t.readBits(1)!==0||(t.skipBits(2),t.readBits(24)!==4817730))return null;let i=8;r>=2&&(i=t.readBits(1)?12:10);let a=t.readBits(3),o=0,s=0;if(a!==7)if(s=t.readBits(1),r===1||r===3){let e=t.readBits(1),n=t.readBits(1);o=!e&&!n?3:e&&!n?2:1,t.skipBits(1)}else o=1;else o=3,s=1;let c=t.readBits(16),l=t.readBits(16),u=(c+1)*(l+1),d=AL(mz).level;for(let e of mz)if(u<=e.maxPictureSize){d=e.level;break}return{profile:r,level:d,bitDepth:i,chromaSubsampling:o,videoFullRangeFlag:s,colourPrimaries:a===2?1:a===1?6:2,transferCharacteristics:a===2?1:a===1?6:2,matrixCoefficients:a===7?0:a===2?1:a===1?6:2}},OB=function*(e){let t=new nz(e),n=()=>{let e=0;for(let n=0;n<8;n++){let r=t.readAlignedByte();if(e|=(r&127)<<n*7,!(r&128))break;if(n===7&&r&128)return null}return e>=2**32-1?null:e};for(;t.getBitsLeft()>=8;){t.skipBits(1);let r=t.readBits(4),i=t.readBits(1),a=t.readBits(1);t.skipBits(1),i&&t.skipBits(8);let o;if(a){let e=n();if(e===null)return;o=e}else o=Math.floor(t.getBitsLeft()/8);X(t.pos%8==0),yield{type:r,data:e.subarray(t.pos/8,t.pos/8+o)},t.skipBits(o*8)}},kB=e=>{for(let{type:t,data:n}of OB(e)){if(t!==1)continue;let e=new nz(n),r=e.readBits(3);e.readBits(1);let i=e.readBits(1),a=0,o=0,s=0;if(i)a=e.readBits(5);else{if(e.readBits(1)&&(e.skipBits(32),e.skipBits(32),e.readBits(1)))return null;let t=e.readBits(1);t&&(s=e.readBits(5),e.skipBits(32),e.skipBits(5),e.skipBits(5));let n=e.readBits(5);for(let r=0;r<=n;r++){e.skipBits(12);let n=e.readBits(5);if(r===0&&(a=n),n>7){let t=e.readBits(1);r===0&&(o=t)}if(t&&e.readBits(1)){let t=s+1;e.skipBits(t),e.skipBits(t),e.skipBits(1)}e.readBits(1)&&e.skipBits(4)}}let c=e.readBits(4),l=e.readBits(4),u=c+1;e.skipBits(u);let d=l+1;e.skipBits(d);let f=0;if(f=i?0:e.readBits(1),f&&(e.skipBits(4),e.skipBits(3)),e.skipBits(1),e.skipBits(1),e.skipBits(1),!i){e.skipBits(1),e.skipBits(1),e.skipBits(1),e.skipBits(1);let t=e.readBits(1);t&&(e.skipBits(1),e.skipBits(1));let n=e.readBits(1),r=0;r=n?2:e.readBits(1),r>0&&(e.readBits(1)||e.skipBits(1)),t&&e.skipBits(3)}e.skipBits(1),e.skipBits(1),e.skipBits(1);let p=e.readBits(1),m=8;r===2&&p?m=e.readBits(1)?12:10:r<=2&&(m=p?10:8);let h=0;r!==1&&(h=e.readBits(1));let g=1,_=1,v=0;return h||(r===0?(g=1,_=1):r===1?(g=0,_=0):m===12&&(g=e.readBits(1),g&&(_=e.readBits(1))),g&&_&&(v=e.readBits(2))),{profile:r,level:a,tier:o,bitDepth:m,monochrome:h,chromaSubsamplingX:g,chromaSubsamplingY:_,chromaSamplePosition:v}}return null},AB=e=>{let t=PL(e),n=t.getUint8(9),r=t.getUint16(10,!0),i=t.getUint32(12,!0),a=t.getInt16(16,!0),o=t.getUint8(18),s=null;return o&&(s=e.subarray(19,21+n)),{outputChannelCount:n,preSkip:r,inputSampleRate:i,outputGain:a,channelMappingFamily:o,channelMappingTable:s}},jB=[480,960,1920,2880,480,960,1920,2880,480,960,1920,2880,480,960,480,960,120,240,480,960,120,240,480,960,120,240,480,960,120,240,480,960],MB=e=>({durationInSamples:jB[e[0]>>3]}),NB=e=>{if(e.length<7)throw Error(`Setup header is too short.`);if(e[0]!==5)throw Error(`Wrong packet type in Setup header.`);if(String.fromCharCode(...e.slice(1,7))!==`vorbis`)throw Error(`Invalid packet signature in Setup header.`);let t=e.length,n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=e[t-1-r];let r=new nz(n),i=0;for(;r.getBitsLeft()>97;)if(r.readBits(1)===1){i=r.pos;break}if(i===0)throw Error(`Invalid Setup header: framing bit not found.`);let a=0,o=!1,s=0;for(;r.getBitsLeft()>=97;){let e=r.pos,t=r.readBits(8),n=r.readBits(16),i=r.readBits(16);if(t>63||n!==0||i!==0){r.pos=e;break}if(r.skipBits(1),a++,a>64)break;r.clone().readBits(6)+1===a&&(o=!0,s=a)}if(!o)throw Error(`Invalid Setup header: mode header not found.`);if(s>63)throw Error(`Unsupported mode count: ${s}.`);let c=s;r.pos=0,r.skipBits(i);let l=Array(c).fill(0);for(let e=c-1;e>=0;e--)r.skipBits(40),l[e]=r.readBits(1);return{modeBlockflags:l}},PB=(e,t,n)=>{switch(e){case`avc`:for(let e of $z(n,t)){let t=n[e.offset],r=eB(t);if(r>=Yz.NON_IDR_SLICE&&r<=Yz.SLICE_DPC)return`delta`;if(r===Yz.IDR)return`key`;if(r===Yz.SEI&&(!MR()||PR()>=144)){let t=tB(n.subarray(e.offset,e.offset+e.length)),r=1;do{let e=0;for(;;){let n=t[r++];if(n===void 0||(e+=n,n<255))break}let n=0;for(;;){let e=t[r++];if(e===void 0||(n+=e,e<255))break}if(e===6){let e=new nz(t);e.pos=8*r;let n=Z(e),i=e.readBits(1);if(n===0&&i===1)return`key`}r+=n}while(r<t.length-1)}}return`delta`;case`hevc`:for(let e of pB(n,t)){let t=mB(n[e.offset]);if(t<Xz.BLA_W_LP)return`delta`;if(t<=Xz.RSV_IRAP_VCL23)return`key`}return`delta`;case`vp8`:return n[0]&1?`delta`:`key`;case`vp9`:{let e=new nz(n);if(e.readBits(2)!==2)return null;let t=e.readBits(1);return(e.readBits(1)<<1)+t===3&&e.skipBits(1),e.readBits(1)?null:e.readBits(1)===0?`key`:`delta`}case`av1`:{let e=!1;for(let{type:t,data:r}of OB(n))if(t===1){let t=new nz(r);t.skipBits(4),e=!!t.readBits(1)}else if(t===3||t===6||t===7){if(e)return`key`;let t=new nz(r);return t.readBits(1)?null:t.readBits(2)===0?`key`:`delta`}return null}default:oR(e),X(!1)}},FB;(function(e){e[e.STREAMINFO=0]=`STREAMINFO`,e[e.VORBIS_COMMENT=4]=`VORBIS_COMMENT`,e[e.PICTURE=6]=`PICTURE`})(FB||={});var IB=(e,t)=>{let n=PL(e),r=0,i=n.getUint32(r,!0);r+=4;let a=FL.decode(e.subarray(r,r+i));r+=i,i>0&&(t.raw??={},t.raw.vendor??=a);let o=n.getUint32(r,!0);r+=4;for(let i=0;i<o;i++){let i=n.getUint32(r,!0);r+=4;let a=FL.decode(e.subarray(r,r+i));r+=i;let o=a.indexOf(`=`);if(o===-1)continue;let s=a.slice(0,o).toUpperCase(),c=a.slice(o+1);switch(t.raw??={},t.raw[s]??=c,s){case`TITLE`:t.title??=c;break;case`DESCRIPTION`:t.description??=c;break;case`ARTIST`:t.artist??=c;break;case`ALBUM`:t.album??=c;break;case`ALBUMARTIST`:t.albumArtist??=c;break;case`COMMENT`:t.comment??=c;break;case`LYRICS`:t.lyrics??=c;break;case`TRACKNUMBER`:{let e=c.split(`/`),n=Number.parseInt(e[0],10),r=e[1]&&Number.parseInt(e[1],10);Number.isInteger(n)&&n>0&&(t.trackNumber??=n),r&&Number.isInteger(r)&&r>0&&(t.tracksTotal??=r)}break;case`TRACKTOTAL`:{let e=Number.parseInt(c,10);Number.isInteger(e)&&e>0&&(t.tracksTotal??=e)}break;case`DISCNUMBER`:{let e=c.split(`/`),n=Number.parseInt(e[0],10),r=e[1]&&Number.parseInt(e[1],10);Number.isInteger(n)&&n>0&&(t.discNumber??=n),r&&Number.isInteger(r)&&r>0&&(t.discsTotal??=r)}break;case`DISCTOTAL`:{let e=Number.parseInt(c,10);Number.isInteger(e)&&e>0&&(t.discsTotal??=e)}break;case`DATE`:{let e=new Date(c);Number.isNaN(e.getTime())||(t.date??=e)}break;case`GENRE`:t.genre??=c;break;case`METADATA_BLOCK_PICTURE`:{let e=RR(c),n=PL(e),r=n.getUint32(0,!1),i=n.getUint32(4,!1),a=String.fromCharCode(...e.subarray(8,8+i)),o=n.getUint32(8+i,!1),s=FL.decode(e.subarray(12+i,12+i+o)),l=n.getUint32(i+o+28),u=e.subarray(i+o+32,i+o+32+l);t.images??=[],t.images.push({data:u,mimeType:a,kind:r===3?`coverFront`:r===4?`coverBack`:`unknown`,name:void 0,description:s||void 0})}break}}},LB=[2,1,2,3,3,4,4,5],RB=e=>{if(e.length<7||e[0]!==11||e[1]!==119)return null;let t=new nz(e);t.skipBits(16),t.skipBits(16);let n=t.readBits(2);if(n===3)return null;let r=t.readBits(6),i=t.readBits(5);if(i>8)return null;let a=t.readBits(3),o=t.readBits(3);return o&1&&o!==1&&t.skipBits(2),o&4&&t.skipBits(2),o===2&&t.skipBits(2),{fscod:n,bsid:i,bsmod:a,acmod:o,lfeon:t.readBits(1),bitRateCode:Math.floor(r/2)}},zB=[128,138,192,128,140,192,160,174,240,160,176,240,192,208,288,192,210,288,224,242,336,224,244,336,256,278,384,256,280,384,320,348,480,320,350,480,384,416,288*2,384,418,288*2,448,486,336*2,448,488,336*2,256*2,278*2,384*2,256*2,279*2,384*2,320*2,348*2,480*2,320*2,349*2,480*2,384*2,417*2,576*2,384*2,418*2,576*2,448*2,487*2,672*2,448*2,488*2,672*2,512*2,557*2,768*2,512*2,558*2,768*2,640*2,696*2,960*2,640*2,697*2,960*2,768*2,835*2,1152*2,768*2,836*2,1152*2,896*2,975*2,1344*2,896*2,976*2,1344*2,1024*2,1114*2,1536*2,1024*2,1115*2,1536*2,1152*2,1253*2,1728*2,1152*2,1254*2,1728*2,1280*2,1393*2,1920*2,1280*2,1394*2,1920*2],BB=1536;new Uint8Array([5,4,65,67,45,51]),new Uint8Array([5,4,69,65,67,51]);var VB=[1,2,3,6],HB=e=>{if(e.length<6||e[0]!==11||e[1]!==119)return null;let t=new nz(e);t.skipBits(16);let n=t.readBits(2);if(t.skipBits(3),n!==0&&n!==2)return null;let r=t.readBits(11),i=t.readBits(2),a=0,o;i===3?(a=t.readBits(2),o=3):o=t.readBits(2);let s=t.readBits(3),c=t.readBits(1),l=t.readBits(5);if(l<11||l>16)return null;let u=VB[o],d;return d=i<3?qz[i]/1e3:Jz[a]/1e3,{dataRate:Math.round((r+1)*d/(u*16)),substreams:[{fscod:i,fscod2:a,bsid:l,bsmod:0,acmod:s,lfeon:c,numDepSub:0,chanLoc:0}]}},UB=e=>{if(e.length<2)return null;let t=new nz(e),n=t.readBits(13),r=t.readBits(3),i=[];for(let n=0;n<=r&&!(Math.ceil(t.pos/8)+3>e.length);n++){let e=t.readBits(2),n=t.readBits(5);t.skipBits(1),t.skipBits(1);let r=t.readBits(3),a=t.readBits(3),o=t.readBits(1);t.skipBits(3);let s=t.readBits(4),c=0;s>0?c=t.readBits(9):t.skipBits(1),i.push({fscod:e,fscod2:null,bsid:n,bsmod:r,acmod:a,lfeon:o,numDepSub:s,chanLoc:c})}return i.length===0?null:{dataRate:n,substreams:i}},WB=e=>{let t=e.substreams[0];return X(t),t.fscod<3?qz[t.fscod]:t.fscod2!==null&&t.fscod2<3?Jz[t.fscod2]:null},GB=e=>{let t=e.substreams[0];X(t);let n=LB[t.acmod]+t.lfeon;if(t.numDepSub>0){let e=[2,2,1,1,2,2,2,1,1];for(let r=0;r<9;r++)t.chanLoc&1<<8-r&&(n+=e[r])}return n},KB=class{constructor(e){this.input=e}dispose(){}},qB=new Uint8Array,JB=class e{constructor(e,t,n,r,i=-1,a,o){if(this.data=e,this.type=t,this.timestamp=n,this.duration=r,this.sequenceNumber=i,e===qB&&a===void 0)throw Error(`Internal error: byteLength must be explicitly provided when constructing metadata-only packets.`);if(a===void 0&&(a=e.byteLength),!(e instanceof Uint8Array))throw TypeError(`data must be a Uint8Array.`);if(t!==`key`&&t!==`delta`)throw TypeError(`type must be either "key" or "delta".`);if(!Number.isFinite(n))throw TypeError(`timestamp must be a number.`);if(!Number.isFinite(r)||r<0)throw TypeError(`duration must be a non-negative number.`);if(!Number.isFinite(i))throw TypeError(`sequenceNumber must be a number.`);if(!Number.isInteger(a)||a<0)throw TypeError(`byteLength must be a non-negative integer.`);if(o!==void 0&&(typeof o!=`object`||!o))throw TypeError(`sideData, when provided, must be an object.`);if(o?.alpha!==void 0&&!(o.alpha instanceof Uint8Array))throw TypeError(`sideData.alpha, when provided, must be a Uint8Array.`);if(o?.alphaByteLength!==void 0&&(!Number.isInteger(o.alphaByteLength)||o.alphaByteLength<0))throw TypeError(`sideData.alphaByteLength, when provided, must be a non-negative integer.`);this.byteLength=a,this.sideData=o??{},this.sideData.alpha&&this.sideData.alphaByteLength===void 0&&(this.sideData.alphaByteLength=this.sideData.alpha.byteLength)}get isMetadataOnly(){return this.data===qB}get microsecondTimestamp(){return Math.trunc(xR*this.timestamp)}get microsecondDuration(){return Math.trunc(xR*this.duration)}toEncodedVideoChunk(){if(this.isMetadataOnly)throw TypeError(`Metadata-only packets cannot be converted to a video chunk.`);if(typeof EncodedVideoChunk>`u`)throw Error(`Your browser does not support EncodedVideoChunk.`);return new EncodedVideoChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}alphaToEncodedVideoChunk(e=this.type){if(!this.sideData.alpha)throw TypeError(`This packet does not contain alpha side data.`);if(this.isMetadataOnly)throw TypeError(`Metadata-only packets cannot be converted to a video chunk.`);if(typeof EncodedVideoChunk>`u`)throw Error(`Your browser does not support EncodedVideoChunk.`);return new EncodedVideoChunk({data:this.sideData.alpha,type:e,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}toEncodedAudioChunk(){if(this.isMetadataOnly)throw TypeError(`Metadata-only packets cannot be converted to an audio chunk.`);if(typeof EncodedAudioChunk>`u`)throw Error(`Your browser does not support EncodedAudioChunk.`);return new EncodedAudioChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}static fromEncodedChunk(t,n){if(!(t instanceof EncodedVideoChunk||t instanceof EncodedAudioChunk))throw TypeError(`chunk must be an EncodedVideoChunk or EncodedAudioChunk.`);let r=new Uint8Array(t.byteLength);return t.copyTo(r),new e(r,t.type,t.timestamp/1e6,(t.duration??0)/1e6,void 0,void 0,n)}clone(t){if(t!==void 0&&(typeof t!=`object`||!t))throw TypeError(`options, when provided, must be an object.`);if(t?.data!==void 0&&!(t.data instanceof Uint8Array))throw TypeError(`options.data, when provided, must be a Uint8Array.`);if(t?.type!==void 0&&t.type!==`key`&&t.type!==`delta`)throw TypeError(`options.type, when provided, must be either "key" or "delta".`);if(t?.timestamp!==void 0&&!Number.isFinite(t.timestamp))throw TypeError(`options.timestamp, when provided, must be a number.`);if(t?.duration!==void 0&&!Number.isFinite(t.duration))throw TypeError(`options.duration, when provided, must be a number.`);if(t?.sequenceNumber!==void 0&&!Number.isFinite(t.sequenceNumber))throw TypeError(`options.sequenceNumber, when provided, must be a number.`);if(t?.sideData!==void 0&&(typeof t.sideData!=`object`||t.sideData===null))throw TypeError(`options.sideData, when provided, must be an object.`);return new e(t?.data??this.data,t?.type??this.type,t?.timestamp??this.timestamp,t?.duration??this.duration,t?.sequenceNumber??this.sequenceNumber,this.byteLength,t?.sideData??this.sideData)}},YB=e=>{let t=(e.hasVideo?`video/`:e.hasAudio?`audio/`:`application/`)+(e.isQuickTime?`quicktime`:`mp4`);if(e.codecStrings.length>0){let n=[...new Set(e.codecStrings)];t+=`; codecs="${n.join(`, `)}"`}return t},XB=e=>{let t=PL(e),n=0,r=t.getUint8(n);n+=1,n+=3;let i=JL(e.subarray(n,n+16));n+=16;let a=null;if(r>0){let r=t.getUint32(n);if(n+=4,r>0){a=[];for(let t=0;t<r;t++)a.push(JL(e.subarray(n,n+16))),n+=16}}let o=t.getUint32(n);return n+=4,{systemId:i,keyIds:a,data:e.slice(n,n+o)}},ZB=(e,t)=>e.systemId===t.systemId&&zR(e.data,t.data),QB=e=>{let t=$(e),n=tK(e,4),r=8;t===1&&(t=XG(e),r=16);let i=t-r;return i<0?null:{name:n,totalSize:t,headerSize:r,contentSize:i}},$B=e=>qG(e)/65536,eV=e=>qG(e)/1073741824,tV=e=>{let t=0;for(let n=0;n<4;n++){t<<=7;let n=BG(e);if(t|=n&127,!(n&128))break}return t},nV=e=>{let t=HG(e);return e.skip(2),t=Math.min(t,e.remainingLength),FL.decode(zG(e,t))},rV=e=>{let t=QB(e);if(!t||t.name!==`data`||e.remainingLength<8)return null;let n=$(e);e.skip(4);let r=zG(e,t.contentSize-8);switch(n){case 1:return FL.decode(r);case 2:return new TextDecoder(`utf-16be`).decode(r);case 13:return new ZR(r,`image/jpeg`);case 14:return new ZR(r,`image/png`);case 27:return new ZR(r,`image/bmp`);default:return r}},iV=new Uint32Array(256),aV=new Uint32Array(256),oV=new Uint32Array(256),sV=new Uint32Array(256),cV=new Uint32Array(256),lV=new Uint32Array(256),uV=new Uint32Array(10),dV=!1,fV=()=>{let e=new Uint8Array(256),t=new Uint8Array(256),n=new Uint8Array(256);for(let e=0,r=1;e<256;e++)n[e]=r,t[r]=e,r=r^r<<1^(r&128?283:0);let r=(e,r)=>e&&r?n[(t[e]+t[r])%255]:0;e[0]=99;for(let r=1;r<256;r++){let i=n[255-t[r]],a=i^i<<1^i<<2^i<<3^i<<4;a=a>>>8^a&255^99,e[r]=a}for(let t=0;t<256;t++){let n=e[t],i=e.indexOf(t);iV[t]=n<<24|n<<16|n<<8|n,lV[t]=i<<24|i<<16|i<<8|i;let a=r(i,14),o=r(i,9),s=r(i,13),c=r(i,11),l=a<<24|o<<16|s<<8|c;aV[t]=l,oV[t]=l>>>8|l<<24,sV[t]=l>>>16|l<<16,cV[t]=l>>>24|l<<8}let i=1;for(let e=0;e<10;e++)uV[e]=i<<24,i=i<<1^(i&128?283:0);dV=!0},pV=class{constructor(){this.roundkey=new Uint32Array(44),this.iv=new Uint32Array(16/Uint32Array.BYTES_PER_ELEMENT),this.in=new Uint8Array(16),this.out=new Uint8Array(16),this.inView=new DataView(this.in.buffer),this.outView=new DataView(this.out.buffer)}init({key:e,iv:t}){X(e.byteLength===16),X(t.byteLength===16),dV||fV();let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=new DataView(t.buffer,t.byteOffset,t.byteLength);this.roundkey[0]=n.getUint32(0,!1),this.roundkey[1]=n.getUint32(4,!1),this.roundkey[2]=n.getUint32(8,!1),this.roundkey[3]=n.getUint32(12,!1),this.iv[0]=r.getUint32(0,!1),this.iv[1]=r.getUint32(4,!1),this.iv[2]=r.getUint32(8,!1),this.iv[3]=r.getUint32(12,!1);for(let e=4;e<44;e+=4){let t=this.roundkey[e-1];this.roundkey[e]=this.roundkey[e-4]^iV[t>>>16&255]&4278190080^iV[t>>>8&255]&16711680^iV[t>>>0&255]&65280^iV[t>>>24&255]&255^uV[e/4-1],this.roundkey[e+1]=this.roundkey[e-3]^this.roundkey[e],this.roundkey[e+2]=this.roundkey[e-2]^this.roundkey[e+1],this.roundkey[e+3]=this.roundkey[e-1]^this.roundkey[e+2]}for(let e=0,t=40;e<t;e+=4,t-=4)for(let n=0;n<4;n++){let r=this.roundkey[e+n];this.roundkey[e+n]=this.roundkey[t+n],this.roundkey[t+n]=r}for(let e=4;e<40;e+=4)for(let t=0;t<4;t++){let n=this.roundkey[e+t];this.roundkey[e+t]=aV[iV[n>>>24&255]&255]^oV[iV[n>>>16&255]&255]^sV[iV[n>>>8&255]&255]^cV[iV[n>>>0&255]&255]}}decrypt(){let e=this.inView.getUint32(0,!1)^this.roundkey[0],t=this.inView.getUint32(4,!1)^this.roundkey[1],n=this.inView.getUint32(8,!1)^this.roundkey[2],r=this.inView.getUint32(12,!1)^this.roundkey[3],i=this.inView.getUint32(0,!1),a=this.inView.getUint32(4,!1),o=this.inView.getUint32(8,!1),s=this.inView.getUint32(12,!1),c,l,u,d;for(let i=1;i<10;i++){let a=i*4;c=aV[e>>>24]^oV[r>>>16&255]^sV[n>>>8&255]^cV[t&255]^this.roundkey[a],l=aV[t>>>24]^oV[e>>>16&255]^sV[r>>>8&255]^cV[n&255]^this.roundkey[a+1],u=aV[n>>>24]^oV[t>>>16&255]^sV[e>>>8&255]^cV[r&255]^this.roundkey[a+2],d=aV[r>>>24]^oV[n>>>16&255]^sV[t>>>8&255]^cV[e&255]^this.roundkey[a+3],e=c,t=l,n=u,r=d}let f=lV[e>>>24&255]&4278190080^lV[r>>>16&255]&16711680^lV[n>>>8&255]&65280^lV[t>>>0&255]&255^this.roundkey[40],p=lV[t>>>24&255]&4278190080^lV[e>>>16&255]&16711680^lV[r>>>8&255]&65280^lV[n>>>0&255]&255^this.roundkey[41],m=lV[n>>>24&255]&4278190080^lV[t>>>16&255]&16711680^lV[e>>>8&255]&65280^lV[r>>>0&255]&255^this.roundkey[42],h=lV[r>>>24&255]&4278190080^lV[n>>>16&255]&16711680^lV[t>>>8&255]&65280^lV[e>>>0&255]&255^this.roundkey[43];this.outView.setUint32(0,f^this.iv[0],!1),this.outView.setUint32(4,p^this.iv[1],!1),this.outView.setUint32(8,m^this.iv[2],!1),this.outView.setUint32(12,h^this.iv[3],!1),this.iv[0]=i,this.iv[1]=a,this.iv[2]=o,this.iv[3]=s}},mV=(e,t,n)=>{let r=!1,i=0,a=2**16,o=new pV;return new ReadableStream({pull:async s=>{r||=(o.init(await t()),!0);let c=a+16,l=e.requestSliceRange(i,0,c);if(l instanceof Promise&&(l=await l),!l||l.length===0)throw Error(`Invalid ciphertext.`);let u=l.length;if(u%16!=0)throw Error(`Invalid ciphertext.`);let d=u===c?u-16:u,f=zG(l,d),p=new Uint8Array(d);for(let e=0;e<d;e+=16)o.in.set(f.subarray(e,e+16)),o.decrypt(),p.set(o.out,e);if(d<u)s.enqueue(p),i+=d;else{let e=p[d-1];if(e===0||e>16)throw Error(`Invalid PKCS#7 padding. Incorrect key or corrupted data.`);let t=p.subarray(0,d-e);s.enqueue(t),s.close(),n()}},cancel:()=>{n()}})},hV=class e extends KB{constructor(e){super(e),this.moovSlice=null,this.currentTrack=null,this.tracks=[],this.metadataPromise=null,this.movieTimescale=-1,this.movieDurationInTimescale=-1,this.isQuickTime=!1,this.metadataTags={},this.currentMetadataKeys=null,this.isFragmented=!1,this.fragmentTrackDefaults=[],this.psshBoxes=[],this.currentFragment=null,this.lastReadFragment=null,this.decryptionKeyCache=new Map,this.reader=e._reader}async getTrackBackings(){return await this.readMetadata(),this.tracks.map(e=>e.trackBacking)}async getMimeType(){await this.readMetadata();let e=await this.getTrackBackings(),t=await Promise.all(e.map(e=>e.getDecoderConfig().then(e=>e?.codec??null)));return YB({isQuickTime:this.isQuickTime,hasVideo:this.tracks.some(e=>e.info?.type===`video`),hasAudio:this.tracks.some(e=>e.info?.type===`audio`),codecStrings:t.filter(Boolean)})}async getMetadataTags(){return await this.readMetadata(),this.metadataTags}readMetadata(){return this.metadataPromise??=(async()=>{let t=0,n=!1;for(;;){let r=this.reader.requestSliceRange(t,8,16);if(r instanceof Promise&&(r=await r),!r)break;let i=t,a=QB(r);if(!a)break;if(a.name===`ftyp`||a.name===`styp`){let e=tK(r,4);this.isQuickTime=e===`qt `}else if(a.name===`moov`){let e=this.reader.requestSlice(r.filePos,a.contentSize);if(e instanceof Promise&&(e=await e),!e)break;this.moovSlice=e,this.readContiguousBoxes(this.moovSlice);for(let e of this.tracks){let t=e.editListPreviousSegmentDurations/this.movieTimescale;e.editListOffset-=Math.round(t*e.timescale)}n=this.isFragmented&&this.reader.fileSize!==null&&this.reader.fileSize>i+a.totalSize;break}else if(a.name===`moof`){if(!this.input._initInput)throw Error(`"moof" box encountered with no "moov" box present; this file is likely a Segment as described in ISO/IEC 14496-12 Section 8.16. A separate init file that contains a "moov" box is required to read this file, please provide it using InputOptions.initInput.`);let t=await this.input._initInput._getDemuxer();if(t.constructor!==e)throw Error(`Init input must match the input's format.`);await t.readMetadata(),this.movieTimescale=t.movieTimescale,this.movieDurationInTimescale=t.movieDurationInTimescale,this.metadataTags=t.metadataTags,this.isFragmented=!0,this.fragmentTrackDefaults=t.fragmentTrackDefaults,this.psshBoxes=t.psshBoxes;for(let e of t.tracks){let t={id:e.id,demuxer:this,trackBacking:null,disposition:e.disposition,timescale:e.timescale,durationInMediaTimescale:e.durationInMediaTimescale,durationInMovieTimescale:e.durationInMovieTimescale,rotation:e.rotation,internalCodecId:e.internalCodecId,name:e.name,languageCode:e.languageCode,sampleTableByteOffset:null,sampleTable:null,fragmentLookupTable:[],currentFragmentState:null,fragmentPositionCache:[],editListPreviousSegmentDurations:e.editListPreviousSegmentDurations,editListOffset:e.editListOffset,encryptionInfo:e.encryptionInfo,encryptionAuxInfo:null,frmaCodecString:null,info:e.info};e.trackBacking&&(X(t.info),t.info.type===`video`&&t.info.width!==-1?(t.trackBacking=new _V(t),this.tracks.push(t)):t.info.type===`audio`&&t.info.numberOfChannels!==-1&&(t.trackBacking=new vV(t),this.tracks.push(t)))}n=!1;break}t=i+a.totalSize}if(n){X(this.reader.fileSize!==null);let e=this.reader.requestSlice(this.reader.fileSize-4,4);e instanceof Promise&&(e=await e),X(e);let t=$(e),n=this.reader.fileSize-t;if(n>=0&&n<=this.reader.fileSize-16){let e=this.reader.requestSliceRange(n,8,16);if(e instanceof Promise&&(e=await e),e){let t=QB(e);if(t&&t.name===`mfra`){let n=this.reader.requestSlice(e.filePos,t.contentSize);n instanceof Promise&&(n=await n),n&&this.readContiguousBoxes(n)}}}}})()}getSampleTableForTrack(e){if(e.sampleTable)return e.sampleTable;let t={sampleTimingEntries:[],sampleCompositionTimeOffsets:[],sampleSizes:[],keySampleIndices:null,chunkOffsets:[],sampleToChunk:[],presentationTimestamps:null,presentationTimestampIndexMap:null};if(e.sampleTable=t,e.sampleTableByteOffset===null)return t;X(this.moovSlice);let n=this.moovSlice.slice(e.sampleTableByteOffset);if(this.currentTrack=e,this.traverseBox(n),this.currentTrack=null,e.info?.type===`audio`&&e.info.codec&&cz.includes(e.info.codec)&&t.sampleCompositionTimeOffsets.length===0){X(e.info?.type===`audio`);let n=Tz(e.info.codec),r=[],i=[];for(let a=0;a<t.sampleToChunk.length;a++){let o=t.sampleToChunk[a],s=t.sampleToChunk[a+1],c=(s?s.startChunkIndex:t.chunkOffsets.length)-o.startChunkIndex;for(let a=0;a<c;a++){let s=o.startSampleIndex+a*o.samplesPerChunk,c=s+o.samplesPerChunk,l=QL(t.sampleTimingEntries,s,e=>e.startIndex),u=t.sampleTimingEntries[l],d=QL(t.sampleTimingEntries,c,e=>e.startIndex),f=t.sampleTimingEntries[d],p=u.startDecodeTimestamp+(s-u.startIndex)*u.delta,m=f.startDecodeTimestamp+(c-f.startIndex)*f.delta-p,h=AL(r);h&&h.delta===m?h.count++:r.push({startIndex:o.startChunkIndex+a,startDecodeTimestamp:p,count:1,delta:m});let g=o.samplesPerChunk*n.sampleSize*e.info.numberOfChannels;i.push(g)}o.startSampleIndex=o.startChunkIndex,o.samplesPerChunk=1}t.sampleTimingEntries=r,t.sampleSizes=i}if(t.sampleCompositionTimeOffsets.length>0){t.presentationTimestamps=[];for(let e of t.sampleTimingEntries)for(let n=0;n<e.count;n++)t.presentationTimestamps.push({presentationTimestamp:e.startDecodeTimestamp+n*e.delta,sampleIndex:e.startIndex+n});for(let e of t.sampleCompositionTimeOffsets)for(let n=0;n<e.count;n++){let r=e.startIndex+n,i=t.presentationTimestamps[r];i&&(i.presentationTimestamp+=e.offset)}t.presentationTimestamps.sort((e,t)=>e.presentationTimestamp-t.presentationTimestamp),t.presentationTimestampIndexMap=Array(t.presentationTimestamps.length).fill(-1);for(let e=0;e<t.presentationTimestamps.length;e++)t.presentationTimestampIndexMap[t.presentationTimestamps[e].sampleIndex]=e}return t}async readFragment(e){if(this.lastReadFragment?.moofOffset===e)return this.lastReadFragment;let t=this.reader.requestSliceRange(e,8,16);t instanceof Promise&&(t=await t),X(t);let n=QB(t);X(n?.name===`moof`);let r=this.reader.requestSlice(e,n.totalSize);r instanceof Promise&&(r=await r),X(r),this.traverseBox(r);let i=this.lastReadFragment;X(i&&i.moofOffset===e);for(let[,e]of i.trackData){let t=e.track,{fragmentPositionCache:n}=t;if(!e.startTimestampIsFinal){let r=t.fragmentLookupTable.find(e=>e.moofOffset===i.moofOffset);if(r)CV(e,r.timestamp);else{let t=QL(n,i.moofOffset-1,e=>e.moofOffset);if(t!==-1){let r=n[t];CV(e,r.endTimestamp)}}e.startTimestampIsFinal=!0}let r=QL(n,e.startTimestamp,e=>e.startTimestamp);if((r===-1||n[r].moofOffset!==i.moofOffset)&&n.splice(r+1,0,{moofOffset:i.moofOffset,startTimestamp:e.startTimestamp,endTimestamp:e.endTimestamp}),e.encryptionAuxInfo&&t.encryptionInfo){let n=await DV(this.reader,t.encryptionInfo,e.encryptionAuxInfo);for(let t=0;t<Math.min(e.samples.length,n.length);t++){let r=n[t];e.samples[t].encryption=r}}}return i}readContiguousBoxes(e){let t=e.filePos;for(;e.filePos-t<=e.length-8&&this.traverseBox(e););}*iterateContiguousBoxes(e){let t=e.filePos;for(;e.filePos-t<=e.length-8;){let t=e.filePos,n=QB(e);if(!n)break;yield{boxInfo:n,slice:e},e.filePos=t+n.totalSize}}traverseBox(e){let t=e.filePos,n=QB(e);if(!n)return!1;let r=e.filePos,i=t+n.totalSize;switch(n.name){case`mdia`:case`minf`:case`dinf`:case`mfra`:case`edts`:case`sinf`:case`schi`:this.readContiguousBoxes(e.slice(r,n.contentSize));break;case`mvhd`:{let t=BG(e);e.skip(3),t===1?(e.skip(16),this.movieTimescale=$(e),this.movieDurationInTimescale=XG(e)):(e.skip(8),this.movieTimescale=$(e),this.movieDurationInTimescale=$(e))}break;case`trak`:{let t={id:-1,demuxer:this,trackBacking:null,disposition:{...ez,primary:!1},info:null,timescale:-1,durationInMovieTimescale:-1,durationInMediaTimescale:-1,rotation:0,internalCodecId:null,name:null,languageCode:`und`,sampleTableByteOffset:-1,sampleTable:null,fragmentLookupTable:[],currentFragmentState:null,fragmentPositionCache:[],editListPreviousSegmentDurations:0,editListOffset:0,encryptionInfo:null,encryptionAuxInfo:null,frmaCodecString:null};this.currentTrack=t,this.readContiguousBoxes(e.slice(r,n.contentSize)),t.id!==-1&&t.timescale!==-1&&t.info!==null&&(t.info.type===`video`&&t.info.width!==-1?(t.trackBacking=new _V(t),this.tracks.push(t)):t.info.type===`audio`&&t.info.numberOfChannels!==-1&&(t.trackBacking=new vV(t),this.tracks.push(t))),this.currentTrack=null}break;case`tkhd`:{let t=this.currentTrack;if(!t)break;let n=BG(e),r=!!(UG(e)&1);if(t.disposition.default=r,n===0)e.skip(8),t.id=$(e),e.skip(4),t.durationInMovieTimescale=$(e);else if(n===1)e.skip(16),t.id=$(e),e.skip(4),t.durationInMovieTimescale=XG(e);else throw Error(`Incorrect track header version ${n}.`);e.skip(16);let i=kL(mR(wV([$B(e),$B(e),eV(e),$B(e),$B(e),eV(e),$B(e),$B(e),eV(e)]),90));X(i===0||i===90||i===180||i===270),t.rotation=i}break;case`elst`:{let t=this.currentTrack;if(!t)break;let n=BG(e);e.skip(3);let r=!1,i=0,a=$(e);for(let o=0;o<a;o++){let a=n===1?XG(e):$(e),o=n===1?ZG(e):qG(e),s=$B(e);if(a!==0){if(r){console.warn(`Unsupported edit list: multiple edits are not currently supported. Only using first edit.`);break}if(o===-1){i+=a;continue}if(s!==1){console.warn(`Unsupported edit list entry: media rate must be 1.`);break}t.editListPreviousSegmentDurations=i,t.editListOffset=o,r=!0}}}break;case`mdhd`:{let t=this.currentTrack;if(!t)break;let n=BG(e);e.skip(3),n===0?(e.skip(8),t.timescale=$(e),t.durationInMediaTimescale=$(e)):n===1&&(e.skip(16),t.timescale=$(e),t.durationInMediaTimescale=XG(e));let r=HG(e);if(r>0){t.languageCode=``;for(let e=0;e<3;e++)t.languageCode=String.fromCharCode(96+(r&31))+t.languageCode,r>>=5;bR(t.languageCode)||(t.languageCode=`und`)}}break;case`hdlr`:{let t=this.currentTrack;if(!t)break;e.skip(8);let n=tK(e,4);n===`vide`?t.info={type:`video`,width:-1,height:-1,squarePixelWidth:-1,squarePixelHeight:-1,codec:null,codecDescription:null,colorSpace:null,avcType:null,avcCodecInfo:null,hevcCodecInfo:null,vp9CodecInfo:null,av1CodecInfo:null}:n===`soun`&&(t.info={type:`audio`,numberOfChannels:-1,sampleRate:-1,codec:null,codecDescription:null,aacCodecInfo:null,pcmLittleEndian:!1,pcmSampleSize:null})}break;case`stbl`:{let i=this.currentTrack;if(!i)break;i.sampleTableByteOffset=t,this.readContiguousBoxes(e.slice(r,n.contentSize))}break;case`stsd`:{let t=this.currentTrack;if(!t||t.info===null||t.sampleTable)break;let n=BG(e);e.skip(3);let r=$(e);for(let i=0;i<r;i++){let r=e.filePos,i=QB(e);if(!i)break;t.internalCodecId=i.name;let a=i.name.toLowerCase();if(t.info.type===`video`){e.skip(24),t.info.width=HG(e),t.info.height=HG(e),t.info.squarePixelWidth=t.info.width,t.info.squarePixelHeight=t.info.height,e.skip(50),t.frmaCodecString=null,this.readContiguousBoxes(e.slice(e.filePos,r+i.totalSize-e.filePos));let n=a===`encv`?t.frmaCodecString:a;t.frmaCodecString=null,n===`avc1`||n===`avc3`?(t.info.codec=`avc`,t.info.avcType=n===`avc1`?1:3):n===`hvc1`||n===`hev1`?t.info.codec=`hevc`:n===`vp08`?t.info.codec=`vp8`:n===`vp09`?t.info.codec=`vp9`:n===`av01`?t.info.codec=`av1`:console.warn(n===null?`Unknown encrypted video codec due to missing frma box.`:`Unsupported video codec (sample entry type '${i.name}').`)}else{e.skip(8);let o=HG(e);e.skip(6);let s=HG(e),c=HG(e);e.skip(4);let l=$(e)/65536,u=null;n===0&&o>0&&(o===1?(e.skip(4),c=8*$(e),e.skip(8)):o===2&&(e.skip(4),l=eK(e),s=$(e),e.skip(4),c=$(e),u=$(e),e.skip(8))),t.info.numberOfChannels=s,t.info.sampleRate=l,t.frmaCodecString=null,this.readContiguousBoxes(e.slice(e.filePos,r+i.totalSize-e.filePos));let d=a===`enca`?t.frmaCodecString:a;if(t.frmaCodecString=null,d!==`mp4a`)if(d===`opus`)t.info.codec=`opus`,t.info.sampleRate=Cz;else if(d===`flac`)t.info.codec=`flac`;else if(d===`ulaw`)t.info.codec=`ulaw`;else if(d===`alaw`)t.info.codec=`alaw`;else if(d===`ac-3`)t.info.codec=`ac3`;else if(d===`ec-3`)t.info.codec=`eac3`;else if(d===`twos`)c===8?t.info.codec=`pcm-s8`:c===16?t.info.codec=t.info.pcmLittleEndian?`pcm-s16`:`pcm-s16be`:(console.warn(`Unsupported sample size ${c} for codec 'twos'.`),t.info.codec=null);else if(d===`sowt`)c===8?t.info.codec=`pcm-s8`:c===16?t.info.codec=`pcm-s16`:(console.warn(`Unsupported sample size ${c} for codec 'sowt'.`),t.info.codec=null);else if(d===`raw `)t.info.codec=`pcm-u8`;else if(d===`in24`)t.info.codec=t.info.pcmLittleEndian?`pcm-s24`:`pcm-s24be`;else if(d===`in32`)t.info.codec=t.info.pcmLittleEndian?`pcm-s32`:`pcm-s32be`;else if(d===`fl32`)t.info.codec=t.info.pcmLittleEndian?`pcm-f32`:`pcm-f32be`;else if(d===`fl64`)t.info.codec=t.info.pcmLittleEndian?`pcm-f64`:`pcm-f64be`;else if(d===`ipcm`){let e=t.info.pcmSampleSize;t.info.pcmLittleEndian?e===16?t.info.codec=`pcm-s16`:e===24?t.info.codec=`pcm-s24`:e===32?t.info.codec=`pcm-s32`:(console.warn(`Invalid ipcm sample size ${e}.`),t.info.codec=null):e===16?t.info.codec=`pcm-s16be`:e===24?t.info.codec=`pcm-s24be`:e===32?t.info.codec=`pcm-s32be`:(console.warn(`Invalid ipcm sample size ${e}.`),t.info.codec=null)}else if(d===`fpcm`){let e=t.info.pcmSampleSize;t.info.pcmLittleEndian?e===32?t.info.codec=`pcm-f32`:e===64?t.info.codec=`pcm-f64`:(console.warn(`Invalid fpcm sample size ${e}.`),t.info.codec=null):e===32?t.info.codec=`pcm-f32be`:e===64?t.info.codec=`pcm-f64be`:(console.warn(`Invalid fpcm sample size ${e}.`),t.info.codec=null)}else if(d===`lpcm`&&u!==null){let e=c+7>>3,n=!!(u&1),r=!!(u&2),i=u&4?-1:0;c>0&&c<=64&&(n?c===32&&(t.info.codec=r?`pcm-f32be`:`pcm-f32`):i&1<<e-1?e===1?t.info.codec=`pcm-s8`:e===2?t.info.codec=r?`pcm-s16be`:`pcm-s16`:e===3?t.info.codec=r?`pcm-s24be`:`pcm-s24`:e===4&&(t.info.codec=r?`pcm-s32be`:`pcm-s32`):e===1&&(t.info.codec=`pcm-u8`)),t.info.codec===null&&console.warn(`Unsupported PCM format.`)}else console.warn(d===null?`Unknown encrypted audio codec due to missing frma box.`:`Unsupported audio codec (sample entry type '${i.name}').`)}e.filePos=r+i.totalSize}}break;case`frma`:{let t=this.currentTrack;if(!t)break;t.frmaCodecString=tK(e,4).toLowerCase()}break;case`schm`:{let t=this.currentTrack;if(!t)break;e.skip(4);let n=tK(e,4);n===`cenc`||n===`cens`||n===`cbcs`?t.encryptionInfo={scheme:n,defaultKid:null,defaultIsProtected:null,defaultPerSampleIvSize:null,defaultConstantIv:null,defaultCryptByteBlock:null,defaultSkipByteBlock:null}:console.warn(`Unsupported encryption scheme '${n}'.`)}break;case`tenc`:{let t=this.currentTrack;if(!t||!t.encryptionInfo)break;let n=BG(e);e.skip(3),e.skip(1);let r=BG(e);if(n>0?(t.encryptionInfo.defaultCryptByteBlock=r>>4,t.encryptionInfo.defaultSkipByteBlock=r&15):(t.encryptionInfo.defaultCryptByteBlock=0,t.encryptionInfo.defaultSkipByteBlock=0),t.encryptionInfo.defaultIsProtected=BG(e)!==0,t.encryptionInfo.defaultPerSampleIvSize=BG(e),t.encryptionInfo.defaultKid=JL(zG(e,16)),t.encryptionInfo.defaultIsProtected&&t.encryptionInfo.defaultPerSampleIvSize===0){let n=BG(e),r=new Uint8Array(16);r.set(zG(e,n),0),t.encryptionInfo.defaultConstantIv=r}}break;case`avcC`:{let t=this.currentTrack;if(!t)break;X(t.info),t.info.codecDescription=zG(e,n.contentSize)}break;case`hvcC`:{let t=this.currentTrack;if(!t)break;X(t.info),t.info.codecDescription=zG(e,n.contentSize)}break;case`vpcC`:{let t=this.currentTrack;if(!t)break;X(t.info?.type===`video`),e.skip(4);let n=BG(e),r=BG(e),i=BG(e),a=i>>4,o=i>>1&7,s=i&1,c=BG(e),l=BG(e),u=BG(e);t.info.vp9CodecInfo={profile:n,level:r,bitDepth:a,chromaSubsampling:o,videoFullRangeFlag:s,colourPrimaries:c,transferCharacteristics:l,matrixCoefficients:u}}break;case`av1C`:{let t=this.currentTrack;if(!t)break;X(t.info?.type===`video`),e.skip(1);let n=BG(e),r=n>>5,i=n&31,a=BG(e),o=a>>7,s=a>>6&1,c=a>>5&1,l=a>>4&1,u=a>>3&1,d=a>>2&1,f=a&3,p=r===2&&s?c?12:10:s?10:8;t.info.av1CodecInfo={profile:r,level:i,tier:o,bitDepth:p,monochrome:l,chromaSubsamplingX:u,chromaSubsamplingY:d,chromaSamplePosition:f}}break;case`colr`:{let t=this.currentTrack;if(!t)break;X(t.info?.type===`video`);let n=tK(e,4);if(n!==`nclx`&&n!==`nclc`)break;let r=HG(e),i=HG(e),a=HG(e),o;n===`nclx`&&(o=!!(BG(e)&128)),t.info.colorSpace={primaries:zL[r],transfer:VL[i],matrix:UL[a],fullRange:o}}break;case`pasp`:{let t=this.currentTrack;if(!t)break;X(t.info?.type===`video`);let n=$(e),r=$(e);n>0&&r>0&&(n>r?t.info.squarePixelWidth=Math.round(t.info.width*n/r):t.info.squarePixelHeight=Math.round(t.info.height*r/n))}break;case`wave`:this.readContiguousBoxes(e.slice(r,n.contentSize));break;case`esds`:{let t=this.currentTrack;if(!t)break;X(t.info?.type===`audio`),e.skip(4),X(BG(e)===3),tV(e),e.skip(2);let n=BG(e),r=(n&128)!=0,i=(n&64)!=0,a=(n&32)!=0;if(r&&e.skip(2),i){let t=BG(e);e.skip(t)}a&&e.skip(2),X(BG(e)===4);let o=tV(e),s=e.filePos,c=BG(e);if(c===64||c===103?(t.info.codec=`aac`,t.info.aacCodecInfo={isMpeg2:c===103,objectType:null}):c===105||c===107?t.info.codec=`mp3`:c===221?t.info.codec=`vorbis`:console.warn(`Unsupported audio codec (objectTypeIndication ${c}) - discarding track.`),e.skip(12),o>e.filePos-s){X(BG(e)===5);let n=tV(e);if(t.info.codecDescription=zG(e,n),t.info.codec===`aac`){let e=az(t.info.codecDescription);e.numberOfChannels!==null&&(t.info.numberOfChannels=e.numberOfChannels),e.sampleRate!==null&&(t.info.sampleRate=e.sampleRate)}}}break;case`enda`:{let t=this.currentTrack;if(!t)break;X(t.info?.type===`audio`),t.info.pcmLittleEndian=!!(HG(e)&255)}break;case`pcmC`:{let t=this.currentTrack;if(!t)break;X(t.info?.type===`audio`),e.skip(4);let n=BG(e);t.info.pcmLittleEndian=!!(n&1),t.info.pcmSampleSize=BG(e)}break;case`dOps`:{let t=this.currentTrack;if(!t)break;X(t.info?.type===`audio`),e.skip(1);let n=BG(e),r=HG(e),i=$(e),a=WG(e),o=BG(e),s;s=o===0?new Uint8Array:zG(e,2+n);let c=new Uint8Array(19+s.byteLength),l=new DataView(c.buffer);l.setUint32(0,1332770163,!1),l.setUint32(4,1214603620,!1),l.setUint8(8,1),l.setUint8(9,n),l.setUint16(10,r,!0),l.setUint32(12,i,!0),l.setInt16(16,a,!0),l.setUint8(18,o),c.set(s,19),t.info.codecDescription=c,t.info.numberOfChannels=n}break;case`dfLa`:{let t=this.currentTrack;if(!t)break;X(t.info?.type===`audio`),e.skip(4);let n=e.filePos;for(;e.filePos<i;){let n=BG(e),r=UG(e);if((n&127)===FB.STREAMINFO){e.skip(10);let n=$(e),r=n>>>12,i=(n>>9&7)+1;t.info.sampleRate=r,t.info.numberOfChannels=i,e.skip(20)}else e.skip(r);if(n&128)break}let r=e.filePos;e.filePos=n;let a=zG(e,r-n),o=new Uint8Array(4+a.byteLength);new DataView(o.buffer).setUint32(0,1716281667,!1),o.set(a,4),t.info.codecDescription=o}break;case`dac3`:{let t=this.currentTrack;if(!t)break;X(t.info?.type===`audio`);let n=new nz(zG(e,3)),r=n.readBits(2);n.skipBits(8);let i=n.readBits(3),a=n.readBits(1);r<3&&(t.info.sampleRate=qz[r]),t.info.numberOfChannels=LB[i]+a}break;case`dec3`:{let t=this.currentTrack;if(!t)break;X(t.info?.type===`audio`);let r=UB(zG(e,n.contentSize));if(!r){console.warn(`Invalid dec3 box contents, ignoring.`);break}let i=WB(r);i!==null&&(t.info.sampleRate=i),t.info.numberOfChannels=GB(r)}break;case`stts`:{let t=this.currentTrack;if(!t||!t.sampleTable)break;e.skip(4);let n=$(e),r=0,i=0;for(let a=0;a<n;a++){let n=$(e),a=$(e);t.sampleTable.sampleTimingEntries.push({startIndex:r,startDecodeTimestamp:i,count:n,delta:a}),r+=n,i+=n*a}}break;case`ctts`:{let t=this.currentTrack;if(!t||!t.sampleTable)break;e.skip(4);let n=$(e),r=0;for(let i=0;i<n;i++){let n=$(e),i=qG(e);t.sampleTable.sampleCompositionTimeOffsets.push({startIndex:r,count:n,offset:i}),r+=n}}break;case`stsz`:{let t=this.currentTrack;if(!t||!t.sampleTable)break;e.skip(4);let n=$(e),r=$(e);if(n===0)for(let n=0;n<r;n++){let n=$(e);t.sampleTable.sampleSizes.push(n)}else t.sampleTable.sampleSizes.push(n)}break;case`stz2`:{let t=this.currentTrack;if(!t||!t.sampleTable)break;e.skip(4),e.skip(3);let n=BG(e),r=$(e),i=new nz(zG(e,Math.ceil(r*n/8)));for(let e=0;e<r;e++){let e=i.readBits(n);t.sampleTable.sampleSizes.push(e)}}break;case`stss`:{let t=this.currentTrack;if(!t||!t.sampleTable)break;e.skip(4),t.sampleTable.keySampleIndices=[];let n=$(e);for(let r=0;r<n;r++){let n=$(e)-1;t.sampleTable.keySampleIndices.push(n)}t.sampleTable.keySampleIndices[0]!==0&&t.sampleTable.keySampleIndices.unshift(0)}break;case`stsc`:{let t=this.currentTrack;if(!t||!t.sampleTable)break;e.skip(4);let n=$(e);for(let r=0;r<n;r++){let n=$(e)-1,r=$(e),i=$(e);t.sampleTable.sampleToChunk.push({startSampleIndex:-1,startChunkIndex:n,samplesPerChunk:r,sampleDescriptionIndex:i})}let r=0;for(let e=0;e<t.sampleTable.sampleToChunk.length;e++)if(t.sampleTable.sampleToChunk[e].startSampleIndex=r,e<t.sampleTable.sampleToChunk.length-1){let n=t.sampleTable.sampleToChunk[e+1].startChunkIndex-t.sampleTable.sampleToChunk[e].startChunkIndex;r+=n*t.sampleTable.sampleToChunk[e].samplesPerChunk}}break;case`stco`:{let t=this.currentTrack;if(!t||!t.sampleTable)break;e.skip(4);let n=$(e);for(let r=0;r<n;r++){let n=$(e);t.sampleTable.chunkOffsets.push(n)}}break;case`co64`:{let t=this.currentTrack;if(!t||!t.sampleTable)break;e.skip(4);let n=$(e);for(let r=0;r<n;r++){let n=XG(e);t.sampleTable.chunkOffsets.push(n)}}break;case`mvex`:this.isFragmented=!0,this.readContiguousBoxes(e.slice(r,n.contentSize));break;case`mehd`:{let t=BG(e);e.skip(3);let n=t===1?XG(e):$(e);this.movieDurationInTimescale=n}break;case`trex`:{e.skip(4);let t=$(e),n=$(e),r=$(e),i=$(e),a=$(e);this.fragmentTrackDefaults.push({trackId:t,defaultSampleDescriptionIndex:n,defaultSampleDuration:r,defaultSampleSize:i,defaultSampleFlags:a})}break;case`tfra`:{let t=BG(e);e.skip(3);let n=$(e),r=this.tracks.find(e=>e.id===n);if(!r)break;let i=$(e),a=(i&48)>>4,o=(i&12)>>2,s=i&3,c=[BG,HG,UG,$],l=c[a],u=c[o],d=c[s],f=$(e);for(let n=0;n<f;n++){let n=t===1?XG(e):$(e),i=t===1?XG(e):$(e);l(e),u(e),d(e),r.fragmentLookupTable.push({timestamp:n,moofOffset:i})}r.fragmentLookupTable.sort((e,t)=>e.timestamp-t.timestamp);for(let e=0;e<r.fragmentLookupTable.length-1;e++){let t=r.fragmentLookupTable[e],n=r.fragmentLookupTable[e+1];t.timestamp===n.timestamp&&(r.fragmentLookupTable.splice(e+1,1),e--)}}break;case`moof`:this.currentFragment={moofOffset:t,moofSize:n.totalSize,implicitBaseDataOffset:t,trackData:new Map,psshBoxes:[]},this.readContiguousBoxes(e.slice(r,n.contentSize)),this.lastReadFragment=this.currentFragment,this.currentFragment=null;break;case`traf`:if(X(this.currentFragment),this.readContiguousBoxes(e.slice(r,n.contentSize)),this.currentTrack){let e=this.currentFragment.trackData.get(this.currentTrack.id);cond:if(e){if(e.samples.length===0){this.currentFragment.trackData.delete(this.currentTrack.id);break cond}e.presentationTimestamps=e.samples.map((e,t)=>({presentationTimestamp:e.presentationTimestamp,sampleIndex:t})).sort((e,t)=>e.presentationTimestamp-t.presentationTimestamp);for(let t=0;t<e.presentationTimestamps.length;t++){let n=e.presentationTimestamps[t],r=e.samples[n.sampleIndex];e.firstKeyFrameTimestamp===null&&r.isKeyFrame&&(e.firstKeyFrameTimestamp=r.presentationTimestamp),t<e.presentationTimestamps.length-1&&(r.duration=e.presentationTimestamps[t+1].presentationTimestamp-n.presentationTimestamp)}let t=e.samples[e.presentationTimestamps[0].sampleIndex],n=e.samples[AL(e.presentationTimestamps).sampleIndex];e.startTimestamp=t.presentationTimestamp,e.endTimestamp=n.presentationTimestamp+n.duration;let{currentFragmentState:r}=this.currentTrack;X(r),r.startTimestamp!==null&&(CV(e,r.startTimestamp),e.startTimestampIsFinal=!0),r.encryptionAuxInfo&&!e.samples[0].encryption&&(e.encryptionAuxInfo=r.encryptionAuxInfo)}this.currentTrack.currentFragmentState=null,this.currentTrack=null}break;case`pssh`:{if(this.input._formatOptions.isobmff?._suppressPsshParsing)break;let t=XB(zG(e,n.contentSize));this.currentFragment?this.currentFragment.psshBoxes.push(t):this.currentTrack||this.psshBoxes.push(t)}break;case`tfhd`:{X(this.currentFragment),e.skip(1);let t=UG(e),n=!!(t&1),r=!!(t&2),i=!!(t&8),a=!!(t&16),o=!!(t&32),s=!!(t&65536),c=!!(t&131072),l=$(e),u=this.tracks.find(e=>e.id===l);if(!u)break;let d=this.fragmentTrackDefaults.find(e=>e.trackId===l);this.currentTrack=u,u.currentFragmentState={baseDataOffset:this.currentFragment.implicitBaseDataOffset,sampleDescriptionIndex:d?.defaultSampleDescriptionIndex??null,defaultSampleDuration:d?.defaultSampleDuration??null,defaultSampleSize:d?.defaultSampleSize??null,defaultSampleFlags:d?.defaultSampleFlags??null,startTimestamp:null,encryptionAuxInfo:null},n?u.currentFragmentState.baseDataOffset=XG(e):c&&(u.currentFragmentState.baseDataOffset=this.currentFragment.moofOffset),r&&(u.currentFragmentState.sampleDescriptionIndex=$(e)),i&&(u.currentFragmentState.defaultSampleDuration=$(e)),a&&(u.currentFragmentState.defaultSampleSize=$(e)),o&&(u.currentFragmentState.defaultSampleFlags=$(e)),s&&(u.currentFragmentState.defaultSampleDuration=0)}break;case`tfdt`:{let t=this.currentTrack;if(!t)break;X(t.currentFragmentState);let n=BG(e);e.skip(3);let r=n===0?$(e):XG(e);t.currentFragmentState.startTimestamp=r}break;case`trun`:{let t=this.currentTrack;if(!t)break;X(this.currentFragment),X(t.currentFragmentState);let n=BG(e),r=UG(e),i=!!(r&1),a=!!(r&4),o=!!(r&256),s=!!(r&512),c=!!(r&1024),l=!!(r&2048),u=$(e),d=null;i&&(d=qG(e));let f=null;a&&(f=$(e));let p;this.currentFragment.trackData.has(t.id)?(p=this.currentFragment.trackData.get(t.id),d!==null&&(p.currentOffset=t.currentFragmentState.baseDataOffset+d)):(p={track:t,currentTimestamp:0,currentOffset:t.currentFragmentState.baseDataOffset+(d??0),startTimestamp:0,endTimestamp:0,firstKeyFrameTimestamp:null,samples:[],presentationTimestamps:[],startTimestampIsFinal:!1,encryptionAuxInfo:null},this.currentFragment.trackData.set(t.id,p));for(let r=0;r<u;r++){let i;o?i=$(e):(X(t.currentFragmentState.defaultSampleDuration!==null),i=t.currentFragmentState.defaultSampleDuration);let a;s?a=$(e):(X(t.currentFragmentState.defaultSampleSize!==null),a=t.currentFragmentState.defaultSampleSize);let u;c?u=$(e):(X(t.currentFragmentState.defaultSampleFlags!==null),u=t.currentFragmentState.defaultSampleFlags),r===0&&f!==null&&(u=f);let d=0;l&&(d=n===0?$(e):qG(e));let m=!(u&65536);p.samples.push({presentationTimestamp:p.currentTimestamp+d,duration:i,byteOffset:p.currentOffset,byteSize:a,isKeyFrame:m,encryption:null}),p.currentOffset+=a,p.currentTimestamp+=i}this.currentFragment.implicitBaseDataOffset=p.currentOffset}break;case`saiz`:{let t=this.currentTrack;if(!t||!t.encryptionInfo)break;if(e.skip(1),UG(e)&1){let n=tK(e,4),r=$(e);if(n!==t.encryptionInfo.scheme||r!==0)break}let n=BG(e),r=$(e),i=null;n===0&&r>0&&(i=zG(e,r));let a=EV(t);a.defaultSampleInfoSize=n,a.sampleSizes=i,a.sampleCount=r}break;case`saio`:{let t=this.currentTrack;if(!t||!t.encryptionInfo)break;let n=BG(e);if(UG(e)&1){let n=tK(e,4),r=$(e);if(n!==t.encryptionInfo.scheme||r!==0)break}let r=$(e);if(r===0)break;r>1&&console.warn(`Multiple saio entries are not supported; using the first offset only.`);let i=n===0?$(e):Number(XG(e));this.currentFragment&&(i+=this.currentFragment.moofOffset);let a=EV(t);a.offset=i}break;case`senc`:{let t=this.currentTrack;if(!t||!t.encryptionInfo)break;X(this.currentFragment);let n=this.currentFragment.trackData.get(t.id);if(!n)break;e.skip(1);let r=!!(UG(e)&2),i=$(e),a=t.encryptionInfo.defaultPerSampleIvSize;X(a!==null);for(let o=0;o<Math.min(i,n.samples.length);o++){let i=new Uint8Array(16);a>0?i.set(zG(e,a),0):i.set(t.encryptionInfo.defaultConstantIv,0);let s=null;if(r){let t=HG(e);s=[];for(let n=0;n<t;n++){let t=HG(e),n=$(e);s.push({clearLen:t,protectedLen:n})}}let c=n.samples[o];c.encryption={iv:i,subsamples:s}}}break;case`udta`:{let t=this.iterateContiguousBoxes(e.slice(r,n.contentSize));for(let{boxInfo:e,slice:n}of t){if(e.name!==`meta`&&!this.currentTrack){let t=n.filePos;this.metadataTags.raw??={},e.name[0]===`©`?this.metadataTags.raw[e.name]??=nV(n):this.metadataTags.raw[e.name]??=zG(n,e.contentSize),n.filePos=t}switch(e.name){case`meta`:n.skip(-e.headerSize),this.traverseBox(n);break;case`©nam`:case`name`:this.currentTrack?this.currentTrack.name=FL.decode(zG(n,e.contentSize)):this.metadataTags.title??=nV(n);break;case`©des`:this.currentTrack||(this.metadataTags.description??=nV(n));break;case`©ART`:this.currentTrack||(this.metadataTags.artist??=nV(n));break;case`©alb`:this.currentTrack||(this.metadataTags.album??=nV(n));break;case`albr`:this.currentTrack||(this.metadataTags.albumArtist??=nV(n));break;case`©gen`:this.currentTrack||(this.metadataTags.genre??=nV(n));break;case`©day`:if(!this.currentTrack){let e=new Date(nV(n));Number.isNaN(e.getTime())||(this.metadataTags.date??=e)}break;case`©cmt`:this.currentTrack||(this.metadataTags.comment??=nV(n));break;case`©lyr`:this.currentTrack||(this.metadataTags.lyrics??=nV(n));break}}}break;case`meta`:{if(this.currentTrack)break;let t=$(e)!==0;this.currentMetadataKeys=new Map,t?this.readContiguousBoxes(e.slice(r,n.contentSize)):this.readContiguousBoxes(e.slice(r+4,n.contentSize-4)),this.currentMetadataKeys=null}break;case`keys`:{if(!this.currentMetadataKeys)break;e.skip(4);let t=$(e);for(let n=0;n<t;n++){let t=$(e);e.skip(4);let r=FL.decode(zG(e,t-8));this.currentMetadataKeys.set(n+1,r)}}break;case`ilst`:{if(!this.currentMetadataKeys)break;let t=this.iterateContiguousBoxes(e.slice(r,n.contentSize));for(let{boxInfo:e,slice:n}of t){let t=e.name,r=(t.charCodeAt(0)<<24)+(t.charCodeAt(1)<<16)+(t.charCodeAt(2)<<8)+t.charCodeAt(3);this.currentMetadataKeys.has(r)&&(t=this.currentMetadataKeys.get(r));let i=rV(n);switch(this.metadataTags.raw??={},this.metadataTags.raw[t]??=i,t){case`©nam`:case`titl`:case`com.apple.quicktime.title`:case`title`:typeof i==`string`&&(this.metadataTags.title??=i);break;case`©des`:case`desc`:case`dscp`:case`com.apple.quicktime.description`:case`description`:typeof i==`string`&&(this.metadataTags.description??=i);break;case`©ART`:case`com.apple.quicktime.artist`:case`artist`:typeof i==`string`&&(this.metadataTags.artist??=i);break;case`©alb`:case`albm`:case`com.apple.quicktime.album`:case`album`:typeof i==`string`&&(this.metadataTags.album??=i);break;case`aART`:case`album_artist`:typeof i==`string`&&(this.metadataTags.albumArtist??=i);break;case`©cmt`:case`com.apple.quicktime.comment`:case`comment`:typeof i==`string`&&(this.metadataTags.comment??=i);break;case`©gen`:case`gnre`:case`com.apple.quicktime.genre`:case`genre`:typeof i==`string`&&(this.metadataTags.genre??=i);break;case`©lyr`:case`lyrics`:typeof i==`string`&&(this.metadataTags.lyrics??=i);break;case`©day`:case`rldt`:case`com.apple.quicktime.creationdate`:case`date`:if(typeof i==`string`){let e=new Date(i);Number.isNaN(e.getTime())||(this.metadataTags.date??=e)}break;case`covr`:case`com.apple.quicktime.artwork`:i instanceof ZR?(this.metadataTags.images??=[],this.metadataTags.images.push({data:i.data,kind:`coverFront`,mimeType:i.mimeType})):i instanceof Uint8Array&&(this.metadataTags.images??=[],this.metadataTags.images.push({data:i,kind:`coverFront`,mimeType:`image/*`}));break;case`track`:if(typeof i==`string`){let e=i.split(`/`),t=Number.parseInt(e[0],10),n=e[1]&&Number.parseInt(e[1],10);Number.isInteger(t)&&t>0&&(this.metadataTags.trackNumber??=t),n&&Number.isInteger(n)&&n>0&&(this.metadataTags.tracksTotal??=n)}break;case`trkn`:if(i instanceof Uint8Array&&i.length>=6){let e=PL(i),t=e.getUint16(2,!1),n=e.getUint16(4,!1);t>0&&(this.metadataTags.trackNumber??=t),n>0&&(this.metadataTags.tracksTotal??=n)}break;case`disc`:case`disk`:if(i instanceof Uint8Array&&i.length>=6){let e=PL(i),t=e.getUint16(2,!1),n=e.getUint16(4,!1);t>0&&(this.metadataTags.discNumber??=t),n>0&&(this.metadataTags.discsTotal??=n)}break}}}break}return e.filePos=i,!0}},gV=class{constructor(e){this.internalTrack=e,this.packetToSampleIndex=new WeakMap,this.packetToFragmentLocation=new WeakMap}getId(){return this.internalTrack.id}getNumber(){let e=this.internalTrack.demuxer,t=this.internalTrack.trackBacking.getType(),n=0;for(let r of e.tracks)if(r.trackBacking.getType()===t&&n++,r===this.internalTrack)break;return n}getCodec(){throw Error(`Not implemented on base class.`)}getInternalCodecId(){return this.internalTrack.internalCodecId}getName(){return this.internalTrack.name}getLanguageCode(){return this.internalTrack.languageCode}getTimeResolution(){return this.internalTrack.timescale}isRelativeToUnixEpoch(){return!1}getDisposition(){return this.internalTrack.disposition}getPairingMask(){return 1n}getBitrate(){return null}getAverageBitrate(){return null}async getDurationFromMetadata(){let e=this.internalTrack;return e.durationInMediaTimescale<=0?null:(X(e.trackBacking),((await e.trackBacking.getFirstPacket({metadataOnly:!0}))?.timestamp??0)+e.durationInMediaTimescale/e.timescale)}async getLiveRefreshInterval(){return null}async getFirstPacket(e){let t=await this.fetchPacketForSampleIndex(0,e);return t||!this.internalTrack.demuxer.isFragmented?t:this.performFragmentedLookup(null,e=>e.trackData.get(this.internalTrack.id)?{sampleIndex:0,correctSampleFound:!0}:{sampleIndex:-1,correctSampleFound:!1},-1/0,1/0,e)}mapTimestampIntoTimescale(e){return pR(e*this.internalTrack.timescale)+this.internalTrack.editListOffset}async getPacket(e,t){let n=this.mapTimestampIntoTimescale(e),r=this.internalTrack.demuxer.getSampleTableForTrack(this.internalTrack),i=yV(r,n),a=await this.fetchPacketForSampleIndex(i,t);return!TV(r)||!this.internalTrack.demuxer.isFragmented?a:this.performFragmentedLookup(null,e=>{let t=e.trackData.get(this.internalTrack.id);if(!t)return{sampleIndex:-1,correctSampleFound:!1};let r=QL(t.presentationTimestamps,n,e=>e.presentationTimestamp);return{sampleIndex:r===-1?-1:t.presentationTimestamps[r].sampleIndex,correctSampleFound:r!==-1&&n<t.endTimestamp}},n,n,t)}async getNextPacket(e,t){let n=this.packetToSampleIndex.get(e);if(n!==void 0)return this.fetchPacketForSampleIndex(n+1,t);let r=this.packetToFragmentLocation.get(e);if(r===void 0)throw Error(`Packet was not created from this track.`);return this.performFragmentedLookup(r.fragment,e=>{if(e===r.fragment){let t=e.trackData.get(this.internalTrack.id);if(r.sampleIndex+1<t.samples.length)return{sampleIndex:r.sampleIndex+1,correctSampleFound:!0}}else if(e.trackData.get(this.internalTrack.id))return{sampleIndex:0,correctSampleFound:!0};return{sampleIndex:-1,correctSampleFound:!1}},-1/0,1/0,t)}async getKeyPacket(e,t){let n=this.mapTimestampIntoTimescale(e),r=this.internalTrack.demuxer.getSampleTableForTrack(this.internalTrack),i=bV(r,n),a=await this.fetchPacketForSampleIndex(i,t);return!TV(r)||!this.internalTrack.demuxer.isFragmented?a:this.performFragmentedLookup(null,e=>{let t=e.trackData.get(this.internalTrack.id);if(!t)return{sampleIndex:-1,correctSampleFound:!1};let r=rR(t.presentationTimestamps,e=>t.samples[e.sampleIndex].isKeyFrame&&e.presentationTimestamp<=n);return{sampleIndex:r===-1?-1:t.presentationTimestamps[r].sampleIndex,correctSampleFound:r!==-1&&n<t.endTimestamp}},n,n,t)}async getNextKeyPacket(e,t){let n=this.packetToSampleIndex.get(e);if(n!==void 0){let e=SV(this.internalTrack.demuxer.getSampleTableForTrack(this.internalTrack),n);return this.fetchPacketForSampleIndex(e,t)}let r=this.packetToFragmentLocation.get(e);if(r===void 0)throw Error(`Packet was not created from this track.`);return this.performFragmentedLookup(r.fragment,e=>{if(e===r.fragment){let t=e.trackData.get(this.internalTrack.id).samples.findIndex((e,t)=>e.isKeyFrame&&t>r.sampleIndex);if(t!==-1)return{sampleIndex:t,correctSampleFound:!0}}else{let t=e.trackData.get(this.internalTrack.id);if(t&&t.firstKeyFrameTimestamp!==null){let e=t.samples.findIndex(e=>e.isKeyFrame);return X(e!==-1),{sampleIndex:e,correctSampleFound:!0}}}return{sampleIndex:-1,correctSampleFound:!1}},-1/0,1/0,t)}async fetchPacketForSampleIndex(e,t){if(e===-1)return null;let n=xV(this.internalTrack.demuxer.getSampleTableForTrack(this.internalTrack),e);if(!n)return null;let r;if(t.metadataOnly)r=qB;else{let t=this.internalTrack.demuxer.reader.requestSlice(n.sampleOffset,n.sampleSize);if(t instanceof Promise&&(t=await t),!t)return null;if(r=zG(t,n.sampleSize),this.internalTrack.encryptionAuxInfo){X(this.internalTrack.encryptionInfo);let t=await DV(this.internalTrack.demuxer.reader,this.internalTrack.encryptionInfo,this.internalTrack.encryptionAuxInfo);e<t.length&&(r=await OV(this.internalTrack,t[e],r,null))}}let i=(n.presentationTimestamp-this.internalTrack.editListOffset)/this.internalTrack.timescale,a=n.duration/this.internalTrack.timescale,o=new JB(r,n.isKeyFrame?`key`:`delta`,i,a,e,n.sampleSize);return this.packetToSampleIndex.set(o,e),o}async fetchPacketInFragment(e,t,n){if(t===-1)return null;let r=e.trackData.get(this.internalTrack.id).samples[t];X(r);let i;if(n.metadataOnly)i=qB;else{let t=this.internalTrack.demuxer.reader.requestSlice(r.byteOffset,r.byteSize);if(t instanceof Promise&&(t=await t),!t)return null;i=zG(t,r.byteSize),r.encryption&&(i=await OV(this.internalTrack,r.encryption,i,e))}let a=(r.presentationTimestamp-this.internalTrack.editListOffset)/this.internalTrack.timescale,o=r.duration/this.internalTrack.timescale,s=new JB(i,r.isKeyFrame?`key`:`delta`,a,o,e.moofOffset+t,r.byteSize);return this.packetToFragmentLocation.set(s,{fragment:e,sampleIndex:t}),s}async performFragmentedLookup(e,t,n,r,i){let a=this.internalTrack.demuxer,o=null,s=null,c=-1;if(e){let{sampleIndex:n,correctSampleFound:r}=t(e);if(r)return this.fetchPacketInFragment(e,n,i);n!==-1&&(s=e,c=n)}let l=QL(this.internalTrack.fragmentLookupTable,n,e=>e.timestamp),u=l===-1?null:this.internalTrack.fragmentLookupTable[l],d=QL(this.internalTrack.fragmentPositionCache,n,e=>e.startTimestamp),f=d===-1?null:this.internalTrack.fragmentPositionCache[d],p=Math.max(u?.moofOffset??0,f?.moofOffset??0)||null,m;for(e?p===null||e.moofOffset>=p?(m=e.moofOffset+e.moofSize,o=e):m=p:m=p??0;;){if(o){let e=o.trackData.get(this.internalTrack.id);if(e&&e.startTimestamp>r)break}let e=a.reader.requestSliceRange(m,8,16);if(e instanceof Promise&&(e=await e),!e)break;let n=m,l=QB(e);if(!l)break;if(l.name===`moof`){o=await a.readFragment(n);let{sampleIndex:e,correctSampleFound:r}=t(o);if(r)return this.fetchPacketInFragment(o,e,i);e!==-1&&(s=o,c=e)}m=n+l.totalSize}if(u&&(!s||s.moofOffset<u.moofOffset)){let e=this.internalTrack.fragmentLookupTable[l-1];X(!e||e.timestamp<u.timestamp);let n=e?.timestamp??-1/0;return this.performFragmentedLookup(null,t,n,r,i)}return s?this.fetchPacketInFragment(s,c,i):null}},_V=class extends gV{constructor(e){super(e),this.decoderConfigPromise=null,this.internalTrack=e}getType(){return`video`}getCodec(){return this.internalTrack.info.codec}getCodedWidth(){return this.internalTrack.info.width}getCodedHeight(){return this.internalTrack.info.height}getSquarePixelWidth(){return this.internalTrack.info.squarePixelWidth}getSquarePixelHeight(){return this.internalTrack.info.squarePixelHeight}getRotation(){return this.internalTrack.rotation}async getColorSpace(){return{primaries:this.internalTrack.info.colorSpace?.primaries,transfer:this.internalTrack.info.colorSpace?.transfer,matrix:this.internalTrack.info.colorSpace?.matrix,fullRange:this.internalTrack.info.colorSpace?.fullRange}}async canBeTransparent(){return!1}async getDecoderConfig(){return this.internalTrack.info.codec?this.decoderConfigPromise??=(async()=>{if(this.internalTrack.info.codec===`vp9`&&!this.internalTrack.info.vp9CodecInfo){let e=await this.getFirstPacket({});this.internalTrack.info.vp9CodecInfo=e&&DB(e.data)}else if(this.internalTrack.info.codec===`av1`&&!this.internalTrack.info.av1CodecInfo){let e=await this.getFirstPacket({});this.internalTrack.info.av1CodecInfo=e&&kB(e.data)}let e={codec:bz(this.internalTrack.info),codedWidth:this.internalTrack.info.width,codedHeight:this.internalTrack.info.height,description:this.internalTrack.info.codecDescription??void 0,colorSpace:this.internalTrack.info.colorSpace??void 0};return(this.internalTrack.info.width!==this.internalTrack.info.squarePixelWidth||this.internalTrack.info.height!==this.internalTrack.info.squarePixelHeight)&&(e.displayAspectWidth=this.internalTrack.info.squarePixelWidth,e.displayAspectHeight=this.internalTrack.info.squarePixelHeight),e})():null}},vV=class extends gV{constructor(e){super(e),this.decoderConfig=null,this.internalTrack=e}getType(){return`audio`}getCodec(){return this.internalTrack.info.codec}getNumberOfChannels(){return this.internalTrack.info.numberOfChannels}getSampleRate(){return this.internalTrack.info.sampleRate}async getDecoderConfig(){return this.internalTrack.info.codec?this.decoderConfig??={codec:Sz(this.internalTrack.info),numberOfChannels:this.internalTrack.info.numberOfChannels,sampleRate:this.internalTrack.info.sampleRate,description:this.internalTrack.info.codecDescription??void 0}:null}},yV=(e,t)=>{if(e.presentationTimestamps){let n=QL(e.presentationTimestamps,t,e=>e.presentationTimestamp);return n===-1?-1:e.presentationTimestamps[n].sampleIndex}else{let n=QL(e.sampleTimingEntries,t,e=>e.startDecodeTimestamp);if(n===-1)return-1;let r=e.sampleTimingEntries[n];return r.startIndex+Math.min(Math.floor((t-r.startDecodeTimestamp)/r.delta),r.count-1)}},bV=(e,t)=>{if(!e.keySampleIndices)return yV(e,t);if(e.presentationTimestamps){let n=QL(e.presentationTimestamps,t,e=>e.presentationTimestamp);if(n===-1)return-1;for(let t=n;t>=0;t--){let n=e.presentationTimestamps[t].sampleIndex;if(ZL(e.keySampleIndices,n,e=>e)!==-1)return n}return-1}else{let n=yV(e,t),r=QL(e.keySampleIndices,n,e=>e);return e.keySampleIndices[r]??-1}},xV=(e,t)=>{let n=QL(e.sampleTimingEntries,t,e=>e.startIndex),r=e.sampleTimingEntries[n];if(!r||r.startIndex+r.count<=t)return null;let i=r.startDecodeTimestamp+(t-r.startIndex)*r.delta,a=QL(e.sampleCompositionTimeOffsets,t,e=>e.startIndex),o=e.sampleCompositionTimeOffsets[a];o&&t-o.startIndex<o.count&&(i+=o.offset);let s=e.sampleSizes[Math.min(t,e.sampleSizes.length-1)],c=QL(e.sampleToChunk,t,e=>e.startSampleIndex),l=e.sampleToChunk[c];X(l);let u=l.startChunkIndex+Math.floor((t-l.startSampleIndex)/l.samplesPerChunk),d=e.chunkOffsets[u],f=l.startSampleIndex+(u-l.startChunkIndex)*l.samplesPerChunk,p=0,m=d;if(e.sampleSizes.length===1)m+=s*(t-f),p+=s*l.samplesPerChunk;else for(let n=f;n<f+l.samplesPerChunk;n++){let r=e.sampleSizes[n];n<t&&(m+=r),p+=r}let h=r.delta;if(e.presentationTimestamps){let n=e.presentationTimestampIndexMap[t];X(n!==void 0),n<e.presentationTimestamps.length-1&&(h=e.presentationTimestamps[n+1].presentationTimestamp-i)}return{presentationTimestamp:i,duration:h,sampleOffset:m,sampleSize:s,chunkOffset:d,chunkSize:p,isKeyFrame:e.keySampleIndices?ZL(e.keySampleIndices,t,e=>e)!==-1:!0}},SV=(e,t)=>{if(!e.keySampleIndices)return t+1;let n=QL(e.keySampleIndices,t,e=>e);return e.keySampleIndices[n+1]??-1},CV=(e,t)=>{e.startTimestamp+=t,e.endTimestamp+=t;for(let n of e.samples)n.presentationTimestamp+=t;for(let n of e.presentationTimestamps)n.presentationTimestamp+=t},wV=e=>{let[t,n]=e,r=Math.atan2(n,t);return Number.isFinite(r)?180/Math.PI*r:0},TV=e=>e.sampleSizes.length===0,EV=e=>e.currentFragmentState?e.currentFragmentState.encryptionAuxInfo??={defaultSampleInfoSize:0,sampleSizes:null,sampleCount:0,offset:null,resolved:null}:e.encryptionAuxInfo??={defaultSampleInfoSize:0,sampleSizes:null,sampleCount:0,offset:null,resolved:null},DV=async(e,t,n)=>{if(n.resolved)return n.resolved;if(n.offset===null||n.sampleCount===0)throw Error(`Incomplete saiz/saio info; cannot resolve encryption data.`);let r=0;if(n.defaultSampleInfoSize>0)r=n.defaultSampleInfoSize*n.sampleCount;else{X(n.sampleSizes);for(let e=0;e<n.sampleCount;e++)r+=n.sampleSizes[e]}let i=e.requestSlice(n.offset,r);if(i instanceof Promise&&(i=await i),!i)throw Error(`Failed to read auxiliary encryption info.`);let a=t.defaultPerSampleIvSize;X(a!==null);let o=[];for(let e=0;e<n.sampleCount;e++){let r=n.defaultSampleInfoSize>0?n.defaultSampleInfoSize:n.sampleSizes[e],s=new Uint8Array(16);a>0?s.set(zG(i,a),0):s.set(t.defaultConstantIv,0);let c=null;if(r>a){let e=HG(i);c=[];for(let t=0;t<e;t++){let e=HG(i),t=$(i);c.push({clearLen:e,protectedLen:t})}}o.push({iv:s,subsamples:c})}return n.resolved=o,o},OV=async(e,t,n,r)=>{X(e.encryptionInfo);let i=e.encryptionInfo;X(i.defaultKid!==null);let a=i.defaultKid,o,s=e.demuxer.decryptionKeyCache.get(a);if(s)o=await s;else{if(!e.demuxer.input._formatOptions.isobmff?.resolveKeyId)throw Error(`Encrypted media samples encountered. To decrypt them, please provide a callback for InputOptions.formatOptions.isobmff.resolveKeyId.`);let t=(async()=>{let t=e.demuxer.psshBoxes;if(r){t=[...t,...r.psshBoxes].filter(e=>e.keyIds===null||e.keyIds.includes(a));for(let e=0;e<t.length-1;e++)for(let n=e+1;n<t.length;n++)ZB(t[e],t[n])&&(t.splice(n,1),n--)}let n=await e.demuxer.input._formatOptions.isobmff.resolveKeyId({keyId:a,psshBoxes:t});if(!(typeof n==`string`&&n.length===32&&qL.test(n)||n instanceof Uint8Array&&n.byteLength===16))throw TypeError(`resolveKeyId must return a 32-character hex string or a 16-byte Uint8Array containing the decryption key.`);return n instanceof Uint8Array?n:YL(n)})();e.demuxer.decryptionKeyCache.set(a,t),o=await t}return i.scheme===`cenc`||i.scheme===`cens`?kV(o,i,t,n):AV(o,i,t,n)},kV=async(e,t,n,r)=>{let i=new Uint8Array(16);i.set(n.iv,0);let a=await crypto.subtle.importKey(`raw`,e,{name:`AES-CTR`},!1,[`decrypt`]),o=async e=>{let t=await crypto.subtle.decrypt({name:`AES-CTR`,counter:i,length:64},a,e);return new Uint8Array(t)};if(!n.subsamples)return o(r);X(t.defaultCryptByteBlock!==null&&t.defaultSkipByteBlock!==null);let s=jV(n.subsamples,t.defaultCryptByteBlock,t.defaultSkipByteBlock),c=0;for(let e of s)for(let t of e.perSubsample)c+=t.length;let l=new Uint8Array(c),u=0;for(let e of s)for(let t of e.perSubsample)l.set(r.subarray(t.offset,t.offset+t.length),u),u+=t.length;let d=await o(l),f=new Uint8Array(r),p=0;for(let e of s)for(let t of e.perSubsample)f.set(d.subarray(p,p+t.length),t.offset),p+=t.length;return f},AV=(e,t,n,r)=>{let i=new pV;i.init({key:e,iv:n.iv});let a=t.defaultCryptByteBlock,o=t.defaultSkipByteBlock;if(X(a!==null&&o!==null),!n.subsamples){let e=new Uint8Array(r),t=Math.floor(r.length/16);for(let n=0;n<t;n++){let t=n*16;i.in.set(r.subarray(t,t+16)),i.decrypt(),e.set(i.out,t)}return e}if(a===0&&o===0)throw Error(`cbcs with subsamples requires pattern encryption.`);let s=new Uint8Array(r),c=jV(n.subsamples,a,o),l=new DataView(n.iv.buffer,n.iv.byteOffset,16);for(let e of c){i.iv[0]=l.getUint32(0,!1),i.iv[1]=l.getUint32(4,!1),i.iv[2]=l.getUint32(8,!1),i.iv[3]=l.getUint32(12,!1);for(let t of e.perSubsample){let e=t.length/16;for(let n=0;n<e;n++){let e=t.offset+n*16;i.in.set(r.subarray(e,e+16)),i.decrypt(),s.set(i.out,e)}}}return s},jV=(e,t,n)=>{let r=[],i=t!==0||n!==0,a=0;for(let o of e){a+=o.clearLen;let e=[];if(!i)o.protectedLen>0&&e.push({offset:a,length:o.protectedLen}),a+=o.protectedLen;else{let r=o.protectedLen,i=a;for(;r>0&&!(r<16*t);){let a=16*t;e.push({offset:i,length:a}),i+=a,r-=a;let o=Math.min(16*n,r);i+=o,r-=o}a+=o.protectedLen}r.push({perSubsample:e})}return r},Q;(function(e){e[e.EBML=440786851]=`EBML`,e[e.EBMLVersion=17030]=`EBMLVersion`,e[e.EBMLReadVersion=17143]=`EBMLReadVersion`,e[e.EBMLMaxIDLength=17138]=`EBMLMaxIDLength`,e[e.EBMLMaxSizeLength=17139]=`EBMLMaxSizeLength`,e[e.DocType=17026]=`DocType`,e[e.DocTypeVersion=17031]=`DocTypeVersion`,e[e.DocTypeReadVersion=17029]=`DocTypeReadVersion`,e[e.Void=236]=`Void`,e[e.Segment=408125543]=`Segment`,e[e.SeekHead=290298740]=`SeekHead`,e[e.Seek=19899]=`Seek`,e[e.SeekID=21419]=`SeekID`,e[e.SeekPosition=21420]=`SeekPosition`,e[e.Duration=17545]=`Duration`,e[e.Info=357149030]=`Info`,e[e.TimestampScale=2807729]=`TimestampScale`,e[e.MuxingApp=19840]=`MuxingApp`,e[e.WritingApp=22337]=`WritingApp`,e[e.Tracks=374648427]=`Tracks`,e[e.TrackEntry=174]=`TrackEntry`,e[e.TrackNumber=215]=`TrackNumber`,e[e.TrackUID=29637]=`TrackUID`,e[e.TrackType=131]=`TrackType`,e[e.FlagEnabled=185]=`FlagEnabled`,e[e.FlagDefault=136]=`FlagDefault`,e[e.FlagForced=21930]=`FlagForced`,e[e.FlagOriginal=21934]=`FlagOriginal`,e[e.FlagHearingImpaired=21931]=`FlagHearingImpaired`,e[e.FlagVisualImpaired=21932]=`FlagVisualImpaired`,e[e.FlagCommentary=21935]=`FlagCommentary`,e[e.FlagLacing=156]=`FlagLacing`,e[e.Name=21358]=`Name`,e[e.Language=2274716]=`Language`,e[e.LanguageBCP47=2274717]=`LanguageBCP47`,e[e.CodecID=134]=`CodecID`,e[e.CodecPrivate=25506]=`CodecPrivate`,e[e.CodecDelay=22186]=`CodecDelay`,e[e.SeekPreRoll=22203]=`SeekPreRoll`,e[e.DefaultDuration=2352003]=`DefaultDuration`,e[e.Video=224]=`Video`,e[e.PixelWidth=176]=`PixelWidth`,e[e.PixelHeight=186]=`PixelHeight`,e[e.DisplayWidth=21680]=`DisplayWidth`,e[e.DisplayHeight=21690]=`DisplayHeight`,e[e.DisplayUnit=21682]=`DisplayUnit`,e[e.AlphaMode=21440]=`AlphaMode`,e[e.Audio=225]=`Audio`,e[e.SamplingFrequency=181]=`SamplingFrequency`,e[e.Channels=159]=`Channels`,e[e.BitDepth=25188]=`BitDepth`,e[e.SimpleBlock=163]=`SimpleBlock`,e[e.BlockGroup=160]=`BlockGroup`,e[e.Block=161]=`Block`,e[e.BlockAdditions=30113]=`BlockAdditions`,e[e.BlockMore=166]=`BlockMore`,e[e.BlockAdditional=165]=`BlockAdditional`,e[e.BlockAddID=238]=`BlockAddID`,e[e.BlockDuration=155]=`BlockDuration`,e[e.ReferenceBlock=251]=`ReferenceBlock`,e[e.Cluster=524531317]=`Cluster`,e[e.Timestamp=231]=`Timestamp`,e[e.Cues=475249515]=`Cues`,e[e.CuePoint=187]=`CuePoint`,e[e.CueTime=179]=`CueTime`,e[e.CueTrackPositions=183]=`CueTrackPositions`,e[e.CueTrack=247]=`CueTrack`,e[e.CueClusterPosition=241]=`CueClusterPosition`,e[e.Colour=21936]=`Colour`,e[e.MatrixCoefficients=21937]=`MatrixCoefficients`,e[e.TransferCharacteristics=21946]=`TransferCharacteristics`,e[e.Primaries=21947]=`Primaries`,e[e.Range=21945]=`Range`,e[e.Projection=30320]=`Projection`,e[e.ProjectionType=30321]=`ProjectionType`,e[e.ProjectionPoseRoll=30325]=`ProjectionPoseRoll`,e[e.Attachments=423732329]=`Attachments`,e[e.AttachedFile=24999]=`AttachedFile`,e[e.FileDescription=18046]=`FileDescription`,e[e.FileName=18030]=`FileName`,e[e.FileMediaType=18016]=`FileMediaType`,e[e.FileData=18012]=`FileData`,e[e.FileUID=18094]=`FileUID`,e[e.Chapters=272869232]=`Chapters`,e[e.Tags=307544935]=`Tags`,e[e.Tag=29555]=`Tag`,e[e.Targets=25536]=`Targets`,e[e.TargetTypeValue=26826]=`TargetTypeValue`,e[e.TargetType=25546]=`TargetType`,e[e.TagTrackUID=25541]=`TagTrackUID`,e[e.TagEditionUID=25545]=`TagEditionUID`,e[e.TagChapterUID=25540]=`TagChapterUID`,e[e.TagAttachmentUID=25542]=`TagAttachmentUID`,e[e.SimpleTag=26568]=`SimpleTag`,e[e.TagName=17827]=`TagName`,e[e.TagLanguage=17530]=`TagLanguage`,e[e.TagString=17543]=`TagString`,e[e.TagBinary=17541]=`TagBinary`,e[e.ContentEncodings=28032]=`ContentEncodings`,e[e.ContentEncoding=25152]=`ContentEncoding`,e[e.ContentEncodingOrder=20529]=`ContentEncodingOrder`,e[e.ContentEncodingScope=20530]=`ContentEncodingScope`,e[e.ContentCompression=20532]=`ContentCompression`,e[e.ContentCompAlgo=16980]=`ContentCompAlgo`,e[e.ContentCompSettings=16981]=`ContentCompSettings`,e[e.ContentEncryption=20533]=`ContentEncryption`})(Q||={});var MV=[Q.EBML,Q.Segment],NV=[Q.SeekHead,Q.Info,Q.Cluster,Q.Tracks,Q.Cues,Q.Attachments,Q.Chapters,Q.Tags],PV=[...MV,...NV],FV=e=>{if(e.remainingLength<1)return null;let t=BG(e);if(e.skip(-1),t===0)return null;let n=1,r=128;for(;(t&r)===0;)n++,r>>=1;return e.remainingLength<n?null:n},IV=e=>{if(e.remainingLength<1)return null;let t=BG(e);if(t===0)return null;let n=1,r=128;for(;(t&r)===0;)n++,r>>=1;if(e.remainingLength<n-1)return null;let i=t&r-1;for(let t=1;t<n;t++)i*=256,i+=BG(e);return i},LV=(e,t)=>{if(t<1||t>8)throw Error(`Bad unsigned int size `+t);let n=0;for(let r=0;r<t;r++)n*=256,n+=BG(e);return n},RV=(e,t)=>{if(t<1)throw Error(`Bad unsigned int size `+t);let n=0n;for(let r=0;r<t;r++)n<<=8n,n+=BigInt(BG(e));return n},zV=e=>{let t=FV(e);return t===null||e.remainingLength<t?null:LV(e,t)},BV=e=>{if(e.remainingLength<1)return null;if(BG(e)===255)return;e.skip(-1);let t=IV(e);if(t===null)return null;if(t!==72057594037927940)return t},VV=e=>{X(e.remainingLength>=2);let t=zV(e);if(t===null)return null;let n=BV(e);return n===null?null:{id:t,size:n}},HV=(e,t)=>{let n=zG(e,t),r=0;for(;r<t&&n[r]!==0;)r+=1;return String.fromCharCode(...n.subarray(0,r))},UV=(e,t)=>{let n=zG(e,t),r=0;for(;r<t&&n[r]!==0;)r+=1;return FL.decode(n.subarray(0,r))},WV=(e,t)=>{if(t===0)return 0;if(t!==4&&t!==8)throw Error(`Bad float size `+t);return t===4?$G(e):eK(e)},GV=async(e,t,n,r)=>{let i=new Set(n),a=t;for(;r===null||a<r;){let t=e.requestSliceRange(a,2,16);if(t instanceof Promise&&(t=await t),!t)break;let n=VV(t);if(!n)break;if(i.has(n.id))return{pos:a,found:!0};JV(n.size),a=t.filePos+n.size}return{pos:r!==null&&r>a?r:a,found:!1}},KV=async(e,t,n,r)=>{let i=2**16,a=new Set(n),o=t;for(;o<r;){let t=e.requestSliceRange(o,0,Math.min(i,r-o));if(t instanceof Promise&&(t=await t),!t||t.length<8)break;for(let e=0;e<t.length-8;e++){t.filePos=o;let e=zV(t);if(e!==null&&a.has(e))return o;o++}}return null},qV={avc:`V_MPEG4/ISO/AVC`,hevc:`V_MPEGH/ISO/HEVC`,vp8:`V_VP8`,vp9:`V_VP9`,av1:`V_AV1`,aac:`A_AAC`,mp3:`A_MPEG/L3`,opus:`A_OPUS`,vorbis:`A_VORBIS`,flac:`A_FLAC`,ac3:`A_AC3`,eac3:`A_EAC3`,"pcm-u8":`A_PCM/INT/LIT`,"pcm-s16":`A_PCM/INT/LIT`,"pcm-s16be":`A_PCM/INT/BIG`,"pcm-s24":`A_PCM/INT/LIT`,"pcm-s24be":`A_PCM/INT/BIG`,"pcm-s32":`A_PCM/INT/LIT`,"pcm-s32be":`A_PCM/INT/BIG`,"pcm-f32":`A_PCM/FLOAT/IEEE`,"pcm-f64":`A_PCM/FLOAT/IEEE`,webvtt:`S_TEXT/WEBVTT`};function JV(e){if(e===void 0)throw Error(`Undefined element size is used in a place where it is not supported.`)}var YV=e=>{let t=(e.hasVideo?`video/`:e.hasAudio?`audio/`:`application/`)+(e.isWebM?`webm`:`x-matroska`);if(e.codecStrings.length>0){let n=[...new Set(e.codecStrings.filter(Boolean))];t+=`; codecs="${n.join(`, `)}"`}return t},XV;(function(e){e[e.None=0]=`None`,e[e.Xiph=1]=`Xiph`,e[e.FixedSize=2]=`FixedSize`,e[e.Ebml=3]=`Ebml`})(XV||={});var ZV;(function(e){e[e.Block=1]=`Block`,e[e.Private=2]=`Private`,e[e.Next=4]=`Next`})(ZV||={});var QV;(function(e){e[e.Zlib=0]=`Zlib`,e[e.Bzlib=1]=`Bzlib`,e[e.lzo1x=2]=`lzo1x`,e[e.HeaderStripping=3]=`HeaderStripping`})(QV||={});var $V=[{id:Q.SeekHead,flag:`seekHeadSeen`},{id:Q.Info,flag:`infoSeen`},{id:Q.Tracks,flag:`tracksSeen`},{id:Q.Cues,flag:`cuesSeen`}],eH=10*2**20,tH=class extends KB{constructor(e){super(e),this.readMetadataPromise=null,this.segments=[],this.currentSegment=null,this.currentTrack=null,this.currentCluster=null,this.currentBlock=null,this.currentBlockAdditional=null,this.currentCueTime=null,this.currentDecodingInstruction=null,this.currentTagTargetIsMovie=!0,this.currentSimpleTagName=null,this.currentAttachedFile=null,this.isWebM=!1,this.reader=e._reader}async getTrackBackings(){return await this.readMetadata(),this.segments.flatMap(e=>e.tracks.map(e=>e.trackBacking))}async getMimeType(){await this.readMetadata();let e=await this.getTrackBackings(),t=await Promise.all(e.map(e=>e.getDecoderConfig().then(e=>e?.codec??null)));return YV({isWebM:this.isWebM,hasVideo:this.segments.some(e=>e.tracks.some(e=>e.info?.type===`video`)),hasAudio:this.segments.some(e=>e.tracks.some(e=>e.info?.type===`audio`)),codecStrings:t.filter(Boolean)})}async getMetadataTags(){await this.readMetadata();for(let e of this.segments)e.metadataTagsCollected||=(this.reader.fileSize!==null&&await this.loadSegmentMetadata(e),!0);let e={};for(let t of this.segments)e={...e,...t.metadataTags};return e}readMetadata(){return this.readMetadataPromise??=(async()=>{let e=0;for(;;){let t=this.reader.requestSliceRange(e,2,16);if(t instanceof Promise&&(t=await t),!t)break;let n=VV(t);if(!n)break;let r=n.id,i=n.size,a=t.filePos;if(r===Q.EBML){JV(i);let e=this.reader.requestSlice(a,i);if(e instanceof Promise&&(e=await e),!e)break;this.readContiguousElements(e)}else if(r===Q.Segment){if(await this.readSegment(a,i),i===void 0||this.reader.fileSize===null)break}else if(r===Q.Cluster){if(this.reader.fileSize===null)break;i===void 0&&(i=(await GV(this.reader,a,PV,this.reader.fileSize)).pos-a);let e=AL(this.segments);e&&(e.elementEndPos=a+i)}JV(i),e=a+i}})()}async readSegment(e,t){this.currentSegment={seekHeadSeen:!1,infoSeen:!1,tracksSeen:!1,cuesSeen:!1,tagsSeen:!1,attachmentsSeen:!1,timestampScale:-1,timestampFactor:-1,duration:-1,seekEntries:[],tracks:[],cuePoints:[],dataStartPos:e,elementEndPos:t===void 0?null:e+t,clusterSeekStartPos:e,lastReadCluster:null,metadataTags:{},metadataTagsCollected:!1},this.segments.push(this.currentSegment);let n=e;for(;this.currentSegment.elementEndPos===null||n<this.currentSegment.elementEndPos;){let e=this.reader.requestSliceRange(n,2,16);if(e instanceof Promise&&(e=await e),!e)break;let t=n,r=VV(e);if(!r||!NV.includes(r.id)&&r.id!==Q.Void){let e=await KV(this.reader,t,NV,Math.min(this.currentSegment.elementEndPos??1/0,t+eH));if(e){n=e;continue}else break}let{id:i,size:a}=r,o=e.filePos,s=$V.findIndex(e=>e.id===i);if(s!==-1){let e=$V[s].flag;this.currentSegment[e]=!0,JV(a);let t=this.reader.requestSlice(o,a);t instanceof Promise&&(t=await t),t&&this.readContiguousElements(t)}else if(i===Q.Tags||i===Q.Attachments){i===Q.Tags?this.currentSegment.tagsSeen=!0:this.currentSegment.attachmentsSeen=!0,JV(a);let e=this.reader.requestSlice(o,a);e instanceof Promise&&(e=await e),e&&this.readContiguousElements(e)}else if(i===Q.Cluster){this.currentSegment.clusterSeekStartPos=t;break}if(a===void 0)break;n=o+a}if(this.currentSegment.seekEntries.sort((e,t)=>e.segmentPosition-t.segmentPosition),this.reader.fileSize!==null)for(let t of this.currentSegment.seekEntries){let n=$V.find(e=>e.id===t.id);if(!n||this.currentSegment[n.flag])continue;let r=this.reader.requestSliceRange(e+t.segmentPosition,2,16);if(r instanceof Promise&&(r=await r),!r)continue;let i=VV(r);if(!i)continue;let{id:a,size:o}=i;if(a!==n.id)continue;JV(o),this.currentSegment[n.flag]=!0;let s=this.reader.requestSlice(r.filePos,o);s instanceof Promise&&(s=await s),s&&this.readContiguousElements(s)}this.currentSegment.timestampScale===-1&&(this.currentSegment.timestampScale=1e6,this.currentSegment.timestampFactor=1e9/1e6);for(let e of this.currentSegment.tracks)e.defaultDurationNs!==null&&(e.defaultDuration=this.currentSegment.timestampFactor*e.defaultDurationNs/1e9);let r=new Map(this.currentSegment.tracks.map(e=>[e.id,e]));for(let e of this.currentSegment.cuePoints){let t=r.get(e.trackId);t&&t.cuePoints.push(e)}for(let e of this.currentSegment.tracks){e.cuePoints.sort((e,t)=>e.time-t.time);for(let t=0;t<e.cuePoints.length-1;t++){let n=e.cuePoints[t],r=e.cuePoints[t+1];n.time===r.time&&(e.cuePoints.splice(t+1,1),t--)}}let i=null,a=-1/0;for(let e of this.currentSegment.tracks)e.cuePoints.length>a&&(a=e.cuePoints.length,i=e);for(let e of this.currentSegment.tracks)e.cuePoints.length===0&&(e.cuePoints=i.cuePoints);this.currentSegment=null}async readCluster(e,t){if(t.lastReadCluster?.elementStartPos===e)return t.lastReadCluster;let n=this.reader.requestSliceRange(e,2,16);n instanceof Promise&&(n=await n),X(n);let r=e,i=VV(n);X(i);let a=i.id;X(a===Q.Cluster);let o=i.size,s=n.filePos;o===void 0&&(o=(await GV(this.reader,s,PV,t.elementEndPos)).pos-s);let c=this.reader.requestSlice(s,o);c instanceof Promise&&(c=await c);let l={segment:t,elementStartPos:r,elementEndPos:s+o,dataStartPos:s,timestamp:-1,trackData:new Map};this.currentCluster=l,c&&(l.elementEndPos=this.readContiguousElements(c,PV));for(let[,e]of l.trackData){let t=e.track;X(e.blocks.length>0);let n=!1;for(let t=0;t<e.blocks.length;t++){let r=e.blocks[t];r.timestamp+=l.timestamp,n||=r.lacing!==XV.None}e.presentationTimestamps=e.blocks.map((e,t)=>({timestamp:e.timestamp,blockIndex:t})).sort((e,t)=>e.timestamp-t.timestamp);for(let n=0;n<e.presentationTimestamps.length;n++){let r=e.presentationTimestamps[n],i=e.blocks[r.blockIndex];e.firstKeyFrameTimestamp===null&&i.isKeyFrame&&(e.firstKeyFrameTimestamp=i.timestamp),n<e.presentationTimestamps.length-1?i.duration=e.presentationTimestamps[n+1].timestamp-i.timestamp:i.duration===0&&t.defaultDuration!=null&&i.lacing===XV.None&&(i.duration=t.defaultDuration)}n&&(this.expandLacedBlocks(e.blocks,t),e.presentationTimestamps=e.blocks.map((e,t)=>({timestamp:e.timestamp,blockIndex:t})).sort((e,t)=>e.timestamp-t.timestamp));let i=e.blocks[e.presentationTimestamps[0].blockIndex],a=e.blocks[AL(e.presentationTimestamps).blockIndex];e.startTimestamp=i.timestamp,e.endTimestamp=a.timestamp+a.duration;let o=QL(t.clusterPositionCache,e.startTimestamp,e=>e.startTimestamp);(o===-1||t.clusterPositionCache[o].elementStartPos!==r)&&t.clusterPositionCache.splice(o+1,0,{elementStartPos:l.elementStartPos,startTimestamp:e.startTimestamp})}return t.lastReadCluster=l,l}getTrackDataInCluster(e,t){let n=e.trackData.get(t);if(!n){let r=e.segment.tracks.find(e=>e.id===t);if(!r)return null;n={track:r,startTimestamp:0,endTimestamp:0,firstKeyFrameTimestamp:null,blocks:[],presentationTimestamps:[]},e.trackData.set(t,n)}return n}expandLacedBlocks(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r.lacing===XV.None)continue;r.decoded||=(r.data=this.decodeBlockData(t,r.data),!0);let i=LG.tempFromBytes(r.data),a=[],o=BG(i)+1;switch(r.lacing){case XV.Xiph:{let e=0;for(let t=0;t<o-1;t++){let t=0;for(;i.bufferPos<i.length;){let n=BG(i);if(t+=n,n<255){a.push(t),e+=t;break}}}a.push(i.length-(i.bufferPos+e))}break;case XV.FixedSize:{let e=i.length-1,t=Math.floor(e/o);for(let e=0;e<o;e++)a.push(t)}break;case XV.Ebml:{let e=IV(i);X(e!==null);let t=e;a.push(t);let n=t;for(let e=1;e<o-1;e++){let e=i.bufferPos,r=IV(i);X(r!==null);let o=r-((1<<(i.bufferPos-e)*7-1)-1);t+=o,a.push(t),n+=t}a.push(i.length-(i.bufferPos+n))}break;default:X(!1)}X(a.length===o),e.splice(n,1);let s=r.duration||o*(t.defaultDuration??0);for(let t=0;t<o;t++){let c=a[t],l=zG(i,c),u=r.timestamp+s*t/o,d=s/o;e.splice(n+t,0,{timestamp:u,duration:d,isKeyFrame:r.isKeyFrame,data:l,lacing:XV.None,decoded:!0,mainAdditional:r.mainAdditional})}n+=o,n--}}async loadSegmentMetadata(e){for(let t of e.seekEntries){if(!(t.id===Q.Tags&&!e.tagsSeen)&&!(t.id===Q.Attachments&&!e.attachmentsSeen))continue;let n=this.reader.requestSliceRange(e.dataStartPos+t.segmentPosition,2,16);if(n instanceof Promise&&(n=await n),!n)continue;let r=VV(n);if(!r||r.id!==t.id)continue;let{size:i}=r;JV(i),X(!this.currentSegment),this.currentSegment=e;let a=this.reader.requestSlice(n.filePos,i);a instanceof Promise&&(a=await a),a&&this.readContiguousElements(a),this.currentSegment=null,t.id===Q.Tags?e.tagsSeen=!0:t.id===Q.Attachments&&(e.attachmentsSeen=!0)}}readContiguousElements(e,t){for(;e.remainingLength>=2;){let n=e.filePos;if(!this.traverseElement(e,t))return n}return e.filePos}traverseElement(e,t){let n=VV(e);if(!n||t&&t.includes(n.id))return!1;let{id:r,size:i}=n,a=e.filePos;switch(JV(i),r){case Q.DocType:this.isWebM=HV(e,i)===`webm`;break;case Q.Seek:{if(!this.currentSegment)break;let t={id:-1,segmentPosition:-1};this.currentSegment.seekEntries.push(t),this.readContiguousElements(e.slice(a,i)),(t.id===-1||t.segmentPosition===-1)&&this.currentSegment.seekEntries.pop()}break;case Q.SeekID:{let t=this.currentSegment?.seekEntries[this.currentSegment.seekEntries.length-1];if(!t)break;t.id=LV(e,i)}break;case Q.SeekPosition:{let t=this.currentSegment?.seekEntries[this.currentSegment.seekEntries.length-1];if(!t)break;t.segmentPosition=LV(e,i)}break;case Q.TimestampScale:if(!this.currentSegment)break;this.currentSegment.timestampScale=LV(e,i),this.currentSegment.timestampFactor=1e9/this.currentSegment.timestampScale;break;case Q.Duration:if(!this.currentSegment)break;this.currentSegment.duration=WV(e,i);break;case Q.TrackEntry:if(!this.currentSegment||(this.currentTrack={id:-1,segment:this.currentSegment,demuxer:this,clusterPositionCache:[],cuePoints:[],disposition:{...ez,primary:!1},trackBacking:null,codecId:null,codecPrivate:null,defaultDuration:null,defaultDurationNs:null,name:null,languageCode:`eng`,hasLanguageBcp47:!1,decodingInstructions:[],info:null},this.readContiguousElements(e.slice(a,i)),!this.currentTrack))break;if(this.currentTrack.decodingInstructions.some(e=>e.data?.type!==`decompress`||e.scope!==ZV.Block||e.data.algorithm!==QV.HeaderStripping)&&(console.warn(`Track #${this.currentTrack.id} has an unsupported content encoding; dropping.`),this.currentTrack=null),this.currentTrack&&this.currentTrack.id!==-1&&this.currentTrack.codecId&&this.currentTrack.info){let e=this.currentTrack.codecId.indexOf(`/`),t=e===-1?this.currentTrack.codecId:this.currentTrack.codecId.slice(0,e);if(this.currentTrack.info.type===`video`&&this.currentTrack.info.width!==-1&&this.currentTrack.info.height!==-1){if(this.currentTrack.info.squarePixelWidth=this.currentTrack.info.width,this.currentTrack.info.squarePixelHeight=this.currentTrack.info.height,this.currentTrack.info.displayWidth!==null&&this.currentTrack.info.displayHeight!==null){let e=this.currentTrack.info.displayWidth*this.currentTrack.info.height,t=this.currentTrack.info.displayHeight*this.currentTrack.info.width;e>0&&t>0&&(e>t?this.currentTrack.info.squarePixelWidth=Math.round(this.currentTrack.info.width*e/t):this.currentTrack.info.squarePixelHeight=Math.round(this.currentTrack.info.height*t/e))}this.currentTrack.codecId===qV.avc?(this.currentTrack.info.codec=`avc`,this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):this.currentTrack.codecId===qV.hevc?(this.currentTrack.info.codec=`hevc`,this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):t===qV.vp8?this.currentTrack.info.codec=`vp8`:t===qV.vp9?this.currentTrack.info.codec=`vp9`:t===qV.av1&&(this.currentTrack.info.codec=`av1`);let e=this.currentTrack;this.currentTrack.trackBacking=new rH(e),this.currentSegment.tracks.push(this.currentTrack)}else if(this.currentTrack.info.type===`audio`){t===qV.aac?(this.currentTrack.info.codec=`aac`,this.currentTrack.info.aacCodecInfo={isMpeg2:this.currentTrack.codecId.includes(`MPEG2`),objectType:null},this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):this.currentTrack.codecId===qV.mp3?this.currentTrack.info.codec=`mp3`:t===qV.opus?(this.currentTrack.info.codec=`opus`,this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate,this.currentTrack.info.sampleRate=Cz):t===qV.vorbis?(this.currentTrack.info.codec=`vorbis`,this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):t===qV.flac?(this.currentTrack.info.codec=`flac`,this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):t===qV.ac3?(this.currentTrack.info.codec=`ac3`,this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):t===qV.eac3?(this.currentTrack.info.codec=`eac3`,this.currentTrack.info.codecDescription=this.currentTrack.codecPrivate):this.currentTrack.codecId===`A_PCM/INT/LIT`?this.currentTrack.info.bitDepth===8?this.currentTrack.info.codec=`pcm-u8`:this.currentTrack.info.bitDepth===16?this.currentTrack.info.codec=`pcm-s16`:this.currentTrack.info.bitDepth===24?this.currentTrack.info.codec=`pcm-s24`:this.currentTrack.info.bitDepth===32&&(this.currentTrack.info.codec=`pcm-s32`):this.currentTrack.codecId===`A_PCM/INT/BIG`?this.currentTrack.info.bitDepth===8?this.currentTrack.info.codec=`pcm-u8`:this.currentTrack.info.bitDepth===16?this.currentTrack.info.codec=`pcm-s16be`:this.currentTrack.info.bitDepth===24?this.currentTrack.info.codec=`pcm-s24be`:this.currentTrack.info.bitDepth===32&&(this.currentTrack.info.codec=`pcm-s32be`):this.currentTrack.codecId===`A_PCM/FLOAT/IEEE`&&(this.currentTrack.info.bitDepth===32?this.currentTrack.info.codec=`pcm-f32`:this.currentTrack.info.bitDepth===64&&(this.currentTrack.info.codec=`pcm-f64`));let e=this.currentTrack;this.currentTrack.trackBacking=new iH(e),this.currentSegment.tracks.push(this.currentTrack)}}this.currentTrack=null;break;case Q.TrackNumber:if(!this.currentTrack)break;this.currentTrack.id=LV(e,i);break;case Q.TrackType:{if(!this.currentTrack)break;let t=LV(e,i);t===1?this.currentTrack.info={type:`video`,width:-1,height:-1,displayWidth:null,displayHeight:null,displayUnit:null,squarePixelWidth:-1,squarePixelHeight:-1,rotation:0,codec:null,codecDescription:null,colorSpace:null,alphaMode:!1}:t===2&&(this.currentTrack.info={type:`audio`,numberOfChannels:1,sampleRate:8e3,bitDepth:-1,codec:null,codecDescription:null,aacCodecInfo:null})}break;case Q.FlagEnabled:if(!this.currentTrack)break;LV(e,i)||(this.currentTrack=null);break;case Q.FlagDefault:if(!this.currentTrack)break;this.currentTrack.disposition.default=!!LV(e,i);break;case Q.FlagForced:if(!this.currentTrack)break;this.currentTrack.disposition.forced=!!LV(e,i);break;case Q.FlagOriginal:if(!this.currentTrack)break;this.currentTrack.disposition.original=!!LV(e,i);break;case Q.FlagHearingImpaired:if(!this.currentTrack)break;this.currentTrack.disposition.hearingImpaired=!!LV(e,i);break;case Q.FlagVisualImpaired:if(!this.currentTrack)break;this.currentTrack.disposition.visuallyImpaired=!!LV(e,i);break;case Q.FlagCommentary:if(!this.currentTrack)break;this.currentTrack.disposition.commentary=!!LV(e,i);break;case Q.CodecID:if(!this.currentTrack)break;this.currentTrack.codecId=HV(e,i);break;case Q.CodecPrivate:if(!this.currentTrack)break;this.currentTrack.codecPrivate=zG(e,i);break;case Q.DefaultDuration:if(!this.currentTrack)break;this.currentTrack.defaultDurationNs=LV(e,i);break;case Q.Name:if(!this.currentTrack)break;this.currentTrack.name=UV(e,i);break;case Q.Language:if(!this.currentTrack||this.currentTrack.hasLanguageBcp47)break;this.currentTrack.languageCode=HV(e,i),bR(this.currentTrack.languageCode)||(this.currentTrack.languageCode=`und`);break;case Q.LanguageBCP47:{if(!this.currentTrack)break;let t=HV(e,i).split(`-`)[0];t?this.currentTrack.languageCode=t:this.currentTrack.languageCode=`und`,this.currentTrack.hasLanguageBcp47=!0}break;case Q.Video:if(this.currentTrack?.info?.type!==`video`)break;this.readContiguousElements(e.slice(a,i));break;case Q.PixelWidth:if(this.currentTrack?.info?.type!==`video`)break;this.currentTrack.info.width=LV(e,i);break;case Q.PixelHeight:if(this.currentTrack?.info?.type!==`video`)break;this.currentTrack.info.height=LV(e,i);break;case Q.DisplayWidth:if(this.currentTrack?.info?.type!==`video`)break;this.currentTrack.info.displayWidth=LV(e,i);break;case Q.DisplayHeight:if(this.currentTrack?.info?.type!==`video`)break;this.currentTrack.info.displayHeight=LV(e,i);break;case Q.DisplayUnit:if(this.currentTrack?.info?.type!==`video`)break;this.currentTrack.info.displayUnit=LV(e,i);break;case Q.AlphaMode:if(this.currentTrack?.info?.type!==`video`)break;this.currentTrack.info.alphaMode=LV(e,i)===1;break;case Q.Colour:if(this.currentTrack?.info?.type!==`video`)break;this.currentTrack.info.colorSpace={},this.readContiguousElements(e.slice(a,i));break;case Q.MatrixCoefficients:{if(this.currentTrack?.info?.type!==`video`||!this.currentTrack.info.colorSpace)break;let t=UL[LV(e,i)]??null;this.currentTrack.info.colorSpace.matrix=t}break;case Q.Range:if(this.currentTrack?.info?.type!==`video`||!this.currentTrack.info.colorSpace)break;this.currentTrack.info.colorSpace.fullRange=LV(e,i)===2;break;case Q.TransferCharacteristics:{if(this.currentTrack?.info?.type!==`video`||!this.currentTrack.info.colorSpace)break;let t=VL[LV(e,i)]??null;this.currentTrack.info.colorSpace.transfer=t}break;case Q.Primaries:{if(this.currentTrack?.info?.type!==`video`||!this.currentTrack.info.colorSpace)break;let t=zL[LV(e,i)]??null;this.currentTrack.info.colorSpace.primaries=t}break;case Q.Projection:if(this.currentTrack?.info?.type!==`video`)break;this.readContiguousElements(e.slice(a,i));break;case Q.ProjectionPoseRoll:{if(this.currentTrack?.info?.type!==`video`)break;let t=-WV(e,i);try{this.currentTrack.info.rotation=kL(t)}catch{}}break;case Q.Audio:if(this.currentTrack?.info?.type!==`audio`)break;this.readContiguousElements(e.slice(a,i));break;case Q.SamplingFrequency:if(this.currentTrack?.info?.type!==`audio`)break;this.currentTrack.info.sampleRate=WV(e,i);break;case Q.Channels:if(this.currentTrack?.info?.type!==`audio`)break;this.currentTrack.info.numberOfChannels=LV(e,i);break;case Q.BitDepth:if(this.currentTrack?.info?.type!==`audio`)break;this.currentTrack.info.bitDepth=LV(e,i);break;case Q.CuePoint:if(!this.currentSegment)break;this.readContiguousElements(e.slice(a,i)),this.currentCueTime=null;break;case Q.CueTime:this.currentCueTime=LV(e,i);break;case Q.CueTrackPositions:{if(this.currentCueTime===null)break;X(this.currentSegment);let t={time:this.currentCueTime,trackId:-1,clusterPosition:-1};this.currentSegment.cuePoints.push(t),this.readContiguousElements(e.slice(a,i)),(t.trackId===-1||t.clusterPosition===-1)&&this.currentSegment.cuePoints.pop()}break;case Q.CueTrack:{let t=this.currentSegment?.cuePoints[this.currentSegment.cuePoints.length-1];if(!t)break;t.trackId=LV(e,i)}break;case Q.CueClusterPosition:{let t=this.currentSegment?.cuePoints[this.currentSegment.cuePoints.length-1];if(!t)break;X(this.currentSegment),t.clusterPosition=this.currentSegment.dataStartPos+LV(e,i)}break;case Q.Timestamp:if(!this.currentCluster)break;this.currentCluster.timestamp=LV(e,i);break;case Q.SimpleBlock:{if(!this.currentCluster)break;let t=IV(e);if(t===null)break;let n=this.getTrackDataInCluster(this.currentCluster,t);if(!n)break;let r=WG(e),o=BG(e),s=o>>1&3,c=!!(o&128);n.track.info?.type===`audio`&&n.track.info.codec&&(c=!0);let l=zG(e,i-(e.filePos-a)),u=n.track.decodingInstructions.length>0;n.blocks.push({timestamp:r,duration:0,isKeyFrame:c,data:l,lacing:s,decoded:!u,mainAdditional:null})}break;case Q.BlockGroup:if(!this.currentCluster)break;this.readContiguousElements(e.slice(a,i)),this.currentBlock=null;break;case Q.Block:{if(!this.currentCluster)break;let t=IV(e);if(t===null)break;let n=this.getTrackDataInCluster(this.currentCluster,t);if(!n)break;let r=WG(e),o=BG(e)>>1&3,s=zG(e,i-(e.filePos-a)),c=n.track.decodingInstructions.length>0;this.currentBlock={timestamp:r,duration:0,isKeyFrame:!0,data:s,lacing:o,decoded:!c,mainAdditional:null},n.blocks.push(this.currentBlock)}break;case Q.BlockAdditions:this.readContiguousElements(e.slice(a,i));break;case Q.BlockMore:if(!this.currentBlock)break;this.currentBlockAdditional={addId:1,data:null},this.readContiguousElements(e.slice(a,i)),this.currentBlockAdditional.data&&this.currentBlockAdditional.addId===1&&(this.currentBlock.mainAdditional=this.currentBlockAdditional.data),this.currentBlockAdditional=null;break;case Q.BlockAdditional:if(!this.currentBlockAdditional)break;this.currentBlockAdditional.data=zG(e,i);break;case Q.BlockAddID:if(!this.currentBlockAdditional)break;this.currentBlockAdditional.addId=LV(e,i);break;case Q.BlockDuration:if(!this.currentBlock)break;this.currentBlock.duration=LV(e,i);break;case Q.ReferenceBlock:if(!this.currentBlock)break;this.currentBlock.isKeyFrame=!1;break;case Q.Tag:this.currentTagTargetIsMovie=!0,this.readContiguousElements(e.slice(a,i));break;case Q.Targets:this.readContiguousElements(e.slice(a,i));break;case Q.TargetTypeValue:LV(e,i)!==50&&(this.currentTagTargetIsMovie=!1);break;case Q.TagTrackUID:case Q.TagEditionUID:case Q.TagChapterUID:case Q.TagAttachmentUID:this.currentTagTargetIsMovie=!1;break;case Q.SimpleTag:if(!this.currentTagTargetIsMovie)break;this.currentSimpleTagName=null,this.readContiguousElements(e.slice(a,i));break;case Q.TagName:this.currentSimpleTagName=UV(e,i);break;case Q.TagString:{if(!this.currentSimpleTagName)break;let t=UV(e,i);this.processTagValue(this.currentSimpleTagName,t)}break;case Q.TagBinary:{if(!this.currentSimpleTagName)break;let t=zG(e,i);this.processTagValue(this.currentSimpleTagName,t)}break;case Q.AttachedFile:{if(!this.currentSegment)break;this.currentAttachedFile={fileUid:null,fileName:null,fileMediaType:null,fileData:null,fileDescription:null},this.readContiguousElements(e.slice(a,i));let t=this.currentSegment.metadataTags;if(this.currentAttachedFile.fileUid&&this.currentAttachedFile.fileData&&(t.raw??={},t.raw[this.currentAttachedFile.fileUid.toString()]=new QR(this.currentAttachedFile.fileData,this.currentAttachedFile.fileMediaType??void 0,this.currentAttachedFile.fileName??void 0,this.currentAttachedFile.fileDescription??void 0)),this.currentAttachedFile.fileMediaType?.startsWith(`image/`)&&this.currentAttachedFile.fileData){let e=this.currentAttachedFile.fileName,n=`unknown`;if(e){let t=e.toLowerCase();t.startsWith(`cover.`)?n=`coverFront`:t.startsWith(`back.`)&&(n=`coverBack`)}t.images??=[],t.images.push({data:this.currentAttachedFile.fileData,mimeType:this.currentAttachedFile.fileMediaType,kind:n,name:this.currentAttachedFile.fileName??void 0,description:this.currentAttachedFile.fileDescription??void 0})}this.currentAttachedFile=null}break;case Q.FileUID:if(!this.currentAttachedFile)break;this.currentAttachedFile.fileUid=RV(e,i);break;case Q.FileName:if(!this.currentAttachedFile)break;this.currentAttachedFile.fileName=UV(e,i);break;case Q.FileMediaType:if(!this.currentAttachedFile)break;this.currentAttachedFile.fileMediaType=HV(e,i);break;case Q.FileData:if(!this.currentAttachedFile)break;this.currentAttachedFile.fileData=zG(e,i);break;case Q.FileDescription:if(!this.currentAttachedFile)break;this.currentAttachedFile.fileDescription=UV(e,i);break;case Q.ContentEncodings:if(!this.currentTrack)break;this.readContiguousElements(e.slice(a,i)),this.currentTrack.decodingInstructions.sort((e,t)=>t.order-e.order);break;case Q.ContentEncoding:this.currentDecodingInstruction={order:0,scope:ZV.Block,data:null},this.readContiguousElements(e.slice(a,i)),this.currentDecodingInstruction.data&&this.currentTrack.decodingInstructions.push(this.currentDecodingInstruction),this.currentDecodingInstruction=null;break;case Q.ContentEncodingOrder:if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.order=LV(e,i);break;case Q.ContentEncodingScope:if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.scope=LV(e,i);break;case Q.ContentCompression:if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.data={type:`decompress`,algorithm:QV.Zlib,settings:null},this.readContiguousElements(e.slice(a,i));break;case Q.ContentCompAlgo:if(this.currentDecodingInstruction?.data?.type!==`decompress`)break;this.currentDecodingInstruction.data.algorithm=LV(e,i);break;case Q.ContentCompSettings:if(this.currentDecodingInstruction?.data?.type!==`decompress`)break;this.currentDecodingInstruction.data.settings=zG(e,i);break;case Q.ContentEncryption:if(!this.currentDecodingInstruction)break;this.currentDecodingInstruction.data={type:`decrypt`};break}return e.filePos=a+i,!0}decodeBlockData(e,t){X(e.decodingInstructions.length>0);let n=t;for(let t of e.decodingInstructions)switch(X(t.data),t.data.type){case`decompress`:switch(t.data.algorithm){case QV.HeaderStripping:if(t.data.settings&&t.data.settings.length>0){let e=t.data.settings,r=new Uint8Array(e.length+n.length);r.set(e,0),r.set(n,e.length),n=r}break;default:}break;default:}return n}processTagValue(e,t){if(!this.currentSegment?.metadataTags)return;let n=this.currentSegment.metadataTags;if(n.raw??={},n.raw[e]??=t,typeof t==`string`)switch(e.toLowerCase()){case`title`:n.title??=t;break;case`description`:n.description??=t;break;case`artist`:n.artist??=t;break;case`album`:n.album??=t;break;case`album_artist`:n.albumArtist??=t;break;case`genre`:n.genre??=t;break;case`comment`:n.comment??=t;break;case`lyrics`:n.lyrics??=t;break;case`date`:{let e=new Date(t);Number.isNaN(e.getTime())||(n.date??=e)}break;case`track_number`:case`part_number`:{let e=t.split(`/`),r=Number.parseInt(e[0],10),i=e[1]&&Number.parseInt(e[1],10);Number.isInteger(r)&&r>0&&(n.trackNumber??=r),i&&Number.isInteger(i)&&i>0&&(n.tracksTotal??=i)}break;case`disc_number`:case`disc`:{let e=t.split(`/`),r=Number.parseInt(e[0],10),i=e[1]&&Number.parseInt(e[1],10);Number.isInteger(r)&&r>0&&(n.discNumber??=r),i&&Number.isInteger(i)&&i>0&&(n.discsTotal??=i)}break}}},nH=class{constructor(e){this.internalTrack=e,this.packetToClusterLocation=new WeakMap}getId(){return this.internalTrack.id}getNumber(){let e=this.internalTrack.demuxer,t=this.internalTrack.trackBacking.getType(),n=0;for(let r of e.segments)for(let e of r.tracks)if(e.trackBacking.getType()===t&&n++,e===this.internalTrack)break;return n}getCodec(){throw Error(`Not implemented on base class.`)}getInternalCodecId(){return this.internalTrack.codecId}getName(){return this.internalTrack.name}getLanguageCode(){return this.internalTrack.languageCode}getTimeResolution(){return this.internalTrack.segment.timestampFactor}isRelativeToUnixEpoch(){return!1}getDisposition(){return this.internalTrack.disposition}getPairingMask(){return 1n}getBitrate(){return null}getAverageBitrate(){return null}async getDurationFromMetadata(){let e=this.internalTrack.segment;if(e.duration<=0)return null;let t=e.duration/e.timestampFactor,n=await this.getFirstPacket({metadataOnly:!0});return t+=n?.timestamp??0,t}async getLiveRefreshInterval(){return null}async getFirstPacket(e){return this.performClusterLookup(null,e=>e.trackData.get(this.internalTrack.id)?{blockIndex:0,correctBlockFound:!0}:{blockIndex:-1,correctBlockFound:!1},-1/0,1/0,e)}intoTimescale(e){return pR(e*this.internalTrack.segment.timestampFactor)}async getPacket(e,t){let n=this.intoTimescale(e);return this.performClusterLookup(null,e=>{let t=e.trackData.get(this.internalTrack.id);if(!t)return{blockIndex:-1,correctBlockFound:!1};let r=QL(t.presentationTimestamps,n,e=>e.timestamp);return{blockIndex:r===-1?-1:t.presentationTimestamps[r].blockIndex,correctBlockFound:r!==-1&&n<t.endTimestamp}},n,n,t)}async getNextPacket(e,t){let n=this.packetToClusterLocation.get(e);if(n===void 0)throw Error(`Packet was not created from this track.`);return this.performClusterLookup(n.cluster,e=>{if(e===n.cluster){let t=e.trackData.get(this.internalTrack.id);if(n.blockIndex+1<t.blocks.length)return{blockIndex:n.blockIndex+1,correctBlockFound:!0}}else if(e.trackData.get(this.internalTrack.id))return{blockIndex:0,correctBlockFound:!0};return{blockIndex:-1,correctBlockFound:!1}},-1/0,1/0,t)}async getKeyPacket(e,t){let n=this.intoTimescale(e);return this.performClusterLookup(null,e=>{let t=e.trackData.get(this.internalTrack.id);if(!t)return{blockIndex:-1,correctBlockFound:!1};let r=rR(t.presentationTimestamps,e=>t.blocks[e.blockIndex].isKeyFrame&&e.timestamp<=n);return{blockIndex:r===-1?-1:t.presentationTimestamps[r].blockIndex,correctBlockFound:r!==-1&&n<t.endTimestamp}},n,n,t)}async getNextKeyPacket(e,t){let n=this.packetToClusterLocation.get(e);if(n===void 0)throw Error(`Packet was not created from this track.`);return this.performClusterLookup(n.cluster,e=>{if(e===n.cluster){let t=e.trackData.get(this.internalTrack.id).blocks.findIndex((e,t)=>e.isKeyFrame&&t>n.blockIndex);if(t!==-1)return{blockIndex:t,correctBlockFound:!0}}else{let t=e.trackData.get(this.internalTrack.id);if(t&&t.firstKeyFrameTimestamp!==null){let e=t.blocks.findIndex(e=>e.isKeyFrame);return X(e!==-1),{blockIndex:e,correctBlockFound:!0}}}return{blockIndex:-1,correctBlockFound:!1}},-1/0,1/0,t)}async fetchPacketInCluster(e,t,n){if(t===-1)return null;let r=e.trackData.get(this.internalTrack.id).blocks[t];X(r),r.decoded||=(r.data=this.internalTrack.demuxer.decodeBlockData(this.internalTrack,r.data),!0);let i=n.metadataOnly?qB:r.data,a=r.timestamp/this.internalTrack.segment.timestampFactor,o=r.duration/this.internalTrack.segment.timestampFactor,s={};r.mainAdditional&&this.internalTrack.info?.type===`video`&&this.internalTrack.info.alphaMode&&(s.alpha=n.metadataOnly?qB:r.mainAdditional,s.alphaByteLength=r.mainAdditional.byteLength);let c=new JB(i,r.isKeyFrame?`key`:`delta`,a,o,e.dataStartPos+t,r.data.byteLength,s);return this.packetToClusterLocation.set(c,{cluster:e,blockIndex:t}),c}async performClusterLookup(e,t,n,r,i){let{demuxer:a,segment:o}=this.internalTrack,s=null,c=null,l=-1;if(e){let{blockIndex:n,correctBlockFound:r}=t(e);if(r)return this.fetchPacketInCluster(e,n,i);n!==-1&&(c=e,l=n)}let u=QL(this.internalTrack.cuePoints,n,e=>e.time),d=u===-1?null:this.internalTrack.cuePoints[u],f=QL(this.internalTrack.clusterPositionCache,n,e=>e.startTimestamp),p=f===-1?null:this.internalTrack.clusterPositionCache[f],m=Math.max(d?.clusterPosition??0,p?.elementStartPos??0)||null,h;for(e?m===null||e.elementStartPos>=m?(h=e.elementEndPos,s=e):h=m:h=m??o.clusterSeekStartPos;o.elementEndPos===null||h<=o.elementEndPos-2;){if(s){let e=s.trackData.get(this.internalTrack.id);if(e&&e.startTimestamp>r)break}let e=a.reader.requestSliceRange(h,2,16);if(e instanceof Promise&&(e=await e),!e)break;let n=h,u=VV(e);if(!u||!NV.includes(u.id)&&u.id!==Q.Void){let e=await KV(a.reader,n,NV,Math.min(o.elementEndPos??1/0,n+eH));if(e){h=e;continue}else break}let d=u.id,f=u.size,p=e.filePos;if(d===Q.Cluster){s=await a.readCluster(n,o),f=s.elementEndPos-p;let{blockIndex:e,correctBlockFound:r}=t(s);if(r)return this.fetchPacketInCluster(s,e,i);e!==-1&&(c=s,l=e)}f===void 0&&(X(d!==Q.Cluster),f=(await GV(a.reader,p,PV,o.elementEndPos)).pos-p);let m=p+f;if(o.elementEndPos===null){let e=a.reader.requestSliceRange(m,2,16);if(e instanceof Promise&&(e=await e),!e)break;if(zV(e)===Q.Segment){o.elementEndPos=m;break}}h=m}if(d&&(!c||c.elementStartPos<d.clusterPosition)){let e=this.internalTrack.cuePoints[u-1];X(!e||e.time<d.time);let n=e?.time??-1/0;return this.performClusterLookup(null,t,n,r,i)}return c?this.fetchPacketInCluster(c,l,i):null}},rH=class extends nH{constructor(e){super(e),this.decoderConfigPromise=null,this.internalTrack=e}getType(){return`video`}getCodec(){return this.internalTrack.info.codec}getCodedWidth(){return this.internalTrack.info.width}getCodedHeight(){return this.internalTrack.info.height}getSquarePixelWidth(){return this.internalTrack.info.squarePixelWidth}getSquarePixelHeight(){return this.internalTrack.info.squarePixelHeight}getRotation(){return this.internalTrack.info.rotation}async getColorSpace(){return{primaries:this.internalTrack.info.colorSpace?.primaries,transfer:this.internalTrack.info.colorSpace?.transfer,matrix:this.internalTrack.info.colorSpace?.matrix,fullRange:this.internalTrack.info.colorSpace?.fullRange}}async canBeTransparent(){return this.internalTrack.info.alphaMode}async getDecoderConfig(){return this.internalTrack.info.codec?this.decoderConfigPromise??=(async()=>{let e=null;(this.internalTrack.info.codec===`vp9`||this.internalTrack.info.codec===`av1`||this.internalTrack.info.codec===`avc`&&!this.internalTrack.info.codecDescription||this.internalTrack.info.codec===`hevc`&&!this.internalTrack.info.codecDescription)&&(e=await this.getFirstPacket({}));let t={codec:bz({width:this.internalTrack.info.width,height:this.internalTrack.info.height,codec:this.internalTrack.info.codec,codecDescription:this.internalTrack.info.codecDescription,colorSpace:this.internalTrack.info.colorSpace,avcType:1,avcCodecInfo:this.internalTrack.info.codec===`avc`&&e?oB(e.data):null,hevcCodecInfo:this.internalTrack.info.codec===`hevc`&&e?gB(e.data):null,vp9CodecInfo:this.internalTrack.info.codec===`vp9`&&e?DB(e.data):null,av1CodecInfo:this.internalTrack.info.codec===`av1`&&e?kB(e.data):null}),codedWidth:this.internalTrack.info.width,codedHeight:this.internalTrack.info.height,description:this.internalTrack.info.codecDescription??void 0,colorSpace:this.internalTrack.info.colorSpace??void 0};return(this.internalTrack.info.width!==this.internalTrack.info.squarePixelWidth||this.internalTrack.info.height!==this.internalTrack.info.squarePixelHeight)&&(t.displayAspectWidth=this.internalTrack.info.squarePixelWidth,t.displayAspectHeight=this.internalTrack.info.squarePixelHeight),t})():null}},iH=class extends nH{constructor(e){super(e),this.decoderConfig=null,this.internalTrack=e}getType(){return`audio`}getCodec(){return this.internalTrack.info.codec}getNumberOfChannels(){return this.internalTrack.info.numberOfChannels}getSampleRate(){return this.internalTrack.info.sampleRate}async getDecoderConfig(){return this.internalTrack.info.codec?this.decoderConfig??={codec:Sz({codec:this.internalTrack.info.codec,codecDescription:this.internalTrack.info.codecDescription,aacCodecInfo:this.internalTrack.info.aacCodecInfo}),numberOfChannels:this.internalTrack.info.numberOfChannels,sampleRate:this.internalTrack.info.sampleRate,description:this.internalTrack.info.codecDescription??void 0}:null}},aH=async(e,t,n,r=null)=>{let i=2**16,a=t;for(;n===null||a<n;){let t=n===null?i:Math.min(i,n-a),o=e.requestSliceRange(a,4,t);if(o instanceof Promise&&(o=await o),!o||o.length<4)break;for(;o.remainingLength>=4;){let t=o.filePos,n=Uz($(o),e.fileSize===null?null:e.fileSize-a);if(n.header&&(!r||n.header.sampleRate===r.sampleRate&&n.header.mpegVersionId===r.mpegVersionId&&n.header.layer===r.layer&&Kz(n.header.channel)===Kz(r.channel)))return{header:n.header,startPos:a};o.filePos=t+n.bytesAdvanced,a=o.filePos}}return null},oH=class extends KB{constructor(e){super(e),this.metadataPromise=null,this.firstFrameHeader=null,this.firstFrameHeaderPos=null,this.loadedSamples=[],this.metadataTags=null,this.xingData=null,this.trackBackings=[],this.readingMutex=new KL,this.lastSampleLoaded=!1,this.lastLoadedPos=0,this.nextTimestampInSamples=0,this.reader=e._reader}async readMetadata(){return this.metadataPromise??=(async()=>{for(;!this.firstFrameHeader&&!this.lastSampleLoaded;)await this.advanceReader();if(!this.firstFrameHeader)throw Error(`No valid MP3 frame found.`);this.trackBackings=[new sH(this)]})()}async advanceReader(){if(this.lastLoadedPos===0)for(;;){let e=this.reader.requestSlice(this.lastLoadedPos,10);if(e instanceof Promise&&(e=await e),!e){this.lastSampleLoaded=!0;return}let t=cK(e);if(!t)break;this.lastLoadedPos=e.filePos+t.size}let e=await aH(this.reader,this.lastLoadedPos,this.reader.fileSize,this.firstFrameHeader);if(!e){this.lastSampleLoaded=!0;return}let t=e.header;this.lastLoadedPos=e.startPos+t.totalSize-1;let n=Hz(t.mpegVersionId,t.channel),r=this.reader.requestSlice(e.startPos+n,4);if(r instanceof Promise&&(r=await r),r){let t=$(r);if(t===1483304551||t===1231971951){if(!this.xingData){let t=this.reader.requestSlice(e.startPos+n+4,12);if(t instanceof Promise&&(t=await t),t){let e=PL(zG(t,12)),n=e.getUint32(0,!1);this.xingData={frameCount:n&Gz.FrameCount?e.getUint32(4,!1):null,fileSize:n&Gz.FileSize?e.getUint32(8,!1):null}}}return}}this.firstFrameHeader||(this.firstFrameHeader=t,this.firstFrameHeaderPos=e.startPos);let i=t.audioSamplesInFrame/this.firstFrameHeader.sampleRate,a={timestamp:this.nextTimestampInSamples/this.firstFrameHeader.sampleRate,duration:i,dataStart:e.startPos,dataSize:t.totalSize};this.loadedSamples.push(a),this.nextTimestampInSamples+=t.audioSamplesInFrame}async getMimeType(){return`audio/mpeg`}async getTrackBackings(){return await this.readMetadata(),this.trackBackings}async getMetadataTags(){let e=await this.readingMutex.acquire();try{if(await this.readMetadata(),this.metadataTags)return this.metadataTags;this.metadataTags={};let e=0,t=!1;for(;;){let n=this.reader.requestSlice(e,10);if(n instanceof Promise&&(n=await n),!n)break;let r=cK(n);if(!r)break;t=!0;let i=this.reader.requestSlice(n.filePos,r.size);if(i instanceof Promise&&(i=await i),!i)break;lK(i,r,this.metadataTags),e=n.filePos+r.size}if(!t&&this.reader.fileSize!==null&&this.reader.fileSize>=128){let e=this.reader.requestSlice(this.reader.fileSize-128,128);e instanceof Promise&&(e=await e),X(e),tK(e,3)===`TAG`&&oK(e,this.metadataTags)}return this.metadataTags}finally{e()}}},sH=class{constructor(e){this.demuxer=e}getType(){return`audio`}getId(){return 1}getNumber(){return 1}getTimeResolution(){return X(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.sampleRate/this.demuxer.firstFrameHeader.audioSamplesInFrame}isRelativeToUnixEpoch(){return!1}getPairingMask(){return 1n}getBitrate(){return null}getAverageBitrate(){return null}async getDurationFromMetadata(){let e=this.demuxer;if(X(e.firstFrameHeader!==null),X(e.firstFrameHeaderPos!==null),e.xingData){if(e.xingData.frameCount!==null)return e.xingData.frameCount*e.firstFrameHeader.audioSamplesInFrame/e.firstFrameHeader.sampleRate}else if(e.reader.fileSize!==null){let t=Vz(e.firstFrameHeader.lowSamplingFrequency,e.firstFrameHeader.layer,e.firstFrameHeader.bitrate,e.firstFrameHeader.sampleRate),n=(e.reader.fileSize-e.firstFrameHeaderPos)/t;return Math.round(n)*e.firstFrameHeader.audioSamplesInFrame/e.firstFrameHeader.sampleRate}return null}async getLiveRefreshInterval(){return null}getName(){return null}getLanguageCode(){return`und`}getCodec(){return`mp3`}getInternalCodecId(){return null}getNumberOfChannels(){return X(this.demuxer.firstFrameHeader),Kz(this.demuxer.firstFrameHeader.channel)}getSampleRate(){return X(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.sampleRate}getDisposition(){return{...ez}}async getDecoderConfig(){return X(this.demuxer.firstFrameHeader),{codec:`mp3`,numberOfChannels:Kz(this.demuxer.firstFrameHeader.channel),sampleRate:this.demuxer.firstFrameHeader.sampleRate}}async getPacketAtIndex(e,t){if(e===-1)return null;let n=this.demuxer.loadedSamples[e];if(!n)return null;let r;if(t.metadataOnly)r=qB;else{let e=this.demuxer.reader.requestSlice(n.dataStart,n.dataSize);if(e instanceof Promise&&(e=await e),!e)return null;r=zG(e,n.dataSize)}return new JB(r,`key`,n.timestamp,n.duration,e,n.dataSize)}getFirstPacket(e){return this.getPacketAtIndex(0,e)}async getNextPacket(e,t){let n=await this.demuxer.readingMutex.acquire();try{let n=ZL(this.demuxer.loadedSamples,e.timestamp,e=>e.timestamp);if(n===-1)throw Error(`Packet was not created from this track.`);let r=n+1;for(;r>=this.demuxer.loadedSamples.length&&!this.demuxer.lastSampleLoaded;)await this.demuxer.advanceReader();return this.getPacketAtIndex(r,t)}finally{n()}}async getPacket(e,t){let n=await this.demuxer.readingMutex.acquire();try{for(;;){let n=QL(this.demuxer.loadedSamples,e,e=>e.timestamp);if(n===-1&&this.demuxer.loadedSamples.length>0)return null;if(this.demuxer.lastSampleLoaded||n>=0&&n+1<this.demuxer.loadedSamples.length)return this.getPacketAtIndex(n,t);await this.demuxer.advanceReader()}}finally{n()}}getKeyPacket(e,t){return this.getPacket(e,t)}getNextKeyPacket(e,t){return this.getNextPacket(e,t)}},cH=79764919,lH=new Uint32Array(256);for(let e=0;e<256;e++){let t=e<<24;for(let e=0;e<8;e++)t=t&2147483648?t<<1^cH:t<<1;lH[e]=t>>>0&4294967295}var uH=e=>{let t=PL(e),n=t.getUint32(22,!0);t.setUint32(22,0,!0);let r=0;for(let t=0;t<e.length;t++){let n=e[t];r=(r<<8^lH[r>>>24^n])>>>0}return t.setUint32(22,n,!0),r},dH=(e,t,n)=>{let r=0,i=null;if(e.length>0)if(t.codec===`vorbis`){X(t.vorbisInfo);let a=t.vorbisInfo.modeBlockflags.length,o=(1<<vR(a-1))-1<<1,s=(e[0]&o)>>1;if(s>=t.vorbisInfo.modeBlockflags.length)throw Error(`Invalid mode number.`);let c=n,l=t.vorbisInfo.modeBlockflags[s];if(i=t.vorbisInfo.blocksizes[l],l===1){let n=(o|1)+1,r=e[0]&n?1:0;c=t.vorbisInfo.blocksizes[r]}r=c===null?0:c+i>>2}else t.codec===`opus`&&(r=MB(e).durationInSamples);return{durationInSamples:r,vorbisBlockSize:i}},fH=e=>{let t=`audio/ogg`;if(e.codecStrings){let n=[...new Set(e.codecStrings)];t+=`; codecs="${n.join(`, `)}"`}return t},pH=65307,mH=e=>{let t=e.filePos;if(KG(e)!==1399285583)return null;e.skip(1);let n=BG(e),r=QG(e),i=KG(e),a=KG(e),o=KG(e),s=BG(e),c=new Uint8Array(s);for(let t=0;t<s;t++)c[t]=BG(e);let l=27+s,u=c.reduce((e,t)=>e+t,0);return{headerStartPos:t,totalSize:l+u,dataStartPos:t+l,dataSize:u,headerType:n,granulePosition:r,serialNumber:i,sequenceNumber:a,checksum:o,lacingValues:c}},hH=(e,t)=>{for(;e.filePos<t-3;){let t=KG(e),n=t&255,r=t>>>8&255,i=t>>>16&255,a=t>>>24&255;if(!(n!==79&&r!==79&&i!==79&&a!==79)){if(e.skip(-4),t===1399285583)return!0;e.skip(1)}}return!1},gH=class extends KB{constructor(e){super(e),this.metadataPromise=null,this.bitstreams=[],this.trackBackings=[],this.metadataTags={},this.reader=e._reader}async readMetadata(){return this.metadataPromise??=(async()=>{let e=0;for(;;){let t=this.reader.requestSliceRange(e,27,282);if(t instanceof Promise&&(t=await t),!t)break;let n=mH(t);if(!n||!(n.headerType&2))break;this.bitstreams.push({serialNumber:n.serialNumber,bosPage:n,description:null,numberOfChannels:-1,sampleRate:-1,codecInfo:{codec:null,vorbisInfo:null,opusInfo:null},lastMetadataPacket:null}),e=n.headerStartPos+n.totalSize}for(let e of this.bitstreams){let t=await this.readPacket(e.bosPage,0);t&&(t.data.byteLength>=7&&t.data[0]===1&&t.data[1]===118&&t.data[2]===111&&t.data[3]===114&&t.data[4]===98&&t.data[5]===105&&t.data[6]===115?await this.readVorbisMetadata(t,e):t.data.byteLength>=8&&t.data[0]===79&&t.data[1]===112&&t.data[2]===117&&t.data[3]===115&&t.data[4]===72&&t.data[5]===101&&t.data[6]===97&&t.data[7]===100&&await this.readOpusMetadata(t,e),e.codecInfo.codec!==null&&this.trackBackings.push(new _H(e,this)))}})()}async readVorbisMetadata(e,t){let n=await this.findNextPacketStart(e);if(!n)return;let r=await this.readPacket(n.startPage,n.startSegmentIndex);if(!r||(n=await this.findNextPacketStart(r),!n))return;let i=await this.readPacket(n.startPage,n.startSegmentIndex);if(!i||r.data[0]!==3||i.data[0]!==5)return;let a=[],o=e=>{for(;a.push(Math.min(255,e)),!(e<255);)e-=255};o(e.data.length),o(r.data.length);let s=new Uint8Array(1+a.length+e.data.length+r.data.length+i.data.length);s[0]=2,s.set(a,1),s.set(e.data,1+a.length),s.set(r.data,1+a.length+e.data.length),s.set(i.data,1+a.length+e.data.length+r.data.length),t.codecInfo.codec=`vorbis`,t.description=s,t.lastMetadataPacket=i;let c=PL(e.data);t.numberOfChannels=c.getUint8(11),t.sampleRate=c.getUint32(12,!0);let l=c.getUint8(28);t.codecInfo.vorbisInfo={blocksizes:[1<<(l&15),1<<(l>>4)],modeBlockflags:NB(i.data).modeBlockflags},IB(r.data.subarray(7),this.metadataTags)}async readOpusMetadata(e,t){let n=await this.findNextPacketStart(e);if(!n)return;let r=await this.readPacket(n.startPage,n.startSegmentIndex);if(!r)return;t.codecInfo.codec=`opus`,t.description=e.data,t.lastMetadataPacket=r;let i=AB(e.data);t.numberOfChannels=i.outputChannelCount,t.sampleRate=Cz,t.codecInfo.opusInfo={preSkip:i.preSkip},IB(r.data.subarray(8),this.metadataTags)}async readPacket(e,t){X(t<e.lacingValues.length);let n=0;for(let r=0;r<t;r++)n+=e.lacingValues[r];let r=e,i=n,a=t,o=[];outer:for(;;){let t=this.reader.requestSlice(r.dataStartPos,r.dataSize);t instanceof Promise&&(t=await t),X(t);let s=zG(t,r.dataSize);for(;;){if(a===r.lacingValues.length){o.push(s.subarray(n,i));break}let e=r.lacingValues[a];if(i+=e,e<255){o.push(s.subarray(n,i));break outer}a++}let c=r.headerStartPos+r.totalSize;for(;;){let t=this.reader.requestSliceRange(c,27,282);if(t instanceof Promise&&(t=await t),!t)return null;let n=mH(t);if(!n)return null;if(r=n,r.serialNumber===e.serialNumber)break;c=r.headerStartPos+r.totalSize}n=0,i=0,a=0}let s=o.reduce((e,t)=>e+t.length,0);if(s===0)return null;let c=new Uint8Array(s),l=0;for(let e=0;e<o.length;e++){let t=o[e];c.set(t,l),l+=t.length}return{data:c,endPage:r,endSegmentIndex:a}}async findNextPacketStart(e){if(e.endSegmentIndex<e.endPage.lacingValues.length-1)return{startPage:e.endPage,startSegmentIndex:e.endSegmentIndex+1};if(e.endPage.headerType&4)return null;let t=e.endPage.headerStartPos+e.endPage.totalSize;for(;;){let n=this.reader.requestSliceRange(t,27,282);if(n instanceof Promise&&(n=await n),!n)return null;let r=mH(n);if(!r)return null;if(r.serialNumber===e.endPage.serialNumber)return{startPage:r,startSegmentIndex:0};t=r.headerStartPos+r.totalSize}}async getMimeType(){return await this.readMetadata(),fH({codecStrings:(await Promise.all(this.trackBackings.map(e=>e.getDecoderConfig().then(e=>e?.codec??null)))).filter(Boolean)})}async getTrackBackings(){return await this.readMetadata(),this.trackBackings}async getMetadataTags(){return await this.readMetadata(),this.metadataTags}},_H=class{constructor(e,t){this.bitstream=e,this.demuxer=t,this.encodedPacketToMetadata=new WeakMap,this.sequentialScanCache=[],this.sequentialScanMutex=new KL,this.internalSampleRate=e.codecInfo.codec===`opus`?Cz:e.sampleRate}getType(){return`audio`}getId(){return this.bitstream.serialNumber}getNumber(){let e=this.demuxer.trackBackings.findIndex(e=>e.bitstream===this.bitstream);return X(e!==-1),e+1}getNumberOfChannels(){return this.bitstream.numberOfChannels}getSampleRate(){return this.bitstream.sampleRate}getTimeResolution(){return this.bitstream.sampleRate}isRelativeToUnixEpoch(){return!1}getPairingMask(){return 1n}getBitrate(){return null}getAverageBitrate(){return null}async getDurationFromMetadata(){return null}async getLiveRefreshInterval(){return null}getCodec(){return this.bitstream.codecInfo.codec}getInternalCodecId(){return null}async getDecoderConfig(){return X(this.bitstream.codecInfo.codec),{codec:this.bitstream.codecInfo.codec,numberOfChannels:this.bitstream.numberOfChannels,sampleRate:this.bitstream.sampleRate,description:this.bitstream.description??void 0}}getName(){return null}getLanguageCode(){return`und`}getDisposition(){return{...ez,primary:!1}}granulePositionToTimestampInSamples(e){return this.bitstream.codecInfo.codec===`opus`?(X(this.bitstream.codecInfo.opusInfo),e-this.bitstream.codecInfo.opusInfo.preSkip):e}createEncodedPacketFromOggPacket(e,t,n){if(!e)return null;let{durationInSamples:r,vorbisBlockSize:i}=dH(e.data,this.bitstream.codecInfo,t.vorbisLastBlocksize),a=new JB(n.metadataOnly?qB:e.data,`key`,Math.max(0,t.timestampInSamples)/this.internalSampleRate,r/this.internalSampleRate,e.endPage.headerStartPos+e.endSegmentIndex,e.data.byteLength);return this.encodedPacketToMetadata.set(a,{packet:e,timestampInSamples:t.timestampInSamples,durationInSamples:r,vorbisLastBlockSize:t.vorbisLastBlocksize,vorbisBlockSize:i}),a}async getFirstPacket(e){X(this.bitstream.lastMetadataPacket);let t=await this.demuxer.findNextPacketStart(this.bitstream.lastMetadataPacket);if(!t)return null;let n=0;this.bitstream.codecInfo.codec===`opus`&&(X(this.bitstream.codecInfo.opusInfo),n-=this.bitstream.codecInfo.opusInfo.preSkip);let r=await this.demuxer.readPacket(t.startPage,t.startSegmentIndex);return this.createEncodedPacketFromOggPacket(r,{timestampInSamples:n,vorbisLastBlocksize:null},e)}async getNextPacket(e,t){let n=this.encodedPacketToMetadata.get(e);if(!n)throw Error(`Packet was not created from this track.`);let r=await this.demuxer.findNextPacketStart(n.packet);if(!r)return null;let i=n.timestampInSamples+n.durationInSamples,a=await this.demuxer.readPacket(r.startPage,r.startSegmentIndex);return this.createEncodedPacketFromOggPacket(a,{timestampInSamples:i,vorbisLastBlocksize:n.vorbisBlockSize},t)}async getPacket(e,t){if(this.demuxer.reader.fileSize===null)return this.getPacketSequential(e,t);let n=pR(e*this.internalSampleRate);if(n===0)return this.getFirstPacket(t);if(n<0)return null;X(this.bitstream.lastMetadataPacket);let r=await this.demuxer.findNextPacketStart(this.bitstream.lastMetadataPacket);if(!r)return null;let i=r.startPage,a=this.demuxer.reader.fileSize,o=[i];outer:for(;i.headerStartPos+i.totalSize<a;){let e=i.headerStartPos,t=Math.floor((e+a)/2),r=t;for(;;){let e=Math.min(r+pH,a-27),s=this.demuxer.reader.requestSlice(r,e-r);if(s instanceof Promise&&(s=await s),X(s),!hH(s,e)){a=t+27;continue outer}let c=this.demuxer.reader.requestSliceRange(s.filePos,27,282);c instanceof Promise&&(c=await c),X(c);let l=mH(c);X(l);let u=!1;if(l.serialNumber===this.bitstream.serialNumber)u=!0;else{let e=this.demuxer.reader.requestSlice(l.headerStartPos,l.totalSize);e instanceof Promise&&(e=await e),X(e),u=uH(zG(e,l.totalSize))===l.checksum}if(!u){r=l.headerStartPos+4;continue}if(u&&l.serialNumber!==this.bitstream.serialNumber){r=l.headerStartPos+l.totalSize;continue}if(l.granulePosition===-1){r=l.headerStartPos+l.totalSize;continue}this.granulePositionToTimestampInSamples(l.granulePosition)>n?a=l.headerStartPos:(i=l,o.push(l));continue outer}}let s=r.startPage;for(let e of o){if(e.granulePosition===i.granulePosition)break;(!s||e.headerStartPos>s.headerStartPos)&&(s=e)}let c=s,l=[c];for(;!(c.serialNumber===this.bitstream.serialNumber&&c.granulePosition===i.granulePosition);){let e=c.headerStartPos+c.totalSize,t=this.demuxer.reader.requestSliceRange(e,27,282);t instanceof Promise&&(t=await t),X(t);let n=mH(t);X(n),c=n,c.serialNumber===this.bitstream.serialNumber&&l.push(c)}X(c.granulePosition!==-1);let u=null,d,f,p=c,m=0;if(c.headerStartPos===r.startPage.headerStartPos)d=this.granulePositionToTimestampInSamples(0),f=!0,u=0;else{d=0,f=!1;for(let e=c.lacingValues.length-1;e>=0;e--)if(c.lacingValues[e]<255){u=e+1;break}if(u===null)throw Error(`Invalid page with granule position: no packets end on this page.`);m=u-1;let e={data:qB,endPage:p,endSegmentIndex:m};if(await this.demuxer.findNextPacketStart(e)){let e=yH(l,c,u);X(e);let t=vH(l,e.page,e.segmentIndex);t&&(c=t.page,u=t.segmentIndex)}else for(;;){let e=yH(l,c,u);if(!e)break;let t=vH(l,e.page,e.segmentIndex);if(!t)break;if(c=t.page,u=t.segmentIndex,e.page.headerStartPos!==p.headerStartPos){p=e.page,m=e.segmentIndex;break}}}let h=null,g=null;for(;c!==null;){X(u!==null);let e=await this.demuxer.readPacket(c,u);if(!e)break;if(!(c.headerStartPos===r.startPage.headerStartPos&&u<r.startSegmentIndex)){let r=this.createEncodedPacketFromOggPacket(e,{timestampInSamples:d,vorbisLastBlocksize:g?.vorbisBlockSize??null},t);X(r);let i=this.encodedPacketToMetadata.get(r);if(X(i),!f&&e.endPage.headerStartPos===p.headerStartPos&&e.endSegmentIndex===m?(d=this.granulePositionToTimestampInSamples(c.granulePosition),f=!0,r=this.createEncodedPacketFromOggPacket(e,{timestampInSamples:d-i.durationInSamples,vorbisLastBlocksize:g?.vorbisBlockSize??null},t),X(r),i=this.encodedPacketToMetadata.get(r),X(i)):d+=i.durationInSamples,h=r,g=i,f&&(Math.max(d,0)>n||Math.max(i.timestampInSamples,0)===n))break}let i=await this.demuxer.findNextPacketStart(e);if(!i)break;c=i.startPage,u=i.startSegmentIndex}return h}async getPacketSequential(e,t){let n=await this.sequentialScanMutex.acquire();try{let n=pR(e*this.internalSampleRate);e=n/this.internalSampleRate;let r=QL(this.sequentialScanCache,n,e=>e.timestampInSamples),i;if(r!==-1){let e=this.sequentialScanCache[r];i=this.createEncodedPacketFromOggPacket(e.packet,{timestampInSamples:e.timestampInSamples,vorbisLastBlocksize:e.vorbisLastBlockSize},t)}else i=await this.getFirstPacket(t);let a=0;for(;i&&i.timestamp<e;){let n=await this.getNextPacket(i,t);if(!n||n.timestamp>e)break;if(i=n,a++,a===100){a=0;let e=this.encodedPacketToMetadata.get(i);X(e),this.sequentialScanCache.length>0&&X(AL(this.sequentialScanCache).timestampInSamples<=e.timestampInSamples),this.sequentialScanCache.push(e)}}return i}finally{n()}}getKeyPacket(e,t){return this.getPacket(e,t)}getNextKeyPacket(e,t){return this.getNextPacket(e,t)}},vH=(e,t,n)=>{let r=t,i=n;outer:for(;;){for(i--;i>=0;i--)if(r.lacingValues[i]<255){i++;break outer}if(X(i===-1),!(r.headerType&1)){i=0;break}let t=nR(e,e=>e.headerStartPos<r.headerStartPos);if(!t)return null;r=t,i=r.lacingValues.length}if(X(i!==-1),i===r.lacingValues.length){let t=e[e.indexOf(r)+1];X(t),r=t,i=0}return{page:r,segmentIndex:i}},yH=(e,t,n)=>{if(n>0)return{page:t,segmentIndex:n-1};let r=nR(e,e=>e.headerStartPos<t.headerStartPos);return r?{page:r,segmentIndex:r.lacingValues.length-1}:null},bH;(function(e){e[e.PCM=1]=`PCM`,e[e.IEEE_FLOAT=3]=`IEEE_FLOAT`,e[e.ALAW=6]=`ALAW`,e[e.MULAW=7]=`MULAW`,e[e.EXTENSIBLE=65534]=`EXTENSIBLE`})(bH||={});var xH=class extends KB{constructor(e){super(e),this.metadataPromise=null,this.dataStart=-1,this.dataSize=-1,this.audioInfo=null,this.trackBackings=[],this.lastKnownPacketIndex=0,this.metadataTags={},this.reader=e._reader}async readMetadata(){return this.metadataPromise??=(async()=>{let e=this.reader.requestSlice(0,12);e instanceof Promise&&(e=await e),X(e);let t=tK(e,4),n=t!==`RIFX`,r=t===`RF64`,i=GG(e,n),a=r?this.reader.fileSize:Math.min(i+8,this.reader.fileSize??1/0);if(tK(e,4)!==`WAVE`)throw Error(`Invalid WAVE file - wrong format`);let o=0,s=null,c=e.filePos;for(;a===null||c<a;){let e=this.reader.requestSlice(c,8);if(e instanceof Promise&&(e=await e),!e)break;let t=tK(e,4),i=GG(e,n),l=e.filePos;if(r&&o===0&&t!==`ds64`)throw Error(`Invalid RF64 file: First chunk must be "ds64".`);if(t===`fmt `)await this.parseFmtChunk(l,i,n);else if(t===`data`){if(s??=i,this.dataStart=e.filePos,this.dataSize=Math.min(s,(a??1/0)-this.dataStart),this.reader.fileSize===null)break}else if(t===`ds64`){let e=this.reader.requestSlice(l,i);if(e instanceof Promise&&(e=await e),!e)break;let t=YG(e,n);s=YG(e,n),a=Math.min(t+8,this.reader.fileSize??1/0)}else t===`LIST`?await this.parseListChunk(l,i,n):(t===`ID3 `||t===`id3 `)&&await this.parseId3Chunk(l,i);c=l+i+(i&1),o++}if(!this.audioInfo)throw Error(`Invalid WAVE file - missing "fmt " chunk`);if(this.dataStart===-1)throw Error(`Invalid WAVE file - missing "data" chunk`);let l=this.audioInfo.blockSizeInBytes;this.dataSize=Math.floor(this.dataSize/l)*l,this.trackBackings.push(new CH(this))})()}async parseFmtChunk(e,t,n){let r=this.reader.requestSlice(e,t);if(r instanceof Promise&&(r=await r),!r)return;let i=VG(r,n),a=VG(r,n),o=GG(r,n);r.skip(4);let s=VG(r,n),c;if(c=t===14?8:VG(r,n),t>=18&&i!==357){let e=VG(r,n),a=t-18;if(Math.min(a,e)>=22&&i===bH.EXTENSIBLE){r.skip(6);let e=zG(r,16);i=e[0]|e[1]<<8}}(i===bH.MULAW||i===bH.ALAW)&&(c=8),this.audioInfo={format:i,numberOfChannels:a,sampleRate:o,sampleSizeInBytes:Math.ceil(c/8),blockSizeInBytes:s}}async parseListChunk(e,t,n){let r=this.reader.requestSlice(e,t);if(r instanceof Promise&&(r=await r),!r)return;let i=tK(r,4);if(i!==`INFO`&&i!==`INF0`)return;let a=r.filePos;for(;a<=e+t-8;){r.filePos=a;let e=tK(r,4),t=GG(r,n),i=zG(r,t),o=0;for(let e=0;e<i.length&&i[e]!==0;e++)o++;let s=String.fromCharCode(...i.subarray(0,o));switch(this.metadataTags.raw??={},this.metadataTags.raw[e]=s,e){case`INAM`:case`TITL`:this.metadataTags.title??=s;break;case`TIT3`:this.metadataTags.description??=s;break;case`IART`:this.metadataTags.artist??=s;break;case`IPRD`:this.metadataTags.album??=s;break;case`IPRT`:case`ITRK`:case`TRCK`:{let e=s.split(`/`),t=Number.parseInt(e[0],10),n=e[1]&&Number.parseInt(e[1],10);Number.isInteger(t)&&t>0&&(this.metadataTags.trackNumber??=t),n&&Number.isInteger(n)&&n>0&&(this.metadataTags.tracksTotal??=n)}break;case`ICRD`:case`IDIT`:{let e=new Date(s);Number.isNaN(e.getTime())||(this.metadataTags.date??=e)}break;case`YEAR`:{let e=Number.parseInt(s,10);Number.isInteger(e)&&e>0&&(this.metadataTags.date??=new Date(e,0,1))}break;case`IGNR`:case`GENR`:this.metadataTags.genre??=s;break;case`ICMT`:case`CMNT`:case`COMM`:this.metadataTags.comment??=s;break}a+=8+t+(t&1)}}async parseId3Chunk(e,t){let n=this.reader.requestSlice(e,t);if(n instanceof Promise&&(n=await n),!n)return;let r=cK(n);if(r){let i=t-10;r.size=Math.min(r.size,i),r.size>0&&lK(n.slice(e+10,r.size),r,this.metadataTags)}}getCodec(){if(X(this.audioInfo),this.audioInfo.format===bH.MULAW)return`ulaw`;if(this.audioInfo.format===bH.ALAW)return`alaw`;if(this.audioInfo.format===bH.PCM){if(this.audioInfo.sampleSizeInBytes===1)return`pcm-u8`;if(this.audioInfo.sampleSizeInBytes===2)return`pcm-s16`;if(this.audioInfo.sampleSizeInBytes===3)return`pcm-s24`;if(this.audioInfo.sampleSizeInBytes===4)return`pcm-s32`}return this.audioInfo.format===bH.IEEE_FLOAT&&this.audioInfo.sampleSizeInBytes===4?`pcm-f32`:null}async getMimeType(){return`audio/wav`}async getTrackBackings(){return await this.readMetadata(),this.trackBackings}async getMetadataTags(){return await this.readMetadata(),this.metadataTags}},SH=2048,CH=class{constructor(e){this.demuxer=e}getType(){return`audio`}getId(){return 1}getNumber(){return 1}getCodec(){return this.demuxer.getCodec()}getInternalCodecId(){return X(this.demuxer.audioInfo),this.demuxer.audioInfo.format}async getDecoderConfig(){let e=this.demuxer.getCodec();return e?(X(this.demuxer.audioInfo),{codec:e,numberOfChannels:this.demuxer.audioInfo.numberOfChannels,sampleRate:this.demuxer.audioInfo.sampleRate}):null}getNumberOfChannels(){return X(this.demuxer.audioInfo),this.demuxer.audioInfo.numberOfChannels}getSampleRate(){return X(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}getTimeResolution(){return X(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}isRelativeToUnixEpoch(){return!1}getPairingMask(){return 1n}getBitrate(){return null}getAverageBitrate(){return null}async getDurationFromMetadata(){return X(this.demuxer.dataSize!==-1),this.demuxer.dataSize/this.demuxer.audioInfo.blockSizeInBytes/this.demuxer.audioInfo.sampleRate}async getLiveRefreshInterval(){return null}getName(){return null}getLanguageCode(){return`und`}getDisposition(){return{...ez}}async getPacketAtIndex(e,t){X(e>=0),X(this.demuxer.audioInfo);let n=e*SH*this.demuxer.audioInfo.blockSizeInBytes;if(n>=this.demuxer.dataSize)return null;let r=Math.min(SH*this.demuxer.audioInfo.blockSizeInBytes,this.demuxer.dataSize-n);if(this.demuxer.reader.fileSize===null){let e=this.demuxer.reader.requestSlice(this.demuxer.dataStart+n,r);if(e instanceof Promise&&(e=await e),!e)return null}let i;if(t.metadataOnly)i=qB;else{let e=this.demuxer.reader.requestSlice(this.demuxer.dataStart+n,r);e instanceof Promise&&(e=await e),X(e),i=zG(e,r)}let a=e*SH/this.demuxer.audioInfo.sampleRate,o=r/this.demuxer.audioInfo.blockSizeInBytes/this.demuxer.audioInfo.sampleRate;return this.demuxer.lastKnownPacketIndex=Math.max(e,this.demuxer.lastKnownPacketIndex),new JB(i,`key`,a,o,e,r)}getFirstPacket(e){return this.getPacketAtIndex(0,e)}async getPacket(e,t){X(this.demuxer.audioInfo);let n=Math.floor(Math.min(e*this.demuxer.audioInfo.sampleRate/SH,(this.demuxer.dataSize-1)/(SH*this.demuxer.audioInfo.blockSizeInBytes)));if(n<0)return null;let r=await this.getPacketAtIndex(n,t);if(r)return r;if(n===0)return null;X(this.demuxer.reader.fileSize===null);let i=await this.getPacketAtIndex(this.demuxer.lastKnownPacketIndex,t);for(;i;){let e=await this.getNextPacket(i,t);if(!e)break;i=e}return i}getNextPacket(e,t){X(this.demuxer.audioInfo);let n=Math.round(e.timestamp*this.demuxer.audioInfo.sampleRate/SH);return this.getPacketAtIndex(n+1,t)}getKeyPacket(e,t){return this.getPacket(e,t)}getNextKeyPacket(e,t){return this.getNextPacket(e,t)}},wH=e=>{let t=e.filePos,n=new nz(zG(e,9));if(n.readBits(12)!==4095||(n.skipBits(1),n.readBits(2)!==0))return null;let r=n.readBits(1),i=n.readBits(2)+1,a=n.readBits(4);if(a===15)return null;n.skipBits(1);let o=n.readBits(3);if(o===0)throw Error(`ADTS frames with channel configuration 0 are not supported.`);n.skipBits(1),n.skipBits(1),n.skipBits(1),n.skipBits(1);let s=n.readBits(13);n.skipBits(11);let c=n.readBits(2)+1;if(c!==1)throw Error(`ADTS frames with more than one AAC frame are not supported.`);let l=null;return r===1?e.filePos-=2:l=n.readBits(16),{objectType:i,samplingFrequencyIndex:a,channelConfiguration:o,frameLength:s,numberOfAacFrames:c,crcCheck:l,startPos:t}},TH=1024,EH=class extends KB{constructor(e){super(e),this.metadataPromise=null,this.firstFrameHeader=null,this.loadedSamples=[],this.metadataTags=null,this.trackBackings=[],this.readingMutex=new KL,this.lastSampleLoaded=!1,this.lastLoadedPos=0,this.nextTimestampInSamples=0,this.reader=e._reader}async readMetadata(){return this.metadataPromise??=(async()=>{for(;!this.firstFrameHeader&&!this.lastSampleLoaded;)await this.advanceReader();X(this.firstFrameHeader),this.trackBackings=[new DH(this)]})()}async advanceReader(){if(this.lastLoadedPos===0)for(;;){let e=this.reader.requestSlice(this.lastLoadedPos,10);if(e instanceof Promise&&(e=await e),!e){this.lastSampleLoaded=!0;return}let t=cK(e);if(!t)break;this.lastLoadedPos=e.filePos+t.size}let e=this.reader.requestSliceRange(this.lastLoadedPos,7,9);if(e instanceof Promise&&(e=await e),!e){this.lastSampleLoaded=!0;return}let t=wH(e);if(!t){this.lastSampleLoaded=!0;return}if(this.reader.fileSize!==null&&t.startPos+t.frameLength>this.reader.fileSize){this.lastSampleLoaded=!0;return}this.firstFrameHeader||=t;let n=rz[t.samplingFrequencyIndex];X(n!==void 0);let r=TH/n,i={timestamp:this.nextTimestampInSamples/n,duration:r,dataStart:t.startPos,dataSize:t.frameLength};this.loadedSamples.push(i),this.nextTimestampInSamples+=TH,this.lastLoadedPos=t.startPos+t.frameLength}async getMimeType(){return`audio/aac`}async getTrackBackings(){return await this.readMetadata(),this.trackBackings}async getMetadataTags(){let e=await this.readingMutex.acquire();try{if(await this.readMetadata(),this.metadataTags)return this.metadataTags;this.metadataTags={};let e=0;for(;;){let t=this.reader.requestSlice(e,10);if(t instanceof Promise&&(t=await t),!t)break;let n=cK(t);if(!n)break;let r=this.reader.requestSlice(t.filePos,n.size);if(r instanceof Promise&&(r=await r),!r)break;lK(r,n,this.metadataTags),e=t.filePos+n.size}return this.metadataTags}finally{e()}}},DH=class{constructor(e){this.demuxer=e}getType(){return`audio`}getId(){return 1}getNumber(){return 1}getTimeResolution(){return this.getSampleRate()/TH}isRelativeToUnixEpoch(){return!1}getPairingMask(){return 1n}getBitrate(){return null}getAverageBitrate(){return null}async getDurationFromMetadata(){return null}async getLiveRefreshInterval(){return null}getName(){return null}getLanguageCode(){return`und`}getCodec(){return`aac`}getInternalCodecId(){return X(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.objectType}getNumberOfChannels(){X(this.demuxer.firstFrameHeader);let e=iz[this.demuxer.firstFrameHeader.channelConfiguration];return X(e!==void 0),e}getSampleRate(){X(this.demuxer.firstFrameHeader);let e=rz[this.demuxer.firstFrameHeader.samplingFrequencyIndex];return X(e!==void 0),e}getDisposition(){return{...ez}}async getDecoderConfig(){return X(this.demuxer.firstFrameHeader),{codec:`mp4a.40.${this.demuxer.firstFrameHeader.objectType}`,numberOfChannels:this.getNumberOfChannels(),sampleRate:this.getSampleRate()}}async getPacketAtIndex(e,t){if(e===-1)return null;let n=this.demuxer.loadedSamples[e];if(!n)return null;let r;if(t.metadataOnly)r=qB;else{let e=this.demuxer.reader.requestSlice(n.dataStart,n.dataSize);if(e instanceof Promise&&(e=await e),!e)return null;r=zG(e,n.dataSize)}return new JB(r,`key`,n.timestamp,n.duration,e,n.dataSize)}getFirstPacket(e){return this.getPacketAtIndex(0,e)}async getNextPacket(e,t){let n=await this.demuxer.readingMutex.acquire();try{let n=ZL(this.demuxer.loadedSamples,e.timestamp,e=>e.timestamp);if(n===-1)throw Error(`Packet was not created from this track.`);let r=n+1;for(;r>=this.demuxer.loadedSamples.length&&!this.demuxer.lastSampleLoaded;)await this.demuxer.advanceReader();return this.getPacketAtIndex(r,t)}finally{n()}}async getPacket(e,t){let n=await this.demuxer.readingMutex.acquire();try{for(;;){let n=QL(this.demuxer.loadedSamples,e,e=>e.timestamp);if(n===-1&&this.demuxer.loadedSamples.length>0)return null;if(this.demuxer.lastSampleLoaded||n>=0&&n+1<this.demuxer.loadedSamples.length)return this.getPacketAtIndex(n,t);await this.demuxer.advanceReader()}}finally{n()}}getKeyPacket(e,t){return this.getPacket(e,t)}getNextKeyPacket(e,t){return this.getNextPacket(e,t)}},OH=e=>e===0?null:e===1?192:e>=2&&e<=5?144*2**e:e===6?`uncommon-u8`:e===7?`uncommon-u16`:e>=8&&e<=15?2**e:null,kH=(e,t)=>{switch(e){case 0:return t;case 1:return 88200;case 2:return 176400;case 3:return 192e3;case 4:return 8e3;case 5:return 16e3;case 6:return 22050;case 7:return 24e3;case 8:return 32e3;case 9:return 44100;case 10:return 48e3;case 11:return 96e3;case 12:return`uncommon-u8`;case 13:return`uncommon-u16`;case 14:return`uncommon-u16-10`;default:return null}},AH=e=>{let t=0,n=new nz(zG(e,1));for(;n.readBits(1)===1;)t++;if(t===0)return n.readBits(7);let r=[],i=t-1,a=new nz(zG(e,i)),o=8-t-1;for(let e=0;e<o;e++)r.unshift(n.readBits(1));for(let e=0;e<i;e++)for(let e=0;e<8;e++){let t=a.readBits(1);e<2||r.unshift(t)}return r.reduce((e,t,n)=>e|t<<n,0)},jH=(e,t)=>{if(t===`uncommon-u16`)return HG(e)+1;if(t===`uncommon-u8`)return BG(e)+1;if(typeof t==`number`)return t;oR(t),X(!1)},MH=(e,t)=>t===`uncommon-u16`?HG(e):t===`uncommon-u16-10`?HG(e)*10:t===`uncommon-u8`?BG(e):typeof t==`number`?t:null,NH=e=>{let t=0;for(let n of e){t^=n;for(let e=0;e<8;e++)t&128?t=t<<1^7:t<<=1,t&=255}return t},PH=class extends KB{constructor(e){super(e),this.loadedSamples=[],this.metadataPromise=null,this.trackBacking=null,this.metadataTags={},this.audioInfo=null,this.lastLoadedPos=null,this.blockingBit=null,this.readingMutex=new KL,this.lastSampleLoaded=!1,this.reader=e._reader}async getMetadataTags(){return await this.readMetadata(),this.metadataTags}async getTrackBackings(){return await this.readMetadata(),X(this.trackBacking),[this.trackBacking]}async getMimeType(){return`audio/flac`}async readMetadata(){let e=4;return this.metadataPromise??=(async()=>{for(;this.reader.fileSize===null||e<this.reader.fileSize;){let t=this.reader.requestSlice(e,4);if(t instanceof Promise&&(t=await t),e+=4,t===null)throw Error(`Metadata block at position ${e} is too small! Corrupted file.`);X(t);let n=BG(t),r=UG(t),i=(n&128)!=0;switch(n&127){case FB.STREAMINFO:{let t=this.reader.requestSlice(e,r);if(t instanceof Promise&&(t=await t),X(t),t===null)throw Error(`StreamInfo block at position ${e} is too small! Corrupted file.`);let n=zG(t,34),i=new nz(n),a=i.readBits(16),o=i.readBits(16),s=i.readBits(24),c=i.readBits(24),l=i.readBits(20),u=i.readBits(3)+1;i.readBits(5);let d=i.readBits(36);i.skipBits(128);let f=new Uint8Array(42);f.set(new Uint8Array([102,76,97,67]),0),f.set(new Uint8Array([128,0,0,34]),4),f.set(n,8),this.audioInfo={numberOfChannels:u,sampleRate:l,totalSamples:d,minimumBlockSize:a,maximumBlockSize:o,minimumFrameSize:s,maximumFrameSize:c,description:f},this.trackBacking=new FH(this);break}case FB.VORBIS_COMMENT:{let t=this.reader.requestSlice(e,r);t instanceof Promise&&(t=await t),X(t),IB(zG(t,r),this.metadataTags);break}case FB.PICTURE:{let t=this.reader.requestSlice(e,r);t instanceof Promise&&(t=await t),X(t);let n=$(t),i=$(t),a=FL.decode(zG(t,i)),o=$(t),s=FL.decode(zG(t,o));t.skip(16);let c=$(t),l=zG(t,c);this.metadataTags.images??=[],this.metadataTags.images.push({data:l,mimeType:a,kind:n===3?`coverFront`:n===4?`coverBack`:`unknown`,description:s});break}default:break}if(e+=r,i){this.lastLoadedPos=e;break}}if(!this.audioInfo)throw Error(`Missing STREAMINFO metadata block! Corrupted FLAC file.`)})()}async readNextFlacFrame({startPos:e,isFirstPacket:t}){X(this.audioInfo);let n=this.audioInfo.maximumBlockSize*this.audioInfo.numberOfChannels*4+16+2,r=this.audioInfo.minimumFrameSize||10,i=(this.audioInfo.maximumFrameSize||n)+16,a=await this.reader.requestSliceRange(e,16,i);if(!a)return null;let o=this.readFlacFrameHeader({slice:a,isFirstPacket:t});if(!o)return null;for(a.filePos=e+r;;){if(a.filePos>a.end-6)return{num:o.num,blockSize:o.blockSize,sampleRate:o.sampleRate,size:a.end-e,isLastFrame:!0};if(BG(a)===255){let t=a.filePos;if(BG(a)!==(this.blockingBit===1?249:248)){a.filePos=t;continue}a.skip(-2);let n=a.filePos-e,r=this.readFlacFrameHeader({slice:a,isFirstPacket:!1});if(!r){a.filePos=t;continue}if(this.blockingBit===0){if(r.num-o.num!==1){a.filePos=t;continue}}else if(r.num-o.num!==o.blockSize){a.filePos=t;continue}return{num:o.num,blockSize:o.blockSize,sampleRate:o.sampleRate,size:n,isLastFrame:!1}}}}readFlacFrameHeader({slice:e,isFirstPacket:t}){let n=e.filePos,r=new nz(zG(e,4));if(r.readBits(15)!==32764)return null;if(this.blockingBit===null){X(t);let e=r.readBits(1);this.blockingBit=e}else if(this.blockingBit===1){if(X(!t),r.readBits(1)!==1)return null}else if(this.blockingBit===0){if(X(!t),r.readBits(1)!==0)return null}else throw Error(`Invalid blocking bit`);let i=OH(r.readBits(4));if(!i)return null;X(this.audioInfo);let a=kH(r.readBits(4),this.audioInfo.sampleRate);if(!a||(r.readBits(4),r.readBits(3),r.readBits(1)!==0))return null;let o=AH(e),s=jH(e,i),c=MH(e,a);if(c===null||c!==this.audioInfo.sampleRate)return null;let l=e.filePos-n,u=BG(e);return e.skip(-l),e.skip(-1),u===NH(zG(e,l))?{num:o,blockSize:s,sampleRate:c}:null}async advanceReader(){await this.readMetadata(),X(this.lastLoadedPos!==null),X(this.audioInfo);let e=this.lastLoadedPos,t=await this.readNextFlacFrame({startPos:e,isFirstPacket:this.loadedSamples.length===0});if(!t){this.lastSampleLoaded=!0;return}let n=this.loadedSamples[this.loadedSamples.length-1],r={blockOffset:n?n.blockOffset+n.blockSize:0,blockSize:t.blockSize,byteOffset:e,byteSize:t.size};if(this.lastLoadedPos+=t.size,this.loadedSamples.push(r),t.isLastFrame){this.lastSampleLoaded=!0;return}}},FH=class{constructor(e){this.demuxer=e}getType(){return`audio`}getId(){return 1}getNumber(){return 1}getCodec(){return`flac`}getInternalCodecId(){return null}getNumberOfChannels(){return X(this.demuxer.audioInfo),this.demuxer.audioInfo.numberOfChannels}getSampleRate(){return X(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}getName(){return null}getLanguageCode(){return`und`}getTimeResolution(){return X(this.demuxer.audioInfo),this.demuxer.audioInfo.sampleRate}isRelativeToUnixEpoch(){return!1}getPairingMask(){return 1n}getBitrate(){return null}getAverageBitrate(){return null}async getDurationFromMetadata(){return X(this.demuxer.audioInfo),this.demuxer.audioInfo.totalSamples===0?null:this.demuxer.audioInfo.totalSamples/this.demuxer.audioInfo.sampleRate}async getLiveRefreshInterval(){return null}getDisposition(){return{...ez}}async getDecoderConfig(){return X(this.demuxer.audioInfo),{codec:`flac`,numberOfChannels:this.demuxer.audioInfo.numberOfChannels,sampleRate:this.demuxer.audioInfo.sampleRate,description:this.demuxer.audioInfo.description}}async getPacket(e,t){if(X(this.demuxer.audioInfo),e<0)return null;let n=await this.demuxer.readingMutex.acquire();try{for(;;){let n=QL(this.demuxer.loadedSamples,e,e=>e.blockOffset/this.demuxer.audioInfo.sampleRate);if(n===-1){await this.demuxer.advanceReader();continue}let r=this.demuxer.loadedSamples[n];if(r.blockOffset/this.demuxer.audioInfo.sampleRate+r.blockSize/this.demuxer.audioInfo.sampleRate<=e){if(this.demuxer.lastSampleLoaded)return this.getPacketAtIndex(this.demuxer.loadedSamples.length-1,t);await this.demuxer.advanceReader();continue}return this.getPacketAtIndex(n,t)}}finally{n()}}async getNextPacket(e,t){let n=await this.demuxer.readingMutex.acquire();try{let n=e.sequenceNumber+1;if(this.demuxer.lastSampleLoaded&&n>=this.demuxer.loadedSamples.length)return null;for(;n>=this.demuxer.loadedSamples.length&&!this.demuxer.lastSampleLoaded;)await this.demuxer.advanceReader();return this.getPacketAtIndex(n,t)}finally{n()}}getKeyPacket(e,t){return this.getPacket(e,t)}getNextKeyPacket(e,t){return this.getNextPacket(e,t)}async getPacketAtIndex(e,t){let n=this.demuxer.loadedSamples[e];if(!n)return null;let r;if(t.metadataOnly)r=qB;else{let e=this.demuxer.reader.requestSlice(n.byteOffset,n.byteSize);if(e instanceof Promise&&(e=await e),!e)return null;r=zG(e,n.byteSize)}X(this.demuxer.audioInfo);let i=n.blockOffset/this.demuxer.audioInfo.sampleRate,a=n.blockSize/this.demuxer.audioInfo.sampleRate;return new JB(r,`key`,i,a,e,n.byteSize)}async getFirstPacket(e){for(;this.demuxer.loadedSamples.length===0&&!this.demuxer.lastSampleLoaded;)await this.demuxer.advanceReader();return this.getPacketAtIndex(0,e)}},IH=9e4,LH=e=>{let t=`video/MP2T`,n=[...new Set(e.filter(Boolean))];return n.length>0&&(t+=`; codecs="${n.join(`, `)}"`),t},RH=`PES packet is missing PTS where it was expected. PES packets without PTS are not currently supported. If you think this file should be supported, please report it.`,zH=new Set,BH=class extends KB{constructor(e){super(e),this.metadataPromise=null,this.elementaryStreams=[],this.trackBackingEntries=[],this.packetOffset=0,this.packetStride=-1,this.sectionEndPositions=[],this.seekChunkSize=5*1024*1024,this.minReferencePointByteDistance=-1,this.reader=e._reader}async readMetadata(){return this.metadataPromise??=(async()=>{let e=this.reader.requestSlice(0,205);e instanceof Promise&&(e=await e),X(e);let t=zG(e,205);if(t[0]===71&&t[188]===71)this.packetOffset=0,this.packetStride=188;else if(t[0]===71&&t[204]===71)this.packetOffset=0,this.packetStride=204;else if(t[4]===71&&t[196]===71)this.packetOffset=4,this.packetStride=192;else throw Error(`Unreachable.`);this.minReferencePointByteDistance=256*this.packetStride;let n=this.packetOffset,r=null,i=!1,a=!1;for(;;){let e=await this.readPacketHeader(n);if(!e)break;if(e.payloadUnitStartIndicator===0){n+=this.packetStride;continue}let t=await this.readSection(n,!0,!a);if(!t)break;let o=!1;if(!a&&t.pid!==0&&!(t.payload[0]===0&&t.payload[1]===0&&t.payload[2]===1)){let e=new nz(t.payload),n=e.readAlignedByte();e.skipBits(8*n),o=e.readBits(8)===2}if(t.pid===0&&!i){let e=new nz(t.payload),n=e.readAlignedByte();e.skipBits(8*n),e.skipBits(14);let a=e.readBits(10);for(e.skipBits(40);8*(a+3)-e.pos>32;){let t=e.readBits(16);e.skipBits(3);let n=e.readBits(13);if(t!==0){if(r!==null)throw Error(`Only files with a single program are supported.`);r=n}}if(r===null)throw Error(`Program Association Table must link to a Program Map Table.`);i=!0}else if((t.pid===r||o)&&!a){let e=new nz(t.payload),n=e.readAlignedByte();e.skipBits(8*n),e.skipBits(12);let r=e.readBits(12);e.skipBits(43),e.readBits(13),e.skipBits(6);let i=e.readBits(10);for(e.skipBits(8*i);8*(r+3)-e.pos>32;){let t=e.readBits(8);e.skipBits(3);let n=e.readBits(13);e.skipBits(6);let r=e.readBits(10),i=e.pos+8*r,a=!1,o=!1;for(;e.pos<i;){let t=e.readBits(8),n=e.readBits(8);t===106?a=!0:(t===122||t===204)&&(o=!0),e.skipBits(8*n)}let s=null;switch(t){case 27:case 36:s={type:`video`,codec:t===27?`avc`:`hevc`,decoderConfig:null,avcCodecInfo:null,hevcCodecInfo:null,colorSpace:{primaries:null,transfer:null,matrix:null,fullRange:null},width:-1,height:-1,squarePixelWidth:-1,squarePixelHeight:-1,reorderSize:-1};break;case 3:case 4:case 15:case 129:case 135:{let e;if(t===3||t===4)e=`mp3`;else if(t===15)e=`aac`;else if(t===129)e=`ac3`;else if(t===135)e=`eac3`;else throw Error(`Unreachable.`);s={type:`audio`,codec:e,decoderConfig:null,aacCodecInfo:null,numberOfChannels:-1,sampleRate:-1}}break;case 6:o?s={type:`audio`,codec:`eac3`,decoderConfig:null,aacCodecInfo:null,numberOfChannels:-1,sampleRate:-1}:a&&(s={type:`audio`,codec:`ac3`,decoderConfig:null,aacCodecInfo:null,numberOfChannels:-1,sampleRate:-1});break;default:zH.has(t)||(console.warn(`Note: MPEG-TS streams with stream_type 0x${t.toString(16)} are not currently supported.`),zH.add(t))}s&&this.elementaryStreams.push({demuxer:this,pid:n,streamType:t,initialized:!1,firstSection:null,canBeTrustedWithKeyPackets:!1,info:s,referencePesPackets:[]})}a=!0}else{let e=this.elementaryStreams.find(e=>e.pid===t.pid);outer:if(e&&!e.initialized){let n=HH(t,!0);if(!n)throw Error(`Couldn't read first PES packet for Elementary Stream with PID ${e.pid}`);if(e.firstSection=t,e.canBeTrustedWithKeyPackets=t.randomAccessIndicator===1,this.input._initInput){let n=(await this.input._initInput._getDemuxer()).elementaryStreams.find(n=>n.pid===t.pid&&n.info.codec===e.info.codec);if(n){e.info=n.info,e.initialized=!0;break outer}}let r=new qH(e,n);if(e.info.type===`video`){for(;;){let t=r;if(t.suppliedPacket=null,await r.markNextPacket(),e.info.codec===`avc`){if(!r.suppliedPacket)throw Error(`Invalid AVC video stream; could not extract AVCDecoderConfigurationRecord from any packet.`);if(e.info.avcCodecInfo=oB(r.suppliedPacket.data),!e.info.avcCodecInfo)continue;let t=e.info.avcCodecInfo.sequenceParameterSets[0];X(t);let n=uB(t);e.info.width=n.displayWidth,e.info.height=n.displayHeight;let i=n.pixelAspectRatio.num,a=n.pixelAspectRatio.den;i>0&&a>0&&(i>a?(e.info.squarePixelWidth=Math.round(e.info.width*i/a),e.info.squarePixelHeight=e.info.height):(e.info.squarePixelWidth=e.info.width,e.info.squarePixelHeight=Math.round(e.info.height*a/i))),e.info.colorSpace={primaries:zL[n.colourPrimaries],transfer:VL[n.transferCharacteristics],matrix:UL[n.matrixCoefficients],fullRange:!!n.fullRangeFlag},e.info.reorderSize=n.maxDecFrameBuffering;break}else if(e.info.codec===`hevc`){if(!r.suppliedPacket)throw Error(`Invalid HEVC video stream; could not extract HVCDecoderConfigurationRecord from first packet.`);if(e.info.hevcCodecInfo=gB(r.suppliedPacket.data),!e.info.hevcCodecInfo)continue;let t=e.info.hevcCodecInfo.arrays.find(e=>e.nalUnitType===Xz.SPS_NUT).nalUnits[0];X(t);let n=hB(t);e.info.width=n.displayWidth,e.info.height=n.displayHeight,n.pixelAspectRatio.num>n.pixelAspectRatio.den?(e.info.squarePixelWidth=Math.round(e.info.width*n.pixelAspectRatio.num/n.pixelAspectRatio.den),e.info.squarePixelHeight=e.info.height):(e.info.squarePixelWidth=e.info.width,e.info.squarePixelHeight=Math.round(e.info.height*n.pixelAspectRatio.den/n.pixelAspectRatio.num)),e.info.colorSpace={primaries:zL[n.colourPrimaries],transfer:VL[n.transferCharacteristics],matrix:UL[n.matrixCoefficients],fullRange:!!n.fullRangeFlag},e.info.reorderSize=n.maxDecFrameBuffering;break}else throw Error(`Unhandled.`)}e.info.decoderConfig={codec:bz({width:e.info.width,height:e.info.height,codec:e.info.codec,codecDescription:null,colorSpace:e.info.colorSpace,avcType:1,avcCodecInfo:e.info.avcCodecInfo,hevcCodecInfo:e.info.hevcCodecInfo,vp9CodecInfo:null,av1CodecInfo:null}),codedWidth:e.info.width,codedHeight:e.info.height,colorSpace:e.info.colorSpace},(e.info.width!==e.info.squarePixelWidth||e.info.height!==e.info.squarePixelHeight)&&(e.info.decoderConfig.displayAspectWidth=e.info.squarePixelWidth,e.info.decoderConfig.displayAspectHeight=e.info.squarePixelHeight),e.initialized=!0}else{if(await r.markNextPacket(),!r.suppliedPacket)throw Error(`Couldn't parse first media packet for Elementary Stream with PID ${e.pid}`);if(e.info.codec===`aac`){let t=wH(LG.tempFromBytes(r.suppliedPacket.data));if(!t)throw Error(`Invalid AAC audio stream; could not read ADTS frame header from first packet.`);e.info.aacCodecInfo={isMpeg2:!1,objectType:t.objectType},e.info.numberOfChannels=iz[t.channelConfiguration],e.info.sampleRate=rz[t.samplingFrequencyIndex]}else if(e.info.codec===`mp3`){let t=Uz($(LG.tempFromBytes(r.suppliedPacket.data)),r.suppliedPacket.data.byteLength);if(!t.header)throw Error(`Invalid MP3 audio stream; could not read frame header from first packet.`);e.info.numberOfChannels=Kz(t.header.channel),e.info.sampleRate=t.header.sampleRate}else if(e.info.codec===`ac3`){let t=RB(r.suppliedPacket.data);if(!t)throw Error(`Invalid AC-3 audio stream; could not read sync frame from first packet.`);if(t.fscod===3)throw Error(`Invalid AC-3 audio stream; reserved sample rate code found in first packet.`);e.info.numberOfChannels=LB[t.acmod]+t.lfeon,e.info.sampleRate=qz[t.fscod]}else if(e.info.codec===`eac3`){let t=HB(r.suppliedPacket.data);if(!t)throw Error(`Invalid E-AC-3 audio stream; could not read sync frame from first packet.`);let n=WB(t);if(n===null)throw Error(`Invalid E-AC-3 audio stream; reserved sample rate code found in first packet.`);e.info.numberOfChannels=GB(t),e.info.sampleRate=n}else throw Error(`Unhandled.`);e.info.decoderConfig={codec:Sz({codec:e.info.codec,codecDescription:null,aacCodecInfo:e.info.aacCodecInfo}),numberOfChannels:e.info.numberOfChannels,sampleRate:e.info.sampleRate},e.initialized=!0}}}if(a&&this.elementaryStreams.every(e=>e.initialized))break;n+=this.packetStride}if(!a)throw Error(i?`No Program Map Table found in the file.`:`No Program Association Table found in the file.`);for(let e of this.elementaryStreams)e.info.type===`video`?this.trackBackingEntries.push(new WH(e)):this.trackBackingEntries.push(new GH(e))})()}async getTrackBackings(){return await this.readMetadata(),this.trackBackingEntries}async getMetadataTags(){return{}}async getMimeType(){return await this.readMetadata(),LH(await Promise.all(this.trackBackingEntries.map(e=>e.getDecoderConfig().then(e=>e?.codec??null))))}async readSection(e,t,n=!1){let r=e,i=e,a=[],o=0,s=null,c=!0,l=0;for(;;){let e=await this.readPacket(i);if(i+=this.packetStride,!e)break;if(s){if(e.pid!==s.pid){if(n)break;continue}if(e.payloadUnitStartIndicator===1)break}else{if(e.payloadUnitStartIndicator===0)break;s=e}let u=!!(e.adaptationFieldControl&2),d=!!(e.adaptationFieldControl&1),f=0;if(u&&(f=1+e.body[0],e===s&&f>1&&(l=e.body[1]>>6&1)),d&&(f===0?(a.push(e.body),o+=e.body.byteLength):(a.push(e.body.subarray(f)),o+=e.body.byteLength-f)),r=i,!t&&o>=64){c=!1;break}if(ZL(this.sectionEndPositions,r,e=>e)!==-1){c=!1;break}}if(c){let e=QL(this.sectionEndPositions,r,e=>e);this.sectionEndPositions.splice(e+1,0,r)}if(!s)return null;let u;if(a.length===1)u=a[0];else{let e=a.reduce((e,t)=>e+t.length,0);u=new Uint8Array(e);let t=0;for(let e of a)u.set(e,t),t+=e.length}return{startPos:e,endPos:t?r:null,pid:s.pid,payload:u,randomAccessIndicator:l}}async readPacketHeader(e){let t=this.reader.requestSlice(e,4);if(t instanceof Promise&&(t=await t),!t)return null;if(BG(t)!==71)throw Error(`Invalid TS packet sync byte. Likely an internal bug, please report this file.`);let n=HG(t);n>>15;let r=n>>14&1;n>>13&1;let i=n&8191,a=BG(t);a>>6;let o=a>>4&3;return a&15,{payloadUnitStartIndicator:r,pid:i,adaptationFieldControl:o}}async readPacket(e){let t=this.reader.requestSlice(e,188);if(t instanceof Promise&&(t=await t),!t)return null;let n=zG(t,188);if(n[0]!==71)throw Error(`Invalid TS packet sync byte. Likely an internal bug, please report this file.`);let r=(n[1]<<8)+n[2];r>>15;let i=r>>14&1;r>>13&1;let a=r&8191,o=n[3];o>>6;let s=o>>4&3;return o&15,{payloadUnitStartIndicator:i,pid:a,adaptationFieldControl:s,body:n.subarray(4)}}},VH=(e,t)=>{if(e.payload.byteLength<3)return null;let n=new nz(e.payload);if(n.readBits(24)!==1)return null;let r=n.readBits(8);if(n.skipBits(16),r===188||r===190||r===191||r===240||r===241||r===255||r===242||r===248)return null;n.skipBits(8);let i=n.readBits(2);n.skipBits(14);let a=null;if(i===2||i===3)a=0,n.skipBits(4),a+=n.readBits(3)*(1<<30),n.skipBits(1),a+=n.readBits(15)*32768,n.skipBits(1),a+=n.readBits(15);else if(t)throw Error(RH);return{sectionStartPos:e.startPos,sectionEndPos:e.endPos,pts:a,randomAccessIndicator:e.randomAccessIndicator}},HH=(e,t)=>{X(e.endPos!==null);let n=VH(e,t);if(!n)return null;let r=new nz(e.payload);r.skipBits(32);let i=r.readBits(16);r.skipBits(16);let a=r.readBits(8),o=r.pos+8*a;r.pos=o;let s=o/8;X(Number.isInteger(s));let c=e.payload.subarray(s,i>0?6+i:e.payload.byteLength);return{...n,data:c}},UH=class e{constructor(e){this.elementaryStream=e,this.packetBuffers=new WeakMap,this.packetSectionStarts=new WeakMap}getId(){return this.elementaryStream.pid}getNumber(){let t=this.elementaryStream.demuxer,n=this.elementaryStream.info.type,r=0;for(let i of t.trackBackingEntries)if(i.getType()===n&&r++,X(i instanceof e),i.elementaryStream===this.elementaryStream)break;return r}getCodec(){throw Error(`Not implemented on base class.`)}getInternalCodecId(){return this.elementaryStream.streamType}getName(){return null}getLanguageCode(){return`und`}getDisposition(){return{...ez,primary:!1}}getTimeResolution(){return IH}isRelativeToUnixEpoch(){return!1}getPairingMask(){return 1n}getBitrate(){return null}getAverageBitrate(){return null}async getDurationFromMetadata(){return null}async getLiveRefreshInterval(){return null}createEncodedPacket(e,t,n){let r;return r=this.allPacketsAreKeyPackets()||e.randomAccessIndicator===1?`key`:`delta`,new JB(n.metadataOnly?qB:e.data,r,e.pts/IH,Math.max(t/IH,0),e.sequenceNumber,e.data.byteLength)}async getFirstPacket(e){let t=this.elementaryStream.firstSection;X(t);let n=HH(t,!0);X(n);let r=new qH(this.elementaryStream,n),i=new JH(this,r),a=await i.readNext();if(!a)return null;let o=this.createEncodedPacket(a.packet,a.duration,e);return this.packetBuffers.set(o,i),this.packetSectionStarts.set(o,a.packet.sectionStartPos),o}async getNextPacket(e,t){let n=this.packetBuffers.get(e);if(n){let r=await n.readNext();if(!r)return null;this.packetBuffers.delete(e);let i=this.createEncodedPacket(r.packet,r.duration,t);return this.packetBuffers.set(i,n),this.packetSectionStarts.set(i,r.packet.sectionStartPos),i}let r=this.packetSectionStarts.get(e);if(r===void 0)throw Error(`Packet was not created from this track.`);let i=await this.elementaryStream.demuxer.readSection(r,!0);X(i);let a=HH(i,!0);X(a);let o=new qH(this.elementaryStream,a);n=new JH(this,o);let s=e.sequenceNumber;for(;;){let e=await n.readNext();if(!e)return null;if(e.packet.sequenceNumber>s){let r=this.createEncodedPacket(e.packet,e.duration,t);return this.packetBuffers.set(r,n),this.packetSectionStarts.set(r,e.packet.sectionStartPos),r}}}async getNextKeyPacket(e,t){let n=e;for(;;){if(n=await this.getNextPacket(n,t),!n)return null;if(n.type===`key`)return n}}getPacket(e,t){return this.doPacketLookup(e,!1,t)}getKeyPacket(e,t){return this.doPacketLookup(e,!0,t)}async doPacketLookup(e,t,n){let r=pR(e*IH),i=this.elementaryStream.demuxer,{reader:a,seekChunkSize:o}=i,s=this.elementaryStream.pid,c=async(e,t,n)=>{let r=e;for(;r<t;){let e=await i.readPacketHeader(r);if(!e)return null;if(e.pid===s&&e.payloadUnitStartIndicator===1){let e=await i.readSection(r,n);if(!e)return null;let t=VH(e,!1);if(t&&t.pts!==null)return{pesPacketHeader:t,section:e}}r+=i.packetStride}return null},l=this.elementaryStream.firstSection;X(l);let u=VH(l,!0);if(X(u),r<u.pts)return null;let d,f=this.elementaryStream.referencePesPackets,p=QL(f,r,e=>e.pts),m=p===-1?null:f[p];if(m&&r-m.pts<9e4/2)d=m.sectionStartPos;else{let e=0;if(a.fileSize!==null){let t=Math.ceil(a.fileSize/o);if(t>1){let n=0,a=t-1;for(e=n;n<=a;){let t=Math.floor((n+a)/2),s=gR(t*o,i.packetStride)+u.sectionStartPos,l=await c(s,s+o,!1);if(!l){a=t-1;continue}l.pesPacketHeader.pts<=r?(e=t,n=t+1):a=t-1}}}d=gR(e*o,i.packetStride)+u.sectionStartPos}let h=(await c(d,a.fileSize??1/0,!1))?.pesPacketHeader??null;h||=u;let g=this.getReorderSize(),_=async(e,t)=>{let a=await i.readSection(e,!0);X(a);let o=HH(a,!0);X(o);let s=new qH(this.elementaryStream,o),c=new JH(this,s);for(;!((AL(c.presentationOrderPackets)?.pts??-1/0)>=r||!await c.readNextPacket()););let l=rR(c.presentationOrderPackets,t);if(l===-1)return null;let u=c.presentationOrderPackets[l],d=l===0?0:u.pts-c.presentationOrderPackets[l-1].pts;for(;c.decodeOrderPackets[0]!==u;)c.decodeOrderPackets.shift();c.lastDuration=d;let f=await c.readNext();X(f);let p=this.createEncodedPacket(f.packet,f.duration,n);return this.packetBuffers.set(p,c),this.packetSectionStarts.set(p,f.packet.sectionStartPos),p};if(!t||this.allPacketsAreKeyPackets()){outer:for(;;){let e=h.sectionStartPos+i.packetStride;for(;;){let t=await i.readPacketHeader(e);if(!t)break outer;if(t.pid===s&&t.payloadUnitStartIndicator===1){let t=await i.readSection(e,!1);if(t){let e=VH(t,!1);if(e&&e.pts!==null){if(e.pts>r)break outer;h=e,KH(this.elementaryStream,h);break}}}e+=i.packetStride}}outer:for(let e=0;e<g+1;e++){let e=h.sectionStartPos-i.packetStride;for(;e>=i.packetOffset;){let t=await i.readPacketHeader(e);if(!t)break outer;if(t.pid===s&&t.payloadUnitStartIndicator===1){let t=await i.readSection(e,!1);if(t){let e=VH(t,!1);if(e&&e.pts!==null){h=e;break}}}e-=i.packetStride}}return _(h.sectionStartPos,e=>e.pts<=r)}else{let e=d,t=null,n=!this.elementaryStream.canBeTrustedWithKeyPackets;for(;;){let d=null,f=e<=u.sectionStartPos,p,m=null;if(f)p=u,m=l;else{let t=await c(e,a.fileSize??1/0,n);p=t?.pesPacketHeader??null,m=t?.section??null}let h=!1,v=0;outer:for(;p&&!(t!==null&&p.sectionStartPos>=t);){if(p.pts<=r){let e;if(this.elementaryStream.canBeTrustedWithKeyPackets)e=p.randomAccessIndicator===1;else{X(m);let t=HH(m,!0);X(t);let n=new qH(this.elementaryStream,t);await n.markNextPacket(),e=n.suppliedPacket?.randomAccessIndicator===1}e&&(d=p)}if(p.pts>r&&(h=!0),h&&(v++,v>g))break;let e=p.sectionStartPos+i.packetStride;for(;;){let t=await i.readPacketHeader(e);if(!t)break outer;if(t.pid===s&&t.payloadUnitStartIndicator===1){let t=await i.readSection(e,n);if(t){let e=VH(t,!1);if(e&&e.pts!==null){p=e,m=t,KH(this.elementaryStream,p);break}}}e+=i.packetStride}}if(d){let e=d;if(v===0)outer:for(let t=0;t<g;t++){let t=e.sectionStartPos-i.packetStride;for(;t>=i.packetOffset;){let r=await i.readPacketHeader(t);if(!r)break outer;if(r.pid===s&&r.payloadUnitStartIndicator===1){let r=await i.readSection(t,n);if(r){let t=VH(r,!1);if(t&&t.pts!==null){e=t;break}}}t-=i.packetStride}}let t=await _(e.sectionStartPos,e=>e.pts<=r&&e.randomAccessIndicator===1);return X(t),t}if(f)return null;t=e,e=Math.max(gR(e-u.sectionStartPos-o,i.packetStride)+u.sectionStartPos,u.sectionStartPos)}}}},WH=class extends UH{getType(){return`video`}getCodec(){return this.elementaryStream.info.codec}getCodedWidth(){return this.elementaryStream.info.width}getCodedHeight(){return this.elementaryStream.info.height}getSquarePixelWidth(){return this.elementaryStream.info.squarePixelWidth}getSquarePixelHeight(){return this.elementaryStream.info.squarePixelHeight}getRotation(){return 0}async getColorSpace(){return this.elementaryStream.info.colorSpace}async canBeTransparent(){return!1}async getDecoderConfig(){return X(this.elementaryStream.info.decoderConfig),this.elementaryStream.info.decoderConfig}allPacketsAreKeyPackets(){return!1}getReorderSize(){return this.elementaryStream.info.reorderSize}},GH=class extends UH{getType(){return`audio`}getCodec(){return this.elementaryStream.info.codec}getNumberOfChannels(){return this.elementaryStream.info.numberOfChannels}getSampleRate(){return this.elementaryStream.info.sampleRate}async getDecoderConfig(){return X(this.elementaryStream.info.decoderConfig),this.elementaryStream.info.decoderConfig}allPacketsAreKeyPackets(){return!0}getReorderSize(){return 0}},KH=(e,t)=>{let n=e.referencePesPackets,r=QL(n,t.sectionStartPos,e=>e.sectionStartPos);if(r>=0){let i=n[r];if(t.pts<=i.pts)return!1;let a=e.demuxer.minReferencePointByteDistance;if(t.sectionStartPos-i.sectionStartPos<a)return!1;if(r<n.length-1){let e=n[r+1];if(e.pts<t.pts||e.sectionStartPos-t.sectionStartPos<a)return!1}}return n.splice(r+1,0,t),!0},qH=class{constructor(e,t){this.currentPos=0,this.pesPackets=[],this.currentPesPacketIndex=0,this.currentPesPacketPos=0,this.endPos=0,this.lastSuppliedPesPacket=null,this.nextPts=null,this.suppliedPacket=null,this.elementaryStream=e,this.pid=e.pid,this.demuxer=e.demuxer,this.startingPesPacket=t}ensureBuffered(e){let t=this.endPos-this.currentPos;return t>=e?e:this.bufferData(e-t).then(()=>Math.min(this.endPos-this.currentPos,e))}getCurrentPesPacket(){let e=this.pesPackets[this.currentPesPacketIndex];return X(e),e}async bufferData(e){let t=this.endPos+e;for(;this.endPos<t;){let e;if(this.pesPackets.length===0)e=this.startingPesPacket;else{let t=AL(this.pesPackets).sectionEndPos;for(X(t!==null);;){let n=await this.demuxer.readPacketHeader(t);if(!n)return;if(n.pid===this.pid){let n=await this.demuxer.readSection(t,!0);if(!n)return;let r=HH(n,!1);if(r){e=r;break}}t+=this.demuxer.packetStride}}this.pesPackets.push(e),this.endPos+=e.data.byteLength}}readBytes(e){let t=this.getCurrentPesPacket(),n=this.currentPos-this.currentPesPacketPos,r=n+e;if(this.currentPos+=e,r<=t.data.byteLength)return t.data.subarray(n,r);let i=new Uint8Array(e);i.set(t.data.subarray(n));let a=t.data.byteLength-n;for(;;){this.advanceCurrentPacket();let t=this.getCurrentPesPacket(),n=e-a;if(n<=t.data.byteLength){i.set(t.data.subarray(0,n),a);break}i.set(t.data,a),a+=t.data.byteLength}return i}readU8(){let e=this.getCurrentPesPacket(),t=this.currentPos-this.currentPesPacketPos;return this.currentPos++,t<e.data.byteLength?e.data[t]:(this.advanceCurrentPacket(),e=this.getCurrentPesPacket(),e.data[0])}seekTo(e){if(e!==this.currentPos){if(e<this.currentPos)for(;e<this.currentPesPacketPos;){this.currentPesPacketIndex--;let e=this.getCurrentPesPacket();this.currentPesPacketPos-=e.data.byteLength}else for(;;){let t=this.getCurrentPesPacket();if(e<this.currentPesPacketPos+t.data.byteLength)break;this.currentPesPacketPos+=t.data.byteLength,this.currentPesPacketIndex++}this.currentPos=e}}skip(e){this.seekTo(this.currentPos+e)}advanceCurrentPacket(){this.currentPesPacketPos+=this.getCurrentPesPacket().data.byteLength,this.currentPesPacketIndex++}async markNextPacket(){X(!this.suppliedPacket);let e=this.elementaryStream;if(e.info.type===`video`){let t=e.info.codec,n=1024;if(t!==`avc`&&t!==`hevc`)throw Error(`Unhandled.`);let r=null;for(;;){let e=this.ensureBuffered(n);if(e instanceof Promise&&(e=await e),e===0)break;let i=this.currentPos,a=this.readBytes(e),o=a.byteLength,s=0;for(;s<o;){let e=a.indexOf(0,s);if(e===-1||e>=o)break;s=e;let n=i+s;if(s+4>=o){this.seekTo(n);break}let c=a[s+1],l=a[s+2],u=a[s+3],d=0,f=null;if(c===0&&l===0&&u===1?(d=4,f=a[s+4]):c===0&&l===1&&(d=3,f=u),d===0){s++;continue}let p=n;if(r===null){r=p,s+=d;continue}if(f!==null){let e=t===`avc`?eB(f):mB(f);if(t===`avc`?e===Yz.AUD:e===Xz.AUD_NUT){let e=p-r;return this.seekTo(r),this.supplyPacket(e,0)}}s+=d}if(e<n)break}if(r!==null){let e=this.endPos-r;return this.seekTo(r),this.supplyPacket(e,0)}}else{let t=e.info.codec;for(;;){let n=this.ensureBuffered(128);n instanceof Promise&&(n=await n);let r=this.currentPos;for(;this.currentPos-r<n;){let n=this.readU8();if(t===`aac`){if(n!==255)continue;this.skip(-1);let t=this.currentPos,r=this.ensureBuffered(9);if(r instanceof Promise&&(r=await r),r<9)return;let i=this.readBytes(9),a=wH(LG.tempFromBytes(i));if(a){this.seekTo(t);let n=this.ensureBuffered(a.frameLength);return n instanceof Promise&&(n=await n),this.supplyPacket(n,Math.round(TH*IH/e.info.sampleRate))}else this.seekTo(t+1)}else if(t===`mp3`){if(n!==255)continue;this.skip(-1);let t=this.currentPos,r=this.ensureBuffered(4);if(r instanceof Promise&&(r=await r),r<4)return;let i=Uz(PL(this.readBytes(4)).getUint32(0),null);if(i.header){this.seekTo(t);let n=this.ensureBuffered(i.header.totalSize);n instanceof Promise&&(n=await n);let r=i.header.audioSamplesInFrame*IH/e.info.sampleRate;return this.supplyPacket(n,Math.round(r))}else this.seekTo(t+1)}else if(t===`ac3`){if(n!==11)continue;this.skip(-1);let t=this.currentPos,r=this.ensureBuffered(5);if(r instanceof Promise&&(r=await r),r<5)return;let i=this.readBytes(5);if(i[0]!==11||i[1]!==119){this.seekTo(t+1);continue}let a=i[4]>>6,o=i[4]&63;if(a===3||o>37){this.seekTo(t+1);continue}let s=zB[3*o+a];X(s!==void 0),this.seekTo(t),r=this.ensureBuffered(s),r instanceof Promise&&(r=await r);let c=Math.round(BB*IH/e.info.sampleRate);return this.supplyPacket(r,c)}else if(t===`eac3`){if(n!==11)continue;this.skip(-1);let t=this.currentPos,r=this.ensureBuffered(5);if(r instanceof Promise&&(r=await r),r<5)return;let i=this.readBytes(5);if(i[0]!==11||i[1]!==119){this.seekTo(t+1);continue}let a=(((i[2]&7)<<8|i[3])+1)*2,o=VB[i[4]>>6==3?3:i[4]>>4&3];this.seekTo(t),r=this.ensureBuffered(a),r instanceof Promise&&(r=await r);let s=o*256,c=Math.round(s*IH/e.info.sampleRate);return this.supplyPacket(r,c)}else throw Error(`Unhandled.`)}if(n<128)break}}}supplyPacket(e,t){let n=this.getCurrentPesPacket(),r;if(this.lastSuppliedPesPacket===n)X(this.nextPts!==null),r=this.nextPts;else{if(n.pts===null)throw Error(RH);r=n.pts,KH(this.elementaryStream,n)}this.lastSuppliedPesPacket=n,this.nextPts=r+t;let i=n.sectionStartPos,a=i+(this.currentPos-this.currentPesPacketPos),o=this.readBytes(e),s=n.randomAccessIndicator;if(s===0&&!this.elementaryStream.canBeTrustedWithKeyPackets){if(this.elementaryStream.info.type===`audio`)s=1;else if(this.elementaryStream.info.decoderConfig){let e=PB(this.elementaryStream.info.codec,this.elementaryStream.info.decoderConfig,o)===`key`;s=Number(e)}}this.suppliedPacket={pts:r,data:o,sequenceNumber:a,sectionStartPos:i,randomAccessIndicator:s},this.pesPackets.splice(0,this.currentPesPacketIndex),this.currentPesPacketIndex=0}},JH=class{constructor(e,t){this.decodeOrderPackets=[],this.reorderBuffer=[],this.presentationOrderPackets=[],this.reachedEnd=!1,this.lastDuration=0,this.backing=e,this.context=t,this.reorderSize=e.getReorderSize(),X(this.reorderSize>=0)}async readNext(){if(this.decodeOrderPackets.length===0&&!await this.readNextPacket())return null;await this.ensureCurrentPacketHasNext();let e=this.decodeOrderPackets[0],t=this.presentationOrderPackets.indexOf(e);X(t!==-1);let n;for(t===this.presentationOrderPackets.length-1?n=this.lastDuration:(n=this.presentationOrderPackets[t+1].pts-e.pts,this.lastDuration=n),this.decodeOrderPackets.shift();this.presentationOrderPackets.length>0;){let e=this.presentationOrderPackets[0];if(this.decodeOrderPackets.includes(e))break;this.presentationOrderPackets.shift()}return{packet:e,duration:n}}async readNextPacket(){if(this.reachedEnd)return!1;let e;return this.context.suppliedPacket||await this.context.markNextPacket(),e=this.context.suppliedPacket,this.context.suppliedPacket=null,e?(this.decodeOrderPackets.push(e),this.processPacketThroughReorderBuffer(e),!0):(this.reachedEnd=!0,this.flushReorderBuffer(),!1)}async ensureCurrentPacketHasNext(){let e=this.decodeOrderPackets[0];for(X(e);;){let t=this.presentationOrderPackets.indexOf(e);if(t!==-1&&t<=this.presentationOrderPackets.length-2||!await this.readNextPacket())break}}processPacketThroughReorderBuffer(e){if(this.reorderBuffer.push(e),this.reorderBuffer.length>this.reorderSize){let e=0;for(let t=1;t<this.reorderBuffer.length;t++)this.reorderBuffer[t].pts<this.reorderBuffer[e].pts&&(e=t);let t=this.reorderBuffer[e];this.presentationOrderPackets.push(t),this.reorderBuffer.splice(e,1)}}flushReorderBuffer(){this.reorderBuffer.sort((e,t)=>e.pts-t.pts),this.presentationOrderPackets.push(...this.reorderBuffer),this.reorderBuffer.length=0}},YH=`application/vnd.apple.mpegurl`,XH=`#EXT-X-STREAM-INF:`,ZH=`#EXT-X-I-FRAME-STREAM-INF:`,QH=`#EXT-X-MEDIA:`,$H=`#EXTINF:`,eU=`#EXT-X-MAP:`,tU=`#EXT-X-KEY:`,nU=`#EXT-X-MEDIA-SEQUENCE:`,rU=`#EXT-X-BYTERANGE:`,iU=`#EXT-X-PROGRAM-DATE-TIME:`,aU=`#EXT-X-TARGETDURATION:`,oU=e=>e.length===0||e.startsWith(`#`)&&!e.startsWith(`#EXT`),sU=class{constructor(e){this._attributes={};let t=``,n=``,r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];o===`"`?i=!i:o===`=`&&!r&&!i?r=!0:o===`,`&&!i?(t&&(this._attributes[t.trim().toLowerCase()]=n),t=``,n=``,r=!1):r?n+=o:t+=o}t&&(this._attributes[t.trim().toLowerCase()]=n)}get(e){return this._attributes[e.toLowerCase()]??null}getAsNumber(e){let t=this.get(e);if(t===null)return null;let n=Number(t);return Number.isFinite(n)?n:null}merge(e){Object.assign(this._attributes,e._attributes)}},cU=class{constructor(e,t,n){this.nextInputCacheAge=0,this.inputCache=[],this.trackBackingsPromise=null,this.firstSegment=null,this.firstSegmentFirstTimestamps=new WeakMap,this.firstTimestampCache=new WeakMap,this.input=e,this.path=t,this.trackDeclarations=n}async getDurationFromMetadata(e){let t=await this.getSegmentAt(1/0,{skipLiveWait:e.skipLiveWait});return t?t.timestamp+t.duration:null}async getTrackBackings(){return this.trackBackingsPromise??=(async()=>{let e=[];if(this.trackDeclarations){for(let t of this.trackDeclarations)if(t.type===`video`){let n=UR(e,e=>e.getType()===`video`)+1;e.push(new uU(this,t,n))}else if(t.type===`audio`){let n=UR(e,e=>e.getType()===`audio`)+1;e.push(new dU(this,t,n))}}else{if(this.firstSegment=await this.getFirstSegment({}),!this.firstSegment)return[];let t=await this.getInputForSegment(this.firstSegment).getTracks();for(let n of t)if(n.type===`video`){let t=UR(e,e=>e.getType()===`video`)+1;e.push(new uU(this,{id:e.length+1,type:`video`},t))}else if(n.type===`audio`){let t=UR(e,e=>e.getType()===`audio`)+1;e.push(new dU(this,{id:e.length+1,type:`audio`},t))}}return e})()}async getFirstTimestampForInput(e){let t=this.firstTimestampCache.get(e);if(t!==void 0)return t;let n=await e.getFirstTimestamp();return this.firstTimestampCache.set(e,n),n}async getMediaOffset(e,t){let n=e.firstSegment??e,r;if(this.firstSegmentFirstTimestamps.has(n))r=this.firstSegmentFirstTimestamps.get(n);else{let e=this.getInputForSegment(n);r=await this.getFirstTimestampForInput(e),this.firstSegmentFirstTimestamps.set(n,r)}if(n===e)return n.timestamp-r;let i=await this.getFirstTimestampForInput(t),a=e.timestamp-n.timestamp,o=i-r-a;return Math.abs(o)<=Math.min(.25,a)?n.timestamp-r:e.timestamp-i}dispose(){for(let e of this.inputCache)e.input.dispose();this.inputCache.length=0}},lU=class{constructor(e,t,n){this.packetInfos=new WeakMap,this.hydrationPromise=null,this.firstInputTrack=null,this.segmentedInput=e,this.decl=t,this.number=n}hydrate(){return this.hydrationPromise??=(async()=>{if(this.segmentedInput.firstSegment??=await this.segmentedInput.getFirstSegment({}),!this.segmentedInput.firstSegment)throw Error(`Missing first segment, can't retrieve track.`);let e=(await this.segmentedInput.getInputForSegment(this.segmentedInput.firstSegment).getTracks()).find(e=>e.type===this.decl.type&&e.number===this.number);if(!e)throw Error(`No matching track found in underlying media data.`);this.firstInputTrack=e})()}getId(){return this.decl.id}getType(){return this.decl.type}getNumber(){return this.number}delegate(e){return this.firstInputTrack?e():this.hydrate().then(e)}async getDecoderConfig(){return this.delegate(()=>this.firstInputTrack._backing.getDecoderConfig())}getHasOnlyKeyPackets(){return this.delegate(()=>this.firstInputTrack._backing.getHasOnlyKeyPackets?.()??null)}getPairingMask(){return 1n}getCodec(){return this.delegate(()=>this.firstInputTrack._backing.getCodec())}getInternalCodecId(){return this.delegate(()=>this.firstInputTrack._backing.getInternalCodecId())}getDisposition(){return this.delegate(()=>this.firstInputTrack._backing.getDisposition())}getLanguageCode(){return this.delegate(()=>this.firstInputTrack._backing.getLanguageCode())}getName(){return this.delegate(()=>this.firstInputTrack._backing.getName())}getTimeResolution(){return this.delegate(()=>this.firstInputTrack._backing.getTimeResolution())}async isRelativeToUnixEpoch(){return await this.hydrate(),X(this.segmentedInput.firstSegment),this.segmentedInput.firstSegment.relativeToUnixEpoch}getBitrate(){return this.delegate(()=>this.firstInputTrack._backing.getBitrate())}getAverageBitrate(){return this.delegate(()=>this.firstInputTrack._backing.getAverageBitrate())}getDurationFromMetadata(e){return this.segmentedInput.getDurationFromMetadata(e)}getLiveRefreshInterval(){return this.segmentedInput.getLiveRefreshInterval()}async createAdjustedPacket(e,t,n){X(e.sequenceNumber>=0),X(this.segmentedInput.firstSegment);let r=await this.segmentedInput.getMediaOffset(t,n.input),i=t.timestamp-this.segmentedInput.firstSegment.timestamp,a=e.clone({timestamp:hR(e.timestamp+r,await n.getTimeResolution()),sequenceNumber:Math.floor(1e8*i)+e.sequenceNumber});return this.packetInfos.set(a,{segment:t,track:n,sourcePacket:e}),a}async getFirstPacket(e){await this.hydrate(),X(this.segmentedInput.firstSegment),X(this.firstInputTrack);let t=await this.firstInputTrack._backing.getFirstPacket(e);return t?this.createAdjustedPacket(t,this.segmentedInput.firstSegment,this.firstInputTrack):null}getNextPacket(e,t){return this._getNextInternal(e,t,!1)}getNextKeyPacket(e,t){return this._getNextInternal(e,t,!0)}async _getNextInternal(e,t,n){let r=this.packetInfos.get(e);if(!r)throw Error(`Packet was not created from this track.`);let i=n?await r.track._backing.getNextKeyPacket(r.sourcePacket,t):await r.track._backing.getNextPacket(r.sourcePacket,t);if(i)return this.createAdjustedPacket(i,r.segment,r.track);let a=r.segment;for(;;){let e=await this.segmentedInput.getNextSegment(a,{skipLiveWait:t.skipLiveWait});if(!e)return null;let n=(await this.segmentedInput.getInputForSegment(e).getTracks()).find(e=>e.type===r.track.type&&e.number===r.track.number);if(!n){a=e;continue}let i=await n._backing.getFirstPacket(t);return i?this.createAdjustedPacket(i,e,n):null}}getPacket(e,t){return this._getPacketInternal(e,t,!1)}getKeyPacket(e,t){return this._getPacketInternal(e,t,!0)}async _getPacketInternal(e,t,n){let r=await this.segmentedInput.getSegmentAt(e,{skipLiveWait:t.skipLiveWait});if(!r)return null;for(await this.hydrate();r;){let i=this.segmentedInput.getInputForSegment(r),a=(await i.getTracks()).find(e=>e.type===this.firstInputTrack.type&&e.number===this.firstInputTrack.number);if(!a){r=await this.segmentedInput.getPreviousSegment(r,{skipLiveWait:t.skipLiveWait});continue}let o=e-await this.segmentedInput.getMediaOffset(r,i),s=n?await a._backing.getKeyPacket(o,t):await a._backing.getPacket(o,t);if(!s){r=await this.segmentedInput.getPreviousSegment(r,{skipLiveWait:t.skipLiveWait});continue}return this.createAdjustedPacket(s,r,a)}return null}},uU=class extends lU{getType(){return`video`}getCodec(){return this.delegate(()=>this.firstInputTrack._backing.getCodec())}getCodedWidth(){return this.delegate(()=>this.firstInputTrack._backing.getCodedWidth())}getCodedHeight(){return this.delegate(()=>this.firstInputTrack._backing.getCodedHeight())}getSquarePixelWidth(){return this.delegate(()=>this.firstInputTrack._backing.getSquarePixelWidth())}getSquarePixelHeight(){return this.delegate(()=>this.firstInputTrack._backing.getSquarePixelHeight())}getRotation(){return this.delegate(()=>this.firstInputTrack._backing.getRotation())}async getColorSpace(){return this.delegate(()=>this.firstInputTrack._backing.getColorSpace())}async canBeTransparent(){return this.delegate(()=>this.firstInputTrack._backing.canBeTransparent())}async getDecoderConfig(){return this.delegate(()=>this.firstInputTrack._backing.getDecoderConfig())}},dU=class extends lU{getType(){return`audio`}getCodec(){return this.delegate(()=>this.firstInputTrack._backing.getCodec())}getNumberOfChannels(){return this.delegate(()=>this.firstInputTrack._backing.getNumberOfChannels())}getSampleRate(){return this.delegate(()=>this.firstInputTrack._backing.getSampleRate())}async getDecoderConfig(){return this.delegate(()=>this.firstInputTrack._backing.getDecoderConfig())}},fU=o(((e,t)=>{t.exports={}}));fU(),BR();var pU=1/0;typeof FinalizationRegistry<`u`&&new FinalizationRegistry(e=>{e()});var mU=class extends YR{constructor(){super(),this._disposed=!1,this._refCount=0,this._usedForHls=!1,this._refFinalizationRegistry=null,this._sizePromise=null,this.onread=null,typeof FinalizationRegistry<`u`&&(this._refFinalizationRegistry=new FinalizationRegistry(e=>{e._decrementRefCount()}))}async getSizeOrNull(){if(this._disposed)throw new FG;return this._sizePromise??=(async()=>{let e=this._getFileSize();return e===void 0?(await this._read(0,1,0,pU),e=this._getFileSize(),X(e!==void 0),e):e})()}async getSize(){if(this._disposed)throw new FG;let e=await this.getSizeOrNull();if(e===null)throw Error(`Cannot determine the size of an unsized source.`);return e}slice(e,t){if(!Number.isInteger(e)||e<0)throw TypeError(`offset must be a non-negative integer.`);if(t!==void 0&&(!Number.isInteger(t)||t<0))throw TypeError(`length, when provided, must be a non-negative integer.`);return new kU(this,e,t)}_dispatchRead(e,t){this.onread?.(e,t),this._emit(`read`,{start:e,end:t})}ref(){return new hU(this)}_incrementRefCount(){this._refCount++}_decrementRefCount(){this._refCount--,this._refCount===0&&(this._dispose(),this._disposed=!0)}},hU=class{constructor(e){if(this._freed=!1,e._disposed)throw Error(`Cannot ref a disposed source.`);e._incrementRefCount(),e._refFinalizationRegistry?.register(this,e,this),this._source=e}get source(){if(!this._source)throw Error(`Can't get source; ref has already been freed.`);return this._source}get freed(){return this._freed}free(){if(this._freed)throw Error(`Illegal operation: double free on SourceRef.`);let e=this.source;X(e._refCount>0),e._decrementRefCount(),e._refFinalizationRegistry?.unregister(this),this._freed=!0,this._source=null}[Symbol.dispose](){this.freed||this.free()}},gU=class extends mU{constructor(e,t){if(typeof e!=`string`)throw TypeError(`rootPath must be a string.`);if(typeof t!=`function`)throw TypeError(`requestHandler must be a function.`);super(),this.rootPath=e,this.requestHandler=t}_resolveRequest(e){let t=this.requestHandler(e),n=e=>{if(!(e instanceof mU||e instanceof hU))throw TypeError(`requestHandler must return or resolve to a Source or SourceRef.`);let t=e instanceof mU?e.ref():e;return t.source._usedForHls||=this._usedForHls,t};return t instanceof Promise?t.then(n):n(t)}},_U=(e,t)=>e.path===t.path,vU=class extends gU{constructor(){super(...arguments),this._root=null,this._rootRequest=null}_read(e,t,n,r){if(!this._root){if(!this._rootRequest){let e=this._resolveRequest({path:this.rootPath,isRoot:!0}),t=e=>{let t=e instanceof mU?e.ref():e;return this._root=t,this._rootRequest=null,t};e instanceof Promise?this._rootRequest=e.then(t):(t(e),X(this._root))}if(this._rootRequest)return this._rootRequest.then(i=>i.source._read(e,t,n,r))}return this._root.source._read(e,t,n,r)}_getFileSize(){if(this._root)return this._root.source._getFileSize()}_dispose(){this._root?this._root.free():this._rootRequest&&this._rootRequest.then(e=>e.free())}},yU=class extends mU{constructor(e){if(!(e instanceof ArrayBuffer)&&!(typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer)&&!ArrayBuffer.isView(e))throw TypeError(`buffer must be an ArrayBuffer, SharedArrayBuffer, or ArrayBufferView.`);super(),this._onreadCalled=!1,this._bytes=NL(e),this._view=PL(e)}_getFileSize(){return this._bytes.byteLength}_read(){return this._onreadCalled||=(this._dispatchRead(0,this._bytes.byteLength),!0),{bytes:this._bytes,view:this._view,offset:0}}_dispose(){}},bU=.5*2**20,xU=((e,t,n)=>{if(t instanceof Error&&(t.message.includes(`Failed to fetch`)||t.message.includes(`Load failed`)||t.message.includes(`NetworkError when attempting to fetch resource`))&&typeof window<`u`){let e=null;try{typeof window<`u`&&window.location!==void 0&&(e=new URL(n instanceof Request?n.url:n,window.location.href).origin)}catch{}if((!(typeof navigator<`u`&&typeof navigator.onLine==`boolean`)||navigator.onLine)&&e!==null&&e!==window.location.origin)return console.warn(`Request will not be retried because a CORS error was suspected due to different origins. You can modify this behavior by providing your own function for the 'getRetryDelay' option.`),null}return Math.min(2**(e-2),16)}),SU=new Set,CU=class e extends gU{constructor(t,n={}){if(typeof t!=`string`&&!(t instanceof URL)&&!(typeof Request<`u`&&t instanceof Request))throw TypeError(`url must be a string, URL or Request.`);if(!n||typeof n!=`object`)throw TypeError(`options must be an object.`);if(n.requestInit!==void 0&&(!n.requestInit||typeof n.requestInit!=`object`))throw TypeError(`options.requestInit, when provided, must be an object.`);if(n.getRetryDelay!==void 0&&typeof n.getRetryDelay!=`function`)throw TypeError(`options.getRetryDelay, when provided, must be a function.`);if(n.maxCacheSize!==void 0&&(!VR(n.maxCacheSize)||n.maxCacheSize<0))throw TypeError(`options.maxCacheSize, when provided, must be a non-negative number.`);if(n.parallelism!==void 0&&(!Number.isInteger(n.parallelism)||n.parallelism<1))throw TypeError(`options.parallelism, when provided, must be a positive number.`);if(n.fetchFn!==void 0&&typeof n.fetchFn!=`function`)throw TypeError(`options.fetchFn, when provided, must be a function.`);let r=t instanceof Request?t.url:t instanceof URL?t.href:t;super(r,t=>new e(t.path,this._options)),this._offset=0,this._length=null,this._fileSizeDetermined=!1,this._url=t,this._options=n,this._getRetryDelay=n.getRetryDelay??xU,this._requestInit={...n.requestInit};let i=null;if(n.requestInit?.headers){let e={...CR(n.requestInit.headers)},t=Object.keys(e).find(e=>e.toLowerCase()===`range`);t!==void 0&&(i=e[t],delete e[t],this._requestInit.headers=e)}if(t instanceof Request){let e=t.headers.get(`Range`);if(e!==null){i??=e;let n=new Request(t);n.headers.delete(`Range`),this._url=n}}if(i!==null){let e=TU(i);e&&(this._offset=e.offset,this._length=e.length)}this._orchestrator=new OU({maxCacheSize:n.maxCacheSize??64*2**20,maxWorkerCount:n.parallelism??2,runWorker:this._runWorker.bind(this),prefetchProfile:DU.network})}_getFileSize(){if(!this._fileSizeDetermined)return this._length===null?void 0:this._length;let e=this._orchestrator.fileSize;return e===null?this._length===null?null:this._length:fR(e-this._offset,0,this._length??1/0)}_read(e,t,n,r){if(this._length!==null&&t>this._length)return null;let i=this._offset,a=this._orchestrator.read(i+e,i+t,Math.max(i+n,i),i+Math.min(r,this._length??1/0)),o=e=>e?(e.offset-=this._offset,e):null;return a instanceof Promise?a.then(o):o(a)}async _runWorker(e){for(;;){let t=new AbortController,n=await wR(this._options.fetchFn??fetch,this._url,SR(this._requestInit,{headers:{Range:`bytes=${e.currentPos}-`},signal:t.signal}),this._getRetryDelay,()=>this._disposed);if(!n.ok)throw Error(`Error fetching ${String(this._url)}: ${n.status} ${n.statusText}`);outer:if(this._orchestrator.fileSize===null){let t=n.headers.get(`Content-Range`);if(t){let e=/\/(\d+)/.exec(t);if(e){this._orchestrator.supplyFileSize(Number(e[1]));break outer}}let r=n.headers.get(`Content-Length`);r&&this._orchestrator.supplyFileSize(e.currentPos+Number(r))}if(this._fileSizeDetermined=!0,n.status!==206){if(!this._usedForHls){let e=new URL(this._url instanceof Request?this._url.url:this._url,typeof window<`u`?window.location.href:void 0);e.origin!==`null`&&!(e.pathname.endsWith(`.m3u8`)||e.pathname.endsWith(`.m3u`))&&(SU.has(e.origin)||(console.log(this._usedForHls,this._url,e.pathname),console.warn(`HTTP server (origin ${e.origin}) did not respond to a range request with 206 Partial Content, meaning the entire resource will now be downloaded. To enable efficient media file streaming across a network, please make sure your server supports range requests.`),SU.add(e.origin)))}e.currentPos=0,this._orchestrator.options.maxCacheSize=1/0,this._orchestrator.fileSize===null?(e.targetPos=1/0,e.strictTarget=!1):e.targetPos=this._orchestrator.fileSize,this._orchestrator.consolidateEverythingIntoOneWorker(e)}if(!n.body)throw Error(`Missing HTTP response body stream. The used fetch function must provide the response body as a ReadableStream.`);let r=n.body.getReader();for(;;){if(e.currentPos>=e.targetPos||e.aborted){t.abort(),this._orchestrator.signalWorkerStoppedRunning(e);return}let n;try{n=await r.read()}catch(e){if(this._disposed)throw e;let t=this._getRetryDelay(1,e,this._url);if(t!==null){console.error(`Error while reading response stream. Attempting to resume.`,e),await qR(1e3*t);break}else throw e}if(e.aborted)continue;let{done:i,value:a}=n;if(i){if(e.currentPos>=e.targetPos){this._orchestrator.onWorkerFinished(e);return}if(e.strictTarget)break;this._orchestrator.onWorkerFinished(e);return}this._dispatchRead(e.currentPos,e.currentPos+a.length),this._orchestrator.supplyWorkerData(e,a)}}}_dispose(){this._orchestrator.dispose()}},wU=/^bytes=(\d+)-(\d*)$/,TU=e=>{let t=wU.exec(e.trim());if(!t)return null;let n=Number(t[1]),r=t[2]===``?null:Number(t[2]);return r!==null&&r<n?null:{offset:n,length:r===null?null:r-n+1}},EU=class extends mU{constructor(e,t={}){if(!(e instanceof ReadableStream))throw TypeError(`stream must be a ReadableStream.`);if(!t||typeof t!=`object`)throw TypeError(`options must be an object.`);if(t.maxCacheSize!==void 0&&(!VR(t.maxCacheSize)||t.maxCacheSize<0))throw TypeError(`options.maxCacheSize, when provided, must be a non-negative number.`);super(),this._reader=null,this._cache=[],this._pendingSlices=[],this._currentIndex=0,this._targetIndex=0,this._maxRequestedIndex=0,this._endIndex=null,this._pulling=!1,this._stream=e,this._maxCacheSize=t.maxCacheSize??32*2**20}_getFileSize(){return this._endIndex}_read(e,t){if(this._endIndex!==null&&t>this._endIndex)return null;this._maxRequestedIndex=Math.max(this._maxRequestedIndex,t);let n=QL(this._cache,e,e=>e.start),r=n===-1?null:this._cache[n];if(r&&r.start<=e&&t<=r.end)return{bytes:r.bytes,view:r.view,offset:r.start};let i=e,a=new Uint8Array(t-e);if(n!==-1)for(let r=n;r<this._cache.length;r++){let n=this._cache[r];if(n.start>=t)break;let o=Math.max(e,n.start);o>i&&this._throwDueToCacheMiss();let s=Math.min(t,n.end);o<s&&(a.set(n.bytes.subarray(o-n.start,s-n.start),o-e),i=s)}if(i===t)return{bytes:a,view:PL(a),offset:e};this._currentIndex>i&&this._throwDueToCacheMiss();let{promise:o,resolve:s,reject:c}=eR();return this._pendingSlices.push({start:e,end:t,bytes:a,resolve:s,reject:c}),this._targetIndex=Math.max(this._targetIndex,t),this._pulling||(this._pulling=!0,this._pull().catch(e=>{if(this._pulling=!1,this._pendingSlices.length>0)this._pendingSlices.forEach(t=>t.reject(e)),this._pendingSlices.length=0;else throw e})),o}_throwDueToCacheMiss(){throw Error(`Read is before the cached region. With ReadableStreamSource, you must access the data more sequentially or increase the size of its cache.`)}async _pull(){for(this._reader??=this._stream.getReader();this._currentIndex<this._targetIndex&&!this._disposed;){let{done:e,value:t}=await this._reader.read();if(e){for(let e of this._pendingSlices)e.resolve(null);this._pendingSlices.length=0,this._endIndex=this._currentIndex;break}let n=this._currentIndex,r=this._currentIndex+t.byteLength;this._dispatchRead(n,r);for(let e=0;e<this._pendingSlices.length;e++){let i=this._pendingSlices[e],a=Math.max(n,i.start),o=Math.min(r,i.end);a<o&&(i.bytes.set(t.subarray(a-n,o-n),a-i.start),o===i.end&&(i.resolve({bytes:i.bytes,view:PL(i.bytes),offset:i.start}),this._pendingSlices.splice(e,1),e--))}for(this._cache.push({start:n,end:r,bytes:t,view:PL(t),age:0});this._cache.length>0;){let e=this._cache[0];if(this._maxRequestedIndex-e.end<=this._maxCacheSize)break;this._cache.shift()}this._currentIndex+=t.byteLength}this._pulling=!1}_dispose(){this._pendingSlices.length=0,this._cache.length=0,this._reader?.cancel()}},DU={none:(e,t)=>({start:e,end:t}),fileSystem:(e,t)=>{let n=2**16;return e=Math.floor((e-n)/n)*n,t=Math.ceil((t+n)/n)*n,{start:e,end:t}},network:(e,t,n)=>{let r=2**16;e=Math.max(0,Math.floor((e-r)/r)*r);for(let r of n){let n=8*2**20,i=Math.max((r.startPos+r.targetPos)/2,r.targetPos-n);if(IR(e,t,i,r.targetPos)){let e=r.targetPos-r.startPos,i=Math.ceil((e+1)/n)*n,a=2**Math.ceil(Math.log2(e+1)),o=Math.min(a,i);t=Math.max(t,r.startPos+o)}}return t=Math.max(t,e+bU),{start:e,end:t}}},OU=class{constructor(e){this.options=e,this.fileSize=null,this.nextAge=0,this.workers=[],this.cache=[],this.currentCacheSize=0,this.disposed=!1,this.queuedReads=[]}read(e,t,n,r){X(!this.disposed);let i=this.options.prefetchProfile(e,t,this.workers),a=Math.max(i.start,n),o=Math.min(i.end,this.fileSize??1/0,r);X(a<=e&&t<=o);let s=null,c=QL(this.cache,e,e=>e.start),l=c===-1?null:this.cache[c];l&&l.start<=e&&t<=l.end&&(l.age=this.nextAge++,s={bytes:l.bytes,view:l.view,offset:l.start});let u=QL(this.cache,a,e=>e.start),d=s?null:new Uint8Array(t-e),f=0,p=a,m=[];if(u!==-1){for(let n=u;n<this.cache.length;n++){let r=this.cache[n];if(r.start>=o)break;if(r.end<=a)continue;let i=Math.max(a,r.start),s=Math.min(o,r.end);if(X(i<=s),p<i&&m.push({start:p,end:i}),p=s,d){let n=Math.max(e,r.start),i=Math.min(t,r.end);if(n<i){let t=n-e;d.set(r.bytes.subarray(n-r.start,i-r.start),t),t===f&&(f=i-e)}}r.age=this.nextAge++}p<o&&m.push({start:p,end:o})}else m.push({start:a,end:o});if(d&&f>=d.length&&(s={bytes:d,view:PL(d),offset:e}),m.length===0)return X(s),s;let{promise:h,resolve:g,reject:_}=eR(),v=[];for(let n of m){let r=Math.max(e,n.start),i=Math.min(t,n.end);r===n.start&&i===n.end?v.push(n):r<i&&v.push({start:r,end:i})}let y=d&&{start:e,bytes:d,holes:v,resolve:g,reject:_};outer:for(let e of m){for(let t of this.workers)if(this.checkHoleAgainstWorker(t,e,y?[y]:[])){this.checkQueuedReadsAgainstWorker(t);continue outer}let t=e.end<o||this.fileSize!==null,n=this.createWorker(e.start,e.end,t);if(n)y&&(n.pendingSlices=[y]),this.runWorker(n);else{let n=QL(this.queuedReads,e.start,e=>e.hole.start),r=n===-1?null:this.queuedReads[n];for(r&&e.start<=r.hole.end?(r.hole.end=Math.max(r.hole.end,e.end),r.strictTarget&&=t,y&&r.pendingSlices.push(y)):(n++,r={hole:{start:e.start,end:e.end},strictTarget:t,pendingSlices:y?[y]:[],age:this.nextAge++},this.queuedReads.splice(n,0,r));n+1<this.queuedReads.length;){let e=this.queuedReads[n+1];if(e.hole.start>r.hole.end)break;r.hole.end=Math.max(r.hole.end,e.hole.end),r.pendingSlices.push(...e.pendingSlices),r.strictTarget&&=e.strictTarget,r.age=Math.min(r.age,e.age),this.queuedReads.splice(n+1,1)}}}return s||=(X(d),h.then(t=>t&&{bytes:t,view:PL(t),offset:e})),s}checkHoleAgainstWorker(e,t,n){if(IR(t.start-2**17,t.start,e.currentPos,e.targetPos)){e.targetPos=Math.max(e.targetPos,t.end);for(let t=0;t<n.length;t++){let r=n[t];e.pendingSlices.includes(r)||e.pendingSlices.push(r)}return e.running||this.runWorker(e),!0}return!1}checkQueuedReadsAgainstWorker(e){let t=!1;for(let n=0;n<this.queuedReads.length;n++){let r=this.queuedReads[n];if(this.checkHoleAgainstWorker(e,r.hole,r.pendingSlices))this.queuedReads.splice(n,1),n--,t=!0;else if(t)break}}createWorker(e,t,n){if(this.workers.length>=this.options.maxWorkerCount){let e=null,t=null;for(let n=0;n<this.workers.length;n++){let r=this.workers[n];!r.running&&r.pendingSlices.length===0&&(!e||r.age<e.age)&&(t=n,e=r)}if(e)X(t!==null),X(e.pendingSlices.length===0),this.workers.splice(t,1);else return null}let r={startPos:e,currentPos:e,targetPos:t,strictTarget:n,running:!1,aborted:this.disposed,pendingSlices:[],age:this.nextAge++};return this.workers.push(r),r}runWorker(e){X(!e.running),X(e.currentPos<e.targetPos),e.running=!0,e.age=this.nextAge++,this.options.runWorker(e).catch(t=>{if(e.running=!1,e.pendingSlices.length>0)e.pendingSlices.forEach(e=>e.reject(t)),e.pendingSlices.length=0;else throw t}).finally(()=>{if(!e.running&&this.queuedReads.length>0){let e=0;for(let t=1;t<this.queuedReads.length;t++)this.queuedReads[t].age<this.queuedReads[e].age&&(e=t);let t=this.queuedReads[e];this.queuedReads.splice(e,1);let n=this.createWorker(t.hole.start,t.hole.end,t.strictTarget);X(n),n.pendingSlices=t.pendingSlices,this.runWorker(n)}})}consolidateEverythingIntoOneWorker(e){let t=new Set(e.pendingSlices);for(let n=0;n<this.workers.length;n++){let r=this.workers[n];if(r!==e){for(let e of r.pendingSlices)t.add(e);r.aborted=!0,r.pendingSlices.length=0,this.workers.splice(n,1),n--}}for(let e=0;e<this.queuedReads.length;e++){let n=this.queuedReads[e];for(let e of n.pendingSlices)t.add(e)}e.pendingSlices=[...t],this.queuedReads.length=0}supplyWorkerData(e,t){X(!e.aborted);let n=e.currentPos,r=n+t.length;this.insertIntoCache({start:n,end:r,bytes:t,view:PL(t),age:this.nextAge++}),e.currentPos+=t.length,e.currentPos>e.targetPos&&(e.targetPos=e.currentPos,this.checkQueuedReadsAgainstWorker(e));for(let i=0;i<e.pendingSlices.length;i++){let a=e.pendingSlices[i],o=Math.max(n,a.start),s=Math.min(r,a.start+a.bytes.length);o<s&&a.bytes.set(t.subarray(o-n,s-n),o-a.start);for(let e=0;e<a.holes.length;e++){let t=a.holes[e];n<=t.start&&r>t.start&&(t.start=r),t.end<=t.start&&(a.holes.splice(e,1),e--)}a.holes.length===0&&(a.resolve(a.bytes),e.pendingSlices.splice(i,1),i--)}for(let t=0;t<this.workers.length;t++){let i=this.workers[t];e===i||i.running||IR(n,r,i.currentPos,i.targetPos)&&(this.workers.splice(t,1),t--)}}supplyFileSize(e){X(this.fileSize===null),this.fileSize=e;for(let t of this.workers){t.targetPos=Math.min(t.targetPos,e),t.strictTarget=!0;for(let n=0;n<t.pendingSlices.length;n++){let r=t.pendingSlices[n];for(let i of r.holes)if(i.end>e){r.resolve(null),t.pendingSlices.splice(n,1),n--;break}}}for(let t=0;t<this.queuedReads.length;t++){let n=this.queuedReads[t];if(n.hole.start>=e){for(let e of n.pendingSlices)e.resolve(null);this.queuedReads.splice(t,1),t--}else if(n.hole.end>e){n.hole.end=e,n.strictTarget=!0;for(let t=0;t<n.pendingSlices.length;t++){let r=n.pendingSlices[t];r.start>=e&&(r.resolve(null),n.pendingSlices.splice(t,1),t--)}}}}signalWorkerStoppedRunning(e){e.running=!1,e.pendingSlices.length=0}onWorkerFinished(e){let t=this.workers.indexOf(e);X(t!==-1),e.running=!1,this.workers.splice(t,1),this.fileSize===null&&this.supplyFileSize(e.currentPos);for(let t of e.pendingSlices)t.resolve(null)}insertIntoCache(e){if(this.options.maxCacheSize===0)return;let t=QL(this.cache,e.start,e=>e.start)+1;if(t>0){let n=this.cache[t-1];if(n.end>=e.end)return;if(n.end>e.start){let r=new Uint8Array(e.end-n.start);r.set(n.bytes,0),r.set(e.bytes,e.start-n.start),this.currentCacheSize+=e.end-n.end,n.bytes=r,n.view=PL(r),n.end=e.end,t--,e=n}else this.cache.splice(t,0,e),this.currentCacheSize+=e.bytes.length}else this.cache.splice(t,0,e),this.currentCacheSize+=e.bytes.length;for(let n=t+1;n<this.cache.length;n++){let t=this.cache[n];if(e.end<=t.start)break;if(e.end>=t.end){this.cache.splice(n,1),this.currentCacheSize-=t.bytes.length,n--;continue}let r=new Uint8Array(t.end-e.start);r.set(e.bytes,0),r.set(t.bytes,t.start-e.start),this.currentCacheSize-=e.end-t.start,e.bytes=r,e.view=PL(r),e.end=t.end,this.cache.splice(n,1);break}for(;this.currentCacheSize>this.options.maxCacheSize;){let e=0,t=this.cache[0];for(let n=1;n<this.cache.length;n++){let r=this.cache[n];r.age<t.age&&(e=n,t=r)}if(this.currentCacheSize-t.bytes.length<=this.options.maxCacheSize)break;this.cache.splice(e,1),this.currentCacheSize-=t.bytes.length}}dispose(){for(let e of this.workers)e.aborted=!0;this.workers.length=0,this.cache.length=0,this.disposed=!0}},kU=class extends mU{constructor(e,t,n){if(super(),this._ref=null,e._disposed)throw Error(`Cannot create a slice of a disposed source.`);this._baseSource=e,this._offset=t,this._length=n??null}_getFileSize(){let e=this._baseSource._getFileSize();return e===void 0?this._length===null?void 0:this._length:e===null?this._length===null?null:this._length:fR(e-this._offset,0,this._length??1/0)}_read(e,t,n,r){if(this._length!==null&&t>this._length)return null;let i=this._baseSource._read(this._offset+e,this._offset+t,this._offset+n,this._offset+r),a=e=>e?(e.offset-=this._offset,e):null;return i instanceof Promise?i.then(a):a(i)}_dispose(){this._ref?.free()}ref(){return this._ref??=this._baseSource.ref(),super.ref()}},AU=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},jU=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r}),MU=/^0[xX][0-9a-fA-F]+$/,NU=/^data:.*;base64,/i,PU=class extends cU{constructor(e,t,n,r){super(e.input,t,n),this.segments=[],this.nextLines=null,this.currentUpdateSegmentsPromise=null,this.streamHasEnded=!1,this.lastSegmentUpdateTime=-1/0,this.refreshInterval=5,this.demuxer=e,this.nextLines=r}runUpdateSegments(){return this.currentUpdateSegmentsPromise??=(async()=>{try{let e=this.getRemainingWaitTimeMs();e>0&&await qR(e),this.lastSegmentUpdateTime=performance.now(),await this.updateSegments()}finally{this.currentUpdateSegmentsPromise=null}})()}getRemainingWaitTimeMs(){let e=performance.now()-this.lastSegmentUpdateTime,t=Math.max(0,1e3*this.refreshInterval-e);return t<=50?0:t}async updateSegments(){let e=this.nextLines;if(this.nextLines=null,!e){let t={stack:[],error:void 0,hasError:!1};try{let n=await new IG(AU(t,await this.demuxer.input._getSourceUncached({path:this.path,isRoot:!1}),!1).source).requestEntireFile();X(n),e=nK(n,n.length,{ignore:oU})}catch(e){t.error=e,t.hasError=!0}finally{jU(t)}}let t=!1,n=0,r=null,i=null,a=0,o=null,s=null,c=null,l=null,u=null,d=null,f=!1,p=AL(this.segments)??null,m=e=>{let t=e.indexOf(`@`),n=Number(t===-1?e:e.slice(0,t));if(!Number.isInteger(n)||n<0)throw Error(`Invalid #EXT-X-BYTERANGE length '${e}'.`);let r=null;if(t!==-1&&(r=Number(e.slice(t+1)),!Number.isInteger(r)||r<0))throw Error(`Invalid #EXT-X-BYTERANGE offset '${e}'.`);return{length:n,offset:r}},h=e=>{a=e,p&&(X(p.sequenceNumber!==null),p.sequenceNumber<e&&(n=p.timestamp+p.duration,o=p.firstSegment,s=p.initSegment,u=p.lastProgramDateTimeSeconds,p=null))};for(let g=0;g<e.length;g++){let _=e[g];if(!t){if(_!==`#EXTM3U`)throw Error(`Invalid M3U8 file; expected first line to be #EXTM3U.`);t=!0;continue}if(!_.startsWith(`#`)){if(!p){if(r===null)throw Error(`Invalid M3U8 file; a segment must be preceded by an #EXTINF tag.`);let e=i;if(e&&e.method===`AES-128`&&!e.iv){let t=new Uint8Array(16),n=PL(t);n.setUint32(8,Math.floor(a/2**32)),n.setUint32(12,a),e={...e,iv:t}}let t={path:HR(this.path,_),offset:l?.offset??0,length:l?.length??null},c={timestamp:n,relativeToUnixEpoch:u!==null,firstSegment:o,sequenceNumber:a,location:t,duration:r,encryption:e,initSegment:s,lastProgramDateTimeSeconds:u};o??=c,n+=r,this.segments.push(c)}r=null,l===null?c=null:l=null,h(a+1)}if(_.startsWith(`#EXTINF:`)){if(p){f=!0;continue}f||=(u===null&&a>0&&d!==null&&(n=a*d),!0);let e=_.slice($H.length),t=e.indexOf(`,`),i=t===-1?e:e.slice(0,t),o=Number(i);if(!Number.isFinite(o)||o<0)throw Error(`Invalid #EXTINF tag duration '${i}'.`);r=o}else if(_.startsWith(`#EXT-X-MAP:`)){let e=new sU(_.slice(eU.length)),t=e.get(`uri`);if(!t)throw Error(`Invalid #EXT-X-MAP tag; missing URI attribute.`);let a=e.get(`byterange`),o=null;if(a!==null&&(o=m(a)),o&&o.offset===null)throw Error(`Invalid #EXT-X-MAP tag; BYTERANGE attribute must have a specified offset.`);if(!p){let e={path:HR(this.path,t),offset:o?.offset??0,length:o?.length??null};if(i?.method===`AES-128`&&!i.iv)throw Error(`IV attribute must be set on #EXT-X-KEY tag preceding the #EXT-X-MAP tag.`);s={timestamp:n,relativeToUnixEpoch:u!==null,firstSegment:null,sequenceNumber:null,location:e,duration:0,encryption:i,initSegment:null,lastProgramDateTimeSeconds:u}}r=null,l===null?c=null:l=null}else if(_.startsWith(`#EXT-X-KEY:`)){let e=new sU(_.slice(tU.length)),t=e.get(`method`);if(t===`NONE`)i=null;else if(t===`AES-128`){let t=e.get(`uri`);if(!t)throw Error(`Invalid #EXT-X-KEY: AES-128 requires a URI attribute.`);let n=null,r=e.get(`iv`);if(r){if(!MU.test(r))throw Error(`Unsupported IV format '${r}'.`);let e=r.slice(2);e=e.padStart(32,`0`),n=new Uint8Array(16);for(let t=0;t<16;t++){let r=-32+t;n[t]=parseInt(e.slice(r,r+2),16)}}let a=e.get(`keyformat`)??`identity`;if(a!==`identity`)throw Error(`For AES-128 encryption, only the 'identity' KEYFORMAT is currently supported. If you think other formats should be supported, please raise an issue.`);i={method:`AES-128`,keyUri:HR(this.path,t),iv:n,keyFormat:a}}else if(t===`SAMPLE-AES`||t===`SAMPLE-AES-CTR`){let n=e.get(`uri`);if(!n)throw Error(`Invalid #EXT-X-KEY: ${t} requires a URI attribute.`);if((e.get(`keyformat`)??`identity`)===`identity`)throw Error(`For SAMPLE-AES and SAMPLE-AES-CTR encryption, the 'identity' KEYFORMAT is not supported. If you think this format should be supported, please raise an issue.`);let r=null;if(NU.test(n)){let e=n.indexOf(`,`),t=RR(n.slice(e+1));if(t.length>=8&&t[4]===112&&t[5]===115&&t[6]===115&&t[7]===104){let e=PL(t).getUint32(0);r=XB(t.subarray(8,Math.min(e,t.length)))}}i={method:t,psshBox:r}}else throw Error(`Unsupported encryption method '${t}'. If you think this method should be supported, please raise an issue.`)}else if(_.startsWith(`#EXT-X-MEDIA-SEQUENCE:`)){let e=_.slice(nU.length),t=Number(e);if(!Number.isInteger(t)||t<0)throw Error(`Invalid EXT-X-MEDIA-SEQUENCE value '${e}'.`);h(t)}else if(_.startsWith(`#EXT-X-BYTERANGE:`)){let e=m(_.slice(rU.length));if(e.offset===null){if(c===null)throw Error(`Invalid M3U8 file; #EXT-X-BYTERANGE without offset requires a previous byte range.`);e.offset=c}l=e,c=e.offset+e.length}else if(_.startsWith(`#EXT-X-PROGRAM-DATE-TIME:`)){if(p)continue;let e=_.slice(iU.length),t=Date.parse(e);if(!Number.isFinite(t))continue;let r=t/1e3;if(u===r)continue;if(u===null&&this.segments.length>0){let e=AL(this.segments),t=r-(e.timestamp+e.duration);for(let e of this.segments)e.timestamp+=t,e.relativeToUnixEpoch=!0;n+=t}u=r,n=r}else if(_===`#EXT-X-DISCONTINUITY`)o=null;else if(_.startsWith(`#EXT-X-TARGETDURATION:`)){let e=_.slice(aU.length),t=Number(e);if(!Number.isFinite(t)||t<0)throw Error(`Invalid EXT-X-TARGETDURATION value '${e}'.`);this.refreshInterval=t,d=t}else if(_===`#EXT-X-ENDLIST`){this.streamHasEnded=!0;break}else _.startsWith(`#EXT-X-PLAYLIST-TYPE:`)&&_.slice(21).toLowerCase()===`vod`&&(this.streamHasEnded=!0)}if(!t)throw Error(`Invalid M3U8 file; no #EXTM3U header.`)}async getFirstSegment(){return this.segments.length===0&&await this.runUpdateSegments(),this.segments[0]??null}async getSegmentAt(e,t){this.segments.length===0&&await this.runUpdateSegments();let n=!!t.skipLiveWait&&this.getRemainingWaitTimeMs()>0;for(;;){let r=QL(this.segments,e,e=>e.timestamp);if(r===-1)return null;if(r<this.segments.length-1||this.streamHasEnded||n)return this.segments[r];let i=this.segments[r];if(e<i.timestamp+i.duration)return i;await this.runUpdateSegments(),t.skipLiveWait&&(n=!0)}}async getNextSegment(e,t){let n=this.segments.indexOf(e);X(n!==-1);let r=n+1,i=!!t.skipLiveWait&&this.getRemainingWaitTimeMs()>0;for(;;){if(r<this.segments.length)return this.segments[r];if(this.streamHasEnded||i)return null;await this.runUpdateSegments(),t.skipLiveWait&&(i=!0)}}async getPreviousSegment(e){let t=this.segments.indexOf(e);return X(t!==-1),this.segments[t-1]??null}getInputForSegment(e){let t=e,n=this.inputCache.find(e=>e.segment===t);if(n)return n.age=this.nextInputCacheAge++,n.input;let r=null;(t.initSegment||t.firstSegment)&&(r=this.getInputForSegment(t.initSegment??t.firstSegment));let i={...this.input._formatOptions,isobmff:{...this.input._formatOptions.isobmff,resolveKeyId:this.input._formatOptions.isobmff?.resolveKeyId&&(e=>{if(!t.encryption||!(t.encryption.method===`SAMPLE-AES`||t.encryption.method===`SAMPLE-AES-CTR`)||!t.encryption.psshBox)return this.input._formatOptions.isobmff.resolveKeyId(e);let n=e.psshBoxes,{psshBox:r}=t.encryption;return(r.keyIds===null||r.keyIds.includes(e.keyId))&&!n.some(e=>ZB(e,r))&&(n=[...n,r]),this.input._formatOptions.isobmff.resolveKeyId({...e,psshBoxes:n})})}},a=new NG({source:new vU(t.location.path,async e=>{X(e.isRoot);let n={...e,isRoot:!1},r,i=t.location.offset>0||t.location.length!==null;if(!t.encryption||t.encryption.method===`SAMPLE-AES`||t.encryption.method===`SAMPLE-AES-CTR`){if(r=await this.input._getSourceCached(n),i){let e=r.source.slice(t.location.offset,t.location.length??void 0).ref();r.free(),r=e}}else if(t.encryption.method===`AES-128`){let e=t.encryption;X(e.iv);let a=await this.input._getSourceCached(n);if(i){let e=a.source.slice(t.location.offset,t.location.length??void 0).ref();a.free(),a=e}r=new EU(mV(new IG(a.source),async()=>{let t={stack:[],error:void 0,hasError:!1};try{let n=await new IG(AU(t,await this.input._getSourceCached({path:e.keyUri,isRoot:!1},2),!1).source).requestSlice(0,16);if(!n)throw Error(`Invalid AES-128 key; expected at least 16 bytes of data.`);return{key:zG(n,16),iv:e.iv}}catch(e){t.error=e,t.hasError=!0}finally{jU(t)}},()=>{a.free()})).ref()}else X(!1);return r}),formats:this.input._formats.filter(e=>!(e instanceof eW)),initInput:r??void 0,formatOptions:i});if(a._onFormatDetermined=e=>{if((t.encryption?.method===`SAMPLE-AES`||t.encryption?.method===`SAMPLE-AES-CTR`)&&!e._isIsobmff)throw Error(`The SAMPLE-AES and SAMPLE-AES-CTR encryption methods are currently only supported for ISOBMFF files.`)},this.inputCache.push({segment:t,input:a,age:this.nextInputCacheAge++}),this.inputCache.length>4){let e=WR(this.inputCache,e=>e.age);X(e!==-1),this.inputCache.splice(e,1)}return a}async getLiveRefreshInterval(){return this.getRemainingWaitTimeMs()===0&&await this.runUpdateSegments(),this.streamHasEnded?null:this.refreshInterval}},FU=class extends KB{constructor(e){super(e),this.metadataPromise=null,this.trackBackings=null,this.internalTracks=null,this.segmentedInputs=[],this.hasMasterPlaylist=!0}readMetadata(){return this.metadataPromise??=(async()=>{X(this.input._rootSource instanceof gU);let{rootPath:e}=this.input._rootSource,t=await this.input._reader.requestEntireFile();X(t);let n=nK(t,t.length,{ignore:oU}),r=[],i=[];for(let t=1;t<n.length;t++){let a=n[t];if(a.startsWith(`#EXT-X-STREAM-INF:`)){let i=t,o=n[++t];if(o===void 0)throw Error(`Incorrect M3U8 file; a line must follow the #EXT-X-STREAM-INF tag.`);let s=HR(e,o),c=new sU(a.slice(XH.length));if(c.getAsNumber(`bandwidth`)===null)throw Error(`Invalid M3U8 file; #EXT-X-STREAM-INF tag requires a BANDWIDTH attribute with a valid numerical value.`);r.push({fullPath:s,attributes:c,lineNumber:i,hasOnlyKeyPackets:!1})}else if(a.startsWith(`#EXT-X-I-FRAME-STREAM-INF:`)){let n=new sU(a.slice(ZH.length)),i=n.get(`uri`);if(i===null)throw Error(`Invalid M3U8 file; #EXT-X-I-FRAME-STREAM-INF tag requires a URI attribute.`);if(n.getAsNumber(`bandwidth`)===null)throw Error(`Invalid M3U8 file; #EXT-X-I-FRAME-STREAM-INF tag requires a BANDWIDTH attribute with a valid numerical value.`);let o=HR(e,i);r.push({fullPath:o,attributes:n,lineNumber:t,hasOnlyKeyPackets:!0})}else if(a.startsWith(`#EXT-X-MEDIA:`)){let n=new sU(a.slice(QH.length));if(n.get(`type`)===null)throw Error(`Invalid M3U8 file; #EXT-X-MEDIA tag requires a TYPE attribute.`);if(n.get(`group-id`)===null)throw Error(`Invalid M3U8 file; #EXT-X-MEDIA tag requires a GROUP-ID attribute.`);let r=null,o=n.get(`uri`);o!==null&&(r=HR(e,o)),i.push({fullPath:r,attributes:n,lineNumber:t})}else if(a!==`#EXT-X-I-FRAMES-ONLY`&&a.startsWith(`#EXTINF:`)){let t=new PU(this,e,null,n);this.segmentedInputs=[t],this.hasMasterPlaylist=!1,this.trackBackings=await t.getTrackBackings();return}}let a=[...new Set(i.filter(e=>e.attributes.get(`type`).toLowerCase()===`video`).map(e=>e.attributes.get(`group-id`)))],o=[...new Set(i.filter(e=>e.attributes.get(`type`).toLowerCase()===`audio`).map(e=>e.attributes.get(`group-id`)))],s=await Promise.all(r.map(async(t,n)=>{let r=[],s=t.attributes.get(`codecs`),c;if(s)c=s.split(`,`).map(e=>e.trim());else{let e=await this.getSegmentedInputForPath(t.fullPath).getTrackBackings(),n=await Promise.all(e.map(async e=>({track:e,codec:await e.getCodec()})));c=await Promise.all(n.filter(e=>e.codec!==null).map(e=>e.track.getDecoderConfig().then(e=>e.codec)))}let l=t.attributes.get(`video`),u=t.attributes.get(`audio`),d=c.some(e=>sz.includes(Ez(e))),f=c.some(e=>uz.includes(Ez(e)));if(l!==null&&!d){if(!a.includes(l))throw Error(`Invalid M3U8 file; variant stream references video group "${l}" which is not defined in any #EXT-X-MEDIA tags.`);let t=i.find(e=>{let t=e.attributes.get(`group-id`),n=e.attributes.get(`type`);return t===l&&n.toLowerCase()===`video`});outer:if(t){let n=t.attributes.get(`uri`);if(n===null)break outer;let r=HR(e,n),i=(await this.getSegmentedInputForPath(r).getTrackBackings()).find(e=>e.getType()===`video`);if(!i||await i.getCodec()===null)break outer;let a=await i.getDecoderConfig().then(e=>e?.codec??null);X(a!==null),c.push(a)}}if(u!==null&&!f){if(!o.includes(u))throw Error(`Invalid M3U8 file; variant stream references audio group "${u}" which is not defined in any #EXT-X-MEDIA tags.`);let t=i.find(e=>{let t=e.attributes.get(`group-id`),n=e.attributes.get(`type`);return t===u&&n.toLowerCase()===`audio`});outer:if(t){let n=t.attributes.get(`uri`);if(n===null)break outer;let r=HR(e,n),i=(await this.getSegmentedInputForPath(r).getTrackBackings()).find(e=>e.getType()===`audio`);if(!i||await i.getCodec()===null)break outer;let a=await i.getDecoderConfig().then(e=>e?.codec??null);X(a!==null),c.push(a)}}c=[...new Set(c)];let p=null,m=null,h=t.attributes.getAsNumber(`bandwidth`);X(h!==null);let g=t.attributes.getAsNumber(`average-bandwidth`),_=t.attributes.get(`name`);for(let e of c){let s=Ez(e);if(s!==null){if(sz.includes(s)){if(p!==null)throw Error(`Unsupported M3U8 file; multiple video codecs found in the CODECS attribute of a variant stream.`);p=e;let o=t.attributes.get(`video`);if(o===null){let e=t.attributes.get(`resolution`),i=null,a=null;if(e){let t=e.match(/^(\d+)x(\d+)$/);t&&(i=Number(t[1]),a=Number(t[2]))}r.push({id:-1,demuxer:this,backingTrack:null,default:!0,autoselect:!0,languageCode:`und`,lineNumber:t.lineNumber,fullPath:t.fullPath,fullCodecString:p,pairingMask:1n<<BigInt(n),peakBitrate:h,averageBitrate:g,name:_,hasOnlyKeyPackets:t.hasOnlyKeyPackets,info:{type:`video`,width:i,height:a}})}else{if(!a.includes(o))throw Error(`Invalid M3U8 file; variant stream references video group "${o}" which is not defined in any #EXT-X-MEDIA tags.`);for(let e of i){let i=e.attributes.get(`group-id`),a=e.attributes.get(`type`);if(i!==o||a.toLowerCase()!==`video`)continue;let s=e.attributes.get(`resolution`)??t.attributes.get(`resolution`),c=null,l=null;if(s){let e=s.match(/^(\d+)x(\d+)$/);e&&(c=Number(e[1]),l=Number(e[2]))}r.push({id:-1,demuxer:this,backingTrack:null,default:zU(e.attributes),autoselect:zU(e.attributes)||BU(e.attributes),languageCode:VU(e.attributes.get(`language`)),lineNumber:e.lineNumber,fullPath:e.fullPath??t.fullPath,fullCodecString:p,pairingMask:1n<<BigInt(n),peakBitrate:null,averageBitrate:null,name:e.attributes.get(`name`),hasOnlyKeyPackets:t.hasOnlyKeyPackets,info:{type:`video`,width:c,height:l}})}}}else if(uz.includes(s)){if(m!==null)throw Error(`Unsupported M3U8 file; multiple audio codecs found in the CODECS attribute of a variant stream.`);m=e;let a=t.attributes.get(`audio`);if(a===null){let e=t.attributes.get(`channels`),i=e===null?null:Number(e.split(`/`)[0]);r.push({id:-1,demuxer:this,backingTrack:null,default:!0,autoselect:!0,languageCode:`und`,lineNumber:t.lineNumber,fullPath:t.fullPath,fullCodecString:m,pairingMask:1n<<BigInt(n),peakBitrate:h,averageBitrate:g,name:_,hasOnlyKeyPackets:t.hasOnlyKeyPackets,info:{type:`audio`,numberOfChannels:i!==null&&Number.isInteger(i)&&i>0?i:null}})}else{if(!o.includes(a))throw Error(`Invalid M3U8 file; variant stream references audio group "${a}" which is not defined in any #EXT-X-MEDIA tags.`);for(let e of i){let i=e.attributes.get(`group-id`),o=e.attributes.get(`type`);if(i!==a||o.toLowerCase()!==`audio`)continue;let s=e.attributes.get(`channels`)??t.attributes.get(`channels`),c=s===null?null:Number(s.split(`/`)[0]);r.push({id:-1,demuxer:this,backingTrack:null,default:zU(e.attributes),autoselect:zU(e.attributes)||BU(e.attributes),languageCode:VU(e.attributes.get(`language`)),lineNumber:e.lineNumber,fullPath:e.fullPath??t.fullPath,fullCodecString:m,pairingMask:1n<<BigInt(n),peakBitrate:null,averageBitrate:null,name:e.attributes.get(`name`),hasOnlyKeyPackets:t.hasOnlyKeyPackets,info:{type:`audio`,numberOfChannels:c!==null&&Number.isInteger(c)&&c>0?c:null}})}}}}}return r})),c=[],l=e=>{let t=c.find(t=>t.fullPath===e.fullPath&&t.info.type===e.info.type);t?(t.pairingMask|=e.pairingMask,t.default||=e.default,t.autoselect||=e.autoselect,t.lineNumber=Math.min(t.lineNumber,e.lineNumber),e.peakBitrate!==null&&(t.peakBitrate=Math.max(t.peakBitrate??-1/0,e.peakBitrate)),e.averageBitrate!==null&&(t.averageBitrate=Math.max(t.averageBitrate??-1/0,e.averageBitrate)),t.languageCode===`und`&&(t.languageCode=e.languageCode)):(e.id=c.length+1,c.push(e))};for(let e of s)for(let t of e)l(t);c.sort((e,t)=>e.lineNumber-t.lineNumber),this.trackBackings=[];for(let e of c)e.info.type===`video`?this.trackBackings.push(new LU(e)):this.trackBackings.push(new RU(e));this.internalTracks=c})()}async getTrackBackings(){return await this.readMetadata(),X(this.trackBackings),this.trackBackings}getSegmentedInputForPath(e){let t=this.segmentedInputs.find(t=>t.path===e);if(t)return t;let n=null;return this.internalTracks&&(n=this.internalTracks.filter(t=>t.fullPath===e).map(e=>({id:e.id,type:e.info.type}))),t=new PU(this,e,n,null),this.segmentedInputs.push(t),t}async getMetadataTags(){return{}}async getMimeType(){return YH}dispose(){if(this.segmentedInputs){for(let e of this.segmentedInputs)e.dispose();this.segmentedInputs.length=0}}},IU=class{constructor(e){this.internalTrack=e,this.hydrationPromise=null}hydrate(){return this.hydrationPromise??=(async()=>{let e=this.internalTrack.demuxer.getSegmentedInputForPath(this.internalTrack.fullPath),t=null,n=(await e.getTrackBackings()).filter(e=>e.getType()===this.getType());if(n.length===1)t=n[0];else if(this instanceof LU){for(let e of n)if(await e.getCodec()===this.getCodec()){t=e;break}}else{X(this instanceof RU);for(let e of n)if(await e.getCodec()===this.getCodec()){t=e;break}}if(!t)throw Error(`Could not find matching track in underlying media data.`);this.internalTrack.backingTrack=t})()}delegate(e){return this.internalTrack.backingTrack?e():this.hydrate().then(e)}getCodec(){throw Error(`Not implemented on base class.`)}getDisposition(){return{...ez,default:this.internalTrack.autoselect,primary:this.internalTrack.default}}getId(){return this.internalTrack.id}getPairingMask(){return this.internalTrack.pairingMask}getInternalCodecId(){return null}getLanguageCode(){return this.internalTrack.languageCode}getName(){return this.internalTrack.name}getNumber(){X(this.internalTrack.demuxer.internalTracks);let e=this.internalTrack.info.type,t=0;for(let n of this.internalTrack.demuxer.internalTracks)if(n.info.type===e&&t++,n===this.internalTrack)break;return t}getTimeResolution(){return this.delegate(()=>this.internalTrack.backingTrack.getTimeResolution())}isRelativeToUnixEpoch(){return this.delegate(()=>this.internalTrack.backingTrack.isRelativeToUnixEpoch())}getBitrate(){return this.internalTrack.peakBitrate}getAverageBitrate(){return this.internalTrack.averageBitrate}async getDurationFromMetadata(e){return await this.hydrate(),this.internalTrack.backingTrack.getDurationFromMetadata(e)}async getLiveRefreshInterval(){return await this.hydrate(),this.internalTrack.backingTrack.getLiveRefreshInterval()}getHasOnlyKeyPackets(){return this.internalTrack.hasOnlyKeyPackets||null}async getFirstPacket(e){return await this.hydrate(),this.internalTrack.backingTrack.getFirstPacket(e)}async getPacket(e,t){return await this.hydrate(),this.internalTrack.backingTrack.getPacket(e,t)}async getKeyPacket(e,t){return await this.hydrate(),this.internalTrack.backingTrack.getKeyPacket(e,t)}async getNextPacket(e,t){return await this.hydrate(),this.internalTrack.backingTrack.getNextPacket(e,t)}async getNextKeyPacket(e,t){return await this.hydrate(),this.internalTrack.backingTrack.getNextKeyPacket(e,t)}},LU=class extends IU{constructor(e){super(e)}get backingVideoTrack(){return this.internalTrack.backingTrack}getType(){return`video`}getCodec(){return Ez(this.internalTrack.fullCodecString)}getCodedWidth(){return this.delegate(()=>this.backingVideoTrack.getCodedWidth())}getCodedHeight(){return this.delegate(()=>this.backingVideoTrack.getCodedHeight())}getSquarePixelWidth(){return this.delegate(()=>this.backingVideoTrack.getSquarePixelWidth())}getSquarePixelHeight(){return this.delegate(()=>this.backingVideoTrack.getSquarePixelHeight())}getMetadataDisplayWidth(){return this.backingVideoTrack?null:this.internalTrack.info.width}getMetadataDisplayHeight(){return this.backingVideoTrack?null:this.internalTrack.info.height}getRotation(){return this.delegate(()=>this.backingVideoTrack.getRotation())}async getColorSpace(){return await this.hydrate(),this.backingVideoTrack.getColorSpace()}async canBeTransparent(){return await this.hydrate(),this.backingVideoTrack.canBeTransparent()}getMetadataCodecParameterString(){return this.backingVideoTrack?null:this.internalTrack.fullCodecString}async getDecoderConfig(){return await this.hydrate(),this.backingVideoTrack.getDecoderConfig()}},RU=class extends IU{constructor(e){super(e)}get backingAudioTrack(){return this.internalTrack.backingTrack}getType(){return`audio`}getCodec(){return Ez(this.internalTrack.fullCodecString)}getNumberOfChannels(){return this.internalTrack.info.numberOfChannels===null?this.delegate(()=>this.backingAudioTrack.getNumberOfChannels()):this.internalTrack.info.numberOfChannels}getSampleRate(){return this.delegate(()=>this.backingAudioTrack.getSampleRate())}getMetadataCodecParameterString(){return this.backingAudioTrack?null:this.internalTrack.fullCodecString}async getDecoderConfig(){return await this.hydrate(),this.backingAudioTrack.getDecoderConfig()}},zU=e=>{let t=e.get(`default`);if(t===null)return!1;let n=t.toUpperCase();if(n===`YES`)return!0;if(n===`NO`)return!1;throw Error(`Invalid M3U8 file; #EXT-X-MEDIA DEFAULT attribute must be YES or NO, got "${t}".`)},BU=e=>{let t=e.get(`autoselect`);if(t===null)return!1;let n=t.toUpperCase();if(n===`YES`)return!0;if(n===`NO`)return!1;throw Error(`Invalid M3U8 file; #EXT-X-MEDIA AUTOSELECT attribute must be YES or NO, got "${t}".`)},VU=e=>e===null?`und`:e.split(`-`)[0]||`und`,HU=class{constructor(){this._isIsobmff=!1}},UU=class extends HU{constructor(){super(...arguments),this._isIsobmff=!0}async _getMajorBrand(e){let t=e._reader.requestSlice(0,12);if(t instanceof Promise&&(t=await t),!t)return null;t.skip(4);let n=tK(t,4);return n!==`ftyp`&&n!==`styp`?null:tK(t,4)}_createDemuxer(e){return new hV(e)}},WU=class extends UU{async _canReadInput(e){let t=await this._getMajorBrand(e);if(t!==null)return t!==`qt `;let n=e._reader.requestSlice(4,4);if(n instanceof Promise&&(n=await n),!n)return!1;let r=tK(n,4);return r===`moof`||r===`sidx`}get name(){return`MP4`}get mimeType(){return`video/mp4`}},GU=class extends UU{async _canReadInput(e){return await this._getMajorBrand(e)===`qt `}get name(){return`QuickTime File Format`}get mimeType(){return`video/quicktime`}},KU=class extends HU{async isSupportedEBMLOfDocType(e,t){let n=e._reader.requestSlice(0,16);if(n instanceof Promise&&(n=await n),!n)return!1;let r=FV(n);if(r===null||r<1||r>8||LV(n,r)!==Q.EBML)return!1;let i=BV(n);if(typeof i!=`number`)return!1;let a=e._reader.requestSlice(n.filePos,i);if(a instanceof Promise&&(a=await a),!a)return!1;let o=n.filePos;for(;a.filePos<=o+i-2;){let e=VV(a);if(!e)break;let{id:n,size:r}=e,i=a.filePos;if(r===void 0)return!1;switch(n){case Q.EBMLVersion:if(LV(a,r)!==1)return!1;break;case Q.EBMLReadVersion:if(LV(a,r)!==1)return!1;break;case Q.DocType:if(HV(a,r)!==t)return!1;break;case Q.DocTypeVersion:if(LV(a,r)>4)return!1;break}a.filePos=i+r}return!0}_canReadInput(e){return this.isSupportedEBMLOfDocType(e,`matroska`)}_createDemuxer(e){return new tH(e)}get name(){return`Matroska`}get mimeType(){return`video/x-matroska`}},qU=class extends KU{_canReadInput(e){return this.isSupportedEBMLOfDocType(e,`webm`)}get name(){return`WebM`}get mimeType(){return`video/webm`}},JU=class extends HU{async _canReadInput(e){let t=0;for(;;){let n=e._reader.requestSlice(t,10);if(n instanceof Promise&&(n=await n),!n)break;let r=cK(n);if(!r)break;t=n.filePos+r.size}let n=await aH(e._reader,t,t+4096);if(!n)return!1;let r=n.header,i=Hz(r.mpegVersionId,r.channel),a=e._reader.requestSlice(n.startPos+i,4);if(a instanceof Promise&&(a=await a),!a)return!1;let o=$(a);if(o===1483304551||o===1231971951)return!0;t=n.startPos+n.header.totalSize;let s=await aH(e._reader,t,t+4);if(!s)return!1;let c=s.header;return!(r.channel!==c.channel||r.sampleRate!==c.sampleRate)}_createDemuxer(e){return new oH(e)}get name(){return`MP3`}get mimeType(){return`audio/mpeg`}},YU=class extends HU{async _canReadInput(e){let t=e._reader.requestSlice(0,12);if(t instanceof Promise&&(t=await t),!t)return!1;let n=tK(t,4);return n!==`RIFF`&&n!==`RIFX`&&n!==`RF64`?!1:(t.skip(4),tK(t,4)===`WAVE`)}_createDemuxer(e){return new xH(e)}get name(){return`WAVE`}get mimeType(){return`audio/wav`}},XU=class extends HU{async _canReadInput(e){let t=e._reader.requestSlice(0,4);return t instanceof Promise&&(t=await t),t?tK(t,4)===`OggS`:!1}_createDemuxer(e){return new gH(e)}get name(){return`Ogg`}get mimeType(){return`application/ogg`}},ZU=class extends HU{async _canReadInput(e){let t=e._reader.requestSlice(0,4);return t instanceof Promise&&(t=await t),t?tK(t,4)===`fLaC`:!1}get name(){return`FLAC`}get mimeType(){return`audio/flac`}_createDemuxer(e){return new PH(e)}},QU=class extends HU{async _canReadInput(e){let t=0;for(;;){let n=e._reader.requestSlice(t,10);if(n instanceof Promise&&(n=await n),!n)break;let r=cK(n);if(!r)break;t=n.filePos+r.size}let n=e._reader.requestSliceRange(t,7,9);if(n instanceof Promise&&(n=await n),!n)return!1;let r=wH(n);if(!r||(t+=r.frameLength,n=e._reader.requestSliceRange(t,7,9),n instanceof Promise&&(n=await n),!n))return!1;let i=wH(n);return i?r.objectType===i.objectType&&r.samplingFrequencyIndex===i.samplingFrequencyIndex&&r.channelConfiguration===i.channelConfiguration:!1}_createDemuxer(e){return new EH(e)}get name(){return`ADTS`}get mimeType(){return`audio/aac`}},$U=class extends HU{async _canReadInput(e){let t=e._reader.requestSlice(0,205);if(t instanceof Promise&&(t=await t),!t)return!1;let n=zG(t,205);return n[0]===71&&n[188]===71||n[0]===71&&n[204]===71?!0:n[4]===71&&n[196]===71}_createDemuxer(e){return new BH(e)}get name(){return`MPEG Transport Stream`}get mimeType(){return`video/MP2T`}},eW=class extends HU{async _canReadInput(e){let t=e._reader.requestSlice(0,7);if(t instanceof Promise&&(t=await t),!t||tK(t,7)!==`#EXTM3U`)return!1;if(!(e._rootSource instanceof gU))throw TypeError("HLS inputs require `InputOptions.source` to be a PathedSource or a ref to one.");return e._rootSource._usedForHls=!0,!0}_createDemuxer(e){return new FU(e)}get name(){return`HTTP Live Streaming (HLS)`}get mimeType(){return YH}},tW=[new eW,new WU,new GU,new KU,new qU,new YU,new XU,new ZU,new JU,new QU,new $U],nW=(e,t)=>{if(!e||typeof e!=`object`)throw TypeError(`${t}, when provided, must be an object.`);if(e.isobmff!==void 0){if(!e.isobmff||typeof e.isobmff!=`object`)throw TypeError(`${t}.isobmff, when provided, must be an object.`);if(e.isobmff.resolveKeyId!==void 0&&typeof e.isobmff.resolveKeyId!=`function`)throw TypeError(`${t}.isobmff.resolveKeyId, when provided, must be a function.`)}},rW=function(e,t,n){if(t!=null){if(typeof t!=`object`&&typeof t!=`function`)throw TypeError(`Object expected.`);var r,i;if(n){if(!Symbol.asyncDispose)throw TypeError(`Symbol.asyncDispose is not defined.`);r=t[Symbol.asyncDispose]}if(r===void 0){if(!Symbol.dispose)throw TypeError(`Symbol.dispose is not defined.`);r=t[Symbol.dispose],n&&(i=r)}if(typeof r!=`function`)throw TypeError(`Object not disposable.`);i&&(r=function(){try{i.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:r,async:n})}else n&&e.stack.push({async:!0});return t},iW=(function(e){return function(t){function n(n){t.error=t.hasError?new e(n,t.error,`An error was suppressed during disposal.`):n,t.hasError=!0}var r,i=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&i===1)return i=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var e=r.dispose.call(r.value);if(r.async)return i|=2,Promise.resolve(e).then(a,function(e){return n(e),a()})}else i|=1}catch(e){n(e)}if(i===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}})(typeof SuppressedError==`function`?SuppressedError:function(e,t,n){var r=Error(n);return r.name=`SuppressedError`,r.error=e,r.suppressed=t,r});BR();var aW=-1/0,oW=-1/0,sW=null;typeof FinalizationRegistry<`u`&&(sW=new FinalizationRegistry(e=>{let t=performance.now();e.type===`video`?(t-aW>=1e3&&(console.error(`A VideoSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your VideoSamples as soon as you're done using them.`),aW=t),typeof VideoFrame<`u`&&e.data instanceof VideoFrame&&e.data.close()):(t-oW>=1e3&&(console.error(`An AudioSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your AudioSamples as soon as you're done using them.`),oW=t),typeof AudioData<`u`&&e.data instanceof AudioData&&e.data.close())}));var cW=class{constructor(){this._referenceCount=0,this._lastAllocationBuffer=null}},lW=[`I420`,`I420P10`,`I420P12`,`I420A`,`I420AP10`,`I420AP12`,`I422`,`I422P10`,`I422P12`,`I422A`,`I422AP10`,`I422AP12`,`I444`,`I444P10`,`I444P12`,`I444A`,`I444AP10`,`I444AP12`,`NV12`,`RGBA`,`RGBX`,`BGRA`,`BGRX`],uW=new Set(lW),dW=class e{get codedWidth(){return this.visibleRect.width}get codedHeight(){return this.visibleRect.height}get displayWidth(){return this.rotation%180==0?this.squarePixelWidth:this.squarePixelHeight}get displayHeight(){return this.rotation%180==0?this.squarePixelHeight:this.squarePixelWidth}get microsecondTimestamp(){return Math.trunc(xR*this.timestamp)}get microsecondDuration(){return Math.trunc(xR*this.duration)}get hasAlpha(){return this.format&&this.format.includes(`A`)}constructor(t,n){if(this._closed=!1,t instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&t instanceof SharedArrayBuffer||ArrayBuffer.isView(t)){if(!n||typeof n!=`object`)throw TypeError(`init must be an object.`);if(n.format===void 0||!uW.has(n.format))throw TypeError(`init.format must be one of: `+lW.join(`, `));if(!Number.isInteger(n.codedWidth)||n.codedWidth<=0)throw TypeError(`init.codedWidth must be a positive integer.`);if(!Number.isInteger(n.codedHeight)||n.codedHeight<=0)throw TypeError(`init.codedHeight must be a positive integer.`);if(n.rotation!==void 0&&![0,90,180,270].includes(n.rotation))throw TypeError(`init.rotation, when provided, must be 0, 90, 180, or 270.`);if(!Number.isFinite(n.timestamp))throw TypeError(`init.timestamp must be a number.`);if(n.duration!==void 0&&(!Number.isFinite(n.duration)||n.duration<0))throw TypeError(`init.duration, when provided, must be a non-negative number.`);if(n.layout!==void 0){if(!Array.isArray(n.layout))throw TypeError(`init.layout, when provided, must be an array.`);for(let e of n.layout){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`Each entry in init.layout must be an object.`);if(!Number.isInteger(e.offset)||e.offset<0)throw TypeError(`plane.offset must be a non-negative integer.`);if(!Number.isInteger(e.stride)||e.stride<0)throw TypeError(`plane.stride must be a non-negative integer.`)}}if(n.visibleRect!==void 0&&KR(n.visibleRect,`init.visibleRect`),n.displayWidth!==void 0&&(!Number.isInteger(n.displayWidth)||n.displayWidth<=0))throw TypeError(`init.displayWidth, when provided, must be a positive integer.`);if(n.displayHeight!==void 0&&(!Number.isInteger(n.displayHeight)||n.displayHeight<=0))throw TypeError(`init.displayHeight, when provided, must be a positive integer.`);if(n.displayWidth!==void 0!=(n.displayHeight!==void 0))throw TypeError(`init.displayWidth and init.displayHeight must be either both provided or both omitted.`);this._data=n._doNotCopy?NL(t):NL(t).slice(),this._layout=n.layout??xW(n.format,n.codedWidth,n.codedHeight),this.format=n.format,this.rotation=n.rotation??0,this.timestamp=n.timestamp,this.duration=n.duration??0;let e=n.colorSpace??null;e===null&&(e=this.format===`RGBA`||this.format===`RGBX`||this.format===`BGRA`||this.format===`BGRX`?{primaries:`bt709`,transfer:`iec61966-2-1`,matrix:`rgb`,fullRange:!0}:{primaries:`bt709`,transfer:`bt709`,matrix:`bt709`,fullRange:!1}),this.colorSpace=new gW(e),this.visibleRect={left:n.visibleRect?.left??0,top:n.visibleRect?.top??0,width:n.visibleRect?.width??n.codedWidth,height:n.visibleRect?.height??n.codedHeight},n.displayWidth===void 0?(this.squarePixelWidth=this.visibleRect.width,this.squarePixelHeight=this.visibleRect.height):(this.squarePixelWidth=this.rotation%180==0?n.displayWidth:n.displayHeight,this.squarePixelHeight=this.rotation%180==0?n.displayHeight:n.displayWidth)}else if(typeof VideoFrame<`u`&&t instanceof VideoFrame){if(n?.rotation!==void 0&&![0,90,180,270].includes(n.rotation))throw TypeError(`init.rotation, when provided, must be 0, 90, 180, or 270.`);if(n?.timestamp!==void 0&&!Number.isFinite(n?.timestamp))throw TypeError(`init.timestamp, when provided, must be a number.`);if(n?.duration!==void 0&&(!Number.isFinite(n.duration)||n.duration<0))throw TypeError(`init.duration, when provided, must be a non-negative number.`);n?.visibleRect!==void 0&&KR(n.visibleRect,`init.visibleRect`),this._data=t,this._layout=null,this.format=t.format,this.visibleRect={left:t.visibleRect?.x??0,top:t.visibleRect?.y??0,width:t.visibleRect?.width??t.codedWidth,height:t.visibleRect?.height??t.codedHeight},this.rotation=n?.rotation??0,this.squarePixelWidth=t.displayWidth,this.squarePixelHeight=t.displayHeight,this.timestamp=n?.timestamp??t.timestamp/1e6,this.duration=n?.duration??(t.duration??0)/1e6,this.colorSpace=new gW(t.colorSpace)}else if(typeof HTMLImageElement<`u`&&t instanceof HTMLImageElement||typeof SVGImageElement<`u`&&t instanceof SVGImageElement||typeof ImageBitmap<`u`&&t instanceof ImageBitmap||typeof HTMLVideoElement<`u`&&t instanceof HTMLVideoElement||typeof HTMLCanvasElement<`u`&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&t instanceof OffscreenCanvas){if(!n||typeof n!=`object`)throw TypeError(`init must be an object.`);if(n.rotation!==void 0&&![0,90,180,270].includes(n.rotation))throw TypeError(`init.rotation, when provided, must be 0, 90, 180, or 270.`);if(!Number.isFinite(n.timestamp))throw TypeError(`init.timestamp must be a number.`);if(n.duration!==void 0&&(!Number.isFinite(n.duration)||n.duration<0))throw TypeError(`init.duration, when provided, must be a non-negative number.`);if(typeof VideoFrame<`u`)return new e(new VideoFrame(t,{timestamp:Math.trunc(n.timestamp*xR),duration:Math.trunc((n.duration??0)*xR)||void 0}),n);let r=0,i=0;if(`naturalWidth`in t?(r=t.naturalWidth,i=t.naturalHeight):`videoWidth`in t?(r=t.videoWidth,i=t.videoHeight):`width`in t&&(r=Number(t.width),i=Number(t.height)),!r||!i)throw TypeError(`Could not determine dimensions.`);let a=new OffscreenCanvas(r,i),o=a.getContext(`2d`,{alpha:AR(),willReadFrequently:!0});if(!o)throw Error(`OffscreenCanvas must have support for the '2d' context in order to create a VideoSample from this data.`);o.drawImage(t,0,0),this._data=a,this._layout=null,this.format=`RGBX`,this.visibleRect={left:0,top:0,width:r,height:i},this.squarePixelWidth=r,this.squarePixelHeight=i,this.rotation=n.rotation??0,this.timestamp=n.timestamp,this.duration=n.duration??0,this.colorSpace=new gW({matrix:`rgb`,primaries:`bt709`,transfer:`iec61966-2-1`,fullRange:!0})}else if(t instanceof cW){if(!n||typeof n!=`object`)throw TypeError(`init must be an object.`);if(n.rotation!==void 0&&![0,90,180,270].includes(n.rotation))throw TypeError(`init.rotation, when provided, must be 0, 90, 180, or 270.`);if(!Number.isFinite(n.timestamp))throw TypeError(`init.timestamp must be a number.`);if(n.duration!==void 0&&(!Number.isFinite(n.duration)||n.duration<0))throw TypeError(`init.duration, when provided, must be a non-negative number.`);if(this._data=t,t._referenceCount++,this.format=t.getFormat(),this.format!==null&&!lW.includes(this.format))throw TypeError(`getFormat() must return a VideoSamplePixelFormat or null.`);if(this.visibleRect={left:0,top:0,width:t.getCodedWidth(),height:t.getCodedHeight()},!Number.isInteger(this.visibleRect.width)||this.visibleRect.width<=0)throw TypeError(`getCodedWidth() must return a positive integer.`);if(!Number.isInteger(this.visibleRect.height)||this.visibleRect.height<=0)throw TypeError(`getCodedHeight() must return a positive integer.`);if(this.squarePixelWidth=t.getSquarePixelWidth(),!Number.isInteger(this.squarePixelWidth)||this.squarePixelWidth<=0)throw TypeError(`getSquarePixelWidth() must return a positive integer.`);if(this.squarePixelHeight=t.getSquarePixelHeight(),!Number.isInteger(this.squarePixelHeight)||this.squarePixelHeight<=0)throw TypeError(`getSquarePixelHeight() must return a positive integer.`);this.rotation=n.rotation??0,this.timestamp=n.timestamp,this.duration=n.duration??0,this.colorSpace=t.getColorSpace()}else throw TypeError(`Invalid data type: Must be a BufferSource, CanvasImageSource, or VideoSampleResource.`);this.encodeOptions=n?.encodeOptions??{},this.pixelAspectRatio=GR({num:this.squarePixelWidth*this.codedHeight,den:this.squarePixelHeight*this.codedWidth}),sW?.register(this,{type:`video`,data:this._data},this)}clone(){if(this._closed)throw Error(`VideoSample is closed.`);return X(this._data!==null),this._data instanceof cW?new e(this._data,{timestamp:this.timestamp,duration:this.duration,rotation:this.rotation,encodeOptions:this.encodeOptions}):_W(this._data)?new e(this._data.clone(),{timestamp:this.timestamp,duration:this.duration,rotation:this.rotation,encodeOptions:this.encodeOptions}):this._data instanceof Uint8Array?(X(this._layout),new e(this._data,{format:this.format,layout:this._layout,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation,visibleRect:this.visibleRect,displayWidth:this.displayWidth,displayHeight:this.displayHeight,encodeOptions:this.encodeOptions,_doNotCopy:!0})):new e(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.timestamp,duration:this.duration,colorSpace:this.colorSpace,rotation:this.rotation,visibleRect:this.visibleRect,displayWidth:this.displayWidth,displayHeight:this.displayHeight,encodeOptions:this.encodeOptions})}close(){this._closed||=(sW?.unregister(this),this._data instanceof cW?(this._data._referenceCount--,this._data._referenceCount===0&&this._data.close()):_W(this._data)?this._data.close():this._data=null,!0)}allocationSize(e={}){if(bW(e),this._closed)throw Error(`VideoSample is closed.`);if((e.format??this.format)==null)throw Error(`Cannot get allocation size when format is null.`);return _W(this._data)?this._data.allocationSize(e):CW(this,e).allocationSize}async copyTo(t,n={}){if(!GL(t))throw TypeError(`destination must be an ArrayBuffer or an ArrayBuffer view.`);if(bW(n),this._closed)throw Error(`VideoSample is closed.`);if((n.format??this.format)==null)throw Error(`Cannot copy video sample data when format is null.`);if(X(this._data!==null),_W(this._data))return this._data.copyTo(t,n);if(n.format&&![`RGBA`,`RGBX`,`BGRA`,`BGRX`].includes(this.format)&&[`RGBA`,`RGBX`,`BGRA`,`BGRX`].includes(n.format))if(this._data instanceof cW){let r={stack:[],error:void 0,hasError:!1};try{let i=rW(r,await this._data.toRgbSample({timestamp:this.timestamp,duration:this.duration,rotation:this.rotation},n.colorSpace??`srgb`),!1);if(!(i instanceof e))throw TypeError(`toRgbSample() must return a VideoSample.`);if(![`RGBA`,`RGBX`,`BGRA`,`BGRX`].includes(i.format))throw Error(`Sample returned by toRgbSample was expected to have an RGB format, got '${i.format}' instead.`);return await i.copyTo(t,n)}catch(e){r.error=e,r.hasError=!0}finally{iW(r)}}else{if(typeof VideoFrame>`u`)throw Error(`For this sample, converting from a non-RGB to an RGB format requires VideoFrame to be defined.`);let e=this.toVideoFrame(),r=await e.copyTo(t,n);return e.close(),r}let r=CW(this,n);X(this.format);let i=NL(t);if(i.byteLength<r.allocationSize)throw TypeError(`Destination buffer too small. Required: ${r.allocationSize}, Available: ${i.byteLength}`);let a=SW(this.format),o;if(this._data instanceof cW){let e=this._data.getDataPlanes();if(e instanceof Promise&&(e=await e),!Array.isArray(e)||e.some(e=>!(e.data instanceof Uint8Array)||!Number.isInteger(e.stride)||e.stride<0))throw TypeError(`getDataPlanes() must return an array of objects with a Uint8Array "data" property and a non-negative integer "stride" property.`);o=e}else if(this._data instanceof Uint8Array)X(this._layout),X(this._layout.length===a.length),o=this._layout.map((e,t)=>{let n=Math.ceil(this.codedHeight/a[t].heightDivisor);return{data:this._data.subarray(e.offset,e.offset+e.stride*n),stride:e.stride}});else{let e=this._data.getContext(`2d`);X(e),o=[{data:NL(e.getImageData(0,0,this.codedWidth,this.codedHeight).data),stride:4*this.codedWidth}]}let s=[],c=a.length;for(let e=0;e<c;e++){let t=r.computedLayouts[e],n=o[e].stride,a=o[e].data,c=t.sourceTop*n;c+=t.sourceLeftBytes;let l=t.destinationOffset,u=t.sourceWidthBytes,d={offset:l,stride:t.destinationStride};for(let e=0;e<t.sourceHeight;e++){if(c+u>a.byteLength)throw Error(`Source buffer OOB read.`);if(l+u>i.byteLength)throw Error(`Destination buffer OOB write.`);let e=a.subarray(c,c+u);i.set(e,l),c+=n,l+=t.destinationStride}s.push(d)}if(n.format!==void 0){let e=this.format.startsWith(`RGB`)!==n.format.startsWith(`RGB`),t=this.format.includes(`X`)&&n.format.includes(`A`);if(e||t)for(let n=0;n<r.allocationSize;n+=4){if(e){let e=i[n];i[n]=i[n+2],i[n+2]=e}t&&(i[n+3]=255)}}return s}toVideoFrame(){if(this._closed)throw Error(`VideoSample is closed.`);if(X(this._data!==null),this._data instanceof cW){if(this.format===null)throw Error(`Cannot convert a VideoSampleResource-backed VideoSample to VideoFrame if format is null.`);let e=this._data.getDataPlanes();if(e instanceof Promise)throw Error(`Cannot convert a VideoSampleResource-backed VideoSample to VideoFrame if getDataPlanes() returns a promise.`);let t=e.reduce((e,t)=>e+t.data.byteLength,0),n=new Uint8Array(t),r=0,i=[];for(let t of e)n.set(t.data,r),i.push(r),r+=t.data.byteLength;return new VideoFrame(n,{format:this.format,layout:e.map((e,t)=>({offset:i[t],stride:e.stride})),codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration,colorSpace:this.colorSpace,displayWidth:this.squarePixelWidth,displayHeight:this.squarePixelHeight})}else if(_W(this._data))return new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0});else if(this._data instanceof Uint8Array)return new VideoFrame(this._data,{format:this.format,codedWidth:this.codedWidth,codedHeight:this.codedHeight,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0,colorSpace:this.colorSpace,displayWidth:this.squarePixelWidth,displayHeight:this.squarePixelHeight});else return new VideoFrame(this._data,{timestamp:this.microsecondTimestamp,duration:this.microsecondDuration||void 0})}draw(e,t,n,r,i,a,o,s,c){let l=0,u=0,d=this.displayWidth,f=this.displayHeight,p=0,m=0,h=this.displayWidth,g=this.displayHeight;if(a===void 0?(p=t,m=n,r!==void 0&&(h=r,g=i)):(l=t,u=n,d=r,f=i,p=a,m=o,s===void 0?(h=d,g=f):(h=s,g=c)),!(typeof CanvasRenderingContext2D<`u`&&e instanceof CanvasRenderingContext2D||typeof OffscreenCanvasRenderingContext2D<`u`&&e instanceof OffscreenCanvasRenderingContext2D))throw TypeError(`context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.`);if(!Number.isFinite(l))throw TypeError(`sx must be a number.`);if(!Number.isFinite(u))throw TypeError(`sy must be a number.`);if(!Number.isFinite(d)||d<0)throw TypeError(`sWidth must be a non-negative number.`);if(!Number.isFinite(f)||f<0)throw TypeError(`sHeight must be a non-negative number.`);if(!Number.isFinite(p))throw TypeError(`dx must be a number.`);if(!Number.isFinite(m))throw TypeError(`dy must be a number.`);if(!Number.isFinite(h)||h<0)throw TypeError(`dWidth must be a non-negative number.`);if(!Number.isFinite(g)||g<0)throw TypeError(`dHeight must be a non-negative number.`);if(this._closed)throw Error(`VideoSample is closed.`);({sx:l,sy:u,sWidth:d,sHeight:f}=this._rotateSourceRegion(l,u,d,f,this.rotation));let _=this.toCanvasImageSource();e.save();let v=p+h/2,y=m+g/2;e.translate(v,y),e.rotate(this.rotation*Math.PI/180);let b=this.rotation%180==0?1:h/g;e.scale(1/b,b),e.drawImage(_,l,u,d,f,-h/2,-g/2,h,g),e.restore()}drawWithFit(e,t){if(!(typeof CanvasRenderingContext2D<`u`&&e instanceof CanvasRenderingContext2D||typeof OffscreenCanvasRenderingContext2D<`u`&&e instanceof OffscreenCanvasRenderingContext2D))throw TypeError(`context must be a CanvasRenderingContext2D or OffscreenCanvasRenderingContext2D.`);if(!t||typeof t!=`object`)throw TypeError(`options must be an object.`);if(![`fill`,`contain`,`cover`].includes(t.fit))throw TypeError(`options.fit must be 'fill', 'contain', or 'cover'.`);if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw TypeError(`options.rotation, when provided, must be 0, 90, 180, or 270.`);t.crop!==void 0&&yW(t.crop,`options.`);let n=e.canvas.width,r=e.canvas.height,i=t.rotation??this.rotation,[a,o]=i%180==0?[this.squarePixelWidth,this.squarePixelHeight]:[this.squarePixelHeight,this.squarePixelWidth],s=t.crop;s&&=vW(s,a,o);let c,l,u,d,{sx:f,sy:p,sWidth:m,sHeight:h}=this._rotateSourceRegion(t.crop?.left??0,t.crop?.top??0,t.crop?.width??a,t.crop?.height??o,i);if(t.fit===`fill`)c=0,l=0,u=n,d=r;else{let[e,i]=t.crop?[t.crop.width,t.crop.height]:[a,o],s=t.fit===`contain`?Math.min(n/e,r/i):Math.max(n/e,r/i);u=e*s,d=i*s,c=(n-u)/2,l=(r-d)/2}e.save();let g=i%180==0?1:u/d;e.translate(n/2,r/2),e.rotate(i*Math.PI/180),e.scale(1/g,g),e.translate(-n/2,-r/2),e.drawImage(this.toCanvasImageSource(),f,p,m,h,c,l,u,d),e.restore()}_rotateSourceRegion(e,t,n,r,i){return i===90?[e,t,n,r]=[t,this.squarePixelHeight-e-n,r,n]:i===180?[e,t]=[this.squarePixelWidth-e-n,this.squarePixelHeight-t-r]:i===270&&([e,t,n,r]=[this.squarePixelWidth-t-r,e,r,n]),{sx:e,sy:t,sWidth:n,sHeight:r}}toCanvasImageSource(){if(this._closed)throw Error(`VideoSample is closed.`);if(X(this._data!==null),this._data instanceof cW||this._data instanceof Uint8Array){let e=this.toVideoFrame();return queueMicrotask(()=>e.close()),e}else return this._data}async transform(t){if(!t||typeof t!=`object`)throw TypeError(`options must be an object.`);if(t.width!==void 0&&(!Number.isInteger(t.width)||t.width<=0))throw TypeError(`options.width, when provided, must be a positive integer.`);if(t.height!==void 0&&(!Number.isInteger(t.height)||t.height<=0))throw TypeError(`options.height, when provided, must be a positive integer.`);if(t.roundDimensionsTo!==void 0&&(!Number.isInteger(t.roundDimensionsTo)||t.roundDimensionsTo<=0))throw TypeError(`options.roundDimensionsTo, when provided, must be a positive integer.`);if(t.fit!==void 0&&![`fill`,`contain`,`cover`].includes(t.fit))throw TypeError(`options.fit, when provided, must be one of "fill", "contain", or "cover".`);if(t.width!==void 0&&t.height!==void 0&&t.fit===void 0)throw TypeError(`When both options.width and options.height are provided, options.fit must also be provided.`);if(t.rotate!==void 0&&![0,90,180,270].includes(t.rotate))throw TypeError(`options.rotate, when provided, must be 0, 90, 180 or 270.`);if(t.crop!==void 0&&yW(t.crop,`options.`),t.alpha!==void 0&&![`keep`,`discard`].includes(t.alpha))throw TypeError(`options.alpha, when provided, must be 'keep' or 'discard'.`);let n=kL(this.rotation+(t.rotate??0)),[r,i]=n%180==0?[this.squarePixelWidth,this.squarePixelHeight]:[this.squarePixelHeight,this.squarePixelWidth],a=t.crop;a&&=vW(a,r,i);let o=a?a.width:r,s=a?a.height:i,c=o/s,l,u;t.width!==void 0&&t.height===void 0?(l=t.width,u=l/c):t.width===void 0&&t.height!==void 0?(u=t.height,l=u*c):t.width!==void 0&&t.height!==void 0?(l=t.width,u=t.height):(l=o,u=s),l=mR(l,t.roundDimensionsTo??1),u=mR(u,t.roundDimensionsTo??1);let d={width:l,height:u,fit:t.fit??`fill`,rotation:n,crop:a??{left:0,top:0,width:r,height:i},alpha:t.alpha??`keep`};for(let e of fW){let t=e(this,d);if(t instanceof Promise&&(t=await t),t!==null)return t}let f=null,p=!1;for(let e of mW)if(e.canvas.width===d.width&&e.canvas.height===d.height){f=e.canvas,e.age=hW++;break}if(f===null){if(typeof OffscreenCanvas<`u`)f=new OffscreenCanvas(d.width,d.height);else{if(typeof window>`u`||typeof document>`u`)throw Error(`Cannot transform VideoSamples in this environment. Either run in an environment with OffscreenCanvas or HTMLCanvasElement, or supply a custom VideoSample transformer using registerVideoSampleTransformer().`);f=document.createElement(`canvas`),f.width=d.width,f.height=d.height}p=!0,mW.length>=pW&&mW.splice(WR(mW,e=>e.age),1),mW.push({canvas:f,age:hW++})}let m=f.getContext(`2d`,{alpha:!0});if(!m)throw Error(`The '2d' canvas context is required to transform VideoSamples. Register a custom transformer using registerVideoSampleTransformer to work around this limitation.`);return d.alpha===`discard`?(m.fillStyle=`black`,m.fillRect(0,0,d.width,d.height)):p||m.clearRect(0,0,d.width,d.height),this.drawWithFit(m,{fit:d.fit,rotation:d.rotation,crop:d.crop}),new e(f,{timestamp:this.timestamp,duration:this.duration,rotation:0})}setRotation(e){if(![0,90,180,270].includes(e))throw TypeError(`newRotation must be 0, 90, 180, or 270.`);this.rotation=e}setTimestamp(e){if(!Number.isFinite(e))throw TypeError(`newTimestamp must be a number.`);this.timestamp=e}setDuration(e){if(!Number.isFinite(e)||e<0)throw TypeError(`newDuration must be a non-negative number.`);this.duration=e}setEncodeOptions(e){if(!e||typeof e!=`object`)throw TypeError(`newEncodeOptions must be an object.`);this.encodeOptions=e}[Symbol.dispose](){this.close()}},fW=[],pW=3,mW=[],hW=0,gW=class{constructor(e){if(e!==void 0){if(!e||typeof e!=`object`)throw TypeError(`init.colorSpace, when provided, must be an object.`);let t=Object.keys(RL);if(e.primaries!=null&&!t.includes(e.primaries))throw TypeError(`init.colorSpace.primaries, when provided, must be one of ${t.join(`, `)}.`);let n=Object.keys(BL);if(e.transfer!=null&&!n.includes(e.transfer))throw TypeError(`init.colorSpace.transfer, when provided, must be one of ${n.join(`, `)}.`);let r=Object.keys(HL);if(e.matrix!=null&&!r.includes(e.matrix))throw TypeError(`init.colorSpace.matrix, when provided, must be one of ${r.join(`, `)}.`);if(e.fullRange!=null&&typeof e.fullRange!=`boolean`)throw TypeError(`init.colorSpace.fullRange, when provided, must be a boolean.`)}this.primaries=e?.primaries??null,this.transfer=e?.transfer??null,this.matrix=e?.matrix??null,this.fullRange=e?.fullRange??null}toJSON(){return{primaries:this.primaries,transfer:this.transfer,matrix:this.matrix,fullRange:this.fullRange}}},_W=e=>typeof VideoFrame<`u`&&e instanceof VideoFrame,vW=(e,t,n)=>{let r=Math.min(e.left,t),i=Math.min(e.top,n),a=Math.min(e.width,t-r),o=Math.min(e.height,n-i);return X(a>=0),X(o>=0),{left:r,top:i,width:a,height:o}},yW=(e,t)=>{if(!e||typeof e!=`object`)throw TypeError(t+`crop, when provided, must be an object.`);if(!Number.isInteger(e.left)||e.left<0)throw TypeError(t+`crop.left must be a non-negative integer.`);if(!Number.isInteger(e.top)||e.top<0)throw TypeError(t+`crop.top must be a non-negative integer.`);if(!Number.isInteger(e.width)||e.width<0)throw TypeError(t+`crop.width must be a non-negative integer.`);if(!Number.isInteger(e.height)||e.height<0)throw TypeError(t+`crop.height must be a non-negative integer.`)},bW=e=>{if(!e||typeof e!=`object`)throw TypeError(`options must be an object.`);if(e.colorSpace!==void 0&&![`display-p3`,`srgb`].includes(e.colorSpace))throw TypeError(`options.colorSpace, when provided, must be 'display-p3' or 'srgb'.`);if(e.format!==void 0&&typeof e.format!=`string`)throw TypeError(`options.format, when provided, must be a string.`);if(e.layout!==void 0){if(!Array.isArray(e.layout))throw TypeError(`options.layout, when provided, must be an array.`);for(let t of e.layout){if(!t||typeof t!=`object`)throw TypeError(`Each entry in options.layout must be an object.`);if(!Number.isInteger(t.offset)||t.offset<0)throw TypeError(`plane.offset must be a non-negative integer.`);if(!Number.isInteger(t.stride)||t.stride<0)throw TypeError(`plane.stride must be a non-negative integer.`)}}if(e.rect!==void 0){if(!e.rect||typeof e.rect!=`object`)throw TypeError(`options.rect, when provided, must be an object.`);if(e.rect.x!==void 0&&(!Number.isInteger(e.rect.x)||e.rect.x<0))throw TypeError(`options.rect.x, when provided, must be a non-negative integer.`);if(e.rect.y!==void 0&&(!Number.isInteger(e.rect.y)||e.rect.y<0))throw TypeError(`options.rect.y, when provided, must be a non-negative integer.`);if(e.rect.width!==void 0&&(!Number.isInteger(e.rect.width)||e.rect.width<0))throw TypeError(`options.rect.width, when provided, must be a non-negative integer.`);if(e.rect.height!==void 0&&(!Number.isInteger(e.rect.height)||e.rect.height<0))throw TypeError(`options.rect.height, when provided, must be a non-negative integer.`)}},xW=(e,t,n)=>{let r=SW(e),i=[],a=0;for(let e of r){let r=Math.ceil(t/e.widthDivisor),o=Math.ceil(n/e.heightDivisor),s=r*e.sampleBytes,c=s*o;i.push({offset:a,stride:s}),a+=c}return i},SW=e=>{let t=(e,t,n,r,i)=>{let a=[{sampleBytes:e,widthDivisor:1,heightDivisor:1},{sampleBytes:t,widthDivisor:n,heightDivisor:r},{sampleBytes:t,widthDivisor:n,heightDivisor:r}];return i&&a.push({sampleBytes:e,widthDivisor:1,heightDivisor:1}),a};switch(e){case`I420`:return t(1,1,2,2,!1);case`I420P10`:case`I420P12`:return t(2,2,2,2,!1);case`I420A`:return t(1,1,2,2,!0);case`I420AP10`:case`I420AP12`:return t(2,2,2,2,!0);case`I422`:return t(1,1,2,1,!1);case`I422P10`:case`I422P12`:return t(2,2,2,1,!1);case`I422A`:return t(1,1,2,1,!0);case`I422AP10`:case`I422AP12`:return t(2,2,2,1,!0);case`I444`:return t(1,1,1,1,!1);case`I444P10`:case`I444P12`:return t(2,2,1,1,!1);case`I444A`:return t(1,1,1,1,!0);case`I444AP10`:case`I444AP12`:return t(2,2,1,1,!0);case`NV12`:return[{sampleBytes:1,widthDivisor:1,heightDivisor:1},{sampleBytes:2,widthDivisor:2,heightDivisor:2}];case`RGBA`:case`RGBX`:case`BGRA`:case`BGRX`:return[{sampleBytes:4,widthDivisor:1,heightDivisor:1}];default:oR(e),X(!1)}},CW=(e,t)=>{let n={left:0,top:0,width:e.codedWidth,height:e.codedHeight},r=t.rect,i=wW(n,r,e.codedWidth,e.codedHeight,e.format),a=t.layout,o;if(!t.format||t.format===e.format)o=e.format;else if([`RGBA`,`RGBX`,`BGRA`,`BGRX`].includes(t.format))o=t.format;else throw Error(`NotSupportedError: Invalid destination format.`);return EW(i,o,a)},wW=(e,t,n,r,i)=>{let a={...e};if(t!==void 0){if(t.width===0||t.height===0)throw TypeError(`visibleRect dimensions cannot be zero.`);if((t.x||0)+(t.width||0)>n)throw TypeError(`visibleRect exceeds codedWidth.`);if((t.y||0)+(t.height||0)>r)throw TypeError(`visibleRect exceeds codedHeight.`);a.x=t.x||0,a.y=t.y||0,a.width=t.width||0,a.height=t.height||0}if(!TW(i,a))throw TypeError(`visibleRect alignment is invalid for the format.`);return a},TW=(e,t)=>{if(e===null)return!0;let n=SW(e);for(let e=0;e<n.length;e++){let r=n[e],i=r.widthDivisor,a=r.heightDivisor;if((t.x||0)%i!==0||(t.y||0)%a!==0)return!1}return!0},EW=(e,t,n)=>{let r=SW(t),i=r.length;if(n!==void 0&&n.length!==i)throw TypeError(`Layout must have ${i} planes.`);let a=0,o=[],s=[];for(let t=0;t<i;t++){let i=r[t],c=i.sampleBytes,l=i.widthDivisor,u=i.heightDivisor,d={destinationOffset:0,destinationStride:0,sourceTop:0,sourceHeight:0,sourceLeftBytes:0,sourceWidthBytes:0};if(d.sourceTop=Math.ceil(Math.trunc(e.y||0)/u),d.sourceHeight=Math.ceil(Math.trunc(e.height||0)/u),d.sourceLeftBytes=Math.floor(Math.trunc(e.x||0)/l)*c,d.sourceWidthBytes=Math.floor(Math.trunc(e.width||0)/l)*c,n!==void 0){let e=n[t];if(e.stride<d.sourceWidthBytes)throw TypeError(`Stride for plane ${t} is too small.`);d.destinationOffset=e.offset,d.destinationStride=e.stride}else d.destinationOffset=a,d.destinationStride=d.sourceWidthBytes;let f=d.destinationStride*d.sourceHeight+d.destinationOffset;if(f>4294967295)throw TypeError(`Allocation size exceeds limit.`);s.push(f),a=Math.max(a,f);for(let e=0;e<t;e++){let n=o[e];if(!(s[t]<=n.destinationOffset||s[e]<=d.destinationOffset))throw TypeError(`Planes overlap.`)}o.push(d)}return{allocationSize:a,computedLayouts:o}},DW=new Set([`f32`,`f32-planar`,`s16`,`s16-planar`,`s32`,`s32-planar`,`u8`,`u8-planar`]),OW=class{constructor(){this._referenceCount=0}},kW=class e{get microsecondTimestamp(){return Math.trunc(xR*this.timestamp)}get microsecondDuration(){return Math.trunc(xR*this.duration)}constructor(e){if(this._closed=!1,PW(e)){if(e.format===null)throw TypeError(`AudioData with null format is not supported.`);this._data=e,this.format=e.format,this.sampleRate=e.sampleRate,this.numberOfFrames=e.numberOfFrames,this.numberOfChannels=e.numberOfChannels,this.timestamp=e.timestamp/1e6,this.duration=e.numberOfFrames/e.sampleRate}else if(e instanceof OW){if(this._data=e,e._referenceCount++,this.format=e.getFormat(),!DW.has(this.format))throw TypeError(`getFormat() must return an AudioSampleFormat.`);if(this.sampleRate=e.getSampleRate(),!Number.isInteger(this.sampleRate)||this.sampleRate<=0)throw TypeError(`getSampleRate() must return a positive integer.`);if(this.numberOfFrames=e.getNumberOfFrames(),!Number.isInteger(this.numberOfFrames)||this.numberOfFrames<0)throw TypeError(`getNumberOfFrames() must return a non-negative integer.`);if(this.numberOfChannels=e.getNumberOfChannels(),!Number.isInteger(this.numberOfChannels)||this.numberOfChannels<=0)throw TypeError(`getNumberOfChannels() must return a positive integer.`);if(this.timestamp=e.getTimestamp(),!Number.isFinite(this.timestamp))throw TypeError(`getTimestamp() must return a finite number.`);this.duration=this.numberOfFrames/this.sampleRate}else{if(!e||typeof e!=`object`)throw TypeError(`Invalid AudioDataInit: must be an object.`);if(!DW.has(e.format))throw TypeError(`Invalid AudioDataInit: invalid format.`);if(!Number.isFinite(e.sampleRate)||e.sampleRate<=0)throw TypeError(`Invalid AudioDataInit: sampleRate must be > 0.`);if(!Number.isInteger(e.numberOfChannels)||e.numberOfChannels===0)throw TypeError(`Invalid AudioDataInit: numberOfChannels must be an integer > 0.`);if(!Number.isFinite(e?.timestamp))throw TypeError(`init.timestamp must be a number.`);let t=e.data.byteLength/(AW(e.format)*e.numberOfChannels);if(!Number.isInteger(t))throw TypeError(`Invalid AudioDataInit: data size is not a multiple of frame size.`);this.format=e.format,this.sampleRate=e.sampleRate,this.numberOfFrames=t,this.numberOfChannels=e.numberOfChannels,this.timestamp=e.timestamp,this.duration=t/e.sampleRate;let n;if(e.data instanceof ArrayBuffer)n=new Uint8Array(e.data);else if(ArrayBuffer.isView(e.data))n=new Uint8Array(e.data.buffer,e.data.byteOffset,e.data.byteLength);else throw TypeError(`Invalid AudioDataInit: data is not a BufferSource.`);let r=this.numberOfFrames*this.numberOfChannels*AW(this.format);if(n.byteLength<r)throw TypeError(`Invalid AudioDataInit: insufficient data size.`);this._data=n}sW?.register(this,{type:`audio`,data:this._data},this)}allocationSize(e){if(!e||typeof e!=`object`)throw TypeError(`options must be an object.`);if(!Number.isInteger(e.planeIndex)||e.planeIndex<0)throw TypeError(`planeIndex must be a non-negative integer.`);if(e.format!==void 0&&!DW.has(e.format))throw TypeError(`Invalid format.`);if(e.frameOffset!==void 0&&(!Number.isInteger(e.frameOffset)||e.frameOffset<0))throw TypeError(`frameOffset must be a non-negative integer.`);if(e.frameCount!==void 0&&(!Number.isInteger(e.frameCount)||e.frameCount<0))throw TypeError(`frameCount must be a non-negative integer.`);if(this._closed)throw Error(`AudioSample is closed.`);let t=e.format??this.format,n=e.frameOffset??0;if(n>=this.numberOfFrames)throw RangeError(`frameOffset out of range`);let r=e.frameCount===void 0?this.numberOfFrames-n:e.frameCount;if(r>this.numberOfFrames-n)throw RangeError(`frameCount out of range`);let i=AW(t),a=jW(t);if(a&&e.planeIndex>=this.numberOfChannels||!a&&e.planeIndex!==0)throw RangeError(`planeIndex out of range`);return(a?r:r*this.numberOfChannels)*i}copyTo(e,t){if(!GL(e))throw TypeError(`destination must be an ArrayBuffer or an ArrayBuffer view.`);if(!t||typeof t!=`object`)throw TypeError(`options must be an object.`);if(!Number.isInteger(t.planeIndex)||t.planeIndex<0)throw TypeError(`planeIndex must be a non-negative integer.`);if(t.format!==void 0&&!DW.has(t.format))throw TypeError(`Invalid format.`);if(t.frameOffset!==void 0&&(!Number.isInteger(t.frameOffset)||t.frameOffset<0))throw TypeError(`frameOffset must be a non-negative integer.`);if(t.frameCount!==void 0&&(!Number.isInteger(t.frameCount)||t.frameCount<0))throw TypeError(`frameCount must be a non-negative integer.`);if(this._closed)throw Error(`AudioSample is closed.`);let{format:n,frameCount:r,frameOffset:i}=t,{planeIndex:a}=t,o=this.format,s=n??this.format;if(!s)throw Error(`Destination format not determined`);let c=this.numberOfFrames,l=this.numberOfChannels,u=i??0;if(u>=c)throw RangeError(`frameOffset out of range`);let d=r===void 0?c-u:r;if(d>c-u)throw RangeError(`frameCount out of range`);let f=AW(s),p=jW(s);if(p&&a>=l||!p&&a!==0)throw RangeError(`planeIndex out of range`);let m=(p?d:d*l)*f;if(e.byteLength<m)throw RangeError(`Destination buffer is too small`);let h=PL(e),g=NW(s);if(PW(this._data))OR()&&l>2&&s!==o?IW(this._data,h,o,s,l,a,u,d):this._data.copyTo(e,{planeIndex:a,frameOffset:u,frameCount:d,format:s});else{let e=MW(o),t=AW(o),n=jW(o),r;if(this._data instanceof OW){let e=e=>{let r=this._data.getDataPlane(e);if(!(r instanceof Uint8Array))throw TypeError(`getDataPlane() must return a Uint8Array.`);let i=c*t*(n?1:l);if(r.byteLength!==i)throw TypeError(`Data plane ${e} has invalid size. Expected exactly ${i} bytes, got ${r.byteLength} bytes.`);return r};if(n)if(p)r=e(a),a=0;else{r=new Uint8Array(c*t*l);for(let n=0;n<l;n++){let i=e(n);r.set(i,n*c*t)}}else r=e(0)}else r=this._data;let i=PL(r);for(let r=0;r<d;r++)if(p){let o=r*f,s;s=n?(a*c+(r+u))*t:((r+u)*l+a)*t,g(h,o,e(i,s))}else for(let a=0;a<l;a++){let o=(r*l+a)*f,s;s=n?(a*c+(r+u))*t:((r+u)*l+a)*t,g(h,o,e(i,s))}}}clone(){if(this._closed)throw Error(`AudioSample is closed.`);if(this._data instanceof OW){let t=new e(this._data);return t.setTimestamp(this.timestamp),t}else if(PW(this._data)){let t=new e(this._data.clone());return t.setTimestamp(this.timestamp),t}else return new e({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.timestamp,data:this._data})}trim(t,n=this.numberOfFrames){if(!Number.isInteger(t)||t<0)throw TypeError(`startSample must be a non-negative integer.`);if(!Number.isInteger(n)||n<0)throw TypeError(`endSample must be a non-negative integer.`);if(t>this.numberOfFrames)throw RangeError(`startSample out of range.`);if(n>this.numberOfFrames)throw RangeError(`endSample out of range.`);if(n<t)throw RangeError(`endSample must not be less than startSample.`);if(this._closed)throw Error(`AudioSample is closed.`);let r=n-t,i=AW(this.format),a;if(jW(this.format)){let e=r*i;if(a=new Uint8Array(e*this.numberOfChannels),r>0)for(let n=0;n<this.numberOfChannels;n++)this.copyTo(a.subarray(n*e,(n+1)*e),{planeIndex:n,format:this.format,frameOffset:t,frameCount:r})}else a=new Uint8Array(r*this.numberOfChannels*i),r>0&&this.copyTo(a,{planeIndex:0,format:this.format,frameOffset:t,frameCount:r});return new e({data:a,format:this.format,sampleRate:this.sampleRate,numberOfChannels:this.numberOfChannels,timestamp:this.timestamp+t/this.sampleRate})}close(){this._closed||=(sW?.unregister(this),this._data instanceof OW?(this._data._referenceCount--,this._data._referenceCount===0&&this._data.close()):PW(this._data)?this._data.close():this._data=new Uint8Array,!0)}toAudioData(){if(this._closed)throw Error(`AudioSample is closed.`);return this._data instanceof OW?this._createAudioDataFromData():PW(this._data)?this._data.timestamp===this.microsecondTimestamp?this._data.clone():this._createAudioDataFromData():new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:this._data.buffer instanceof ArrayBuffer?this._data.buffer:this._data.slice()})}_createAudioDataFromData(){if(jW(this.format)){let e=this.allocationSize({planeIndex:0,format:this.format}),t=new ArrayBuffer(e*this.numberOfChannels);for(let n=0;n<this.numberOfChannels;n++)this.copyTo(new Uint8Array(t,n*e,e),{planeIndex:n,format:this.format});return new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:t})}else{let e=new ArrayBuffer(this.allocationSize({planeIndex:0,format:this.format}));return this.copyTo(e,{planeIndex:0,format:this.format}),new AudioData({format:this.format,sampleRate:this.sampleRate,numberOfFrames:this.numberOfFrames,numberOfChannels:this.numberOfChannels,timestamp:this.microsecondTimestamp,data:e})}}toAudioBuffer(){if(this._closed)throw Error(`AudioSample is closed.`);let e=new AudioBuffer({numberOfChannels:this.numberOfChannels,length:this.numberOfFrames,sampleRate:this.sampleRate}),t=new Float32Array(this.allocationSize({planeIndex:0,format:`f32-planar`})/4);for(let n=0;n<this.numberOfChannels;n++)this.copyTo(t,{planeIndex:n,format:`f32-planar`}),e.copyToChannel(t,n);return e}setTimestamp(e){if(!Number.isFinite(e))throw TypeError(`newTimestamp must be a number.`);this.timestamp=e}[Symbol.dispose](){this.close()}static*_fromAudioBuffer(t,n){if(!(t instanceof AudioBuffer))throw TypeError(`audioBuffer must be an AudioBuffer.`);let r=t.numberOfChannels,i=t.sampleRate,a=t.length,o=Math.floor(24e4/r),s=0,c=a;for(;c>0;){let a=Math.min(o,c),l=new Float32Array(r*a);for(let e=0;e<r;e++)t.copyFromChannel(l.subarray(e*a,(e+1)*a),e,s);yield new e({format:`f32-planar`,sampleRate:i,numberOfFrames:a,numberOfChannels:r,timestamp:n+s/i,data:l}),s+=a,c-=a}}static fromAudioBuffer(t,n){if(!(t instanceof AudioBuffer))throw TypeError(`audioBuffer must be an AudioBuffer.`);let r=t.numberOfChannels,i=t.sampleRate,a=t.length,o=Math.floor(24e4/r),s=0,c=a,l=[];for(;c>0;){let a=Math.min(o,c),u=new Float32Array(r*a);for(let e=0;e<r;e++)t.copyFromChannel(u.subarray(e*a,(e+1)*a),e,s);let d=new e({format:`f32-planar`,sampleRate:i,numberOfFrames:a,numberOfChannels:r,timestamp:n+s/i,data:u});l.push(d),s+=a,c-=a}return l}},AW=e=>{switch(e){case`u8`:case`u8-planar`:return 1;case`s16`:case`s16-planar`:return 2;case`s32`:case`s32-planar`:return 4;case`f32`:case`f32-planar`:return 4;default:throw Error(`Unknown AudioSampleFormat`)}},jW=e=>{switch(e){case`u8-planar`:case`s16-planar`:case`s32-planar`:case`f32-planar`:return!0;default:return!1}},MW=e=>{switch(e){case`u8`:case`u8-planar`:return(e,t)=>(e.getUint8(t)-128)/128;case`s16`:case`s16-planar`:return(e,t)=>e.getInt16(t,!0)/32768;case`s32`:case`s32-planar`:return(e,t)=>e.getInt32(t,!0)/2147483648;case`f32`:case`f32-planar`:return(e,t)=>e.getFloat32(t,!0)}},NW=e=>{switch(e){case`u8`:case`u8-planar`:return(e,t,n)=>e.setUint8(t,fR((n+1)*127.5,0,255));case`s16`:case`s16-planar`:return(e,t,n)=>e.setInt16(t,fR(Math.round(n*32767),-32768,32767),!0);case`s32`:case`s32-planar`:return(e,t,n)=>e.setInt32(t,fR(Math.round(n*2147483647),-2147483648,2147483647),!0);case`f32`:case`f32-planar`:return(e,t,n)=>e.setFloat32(t,n,!0)}},PW=e=>typeof AudioData<`u`&&e instanceof AudioData,FW=e=>{switch(e){case`u8-planar`:return`u8`;case`s16-planar`:return`s16`;case`s32-planar`:return`s32`;case`f32-planar`:return`f32`;default:return e}},IW=(e,t,n,r,i,a,o,s)=>{let c=MW(n),l=NW(r),u=AW(n),d=AW(r),f=jW(n);if(jW(r))if(f){let r=new ArrayBuffer(s*u),i=PL(r);e.copyTo(r,{planeIndex:a,frameOffset:o,frameCount:s,format:n});for(let e=0;e<s;e++){let n=e*u;l(t,e*d,c(i,n))}}else{let r=new ArrayBuffer(s*i*u),f=PL(r);e.copyTo(r,{planeIndex:0,frameOffset:o,frameCount:s,format:n});for(let e=0;e<s;e++){let n=(e*i+a)*u;l(t,e*d,c(f,n))}}else if(f){let r=s*u,a=new ArrayBuffer(r),f=PL(a);for(let r=0;r<i;r++){e.copyTo(a,{planeIndex:r,frameOffset:o,frameCount:s,format:n});for(let e=0;e<s;e++){let n=e*u;l(t,(e*i+r)*d,c(f,n))}}}else{let r=new ArrayBuffer(s*i*u),a=PL(r);e.copyTo(r,{planeIndex:0,frameOffset:o,frameCount:s,format:n});for(let e=0;e<s;e++)for(let n=0;n<i;n++){let r=e*i+n,o=r*u;l(t,r*d,c(a,o))}}},LW=(e,t)=>{let n=e.allocationSize({format:t,planeIndex:0}),r=new ArrayBuffer(n);return e.copyTo(r,{format:t,planeIndex:0}),new kW({data:r,format:t,numberOfChannels:e.numberOfChannels,sampleRate:e.sampleRate,timestamp:e.timestamp,duration:e.duration})},RW=new Map,zW=new Map,BW=e=>{if(!e||typeof e!=`object`)throw TypeError(`Encoding config must be an object.`);if(!sz.includes(e.codec))throw TypeError(`Invalid video codec '${e.codec}'. Must be one of: ${sz.join(`, `)}.`);if(!(e.bitrate instanceof KW)&&(!Number.isInteger(e.bitrate)||e.bitrate<=0))throw TypeError(`config.bitrate must be a positive integer or a quality.`);if(e.keyFrameInterval!==void 0&&(!Number.isFinite(e.keyFrameInterval)||e.keyFrameInterval<0))throw TypeError(`config.keyFrameInterval, when provided, must be a non-negative number.`);if(e.sizeChangeBehavior!==void 0&&![`deny`,`passThrough`,`fill`,`contain`,`cover`].includes(e.sizeChangeBehavior))throw TypeError(`config.sizeChangeBehavior, when provided, must be 'deny', 'passThrough', 'fill', 'contain' or 'cover'.`);if(e.transform!==void 0){if(typeof e.transform!=`object`||!e.transform)throw TypeError(`config.transform, when provided, must be an object.`);if(e.transform.width!==void 0&&(!Number.isInteger(e.transform.width)||e.transform.width<=0))throw TypeError(`config.transform.width, when provided, must be a positive integer.`);if(e.transform.height!==void 0&&(!Number.isInteger(e.transform.height)||e.transform.height<=0))throw TypeError(`config.transform.height, when provided, must be a positive integer.`);if(e.transform.fit!==void 0&&![`fill`,`contain`,`cover`].includes(e.transform.fit))throw TypeError(`config.transform.fit, when provided, must be one of "fill", "contain", or "cover".`);if(e.transform.width!==void 0&&e.transform.height!==void 0&&e.transform.fit===void 0&&![`fill`,`contain`,`cover`].includes(e.sizeChangeBehavior))throw TypeError(`When both config.transform.width and config.transform.height are provided, config.transform.fit must also be provided.`);if(e.transform.fit!==void 0&&[`fill`,`contain`,`cover`].includes(e.sizeChangeBehavior)&&e.transform.fit!==e.sizeChangeBehavior)throw TypeError(`config.transform.fit, when provided, cannot differ from config.sizeChangeBehavior when config.sizeChangeBehavior is 'fill', 'contain' or 'cover', as sizeChangeBehavior already determines the fitting algorithm.`);if(e.transform.rotate!==void 0&&![0,90,180,270].includes(e.transform.rotate))throw TypeError(`config.transform.rotate, when provided, must be 0, 90, 180 or 270.`);if(e.transform.crop!==void 0&&yW(e.transform.crop,`config.transform.`),e.transform.process!==void 0&&typeof e.transform.process!=`function`)throw TypeError(`config.transform.process, when provided, must be a function.`);if(e.transform.frameRate!==void 0&&(!Number.isFinite(e.transform.frameRate)||e.transform.frameRate<=0))throw TypeError(`config.transform.frameRate, when provided, must be a finite positive number.`);if(e.transform.force!==void 0&&typeof e.transform.force!=`boolean`)throw TypeError(`config.transform.force, when provided, must be a boolean.`)}if(e.onEncodedPacket!==void 0&&typeof e.onEncodedPacket!=`function`)throw TypeError(`config.onEncodedPacket, when provided, must be a function.`);if(e.onEncoderConfig!==void 0&&typeof e.onEncoderConfig!=`function`)throw TypeError(`config.onEncoderConfig, when provided, must be a function.`);if(e.onEncodedSample!==void 0&&typeof e.onEncodedSample!=`function`)throw TypeError(`config.onEncodedSample, when provided, must be a function.`);VW(e.codec,e)},VW=(e,t)=>{if(!t||typeof t!=`object`)throw TypeError(`Encoding options must be an object.`);if(t.alpha!==void 0&&![`discard`,`keep`].includes(t.alpha))throw TypeError(`options.alpha, when provided, must be 'discard' or 'keep'.`);if(t.bitrateMode!==void 0&&![`constant`,`variable`].includes(t.bitrateMode))throw TypeError(`bitrateMode, when provided, must be 'constant' or 'variable'.`);if(t.latencyMode!==void 0&&![`quality`,`realtime`].includes(t.latencyMode))throw TypeError(`latencyMode, when provided, must be 'quality' or 'realtime'.`);if(t.fullCodecString!==void 0&&typeof t.fullCodecString!=`string`)throw TypeError(`fullCodecString, when provided, must be a string.`);if(t.fullCodecString!==void 0&&Ez(t.fullCodecString)!==e)throw TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${e}).`);if(t.hardwareAcceleration!==void 0&&![`no-preference`,`prefer-hardware`,`prefer-software`].includes(t.hardwareAcceleration))throw TypeError(`hardwareAcceleration, when provided, must be 'no-preference', 'prefer-hardware' or 'prefer-software'.`);if(t.scalabilityMode!==void 0&&typeof t.scalabilityMode!=`string`)throw TypeError(`scalabilityMode, when provided, must be a string.`);if(t.contentHint!==void 0&&typeof t.contentHint!=`string`)throw TypeError(`contentHint, when provided, must be a string.`)},HW=e=>{let t=e.bitrate instanceof KW?e.bitrate._toVideoBitrate(e.codec,e.width,e.height):e.bitrate;return{codec:e.fullCodecString??vz(e.codec,e.width,e.height,t),width:e.width,height:e.height,displayWidth:e.squarePixelWidth,displayHeight:e.squarePixelHeight,bitrate:t,bitrateMode:e.bitrateMode,alpha:e.alpha??`discard`,framerate:e.framerate,latencyMode:e.latencyMode,hardwareAcceleration:e.hardwareAcceleration,scalabilityMode:e.scalabilityMode,contentHint:e.contentHint,...Dz(e.codec)}},UW=e=>{if(!e||typeof e!=`object`)throw TypeError(`Encoding config must be an object.`);if(!uz.includes(e.codec))throw TypeError(`Invalid audio codec '${e.codec}'. Must be one of: ${uz.join(`, `)}.`);if(e.bitrate===void 0&&!(cz.includes(e.codec)||e.codec===`flac`))throw TypeError(`config.bitrate must be provided for compressed audio codecs.`);if(e.bitrate!==void 0&&!(e.bitrate instanceof KW)&&(!Number.isInteger(e.bitrate)||e.bitrate<=0))throw TypeError(`config.bitrate, when provided, must be a positive integer or a quality.`);if(e.transform!==void 0){if(typeof e.transform!=`object`||!e.transform)throw TypeError(`config.transform, when provided, must be an object.`);if(e.transform.numberOfChannels!==void 0&&(!Number.isInteger(e.transform.numberOfChannels)||e.transform.numberOfChannels<=0))throw TypeError(`config.transform.numberOfChannels, when provided, must be a positive integer.`);if(e.transform.sampleRate!==void 0&&(!Number.isInteger(e.transform.sampleRate)||e.transform.sampleRate<=0))throw TypeError(`config.transform.sampleRate, when provided, must be a positive integer.`);if(e.transform.sampleFormat!==void 0&&![`u8`,`s16`,`s32`,`f32`].includes(e.transform.sampleFormat))throw TypeError(`config.transform.sampleFormat, when provided, must be one of: u8, s16, s32, f32.`);if(e.transform.process!==void 0&&typeof e.transform.process!=`function`)throw TypeError(`config.transform.process, when provided, must be a function.`)}if(e.onEncodedPacket!==void 0&&typeof e.onEncodedPacket!=`function`)throw TypeError(`config.onEncodedPacket, when provided, must be a function.`);if(e.onEncoderConfig!==void 0&&typeof e.onEncoderConfig!=`function`)throw TypeError(`config.onEncoderConfig, when provided, must be a function.`);if(e.onEncodedSample!==void 0&&typeof e.onEncodedSample!=`function`)throw TypeError(`config.onEncodedSample, when provided, must be a function.`);WW(e.codec,e)},WW=(e,t)=>{if(!t||typeof t!=`object`)throw TypeError(`Encoding options must be an object.`);if(t.bitrateMode!==void 0&&![`constant`,`variable`].includes(t.bitrateMode))throw TypeError(`bitrateMode, when provided, must be 'constant' or 'variable'.`);if(t.fullCodecString!==void 0&&typeof t.fullCodecString!=`string`)throw TypeError(`fullCodecString, when provided, must be a string.`);if(t.fullCodecString!==void 0&&Ez(t.fullCodecString)!==e)throw TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${e}).`)},GW=e=>{let t=e.bitrate instanceof KW?e.bitrate._toAudioBitrate(e.codec):e.bitrate;return{codec:e.fullCodecString??xz(e.codec,e.numberOfChannels,e.sampleRate),numberOfChannels:e.numberOfChannels,sampleRate:e.sampleRate,bitrate:t,bitrateMode:e.bitrateMode,...Oz(e.codec)}},KW=class{constructor(e){this._factor=e}_toVideoBitrate(e,t,n){let r=3e6*(t*n/(1920*1080))**.95*{avc:1,hevc:.6,vp9:.6,av1:.4,vp8:1.2}[e]*this._factor;return Math.ceil(r/1e3)*1e3}_toAudioBitrate(e){if(cz.includes(e)||e===`flac`)return;let t={aac:128e3,opus:64e3,mp3:16e4,vorbis:64e3,ac3:384e3,eac3:192e3}[e];if(!t)throw Error(`Unhandled codec: ${e}`);let n=t*this._factor;return e===`aac`?n=[96e3,128e3,16e4,192e3].reduce((e,t)=>Math.abs(t-n)<Math.abs(e-n)?t:e):e===`opus`||e===`vorbis`?n=Math.max(6e3,n):e===`mp3`&&(n=[8e3,16e3,24e3,32e3,4e4,48e3,64e3,8e4,96e3,112e3,128e3,16e4,192e3,224e3,256e3,32e4].reduce((e,t)=>Math.abs(t-n)<Math.abs(e-n)?t:e)),Math.round(n/1e3)*1e3}},qW=new KW(2),JW=async(e,t={})=>{let{width:n=1280,height:r=720,bitrate:i=1e6,...a}=t;if(!sz.includes(e))return!1;if(!Number.isInteger(n)||n<=0)throw TypeError(`width must be a positive integer.`);if(!Number.isInteger(r)||r<=0)throw TypeError(`height must be a positive integer.`);if(!(i instanceof KW)&&(!Number.isInteger(i)||i<=0))throw TypeError(`bitrate must be a positive integer or a quality.`);VW(e,a);let o=HW({codec:e,width:n,height:r,bitrate:i,framerate:void 0,...a,alpha:`discard`}),s=JSON.stringify(o),c=RW.get(s);if(c)return c;let l=(async()=>eG.some(t=>t.supports(e,o))?!0:typeof VideoEncoder>`u`||(n%2==1||r%2==1)&&(e===`avc`||e===`hevc`)||!(await VideoEncoder.isConfigSupported(o)).supported?!1:AR()?new Promise(async e=>{try{let t=new VideoEncoder({output:()=>{},error:()=>e(!1)});t.configure(o);let i=new Uint8Array(n*r*4),a=new VideoFrame(i,{format:`RGBA`,codedWidth:n,codedHeight:r,timestamp:0});t.encode(a),a.close(),await t.flush(),e(!0)}catch{e(!1)}}):!0)();return RW.set(s,l),l},YW=async(e,t={})=>{let{numberOfChannels:n=2,sampleRate:r=48e3,bitrate:i=128e3,...a}=t;if(!uz.includes(e))return!1;if(!Number.isInteger(n)||n<=0)throw TypeError(`numberOfChannels must be a positive integer.`);if(!Number.isInteger(r)||r<=0)throw TypeError(`sampleRate must be a positive integer.`);if(!(i instanceof KW)&&(!Number.isInteger(i)||i<=0))throw TypeError(`bitrate must be a positive integer.`);WW(e,a);let o=GW({codec:e,numberOfChannels:n,sampleRate:r,bitrate:i,...a}),s=JSON.stringify(o),c=zW.get(s);if(c)return c;let l=(async()=>tG.some(t=>t.supports(e,o))||cz.includes(e)?!0:typeof AudioEncoder>`u`?!1:(await AudioEncoder.isConfigSupported(o)).supported===!0)();return zW.set(s,l),l},XW=async(e,t)=>{for(let n of e)if(await JW(n,t))return n;return null},ZW=async(e,t)=>{for(let n of e)if(await YW(n,t))return n;return null},QW=[],$W=[],eG=[],tG=[],nG=e=>{let t=8191,n=e,r=4096,i=0,a=12,o=0;for(n<0&&(n=-n,i=128),n+=33,n>t&&(n=t);(n&r)!==r&&a>=5;)r>>=1,a--;return o=n>>a-4&15,~(i|a-5<<4|o)&255},rG=e=>{let t=0,n=0,r=~e;r&128&&(r&=-129,t=-1),n=((r&240)>>4)+5;let i=(1<<n|(r&15)<<n-4|1<<n-5)-33;return t===0?i:-i},iG=e=>{let t=4095,n=2048,r=0,i=11,a=0,o=e;for(o<0&&(o=-o,r=128),o>t&&(o=t);(o&n)!==n&&i>=5;)n>>=1,i--;return a=o>>(i===4?1:i-4)&15,(r|i-4<<4|a)^85},aG=e=>{let t=0,n=0,r=e^85;r&128&&(r&=-129,t=-1),n=((r&240)>>4)+4;let i=0;return i=n===4?r<<1|1:1<<n|(r&15)<<n-4|1<<n-5,t===0?i:-i},oG=e=>{if(!e||typeof e!=`object`)throw TypeError(`options must be an object.`);if(e.metadataOnly!==void 0&&typeof e.metadataOnly!=`boolean`)throw TypeError(`options.metadataOnly, when defined, must be a boolean.`);if(e.verifyKeyPackets!==void 0&&typeof e.verifyKeyPackets!=`boolean`)throw TypeError(`options.verifyKeyPackets, when defined, must be a boolean.`);if(e.verifyKeyPackets&&e.metadataOnly)throw TypeError(`options.verifyKeyPackets and options.metadataOnly cannot be enabled together.`);if(e.skipLiveWait!==void 0&&typeof e.skipLiveWait!=`boolean`)throw TypeError(`options.skipLiveWait, when defined, must be a boolean.`)},sG=e=>{if(!VR(e))throw TypeError(`timestamp must be a number.`)},cG=(e,t,n)=>n.verifyKeyPackets?t.then(async t=>{if(!t||t.type===`delta`)return t;let n=await e.determinePacketType(t);return n&&(t.type=n),t}):t,lG=class{constructor(e){if(!(e instanceof CG))throw TypeError(`track must be an InputTrack.`);this._track=e}async getFirstPacket(e={}){if(oG(e),this._track.input._disposed)throw new FG;return cG(this._track,this._track._backing.getFirstPacket(e),e)}async getFirstKeyPacket(e={}){oG(e);let t=await this.getFirstPacket(e);return t?t.type===`key`?t:this.getNextKeyPacket(t,e):null}async getPacket(e,t={}){if(sG(e),oG(t),this._track.input._disposed)throw new FG;return cG(this._track,this._track._backing.getPacket(e,t),t)}async getNextPacket(e,t={}){if(!(e instanceof JB))throw TypeError(`packet must be an EncodedPacket.`);if(oG(t),this._track.input._disposed)throw new FG;return cG(this._track,this._track._backing.getNextPacket(e,t),t)}async getKeyPacket(e,t={}){if(sG(e),oG(t),this._track.input._disposed)throw new FG;if(!t.verifyKeyPackets)return this._track._backing.getKeyPacket(e,t);let n=await this._track._backing.getKeyPacket(e,t);return n&&(X(n.type===`key`),await this._track.determinePacketType(n)===`delta`?this.getKeyPacket(n.timestamp-1/await this._track.getTimeResolution(),t):n)}async getNextKeyPacket(e,t={}){if(!(e instanceof JB))throw TypeError(`packet must be an EncodedPacket.`);if(oG(t),this._track.input._disposed)throw new FG;if(!t.verifyKeyPackets)return this._track._backing.getNextKeyPacket(e,t);let n=await this._track._backing.getNextKeyPacket(e,t);return n&&(X(n.type===`key`),await this._track.determinePacketType(n)===`delta`?this.getNextKeyPacket(n,t):n)}packets(e,t,n={}){if(e!==void 0&&!(e instanceof JB))throw TypeError(`startPacket must be an EncodedPacket.`);if(e!==void 0&&e.isMetadataOnly&&!n?.metadataOnly)throw TypeError(`startPacket can only be metadata-only if options.metadataOnly is enabled.`);if(t!==void 0&&!(t instanceof JB))throw TypeError(`endPacket must be an EncodedPacket.`);if(oG(n),this._track.input._disposed)throw new FG;let r=[],{promise:i,resolve:a}=eR(),{promise:o,resolve:s}=eR(),c=!1,l=!1,u=null,d=[],f=()=>Math.max(2,d.length);(async()=>{let u=e??await this.getFirstPacket(n);for(;u&&!l&&!this._track.input._disposed&&!(t&&u.sequenceNumber>=t?.sequenceNumber);){if(r.length>f()){({promise:o,resolve:s}=eR()),await o;continue}r.push(u),a(),{promise:i,resolve:a}=eR(),u=await this.getNextPacket(u,n)}c=!0,a()})().catch(e=>{u||(u=e,a())});let p=this._track;return{async next(){for(;;)if(p.input._disposed)throw new FG;else if(l)return{value:void 0,done:!0};else if(u)throw u;else if(r.length>0){let e=r.shift(),t=performance.now();for(d.push(t);d.length>0&&t-d[0]>=1e3;)d.shift();return s(),{value:e,done:!1}}else if(c)return{value:void 0,done:!0};else await i},async return(){return l=!0,s(),a(),{value:void 0,done:!0}},async throw(e){throw e},[Symbol.asyncIterator](){return this}}}},uG=class{constructor(e,t){this.onSample=e,this.onError=t}},dG=class{mediaSamplesInRange(e=-1/0,t=1/0,n){sG(e),sG(t);let r=[],i=!1,a=null,{promise:o,resolve:s}=eR(),{promise:c,resolve:l}=eR(),u=!1,d=!1,f=!1,p=null,m={...n,verifyKeyPackets:!0,metadataOnly:!1};(async()=>{let n=await this._createDecoder(n=>{if(l(),n.timestamp>=t&&(d=!0),d){n.close();return}a&&(n.timestamp>e?(r.push(a),i=!0):a.close()),n.timestamp>=e&&(r.push(n),i=!0),a=i?null:n,r.length>0&&(s(),{promise:o,resolve:s}=eR())},e=>{p||(p=e,s())}),h=this._createPacketSink(),g=await h.getKeyPacket(e,m)??await h.getFirstKeyPacket(m),_=g,v=h.packets(g??void 0,void 0,m);for(await v.next();_&&!d&&!this._track.input._disposed;){let e=fG(r.length);if(r.length+n.getDecodeQueueSize()>e){({promise:c,resolve:l}=eR()),await c;continue}n.decode(_);let t=await v.next();if(t.done)break;_=t.value}await v.return(),!f&&!this._track.input._disposed&&await n.flush(),n.close(),!i&&a&&r.push(a),u=!0,s()})().catch(e=>{p||(p=e,s())});let h=this._track,g=()=>{a?.close();for(let e of r)e.close()};return{async next(){for(;;)if(h.input._disposed)throw g(),new FG;else if(f)return{value:void 0,done:!0};else if(p)throw g(),p;else if(r.length>0){let e=r.shift();return l(),{value:e,done:!1}}else if(!u)await o;else return{value:void 0,done:!0}},async return(){return f=!0,d=!0,l(),s(),g(),{value:void 0,done:!0}},async throw(e){throw e},[Symbol.asyncIterator](){return this}}}mediaSamplesAtTimestamps(e,t){aR(e);let n=iR(e),r=[],i=[],{promise:a,resolve:o}=eR(),{promise:s,resolve:c}=eR(),l=!1,u=!1,d=null,f=e=>{i.push(e),o(),{promise:a,resolve:o}=eR()},p={...t,verifyKeyPackets:!0,metadataOnly:!1};(async()=>{let e=await this._createDecoder(e=>{if(c(),u){e.close();return}let t=0;for(;r.length>0&&e.timestamp-r[0]>-1e-10;)t++,r.shift();if(t>0)for(let n=0;n<t;n++)f(n<t-1?e.clone():e);else e.close()},e=>{d||(d=e,o())}),t=this._createPacketSink(),a=null,m=null,h=-1,g=async()=>{X(m);let n=m;for(e.decode(n);n.sequenceNumber<h;){let r=fG(i.length);for(;i.length+e.getDecodeQueueSize()>r&&!u;)({promise:s,resolve:c}=eR()),await s;if(u)break;let a=await t.getNextPacket(n,p);X(a),e.decode(a),n=a}h=-1},_=async()=>{await e.flush();for(let e=0;e<r.length;e++)f(null);r.length=0};for await(let e of n){if(sG(e),u||this._track.input._disposed)break;let n=await t.getPacket(e,p),i=n&&await t.getKeyPacket(e,p);if(!i){h!==-1&&(await g(),await _()),f(null),a=null;continue}a&&(i.sequenceNumber!==m.sequenceNumber||n.timestamp<a.timestamp)&&(await g(),await _()),r.push(n.timestamp),h=Math.max(n.sequenceNumber,h),a=n,m=i}!u&&!this._track.input._disposed&&(h!==-1&&await g(),await _()),e.close(),l=!0,o()})().catch(e=>{d||(d=e,o())});let m=this._track,h=()=>{for(let e of i)e?.close()};return{async next(){for(;;)if(m.input._disposed)throw h(),new FG;else if(u)return{value:void 0,done:!0};else if(d)throw h(),d;else if(i.length>0){let e=i.shift();return X(e!==void 0),c(),{value:e,done:!1}}else if(!l)await a;else return{value:void 0,done:!0}},async return(){return u=!0,c(),o(),h(),{value:void 0,done:!0}},async throw(e){throw e},[Symbol.asyncIterator](){return this}}}},fG=e=>e===0?40:8,pG=class extends uG{constructor(e,t,n,r,i,a){super(e,t),this.codec=n,this.decoderConfig=r,this.rotation=i,this.timeResolution=a,this.decoder=null,this.customDecoder=null,this.customDecoderCallSerializer=new ER,this.customDecoderQueueSize=0,this.inputTimestamps=[],this.sampleQueue=[],this.currentPacketIndex=0,this.raslSkipped=!1,this.alphaDecoder=null,this.alphaHadKeyframe=!1,this.colorQueue=[],this.alphaQueue=[],this.merger=null,this.decodedAlphaChunkCount=0,this.alphaDecoderQueueSize=0,this.nullAlphaFrameQueue=[],this.currentAlphaPacketIndex=0,this.alphaRaslSkipped=!1,this.frameHandlerSerializer=new ER;let o=QW.find(e=>e.supports(n,r));if(o)this.customDecoder=new o,this.customDecoder.codec=n,this.customDecoder.config=r,this.customDecoder.onSample=e=>{if(!(e instanceof dW))throw TypeError(`The argument passed to onSample must be a VideoSample.`);this.finalizeAndEmitSample(e)},this.customDecoderCallSerializer.call(()=>this.customDecoder.init());else{let e=e=>{this.frameHandlerSerializer.call(async()=>{if(this.alphaQueue.length>0){let t=this.alphaQueue.shift();X(t!==void 0),await this.mergeAlpha(e,t)}else this.colorQueue.push(e)}).catch(e=>this.onError(e))};if(n===`avc`&&this.decoderConfig.description&&MR()){let e=cB(NL(this.decoderConfig.description));if(e&&e.sequenceParameterSets.length>0){let t=uB(e.sequenceParameterSets[0]);t&&t.frameMbsOnlyFlag===0&&(this.decoderConfig={...this.decoderConfig,hardwareAcceleration:`prefer-software`})}}let t=Error(`Decoding error`).stack;this.decoder=new VideoDecoder({output:t=>{try{e(t)}catch(e){this.onError(e)}},error:e=>{e.stack=t,this.onError(e)}}),this.decoder.configure(this.decoderConfig)}}getDecodeQueueSize(){return this.customDecoder?this.customDecoderQueueSize:(X(this.decoder),Math.max(this.decoder.decodeQueueSize,this.alphaDecoder?.decodeQueueSize??0))}decode(e){if(this.codec===`hevc`&&this.currentPacketIndex>0&&!this.raslSkipped){if(this.hasHevcRaslPicture(e.data))return;this.raslSkipped=!0}if(this.customDecoder)this.customDecoderQueueSize++,this.customDecoderCallSerializer.call(()=>this.customDecoder.decode(e)).then(()=>this.customDecoderQueueSize--);else{if(X(this.decoder),OR()||$L(this.inputTimestamps,e.timestamp,e=>e),MR()&&this.currentPacketIndex===0){if(this.codec===`avc`){let t=[];for(let n of $z(e.data,this.decoderConfig)){let r=eB(e.data[n.offset]);r===Yz.AUD&&(t.length=0),r>=20&&r<=31||t.push(e.data.subarray(n.offset,n.offset+n.length))}e=new JB(aB(t,this.decoderConfig),e.type,e.timestamp,e.duration)}else if(this.codec===`hevc`){let t=EB(e.data,this.decoderConfig);t&&(e=new JB(t,e.type,e.timestamp,e.duration))}}this.decoder.decode(e.toEncodedVideoChunk()),this.decodeAlphaData(e)}this.currentPacketIndex++}decodeAlphaData(e){if(!e.sideData.alpha){this.pushNullAlphaFrame();return}if(this.merger||=new hG,!this.alphaDecoder){let e=e=>{this.frameHandlerSerializer.call(async()=>{if(this.colorQueue.length>0){let t=this.colorQueue.shift();X(t!==void 0),await this.mergeAlpha(t,e)}else this.alphaQueue.push(e);for(this.decodedAlphaChunkCount++;this.nullAlphaFrameQueue.length>0&&this.nullAlphaFrameQueue[0]===this.decodedAlphaChunkCount;)if(this.nullAlphaFrameQueue.shift(),this.colorQueue.length>0){let e=this.colorQueue.shift();X(e!==void 0),await this.mergeAlpha(e,null)}else this.alphaQueue.push(null);this.alphaDecoderQueueSize--}).catch(e=>this.onError(e))},t=Error(`Decoding error`).stack;this.alphaDecoder=new VideoDecoder({output:t=>{try{e(t)}catch(e){this.onError(e)}},error:e=>{e.stack=t,this.onError(e)}}),this.alphaDecoder.configure(this.decoderConfig)}let t=PB(this.codec,this.decoderConfig,e.sideData.alpha);if(this.alphaHadKeyframe||=t===`key`,this.alphaHadKeyframe){if(this.codec===`hevc`&&this.currentAlphaPacketIndex>0&&!this.alphaRaslSkipped){if(this.hasHevcRaslPicture(e.sideData.alpha)){this.pushNullAlphaFrame();return}this.alphaRaslSkipped=!0}this.currentAlphaPacketIndex++,this.alphaDecoder.decode(e.alphaToEncodedVideoChunk(t??e.type)),this.alphaDecoderQueueSize++}else this.pushNullAlphaFrame()}pushNullAlphaFrame(){this.alphaDecoderQueueSize===0?this.alphaQueue.push(null):this.nullAlphaFrameQueue.push(this.decodedAlphaChunkCount+this.alphaDecoderQueueSize)}hasHevcRaslPicture(e){for(let t of pB(e,this.decoderConfig)){let n=mB(e[t.offset]);if(n===Xz.RASL_N||n===Xz.RASL_R)return!0}return!1}sampleHandler(e){if(OR()){if(this.sampleQueue.length>0&&e.timestamp>=AL(this.sampleQueue).timestamp){for(let e of this.sampleQueue)this.finalizeAndEmitSample(e);this.sampleQueue.length=0}$L(this.sampleQueue,e,e=>e.timestamp)}else{let t=this.inputTimestamps.shift();X(t!==void 0),e.setTimestamp(t),this.finalizeAndEmitSample(e)}}finalizeAndEmitSample(e){e.setTimestamp(Math.round(e.timestamp*this.timeResolution)/this.timeResolution),e.setDuration(Math.round(e.duration*this.timeResolution)/this.timeResolution),e.setRotation(this.rotation),this.onSample(e)}async mergeAlpha(e,t){if(!t){let t=new dW(e);this.sampleHandler(t);return}X(this.merger);let n=new dW(await this.merger.update(e,t));this.sampleHandler(n)}async flush(){if(this.customDecoder?await this.customDecoderCallSerializer.call(()=>this.customDecoder.flush()):(X(this.decoder),await Promise.all([this.decoder.flush(),this.alphaDecoder?.flush()]),await this.frameHandlerSerializer.currentPromise,this.colorQueue.forEach(e=>e.close()),this.colorQueue.length=0,this.alphaQueue.forEach(e=>e?.close()),this.alphaQueue.length=0,this.alphaHadKeyframe=!1,this.decodedAlphaChunkCount=0,this.alphaDecoderQueueSize=0,this.nullAlphaFrameQueue.length=0,this.currentAlphaPacketIndex=0,this.alphaRaslSkipped=!1),OR()){for(let e of this.sampleQueue)this.finalizeAndEmitSample(e);this.sampleQueue.length=0}this.currentPacketIndex=0,this.raslSkipped=!1}close(){this.customDecoder?this.customDecoderCallSerializer.call(()=>this.customDecoder.close()):(X(this.decoder),this.decoder.close(),this.alphaDecoder?.close(),this.colorQueue.forEach(e=>e.close()),this.colorQueue.length=0,this.alphaQueue.forEach(e=>e?.close()),this.alphaQueue.length=0,this.merger?.close());for(let e of this.sampleQueue)e.close();this.sampleQueue.length=0}},mG=!1,hG=class e{constructor(){this.canvas=null,this.gl=null,this.program=null,this.vao=null,this.colorTexture=null,this.alphaTexture=null,this.worker=null,this.pendingRequests=new Map,this.nextRequestId=0;let t=typeof OffscreenCanvas<`u`||typeof document<`u`&&typeof document.createElement==`function`;if(!e.forceCpu&&t&&!mG)try{typeof OffscreenCanvas<`u`?this.canvas=new OffscreenCanvas(300,150):this.canvas=document.createElement(`canvas`);let e=this.canvas.getContext(`webgl2`,{premultipliedAlpha:!1});if(!e)throw Error(`Couldn't acquire WebGL 2 context.`);this.gl=e,this.program=this.createProgram(),this.vao=this.createVAO(),this.colorTexture=this.createTexture(),this.alphaTexture=this.createTexture(),this.gl.useProgram(this.program),this.gl.uniform1i(this.gl.getUniformLocation(this.program,`u_colorTexture`),0),this.gl.uniform1i(this.gl.getUniformLocation(this.program,`u_alphaTexture`),1)}catch(e){this.gl=null,this.canvas=null,mG=!0,console.warn(`Falling back to CPU for color/alpha merging.`,e)}}async update(e,t){return this.gl?this.updateGpu(e,t):this.updateCpu(e,t)}createProgram(){X(this.gl);let e=this.createShader(this.gl.VERTEX_SHADER,`#version 300 es
|
|
386
|
+
in vec2 a_position;
|
|
387
|
+
in vec2 a_texCoord;
|
|
388
|
+
out vec2 v_texCoord;
|
|
389
|
+
|
|
390
|
+
void main() {
|
|
391
|
+
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
392
|
+
v_texCoord = a_texCoord;
|
|
393
|
+
}
|
|
394
|
+
`),t=this.createShader(this.gl.FRAGMENT_SHADER,`#version 300 es
|
|
395
|
+
precision highp float;
|
|
396
|
+
|
|
397
|
+
uniform sampler2D u_colorTexture;
|
|
398
|
+
uniform sampler2D u_alphaTexture;
|
|
399
|
+
in vec2 v_texCoord;
|
|
400
|
+
out vec4 fragColor;
|
|
401
|
+
|
|
402
|
+
void main() {
|
|
403
|
+
vec3 color = texture(u_colorTexture, v_texCoord).rgb;
|
|
404
|
+
float alpha = texture(u_alphaTexture, v_texCoord).r;
|
|
405
|
+
fragColor = vec4(color, alpha);
|
|
406
|
+
}
|
|
407
|
+
`),n=this.gl.createProgram();return this.gl.attachShader(n,e),this.gl.attachShader(n,t),this.gl.linkProgram(n),n}createShader(e,t){X(this.gl);let n=this.gl.createShader(e);return this.gl.shaderSource(n,t),this.gl.compileShader(n),n}createVAO(){X(this.gl),X(this.program);let e=this.gl.createVertexArray();this.gl.bindVertexArray(e);let t=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,1,1,1,0]),n=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,n),this.gl.bufferData(this.gl.ARRAY_BUFFER,t,this.gl.STATIC_DRAW);let r=this.gl.getAttribLocation(this.program,`a_position`),i=this.gl.getAttribLocation(this.program,`a_texCoord`);return this.gl.enableVertexAttribArray(r),this.gl.vertexAttribPointer(r,2,this.gl.FLOAT,!1,16,0),this.gl.enableVertexAttribArray(i),this.gl.vertexAttribPointer(i,2,this.gl.FLOAT,!1,16,8),e}createTexture(){X(this.gl);let e=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),e}updateGpu(e,t){X(this.gl),X(this.canvas),(e.displayWidth!==this.canvas.width||e.displayHeight!==this.canvas.height)&&(this.canvas.width=e.displayWidth,this.canvas.height=e.displayHeight),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.colorTexture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.gl.activeTexture(this.gl.TEXTURE1),this.gl.bindTexture(this.gl.TEXTURE_2D,this.alphaTexture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,t),this.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.bindVertexArray(this.vao),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4);let n=new VideoFrame(this.canvas,{timestamp:e.timestamp,duration:e.duration??void 0});return e.close(),t.close(),n}updateCpu(e,t){if(!this.worker){let e=new Blob([`(${gG.toString()})()`],{type:`application/javascript`}),t=URL.createObjectURL(e);this.worker=new Worker(t),URL.revokeObjectURL(t),this.worker.addEventListener(`message`,e=>{let t=e.data,n=this.pendingRequests.get(t.id);n&&(this.pendingRequests.delete(t.id),`error`in t?n.reject(Error(t.error)):n.resolve(t.frame))}),this.worker.addEventListener(`error`,e=>{let t=Error(e.message||`Color/alpha merge worker error.`);for(let e of this.pendingRequests.values())e.reject(t);this.pendingRequests.clear()})}let n=this.nextRequestId++,r=eR();return this.pendingRequests.set(n,r),this.worker.postMessage({id:n,color:e,alpha:t},{transfer:[e,t]}),r.promise}close(){this.gl?.getExtension(`WEBGL_lose_context`)?.loseContext(),this.gl=null,this.canvas=null,this.worker?.terminate(),this.worker=null;let e=Error(`Color/alpha merger closed.`);for(let t of this.pendingRequests.values())t.reject(e);this.pendingRequests.clear()}};hG.forceCpu=!0;var gG=()=>{let e=null,t=null,n=Promise.resolve();self.addEventListener(`message`,e=>{let{id:t,color:i,alpha:a}=e.data;n=n.then(async()=>{try{let e=await r(i,a);self.postMessage({id:t,frame:e},{transfer:[e]})}catch(e){self.postMessage({id:t,error:e.message})}finally{i.close(),a.close()}})});let r=async(e,t)=>{let n=e.format,r=t.format;if(!n||!r)throw Error(`CPU color/alpha merging requires a known VideoFrame format.`);let s=n.includes(`P10`),c=n.includes(`P12`),l=r.includes(`P10`),u=r.includes(`P12`);if(l!==s||u!==c)throw Error(`CPU color/alpha merging requires the alpha frame to have the same bit depth as the color frame (color: '${n}', alpha: '${r}').`);let d=e.visibleRect?e.visibleRect.width:e.codedWidth,f=e.visibleRect?e.visibleRect.height:e.codedHeight;if(n===`RGBX`||n===`RGBA`||n===`BGRX`||n===`BGRA`)return await i(e,t,d,f,n);if(n===`I420`||n===`I420P10`||n===`I420P12`||n===`I422`||n===`I422P10`||n===`I422P12`||n===`I444`||n===`I444P10`||n===`I444P12`)return await a(e,t,d,f,n);if(n===`NV12`)return await o(e,t,d,f);throw Error(`CPU color/alpha merging does not support format '${n}'.`)},i=async(e,t,n,r,i)=>{let a=n*r,o=new Uint8Array(a*4);await e.copyTo(o);let c=await s(t,n,r,1);for(let e=0,t=3;e<a;e++,t+=4)o[t]=c[e];let l={format:i===`RGBX`||i===`RGBA`?`RGBA`:`BGRA`,codedWidth:n,codedHeight:r,timestamp:e.timestamp,duration:e.duration??void 0,transfer:[o.buffer]};return new VideoFrame(o,l)},a=async(e,t,n,r,i)=>{let a=i.includes(`P10`),o=i.includes(`P12`),c=a||o?2:1,l,u;i.startsWith(`I420`)?(l=Math.ceil(n/2),u=Math.ceil(r/2)):i.startsWith(`I422`)?(l=Math.ceil(n/2),u=r):(l=n,u=r);let d=n*r,f=l*u,p=d*c,m=f*c,h=d*c,g=p+2*m+h,_=new Uint8Array(g);await e.copyTo(_);let v=await s(t,n,r,c),y=p+2*m;_.set(v,y);let b={format:i.slice(0,4)+`A`+i.slice(4),codedWidth:n,codedHeight:r,timestamp:e.timestamp,duration:e.duration??void 0,transfer:[_.buffer]};return new VideoFrame(_,b)},o=async(e,n,r,i)=>{let a=r*i,o=Math.ceil(r/2)*Math.ceil(i/2),c=e.allocationSize();(!t||t.byteLength!==c)&&(t=new Uint8Array(c)),await e.copyTo(t);let l=new Uint8Array(a+2*o+a);l.set(t.subarray(0,a),0);let u=a,d=a+o,f=a;for(let e=0;e<o;e++)l[u+e]=t[f+e*2],l[d+e]=t[f+e*2+1];let p=await s(n,r,i,1);l.set(p,a+2*o);let m={format:`I420A`,codedWidth:r,codedHeight:i,timestamp:e.timestamp,duration:e.duration??void 0,transfer:[l.buffer]};return new VideoFrame(l,m)},s=async(t,n,r,i)=>{let a=t.allocationSize();(!e||e.byteLength!==a)&&(e=new Uint8Array(a)),await t.copyTo(e);let o=t.format;if(o===`RGBA`||o===`BGRA`||o===`RGBX`||o===`BGRX`){let t=o===`RGBA`||o===`RGBX`?0:2,i=n*r;for(let n=0;n<i;n++)e[n]=e[n*4+t];return e.subarray(0,i)}else return e.subarray(0,n*r*i)}},_G=class extends dG{constructor(e){if(!(e instanceof EG))throw TypeError(`videoTrack must be an InputVideoTrack.`);super(),this._track=e}async _createDecoder(e,t){if(!await this._track.canDecode())throw Error(`This video track cannot be decoded by this browser. Make sure to check decodability before using a track.`);let n=await this._track.getCodec(),r=await this._track.getRotation(),i=await this._track.getDecoderConfig(),a=await this._track.getTimeResolution();return X(n&&i),new pG(e,t,n,i,r,a)}_createPacketSink(){return new lG(this._track)}async getSample(e,t={}){sG(e);for await(let n of this.mediaSamplesAtTimestamps([e],t))return n;throw Error(`Internal error: Iterator returned nothing.`)}samples(e,t,n={}){return this.mediaSamplesInRange(e,t,n)}samplesAtTimestamps(e,t={}){return this.mediaSamplesAtTimestamps(e,t)}},vG=class{constructor(e,t={}){if(this._rotation=0,this._initPromise=null,this._nextCanvasIndex=0,!(e instanceof EG))throw TypeError(`videoTrack must be an InputVideoTrack.`);if(t&&typeof t!=`object`)throw TypeError(`options must be an object.`);if(t.alpha!==void 0&&typeof t.alpha!=`boolean`)throw TypeError(`options.alpha, when provided, must be a boolean.`);if(t.width!==void 0&&(!Number.isInteger(t.width)||t.width<=0))throw TypeError(`options.width, when defined, must be a positive integer.`);if(t.height!==void 0&&(!Number.isInteger(t.height)||t.height<=0))throw TypeError(`options.height, when defined, must be a positive integer.`);if(t.fit!==void 0&&![`fill`,`contain`,`cover`].includes(t.fit))throw TypeError(`options.fit, when provided, must be one of "fill", "contain", or "cover".`);if(t.width!==void 0&&t.height!==void 0&&t.fit===void 0)throw TypeError(`When both options.width and options.height are provided, options.fit must also be provided.`);if(t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw TypeError(`options.rotation, when provided, must be 0, 90, 180 or 270.`);if(t.crop!==void 0&&yW(t.crop,`options.`),t.poolSize!==void 0&&(typeof t.poolSize!=`number`||!Number.isInteger(t.poolSize)||t.poolSize<0))throw TypeError(`poolSize must be a non-negative integer.`);this._videoTrack=e,this._alpha=t.alpha??!1,this._options=t,this._fit=t.fit??`fill`,this._videoSampleSink=new _G(e),this._canvasPool=Array.from({length:t.poolSize??0},()=>null)}_ensureInit(){return this._initPromise??=(async()=>{let e=this._options,t=this._videoTrack,n=e.rotation??await t.getRotation(),r=await t.getSquarePixelWidth(),i=await t.getSquarePixelHeight(),[a,o]=n%180==0?[r,i]:[i,r],s=e.crop;s&&=vW(s,a,o);let[c,l]=s?[s.width,s.height]:[a,o],u=c/l;e.width!==void 0&&e.height===void 0?(c=e.width,l=Math.round(c/u)):e.width===void 0&&e.height!==void 0?(l=e.height,c=Math.round(l*u)):e.width!==void 0&&e.height!==void 0&&(c=e.width,l=e.height),this._width=c,this._height=l,this._rotation=n,this._crop=s})()}_videoSampleToWrappedCanvas(e){let t=this._width,n=this._height,r=this._canvasPool[this._nextCanvasIndex],i=!1;r||(typeof document<`u`?(r=document.createElement(`canvas`),r.width=t,r.height=n):r=new OffscreenCanvas(t,n),this._canvasPool.length>0&&(this._canvasPool[this._nextCanvasIndex]=r),i=!0),this._canvasPool.length>0&&(this._nextCanvasIndex=(this._nextCanvasIndex+1)%this._canvasPool.length);let a=r.getContext(`2d`,{alpha:this._alpha||AR()});X(a),a.resetTransform(),i||(!this._alpha&&AR()?(a.fillStyle=`black`,a.fillRect(0,0,t,n)):a.clearRect(0,0,t,n)),e.drawWithFit(a,{fit:this._fit,rotation:this._rotation,crop:this._crop});let o={canvas:r,timestamp:e.timestamp,duration:e.duration};return e.close(),o}async getCanvas(e,t){sG(e),await this._ensureInit();let n=await this._videoSampleSink.getSample(e,t);return n&&this._videoSampleToWrappedCanvas(n)}async*canvases(e,t,n){await this._ensureInit(),yield*dR(this._videoSampleSink.samples(e,t,n),e=>this._videoSampleToWrappedCanvas(e))}async*canvasesAtTimestamps(e,t){await this._ensureInit(),yield*dR(this._videoSampleSink.samplesAtTimestamps(e,t),e=>e&&this._videoSampleToWrappedCanvas(e))}},yG=class extends uG{constructor(e,t,n,r){super(e,t),this.decoder=null,this.customDecoder=null,this.customDecoderCallSerializer=new ER,this.customDecoderQueueSize=0,this.currentTimestamp=null,this.expectedFirstTimestamp=null,this.timestampOffset=0;let i=t=>{let n=t.timestamp;this.expectedFirstTimestamp&&this.currentTimestamp===null&&(this.timestampOffset=this.expectedFirstTimestamp-n),n+=this.timestampOffset,(this.currentTimestamp===null||Math.abs(n-this.currentTimestamp)>=t.duration)&&(this.currentTimestamp=n);let i=this.currentTimestamp;if(this.currentTimestamp+=t.duration,t.numberOfFrames===0){t.close();return}let a=r.sampleRate;t.setTimestamp(Math.round(i*a)/a),e(t)},a=$W.find(e=>e.supports(n,r));if(a)this.customDecoder=new a,this.customDecoder.codec=n,this.customDecoder.config=r,this.customDecoder.onSample=e=>{if(!(e instanceof kW))throw TypeError(`The argument passed to onSample must be an AudioSample.`);i(e)},this.customDecoderCallSerializer.call(()=>this.customDecoder.init());else{let e=Error(`Decoding error`).stack;this.decoder=new AudioDecoder({output:e=>{try{i(new kW(e))}catch(e){this.onError(e)}},error:t=>{t.stack=e,this.onError(t)}}),this.decoder.configure(r)}}getDecodeQueueSize(){return this.customDecoder?this.customDecoderQueueSize:(X(this.decoder),this.decoder.decodeQueueSize)}decode(e){this.customDecoder?(this.customDecoderQueueSize++,this.customDecoderCallSerializer.call(()=>this.customDecoder.decode(e)).then(()=>this.customDecoderQueueSize--)):(X(this.decoder),this.expectedFirstTimestamp??=e.timestamp,this.decoder.decode(e.toEncodedAudioChunk()))}async flush(){this.customDecoder?await this.customDecoderCallSerializer.call(()=>this.customDecoder.flush()):(X(this.decoder),await this.decoder.flush()),this.currentTimestamp=null,this.expectedFirstTimestamp=null,this.timestampOffset=0}close(){this.customDecoder?this.customDecoderCallSerializer.call(()=>this.customDecoder.close()):(X(this.decoder),this.decoder.close())}},bG=class extends uG{constructor(e,t,n){super(e,t),this.decoderConfig=n,this.currentTimestamp=null,X(cz.includes(n.codec)),this.codec=n.codec;let{dataType:r,sampleSize:i,littleEndian:a}=Tz(this.codec);switch(this.inputSampleSize=i,i){case 1:r===`unsigned`?this.readInputValue=(e,t)=>e.getUint8(t)-2**7:r===`signed`?this.readInputValue=(e,t)=>e.getInt8(t):r===`ulaw`?this.readInputValue=(e,t)=>rG(e.getUint8(t)):r===`alaw`?this.readInputValue=(e,t)=>aG(e.getUint8(t)):X(!1);break;case 2:r===`unsigned`?this.readInputValue=(e,t)=>e.getUint16(t,a)-2**15:r===`signed`?this.readInputValue=(e,t)=>e.getInt16(t,a):X(!1);break;case 3:r===`unsigned`?this.readInputValue=(e,t)=>sR(e,t,a)-2**23:r===`signed`?this.readInputValue=(e,t)=>cR(e,t,a):X(!1);break;case 4:r===`unsigned`?this.readInputValue=(e,t)=>e.getUint32(t,a)-2**31:r===`signed`?this.readInputValue=(e,t)=>e.getInt32(t,a):r===`float`?this.readInputValue=(e,t)=>e.getFloat32(t,a):X(!1);break;case 8:r===`float`?this.readInputValue=(e,t)=>e.getFloat64(t,a):X(!1);break;default:oR(i),X(!1)}switch(i){case 1:r===`ulaw`||r===`alaw`?(this.outputSampleSize=2,this.outputFormat=`s16`,this.writeOutputValue=(e,t,n)=>e.setInt16(t,n,!0)):(this.outputSampleSize=1,this.outputFormat=`u8`,this.writeOutputValue=(e,t,n)=>e.setUint8(t,n+2**7));break;case 2:this.outputSampleSize=2,this.outputFormat=`s16`,this.writeOutputValue=(e,t,n)=>e.setInt16(t,n,!0);break;case 3:this.outputSampleSize=4,this.outputFormat=`s32`,this.writeOutputValue=(e,t,n)=>e.setInt32(t,n<<8,!0);break;case 4:this.outputSampleSize=4,r===`float`?(this.outputFormat=`f32`,this.writeOutputValue=(e,t,n)=>e.setFloat32(t,n,!0)):(this.outputFormat=`s32`,this.writeOutputValue=(e,t,n)=>e.setInt32(t,n,!0));break;case 8:this.outputSampleSize=4,this.outputFormat=`f32`,this.writeOutputValue=(e,t,n)=>e.setFloat32(t,n,!0);break;default:oR(i),X(!1)}}getDecodeQueueSize(){return 0}decode(e){let t=PL(e.data),n=e.byteLength/this.decoderConfig.numberOfChannels/this.inputSampleSize,r=n*this.decoderConfig.numberOfChannels*this.outputSampleSize,i=new ArrayBuffer(r),a=new DataView(i);for(let e=0;e<n*this.decoderConfig.numberOfChannels;e++){let n=e*this.inputSampleSize,r=e*this.outputSampleSize,i=this.readInputValue(t,n);this.writeOutputValue(a,r,i)}let o=n/this.decoderConfig.sampleRate;(this.currentTimestamp===null||Math.abs(e.timestamp-this.currentTimestamp)>=o)&&(this.currentTimestamp=e.timestamp);let s=this.currentTimestamp;this.currentTimestamp+=o;let c=new kW({format:this.outputFormat,data:i,numberOfChannels:this.decoderConfig.numberOfChannels,sampleRate:this.decoderConfig.sampleRate,numberOfFrames:n,timestamp:s});this.onSample(c)}async flush(){}close(){}},xG=class extends dG{constructor(e){if(!(e instanceof DG))throw TypeError(`audioTrack must be an InputAudioTrack.`);super(),this._track=e}async _createDecoder(e,t){if(!await this._track.canDecode())throw Error(`This audio track cannot be decoded by this browser. Make sure to check decodability before using a track.`);let n=await this._track.getCodec(),r=await this._track.getDecoderConfig();return X(n&&r),cz.includes(r.codec)?new bG(e,t,r):new yG(e,t,n,r)}_createPacketSink(){return new lG(this._track)}async getSample(e,t={}){sG(e);for await(let n of this.mediaSamplesAtTimestamps([e],t))return n;throw Error(`Internal error: Iterator returned nothing.`)}samples(e,t,n={}){return this.mediaSamplesInRange(e,t,n)}samplesAtTimestamps(e,t={}){return this.mediaSamplesAtTimestamps(e,t)}},SG=class{constructor(e){if(!(e instanceof DG))throw TypeError(`audioTrack must be an InputAudioTrack.`);this._audioSampleSink=new xG(e)}_audioSampleToWrappedArrayBuffer(e){let t={buffer:e.toAudioBuffer(),timestamp:e.timestamp,duration:e.duration};return e.close(),t}async getBuffer(e,t){sG(e);let n=await this._audioSampleSink.getSample(e,t);return n&&this._audioSampleToWrappedArrayBuffer(n)}buffers(e,t,n){return dR(this._audioSampleSink.samples(e,t,n),e=>this._audioSampleToWrappedArrayBuffer(e))}buffersAtTimestamps(e,t){return dR(this._audioSampleSink.samplesAtTimestamps(e,t),e=>e&&this._audioSampleToWrappedArrayBuffer(e))}},CG=class e{constructor(e,t){this.input=e,this._backing=t}isVideoTrack(){return this instanceof EG}isAudioTrack(){return this instanceof DG}get id(){return this._backing.getId()}get number(){return this._backing.getNumber()}async getInternalCodecId(){return this._backing.getInternalCodecId()}get internalCodecId(){return wG(this._backing.getInternalCodecId(),`internalCodecId`,`getInternalCodecId`)}async getLanguageCode(){return this._backing.getLanguageCode()}get languageCode(){return wG(this._backing.getLanguageCode(),`languageCode`,`getLanguageCode`)}async getName(){return this._backing.getName()}get name(){return wG(this._backing.getName(),`name`,`getName`)}async getTimeResolution(){return this._backing.getTimeResolution()}get timeResolution(){return wG(this._backing.getTimeResolution(),`timeResolution`,`getTimeResolution`)}async isRelativeToUnixEpoch(){return this._backing.isRelativeToUnixEpoch()}async getDisposition(){return this._backing.getDisposition()}get disposition(){return wG(this._backing.getDisposition(),`disposition`,`getDisposition`)}async getBitrate(){return this._backing.getBitrate()}async getAverageBitrate(){return this._backing.getAverageBitrate()}async getFirstTimestamp(){return(await this._backing.getFirstPacket({metadataOnly:!0}))?.timestamp??0}async computeDuration(e){let t=await this._backing.getPacket(1/0,{metadataOnly:!0,...e});return hR((t?.timestamp??0)+(t?.duration??0),await this.getTimeResolution())}async getDurationFromMetadata(e={}){return this._backing.getDurationFromMetadata(e)}async computePacketStats(e=1/0,t){let n=new lG(this),r=1/0,i=-1/0,a=0,o=0;for await(let s of n.packets(void 0,void 0,{metadataOnly:!0,...t})){if(a>=e&&s.timestamp>=i)break;r=Math.min(r,s.timestamp),i=Math.max(i,s.timestamp+s.duration),a++,o+=s.byteLength}return{packetCount:a,averagePacketRate:a?Number((a/(i-r)).toPrecision(16)):0,averageBitrate:a?Number((8*o/(i-r)).toPrecision(16)):0}}async isLive(){return await this._backing.getLiveRefreshInterval()!==null}async getLiveRefreshInterval(){return this._backing.getLiveRefreshInterval()}canBePairedWith(t){if(!(t instanceof e))throw TypeError(`other must be an InputTrack.`);return this.input!==t.input||this===t?!1:(this._backing.getPairingMask()&t._backing.getPairingMask())!==0n}async getPairableTracks(e){return this.input.getTracks(jG({filter:e=>e.canBePairedWith(this)},e))}async getPairableVideoTracks(e){return this.input.getVideoTracks(jG({filter:e=>e.canBePairedWith(this)},e))}async getPairableAudioTracks(e){return this.input.getAudioTracks(jG({filter:e=>e.canBePairedWith(this)},e))}async getPrimaryPairableVideoTrack(e){return this.input.getPrimaryVideoTrack(jG({filter:e=>e.canBePairedWith(this)},e))}async getPrimaryPairableAudioTrack(e){return this.input.getPrimaryAudioTrack(jG({filter:e=>e.canBePairedWith(this)},e))}async hasPairableTrack(e){e&&=TG(e);let t=await this.input.getTracks();for(let n of t)if(this.canBePairedWith(n)&&(!e||await e(n)))return!0;return!1}hasPairableVideoTrack(e){return e&&=TG(e),this.hasPairableTrack(async t=>t.isVideoTrack()&&(!e||await e(t)))}hasPairableAudioTrack(e){return e&&=TG(e),this.hasPairableTrack(async t=>t.isAudioTrack()&&(!e||await e(t)))}},wG=(e,t,n)=>{if(e instanceof Promise)throw Error(`'${t}' is deprecated and not available synchronously for this track. Use the preferred '${n}()' instead.`);return e},TG=e=>{if(e!==void 0&&typeof e!=`function`)throw TypeError(`predicate, when provided, must be a function.`);return e?t=>{let n=e=>{if(typeof e!=`boolean`)throw TypeError(`predicate must return or resolve to a boolean value.`);return e},r=e(t);return r instanceof Promise?r.then(n):n(r)}:void 0},EG=class extends CG{constructor(e,t){super(e,t),this._pixelAspectRatioCache=null,this._backing=t}get type(){return`video`}async getCodec(){return this._backing.getCodec()}get codec(){return wG(this._backing.getCodec(),`codec`,`getCodec`)}async hasOnlyKeyPackets(){return await this._backing.getHasOnlyKeyPackets?.()??!1}async getCodedWidth(){return this._backing.getCodedWidth()}get codedWidth(){return wG(this._backing.getCodedWidth(),`codedWidth`,`getCodedWidth`)}async getCodedHeight(){return this._backing.getCodedHeight()}get codedHeight(){return wG(this._backing.getCodedHeight(),`codedHeight`,`getCodedHeight`)}async getRotation(){return this._backing.getRotation()}get rotation(){return wG(this._backing.getRotation(),`rotation`,`getRotation`)}async getSquarePixelWidth(){return this._backing.getSquarePixelWidth()}get squarePixelWidth(){return wG(this._backing.getSquarePixelWidth(),`squarePixelWidth`,`getSquarePixelWidth`)}async getSquarePixelHeight(){return this._backing.getSquarePixelHeight()}get squarePixelHeight(){return wG(this._backing.getSquarePixelHeight(),`squarePixelHeight`,`getSquarePixelHeight`)}async getPixelAspectRatio(){return this._pixelAspectRatioCache??=GR({num:await this.getSquarePixelWidth()*await this.getCodedHeight(),den:await this.getSquarePixelHeight()*await this.getCodedWidth()})}get pixelAspectRatio(){return this._pixelAspectRatioCache??=GR({num:wG(this._backing.getSquarePixelWidth(),`pixelAspectRatio`,`getPixelAspectRatio`)*wG(this._backing.getCodedHeight(),`pixelAspectRatio`,`getPixelAspectRatio`),den:wG(this._backing.getSquarePixelHeight(),`pixelAspectRatio`,`getPixelAspectRatio`)*wG(this._backing.getCodedWidth(),`pixelAspectRatio`,`getPixelAspectRatio`)})}async getDisplayWidth(){return await this._backing.getMetadataDisplayWidth?.()??(await this.getRotation()%180==0?this.getSquarePixelWidth():this.getSquarePixelHeight())}get displayWidth(){let e=this._backing.getMetadataDisplayWidth?.();if(e!==void 0){let t=wG(e,`displayWidth`,`getDisplayWidth`);if(t!==null)return t}return wG(wG(this._backing.getRotation(),`displayWidth`,`getDisplayWidth`)%180==0?this._backing.getSquarePixelWidth():this._backing.getSquarePixelHeight(),`displayWidth`,`getDisplayWidth`)}async getDisplayHeight(){return await this._backing.getMetadataDisplayHeight?.()??(await this.getRotation()%180==0?this.getSquarePixelHeight():this.getSquarePixelWidth())}get displayHeight(){let e=this._backing.getMetadataDisplayHeight?.();if(e!==void 0){let t=wG(e,`displayHeight`,`getDisplayHeight`);if(t!==null)return t}return wG(wG(this._backing.getRotation(),`displayHeight`,`getDisplayHeight`)%180==0?this._backing.getSquarePixelHeight():this._backing.getSquarePixelWidth(),`displayHeight`,`getDisplayHeight`)}async getColorSpace(){return this._backing.getColorSpace()}async hasHighDynamicRange(){let e=await this._backing.getColorSpace();return e.primaries===`bt2020`||e.primaries===`smpte432`||e.transfer===`pq`||e.transfer===`hlg`||e.matrix===`bt2020-ncl`}async canBeTransparent(){return this._backing.canBeTransparent()}async getDecoderConfig(){return this._backing.getDecoderConfig()}async getCodecParameterString(){return await this._backing.getMetadataCodecParameterString?.()??(await this._backing.getDecoderConfig())?.codec??null}async canDecode(){try{let e=await this._backing.getDecoderConfig();if(!e)return!1;let t=await this._backing.getCodec();return X(t!==null),QW.some(n=>n.supports(t,e))?!0:typeof VideoDecoder>`u`?!1:(await VideoDecoder.isConfigSupported(e)).supported===!0}catch(e){return console.error(`Error during decodability check:`,e),!1}}async determinePacketType(e){if(!(e instanceof JB))throw TypeError(`packet must be an EncodedPacket.`);if(e.isMetadataOnly)throw TypeError(`packet must not be metadata-only to determine its type.`);let t=await this.getCodec();if(t===null)return null;let n=await this.getDecoderConfig();return X(n),PB(t,n,e.data)}},DG=class extends CG{constructor(e,t){super(e,t),this._backing=t}get type(){return`audio`}async getCodec(){return this._backing.getCodec()}get codec(){return wG(this._backing.getCodec(),`codec`,`getCodec`)}async hasOnlyKeyPackets(){return await this._backing.getHasOnlyKeyPackets?.()??!0}async getNumberOfChannels(){return this._backing.getNumberOfChannels()}get numberOfChannels(){return wG(this._backing.getNumberOfChannels(),`numberOfChannels`,`getNumberOfChannels`)}async getSampleRate(){return this._backing.getSampleRate()}get sampleRate(){return wG(this._backing.getSampleRate(),`sampleRate`,`getSampleRate`)}async getDecoderConfig(){return this._backing.getDecoderConfig()}async getCodecParameterString(){return await this._backing.getMetadataCodecParameterString?.()??(await this._backing.getDecoderConfig())?.codec??null}async canDecode(){try{let e=await this._backing.getDecoderConfig();if(!e)return!1;let t=await this._backing.getCodec();return X(t!==null),$W.some(n=>n.supports(t,e))||e.codec.startsWith(`pcm-`)?!0:typeof AudioDecoder>`u`?!1:(await AudioDecoder.isConfigSupported(e)).supported===!0}catch(e){return console.error(`Error during decodability check:`,e),!1}}async determinePacketType(e){if(!(e instanceof JB))throw TypeError(`packet must be an EncodedPacket.`);return await this.getCodec()===null?null:`key`}},OG=e=>-(e??-1/0),kG=e=>-e,AG=e=>{if(typeof e!=`object`||!e)throw TypeError(`query must be an object.`);if(e.filter!==void 0&&typeof e.filter!=`function`)throw TypeError(`query.filter, when provided, must be a function.`);if(e.sortBy!==void 0&&typeof e.sortBy!=`function`)throw TypeError(`query.sortBy, when provided, must be a function.`);return{filter:e.filter?t=>{let n=e=>{if(typeof e!=`boolean`)throw TypeError(`query.filter must return or resolve to a boolean.`);return e},r=e.filter(t);return r instanceof Promise?r.then(n):n(r)}:void 0,sortBy:e.sortBy?t=>{let n=e=>{if(typeof e!=`number`&&(!Array.isArray(e)||!e.every(e=>typeof e==`number`)))throw TypeError(`query.sortBy must return or resolve to a number or an array of numbers.`);return e},r=e.sortBy(t);return r instanceof Promise?r.then(n):n(r)}:void 0}},jG=(e,t)=>({filter:e?.filter||t?.filter?n=>{let r=e?.filter?.(n)??!0,i=e=>e===!1?!1:t?.filter?.(n)??!0;return r instanceof Promise?r.then(i):i(r)}:void 0,sortBy:e?.sortBy||t?.sortBy?n=>{let r=e?.sortBy?.(n)??[],i=t?.sortBy?.(n)??[],a=(e,t)=>[...Array.isArray(e)?e:[e],...Array.isArray(t)?t:[t]];return r instanceof Promise||i instanceof Promise?Promise.all([r,i]).then(([e,t])=>a(e,t)):a(r,i)}:void 0}),MG=async(e,t)=>{let n=e;if(t?.filter){let r=e.map(e=>t.filter(e));if(r.some(e=>e instanceof Promise)){let t=await Promise.all(r);n=e.filter((e,n)=>t[n])}else n=e.filter((e,t)=>r[t])}if(!t?.sortBy)return n;let r=n.map(e=>t.sortBy(e)),i=r.some(e=>e instanceof Promise)?await Promise.all(r):r;return n.map((e,t)=>({track:e,sortValue:i[t]})).sort((e,t)=>{let n=Array.isArray(e.sortValue)?e.sortValue:[e.sortValue],r=Array.isArray(t.sortValue)?t.sortValue:[t.sortValue],i=Math.max(n.length,r.length);for(let e=0;e<i;e++){let t=n[e]??0,i=r[e]??0;if(t!==i)return t-i}return 0}).map(e=>e.track)};BR();var NG=class e extends YR{get disposed(){return this._disposed}constructor(t){if(super(),this._demuxerPromise=null,this._format=null,this._trackBackingsCache=null,this._backingToTrack=new Map,this._disposed=!1,this._nextSourceCacheAge=0,this._sourceRefs=[],this._sourceCache=[],this._sourceCachePromises=[],this._onFormatDetermined=null,!t||typeof t!=`object`)throw TypeError(`options must be an object.`);if(!Array.isArray(t.formats)||t.formats.some(e=>!(e instanceof HU)))throw TypeError(`options.formats must be an array of InputFormat.`);if(!(t.source instanceof mU||t.source instanceof hU))throw TypeError(`options.source must be a Source or SourceRef.`);if(t.source instanceof mU&&t.source._disposed)throw TypeError(`options.source must not be a disposed Source.`);if(t.initInput!==void 0&&!(t.initInput instanceof e))throw TypeError(`options.initInput, when provided, must be an Input.`);t.formatOptions!==void 0&&nW(t.formatOptions,`formatOptions`),this._formats=t.formats,this._initInput=t.initInput??null,this._formatOptions=t.formatOptions??{},t.source instanceof mU?this._rootRef=t.source.ref():this._rootRef=t.source,this._sourceRefs.push(this._rootRef)}get _rootSource(){return this._rootRef.source}async _getSourceUncached(e){X(this._rootSource instanceof gU);let t=await this._rootSource._resolveRequest(e);return this._emit(`source`,{source:t.source,request:e,isRoot:e.isRoot}),t}_getSourceCached(e,t=1){let n=this._sourceCache.find(n=>n.cacheGroup===t&&_U(n.request,e));if(n)return n.age++,Promise.resolve(n.sourceRef.source.ref());let r=this._sourceCachePromises.find(n=>n.cacheGroup===t&&_U(n.request,e));if(r)return r.promise.then(e=>e.sourceRef.source.ref());let i=(async()=>{let n=await this._getSourceUncached(e);if(UR(this._sourceCache,e=>e.cacheGroup===t&&e.sourceRef.source._refCount===1)>=4){let e=WR(this._sourceCache,e=>e.cacheGroup===t&&e.sourceRef.source._refCount===1?e.age:1/0);X(e!==-1);let n=this._sourceCache[e];this._sourceCache.splice(e,1),n.sourceRef.free(),tR(this._sourceRefs,n.sourceRef)}this._sourceRefs.push(n);let r=this._sourceCachePromises.findIndex(t=>t.request===e);return X(r!==-1),this._sourceCachePromises.splice(r,1),{request:e,sourceRef:n,age:this._nextSourceCacheAge++,cacheGroup:t}})();return this._sourceCachePromises.push({request:e,cacheGroup:t,promise:i}),i.then(e=>{let t=e.sourceRef.source.ref();return this._sourceCache.push(e),t})}_getDemuxer(){return this._demuxerPromise??=(async()=>{this._reader=new IG(this._rootSource),this._emit(`source`,{source:this._rootSource,request:null,isRoot:!0});for(let e of this._formats)if(await e._canReadInput(this))return this._format=e,this._onFormatDetermined?.(e),e._createDemuxer(this);throw new PG})()}get source(){return this._rootSource}async getFormat(){return await this._getDemuxer(),X(this._format),this._format}async canRead(){try{return await this._getDemuxer(),!0}catch(e){if(e instanceof PG)return!1;throw e}}async getFirstTimestamp(e){e??=await this.getTracks();let t=e.filter(e=>e!==null);if(t.length===0)return 0;let n=await Promise.all(t.map(e=>e.getFirstTimestamp()));return Math.min(...n)}async computeDuration(e,t){e??=await this.getTracks();let n=e.filter(e=>e!==null);if(n.length===0)return 0;let r=await Promise.all(n.map(e=>e.computeDuration(t)));return Math.max(...r)}async getDurationFromMetadata(e,t){e??=await this.getTracks();let n=e.filter(e=>e!==null),r=(await Promise.all(n.map(e=>e.getDurationFromMetadata(t)))).filter(e=>e!==null);return r.length===0?null:Math.max(...r)}async getTracks(e){return e&&=AG(e),MG((await this._getTrackBackings()).map(e=>this._wrapBackingAsTrack(e)),e)}async getVideoTracks(e){return e&&=AG(e),MG((await this.getTracks()).filter(e=>e.isVideoTrack()),e)}async getAudioTracks(e){return e&&=AG(e),MG((await this.getTracks()).filter(e=>e.isAudioTrack()),e)}async getPrimaryVideoTrack(e){e&&=AG(e);let t=jG(e,{sortBy:async e=>[kG((await e.getDisposition()).default),kG(await e.hasPairableAudioTrack()),kG(!await e.hasOnlyKeyPackets()),OG(await e.getBitrate())]});return(await this.getVideoTracks(t))[0]??null}async getPrimaryAudioTrack(e){e&&=AG(e);let t=await this.getPrimaryVideoTrack(),n=jG(e,{sortBy:async e=>[kG(!t||e.canBePairedWith(t)),kG((await e.getDisposition()).default),OG(await e.getBitrate())]});return(await this.getAudioTracks(n))[0]??null}async _getTrackBackings(){let e=await this._getDemuxer();return this._trackBackingsCache??=await e.getTrackBackings()}_wrapBackingAsTrack(e){let t=this._backingToTrack.get(e);if(t)return t;let n=e.getType()===`video`?new EG(this,e):new DG(this,e);return this._backingToTrack.set(e,n),n}async getMimeType(){return(await this._getDemuxer()).getMimeType()}async getMetadataTags(){return(await this._getDemuxer()).getMetadataTags()}dispose(){if(!this._disposed){this._disposed=!0;for(let e of this._sourceRefs)e.free();this._sourceRefs.length=0,this._demuxerPromise&&this._demuxerPromise.then(e=>e.dispose()).catch(()=>{})}}[Symbol.dispose](){this.dispose()}},PG=class extends Error{constructor(e=`Input has an unsupported or unrecognizable format.`){super(e),this.name=`UnsupportedInputFormatError`}},FG=class extends Error{constructor(e=`Input has been disposed.`){super(e),this.name=`InputDisposedError`}},IG=class{constructor(e){this.source=e}get fileSize(){let e=this.source._getFileSize();if(e===void 0)throw Error(`Reading file size too early; read required first.`);return e}get fileSizeNonStrict(){return this.source._getFileSize()??null}requestSlice(e,t){if(this.source._disposed)throw new FG;if(e<0||this.fileSizeNonStrict!==null&&e+t>this.fileSizeNonStrict)return null;if(t===0){let t=new Uint8Array;return new LG(t,PL(t),0,e,e)}let n=e+t,r=this.source._read(e,n,0,pU);return r instanceof Promise?r.then(t=>t?new LG(t.bytes,t.view,t.offset,e,n):null):r?new LG(r.bytes,r.view,r.offset,e,n):null}requestSliceRange(e,t,n){if(this.source._disposed)throw new FG;if(e<0)return null;if(this.fileSizeNonStrict!==null)return this.requestSlice(e,fR(this.fileSizeNonStrict-e,t,n));{let r=this.requestSlice(e,n),i=r=>r||(X(this.fileSizeNonStrict!==null),this.requestSlice(e,fR(this.fileSizeNonStrict-e,t,n)));return r instanceof Promise?r.then(i):i(r)}}requestEntireFile(){return this.fileSizeNonStrict===null?(async()=>{let e=[],t=0;for(;;){if(e.length===1&&this.fileSizeNonStrict!==null)return this.requestSlice(0,this.fileSizeNonStrict);let n=this.requestSliceRange(t,0,1024);if(n instanceof Promise&&(n=await n),!n||n.length===0)break;let r=zG(n,n.length);e.push(r),t+=n.length}let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return new LG(n,PL(n),0,0,t)})():this.requestSlice(0,this.fileSizeNonStrict)}},LG=class e{constructor(e,t,n,r,i){this.bytes=e,this.view=t,this.offset=n,this.start=r,this.end=i,this.bufferPos=r-n}static tempFromBytes(t){return new e(t,PL(t),0,0,t.length)}get length(){return this.end-this.start}get filePos(){return this.offset+this.bufferPos}set filePos(e){this.bufferPos=e-this.offset}get remainingLength(){return Math.max(this.end-this.filePos,0)}skip(e){this.bufferPos+=e}slice(t,n=this.end-t){if(t<this.start||t+n>this.end)throw RangeError(`Slicing outside of original slice.`);return new e(this.bytes,this.view,this.offset,t,t+n)}},RG=(e,t)=>{if(e.filePos<e.start||e.filePos+t>e.end)throw RangeError(`Tried reading [${e.filePos}, ${e.filePos+t}), but slice is [${e.start}, ${e.end}). This is likely an internal error, please report it alongside the file that caused it.`)},zG=(e,t)=>{RG(e,t);let n=e.bytes.subarray(e.bufferPos,e.bufferPos+t);return e.bufferPos+=t,n},BG=e=>(RG(e,1),e.view.getUint8(e.bufferPos++)),VG=(e,t)=>{RG(e,2);let n=e.view.getUint16(e.bufferPos,t);return e.bufferPos+=2,n},HG=e=>{RG(e,2);let t=e.view.getUint16(e.bufferPos,!1);return e.bufferPos+=2,t},UG=e=>{RG(e,3);let t=sR(e.view,e.bufferPos,!1);return e.bufferPos+=3,t},WG=e=>{RG(e,2);let t=e.view.getInt16(e.bufferPos,!1);return e.bufferPos+=2,t},GG=(e,t)=>{RG(e,4);let n=e.view.getUint32(e.bufferPos,t);return e.bufferPos+=4,n},$=e=>{RG(e,4);let t=e.view.getUint32(e.bufferPos,!1);return e.bufferPos+=4,t},KG=e=>{RG(e,4);let t=e.view.getUint32(e.bufferPos,!0);return e.bufferPos+=4,t},qG=e=>{RG(e,4);let t=e.view.getInt32(e.bufferPos,!1);return e.bufferPos+=4,t},JG=e=>{RG(e,4);let t=e.view.getInt32(e.bufferPos,!0);return e.bufferPos+=4,t},YG=(e,t)=>{let n,r;return t?(n=GG(e,!0),r=GG(e,!0)):(r=GG(e,!1),n=GG(e,!1)),r*4294967296+n},XG=e=>{let t=$(e),n=$(e);return t*4294967296+n},ZG=e=>{let t=qG(e),n=$(e);return t*4294967296+n},QG=e=>{let t=KG(e);return JG(e)*4294967296+t},$G=e=>{RG(e,4);let t=e.view.getFloat32(e.bufferPos,!1);return e.bufferPos+=4,t},eK=e=>{RG(e,8);let t=e.view.getFloat64(e.bufferPos,!1);return e.bufferPos+=8,t},tK=(e,t)=>{RG(e,t);let n=``;for(let r=0;r<t;r++)n+=String.fromCharCode(e.bytes[e.bufferPos++]);return n},nK=(e,t,n)=>FL.decode(zG(e,t)).split(`
|
|
408
|
+
`).map(e=>e.trim()).filter(e=>e.length>0&&!n?.ignore?.(e)),rK;(function(e){e[e.Unsynchronisation=128]=`Unsynchronisation`,e[e.ExtendedHeader=64]=`ExtendedHeader`,e[e.ExperimentalIndicator=32]=`ExperimentalIndicator`,e[e.Footer=16]=`Footer`})(rK||={});var iK;(function(e){e[e.ISO_8859_1=0]=`ISO_8859_1`,e[e.UTF_16_WITH_BOM=1]=`UTF_16_WITH_BOM`,e[e.UTF_16_BE_NO_BOM=2]=`UTF_16_BE_NO_BOM`,e[e.UTF_8=3]=`UTF_8`})(iK||={});var aK=`Blues.Classic rock.Country.Dance.Disco.Funk.Grunge.Hip-hop.Jazz.Metal.New age.Oldies.Other.Pop.Rhythm and blues.Rap.Reggae.Rock.Techno.Industrial.Alternative.Ska.Death metal.Pranks.Soundtrack.Euro-techno.Ambient.Trip-hop.Vocal.Jazz & funk.Fusion.Trance.Classical.Instrumental.Acid.House.Game.Sound clip.Gospel.Noise.Alternative rock.Bass.Soul.Punk.Space.Meditative.Instrumental pop.Instrumental rock.Ethnic.Gothic.Darkwave.Techno-industrial.Electronic.Pop-folk.Eurodance.Dream.Southern rock.Comedy.Cult.Gangsta.Top 40.Christian rap.Pop/funk.Jungle music.Native US.Cabaret.New wave.Psychedelic.Rave.Showtunes.Trailer.Lo-fi.Tribal.Acid punk.Acid jazz.Polka.Retro.Musical.Rock 'n' roll.Hard rock.Folk.Folk rock.National folk.Swing.Fast fusion.Bebop.Latin.Revival.Celtic.Bluegrass.Avantgarde.Gothic rock.Progressive rock.Psychedelic rock.Symphonic rock.Slow rock.Big band.Chorus.Easy listening.Acoustic.Humour.Speech.Chanson.Opera.Chamber music.Sonata.Symphony.Booty bass.Primus.Porn groove.Satire.Slow jam.Club.Tango.Samba.Folklore.Ballad.Power ballad.Rhythmic Soul.Freestyle.Duet.Punk rock.Drum solo.A cappella.Euro-house.Dance hall.Goa music.Drum & bass.Club-house.Hardcore techno.Terror.Indie.Britpop.Negerpunk.Polsk punk.Beat.Christian gangsta rap.Heavy metal.Black metal.Crossover.Contemporary Christian.Christian rock.Merengue.Salsa.Thrash metal.Anime.Jpop.Synthpop.Christmas.Art rock.Baroque.Bhangra.Big beat.Breakbeat.Chillout.Downtempo.Dub.EBM.Eclectic.Electro.Electroclash.Emo.Experimental.Garage.Global.IDM.Illbient.Industro-Goth.Jam Band.Krautrock.Leftfield.Lounge.Math rock.New romantic.Nu-breakz.Post-punk.Post-rock.Psytrance.Shoegaze.Space rock.Trop rock.World music.Neoclassical.Audiobook.Audio theatre.Neue Deutsche Welle.Podcast.Indie rock.G-Funk.Dubstep.Garage rock.Psybient`.split(`.`),oK=(e,t)=>{let n=e.filePos;t.raw??={},t.raw.TAG??=zG(e,125),e.filePos=n;let r=sK(e,30);r&&(t.title??=r);let i=sK(e,30);i&&(t.artist??=i);let a=sK(e,30);a&&(t.album??=a);let o=sK(e,4),s=Number.parseInt(o,10);Number.isInteger(s)&&s>0&&(t.date??=new Date(String(s)));let c=zG(e,30),l;if(c[28]===0&&c[29]!==0){let n=c[29];n>0&&(t.trackNumber??=n),e.skip(-30),l=sK(e,28),e.skip(2)}else e.skip(-30),l=sK(e,30);l&&(t.comment??=l);let u=BG(e);u<aK.length&&(t.genre??=aK[u])},sK=(e,t)=>{let n=zG(e,t),r=FR(n.indexOf(0),n.length),i=n.subarray(0,r),a=``;for(let e=0;e<i.length;e++)a+=String.fromCharCode(i[e]);return a.trimEnd()},cK=e=>{let t=e.filePos,n=tK(e,3),r=BG(e),i=BG(e),a=BG(e),o=$(e);return n!==`ID3`||r===255||i===255||o&2155905152?(e.filePos=t,null):{majorVersion:r,revision:i,flags:a,size:Wz(o)}},lK=(e,t,n)=>{if(![2,3,4].includes(t.majorVersion)){console.warn(`Unsupported ID3v2 major version: ${t.majorVersion}`);return}let r=new uK(t,zG(e,t.size));if(t.flags&rK.Footer&&r.removeFooter(),t.flags&rK.Unsynchronisation&&t.majorVersion===3&&r.ununsynchronizeAll(),t.flags&rK.ExtendedHeader){let e=r.readU32();t.majorVersion===3?r.pos+=e:r.pos+=e-4}for(;r.pos<=r.bytes.length-r.frameHeaderSize();){let e=r.readId3V2Frame();if(!e)break;let i=r.pos,a=r.pos+e.size,o=!1,s=!1,c=!1;if(t.majorVersion===3?(o=!!(e.flags&64),s=!!(e.flags&128)):t.majorVersion===4&&(o=!!(e.flags&4),s=!!(e.flags&8),c=!!(e.flags&2)||!!(t.flags&rK.Unsynchronisation)),o){console.warn(`Skipping encrypted ID3v2 frame ${e.id}`),r.pos=a;continue}if(s){console.warn(`Skipping compressed ID3v2 frame ${e.id}`),r.pos=a;continue}if(c&&r.ununsynchronizeRegion(r.pos,a),n.raw??={},e.id===`TXXX`){let e=n.raw.TXXX??={},t=r.readId3V2TextEncoding(),i=r.readId3V2Text(t,a),o=r.readId3V2Text(t,a);e[i]??=o}else e.id[0]===`T`?n.raw[e.id]??=r.readId3V2EncodingAndText(a):n.raw[e.id]??=r.readBytes(e.size);switch(r.pos=i,e.id){case`TIT2`:case`TT2`:n.title??=r.readId3V2EncodingAndText(a);break;case`TIT3`:case`TT3`:n.description??=r.readId3V2EncodingAndText(a);break;case`TPE1`:case`TP1`:n.artist??=r.readId3V2EncodingAndText(a);break;case`TALB`:case`TAL`:n.album??=r.readId3V2EncodingAndText(a);break;case`TPE2`:case`TP2`:n.albumArtist??=r.readId3V2EncodingAndText(a);break;case`TRCK`:case`TRK`:{let e=r.readId3V2EncodingAndText(a).split(`/`),t=Number.parseInt(e[0],10),i=e[1]&&Number.parseInt(e[1],10);Number.isInteger(t)&&t>0&&(n.trackNumber??=t),i&&Number.isInteger(i)&&i>0&&(n.tracksTotal??=i)}break;case`TPOS`:case`TPA`:{let e=r.readId3V2EncodingAndText(a).split(`/`),t=Number.parseInt(e[0],10),i=e[1]&&Number.parseInt(e[1],10);Number.isInteger(t)&&t>0&&(n.discNumber??=t),i&&Number.isInteger(i)&&i>0&&(n.discsTotal??=i)}break;case`TCON`:case`TCO`:{let e=r.readId3V2EncodingAndText(a),t=/^\((\d+)\)/.exec(e);if(t){let e=Number.parseInt(t[1]);if(aK[e]!==void 0){n.genre??=aK[e];break}}if(t=/^\d+$/.exec(e),t){let e=Number.parseInt(t[0]);if(aK[e]!==void 0){n.genre??=aK[e];break}}n.genre??=e}break;case`TDRC`:case`TDAT`:{let e=r.readId3V2EncodingAndText(a),t=new Date(e);Number.isNaN(t.getTime())||(n.date??=t)}break;case`TYER`:case`TYE`:{let e=r.readId3V2EncodingAndText(a),t=Number.parseInt(e,10);Number.isInteger(t)&&(n.date??=new Date(String(t)))}break;case`USLT`:case`ULT`:{let e=r.readU8();r.pos+=3,r.readId3V2Text(e,a),n.lyrics??=r.readId3V2Text(e,a)}break;case`COMM`:case`COM`:{let e=r.readU8();r.pos+=3,r.readId3V2Text(e,a),n.comment??=r.readId3V2Text(e,a)}break;case`APIC`:case`PIC`:{let e=r.readId3V2TextEncoding(),i;if(t.majorVersion===2){let e=r.readAscii(3);i=e===`PNG`?`image/png`:e===`JPG`?`image/jpeg`:`image/*`}else i=r.readId3V2Text(e,a);let o=r.readU8(),s=r.readId3V2Text(e,a).trimEnd(),c=a-r.pos;if(c>=0){let e=r.readBytes(c);n.images||=[],n.images.push({data:e,mimeType:i,kind:o===3?`coverFront`:o===4?`coverBack`:`unknown`,description:s})}}break;default:r.pos+=e.size;break}r.pos=a}},uK=class{constructor(e,t){this.header=e,this.bytes=t,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength)}frameHeaderSize(){return this.header.majorVersion===2?6:10}ununsynchronizeAll(){let e=[];for(let t=0;t<this.bytes.length;t++){let n=this.bytes[t];e.push(n),n===255&&t!==this.bytes.length-1&&this.bytes[t]===0&&t++}this.bytes=new Uint8Array(e),this.view=new DataView(this.bytes.buffer)}ununsynchronizeRegion(e,t){let n=[];for(let r=e;r<t;r++){let e=this.bytes[r];n.push(e),e===255&&r!==t-1&&this.bytes[r+1]===0&&r++}let r=this.bytes.subarray(0,e),i=this.bytes.subarray(t);this.bytes=new Uint8Array(r.length+n.length+i.length),this.bytes.set(r,0),this.bytes.set(n,r.length),this.bytes.set(i,r.length+n.length),this.view=new DataView(this.bytes.buffer)}removeFooter(){this.bytes=this.bytes.subarray(0,this.bytes.length-10),this.view=new DataView(this.bytes.buffer)}readBytes(e){let t=this.bytes.subarray(this.pos,this.pos+e);return this.pos+=e,t}readU8(){let e=this.view.getUint8(this.pos);return this.pos+=1,e}readU16(){let e=this.view.getUint16(this.pos,!1);return this.pos+=2,e}readU24(){let e=this.view.getUint16(this.pos,!1),t=this.view.getUint8(this.pos+2);return this.pos+=3,e*256+t}readU32(){let e=this.view.getUint32(this.pos,!1);return this.pos+=4,e}readAscii(e){let t=``;for(let n=0;n<e;n++)t+=String.fromCharCode(this.view.getUint8(this.pos+n));return this.pos+=e,t}readId3V2Frame(){if(this.header.majorVersion===2){let e=this.readAscii(3);return e===`\0\0\0`?null:{id:e,size:this.readU24(),flags:0}}else{let e=this.readAscii(4);if(e===`\0\0\0\0`)return null;let t=this.readU32(),n=this.header.majorVersion===4?Wz(t):t,r=this.readU16(),i=this.pos,a=e=>{let t=this.pos+e;if(t>this.bytes.length)return!1;if(t<=this.bytes.length-this.frameHeaderSize()){this.pos+=e;let t=this.readAscii(4);if(t!==`\0\0\0\0`&&!/[0-9A-Z]{4}/.test(t))return!1}return!0};if(!a(n)){let e=this.header.majorVersion===4?t:Wz(t);a(e)&&(n=e)}return this.pos=i,{id:e,size:n,flags:r}}}readId3V2TextEncoding(){let e=this.readU8();if(e>3)throw Error(`Unsupported text encoding: ${e}`);return e}readId3V2Text(e,t){let n=this.pos,r=this.readBytes(t-this.pos);switch(e){case iK.ISO_8859_1:{let e=``;for(let t=0;t<r.length;t++){let i=r[t];if(i===0){this.pos=n+t+1;break}e+=String.fromCharCode(i)}return e}case iK.UTF_16_WITH_BOM:if(r[0]===255&&r[1]===254){let e=new TextDecoder(`utf-16le`),t=FR(r.findIndex((e,t)=>e===0&&r[t+1]===0&&t%2==0),r.length);return this.pos=n+Math.min(t+2,r.length),e.decode(r.subarray(2,t))}else if(r[0]===254&&r[1]===255){let e=new TextDecoder(`utf-16be`),t=FR(r.findIndex((e,t)=>e===0&&r[t+1]===0&&t%2==0),r.length);return this.pos=n+Math.min(t+2,r.length),e.decode(r.subarray(2,t))}else{let e=FR(r.findIndex(e=>e===0),r.length);return this.pos=n+Math.min(e+1,r.length),FL.decode(r.subarray(0,e))}case iK.UTF_16_BE_NO_BOM:{let e=new TextDecoder(`utf-16be`),t=FR(r.findIndex((e,t)=>e===0&&r[t+1]===0&&t%2==0),r.length);return this.pos=n+Math.min(t+2,r.length),e.decode(r.subarray(0,t))}case iK.UTF_8:{let e=FR(r.findIndex(e=>e===0),r.length);return this.pos=n+Math.min(e+1,r.length),FL.decode(r.subarray(0,e))}}}readId3V2EncodingAndText(e){if(this.pos>=e)return``;let t=this.readId3V2TextEncoding();return this.readId3V2Text(t,e)}},dK=.05,fK=(e,t,n)=>{let[r,i]=b.useState({input:null,videoSink:null,duration:0,isReady:!1,error:null});b.useRef(r).current=r;let a=b.useRef(0),o=b.useRef(null),s=b.useRef(null),c=b.useRef(null),l=b.useRef(null),u=b.useRef(null),d=b.useRef(null),f=b.useRef(!1),p=b.useRef(null),m=b.useRef([]),h=b.useRef(null),g=b.useRef(!1),[,_]=b.useReducer(e=>e+1,0);return b.useEffect(()=>{if(!n)return;let t=!0,r=++a.current,o=null;return(async()=>{try{if(!t||r!==a.current)return;o=$_(`mediabunny init ${e.id}`);let n=await async function(e){if(function(e){return e.startsWith(`data:`)}(e))return new yU(function(e){let t=e.indexOf(`,`);if(t===-1)throw Error(`Invalid data URL format`);let n=e.slice(t+1),r=atob(n),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);return i.buffer}(e));if(function(e){return e.startsWith(`file://`)}(e))try{return new yU(await(await fetch(e)).arrayBuffer())}catch(t){throw Error(`Failed to load file URL: ${e}. File URLs may not be supported in this environment. Error: ${t}`)}return new CU(e)}(e.src);if(!t||r!==a.current){o&&=(o(),null);return}let s=new NG({source:n,formats:tW}),c=await s.computeDuration(),l=await s.getPrimaryVideoTrack();if(!l)throw Error(`No video track found`);if(l.codec===null)throw Error(`Unsupported video codec`);if(!await l.canDecode())throw Error(`Unable to decode the video track`);let u=new vG(l,{poolSize:5,fit:`contain`,alpha:await l.canBeTransparent()});if(!t||r!==a.current){s.dispose(),o&&=(o(),null);return}o&&=(o(),null),i(e=>Object.assign(Object.assign({},e),{input:s,videoSink:u,duration:c,isReady:!0,error:null}))}catch(n){console.error(`Failed to initialize mediabunny:`,n),o&&=(o(),null),t&&r===a.current&&(iv(`Failed to initialize mediabunny for video ${e.id}: ${n}`),i(e=>Object.assign(Object.assign({},e),{error:String(n),isReady:!1})))}})(),()=>{t=!1,o&&=(o(),null)}},[e.src,n]),b.useEffect(()=>()=>{s.current&&=(s.current.return(),null),o.current&&=(o.current(),null),c.current=null,l.current=null,u.current=null,f.current=!1,p.current=null,m.current=[],h.current=null,g.current=!1,i({input:null,videoSink:null,duration:0,isReady:!1,error:null})},[n]),b.useEffect(()=>{if(!n||!r.isReady||!r.videoSink)return;let i=++a.current,v=typeof e.src==`string`?e.src.slice(0,120):String(e.src),y=(t,n={},i=`debug`)=>{let a=``;try{a=JSON.stringify(Object.assign(Object.assign({},n),{timeCalc:d.current}))}catch(e){a=`[unserializable extras: ${String(e)}]`}let o=`mediabunny event=${t} elementId=${e.id} targetTime=${u.current} duration=${r.duration} lastFrameTimestamp=${l.current} hasIterator=${!!s.current} prefetchSize=${m.current.length} srcHint=${v} extras=${a}`;i===`error`?console.error(o):i===`warn`?console.warn(o):console.debug(o)},b=e=>{let t=r.duration||0;if(!t||!Number.isFinite(t))return e;let n=t>dK?t-dK:t;return Math.max(0,Math.min(e,n))},x=e=>{let t=r.duration||0;return!(!t||!Number.isFinite(t))&&t-e<=.050001000000000004},S=e=>{let t=c.current;t&&t.width===e.canvas.width&&t.height===e.canvas.height||(t||(t=document.createElement(`canvas`),c.current=t),t.width=e.canvas.width,t.height=e.canvas.height);let n=t.getContext(`2d`);n&&(n.clearRect(0,0,t.width,t.height),n.drawImage(e.canvas,0,0)),l.current=e.timestamp},C=e=>{let t=s.current;t&&(g.current||(g.current=!0,h.current=(async()=>{try{for(;m.current.length<4&&e===a.current;){let n=await t.next();if(e!==a.current)return;if(n.done||!n.value)break;m.current.push({timestamp:n.value.timestamp,frame:n.value})}}catch{}finally{g.current=!1,h.current=null}})()))},w=e=>{let t=m.current;for(let n=0;n<t.length;n++)if(Math.abs(t[n].timestamp-e)<dK){let e=t[n];return m.current=t.slice(n+1),e}return null},T=()=>{m.current=[]},E=async(e,t,n=0)=>{let i=b(e),o=(e=>{let t=l.current;return t===null||e<t-dK||e>t+.5})(i)?`seek`:`iterate`;try{let n=r.videoSink,c=l.current;if(c!==null&&Math.abs(c-i)<dK){u.current=e;return}let d=w(i);if(d){S(d.frame),u.current=e,C(t),_();return}if(h.current){await h.current;let n=w(i);if(n){S(n.frame),u.current=e,C(t),_();return}}if(T(),o===`seek`){s.current&&=(await s.current.return(),null);let r=n.canvases(i);s.current=r;let c=await r.next();if(t!==a.current){s.current&&=(await s.current.return(),null);return}if(c.done||!c.value){if(x(i)||y(`iterator_exhausted`,{mode:o,requestedTargetTime:e,clampedTargetTime:i},`warn`),t===a.current&&!x(i))try{s.current&&=(await s.current.return(),null),T();let r=n.canvases(i);s.current=r;let a=await r.next();!a.done&&a.value&&(S(a.value),C(t),u.current=e,_())}catch{}return}S(c.value),C(t)}else{let r=s.current;if(!r)return;let c=!1;for(;t===a.current;){let l=await r.next();if(t!==a.current)break;if(l.done||!l.value){if(x(i)||y(`iterator_exhausted`,{mode:o,requestedTargetTime:e,clampedTargetTime:i},`warn`),!c&&!x(i)){c=!0;try{s.current&&=(await s.current.return(),null),T();let e=n.canvases(i);s.current=e;let r=await e.next();if(t!==a.current||r.done||!r.value)break;S(r.value),C(t);break}catch{break}}break}let u=l.value;if(S(u),Math.abs(u.timestamp-i)<dK){C(t);break}if(u.timestamp>i){C(t);break}}}u.current=e,_()}catch(r){let a=r instanceof Error?{name:r.name,message:r.message,stack:r.stack}:{message:String(r)},c=r instanceof Error?`${r.name}: ${r.message}`:String(r),u=c.includes(`Unsupported configuration`)||c.includes(`isConfigSupported`)||c.includes(`OperationError`);if(y(`frame_process_failed`,{mode:o,requestedTargetTime:e,clampedTargetTime:i,unsupportedConfigAttempt:n,isUnsupportedConfig:u,error:a},`error`),u&&n<1)try{s.current&&=(await s.current.return(),null),T(),h.current=null,g.current=!1,l.current=null,await E(e,t,n+1)}catch{}}},D=cr(()=>{let n=r.videoSink,s=r.duration;if(!n||!s)return;let c=e.startTime*s*1e3,l=s*(e.endTime-e.startTime)*1e3,u=((t.currentTime||e.page.startTime)-e.page.startTime)%l+c,m=u/1e3,h=b(m);d.current={pageStartTime:e.page.startTime,storeCurrentTime:t.currentTime,offsetMs:c,durationMs:l,restMs:u,targetTime:m,clampedTargetTime:h,startTime:e.startTime,endTime:e.endTime,videoDuration:s},((t,n)=>{f.current?p.current=t:(f.current=!0,o.current||=$_(`mediabunny video frame ${e.id}`),(async()=>{let e=t;for(;e!==null&&n===a.current;)await E(e,n),e=p.current,p.current=null;o.current&&=(o.current(),null),f.current=!1})())})(h,i)});return()=>{D(),a.current++,o.current&&=(o.current(),null)}},[n,r.isReady,r.videoSink,r.duration,t,e]),n&&r.isReady?c.current:null};function pK(){return document.createElement(`canvas`)}var mK=new window.Image;mK.src=Sy(`
|
|
409
|
+
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
410
|
+
<path opacity="0.6" d="M4 5.49683V18.5032C4 20.05 5.68077 21.0113 7.01404 20.227L18.0694 13.7239C19.384 12.9506 19.384 11.0494 18.0694 10.2761L7.01404 3.77296C5.68077 2.98869 4 3.95 4 5.49683Z" fill="white"/>
|
|
411
|
+
<path d="M4 5.49683V18.5032C4 20.05 5.68077 21.0113 7.01404 20.227L18.0694 13.7239C19.384 12.9506 19.384 11.0494 18.0694 10.2761L7.01404 3.77296C5.68077 2.98869 4 3.95 4 5.49683Z" stroke="#323232" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
412
|
+
</svg>
|
|
413
|
+
`);var hK=new window.Image;hK.src=Sy(`
|
|
414
|
+
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
415
|
+
<path opacity="0.6" d="M14 19L14 5C14 3.89543 14.8954 3 16 3L17 3C18.1046 3 19 3.89543 19 5L19 19C19 20.1046 18.1046 21 17 21L16 21C14.8954 21 14 20.1046 14 19Z" fill="white"/>
|
|
416
|
+
<path opacity="0.6" d="M10 19L10 5C10 3.89543 9.10457 3 8 3L7 3C5.89543 3 5 3.89543 5 5L5 19C5 20.1046 5.89543 21 7 21L8 21C9.10457 21 10 20.1046 10 19Z" fill="white"/>
|
|
417
|
+
<path d="M14 19L14 5C14 3.89543 14.8954 3 16 3L17 3C18.1046 3 19 3.89543 19 5L19 19C19 20.1046 18.1046 21 17 21L16 21C14.8954 21 14 20.1046 14 19Z" stroke="#323232" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
418
|
+
<path d="M10 19L10 5C10 3.89543 9.10457 3 8 3L7 3C5.89543 3 5 3.89543 5 5L5 19C5 20.1046 5.89543 21 7 21L8 21C9.10457 21 10 20.1046 10 19Z" stroke="#323232" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
419
|
+
</svg>
|
|
420
|
+
`);var gK=(e,t,n,r,i=0,a=!1)=>{let o=Math.floor(Math.max(e.width*r,1)),s=Math.floor(Math.max(e.height*r,1)),c=Math.min(i*r,o/2,s/2),l=Math.max(e.width/n.width,e.height/n.height)*r,u=e.page?._exportingOrRendering&&h_.imageDownScalingEnabled&&l<1&&!a,d=t instanceof HTMLVideoElement?t.videoWidth:t?.width,f=t instanceof HTMLVideoElement?t.videoHeight:t?.height,p=n.x===0&&n.y===0&&n.width===d&&n.height===f,m=b.useMemo(()=>{if(t&&d&&f)return p&&c===0&&!u?void 0:pK()},[t,c,u,p,d,f]),h=()=>{if(!m||!t)return;m.width=o,m.height=s;let e=m.getContext(`2d`);if(!e)return;c&&(e.beginPath(),e.moveTo(c,0),e.lineTo(o-c,0),e.arc(o-c,c,c,3*Math.PI/2,0,!1),e.lineTo(o,s-c),e.arc(o-c,s-c,c,0,Math.PI/2,!1),e.lineTo(c,s),e.arc(c,s-c,c,Math.PI/2,Math.PI,!1),e.lineTo(0,c),e.arc(c,c,c,Math.PI,3*Math.PI/2,!1),e.clip());let r=u?function(e,t){var n,r;let i=pK(),a=e instanceof HTMLVideoElement?e.videoWidth:e.width,o=e instanceof HTMLVideoElement?e.videoHeight:e.height;i.width=a,i.height=o,(n=i.getContext(`2d`))==null||n.drawImage(e,0,0,i.width,i.height);let s=function(e,t,n,r,i,a,o){for(var s=new ImageData(t,n),c=new Int32Array(e.data.buffer),l=e.width,u=new Int32Array(s.data.buffer),d=s.width,f=t/a,p=n/o,m=Math.round(1/f),h=Math.round(1/p),g=m*h,_=0;_<s.height;_++)for(var v=0;v<d;v++){for(var y=0+Math.round(v/f)+(0+Math.round(_/p))*l,b=0,x=0,S=0,C=0,w=0;w<h;w++)for(var T=0;T<m;T++){var E=c[y+T+w*l];b+=E<<24>>>24,x+=E<<16>>>24,S+=E<<8>>>24,C+=E>>>24}b=Math.round(b/g),x=Math.round(x/g),S=Math.round(S/g),C=Math.round(C/g),u[v+_*d]=C<<24|S<<16|x<<8|b}return s}(i.getContext(`2d`).getImageData(0,0,i.width,i.height),Math.floor(i.width*t),Math.floor(i.height*t),0,0,i.width,i.height);return i.width=Math.floor(i.width*t),i.height=Math.floor(i.height*t),(r=i.getContext(`2d`))==null||r.putImageData(s,0,0),i}(t,l):t,i=u?{x:Math.floor(n.x*l),y:Math.floor(n.y*l),width:Math.floor(n.width*l),height:Math.floor(n.height*l)}:n;e.drawImage(r,i.x,i.y,i.width,i.height,0,0,m.width,m.height)};return b.useLayoutEffect(()=>{h()},[m,e.width,e.height,n.x,n.y,n.width,n.height,i,r,a,e.page?._exportingOrRendering,u]),b.useEffect(()=>()=>{m&&m.nodeName===`CANVAS`&&W.Util.releaseCanvas(m)},[m]),[m||t,h]},_K=pK(),vK=wa(({element:e})=>{let t=Math.min(30,e.width/4,e.height/4),n=b.useRef(null);b.useEffect(()=>{let e=n.current;if(!e)return;let t=new W.Animation(t=>{e.rotate((t?.timeDiff||0)/2)},e.getLayer());return t.start(),()=>{t.stop()}});let{mediaLoadingStyle:r}=up();return(0,S.jsxs)(jf,{x:e.a.x,y:e.a.y,rotation:e.a.rotation,listening:!1,opacity:e.a.opacity,hideInExport:!e.showInExport,children:[(0,S.jsx)(Nf,{width:e.width,height:e.height,fill:r.fill}),(0,S.jsx)(`Arc`,{ref:n,x:e.width/2,y:e.height/2,fill:r.textFill,outerRadius:Math.abs(t),innerRadius:Math.max(1,t-5),angle:270})]})}),yK=wa(({element:e})=>{let{mediaErrorStyle:t}=up(),n=Math.max(10,Math.min(30,e.width/25));return(0,S.jsxs)(jf,{x:e.a.x,y:e.a.y,rotation:e.a.rotation,listening:!1,opacity:e.a.opacity,hideInExport:!e.showInExport,children:[(0,S.jsx)(Nf,{width:e.width,height:e.height,fill:t.fill}),(0,S.jsx)(If,{text:`Can not load the video...`,fontSize:n,width:e.width,height:e.height,align:`center`,fill:t.textFill,verticalAlign:`middle`,padding:5})]})}),bK=function(e,t,n){let r=b.useRef(`loading`),i=b.useRef(void 0),[a,o]=b.useState(0),s=b.useRef(void 0),c=b.useRef(void 0),l=b.useRef(void 0);return s.current===e&&c.current===t&&l.current===n||(r.current=`loading`,i.current=void 0,s.current=e,c.current=t,l.current=n),b.useLayoutEffect(function(){if(e){var a=document.createElement(`video`);return a.addEventListener(`canplay`,s),a.addEventListener(`error`,c),t&&(a.crossOrigin=t),n&&(a.referrerPolicy=n),a.src=e,a.load(),function(){a.removeEventListener(`canplay`,s),a.removeEventListener(`error`,c)}}function s(){r.current=`loaded`,i.current=a,i.current.currentTime=0,o(Math.random()),i.current.removeEventListener(`canplay`,s)}function c(e){let t=a.readyState===4,n=a.buffered&&a.buffered.length>0&&a.buffered.end(a.buffered.length-1)/a.duration*100>=100;if(t&&n)return;let s=e.message||a.error?.message||`Unknown error`,c=Error(`Video failed to load: `+s);console.error(c),r.current=`failed`,i.current=void 0,o(Math.random())}},[e,t,n]),[i.current,r.current]};function xK(e){return e.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA}var SK=(e,t,n)=>{let r=b.useRef(void 0),i=()=>{var e;(e=r.current)==null||e.call(r),r.current=void 0};b.useEffect(()=>i,[]),b.useLayoutEffect(()=>{let a=`video with id ${n} url: ${t.slice(0,200)}`;e!==`loading`||r.current||(r.current=$_(a)),e!==`loading`&&i(),e===`failed`&&iv(a)},[e])},CK=wa(({element:e,store:t})=>{let[n,r]=b.useState(!1),i=b.useRef(null),a=b.useRef(null),o=e.isSelected,[s,c]=b.useState(!1),[l,u]=bK(e.src,`anonymous`),[d,f]=b.useState(!1),p=t.activePage===e.page,m=e.page?._exportingOrRendering&&u===`loaded`,h=fK(e,t,m);SK(u,e.src,e.id),l&&(l.playsInline=!0);let g=((e,t,n)=>{let r=b.useMemo(()=>{var r,i;let{flipX:a,flipY:o}=e,s=e.type===`svg`||e.src.indexOf(`data:image/svg+xml`)>=0||e.src.indexOf(`.svg`)>=0,c=navigator.userAgent.toLowerCase().indexOf(`firefox`)>-1;if(!(a||o||c&&s))return t;if(!t)return null;let l=t instanceof HTMLVideoElement?t.videoWidth:t?.width,u=t instanceof HTMLVideoElement?t.videoHeight:t?.height;if(!l||!u)return null;let d=pK(),f=1;e.type===`svg`&&(f=Math.max(e.width/l*n,e.height/u*n)),d.width=Math.max(l*f,1),d.height=Math.max(u*f,1);let p=a?-d.width:0,m=o?-d.height:0;return(r=d.getContext(`2d`))==null||r.scale(a?-1:1,o?-1:1),(i=d.getContext(`2d`))==null||i.drawImage(t,p,m,d.width,d.height),d},[e.flipX,e.flipY,t,e.width,e.height,n]);return b.useEffect(()=>()=>{r&&r.nodeName===`CANVAS`&&W.Util.releaseCanvas(r)},[r]),r})(e,l,t._elementsPixelRatio),_=m&&h||g||_K;b.useEffect(()=>{l&&t.history.ignore(()=>{e.set({duration:1e3*l.duration})})},[l]),b.useEffect(()=>{if(!l)return;let n=t.animatedElementsIds,r=(!n.length||n.includes(e.id))&&t.isPlaying,a=p&&(r||s);if(!a){l.pause();return}a&&(l.currentTime=e.startTime*l.duration,l.play());let o=new W.Animation(()=>{oe.current()},i.current?.getLayer());o.start();let u=()=>{c(!1),l.currentTime=e.startTime*l.duration},d=()=>{l.currentTime>=e.endTime*l.duration&&(l.pause(),l.currentTime=e.startTime*l.duration,c(!1))};return l.addEventListener(`ended`,u),l.addEventListener(`timeupdate`,d),()=>{l.pause(),o.stop(),l.removeEventListener(`ended`,u),l.removeEventListener(`timeupdate`,d)}},[l,s,t.isPlaying,p]),b.useEffect(()=>{l&&(l.volume=e.volume)},[l,e.volume]);let v=b.useRef(null);b.useEffect(()=>{let n=cr(()=>{var n;if(l){if(m&&h){F(),t.currentTime;return}let r=t.animatedElementsIds;if(r.length&&!r.includes(e.id))return;let a=t.currentTime>=e.page.startTime&&t.currentTime<e.page.startTime+e.page.duration,o=e.startTime*l.duration*1e3,s=l.duration*(e.endTime-e.startTime)*1e3,c=((t.currentTime||e.page.startTime)-e.page.startTime)%s+o;if(a||(c=0),Math.abs(1e3*l.currentTime-c)>500||!t.isPlaying){let n=c/1e3;n!==l.currentTime&&(l.currentTime=n),!xK(l)&&!t.isPlaying&&!v.current&&(v.current=$_(`video ${e.id}`))}oe.current(),(n=i.current?.getLayer())==null||n.batchDraw()}});return()=>{n(),v.current&&=(v.current(),null)}},[t,l,m,h]),b.useEffect(()=>{var t,n;if(!l)return;if(m){(t=v.current)==null||t.call(v),v.current=null;return}let r=()=>{var t,n;!xK(l)&&(t=e.page)!=null&&t._exportingOrRendering||(v.current&&=(oe.current(),(n=i.current?.getLayer())==null||n.batchDraw(),v.current(),null))},a;return(n=e.page)!=null&&n._exportingOrRendering&&(a=setInterval(r,20)),l.addEventListener(`timeupdate`,r),l.addEventListener(`canplay`,r),()=>{clearInterval(a),l.removeEventListener(`timeupdate`,r),l.removeEventListener(`canplay`,r)}},[e.page?._exportingOrRendering,l,e.id,$_,m]);let{cropX:y,cropY:x,cropWidth:C,cropHeight:w}=e;u!==`loaded`&&(y=x=0,C=w=1);let T=(E=_)instanceof HTMLVideoElement?E.videoWidth:E?.width||0;var E;let D=(e=>e instanceof HTMLVideoElement?e.videoHeight:e?.height||0)(_),O=T*C,k=D*w,ee=e.width/e.height,A,j,te=O/k,M=e.type===`svg`;M?(A=O,j=k):ee>=te?(A=O,j=O/ee):(A=k*ee,j=k);let ne={x:T*y,y:D*x,width:A,height:j},N=e.cornerRadius??0,[P,re]=gK(e,_,ne,t._elementsPixelRatio,N,!0),[ie,ae]=((e,t,n,r)=>{let[i,a]=(0,Uf.default)((e=>{let[t,n]=b.useState(e);return b.useEffect(()=>{(async()=>{let r=await async function(e){return e.indexOf(`data:image/svg+xml`)>=0||e.indexOf(`.svg`)>=0?Sy(Cy(await xy(e))):e}(e);r!==t&&n(r)})()},[e]),t})(e.clipSrc||``),`anonymous`);SK(e.clipSrc?a:`loaded`,e.clipSrc,e.id);let o=b.useMemo(()=>{if(t&&i)return pK()},[t,i]);function s(){var r;if(!i)return;let a=t instanceof HTMLVideoElement?t.videoWidth:t?.width,s=t instanceof HTMLVideoElement?t.videoHeight:t?.height;if(!t||!a||!s||!i||!i.width||!i.height||!o)return;let c=pK(),l=Math.max(e.width/i.width*n,e.height/i.height*n);c.width=i.width*l,c.height=i.height*l,(r=c.getContext(`2d`))==null||r.drawImage(i,0,0,c.width,c.height),o.width=Math.max(a,1),o.height=Math.max(s,1);let u=o.getContext(`2d`);u&&(u.save(),u.drawImage(c,0,0,a,s),W.Util.releaseCanvas(c),u.globalCompositeOperation=`source-in`,u.drawImage(t,0,0,o.width,o.height),u.restore())}return b.useLayoutEffect(()=>{s()},[o,t,i,e.width,e.height,n,...r]),[e.clipSrc&&i?o:t,s]})(e,P,t._elementsPixelRatio,[ne,N,t._elementsPixelRatio]);function F(){var e;re(),ae(),(e=i.current?.getLayer())==null||e.batchDraw()}b.useEffect(()=>{F()});let oe=b.useRef(F);oe.current=F;let se=Math.max(e.width/A,e.height/j);b.useEffect(()=>{if(!e._cropModeEnabled)return;let t=i.current?.getStage();function n(t){e._cropModeEnabled&&t.target!==a.current&&e.toggleCropMode(!1)}function r(n){e._cropModeEnabled&&n.target.parentNode!==t?.content&&e.toggleCropMode(!1)}return document.body.addEventListener(`click`,r),t?.on(`click`,n),t?.on(`tap`,n),()=>{document.body.removeEventListener(`click`,r),document.body.removeEventListener(`touchstart`,r),t?.off(`click`,n),t?.off(`click`,n)}},[e._cropModeEnabled]),b.useLayoutEffect(()=>{if(!n&&!e._cropModeEnabled)return Bx(i.current,e),cr(()=>{Bx(i.current,e)},{delay:100})},[_,n,C,w,e._cropModeEnabled]),b.useLayoutEffect(()=>{var t;n||e._cropModeEnabled?(t=i.current)==null||t.clearCache():Bx(i.current,e)},[n,e.width,e.height,e._cropModeEnabled]),b.useEffect(()=>{Bx(i.current,e)},[e.shadowEnabled,e.shadowBlur,e.cornerRadius,e.shadowColor,e.shadowOffsetX,e.shadowOffsetY,e.shadowOpacity]);let ce=b.useRef(null),le=b.useRef(null),ue=b.useRef(null);b.useLayoutEffect(()=>{e._cropModeEnabled&&(le.current.nodes([ce.current]),ue.current.nodes([a.current]))},[e._cropModeEnabled]);let de=t=>{Math.round(t.target.x())>0&&(t.target.x(0),t.target.scaleX(1)),Math.round(t.target.y())>0&&(t.target.y(0),t.target.scaleY(1));let n=t.target.width()*t.target.scaleX(),r=t.target.height()*t.target.scaleY(),i=Math.min(1,A/n),a=Math.min(1,j/r),o=1-i,s=Math.min(o,Math.max(0,Math.round(-t.target.x())/n)),c=1-a,l=Math.min(c,Math.max(0,Math.round(-t.target.y())/r));t.target.setAttrs({x:-s*T,y:-l*D,scaleX:1,scaleY:1}),e.set({cropX:s,cropY:l,cropWidth:i,cropHeight:a})},fe=()=>{e.type!==`svg`&&e.contentEditable&&setTimeout(()=>{e.toggleCropMode(!0)})},pe=u===`loading`,me=u===`failed`,he=!pe&&!me,ge=b.useRef({cropX:0,cropY:0,cropWidth:0,cropHeight:0}),_e=he?e.a.opacity:0;G_(i,_e);let ve=e.selectable||t.role===dC.ADMIN,ye=Vx();return(0,S.jsx)(S.Fragment,{children:(0,S.jsxs)(jf,{onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),children:[pe&&(0,S.jsx)(vK,{element:e}),me&&(0,S.jsx)(yK,{element:e}),(0,S.jsx)(Ff,{ref:i,name:`element`,id:e.id,image:ie,x:e.a.x,y:e.a.y,width:e.a.width||1,height:e.a.height||1,rotation:e.a.rotation,opacity:_e,shadowEnabled:e.shadowEnabled,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY,shadowColor:e.shadowColor,shadowOpacity:e.shadowOpacity,customCrop:ne,listening:ve,draggable:ye?e.draggable&&o:e.draggable,preventDefault:!ye||o,hideInExport:!e.showInExport,onDragMove:t=>{e.set({x:t.target.x(),y:t.target.y()})},onDragEnd:t=>{e.set({x:t.target.x(),y:t.target.y()})},onDblClick:fe,onDblTap:fe,onTransformStart:()=>{r(!0),ge.current={cropX:e.cropX,cropY:e.cropY,cropWidth:e.cropWidth,cropHeight:e.cropHeight}},onTransform:t=>{let n=t.currentTarget,r=Math.abs(n.scaleX()-1)<1e-7?1:n.scaleX(),i=Math.abs(n.scaleY()-1)<1e-7?1:n.scaleY();n.scaleX(1),n.scaleY(1);let a=t.target.getStage()?.findOne(`Transformer`),o=1-A/T,s=Math.min(o,Math.max(0,e.cropX)),c=1-j/D,l=Math.min(c,Math.max(0,e.cropY)),u=a.getActiveAnchor(),d=!(u.indexOf(`middle`)>=0||u.indexOf(`center`)>=0),f=!d&&r<1&&ge.current.cropHeight>j/D,p=d?e.cropWidth:e.cropWidth*r;f&&(p=e.cropWidth);let m=!d&&i<1&&ge.current.cropWidth>A/T,h=d?e.cropHeight:e.cropHeight*i;m&&(h=e.cropHeight),M&&(p=e.cropWidth,h=e.cropHeight),e.set({cropX:s,cropY:l,x:n.x(),y:n.y(),width:n.width()*r,height:n.height()*i,rotation:t.target.rotation(),cropWidth:Math.min(p,1-s),cropHeight:Math.min(h,1-l)})},onTransformEnd:t=>{let n=t.currentTarget;e.set({width:n.width(),height:n.height(),x:n.x(),y:n.y(),rotation:t.target.rotation(),cropWidth:A/T,cropHeight:j/D}),r(!1)}}),(0,S.jsx)(Nf,{x:e.a.x,y:e.a.y,width:Math.max(e.a.width-e.borderSize,0),height:Math.max(e.a.height-e.borderSize,0),opacity:_e,offsetX:-e.borderSize/2,offsetY:-e.borderSize/2,stroke:e.borderColor,strokeWidth:e.borderSize,listening:!1,visible:!!e.borderSize,rotation:e.rotation,cornerRadius:Math.max(0,N-e.borderSize),hideInExport:!e.showInExport}),!t.isPlaying&&(0,S.jsx)(`Image`,{image:s?d||ye?hK:void 0:mK,x:e.a.x,y:e.a.y,offsetX:-e.a.width/2+15/t.scale,offsetY:-e.a.height/2+15/t.scale,rotation:e.a.rotation,width:30/t.scale,height:30/t.scale,hideInExport:!0,onClick:()=>c(!s),onTap:()=>c(!s)}),e._cropModeEnabled&&(0,S.jsxs)(tx,{selector:`.page-abs-container`,enabled:!0,children:[(0,S.jsx)(`Rect`,{x:-window.innerWidth/t.scale,y:-window.innerWidth/t.scale,width:window.innerWidth/t.scale*3,height:window.innerWidth/t.scale*3,fill:`rgba(0,0,0,0.3)`}),(0,S.jsx)(`Image`,{listening:!1,image:ie,x:e.a.x,y:e.a.y,width:e.a.width,height:e.a.height,rotation:e.a.rotation,shadowEnabled:e.shadowEnabled,shadowBlur:e.shadowBlur}),(0,S.jsxs)(`Group`,{x:e.a.x,y:e.a.y,rotation:e.a.rotation,scaleX:se,scaleY:se,children:[(0,S.jsx)(`Image`,{image:_,ref:a,width:T,height:D,opacity:.4,draggable:!0,x:-e.cropX*T,y:-e.cropY*D,onDragMove:de,onTransform:de}),(0,S.jsx)(`Transformer`,{ref:ue,anchorSize:20,enabledAnchors:[`top-left`,`top-right`,`bottom-left`,`bottom-right`],boundBoxFunc:(e,t)=>t.width<5||t.height<5?e:t,rotateEnabled:!1,borderEnabled:!1,anchorCornerRadius:10,anchorStrokeWidth:2,borderStrokeWidth:2}),(0,S.jsx)(`Rect`,{width:A,height:j,ref:ce,listening:!1,onTransform:t=>{t.target.x()<-e.cropX*T-1e-9&&(t.target.x(-e.cropX*T),t.target.scaleX(1)),t.target.y()<-e.cropY*D-1e-9&&(t.target.y(-e.cropY*D),t.target.scaleY(1));let n=Math.min(1,Math.max(0,e.cropX+t.target.x()/T)),r=Math.min(1,Math.max(0,t.target.y()/D+e.cropY)),i=t.target.width()*t.target.scaleX(),a=t.target.height()*t.target.scaleY(),o=Math.min(1-n,i/T),s=Math.min(1-r,a/D),c=t.target.getAbsolutePosition(t.target.getParent().getParent());t.target.scale({x:1,y:1}),t.target.position({x:0,y:0}),e.set({x:c.x,y:c.y,cropX:n,cropY:r,cropWidth:o,cropHeight:s,width:Math.min(i*se,T*(1-n)*se),height:Math.min(a*se,D*(1-r)*se)})}}),(0,S.jsx)(`Transformer`,{ref:le,enabledAnchors:[`top-left`,`top-right`,`bottom-left`,`bottom-right`],boundBoxFunc:(e,t)=>t.width<5||t.height<5?e:t,keepRatio:!1,rotateEnabled:!1,anchorFill:`rgb(240, 240, 240)`,anchorStrokeWidth:2,borderStrokeWidth:2,visible:e.resizable})]})]})]})})}),wK={},TK=wa(({element:e,store:t})=>{let n=b.useRef(null),r=e.selectable||t.role===dC.ADMIN,i=Vx(),a=e.isSelected,o=Math.min(e.strokeWidth,e.width/2,e.height/2),s=Math.max(0,Math.min(e.width/2,e.height/2,e.cornerRadius)),c=Cx(e,e.a.fill,`fill`),l=Object.assign(Object.assign({width:e.a.width,height:e.a.height},c),{cornerRadius:s,shadowEnabled:e.shadowEnabled,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY,shadowColor:e.shadowColor,shadowOpacity:e.shadowOpacity,preventDefault:!i||a,hideInExport:!e.showInExport}),u=Cx(e,e.stroke,`stroke`),d=Object.assign(Object.assign({visible:o>0,x:o/2,y:o/2,width:e.a.width-o,height:e.a.height-o},u),{strokeWidth:o,cornerRadius:Math.max(0,s-o),dash:e.dash.map(e=>e*o),hideInExport:!e.showInExport,listening:!1}),f=Math.max(0,10-Math.min(e.a.width,e.a.height)),p=(m=e.subType,wK[m]||(wK[m]=(h=By(m),wa(({element:e,fillProps:t,strokeProps:n,hitStrokeWidth:r})=>{let i=h({width:e.a.width,height:e.a.height,cornerRadius:e.cornerRadius}),a=1,o=1;typeof i!=`string`&&(a=i.scaleX,o=i.scaleY,i=i.path);let s=b.useRef(null);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`Rect`,{width:e.a.width,height:e.a.height,fill:`transparent`,hitStrokeWidth:r}),(0,S.jsx)(`Path`,Object.assign({},t,{ref:s,data:i,scaleX:a,scaleY:o})),(0,S.jsx)(`Group`,{clipFunc:e=>{let t=s.current;if(t){var n=t.dataArray;e.beginPath();for(var r=0;r<n.length;r++){var i=n[r].command,a=n[r].points;switch(i){case`L`:e.lineTo(a[0],a[1]);break;case`M`:e.moveTo(a[0],a[1]);break;case`C`:e.bezierCurveTo(a[0],a[1],a[2],a[3],a[4],a[5]);break;case`Q`:e.quadraticCurveTo(a[0],a[1],a[2],a[3]);break;case`A`:var o=a[0],c=a[1],l=a[2],u=a[3],d=a[4],f=a[5],p=a[6],m=a[7],h=l>u?l:u,g=l>u?1:l/u,_=l>u?u/l:1;e.translate(o,c),e.rotate(p),e.scale(g,_),e.arc(0,0,h,d,d+f,!m),e.scale(1/g,1/_),e.rotate(-p),e.translate(-o,-c);break;case`z`:e.closePath()}}}},scaleX:a,scaleY:o,children:(0,S.jsx)(`Path`,Object.assign({},n,{x:0,y:0,data:i,strokeWidth:2*n.strokeWidth,dash:n.dash.map(e=>e)}))})]})}))),wK[m]||`Group`);var m,h;return(0,S.jsx)(S.Fragment,{children:(0,S.jsx)(jf,{ref:n,id:e.id,x:e.a.x,y:e.a.y,rotation:e.a.rotation,opacity:e.a.opacity,listening:r,draggable:i?e.draggable&&a:e.draggable,name:`element`,onDragMove:t=>{e.set({x:t.target.x(),y:t.target.y()})},onDragEnd:t=>{e.set({x:t.target.x(),y:t.target.y()})},onTransform:t=>{let n=t.target.scale();t.target.scaleX(1),t.target.scaleY(1),e.set({width:e.width*n.x,height:e.height*n.y,x:t.target.x(),y:t.target.y(),rotation:t.target.rotation()})},children:(0,S.jsx)(p,{element:e,fillProps:l,strokeProps:d,hitStrokeWidth:f})})})}),EK=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.loop=e.conditional=e.parse=void 0,e.parse=function e(t,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:r;if(Array.isArray(n))n.forEach(function(n){return e(t,n,r,i)});else if(typeof n==`function`)n(t,r,i,e);else{var a=Object.keys(n)[0];Array.isArray(n[a])?(i[a]={},e(t,n[a],r,i[a])):i[a]=n[a](t,r,i,e)}return r},e.conditional=function(e,t){return function(n,r,i,a){t(n,r,i)&&a(n,e,r,i)}},e.loop=function(e,t){return function(n,r,i,a){for(var o=[],s=n.pos;t(n,r,i);){var c={};if(a(n,e,r,c),n.pos===s)break;s=n.pos,o.push(c)}return o}}})),DK=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.readBits=e.readArray=e.readUnsigned=e.readString=e.peekBytes=e.readBytes=e.peekByte=e.readByte=e.buildStream=void 0,e.buildStream=function(e){return{data:e,pos:0}};var t=function(){return function(e){return e.data[e.pos++]}};e.readByte=t,e.peekByte=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return function(t){return t.data[t.pos+e]}};var n=function(e){return function(t){return t.data.subarray(t.pos,t.pos+=e)}};e.readBytes=n,e.peekBytes=function(e){return function(t){return t.data.subarray(t.pos,t.pos+e)}},e.readString=function(e){return function(t){return Array.from(n(e)(t)).map(function(e){return String.fromCharCode(e)}).join(``)}},e.readUnsigned=function(e){return function(t){var r=n(2)(t);return e?(r[1]<<8)+r[0]:(r[0]<<8)+r[1]}},e.readArray=function(e,t){return function(r,i,a){for(var o=typeof t==`function`?t(r,i,a):t,s=n(e),c=Array(o),l=0;l<o;l++)c[l]=s(r);return c}};var r=function(e,t,n){for(var r=0,i=0;i<n;i++)r+=e[t+i]&&2**(n-i-1);return r};e.readBits=function(e){return function(n){for(var i=t()(n),a=Array(8),o=0;o<8;o++)a[7-o]=!!(i&1<<o);return Object.keys(e).reduce(function(t,n){var i=e[n];return i.length?t[n]=r(a,i.index,i.length):t[n]=a[i.index],t},{})}}})),OK=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var t=EK(),n=DK(),r={blocks:function(e){for(var t=0,r=[],i=e.data.length,a=0,o=(0,n.readByte)()(e);o!==t&&o;o=(0,n.readByte)()(e)){if(e.pos+o>=i){var s=i-e.pos;r.push((0,n.readBytes)(s)(e)),a+=s;break}r.push((0,n.readBytes)(o)(e)),a+=o}for(var c=new Uint8Array(a),l=0,u=0;u<r.length;u++)c.set(r[u],l),l+=r[u].length;return c}},i=(0,t.conditional)({gce:[{codes:(0,n.readBytes)(2)},{byteSize:(0,n.readByte)()},{extras:(0,n.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,n.readUnsigned)(!0)},{transparentColorIndex:(0,n.readByte)()},{terminator:(0,n.readByte)()}]},function(e){var t=(0,n.peekBytes)(2)(e);return t[0]===33&&t[1]===249}),a=(0,t.conditional)({image:[{code:(0,n.readByte)()},{descriptor:[{left:(0,n.readUnsigned)(!0)},{top:(0,n.readUnsigned)(!0)},{width:(0,n.readUnsigned)(!0)},{height:(0,n.readUnsigned)(!0)},{lct:(0,n.readBits)({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},(0,t.conditional)({lct:(0,n.readArray)(3,function(e,t,n){return 2**(n.descriptor.lct.size+1)})},function(e,t,n){return n.descriptor.lct.exists}),{data:[{minCodeSize:(0,n.readByte)()},r]}]},function(e){return(0,n.peekByte)()(e)===44}),o=(0,t.conditional)({text:[{codes:(0,n.readBytes)(2)},{blockSize:(0,n.readByte)()},{preData:function(e,t,r){return(0,n.readBytes)(r.text.blockSize)(e)}},r]},function(e){var t=(0,n.peekBytes)(2)(e);return t[0]===33&&t[1]===1}),s=(0,t.conditional)({application:[{codes:(0,n.readBytes)(2)},{blockSize:(0,n.readByte)()},{id:function(e,t,r){return(0,n.readString)(r.blockSize)(e)}},r]},function(e){var t=(0,n.peekBytes)(2)(e);return t[0]===33&&t[1]===255}),c=(0,t.conditional)({comment:[{codes:(0,n.readBytes)(2)},r]},function(e){var t=(0,n.peekBytes)(2)(e);return t[0]===33&&t[1]===254});e.default=[{header:[{signature:(0,n.readString)(3)},{version:(0,n.readString)(3)}]},{lsd:[{width:(0,n.readUnsigned)(!0)},{height:(0,n.readUnsigned)(!0)},{gct:(0,n.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,n.readByte)()},{pixelAspectRatio:(0,n.readByte)()}]},(0,t.conditional)({gct:(0,n.readArray)(3,function(e,t){return 2**(t.lsd.gct.size+1)})},function(e,t){return t.lsd.gct.exists}),{frames:(0,t.loop)([i,s,c,a,o],function(e){var t=(0,n.peekByte)()(e);return t===33||t===44})}]})),kK=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.deinterlace=void 0,e.deinterlace=function(e,t){for(var n=Array(e.length),r=e.length/t,i=function(r,i){var a=e.slice(i*t,(i+1)*t);n.splice.apply(n,[r*t,t].concat(a))},a=[0,4,2,1],o=[8,8,4,2],s=0,c=0;c<4;c++)for(var l=a[c];l<r;l+=o[c])i(l,s),s++;return n}})),AK=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.lzw=void 0,e.lzw=function(e,t,n){var r=4096,i=-1,a=n,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S=Array(n),C=Array(r),w=Array(r),T=Array(r+1);for(_=e,s=1<<_,u=s+1,o=s+2,f=i,l=_+1,c=(1<<l)-1,m=0;m<s;m++)C[m]=0,w[m]=m;var g=p=v=y=x=b=0,p,v,y,x,b;for(h=0;h<a;){if(y===0){if(p<l){g+=t[b]<<p,p+=8,b++;continue}if(m=g&c,g>>=l,p-=l,m>o||m==u)break;if(m==s){l=_+1,c=(1<<l)-1,o=s+2,f=i;continue}if(f==i){T[y++]=w[m],f=m,v=m;continue}for(d=m,m==o&&(T[y++]=v,m=f);m>s;)T[y++]=w[m],m=C[m];v=w[m]&255,T[y++]=v,o<r&&(C[o]=f,w[o]=v,o++,(o&c)===0&&o<r&&(l++,c+=o)),f=d}y--,S[x++]=T[y],h++}for(h=x;h<a;h++)S[h]=0;return S}})),jK=o((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.decompressFrames=e.decompressFrame=e.parseGIF=void 0;var t=o(OK()),n=EK(),r=DK(),i=kK(),a=AK();function o(e){return e&&e.__esModule?e:{default:e}}e.parseGIF=function(e){var i=new Uint8Array(e);return(0,n.parse)((0,r.buildStream)(i),t.default)};var s=function(e){for(var t=e.pixels.length,n=new Uint8ClampedArray(t*4),r=0;r<t;r++){var i=r*4,a=e.pixels[r],o=e.colorTable[a]||[0,0,0];n[i]=o[0],n[i+1]=o[1],n[i+2]=o[2],n[i+3]=a===e.transparentIndex?0:255}return n},c=function(e,t,n){if(!e.image){console.warn(`gif frame does not have associated image.`);return}var r=e.image,o=r.descriptor.width*r.descriptor.height,c=(0,a.lzw)(r.data.minCodeSize,r.data.blocks,o);r.descriptor.lct.interlaced&&(c=(0,i.deinterlace)(c,r.descriptor.width));var l={pixels:c,dims:{top:e.image.descriptor.top,left:e.image.descriptor.left,width:e.image.descriptor.width,height:e.image.descriptor.height}};return r.descriptor.lct&&r.descriptor.lct.exists?l.colorTable=r.lct:l.colorTable=t,e.gce&&(l.delay=(e.gce.delay||10)*10,l.disposalType=e.gce.extras.disposal,e.gce.extras.transparentColorGiven&&(l.transparentIndex=e.gce.transparentColorIndex)),n&&(l.patch=s(l)),l};e.decompressFrame=c,e.decompressFrames=function(e,t){return e.frames.filter(function(e){return e.image}).map(function(n){return c(n,e.gct,t)})}}))();function MK(e,t,n){let r=t.getContext(`2d`),i=n.getContext(`2d`);if(!r||!i)return;e.disposalType===2&&r.clearRect(0,0,t.width,t.height),n.width=e.width,n.height=e.height;let a=i.createImageData(e.width,e.height);a.data.set(e.patch),i.putImageData(a,0,0),r.drawImage(n,e.left,e.top)}var NK=wa(({element:e})=>{let t=Math.min(30,e.width/4,e.height/4),n=b.useRef(null);b.useEffect(()=>{let e=n.current;if(!e)return;let t=new W.Animation(t=>{e.rotate((t?.timeDiff||0)/2)},e.getLayer());return t.start(),()=>{t.stop()}},[]);let{mediaLoadingStyle:r}=up();return(0,S.jsxs)(jf,{x:e.a.x,y:e.a.y,rotation:e.a.rotation,listening:!1,opacity:e.a.opacity,hideInExport:!e.showInExport,children:[(0,S.jsx)(Nf,{width:e.width,height:e.height,fill:r.fill}),(0,S.jsx)(`Arc`,{ref:n,x:e.width/2,y:e.height/2,fill:r.textFill,outerRadius:Math.abs(t),innerRadius:Math.max(1,t-5),angle:270})]})}),PK=wa(({element:e})=>{let{mediaErrorStyle:t}=up(),n=Math.max(10,Math.min(30,e.width/22));return(0,S.jsxs)(jf,{x:e.a.x,y:e.a.y,rotation:e.a.rotation,listening:!1,opacity:e.a.opacity,hideInExport:!e.showInExport,children:[(0,S.jsx)(Nf,{width:e.width,height:e.height,fill:t.fill}),(0,S.jsx)(If,{text:`Cannot load the GIF...`,fontSize:n,width:e.width,height:e.height,align:`center`,fill:t.textFill,verticalAlign:`middle`,padding:5})]})}),FK=wa(({element:e,store:t})=>{let[n,r]=b.useState(!1),i=e.isSelected,a=b.useRef(null),o=b.useRef(void 0),[s,c,l,u]=function(e){let[t,n]=b.useState([]),[r,i]=b.useState(0),[a,o]=b.useState(`loading`),[s,c]=b.useState({width:0,height:0});return b.useEffect(()=>{(async()=>{try{let t=(0,jK.parseGIF)(await(await fetch(e)).arrayBuffer()),r=(0,jK.decompressFrames)(t,!0),a=t.lsd.width,s=t.lsd.height;c({width:a,height:s});let l=r.map(e=>({patch:new Uint8ClampedArray(e.patch),delay:e.delay,width:e.dims.width,height:e.dims.height,left:e.dims.left,top:e.dims.top,disposalType:e.disposalType})),u=l.reduce((e,t)=>e+t.delay,0);n(l),i(u),o(`loaded`)}catch(e){console.error(`Failed to load GIF:`,e),o(`failed`)}})()},[e]),[t,r,s,a]}(e.src);OC(u,e.src,e.id),b.useEffect(()=>(o.current=document.createElement(`canvas`),()=>{o.current&&W.Util.releaseCanvas(o.current)}),[]),b.useEffect(()=>{if(u===`loaded`&&o.current&&(o.current.width=l.width,o.current.height=l.height,s.length>0)){let e=o.current.getContext(`2d`);if(e){e.clearRect(0,0,l.width,l.height);let t=document.createElement(`canvas`);MK(s[0],o.current,t)}}},[l,u,s]),b.useEffect(()=>{if(!s.length||!o.current)return;let n=o.current;n.width=l.width,n.height=l.height;let r=document.createElement(`canvas`),i=n.getContext(`2d`);i&&i.clearRect(0,0,n.width,n.height);let u=-1;MK(s[0],n,r),v(),u=0;let d=e=>{let t=(e=>{let t=e%c,n=0;for(let e=0;e<s.length;e++)if(n+=s[e].delay,n>t)return e;return 0})(e);t!==u&&(MK(s[t],n,r),v(),a.current.getLayer().draw(),u=t)};if(t.isPlaying||e.page?._exportingOrRendering)return cr(()=>{d(t.currentTime-e.page.startTime)});{let e=window.setInterval(()=>{d(t.currentTime||performance.now())},16);return()=>{clearInterval(e)}}},[t.isPlaying,s,c,e.page?._exportingOrRendering]),b.useEffect(()=>{c&&t.history.ignore(()=>{e.set({duration:c})})},[c]);let{cropX:d,cropY:f,cropWidth:p,cropHeight:m}=e;u!==`loaded`&&(d=f=0,p=m=1);let h={x:l.width*d,y:l.height*f,width:l.width*p,height:l.height*m},g=e.cornerRadius??0,[_,v]=gK(e,o.current,h,t._elementsPixelRatio,g,n||e._cropModeEnabled);b.useLayoutEffect(()=>{if(!n&&!e._cropModeEnabled&&a.current)return Bx(a.current,e),cr(()=>{Bx(a.current,e)},{delay:100})},[o.current,n,p,m,e._cropModeEnabled,l.width,l.height]);let y=u===`loading`,x=u===`failed`,C=y||x?0:e.a.opacity;G_(a,C);let w=e.selectable||t.role===dC.ADMIN,T=Vx();return(0,S.jsxs)(S.Fragment,{children:[y&&(0,S.jsx)(NK,{element:e}),x&&(0,S.jsx)(PK,{element:e}),(0,S.jsx)(Ff,{ref:a,name:`element`,id:e.id,image:_,x:e.a.x,y:e.a.y,width:e.a.width||1,height:e.a.height||1,rotation:e.a.rotation,opacity:C,shadowEnabled:e.shadowEnabled,shadowBlur:e.shadowBlur,shadowOffsetX:e.shadowOffsetX,shadowOffsetY:e.shadowOffsetY,shadowColor:e.shadowColor,shadowOpacity:e.shadowOpacity,customCrop:h,listening:w,draggable:T?e.draggable&&i:e.draggable,preventDefault:!T||i,hideInExport:!e.showInExport,onDragMove:t=>{e.set({x:t.target.x(),y:t.target.y()})},onDragEnd:t=>{e.set({x:t.target.x(),y:t.target.y()})},onTransformStart:()=>r(!0),onTransform:t=>{let n=t.currentTarget,r=Math.abs(n.scaleX()-1)<1e-7?1:n.scaleX(),i=Math.abs(n.scaleY()-1)<1e-7?1:n.scaleY();n.scaleX(1),n.scaleY(1),e.set({x:n.x(),y:n.y(),width:n.width()*r,height:n.height()*i,rotation:n.rotation()})},onTransformEnd:()=>r(!1)}),(0,S.jsx)(Nf,{x:e.a.x,y:e.a.y,width:Math.max(e.a.width-e.borderSize,0),height:Math.max(e.a.height-e.borderSize,0),opacity:C,offsetX:-e.borderSize/2,offsetY:-e.borderSize/2,stroke:e.borderColor,strokeWidth:e.borderSize,listening:!1,visible:!!e.borderSize,rotation:e.rotation,cornerRadius:Math.max(0,g-e.borderSize),hideInExport:!e.showInExport})]})}),IK=`#0d83dd`,LK=(e,t)=>{let n=e.target.getStage();n&&(n.container().style.cursor=t)},RK=wa(({axis:e,hovered:t,pillX:n,pillY:r,pillW:i,pillH:a,hitX:o,hitY:s,hitW:c,hitH:l,tint:u,hoverKind:d,idx:f,onSelect:p,onHoverChange:m})=>(0,S.jsxs)(S.Fragment,{children:[t&&(0,S.jsx)(`Rect`,{x:u.x,y:u.y,width:u.width,height:u.height,fill:`rgba(13, 131, 221, 0.08)`,listening:!1}),(0,S.jsx)(Nf,{x:n,y:r,width:i,height:a,cornerRadius:Math.min(i,a)/2,fill:t?IK:`#9ca3af`,opacity:t?.55:.18,listening:!1}),(0,S.jsx)(Nf,{x:o,y:s,width:c,height:l,fill:`transparent`,onMouseEnter:e=>{m({kind:d,idx:f}),LK(e,`pointer`)},onMouseLeave:e=>{m(null),LK(e,``)},onClick:p})]})),zK=wa(({x:e,y:t,hovered:n,hoverKind:r,idx:i,isTouch:a,sizes:o,onInsert:s,onHoverChange:c})=>{let{hit:l,r:u,halo:d,stroke:f}=o,p=n||a;return(0,S.jsxs)(jf,{x:e,y:t,onMouseEnter:e=>{c({kind:r,idx:i}),LK(e,`pointer`)},onMouseLeave:e=>{c(null),LK(e,``)},onClick:e=>{e.cancelBubble=!0,s()},children:[(0,S.jsx)(Nf,{x:-l/2,y:-l/2,width:l,height:l,fill:`transparent`}),p&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`Circle`,{radius:u+d,fill:`white`,listening:!1}),(0,S.jsx)(`Circle`,{radius:u,fill:IK,listening:!1}),(0,S.jsx)(`Line`,{points:[.55*-u,0,.55*u,0],stroke:`white`,strokeWidth:f,lineCap:`round`,listening:!1}),(0,S.jsx)(`Line`,{points:[0,.55*-u,0,.55*u],stroke:`white`,strokeWidth:f,lineCap:`round`,listening:!1})]})]})}),BK=wa(({element:e,store:t,inv:n,isTouch:r,hover:i,setHover:a})=>{let o=16*n,s=2*n,c=10*n,l={hit:22*n,r:7*n,halo:2*n,stroke:2*n},u=(e,t)=>i!==null&&i.kind===e&&i.idx===t,d=(t,n)=>r=>{r.cancelBubble=!0;let i=e._anchorCellId?e.cells.find(t=>t.id===e._anchorCellId):void 0;r.evt.shiftKey&&i?t===`col`?e.selectColumnRange(i.col,n):e.selectRowRange(i.row,n):t===`col`?e.selectColumn(n):e.selectRow(n)},f=[0],p=[0];for(let t=0;t<e.cols;t++)f.push(f[t]+e.colWidths[t]*e.a.width);for(let t=0;t<e.rows;t++)p.push(p[t]+e.rowHeights[t]*e.a.height);let m=[];for(let t=0;t<e.cols;t++){let n=Math.max(0,f[t+1]-f[t]-6);n<=0||m.push((0,S.jsx)(RK,{axis:`col`,hovered:u(`colSelect`,t),pillX:f[t]+3,pillY:-s-c,pillW:n,pillH:s,hitX:f[t]+1,hitY:-o-c+s,hitW:n+4,hitH:o,tint:{x:f[t],y:0,width:f[t+1]-f[t],height:e.a.height},hoverKind:`colSelect`,idx:t,onSelect:d(`col`,t),onHoverChange:a},`col-pill-${t}`))}for(let n=0;n<=e.cols;n++)m.push((0,S.jsx)(zK,{x:f[n],y:-c-s/2,hovered:u(`colInsert`,n),hoverKind:`colInsert`,idx:n,isTouch:r,sizes:l,onInsert:()=>t.history.transaction(()=>e.addColumn(n)),onHoverChange:a},`col-insert-${n}`));for(let t=0;t<e.rows;t++){let n=Math.max(0,p[t+1]-p[t]-6);n<=0||m.push((0,S.jsx)(RK,{axis:`row`,hovered:u(`rowSelect`,t),pillX:-s-c,pillY:p[t]+3,pillW:s,pillH:n,hitX:-o-c+s,hitY:p[t]+1,hitW:o,hitH:n+4,tint:{x:0,y:p[t],width:e.a.width,height:p[t+1]-p[t]},hoverKind:`rowSelect`,idx:t,onSelect:d(`row`,t),onHoverChange:a},`row-pill-${t}`))}for(let n=0;n<=e.rows;n++)m.push((0,S.jsx)(zK,{x:-c-s/2,y:p[n],hovered:u(`rowInsert`,n),hoverKind:`rowInsert`,idx:n,isTouch:r,sizes:l,onInsert:()=>t.history.transaction(()=>e.addRow(n)),onHoverChange:a},`row-insert-${n}`));return(0,S.jsx)(S.Fragment,{children:m})}),VK=wa(({element:e,store:t})=>{let n=b.useRef(null),r=b.useRef(null),i=e.selectable||t.role===dC.ADMIN,a=Vx(),o=e.isSelected,s=e._focusedCellIds.length>0,c=e.editingCell,l=1/Math.max(.01,t.scale),[u,d]=b.useState(null);b.useEffect(()=>{o||(e.clearCellFocus(),d(null))},[o]);let f=c?._editModeEnabled;b.useEffect(()=>{e._editingCellId&&c&&!c._editModeEnabled&&e.exitCellEdit()},[f]),b.useEffect(()=>{s&&!e._editingCellId&&setTimeout(()=>r.current?.focus(),0)},[s,e._editingCellId]);let p=b.useMemo(()=>Ut.box(!1),[]);b.useEffect(()=>cr(()=>{p.get()||e._fitRowsToContent&&t.history.ignore(()=>{e._applyFitRowsToContent()})}),[e,t,p]);let m=t=>{let r=t.target.getStage();if(!r)return;let i=r.getPointerPosition();if(!i)return;let a=n.current;if(!a)return;let o=a.getAbsoluteTransform().copy().invert().point(i);for(let t of e.visibleCells){let n=e.getCellRect(t.row,t.col,t.rowSpan,t.colSpan);if(o.x>=n.x&&o.x<=n.x+n.width&&o.y>=n.y&&o.y<=n.y+n.height)return t}},h=(e,t)=>e===`dashed`?[4*t,2*t]:e===`dotted`?[t,t]:void 0,g=[];for(let t of e.visibleCells){let n=e.getCellRect(t.row,t.col,t.rowSpan,t.colSpan),r=t.row===0,i=t.row+t.rowSpan===e.rows,a=t.col===0,o=t.col+t.colSpan===e.cols;if(t.row===0){let e=t.getEffectiveBorder(`top`);if(e.style!==`none`&&e.width>0){let r=n.y+e.width/2,i=n.x-(a?0:e.width/2),s=n.x+n.width+(o?0:e.width/2);g.push((0,S.jsx)(Pf,{points:[i,r,s,r],stroke:e.color,strokeWidth:e.width,dash:h(e.style,e.width),listening:!1},`bt-${t.id}`))}}if(t.col===0){let e=t.getEffectiveBorder(`left`);if(e.style!==`none`&&e.width>0){let a=n.x+e.width/2,o=n.y-(r?0:e.width/2),s=n.y+n.height+(i?0:e.width/2);g.push((0,S.jsx)(Pf,{points:[a,o,a,s],stroke:e.color,strokeWidth:e.width,dash:h(e.style,e.width),listening:!1},`bl-${t.id}`))}}{let e=t.getEffectiveBorder(`bottom`);if(e.style!==`none`&&e.width>0){let r=i?n.y+n.height-e.width/2:n.y+n.height,s=n.x-(a?0:e.width/2),c=n.x+n.width+(o?0:e.width/2);g.push((0,S.jsx)(Pf,{points:[s,r,c,r],stroke:e.color,strokeWidth:e.width,dash:h(e.style,e.width),listening:!1},`bb-${t.id}`))}}{let e=t.getEffectiveBorder(`right`);if(e.style!==`none`&&e.width>0){let a=o?n.x+n.width-e.width/2:n.x+n.width,s=n.y-(r?0:e.width/2),c=n.y+n.height+(i?0:e.width/2);g.push((0,S.jsx)(Pf,{points:[a,s,a,c],stroke:e.color,strokeWidth:e.width,dash:h(e.style,e.width),listening:!1},`br-${t.id}`))}}}return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(Nf,{id:e.id,name:`element`,x:e.a.x,y:e.a.y,rotation:e.a.rotation,width:e.a.width,height:e.a.height,fill:`transparent`,opacity:e.a.opacity,hideInExport:!e.showInExport,listening:i,draggable:a?e.draggable&&o:e.draggable,onClick:t=>{if(!o||e.locked||!e.contentEditable)return;let n=m(t);n&&(t.evt.shiftKey&&s?(t.cancelBubble=!0,e.focusCellRange(n.row,n.col)):e.focusCell(n.id))},onDblClick:t=>{if(!o||e.locked||!e.contentEditable)return;let n=m(t);n&&e.enterCellEdit(n.id)},onDragMove:t=>{var r;let i=t.target;e.set({x:i.x(),y:i.y()}),(r=n.current)==null||r.position({x:i.x(),y:i.y()})},onDragEnd:t=>{let n=t.target;e.set({x:n.x(),y:n.y()})},onTransformStart:()=>{or(()=>p.set(!0))},onTransformEnd:()=>{e._resetBaseRowHeights(),or(()=>p.set(!1))},onTransform:t=>{var r,i;let a=t.target,o=a.scaleX(),s=a.scaleY();a.scaleX(1),a.scaleY(1);let c=e.width*o,l=e.height*s;a.width(c),a.height(l);let u=a.x(),d=a.y(),f=a.rotation();(r=n.current)==null||r.position({x:u,y:d}),(i=n.current)==null||i.rotation(f),e.set({width:c,x:u,y:d,rotation:f}),e.setHeightRedistribute(l)}}),(0,S.jsxs)(jf,{ref:n,x:e.a.x,y:e.a.y,rotation:e.a.rotation,opacity:e.a.opacity,hideInExport:!e.showInExport,scaleX:e.a.width/e.width,scaleY:e.a.height/e.height,children:[e.visibleCells.map(t=>{let n=e.getCellRect(t.row,t.col,t.rowSpan,t.colSpan);return t.cellBackground===`transparent`?null:(0,S.jsx)(Nf,{x:n.x,y:n.y,width:n.width,height:n.height,fill:t.cellBackground,listening:!1},`bg-${t.id}`)}),g,e.visibleCells.map(e=>(0,S.jsx)(nS,{element:e,store:t},`text-${e.id}`)),o&&e._focusedCellIds.map(t=>{let n=e.cells.find(e=>e.id===t);if(!n)return null;let r=e.getCellRect(n.row,n.col,n.rowSpan,n.colSpan),i=2*l;return(0,S.jsx)(`Rect`,{x:r.x,y:r.y,width:r.width,height:r.height,fill:`rgba(13, 131, 221, 0.1)`,stroke:`#0d83dd`,strokeWidth:i,listening:!1},`focus-${t}`)}),s&&!c&&(0,S.jsx)(ex,{children:(0,S.jsx)(`input`,{ref:r,style:{position:`absolute`,opacity:0,width:`1px`,height:`1px`,pointerEvents:`none`},readOnly:!0})}),o&&!c&&!t.isPlaying&&(()=>{let n=[],r=0;for(let i=0;i<e.cols-1;i++){r+=e.colWidths[i]*e.a.width;let a=r,o=i;n.push((0,S.jsx)(`Line`,{x:a,points:[0,0,0,e.a.height],stroke:`transparent`,strokeWidth:1,hitStrokeWidth:16,draggable:!0,onMouseEnter:e=>{let t=e.target.getStage()?.container();t&&(t.style.cursor=`col-resize`),d({kind:`colInsert`,idx:o+1})},onMouseLeave:e=>{let t=e.target.getStage()?.container();t&&(t.style.cursor=``),d(null)},onDragStart:e=>{e.cancelBubble=!0,t.history.startTransaction()},onDragMove:t=>{t.cancelBubble=!0;let n=t.target,r=(n.x()-a)/e.width;n.x(a),e.resizeColumn(o,r)},onDragEnd:e=>{e.cancelBubble=!0,e.target.x(a),t.history.endTransaction()}},`col-resize-${i}`))}return n})(),o&&!c&&!t.isPlaying&&(()=>{let n=[],r=0;for(let i=0;i<e.rows-1;i++){r+=e.rowHeights[i]*e.a.height;let a=r,o=i;n.push((0,S.jsx)(`Line`,{y:a,points:[0,0,e.a.width,0],stroke:`transparent`,strokeWidth:1,hitStrokeWidth:16,draggable:!0,onMouseEnter:e=>{let t=e.target.getStage()?.container();t&&(t.style.cursor=`row-resize`),d({kind:`rowInsert`,idx:o+1})},onMouseLeave:e=>{let t=e.target.getStage()?.container();t&&(t.style.cursor=``),d(null)},onDragStart:e=>{e.cancelBubble=!0,or(()=>p.set(!0)),t.history.startTransaction()},onDragMove:t=>{t.cancelBubble=!0;let n=t.target,r=(n.y()-a)/e.height;n.y(a),e.resizeRow(o,r)},onDragEnd:n=>{n.cancelBubble=!0,n.target.y(a),e._resetBaseRowHeights(),or(()=>p.set(!1)),t.history.endTransaction()}},`row-resize-${i}`))}return n})(),o&&!c&&!t.isPlaying&&(0,S.jsx)(BK,{element:e,store:t,inv:l,isTouch:a,hover:u,setHover:d})]})]})}),HK=wa(({element:e})=>{let{highlighterStyle:t}=up();return(0,S.jsx)(Nf,Object.assign({name:`highlighter`,x:e.a.x,y:e.a.y,rotation:e.a.rotation,width:e.a.width,height:e.a.height,listening:!1,strokeScaleEnabled:!1},t))}),UK={text:nS,image:kC,svg:kC,line:OL,video:CK,figure:TK,group:wa(e=>{let{element:t,store:n}=e,r=t,{children:i}=r,a=t.selectable||n.role===dC.ADMIN,o=r.a;return(0,S.jsx)(jf,{x:o.x,y:o.y,offsetX:o.offsetX,offsetY:o.offsetY,scaleX:o.scaleX,scaleY:o.scaleY,rotation:o.rotation,opacity:o.opacity,listening:a,hideInExport:!t.showInExport,id:t.id,children:i.map(t=>(0,b.createElement)(GK,Object.assign({},e,{key:t.id,store:n,element:t})))})}),gif:FK,table:VK},WK=(e,t)=>{let n=[];Rb(e,e=>{e.type!==`group`&&n.push(e.a)});let r=[];n.forEach(e=>{let t=[{x:0,y:0},{x:0+e.width,y:0},{x:0+e.width,y:0+e.height},{x:0,y:0+e.height}],n=new W.Transform;n.translate(e.x,e.y),n.rotate(W.Util.degToRad(e.rotation)),t.forEach(e=>{let t=n.point(e);r.push(t)})});let i=new W.Transform;i.rotate(-W.Util.degToRad(t));let a=1/0,o=1/0,s=-1/0,c=-1/0;r.forEach(e=>{let t=i.point(e);a=Math.min(a,t.x),o=Math.min(o,t.y),s=Math.max(s,t.x),c=Math.max(c,t.y)}),i.invert();let l=i.point({x:a,y:o});return{x:l.x,y:l.y,width:s-a,height:c-o,rotation:t}},GK=wa(e=>{let{element:t,store:n}=e,[r,i]=b.useState(!1),a=t.isSelectedDirectly,o=t.parent?.type===`group`,s=t.type!==`group`||o?null:n.selectedElements,c=!!s&&s.length===1&&s[0]!==t&&s[0].top===t,[l,u]=b.useState(!1),d=(e=>{let[t,n]=b.useState();return b.useEffect(()=>{let t=setTimeout(()=>{let t=e.page.id,r=W.stages.find(e=>e.getAttr(`pageId`)===t);r||console.error(`No stage is found for element`,e.id),n(r)});return()=>clearTimeout(t)},[e.id]),t})(t),f=b.useRef(void 0),p=()=>(f.current||=d?.findOne(`Transformer`),f.current);b.useEffect(()=>{if(d){let e=e=>{let r=e.target.findAncestor(`.element`,!0),a=n.getElementById(r?.id())?.top;i(a?.id===t.id)};d.on(`mouseover`,e);let r=()=>{i(!1)};return d.on(`mouseleave`,r),()=>{d.off(`mouseover`,e),d.off(`mouseleave`,r)}}},[d]),b.useEffect(()=>{if(!c)return;let e=p();if(!d||!e)return;u(!1);let t=()=>u(!0),n=()=>u(!1);return d.on(`dragstart`,t),d.on(`dragend`,n),e.on(`transformstart`,t),e.on(`transformend`,n),()=>{d.off(`dragstart`,t),d.off(`dragend`,n),e.off(`transformstart`,t),e.off(`transformend`,n)}},[d,c]);let m=UK[e.element.type];return e.element.type===`text`&&(h_.renderTagTextEnabled?m=gL:h_.htmlRenderEnabled&&(m=$P)),e.element.visible?m?(0,S.jsxs)(jf,{name:`element-container`,children:[(0,S.jsx)(m,Object.assign({},e)),(r||c)&&!a&&!o&&!l&&(0,S.jsx)(HK,{element:t.type===`group`?{a:WK(t,c?`rotation`in s[0]?s[0].rotation:0:p()?.rotation()||0)}:t})]}):(console.error(`Can not find component for `+e.element.type),null):null});function KK(e,t=.5){if(e.length<3)return e;let n=[];n.push(e[0]);for(let t=0;t<e.length-1;t++){let r=e[Math.max(0,t-1)],i=e[t],a=e[t+1],o=e[Math.min(e.length-1,t+2)];for(let e=0;e<10;e++){let t=e/10,s=t*t,c=s*t,l=.5*(2*i.x+(-r.x+a.x)*t+(2*r.x-5*i.x+4*a.x-o.x)*s+(-r.x+3*i.x-3*a.x+o.x)*c),u=.5*(2*i.y+(-r.y+a.y)*t+(2*r.y-5*i.y+4*a.y-o.y)*s+(-r.y+3*i.y-3*a.y+o.y)*c);n.push({x:l,y:u})}}return n.push(e[e.length-1]),n}function qK(e){if(e.length===0)return``;if(e.length===1){let t=e[0];return`M ${t.x},${t.y} L ${t.x+.1},${t.y}`}let t=`M ${e[0].x},${e[0].y}`;for(let n=1;n<e.length-1;n++){let r=e[n],i=e[n+1],a=(r.x+i.x)/2,o=(r.y+i.y)/2;t+=` Q ${r.x},${r.y} ${a},${o}`}if(e.length>1){let n=e[e.length-1];t+=` L ${n.x},${n.y}`}return t}function JK(e){if(e.length===0)return{x:0,y:0,width:0,height:0};let t=e[0].x,n=e[0].y,r=e[0].x,i=e[0].y;for(let a of e)t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x),i=Math.max(i,a.y);return{x:t,y:n,width:r-t,height:i-n}}function YK(e,t){if(e.length===0)throw Error(`Cannot create SVG from empty path`);let n=t.smooth?KK(e):e,r=JK(n),i=t.strokeWidth,a=r.x-i,o=r.y-i,s=r.width+2*i,c=r.height+2*i;return{src:Sy(`\n <svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${c}" viewBox="0 0 ${s} ${c}">\n <path\n d="${qK(n.map(e=>({x:e.x-a,y:e.y-o})))}"\n stroke="${t.stroke}"\n stroke-width="${t.strokeWidth}"\n stroke-linecap="round"\n stroke-linejoin="round"\n fill="none"\n />\n </svg>\n `.trim()),x:a,y:o,width:s,height:c}}var XK=wa(({store:e,page:t,width:n,height:r,scale:i,xPadding:a,yPadding:o,bleed:s})=>{let[c,l]=b.useState(!1),[u,d]=b.useState([]),f=b.useRef(null),p=e.tool===`draw`,{strokeWidth:m,stroke:h,opacity:g,brushType:_}=e.toolOptions,v=b.useCallback(e=>{if(!p||(l(!0),e.cancelBubble=!0,!e.target.getStage()))return;let t=f.current.getRelativePointerPosition();t&&d([{x:t.x,y:t.y}])},[p,i,a,o,s]),y=b.useCallback(e=>{if(!p||!c||(e.cancelBubble=!0,!e.target.getStage()))return;let t=f.current.getRelativePointerPosition();t&&d(e=>[...e,{x:t.x,y:t.y}])},[p,c,i,a,o,s]),x=b.useCallback(()=>{if(p&&c){if(l(!1),u.length>=1)try{let n=YK(u,{stroke:h,strokeWidth:m,smooth:!0}),r=e.selectedElementsIds.slice();e.history.transaction(()=>{t.addElement({type:`svg`,x:n.x,y:n.y,width:n.width,height:n.height,src:n.src,opacity:g},{skipSelect:!0})}),e.selectElements(r)}catch(e){console.error(`Error creating path SVG:`,e)}d([])}},[p,c,u,h,m,g,t,e.history,e]);b.useEffect(()=>{if(!c)return;let e=()=>x();return window.addEventListener(`mouseup`,e),window.addEventListener(`touchend`,e),()=>{window.removeEventListener(`mouseup`,e),window.removeEventListener(`touchend`,e)}},[c,x]);let C=b.useMemo(()=>u.flatMap(e=>[e.x,e.y]),[u]);return b.useEffect(()=>{if(p&&f.current){let e=f.current.getStage();if(!e)return;let t=m*i;if(t>100||t<4)e.container().style.cursor=`crosshair`;else{let n=t/2,r=t/2,i=`data:image/svg+xml;base64,${btoa(`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="0 0 ${t} ${t}">\n <circle cx="${r}" cy="${r}" r="${n-1}" fill="${h}" opacity="${g}" stroke="white" stroke-width="1"/>\n <circle cx="${r}" cy="${r}" r="${n-1}" fill="none" stroke="black" stroke-width="1" opacity="0.3"/>\n </svg>`)}`;e.container().style.cursor=`url("${i}") ${r} ${r}, crosshair`}return()=>{e.container()&&(e.container().style.cursor=``)}}},[p,h,m,g,i]),p?(0,S.jsxs)(jf,{ref:f,listening:p,x:a+s*i,y:o+s*i,scaleX:i,scaleY:i,children:[(0,S.jsx)(Nf,{x:-(a+s*i)/i,y:-(o+s*i)/i,width:n/i,height:r/i,fill:`transparent`,onMouseDown:v,onMouseMove:y,onMouseUp:x,onTouchStart:v,onTouchMove:y,onTouchEnd:x}),u.length>0&&(0,S.jsx)(`Line`,{points:C,stroke:h,strokeWidth:m,lineCap:`round`,lineJoin:`round`,opacity:g,tension:.5,listening:!1})]}):null});function ZK(e,t,n=`scale`){let r=t.width/t.height,i,a;r>=e.width/e.height?(i=e.width,a=e.width/r):(i=e.height*r,a=e.height);let o=0,s=0;return n===`left-top`?(o=0,s=0):n===`left-middle`?(o=0,s=(e.height-a)/2):n===`left-bottom`?(o=0,s=e.height-a):n===`center-top`?(o=(e.width-i)/2,s=0):n===`center-middle`?(o=(e.width-i)/2,s=(e.height-a)/2):n===`center-bottom`?(o=(e.width-i)/2,s=e.height-a):n===`right-top`?(o=e.width-i,s=0):n===`right-middle`?(o=e.width-i,s=(e.height-a)/2):n===`right-bottom`?(o=e.width-i,s=e.height-a):n===`scale`?(o=0,s=0,i=e.width,a=e.height):console.error(Error(`Unknown clip position property - `+n)),{cropX:o,cropY:s,cropWidth:i,cropHeight:a}}var QK=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n},$K=e=>Vf.batchedUpdates(e,null);ca(e=>{Vf.isAlreadyRendering()?queueMicrotask(()=>$K(e)):$K(e)});var eq=W.DD._drag;window.removeEventListener(`mousemove`,eq),W.DD._drag=function(e){or(()=>{eq.call(this,e)})},window.addEventListener(`mousemove`,W.DD._drag);var tq={enabledAnchors:[`top-left`,`top-center`,`top-right`,`middle-left`,`bottom-left`,`bottom-right`,`bottom-center`,`middle-right`],rotateEnabled:!0,rotationSnaps:[0,45,90,135,180,225,270,315],ignoreStroke:!0,flipEnabled:!1,keepRatio:!0},nq={text:{enabledAnchors:[`top-left`,`top-right`,`middle-left`,`bottom-left`,`bottom-right`,`middle-right`]},svg:{enabledAnchors:[`top-left`,`top-right`,`bottom-left`,`bottom-right`]},gif:{enabledAnchors:[`top-left`,`top-right`,`bottom-left`,`bottom-right`]},line:{enabledAnchors:[],borderEnabled:!1,rotateEnabled:!1},image:{enabledAnchors:[`top-left`,`top-right`,`bottom-left`,`bottom-right`]},many:{enabledAnchors:[`top-left`,`top-right`,`bottom-left`,`bottom-right`]},group:{enabledAnchors:[`top-left`,`top-right`,`bottom-left`,`bottom-right`]},table:{keepRatio:!1,enabledAnchors:[`top-left`,`top-center`,`top-right`,`middle-left`,`middle-right`,`bottom-left`,`bottom-center`,`bottom-right`]}},rq=e=>(0,S.jsx)(Nf,Object.assign({},e,{preventDefault:!1})),iq=e=>{var{url:t}=e,n=QK(e,[`url`]);let[r,i]=(0,Uf.default)(t,`anonymous`),a=r?ZK(r,{width:n.width,height:n.height},`center-middle`):{};return OC(i,t,`page background`),(0,S.jsx)(Ff,Object.assign({image:r},n,a))},aq=e=>{let t=Cx({a:{width:e.width,height:e.height},width:e.width,height:e.height},e.fill);return(0,S.jsx)(Nf,Object.assign({},e,t))},oq=e=>{let{background:t,scale:n,borderColor:r,transparencyBackgroundColor:i}=e,a=QK(e,[`background`,`scale`,`borderColor`,`transparencyBackgroundColor`]),o=b.useMemo(()=>!!W.Util.colorToRGBA(t)||sy(t),[t]),s=b.useMemo(()=>{if(sy(t))return!0;let e=W.Util.colorToRGBA(t);return!e||e.a<1},[t]),c=b.useMemo(()=>{if(!s||i)return null;let e=document.createElement(`canvas`);e.width=60,e.height=60;let t=e.getContext(`2d`);return t&&(t.fillStyle=`black`,t.fillRect(30,0,30,30),t.fillRect(0,30,30,30)),e},[s,i]);return(0,S.jsxs)(b.Fragment,{children:[s&&(0,S.jsx)(`Rect`,i?Object.assign({fill:i},a,{hideInExport:!0}):Object.assign({fillPatternImage:c},a,{opacity:.1,hideInExport:!0})),o?(0,S.jsx)(aq,Object.assign({fill:t},a)):(0,S.jsx)(iq,Object.assign({url:t},a))]})},sq=wa(({selection:e})=>{let{selectionRectStyle:t}=up();return e.visible?(0,S.jsx)(Nf,{name:`selection`,x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),width:Math.abs(e.x1-e.x2),height:Math.abs(e.y1-e.y2),fill:t.fill,stroke:t.stroke,strokeWidth:t.strokeWidth}):null});function cq(e){let t=180*e/Math.PI;return t%=360,t>180?t-=360:t<-180&&(t+=360),Math.round(t)}var lq=wa(({x:e,y:t,width:n,height:r,rotation:i,anchor:a,store:o})=>{let{transformLabelStyle:s}=up();if(e===void 0||t===void 0||n===void 0||r===void 0||i===void 0||a===void 0)return null;let c=Yy({x:e,y:t,width:n,height:r,rotation:W.Util.radToDeg(i)}),l=(r/2+70)*Math.cos(i-Math.PI/2),u=(r/2+70)*Math.sin(i-Math.PI/2),d=ty({unit:o.unit,dpi:o.dpi,px:n/o.scale,precious:o.unit===`px`?0:1})+` x `+ty({unit:o.unit,dpi:o.dpi,px:r/o.scale,precious:o.unit===`px`?0:1})+(o.unit===`px`?``:` `+o.unit);return(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(Mf,{x:(c.minX+c.maxX)/2+l,y:(c.minY+c.maxY)/2+u,offsetX:14,offsetY:14,visible:a===`rotater`,children:[(0,S.jsx)(`Tag`,{cornerRadius:5,fill:s.fill}),(0,S.jsx)(If,{align:`center`,verticalAlign:`middle`,fill:s.textFill,padding:8,text:cq(i).toString()+`°`})]}),(0,S.jsxs)(Mf,{x:(c.minX+c.maxX)/2,y:c.maxY+20,visible:a!==`rotater`,children:[(0,S.jsx)(`Tag`,{cornerRadius:5,fill:s.fill,pointerDirection:`up`,pointerHeight:0,pointerWidth:0}),(0,S.jsx)(If,{align:`center`,verticalAlign:`middle`,fill:s.textFill,padding:8,text:d})]})]})}),uq=wa(({elements:e,store:t})=>{let n=e.filter(e=>e.alwaysOnTop),r=e.filter(e=>!e.alwaysOnTop).concat(n);return(0,S.jsx)(b.Fragment,{children:r.map(e=>(0,S.jsx)(GK,{store:t,element:e,onClick:()=>{console.warn(`Polotno warning: onClick callback is deprecated. Just stop using it. Polotno will do selection automatically.`)}},e.id))})}),dq=({store:e})=>{let[t,n]=b.useState(!1),[r,i]=b.useState({x:0,y:0});return{open:b.useCallback(e=>{n(!0),i(e)},[]),close:b.useCallback(()=>{n(!1)},[]),props:{isOpen:t,offset:r,setIsOpen:n}}},fq=null,pq=atob(`UG9sb3RubyBmcmVlIGxpY2Vuc2UgbGltaXRhdGlvbiBleGNlZWRlZCAtIFBsZWFzZSB1cGdyYWRlIHlvdXIgYWNjb3VudC4=`),mq=atob(`I2MwMzkyYg==`),hq=atob(`djAuOS4y`),gq=e=>(0,S.jsx)(S.Fragment,{children:(0,S.jsxs)(Mf,{fill:mq,height:200,children:[(0,S.jsx)(`Tag`,{fill:mq}),(0,S.jsx)(If,Object.assign({},e,{fill:`white`,text:pq,height:void 0,padding:10,fontSize:20}))]})}),_q=atob(`RlJFRSAgVFJJQUwgIExJQ0VOU0U=`),vq=(atob(`UG93ZXJlZCBieSBQb2xvdG5v`),atob(`TElDRU5TRSAgS0VZICBJUyAgTUlTU0lORw==`)),yq=atob(`UGxlYXNlIGFjdGl2YXRlIHlvdXIgbGljZW5zZS4KTGljZW5zZSByZWxhdGVkIHF1ZXN0aW9uczoKcG9sb3Ruby5jb20vY29udGFjdA==`),bq=e=>{let t=A_()===1,n=t?vq:_q,r=t?230:195;return(0,S.jsxs)(jf,Object.assign({},e,{listening:!1,children:[(0,S.jsx)(Nf,{fill:mq,width:r,height:24,cornerRadius:2}),(0,S.jsx)(If,{text:n,fill:`white`,fontSize:13,fontFamily:`monospace`,width:r,align:`center`,y:5,listening:!1}),t&&(0,S.jsx)(`Text`,{text:yq,fill:`rgba(0,0,0,0.6)`,fontSize:14,y:30,listening:!1})]}))},xq=wa(({store:e,page:t,width:n,height:r,pageControlsEnabled:i,components:a,altCloneEnabled:o,groupSelectionMode:s=`drill`,viewportSize:c,layout:l=`vertical`,tooltipSafeArea:u,transformerSafeArea:d})=>{let f=up(),p=f.transformerStyle,m=tq,h=e.bleedVisible?t.bleed:0,g=t.computedWidth+2*h,_=t.computedHeight+2*h,v=(n-g*e.scale)/2,y=(r-_*e.scale)/2,x=b.useRef(null),C=b.useRef(null),w=b.useRef(null),T=i==null||i,E=b.useRef(!1),[D,O]=b.useState(null),[k,ee]=b.useState({}),[A,j]=b.useState(0),te=dq({store:e}),M=e.selectedElements.find(e=>e._cropModeEnabled),ne=e.selectedElements.find(e=>e.curveEnabled),N=e.selectedShapes.filter(e=>!e.resizable).length>0,P=e.selectedShapes.filter(e=>!e.draggable).length>0,re=e.selectedElements.filter(e=>!e.visible).length>0,ie=()=>{var t;let n=x.current;if(!n)return[];let r=n.getStage(),i=e.selectedShapes.map(e=>e._cropModeEnabled?null:r.findOne(`#`+e.id)).filter(e=>!!e),a=e.selectedElements.length===1,o=a&&e.selectedElements[0]?.type||`many`,s=nq[o],c=Object.assign(Object.assign({},m),s||{});return s&&(o!==`svg`&&o!==`image`&&o!==`gif`||e.selectedElements[0].keepRatio||(c.enabledAnchors=m.enabledAnchors),o===`text`&&h_.textVerticalResizeEnabled&&(c.enabledAnchors=nq.text.enabledAnchors?.concat([`bottom-center`,`top-center`])),o===`text`&&a&&e.selectedElements[0].curveEnabled&&(c.enabledAnchors=nq.many.enabledAnchors)),n.setAttrs(Object.assign(Object.assign({},c),p)),N&&n.enabledAnchors([]),P&&n.rotateEnabled(!1),n.nodes(i),(t=n.getLayer())==null||t.batchDraw(),i};b.useLayoutEffect(()=>{let e=ie();e.find(e=>e?.isDragging())&&(e.forEach(e=>{e.isDragging()||e==null||e.startDrag()}),yL())},[e.selectedShapes,M,N,re,P,ne,p]);let ae=()=>{let e=x.current;if(!e)return;if(!e.isTransforming()){ee({});return}if(!e.nodes().length||!e.isTransforming())return;let t=e.__getNodeRect(),n=e?.getActiveAnchor(),r=e.getStage();ee({anchor:n,x:t.x-(r?.x()??0),y:t.y-(r?.y()??0),rotation:t.rotation,width:t.width,height:t.height})},F=b.useCallback(()=>{if(x.current?.isTransforming())return;let e=x.current;if(!e||!e.nodes().length){j(0);return}let t=e.getClientRect();e.getStage()&&j(function(e,t,n,r=0){let i=e.x+e.width/2,a=e.y+e.height/2,o=e.width/2,s=e.height/2,c=r*Math.PI/180,l=e=>{let t=e*Math.PI/180,r=(e%360+360)%360,l;l=r===0||r===180?s:o;let u=Math.sin(t)*(l+n),d=-Math.cos(t)*(l+n),f=u*Math.cos(c)-d*Math.sin(c),p=u*Math.sin(c)+d*Math.cos(c);return{x:i+f,y:a+p}},u=e=>e.x>=t.left&&e.x<=t.right&&e.y>=t.top&&e.y<=t.bottom;if(u(l(0)))return 0;for(let e of[180,270,90])if(u(l(e)))return e;return 0}(t,{top:d?.top||0,bottom:r-(d?.bottom||0),left:d?.left||0,right:n-(d?.right||0)},p.rotateAnchorOffset,e.rotation()))},[d,n,r]);b.useEffect(()=>{var e;(e=x.current)==null||e.update(),ae(),F()},[e.scale,F]),b.useEffect(()=>{F()},[e.selectedShapes,F]);let oe=Oa(()=>({visible:!1,x1:0,y1:0,x2:0,y2:0})),se=b.useRef(!1),ce=ir(t=>{if(e.role===dC.VIEWER)return;se.current=!1;let n=t.target.findAncestor(`.elements-container`),r=t.target.findAncestor(`Transformer`),i=t.target.findAncestor(`.page-abs-container`);if(n||r||i)return;let a=t.target.getStage()?.getPointerPosition();a&&(a.x-=t.target.getStage()?.x()??0,a.y-=t.target.getStage()?.y()??0,oe.visible=!0,oe.x1=a.x,oe.y1=a.y,oe.x2=a.x,oe.y2=a.y,(t.target.getStage()?.getPointersPositions().length??0)>=2&&(oe.visible=!1))});(({stageRef:e,containerRef:t,viewportSize:n})=>{b.useEffect(()=>{let n=t.current?.closest(`.polotno-workspace-inner`);function r(){if(!e.current)return;let r=t.current?.getBoundingClientRect(),i=n?.getBoundingClientRect();if(!r||!i)return;let a=Math.max(0,i.left-r.left-100),o=Math.max(0,i.top-r.top-100);e.current.position({x:-a,y:-o}),e.current.container().style.transform=`translate(${a}px, ${o}px)`}return r(),n?.addEventListener(`scroll`,r),()=>{n?.removeEventListener(`scroll`,r)}},[n.width,n.height])})({stageRef:C,containerRef:w,viewportSize:c}),b.useEffect(()=>{let t=ir(e=>{var t;if(!oe.visible)return;(t=C.current)==null||t.setPointersPositions(e);let n=C.current?.getPointerPosition();n?(n.x-=C.current?.x()??0,n.y-=C.current?.y()??0):n={x:oe.x2,y:oe.y2},oe.x2=n.x,oe.y2=n.y}),n=ir(()=>{if(!oe.visible||!C.current)return;let t=C.current.findOne(`.selection`),n=t?t.getClientRect({skipStroke:!0}):{width:0,height:0,x:0,y:0};if(n.width&&n.height){let t=[];C.current.find(`.element`).forEach(r=>{let i=r.getClientRect(),a=e.getElementById(r.id()),o=a?.draggable,s=a?.selectable;W.Util.haveIntersection(n,i)&&o&&s&&t.push(a.top.id)});let r=[...new Set(t)];se.current=!0,e.selectElements(r)}oe.visible=!1});return window.addEventListener(`mousemove`,t),window.addEventListener(`touchmove`,t),window.addEventListener(`mouseup`,n,{capture:!0}),window.addEventListener(`touchend`,n,{capture:!0}),()=>{window.removeEventListener(`mousemove`,t),window.removeEventListener(`touchmove`,t),window.removeEventListener(`mouseup`,n),window.removeEventListener(`touchend`,n)}},[]);let le=b.useCallback(n=>{if(!e.selectedElements[0]||n&&e.selectedElementsIds.includes(n))return;let r=Xy(e.selectedShapes),i=Yy(n?e.getElementById(n):{x:0,y:0,width:t.computedWidth,height:t.computedHeight,rotation:0}),a=[];r.minX>i.maxX&&a.push({distance:r.minX-i.maxX,box1:r,box2:i,points:[{x:r.minX,y:r.minY+r.height/2},{x:i.maxX,y:r.minY+r.height/2},{x:i.maxX,y:i.minY+i.height/2}]}),r.maxX<i.minX&&a.push({distance:i.minX-r.maxX,box1:r,box2:i,points:[{x:r.maxX,y:r.minY+r.height/2},{x:i.minX,y:r.minY+r.height/2},{x:i.minX,y:i.minY+i.height/2}]}),r.minY>i.maxY&&a.push({box1:r,box2:i,distance:r.minY-i.maxY,points:[{x:r.minX+r.width/2,y:r.minY},{x:r.minX+r.width/2,y:i.maxY},{x:i.minX+i.width/2,y:i.maxY}]}),r.maxY<i.minY&&a.push({box1:r,box2:i,distance:i.minY-r.maxY,points:[{x:r.minX+r.width/2,y:r.maxY},{x:r.minX+r.width/2,y:i.minY},{x:i.minX+i.width/2,y:i.minY}]});let o=r.minX>=i.minX&&r.maxX<=i.maxX&&r.minY>=i.minY&&r.maxY<=i.maxY;if(o&&(a.push({distance:r.minX-i.minX,box1:r,box2:i,points:[{x:r.minX,y:r.minY+r.height/2},{x:i.minX,y:r.minY+r.height/2},{x:i.minX,y:i.minY+i.height/2}]}),a.push({distance:i.maxX-r.maxX,box1:r,box2:i,points:[{x:r.maxX,y:r.minY+r.height/2},{x:i.maxX,y:r.minY+r.height/2},{x:i.maxX,y:i.minY+i.height/2}]}),a.push({box1:r,box2:i,distance:r.minY-i.minY,points:[{x:r.minX+r.width/2,y:r.minY},{x:r.minX+r.width/2,y:i.minY},{x:i.minX+i.width/2,y:i.minY}]}),a.push({box1:r,box2:i,distance:i.maxY-r.maxY,points:[{x:r.minX+r.width/2,y:r.maxY},{x:r.minX+r.width/2,y:i.maxY},{x:i.minX+i.width/2,y:i.maxY}]})),a.length===0&&!o){let e=r.minX<i.maxX&&r.maxX>i.minX,t=r.minY<i.maxY&&r.maxY>i.minY;if(e&&t){let e=(Math.max(r.minY,i.minY)+Math.min(r.maxY,i.maxY))/2,t=(Math.max(r.minX,i.minX)+Math.min(r.maxX,i.maxX))/2;r.minX<i.minX?a.push({distance:i.minX-r.minX,box1:r,box2:i,points:[{x:r.minX,y:e},{x:i.minX,y:e},{x:i.minX,y:e}]}):a.push({distance:r.minX-i.minX,box1:r,box2:i,points:[{x:r.minX,y:e},{x:i.minX,y:e},{x:i.minX,y:e}]}),r.maxX>i.maxX?a.push({distance:r.maxX-i.maxX,box1:r,box2:i,points:[{x:i.maxX,y:e},{x:r.maxX,y:e},{x:i.maxX,y:e}]}):a.push({distance:i.maxX-r.maxX,box1:r,box2:i,points:[{x:r.maxX,y:e},{x:i.maxX,y:e},{x:i.maxX,y:e}]}),r.minY<i.minY?a.push({box1:r,box2:i,distance:i.minY-r.minY,points:[{x:t,y:r.minY},{x:t,y:i.minY},{x:t,y:i.minY}]}):a.push({box1:r,box2:i,distance:r.minY-i.minY,points:[{x:t,y:r.minY},{x:t,y:i.minY},{x:t,y:i.minY}]}),r.maxY>i.maxY?a.push({box1:r,box2:i,distance:r.maxY-i.maxY,points:[{x:t,y:i.maxY},{x:t,y:r.maxY},{x:t,y:i.maxY}]}):a.push({box1:r,box2:i,distance:i.maxY-r.maxY,points:[{x:t,y:r.maxY},{x:t,y:i.maxY},{x:t,y:i.maxY}]})}}JSON.stringify(D)!==JSON.stringify(a)&&O(a)},[e,t]);b.useEffect(()=>{e.selectedElements[0]&&e.distanceGuidesVisible?le():D&&O(null)},[e.distanceGuidesVisible,le,e.selectedShapes.map(e=>`${e.x},${e.y},${e.width},${e.height},${e.rotation}`).join(`|`)]);let ue=b.useRef(!1);b.useEffect(()=>{let e,t=w.current?.closest(`.polotno-workspace-inner`),n=()=>{ue.current=!0,clearTimeout(e),e=setTimeout(()=>{ue.current=!1},300)};return t?.addEventListener(`scroll`,n),()=>{clearTimeout(e),t?.removeEventListener(`scroll`,n)}},[]),b.useEffect(()=>{let e=C.current;if(!e)return;let t=e.container(),n=e=>{var t,n;e.touches.length>=2&&((t=x.current)!=null&&t.isDragging()&&x.current.stopDrag(),(n=x.current)==null||n.nodes().forEach(e=>{e.isDragging()&&e.stopDrag()}))};return t.addEventListener(`touchstart`,n,{passive:!0}),t.addEventListener(`touchmove`,n,{passive:!0}),()=>{t.removeEventListener(`touchstart`,n),t.removeEventListener(`touchmove`,n)}},[]);let de=n=>{if(e.role===dC.VIEWER||(e.activePage!==t&&t.select(),ue.current)||se.current)return;let r=n.evt.shiftKey,i=n.evt.ctrlKey||n.evt.metaKey,a=r||i,o=n.target.findAncestor(`.elements-container`),c=n.target.findAncestor(`.page-abs-container`),l=n.target.findAncestor(`Transformer`),u=n.target.findAncestor(`.page-container`,!0);if(!(a||o||l||c||u||oe.visible)){e.selectElements([]),e.selectPages([]);return}if(i&&!r){let t=C.current,n=t?.getPointerPosition();if(!t||!n)return;let r=t.getAllIntersections(n),i=new Set,a=[];for(let t of[...r].reverse()){let n=t.findAncestor(`.element`,!0);if(!n)continue;let r=e.getElementById(n.id())?.top;r&&(i.has(r.id)||(i.add(r.id),a.push(r.id)))}if(a.length===0)return;let o;if(e.selectedElementsIds.length===1){let t=e.selectedElementsIds[0],n=a.indexOf(t);o=n===-1?a[0]:a[(n+1)%a.length]}else o=a[0];e.selectElements([o]),e.selectPages([]);return}let d=n.target.findAncestor(`.element-container`,!0)?.findOne(`.element`)||n.target.findAncestor(`.element`,!0),f=e.getElementById(d?.id()),p=f?.top,m;m=s===`group`?p?.id:p?e.selectedElements.some(e=>e.top?.id===p.id)?f?.id:p?.id:void 0;let h=f?.id;if(h&&e.selectedElementsIds.indexOf(h)>=0&&!r)return;let g=!!m&&e.selectedElementsIds.indexOf(m)>=0,_=n.target.findAncestor(`.page-container`,!0);if(m&&r&&!g){let t=e.selectedElementsIds.concat([m]),n=new Set(t),r=t.filter(t=>{let r=e.getElementById(t);if(!r)return!1;for(let e=r.parent;e;e=e?.parent)if(n.has(e.id))return!1;return!0});e.selectElements(r),e.selectPages([])}else m&&r&&g?e.selectElements(e.selectedElementsIds.filter(e=>e!==m)):!m||r||g?m&&!r&&g||(_?(r||e.selectElements([]),e.selectPages([t.id])):e.selectPages([])):(e.selectElements([m]),e.selectPages([]))};bL(x,e);let fe=e.activePage===t,pe=e._selectedPagesIds.includes(t.id),me=a?.PageControls,he=a?.Tooltip,ge=a?.ContextMenu,_e=1/e.scale,ve=0/e.scale;return(0,S.jsxs)(`div`,{ref:w,onDragOver:e=>e.preventDefault(),onDrop:n=>{if(n.preventDefault(),e.role===dC.VIEWER||!C.current)return;C.current.setPointersPositions(n);let r=C.current.findOne(`.elements-container`)?.getRelativePointerPosition(),i=C.current.getPointerPosition(),a=C.current.getAllIntersections(i).map(e=>e.findAncestor(`.element`,!0)).filter(Boolean),o=[...new Set(a.reverse())].map(t=>e.getElementById(t.id())).filter(e=>!!e),s=o[0];fq&&r&&(fq(r,s,{elements:o,page:t}),fq=null)},style:{position:`relative`,width:n+`px`,height:r+`px`,overflow:`hidden`,flexShrink:0},className:`polotno-page-container`+(fe?` active-page`:``),children:[(0,S.jsx)(Hf,{ref:C,width:Math.min(n,c.width+200),height:Math.min(c.height+200,r),onClick:de,onTap:de,onContextMenu:t=>{if(t.evt.preventDefault(),e.role===dC.VIEWER)return;let n=t.target.findAncestor(`.element`,!0),r=e.getElementById(n?.id())?.top?.id;if(!r){e.selectElements([]),te.close();return}e.selectedElementsIds.indexOf(r)>=0||e.selectElements([r]);let i=(C.current?.findOne(`.page-abs-container`))?.getRelativePointerPosition();te.open({x:i?.x??0,y:i?.y??0})},onMouseDown:ce,onMouseMove:t=>{if(!e.distanceGuidesVisible&&!t.evt.altKey){D&&O(null);return}le(t.target.findAncestor(`.element`,!0)?.id())},onDragStart:t=>{var n;let r=t.target.getStage();if(r&&r.getPointersPositions().length>=2){t.target.stopDrag();return}let i=t.target.findAncestor(`.element`,!0);if(i){let r=e.getElementById(i?.id()),a=r?.top?.id;if(!(r&&e.selectedElementsIds.indexOf(r.id)>=0||a&&e.selectedElementsIds.indexOf(a)>=0)&&a){e.selectElements([a]);let r=ie();t.target.stopDrag(),r.forEach(e=>{e.isDragging()||e.startDrag(t)}),(n=x.current)==null||n.startDrag(t),yL()}}D&&O(null)},pageId:t.id,style:{position:`absolute`,overflow:`hidden`,top:0,left:0},children:(0,S.jsxs)(Af,{children:[(0,S.jsx)(rq,{width:n,height:r,fill:f.workspaceBackgroundColor}),(0,S.jsx)(jf,{x:v,y,scaleX:e.scale,scaleY:e.scale,name:`page-container`,children:(0,S.jsxs)(jf,{name:`page-container-2`,children:[(0,S.jsx)(jf,{name:`page-background-group`,x:h,y:h,children:(0,S.jsx)(oq,{x:-t.bleed,y:-t.bleed,width:t.computedWidth+2*t.bleed,height:t.computedHeight+2*t.bleed,background:t.background,transparencyBackgroundColor:f.transparencyBackgroundColor,name:`page-background`,preventDefault:!1,scale:e.scale})}),(0,S.jsxs)(jf,{x:h,y:h,name:`elements-container`,listening:!e.isPlaying&&e.role!==dC.VIEWER,children:[(0,S.jsx)(Nf,{name:`elements-area`,width:t.computedWidth,height:t.computedHeight,listening:!1}),(0,S.jsx)(uq,{elements:t.children,store:e})]}),(0,S.jsx)(Nf,{stroke:f.bleedColor,name:`bleed`,strokeWidth:t.bleed,x:t.bleed/2,y:t.bleed/2,width:t.computedWidth+t.bleed,height:t.computedHeight+t.bleed,listening:!1,visible:t.bleed>0&&e.bleedVisible,hideInExport:!0}),O_()===hq&&(0,S.jsx)(gq,{name:`hit-detection`,x:-_e/2-ve,y:-_e/2-ve,width:g+_e+2*ve,height:_+_e+2*ve})]})}),(0,S.jsx)(Pf,{name:`workspace-background`,points:[0,0,n,0,n,r,0,r,0,0,v,y,v,r-y,n-v,r-y,n-v,y,v,y],listening:!1,closed:!0,fill:f.workspaceBackgroundColor}),(0,S.jsx)(jf,{x:v,y,scaleX:e.scale,scaleY:e.scale,children:(0,S.jsx)(Nf,{name:`page-highlight`,hideInExport:!0,x:-_e/2-ve,y:-_e/2-ve,width:g+_e+2*ve,height:_+_e+2*ve,stroke:pe?f.activePageBorderColor:f.pageBorderColor,strokeWidth:2,listening:!1,strokeScaleEnabled:!1})}),(0,S.jsxs)(jf,{x:v+h*e.scale,y:y+h*e.scale,scaleX:e.scale,scaleY:e.scale,name:`page-abs-container`,children:[(0,S.jsx)(Bf,{ref:x,rotateAnchorAngle:A,onDragStart:n=>{var r;let i=n.target.getStage();i&&i.getPointersPositions().length>=2?n.target.stopDrag():((r=n.evt)!=null&&r.altKey&&o&&e.selectedElements.forEach(e=>{let n=e.clone({},{skipSelect:!0}),r=t.children.indexOf(e);t.setElementZIndex(n.id,r)}),E.current=!0,e.history.startTransaction())},onDragEnd:()=>{E.current&&=(e.history.endTransaction(),!1),F()},onTransformStart:()=>{e.history.startTransaction(),O(null)},boundBoxFunc:(t,n)=>{let r=Math.abs(n.width)<1||Math.abs(n.height)<1,i=Math.abs(t.width)<1||Math.abs(t.height)<1;if(r&&!i)return t;let a=e.selectedElements;if(a.length===1&&a[0]?.type===`table`){let e=a[0],r=Math.abs(t.width),i=Math.abs(t.height);if(r>0&&i>0){let a=Math.abs(n.width)/r,o=Math.abs(n.height)/i,s=e.width*a,c=e.height*o,l=Object.assign({},n);return s<e.minWidth&&(l.width=t.width,l.x=t.x),c<e.minHeight&&(l.height=t.height,l.y=t.y),l}}return n},onTransform:e=>{let t=x.current.nodes(),n=t[t.length-1];e.target===n&&setTimeout(()=>{ae()},0)},onTransformEnd:t=>{ee({}),e.history.endTransaction(),F()},visible:!e.isPlaying}),D&&D.map(({points:t,distance:n,box1:r,box2:i},a)=>(0,S.jsxs)(`Group`,{name:`distances-container`,hideInExport:!0,listening:!1,children:[(0,S.jsx)(`Rect`,Object.assign({},r,{stroke:f.distanceGuideStyle.stroke,strokeWidth:1,strokeScaleEnabled:!1})),(0,S.jsx)(`Rect`,Object.assign({},i,{stroke:f.distanceGuideStyle.stroke,strokeWidth:1,strokeScaleEnabled:!1})),(0,S.jsx)(`Line`,{points:[t[0].x,t[0].y,t[1].x,t[1].y],stroke:f.distanceGuideStyle.stroke,strokeWidth:1,strokeScaleEnabled:!1}),(0,S.jsx)(`Line`,{points:[t[1].x,t[1].y,t[2].x,t[2].y],stroke:f.distanceGuideStyle.stroke,strokeWidth:1,strokeScaleEnabled:!1}),(0,S.jsxs)(`Label`,{x:(t[0].x+t[1].x)/2,y:(t[0].y+t[1].y)/2,offsetY:-10,scaleX:1/e.scale,scaleY:1/e.scale,children:[(0,S.jsx)(`Tag`,{cornerRadius:5,fill:f.distanceGuideStyle.labelFill,pointerDirection:`down`}),(0,S.jsx)(`Text`,{align:`center`,verticalAlign:`middle`,fill:f.distanceGuideStyle.labelTextFill,padding:5,text:ry({unit:e.unit,dpi:e.dpi,px:n})})]})]},a)),t._rendering&&(0,S.jsxs)(`Group`,{children:[(0,S.jsx)(`Rect`,{width:g,height:_,fill:`rgba(255,255,255,0.9)`}),(0,S.jsx)(`Text`,{text:`Rendering...`,fontSize:60,width:g,height:_,align:`center`,verticalAlign:`middle`})]}),he&&(0,S.jsx)(he,{components:a,store:e,page:t,stageRef:C,tooltipSafeArea:u}),ge&&(0,S.jsx)(ex,{children:(0,S.jsx)(ge,Object.assign({components:a,store:e},te.props))})]}),(0,S.jsx)(XK,{store:e,page:t,width:n,height:r,scale:e.scale,xPadding:v,yPadding:y,bleed:h}),(0,S.jsx)(lq,Object.assign({},k,{store:e})),(0,S.jsx)(sq,{selection:oe}),A_()>0&&(0,S.jsxs)(`Group`,{hideInExport:!0,children:[(0,S.jsx)(bq,{name:`cache-bounds`,x:n-(A_()===1?250:210),y:r-(A_()===1?95:45)}),(0,S.jsx)(bq,{name:`cache-bounds-t`,x:10,y:10})]}),j_()&&(0,S.jsx)(`Text`,{text:`Powered by polotno.com`,fontSize:14,fill:`rgba(0,0,0,0.6)`,x:n-170,y:r-18,onMouseEnter:e=>{e.target.getStage().container().style.cursor=`pointer`},onMouseLeave:e=>{e.target.getStage().container().style.cursor=``},onTouchStart:e=>{e.cancelBubble=!0},onMouseDown:e=>{e.cancelBubble=!0},onClick:()=>{window.open(`https://polotno.com`,`_blank`,`noopener`)},onTap:()=>{window.open(`https://polotno.com`,`_blank`,`noopener`)}}),(0,S.jsx)(jf,{name:`line-guides`})]})}),T&&me&&(0,S.jsx)(me,{store:e,page:t,xPadding:v,yPadding:y,layout:l})]})}),Sq=PP(`div`,b.forwardRef)`
|
|
421
|
+
position: absolute;
|
|
422
|
+
top: 0;
|
|
423
|
+
left: 0;
|
|
424
|
+
pointer-events: none;
|
|
425
|
+
`,Cq=PP(`div`,b.forwardRef)`
|
|
426
|
+
height: 14px;
|
|
427
|
+
position: sticky;
|
|
428
|
+
font-size: 8px;
|
|
429
|
+
line-height: 14px;
|
|
430
|
+
top: 0;
|
|
431
|
+
left: 0;
|
|
432
|
+
color: grey;
|
|
433
|
+
border-bottom: 1px solid grey;
|
|
434
|
+
background-color: #e8e8e8;
|
|
435
|
+
overflow: hidden;
|
|
436
|
+
box-sizing: border-box;
|
|
437
|
+
`,wq=PP(`div`,b.forwardRef)`
|
|
438
|
+
left: 0;
|
|
439
|
+
width: 14px;
|
|
440
|
+
position: sticky;
|
|
441
|
+
font-size: 8px;
|
|
442
|
+
line-height: 14px;
|
|
443
|
+
color: grey;
|
|
444
|
+
border-right: 1px solid grey;
|
|
445
|
+
background-color: #e8e8e8;
|
|
446
|
+
overflow: hidden;
|
|
447
|
+
box-sizing: border-box;
|
|
448
|
+
`,Tq=PP(`div`,b.forwardRef)`
|
|
449
|
+
position: absolute;
|
|
450
|
+
border-left: 1px solid grey;
|
|
451
|
+
padding-left: 2px;
|
|
452
|
+
`,Eq=PP(`div`,b.forwardRef)`
|
|
453
|
+
position: absolute;
|
|
454
|
+
left: 14px;
|
|
455
|
+
border-left: 1px solid grey;
|
|
456
|
+
padding-left: 2px;
|
|
457
|
+
transform: rotate(90deg);
|
|
458
|
+
transform-origin: left top;
|
|
459
|
+
overflow: hidden;
|
|
460
|
+
`,Dq=[.1,.2,.5,1,2,5,10,20,25,50,100,200,500,1e3,2e3,5e3,1e4],Oq=wa(({store:e,width:t,height:n,pageSizes:r,layout:i=`vertical`,renderOnlyActivePage:a})=>{let{rulerStyle:o}=up(),s=b.useRef(null);if(!e.activePage)return null;let c=i===`horizontal`,l=e.activePage,u=(e.bleedVisible&&l.bleed,l.computedWidth*e.scale),d=l.computedHeight*e.scale,f=(t-u)/2,p=(n-d)/2,m=(h=t=>ny({unitVal:t,dpi:e.dpi,unit:e.unit})*e.scale,Dq.find(e=>h(e)>30)||1e4);var h;let g=ny({unitVal:m,dpi:e.dpi,unit:e.unit})*e.scale,_=Math.round(u/g)+1,v=Math.round(d/g)+1,y=Xy(e.selectedShapes),{backgroundColor:x,textColor:C,borderColor:w,borderSize:T,tickColor:E,tickSize:D}=o;return(0,S.jsx)(Sq,{ref:s,className:`polotno-rulers`,style:{display:`flex`,flexDirection:`column`},children:(0,S.jsxs)(S.Fragment,c?{children:[(0,S.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,position:`sticky`,top:0,zIndex:1},children:[(0,S.jsx)(`div`,{className:`polotno-ruler-corner`,style:{width:`14px`,height:`14px`,flexShrink:0,marginRight:`-14px`,boxSizing:`border-box`,backgroundColor:x,borderRight:`${T}px solid ${w}`,borderBottom:`${T}px solid ${w}`,position:`sticky`,left:0,zIndex:2}}),(a?[e.activePage]:e.pages).map((n,i)=>{if(!n)return null;let a=r?r[i]:t,o=(a-n.computedWidth*e.scale)/2;return(0,S.jsxs)(Cq,{style:{width:a+`px`,flexShrink:0,position:`relative`,backgroundColor:x,color:C,borderBottom:`${T}px solid ${w}`},className:`polotno-x-ruler`,children:[[...Array(_)].map((t,n)=>(0,S.jsx)(Tq,{className:`polotno-ruler-tick`,style:{left:o+n*g+`px`,width:g+`px`,borderLeft:`${D}px solid ${E}`},children:e.unit===`px`||m>=1?Math.round(m*n):(m*n).toFixed(1)},n)),e.selectedShapes[0]?.page===n&&(0,S.jsx)(`div`,{className:`polotno-ruler-selection`,style:{position:`absolute`,left:o+y.x*e.scale+`px`,height:`14px`,width:y.width*e.scale,backgroundColor:`rgba(0,0,0,0.15)`}})]},n.id)})]}),(0,S.jsxs)(wq,{style:{height:n+`px`,position:`sticky`,left:0,marginTop:`-14px`,backgroundColor:x,color:C,borderRight:`${T}px solid ${w}`},className:`polotno-y-ruler`,children:[[...Array(v)].map((t,n)=>(0,S.jsx)(Eq,{className:`polotno-ruler-tick`,style:{top:p+n*g+`px`,width:g+`px`,borderLeft:`${D}px solid ${E}`},children:e.unit===`px`||m>=1?Math.round(m*n):(m*n).toFixed(1)},n)),!!e.selectedShapes.length&&(0,S.jsx)(`div`,{className:`polotno-ruler-selection`,style:{position:`absolute`,top:p+y.y*e.scale+`px`,width:`14px`,height:y.height*e.scale,backgroundColor:`rgba(0,0,0,0.15)`}})]})]}:{children:[(0,S.jsxs)(Cq,{style:{width:t+`px`,backgroundColor:x,color:C,borderBottom:`${T}px solid ${w}`},className:`polotno-x-ruler`,children:[[...Array(_)].map((t,n)=>(0,S.jsx)(Tq,{className:`polotno-ruler-tick`,style:{left:f+n*g+`px`,width:g+`px`,borderLeft:`${D}px solid ${E}`},children:e.unit===`px`||m>=1?Math.round(m*n):(m*n).toFixed(1)},n)),!!e.selectedShapes.length&&(0,S.jsx)(`div`,{className:`polotno-ruler-selection`,style:{position:`absolute`,left:f+y.x*e.scale+`px`,height:`14px`,width:y.width*e.scale,backgroundColor:`rgba(0,0,0,0.15)`}})]}),(a?[e.activePage]:e.pages).map((t,i)=>{if(!t)return null;let a=r?r[i]:n,o=(a-t.computedHeight*e.scale)/2,s=i===0?14:0;return(0,S.jsxs)(wq,{style:{height:a-s+`px`,backgroundColor:x,color:C,borderRight:`${T}px solid ${w}`},className:`polotno-y-ruler`,children:[[...Array(v)].map((t,n)=>(0,S.jsx)(Eq,{className:`polotno-ruler-tick`,style:{top:o+n*g-s+`px`,width:g+`px`,borderLeft:`${D}px solid ${E}`},children:e.unit===`px`||m>=1?Math.round(m*n):(m*n).toFixed(1)},n)),e.selectedShapes[0]?.page===t&&(0,S.jsx)(`div`,{className:`polotno-ruler-selection`,style:{position:`absolute`,top:o+y.y*e.scale-s+`px`,width:`14px`,height:y.height*e.scale,backgroundColor:`rgba(0,0,0,0.15)`}})]},t.id)})]})})}),kq=wa(({audio:e,store:t})=>{let[n,r]=function(e){let[t,n]=b.useState(null),[r,i]=b.useState(`loading`);return b.useEffect(()=>{let t=new Audio(e),r=()=>{i(`loaded`),n(t)},a=()=>{i(`failed`),n(null)};return t.addEventListener(`canplay`,r),t.addEventListener(`error`,a),()=>{t.removeEventListener(`canplay`,r),t.removeEventListener(`error`,a)}},[e]),[t,r]}(e.src);return b.useEffect(()=>{n&&t.history.ignore(()=>{e.set({duration:1e3*n.duration})})},[n,e,t.history]),b.useEffect(()=>{if(!n)return;let r=()=>{n.currentTime=e.startTime*e.duration/1e3},i=()=>{let t=e.endTime*e.duration/1e3;n.currentTime>=t&&(n.pause(),n.currentTime=e.startTime*e.duration/1e3)};n.addEventListener(`ended`,r),n.addEventListener(`timeupdate`,i);let a=cr(()=>{let r=t.animatedElementsIds;if(r.length&&!r.includes(e.id))return;let i=t.currentTime-e.delay,a=e.duration*(e.endTime-e.startTime),o=i>=0&&i<a;if(!t.isPlaying||t.animatedElementsIds.length!==0||!o){n.pause();return}n.volume=e.volume,n.paused&&n.play();let s=i%a/1e3+e.startTime*e.duration/1e3,c=n.currentTime;Math.abs(c-s)>.5&&s!==c&&(n.currentTime=s)});return()=>{n.pause(),n.removeEventListener(`ended`,r),n.removeEventListener(`timeupdate`,i),a()}},[t.isPlaying,e.startTime,e.endTime,e.volume,n]),null}),Aq={data:[],pageId:``},jq=`polotno_clipboard`,Mq=(e,t)=>{Aq={data:JSON.parse(JSON.stringify(e)),pageId:t||``};try{localStorage.setItem(jq,JSON.stringify(e)),localStorage.setItem(`polotno_clipboard_page`,t||``)}catch{}},Nq=()=>{try{let e=localStorage.getItem(jq),t=localStorage.getItem(`polotno_clipboard_page`);if(e)return{data:JSON.parse(e),pageId:t}}catch{}return Aq},Pq=e=>{e.selectedElements.length!==0&&Mq(e.selectedElements.map(e=>e.toJSON()),e.activePage?.id)},Fq=e=>{Mq(e.selectedElements.map(e=>e.toJSON()),e.activePage?.id);let t=e.selectedElements.filter(e=>e.removable).map(e=>e.id);e.deleteElements(t)},Iq=e=>{e.history.transaction(()=>{let t=0,n=0,{data:r,pageId:i}=Nq();if(i===e.activePage?.id)t=e.width/20,n=e.height/20;else{let i=[];Rb({children:r},e=>{e.type!==`group`&&i.push(e)});let a=Xy(i);a.maxX>e.width&&(t=-a.minX),a.maxY>e.height&&(n=-a.minY)}let a=[];Rb({children:r},e=>{delete e.id,e.type!==`group`&&(e.x+=t,e.y+=n)}),r.forEach(t=>{let n=e.activePage?.addElement(t);n&&a.push(n.id)}),Mq(r,e.activePage?.id),e.selectElements(a)})};function Lq(e,t){let n=[];e.forEach(e=>{if(!1===e.removable)return;let t=e.clone();e.type===`group`?t.children.forEach(e=>{e.set({x:e.x+50,y:e.y+50})}):t.set({x:e.x+50,y:e.y+50}),n.push(t.id)}),t.selectElements(n)}var Rq=e=>{if(e.type!==`group`)return Yy(e);let t=1/0,n=1/0,r=-1/0,i=-1/0;return e.children.forEach(e=>{let a=Rq(e);t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x+a.width),i=Math.max(i,a.y+a.height)}),{x:t,y:n,width:r-t,height:i-n}},zq=(e,t,n)=>{if(e.type!==`group`){let r=Yy(e),i=t-r.x,a=n-r.y;e.set({x:e.x+i,y:e.y+a})}else{let r=t-Rq(e).x,i=n-Rq(e).y;e.children.forEach(e=>{let t=Rq(e);zq(e,t.x+r,t.y+i)})}};function Bq(e){let t=e.activePage?.computedWidth;e.selectedElements.forEach(e=>{t=Math.min(t,Rq(e).x)}),e.selectedElements.length===1&&(t=0),e.selectedElements.forEach(e=>{let n=Rq(e);zq(e,n.x-n.x+t,n.y)})}function Vq(e){let t=0;e.selectedElements.forEach(e=>{let n=Rq(e);t=Math.max(t,n.x+n.width)}),e.selectedElements.length===1&&(t=e.activePage?.computedWidth),e.selectedElements.forEach(e=>{let n=Rq(e);zq(e,t-n.width,n.y)})}function Hq(e){let t=e.activePage?.computedHeight;e.selectedElements.forEach(e=>{t=Math.min(t,Rq(e).y)}),e.selectedElements.length===1&&(t=0),e.selectedElements.forEach(e=>{let n=Rq(e);zq(e,n.x,n.y-n.y+t)})}function Uq(e){let t=e.activePage?.computedHeight,n=0;e.selectedElements.forEach(e=>{let r=Rq(e);t=Math.min(t,r.y),n=Math.max(n,r.y+r.height)});let r=(n+t)/2;e.selectedElements.length===1&&(r=e.activePage?.computedHeight/2),e.selectedElements.forEach(e=>{let t=Rq(e);zq(e,t.x,r-t.height/2)})}function Wq(e){let t=0;e.selectedElements.forEach(e=>{let n=Rq(e);t=Math.max(t,n.y+n.height)}),e.selectedElements.length===1&&(t=e.activePage?.computedHeight),e.selectedElements.forEach(e=>{let n=Rq(e);zq(e,n.x,t-n.height)})}function Gq(e){let t=e.activePage?.computedWidth,n=0;e.selectedElements.forEach(e=>{let r=Rq(e);t=Math.min(t,r.x),n=Math.max(n,r.x+r.width)});let r=(n+t)/2;e.selectedElements.length===1&&(r=e.activePage?.computedWidth/2),e.selectedElements.forEach(e=>{let t=Rq(e);zq(e,r-t.width/2,t.y)})}var Kq=`rgba(191, 191, 191, 100)`;function qq(e,t,n){let r=e.getCell(t,n);r&&e.focusCell(r.id)}function Jq(e,t,n){let r=e.getCell(t,n);r&&e.enterCellEdit(r.id)}function Yq(e,t){var n,r,i,a;if(t.role===dC.VIEWER)return;let o=document.activeElement,s=document.querySelector(`.polotno-workspace-container`),c=o?.tagName===`INPUT`||o?.tagName===`TEXTAREA`||!!o?.isContentEditable,l=!(!o||!s?.contains(o)),u=c&&!l,d=function(e){if(e.selectedElements.length!==1)return null;let t=e.selectedElements[0];return t.type===`table`?t:null}(t);if(!u&&d&&function(e,t,n){let r=t._focusedCellIds.length>0,i=!!t._editingCellId;if(!r&&!i)return!1;if(i){if(e.key===`Escape`)return e.preventDefault(),t.exitCellEdit(),!0;if(e.key===`Tab`){e.preventDefault();let n=t.editingCell;if(t.exitCellEdit(),n)if(e.shiftKey){let e=n.col-1,r=n.row;e<0&&(--r,e=t.cols-1),r<0&&(r=t.rows-1,e=t.cols-1),Jq(t,r,e)}else{let e=n.col+1,r=n.row;e>=t.cols&&(r+=1,e=0),r>=t.rows&&(r=0,e=0),Jq(t,r,e)}return!0}if(e.metaKey||e.ctrlKey){let n=t.editingCell;if(n){if(e.key===`b`)return e.preventDefault(),n.set({fontWeight:n.fontWeight===`bold`?`normal`:`bold`}),!0;if(e.key===`i`)return e.preventDefault(),n.set({fontStyle:n.fontStyle===`italic`?`normal`:`italic`}),!0;if(e.key===`u`){e.preventDefault();let t=n.textDecoration.split(` `).filter(Boolean),r=t.includes(`underline`);return n.set({textDecoration:r?t.filter(e=>e!==`underline`).join(` `):[...t,`underline`].join(` `)}),!0}}}return!0}if(e.key===`Escape`)return e.preventDefault(),t.clearCellFocus(),!0;let a=t.focusedCells[0];if(!a)return!1;let o=a.row,s=a.col;if(e.key===`Enter`)return e.preventDefault(),t.enterCellEdit(a.id),!0;if(e.key===`Tab`){if(e.preventDefault(),e.shiftKey){let e=s-1,n=o;e<0&&(--n,e=t.cols-1),n<0&&(n=t.rows-1,e=t.cols-1),qq(t,n,e)}else{let e=s+1,n=o;e>=t.cols&&(n+=1,e=0),n>=t.rows&&(n=0,e=0),qq(t,n,e)}return!0}if(e.key===`ArrowRight`||e.key===`ArrowLeft`||e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),e.shiftKey){let n=function(e){let t=e.cells.find(t=>t.id===e._anchorCellId);if(!t)return null;let n=e.focusedCells;if(n.length<=1)return{row:t.row,col:t.col};let r=1/0,i=-1,a=1/0,o=-1;for(let e of n)e.row<r&&(r=e.row),e.row>i&&(i=e.row),e.col<a&&(a=e.col),e.col>o&&(o=e.col);return{row:t.row===r?i:r,col:t.col===a?o:a}}(t)||{row:o,col:s},r=n.row,i=n.col;e.key===`ArrowRight`&&(i=Math.min(n.col+1,t.cols-1)),e.key===`ArrowLeft`&&(i=Math.max(n.col-1,0)),e.key===`ArrowDown`&&(r=Math.min(n.row+1,t.rows-1)),e.key===`ArrowUp`&&(r=Math.max(n.row-1,0)),t.focusCellRange(r,i)}else e.key===`ArrowRight`&&qq(t,o,Math.min(s+1,t.cols-1)),e.key===`ArrowLeft`&&qq(t,o,Math.max(s-1,0)),e.key===`ArrowDown`&&qq(t,Math.min(o+1,t.rows-1),s),e.key===`ArrowUp`&&qq(t,Math.max(o-1,0),s);return!0}let c=e.ctrlKey||e.metaKey;if(!(c||e.shiftKey||e.altKey||e.key!==`Delete`&&e.key!==`Backspace`))return e.preventDefault(),t.focusedCells.forEach(e=>{e.set({text:``})}),!0;if(c&&e.shiftKey&&!e.altKey&&e.code===`Equal`){e.preventDefault();let r=t.getFocusedCellRange(),i=r?r.maxRow+1:o+1;return n.history.transaction(()=>{t.addRow(i)}),!0}if(c&&e.shiftKey&&e.altKey&&e.code===`Equal`){e.preventDefault();let r=t.getFocusedCellRange(),i=r?r.maxCol+1:s+1;return n.history.transaction(()=>{t.addColumn(i)}),!0}if(c&&!e.shiftKey&&e.code===`Backspace`){let r=t.getFocusedCellRange();if(r&&r.minCol===0&&r.maxCol===t.cols-1&&t.rows>1)return e.preventDefault(),n.history.transaction(()=>{t.removeRowRange(r.minRow,r.maxRow)}),!0}if(c&&e.shiftKey&&e.code===`Backspace`){let r=t.getFocusedCellRange();if(r&&r.minRow===0&&r.maxRow===t.rows-1&&t.cols>1)return e.preventDefault(),n.history.transaction(()=>{t.removeColumnRange(r.minCol,r.maxCol)}),!0}if(c&&e.code===`KeyC`){e.preventDefault();let n=t.focusedCells.map(e=>Sv(e.text));return navigator.clipboard.writeText(n.join(`
|
|
461
|
+
`)),!0}return c&&e.code===`KeyV`?(e.preventDefault(),navigator.clipboard.readText().then(e=>{let n=t.focusedCells[0];n&&n.set({text:e})}),!0):!(!c||e.code!==`KeyA`||(e.preventDefault(),t.cells.forEach(e=>{t.focusCell(e.id,!0)}),0))}(e,d,t)||c)return;let f=document.activeElement===s||l;if(!f){let e=window.getSelection();if(e&&e.toString().length>0)return}if(e.key===`Alt`){let n=s;(f||t.distanceGuidesVisible||n&&n.matches(`:hover`))&&e.preventDefault();return}let p=t.selectedElements.filter(e=>e.removable).map(e=>e.id);e.keyCode!==46&&e.keyCode!==8||t.deleteElements(p);let m=e.ctrlKey||e.metaKey,h=e.shiftKey,g=e.altKey;if(e.key===`Escape`){e.preventDefault(),t.tool===`draw`?t.setTool(`selection`):t.selectElements([]);return}if(!m||h||e.key.toLowerCase()!==`z`&&e.key.toLowerCase()!==`y`||(e.preventDefault(),t.history.undo()),m&&h&&(e.key.toLowerCase()===`z`||e.key.toLowerCase()===`y`)&&(e.preventDefault(),t.history.redo()),m&&e.code===`KeyA`){e.preventDefault();let n=(t.activePage?.children.filter(e=>e.selectable))?.map(e=>e.id)||[];t.selectElements(n)}if(m&&e.code===`KeyC`&&(e.preventDefault(),Pq(t)),m&&e.code===`KeyX`&&(e.preventDefault(),Fq(t)),m&&e.code===`KeyV`&&(e.preventDefault(),Iq(t)),e.code===`ArrowDown`){e.preventDefault();let n=e.shiftKey?10:1;t.selectedShapes.forEach(e=>{e.draggable&&e.set({y:e.y+n})})}if(e.code===`ArrowUp`){e.preventDefault();let n=e.shiftKey?10:1;t.selectedShapes.forEach(e=>{e.draggable&&e.set({y:e.y-n})})}if(e.code===`ArrowLeft`){e.preventDefault();let n=e.shiftKey?10:1;t.selectedShapes.forEach(e=>{e.draggable&&e.set({x:e.x-n})})}if(e.code===`ArrowRight`){e.preventDefault();let n=e.shiftKey?10:1;t.selectedShapes.forEach(e=>{e.draggable&&e.set({x:e.x+n})})}if(m&&e.code===`KeyG`){e.preventDefault();let n=t.selectedElements[0];if(n&&n.type===`group`){let e=n;t.ungroupElements([e.id])}else t.groupElements(t.selectedElements.map(e=>e.id))}if(m&&e.code===`KeyD`&&(e.preventDefault(),Lq(t.selectedElements,t)),e.code===`KeyT`&&!m){e.preventDefault();let r=t.width/2,i=t.width/2-r/2,a=t.height/2-30/2,o=(t.width+t.height)/2160;(n=t.activePage)==null||n.addElement({type:`text`,x:i,y:a,width:r,fontSize:30*o,text:`Sample Text`,fontFamily:`Roboto`})}if(e.code===`KeyR`&&!m){e.preventDefault();let n={type:`figure`,x:t.width/4,y:t.height/4,width:300,height:300,fill:Kq,stroke:`#0c0c0c`,strokeWidth:0,subType:`rect`};(r=t.activePage)==null||r.addElement(n)}if(e.code===`KeyL`&&!m){e.preventDefault();let n=(t.activePage?.computedWidth??0)/3,r={type:`line`,x:(t.activePage?.computedWidth??0)/2-n/2,y:(t.activePage?.computedHeight??0)/2,width:n,color:Kq};(i=t.activePage)==null||i.addElement(r)}if(e.code===`KeyO`&&!m){e.preventDefault(),e.preventDefault();let n={type:`figure`,x:t.width/4,y:t.height/4,width:300,height:300,fill:Kq,stroke:`#0c0c0c`,strokeWidth:0,subType:`circle`};(a=t.activePage)==null||a.addElement(n)}m&&e.code===`Equal`&&(e.preventDefault(),t.setScale(t.scale+.1)),m&&e.code===`Minus`&&(e.preventDefault(),t.setScale(t.scale-.1)),g&&(e.code===`KeyA`&&(e.preventDefault(),Bq(t)),e.code===`KeyD`&&(e.preventDefault(),Vq(t)),e.code===`KeyS`&&(e.preventDefault(),Wq(t)),e.code===`KeyW`&&(e.preventDefault(),Hq(t)),e.code===`KeyV`&&(e.preventDefault(),Uq(t)),e.code===`KeyH`&&(e.preventDefault(),Gq(t))),e.code===`BracketRight`&&(e.preventDefault(),t.selectedElements.forEach(e=>m?e.moveUp():e.moveTop())),e.code===`BracketLeft`&&(e.preventDefault(),t.selectedElements.forEach(e=>m?e.moveDown():e.moveBottom()))}var Xq=Ut({toolbar:{duration:`Duration`,opacity:`Opacity`,effects:`Effects`,blur:`Blur`,curvedText:`Curved text`,curvePower:`Power`,temperature:`Temperature`,saturation:`Saturation`,contrast:`Contrast`,shadows:`Shadows`,white:`White`,black:`Black`,vibrance:`Vibrance`,textBackground:`Background`,backgroundCornerRadius:`Corner radius`,backgroundOpacity:`Opacity`,backgroundPadding:`Padding`,brightness:`Brightness`,filters:`Filters`,sepia:`Sepia`,grayscale:`Grayscale`,cold:`Cold`,natural:`Natural`,warm:`Warm`,textStroke:`Text Stroke`,shadow:`Shadow`,border:`Border`,cornerRadius:`Corner Radius`,copyStyle:`Copy style`,uppercase:`Uppercase`,position:`Position`,layering:`Layering`,toForward:`To Front`,up:`Forward`,down:`Backward`,toBottom:`To back`,alignLeft:`Align left`,alignCenter:`Align center`,alignRight:`Align right`,alignTop:`Align top`,alignMiddle:`Align middle`,alignBottom:`Align bottom`,flip:`Flip`,flipHorizontally:`Flip horizontally`,flipVertically:`Flip vertically`,fitToBackground:`Fit to page`,removeBackground:`Remove background`,removeBackgroundTitle:`Remove background from image`,cancelRemoveBackground:`Cancel`,confirmRemoveBackground:`Confirm`,crop:`Crop`,cropDone:`Done`,cropCancel:`Cancel`,clip:`Apply mask`,removeClip:`Remove mask`,removeMask:`Remove mask`,transparency:`Transparency`,lockedDescription:`Object is locked. Unlock it to allow changes from canvas.`,unlockedDescription:`Object is unlocked. Lock it to prevent changes from canvas.`,removeElements:`Remove elements`,duplicateElements:`Duplicate elements`,download:`Download`,saveAsImage:`Save as image`,saveAsPDF:`Save as PDF`,lineHeight:`Line height`,letterSpacing:`Letter spacing`,offsetX:`Offset X`,offsetY:`Offset Y`,color:`Color`,selectable:`Selectable`,draggable:`Draggable`,removable:`Removable`,resizable:`Resizable`,contentEditable:`Can change content`,styleEditable:`Can change style`,alwaysOnTop:`Always on top`,showInExport:`Show in export`,ungroupElements:`Ungroup`,groupElements:`Group`,lineSize:`Line size`,fade:`Fade`,move:`Move`,zoom:`Zoom`,animate:`Animate`,rotate:`Rotate`,none:`None`,bounce:`Bounce`,blink:`Blink`,strength:`Strength`,spaceEvenly:`Space evenly`,horizontalDistribution:`Horizontally`,verticalDistribution:`Vertically`,strokeWidth:`Stroke Width`,strokeSettings:`Stroke settings`,spacing:`Spacing`,volume:`Volume`,lineStyle:`Line style`,lineStartHead:`Line start`,lineEndHead:`Line end`,textDirection:`Text direction`,fontSize:`Font size`,fontFamily:`Font family`,fontFamilyMixed:`Mixed`,fontsInSelection:`Fonts in selection`,textAlign:`Text align`,verticalAlign:`Vertical align`,bold:`Bold`,italic:`Italic`,underline:`Underline`,strikethrough:`Strikethrough`,cellBackground:`Cell background`,tableBorderSettings:`Border settings`,tableBorderColor:`Border color`,tableBorderWidth:`Border width`,tableBorderStyle:`Border style`,borderModeAll:`All borders`,borderModeOuter:`Outer borders`,borderModeInner:`Inner borders`,borderModeBottomOnly:`Bottom only`,borderModeTopOnly:`Top only`,borderModeLeftOnly:`Left only`,borderModeRightOnly:`Right only`,borderModeInnerHorizontal:`Inner horizontal`,borderModeInnerVertical:`Inner vertical`,tableStructure:`Table structure`,tableRows:`Rows`,tableColumns:`Columns`,insertRowAbove:`Insert row above`,insertRowBelow:`Insert row below`,deleteRow:`Delete row`,insertColumnLeft:`Insert column left`,insertColumnRight:`Insert column right`,deleteColumn:`Delete column`,deleteRows:`Delete rows`,deleteColumns:`Delete columns`,distributeRowsEvenly:`Distribute rows evenly`,distributeColumnsEvenly:`Distribute columns evenly`,cellPadding:`Cell padding`,listFormat:`List`,colorPicker:{solid:`Solid`,linear:`Linear`,angle:`Angle`,colors:`Colors`,resetColors:`Reset`,recolorAll:`Recolor all`},aiText:{aiWrite:`AI write`,rewrite:`Rewrite`,shorten:`Shorten`,continue:`Continue writing`,proofread:`Proofread`,tones:`Tones`,friendly:`Friendly`,professional:`Professional`,humorous:`Humorous`,formal:`Formal`,customPrompt:`Custom prompt`,generatedResult:`Generated result`,cancel:`Cancel`,generate:`Generate`,back:`Back`,tryAgain:`Try Again`,insert:`Insert`,promptPlaceholder:`Describe what you want to generate`}},workspace:{noPages:`There are no pages yet...`,addPage:`Add page`,removePage:`Remove page`,duplicatePage:`Duplicate page`,moveUp:`Move up`,moveDown:`Move down`,moveLeft:`Move left`,moveRight:`Move right`},scale:{reset:`Reset`},error:{removeBackground:`Ops! Something went wrong. Background can not be removed.`},sidePanel:{templates:`Templates`,searchTemplatesWithSameSize:`Show templates with the same size`,searchPlaceholder:`Search...`,otherFormats:`Other formats`,noResults:`No results`,error:`Loading is failed...`,text:`Text`,uploadFont:`Upload font`,myFonts:`My fonts`,photos:`Photos`,videos:`Videos`,animations:`Animations`,effects:`Effects`,elements:`Elements`,shapes:`Shapes`,tables:`Tables`,lines:`Lines`,draw:`Draw`,upload:`Upload`,uploadImage:`Add file`,uploadTip:`Upload your assets`,background:`Background`,resize:`Resize`,layers:`Layers`,animate:`Animate`,layerTypes:{image:`Image`,text:`Text`,svg:`SVG`,line:`Line`,figure:`Figure`,group:`Group`},layersTip:`Elements on your active page:`,noLayers:`No elements on the page...`,namePlaceholder:`Type element name...`,useMagicResize:`Use magic resize`,clipImage:`Mask image`,width:`Width`,height:`Height`,units:`Units`,magicResizeDescription:`Magic resize will automatically resize and move all elements on the canvas`,headerText:`Header`,createHeader:`Create header`,subHeaderText:`Sub Header`,createSubHeader:`Create sub header`,bodyText:`Body text`,createBody:`Create body text`},pagesTimeline:{pages:`Pages`,removePage:`Remove page`,addPage:`Add page`,duplicatePage:`Duplicate page`,removeAudio:`Remove audio`,duplicateAudio:`Duplicate audio`,muteAudio:`Mute`,unmuteAudio:`Unmute`,volume:`Volume`},contextMenu:{duplicate:`Duplicate`,remove:`Remove`,lock:`Lock`,unlock:`Unlock`,copy:`Copy`,paste:`Paste`,copyStyle:`Copy style`,moveUp:`Move up`,moveDown:`Move down`,moveBack:`Move back`,moveForward:`Move forward`}}),Zq=e=>e&&typeof e==`object`;function Qq(e,t){Object.keys(t).forEach(n=>{let r=e[n],i=t[n];Zq(i)&&Zq(r)?Qq(r,i):e[n]=i})}function $q(e,t,n=``){Object.keys(t).forEach(r=>{let i=t[r],a=n?`${n}.${r}`:r;Zq(i)?Zq(e[r])?$q(e[r],i,a):console.warn(`Missing nested translation object at '${a}'`):e[r]===void 0&&console.warn(`Missing translation '${a}'`)})}ir((e,{validate:t=!1}={})=>{t&&$q(e,Xq),Qq(Xq,e)});var eJ={},tJ=e=>{let t=function(e,t){var n,r=t.split(`.`),i=e;for(n=0;n<r.length;++n){if(i[r[n]]==null)return;i=i[r[n]]}return i}(Xq,e);if(t!==void 0)return t;eJ[e]||(eJ[e]=!0,console.warn(`Missing translation '${e}'`));let n=e.split(`.`),r=n[n.length-1]||` `;return r.charAt(0).toUpperCase()+r.slice(1)},nJ=(e,t,n)=>Math.max(t,Math.min(n,e)),rJ=(e,t)=>Math.sqrt((t.clientX-e.clientX)**2+(t.clientY-e.clientY)**2),iJ=({store:e})=>(0,S.jsxs)(`div`,{style:{position:`absolute`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,textAlign:`center`},children:[(0,S.jsx)(`p`,{children:tJ(`workspace.noPages`)}),(0,S.jsx)(`button`,{onClick:()=>{e.addPage()},children:tJ(`workspace.addPage`)})]}),aJ=({width:e,height:t,xPadding:n,yPadding:r,backgroundColor:i})=>(0,S.jsx)(`div`,{style:{width:e+`px`,height:t+`px`,backgroundColor:i,paddingLeft:n+`px`,paddingRight:n+`px`,paddingTop:r+`px`,paddingBottom:r+`px`,flexShrink:0},children:(0,S.jsx)(`div`,{style:{width:` 100%`,height:`100%`,backgroundColor:`white`}})}),oJ=wa(({store:e,layout:t=`vertical`,pageControlsEnabled:n,backgroundColor:r,transparencyBackgroundColor:i,pageBorderColor:a,activePageBorderColor:o,bleedColor:s,snapGuideStroke:c,snapGuideStrokeWidth:l,snapGuideDash:u,selectionRectFill:d,selectionRectStroke:f,selectionRectStrokeWidth:p,transformLabelFill:m,transformLabelTextFill:h,cropOverlayFill:g,transformerStyle:_,innerImageCropTransformerStyle:v,outerImageCropTransformerStyle:y,highlighterStyle:x,mediaLoadingStyle:C,mediaErrorStyle:w,textOverflowIndicatorStyle:T,distanceGuideStroke:E,distanceLabelFill:D,distanceLabelTextFill:O,rulerBackgroundColor:k,rulerTextColor:ee,rulerBorderColor:A,rulerBorderSize:j,rulerTickColor:te,rulerTickSize:M,components:ne,onKeyDown:N,paddingX:P,paddingY:re,pageGap:ie,altCloneEnabled:ae=!0,groupSelectionMode:F=`drill`,visiblePagesOffset:oe,renderOnlyActivePage:se,scrollToPageThreshold:ce=.5,tooltipSafeArea:le})=>{let ue=t===`horizontal`,de=P??20,fe=re??55,[pe,me]=b.useState({width:100,height:100}),he=b.useRef(pe),ge=b.useRef(null),_e=b.useRef(null),ve=b.useRef(0),ye=e.bleedVisible?Math.max(0,...e.pages.map(e=>e.bleed)):0,be=Math.max(...e.pages.map(e=>e.computedWidth)),xe=Math.max(...e.pages.map(e=>e.computedHeight)),Se=e.activePage?.computedHeight||0,Ce=be+2*ye,we=(se?Se:xe)+2*ye,Te=async({skipTimeout:t}={skipTimeout:!1})=>{if(t||await new Promise(e=>setTimeout(e,50)),ge.current===null||!Number.isFinite(Ce)||!Number.isFinite(we))return;let n=ge.current.getBoundingClientRect();n.width!==0&&n.height!==0||(console.warn(`Polotno warning: <Workspace /> component can not automatically detect its size.
|
|
462
|
+
Width or height of parent elements is equal 0.
|
|
463
|
+
Please make sure it has non-zero size. You may need to adjust it with your styles. <Workspace /> will automatically fit into parent container.
|
|
464
|
+
For simpler debugging here is the log of the parent element:`),console.log(ge.current));let r=_e.current.clientWidth||n.width,i={width:r,height:n.height};(he.current.width!==i.width||he.current.height!==i.height)&&(me(i),he.current=i);let a=(r-2*de)/Ce,o=e.pages.length>1?3.1:2,s=(n.height-fe*o)/we,c=(r-de*(e.pages.length>1?3.1:2))/Ce,l=(n.height-2*fe)/we,u=e.pages.length?Math.max(Math.min(ue?c:a,ue?l:s),.01):1;e.scaleToFit!==u&&(e.setScale(u),e._setScaleToFit(u))};b.useLayoutEffect(()=>{Te({skipTimeout:!0})},[]),b.useEffect(()=>{Te()},[Ce,we,re,P]),b.useLayoutEffect(()=>{Te({skipTimeout:!0})},[e.openedSidePanel]),b.useEffect(()=>{e.__()},[]),b.useEffect(()=>{let e=ge.current;if(window.ResizeObserver){let t=new ResizeObserver(()=>{Te({skipTimeout:!0})});return t.observe(e),()=>t.unobserve(e)}{let e=setInterval(()=>{Te({skipTimeout:!0})},100);return()=>clearInterval(e)}},[Ce,we]);let Ee=se?1:e.pages.length,De,Oe;if(ue){let t=Ce*e.scale*Ee;De=Math.max(de,(pe.width-t)/Ee/2),Oe=Math.max(fe,(pe.height-we*e.scale)/2)}else{De=Math.max(de,(pe.width-Ce*e.scale)/2);let t=we*e.scale*Ee;Oe=Math.max(fe,(pe.height-t)/Ee/2)}Number.isNaN(De)&&(De=de),Number.isNaN(Oe)&&(Oe=fe),b.useEffect(()=>{let t=t=>{(N||Yq)(t,e)};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[]),b.useEffect(()=>{let t=t=>{if(t.ctrlKey||t.metaKey){t.preventDefault();let n=Math.max(5,e.scaleToFit),r=Math.min(.1,e.scaleToFit);ue&&Ce>0&&Number.isFinite(Ce)&&(r=Math.max(r,300/Ce)),r=Math.max(r,.01);let i=nJ(t.deltaY<0?e.scale*1.03:e.scale/1.03,r,n);e.setScale(i);return}},n=_e.current;return n?.addEventListener(`wheel`,t),()=>n?.removeEventListener(`wheel`,t)},[ue,Ce,e]),b.useEffect(()=>{let t=_e.current;if(!t)return;let n=e=>{e.touches.length===2&&(ve.current=rJ(e.touches[0],e.touches[1]))},r=n=>{if(n.touches.length===2&&ve.current>0){n.preventDefault();let r=rJ(n.touches[0],n.touches[1]),i=r/ve.current,a=Math.max(5,e.scaleToFit),o=Math.min(.1,e.scaleToFit);ue&&Ce>0&&Number.isFinite(Ce)&&(o=Math.max(o,300/Ce)),o=Math.max(o,.01);let s=e.scale,c=nJ(s*i,o,a),l=c/s,u=t.getBoundingClientRect(),d=(n.touches[0].clientX+n.touches[1].clientX)/2-u.left,f=(n.touches[0].clientY+n.touches[1].clientY)/2-u.top,p=t.scrollLeft+d,m=t.scrollTop+f;Fe.current=!0,e.setScale(c),t.scrollLeft=p*l-d,t.scrollTop=m*l-f,ve.current=r}},i=()=>{ve.current=0};return t.addEventListener(`touchstart`,n,{passive:!0}),t.addEventListener(`touchmove`,r,{passive:!1}),t.addEventListener(`touchend`,i,{passive:!0}),()=>{t.removeEventListener(`touchstart`,n),t.removeEventListener(`touchmove`,r),t.removeEventListener(`touchend`,i)}},[ue,Ce,e]);let ke=ie!==void 0,Ae=e.pages.map(t=>{if(ue){let n=(t.computedWidth+2*ye)*e.scale;return ke?n+ie:n+2*De}{let n=(t.computedHeight+2*ye)*e.scale;return ke?n+ie:n+2*Oe}}),je=[],Me=ke?ue?De:Oe:0;for(let e=0;e<Ae.length;e++)je.push(Me),Me+=Ae[e];let Ne=Ae.reduce((e,t)=>e+t,0),Pe=ke?Ne+(ue?2*De:2*Oe):Ne,Fe=b.useRef(!1),[,Ie]=b.useReducer(e=>e+1,0);((e,t,n,r,i)=>{let a=b.useRef(0),o=b.useRef(0),s=b.useRef(null),c=b.useRef(null),l=b.useRef(!1),u=b.useRef(r.pages.length);l.current=u.current!==r.pages.length,u.current=r.pages.length,b.useEffect(()=>{let t=e.current,n=()=>{a.current=t.scrollLeft,o.current=t.scrollTop,s.current=t.scrollWidth,c.current=t.scrollHeight};return t.addEventListener(`scroll`,n),n(),()=>{t.removeEventListener(`scroll`,n)}},[]),b.useLayoutEffect(()=>{if(!e.current)return;if(l.current){let t=e.current;s.current=t.scrollWidth,c.current=t.scrollHeight,a.current=t.scrollLeft,o.current=t.scrollTop;return}let t=e.current,n=s.current,r=c.current;if(n===null||r===null){s.current=t.scrollWidth,c.current=t.scrollHeight,a.current=t.scrollLeft,o.current=t.scrollTop;return}i.current=!0;let u=t.offsetWidth,d=t.offsetHeight,f=(a.current+u/2)/n,p=(o.current+d/2)/r,m=Math.max(0,t.scrollWidth-u),h=Math.max(0,t.scrollHeight-d);t.scrollLeft=nJ(f*t.scrollWidth-u/2,0,m),t.scrollTop=nJ(p*t.scrollHeight-d/2,0,h),s.current=t.scrollWidth,c.current=t.scrollHeight,a.current=t.scrollLeft,o.current=t.scrollTop},[n,t])})(_e,Pe,e.scale,e,Fe);let{handleScroll:Le}=((e,t,n,r,i,a,o,s,c,l)=>{let u=b.useRef(!1),d=b.useRef(null),f=b.useRef(!1),p=c===`horizontal`;b.useEffect(()=>{let t=e.current,n=()=>{o.current};return t.addEventListener(`scroll`,n),()=>{t.removeEventListener(`scroll`,n)}},[]);let m=r.pages.indexOf(r.activePage);return b.useLayoutEffect(()=>{if(s||!r.activePage||!e.current||u.current)return;let a=e.current,o=r.pages.indexOf(r.activePage),c=t[o]||0,d=p?a.scrollLeft:a.scrollTop,m=p?a.scrollWidth-a.clientWidth:a.scrollHeight-a.clientHeight,h=Math.min(c,Math.max(0,m)),g=n[o]||n[0]||0,_=()=>{};return(Math.abs(h-d)>g*i||f.current)&&(f.current=!0,_=(({element:e,scrollTop:t,scrollLeft:n,duration:r=300,onFinish:i=()=>{}})=>{let a=t!==void 0,o=a?e.scrollTop:e.scrollLeft,s=a?t:n,c=s-o,l=0,u=!1;if(r===0)return a?e.scrollTop=s:e.scrollLeft=s,()=>{};let d=()=>{if(u)return;l+=20;let t=f(l,o,c,r);a?e.scrollTop=t:e.scrollLeft=t,l<r?setTimeout(d,20):i()},f=(e,t,n,r)=>(e/=r/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t;return d(),()=>{u=!0}})(Object.assign(Object.assign({element:a},p?{scrollLeft:h}:{scrollTop:h}),{onFinish:()=>{f.current=!1,l?.()},duration:r.isPlaying?0:300}))),_},[r.activePage,m,r.isPlaying,s,c,t,n]),{handleScroll:e=>{if(s||f.current)return;u.current=!0,clearTimeout(d.current),d.current=setTimeout(()=>{u.current=!1},300);let n=(p?e.currentTarget.scrollLeft:e.currentTarget.scrollTop)+(p?a.width:a.height)/3,i=0;for(let e=t.length-1;e>=0;e--)if(n>=t[e]){i=e;break}let o=r.pages[i];o&&r.activePage!==o&&o.select()}}})(_e,je,Ae,e,ce,pe,Fe,se,t,Ie),Re=pe.width>=Ce*e.scale+2*De,ze=pe.height>=we*e.scale+2*Oe,I=r||`rgba(232, 232, 232, 0.9)`,Be=ne?.NoPages||iJ,Ve=ue?pe.width:pe.height,He=_e.current?ue?_e.current.scrollLeft:_e.current.scrollTop:0,Ue=e=>{for(let t=je.length-1;t>=0;t--)if(e>=je[t])return t;return 0},We=Math.max(0,Ue(He)),Ge=Math.min(e.pages.length-1,Ue(He+Ve)),Ke=oe??1,qe=Math.max(0,We-Ke),Je=Math.min(e.pages.length-1,Ge+Ke);return(0,S.jsx)(lp,{value:hp({cropOverlayFill:g,workspaceBackgroundColor:r,pageBorderColor:a,activePageBorderColor:o,bleedColor:s,transparencyBackgroundColor:i,transformerStyle:_,innerImageCropTransformerStyle:v,outerImageCropTransformerStyle:y,highlighterStyle:x,snapGuideStroke:c,snapGuideStrokeWidth:l,snapGuideDash:u,selectionRectFill:d,selectionRectStroke:f,selectionRectStrokeWidth:p,transformLabelFill:m,transformLabelTextFill:h,distanceGuideStroke:E,distanceLabelFill:D,distanceLabelTextFill:O,mediaLoadingStyle:C,mediaErrorStyle:w,textOverflowIndicatorStyle:T,rulerBackgroundColor:k,rulerTextColor:ee,rulerBorderColor:A,rulerBorderSize:j,rulerTickColor:te,rulerTickSize:M}),children:(0,S.jsx)(`div`,{ref:ge,style:{width:`100%`,height:`100%`,position:`relative`,outline:`none`,flex:1,backgroundColor:I,overflow:`hidden`},tabIndex:0,className:`polotno-workspace-container`,children:(0,S.jsxs)(`div`,{ref:_e,onScroll:Le,style:Object.assign({position:`absolute`,top:0,left:0,width:`100%`,height:`100%`,display:`flex`,flexDirection:ue?`row`:`column`,overflow:`auto`,overflowX:ue?`auto`:Re?`hidden`:`auto`,overflowY:ue&&ze?`hidden`:`auto`},ke&&{paddingTop:ue?0:Oe,paddingBottom:ue?0:Oe,paddingLeft:ue?De:0,paddingRight:ue?De:0,boxSizing:`border-box`}),className:`polotno-workspace-inner`,children:[e.pages.map((r,i)=>{let a=r===e.activePage;if(se&&!a&&!r._exportingOrRendering&&!r._forceMount)return null;let o=a||i>=qe&&i<=Je||r._exportingOrRendering||r._forceMount,s=ue?Ae[i]:Ce*e.scale+2*De,c=ue?we*e.scale+2*Oe:Ae[i];if(!o)return(0,S.jsx)(`div`,{style:{flexShrink:0},children:(0,S.jsx)(aJ,{width:s,height:c,backgroundColor:I,xPadding:De,yPadding:Oe})},r.id);let l=(0,S.jsx)(xq,{page:r,xPadding:De,yPadding:Oe,width:s,height:c,store:e,pageControlsEnabled:n,altCloneEnabled:ae,groupSelectionMode:F,components:ne,viewportSize:pe,layout:t,tooltipSafeArea:le},r.id);return(r._exportingOrRendering||r._forceMount)&&!a&&se?(0,S.jsx)(`div`,{style:{display:`none`,flexShrink:0},children:l},r.id):l}),e.rulesVisible&&(0,S.jsx)(Oq,{store:e,xPadding:De,yPadding:Oe,width:Ce*e.scale+2*De,height:we*e.scale+2*Oe,pageSizes:Ae,layout:t,renderOnlyActivePage:se}),e.pages.length===0&&(0,S.jsx)(Be,{store:e}),e.audios.map(t=>(0,S.jsx)(kq,{audio:t,store:e},t.id))]})})})}),sJ=`modulepreload`,cJ=function(e,t){return new URL(e,t).href},lJ={},uJ=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=cJ(t,n),t in lJ)return;lJ[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:sJ,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};H.prototype._requestDraw=()=>{},U_(!1),w_(`change-font-size`);var dJ=pC({key:new URLSearchParams(location.search).get(`key`)});window.store=dJ;var fJ=null;window.__polotnoLoadJspdf=async()=>(fJ||=uJ(()=>import(`./jspdf.es.min-D1g0nHTs.js`),__vite__mapDeps([0,1]),import.meta.url),await fJ);var pJ=null;window.__polotnoLoadVideoExport=async()=>(pJ||=uJ(()=>import(`./lib-U0NRl5MI.js`),[],import.meta.url),await pJ),window.config={addGlobalFont:Dv,setRichTextEnabled:x_,setTextVerticalResizeEnabled:__,setTextOverflow:w_,onLoadError:rv,setAssetLoadTimeout:Y_,setFontLoadTimeout:Z_,unstable_setTextSplitAllowed:T_,setRenderTagTextEnabled:S_,setLegacyRichTextEnabled:b_},x.createRoot(document.getElementById(`root`)).render(b.createElement(oJ,{visiblePagesOffset:0,renderOnlyActivePage:!0,store:dJ,components:{PageControls:()=>null,Tooltip:()=>null}}));export{$R as $,gB as A,dz as B,fU as C,IL as Ct,iB as D,o as Dt,JB as E,$v as Et,sB as F,Lz as G,yz as H,wB as I,rz as J,Pz as K,uz as L,RB as M,HB as N,PB as O,l as Ot,AB as P,ZR as Q,lz as R,CU as S,GR as St,YB as T,NL as Tt,Tz as U,sz as V,Iz as W,az as X,oz as Y,nz as Z,dW as _,AL as _t,iG as a,HL as at,tW as b,uR as bt,eG as c,oR as ct,HW as d,WL as dt,tz as et,ZW as f,TR as ft,kW as g,LR as gt,BW as h,jL as ht,SG as i,YR as it,Zz as j,oB as k,qW as l,QL as lt,UW as m,bR as mt,LG as n,RL as nt,nG as o,BL as ot,XW as p,_R as pt,iz as q,NG as r,ER as rt,tG as s,X as st,uJ as t,KL as tt,GW as u,fR as ut,LW as v,eR as vt,wH as w,JR as wt,yU as x,lR as xt,FW as y,hR as yt,cz as z};
|