@kition/kit-table-ui 0.1.1 → 0.1.2

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.
@@ -1,167 +0,0 @@
1
- import{D as e,O as t,c as n,i as r,k as i,l as a,m as o,n as s,r as c,s as l,t as u,u as d,v as f,w as p}from"./kit-ui-protocol-BNgs-zwK.js";var m=Object.create,h=Object.defineProperty,g=Object.getOwnPropertyDescriptor,_=Object.getOwnPropertyNames,v=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty,b=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),x=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=_(t),a=0,o=i.length,s;a<o;a++)s=i[a],!y.call(e,s)&&s!==n&&h(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=g(t,s))||r.enumerable});return e},S=(e,t,n)=>(n=e==null?{}:m(v(e)),x(t||!e||!e.__esModule||!y.call(e,`default`)?h(n,`default`,{value:e,enumerable:!0}):n,e)),C=b((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&&j(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&&j(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,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(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,j(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}}}})),w=b(((e,t)=>{t.exports=C()})),T=b((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.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.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`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function A(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var j=/\/+/g;function M(e,t){return typeof e==`object`&&e&&e.key!=null?A(``+e.key):t.toString(36)}function N(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(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 ee(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,ee(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+M(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(j,`$&/`)+`/`),ee(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(j,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+M(a,u),c+=ee(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+M(a,u++),c+=ee(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ee(N(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 P(e,t,n){if(e==null)return e;var r=[],i=0;return ee(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function F(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var te=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)};function ne(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,te)}catch(e){te(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function I(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else ne(I.bind(null,e))}var re={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=re,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=I,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=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.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 D(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)E.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 D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:F}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=ne,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),E=b(((e,t)=>{t.exports=T()})),D=b((e=>{var t=E();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`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(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.browser=function(e){return{$$typeof:o,_reason:e}},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 c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.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=u(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=u(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,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority: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=u(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=u(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,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority: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 l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),O=b(((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=D()})),k=b((e=>{var t=w(),n=E(),r=O();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){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e: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 d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function x(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function S(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function C(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var T=Object.assign,D=Symbol.for(`react.element`),k=Symbol.for(`react.transitional.element`),A=Symbol.for(`react.portal`),j=Symbol.for(`react.fragment`),M=Symbol.for(`react.strict_mode`),N=Symbol.for(`react.profiler`),ee=Symbol.for(`react.consumer`),P=Symbol.for(`react.context`),F=Symbol.for(`react.forward_ref`),te=Symbol.for(`react.suspense`),ne=Symbol.for(`react.suspense_list`),I=Symbol.for(`react.memo`),re=Symbol.for(`react.lazy`),ie=Symbol.for(`react.activity`),ae=Symbol.for(`react.legacy_hidden`),oe=Symbol.for(`react.memo_cache_sentinel`),se=Symbol.for(`react.view_transition`),L=Symbol.for(`react.recoverable`),ce=Symbol.iterator;function le(e){return typeof e!=`object`||!e?null:(e=ce&&e[ce]||e[`@@iterator`],typeof e==`function`?e:null)}var ue=Symbol.for(`react.client.reference`);function de(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ue?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case j:return`Fragment`;case N:return`Profiler`;case M:return`StrictMode`;case te:return`Suspense`;case ne:return`SuspenseList`;case ie:return`Activity`;case se:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case A:return`Portal`;case P:return e.displayName||`Context`;case ee:return(e._context.displayName||`Context`)+`.Consumer`;case F:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case I:return t=e.displayName||null,t===null?de(e.type)||`Memo`:t;case re:t=e._payload,e=e._init;try{return de(e(t))}catch{}}return null}var R=Array.isArray,z=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,fe=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,pe={pending:!1,data:null,method:null,action:null},me=[],he=-1;function ge(e){return{current:e}}function _e(e){0>he||(e.current=me[he],me[he]=null,he--)}function ve(e,t){he++,me[he]=e.current,e.current=t}var ye=ge(null),B=ge(null),be=ge(null),xe=ge(null);function Se(e,t){switch(ve(be,t),ve(B,e),ve(ye,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?xp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=xp(t),e=Sp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}_e(ye),ve(ye,e)}function Ce(){_e(ye),_e(B),_e(be)}function we(e){var t=e.memoizedState;t!==null&&(vh._currentValue=t.memoizedState,ve(xe,e)),t=ye.current;var n=Sp(t,e.type);t!==n&&(ve(B,e),ve(ye,n))}function Te(e){B.current===e&&(_e(ye),_e(B)),xe.current===e&&(_e(xe),vh._currentValue=pe)}var Ee,De;function Oe(e){if(Ee===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ee=t&&t[1]||``,De=-1<e.stack.indexOf(`
2
- at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
3
- `+Ee+e+De}var ke=!1;function Ae(e,t){if(!e||ke)return``;ke=!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}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}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(`
4
- `),l=s.split(`
5
- `);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=`
6
- `+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{ke=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Oe(n):``}function je(e,t){switch(e.tag){case 26:case 27:case 5:return Oe(e.type);case 16:return Oe(`Lazy`);case 13:return e.child!==t&&t!==null?Oe(`Suspense Fallback`):Oe(`Suspense`);case 19:return Oe(`SuspenseList`);case 0:case 15:return Ae(e.type,!1);case 11:return Ae(e.type.render,!1);case 1:return Ae(e.type,!0);case 31:return Oe(`Activity`);case 30:return Oe(`ViewTransition`);default:return``}}function Me(e){try{var t=``,n=null;do t+=je(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
7
- Error generating stack: `+e.message+`
8
- `+e.stack}}var Ne=Object.prototype.hasOwnProperty,Pe=t.unstable_scheduleCallback,Fe=t.unstable_cancelCallback,Ie=t.unstable_shouldYield,Le=t.unstable_requestPaint,Re=t.unstable_now,ze=t.unstable_getCurrentPriorityLevel,Be=t.unstable_ImmediatePriority,Ve=t.unstable_UserBlockingPriority,He=t.unstable_NormalPriority,Ue=t.unstable_LowPriority,We=t.unstable_IdlePriority,Ge=t.log,Ke=t.unstable_setDisableYieldValue,qe=null,Je=null;function Ye(e){if(typeof Ge==`function`&&Ke(e),Je&&typeof Je.setStrictMode==`function`)try{Je.setStrictMode(qe,e)}catch{}}var Xe=Math.clz32?Math.clz32:$e,Ze=Math.log,Qe=Math.LN2;function $e(e){return e>>>=0,e===0?32:31-(Ze(e)/Qe|0)|0}var et=256,tt=262144,nt=4194304;function rt(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&-e;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 it(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=rt(n))):i=rt(o):i=rt(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=rt(n))):i=rt(o)):i=rt(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 at(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ot(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var r=31-Xe(n),i=1<<r;t|=e[r],n&=~i}return t}function st(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 ct(){var e=nt;return nt<<=1,!(nt&62914560)&&(nt=4194304),e}function lt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function ut(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function dt(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-Xe(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&&ft(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function ft(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Xe(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function pt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Xe(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function mt(e,t){var n=t&-t;return n=n&42?1:ht(n),(n&(e.suspendedLanes|t))===0?n:0}function ht(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 gt(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function _t(){var e=fe.p;return e===0?(e=window.event,e===void 0?32:Ph(e.type)):e}function vt(e,t){var n=fe.p;try{return fe.p=e,t()}finally{fe.p=n}}var yt=Math.random().toString(36).slice(2),bt=`__reactFiber$`+yt,xt=`__reactProps$`+yt,St=`__reactContainer$`+yt,Ct=`__reactEvents$`+yt,wt=`__reactListeners$`+yt,Tt=`__reactHandles$`+yt,Et=`__reactResources$`+yt,Dt=`__reactMarker$`+yt,Ot=`__reactLoad$`+yt;function kt(e){delete e[bt],delete e[xt],delete e[wt],delete e[Tt]}function At(e){var t;if(t=e[bt])return t;for(var n=e.parentNode;n;){if(t=n[St]||n[bt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Cm(e);e!==null;){if(n=e[bt])return n;e=Cm(e)}return t}e=n,n=e.parentNode}return null}function jt(e){if(e=e[bt]||e[St]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function Mt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function Nt(e){var t=e[Et];return t||=e[Et]={hoistableStyles:new Map,hoistableScripts:new Map},t}function Pt(e){e[Dt]=!0}function Ft(e){e[Ot]=void 0}var It=new Set,Lt={};function Rt(e,t){zt(e,t),zt(e+`Capture`,t)}function zt(e,t){for(Lt[e]=t,e=0;e<t.length;e++)It.add(t[e])}var Bt=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]*$`),Vt={},Ht={};function Ut(e){return Ne.call(Ht,e)?!0:Ne.call(Vt,e)?!1:Bt.test(e)?Ht[e]=!0:(Vt[e]=!0,!1)}var Wt=!1;function Gt(){var e=Wt;return Wt=!1,e}function Kt(e,t,n){if(Ut(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 qt(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 Jt(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 Yt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Xt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Zt(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 Qt(e){if(!e._valueTracker){var t=Xt(e)?`checked`:`value`;e._valueTracker=Zt(e,t,``+e[t])}}function $t(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Xt(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}var en=/[\n"\\]/g;function tn(e){return e.replace(en,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function nn(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=``+Yt(t)):e.value!==``+Yt(t)&&(e.value=``+Yt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):an(e,Yt(n)):o===`number`&&e.value==t?an(e,Yt(e.value)):an(e,Yt(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=``+Yt(s):e.removeAttribute(`name`)}function rn(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)){Qt(e);return}n=n==null?``:``+Yt(n),t=t==null?n:``+Yt(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),Qt(e)}function an(e,t){e.defaultValue!==``+t&&(e.defaultValue=``+t)}function on(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=``+Yt(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 sn(e,t,n){t!=null&&(t=``+Yt(t),t!==e.value&&(e.value=t),n==null)?e.defaultValue!==t&&(e.defaultValue=t):e.defaultValue=n==null?``:``+Yt(n)}function cn(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(R(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Yt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Qt(e)}function ln(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var un=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 dn(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||un.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function fn(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]=``,Wt=!0);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&(dn(e,a,r),Wt=!0)}else for(var o in t)t.hasOwnProperty(o)&&dn(e,o,t[o])}function pn(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 mn=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`],[`maskType`,`mask-type`],[`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`]]),hn=/^[\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 gn(e){return hn.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function V(){}var _n=null;function vn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var yn=null,bn=null;function xn(e){var t=jt(e);if(t&&(e=t.stateNode)){var n=e[xt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(nn(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="`+tn(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[xt]||null;if(!a)throw Error(i(90));nn(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&&$t(r)}break a;case`textarea`:sn(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&on(e,!!n.multiple,t,!1)}}}var Sn=!1;function Cn(e,t,n){if(Sn)return e(t,n);Sn=!0;try{return e(t)}finally{if(Sn=!1,(yn!==null||bn!==null)&&(qd(),yn&&(t=yn,e=bn,bn=yn=null,xn(t),e)))for(t=0;t<e.length;t++)xn(e[t])}}function wn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[xt]||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 Tn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,En=!1;if(Tn)try{var Dn={};Object.defineProperty(Dn,"passive",{get:function(){En=!0}}),window.addEventListener(`test`,Dn,Dn),window.removeEventListener(`test`,Dn,Dn)}catch{En=!1}var On=null,kn=null,An=null;function jn(){if(An)return An;var e,t=kn,n=t.length,r,i=`value`in On?On.value:On.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 An=i.slice(e,1<r?1-r:void 0)}function Mn(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 Nn(){return!0}function Pn(){return!1}function Fn(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)?Nn:Pn,this.isPropagationStopped=Pn,this}return T(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=Nn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=Nn)},persist:function(){},isPersistent:Nn}),t}var In={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ln=Fn(In),Rn=T({},In,{view:0,detail:0}),zn=Fn(Rn),Bn,Vn,Hn,Un=T({},Rn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:er,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!==Hn&&(Hn&&e.type===`mousemove`?(Bn=e.screenX-Hn.screenX,Vn=e.screenY-Hn.screenY):Vn=Bn=0,Hn=e),Bn)},movementY:function(e){return`movementY`in e?e.movementY:Vn}}),Wn=Fn(Un),Gn=Fn(T({},Un,{dataTransfer:0})),Kn=Fn(T({},Rn,{relatedTarget:0})),qn=Fn(T({},In,{animationName:0,elapsedTime:0,pseudoElement:0})),Jn=Fn(T({},In,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Yn=Fn(T({},In,{data:0})),Xn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Zn={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`},Qn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function $n(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Qn[e])?!!t[e]:!1}function er(){return $n}var tr=Fn(T({},Rn,{key:function(e){if(e.key){var t=Xn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=Mn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Zn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:er,charCode:function(e){return e.type===`keypress`?Mn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?Mn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),nr=Fn(T({},Un,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),rr=Fn(T({},In,{submitter:0})),ir=Fn(T({},Rn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:er})),ar=Fn(T({},In,{propertyName:0,elapsedTime:0,pseudoElement:0})),or=Fn(T({},Un,{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})),sr=Fn(T({},In,{newState:0,oldState:0,source:0})),cr=[9,13,27,32],lr=Tn&&`CompositionEvent`in window,ur=null;Tn&&`documentMode`in document&&(ur=document.documentMode);var dr=Tn&&`TextEvent`in window&&!ur,fr=Tn&&(!lr||ur&&8<ur&&11>=ur),pr=` `,mr=!1;function hr(e,t){switch(e){case`keyup`:return cr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function gr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var _r=!1;function vr(e,t){switch(e){case`compositionend`:return gr(t);case`keypress`:return t.which===32?(mr=!0,pr):null;case`textInput`:return e=t.data,e===pr&&mr?null:e;default:return null}}function yr(e,t){if(_r)return e===`compositionend`||!lr&&hr(e,t)?(e=jn(),An=kn=On=null,_r=!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 fr&&t.locale!==`ko`?null:t.data;default:return null}}var br={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 xr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!br[e.type]:t===`textarea`}function Sr(e,t,n,r){yn?bn?bn.push(r):bn=[r]:yn=r,t=ip(t,`onChange`),0<t.length&&(n=new Ln(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Cr=null,wr=null;function Tr(e){Xf(e,0)}function Er(e){if($t(Mt(e)))return e}function Dr(e,t){if(e===`change`)return t}var Or=!1;if(Tn){var kr;if(Tn){var Ar=`oninput`in document;if(!Ar){var jr=document.createElement(`div`);jr.setAttribute(`oninput`,`return;`),Ar=typeof jr.oninput==`function`}kr=Ar}else kr=!1;Or=kr&&(!document.documentMode||9<document.documentMode)}function Mr(){Cr&&(Cr.detachEvent(`onpropertychange`,Nr),wr=Cr=null)}function Nr(e){if(e.propertyName===`value`&&Er(wr)){var t=[];Sr(t,wr,e,vn(e)),Cn(Tr,t)}}function Pr(e,t,n){e===`focusin`?(Mr(),Cr=t,wr=n,Cr.attachEvent(`onpropertychange`,Nr)):e===`focusout`&&Mr()}function Fr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Er(wr)}function Ir(e,t){if(e===`click`)return Er(t)}function Lr(e,t){if(e===`input`||e===`change`)return Er(t)}function Rr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var zr=typeof Object.is==`function`?Object.is:Rr;function Br(e,t){if(zr(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(!Ne.call(t,i)||!zr(e[i],t[i]))return!1}return!0}function Vr(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function Hr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Ur(e,t){var n=Hr(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=Hr(n)}}function Wr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Wr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Gr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Vr(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=Vr(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 qr=Tn&&`documentMode`in document&&11>=document.documentMode,Jr=null,Yr=null,Xr=null,Zr=!1;function Qr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Zr||Jr==null||Jr!==Vr(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}),Xr&&Br(Xr,r)||(Xr=r,r=ip(Yr,`onSelect`),0<r.length&&(t=new Ln(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Jr)))}function $r(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var ei={animationend:$r(`Animation`,`AnimationEnd`),animationiteration:$r(`Animation`,`AnimationIteration`),animationstart:$r(`Animation`,`AnimationStart`),transitionrun:$r(`Transition`,`TransitionRun`),transitionstart:$r(`Transition`,`TransitionStart`),transitioncancel:$r(`Transition`,`TransitionCancel`),transitionend:$r(`Transition`,`TransitionEnd`)},ti={},ni={};Tn&&(ni=document.createElement(`div`).style,`AnimationEvent`in window||(delete ei.animationend.animation,delete ei.animationiteration.animation,delete ei.animationstart.animation),`TransitionEvent`in window||delete ei.transitionend.transition);function ri(e){if(ti[e])return ti[e];if(!ei[e])return e;var t=ei[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in ni)return ti[e]=t[n];return e}var ii=ri(`animationend`),ai=ri(`animationiteration`),oi=ri(`animationstart`),si=ri(`transitionrun`),ci=ri(`transitionstart`),li=ri(`transitioncancel`),ui=ri(`transitionend`),di=new Map,fi=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error fullscreenChange fullscreenError 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(` `);fi.push(`scrollEnd`);function pi(e,t){di.set(e,t),Rt(t,[e])}var mi=0;function hi(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=Od.identifierPrefix;var n=mi++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function gi(e){if(e==null||typeof e==`string`)return e;var t=null,n=Id;if(n!==null)for(var r=0;r<n.length;r++){var i=e[n[r]];if(i!=null){if(i===`none`)return`none`;t=t==null?i:t+(` `+i)}}return t??e.default}function _i(e,t){return e=gi(e),t=gi(t),t==null?e===`auto`?null:e:t===`auto`?null:t}var vi=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)},yi=[],bi=0,xi=0;function Si(){for(var e=bi,t=xi=bi=0;t<e;){var n=yi[t];yi[t++]=null;var r=yi[t];yi[t++]=null;var i=yi[t];yi[t++]=null;var a=yi[t];if(yi[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&&Ei(n,i,a)}}function Ci(e,t,n,r){yi[bi++]=e,yi[bi++]=t,yi[bi++]=n,yi[bi++]=r,xi|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function wi(e,t,n,r){return Ci(e,t,n,r),H(e)}function Ti(e,t){return Ci(e,null,null,t),H(e)}function Ei(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-Xe(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function H(e){if(50<Ld)throw Ld=0,Rd=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Di={};function Oi(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 ki(e,t,n,r){return new Oi(e,t,n,r)}function Ai(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ji(e,t){var n=e.alternate;return n===null?(n=ki(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&1206910976,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 Mi(e,t){e.flags&=1206910978;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 Ni(e,t,n,r,a,o){var s=0;if(r=e,typeof r==`function`)Ai(r)&&(s=1);else if(typeof r==`string`)s=ih(e,n,ye.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(r){case ie:return e=ki(31,n,t,a),e.elementType=ie,e.lanes=o,e;case j:return Pi(n.children,a,o,t);case M:s=8,a|=24;break;case N:return e=ki(12,n,t,a|2),e.elementType=N,e.lanes=o,e;case te:return e=ki(13,n,t,a),e.elementType=te,e.lanes=o,e;case ne:return e=ki(19,n,t,a),e.elementType=ne,e.lanes=o,e;case ae:case se:return e=a|32,e=ki(30,n,t,e),e.elementType=se,e.lanes=o,e.stateNode={autoName:null,paired:null,clones:null,ref:null},e;default:if(typeof r==`object`&&r)switch(r.$$typeof){case P:s=10;break a;case ee:s=9;break a;case F:s=11;break a;case I:s=14;break a;case re:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=ki(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function Pi(e,t,n,r){return e=ki(7,e,r,t),e.lanes=n,e}function Fi(e,t,n){return e=ki(6,e,null,t),e.lanes=n,e}function Ii(e){var t=ki(18,null,null,0);return t.stateNode=e,t}function Li(e,t,n){return t=ki(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var Ri=new WeakMap;function zi(e,t){if(typeof e==`object`&&e){var n=Ri.get(e);return n===void 0?(t={value:e,source:t,stack:Me(t)},Ri.set(e,t),t):n}return{value:e,source:t,stack:Me(t)}}var Bi=[],Vi=0,Hi=null,Ui=0,Wi=[],Gi=0,Ki=null,qi=1,Ji=``;function Yi(e,t){Bi[Vi++]=Ui,Bi[Vi++]=Hi,Hi=e,Ui=t}function Xi(e,t,n){Wi[Gi++]=qi,Wi[Gi++]=Ji,Wi[Gi++]=Ki,Ki=e;var r=qi;e=Ji;var i=32-Xe(r)-1;r&=~(1<<i),n+=1;var a=32-Xe(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,qi=1<<32-Xe(t)+i|n<<i|r,Ji=a+e}else qi=1<<a|n<<i|r,Ji=e}function Zi(e){e.return!==null&&(Yi(e,1),Xi(e,1,0))}function Qi(e){for(;e===Hi;)Hi=Bi[--Vi],Bi[Vi]=null,Ui=Bi[--Vi],Bi[Vi]=null;for(;e===Ki;)Ki=Wi[--Gi],Wi[Gi]=null,Ji=Wi[--Gi],Wi[Gi]=null,qi=Wi[--Gi],Wi[Gi]=null}function $i(e,t){Wi[Gi++]=qi,Wi[Gi++]=Ji,Wi[Gi++]=Ki,qi=t.id,Ji=t.overflow,Ki=e}var ea=null,ta=null,na=!1,ra=null,ia=!1,aa=Error(i(519));function oa(e){throw fa(zi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),aa}function sa(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[bt]=e,t[xt]=r,n){case`dialog`:Zf(`cancel`,t),Zf(`close`,t);break;case`iframe`:case`object`:case`embed`:Zf(`load`,t);break;case`video`:case`audio`:for(n=0;n<Jf.length;n++)Zf(Jf[n],t);break;case`source`:Zf(`error`,t);break;case`img`:case`image`:case`link`:Zf(`error`,t),Zf(`load`,t);break;case`details`:Zf(`toggle`,t);break;case`input`:Zf(`invalid`,t),rn(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Zf(`invalid`,t);break;case`textarea`:Zf(`invalid`,t),cn(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||up(t.textContent,n)?(r.popover!=null&&(Zf(`beforetoggle`,t),Zf(`toggle`,t)),r.onScroll!=null&&Zf(`scroll`,t),r.onScrollEnd!=null&&Zf(`scrollend`,t),r.onClick!=null&&(t.onclick=V),t=!0):t=!1,t||oa(e,!0)}function ca(e){for(ea=e.return;ea;)switch(ea.tag){case 5:case 31:case 13:ia=!1;return;case 27:case 3:ia=!0;return;default:ea=ea.return}}function la(e){if(e!==ea)return!1;if(!na)return ca(e),na=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||wp(e.type,e.memoizedProps)),n=!n),n&&ta&&oa(e),ca(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));ta=Sm(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));ta=Sm(e)}else t===27?(t=ta,Np(e.type)?(e=xm,xm=null,ta=e):ta=t):ta=ea?bm(e.stateNode.nextSibling):null;return!0}function ua(){ta=ea=null,na=!1}function da(){var e=ra;return e!==null&&(bd===null?bd=e:bd.push.apply(bd,e),ra=null),e}function fa(e){ra===null?ra=[e]:ra.push(e)}var pa=ge(null),ma=null,ha=null;function ga(e,t,n){ve(pa,t._currentValue),t._currentValue=n}function _a(e){e._currentValue=pa.current,_e(pa)}function va(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 ya(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),va(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),va(s,n,e),s=null}else a.tag===13&&a.memoizedState!==null&&a.memoizedState.dehydrated===null?(a.lanes|=n,s=a.alternate,s!==null&&(s.lanes|=n),va(a.return,n,e),s=a.child,s=s===null?null:s.sibling):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 ba(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;zr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===xe.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[vh]:e.push(vh))}a=a.return}return e!==null&&ya(t,e,n,r),t.flags|=262144,e!==null}function xa(e){for(e=e.firstContext;e!==null;){if(!zr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Sa(e){ma=e,ha=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Ca(e){return Ta(ma,e)}function wa(e,t){return ma===null&&Sa(e),Ta(e,t)}function Ta(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},ha===null){if(e===null)throw Error(i(308));ha=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ha=ha.next=t;return n}var Ea=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()})}},Da=t.unstable_scheduleCallback,Oa=t.unstable_NormalPriority,ka={$$typeof:P,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Aa(){return{controller:new Ea,data:new Map,refCount:0}}function ja(e){e.refCount--,e.refCount===0&&Da(Oa,function(){e.controller.abort()})}function Ma(e,t){if(e.pendingLanes&4194048){var n=e.transitionTypes;for(n===null&&(n=e.transitionTypes=[]),e=0;e<t.length;e++){var r=t[e];n.indexOf(r)===-1&&n.push(r)}}}var Na=null;function Pa(e){var t=e.transitionTypes;return e.transitionTypes=null,t}var Fa=null,Ia=0,La=0,Ra=null;function za(e,t){if(Fa===null){var n=Fa=[];Ia=0,La=Uf(),Ra={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Ia++,t.then(Ba,Ba),t}function Ba(){if(--Ia===0&&(Na=null,Fa!==null)){Ra!==null&&(Ra.status=`fulfilled`);var e=Fa;Fa=null,La=0,Ra=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 Ha=z.S;z.S=function(e,t){if(Cd=Re(),typeof t==`object`&&t&&typeof t.then==`function`&&za(e,t),Na!==null)for(var n=kf;n!==null;)Ma(n,Na),n=n.next;if(n=e.types,n!==null){for(var r=kf;r!==null;)Ma(r,n),r=r.next;if(La!==0){r=Na,r===null&&(r=Na=[]);for(var i=0;i<n.length;i++){var a=n[i];r.indexOf(a)===-1&&r.push(a)}}}Ha!==null&&Ha(e,t)};var Ua=ge(null);function Wa(){var e=Ua.current;return e===null?id.pooledCache:e}function Ga(e,t){t===null?ve(Ua,Ua.current):ve(Ua,t.pool)}function Ka(){var e=Wa();return e===null?null:{parent:ka._currentValue,pool:e}}var qa=Error(i(460)),Ja=Error(i(474)),Ya=Error(i(542)),Xa={then:function(){}};function Za(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Qa(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(V,V),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,no(e),e===void 0&&!(`reason`in t)?Error(i(600)):e;default:if(typeof t.status==`string`)t.then(V,V);else{if(e=id,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,no(e),e}throw eo=t,qa}}function $a(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(eo=e,qa):e}}var eo=null;function to(){if(eo===null)throw Error(i(459));var e=eo;return eo=null,e}function no(e){if(e===qa||e===Ya)throw Error(i(483))}var ro=null,io=0;function ao(e){var t=io;return io+=1,ro===null&&(ro=[]),Qa(ro,e,t)}function oo(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function so(e,t){throw t.$$typeof===D?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function co(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=ji(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|=134217730,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=134217730),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=Fi(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===j?(e=d(e,t,n.props.children,r,n.key),oo(e,n),e):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===re&&$a(i)===t.type)?(t=a(t,n.props),oo(t,n),t.return=e,t):(t=Ni(n.type,n.key,n.props,null,e.mode,r),oo(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=Li(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=Pi(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=Fi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case k:return n=Ni(t.type,t.key,t.props,null,e.mode,n),oo(n,t),n.return=e,n;case A:return t=Li(t,e.mode,n),t.return=e,t;case re:return t=$a(t),f(e,t,n)}if(R(t)||le(t))return t=Pi(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,ao(t),n);if(t.$$typeof===P)return f(e,wa(e,t),n);so(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 k:return n.key===i?l(e,t,n,r):null;case A:return n.key===i?u(e,t,n,r):null;case re:return n=$a(n),p(e,t,n,r)}if(R(n)||le(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,ao(n),r);if(n.$$typeof===P)return p(e,t,wa(e,n),r);so(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 k:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case A:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case re:return r=$a(r),m(e,t,n,r,i)}if(R(r)||le(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,ao(r),i);if(r.$$typeof===P)return m(e,t,n,wa(t,r),i);so(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),na&&Yi(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 na&&Yi(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(_.key===null?h:_.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)}),na&&Yi(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),na&&Yi(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 na&&Yi(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(_.key===null?g:_.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)}),na&&Yi(a,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===j&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case k:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===j){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),oo(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===re&&$a(l)===r.type){n(e,r.sibling),c=a(r,o.props),oo(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===j?(c=Pi(o.props.children,e.mode,c,o.key),oo(c,o),c.return=e,e=c):(c=Ni(o.type,o.key,o.props,null,e.mode,c),oo(c,o),c.return=e,e=c)}return s(e);case A: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}n(e,r);break}t(e,r),r=r.sibling}c=Li(o,e.mode,c),c.return=e,e=c}return s(e);case re:return o=$a(o),_(e,r,o,c)}if(R(o))return h(e,r,o,c);if(le(o)){if(l=le(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,ao(o),c);if(o.$$typeof===P)return _(e,r,wa(e,o),c);so(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=Fi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{io=0;var i=_(e,t,n,r);return ro=null,i}catch(t){if(t===qa||t===Ya)throw t;var a=ki(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var lo=co(!0),uo=co(!1),fo=!1;function po(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function mo(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 ho(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function go(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,rd&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=H(e),Ei(e,null,n),t}return Ci(e,r,t,n),H(e)}function _o(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,pt(e,n)}}function vo(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}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var yo=!1;function bo(){if(yo){var e=Ra;if(e!==null)throw e}}function xo(e,t,n,r){yo=!1;var i=e.updateQueue;fo=!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?(od&f)===f:(r&f)===f){f!==0&&f===La&&(yo=!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=T({},d,f);break a;case 2:fo=!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),md|=o,e.lanes=o,e.memoizedState=d}}function So(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Co(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)So(n[e],t)}var wo=ge(null),To=ge(0);function Eo(e,t){e=fd,ve(To,e),ve(wo,t),fd=e|t.baseLanes}function Do(){ve(To,fd),ve(wo,wo.current)}function Oo(){fd=To.current,_e(wo),_e(To)}var ko=ge(null),Ao=null;function jo(e){var t=e.alternate;ve(Io,Io.current&1),ve(ko,e),Ao===null&&(t===null||wo.current!==null||t.memoizedState!==null)&&(Ao=e)}function Mo(e){ve(Io,Io.current),ve(ko,e),Ao===null&&(Ao=e)}function No(e){e.tag===22?(ve(Io,Io.current),ve(ko,e),Ao===null&&(Ao=e)):Po()}function Po(){ve(Io,Io.current),ve(ko,ko.current)}function Fo(e){_e(ko),Ao===e&&(Ao=null),_e(Io)}var Io=ge(0);function Lo(e,t){ve(ko,ko.current),ve(Io,t)}function Ro(e){_e(Io),_e(ko),Ao===e&&(Ao=null)}function zo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||_m(n)||vm(n)))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==`independent`){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 Bo=0,Vo=null,Ho=null,Uo=null,Wo=!1,Go=!1,Ko=!1,qo=0,Jo=0,Yo=null,Xo=0;function Zo(){throw Error(i(321))}function Qo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!zr(e[n],t[n]))return!1;return!0}function $o(e,t,n,r,i,a){return Bo=a,Vo=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,z.H=e===null||e.memoizedState===null?gc:_c,Ko=!1,a=n(r,i),Ko=!1,Go&&(a=ts(t,n,r,i)),es(e),a}function es(e){z.H=hc;var t=Ho!==null&&Ho.next!==null;if(Bo=0,Uo=Ho=Vo=null,Wo=!1,Jo=0,Yo=null,t)throw Error(i(300));e===null||Pc||(e=e.dependencies,e!==null&&xa(e)&&(Pc=!0))}function ts(e,t,n,r){Vo=e;var a=0;do{if(Go&&(Yo=null),Jo=0,Go=!1,25<=a)throw Error(i(301));if(a+=1,Uo=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)}z.H=vc,o=t(n,r)}while(Go);return o}function ns(){var e=z.H,t=e.useState()[0];return t=typeof t.then==`function`?ls(t):t,e=e.useState()[0],(Ho===null?null:Ho.memoizedState)!==e&&(Vo.flags|=1024),t}function rs(){var e=qo!==0;return qo=0,e}function is(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function as(e){if(Wo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Wo=!1}Bo=0,Uo=Ho=Vo=null,Go=!1,Jo=qo=0,Yo=null}function os(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Uo===null?Vo.memoizedState=Uo=e:Uo=Uo.next=e,Uo}function ss(){if(Ho===null){var e=Vo.alternate;e=e===null?null:e.memoizedState}else e=Ho.next;var t=Uo===null?Vo.memoizedState:Uo.next;if(t!==null)Uo=t,Ho=e;else{if(e===null)throw Vo.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},Uo===null?Vo.memoizedState=Uo=e:Uo=Uo.next=e}return Uo}function cs(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ls(e){var t=Jo;return Jo+=1,Yo===null&&(Yo=[]),e=Qa(Yo,e,t),t=Vo,(Uo===null?t.memoizedState:Uo.next)===null&&(t=t.alternate,z.H=t===null||t.memoizedState===null?gc:_c),e}function us(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return ls(e);if(e.$$typeof===L)return;if(e.$$typeof===P)return Ca(e)}throw Error(i(438,String(e)))}function ds(e){var t=null,n=Vo.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=Vo.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=cs(),Vo.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]=oe;return t.index++,n}function fs(e,t){return typeof t==`function`?t(e):t}function ps(e){return ms(ss(),Ho,e)}function ms(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?(Bo&f)===f:(od&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===La&&(d=!0);else if((Bo&p)===p){u=u.next,p===La&&(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,Vo.lanes|=p,md|=p;f=u.action,Ko&&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,Vo.lanes|=f,md|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!zr(o,e.memoizedState)&&(Pc=!0,d&&(n=Ra,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 hs(e){var t=ss(),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);zr(o,t.memoizedState)||(Pc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function gs(e,t,n){var r=Vo,a=ss(),o=na;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!zr((Ho||a).memoizedState,n);if(s&&(a.memoizedState=n,Pc=!0),a=a.queue,Vs(ys.bind(null,r,a,e),[e]),e=a.getSnapshot!==t||s||Uo!==null&&!!(Uo.memoizedState.tag&1),Is(e?9:8,{destroy:void 0},vs.bind(null,r,a,n,t),null),e){if(r.flags|=2048,id===null)throw Error(i(349));o||Bo&127||_s(r,t,n)}return n}function _s(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Vo.updateQueue,t===null?(t=cs(),Vo.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function vs(e,t,n,r){t.value=n,t.getSnapshot=r,bs(t)&&xs(e)}function ys(e,t,n){return n(function(){bs(t)&&xs(e)})}function bs(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!zr(e,n)}catch{return!0}}function xs(e){var t=Ti(e,2);t!==null&&Hd(t,e,2)}function Ss(e){var t=os();if(typeof e==`function`){var n=e;if(e=n(),Ko){Ye(!0);try{n()}finally{Ye(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:fs,lastRenderedState:e},t}function Cs(e,t,n,r){return e.baseState=n,ms(e,Ho,typeof r==`function`?r:fs)}function ws(e,t,n,r,a){if(fc(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)}};z.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Ts(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Ts(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=z.T,o={};o.types=a===null?null:a.types,z.T=o;try{var s=n(i,r),c=z.S;c!==null&&c(o,s),Es(e,t,s)}catch(n){Os(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),z.T=a}}else try{a=n(i,r),Es(e,t,a)}catch(n){Os(e,t,n)}}function Es(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Ds(e,t,n)},function(n){return Os(e,t,n)}):Ds(e,t,n)}function Ds(e,t,n){t.status=`fulfilled`,t.value=n,ks(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Ts(e,n)))}function Os(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,ks(t),t=t.next;while(t!==r)}e.action=null}function ks(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function As(e,t){return t}function js(e,t){if(na){var n=id.formState;if(n!==null){a:{var r=Vo;if(na){if(ta){b:{for(var i=ta,a=ia;i.nodeType!==8;)if(!a||(i=bm(i.nextSibling),i===null)){i=null;break b}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){ta=bm(i.nextSibling),r=i.data===`F!`;break a}}oa(r)}r=!1}r&&(t=n[0])}}return n=os(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:As,lastRenderedState:t},n.queue=r,n=lc.bind(null,Vo,r),r.dispatch=n,r=Ss(!1),a=dc.bind(null,Vo,!1,r.queue),r=os(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=ws.bind(null,Vo,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Ms(e){return Ns(ss(),Ho,e)}function Ns(e,t,n){if(t=ms(e,t,As)[0],e=ps(fs)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=ls(t)}catch(e){throw e===qa?Ya:e}else r=t;t=ss();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(Vo.flags|=2048,Is(9,{destroy:void 0},Ps.bind(null,i,n),null)),[r,a,e]}function Ps(e,t){e.action=t}function Fs(e){var t=ss(),n=Ho;if(n!==null)return Ns(t,n,e);ss(),t=t.memoizedState,n=ss();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Is(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=Vo.updateQueue,t===null&&(t=cs(),Vo.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 Ls(){return ss().memoizedState}function Rs(e,t,n,r){var i=os();Vo.flags|=e,i.memoizedState=Is(1|t,{destroy:void 0},n,r===void 0?null:r)}function zs(e,t,n,r){var i=ss();r=r===void 0?null:r;var a=i.memoizedState.inst;Ho!==null&&r!==null&&Qo(r,Ho.memoizedState.deps)?i.memoizedState=Is(t,a,n,r):(Vo.flags|=e,i.memoizedState=Is(1|t,a,n,r))}function Bs(e,t){Rs(8390656,8,e,t)}function Vs(e,t){zs(2048,8,e,t)}function Hs(e){Vo.flags|=4;var t=Vo.updateQueue;if(t===null)t=cs(),Vo.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Us(e){var t=ss().memoizedState;return Hs({ref:t,nextImpl:e}),function(){if(rd&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Ws(e,t){return zs(4,2,e,t)}function Gs(e,t){return zs(4,4,e,t)}function Ks(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 qs(e,t,n){n=n==null?null:n.concat([e]),zs(4,4,Ks.bind(null,t,e),n)}function Js(){}function Ys(e,t){var n=ss();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&Qo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Xs(e,t){var n=ss();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&Qo(t,r[1]))return r[0];if(r=e(),Ko){Ye(!0);try{e()}finally{Ye(!1)}}return n.memoizedState=[r,t],r}function Zs(e,t,n){return n===void 0||Bo&1073741824&&!(od&261930)?e.memoizedState=t:(e.memoizedState=n,e=Bd(),Vo.lanes|=e,md|=e,n)}function Qs(e,t,n,r){return zr(n,t)?n:wo.current===null?!(Bo&106)||Bo&1073741824&&!(od&261930)?(Pc=!0,e.memoizedState=n):(e=Bd(),Vo.lanes|=e,md|=e,t):(e=Zs(e,n,r),zr(e,t)||(Pc=!0),e)}function $s(e,t,n,r,i){var a=fe.p;fe.p=a!==0&&8>a?a:8;var o=z.T,s={};s.types=o===null?null:o.types,z.T=s,dc(e,!1,t,n);try{var c=i(),l=z.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?uc(e,t,Va(c,r),zd(e)):uc(e,t,r,zd(e))}catch(n){uc(e,t,{then:function(){},status:`rejected`,reason:n},zd())}finally{fe.p=a,o!==null&&s.types!==null&&(o.types=s.types),z.T=o}}function ec(){}function tc(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=nc(e).queue;$s(e,a,t,pe,n===null?ec:function(){return rc(e),n(r)})}function nc(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:pe,baseState:pe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:fs,lastRenderedState:pe},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:fs,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function rc(e){var t=nc(e);t.next===null&&(t=e.alternate.memoizedState),uc(e,t.next.queue,{},zd())}function ic(){return Ca(vh)}function ac(){return ss().memoizedState}function oc(){return ss().memoizedState}function sc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=zd();e=ho(n);var r=go(t,e,n);r!==null&&(Hd(r,t,n),_o(r,t,n)),t={cache:Aa()},e.payload=t;return}t=t.return}}function cc(e,t,n){var r=zd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},fc(e)?pc(t,n):(n=wi(e,t,n,r),n!==null&&(Hd(n,e,r),mc(n,t,r)))}function lc(e,t,n){uc(e,t,n,zd())}function uc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(fc(e))pc(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,zr(s,o))return Ci(e,t,i,0),id===null&&Si(),!1}catch{}if(n=wi(e,t,i,r),n!==null)return Hd(n,e,r),mc(n,t,r),!0}return!1}function dc(e,t,n,r){if(r={lane:2,revertLane:Uf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},fc(e)){if(t)throw Error(i(479))}else t=wi(e,n,r,2),t!==null&&Hd(t,e,2)}function fc(e){var t=e.alternate;return e===Vo||t!==null&&t===Vo}function pc(e,t){Go=Wo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function mc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,pt(e,n)}}var hc={readContext:Ca,use:us,useCallback:Zo,useContext:Zo,useEffect:Zo,useImperativeHandle:Zo,useLayoutEffect:Zo,useInsertionEffect:Zo,useMemo:Zo,useReducer:Zo,useRef:Zo,useState:Zo,useDebugValue:Zo,useDeferredValue:Zo,useTransition:Zo,useSyncExternalStore:Zo,useId:Zo,useHostTransitionStatus:Zo,useFormState:Zo,useActionState:Zo,useOptimistic:Zo,useMemoCache:Zo,useCacheRefresh:Zo,useEffectEvent:Zo},gc={readContext:Ca,use:us,useCallback:function(e,t){return os().memoizedState=[e,t===void 0?null:t],e},useContext:Ca,useEffect:Bs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Rs(4194308,4,Ks.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Rs(4194308,4,e,t)},useInsertionEffect:function(e,t){Rs(4,2,e,t)},useMemo:function(e,t){var n=os();t=t===void 0?null:t;var r=e();if(Ko){Ye(!0);try{e()}finally{Ye(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=os();if(n!==void 0){var i=n(t);if(Ko){Ye(!0);try{n(t)}finally{Ye(!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=cc.bind(null,Vo,e),[r.memoizedState,e]},useRef:function(e){var t=os();return e={current:e},t.memoizedState=e},useState:function(e){e=Ss(e);var t=e.queue,n=lc.bind(null,Vo,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Js,useDeferredValue:function(e,t){return Zs(os(),e,t)},useTransition:function(){var e=Ss(!1);return e=$s.bind(null,Vo,e.queue,!0,!1),os().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Vo,a=os();if(na){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),id===null)throw Error(i(349));od&127||_s(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Bs(ys.bind(null,r,o,e),[e]),r.flags|=2048,Is(9,{destroy:void 0},vs.bind(null,r,o,n,t),null),n},useId:function(){var e=os(),t=id.identifierPrefix;if(na){var n=Ji,r=qi;n=(r&~(1<<32-Xe(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=qo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=Xo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:ic,useFormState:js,useActionState:js,useOptimistic:function(e){var t=os();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=dc.bind(null,Vo,!0,n),n.dispatch=t,[e,t]},useMemoCache:ds,useCacheRefresh:function(){return os().memoizedState=sc.bind(null,Vo)},useEffectEvent:function(e){var t=os(),n={impl:e};return t.memoizedState=n,function(){if(rd&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},_c={readContext:Ca,use:us,useCallback:Ys,useContext:Ca,useEffect:Vs,useImperativeHandle:qs,useInsertionEffect:Ws,useLayoutEffect:Gs,useMemo:Xs,useReducer:ps,useRef:Ls,useState:function(){return ps(fs)},useDebugValue:Js,useDeferredValue:function(e,t){return Qs(ss(),Ho.memoizedState,e,t)},useTransition:function(){var e=ps(fs)[0],t=ss().memoizedState;return[typeof e==`boolean`?e:ls(e),t]},useSyncExternalStore:gs,useId:ac,useHostTransitionStatus:ic,useFormState:Ms,useActionState:Ms,useOptimistic:function(e,t){return Cs(ss(),Ho,e,t)},useMemoCache:ds,useCacheRefresh:oc,useEffectEvent:Us},vc={readContext:Ca,use:us,useCallback:Ys,useContext:Ca,useEffect:Vs,useImperativeHandle:qs,useInsertionEffect:Ws,useLayoutEffect:Gs,useMemo:Xs,useReducer:hs,useRef:Ls,useState:function(){return hs(fs)},useDebugValue:Js,useDeferredValue:function(e,t){var n=ss();return Ho===null?Zs(n,e,t):Qs(n,Ho.memoizedState,e,t)},useTransition:function(){var e=hs(fs)[0],t=ss().memoizedState;return[typeof e==`boolean`?e:ls(e),t]},useSyncExternalStore:gs,useId:ac,useHostTransitionStatus:ic,useFormState:Fs,useActionState:Fs,useOptimistic:function(e,t){var n=ss();return Ho===null?(n.baseState=e,[e,n.queue.dispatch]):Cs(n,Ho,e,t)},useMemoCache:ds,useCacheRefresh:oc,useEffectEvent:Us};function yc(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:T({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var bc={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=zd(),i=ho(r);i.payload=t,n!=null&&(i.callback=n),t=go(e,i,r),t!==null&&(Hd(t,e,r),_o(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=zd(),i=ho(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=go(e,i,r),t!==null&&(Hd(t,e,r),_o(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=zd(),r=ho(n);r.tag=2,t!=null&&(r.callback=t),t=go(e,r,n),t!==null&&(Hd(t,e,n),_o(t,e,n))}};function xc(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?!Br(n,r)||!Br(i,a):!0}function Sc(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&&bc.enqueueReplaceState(t,t.state,null)}function Cc(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=T({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function wc(e){vi(e)}function Tc(e){console.error(e)}function Ec(e){vi(e)}function Dc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Oc(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 kc(e,t,n){return n=ho(n),n.tag=3,n.payload={element:null},n.callback=function(){Dc(e,t)},n}function Ac(e){return e=ho(e),e.tag=3,e}function jc(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(){Oc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Oc(t,n,r),typeof i!=`function`&&(Ed===null?Ed=new Set([this]):Ed.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Mc(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&ba(t,n,a,!0),n=ko.current,n!==null){switch(n.tag){case 31:case 13:case 19:return Ao===null?ef():n.alternate===null&&pd===0&&(pd=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===Xa?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Cf(e,r,a)),!1;case 22:return n.flags|=65536,r===Xa?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)),Cf(e,r,a)),!1}throw Error(i(435,n.tag))}return Cf(e,r,a),ef(),!1}if(na)return t=ko.current,t===null?(r!==aa&&(t=Error(i(423),{cause:r}),fa(zi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=zi(r,n),a=kc(e.stateNode,r,a),vo(e,a),pd!==4&&(pd=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==aa&&(e=Error(i(422),{cause:r}),fa(zi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=zi(o,n),yd===null?yd=[o]:yd.push(o),pd!==4&&(pd=2),t===null)return!0;r=zi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=kc(n.stateNode,r,e),vo(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`&&(Ed===null||!Ed.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Ac(a),jc(a,e,n,r),vo(n,a),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}var Nc=Error(i(461)),Pc=!1;function Fc(e,t,n,r){t.child=e===null?uo(t,null,n,r):lo(t,e.child,n,r)}function Ic(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 Sa(t),r=$o(e,t,n,o,a,i),s=rs(),e!==null&&!Pc?(is(e,t,i),ul(e,t,i)):(na&&s&&Zi(t),t.flags|=1,Fc(e,t,r,i),t.child)}function Lc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Ai(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Rc(e,t,a,r,i)):(e=Ni(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!dl(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Br:n,n(o,r)&&e.ref===t.ref)return ul(e,t,i)}return t.flags|=1,e=ji(a,r),e.ref=t.ref,e.return=t,t.child=e}function Rc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Br(a,r)&&e.ref===t.ref){if(Pc=!1,t.pendingProps=r=a,dl(e,i))e.flags&131072&&(Pc=!0);else return t.lanes=e.lanes,ul(e,t,i)}}return Kc(e,t,n,r,i)}function zc(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 Vc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Ga(t,a===null?null:a.cachePool),a===null?Do():Eo(t,a),No(t);else return r=t.lanes=536870912,Vc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Ga(t,null),Do(),Po()):(Ga(t,a.cachePool),Eo(t,a),Po(),t.memoizedState=null);return Fc(e,t,i,n),t.child}function Bc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Vc(e,t,n,r,i){var a=Wa();return a=a===null?null:{parent:ka._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Ga(t,null),Do(),No(t),e!==null&&ba(e,t,r,!0),t.childLanes=i,null}function Hc(e,t){return t=tl({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function Uc(e,t,n){return lo(t,e.child,null,n),e=Hc(t,t.pendingProps),e.flags|=2,Fo(t),t.memoizedState=null,e}function Wc(e,t,n){var r=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(na){if(r.mode===`hidden`)return e=Hc(t,r),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},Bc(null,e);if(Mo(t),(e=ta)?(e=gm(e,ia),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Ki===null?null:{id:qi,overflow:Ji},retryLane:536870912,hydrationErrors:null},n=Ii(e),n.return=t,t.child=n,ea=t,ta=null)):e=null,e===null)throw oa(t);return t.lanes=536870912,null}return Hc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(Mo(t),a){if(t.flags&256)t.flags&=-257,t=Uc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558))}else if(Pc||ba(e,t,n,!1),a=(n&e.childLanes)!==0,Pc||a){if(wo.current===null){if(r=id,r!==null&&(s=mt(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Ti(e,s),Hd(r,e,s),Nc;ef()}t=Uc(e,t,n)}else e=o.treeContext,ta=bm(s.nextSibling),ea=t,na=!0,ra=null,ia=!1,e!==null&&$i(t,e),t=Hc(t,r),t.flags|=134221824;return t}return e=ji(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Gc(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 Kc(e,t,n,r,i){return Sa(t),n=$o(e,t,n,r,void 0,i),r=rs(),e!==null&&!Pc?(is(e,t,i),ul(e,t,i)):(na&&r&&Zi(t),t.flags|=1,Fc(e,t,n,i),t.child)}function qc(e,t,n,r,i,a){return Sa(t),t.updateQueue=null,n=ts(t,r,n,i),es(e),r=rs(),e!==null&&!Pc?(is(e,t,a),ul(e,t,a)):(na&&r&&Zi(t),t.flags|=1,Fc(e,t,n,a),t.child)}function Jc(e,t,n,r,i){if(Sa(t),t.stateNode===null){var a=Di,o=n.contextType;typeof o==`object`&&o&&(a=Ca(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=bc,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},po(t),o=n.contextType,a.context=typeof o==`object`&&o?Ca(o):Di,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(yc(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&&bc.enqueueReplaceState(a,a.state,null),xo(t,r,a,i),bo(),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=Cc(n,s);a.props=c;var l=a.context,u=n.contextType;o=Di,typeof u==`object`&&u&&(o=Ca(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)&&Sc(t,a,r,o),fo=!1;var f=t.memoizedState;a.state=f,xo(t,r,a,i),bo(),l=t.memoizedState,s||f!==l||fo?(typeof d==`function`&&(yc(t,n,d,r),l=t.memoizedState),(c=fo||xc(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,mo(e,t),o=t.memoizedProps,u=Cc(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Di,typeof l==`object`&&l&&(c=Ca(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)&&Sc(t,a,r,c),fo=!1,f=t.memoizedState,a.state=f,xo(t,r,a,i),bo();var p=t.memoizedState;o!==d||f!==p||fo||e!==null&&e.dependencies!==null&&xa(e.dependencies)?(typeof s==`function`&&(yc(t,n,s,r),p=t.memoizedState),(u=fo||xc(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&xa(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,Gc(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=lo(t,e.child,null,i),t.child=lo(t,null,n,i)):Fc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=ul(e,t,i),e}function Yc(e,t,n,r){return ua(),t.flags|=256,Fc(e,t,n,r),t.child}var Xc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Zc(e){return{baseLanes:e,cachePool:Ka()}}function Qc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=_d),e}function $c(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!(Io.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if(na){if(i?jo(t):Po(),(e=ta)?(e=gm(e,ia),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Ki===null?null:{id:qi,overflow:Ji},retryLane:536870912,hydrationErrors:null},n=Ii(e),n.return=t,t.child=n,ea=t,ta=null)):e=null,e===null)throw oa(t);return t.lanes=vm(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(Po(),i=t.mode,a=tl({mode:`hidden`,children:a},i),r=Pi(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=Zc(n),r.childLanes=Qc(e,o,n),t.memoizedState=Xc,Bc(null,r)):(jo(t),el(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return rl(e,t,a,o,r,c,s,n)}return i?(Po(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=ji(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=Pi(i,a,n,null),i.flags|=2):i=ji(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,Bc(null,r),r=t.child,i=e.child.memoizedState,i===null?i=Zc(n):(a=i.cachePool,a===null?a=Ka():(s=ka._currentValue,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=Qc(e,o,n),t.memoizedState=Xc,Bc(e.child,r)):(jo(t),n=e.child,e=n.sibling,n=ji(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(o=t.deletions,o===null?(t.deletions=[e],t.flags|=16):o.push(e)),t.child=n,t.memoizedState=null,n)}function el(e,t){return t=tl({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function tl(e,t){return e=ki(22,e,null,t),e.lanes=0,e}function nl(e,t,n){return lo(t,e.child,null,n),e=el(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function rl(e,t,n,r,a,o,s,c){if(n)return t.flags&256?(jo(t),t.flags&=-257,nl(e,t,c)):t.memoizedState===null?(Po(),o=a.fallback,s=t.mode,a=tl({mode:`visible`,children:a.children},s),o=Pi(o,s,c,null),o.flags|=2,a.return=t,o.return=t,a.sibling=o,t.child=a,lo(t,e.child,null,c),a=t.child,a.memoizedState=Zc(c),a.childLanes=Qc(e,r,c),t.memoizedState=Xc,Bc(null,a)):(Po(),t.child=e.child,t.flags|=128,null);if(jo(t),vm(o)){if(r=o.nextSibling&&o.nextSibling.dataset,r)var l=r.dgst;return r=l,r!==``&&(a=Error(i(419)),a.stack=``,a.digest=r,fa({value:a,source:null,stack:null})),nl(e,t,c)}if(Pc||ba(e,t,c,!1),r=(c&e.childLanes)!==0,Pc||r){if(wo.current!==null)return nl(e,t,c);if(r=id,r!==null&&(a=mt(r,c),a!==0&&a!==s.retryLane))throw s.retryLane=a,Ti(e,a),Hd(r,e,a),Nc;return _m(o)||ef(),nl(e,t,c)}return _m(o)?(t.flags|=192,t.child=e.child,null):(e=s.treeContext,ta=bm(o.nextSibling),ea=t,na=!0,ra=null,ia=!1,e!==null&&$i(t,e),t=el(t,a.children),t.flags|=134221824,t)}function il(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),va(e.return,t,n)}function al(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&zo(n)===null&&(t=e),e=e.sibling}return t}function ol(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 sl(e){var t=e.child;for(e.child=null;t!==null;){var n=t.sibling;t.sibling=e.child,e.child=t,t=n}}function cl(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Io.current;if(t.flags&128)return Lo(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,Lo(t,o),i===`backwards`&&e!==null?(sl(e),Fc(e,t,r,n),sl(e)):Fc(e,t,r,n),r=na?Ui:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&il(e,n,t);else if(e.tag===19)il(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`backwards`:n=al(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,sl(t)),ol(t,!0,i,null,a,r);break;case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&zo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}ol(t,!0,n,null,a,r);break;case`together`:ol(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=al(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),ol(t,!1,i,n,a,r)}return t.child}function ll(e,t,n){var r=t.pendingProps;return ga(t,t.type,r.value),Fc(e,t,r.children,n),t.child}function ul(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),md|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(ba(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=ji(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ji(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function dl(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&xa(e)))}function fl(e,t,n){switch(t.tag){case 3:Se(t,t.stateNode.containerInfo),ga(t,ka,e.memoizedState.cache),ua();break;case 27:case 5:we(t);break;case 4:Se(t,t.stateNode.containerInfo);break;case 10:ga(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,Mo(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return jo(t),t.flags|=128,null;r=ba(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?$c(e,t,n):(jo(t),e=ul(e,t,n),e===null?null:e.sibling)}jo(t);break;case 19:if(t.flags&128)return cl(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(ba(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return cl(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Lo(t,Io.current),r)break;return null;case 22:return t.lanes=0,zc(e,t,n,t.pendingProps);case 24:ga(t,ka,e.memoizedState.cache)}return ul(e,t,n)}function pl(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)Pc=!0;else{if(!dl(e,n)&&!(t.flags&128))return Pc=!1,fl(e,t,n);Pc=!!(e.flags&131072)}}else Pc=!1,na&&t.flags&1048576&&Xi(t,Ui,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=$a(t.elementType),t.type=e,typeof e==`function`)Ai(e)?(r=Cc(e,r),t.tag=1,t=Jc(null,t,e,r,n)):(t.tag=0,t=Kc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===F){t.tag=11,t=Ic(null,t,e,r,n);break a}if(a===I){t.tag=14,t=Lc(null,t,e,r,n);break a}if(a===P){t.tag=10,t.type=e,t=ll(null,t,n);break a}}throw t=de(e)||e,Error(i(306,t,``))}}return t;case 0:return Kc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Cc(r,t.pendingProps),Jc(e,t,r,a,n);case 3:a:{if(Se(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,mo(e,t),xo(t,r,null,n);var s=t.memoizedState;if(r=s.cache,ga(t,ka,r),r!==o.cache&&ya(t,[ka],n,!0),bo(),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=Yc(e,t,r,n);break a}if(r!==a){a=zi(Error(i(424)),t),fa(a),t=Yc(e,t,r,n);break a}switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(ta=bm(e.firstChild),ea=t,na=!0,ra=null,ia=!0,n=uo(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(ua(),r===a){t=ul(e,t,n);break a}Fc(e,t,r,n)}t=t.child}return t;case 26:return Gc(e,t),e===null?(n=Wm(t.type,null,t.pendingProps,null))?t.memoizedState=n:na||(t.stateNode=Cp(t.type,t.pendingProps,be.current,t)):t.memoizedState=Wm(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return we(t),e===null&&na&&(r=t.stateNode=Em(t.type,t.pendingProps,be.current),ea=t,ia=!0,a=ta,Np(t.type)?(xm=a,ta=bm(r.firstChild)):ta=a),Fc(e,t,t.pendingProps.children,n),Gc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&na&&((a=r=ta)&&(r=mm(r,t.type,t.pendingProps,ia),r===null?a=!1:(t.stateNode=r,ea=t,ta=bm(r.firstChild),ia=!1,a=!0)),a||oa(t)),we(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,wp(a,o)?r=null:s!==null&&wp(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=$o(e,t,ns,null,null,n),vh._currentValue=a),Gc(e,t),Fc(e,t,r,n),t.child;case 6:return e===null&&na&&((e=n=ta)&&(n=hm(n,t.pendingProps,ia),n===null?e=!1:(t.stateNode=n,ea=t,ta=null,e=!0)),e||oa(t)),null;case 13:return $c(e,t,n);case 4:return Se(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=lo(t,null,r,n):Fc(e,t,r,n),t.child;case 11:return Ic(e,t,t.type,t.pendingProps,n);case 7:return r=t.pendingProps,Gc(e,t),Fc(e,t,r,n),t.child;case 8:return Fc(e,t,t.pendingProps.children,n),t.child;case 12:return Fc(e,t,t.pendingProps.children,n),t.child;case 10:return ll(e,t,n);case 9:return a=t.type._context,r=t.pendingProps.children,Sa(t),a=Ca(a),r=r(a),t.flags|=1,Fc(e,t,r,n),t.child;case 14:return Lc(e,t,t.type,t.pendingProps,n);case 15:return Rc(e,t,t.type,t.pendingProps,n);case 19:return cl(e,t,n);case 31:return Wc(e,t,n);case 22:return zc(e,t,n,t.pendingProps);case 24:return Sa(t),r=Ca(ka),e===null?(a=Wa(),a===null&&(a=id,o=Aa(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},po(t),ga(t,ka,a)):((e.lanes&n)!==0&&(mo(e,t),xo(t,null,null,n),bo()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,ga(t,ka,r),r!==a.cache&&ya(t,[ka],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),ga(t,ka,r))),Fc(e,t,t.pendingProps.children,n),t.child;case 30:return t.stateNode===null&&(t.stateNode={autoName:null,paired:null,clones:null,ref:null}),r=t.pendingProps,r.name!=null&&r.name!==`auto`?t.flags|=e===null?18882560:18874368:na&&Zi(t),e!==null&&e.memoizedProps.name!==r.name?t.flags|=4194816:Gc(e,t),Fc(e,t,r.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function ml(e){e.flags|=4}function hl(e,t,n,r,i){var a;if((a=!!(e.mode&32))&&(a=n===null?ah(t,r):ah(t,r)&&(r.src!==n.src||r.srcSet!==n.srcSet)),a){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(Zd())e.flags|=8192;else throw eo=Xa,Ja}}else e.flags&=-16777217}function gl(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!oh(t)){if(Zd())e.flags|=8192;else throw eo=Xa,Ja}}function _l(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:ct(),e.lanes|=t,vd|=t)}function vl(e,t){if(!na)switch(e.tailMode){case`visible`:break;case`collapsed`:for(var n=e.tail,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;break;default:for(t=e.tail,n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null}}function yl(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&1206910976,r|=i.flags&1206910976,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 bl(e,t,n){var r=t.pendingProps;switch(Qi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return yl(t),null;case 1:return yl(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),_a(ka),Ce(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(la(t)?ml(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,da())),yl(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(ml(t),o===null?(yl(t),hl(t,a,null,r,n)):(yl(t),gl(t,o))):o?o===e.memoizedState?(yl(t),t.flags&=-16777217):(ml(t),yl(t),gl(t,o)):(e=e.memoizedProps,e!==r&&ml(t),yl(t),hl(t,a,e,r,n)),null;case 27:if(Te(t),n=be.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&ml(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return yl(t),t.subtreeFlags&=-33554433,null}e=ye.current,la(t)?sa(t,e):(e=Em(a,r,n),t.stateNode=e,ml(t))}return yl(t),t.subtreeFlags&=-33554433,null;case 5:if(Te(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&ml(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return yl(t),t.subtreeFlags&=-33554433,null}if(o=ye.current,la(t))sa(t,o);else{var s=bp(be.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[bt]=t,o[xt]=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(pp(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&&ml(t)}}return yl(t),t.subtreeFlags&=-33554433,hl(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&ml(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=be.current,la(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=ea,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[bt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||up(e.nodeValue,n)),e||oa(t,!0)}else e=bp(e).createTextNode(r),e[bt]=t,t.stateNode=e}return yl(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=la(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[bt]=t}else ua(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;yl(t),e=!1}else n=da(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Fo(t),t):(Fo(t),null);if(t.flags&128)throw Error(i(558))}return yl(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=la(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[bt]=t}else ua(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;yl(t),a=!1}else a=da(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Fo(t),t):(Fo(t),null)}return Fo(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),_l(t,t.updateQueue),yl(t),null);case 4:return Ce(),e===null&&ep(t.stateNode.containerInfo),t.flags|=67108864,yl(t),null;case 10:return _a(t.type),yl(t),null;case 19:if(Ro(t),r=t.memoizedState,r===null)return yl(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)vl(r,!1);else{if(pd!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=zo(e),o!==null){for(t.flags|=128,vl(r,!1),e=o.updateQueue,t.updateQueue=e,_l(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Mi(n,e),n=n.sibling;return Lo(t,Io.current&1|2),na&&Yi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Re()>wd&&(t.flags|=128,a=!0,vl(r,!1),t.lanes=4194304)}}else{if(!a){if(e=zo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,_l(t,e),vl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!na)return yl(t),null}else 2*Re()-r.renderingStartTime>wd&&n!==536870912&&(t.flags|=128,a=!0,vl(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)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Re(),e.sibling=null,o=Io.current,o=a?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||na?Lo(t,o):(n=o,ve(ko,t),ve(Io,n),Ao===null&&(Ao=t)),na&&Yi(t,r.treeForkCount),e}return yl(t),null;case 22:case 23:return Fo(t),Oo(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(yl(t),t.subtreeFlags&6&&(t.flags|=8192)):yl(t),n=t.updateQueue,n!==null&&_l(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&&_e(Ua),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),_a(ka),yl(t),null;case 25:return null;case 30:return t.flags|=33554432,yl(t),null}throw Error(i(156,t.tag))}function xl(e,t){switch(Qi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return _a(ka),Ce(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Te(t),null;case 31:if(t.memoizedState!==null){if(Fo(t),t.alternate===null)throw Error(i(340));ua()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Fo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));ua()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Ro(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return Ce(),null;case 10:return _a(t.type),null;case 22:case 23:return Fo(t),Oo(),e!==null&&_e(Ua),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return _a(ka),null;case 25:return null;default:return null}}function Sl(e,t){switch(Qi(t),t.tag){case 3:_a(ka),Ce();break;case 26:case 27:case 5:Te(t);break;case 4:Ce();break;case 31:t.memoizedState!==null&&Fo(t);break;case 13:Fo(t);break;case 19:Ro(t);break;case 10:_a(t.type);break;case 22:case 23:Fo(t),Oo(),e!==null&&_e(Ua);break;case 24:_a(ka)}}function Cl(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){Sf(t,t.return,e)}}function wl(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){Sf(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Sf(t,t.return,e)}}function Tl(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Co(t,n)}catch(t){Sf(e,e.return,t)}}}function El(e,t,n){n.props=Cc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Sf(e,t,n)}}function Dl(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:var i=e.stateNode,a=hi(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Gp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Kp(e);f(e.child,!1,lm,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Sf(e,t,n)}}function Ol(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Sf(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){Sf(e,t,n)}else n.current=null}}function kl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n<t.length;n++)dm(e.stateNode,t[n])}function Al(e){for(var t=e.return;t!==null&&(Nl(t)&&dm(e.stateNode,t.stateNode),!Ml(t));)t=t.return}function jl(e){for(var t=e.return;t!==null&&(Nl(t)&&fm(e.stateNode,t.stateNode),!Ml(t));)t=t.return}function Ml(e){return e.tag===5||e.tag===3||e.tag===27}function Nl(e){return e&&e.tag===7&&e.stateNode!==null}function Pl(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){Sf(e,e.return,t)}}function Fl(e,t,n){try{var r=e.stateNode;hp(r,e.type,n,t),r[xt]=t}catch(t){Sf(e,e.return,t)}}function Il(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Np(e.type)||e.tag===4}function Ll(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Il(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&&Np(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 Rl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(i,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(i),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=V)),kl(e,r),Wt=!0;else if(i!==4&&(i===27&&(kl(e,r),r=null,Np(e.type)&&(n=e.stateNode,t=null)),e=e.child,e!==null))for(Rl(e,t,n,r),e=e.sibling;e!==null;)Rl(e,t,n,r),e=e.sibling}function zl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?n.insertBefore(i,t):n.appendChild(i),kl(e,r),Wt=!0;else if(i!==4&&(i===27&&(kl(e,r),r=null,Np(e.type)&&(n=e.stateNode)),e=e.child,e!==null))for(zl(e,t,n,r),e=e.sibling;e!==null;)zl(e,t,n,r),e=e.sibling}function Bl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);pp(t,r,n),t[bt]=e,t[xt]=n}catch(t){Sf(e,e.return,t)}}var Vl=!1,Hl=null;function Ul(e){(e.tag===30||e.subtreeFlags&33554432)&&(Vl=!0)}var Wl=null;function Gl(){var e=Wl;return Wl=null,e}var Kl=0;function ql(e,t,n,r,i){return Kl=0,Jl(e.child,t,n,r,i)}function Jl(e,t,n,r,i){for(var a=!1;e!==null;){if(e.tag===5){var o=e.stateNode;if(r!==null){var s=zp(o);r.push(s),s.view&&(a=!0)}else a||zp(o).view&&(a=!0);Vl=!0,Ip(o,Kl===0?t:t+`_`+Kl,n),Kl++}else(e.tag!==22||e.memoizedState===null)&&(e.tag===30&&i||Jl(e.child,t,n,r,i)&&(a=!0));e=e.sibling}return a}function Yl(e,t){for(;e!==null;)e.tag===5?Lp(e.stateNode,e.memoizedProps):(e.tag!==22||e.memoizedState===null)&&(e.tag===30&&t||Yl(e.child,t)),e=e.sibling}function Xl(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if((e.tag!==22||e.memoizedState===null)&&(Xl(e),e.tag===30&&e.flags&18874368&&e.stateNode.paired)){var t=e.memoizedProps;if(t.name==null||t.name===`auto`)throw Error(i(544));var n=t.name;t=_i(t.default,t.share),t!==`none`&&(ql(e,n,t,null,!1)||Yl(e.child,!1))}e=e.sibling}}function Zl(e,t){if(e.tag===30){var n=e.stateNode,r=e.memoizedProps,i=hi(r,n),a=_i(r.default,n.paired?r.share:r.enter);a===`none`?Xl(e):ql(e,i,a,null,!1)?(Xl(e),n.paired||t||Vd(e,r.onEnter)):Yl(e.child,!1)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Zl(e,t),e=e.sibling;else Xl(e)}function Ql(e){if(Hl!==null&&Hl.size!==0){var t=Hl;if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var n=e.memoizedProps,r=n.name;if(r!=null&&r!==`auto`){var i=t.get(r);if(i!==void 0){var a=_i(n.default,n.share);if(a!==`none`&&(ql(e,r,a,null,!1)?(a=e.stateNode,i.paired=a,a.paired=i,Vd(e,n.onShare)):Yl(e.child,!1)),t.delete(r),t.size===0)break}}}Ql(e)}e=e.sibling}}}function $l(e){if(e.tag===30){var t=e.memoizedProps,n=hi(t,e.stateNode),r=Hl===null?void 0:Hl.get(n),i=_i(t.default,r===void 0?t.exit:t.share);i!==`none`&&(ql(e,n,i,null,!1)?r===void 0?Vd(e,t.onExit):(i=e.stateNode,r.paired=i,i.paired=r,Hl.delete(n),Vd(e,t.onShare)):Yl(e.child,!1)),Hl!==null&&Ql(e)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)$l(e),e=e.sibling;else Hl!==null&&Ql(e)}function eu(e){for(e=e.child;e!==null;){if(e.tag===30){var t=e.memoizedProps,n=hi(t,e.stateNode);t=_i(t.default,t.update),e.flags&=-5,t!==`none`&&ql(e,n,t,e.memoizedState=[],!1)}else e.subtreeFlags&33554432&&eu(e);e=e.sibling}}function tu(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var t=e.stateNode;t.paired!==null&&(t.paired=null,Yl(e.child,!1))}tu(e)}e=e.sibling}}function nu(e){if(e.tag===30)e.stateNode.paired=null,Yl(e.child,!1),tu(e);else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)nu(e),e=e.sibling;else tu(e)}function ru(e){for(e=e.child;e!==null;)e.tag===30?Yl(e.child,!1):e.subtreeFlags&33554432&&ru(e),e=e.sibling}function iu(e,t,n,r,i,a,o){for(var s=!1;t!==null;){if(t.tag===5){var c=t.stateNode;if(a!==null&&Kl<a.length){var l=a[Kl],u=zp(c);(l.view||u.view)&&(s=!0);var d;if(d=!(e.flags&4)){if(u.clip)d=!0;else{d=l.rect;var f=u.rect;d=d.y!==f.y||d.x!==f.x||d.height!==f.height||d.width!==f.width}}d&&(e.flags|=4),u.abs?u=!l.abs:(l=l.rect,u=u.rect,u=l.height!==u.height||l.width!==u.width),u&&(e.flags|=32)}else e.flags|=32;e.flags&4&&Ip(c,Kl===0?n:n+`_`+Kl,i),s&&e.flags&4||(Wl===null&&(Wl=[]),Wl.push(c,Kl===0?r:r+`_`+Kl,t.memoizedProps)),Kl++}else(t.tag!==22||t.memoizedState===null)&&(t.tag===30&&o?e.flags|=t.flags&32:iu(e,t.child,n,r,i,a,o)&&(s=!0));t=t.sibling}return s}function au(e,t){for(e=e.child;e!==null;){if(e.tag===30){var n=e.memoizedProps,r=e.stateNode,i=hi(n,r),a=_i(n.default,n.update);if(t){r=r.clones;var o=r===null?null:r.map(Bp)}else o=e.memoizedState,e.memoizedState=null;r=e;var s=e.child;Kl=0,i=iu(r,s,i,i,a,o,!1),e.flags&4&&i&&(t||Vd(e,n.onUpdate))}else e.subtreeFlags&33554432&&au(e,t);e=e.sibling}}var ou=!1,su=!1,cu=!1,lu=!1,uu=typeof WeakSet==`function`?WeakSet:Set,du=null,fu=!1,pu=!1,mu=!1,hu=!1;function gu(e,t,n){if(e=e.containerInfo,vp=Dh,e=Gr(e),Kr(e)){if(`selectionStart`in e)var r={start:e.selectionStart,end:e.selectionEnd};else a:{r=(r=e.ownerDocument)&&r.defaultView||window;var i=r.getSelection&&r.getSelection();if(i&&i.rangeCount!==0){r=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==r||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===r&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}r=c===-1||l===-1?null:{start:c,end:l}}else r=null}r||={start:0,end:0}}else r=null;for(yp={focusedElem:e,selectionRange:r},Dh=!1,n=(n&335544064)===n,du=t,t=n?9270:1024;du!==null;){if(e=du,n&&(r=e.deletions,r!==null))for(a=0;a<r.length;a++)n&&$l(r[a]);if(e.alternate===null&&e.flags&2)n&&Ul(e),_u(n);else{if(e.tag===22){if(r=e.alternate,e.memoizedState!==null){r!==null&&r.memoizedState===null&&n&&$l(r),_u(n);continue}if(r!==null&&r.memoizedState!==null){n&&Ul(e),_u(n);continue}}r=e.child,(e.subtreeFlags&t)!==0&&r!==null?(r.return=e,du=r):(n&&eu(e),_u(n))}}Hl=null}function _u(e){for(;du!==null;){var t=du,n=e,r=t.alternate,a=t.flags;switch(t.tag){case 0:case 11:case 15:break;case 1:if(a&1024&&r!==null){n=void 0,a=r.memoizedProps,r=r.memoizedState;var o=t.stateNode;try{var s=Cc(t.type,a);n=o.getSnapshotBeforeUpdate(s,r),o.__reactInternalSnapshotBeforeUpdate=n}catch(e){Sf(t,t.return,e)}}break;case 3:if(a&1024){if(r=t.stateNode.containerInfo,n=r.nodeType,n===9)pm(r);else if(n===1)switch(r.nodeName){case`HEAD`:case`HTML`:case`BODY`:pm(r);break;default:r.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;case 30:n&&r!==null&&(n=hi(r.memoizedProps,r.stateNode),a=t.memoizedProps,a=_i(a.default,a.update),a!==`none`&&ql(r,n,a,r.memoizedState=[],!0));break;default:if(a&1024)throw Error(i(163))}if(r=t.sibling,r!==null){r.return=t.return,du=r;break}du=t.return}}function vu(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Ru(e,n),r&4&&Cl(5,n);break;case 1:if(Ru(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Sf(n,n.return,e)}else{var i=Cc(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Sf(n,n.return,e)}}}r&64&&Tl(n),r&512&&Dl(n,n.return);break;case 3:if(Ru(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{Co(e,t)}catch(e){Sf(n,n.return,e)}}break;case 27:t===null&&r&4&&Bl(n);case 26:case 5:Ru(e,n),t===null&&r&4&&Pl(n),r&512&&Dl(n,n.return);break;case 12:Ru(e,n);break;case 31:Ru(e,n),r&4&&Du(e,n);break;case 13:Ru(e,n),r&4&&Ou(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Ef.bind(null,n),ym(e,n))));break;case 22:if(r=n.memoizedState!==null||ou,!r){var a=t!==null&&t.memoizedState!==null||su;t=ou,i=su,ou=r,(su=a)&&!i?(r=2,n.subtreeFlags&8772&&(r|=1),Bu(e,n,r)):Ru(e,n),ou=t,su=i}break;case 30:Ru(e,n),r&512&&Dl(n,n.return);break;case 7:r&512&&Dl(n,n.return);default:Ru(e,n)}}function yu(e,t){for(e=e.child;e!==null;)bu(e,t),e=e.sibling}function bu(e,t){switch(e.tag){case 5:case 26:try{var n=e.stateNode;if(t){var r=n.style;typeof r.setProperty==`function`?r.setProperty(`display`,`none`,`important`):r.display=`none`}else{var i=e.stateNode,a=e.memoizedProps.style,o=a!=null&&a.hasOwnProperty(`display`)?a.display:null;i.style.display=o==null||typeof o==`boolean`?``:(``+o).trim()}}catch(t){Sf(e,e.return,t)}xu(e,t);break;case 6:try{e.stateNode.nodeValue=t?``:e.memoizedProps,Wt=!0}catch(t){Sf(e,e.return,t)}break;case 18:try{var s=e.stateNode;t?Fp(s,!0):Fp(e.stateNode,!1)}catch(t){Sf(e,e.return,t)}break;case 22:case 23:e.memoizedState===null&&yu(e,t);break;default:yu(e,t)}}function xu(e,t){if(e.subtreeFlags&67108864)for(e=e.child;e!==null;){a:{var n=e,r=t;switch(n.tag){case 4:bu(n,r);break a;case 22:n.memoizedState===null&&xu(n,r);break a;default:xu(n,r)}}e=e.sibling}}function Su(e){var t=e.alternate;t!==null&&(e.alternate=null,Su(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&kt(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 Cu=null,wu=!1;function Tu(e,t,n){for(n=n.child;n!==null;)Eu(e,t,n),n=n.sibling}function Eu(e,t,n){if(Je&&typeof Je.onCommitFiberUnmount==`function`)try{Je.onCommitFiberUnmount(qe,n)}catch{}switch(n.tag){case 26:su||Ol(n,t),Tu(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&!su&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:su||Ol(n,t),jl(n);var r=Cu,i=wu;Np(n.type)&&(Cu=n.stateNode,wu=!1),Tu(e,t,n),Dm(n.stateNode,n.type,n.memoizedProps),Cu=r,wu=i;break;case 5:su||Ol(n,t),jl(n);case 6:if(n.tag===6&&jl(n),r=Cu,i=wu,Cu=null,Tu(e,t,n),Cu=r,wu=i,Cu!==null){if(wu)try{(Cu.nodeType===9?Cu.body:Cu.nodeName===`HTML`?Cu.ownerDocument.body:Cu).removeChild(n.stateNode),Wt=!0}catch(e){Sf(n,t,e)}else try{Cu.removeChild(n.stateNode),Wt=!0}catch(e){Sf(n,t,e)}}break;case 18:Cu!==null&&(wu?(e=Cu,Pp(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),$h(e)):Pp(Cu,n.stateNode));break;case 4:r=Cu,i=wu,Cu=n.stateNode.containerInfo,wu=!0,Tu(e,t,n),Cu=r,wu=i;break;case 0:case 11:case 14:case 15:wl(2,n,t),su||wl(4,n,t),Tu(e,t,n);break;case 1:su||(Ol(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&El(n,t,r)),Tu(e,t,n);break;case 21:Tu(e,t,n);break;case 22:su=(r=su)||n.memoizedState!==null,Tu(e,t,n),su=r;break;case 30:Ol(n,t),Tu(e,t,n);break;case 7:su||Ol(n,t),Tu(e,t,n);break;default:Tu(e,t,n)}}function Du(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{$h(e)}catch(e){Sf(t,t.return,e)}}}function Ou(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{$h(e)}catch(e){Sf(t,t.return,e)}}function ku(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new uu),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new uu),t;default:throw Error(i(435,e.tag))}}function Au(e,t){var n=ku(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Df.bind(null,e,t);t.then(r,r)}})}function ju(e,t,n){var r=t.deletions;if(r!==null)for(var a=0;a<r.length;a++){var o=r[a],s=e,c=t,l=c;a:for(;l!==null;){switch(l.tag){case 27:if(Np(l.type)){Cu=l.stateNode,wu=!1;break a}break;case 5:Cu=l.stateNode,wu=!1;break a;case 3:case 4:Cu=l.stateNode.containerInfo,wu=!0;break a}l=l.return}if(Cu===null)throw Error(i(160));Eu(s,c,o),Cu=null,wu=!1,s=o.alternate,s!==null&&(s.return=null),o.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Nu(t,e,n),t=t.sibling}var Mu=null;function Nu(e,t,n){var r=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(a&4&&(r=e.updateQueue,r=r===null?null:r.events,r!==null))for(var o=0;o<r.length;o++){var s=r[o];s.ref.impl=s.nextImpl}ju(t,e,n),Pu(e),a&4&&(wl(3,e,e.return),Cl(3,e),wl(5,e,e.return));break;case 1:ju(t,e,n),Pu(e),a&512&&(su||r===null||Ol(r,r.return)),a&64&&ou&&(e=e.updateQueue,e!==null&&(t=e.callbacks,t!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?t:n.concat(t))));break;case 26:if(o=Mu,ju(t,e,n),Pu(e),a&512&&(su||r===null||Ol(r,r.return)),a&4){if(a=r===null?null:r.memoizedState,n=e.memoizedState,r===null){if(n===null){if(e.stateNode===null){if(ou)e.stateNode=Cp(e.type,e.memoizedProps,t.containerInfo,e);else{a:{t=e.type,n=e.memoizedProps,a=o.ownerDocument||o;b:switch(t){case`title`:r=a.getElementsByTagName(`title`)[0],(!r||r[Dt]||r[bt]||r.namespaceURI===`http://www.w3.org/2000/svg`||r.hasAttribute(`itemprop`))&&(r=a.createElement(t),a.head.insertBefore(r,a.querySelector(`head > title`))),pp(r,t,n),r[bt]=e,Pt(r),t=r;break a;case`link`:if(o=nh(`link`,`href`,a).get(t+(n.href||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&r.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&r.getAttribute(`title`)===(n.title==null?null:n.title)&&r.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){o.splice(s,1);break b}}r=a.createElement(t),pp(r,t,n),a.head.appendChild(r);break;case`meta`:if(o=nh(`meta`,`content`,a).get(t+(n.content||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`content`)===(n.content==null?null:``+n.content)&&r.getAttribute(`name`)===(n.name==null?null:n.name)&&r.getAttribute(`property`)===(n.property==null?null:n.property)&&r.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&r.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){o.splice(s,1);break b}}r=a.createElement(t),pp(r,t,n),a.head.appendChild(r);break;default:throw Error(i(468,t))}r[bt]=e,Pt(r),t=r}e.stateNode=t}}else ou||rh(o,e.type,e.stateNode)}else e.stateNode=Zm(o,n,e.memoizedProps)}else a===n?n===null&&e.stateNode!==null&&Fl(e,e.memoizedProps,r.memoizedProps):(a===null?(t=r.stateNode,t===null||su||t.parentNode.removeChild(t)):a.count--,n===null?ou||rh(o,e.type,e.stateNode):Zm(o,n,e.memoizedProps))}break;case 27:ju(t,e,n),Pu(e),a&512&&(su||r===null||Ol(r,r.return)),r!==null&&a&4&&Fl(e,e.memoizedProps,r.memoizedProps);break;case 5:if(o=cu,cu=!1,ju(t,e,n),cu=o,Pu(e),a&512&&(su||r===null||Ol(r,r.return)),e.flags&32){t=e.stateNode;try{ln(t,``),Wt=!0}catch(t){Sf(e,e.return,t)}}a&4&&e.stateNode!=null&&(t=e.memoizedProps,Fl(e,t,r===null?t:r.memoizedProps)),a&1024&&(lu=!0);break;case 6:if(ju(t,e,n),Pu(e),a&4){if(e.stateNode===null)throw Error(i(162));t=e.memoizedProps,n=e.stateNode;try{n.nodeValue=t,Wt=!0}catch(t){Sf(e,e.return,t)}}break;case 3:if(Wt=!1,th=null,o=Mu,Mu=jm(t.containerInfo),ju(t,e,n),Mu=o,Pu(e),a&4&&r!==null&&r.memoizedState.isDehydrated)try{$h(t.containerInfo)}catch(t){Sf(e,e.return,t)}lu&&(lu=!1,Fu(e)),Wt=!1;break;case 4:a=cu,cu=ou,r=Gt(),o=Mu,Mu=jm(e.stateNode.containerInfo),ju(t,e,n),Pu(e),Mu=o,Wt&&pu&&(mu=!0),Wt=r,cu=a;break;case 12:ju(t,e,n),Pu(e);break;case 31:ju(t,e,n),Pu(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Au(e,t)));break;case 13:ju(t,e,n),Pu(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(Sd=Re()),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Au(e,t)));break;case 22:o=e.memoizedState!==null,s=r!==null&&r.memoizedState!==null;var c=ou,l=su,u=cu;ou=c||o,cu=u||o,su=l||s,ju(t,e,n),su=l,cu=u,ou=c,Pu(e),a&8192&&(t=e.stateNode,t._visibility=o?t._visibility&-2:t._visibility|1,!o||r===null||s||ou||su||(t=s||su,n=ou,r=su,ou=o||ou,su=t,zu(e,2),ou=n,su=r),!o&&cu||yu(e,o)),a&4&&(t=e.updateQueue,t!==null&&(n=t.retryQueue,n!==null&&(t.retryQueue=null,Au(e,n))));break;case 19:ju(t,e,n),Pu(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Au(e,t)));break;case 30:a&512&&(su||r===null||Ol(r,r.return)),a=Gt(),o=pu,s=(n&335544064)===n,c=e.memoizedProps,pu=s&&_i(c.default,c.update)!==`none`,ju(t,e,n),Pu(e),s&&r!==null&&Wt&&(e.flags|=4),pu=o,Wt=a;break;case 21:break;case 7:a&512&&(su||r===null||Ol(r,r.return)),r&&r.stateNode!==null&&(r.stateNode._fragmentFiber=e);default:ju(t,e,n),Pu(e)}}function Pu(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Il(r)){n=r;break}r=r.return}r=null;for(var a=e.return;a!==null;){if(Nl(a)){var o=a.stateNode;r===null?r=[o]:r.push(o)}if(Ml(a))break;a=a.return}var s=r;if(n==null)throw Error(i(160));switch(n.tag){case 27:var c=n.stateNode;zl(e,Ll(e),c,s);break;case 5:var l=n.stateNode;n.flags&32&&(ln(l,``),n.flags&=-33),zl(e,Ll(e),l,s);break;case 3:case 4:var u=n.stateNode.containerInfo;Rl(e,Ll(e),u,s);break;default:throw Error(i(161))}}catch(t){Sf(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Fu(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Fu(t),t.tag===5&&t.flags&1024&&(t=t.stateNode,Dh=!0,t.reset(),Dh=!1),e=e.sibling}}function Iu(e,t){if(t.subtreeFlags&9270)for(t=t.child;t!==null;)Lu(t,e),t=t.sibling;else au(t,!1)}function Lu(e,t){var n=e.alternate;if(n===null)Zl(e,!1);else switch(e.tag){case 3:if(hu=fu=!1,Gl(),Iu(t,e),!fu&&!mu){if(e=Wl,e!==null)for(var r=0;r<e.length;r+=3){n=e[r];var i=e[r+1];Lp(n,e[r+2]),n=n.ownerDocument.documentElement,n!==null&&n.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(`+i+`)`})}e=t.containerInfo,e=e.nodeType===9?e.documentElement:e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===``&&(e.style.viewTransitionName=`none`,e.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(root)`}),e.animate({width:[0,0],height:[0,0]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition`})),hu=!0}Wl=null;break;case 5:Iu(t,e);break;case 4:r=fu,fu=!1,Iu(t,e),fu&&(mu=!0),fu=r;break;case 22:e.memoizedState===null&&(n.memoizedState===null?Iu(t,e):Zl(e,!1));break;case 30:r=fu,i=Gl(),fu=!1,Iu(t,e),fu&&(e.flags|=4);var a=e.memoizedProps,o=e.stateNode;t=hi(a,o),o=hi(n.memoizedProps,o);var s=_i(a.default,a.update);s===`none`?t=!1:(a=n.memoizedState,n.memoizedState=null,n=e.child,Kl=0,t=iu(e,n,t,o,s,a,!0),Kl!==(a===null?0:a.length)&&(e.flags|=32)),e.flags&4&&t?(Vd(e,e.memoizedProps.onUpdate),Wl=i):i!==null&&(i.push.apply(i,Wl),Wl=i),fu=e.flags&32?!0:r;break;default:Iu(t,e)}}function Ru(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)vu(e,t.alternate,t),t=t.sibling}function zu(e,t){for(e=e.child;e!==null;){var n=e,r=t;switch(n.tag){case 0:case 11:case 14:case 15:wl(4,n,n.return),zu(n,r);break;case 1:Ol(n,n.return);var i=n.stateNode;typeof i.componentWillUnmount==`function`&&El(n,n.return,i),zu(n,r);break;case 27:r&2&&Dm(n.stateNode,n.type,n.memoizedProps);case 5:Ol(n,n.return),n.tag!==5&&n.tag!==27||jl(n),zu(n,r);break;case 6:jl(n);break;case 26:Ol(n,n.return),i=n.stateNode,n.memoizedState!==null||i===null||su||i.parentNode.removeChild(i),zu(n,r);break;case 22:n.memoizedState===null&&zu(n,r);break;case 30:Ol(n,n.return),zu(n,r);break;case 7:Ol(n,n.return);default:zu(n,r)}e=e.sibling}}function Bu(e,t,n){for(n=t.subtreeFlags&8772?n:n&-2,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags,s=!!(n&1);switch(a.tag){case 0:case 11:case 15:Bu(i,a,n),Cl(4,a);break;case 1:if(Bu(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Sf(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var c=r.stateNode;try{var l=i.shared.hiddenCallbacks;if(l!==null)for(i.shared.hiddenCallbacks=null,i=0;i<l.length;i++)So(l[i],c)}catch(e){Sf(r,r.return,e)}}s&&o&64&&Tl(a),Dl(a,a.return);break;case 27:n&2&&Bl(a);case 5:a.tag!==5&&a.tag!==27||Al(a),Bu(i,a,n),s&&r===null&&o&4&&Pl(a),Dl(a,a.return);break;case 6:Al(a);break;case 26:c=a.stateNode,a.memoizedState!==null||c===null||ou||rh(jm(c.ownerDocument),a.type,c),Bu(i,a,n),s&&r===null&&o&4&&Pl(a),Dl(a,a.return);break;case 12:Bu(i,a,n);break;case 31:Bu(i,a,n),s&&o&4&&Du(i,a);break;case 13:Bu(i,a,n),s&&o&4&&Ou(i,a);break;case 22:a.memoizedState===null&&Bu(i,a,n),Dl(a,a.return);break;case 30:Bu(i,a,n),Dl(a,a.return);break;case 7:Dl(a,a.return);default:Bu(i,a,n)}t=t.sibling}}function Vu(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&&ja(n))}function Hu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ja(e))}function Uu(e,t,n,r){var i=(n&335544064)===n;if(t.subtreeFlags&(i?10262:10256))for(t=t.child;t!==null;)Wu(e,t,n,r),t=t.sibling;else i&&ru(t)}function Wu(e,t,n,r){var i=(n&335544064)===n;i&&t.alternate===null&&t.return!==null&&t.return.alternate!==null&&nu(t);var a=t.flags;switch(t.tag){case 0:case 11:case 15:Uu(e,t,n,r),a&2048&&Cl(9,t);break;case 1:Uu(e,t,n,r);break;case 3:Uu(e,t,n,r),i&&hu&&(e=e.containerInfo,e=e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,e.style.viewTransitionName===`root`&&(e.style.viewTransitionName=``),e=e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===`none`&&(e.style.viewTransitionName=``)),a&2048&&(a=null,t.alternate!==null&&(a=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==a&&(t.refCount++,a!=null&&ja(a)));break;case 12:if(a&2048){Uu(e,t,n,r),a=t.stateNode;try{var o=t.memoizedProps,s=o.id,c=o.onPostCommit;typeof c==`function`&&c(s,t.alternate===null?`mount`:`update`,a.passiveEffectDuration,-0)}catch(e){Sf(t,t.return,e)}}else Uu(e,t,n,r);break;case 31:Uu(e,t,n,r);break;case 13:Uu(e,t,n,r);break;case 23:break;case 22:o=t.stateNode,s=t.alternate,t.memoizedState===null?(i&&s!==null&&s.memoizedState!==null&&nu(t),o._visibility&2?Uu(e,t,n,r):(o._visibility|=2,Gu(e,t,n,r,!!(t.subtreeFlags&10256)||!1))):(i&&s!==null&&s.memoizedState===null&&nu(s),o._visibility&2?Uu(e,t,n,r):Ku(e,t)),a&2048&&Vu(s,t);break;case 24:Uu(e,t,n,r),a&2048&&Hu(t.alternate,t);break;case 30:i&&(a=t.alternate,a!==null&&(Yl(a.child,!0),Yl(t.child,!0))),Uu(e,t,n,r);break;default:Uu(e,t,n,r)}}function Gu(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!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:Gu(a,o,s,c,i),Cl(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Gu(a,o,s,c,i)):u._visibility&2?Gu(a,o,s,c,i):Ku(a,o),i&&l&2048&&Vu(o.alternate,o);break;case 24:Gu(a,o,s,c,i),i&&l&2048&&Hu(o.alternate,o);break;default:Gu(a,o,s,c,i)}t=t.sibling}}function Ku(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:Ku(n,r),i&2048&&Vu(r.alternate,r);break;case 24:Ku(n,r),i&2048&&Hu(r.alternate,r);break;default:Ku(n,r)}t=t.sibling}}var qu=8192;function Ju(e,t,n){if(e.subtreeFlags&qu)for(e=e.child;e!==null;)Yu(e,t,n),e=e.sibling}function Yu(e,t,n){switch(e.tag){case 26:Ju(e,t,n),e.flags&qu&&(e.memoizedState===null?(e=e.stateNode,(t&335544128)===t&&ch(n,e)):lh(n,Mu,e.memoizedState,e.memoizedProps));break;case 5:Ju(e,t,n),e.flags&qu&&(e=e.stateNode,(t&335544128)===t&&ch(n,e));break;case 3:case 4:var r=Mu;Mu=jm(e.stateNode.containerInfo),Ju(e,t,n),Mu=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=qu,qu=16777216,Ju(e,t,n),qu=r):Ju(e,t,n));break;case 30:if((e.flags&qu)!==0&&(r=e.memoizedProps.name,r!=null&&r!==`auto`)){var i=e.stateNode;i.paired=null,Hl===null&&(Hl=new Map),Hl.set(r,i)}Ju(e,t,n);break;default:Ju(e,t,n)}}function Xu(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 Zu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];du=r,ed(r,e)}Xu(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Qu(e),e=e.sibling}function Qu(e){switch(e.tag){case 0:case 11:case 15:Zu(e),e.flags&2048&&wl(9,e,e.return);break;case 3:Zu(e);break;case 12:Zu(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,$u(e)):Zu(e);break;default:Zu(e)}}function $u(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];du=r,ed(r,e)}Xu(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:wl(8,t,t.return),$u(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,$u(t));break;default:$u(t)}e=e.sibling}}function ed(e,t){for(;du!==null;){var n=du;switch(n.tag){case 0:case 11:case 15:wl(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:ja(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,du=r;else a:for(n=e;du!==null;){r=du;var i=r.sibling,a=r.return;if(Su(r),r===n){du=null;break a}if(i!==null){i.return=a,du=i;break a}du=a}}}var td={getCacheForType:function(e){var t=Ca(ka),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Ca(ka).controller.signal}},nd=typeof WeakMap==`function`?WeakMap:Map,rd=0,id=null,ad=null,od=0,sd=0,cd=null,ld=!1,ud=!1,dd=!1,fd=0,pd=0,md=0,hd=0,gd=0,_d=0,vd=0,yd=null,bd=null,xd=!1,Sd=0,Cd=0,wd=1/0,Td=null,Ed=null,Dd=0,Od=null,kd=null,Ad=0,jd=0,Md=null,Nd=null,Pd=null,Fd=null,Id=null,Ld=0,Rd=null;function zd(){return rd&2&&od!==0?od&-od:z.T===null?_t():Uf()}function Bd(){if(_d===0){if(!(od&536870912)||na){var e=tt;tt<<=1,!(tt&3932160)&&(tt=262144),_d=e}else _d=536870912}return e=ko.current,e!==null&&(e.flags|=32),_d}function Vd(e,t){if(t!=null){var n=e.stateNode,r=n.ref;r===null&&(r=n.ref=Gp(hi(e.memoizedProps,n))),Fd===null&&(Fd=[]),Fd.push(t.bind(null,r))}}function Hd(e,t,n){(e===id&&(sd===2||sd===9)||e.cancelPendingCommit!==null)&&(Yd(e,0),Kd(e,od,_d,!1)),ut(e,n),(!(rd&2)||e!==id)&&(e===id&&(!(rd&2)&&(hd|=n),pd===4&&Kd(e,od,_d,!1)),Ff(e))}function Ud(e,t,n){if(rd&6)throw Error(i(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||at(e,t),a=r?rf(e,t):tf(e,t,!0),o=r;do{if(a===0){ud&&!r&&Kd(e,t,0,!1);break}if(n=e.current.alternate,o&&!Gd(n))a=tf(e,t,!1),o=!1;else{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=yd;var l=c.current.memoizedState.isDehydrated;if(l&&(Yd(c,s).flags|=256),s=tf(c,s,!1),s!==2&&s!==6){if(dd&&!l){c.errorRecoveryDisabledLanes|=o,hd|=o,a=4;break a}o=bd,bd=a,o!==null&&(bd===null?bd=o:bd.push.apply(bd,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){Yd(e,0),Kd(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&&(t&62914560)!==t)break;case 6:Kd(r,t,_d,!ld);break a;case 2:bd=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=Sd+300-Re(),10<a)){if(Kd(r,t,_d,!ld),it(r,0,!0)!==0)break a;Ad=t,r.timeoutHandle=Dp(Wd.bind(null,r,n,bd,Td,xd,t,_d,hd,vd,ld,o,`Throttled`,-0,0),a);break a}Wd(r,n,bd,Td,xd,t,_d,hd,vd,ld,o,null,-0,0)}break}}while(1);Ff(e)}function Wd(e,t,n,r,i,a,o,s,c,l,u,d,f,p){e.timeoutHandle=-1;var m=t.subtreeFlags,h=(a&335544064)===a;d=null,(h||m&8192||(m&16785408)==16785408)&&(d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:V},Hl=null,Yu(t,a,d),h&&(m=d,h=e.containerInfo,h=(h.nodeType===9?h:h.ownerDocument).__reactViewTransition,h!=null&&(m.count++,m.waitingForViewTransition=!0,m=ph.bind(m),h.finished.then(m,m))),m=(a&62914560)===a?Sd-Re():(a&4194048)===a?Cd-Re():0,m=dh(d,m),m!==null)?(Ad=a,e.cancelPendingCommit=m(df.bind(null,e,t,a,n,r,i,o,s,c,l,u,d,null,f,p)),Kd(e,a,o,!l)):df(e,t,a,n,r,i,o,s,c,l,u,d)}function Gd(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(!zr(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 Kd(e,t,n,r){t=ot(e,t),t&=~gd,t&=~hd,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Xe(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&ft(e,n,t)}function qd(){return rd&6?!0:(If(0,!1),!1)}function Jd(){if(ad!==null){if(sd===0)var e=ad.return;else e=ad,ha=ma=null,as(e),ro=null,io=0,e=ad;for(;e!==null;)Sl(e.alternate,e),e=e.return;ad=null}}function Yd(e,t){var n=e.timeoutHandle;return n!==-1&&(e.timeoutHandle=-1,Op(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Ad=0,Jd(),id=e,ad=n=ji(e.current,null),od=t,sd=0,cd=null,ld=!1,ud=at(e,t),dd=!1,vd=_d=gd=hd=md=pd=0,bd=yd=null,xd=!1,fd=ot(e,t),Si(),n}function Xd(e,t){Vo=null,z.H=hc,t===qa||t===Ya?(t=to(),sd=3):t===Ja?(t=to(),sd=4):sd=t===Nc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,cd=t,ad===null&&(pd=1,Dc(e,zi(t,e.current)))}function Zd(){var e=ko.current;return e===null?!0:(od&4194048)===od?Ao===null:(od&62914560)===od||od&536870912?e===Ao:!1}function Qd(){var e=z.H;return z.H=hc,e===null?hc:e}function $d(){var e=z.A;return z.A=td,e}function ef(){pd=4,ld||(od&4194048)!==od&&ko.current!==null||(ud=!0),!(md&134217727)&&!(hd&134217727)||id===null||Kd(id,od,_d,!1)}function tf(e,t,n){var r=rd;rd|=2;var i=Qd(),a=$d();(id!==e||od!==t)&&(Td=null,Yd(e,t)),t=!1;var o=pd;a:do try{if(sd!==0&&ad!==null){var s=ad,c=cd;switch(sd){case 8:Jd(),o=6;break a;case 3:case 2:case 9:case 6:ko.current===null&&(t=!0);var l=sd;if(sd=0,cd=null,cf(e,s,c,l),n&&ud){o=0;break a}break;default:l=sd,sd=0,cd=null,cf(e,s,c,l)}}nf(),o=pd;break}catch(t){Xd(e,t)}while(1);return t&&e.shellSuspendCounter++,ha=ma=null,rd=r,z.H=i,z.A=a,ad===null&&(id=null,od=0,Si()),o}function nf(){for(;ad!==null;)of(ad)}function rf(e,t){var n=rd;rd|=2;var r=Qd(),a=$d();id!==e||od!==t?(Td=null,wd=Re()+500,Yd(e,t)):ud=at(e,t);a:do try{if(sd!==0&&ad!==null){t=ad;var o=cd;b:switch(sd){case 1:sd=0,cd=null,cf(e,t,o,1);break;case 2:case 9:if(Za(o)){sd=0,cd=null,sf(t);break}t=function(){sd!==2&&sd!==9||id!==e||(sd=7),Ff(e)},o.then(t,t);break a;case 3:sd=7;break a;case 4:sd=5;break a;case 7:Za(o)?(sd=0,cd=null,sf(t)):(sd=0,cd=null,cf(e,t,o,7));break;case 5:var s=null;switch(ad.tag){case 26:s=ad.memoizedState;case 5:case 27:var c=ad;if(s?oh(s):c.stateNode.complete){sd=0,cd=null;var l=c.sibling;if(l!==null)ad=l;else{var u=c.return;u===null?ad=null:(ad=u,lf(u))}break b}}sd=0,cd=null,cf(e,t,o,5);break;case 6:sd=0,cd=null,cf(e,t,o,6);break;case 8:Jd(),pd=6;break a;default:throw Error(i(462))}}af();break}catch(t){Xd(e,t)}while(1);return ha=ma=null,z.H=r,z.A=a,rd=n,ad===null?(id=null,od=0,Si(),pd):0}function af(){for(;ad!==null&&!Ie();)of(ad)}function of(e){var t=pl(e.alternate,e,fd);e.memoizedProps=e.pendingProps,t===null?lf(e):ad=t}function sf(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=qc(n,t,t.pendingProps,t.type,void 0,od);break;case 11:t=qc(n,t,t.pendingProps,t.type.render,t.ref,od);break;case 5:as(t);var r=t;r===ea&&(na?(ca(r),r.tag===5&&r.stateNode!=null&&(ta=r.stateNode)):(ca(r),na=!0));default:Sl(n,t),t=ad=Mi(t,fd),t=pl(n,t,fd)}e.memoizedProps=e.pendingProps,t===null?lf(e):ad=t}function cf(e,t,n,r){ha=ma=null,as(t),ro=null,io=0;var i=t.return;try{if(Mc(e,i,t,n,od)){pd=1,Dc(e,zi(n,e.current)),ad=null;return}}catch(t){if(i!==null)throw ad=i,t;pd=1,Dc(e,zi(n,e.current)),ad=null;return}t.flags&32768?(na||r===1?e=!0:ud||od&536870912?e=!1:(ld=e=!0,(r===2||r===9||r===3||r===6)&&(r=ko.current,r!==null&&r.tag===13&&(r.flags|=16384))),uf(t,e)):lf(t)}function lf(e){var t=e;do{if(t.flags&32768){uf(t,ld);return}e=t.return;var n=bl(t.alternate,t,fd);if(n!==null){ad=n;return}if(t=t.sibling,t!==null){ad=t;return}ad=t=e}while(t!==null);pd===0&&(pd=5)}function uf(e,t){do{var n=xl(e.alternate,e);if(n!==null){n.flags&=32767,ad=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){ad=e;return}ad=e=n}while(e!==null);pd=6,ad=null}function df(e,t,n,r,a,o,s,c,l,u,d,f){e.cancelPendingCommit=null;do yf();while(Dd!==0);if(rd&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));e===id&&(ad=id=null,od=0),kd=t,Od=e,Ad=n,Md=a,Nd=r,ff(e,t,n,s,c,l,f)}}function ff(e,t,n,r,i,a,o){var s=t.lanes|t.childLanes;if(jd=s,s|=xi,dt(e,n,s,r,i,a),Fd=null,(n&335544064)===n?(Id=Pa(e),r=10262):(Id=null,r=10256),(t.subtreeFlags&r)!==0||(t.flags&r)!==0?(e.callbackNode=null,e.callbackPriority=0,Of(He,function(){return bf(),null})):(e.callbackNode=null,e.callbackPriority=0),Vl=!1,r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=z.T,z.T=null,i=fe.p,fe.p=2,a=rd,rd|=4;try{gu(e,t,n)}finally{rd=a,fe.p=i,z.T=r}}Dd=1,Vl?Pd=Up(o,e.containerInfo,Id,hf,gf,mf,_f,bf,pf,null,null):(hf(),gf(),_f())}function pf(e){if(Dd!==0){var t=Od.onRecoverableError;t(e,{componentStack:null})}}function mf(){Dd===3&&(Dd=0,Lu(kd,Od),Dd=4)}function hf(){if(Dd===1){Dd=0;var e=Od,t=kd,n=Ad,r=!!(t.flags&13878);if(t.subtreeFlags&13878||r){r=z.T,z.T=null;var i=fe.p;fe.p=2;var a=rd;rd|=4;try{pu=mu=!1,Nu(t,e,n),n=yp;var o=Gr(e.containerInfo),s=n.focusedElem,c=n.selectionRange;if(o!==s&&s&&s.ownerDocument&&Wr(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 _=Ur(s,h),v=Ur(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}}Dh=!!vp,yp=vp=null}finally{rd=a,fe.p=i,z.T=r}}e.current=t,Dd=2}}function gf(){if(Dd===2){Dd=0;var e=Od,t=kd,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=z.T,z.T=null;var r=fe.p;fe.p=2;var i=rd;rd|=4;try{vu(e,t.alternate,t)}finally{rd=i,fe.p=r,z.T=n}}Dd=3}}function _f(){if(Dd===4||Dd===3){Dd=0;var e=Pd;Pd=null,Le();var t=Od,n=kd,r=Ad,i=Nd,a=(r&335544064)===r?10262:10256;if((n.subtreeFlags&a)!==0||(n.flags&a)!==0?Dd=5:(Dd=0,kd=Od=null,vf(t,t.pendingLanes)),a=t.pendingLanes,a===0&&(Ed=null),gt(r),n=n.stateNode,Je&&typeof Je.onCommitFiberRoot==`function`)try{Je.onCommitFiberRoot(qe,n,void 0,(n.current.flags&128)==128)}catch{}if(i!==null){n=z.T,a=fe.p,fe.p=2,z.T=null;try{for(var o=t.onRecoverableError,s=0;s<i.length;s++){var c=i[s];o(c.value,{componentStack:c.stack})}}finally{z.T=n,fe.p=a}}if(i=Fd,o=Id,Id=null,i!==null&&(Fd=null,o===null&&(o=[]),e!==null))for(c=0;c<i.length;c++)n=(0,i[c])(o),n!==void 0&&e.finished.finally(n);Ad&3&&yf(),Ff(t),a=t.pendingLanes,r&261930&&a&42?t===Rd?Ld++:(Ld=0,Rd=t):(Ld=0,Rd=null),If(0,!1)}}function vf(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,ja(t)))}function yf(){return Pd!==null&&(Pd.skipTransition(),Pd=null),hf(),gf(),_f(),bf()}function bf(){if(Dd!==5)return!1;var e=Od,t=jd;jd=0;var n=gt(Ad),r=z.T,a=fe.p;try{fe.p=32>n?32:n,z.T=null,n=Md,Md=null;var o=Od,s=Ad;if(Dd=0,kd=Od=null,Ad=0,rd&6)throw Error(i(331));var c=rd;if(rd|=4,Qu(o.current),Wu(o,o.current,s,n),rd=c,If(0,!1),Je&&typeof Je.onPostCommitFiberRoot==`function`)try{Je.onPostCommitFiberRoot(qe,o)}catch{}return!0}finally{fe.p=a,z.T=r,vf(e,t)}}function xf(e,t,n){t=zi(n,t),t=kc(e.stateNode,t,2),e=go(e,t,2),e!==null&&(ut(e,2),Ff(e))}function Sf(e,t,n){if(e.tag===3)xf(e,e,n);else for(;t!==null;){if(t.tag===3){xf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(Ed===null||!Ed.has(r))){e=zi(n,e),n=Ac(2),r=go(t,n,2),r!==null&&(jc(n,r,t,e),ut(r,2),Ff(r));break}}t=t.return}}function Cf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new nd;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)||(dd=!0,i.add(n),e=wf.bind(null,e,t,n),t.then(e,e))}function wf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,id===e&&(od&n)===n&&(pd===4||pd===3&&(od&62914560)===od&&300>Re()-Sd?rd&2?gd|=n:Yd(e,0):gd|=n,vd===od&&(vd=0)),Ff(e)}function Tf(e,t){t===0&&(t=ct()),e=Ti(e,t),e!==null&&(ut(e,t),Ff(e))}function Ef(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Tf(e,n)}function Df(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),Tf(e,n)}function Of(e,t){return Pe(e,t)}var kf=null,Af=null,jf=!1,Mf=!1,Nf=!1,Pf=0;function Ff(e){e!==Af&&e.next===null&&(Af===null?kf=Af=e:Af=Af.next=e),Mf=!0,jf||(jf=!0,Hf())}function If(e,t){if(!Nf&&Mf){Nf=!0;do for(var n=!1,r=kf;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-Xe(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Vf(r,a))}else a=od,a=it(r,r===id?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||at(r,a)||(n=!0,Vf(r,a))}r=r.next}while(n);Nf=!1}}function Lf(){Rf()}function Rf(){Mf=jf=!1;var e=0;Pf!==0&&Ep()&&(e=Pf);for(var t=Re(),n=null,r=kf;r!==null;){var i=r.next,a=zf(r,t);a===0?(r.next=null,n===null?kf=i:n.next=i,i===null&&(Af=n)):(n=r,(e!==0||a&3)&&(Mf=!0)),r=i}Dd!==0&&Dd!==5||If(e,!1),Pf!==0&&(Pf=0)}function zf(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Xe(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=st(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=id,n=od,n=it(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(sd===2||sd===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Fe(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||at(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Fe(r),gt(n)){case 2:case 8:n=Ve;break;case 32:n=He;break;case 268435456:n=We;break;default:n=He}return r=Bf.bind(null,e),n=Pe(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Fe(r),e.callbackPriority=2,e.callbackNode=null,2}function Bf(e,t){if(Dd!==0&&Dd!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(yf()&&e.callbackNode!==n)return null;var r=od;return r=it(e,e===id?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Ud(e,r,t),zf(e,Re()),e.callbackNode!=null&&e.callbackNode===n?Bf.bind(null,e):null)}function Vf(e,t){if(yf())return null;Ud(e,t,!0)}function Hf(){jp(function(){rd&6?Pe(Be,Lf):Rf()})}function Uf(){if(Pf===0){var e=La;e===0&&(e=et,et<<=1,!(et&261888)&&(et=256)),Pf=e}return Pf}function Wf(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:gn(e)}function Gf(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Wf((i[xt]||null).action),o=r.submitter;o&&(t=(t=o[xt]||null)?Wf(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Ln(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(Pf!==0){var e=new FormData(i,o);tc(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=new FormData(i,o),tc(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var Kf=0;Kf<fi.length;Kf++){var qf=fi[Kf];pi(qf.toLowerCase(),`on`+(qf[0].toUpperCase()+qf.slice(1)))}pi(ii,`onAnimationEnd`),pi(ai,`onAnimationIteration`),pi(oi,`onAnimationStart`),pi(`dblclick`,`onDoubleClick`),pi(`focusin`,`onFocus`),pi(`focusout`,`onBlur`),pi(si,`onTransitionRun`),pi(ci,`onTransitionStart`),pi(li,`onTransitionCancel`),pi(ui,`onTransitionEnd`),zt(`onMouseEnter`,[`mouseout`,`mouseover`]),zt(`onMouseLeave`,[`mouseout`,`mouseover`]),zt(`onPointerEnter`,[`pointerout`,`pointerover`]),zt(`onPointerLeave`,[`pointerout`,`pointerover`]),Rt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Rt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Rt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Rt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Rt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Rt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var Jf=`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(` `),Yf=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(Jf));function Xf(e,t){t=!!(t&4);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){vi(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){vi(e)}i.currentTarget=null,a=c}}}}function Zf(e,t){var n=t[Ct];n===void 0&&(n=t[Ct]=new Set);var r=e+`__bubble`;n.has(r)||(tp(t,e,2,!1),n.add(r))}function Qf(e,t,n){var r=0;t&&(r|=4),tp(n,e,r,t)}var $f=`_reactListening`+Math.random().toString(36).slice(2);function ep(e){if(!e[$f]){e[$f]=!0,It.forEach(function(t){t!==`selectionchange`&&(Yf.has(t)||Qf(t,!1,e),Qf(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[$f]||(t[$f]=!0,Qf(`selectionchange`,!1,t))}}function tp(e,t,n,r){switch(Ph(t)){case 2:var i=Oh;break;case 8:i=kh;break;default:i=Ah}n=i.bind(null,t,n,e),i=void 0,!En||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 np(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=At(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}Cn(function(){var r=a,i=vn(n),s=[];a:{var c=di.get(e);if(c!==void 0){var l=Ln,u=e;switch(e){case`keypress`:if(Mn(n)===0)break a;case`keydown`:case`keyup`:l=tr;break;case`focusin`:u=`focus`,l=Kn;break;case`focusout`:u=`blur`,l=Kn;break;case`beforeblur`:case`afterblur`:l=Kn;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=Wn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=Gn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=ir;break;case ii:case ai:case oi:l=qn;break;case ui:l=ar;break;case`scroll`:case`scrollend`:l=zn;break;case`wheel`:l=or;break;case`copy`:case`cut`:case`paste`:l=Jn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=nr;break;case`submit`:l=rr;break;case`toggle`:case`beforetoggle`:l=sr}var d=!!(t&4),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=wn(m,p),g!=null&&d.push(rp(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(l=e===`mouseover`||e===`pointerover`,c=e===`mouseout`||e===`pointerout`,l&&n!==_n&&(u=n.relatedTarget||n.fromElement)&&(At(u)||u[St]))break a;(c||l)&&(u=i.window===i?i:(l=i.ownerDocument)?l.defaultView||l.parentWindow:window,c?(l=n.relatedTarget||n.toElement,c=r,l=l?At(l):null,l!==null&&(f=o(l),d=l.tag,l!==f||d!==5&&d!==27&&d!==6)&&(l=null)):(c=null,l=r),c!==l&&(d=Wn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=nr,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=c==null?u:Mt(c),h=l==null?u:Mt(l),u=new d(g,m+`leave`,c,n,i),u.target=f,u.relatedTarget=h,g=null,At(i)===r&&(d=new d(p,m+`enter`,l,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,d=c&&l?C(c,l,ap):null,c!==null&&op(s,u,c,d,!1),l!==null&&f!==null&&op(s,f,l,d,!0)))}a:{if(c=r?Mt(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var _=Dr;else if(xr(c)){if(Or)_=Lr;else{_=Fr;var v=Pr}}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&pn(r.elementType)&&(_=Dr):_=Ir;if(_&&=_(e,r)){Sr(s,_,n,i);break a}v&&v(e,c,r)}switch(v=r?Mt(r):window,e){case`focusin`:(xr(v)||v.contentEditable===`true`)&&(Jr=v,Yr=r,Xr=null);break;case`focusout`:Xr=Yr=Jr=null;break;case`mousedown`:Zr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Zr=!1,Qr(s,n,i);break;case`selectionchange`:if(qr)break;case`keydown`:case`keyup`:Qr(s,n,i)}var y;if(lr)b:{switch(e){case`compositionstart`:var b=`onCompositionStart`;break b;case`compositionend`:b=`onCompositionEnd`;break b;case`compositionupdate`:b=`onCompositionUpdate`;break b}b=void 0}else _r?hr(e,n)&&(b=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(b=`onCompositionStart`);b&&(fr&&n.locale!==`ko`&&(_r||b!==`onCompositionStart`?b===`onCompositionEnd`&&_r&&(y=jn()):(On=i,kn=`value`in On?On.value:On.textContent,_r=!0)),v=ip(r,b),0<v.length&&(b=new Yn(b,e,null,n,i),s.push({event:b,listeners:v}),y?b.data=y:(y=gr(n),y!==null&&(b.data=y)))),(y=dr?vr(e,n):yr(e,n))&&(b=ip(r,`onBeforeInput`),0<b.length&&(v=new Yn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:v,listeners:b}),v.data=y)),Gf(s,e,r,n,i)}Xf(s,t)})}function rp(e,t,n){return{instance:e,listener:t,currentTarget:n}}function ip(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=wn(e,n),i!=null&&r.unshift(rp(e,i,a)),i=wn(e,t),i!=null&&r.push(rp(e,i,a))),e.tag===3)return r;e=e.return}return[]}function ap(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function op(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=wn(n,a),l!=null&&o.unshift(rp(n,l,c))):i||(l=wn(n,a),l!=null&&o.push(rp(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var sp=/\r\n?/g,cp=/\u0000|\uFFFD/g;function lp(e){return(typeof e==`string`?e:``+e).replace(sp,`
9
- `).replace(cp,``)}function up(e,t){return t=lp(t),lp(e)===t}function dp(e,t,n,r,a,o){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||ln(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&ln(e,``+r);else return;break;case`className`:qt(e,`class`,r);break;case`tabIndex`:qt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:qt(e,n,r);break;case`style`:fn(e,r,o);return;case`data`:if(t!==`object`){qt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=gn(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}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&dp(e,t,`name`,a.name,a,null),dp(e,t,`formEncType`,a.formEncType,a,null),dp(e,t,`formMethod`,a.formMethod,a,null),dp(e,t,`formTarget`,a.formTarget,a,null)):(dp(e,t,`encType`,a.encType,a,null),dp(e,t,`method`,a.method,a,null),dp(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=gn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=V);return;case`onScroll`:r!=null&&Zf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Zf(`scrollend`,e);return;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));o?.__html!==n&&(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=gn(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`credentialless`: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`:Zf(`beforetoggle`,e),Zf(`toggle`,e),Kt(e,`popover`,r);break;case`xlinkActuate`:Jt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Jt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Jt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Jt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Jt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Jt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Jt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Jt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Jt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Kt(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=mn.get(n)||n,Kt(e,n,r);else return}Wt=!0}function fp(e,t,n,r,a,o){switch(n){case`style`:fn(e,r,o);return;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));o?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)ln(e,r);else if(typeof r==`number`||typeof r==`bigint`)ln(e,``+r);else return;break;case`onScroll`:r!=null&&Zf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Zf(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=V);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!Lt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),o=n.slice(2,a?n.length-7:void 0),t=e[xt]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(o,t,a),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(o,r,a);break a}Wt=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Kt(e,n,r)}return}Wt=!0}function pp(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Zf(`error`,e),Zf(`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:dp(e,t,o,s,n,null)}}a&&dp(e,t,`srcSet`,n.srcSet,n,null),r&&dp(e,t,`src`,n.src,n,null);return;case`input`:Zf(`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:dp(e,t,r,d,n,null)}}rn(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Zf(`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:dp(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&on(e,!!r,n,!0):on(e,!!r,t,!1);return;case`textarea`:for(s in Zf(`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:dp(e,t,s,c,n,null)}cn(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:dp(e,t,l,r,n,null)}return;case`dialog`:Zf(`beforetoggle`,e),Zf(`toggle`,e),Zf(`cancel`,e),Zf(`close`,e);break;case`iframe`:case`object`:Zf(`load`,e);break;case`video`:case`audio`:for(r=0;r<Jf.length;r++)Zf(Jf[r],e);break;case`image`:Zf(`error`,e),Zf(`load`,e);break;case`details`:Zf(`toggle`,e);break;case`embed`:case`source`:case`link`:Zf(`error`,e),Zf(`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:dp(e,t,u,r,n,null)}return;default:if(pn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&fp(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&dp(e,t,c,r,n,null))}var mp={};function hp(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)||dp(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`:m!==f&&(Wt=!0),o=m;break;case`name`:m!==f&&(Wt=!0),a=m;break;case`checked`:m!==f&&(Wt=!0),u=m;break;case`defaultChecked`:m!==f&&(Wt=!0),d=m;break;case`value`:m!==f&&(Wt=!0),s=m;break;case`defaultValue`:m!==f&&(Wt=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&dp(e,t,p,m,r,f)}}nn(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)||dp(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`:o!==l&&(Wt=!0),p=o;break;case`defaultValue`:o!==l&&(Wt=!0),c=o;break;case`multiple`:o!==l&&(Wt=!0),s=o;default:o!==l&&dp(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?on(e,!!n,n?[]:``,!1):on(e,!!n,t,!0)):on(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:dp(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`:a!==o&&(Wt=!0),p=a;break;case`defaultValue`:a!==o&&(Wt=!0),m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&dp(e,t,s,a,r,o)}sn(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:dp(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`:p!==m&&(Wt=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:dp(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)&&dp(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:dp(e,t,u,p,r,m)}return;default:if(pn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&fp(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||fp(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&dp(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||dp(e,t,f,p,r,m)}function gp(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function _p(){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&&gp(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&&gp(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 vp=null,yp=null;function bp(e){return e.nodeType===9?e:e.ownerDocument}function xp(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 Sp(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 Cp(e,t,n,r){return n=bp(n).createElement(e),n[bt]=r,n[xt]=t,pp(n,e,t),Pt(n),n}function wp(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 Tp=null;function Ep(){var e=window.event;return e&&e.type===`popstate`?e!==Tp&&(Tp=e,!0):(Tp=null,!1)}var Dp=typeof setTimeout==`function`?setTimeout:void 0,Op=typeof clearTimeout==`function`?clearTimeout:void 0,kp=typeof Promise==`function`?Promise:void 0,Ap=typeof requestAnimationFrame==`function`?requestAnimationFrame:Dp,jp=typeof queueMicrotask==`function`?queueMicrotask:kp===void 0?Dp:function(e){return kp.resolve(null).then(e).catch(Mp)};function Mp(e){setTimeout(function(){throw e})}function Np(e){return e===`head`}function Pp(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),$h(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)Om(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,Om(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[Dt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&Om(e.ownerDocument.body)}n=i}while(n);$h(t)}function Fp(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 Ip(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Lp(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function Rp(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function zp(e){return Rp(e.getBoundingClientRect(),getComputedStyle(e),e)}function Bp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return Rp(t,n,e)}function Vp(e){return e.documentElement.clientHeight}function Hp(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Up(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(Vp(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=sh(f),u>uh){s.length=o;break}f=new Promise(Hp.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Wp(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Wp.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:T({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Wp.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Wp.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Gp(e){return{name:e,group:new Wp(`group`,e),imagePair:new Wp(`image-pair`,e),old:new Wp(`old`,e),new:new Wp(`new`,e)}}function Kp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Kp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Zp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=Yp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),f(this._fragmentFiber.child,!1,qp,e,s,r)}this._eventListeners=a}};function qp(e,t,n,r){return _(e).addEventListener(t,n,r),!1}Kp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Zp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=Yp(i.optionsOrUseCapture),f(this._fragmentFiber.child,!1,Jp,e,n,i),r.splice(t,1),a!==null&&a()}};function Jp(e,t,n,r){return _(e).removeEventListener(t,n,r),!1}function Yp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function Xp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Zp(e,t,n,r){if(e.length===0)return-1;r=Xp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&Xp(a.optionsOrUseCapture)===r)return i}return-1}Kp.prototype.dispatchEvent=function(e){var t=p(this._fragmentFiber);if(t===null)return!0;t=_(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,Yp(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,Yp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Kp.prototype.focus=function(e){f(this._fragmentFiber.child,!0,Qp,e,void 0,void 0)};function Qp(e,t){return e.tag!==6&&(e=_(e),wm(e,t))}Kp.prototype.focusLast=function(e){var t=[];f(this._fragmentFiber.child,!0,$p,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Qp(t[n],e);n--);};function $p(e,t){return t.push(e),!1}Kp.prototype.blur=function(){var e=p(this._fragmentFiber);e!==null&&(e=_(e),e=bp(e).activeElement,e!==null&&f(this._fragmentFiber.child,!1,em,e,void 0,void 0))};function em(e,t){return e.tag!==6&&(e=_(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Kp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),f(this._fragmentFiber.child,!1,tm,e,void 0,void 0)};function tm(e,t){return e.tag===6||(e=_(e),t.observe(e)),!1}Kp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),f(this._fragmentFiber.child,!1,nm,e,void 0,void 0);for(var n=t=0;n<rm.length;n++){var r=rm[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):rm[t++]=r}rm.length=t}};function nm(e,t){return e.tag===6||(e=_(e),t.unobserve(e)),!1}var rm=[],im=!1;function am(e,t,n){rm.push({fragmentInstance:e,observer:t,instance:n}),im||(im=!0,Tm(function(){im=!1;var e=rm;rm=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Kp.prototype.getClientRects=function(){var e=[];return f(this._fragmentFiber.child,!1,om,e,void 0,void 0),e};function om(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=_(e),t.push.apply(t,e.getClientRects());return!1}Kp.prototype.getRootNode=function(e){var t=p(this._fragmentFiber);return t===null?this:_(t).getRootNode(e)},Kp.prototype.compareDocumentPosition=function(e){var t=p(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];f(this._fragmentFiber.child,!1,$p,n,void 0,void 0);var r=_(t);if(n.length===0){if(n=r,m(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=h(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=_(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=_(n[0]),i=_(n[n.length-1]);var a=m(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||sm(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function sm(e,t,n,r,i){var a=At(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=p(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=C(n,a,S),t===null?t=!1:(f(t,!0,b,a,n),a=v,v=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=C(r,a,S),t===null?t=!1:(f(t,!0,x,a,r),a=v,y=v=null,t=a!==null)),t):!1}function cm(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Kp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(i(566));var t=[];f(this._fragmentFiber.child,!1,$p,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=h(this._fragmentFiber);if(r=n?r[1]||r[0]||p(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=_(r),cm(e,n);return}if(r=_(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var a=t[r];a.tag===6?(a=_(a),cm(a,n)):_(a).scrollIntoView(e),r+=n?-1:1}};function lm(e,t){return e=_(e),um(e,t),!1}function um(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function dm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,Yp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<rm.length;i++){var a=rm[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(rm[r++]=a)}rm.length=r,n.observe(e)}),um(e,t))}function fm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,Yp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?am(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function pm(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`:pm(n),kt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function mm(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[Dt])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=bm(e.nextSibling),e===null)break}return null}function hm(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=bm(e.nextSibling),e===null))return null;return e}function gm(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=bm(e.nextSibling),e===null))return null;return e}function _m(e){return e.data===`$?`||e.data===`$~`}function vm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function ym(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 bm(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 xm=null;function Sm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return bm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function Cm(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 wm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function Tm(e){Ap(function(){Ap(function(t){return e(t)})})}function Em(e,t,n){switch(t=bp(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 Dm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&dp(e,t,r,null,mp,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===V&&(e.onclick=null),kt(e)}function Om(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);kt(e)}var km=new Map,Am=new Set;function jm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var Mm=fe.d;fe.d={f:Nm,r:Pm,D:Lm,C:Rm,L:zm,m:Bm,X:Hm,S:Vm,M:Um};function Nm(){var e=Mm.f(),t=qd();return e||t}function Pm(e){var t=jt(e);t!==null&&t.tag===5&&t.type===`form`?rc(t):Mm.r(e)}var Fm=typeof document>`u`?null:document;function Im(e,t,n){var r=Fm;if(r&&typeof t==`string`&&t){var i=tn(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Am.has(i)||(Am.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),pp(t,`link`,e),Pt(t),r.head.appendChild(t)))}}function Lm(e){Mm.D(e),Im(`dns-prefetch`,e,null)}function Rm(e,t){Mm.C(e,t),Im(`preconnect`,e,t)}function zm(e,t,n){Mm.L(e,t,n);var r=Fm;if(r&&e&&t){var i=`link[rel="preload"][as="`+tn(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+tn(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+tn(n.imageSizes)+`"]`)):i+=`[href="`+tn(e)+`"]`;var a=i;switch(t){case`style`:a=Gm(e);break;case`script`:a=Ym(e)}if(!(km.has(a)||(e=T({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),km.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Km(a))||t===`script`&&r.querySelector(Xm(a))))){var o=r.createElement(`link`);pp(o,`link`,e),t===`style`&&(o[Ot]=!0,o.onload=o.onerror=function(){Ft(o)}),Pt(o),r.head.appendChild(o)}}}function Bm(e,t){Mm.m(e,t);var n=Fm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+tn(r)+`"][href="`+tn(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Ym(e)}if(!km.has(a)&&(e=T({rel:`modulepreload`,href:e},t),km.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Xm(a)))return}r=n.createElement(`link`),pp(r,`link`,e),Pt(r),n.head.appendChild(r)}}}function Vm(e,t,n){Mm.S(e,t,n);var r=Fm;if(r&&e){var i=Nt(r).hoistableStyles,a=Gm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Km(a)))s.loading=5;else{e=T({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=km.get(a))&&$m(e,n);var c=o=r.createElement(`link`);Pt(c),pp(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,Qm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Hm(e,t){Mm.X(e,t);var n=Fm;if(n&&e){var r=Nt(n).hoistableScripts,i=Ym(e),a=r.get(i);a||(a=n.querySelector(Xm(i)),a||(e=T({src:e,async:!0},t),(t=km.get(i))&&eh(e,t),a=n.createElement(`script`),Pt(a),pp(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Um(e,t){Mm.M(e,t);var n=Fm;if(n&&e){var r=Nt(n).hoistableScripts,i=Ym(e),a=r.get(i);a||(a=n.querySelector(Xm(i)),a||(e=T({src:e,async:!0,type:`module`},t),(t=km.get(i))&&eh(e,t),a=n.createElement(`script`),Pt(a),pp(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Wm(e,t,n,r){var a=(a=be.current)?jm(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`?(n=Gm(n.href),t=Nt(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,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=Gm(n.href);var o=Nt(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(Km(e)))?o._p||(s.instance=o,s.state.loading=5):(o=km.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},km.set(e,o)),Jm(a,e,o,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`?(n=Ym(n),t=Nt(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Gm(e){return`href="`+tn(e)+`"`}function Km(e){return`link[rel="stylesheet"][`+e+`]`}function qm(e){return T({},e,{"data-precedence":e.precedence,precedence:null})}function Jm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Ot]){r.loading=1;return}}else t=e.createElement(`link`),t[Ot]=!0,t.onload=t.onerror=Ft.bind(null,t),pp(t,`link`,n),Pt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Ym(e){return`[src="`+tn(e)+`"]`}function Xm(e){return`script[async]`+e}function Zm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+tn(n.href)+`"]`);if(r)return t.instance=r,Pt(r),r;var a=T({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Pt(r),pp(r,`style`,a),Qm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Gm(n.href);var o=e.querySelector(Km(a));if(o)return t.state.loading|=4,t.instance=o,Pt(o),o;r=qm(n),(a=km.get(a))&&$m(r,a),o=(e.ownerDocument||e).createElement(`link`),Pt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),pp(o,`link`,r),t.state.loading|=4,Qm(o,n.precedence,e),t.instance=o;case`script`:return o=Ym(n.src),(a=e.querySelector(Xm(o)))?(t.instance=a,Pt(a),a):(r=n,(a=km.get(o))&&(r=T({},n),eh(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Pt(a),pp(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,Qm(r,n.precedence,e));return t.instance}function Qm(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 $m(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function eh(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var th=null;function nh(e,t,n){if(th===null){var r=new Map,i=th=new Map;i.set(n,r)}else i=th,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[Dt]||a[bt]||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 rh(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function ih(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 ah(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function oh(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function sh(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function ch(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=sh(t),e.suspenseyImages.push(t)),e=mh.bind(e),t.decode().then(e,e))}function lh(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=Gm(r.href),a=t.querySelector(Km(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=ph.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Pt(a);return}a=t.ownerDocument||t,r=qm(r),(i=km.get(i))&&$m(r,i),a=a.createElement(`link`),Pt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),pp(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=ph.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var uh=0;function dh(e,t){return e.stylesheets&&e.count===0&&gh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&gh(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&uh===0&&(uh=62500*_p());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&gh(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>uh?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function fh(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)gh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function ph(){this.count--,fh(this)}function mh(){this.imgCount--,fh(this)}var hh=null;function gh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,hh=new Map,t.forEach(_h,e),hh=null,ph.call(e))}function _h(e,t){if(!(t.state.loading&4)){var n=hh.get(e);if(n)var r=n.get(null);else{n=new Map,hh.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=ph.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 vh={$$typeof:P,Provider:null,Consumer:null,_currentValue:pe,_currentValue2:pe,_threadCount:0};function yh(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=lt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=lt(0),this.hiddenUpdates=lt(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function bh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new yh(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=ki(3,null,null,t),e.current=a,a.stateNode=e,t=Aa(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},po(a),e}function xh(e){return e?(e=Di,e):Di}function Sh(e,t,n,r,i,a){i=xh(i),r.context===null?r.context=i:r.pendingContext=i,r=ho(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=go(e,r,t),n!==null&&(Hd(n,e,t),_o(n,e,t))}function Ch(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function wh(e,t){Ch(e,t),(e=e.alternate)&&Ch(e,t)}function Th(e){if(e.tag===13||e.tag===31){var t=Ti(e,67108864);t!==null&&Hd(t,e,67108864),wh(e,67108864)}}function Eh(e){if(e.tag===13||e.tag===31){var t=zd();t=ht(t);var n=Ti(e,t);n!==null&&Hd(n,e,t),wh(e,t)}}var Dh=!0;function Oh(e,t,n,r){var i=z.T;z.T=null;var a=fe.p;try{fe.p=2,Ah(e,t,n,r)}finally{fe.p=a,z.T=i}}function kh(e,t,n,r){var i=z.T;z.T=null;var a=fe.p;try{fe.p=8,Ah(e,t,n,r)}finally{fe.p=a,z.T=i}}function Ah(e,t,n,r){if(Dh){var i=jh(r);if(i===null)np(e,t,r,Mh,n),Uh(e,r);else if(Gh(i,e,t,n,r))r.stopPropagation();else if(Uh(e,r),t&4&&-1<Hh.indexOf(e)){for(;i!==null;){var a=jt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=rt(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Xe(o);s.entanglements[1]|=c,o&=~c}Ff(a),!(rd&6)&&(wd=Re()+500,If(0,!1))}}break;case 31:case 13:s=Ti(a,2),s!==null&&Hd(s,a,2),qd(),wh(a,2)}if(a=jh(r),a===null&&np(e,t,r,Mh,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else np(e,t,r,null,n)}}function jh(e){return e=vn(e),Nh(e)}var Mh=null;function Nh(e){if(Mh=null,e=At(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 Mh=e,null}function Ph(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`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`fullscreenerror`: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`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(ze()){case Be:return 2;case Ve:return 8;case He:case Ue:return 32;case We:return 268435456;default:return 32}default:return 32}}var Fh=!1,Ih=null,Lh=null,Rh=null,zh=new Map,Bh=new Map,Vh=[],Hh=`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 Uh(e,t){switch(e){case`focusin`:case`focusout`:Ih=null;break;case`dragenter`:case`dragleave`:Lh=null;break;case`mouseover`:case`mouseout`:Rh=null;break;case`pointerover`:case`pointerout`:zh.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Bh.delete(t.pointerId)}}function Wh(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=jt(t),t!==null&&Th(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Gh(e,t,n,r,i){switch(t){case`focusin`:return Ih=Wh(Ih,e,t,n,r,i),!0;case`dragenter`:return Lh=Wh(Lh,e,t,n,r,i),!0;case`mouseover`:return Rh=Wh(Rh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return zh.set(a,Wh(zh.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Bh.set(a,Wh(Bh.get(a)||null,e,t,n,r,i)),!0}return!1}function Kh(e){var t=At(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,vt(e.priority,function(){Eh(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,vt(e.priority,function(){Eh(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 qh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=jh(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);_n=r,n.target.dispatchEvent(r),_n=null}else return t=jt(n),t!==null&&Th(t),e.blockedOn=n,!1;t.shift()}return!0}function Jh(e,t,n){qh(e)&&n.delete(t)}function Yh(){Fh=!1,Ih!==null&&qh(Ih)&&(Ih=null),Lh!==null&&qh(Lh)&&(Lh=null),Rh!==null&&qh(Rh)&&(Rh=null),zh.forEach(Jh),Bh.forEach(Jh)}function Xh(e,n){e.blockedOn===n&&(e.blockedOn=null,Fh||(Fh=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Yh)))}var Zh=null;function Qh(e){Zh!==e&&(Zh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Zh===e&&(Zh=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(Nh(r||n)===null)continue;break}var a=jt(n);a!==null&&(e.splice(t,3),t-=3,tc(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function $h(e){function t(t){return Xh(t,e)}Ih!==null&&Xh(Ih,e),Lh!==null&&Xh(Lh,e),Rh!==null&&Xh(Rh,e),zh.forEach(t),Bh.forEach(t);for(var n=0;n<Vh.length;n++){var r=Vh[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Vh.length&&(n=Vh[0],n.blockedOn===null);)Kh(n),n.blockedOn===null&&Vh.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[xt]||null;if(typeof a==`function`)o||Qh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[xt]||null)s=o.formAction;else if(Nh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Qh(n)}}}function eg(){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 tg(e){this._internalRoot=e}ng.prototype.render=tg.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;Sh(n,zd(),e,t,null,null)},ng.prototype.unmount=tg.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Sh(e.current,2,null,e,null,null),qd(),t[St]=null}};function ng(e){this._internalRoot=e}ng.prototype.unstable_scheduleHydration=function(e){if(e){var t=_t();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Vh.length&&t!==0&&t<Vh[n].priority;n++);Vh.splice(n,0,e),n===0&&Kh(e)}};var rg=n.version;if(rg!==`19.3.1`)throw Error(i(527,rg,`19.3.1`));fe.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:d(e),e=e===null?null:e.stateNode,e};var ig={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:z,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var ag=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ag.isDisabled&&ag.supportsFiber)try{qe=ag.inject(ig),Je=ag}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=wc,s=Tc,c=Ec;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=bh(e,1,!1,null,null,n,r,null,o,s,c,eg),e[St]=t.current,ep(e),new tg(t)}})),A=b(((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=k()})),j=S(E(),1),M=[`a[href]`,`button:not([disabled])`,`input:not([disabled]):not([type="hidden"])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`,`);function N(e){return Array.from(e.querySelectorAll(M)).filter(e=>e.getAttribute(`aria-hidden`)!==`true`&&!e.closest(`[aria-hidden="true"]`)&&(typeof e.checkVisibility!=`function`||e.checkVisibility()))}function ee(){let e=(0,j.useRef)(null);return(0,j.useEffect)(()=>{let t=e.current;if(!t)return;let n=document.activeElement instanceof HTMLElement?document.activeElement:null;if(!t.contains(document.activeElement)){let e=N(t),n=t.querySelector(`[data-dialog-initial-focus]`);((n&&e.includes(n)?n:e[0])??t).focus()}function r(e){if(e.key!==`Tab`||e.defaultPrevented)return;let n=N(t);if(n.length===0){e.preventDefault(),t.focus();return}e.preventDefault();let r=document.activeElement,i=n.indexOf(r),a;if(i!==-1)a=(i+(e.shiftKey?-1:1)+n.length)%n.length;else if(r instanceof Node&&t.contains(r)){let t=n.findIndex(e=>r.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING);a=e.shiftKey?(t===-1?n.length:t)-1:t===-1?0:t,a<0&&(a=n.length-1)}else a=e.shiftKey?n.length-1:0;n[a].focus()}return t.addEventListener(`keydown`,r),()=>{t.removeEventListener(`keydown`,r),n&&n.isConnected&&n.focus()}},[]),e}var P=typeof window>`u`?j.useEffect:j.useLayoutEffect;function F(e,t,n=`mousedown`){let r=(0,j.useRef)(t);P(()=>{r.current=t},[t]),(0,j.useEffect)(()=>{if(!t)return;let i=t=>{let n=e.current;n&&!n.contains(t.target)&&r.current?.(t)};return window.addEventListener(n,i),()=>window.removeEventListener(n,i)},[t,n,e])}function te(e,t,n,r=`mousedown`){F(e,t?()=>n():void 0,r),(0,j.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,t])}var ne=b((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})),I=b(((e,t)=>{t.exports=ne()}))(),re={"en-US":{colorPickerSquare:`Saturation and brightness`,colorPickerHue:`Hue`,colorPickerHex:`Hex color`,colorWheel:`color wheel`,colorWheelLightness:`{label} lightness`,colorWheelOffset:`{label}: {x}, {y}`,curveEditor:`Curve`,curveEditorPoint:`Point {index}: {x}, {y}`,expandPanelGroup:`Expand panel group`,collapsePanelGroup:`Collapse panel group`,floatingPanelClose:`Close {title}`,floatingPanelResize:`Resize`,keyframeLane:`Keyframes`,keyframeAt:`Keyframe at {time}`,levelMeter:`Audio levels`,previewDialogOk:`OK`,previewDialogCancel:`Cancel`,previewDialogReset:`Reset`,previewDialogPreview:`Preview`,previewDialogPending:`Updating the preview…`,previewDialogOff:`Preview is off: {error}`,transportControls:`Transport controls`,closePanel:`Close Panel`,maximizeFrame:`Maximize Frame`,restoreWorkspace:`Restore Workspace`,panelMenu:`Panel menu`,moreTabs:`More tabs`,resizePanels:`Resize panels`,passwordShow:`Show password`,passwordHide:`Hide password`,close:`Close`,confirm:`Confirm`,cancel:`Cancel`,sheet:`Side panel`,noData:`No data`,loading:`Loading`,breadcrumb:`Breadcrumb`,pagination:`Pages`,paginationRange:`{first}–{last} of {total}`,previousPage:`Previous page`,nextPage:`Next page`,pageNumber:`Page {page}`,pageSize:`Rows per page`,perPage:`{size} / page`,formRequired:`{label} is required`,formEmail:`{label} must be an email address`,formUrl:`{label} must be a web address`,formPattern:`{label} is not in the expected format`,formMinLength:`{label} needs at least {min} characters`,formMaxLength:`{label} takes at most {max} characters`,formMinValue:`{label} must be at least {min}`,formMaxValue:`{label} must be at most {max}`,noMatches:`No matches`,clear:`Clear`,allChosen:`All`,selectAllRows:`Select all rows on this page`,selectRow:`Select row`,rowActions:`Actions`,selectionActions:`Selection actions`,selectedCount:`{count} selected`,clearSelection:`Clear selection`},"zh-CN":{colorPickerSquare:`饱和度和明度`,colorPickerHue:`色相`,colorPickerHex:`十六进制颜色`,colorWheel:`色轮`,colorWheelLightness:`{label}亮度`,colorWheelOffset:`{label}:{x},{y}`,curveEditor:`曲线`,curveEditorPoint:`点 {index}:{x},{y}`,expandPanelGroup:`展开面板组`,collapsePanelGroup:`折叠面板组`,floatingPanelClose:`关闭{title}`,floatingPanelResize:`调整大小`,keyframeLane:`关键帧`,keyframeAt:`{time} 处的关键帧`,levelMeter:`音频电平`,previewDialogOk:`确定`,previewDialogCancel:`取消`,previewDialogReset:`重置`,previewDialogPreview:`预览`,previewDialogPending:`正在更新预览…`,previewDialogOff:`预览已关闭:{error}`,transportControls:`播放控件`,closePanel:`关闭面板`,maximizeFrame:`最大化框架`,restoreWorkspace:`恢复工作区`,panelMenu:`面板菜单`,moreTabs:`更多选项卡`,resizePanels:`调整面板大小`,passwordShow:`显示密码`,passwordHide:`隐藏密码`,close:`关闭`,confirm:`确定`,cancel:`取消`,sheet:`侧边面板`,noData:`暂无数据`,loading:`加载中`,breadcrumb:`面包屑导航`,pagination:`分页`,paginationRange:`第 {first}–{last} 条,共 {total} 条`,previousPage:`上一页`,nextPage:`下一页`,pageNumber:`第 {page} 页`,pageSize:`每页行数`,perPage:`{size} 条/页`,formRequired:`请填写{label}`,formEmail:`{label}必须是邮箱地址`,formUrl:`{label}必须是网址`,formPattern:`{label}格式不正确`,formMinLength:`{label}至少需要 {min} 个字符`,formMaxLength:`{label}最多 {max} 个字符`,formMinValue:`{label}不能小于 {min}`,formMaxValue:`{label}不能大于 {max}`,noMatches:`没有匹配项`,clear:`清除`,allChosen:`全部`,selectAllRows:`选择本页所有行`,selectRow:`选择行`,rowActions:`操作`,selectionActions:`所选项的操作`,selectedCount:`已选 {count} 项`,clearSelection:`取消选择`}};function ie(e,t){let n=[t,t.split(`-`)[0],`en-US`].map(t=>e[t]??Object.entries(e).find(([e])=>e.split(`-`)[0]===t)?.[1]).filter(e=>!!e);return(e,t)=>{let r=n.find(t=>e in t)?.[e]??e;return t?r.replace(/\{(\w+)\}/g,(e,n)=>n in t?String(t[n]):e):r}}var ae=ie(re,`en-US`),oe=(0,j.createContext)(null);function se(){return(0,j.useContext)(oe)??ae}function L({strings:e,children:t}){return(0,I.jsx)(oe.Provider,{value:e,children:t})}var ce={hidden:!1,disabled:!1},le={state:()=>ce,renderExtras:()=>null,drawn:()=>void 0},ue=(0,j.createContext)(null);function de(){return(0,j.useContext)(ue)??le}function R({elements:e,children:t}){return(0,I.jsx)(ue.Provider,{value:e,children:t})}var z=`button[data-kit-ui-id^="command:"], button[data-kit-ui-id^="tool:"], button[data-kit-ui-id^="host:"]`,fe=`button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), a[href], [tabindex]:not([tabindex="-1"])`;function pe({open:e,anchor:t,onClose:n,label:r,className:i=``,testId:a,children:o}){let s=(0,j.useRef)(null),[c,l]=(0,j.useState)(null),u=(0,j.useRef)(n);u.current=n,(0,j.useLayoutEffect)(()=>{if(!e){l(null);return}let n=()=>{let e=t.current?.getBoundingClientRect();if(!e)return;let n=s.current?.offsetWidth??0,r=e.bottom+4;l({left:Math.max(4,Math.min(e.left,window.innerWidth-n-4)),top:r,maxHeight:Math.max(0,window.innerHeight-r-8)})};n(),window.addEventListener(`resize`,n);let r=typeof ResizeObserver==`function`&&s.current?new ResizeObserver(n):null;return r&&s.current&&r.observe(s.current),()=>{window.removeEventListener(`resize`,n),r?.disconnect()}},[t,e]),(0,j.useLayoutEffect)(()=>{if(!e)return;let n=t.current?.querySelector(`button`),r=s.current;return()=>{let e=document.activeElement;n?.isConnected&&(!e||e===document.body||!e.isConnected||r?.contains(e))&&n.focus({preventScroll:!0})}},[t,e]);let d=c!==null;return(0,j.useLayoutEffect)(()=>{let t=s.current;e&&d&&t&&!t.contains(document.activeElement)&&(t.querySelector(fe)??t).focus({preventScroll:!0})},[e,d]),(0,j.useEffect)(()=>{if(!e)return;let n=e=>{t.current?.contains(e.target)||u.current()},r=e=>{e.key===`Escape`&&!e.defaultPrevented&&u.current()};return window.addEventListener(`pointerdown`,n,!0),window.addEventListener(`keydown`,r),()=>{window.removeEventListener(`pointerdown`,n,!0),window.removeEventListener(`keydown`,r)}},[t,e]),e?(0,I.jsx)(`div`,{ref:s,className:`kui-popover kui-drop-panel ${i}`,role:`dialog`,"aria-label":r,tabIndex:-1,"data-testid":a,style:c?{left:c.left,top:c.top,maxHeight:c.maxHeight}:{visibility:`hidden`},onClick:e=>{e.target.closest(z)&&n()},children:o}):null}var me=A(),he=.25,ge=1.5;function _e({size:e=24,strokeWidth:t=ge,absoluteStrokeWidth:n=!1}={}){return n?t*24/e:t}var ve={name:`activity`,family:`ui`,paths:[`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`],fills:[],accents:[]},ye={name:`align-center-horizontal`,family:`ui`,paths:[`M2 12h20`,`M10 16v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-4`,`M10 8V4a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v4`,`M20 16v1a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v-1`,`M14 8V7c0-1.1.9-2 2-2h2a2 2 0 0 1 2 2v1`],fills:[],accents:[]},B={name:`arrow-down`,family:`ui`,paths:[`M12 4.5v15`,`M6.5 14l5.5 5.5 5.5-5.5`],fills:[],accents:[]},be={name:`arrow-down-a-z`,family:`ui`,paths:[`m3 16 4 4 4-4`,`M7 20V4`,`M20 8h-5`,`M15 10V6.5a2.5 2.5 0 0 1 5 0V10`,`M15 14h5l-5 6h5`],fills:[],accents:[]},xe={name:`arrow-down-to-line`,family:`ui`,paths:[`M12 17V3`,`m6 11 6 6 6-6`,`M19 21H5`],fills:[],accents:[]},Se={name:`arrow-left`,family:`ui`,paths:[`m12 19-7-7 7-7`,`M19 12H5`],fills:[],accents:[]},Ce={name:`arrow-left-from-line`,family:`ui`,paths:[`m9 6-6 6 6 6`,`M3 12h14`,`M21 19V5`],fills:[],accents:[]},we={name:`arrow-left-to-line`,family:`ui`,paths:[`M3 19V5`,`m13 6-6 6 6 6`,`M7 12h14`],fills:[],accents:[]},Te={name:`arrow-right`,family:`ui`,paths:[`M5 12h14`,`m12 5 7 7-7 7`],fills:[],accents:[]},Ee={name:`arrow-right-from-line`,family:`ui`,paths:[`M3 5v14`,`M21 12H7`,`m15 18 6-6-6-6`],fills:[],accents:[]},De={name:`arrow-right-left`,family:`ui`,paths:[`m16 3 4 4-4 4`,`M20 7H4`,`m8 21-4-4 4-4`,`M4 17h16`],fills:[],accents:[]},Oe={name:`arrow-right-to-line`,family:`ui`,paths:[`M17 12H3`,`m11 18 6-6-6-6`,`M21 5v14`],fills:[],accents:[]},ke={name:`arrow-up`,family:`ui`,paths:[`M12 19.5V4.5`,`M6.5 10L12 4.5 17.5 10`],fills:[],accents:[]},Ae={name:`arrow-up-down`,family:`ui`,paths:[`m21 16-4 4-4-4`,`M17 20V4`,`m3 8 4-4 4 4`,`M7 4v16`],fills:[],accents:[]},je={name:`bell`,family:`ui`,paths:[`M10.268 21a2 2 0 0 0 3.464 0`,`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`],fills:[],accents:[]},Me={name:`blend`,family:`ui`,paths:[`M8 9a7 7 0 1 0 14 0a7 7 0 1 0 -14 0z`,`M2 15a7 7 0 1 0 14 0a7 7 0 1 0 -14 0z`],fills:[],accents:[`M8.06 8.06A7 7 0 0 0 15.94 15.94A7 7 0 0 0 8.06 8.06z`]},Ne={name:`bold`,family:`ui`,paths:[`M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8`],fills:[],accents:[]},Pe={name:`book-open`,family:`ui`,paths:[`M12 5v16`,`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`],fills:[],accents:[]},Fe={name:`bookmark`,family:`ui`,paths:[`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`],fills:[],accents:[]},Ie={name:`box`,family:`ui`,paths:[`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,`m3.3 7 8.7 5 8.7-5`,`M12 22V12`],fills:[],accents:[]},Le={name:`briefcase-business`,family:`ui`,paths:[`M12 12h.01`,`M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2`,`M22 13a18.15 18.15 0 0 1-20 0`,`M4 6h16a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-16a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2z`],fills:[],accents:[]},Re={name:`bring-to-front`,family:`ui`,paths:[`M10 8h4a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-4a2 2 0 0 1 -2 -2v-4a2 2 0 0 1 2 -2z`,`M4 10a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2`,`M14 20a2 2 0 0 0 2 2h4a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2`],fills:[],accents:[]},ze={name:`brush`,family:`ui`,paths:[`m11 10 3 3`,`M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z`,`M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031`],fills:[],accents:[`M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z`]},Be={name:`calendar`,family:`ui`,paths:[`M8 2v3`,`M16 2v3`,`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`,`M3 9h18`],fills:[],accents:[]},Ve={name:`calendar-days`,family:`ui`,paths:[`M8 2v3`,`M16 2v3`,`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`,`M3 9h18`,`M8 13h.01`,`M12 13h.01`,`M16 13h.01`,`M8 17h.01`,`M12 17h.01`,`M16 17h.01`],fills:[],accents:[]},He={name:`camera`,family:`ui`,paths:[`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,`M9 13a3 3 0 1 0 6 0a3 3 0 1 0 -6 0z`],fills:[],accents:[]},Ue={name:`chart-column`,family:`ui`,paths:[`M3 3v16a2 2 0 0 0 2 2h16`,`M18 17V9`,`M13 17V5`,`M8 17v-3`],fills:[],accents:[]},We={name:`check`,family:`ui`,paths:[`M4.5 12.5l5 5 10-11`],fills:[],accents:[]},Ge={name:`chevron-down`,family:`ui`,paths:[`M6 9l6 6 6-6`],fills:[],accents:[]},Ke={name:`chevron-left`,family:`ui`,paths:[`m15 18-6-6 6-6`],fills:[],accents:[]},qe={name:`chevron-right`,family:`ui`,paths:[`m9 18 6-6-6-6`],fills:[],accents:[]},Je={name:`chevron-up`,family:`ui`,paths:[`m18 15-6-6-6 6`],fills:[],accents:[]},Ye={name:`chevrons-down-up`,family:`ui`,paths:[`m7 20 5-5 5 5`,`m7 4 5 5 5-5`],fills:[],accents:[]},Xe={name:`chevrons-up-down`,family:`ui`,paths:[`m7 15 5 5 5-5`,`m7 9 5-5 5 5`],fills:[],accents:[]},Ze={name:`circle`,family:`ui`,paths:[`M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0z`],fills:[],accents:[`M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0z`]},Qe={name:`circle-dot`,family:`ui`,paths:[`M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0z`,`M2 12a10 10 0 1 0 20 0a10 10 0 1 0 -20 0z`],fills:[],accents:[`M2 12a10 10 0 1 0 20 0a10 10 0 1 0 -20 0z`]},$e={name:`circle-question-mark`,family:`ui`,paths:[`M2 12a10 10 0 1 0 20 0a10 10 0 1 0 -20 0z`,`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,`M12 17h.01`],fills:[],accents:[]},et={name:`clapperboard`,family:`ui`,paths:[`m12.296 3.464 3.02 3.956`,`M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3z`,`M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,`m6.18 5.276 3.1 3.899`],fills:[],accents:[]},tt={name:`clip-extract`,family:`tool`,paths:[`M12 12V3`,`m8.5 6.5 3.5-3.5 3.5 3.5`,`M3 17.5h6m6 0h6`,`m6.5 14.5 3 3-3 3m11-6-3 3 3 3`],fills:[],accents:[]},nt={name:`clip-lift`,family:`tool`,paths:[`M12 13V3`,`m8.5 6.5 3.5-3.5 3.5 3.5`,`M3 15h5a1 1 0 0 1 1 1v3a1 1 0 0 1 -1 1h-5a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1z`,`M16 15h5a1 1 0 0 1 1 1v3a1 1 0 0 1 -1 1h-5a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1z`],fills:[],accents:[]},rt={name:`clipboard`,family:`ui`,paths:[`M9 2h6a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1v-2a1 1 0 0 1 1 -1z`,`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`],fills:[],accents:[]},it={name:`clipboard-list`,family:`ui`,paths:[`M9 2h6a1 1 0 0 1 1 1v2a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1v-2a1 1 0 0 1 1 -1z`,`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,`M12 11h4`,`M12 16h4`,`M8 11h.01`,`M8 16h.01`],fills:[],accents:[]},at={name:`clipboard-paste`,family:`ui`,paths:[`M8 4H6.5a2 2 0 0 0 -2 2v13a2 2 0 0 0 2 2H10`,`M16 4h1.5a2 2 0 0 1 2 2v4`,`M9 2.5h6a1 1 0 0 1 1 1v1.5a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1v-1.5a1 1 0 0 1 1 -1z`,`M14 13h6a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-6a1 1 0 0 1 -1 -1v-6a1 1 0 0 1 1 -1z`],fills:[],accents:[]},ot={name:`clock`,family:`ui`,paths:[`M2 12a10 10 0 1 0 20 0a10 10 0 1 0 -20 0z`,`M12 6v6l4 2`],fills:[],accents:[]},st={name:`clock-3`,family:`ui`,paths:[`M2 12a10 10 0 1 0 20 0a10 10 0 1 0 -20 0z`,`M12 6v6h4`],fills:[],accents:[]},ct={name:`code`,family:`ui`,paths:[`m16 18 6-6-6-6`,`m8 6-6 6 6 6`],fills:[],accents:[]},lt={name:`columns-2`,family:`ui`,paths:[`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`,`M12 3v18`],fills:[],accents:[`M5 3h7v18H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`]},ut={name:`command-generic`,family:`ui`,paths:[`M7 5h10a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2-2v-10a2 2 0 0 1 2-2z`],fills:[`M10.5 12a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0 -3 0z`],accents:[]},dt={name:`component`,family:`ui`,paths:[`M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z`,`M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z`,`M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z`,`M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z`],fills:[],accents:[]},ft={name:`contrast`,family:`ui`,paths:[`M2 12a10 10 0 1 0 20 0a10 10 0 1 0 -20 0z`,`M12 18a6 6 0 0 0 0-12v12z`],fills:[],accents:[]},pt={name:`copy`,family:`ui`,paths:[`M15 8V5a2 2 0 0 0 -2 -2H5a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h3`,`M10 8h9a2 2 0 0 1 2 2v9a2 2 0 0 1 -2 2h-9a2 2 0 0 1 -2 -2v-9a2 2 0 0 1 2 -2z`],fills:[],accents:[`M10 8h9a2 2 0 0 1 2 2v9a2 2 0 0 1 -2 2h-9a2 2 0 0 1 -2 -2v-9a2 2 0 0 1 2 -2z`]},mt={name:`copy-plus`,family:`ui`,paths:[`M15 12L15 18`,`M12 15L18 15`,`M10 8h10a2 2 0 0 1 2 2v10a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-10a2 2 0 0 1 2 -2z`,`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`],fills:[],accents:[`M10 8h10a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H10a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2z`]},ht={name:`corner-down-right`,family:`ui`,paths:[`m15 10 5 5-5 5`,`M4 4v7a4 4 0 0 0 4 4h12`],fills:[],accents:[]},gt={name:`crop`,family:`ui`,paths:[`M6 2v14a2 2 0 0 0 2 2h14`,`M18 22V8a2 2 0 0 0-2-2H2`],fills:[],accents:[`M6 6h12v12H6z`]},_t={name:`crosshair`,family:`ui`,paths:[`M2 12a10 10 0 1 0 20 0a10 10 0 1 0 -20 0z`,`M22 12L18 12`,`M6 12L2 12`,`M12 6L12 2`,`M12 22L12 18`],fills:[],accents:[]},vt={name:`database`,family:`ui`,paths:[`M3 5a9 3 0 1 0 18 0a9 3 0 1 0 -18 0z`,`M3 5V19A9 3 0 0 0 21 19V5`,`M3 12A9 3 0 0 0 21 12`],fills:[],accents:[]},yt={name:`diameter`,family:`ui`,paths:[`M17 19a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`M3 5a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`M6.48 3.66a10 10 0 0 1 13.86 13.86`,`m6.41 6.41 11.18 11.18`,`M3.66 6.48a10 10 0 0 0 13.86 13.86`],fills:[],accents:[]},bt={name:`diamond`,family:`ui`,paths:[`M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z`],fills:[],accents:[`M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z`]},xt={name:`disc`,family:`ui`,paths:[`M2 12a10 10 0 1 0 20 0a10 10 0 1 0 -20 0z`,`M10 12a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`],fills:[],accents:[]},St={name:`download`,family:`ui`,paths:[`M12 4v11`,`M7.5 10.5l4.5 4.5 4.5-4.5`,`M4 15.5V18a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2.5`],fills:[],accents:[]},Ct={name:`ellipsis`,family:`ui`,paths:[`M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0z`,`M18 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0z`,`M4 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0z`],fills:[],accents:[]},wt={name:`eraser`,family:`ui`,paths:[`M14 4.5l6 6-9 9H7l-4-4z`,`M8 10.5l6 6`,`M13 19.5h7`],fills:[],accents:[`M3 15.5l5-5 6 6-3 3H7z`]},Tt={name:`external-link`,family:`ui`,paths:[`M15 3h6v6`,`M10 14 21 3`,`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`],fills:[],accents:[]},Et={name:`eye`,family:`ui`,paths:[`M2.5 12C5 7.5 8.5 5.5 12 5.5s7 2 9.5 6.5c-2.5 4.5-6 6.5-9.5 6.5S5 16.5 2.5 12z`,`M9 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0z`],fills:[],accents:[]},Dt={name:`eye-off`,family:`ui`,paths:[`M2.5 12C5 7.5 8.5 5.5 12 5.5s7 2 9.5 6.5c-2.5 4.5-6 6.5-9.5 6.5S5 16.5 2.5 12z`,`M4 4l16 16`],fills:[],accents:[]},Ot={name:`fast-forward`,family:`ui`,paths:[`M12 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 12 18z`,`M2 6a2 2 0 0 1 3.414-1.414l6 6a2 2 0 0 1 0 2.828l-6 6A2 2 0 0 1 2 18z`],fills:[],accents:[]},kt={name:`file`,family:`ui`,paths:[`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,`M14 2v5a1 1 0 0 0 1 1h5`],fills:[],accents:[`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`]},At={name:`file-input`,family:`ui`,paths:[`M4 11V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-1`,`M14 2v5a1 1 0 0 0 1 1h5`,`M2 15h10`,`m9 18 3-3-3-3`],fills:[],accents:[]},jt={name:`file-output`,family:`ui`,paths:[`M4.226 20.925A2 2 0 0 0 6 22h12a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v3.127`,`M14 2v5a1 1 0 0 0 1 1h5`,`m5 11-3 3`,`m5 17-3-3h10`],fills:[],accents:[]},Mt={name:`file-plus`,family:`ui`,paths:[`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,`M14 2v5a1 1 0 0 0 1 1h5`,`M9 15h6`,`M12 18v-6`],fills:[],accents:[]},Nt={name:`file-spreadsheet`,family:`ui`,paths:[`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,`M14 2v5a1 1 0 0 0 1 1h5`,`M8 13h2`,`M14 13h2`,`M8 17h2`,`M14 17h2`],fills:[],accents:[]},Pt={name:`file-text`,family:`ui`,paths:[`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,`M14 2v5a1 1 0 0 0 1 1h5`,`M10 9H8`,`M16 13H8`,`M16 17H8`],fills:[],accents:[]},Ft={name:`file-up`,family:`ui`,paths:[`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,`M14 2v5a1 1 0 0 0 1 1h5`,`M12 12v6`,`m15 15-3-3-3 3`],fills:[],accents:[]},It={name:`film`,family:`ui`,paths:[`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`,`M7 3v18`,`M3 7.5h4`,`M3 12h18`,`M3 16.5h4`,`M17 3v18`,`M17 7.5h4`,`M17 16.5h4`],fills:[],accents:[]},Lt={name:`flag`,family:`ui`,paths:[`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`],fills:[],accents:[]},Rt={name:`flip-horizontal`,family:`ui`,paths:[`M12 3v2`,`M12 8v2`,`M12 13v2`,`M12 18v2`,`M9 6.5 3 17.5h6z`,`M15 6.5l6 11h-6z`],fills:[],accents:[]},zt={name:`focus`,family:`ui`,paths:[`M9 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0z`,`M3 7V5a2 2 0 0 1 2-2h2`,`M17 3h2a2 2 0 0 1 2 2v2`,`M21 17v2a2 2 0 0 1-2 2h-2`,`M7 21H5a2 2 0 0 1-2-2v-2`],fills:[],accents:[]},Bt={name:`folder`,family:`ui`,paths:[`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`],fills:[],accents:[]},Vt={name:`folder-open`,family:`ui`,paths:[`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`],fills:[],accents:[]},Ht={name:`frame`,family:`ui`,paths:[`M22 6L2 6`,`M22 18L2 18`,`M6 2L6 22`,`M18 2L18 22`],fills:[],accents:[`M6 6h12v12H6z`]},Ut={name:`funnel`,family:`ui`,paths:[`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`],fills:[],accents:[]},Wt={name:`gallery-horizontal-end`,family:`ui`,paths:[`M2 7v10`,`M6 5v14`,`M12 3h8a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`],fills:[],accents:[]},Gt={name:`gauge`,family:`ui`,paths:[`m12 14 4-4`,`M3.34 19a10 10 0 1 1 17.32 0`],fills:[],accents:[]},Kt={name:`grid-2x2`,family:`ui`,paths:[`M12 3v18`,`M3 12h18`,`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`],fills:[],accents:[]},qt={name:`grid-3x3`,family:`ui`,paths:[`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`,`M3 9h18`,`M3 15h18`,`M9 3v18`,`M15 3v18`],fills:[],accents:[]},Jt={name:`grip-horizontal`,family:`ui`,paths:[`M11 9a1 1 0 1 0 2 0a1 1 0 1 0 -2 0z`,`M18 9a1 1 0 1 0 2 0a1 1 0 1 0 -2 0z`,`M4 9a1 1 0 1 0 2 0a1 1 0 1 0 -2 0z`,`M11 15a1 1 0 1 0 2 0a1 1 0 1 0 -2 0z`,`M18 15a1 1 0 1 0 2 0a1 1 0 1 0 -2 0z`,`M4 15a1 1 0 1 0 2 0a1 1 0 1 0 -2 0z`],fills:[],accents:[]},Yt={name:`grip-vertical`,family:`ui`,paths:[`M8 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0z`,`M8 5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0z`,`M8 19a1 1 0 1 0 2 0a1 1 0 1 0 -2 0z`,`M14 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0z`,`M14 5a1 1 0 1 0 2 0a1 1 0 1 0 -2 0z`,`M14 19a1 1 0 1 0 2 0a1 1 0 1 0 -2 0z`],fills:[],accents:[]},Xt={name:`group`,family:`ui`,paths:[`M3 7V5a2 2 0 0 1 2 -2h2`,`M17 3h2a2 2 0 0 1 2 2v2`,`M21 17v2a2 2 0 0 1 -2 2h-2`,`M7 21H5a2 2 0 0 1 -2 -2v-2`,`M7 6h3a1 1 0 0 1 1 1v3a1 1 0 0 1 -1 1h-3a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1z`,`M14 13h3a1 1 0 0 1 1 1v3a1 1 0 0 1 -1 1h-3a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1z`],fills:[],accents:[]},Zt={name:`hand`,family:`ui`,paths:[`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`],fills:[],accents:[]},Qt={name:`hash`,family:`ui`,paths:[`M4.5 9h15`,`M4.5 15h15`,`M10 4L8 20`,`M16 4L14 20`],fills:[],accents:[]},$t={name:`heading`,family:`ui`,paths:[`M6 12h12`,`M6 20V4`,`M18 20V4`],fills:[],accents:[]},en={name:`heart`,family:`ui`,paths:[`M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5`],fills:[],accents:[`M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5z`]},tn={name:`highlighter`,family:`ui`,paths:[`M14.5 4.5l5 5-7 7-5-5z`,`M7.5 11.5l-3 3V17h4l3-3`,`M3.5 20.5h8`],fills:[],accents:[`M7.5 11.5l-3 3V17h4l3-3z`]},nn={name:`image`,family:`ui`,paths:[`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`,`M7.5 9a1.5 1.5 0 1 0 3 0a1.5 1.5 0 1 0 -3 0z`,`M3.5 18l5-5 3.5 3.5 4.5-4.5 4.5 4.5`],fills:[],accents:[]},rn={name:`info`,family:`ui`,paths:[`M2 12a10 10 0 1 0 20 0a10 10 0 1 0 -20 0z`,`M12 16v-4`,`M12 8h.01`],fills:[],accents:[]},an={name:`italic`,family:`ui`,paths:[`M19 4L10 4`,`M14 20L5 20`,`M15 4L9 20`],fills:[],accents:[]},on={name:`languages`,family:`ui`,paths:[`m5 8 6 6`,`m4 14 6-6 2-3`,`M2 5h12`,`M7 2h1`,`m22 22-5-10-5 10`,`M14 18h6`],fills:[],accents:[]},sn={name:`lasso`,family:`ui`,paths:[`M3.704 14.467a10 8 0 1 1 3.115 2.375`,`M7 22a5 5 0 0 1-2-3.994`,`M3 16a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`],fills:[],accents:[`M2 10a10 8 0 1 0 20 0a10 8 0 1 0 -20 0z`]},cn={name:`layers`,family:`ui`,paths:[`M12 3.5l8.5 4.5-8.5 4.5-8.5-4.5z`,`M3.5 12l8.5 4.5 8.5-4.5`,`M3.5 16l8.5 4.5 8.5-4.5`],fills:[],accents:[]},ln={name:`layout-dashboard`,family:`ui`,paths:[`M4 3h5a1 1 0 0 1 1 1v7a1 1 0 0 1 -1 1h-5a1 1 0 0 1 -1 -1v-7a1 1 0 0 1 1 -1z`,`M15 3h5a1 1 0 0 1 1 1v3a1 1 0 0 1 -1 1h-5a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1z`,`M15 12h5a1 1 0 0 1 1 1v7a1 1 0 0 1 -1 1h-5a1 1 0 0 1 -1 -1v-7a1 1 0 0 1 1 -1z`,`M4 16h5a1 1 0 0 1 1 1v3a1 1 0 0 1 -1 1h-5a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1z`],fills:[],accents:[]},un={name:`layout-template`,family:`ui`,paths:[`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`,`M3 9.5h18`,`M10.5 9.5V21`],fills:[],accents:[]},dn={name:`life-buoy`,family:`ui`,paths:[`M2 12a10 10 0 1 0 20 0a10 10 0 1 0 -20 0z`,`m4.93 4.93 4.24 4.24`,`m14.83 9.17 4.24-4.24`,`m14.83 14.83 4.24 4.24`,`m9.17 14.83-4.24 4.24`,`M8 12a4 4 0 1 0 8 0a4 4 0 1 0 -8 0z`],fills:[],accents:[]},fn={name:`lightbulb`,family:`ui`,paths:[`M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5`,`M9 18h6`,`M10 22h4`],fills:[],accents:[]},pn={name:`link`,family:`ui`,paths:[`M10 7.5H7.5a4.5 4.5 0 0 0 0 9H10`,`M14 7.5h2.5a4.5 4.5 0 0 1 0 9H14`,`M8.5 12h7`],fills:[],accents:[]},mn={name:`link-2`,family:`ui`,paths:[`M9 17H7A5 5 0 0 1 7 7h2`,`M15 7h2a5 5 0 1 1 0 10h-2`,`M8 12L16 12`],fills:[],accents:[]},hn={name:`list`,family:`ui`,paths:[`M3 5h.01`,`M3 12h.01`,`M3 19h.01`,`M8 5h13`,`M8 12h13`,`M8 19h13`],fills:[],accents:[]},gn={name:`list-checks`,family:`ui`,paths:[`M13 5h8`,`M13 12h8`,`M13 19h8`,`m3 17 2 2 4-4`,`m3 7 2 2 4-4`],fills:[],accents:[]},V={name:`list-ordered`,family:`ui`,paths:[`M11 5h10`,`M11 12h10`,`M11 19h10`,`M4 4h1v5`,`M4 9h2`,`M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02`],fills:[],accents:[]},_n={name:`list-plus`,family:`ui`,paths:[`M16 5H3`,`M11 12H3`,`M16 19H3`,`M18 9v6`,`M21 12h-6`],fills:[],accents:[]},vn={name:`list-tree`,family:`ui`,paths:[`M8 5h13`,`M13 12h8`,`M13 19h8`,`M3 10a2 2 0 0 0 2 2h3`,`M3 5v12a2 2 0 0 0 2 2h3`],fills:[],accents:[]},yn={name:`loader-circle`,family:`ui`,paths:[`M21 12a9 9 0 1 1-6.219-8.56`],fills:[],accents:[]},bn={name:`lock`,family:`ui`,paths:[`M6 11h12a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-6a2 2 0 0 1 2 -2z`,`M8 11V7.5a4 4 0 0 1 8 0V11`,`M12 15v2`],fills:[],accents:[]},xn={name:`lock-open`,family:`ui`,paths:[`M6 11h12a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-6a2 2 0 0 1 2 -2z`,`M8 11V7.5a4 4 0 0 1 8 0`,`M12 15v2`],fills:[],accents:[]},Sn={name:`magnet`,family:`ui`,paths:[`m12 15 4 4`,`M2.352 10.648a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.029-6.029a1 1 0 1 1 3 3l-6.029 6.029a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l6.365-6.367A1 1 0 0 0 8.716 4.282z`,`m5 8 4 4`],fills:[],accents:[]},Cn={name:`mail`,family:`ui`,paths:[`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,`M4 4h16a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-16a2 2 0 0 1 -2 -2v-12a2 2 0 0 1 2 -2z`],fills:[],accents:[]},wn={name:`maximize-2`,family:`ui`,paths:[`M15 3h6v6`,`m21 3-7 7`,`m3 21 7-7`,`M9 21H3v-6`],fills:[],accents:[]},Tn={name:`menu`,family:`ui`,paths:[`M4 5h16`,`M4 12h16`,`M4 19h16`],fills:[],accents:[]},En={name:`merge`,family:`ui`,paths:[`m8 6 4-4 4 4`,`M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22`,`m20 22-5-5`],fills:[],accents:[]},Dn={name:`message-square`,family:`ui`,paths:[`M6 4h13a2 2 0 0 1 2 2v9a2 2 0 0 1 -2 2H9.5L4 21V6a2 2 0 0 1 2 -2z`],fills:[],accents:[]},On={name:`minimize-2`,family:`ui`,paths:[`m14 10 7-7`,`M20 10h-6V4`,`m3 21 7-7`,`M4 14h6v6`],fills:[],accents:[]},kn={name:`minus`,family:`ui`,paths:[`M4.5 12h15`],fills:[],accents:[]},An={name:`mouse-pointer`,family:`ui`,paths:[`M12.586 12.586 19 19`,`M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z`],fills:[],accents:[`M3.688 3.037a.497.497 0 0 0-.651.651l6.5 15.999a.501.501 0 0 0 .947-.062l1.569-6.083a2 2 0 0 1 1.448-1.479l6.124-1.579a.5.5 0 0 0 .063-.947z`]},jn={name:`mouse-pointer-2`,family:`ui`,paths:[`M4.5 4.5l15 6-6.5 2.5-2.5 6.5z`],fills:[],accents:[`M4.5 4.5l15 6-6.5 2.5-2.5 6.5z`]},Mn={name:`mouse-pointer-click`,family:`ui`,paths:[`M14 4.1 12 6`,`m5.1 8-2.9-.8`,`m6 12-1.9 2`,`M7.2 2.2 8 5.1`,`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`],fills:[],accents:[]},Nn={name:`move`,family:`ui`,paths:[`M12 2v20`,`m15 19-3 3-3-3`,`m19 9 3 3-3 3`,`M2 12h20`,`m5 9-3 3 3 3`,`m9 5 3-3 3 3`],fills:[],accents:[]},Pn={name:`move-3d`,family:`ui`,paths:[`M5 3v16h16`,`m5 19 6-6`,`m2 6 3-3 3 3`,`m18 16 3 3-3 3`],fills:[],accents:[]},Fn={name:`move-horizontal`,family:`ui`,paths:[`m18 8 4 4-4 4`,`M2 12h20`,`m6 8-4 4 4 4`],fills:[],accents:[]},In={name:`move-up-right`,family:`ui`,paths:[`M13 5H19V11`,`M19 5L5 19`],fills:[],accents:[]},Ln={name:`music`,family:`ui`,paths:[`M9 18V5l12-2v13`,`M3 18a3 3 0 1 0 6 0a3 3 0 1 0 -6 0z`,`M15 16a3 3 0 1 0 6 0a3 3 0 1 0 -6 0z`],fills:[],accents:[`M3 18a3 3 0 1 0 6 0a3 3 0 1 0 -6 0z`,`M15 16a3 3 0 1 0 6 0a3 3 0 1 0 -6 0z`]},Rn={name:`network`,family:`ui`,paths:[`M17 16h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1z`,`M3 16h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1z`,`M10 2h4a1 1 0 0 1 1 1v4a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1v-4a1 1 0 0 1 1 -1z`,`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,`M12 12V8`],fills:[],accents:[`M10 2h4a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1z`]},zn={name:`omega`,family:`ui`,paths:[`M3 20h4.5a.5.5 0 0 0 .5-.5v-.282a.52.52 0 0 0-.247-.437 8 8 0 1 1 8.494-.001.52.52 0 0 0-.247.438v.282a.5.5 0 0 0 .5.5H21`],fills:[],accents:[]},Bn={name:`package`,family:`ui`,paths:[`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,`M12 22V12`,`M3.29 7L12 12L20.71 7`,`m7.5 4.27 9 5.15`],fills:[],accents:[`M3.29 7L12 12v10L4 17.73A2 2 0 0 1 3 16V8a2 2 0 0 1 .29-1z`]},Vn={name:`paint-bucket`,family:`ui`,paths:[`M11 4.5l7.5 7.5-6.5 6.5-7.5-7.5z`,`M10.5 5L8 2.5`,`M5 11h13.5`,`M20.5 15.5c-.5 1-1.5 2-1.5 3a1.5 1.5 0 0 0 3 0c0-1-1-2-1.5-3z`],fills:[],accents:[`M5 11h13.5l-6.5 7.5z`,`M20.5 15.5c-.5 1-1.5 2-1.5 3a1.5 1.5 0 0 0 3 0c0-1-1-2-1.5-3z`]},Hn={name:`paintbrush`,family:`ui`,paths:[`M20.5 3.5l-7.5 7.5`,`M11.5 9.5l3 3`,`M11 12.5c-3 0-4.5 2-4.5 4.5 0 1.5-1 2.5-2.5 3 1 .5 2 .5 3.5 .5 3 0 5-1.5 5-4.5 0-1-.5-2.5-1.5-3.5z`],fills:[],accents:[`M11 12.5c-3 0-4.5 2-4.5 4.5 0 1.5-1 2.5-2.5 3 1 .5 2 .5 3.5 .5 3 0 5-1.5 5-4.5 0-1-.5-2.5-1.5-3.5z`]},Un={name:`palette`,family:`ui`,paths:[`M12 3a9 9 0 0 0 0 18c1.5 0 2-1 2-2s-.5-1.5-.5-2.5a1.5 1.5 0 0 1 1.5-1.5h2a4 4 0 0 0 4-4c0-4.5-4-8-9-8z`],fills:[`M6.25 11a1.25 1.25 0 1 0 2.5 0a1.25 1.25 0 1 0 -2.5 0z`,`M8.25 7a1.25 1.25 0 1 0 2.5 0a1.25 1.25 0 1 0 -2.5 0z`,`M13.25 7a1.25 1.25 0 1 0 2.5 0a1.25 1.25 0 1 0 -2.5 0z`],accents:[`M12 3a9 9 0 0 0 0 18c1.5 0 2-1 2-2s-.5-1.5-.5-2.5a1.5 1.5 0 0 1 1.5-1.5h2a4 4 0 0 0 4-4c0-4.5-4-8-9-8z`]},Wn={name:`panel-bottom`,family:`ui`,paths:[`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`,`M3 15h18`],fills:[],accents:[]},Gn={name:`panel-top`,family:`ui`,paths:[`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`,`M3 9h18`],fills:[],accents:[]},Kn={name:`pause`,family:`ui`,paths:[`M15 3h3a1 1 0 0 1 1 1v16a1 1 0 0 1 -1 1h-3a1 1 0 0 1 -1 -1v-16a1 1 0 0 1 1 -1z`,`M6 3h3a1 1 0 0 1 1 1v16a1 1 0 0 1 -1 1h-3a1 1 0 0 1 -1 -1v-16a1 1 0 0 1 1 -1z`],fills:[],accents:[]},qn={name:`pen-line`,family:`ui`,paths:[`M13 21h8`,`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`],fills:[],accents:[]},Jn={name:`pen-tool`,family:`ui`,paths:[`m18 13-.654-4.736a4 4 0 00-2.756-3.266l-9.163-2.9a2 2 0 00-2.017.493l-.82.819a2 2 0 00-.492 2.017l2.9 9.163a4 4 0 003.266 2.756L13 18`,`M18.648 12.352a1.205 1.205 0 011.704 0l1.296 1.296a1.205 1.205 0 010 1.704l-6.296 6.296a1.205 1.205 0 01-1.704 0l-1.296-1.296a1.205 1.205 0 010-1.704z`,`m3 3 6.586 6.586`,`M9 11a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`],fills:[],accents:[`M18 13l-.654-4.736a4 4 0 0 0-2.756-3.266l-9.163-2.9a2 2 0 0 0-2.017.493l-.82.819a2 2 0 0 0-.492 2.017l2.9 9.163a4 4 0 0 0 3.266 2.756L13 18z`]},Yn={name:`pencil`,family:`ui`,paths:[`M15.5 4.5l4 4L9 19l-5 1 1-5z`,`M13 7l4 4`],fills:[],accents:[`M15.5 4.5l4 4L9 19l-5 1 1-5z`]},Xn={name:`pencil-line`,family:`ui`,paths:[`M13 21h8`,`m15 5 4 4`,`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`],fills:[],accents:[]},Zn={name:`pilcrow`,family:`ui`,paths:[`M13 4v16`,`M17 4v16`,`M19 4H9.5a4.5 4.5 0 0 0 0 9H13`],fills:[],accents:[]},Qn={name:`pin`,family:`ui`,paths:[`M12 17v5`,`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`],fills:[],accents:[]},$n={name:`pin-off`,family:`ui`,paths:[`M12 17v5`,`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,`m2 2 20 20`,`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`],fills:[],accents:[]},er={name:`pipette`,family:`ui`,paths:[`m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12`,`m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z`,`m2 22 .414-.414`],fills:[],accents:[`M12 9l-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12z`]},tr={name:`play`,family:`ui`,paths:[`M7 4.5v15l12-7.5z`],fills:[],accents:[]},nr={name:`plus`,family:`ui`,paths:[`M12 4.5v15`,`M4.5 12h15`],fills:[],accents:[]},rr={name:`printer`,family:`ui`,paths:[`M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2`,`M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6`,`M7 14h10a1 1 0 0 1 1 1v6a1 1 0 0 1 -1 1h-10a1 1 0 0 1 -1 -1v-6a1 1 0 0 1 1 -1z`],fills:[],accents:[]},ir={name:`qr-code`,family:`ui`,paths:[`M4 3h3a1 1 0 0 1 1 1v3a1 1 0 0 1 -1 1h-3a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1z`,`M17 3h3a1 1 0 0 1 1 1v3a1 1 0 0 1 -1 1h-3a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1z`,`M4 16h3a1 1 0 0 1 1 1v3a1 1 0 0 1 -1 1h-3a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1z`,`M21 16h-3a2 2 0 0 0-2 2v3`,`M21 21v.01`,`M12 7v3a2 2 0 0 1-2 2H7`,`M3 12h.01`,`M12 3h.01`,`M12 16v.01`,`M16 12h1`,`M21 12v.01`,`M12 21v-1`],fills:[],accents:[]},ar={name:`radius`,family:`ui`,paths:[`M20.34 17.52a10 10 0 1 0-2.82 2.82`,`M17 19a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`m13.41 13.41 4.18 4.18`,`M10 12a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`],fills:[],accents:[]},or={name:`rainbow`,family:`ui`,paths:[`M22 17a10 10 0 0 0-20 0`,`M6 17a6 6 0 0 1 12 0`,`M10 17a2 2 0 0 1 4 0`],fills:[],accents:[]},sr={name:`rectangle-horizontal`,family:`ui`,paths:[`M4 6h16a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-16a2 2 0 0 1 -2 -2v-8a2 2 0 0 1 2 -2z`],fills:[],accents:[`M4 6h16a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z`]},cr={name:`redo-2`,family:`ui`,paths:[`m15 14 5-5-5-5`,`M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13`],fills:[],accents:[]},lr={name:`refresh-ccw`,family:`ui`,paths:[`M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,`M3 3v5h5`,`M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16`,`M16 16h5v5`],fills:[],accents:[]},ur={name:`refresh-cw`,family:`ui`,paths:[`M4.5 12A7.5 7.5 0 0 1 18 7.5`,`M18 3v4.5h-4.5`,`M19.5 12A7.5 7.5 0 0 1 6 16.5`,`M6 21v-4.5h4.5`],fills:[],accents:[]},dr={name:`repeat`,family:`ui`,paths:[`m17 2 4 4-4 4`,`M3 11v-1a4 4 0 0 1 4-4h14`,`m7 22-4-4 4-4`,`M21 13v1a4 4 0 0 1-4 4H3`],fills:[],accents:[]},fr={name:`replace`,family:`ui`,paths:[`M14 4a1 1 0 0 1 1-1`,`M15 10a1 1 0 0 1-1-1`,`M21 4a1 1 0 0 0-1-1`,`M21 9a1 1 0 0 1-1 1`,`m3 7 3 3 3-3`,`M6 10V5a2 2 0 0 1 2-2h2`,`M4 14h5a1 1 0 0 1 1 1v5a1 1 0 0 1 -1 1h-5a1 1 0 0 1 -1 -1v-5a1 1 0 0 1 1 -1z`],fills:[],accents:[]},pr={name:`rotate-ccw`,family:`ui`,paths:[`M4.5 12A7.5 7.5 0 1 0 6 7.5`,`M6 3v4.5h4.5`],fills:[],accents:[]},mr={name:`rotate-ccw-clock`,family:`ui`,paths:[`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,`M3 3v5h5`,`M12 7v5l4 2`],fills:[],accents:[]},hr={name:`rotate-cw`,family:`ui`,paths:[`M19.5 12A7.5 7.5 0 1 1 18 7.5`,`M18 3v4.5h-4.5`],fills:[],accents:[]},gr={name:`rows-3`,family:`ui`,paths:[`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`,`M21 9H3`,`M21 15H3`],fills:[],accents:[]},_r={name:`ruler`,family:`ui`,paths:[`M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z`,`m14.5 12.5 2-2`,`m11.5 9.5 2-2`,`m8.5 6.5 2-2`,`m17.5 15.5 2-2`],fills:[],accents:[]},vr={name:`ruler-dimension-line`,family:`ui`,paths:[`M10 15v-3`,`M14 15v-3`,`M18 15v-3`,`M2 8V4`,`M22 6H2`,`M22 8V4`,`M6 15v-3`,`M4 12h16a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-16a2 2 0 0 1 -2 -2v-4a2 2 0 0 1 2 -2z`],fills:[],accents:[]},yr={name:`save`,family:`ui`,paths:[`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,`M7 3v4a1 1 0 0 0 1 1h7`],fills:[],accents:[]},br={name:`scaling`,family:`ui`,paths:[`M11 3.5H5.5a2 2 0 0 0 -2 2v13a2 2 0 0 0 2 2h13a2 2 0 0 0 2 -2V13`,`M7.5 12.5h4v4h-4z`,`M13.5 10.5l6-6`,`M15 4.5h4.5V9`],fills:[],accents:[`M7.5 12.5h4v4h-4z`]},xr={name:`scissors`,family:`ui`,paths:[`M3.5 6.5a2.5 2.5 0 1 0 5 0a2.5 2.5 0 1 0 -5 0z`,`M3.5 17.5a2.5 2.5 0 1 0 5 0a2.5 2.5 0 1 0 -5 0z`,`M8 8l12 10`,`M8 16L20 6`],fills:[],accents:[]},Sr={name:`search`,family:`ui`,paths:[`M4 10.5a6.5 6.5 0 1 0 13 0a6.5 6.5 0 1 0 -13 0z`,`M15.5 15.5L20 20`],fills:[],accents:[]},Cr={name:`send`,family:`ui`,paths:[`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,`m21.854 2.147-10.94 10.939`],fills:[],accents:[]},wr={name:`settings`,family:`ui`,paths:[`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,`M9 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0z`],fills:[],accents:[]},Tr={name:`settings-2`,family:`ui`,paths:[`M14 17H5`,`M19 7h-9`,`M14 17a3 3 0 1 0 6 0a3 3 0 1 0 -6 0z`,`M4 7a3 3 0 1 0 6 0a3 3 0 1 0 -6 0z`],fills:[],accents:[]},Er={name:`shapes`,family:`ui`,paths:[`M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z`,`M4 14h5a1 1 0 0 1 1 1v5a1 1 0 0 1 -1 1h-5a1 1 0 0 1 -1 -1v-5a1 1 0 0 1 1 -1z`,`M14 17.5a3.5 3.5 0 1 0 7 0a3.5 3.5 0 1 0 -7 0z`],fills:[],accents:[`M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z`]},Dr={name:`share-2`,family:`ui`,paths:[`M15 5a3 3 0 1 0 6 0a3 3 0 1 0 -6 0z`,`M3 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0z`,`M15 19a3 3 0 1 0 6 0a3 3 0 1 0 -6 0z`,`M8.59 13.51L15.42 17.49`,`M15.41 6.51L8.59 10.49`],fills:[],accents:[]},Or={name:`shell`,family:`ui`,paths:[`M14 11a2 2 0 1 1-4 0 4 4 0 0 1 8 0 6 6 0 0 1-12 0 8 8 0 0 1 16 0 10 10 0 1 1-20 0 11.93 11.93 0 0 1 2.42-7.22 2 2 0 1 1 3.16 2.44`],fills:[],accents:[]},kr={name:`shield-check`,family:`ui`,paths:[`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,`m9 12 2 2 4-4`],fills:[],accents:[]},Ar={name:`sigma`,family:`ui`,paths:[`M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2`],fills:[],accents:[]},jr={name:`signature`,family:`ui`,paths:[`m21 17-2.156-1.868A.5.5 0 0 0 18 15.5v.5a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1c0-2.545-3.991-3.97-8.5-4a1 1 0 0 0 0 5c4.153 0 4.745-11.295 5.708-13.5a2.5 2.5 0 1 1 3.31 3.284`,`M3 21h18`],fills:[],accents:[]},Mr={name:`sliders-horizontal`,family:`ui`,paths:[`M3.5 6H10`,`M14 6h6.5`,`M10 6a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`M3.5 12h11`,`M18.5 12h2`,`M14.5 12a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`M3.5 18h2`,`M9.5 18h11`,`M5.5 18a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`],fills:[],accents:[]},Nr={name:`sparkles`,family:`ui`,paths:[`M10 5.5c.5 4.5 3 7 7.5 7.5-4.5 .5-7 3-7.5 7.5-.5-4.5-3-7-7.5-7.5 4.5-.5 7-3 7.5-7.5z`,`M18.5 3v4`,`M16.5 5h4`],fills:[],accents:[`M10 5.5c.5 4.5 3 7 7.5 7.5-4.5 .5-7 3-7.5 7.5-.5-4.5-3-7-7.5-7.5 4.5-.5 7-3 7.5-7.5z`]},Pr={name:`spell-check`,family:`ui`,paths:[`m20 15-5.5 5.5L12 18`,`m4 16 6-12 5.115 10.23`,`M6 12h8`],fills:[],accents:[]},Fr={name:`spline`,family:`ui`,paths:[`M3 19a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`M17 5a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`M6.5 17.5C8 11 16 13 17.5 6.5`],fills:[],accents:[]},Ir={name:`split`,family:`ui`,paths:[`M16 3h5v5`,`M8 3H3v5`,`M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3`,`m15 9 6-6`],fills:[],accents:[]},Lr={name:`square`,family:`ui`,paths:[`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`],fills:[],accents:[`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`]},Rr={name:`square-check-big`,family:`ui`,paths:[`M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344`,`m9 11 3 3L22 4`],fills:[],accents:[]},zr={name:`square-dashed`,family:`ui`,paths:[`M3 5a2 2 0 0 1 2 -2`,`M19 3a2 2 0 0 1 2 2`,`M21 19a2 2 0 0 1 -2 2`,`M5 21a2 2 0 0 1 -2 -2`,`M8.5 3h2`,`M13.5 3h2`,`M8.5 21h2`,`M13.5 21h2`,`M3 8.5v2`,`M3 13.5v2`,`M21 8.5v2`,`M21 13.5v2`],fills:[],accents:[`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`]},Br={name:`square-function`,family:`ui`,paths:[`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`,`M9 17c2 0 2.8-1 2.8-2.8V10c0-2 1-3.3 3.2-3`,`M9 11.2h5.7`],fills:[],accents:[]},Vr={name:`square-kanban`,family:`ui`,paths:[`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`,`M8 7v7`,`M12 7v4`,`M16 7v9`],fills:[],accents:[]},Hr={name:`star`,family:`ui`,paths:[`M12 3L14.5 9.5H21L15.5 13.5L17.5 20L12 16.5L6.5 20L8.5 13.5L3 9.5H9.5z`],fills:[],accents:[`M12 3L14.5 9.5H21L15.5 13.5L17.5 20L12 16.5L6.5 20L8.5 13.5L3 9.5H9.5z`]},Ur={name:`step-forward`,family:`ui`,paths:[`M10.029 4.285A2 2 0 0 0 7 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z`,`M3 4v16`],fills:[],accents:[]},Wr={name:`sticker`,family:`ui`,paths:[`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,`M15 3v5a1 1 0 0 0 1 1h5`,`M8 13h.01`,`M16 13h.01`,`M10 16s.8 1 2 1c1.3 0 2-1 2-1`],fills:[],accents:[]},Gr={name:`sticky-note`,family:`ui`,paths:[`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,`M15 3v5a1 1 0 0 0 1 1h5`],fills:[],accents:[`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`]},Kr={name:`strikethrough`,family:`ui`,paths:[`M16 4H9a3 3 0 0 0-2.83 4`,`M14 12a4 4 0 0 1 0 8H6`,`M4 12L20 12`],fills:[],accents:[]},qr={name:`subscript`,family:`ui`,paths:[`m4 5 8 8`,`m12 5-8 8`,`M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07`],fills:[],accents:[]},Jr={name:`superscript`,family:`ui`,paths:[`m4 19 8-8`,`m12 19-8-8`,`M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06`],fills:[],accents:[]},Yr={name:`swatch-book`,family:`ui`,paths:[`M11 17a4 4 0 0 1-8 0V5a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2Z`,`M16.7 13H19a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H7`,`M 7 17h.01`,`m11 8 2.3-2.3a2.4 2.4 0 0 1 3.404.004L18.6 7.6a2.4 2.4 0 0 1 .026 3.434L9.9 19.8`],fills:[],accents:[]},Xr={name:`table`,family:`ui`,paths:[`M12 3v18`,`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`,`M3 9h18`,`M3 15h18`],fills:[],accents:[]},Zr={name:`table-2`,family:`ui`,paths:[`M3 9h18`,`M9 3v18`,`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`],fills:[],accents:[]},Qr={name:`table-properties`,family:`ui`,paths:[`M15 3v18`,`M5 3h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2z`,`M21 9H3`,`M21 15H3`],fills:[],accents:[]},$r={name:`tag`,family:`ui`,paths:[`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`],fills:[`M7 7.5a0.5 0.5 0 1 0 1 0a0.5 0.5 0 1 0 -1 0z`],accents:[]},ei={name:`text-cursor`,family:`ui`,paths:[`M17 22h-1a4 4 0 0 1-4-4V6a4 4 0 0 1 4-4h1`,`M7 22h1a4 4 0 0 0 4-4`,`M7 2h1a4 4 0 0 1 4 4`],fills:[],accents:[]},ti={name:`text-cursor-input`,family:`ui`,paths:[`M14 7h5a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-5`,`M8 17H5a2 2 0 0 1 -2 -2V9a2 2 0 0 1 2 -2h3`,`M11 4v16`,`M9 4h4`,`M9 20h4`],fills:[],accents:[]},ni={name:`thumbs-up`,family:`ui`,paths:[`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,`M7 10v12`],fills:[],accents:[]},ri={name:`toggle-left`,family:`ui`,paths:[`M6 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0z`,`M9 5h6a7 7 0 0 1 7 7v0a7 7 0 0 1 -7 7h-6a7 7 0 0 1 -7 -7v0a7 7 0 0 1 7 -7z`],fills:[],accents:[]},ii={name:`trash`,family:`ui`,paths:[`M4 6.5h16`,`M9 6.5V5a1.5 1.5 0 0 1 1.5 -1.5h3A1.5 1.5 0 0 1 15 5v1.5`,`M6 6.5l1 12.5a2 2 0 0 0 2 2h6a2 2 0 0 0 2 -2l1-12.5`],fills:[],accents:[]},ai={name:`triangle-alert`,family:`ui`,paths:[`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,`M12 9v4`,`M12 17h.01`],fills:[],accents:[]},oi={name:`type`,family:`ui`,paths:[`M5 7.5V5h14v2.5`,`M12 5v14`,`M9 19h6`],fills:[],accents:[]},si={name:`underline`,family:`ui`,paths:[`M6 4v6a6 6 0 0 0 12 0V4`,`M4 20L20 20`],fills:[],accents:[]},ci={name:`undo-2`,family:`ui`,paths:[`M9 14 4 9l5-5`,`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`],fills:[],accents:[]},li={name:`ungroup`,family:`ui`,paths:[`M5 3.5h4a1.5 1.5 0 0 1 1.5 1.5v4a1.5 1.5 0 0 1 -1.5 1.5h-4a1.5 1.5 0 0 1 -1.5 -1.5v-4a1.5 1.5 0 0 1 1.5 -1.5z`,`M15 13.5h4a1.5 1.5 0 0 1 1.5 1.5v4a1.5 1.5 0 0 1 -1.5 1.5h-4a1.5 1.5 0 0 1 -1.5 -1.5v-4a1.5 1.5 0 0 1 1.5 -1.5z`],fills:[],accents:[]},ui={name:`unlink`,family:`ui`,paths:[`m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71`,`m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71`,`M8 2L8 5`,`M2 8L5 8`,`M16 19L16 22`,`M19 16L22 16`],fills:[],accents:[]},di={name:`upload`,family:`ui`,paths:[`M12 3v12`,`m17 8-5-5-5 5`,`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`],fills:[],accents:[]},fi={name:`user`,family:`ui`,paths:[`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,`M8 7a4 4 0 1 0 8 0a4 4 0 1 0 -8 0z`],fills:[],accents:[]},pi={name:`vector-polygon`,family:`ui`,paths:[`m12.828 4.813 5.344 2.375`,`m15.769 18.153 3.461-8.306`,`m5.687 14.074 7.625 4.852`,`M9.772 5.579 5.228 11.42`,`M9 4a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`M13 20a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`M18 8a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`M2 13a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`],fills:[],accents:[`M11 4l9 4-5 12-11-7z`]},mi={name:`vector-square`,family:`ui`,paths:[`M17.055 4.533a24 24 0 00-10.11 0`,`M19.467 17.055a24 24 0 000-10.11`,`M4.533 6.945a24 24 0 000 10.11`,`M6.945 19.467a24 24 0 0010.11 0`,`M17 19a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`M17 5a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`M3 19a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`M3 5a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`],fills:[],accents:[`M5 5h14v14H5z`]},hi={name:`video`,family:`ui`,paths:[`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,`M4 6h10a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-8a2 2 0 0 1 2 -2z`],fills:[],accents:[]},gi={name:`volume-2`,family:`ui`,paths:[`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,`M16 9a5 5 0 0 1 0 6`,`M19.364 18.364a9 9 0 0 0 0-12.728`],fills:[],accents:[]},_i={name:`wand-sparkles`,family:`ui`,paths:[`M3.5 20.5L13.5 10.5`,`M13.5 8.5L16 6l2 2-2.5 2.5z`,`M19.5 13.5v3`,`M18 15h3`,`M8 3.5v3`,`M6.5 5h3`],fills:[],accents:[`M13.5 8.5L16 6l2 2-2.5 2.5z`]},vi={name:`waves-horizontal`,family:`ui`,paths:[`M2 12q2.5 2 5 0t5 0 5 0 5 0`,`M2 19q2.5 2 5 0t5 0 5 0 5 0`,`M2 5q2.5 2 5 0t5 0 5 0 5 0`],fills:[],accents:[]},yi={name:`waypoints`,family:`ui`,paths:[`m10.586 5.414-5.172 5.172`,`m18.586 13.414-5.172 5.172`,`M6 12h12`,`M10 20a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`M10 4a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`M18 12a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`M2 12a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`],fills:[],accents:[`M10 20a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`M10 4a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`M18 12a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`,`M2 12a2 2 0 1 0 4 0a2 2 0 1 0 -4 0z`]},bi={name:`whole-word`,family:`ui`,paths:[`M4 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0z`,`M10 9v6`,`M14 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0z`,`M14 7v8`,`M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1`],fills:[],accents:[]},xi={name:`workflow`,family:`ui`,paths:[`M5 3h4a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-4a2 2 0 0 1 -2 -2v-4a2 2 0 0 1 2 -2z`,`M7 11v4a2 2 0 0 0 2 2h4`,`M15 13h4a2 2 0 0 1 2 2v4a2 2 0 0 1 -2 2h-4a2 2 0 0 1 -2 -2v-4a2 2 0 0 1 2 -2z`],fills:[],accents:[]},Si={name:`x`,family:`ui`,paths:[`M6 6l12 12`,`M18 6L6 18`],fills:[],accents:[]},Ci={name:`zap`,family:`ui`,paths:[`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`],fills:[],accents:[]},wi={name:`zoom-in`,family:`ui`,paths:[`M3 11a8 8 0 1 0 16 0a8 8 0 1 0 -16 0z`,`M21 21L16.65 16.65`,`M11 8L11 14`,`M8 11L14 11`],fills:[],accents:[`M3 11a8 8 0 1 0 16 0a8 8 0 1 0 -16 0z`]},Ti={name:`zoom-out`,family:`ui`,paths:[`M3 11a8 8 0 1 0 16 0a8 8 0 1 0 -16 0z`,`M21 21L16.65 16.65`,`M8 11L14 11`],fills:[],accents:[]},Ei=`var(--kit-icon-accent, var(--kit-primary, currentColor))`;function H(e){let t=(0,j.forwardRef)(function({size:t=24,color:n=`currentColor`,strokeWidth:r=ge,absoluteStrokeWidth:i=!1,accent:a,className:o,children:s,...c},l){let u=Number(t);return(0,j.createElement)(`svg`,{ref:l,xmlns:`http://www.w3.org/2000/svg`,width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:n,strokeWidth:_e({size:Number.isFinite(u)?u:24,strokeWidth:Number(r),absoluteStrokeWidth:i}),strokeLinecap:`round`,strokeLinejoin:`round`,className:[`tessera-icon`,`tessera-icon-${e.name}`,o].filter(Boolean).join(` `),"aria-hidden":c[`aria-label`]||c[`aria-labelledby`]?void 0:!0,...c},a===!1?null:e.accents.map((t,n)=>(0,j.createElement)(`path`,{key:`accent-${n}`,d:t,className:`tessera-icon-accent`,fill:typeof a==`string`?a:Ei,stroke:`none`,style:{fillOpacity:a===void 0?`var(--tessera-icon-accent-opacity, ${e.family===`tool`?he:0})`:he}})),e.paths.map((e,t)=>(0,j.createElement)(`path`,{key:t,d:e})),e.fills.map((e,t)=>(0,j.createElement)(`path`,{key:`fill-${t}`,d:e,fill:n})),s)});return t.displayName=`${e.name}Icon`,t}var Di=H(ve),Oi=H(ye),ki=H(B),Ai=H(be),ji=H(xe),Mi=H(Se),Ni=H(Ce),Pi=H(we),Fi=H(Te),Ii=H(Ee),Li=H(De),Ri=H(Oe),zi=H(ke),Bi=H(Ae),Vi=H(je),Hi=H(Me),Ui=H(Ne),Wi=H(Pe),Gi=H(Fe),Ki=H(Ie),qi=H(Le),Ji=H(Re),Yi=H(ze),Xi=H(Be),Zi=H(Ve),Qi=H(He),$i=H(Ue),ea=H(We),ta=H(Ge),na=H(Ke),ra=H(qe),ia=H(Je),aa=H(Ye),oa=H(Xe),sa=H(Ze),ca=H(Qe),la=H($e),ua=H(et),da=H(tt),fa=H(nt),pa=H(rt),ma=H(it),ha=H(at),ga=H(ot),_a=H(st),va=H(ct),ya=H(lt),ba=H(ut),xa=H(dt),Sa=H(ft),Ca=H(pt),wa=H(mt),Ta=H(ht),Ea=H(gt),Da=H(_t),Oa=H(vt),ka=H(yt),Aa=H(bt),ja=H(xt),Ma=H(St),Na=H(Ct),Pa=H(wt),Fa=H(Tt),Ia=H(Et),La=H(Dt),Ra=H(Ot),za=H(kt),Ba=H(At),Va=H(jt),Ha=H(Mt),Ua=H(Nt),Wa=H(Pt),Ga=H(Ft),Ka=H(It),qa=H(Lt),Ja=H(Rt),Ya=H(zt),Xa=H(Bt),Za=H(Vt),Qa=H(Ht),$a=H(Ut),eo=H(Wt),to=H(Gt),no=H(Kt),ro=H(qt),io=H(Jt),ao=H(Yt),oo=H(Xt),so=H(Zt),co=H(Qt),lo=H($t),uo=H(en),fo=H(tn),po=H(nn),mo=H(rn),ho=H(an),go=H(on),_o=H(sn),vo=H(cn),yo=H(ln),bo=H(un),xo=H(dn),So=H(fn),Co=H(pn),wo=H(mn),To=H(hn),Eo=H(gn),Do=H(V),Oo=H(_n),ko=H(vn),Ao=H(yn),jo=H(bn),Mo=H(xn),No=H(Sn),Po=H(Cn),Fo=H(wn),Io=H(Tn),Lo=H(En),Ro=H(Dn),zo=H(On),Bo=H(kn),Vo=H(An),Ho=H(jn),Uo=H(Mn),Wo=H(Nn),Go=H(Pn),Ko=H(Fn),qo=H(In),Jo=H(Ln),Yo=H(Rn),Xo=H(zn),Zo=H(Bn),Qo=H(Vn),$o=H(Hn),es=H(Un),ts=H(Wn),ns=H(Gn),rs=H(Kn),is=H(qn),as=H(Jn),os=H(Yn),ss=H(Xn),cs=H(Zn),ls=H(Qn),us=H($n),ds=H(er),fs=H(tr),ps=H(nr),ms=H(rr),hs=H(ir),gs=H(ar),_s=H(or),vs=H(sr),ys=H(cr),bs=H(lr),xs=H(ur),Ss=H(dr),Cs=H(fr),ws=H(pr),Ts=H(mr),Es=H(hr),Ds=H(gr),Os=H(_r),ks=H(vr),As=H(yr),js=H(br),Ms=H(xr),Ns=H(Sr),Ps=H(Cr),Fs=H(wr),Is=H(Tr),Ls=H(Er),Rs=H(Dr),zs=H(Or),Bs=H(kr),Vs=H(Ar),Hs=H(jr),Us=H(Mr),Ws=H(Nr),Gs=H(Pr),Ks=H(Fr),qs=H(Ir),Js=H(Lr),Ys=H(Rr),Xs=H(zr),Zs=H(Br),Qs=H(Vr),$s=H(Hr),ec=H(Ur),tc=H(Wr),nc=H(Gr),rc=H(Kr),ic=H(qr),ac=H(Jr),oc=H(Yr),sc=H(Xr),cc=H(Zr),lc=H(Qr),uc=H($r),dc=H(ei),fc=H(ti),pc=H(ni),mc=H(ri),hc=H(ii),gc=H(ai),_c=H(oi),vc=H(si),yc=H(ci),bc=H(li),xc=H(ui),Sc=H(di),Cc=H(fi),wc=H(pi),Tc=H(mi),Ec=H(hi),Dc=H(gi),Oc=H(_i),kc=H(vi),Ac=H(yi),jc=H(bi),Mc=H(xi),Nc=H(Si),Pc=H(Ci),Fc=H(wi),Ic=H(Ti),Lc=1.5,Rc=(0,j.forwardRef)(function({variant:e,size:t,iconOnly:n,loading:r,className:i,children:a,...o},s){return(0,I.jsxs)(`button`,{ref:s,type:`button`,className:Vc(`kui-button`,i),"data-variant":e,"data-size":t,"data-icon-only":n||void 0,"aria-busy":r||void 0,...o,children:[r?(0,I.jsx)(zc,{size:16}):null,a]})});function zc({size:e=16,label:t,className:n}){return(0,I.jsx)(Ao,{className:Vc(`kui-spinner`,n),size:e,strokeWidth:Lc,role:t?`status`:void 0,"aria-label":t,"aria-hidden":!t||void 0})}function Bc({icon:e,label:t,pressed:n,className:r,...i}){return(0,I.jsx)(`button`,{type:`button`,className:Vc(`kui-icon-button`,r),"aria-label":t,title:t,"aria-pressed":n,...i,children:(0,I.jsx)(e,{size:16,strokeWidth:Lc,"aria-hidden":`true`})})}function Vc(...e){return e.filter(Boolean).join(` `)}function Hc(e,t,n){let r=e>1,i=e+t<n-1;return r&&i?`both`:r?`start`:i?`end`:`none`}function Uc(e,t){let[n,r]=(0,j.useState)(`none`);return(0,j.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=()=>r(Hc(t.scrollLeft,t.clientWidth,t.scrollWidth));n(),t.addEventListener(`scroll`,n,{passive:!0});let i=null,a=()=>{if(i){i.disconnect(),i.observe(t);for(let e of t.querySelectorAll(`:scope > *, .kui-ribbon-group`))i.observe(e)}};typeof ResizeObserver<`u`&&(i=new ResizeObserver(n)),a();let o=typeof MutationObserver<`u`?new MutationObserver(()=>(a(),n())):null;return o?.observe(t,{childList:!0,subtree:!0}),()=>{t.removeEventListener(`scroll`,n),i?.disconnect(),o?.disconnect()}},[e,t]),n}function Wc({className:e,panelClassName:t,role:n,resetKey:r,labels:i,testId:a,panelRef:o,children:s}){let c=(0,j.useRef)(null),l=o??c,u=Uc(l,r),d=e=>{let t=l.current;if(!t)return;let n=e*Math.max(80,t.clientWidth*.75);typeof t.scrollBy==`function`?t.scrollBy({left:n,behavior:`smooth`}):t.scrollLeft+=n};return(0,I.jsxs)(`div`,{className:`kui-overflow-strip ${e}`,"data-overflow":u,children:[(0,I.jsx)(`div`,{ref:l,className:`kui-overflow-strip-panel ${t}`,role:n,children:s}),u===`start`||u===`both`?(0,I.jsx)(`button`,{type:`button`,className:`kui-ribbon-scroll`,"data-side":`start`,"aria-label":i.start,title:i.start,onClick:()=>d(-1),"data-testid":`${a}-start`,children:(0,I.jsx)(na,{size:14,strokeWidth:Lc,"aria-hidden":`true`})}):null,u===`end`||u===`both`?(0,I.jsx)(`button`,{type:`button`,className:`kui-ribbon-scroll`,"data-side":`end`,"aria-label":i.end,title:i.end,onClick:()=>d(1),"data-testid":`${a}-end`,children:(0,I.jsx)(ra,{size:14,strokeWidth:Lc,"aria-hidden":`true`})}):null]})}var Gc=(0,j.createContext)(`full`),Kc=(0,j.createContext)(e=>`More: ${e}`),qc=Object.freeze({size:`full`,icons:new Set,collapsed:new Set}),Jc=(0,j.createContext)(qc);function Yc(e){return e.id??e.label}function Xc({id:e,label:t,disabled:n,children:r}){let i=de();return(0,I.jsx)(Gc.Provider,{value:`full`,children:(0,I.jsx)(Jc.Provider,{value:qc,children:(0,I.jsxs)(`div`,{className:`kui-ribbon-group`,children:[(0,I.jsx)(`div`,{className:`kui-ribbon-group-body`,children:(0,I.jsxs)(`fieldset`,{className:`kui-element`,disabled:n,role:`presentation`,children:[r,e?i.renderExtras(e,`ribbon`):null]})}),(0,I.jsx)(`div`,{className:`kui-ribbon-group-label`,children:t})]})})})}function Zc(e){let t=[];for(let n of j.Children.toArray(e)){if(!(0,j.isValidElement)(n))continue;if(n.props.primary){t.push(n);continue}let{type:e}=n;if(e!==j.Fragment&&typeof e!=`string`&&e!==tl&&e!==nl)continue;let r=Zc(n.props.children);r.length&&t.push(e===j.Fragment?(0,I.jsx)(j.Fragment,{children:r},n.key):(0,j.cloneElement)(n,void 0,r))}return t}function Qc({id:e,label:t,icon:n,disabled:r,children:i}){let a=(0,j.useContext)(Kc),o=(0,j.useRef)(null),s=(0,j.useRef)(null),[c,l]=(0,j.useState)(!0),[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)(null),m=Zc(i);(0,j.useLayoutEffect)(()=>{if(u)return;let e=m.length>0&&o.current?.querySelector(`[data-primary], button, input, select, textarea`)!=null;e!==c&&l(e)});let h=e??t,g=()=>{u||p(o.current?.getBoundingClientRect().width??null),d(e=>!e)},_=a(t);return(0,I.jsxs)(`div`,{className:`kui-line-group`,role:`group`,"aria-label":t,"data-kit-ui-id":e,children:[u&&c?(0,I.jsx)(`div`,{className:`kui-line-inline`,"aria-hidden":`true`,style:{width:f??void 0,boxSizing:`border-box`,flex:`none`}}):(0,I.jsx)(`div`,{ref:o,className:`kui-line-inline`,hidden:!c,children:(0,I.jsx)(`fieldset`,{className:`kui-element`,disabled:r,role:`presentation`,children:(0,I.jsx)(Gc.Provider,{value:`primary`,children:m})})}),(0,I.jsxs)(`span`,{ref:s,style:{display:`inline-flex`},children:[c?(0,I.jsx)(`button`,{type:`button`,className:`kui-line-more`,"aria-label":_,title:_,"aria-haspopup":`dialog`,"aria-expanded":u,onClick:g,"data-testid":`kui-line-more-${h}`,children:(0,I.jsx)(ta,{size:12,strokeWidth:Lc,"aria-hidden":`true`})}):(0,I.jsxs)(`button`,{type:`button`,className:`kui-ribbon-button kui-line-collapsed`,"data-size":`small`,title:t,"aria-haspopup":`dialog`,"aria-expanded":u,onClick:g,"data-testid":`kui-line-group-${h}`,children:[n?(0,I.jsx)(n,{size:16,strokeWidth:Lc,"aria-hidden":`true`}):null,(0,I.jsx)(`span`,{children:t}),(0,I.jsx)(ta,{size:12,strokeWidth:Lc,"aria-hidden":`true`})]}),(0,I.jsx)(pe,{open:u,anchor:s,onClose:()=>d(!1),label:t,className:`kui-line-popover`,testId:`kui-line-popover-${h}`,children:(0,I.jsx)(Xc,{id:e,label:t,disabled:r,children:i})})]})]})}function $c({id:e,label:t,icon:n,disabled:r,children:i}){let a=(0,j.useRef)(null),[o,s]=(0,j.useState)(!1),c=Yc({id:e,label:t});return(0,I.jsx)(`div`,{className:`kui-ribbon-group kui-ribbon-group-collapsed`,role:`group`,"aria-label":t,"data-kit-ui-id":e,"data-ribbon-group":c,children:(0,I.jsxs)(`span`,{ref:a,style:{display:`inline-flex`},children:[(0,I.jsxs)(`button`,{type:`button`,className:`kui-ribbon-button`,"data-size":`large`,title:t,"aria-haspopup":`dialog`,"aria-expanded":o,onClick:()=>s(e=>!e),"data-testid":`kui-ribbon-collapsed-${c}`,children:[(0,I.jsxs)(`span`,{style:{display:`inline-flex`,alignItems:`center`},children:[n?(0,I.jsx)(n,{size:28,strokeWidth:Lc,"aria-hidden":`true`}):null,(0,I.jsx)(ta,{size:12,strokeWidth:Lc,"aria-hidden":`true`})]}),(0,I.jsx)(`span`,{children:t})]}),(0,I.jsx)(pe,{open:o,anchor:a,onClose:()=>s(!1),label:t,className:`kui-line-popover`,testId:`kui-ribbon-collapsed-panel-${c}`,children:(0,I.jsx)(Xc,{id:e,label:t,disabled:r,children:i})})]})})}function el({id:e,label:t,icon:n,children:r}){let i=de(),a=(0,j.useContext)(Gc),o=(0,j.useContext)(Jc);e&&i.drawn(e);let s=e?i.state(e):null;if(s?.hidden)return null;if(a===`line`)return(0,I.jsx)(Qc,{id:e,label:t,icon:n,disabled:s?.disabled??!1,children:r});let c=Yc({id:e,label:t});return o.collapsed.has(c)?(0,I.jsx)($c,{id:e,label:t,icon:n,disabled:s?.disabled??!1,children:r}):o.icons.has(c)&&o.size!==`icon`?(0,I.jsx)(Jc.Provider,{value:{...o,size:`icon`},children:(0,I.jsx)(el,{id:e,label:t,icon:n,children:r})}):(0,I.jsxs)(`div`,{className:`kui-ribbon-group`,role:`group`,"aria-label":t,"data-kit-ui-id":e,"data-ribbon-group":Yc({id:e,label:t}),children:[(0,I.jsx)(`div`,{className:`kui-ribbon-group-body`,children:(0,I.jsxs)(`fieldset`,{className:`kui-element`,disabled:s?.disabled??!1,role:`presentation`,children:[r,e?i.renderExtras(e,`ribbon`):null]})}),(0,I.jsx)(`div`,{className:`kui-ribbon-group-label`,children:t})]})}function tl({children:e}){let t=(0,j.useContext)(Gc)===`primary`;return(0,I.jsx)(`div`,{className:t?`kui-line-contents`:`kui-ribbon-stack`,children:e})}function nl({children:e}){let t=(0,j.useContext)(Gc)===`primary`;return(0,I.jsx)(`div`,{className:t?`kui-line-contents`:`kui-ribbon-row`,children:e})}function rl(e,t,n,r,i=`full`){return e===`full`?i===`icon`&&n?`icon`:i!==`full`&&t===`large`?`small`:t:e===`primary`?n&&!r?`icon`:t===`large`?`small`:t:t}function il({icon:e,label:t,size:n=`small`,pressed:r,swatch:i,primary:a,lineLabel:o,...s}){let c=(0,j.useContext)(Gc),l=(0,j.useContext)(Jc);if(c===`primary`&&!a)return null;let u=rl(c,n,e!=null,o,l.size),d=u===`large`?28:16;return(0,I.jsxs)(`button`,{type:`button`,className:`kui-ribbon-button`,"data-size":u,"data-primary":a||void 0,"aria-pressed":r,"aria-label":t,title:t,...s,children:[e?(0,I.jsxs)(`span`,{style:{display:`inline-flex`,flexDirection:`column`,alignItems:`center`},children:[(0,I.jsx)(e,{size:d,strokeWidth:Lc,"aria-hidden":`true`}),i?(0,I.jsx)(`span`,{style:{width:d,height:3,marginTop:1,borderRadius:1,background:i}}):null]}):null,u===`icon`?null:(0,I.jsx)(`span`,{children:t})]})}var al=(0,j.createContext)(null);function ol(e,t,n){let r=(0,j.useRef)({inside:t,close:n});r.current={inside:t,close:n},(0,j.useEffect)(()=>{if(!e)return;let t=e=>{r.current.inside.some(t=>t.current?.contains(e.target))||r.current.close()},n=e=>{e.key===`Escape`&&r.current.close()};return window.addEventListener(`pointerdown`,t,!0),window.addEventListener(`keydown`,n),()=>{window.removeEventListener(`pointerdown`,t,!0),window.removeEventListener(`keydown`,n)}},[e])}var sl=e=>[...e.querySelectorAll(`[role^="menuitem"]:not(:disabled)`)].filter(t=>t.parentElement?.closest(`[role="menu"]`)===e);function cl(e,t){if(e.key===`Escape`&&t){e.preventDefault(),e.stopPropagation(),t();return}let n=sl(e.currentTarget);if(!n.length)return;let r=n.indexOf(document.activeElement),i={ArrowDown:r+1,ArrowUp:r<0?n.length-1:r-1,Home:0,End:n.length-1}[e.key];i!==void 0&&(e.preventDefault(),e.stopPropagation(),n[(i+n.length)%n.length].focus())}function ll(e,t,n,r){let i=(0,j.useRef)(r);i.current=r,(0,j.useLayoutEffect)(()=>{if(!e)return;let t=i.current();return()=>{let e=document.activeElement;t?.isConnected&&(!e||e===document.body||n.current?.contains(e))&&t.focus()}},[n,e]),(0,j.useLayoutEffect)(()=>{e&&t&&n.current&&sl(n.current)[0]?.focus()},[n,e,t])}function ul({trigger:e,children:t,align:n=`start`,placement:r=`below`}){let[i,a]=(0,j.useState)(!1),o=(0,j.useRef)(null),s=(0,j.useRef)(null),[c,l]=(0,j.useState)(null),u=(0,j.useCallback)(()=>a(!1),[]),d=(0,j.useCallback)(()=>{if(!o.current)return;let e=o.current.getBoundingClientRect(),t=s.current?.offsetWidth??200,i=n===`end`?e.right-t:e.left,a=e.bottom+4,c=s.current?.offsetHeight??0,u=e.top-4-8,d=Math.max(4,Math.min(i,window.innerWidth-t-4));if(r===`auto`&&a+c>window.innerHeight-8&&u>window.innerHeight-a-8){let t=Math.max(0,u);l({left:d,top:e.top-4-Math.min(c,t),maxHeight:t})}else l({left:d,top:a,maxHeight:Math.max(0,window.innerHeight-a-8)})},[n,r]);return(0,j.useLayoutEffect)(()=>{if(!i)l(null);else return d(),window.addEventListener(`resize`,d),()=>window.removeEventListener(`resize`,d)},[i,d]),ol(i,[s,o],u),ll(i,c!=null,s,()=>o.current?.querySelector(`button, [tabindex]`)??null),(0,I.jsxs)(`span`,{ref:o,style:{display:`inline-flex`},children:[e({open:i,toggle:()=>a(e=>!e)}),i?(0,I.jsx)(`div`,{ref:s,className:`kui-popover`,role:`menu`,style:c?{left:c.left,top:c.top,maxHeight:c.maxHeight}:{visibility:`hidden`},onKeyDown:e=>cl(e,u),onClick:e=>{e.target.closest(`button`)&&a(!1)},children:(0,I.jsx)(al.Provider,{value:{close:u},children:t})}):null]})}function dl({icon:e,label:t,shortcut:n,onSelect:r,disabled:i,checked:a,testId:o,uiId:s}){let c=(0,j.useContext)(al);return(0,I.jsxs)(`button`,{type:`button`,role:a===void 0?`menuitem`:`menuitemcheckbox`,"aria-checked":a,className:`kui-menu-item`,disabled:i,"data-testid":o,"data-kit-ui-id":s,onClick:()=>{c?.close(),r()},children:[a?(0,I.jsx)(ea,{size:15,strokeWidth:Lc,"aria-hidden":`true`}):e?(0,I.jsx)(e,{size:15,strokeWidth:Lc,"aria-hidden":`true`}):(0,I.jsx)(`span`,{style:{width:15}}),(0,I.jsx)(`span`,{children:t}),n?(0,I.jsx)(`kbd`,{children:n}):null]})}function fl(){return(0,I.jsx)(`div`,{className:`kui-menu-separator`,role:`separator`})}function pl({children:e,onClick:t}){return(0,I.jsx)(`footer`,{className:`kui-status-bar`,onClick:t,children:e})}function ml(){return(0,I.jsx)(`div`,{className:`kui-status-spacer`})}function hl({zoom:e,onZoom:t,onFit:n,min:r=.1,max:i=4,labels:a}){let o=e=>Math.log(e/r)/Math.log(i/r),s=e=>r*(i/r)**+e;return(0,I.jsxs)(`div`,{className:`kui-zoom`,children:[(0,I.jsx)(`button`,{type:`button`,className:`kui-icon-button`,"aria-label":a.out,title:a.out,onClick:()=>t(e/1.25),children:`−`}),(0,I.jsx)(`input`,{type:`range`,min:0,max:1,step:.001,value:o(e),onChange:e=>t(s(Number(e.target.value))),"aria-label":a.fit}),(0,I.jsx)(`button`,{type:`button`,className:`kui-icon-button`,"aria-label":a.in,title:a.in,onClick:()=>t(e*1.25),children:`+`}),(0,I.jsxs)(`span`,{className:`kui-zoom-value`,"data-testid":`kit-zoom`,children:[Math.round(e*100),`%`]}),(0,I.jsx)(`button`,{type:`button`,className:`kui-button`,"data-variant":`ghost`,onClick:n,children:a.fit})]})}function gl({title:e,children:t,actions:n,onClose:r,onEscape:i,modal:a=!0,uiId:o,testId:s,position:c,onMove:l}){let u=(0,j.useRef)(null);(0,j.useEffect)(()=>{let e=e=>{if(e.key===`Escape`){if(!a){let e=document.activeElement;if(e&&e!==document.body&&!u.current?.contains(e))return}i?i(e):r()}};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,i,a]);let d=(0,j.useRef)(null),[f,p]=(0,j.useState)(null);(0,j.useEffect)(()=>{p(null)},[c?.x,c?.y]);let m=f??c??null,h=(e,t)=>({x:Math.round(Math.min(Math.max(0,e),Math.max(0,window.innerWidth-48))),y:Math.round(Math.min(Math.max(0,t),Math.max(0,window.innerHeight-32)))}),g=l?{"data-movable":`true`,onPointerDown:e=>{if(e.button!==0)return;let t=u.current?.getBoundingClientRect(),n=m??{x:t?.left??0,y:t?.top??0};d.current={x:e.clientX,y:e.clientY,left:n.x,top:n.y},e.currentTarget.setPointerCapture?.(e.pointerId),e.preventDefault()},onPointerMove:e=>{let t=d.current;t&&p(h(t.left+e.clientX-t.x,t.top+e.clientY-t.y))},onPointerUp:e=>{let t=d.current;if(d.current=null,!t)return;let n=h(t.left+e.clientX-t.x,t.top+e.clientY-t.y);p(n),l(n)},onPointerCancel:()=>{d.current=null}}:{};return(0,I.jsx)(`div`,{className:a?`kui-dialog-backdrop`:`kui-dialog-layer`,onPointerDown:a?e=>e.target===e.currentTarget&&r():void 0,children:(0,I.jsxs)(`div`,{ref:u,className:`kui-dialog`,role:`dialog`,"aria-modal":a,"aria-label":e,"data-kit-ui-id":o,"data-testid":s,style:m?{position:`absolute`,left:m.x,top:m.y,margin:0}:void 0,children:[(0,I.jsx)(`h2`,{...g,children:e}),(0,I.jsx)(`div`,{className:`kui-dialog-body`,children:t}),(0,I.jsx)(`div`,{className:`kui-dialog-actions`,children:n})]})})}var _l=new Set,vl=[],yl=1,bl=new Map,xl=()=>{for(let e of _l)e(vl)};function Sl(e){return e===`loading`?1/0:e===`error`?6e3:4e3}function Cl(e,t){clearTimeout(bl.get(e)),bl.delete(e),Number.isFinite(t)&&bl.set(e,setTimeout(()=>Tl(e),t))}function wl(e,t,n={}){let{id:r,description:i,action:a,duration:o=Sl(e)}=n,s=r===void 0?vl.find(n=>n.level===e&&n.title===t&&n.description===i&&!n.action):void 0,c=r??s?.id??`toast-${yl++}`,l={id:c,level:e,title:t,description:i,action:a};return vl=vl.some(e=>e.id===c)?vl.map(e=>e.id===c?l:e):[...vl,l],xl(),Cl(c,o),c}function Tl(e){let t=e===void 0?vl.map(e=>e.id):[e];for(let e of t)clearTimeout(bl.get(e)),bl.delete(e);vl=e===void 0?[]:vl.filter(t=>t.id!==e),xl()}var El=Object.assign(function(e,t,n){return wl(e,t,{description:n})},{info:(e,t)=>wl(`info`,e,t),success:(e,t)=>wl(`success`,e,t),warning:(e,t)=>wl(`warning`,e,t),error:(e,t)=>wl(`error`,e,t),loading:(e,t)=>wl(`loading`,e,t),dismiss:Tl,promise(e,t,n={}){let r=wl(`loading`,t.loading,{...n,duration:1/0});return e.then(e=>wl(`success`,typeof t.success==`function`?t.success(e):t.success,{...n,id:r}),e=>wl(`error`,typeof t.error==`function`?t.error(e):t.error,{...n,id:r})),e}});function Dl({offset:e=12,closeButton:t=!0}){let n=se(),[r,i]=(0,j.useState)(vl);return(0,j.useEffect)(()=>(_l.add(i),i(vl),()=>{_l.delete(i)}),[]),(0,I.jsx)(`div`,{className:`kui-toasts`,"aria-live":`polite`,style:{top:e},children:r.map(e=>(0,I.jsxs)(`div`,{className:`kui-toast`,"data-level":e.level,role:e.level===`error`?`alert`:`status`,children:[e.level===`loading`?(0,I.jsx)(zc,{size:16,className:`kui-toast-icon`}):null,(0,I.jsxs)(`div`,{className:`kui-toast-text`,children:[(0,I.jsx)(`div`,{className:`kui-toast-title`,children:e.title}),e.description?(0,I.jsx)(`div`,{className:`kui-toast-description`,children:e.description}):null]}),e.action?(0,I.jsx)(`button`,{type:`button`,className:`kui-toast-action`,onClick:()=>{e.action?.onClick(),Tl(e.id)},children:e.action.label}):null,t?(0,I.jsx)(`button`,{type:`button`,className:`kui-toast-close`,"aria-label":n(`close`),onClick:()=>Tl(e.id),children:(0,I.jsx)(Nc,{size:12,strokeWidth:Lc,"aria-hidden":`true`})}):null]},e.id))})}var Ol=function(){return Ol=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},Ol.apply(this,arguments)};function kl(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 Al(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))}var jl=`right-scroll-bar-position`,Ml=`width-before-scroll-bar`,Nl=`with-scroll-bars-hidden`,Pl=`--removed-body-scroll-bar-size`;function Fl(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function Il(e,t){var n=(0,j.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var Ll=typeof window<`u`?j.useLayoutEffect:j.useEffect,Rl=new WeakMap;function zl(e,t){var n=Il(t||null,function(t){return e.forEach(function(e){return Fl(e,t)})});return Ll(function(){var t=Rl.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||Fl(e,null)}),i.forEach(function(e){r.has(e)||Fl(e,a)})}Rl.set(n,e)},[e]),n}function Bl(e){return e}function Vl(e,t){t===void 0&&(t=Bl);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function Hl(e){e===void 0&&(e={});var t=Vl(null);return t.options=Ol({async:!0,ssr:!1},e),t}var Ul=function(e){var t=e.sideCar,n=kl(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return j.createElement(r,Ol({},n))};Ul.isSideCarExport=!0;function Wl(e,t){return e.useMedium(t),Ul}var Gl=Hl(),Kl=function(){},ql=j.forwardRef(function(e,t){var n=j.useRef(null),r=j.useState({onScrollCapture:Kl,onWheelCapture:Kl,onTouchMoveCapture:Kl}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=kl(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=zl([n,t]),C=Ol(Ol({},b),i);return j.createElement(j.Fragment,null,u&&j.createElement(x,{sideCar:Gl,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?j.cloneElement(j.Children.only(s),Ol(Ol({},C),{ref:S})):j.createElement(v,Ol({},C,{className:c,ref:S}),s))});ql.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},ql.classNames={fullWidth:Ml,zeroRight:jl};var Jl=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function Yl(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=Jl();return t&&e.setAttribute(`nonce`,t),e}function Xl(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function Zl(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var Ql=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Yl())&&(Xl(t,n),Zl(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},$l=function(){var e=Ql();return function(t,n){j.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},eu=function(){var e=$l();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},tu={left:0,top:0,right:0,gap:0},nu=function(e){return parseInt(e||``,10)||0},ru=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[nu(n),nu(r),nu(i)]},iu=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return tu;var t=ru(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},au=eu(),ou=`data-scroll-locked`,su=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
10
- .${Nl} {
11
- overflow: hidden ${r};
12
- padding-right: ${s}px ${r};
13
- }
14
- body[${ou}] {
15
- overflow: hidden ${r};
16
- overscroll-behavior: contain;
17
- ${[t&&`position: relative ${r};`,n===`margin`&&`
18
- padding-left: ${i}px;
19
- padding-top: ${a}px;
20
- padding-right: ${o}px;
21
- margin-left:0;
22
- margin-top:0;
23
- margin-right: ${s}px ${r};
24
- `,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
25
- }
26
-
27
- .${jl} {
28
- right: ${s}px ${r};
29
- }
30
-
31
- .${Ml} {
32
- margin-right: ${s}px ${r};
33
- }
34
-
35
- .${jl} .${jl} {
36
- right: 0 ${r};
37
- }
38
-
39
- .${Ml} .${Ml} {
40
- margin-right: 0 ${r};
41
- }
42
-
43
- body[${ou}] {
44
- ${Pl}: ${s}px;
45
- }
46
- `},cu=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},lu=function(){j.useEffect(function(){return document.body.setAttribute(ou,(cu()+1).toString()),function(){var e=cu()-1;e<=0?document.body.removeAttribute(ou):document.body.setAttribute(ou,e.toString())}},[])},uu=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;lu();var a=j.useMemo(function(){return iu(i)},[i]);return j.createElement(au,{styles:su(a,!t,i,n?``:`!important`)})},du=!1;if(typeof window<`u`)try{var fu=Object.defineProperty({},"passive",{get:function(){return du=!0,!0}});window.addEventListener(`test`,fu,fu),window.removeEventListener(`test`,fu,fu)}catch{du=!1}var pu=du?{passive:!1}:!1,mu=function(e){return e.tagName===`TEXTAREA`},hu=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!mu(e)&&n[t]===`visible`)},gu=function(e){return hu(e,`overflowY`)},_u=function(e){return hu(e,`overflowX`)},vu=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),xu(e,r)){var i=Su(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},yu=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},bu=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},xu=function(e,t){return e===`v`?gu(t):_u(t)},Su=function(e,t){return e===`v`?yu(t):bu(t)},Cu=function(e,t){return e===`h`&&t===`rtl`?-1:1},wu=function(e,t,n,r,i){var a=Cu(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=Su(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&xu(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},Tu=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Eu=function(e){return[e.deltaX,e.deltaY]},Du=function(e){return e&&`current`in e?e.current:e},Ou=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ku=function(e){return`
47
- .block-interactivity-${e} {pointer-events: none;}
48
- .allow-interactivity-${e} {pointer-events: all;}
49
- `},Au=0,ju=[];function Mu(e){var t=j.useRef([]),n=j.useRef([0,0]),r=j.useRef(),i=j.useState(Au++)[0],a=j.useState(eu)[0],o=j.useRef(e);j.useEffect(function(){o.current=e},[e]),j.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Al([e.lockRef.current],(e.shards||[]).map(Du),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=j.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Tu(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=vu(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=vu(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return wu(h,t,e,h===`h`?s:c,!0)},[]),c=j.useCallback(function(e){var n=e;if(ju.length&&ju[ju.length-1]===a){var r=`deltaY`in n?Eu(n):Tu(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Ou(e.delta,r)})[0];if(i&&i.should)n.cancelable&&n.preventDefault();else if(!i){var c=(o.current.shards||[]).map(Du).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=j.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:Nu(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=j.useCallback(function(e){n.current=Tu(e),r.current=void 0},[]),d=j.useCallback(function(t){l(t.type,Eu(t),t.target,s(t,e.lockRef.current))},[]),f=j.useCallback(function(t){l(t.type,Tu(t),t.target,s(t,e.lockRef.current))},[]);j.useEffect(function(){return ju.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,pu),document.addEventListener(`touchmove`,c,pu),document.addEventListener(`touchstart`,u,pu),function(){ju=ju.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,pu),document.removeEventListener(`touchmove`,c,pu),document.removeEventListener(`touchstart`,u,pu)}},[]);var p=e.removeScrollBar,m=e.inert;return j.createElement(j.Fragment,null,m?j.createElement(a,{styles:ku(i)}):null,p?j.createElement(uu,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function Nu(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var Pu=Wl(Gl,Mu),Fu=j.forwardRef(function(e,t){return j.createElement(ql,Ol({},e,{ref:t,sideCar:Pu}))});Fu.classNames=ql.classNames;var Iu=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},Lu=new WeakMap,Ru=new WeakMap,zu={},Bu=0,Vu=function(e){return e&&(e.host||Vu(e.parentNode))},Hu=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Vu(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},Uu=function(e,t,n,r){var i=Hu(t,Array.isArray(e)?e:[e]);zu[n]||(zu[n]=new WeakMap);var a=zu[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(Lu.get(e)||0)+1,l=(a.get(e)||0)+1;Lu.set(e,c),a.set(e,l),o.push(e),c===1&&i&&Ru.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),Bu++,function(){o.forEach(function(e){var t=Lu.get(e)-1,i=a.get(e)-1;Lu.set(e,t),a.set(e,i),t||(Ru.has(e)||e.removeAttribute(r),Ru.delete(e)),i||e.removeAttribute(n)}),Bu--,Bu||(Lu=new WeakMap,Lu=new WeakMap,Ru=new WeakMap,zu={})}},Wu=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||Iu(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),Uu(r,i,n,`aria-hidden`)):function(){return null}};function Gu(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Ku(...e){return t=>{let n=!1,r=e.map(e=>{let r=Gu(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():Gu(e[t],null)}}}}function qu(...e){return j.useCallback(Ku(...e),e)}function Ju(e){let t=Yu(e),n=j.forwardRef((e,n)=>{let{children:r,...i}=e,a=j.Children.toArray(r),o=a.find(Qu);if(o){let e=o.props.children,r=a.map(t=>t===o?j.Children.count(e)>1?j.Children.only(null):j.isValidElement(e)?e.props.children:null:t);return(0,I.jsx)(t,{...i,ref:n,children:j.isValidElement(e)?j.cloneElement(e,void 0,r):null})}return(0,I.jsx)(t,{...i,ref:n,children:r})});return n.displayName=`${e}.Slot`,n}function Yu(e){let t=j.forwardRef((e,t)=>{let{children:n,...r}=e;if(j.isValidElement(n)){let e=ed(n),i=$u(r,n.props);return n.type!==j.Fragment&&(i.ref=t?Ku(t,e):e),j.cloneElement(n,i)}return j.Children.count(n)>1?j.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Xu=Symbol(`radix.slottable`);function Zu(e){let t=({children:e})=>(0,I.jsx)(I.Fragment,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=Xu,t}function Qu(e){return j.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Xu}function $u(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function ed(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var td=S(O(),1),nd=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Ju(`Primitive.${t}`),r=j.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,I.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function rd(e,t){e&&td.flushSync(()=>e.dispatchEvent(t))}var id=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),ad=`VisuallyHidden`,od=j.forwardRef((e,t)=>(0,I.jsx)(nd.span,{...e,ref:t,style:{...id,...e.style}}));od.displayName=ad;var sd=od;function cd(e,t){let n=j.createContext(t),r=e=>{let{children:t,...r}=e,i=j.useMemo(()=>r,Object.values(r));return(0,I.jsx)(n.Provider,{value:i,children:t})};r.displayName=e+`Provider`;function i(r){let i=j.useContext(n);if(i)return i;if(t!==void 0)return t;throw Error(`\`${r}\` must be used within \`${e}\``)}return[r,i]}function ld(e,t=[]){let n=[];function r(t,r){let i=j.createContext(r),a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=j.useMemo(()=>o,Object.values(o));return(0,I.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o){let s=o?.[e]?.[a]||i,c=j.useContext(s);if(c)return c;if(r!==void 0)return r;throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>j.createContext(e));return function(n){let r=n?.[e]||t;return j.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,ud(i,...t)]}function ud(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return j.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}typeof window<`u`&&window.document&&window.document.createElement;function dd(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}var fd=globalThis?.document?j.useLayoutEffect:()=>{},pd=j.useInsertionEffect||fd;function md({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=hd({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=j.useRef(e!==void 0);j.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,j.useCallback(t=>{if(s){let n=gd(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function hd({defaultProp:e,onChange:t}){let[n,r]=j.useState(e),i=j.useRef(n),a=j.useRef(t);return pd(()=>{a.current=t},[t]),j.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function gd(e){return typeof e==`function`}function _d(e,t){return j.useReducer((e,n)=>t[e][n]??e,e)}var vd=e=>{let{present:t,children:n}=e,r=yd(t),i=typeof n==`function`?n({present:r.isPresent}):j.Children.only(n),a=qu(r.ref,xd(i));return typeof n==`function`||r.isPresent?j.cloneElement(i,{ref:a}):null};vd.displayName=`Presence`;function yd(e){let[t,n]=j.useState(),r=j.useRef(null),i=j.useRef(e),a=j.useRef(`none`),[o,s]=_d(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return j.useEffect(()=>{let e=bd(r.current);a.current=o===`mounted`?e:`none`},[o]),fd(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=bd(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),fd(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=bd(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=bd(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:j.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function bd(e){return e?.animationName||`none`}function xd(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Sd=j.useId||(()=>void 0),Cd=0;function wd(e){let[t,n]=j.useState(Sd());return fd(()=>{e||n(e=>e??String(Cd++))},[e]),e||(t?`radix-${t}`:``)}function Td(e){let t=j.useRef(e);return j.useEffect(()=>{t.current=e}),j.useMemo(()=>(...e)=>t.current?.(...e),[])}function Ed(e,t=globalThis?.document){let n=Td(e);j.useEffect(()=>{let e=e=>{e.key===`Escape`&&n(e)};return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}var Dd=`DismissableLayer`,Od=`dismissableLayer.update`,kd=`dismissableLayer.pointerDownOutside`,Ad=`dismissableLayer.focusOutside`,jd,Md=j.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Nd=j.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:a,onInteractOutside:o,onDismiss:s,...c}=e,l=j.useContext(Md),[u,d]=j.useState(null),f=u?.ownerDocument??globalThis?.document,[,p]=j.useState({}),m=qu(t,e=>d(e)),h=Array.from(l.layers),[g]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),_=h.indexOf(g),v=u?h.indexOf(u):-1,y=l.layersWithOutsidePointerEventsDisabled.size>0,b=v>=_,x=Id(e=>{let t=e.target,n=[...l.branches].some(e=>e.contains(t));b&&!n&&(i?.(e),o?.(e),e.defaultPrevented||s?.())},f),S=Ld(e=>{let t=e.target;[...l.branches].some(e=>e.contains(t))||(a?.(e),o?.(e),e.defaultPrevented||s?.())},f);return Ed(e=>{v===l.layers.size-1&&(r?.(e),!e.defaultPrevented&&s&&(e.preventDefault(),s()))},f),j.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(jd=f.body.style.pointerEvents,f.body.style.pointerEvents=`none`),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),Rd(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=jd)}},[u,f,n,l]),j.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),Rd())},[u,l]),j.useEffect(()=>{let e=()=>p({});return document.addEventListener(Od,e),()=>document.removeEventListener(Od,e)},[]),(0,I.jsx)(nd.div,{...c,ref:m,style:{pointerEvents:y?b?`auto`:`none`:void 0,...e.style},onFocusCapture:dd(e.onFocusCapture,S.onFocusCapture),onBlurCapture:dd(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:dd(e.onPointerDownCapture,x.onPointerDownCapture)})});Nd.displayName=Dd;var Pd=`DismissableLayerBranch`,Fd=j.forwardRef((e,t)=>{let n=j.useContext(Md),r=j.useRef(null),i=qu(t,r);return j.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,I.jsx)(nd.div,{...e,ref:i})});Fd.displayName=Pd;function Id(e,t=globalThis?.document){let n=Td(e),r=j.useRef(!1),i=j.useRef(()=>{});return j.useEffect(()=>{let e=e=>{if(e.target&&!r.current){let r=function(){zd(kd,n,a,{discrete:!0})},a={originalEvent:e};e.pointerType===`touch`?(t.removeEventListener(`click`,i.current),i.current=r,t.addEventListener(`click`,i.current,{once:!0})):r()}else t.removeEventListener(`click`,i.current);r.current=!1},a=window.setTimeout(()=>{t.addEventListener(`pointerdown`,e)},0);return()=>{window.clearTimeout(a),t.removeEventListener(`pointerdown`,e),t.removeEventListener(`click`,i.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Ld(e,t=globalThis?.document){let n=Td(e),r=j.useRef(!1);return j.useEffect(()=>{let e=e=>{e.target&&!r.current&&zd(Ad,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Rd(){let e=new CustomEvent(Od);document.dispatchEvent(e)}function zd(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?rd(i,a):i.dispatchEvent(a)}var Bd=`focusScope.autoFocusOnMount`,Vd=`focusScope.autoFocusOnUnmount`,Hd={bubbles:!1,cancelable:!0},Ud=`FocusScope`,Wd=j.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=j.useState(null),l=Td(i),u=Td(a),d=j.useRef(null),f=qu(t,e=>c(e)),p=j.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;j.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:Zd(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||Zd(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Zd(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),j.useEffect(()=>{if(s){Qd.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(Bd,Hd);s.addEventListener(Bd,l),s.dispatchEvent(t),t.defaultPrevented||(Gd(tf(qd(s)),{select:!0}),document.activeElement===e&&Zd(s))}return()=>{s.removeEventListener(Bd,l),setTimeout(()=>{let t=new CustomEvent(Vd,Hd);s.addEventListener(Vd,u),s.dispatchEvent(t),t.defaultPrevented||Zd(e??document.body,{select:!0}),s.removeEventListener(Vd,u),Qd.remove(p)},0)}}},[s,l,u,p]);let m=j.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=Kd(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Zd(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Zd(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,I.jsx)(nd.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});Wd.displayName=Ud;function Gd(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Zd(r,{select:t}),document.activeElement!==n)return}function Kd(e){let t=qd(e);return[Jd(t,e),Jd(t.reverse(),e)]}function qd(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function Jd(e,t){for(let n of e)if(!Yd(n,{upTo:t}))return n}function Yd(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function Xd(e){return e instanceof HTMLInputElement&&`select`in e}function Zd(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Xd(e)&&t&&e.select()}}var Qd=$d();function $d(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=ef(e,t),e.unshift(t)},remove(t){e=ef(e,t),e[0]?.resume()}}}function ef(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function tf(e){return e.filter(e=>e.tagName!==`A`)}var nf=`Portal`,rf=j.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=j.useState(!1);fd(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?td.createPortal((0,I.jsx)(nd.div,{...r,ref:t}),o):null});rf.displayName=nf;var af=0;function of(){j.useEffect(()=>{let e=document.querySelectorAll(`[data-radix-focus-guard]`);return document.body.insertAdjacentElement(`afterbegin`,e[0]??sf()),document.body.insertAdjacentElement(`beforeend`,e[1]??sf()),af++,()=>{af===1&&document.querySelectorAll(`[data-radix-focus-guard]`).forEach(e=>e.remove()),af--}},[])}function sf(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var cf=`Dialog`,[lf,uf]=ld(cf),[df,ff]=lf(cf),pf=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=j.useRef(null),c=j.useRef(null),[l,u]=md({prop:r,defaultProp:i??!1,onChange:a,caller:cf});return(0,I.jsx)(df,{scope:t,triggerRef:s,contentRef:c,contentId:wd(),titleId:wd(),descriptionId:wd(),open:l,onOpenChange:u,onOpenToggle:j.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};pf.displayName=cf;var mf=`DialogTrigger`,hf=j.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ff(mf,n),a=qu(t,i.triggerRef);return(0,I.jsx)(nd.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Ff(i.open),...r,ref:a,onClick:dd(e.onClick,i.onOpenToggle)})});hf.displayName=mf;var gf=`DialogPortal`,[_f,vf]=lf(gf,{forceMount:void 0}),yf=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=ff(gf,t);return(0,I.jsx)(_f,{scope:t,forceMount:n,children:j.Children.map(r,e=>(0,I.jsx)(vd,{present:n||a.open,children:(0,I.jsx)(rf,{asChild:!0,container:i,children:e})}))})};yf.displayName=gf;var bf=`DialogOverlay`,xf=j.forwardRef((e,t)=>{let n=vf(bf,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ff(bf,e.__scopeDialog);return a.modal?(0,I.jsx)(vd,{present:r||a.open,children:(0,I.jsx)(Cf,{...i,ref:t})}):null});xf.displayName=bf;var Sf=Ju(`DialogOverlay.RemoveScroll`),Cf=j.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ff(bf,n);return(0,I.jsx)(Fu,{as:Sf,allowPinchZoom:!0,shards:[i.contentRef],children:(0,I.jsx)(nd.div,{"data-state":Ff(i.open),...r,ref:t,style:{pointerEvents:`auto`,...r.style}})})}),wf=`DialogContent`,Tf=j.forwardRef((e,t)=>{let n=vf(wf,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ff(wf,e.__scopeDialog);return(0,I.jsx)(vd,{present:r||a.open,children:a.modal?(0,I.jsx)(Ef,{...i,ref:t}):(0,I.jsx)(Df,{...i,ref:t})})});Tf.displayName=wf;var Ef=j.forwardRef((e,t)=>{let n=ff(wf,e.__scopeDialog),r=j.useRef(null),i=qu(t,n.contentRef,r);return j.useEffect(()=>{let e=r.current;if(e)return Wu(e)},[]),(0,I.jsx)(Of,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:dd(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:dd(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:dd(e.onFocusOutside,e=>e.preventDefault())})}),Df=j.forwardRef((e,t)=>{let n=ff(wf,e.__scopeDialog),r=j.useRef(!1),i=j.useRef(!1);return(0,I.jsx)(Of,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),Of=j.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=ff(wf,n),c=j.useRef(null),l=qu(t,c);return of(),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Wd,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,I.jsx)(Nd,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":Ff(s.open),...o,ref:l,onDismiss:()=>s.onOpenChange(!1)})}),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(zf,{titleId:s.titleId}),(0,I.jsx)(Vf,{contentRef:c,descriptionId:s.descriptionId})]})]})}),kf=`DialogTitle`,Af=j.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ff(kf,n);return(0,I.jsx)(nd.h2,{id:i.titleId,...r,ref:t})});Af.displayName=kf;var jf=`DialogDescription`,Mf=j.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ff(jf,n);return(0,I.jsx)(nd.p,{id:i.descriptionId,...r,ref:t})});Mf.displayName=jf;var Nf=`DialogClose`,Pf=j.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ff(Nf,n);return(0,I.jsx)(nd.button,{type:`button`,...r,ref:t,onClick:dd(e.onClick,()=>i.onOpenChange(!1))})});Pf.displayName=Nf;function Ff(e){return e?`open`:`closed`}var If=`DialogTitleWarning`,[Lf,Rf]=cd(If,{contentName:wf,titleName:kf,docsSlug:`dialog`}),zf=({titleId:e})=>{let t=Rf(If),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
50
-
51
- If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
52
-
53
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return j.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},Bf=`DialogDescriptionWarning`,Vf=({contentRef:e,descriptionId:t})=>{let n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Rf(Bf).contentName}}.`;return j.useEffect(()=>{let r=e.current?.getAttribute(`aria-describedby`);t&&r&&(document.getElementById(t)||console.warn(n))},[n,e,t]),null},Hf=pf,Uf=yf,Wf=xf,Gf=Tf,Kf=Af,qf=Mf,Jf=Pf,Yf=b((e=>{var t=E();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 d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),Xf=b(((e,t)=>{t.exports=Yf()}));function Zf(e){let t=j.useRef({value:e,previous:e});return j.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}function Qf(e){let[t,n]=j.useState(void 0);return fd(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}var $f=[`top`,`right`,`bottom`,`left`],ep=Math.min,tp=Math.max,np=Math.round,rp=Math.floor,ip=e=>({x:e,y:e}),ap={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function op(e,t,n){return tp(e,ep(t,n))}function sp(e,t){return typeof e==`function`?e(t):e}function cp(e){return e.split(`-`)[0]}function lp(e){return e.split(`-`)[1]}function up(e){return e===`x`?`y`:`x`}function dp(e){return e===`y`?`height`:`width`}function fp(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function pp(e){return up(fp(e))}function mp(e,t,n){n===void 0&&(n=!1);let r=lp(e),i=pp(e),a=dp(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Cp(o)),[o,Cp(o)]}function hp(e){let t=Cp(e);return[gp(e),t,gp(t)]}function gp(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var _p=[`left`,`right`],vp=[`right`,`left`],yp=[`top`,`bottom`],bp=[`bottom`,`top`];function xp(e,t,n){switch(e){case`top`:case`bottom`:return n?t?vp:_p:t?_p:vp;case`left`:case`right`:return t?yp:bp;default:return[]}}function Sp(e,t,n,r){let i=lp(e),a=xp(cp(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(gp)))),a}function Cp(e){let t=cp(e);return ap[t]+e.slice(t.length)}function wp(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Tp(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:wp(e)}function Ep(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Dp(e,t,n){let{reference:r,floating:i}=e,a=fp(t),o=pp(t),s=dp(o),c=cp(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=lp(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Op(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=sp(t,e),p=Tp(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Ep(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Ep(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var kp=50,Ap=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Op},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Dp(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<kp&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=Dp(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},jp=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=sp(e,t)||{};if(l==null)return{};let d=Tp(u),f={x:n,y:r},p=pp(i),m=dp(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=ep(d[_],T),D=ep(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=op(E,k,O),j=!c.arrow&&lp(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),Mp=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=sp(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=cp(r),_=fp(o),v=cp(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Cp(o)]:hp(o)),x=p!==`none`;!d&&x&&b.push(...Sp(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=mp(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===fp(t)||T.every(e=>fp(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=fp(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function Np(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Pp(e){return $f.some(t=>e[t]>=0)}var Fp=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=sp(e,t);switch(i){case`referenceHidden`:{let e=Np(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Pp(e)}}}case`escaped`:{let e=Np(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Pp(e)}}}default:return{}}}}},Ip=new Set([`left`,`top`]);async function Lp(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=cp(n),s=lp(n),c=fp(n)===`y`,l=Ip.has(o)?-1:1,u=a&&c?-1:1,d=sp(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Rp=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Lp(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},zp=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=sp(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=fp(i),p=up(f),m=u[p],h=u[f],g=(e,t)=>op(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},Bp=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=sp(e,t),u={x:n,y:r},d=fp(i),f=up(d),p=u[f],m=u[d],h=sp(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Ip.has(cp(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},Vp=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=sp(e,t),c=await i.detectOverflow(t,s),l=cp(n),u=lp(n),d=fp(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=ep(p-c[m],g),y=ep(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*tp(c.left,c.right):S=p-2*tp(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function Hp(){return typeof window<`u`}function Up(e){return Kp(e)?(e.nodeName||``).toLowerCase():`#document`}function Wp(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Gp(e){return((Kp(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Kp(e){return Hp()?e instanceof Node||e instanceof Wp(e).Node:!1}function qp(e){return Hp()?e instanceof Element||e instanceof Wp(e).Element:!1}function Jp(e){return Hp()?e instanceof HTMLElement||e instanceof Wp(e).HTMLElement:!1}function Yp(e){return!Hp()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Wp(e).ShadowRoot}function Xp(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=sm(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Zp(e){return/^(table|td|th)$/.test(Up(e))}function Qp(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var $p=/transform|translate|scale|rotate|perspective|filter/,em=/paint|layout|strict|content/,tm=e=>!!e&&e!==`none`,nm;function rm(e){let t=qp(e)?sm(e):e;return tm(t.transform)||tm(t.translate)||tm(t.scale)||tm(t.rotate)||tm(t.perspective)||!am()&&(tm(t.backdropFilter)||tm(t.filter))||$p.test(t.willChange||``)||em.test(t.contain||``)}function im(e){let t=lm(e);for(;Jp(t)&&!om(t);){if(rm(t))return t;if(Qp(t))return null;t=lm(t)}return null}function am(){return nm??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),nm}function om(e){return/^(html|body|#document)$/.test(Up(e))}function sm(e){return Wp(e).getComputedStyle(e)}function cm(e){return qp(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function lm(e){if(Up(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Yp(e)&&e.host||Gp(e);return Yp(t)?t.host:t}function um(e){let t=lm(e);return om(t)?(e.ownerDocument||e).body:Jp(t)&&Xp(t)?t:um(t)}function dm(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=um(e),i=r===e.ownerDocument?.body,a=Wp(r);if(i){let e=fm(a);return t.concat(a,a.visualViewport||[],Xp(r)?r:[],e&&n?dm(e):[])}return t.concat(r,dm(r,[],n))}function fm(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function pm(e){let t=sm(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Jp(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=np(n)!==a||np(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function mm(e){return qp(e)?e:e.contextElement}function hm(e){let t=mm(e);if(!Jp(t))return ip(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=pm(t),o=(a?np(n.width):n.width)/r,s=(a?np(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var gm=ip(0);function _m(e){let t=Wp(e);return!am()||!t.visualViewport?gm:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function vm(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Wp(e)}function ym(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=mm(e),o=ip(1);t&&(r?qp(r)&&(o=hm(r)):o=hm(e));let s=vm(a,n,r)?_m(a):ip(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=Wp(a),t=qp(r)?Wp(r):r,n=e,i=fm(n);for(;i&&t!==n;){let e=hm(i),t=i.getBoundingClientRect(),r=sm(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Wp(i),i=fm(n)}}return Ep({width:u,height:d,x:c,y:l})}function bm(e,t){let n=cm(e).scrollLeft;return t?t.left+n:ym(Gp(e)).left+n}function xm(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-bm(e,n),y:n.top+t.scrollTop}}function Sm(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Gp(r),s=t?Qp(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=ip(1),u=ip(0),d=Jp(r);if((d||!a)&&((Up(r)!==`body`||Xp(o))&&(c=cm(r)),d)){let e=ym(r);l=hm(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?xm(o,c):ip(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Cm(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function wm(e){let t=cm(e),n=e.ownerDocument.body,r=tp(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=tp(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+bm(e),o=-t.scrollTop;return sm(n).direction===`rtl`&&(a+=tp(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var Tm=25;function Em(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Wp(e),a=Gp(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!am()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(bm(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=Tm&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Dm(e,t){let n=ym(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=hm(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Om(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Em(e,n,t);else if(t===`document`)r=wm(Gp(e));else if(qp(t))r=Dm(t,n);else{let n=_m(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Ep(r)}function km(e,t){let n=t.get(e);if(n)return n;let r=dm(e,[],!1).filter(e=>qp(e)&&Up(e)!==`body`),i=null,a=sm(e).position===`fixed`,o=a?lm(e):e;for(;qp(o)&&!om(o);){let e=sm(o),t=rm(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=lm(o)}return t.set(e,r),r}function Am(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Qp(t)?[]:km(t,this._c):[].concat(n),r],o=Om(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Om(t,a[e],i);s=tp(n.top,s),c=ep(n.right,c),l=ep(n.bottom,l),u=tp(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function jm(e){let{width:t,height:n}=pm(e);return{width:t,height:n}}function Mm(e,t,n){let r=Jp(t),i=Gp(t),a=n===`fixed`,o=ym(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=ip(0);if((r||!a)&&((Up(t)!==`body`||Xp(i))&&(s=cm(t)),r)){let e=ym(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=bm(i));let l=i&&!r&&!a?xm(i,s):ip(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Nm(e){return sm(e).position===`static`}function Pm(e,t){if(!Jp(e)||sm(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Gp(e)===n&&(n=n.ownerDocument.body),n}function Fm(e,t){let n=Wp(e);if(Qp(e))return n;if(!Jp(e)){let t=lm(e);for(;t&&!om(t);){if(qp(t)&&!Nm(t))return t;t=lm(t)}return n}let r=Pm(e,t);for(;r&&Zp(r)&&Nm(r);)r=Pm(r,t);return r&&om(r)&&Nm(r)&&!rm(r)?n:r||im(e)||n}var Im=async function(e){let t=this.getOffsetParent||Fm,n=this.getDimensions,r=await n(e.floating);return{reference:Mm(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Lm(e){return sm(e).direction===`rtl`}var Rm={convertOffsetParentRelativeRectToViewportRelativeRect:Sm,getDocumentElement:Gp,getClippingRect:Am,getOffsetParent:Fm,getElementRects:Im,getClientRects:Cm,getDimensions:jm,getScale:hm,isElement:qp,isRTL:Lm};function zm(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Bm(e,t,n){let r=null,i,a=Gp(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=rp(d),h=rp(a.clientWidth-(u+f)),g=rp(a.clientHeight-(d+p)),_=rp(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:tp(0,ep(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!zm(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=Wp(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Vm(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=mm(e),u=i||a?[...l?dm(l):[],...t?dm(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Bm(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?ym(e):null;c&&g();function g(){let t=ym(e);h&&!zm(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Hm=Rp,Um=zp,Wm=Mp,Gm=Vp,Km=Fp,qm=jp,Jm=Bp,Ym=(e,t,n)=>{let r=new Map,i=n??{},a={...Rm,...i.platform,_c:r};return Ap(e,t,{...i,platform:a})},Xm=typeof document<`u`?j.useLayoutEffect:function(){};function Zm(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!Zm(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!Zm(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Qm(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function $m(e,t){let n=Qm(e);return Math.round(t*n)/n}function eh(e){let t=j.useRef(e);return Xm(()=>{t.current=e}),t}function th(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=j.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=j.useState(r);Zm(f,r)||p(r);let[m,h]=j.useState(null),[g,_]=j.useState(null),v=j.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=j.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=j.useRef(null),C=j.useRef(null),w=j.useRef(u),T=c!=null,E=eh(c),D=eh(i),O=eh(l),k=j.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Ym(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!Zm(w.current,t)&&(w.current=t,td.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);Xm(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=j.useRef(!1);Xm(()=>(A.current=!0,()=>{A.current=!1}),[]),Xm(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let M=j.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),N=j.useMemo(()=>({reference:b,floating:x}),[b,x]),ee=j.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=$m(N.floating,u.x),r=$m(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Qm(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return j.useMemo(()=>({...u,update:k,refs:M,elements:N,floatingStyles:ee}),[u,k,M,N,ee])}var nh=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:qm({element:r.current,padding:i}).fn(n):r?qm({element:r,padding:i}).fn(n):{}}}},rh=(e,t)=>{let n=Hm(e);return{name:n.name,fn:n.fn,options:[e,t]}},ih=(e,t)=>{let n=Um(e);return{name:n.name,fn:n.fn,options:[e,t]}},ah=(e,t)=>({fn:Jm(e).fn,options:[e,t]}),oh=(e,t)=>{let n=Wm(e);return{name:n.name,fn:n.fn,options:[e,t]}},sh=(e,t)=>{let n=Gm(e);return{name:n.name,fn:n.fn,options:[e,t]}},ch=(e,t)=>{let n=Km(e);return{name:n.name,fn:n.fn,options:[e,t]}},lh=(e,t)=>{let n=nh(e);return{name:n.name,fn:n.fn,options:[e,t]}},uh=`Arrow`,dh=j.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,I.jsx)(nd.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,I.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});dh.displayName=uh;var fh=dh,ph=`Popper`,[mh,hh]=ld(ph),[gh,_h]=mh(ph),vh=e=>{let{__scopePopper:t,children:n}=e,[r,i]=j.useState(null);return(0,I.jsx)(gh,{scope:t,anchor:r,onAnchorChange:i,children:n})};vh.displayName=ph;var yh=`PopperAnchor`,bh=j.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=_h(yh,n),o=j.useRef(null),s=qu(t,o),c=j.useRef(null);return j.useEffect(()=>{let e=c.current;c.current=r?.current||o.current,e!==c.current&&a.onAnchorChange(c.current)}),r?null:(0,I.jsx)(nd.div,{...i,ref:s})});bh.displayName=yh;var xh=`PopperContent`,[Sh,Ch]=mh(xh),wh=j.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=_h(xh,n),[_,v]=j.useState(null),y=qu(t,e=>v(e)),[b,x]=j.useState(null),S=Qf(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,k={padding:E,boundary:D.filter(Oh),altBoundary:O},{refs:A,floatingStyles:M,placement:N,isPositioned:ee,middlewareData:P}=th({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>Vm(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[rh({mainAxis:i+w,alignmentAxis:o}),c&&ih({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?ah():void 0,...k}),c&&oh({...k}),sh({...k,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),b&&lh({element:b,padding:s}),kh({arrowWidth:C,arrowHeight:w}),f&&ch({strategy:`referenceHidden`,...k})]}),[F,te]=Ah(N),ne=Td(m);fd(()=>{ee&&ne?.()},[ee,ne]);let re=P.arrow?.x,ie=P.arrow?.y,ae=P.arrow?.centerOffset!==0,[oe,se]=j.useState();return fd(()=>{_&&se(window.getComputedStyle(_).zIndex)},[_]),(0,I.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...M,transform:ee?M.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:oe,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,I.jsx)(Sh,{scope:n,placedSide:F,onArrowChange:x,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,I.jsx)(nd.div,{"data-side":F,"data-align":te,...h,ref:y,style:{...h.style,animation:ee?void 0:`none`}})})})});wh.displayName=xh;var Th=`PopperArrow`,Eh={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Dh=j.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Ch(Th,n),a=Eh[i.placedSide];return(0,I.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,I.jsx)(fh,{...r,ref:t,style:{...r.style,display:`block`}})})});Dh.displayName=Th;function Oh(e){return e!==null}var kh=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Ah(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Ah(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var jh=vh,Mh=bh,Nh=wh,Ph=Dh,Fh=`Popover`,[Ih,Lh]=ld(Fh,[hh]),Rh=hh(),[zh,Bh]=Ih(Fh),Vh=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=Rh(t),c=j.useRef(null),[l,u]=j.useState(!1),[d,f]=md({prop:r,defaultProp:i??!1,onChange:a,caller:Fh});return(0,I.jsx)(jh,{...s,children:(0,I.jsx)(zh,{scope:t,contentId:wd(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:j.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:j.useCallback(()=>u(!0),[]),onCustomAnchorRemove:j.useCallback(()=>u(!1),[]),modal:o,children:n})})};Vh.displayName=Fh;var Hh=`PopoverAnchor`,Uh=j.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Bh(Hh,n),a=Rh(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return j.useEffect(()=>(o(),()=>s()),[o,s]),(0,I.jsx)(Mh,{...a,...r,ref:t})});Uh.displayName=Hh;var Wh=`PopoverTrigger`,Gh=j.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Bh(Wh,n),a=Rh(n),o=qu(t,i.triggerRef),s=(0,I.jsx)(nd.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.contentId,"data-state":og(i.open),...r,ref:o,onClick:dd(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,I.jsx)(Mh,{asChild:!0,...a,children:s})});Gh.displayName=Wh;var Kh=`PopoverPortal`,[qh,Jh]=Ih(Kh,{forceMount:void 0}),Yh=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=Bh(Kh,t);return(0,I.jsx)(qh,{scope:t,forceMount:n,children:(0,I.jsx)(vd,{present:n||a.open,children:(0,I.jsx)(rf,{asChild:!0,container:i,children:r})})})};Yh.displayName=Kh;var Xh=`PopoverContent`,Zh=j.forwardRef((e,t)=>{let n=Jh(Xh,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=Bh(Xh,e.__scopePopover);return(0,I.jsx)(vd,{present:r||a.open,children:a.modal?(0,I.jsx)($h,{...i,ref:t}):(0,I.jsx)(eg,{...i,ref:t})})});Zh.displayName=Xh;var Qh=Ju(`PopoverContent.RemoveScroll`),$h=j.forwardRef((e,t)=>{let n=Bh(Xh,e.__scopePopover),r=j.useRef(null),i=qu(t,r),a=j.useRef(!1);return j.useEffect(()=>{let e=r.current;if(e)return Wu(e)},[]),(0,I.jsx)(Fu,{as:Qh,allowPinchZoom:!0,children:(0,I.jsx)(tg,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:dd(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:dd(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:dd(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),eg=j.forwardRef((e,t)=>{let n=Bh(Xh,e.__scopePopover),r=j.useRef(!1),i=j.useRef(!1);return(0,I.jsx)(tg,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),tg=j.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=Bh(Xh,n),p=Rh(n);return of(),(0,I.jsx)(Wd,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,I.jsx)(Nd,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),children:(0,I.jsx)(Nh,{"data-state":og(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),ng=`PopoverClose`,rg=j.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Bh(ng,n);return(0,I.jsx)(nd.button,{type:`button`,...r,ref:t,onClick:dd(e.onClick,()=>i.onOpenChange(!1))})});rg.displayName=ng;var ig=`PopoverArrow`,ag=j.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=Rh(n);return(0,I.jsx)(Ph,{...i,...r,ref:t})});ag.displayName=ig;function og(e){return e?`open`:`closed`}var sg=Vh,cg=Gh,lg=Yh,ug=Zh,dg=`Switch`,[fg,pg]=ld(dg),[mg,hg]=fg(dg),gg=j.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c=`on`,onCheckedChange:l,form:u,...d}=e,[f,p]=j.useState(null),m=qu(t,e=>p(e)),h=j.useRef(!1),g=!f||u||!!f.closest(`form`),[_,v]=md({prop:i,defaultProp:a??!1,onChange:l,caller:dg});return(0,I.jsxs)(mg,{scope:n,checked:_,disabled:s,children:[(0,I.jsx)(nd.button,{type:`button`,role:`switch`,"aria-checked":_,"aria-required":o,"data-state":xg(_),"data-disabled":s?``:void 0,disabled:s,value:c,...d,ref:m,onClick:dd(e.onClick,e=>{v(e=>!e),g&&(h.current=e.isPropagationStopped(),h.current||e.stopPropagation())})}),g&&(0,I.jsx)(bg,{control:f,bubbles:!h.current,name:r,value:c,checked:_,required:o,disabled:s,form:u,style:{transform:`translateX(-100%)`}})]})});gg.displayName=dg;var _g=`SwitchThumb`,vg=j.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=hg(_g,n);return(0,I.jsx)(nd.span,{"data-state":xg(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});vg.displayName=_g;var yg=`SwitchBubbleInput`,bg=j.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...i},a)=>{let o=j.useRef(null),s=qu(o,a),c=Zf(n),l=Qf(t);return j.useEffect(()=>{let e=o.current;if(!e)return;let t=window.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(t,`checked`).set;if(c!==n&&i){let t=new Event(`click`,{bubbles:r});i.call(e,n),e.dispatchEvent(t)}},[c,n,r]),(0,I.jsx)(`input`,{type:`checkbox`,"aria-hidden":!0,defaultChecked:n,...i,tabIndex:-1,ref:s,style:{...i.style,...l,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0}})});bg.displayName=yg;function xg(e){return e?`checked`:`unchecked`}var Sg=gg,Cg=vg,[wg,Tg]=ld(`Tooltip`,[hh]),Eg=hh(),Dg=`TooltipProvider`,Og=`tooltip.open`,[kg,Ag]=wg(Dg),jg=`Tooltip`,[Mg,Ng]=wg(jg),Pg=`TooltipTrigger`,Fg=j.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Ng(Pg,n),a=Ag(Pg,n),o=Eg(n),s=qu(t,j.useRef(null),i.onTriggerChange),c=j.useRef(!1),l=j.useRef(!1),u=j.useCallback(()=>c.current=!1,[]);return j.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,I.jsx)(Mh,{asChild:!0,...o,children:(0,I.jsx)(nd.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:dd(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:dd(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:dd(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:dd(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:dd(e.onBlur,i.onClose),onClick:dd(e.onClick,i.onClose)})})});Fg.displayName=Pg;var[Ig,Lg]=wg(`TooltipPortal`,{forceMount:void 0}),Rg=`TooltipContent`,zg=j.forwardRef((e,t)=>{let n=Lg(Rg,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Ng(Rg,e.__scopeTooltip);return(0,I.jsx)(vd,{present:r||o.open,children:o.disableHoverableContent?(0,I.jsx)(Wg,{side:i,...a,ref:t}):(0,I.jsx)(Bg,{side:i,...a,ref:t})})}),Bg=j.forwardRef((e,t)=>{let n=Ng(Rg,e.__scopeTooltip),r=Ag(Rg,e.__scopeTooltip),i=j.useRef(null),a=qu(t,i),[o,s]=j.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=j.useCallback(()=>{s(null),d(!1)},[d]),p=j.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Jg(r,qg(r,n.getBoundingClientRect())),a=Yg(t.getBoundingClientRect()),o=Zg([...i,...a]);s(o),d(!0)},[d]);return j.useEffect(()=>()=>f(),[f]),j.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),j.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Xg(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,I.jsx)(Wg,{...e,ref:a})}),[Vg,Hg]=wg(jg,{isInside:!1}),Ug=Zu(`TooltipContent`),Wg=j.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=Ng(Rg,n),l=Eg(n),{onClose:u}=c;return j.useEffect(()=>(document.addEventListener(Og,u),()=>document.removeEventListener(Og,u)),[u]),j.useEffect(()=>{if(c.trigger){let e=e=>{e.target?.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,I.jsx)(Nd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,I.jsxs)(Nh,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,I.jsx)(Ug,{children:r}),(0,I.jsx)(Vg,{scope:n,isInside:!0,children:(0,I.jsx)(sd,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});zg.displayName=Rg;var Gg=`TooltipArrow`,Kg=j.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Eg(n);return Hg(Gg,n).isInside?null:(0,I.jsx)(Ph,{...i,...r,ref:t})});Kg.displayName=Gg;function qg(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function Jg(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}function Yg(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Xg(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Zg(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Qg(t)}function Qg(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}function $g(...e){return e.filter(Boolean).join(` `)}function e_(e){return(0,I.jsx)(Hf,{...e})}function t_({size:e=`lg`,hideClose:t,dismissible:n=!0,disableAutoFocus:r,fixed:i,className:a,children:o,onOpenAutoFocus:s,onPointerDownOutside:c,...l}){return(0,I.jsxs)(Uf,{children:[(0,I.jsx)(Wf,{className:`kui-modal-overlay`}),(0,I.jsxs)(Gf,{className:$g(`kui-modal`,a),"data-size":e,"data-fixed":i||void 0,onOpenAutoFocus:e=>{r&&e.preventDefault(),s?.(e)},onPointerDownOutside:e=>{n||e.preventDefault(),c?.(e)},...l,children:[o,t?null:(0,I.jsx)(n_,{})]})]})}function n_({className:e,...t}){let n=se();return(0,I.jsx)(Jf,{className:$g(`kui-modal-close`,e),"aria-label":n(`close`),...t,children:(0,I.jsx)(Nc,{size:14,strokeWidth:Lc,"aria-hidden":`true`})})}function r_({className:e,...t}){return(0,I.jsx)(`div`,{className:$g(`kui-modal-body`,e),...t})}function i_({className:e,...t}){return(0,I.jsx)(`div`,{className:$g(`kui-modal-header`,e),...t})}function a_({className:e,...t}){return(0,I.jsx)(`div`,{className:$g(`kui-modal-footer`,e),...t})}function o_({className:e,...t}){return(0,I.jsx)(Kf,{className:$g(`kui-modal-title`,e),...t})}function s_({className:e,...t}){return(0,I.jsx)(qf,{className:$g(`kui-modal-description`,e),...t})}function c_(e){return(0,I.jsx)(sg,{...e})}var l_=cg;function u_({align:e=`center`,sideOffset:t=4,className:n,...r}){return(0,I.jsx)(lg,{children:(0,I.jsx)(ug,{align:e,sideOffset:t,className:$g(`kui-popover-panel`,n),...r})})}(0,j.createContext)(!1);function d_({className:e,...t}){return(0,I.jsx)(`span`,{className:$g(`kui-badge`,e),...t})}var f_=(0,j.forwardRef)(function({className:e,...t},n){return(0,I.jsx)(Sg,{ref:n,className:$g(`kui-switch`,e),...t,children:(0,I.jsx)(Cg,{className:`kui-switch-thumb`})})});function p_({open:e,onClose:t,title:n,label:r,children:i,footer:a,dirty:o=!1,onRequestClose:s,width:c=400,side:l=`right`,testId:u=`sheet`}){let d=se(),[f,p]=(0,j.useState)(!1),m=(0,j.useRef)(()=>{});return m.current=()=>{o&&s?s():t()},(0,j.useEffect)(()=>{let e=requestAnimationFrame(()=>p(!0));return()=>cancelAnimationFrame(e)},[]),(0,j.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&m.current()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]),e?(0,I.jsx)(m_,{title:n,footer:a,width:c,side:l,visible:f,testId:u,label:r??(typeof n==`string`?n:d(`sheet`)),closeLabel:d(`close`),onClose:()=>m.current(),children:i}):null}function m_({title:e,footer:t,width:n,side:r,visible:i,testId:a,label:o,closeLabel:s,onClose:c,children:l}){let u=ee();return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{"data-testid":`${a}-backdrop`,className:`kui-sheet-backdrop`,"data-visible":i||void 0,onClick:c,"aria-hidden":`true`}),(0,I.jsxs)(`aside`,{"data-testid":a,ref:u,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":o,className:`kui-sheet`,"data-side":r,"data-visible":i||void 0,style:{width:n},children:[(0,I.jsxs)(`header`,{"data-testid":`${a}-header`,className:`kui-sheet-header`,children:[(0,I.jsx)(`div`,{className:`kui-sheet-title`,children:e}),(0,I.jsx)(`button`,{type:`button`,"data-testid":`${a}-close`,className:`kui-sheet-close`,onClick:c,"aria-label":s,children:(0,I.jsx)(Nc,{size:16,strokeWidth:Lc,"aria-hidden":`true`})})]}),(0,I.jsx)(`div`,{className:`kui-sheet-body`,children:l}),t?(0,I.jsx)(`div`,{"data-testid":`${a}-footer`,className:`kui-sheet-footer`,children:t}):null]})]})}var h_=(0,j.createContext)(null),g_=0;function __({children:e}){let[t,n]=(0,j.useState)(null),r=(0,j.useRef)([]),i=(0,j.useRef)(null),a=(0,j.useCallback)(e=>{let t=typeof e==`string`?{message:e}:e;return new Promise(e=>{let a={id:g_++,options:t,resolve:e};i.current===null?(i.current=a,n(a)):r.current.push(a)})},[]);(0,j.useEffect)(()=>()=>{i.current?.resolve(!1);for(let e of r.current)e.resolve(!1);r.current=[],i.current=null},[]);let o=(0,j.useCallback)(e=>{t?.resolve(e);let a=r.current.shift()??null;i.current=a,n(a)},[t]);return(0,I.jsxs)(h_.Provider,{value:a,children:[e,t?(0,I.jsx)(y_,{options:t.options,onSettle:o},t.id):null]})}function v_(){let e=(0,j.useContext)(h_);if(!e)throw Error(`useConfirm must be used inside <ConfirmProvider>`);return e}function y_({options:e,onSettle:t}){let n=se(),{title:r,message:i,confirmLabel:a,cancelLabel:o,variant:s=`default`,testId:c}=e,l=(0,j.useRef)(null),u=(0,j.useRef)(null),d=(0,j.useRef)(!1),f=e=>{d.current||(d.current=!0,t(e))};return(0,j.useEffect)(()=>{let e=s===`danger`?u:l,t=setTimeout(()=>e.current?.focus(),0);return()=>clearTimeout(t)},[s]),(0,I.jsx)(e_,{open:!0,onOpenChange:e=>e?void 0:f(!1),children:(0,I.jsxs)(t_,{hideClose:!0,disableAutoFocus:!0,size:`sm`,"data-testid":c,children:[(0,I.jsxs)(i_,{children:[(0,I.jsx)(o_,{className:r?void 0:`kui-visually-hidden`,children:r??i}),(0,I.jsx)(s_,{"data-testid":`confirm-message`,children:i})]}),(0,I.jsxs)(a_,{children:[(0,I.jsx)(Rc,{ref:u,"data-testid":`cancel-btn`,variant:`secondary`,size:`md`,onClick:()=>f(!1),children:o??n(`cancel`)}),(0,I.jsx)(Rc,{ref:l,"data-testid":`confirm-btn`,variant:s===`danger`?`danger`:`primary`,size:`md`,onClick:()=>f(!0),children:a??n(`confirm`)})]})]})})}var b_=(0,j.forwardRef)(function({size:e=`sm`,invalid:t,className:n,prefix:r,wrapperClassName:i,...a},o){let s=(0,I.jsx)(`input`,{ref:o,className:w_(`kui-input`,n),"data-size":e,"aria-invalid":t||void 0,...a});return r==null?s:(0,I.jsxs)(`span`,{className:w_(`kui-input-affix`,i),"data-size":e,children:[(0,I.jsx)(`span`,{className:`kui-input-prefix`,"aria-hidden":`true`,children:r}),s]})});(0,j.forwardRef)(function({size:e=`sm`,className:t,wrapperClassName:n,...r},i){let a=se(),[o,s]=(0,j.useState)(!1),c=a(o?`passwordHide`:`passwordShow`),l=o?La:Ia;return(0,I.jsxs)(`span`,{className:w_(`kui-password`,n),"data-size":e,children:[(0,I.jsx)(b_,{ref:i,size:e,className:t,...r,type:o?`text`:`password`}),(0,I.jsx)(`button`,{type:`button`,className:`kui-password-toggle`,"aria-label":c,title:c,tabIndex:-1,onClick:()=>s(e=>!e),children:(0,I.jsx)(l,{size:16,strokeWidth:Lc,"aria-hidden":`true`})})]})});function x_(e,t,n={}){let r=n===null,i=n?.minRows??1,a=n?.maxRows;(0,j.useLayoutEffect)(()=>{let t=e.current;if(!t||r)return;let n=getComputedStyle(t),o=parseFloat(n.lineHeight)||(parseFloat(n.fontSize)||14)*1.4,s=(parseFloat(n.paddingTop)||0)+(parseFloat(n.paddingBottom)||0),c=(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.borderBottomWidth)||0);t.style.height=`auto`;let l=Math.ceil((t.scrollHeight-s)/o),u=Math.max(i,Math.min(a??1/0,l));t.style.height=`${u*o+s+c}px`,t.style.overflowY=a!==void 0&&l>a?`auto`:`hidden`},[e,t,r,i,a])}var S_=(0,j.forwardRef)(function({invalid:e,autoSize:t,className:n,...r},i){let a=(0,j.useRef)(null);return x_(a,r.value,t?typeof t==`object`?t:{}:null),(0,I.jsx)(`textarea`,{ref:e=>{a.current=e,typeof i==`function`?i(e):i&&(i.current=e)},className:w_(`kui-textarea`,n),"data-auto-size":t?!0:void 0,"aria-invalid":e||void 0,...r})}),C_=(0,j.forwardRef)(function({size:e=`sm`,invalid:t,className:n,children:r,...i},a){return(0,I.jsxs)(`span`,{className:w_(`kui-select`,n),"data-size":e,children:[(0,I.jsx)(`select`,{ref:a,"aria-invalid":t||void 0,...i,children:r}),(0,I.jsx)(ta,{className:`kui-select-chevron`,size:14,strokeWidth:Lc,"aria-hidden":`true`})]})});function w_(...e){return e.filter(Boolean).join(` `)}function T_(...e){return e.filter(Boolean).join(` `)}function E_(e,t,n=5){if(!Number.isFinite(e)||!Number.isFinite(t))return[0];t===e&&(t=e+1);let r=(t-e)/n,i=10**Math.floor(Math.log10(r)),a=[1,2,2.5,5,10].map(e=>e*i).find(e=>e>=r)??r,o=Math.floor(e/a)*a,s=[];for(let e=o;e<=t+a*1e-9;e+=a)s.push(Number(e.toFixed(10)));return s[s.length-1]<t&&s.push(Number((s[s.length-1]+a).toFixed(10))),s}var D_=6,O_=e=>`var(--kui-chart-${e%D_+1})`;function k_(e){let t=(0,j.useRef)(null),[n,r]=(0,j.useState)(e);return(0,j.useEffect)(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(([e])=>r({width:Math.max(120,e.contentRect.width),height:Math.max(80,e.contentRect.height)}));return n.observe(e),()=>n.disconnect()},[]),[t,n]}function A_(e,t,n,r){let i=[],a=new Set,o=new Map;for(let s of e){let e=String(s[t]),c=r?String(s[r]):``,l=Number(s[n]);a.has(e)||(a.add(e),i.push(e)),o.has(c)||o.set(c,new Map),Number.isFinite(l)&&o.get(c).set(e,l)}let s=[...o].map(([e,t])=>({name:e,points:t})),c=s.flatMap(e=>[...e.points.values()]);return{categories:i,series:s,ticks:E_(Math.min(0,...c),Math.max(0,...c))}}var j_={top:12,right:16,bottom:28,left:48};function M_({props:e,kind:t,children:n}){let{data:r,xField:i,yField:a,seriesField:o,height:s=280,color:c,formatX:l=e=>e,formatY:u=e=>e.toLocaleString(),label:d,className:f,testId:p}=e,m=se(),[h,g]=k_({width:640,height:typeof s==`number`?s:240}),[_,v]=(0,j.useState)(null),{categories:y,series:b,ticks:x}=(0,j.useMemo)(()=>A_(r,i,a,o),[r,i,a,o]),S=e.integers?x.filter(Number.isInteger):x,C=g.width,w=s===`fill`?g.height:s,T=C-j_.left-j_.right,E=w-j_.top-j_.bottom,D=S[0],O=S[S.length-1],k=y.length?T/y.length:T,A=e=>t===`bar`?j_.left+k*(e+.5):j_.left+(y.length<=1?T/2:e/(y.length-1)*T),M=e=>j_.top+E-(e-D)/(O-D||1)*E,N=Math.max(1,Math.ceil(y.length/Math.max(1,Math.floor(T/72)))),ee=e=>c&&b.length===1?c:O_(e);return(0,I.jsxs)(`figure`,{className:T_(`kui-chart`,f),"data-testid":p,"data-fill":s===`fill`||void 0,children:[o&&b.length>1?(0,I.jsx)(`figcaption`,{className:`kui-chart-legend`,children:b.map((e,t)=>(0,I.jsxs)(`span`,{className:`kui-chart-legend-item`,children:[(0,I.jsx)(`span`,{className:`kui-chart-swatch`,style:{background:ee(t)}}),e.name]},e.name))}):null,(0,I.jsxs)(`div`,{ref:h,className:`kui-chart-plot`,style:s===`fill`?void 0:{height:s},children:[y.length===0?(0,I.jsx)(`div`,{className:`kui-chart-empty`,children:m(`noData`)}):(0,I.jsxs)(`svg`,{width:C,height:w,role:`img`,"aria-label":d,onPointerMove:e=>{let n=e.currentTarget.getBoundingClientRect(),r=e.clientX-n.left-j_.left,i=t===`bar`?Math.floor(r/k):y.length<=1?0:Math.round(r/T*(y.length-1));v(Math.max(0,Math.min(y.length-1,i)))},onPointerLeave:()=>v(null),children:[S.map(e=>(0,I.jsxs)(`g`,{className:`kui-chart-grid`,children:[(0,I.jsx)(`line`,{x1:j_.left,x2:C-j_.right,y1:M(e),y2:M(e)}),(0,I.jsx)(`text`,{x:j_.left-8,y:M(e),textAnchor:`end`,dominantBaseline:`middle`,children:u(e)})]},e)),y.map((e,t)=>t%N===0?(0,I.jsx)(`text`,{className:`kui-chart-axis`,x:A(t),y:w-8,textAnchor:`middle`,children:l(e)},e):null),n({xAt:A,band:k,yAt:M,color:ee,categories:y,series:b,hover:_,plotHeight:E})]}),_===null?null:(0,I.jsxs)(`div`,{className:`kui-chart-readout`,style:{left:Math.min(A(_)+12,C-180),top:j_.top},children:[(0,I.jsx)(`div`,{className:`kui-chart-readout-title`,children:l(y[_])}),b.map((e,t)=>(0,I.jsxs)(`div`,{className:`kui-chart-readout-row`,children:[(0,I.jsx)(`span`,{className:`kui-chart-swatch`,style:{background:ee(t)}}),(0,I.jsx)(`span`,{children:e.name||d}),(0,I.jsx)(`span`,{className:`kui-chart-readout-value`,children:e.points.has(y[_])?u(e.points.get(y[_])):`—`})]},e.name))]})]})]})}function N_(e){return(0,I.jsx)(M_,{props:e,kind:`line`,children:({xAt:t,yAt:n,color:r,categories:i,series:a,hover:o,plotHeight:s})=>(0,I.jsxs)(I.Fragment,{children:[a.map((a,o)=>{let s=i.flatMap((e,r)=>a.points.has(e)?[[t(r),n(a.points.get(e))]]:[]);return(0,I.jsxs)(`g`,{children:[(0,I.jsx)(`polyline`,{className:`kui-chart-line`,points:s.map(([e,t])=>`${e},${t}`).join(` `),style:{stroke:r(o)}}),e.dots?s.map(([e,t])=>(0,I.jsx)(`circle`,{className:`kui-chart-dot`,cx:e,cy:t,r:3,style:{fill:r(o)}},e)):null]},a.name)}),o===null?null:(0,I.jsxs)(`g`,{className:`kui-chart-hover`,children:[(0,I.jsx)(`line`,{x1:t(o),x2:t(o),y1:j_.top,y2:j_.top+s}),a.map((e,a)=>e.points.has(i[o])?(0,I.jsx)(`circle`,{cx:t(o),cy:n(e.points.get(i[o])),r:3.5,style:{fill:r(a)}},e.name):null)]})]})})}function P_(e){let t=e.maxBarWidth??44;return(0,I.jsx)(M_,{props:e,kind:`bar`,children:({xAt:e,band:n,yAt:r,color:i,categories:a,series:o,hover:s})=>{let c=Math.min(n*.7,t*o.length),l=c/Math.max(1,o.length),u=r(0);return(0,I.jsxs)(I.Fragment,{children:[s===null?null:(0,I.jsx)(`rect`,{className:`kui-chart-band`,x:e(s)-n/2,y:j_.top,width:n,height:Math.max(0,u-j_.top)}),a.map((t,n)=>o.map((a,o)=>{let s=a.points.get(t);if(s===void 0)return null;let d=r(s),f=e(n)-c/2+o*l,p=Math.abs(u-d),m=Math.min(6,l/2,p),h=Math.min(d,u),g=s>=0?`M${f},${h+p}V${h+m}Q${f},${h} ${f+m},${h}H${f+l-m}Q${f+l},${h} ${f+l},${h+m}V${h+p}Z`:`M${f},${h}V${h+p-m}Q${f},${h+p} ${f+m},${h+p}H${f+l-m}Q${f+l},${h+p} ${f+l},${h+p-m}V${h}Z`;return(0,I.jsx)(`path`,{className:`kui-chart-bar`,d:g,style:{fill:i(o)}},`${t}-${a.name}`)}))]})}})}function F_(e,t,n,r){let i=r*Math.PI*2-Math.PI/2;return[e+n*Math.cos(i),t+n*Math.sin(i)]}function I_(e,t,n,r,i,a){if(a-i>=.999999){let i=(n,r)=>`M${e},${t-n}A${n},${n} 0 1 ${r} ${e},${t+n}A${n},${n} 0 1 ${r} ${e},${t-n}Z`;return i(n,1)+(r?i(r,0):``)}let[o,s]=F_(e,t,n,i),[c,l]=F_(e,t,n,a),u=+(a-i>.5);if(!r)return`M${e},${t}L${o},${s}A${n},${n} 0 ${u} 1 ${c},${l}Z`;let[d,f]=F_(e,t,r,a),[p,m]=F_(e,t,r,i);return`M${o},${s}A${n},${n} 0 ${u} 1 ${c},${l}L${d},${f}A${r},${r} 0 ${u} 0 ${p},${m}Z`}function L_({data:e,labelField:t,valueField:n,height:r=240,innerRadius:i=0,colors:a,formatValue:o=e=>e.toLocaleString(),label:s,className:c,testId:l}){let u=se(),[d,f]=k_({width:320,height:typeof r==`number`?r:240}),[p,m]=(0,j.useState)(null),h=e.map(e=>({name:String(e[t]),value:Math.max(0,Number(e[n])||0)})).filter(e=>e.value>0),g=h.reduce((e,t)=>e+t.value,0),_=r===`fill`?f.height:r,v=Math.max(10,Math.min(f.width,_)/2-8),y=f.width/2,b=_/2,x=v*Math.min(.9,Math.max(0,i)),S=e=>a?.[e%a.length]??O_(e),C=h.map((e,t)=>h.slice(0,t).reduce((e,t)=>e+t.value,0)/(g||1));return(0,I.jsxs)(`figure`,{className:T_(`kui-chart`,c),"data-testid":l,"data-fill":r===`fill`||void 0,children:[(0,I.jsxs)(`div`,{ref:d,className:`kui-chart-plot`,style:r===`fill`?void 0:{height:r},children:[g===0?(0,I.jsx)(`div`,{className:`kui-chart-empty`,children:u(`noData`)}):(0,I.jsx)(`svg`,{width:f.width,height:_,role:`img`,"aria-label":s,onPointerLeave:()=>m(null),children:h.map((e,t)=>(0,I.jsx)(`path`,{className:`kui-chart-slice`,d:I_(y,b,v,x,C[t],C[t]+e.value/g),fillRule:`evenodd`,style:{fill:S(t)},"data-hovered":p===t||void 0,onPointerEnter:()=>m(t)},e.name))}),p===null||!h[p]?null:(0,I.jsx)(`div`,{className:`kui-chart-readout`,style:{left:8,top:8},children:(0,I.jsxs)(`div`,{className:`kui-chart-readout-row`,children:[(0,I.jsx)(`span`,{className:`kui-chart-swatch`,style:{background:S(p)}}),(0,I.jsx)(`span`,{children:h[p].name}),(0,I.jsxs)(`span`,{className:`kui-chart-readout-value`,children:[o(h[p].value),` · `,Math.round(h[p].value/g*100),`%`]})]})})]}),h.length>1?(0,I.jsx)(`figcaption`,{className:`kui-chart-legend kui-chart-legend-below`,children:h.map((e,t)=>(0,I.jsxs)(`span`,{className:`kui-chart-legend-item`,children:[(0,I.jsx)(`span`,{className:`kui-chart-swatch`,style:{background:S(t)}}),e.name]},e.name))}):null]})}var R_=e=>{let t=parseInt(e.slice(1),16);return[t>>16&255,t>>8&255,t&255]},z_=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};function B_(e){let[t,n,r]=R_(e).map(z_);return .2126*t+.7152*n+.0722*r}function V_(e,t){let[n,r]=[B_(e),B_(t)].sort((e,t)=>t-e);return(n+.05)/(r+.05)}function H_(e){return V_(e,`#ffffff`)>=V_(e,`#000000`)?`#ffffff`:`#000000`}function U_(e,t){let n=e[t],[r,i,a]=R_(n);return{"--kit-primary":n,"--kit-primary-text":H_(n),"--kit-primary-soft":`rgba(${r}, ${i}, ${a}, ${t===`dark`?.2:.1})`}}var W_=/^#[0-9a-fA-F]{6}$/;function G_(e){if(e==null)return null;let t=e;return typeof t.light==`string`&&typeof t.dark==`string`&&W_.test(t.light)&&W_.test(t.dark)?{light:t.light,dark:t.dark}:(console.warn(`[tessera-ui] ui.brand must be { light, dark } as #rrggbb colors; the host primary is used`),null)}var K_=[`menus`,`line`,`classic`,`focus`],q_=[`menus`,`line`,`classic`];function J_(e){return typeof e==`string`&&K_.includes(e)}function Y_(e){return typeof e==`string`&&q_.includes(e)?e:null}function X_(e){return`kui.mode.${e}`}function Z_(e){try{return Y_(localStorage.getItem(X_(e)))}catch{return null}}function Q_(e,t){try{localStorage.setItem(X_(e),t)}catch{}}var $_=Object.freeze({allowed:null,default:null});function ev(e){let t=e.allowed;return t?.length?K_.filter(e=>t.includes(e)):K_}function tv({stored:e,rules:t,kit:n,readOnly:r}){let i=ev(t),a=[e,t.default===`focus`?null:t.default,r?`menus`:null,n,`line`];for(let e of a)if(e&&i.includes(e))return e;return i.find(e=>e!==`focus`)??`menus`}function nv(e,t,n,r){let i=[`classic`,`line`,`menus`],a=e=>e===`menus`||t>=Math.max(720,n[e]??0),o=e;for(let t of i.slice(i.indexOf(e)))if(r.includes(t)&&(o=t,a(t)))return t;return o}var rv=e=>e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);function iv(e,t){let n=t=>e.request(`files/stat`,{handle:t}),r=async(t,n,r={})=>{let i=Math.max(1,r.chunkBytes??4194304),a=0;for(;;){let o=Math.min(n.byteLength,a+i),s=o===n.byteLength,c=rv(n.subarray(a,o)),l=s&&r.expected!==void 0?{handle:t,bytes:c,offset:a,final:s,expected:r.expected}:{handle:t,bytes:c,offset:a,final:s},u=await e.request(`files/write`,l,{transfer:!0});if(s)return u.version??``;a=o}},i={served:t.includes(`files`),canPick:t.includes(`files-pick`),canPrint:t.includes(`print`),pick:async t=>(await e.request(`files/pick`,t)).files,create:(t,n={})=>e.request(`files/create`,{suggestedName:t,...n}),stat:n,read:(t,n={})=>e.request(`files/read`,{handle:t,...n}),readAll:async t=>{let n=[],r=0,i=``;for(;;){let a=await e.request(`files/read`,{handle:t,offset:r});if(i=a.version,n.push(new Uint8Array(a.bytes)),r+=a.bytes.byteLength,r>=a.size||a.bytes.byteLength===0)break}let a=new Uint8Array(r),o=0;for(let e of n)a.set(e,o),o+=e.byteLength;return{bytes:a,version:i}},list:async t=>(await e.request(`files/list`,{handle:t})).files,write:r,release:async t=>{t.length&&await e.request(`files/release`,{handles:t})},print:async t=>{let n=`handle`in t?{handle:t.handle,title:t.title}:{bytes:rv(t.bytes),mime:`application/pdf`,title:t.title};return(await e.request(`files/print`,n,{transfer:!0})).printed===!0},writeOutputs:async(e,t,a={})=>{let o=[];for(let s of e){let e=a.targets?.[s.id],c=e?await n(e):await i.create(s.suggestedName,{...s.mime?{mime:s.mime}:{},...a.folder?{folder:a.folder}:{}}),l=await t(s.id),u=await r(c.handle,l,c.rights.includes(`create`)||c.version===null?{}:{expected:c.version});o.push({...c,version:u,size:l.byteLength})}return o},onRevoked:t=>e.on(`files/revoked`,e=>t(Array.isArray(e?.handles)?e.handles:[]))};return i}var av=Object.freeze({hide:Object.freeze([]),disable:Object.freeze([]),add:Object.freeze([]),personal:Object.freeze([]),modes:$_}),ov=/^(command|menu|tool|panel|tab|group|action|control):(?=\S)[^*]*\*?$/,sv=/^(menu:\S.*|group:[^/\s]+\/\S.*|action)$/,cv=new Map([[`command:edit.undo`,`action:undo`],[`command:edit.redo`,`action:redo`]]),lv=e=>console.warn(`[kit-editor] ${e}`),uv=e=>{try{return JSON.stringify(e)??String(e)}catch{return typeof e}};function dv(e,t,n){return e===void 0?[]:Array.isArray(e)?e.filter(e=>{let r=typeof e==`string`&&ov.test(e);return r||n(`ui.${t}: ${uv(e)} is not an element id`),r}):(n(`ui.${t} is not a list`),[])}var fv=(e,t)=>e===void 0||typeof e===t;function pv(e,t){let n=e&&typeof e==`object`?e:{},r=n.label&&typeof n.label==`object`&&!Array.isArray(n.label)?n.label:null,i=r?Object.values(r):[];return typeof n.id==`string`&&n.id!==``&&typeof n.place==`string`&&sv.test(n.place)&&r!==null&&i.length>0&&i.every(e=>typeof e==`string`&&e.length>0)&&fv(n.icon,`string`)&&fv(n.shortcut,`string`)&&fv(n.disabled,`boolean`)&&fv(n.pressed,`boolean`)?{id:n.id,place:n.place,label:{...n.label},icon:n.icon,shortcut:n.shortcut,disabled:n.disabled,pressed:n.pressed}:(t(`ui.add: ${uv(e)} is not a valid button`),null)}function mv(e,t){let n=new Set,r=[];for(let i of e)n.has(i.id)?t(`ui.add: duplicate button id "${i.id}"`):(n.add(i.id),r.push(i));return r}function hv(e,t){if(e===void 0)return $_;if(typeof e!=`object`||!e||Array.isArray(e))return t(`ui.modes is not an object`),$_;let n=e,r=null;n.allowed!==void 0&&(Array.isArray(n.allowed)?(r=n.allowed.filter(e=>(J_(e)||t(`ui.modes.allowed: ${uv(e)} is not a display mode`),J_(e))),r.length||(r=null)):t(`ui.modes.allowed is not a list`));let i=null;return n.default!==void 0&&(J_(n.default)?i=n.default:t(`ui.modes.default: ${uv(n.default)} is not a display mode`)),{allowed:r,default:i}}function gv(e,t=lv){if(e==null)return av;if(typeof e!=`object`||Array.isArray(e))return t(`ui is not an object`),av;let n=e;n.add!==void 0&&!Array.isArray(n.add)&&t(`ui.add is not a list`);let r=mv(Array.isArray(n.add)?n.add.map(e=>pv(e,t)).filter(e=>e!==null):[],t),i=[];return n.personal!==void 0&&(n.personal!==null&&typeof n.personal==`object`&&!Array.isArray(n.personal)?i=dv(n.personal.hide,`personal.hide`,t):t(`ui.personal is not an object`)),{hide:dv(n.hide,`hide`,t),disable:dv(n.disable,`disable`,t),add:r,personal:i,modes:hv(n.modes,t)}}function _v(e,t){return e.endsWith(`*`)?t.startsWith(e.slice(0,-1)):e===t}function vv(e,t=[]){let n=[e],r=e.startsWith(`menu:`),i=r?e.slice(5).split(`/`):t,a=r?i.length-1:i.length;for(let e=1;e<=a;e+=1)n.push(`menu:${i.slice(0,e).join(`/`)}`);let o=cv.get(e);return o&&n.push(o),n}var yv=`action:more`;function bv(e,t,n=[]){let r=vv(t,n),i=e=>e.some(e=>r.some(t=>_v(e,t))),a=i(e.hide),o=!a&&i(e.disable),s=!a&&t!==yv&&i(e.personal);return{hostHidden:a,hostDisabled:o,personalHidden:s,hidden:a||s,disabled:o,denied:a||o}}function xv(e,t){return e.add.filter(e=>e.place===t)}function Sv(e,t){let n=t=>Object.hasOwn(e.label,t)?e.label[t]:void 0;return n(t)??n(t.split(`-`)[0])??n(`en-US`)??e.id}function Cv(e,t){let n=t==null?`\`${e}\``:`step ${t} (\`${e}\`)`;return new o(-32e3,`${n} is not allowed in this editor`,t==null?{reason:`not-allowed`,command:e}:{reason:`not-allowed`,command:e,step:t})}function wv(e,t,n){return t.findIndex(t=>bv(e,`command:${t.command}`,n(t.command)).denied)}function Tv(e,t){return t.flatMap(t=>{let n=bv(e,`command:${t.id}`,t.menu);return n.hostHidden?[]:[n.hostDisabled?{...t,enabled:!1}:t]})}function Ev(e,t,n){let r=e,i=null,a=new Set,o=e=>{r=i?{...e,personal:i}:e;for(let e of a)e()};return{get:()=>r,subscribe:e=>(a.add(e),()=>void a.delete(e)),replace:o,customizable:t!==null,setPersonal:async e=>{let n=[...new Set(e)];i=n,o({...r,personal:n});try{t&&await t(n)}finally{i===n&&(i=null)}},action:n}}var Dv=[`--kit-primary`,`--kit-primary-text`,`--kit-primary-soft`];function Ov(e,t=null,n=document.documentElement){if(n.dataset.brand===`kit`)for(let e of Dv)n.style.removeProperty(e);for(let[t,r]of Object.entries(e.tokens))t.startsWith(`--`)&&n.style.setProperty(t,r);let r=t!==null&&e.brand!==`host`;if(r)for(let[r,i]of Object.entries(U_(t,e.colorScheme)))n.style.setProperty(r,i);n.dataset.brand=r?`kit`:`host`,n.style.colorScheme=e.colorScheme,n.dataset.colorScheme=e.colorScheme}var kv=()=>typeof navigator<`u`&&/Mac|iPhone|iPad/i.test(navigator.platform);function Av(i){return new Promise(s=>{let d=`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,m=()=>window.parent.postMessage({kitionKitUi:1,ready:r,id:d},`*`),h=r=>{if(r.source!==window.parent)return;if(a(r.data)&&r.data.hello===`kition-kit-ui/1`){m();return}if(!n(r.data)||r.data.protocol!==`kition-kit-ui/1`||!r.ports[0]||r.data.id!=null&&r.data.id!==d)return;window.removeEventListener(`message`,h);let g=new f(r.ports[0],`k`);g.handle(`ui/initialize`,n=>new Promise((r,a)=>{let d=n.document.bytes??null,f=n.capabilities.includes(`replica`)&&(i.capabilities??[]).includes(`replica`),m={read:async e=>{if(d&&e===n.document.path){let e=d;return d=null,{bytes:e,stamp:n.document.version??null}}let t=await g.request(`host/read`,{path:e});return{bytes:t.bytes,stamp:t.version}},stamp:async e=>(await g.request(`host/stamp`,{path:e})).version,write:async(e,t,n)=>{let r=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);return(await g.request(`host/write`,{path:e,bytes:r,mode:`save`,...n===void 0?{}:{expected:n}},{transfer:!0})).version||null},lend:()=>n.document.lend??null};f&&(m.replicaRead=async e=>{let t=await g.request(`host/replicaRead`,{path:e});return t&&t.snapshot instanceof ArrayBuffer&&t.blobs instanceof ArrayBuffer&&typeof t.fileStamp==`string`?t:null},m.replicaWrite=async(e,t)=>{await g.request(`host/replicaWrite`,{path:e,...t},{transfer:!0})});let h=G_(i.brand);Ov(n.theme,h);let _=Ev(gv(n.ui),n.capabilities.includes(`customize`)?async e=>void await g.request(`host/customize`,{personal:{hide:e}}):null,e=>g.notify(`ui/action`,e));g.on(`ui/configure`,e=>_.replace(gv(e?.ui))),document.documentElement.lang=n.locale;let v=n.shortcuts,y=e=>{v.some(n=>t(n,e,kv()))&&(e.preventDefault(),e.stopPropagation(),g.notify(`host/shortcut`,{key:e.key,code:e.code,meta:e.metaKey,ctrl:e.ctrlKey,shift:e.shiftKey,alt:e.altKey}))};window.addEventListener(`keydown`,y,!0),g.on(`ui/theme`,({theme:e})=>Ov(e,h)),g.on(`ui/locale`,({locale:e})=>{document.documentElement.lang=e}),s({peer:g,init:n,files:m,kitFiles:iv(g,n.capabilities),replica:f,readOnly:n.document.readOnly===!0,view:c(n.document.view),permissions:l(n.document.permissions),watermark:u(n.document.watermark),onReveal:e=>g.on(`document/reveal`,t=>{let n=c(t?.view);n&&e(n)}),ui:_,brand:h,kit:{id:i.id,version:i.version},display:Y_(i.display),declaration:i.ui??null,opened:(e=[])=>{let t=[...i.capabilities??[`ai`],...i.ui?[`ui-config`]:[]];r({kit:{id:i.id,version:i.version},capabilities:[...t,...e.filter(e=>!t.includes(e))]})},failed:e=>a(e),changed:e=>g.notify(`document/changed`,e),notify:e=>g.notify(`host/notify`,e),exportFile:async(e,t)=>{let n=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);return(await g.request(`host/write`,{path:e,bytes:n,mode:`export`},{transfer:!0})).path},openAgent:async e=>{await g.request(`host/openAgent`,e?{prompt:e}:{})},pick:async(e,t)=>(await g.request(`host/pick`,{purpose:e,accept:t})).path,pickLinks:async e=>(await g.request(`links/pick`,e)).links,hasService:e=>n.capabilities.includes(`${p}${e}`),service:async(e,t)=>{if(!n.capabilities.includes(`service:${e}`))throw new o(-32e3,`the host does not serve ${e}`,{reason:`not-allowed`});let r=e===`file.saveAs`;return await g.request(`host/service`,{service:e,params:t},r?{transfer:!0}:void 0)},commentAnchors:n.capabilities.includes(`comment-anchors`),onComments:t=>g.on(`comments/show`,n=>{t((Array.isArray(n?.threads)?n.threads:[]).flatMap(t=>{let n=e(t?.anchor);return n&&typeof t?.id==`string`?[{id:t.id,anchor:n,resolved:t.resolved===!0,count:Number.isSafeInteger(t.count)?t.count:0}]:[]}))}),activateComment:e=>g.notify(`comments/activated`,{id:e}),locateComments:t=>g.handle(`comments/locate`,async n=>{let r=(Array.isArray(n?.anchors)?n.anchors:[]).map(t=>e(t)),i=await t(r.filter(e=>e!==null)),a=0;return{found:r.map(e=>e?i[a++]===!0:!1)}}),close:()=>{window.removeEventListener(`keydown`,y,!0),g.close()}})}))};window.addEventListener(`message`,h),m()})}var jv=class extends Error{constructor(e){super(e.message),this.data=e,this.name=`KitModelError`}},Mv=new Set([`edit.undo`,`undo`]),Nv=new Set([`edit.redo`,`redo`]),Pv=`read-only`,Fv=Object.freeze({viewingGroups:Object.freeze([`view`,`select`,`selection`,`go`,`navigate`,`help`,`playback`,`transport`,`playhead`,`caret`]),viewingCommands:Object.freeze([`markers.goNext`,`markers.goPrev`,`markers.goToIn`,`markers.goToOut`,`source.open`,`source.setPlayhead`,`source.inspect`,`sequence.open`,`sequence.moveTab`,`sequence.inspect`,`sequence.matchFrame`,`sequence.revealInProject`]),editingCommands:Object.freeze([`edit.undo`,`edit.redo`,`undo`,`redo`,`u`]),documentSettings:Object.freeze(`view.freezePanes,view.freezeTopRow,view.freezeFirstColumn,view.unfreezePanes,view.gridlines,view.headings,view.showZeros,view.rightToLeft,view.newWindow,view.addGuide,view.clearGuides,view.importGuides,view.moveGuide,view.removeGuide,view.lookAtSelected,view.lookAtAll,view.reset3DView,view.newGuide,view.newGuideLayout,view.newGuidesFromShape,view.deleteGuide,view.clearCanvasGuides,view.clearSelectedArtboardGuides,view.clearSlices,view.lockSlices,select.toWorkPath,select.convertToShape,select.saveSelection,select.float,select.drop,view.guides.make,view.guides.release,view.guides.clear,view.guides.lock,view.saved.new,view.saved.edit,select.save`.split(`,`)),editingGroups:Object.freeze([`file`]),fileOutputs:/^file\.(export|saveCopy|saveACopy|print)/,refusedTools:Object.freeze([`pointer`,`toolKey`,`toolText`]),refusedMethods:Object.freeze([`executeAs`,`undo`,`redo`,`importChanges`,`addBlobs`])});function Iv(e){let{id:t}=e,n=t.split(`.`)[0]??``;return Fv.editingCommands.includes(t)||Fv.documentSettings.includes(t)?!0:Fv.editingGroups.includes(n)?!Fv.fileOutputs.test(t):Fv.viewingCommands.includes(t)||Fv.viewingGroups.includes(n)?!1:e.mutates===!0}function Lv(e,t){return!t||!e?new Set:new Set(e.filter(e=>typeof e==`string`&&!Fv.editingCommands.includes(e)&&!Fv.editingGroups.includes(e.split(`.`)[0]??``)))}function Rv(e,t){return t.size===0?null:Mv.has(e)?`undo`:Nv.has(e)?`redo`:null}function zv(e,t){return Iv(e)&&!t.has(e.id)&&Rv(e.id,t)===null}function Bv(e,t){return t.size>0&&zv(e,t)}var Vv=class extends Error{reason=Pv;constructor(e,t){super(t??`${e} is not allowed: the document is read-only`),this.name=`ReadOnlyError`}};function Hv(e){return e instanceof Vv||e instanceof Error&&e.reason===`read-only`}var Uv=`unsupported`,Wv=class extends Error{constructor(e,t){super(e),this.errors=t,this.name=`KitParamsError`}reason=i},Gv=class extends Error{constructor(e,t){super(t),this.reason=e,this.name=`KitEngineRefusal`}},Kv={width:0,height:0,pinned:{left:0,top:0},revision:0,dirty:!1,canUndo:!1,canRedo:!1,inspected:{}},qv=class e{constructor(e,t){this.worker=e,this.info=t}closed=!1;pending=new Map;nextId=1;failure=null;fontListeners=new Set;fontsPending=0;static async open(t,n,r,i=null,a=null,o=!1,s=!1){let c=new Worker(new URL(new URL(`kitEngine.worker-xC2uPuSX-BzMhIUM6.js`,import.meta.url).href,``+import.meta.url),{type:`module`}),l=new e(c,Kv);c.onmessage=e=>l.settle(e.data),c.onerror=e=>l.fail(Error(e.message||`the kit engine stopped`));try{let e=a?.stored;return l.info=await l.call({method:`open`,manifest:t,name:n,bytes:r,lent:i,replica:a,readOnly:o,canComment:s},e?[r,e.snapshot,e.blobs]:[r]),l}catch(e){throw l.dispose(),e}}static async create(t,n,r,i,a=null,o=!1){let s=new Worker(new URL(new URL(`kitEngine.worker-xC2uPuSX-BzMhIUM6.js`,import.meta.url).href,``+import.meta.url),{type:`module`}),c=new e(s,Kv);s.onmessage=e=>c.settle(e.data),s.onerror=e=>c.fail(Error(e.message||`the kit engine stopped`));try{return c.info=await c.call({method:`create`,manifest:t,name:n,width:r,height:i,lent:a,readOnly:o}),c}catch(e){throw c.dispose(),e}}get width(){return this.info.width}get height(){return this.info.height}get pinned(){return this.info.pinned}settle(e){if(!(`id`in e)){let t=e.fonts<this.fontsPending;if(this.fontsPending=e.fonts,t)for(let e of this.fontListeners)e();return}let t=this.pending.get(e.id);t&&(this.pending.delete(e.id),e.ok===!0?t.resolve(e.value):e.data?t.reject(new jv(e.data)):e.reason===`read-only`?t.reject(new Vv(``,e.error)):e.reason===`invalid-params`?t.reject(new Wv(e.error,e.errors??[])):e.reason===Uv?t.reject(new Gv(Uv,e.error)):t.reject(Error(e.error)))}fail(e){this.failure=e;for(let t of this.pending.values())t.reject(e);this.pending.clear()}call(e,t=[]){if(this.failure)return Promise.reject(this.failure);let n=this.nextId++;return new Promise((r,i)=>{this.pending.set(n,{resolve:r,reject:i}),this.worker.postMessage({id:n,request:e},t)})}async execute(e,t={},n,r){let i={method:`execute`,command:e,params:t,...n?{origin:n}:{},...r?{agent:{state:r.state.state,set:r.set}}:{}},{result:a,info:o,state:s,closed:c}=await this.call(i);return c&&(this.closed=!0,this.info=Kv),o&&(this.info=o),r&&s!==void 0&&(r.state.state=s),a}async render(e,t,n,r,i){return new Uint8Array(await this.call({method:`render`,x:e,y:t,scale:n,width:r,height:i}))}async renderArea(e,t,n,r,i,a){return new Uint8Array(await this.call({method:`renderArea`,x0:e,y0:t,x1:n,y1:r,width:i,height:a}))}async commands(){return await this.call({method:`commands`})}async disabledCommands(){return await this.call({method:`disabledCommands`})}async check(){return await this.call({method:`check`})}async lendHandle(e,t){await this.call({method:`lendHandle`,handle:e,bytes:t},t?[t]:[])}async takeOutput(e,t){return new Uint8Array(await this.call({method:`takeOutput`,id:e,...t===void 0?{}:{max:t}}))}async save(){return(await this.serialize()).bytes}async serialize(){let e=await this.call({method:`save`});return{bytes:new Uint8Array(e.bytes),revision:e.revision}}async saveWithReplica(){let e=await this.call({method:`saveWithReplica`});return{bytes:new Uint8Array(e.bytes),replica:e.replica,revision:e.revision}}async replicaVersion(){return await this.call({method:`replicaVersion`})}async replicaExport(e){return await this.call({method:`replicaExport`,since:e})}async replicaImport(e,t){let{damage:n,info:r}=await this.call({method:`replicaImport`,changes:e,blobs:t});return this.info=r,n}async replicaDocId(){return await this.call({method:`replicaDocId`})}async replicaMerge(e,t,n,r){let{summary:i,info:a}=await this.call({method:`replicaMerge`,changes:e,blobs:t,origin:n,schema:r});return this.info=a,i}async replicaCompare(e,t){return await this.call({method:`replicaCompare`,changes:e,schema:t})}async modelVersion(){return await this.call({method:`modelVersion`})}async premiseRead(e,t){return this.call({method:`premiseRead`,name:e,params:t})}async inspectAt(e,t){return await this.call({method:`inspectAt`,context:e,part:t})}async modelChanges(e,t){return await this.call({method:`modelChanges`,since:e,schema:t})}async modelDescribe(e){return await this.call({method:`modelDescribe`,schema:e})}async agentReply(e){return await this.call({method:`modelReply`,value:e})}async modelBatch(e,t){let{answer:n,info:r}=await this.call({method:`modelBatch`,request:e,schema:t});return this.info=r,n}async markSaved(e){this.info=await this.call({method:`markSaved`,revision:e})}onFonts(e){return this.fontListeners.add(e),()=>this.fontListeners.delete(e)}async loadFonts(){await this.call({method:`fonts`})}async refreshInfo(){return this.info=await this.call({method:`info`}),this.info}async invoke(e,...t){return await this.call({method:`invoke`,name:e,args:t})}async tool(e,t=[],n=!1){let{value:r,info:i}=await this.call({method:`tool`,name:e,args:t,settled:n});return i&&(this.info=i),{value:r,changed:i!=null}}dispose(){this.worker.terminate(),this.fail(Error(`the document was closed`))}},Jv=e=>e.x1<=e.x0||e.y1<=e.y0;function Yv(e,t){return e===null||t===null?null:Jv(t)?e:Jv(e)?t:{x0:Math.min(e.x0,t.x0),y0:Math.min(e.y0,t.y0),x1:Math.max(e.x1,t.x1),y1:Math.max(e.y1,t.y1)}}var Xv={x0:0,y0:0,x1:0,y1:0},Zv=32;function Qv(){let e=[],t=0;return{add(n){if(t+=1,e.push({seq:t,damage:n}),e.length>Zv){let[t,n,...r]=e;e=[{seq:n.seq,damage:Yv(t.damage,n.damage)},...r]}return t},total:()=>e.reduce((e,t)=>Yv(e,t.damage),Xv),last:()=>t,paid(t){e=e.filter(e=>e.seq>t)}}}async function $v(e,t,n,r=!1){if(!e.replicaRead)return null;try{let i=await e.replicaRead(t);if(!i)return null;if(r)return{snapshot:i.snapshot,blobs:i.blobs};let a=n??await e.stamp(t);return a&&i.fileStamp===a?{snapshot:i.snapshot,blobs:i.blobs}:null}catch{return null}}async function ey(e,t,n,r,i){let a=await e.write(t,n,i)||await e.stamp(t).catch(()=>null);if(r&&a&&e.replicaWrite)try{await e.replicaWrite(t,{...r,fileStamp:a})}catch(e){console.warn(`[kit] could not store the document replica`,e)}return a}function ty(e){let t=typeof e==`object`&&e?e.damage:null;if(typeof t!=`object`||!t)return null;let{x0:n,y0:r,x1:i,y1:a}=t;return[n,r,i,a].every(e=>typeof e==`number`&&Number.isFinite(e))&&i>n&&a>r?{x0:n,y0:r,x1:i,y1:a}:null}var ny=new WeakMap;function ry(){let e=Qv(),t={tick:0,damage:null},n=new Set;return{get:()=>t,subscribe(e){return n.add(e),()=>void n.delete(e)},bump(r){t={tick:e.add(r),damage:e.total()};for(let e of n)e()},taken(t){e.paid(t)}}}var iy=new WeakMap,ay=class extends Error{constructor(e){super(`${e} changed on disk since it was opened; merge the change or keep yours before saving`),this.name=`FileChangedError`}},oy=2e3;function sy(e){return e instanceof Error?e.message:String(e)}function cy(e,t,n,r,i,a={}){let o=a.readOnly===!0,s=o&&a.canComment===!0,c=a.replicaMergesFile===!0,l=(0,j.useRef)(a.followFile);l.current=a.followFile;let u=(0,j.useRef)(null),d=(0,j.useRef)(i);d.current=i;let f=(0,j.useRef)(null),p=(0,j.useRef)(!1),[m,h]=(0,j.useState)(null),[g,_]=(0,j.useState)(null),[v,y]=(0,j.useState)(null),[b,x]=(0,j.useState)({revision:0,damage:null}),[S,C]=(0,j.useState)(!1),[w,T]=(0,j.useState)(null),[E,D]=(0,j.useState)(null),[O,k]=(0,j.useState)(!1),[A,M]=(0,j.useState)(!1),[N,ee]=(0,j.useState)(0),P=(0,j.useRef)(null);P.current??=ry();let F=P.current,te=(0,j.useRef)(null);te.current??=Qv();let ne=te.current,I=(0,j.useRef)(new WeakMap),re=(0,j.useCallback)((e=null)=>{let t=u.current;t&&(_(t.info),y(d.current(t.info)),C(t.info.dirty),ne.add(e),x(e=>{let t={revision:e.revision+1,damage:ne.total()};return I.current.set(t,ne.last()),t}))},[ne]);(0,j.useLayoutEffect)(()=>{let e=I.current.get(b);e&&ne.paid(e)},[b,ne]);let ie=(0,j.useCallback)(async r=>{p.current=!0;try{let{bytes:i,stamp:a}=await e.read(n);if(!r())return;let l=await $v(e,n,a,c);if(!r())return;let d=performance.now(),p=n.split(`/`).filter(Boolean).pop()||n,m=await qv.open(t,p,i,e.lend?.(n)??null,e.replicaWrite?{stored:l,follow:!0}:null,o,s);if(D(Math.round(performance.now()-d)),!r()){m.dispose();return}let g=u.current;u.current=m,f.current=a,h(m),M(!1),T(null),re(),g?.dispose()}finally{p.current=!1}},[s,e,t,c,n,o,re]);(0,j.useEffect)(()=>{let e=!0;return ie(()=>e).catch(t=>{e&&T(sy(t))}),()=>{e=!1}},[N,ie]),(0,j.useEffect)(()=>()=>{u.current?.dispose(),u.current=null},[n]);let ae=(0,j.useRef)(new Set),oe=(0,j.useCallback)(e=>{ae.current.add(e);let t=()=>ae.current.delete(e);return e.then(t,t),e},[]),se=(0,j.useCallback)(async()=>{for(;ae.current.size;)await Promise.allSettled([...ae.current])},[]),L=(0,j.useCallback)(async(t=()=>!0)=>{let r=u.current;if(r&&!p.current&&f.current)try{let i=await e.stamp(n);if(!t()||!i||i===f.current||p.current||u.current!==r||(await se(),!t()||p.current||u.current!==r))return;if(r.info.dirty){M(!0);return}let a=l.current;if(a){p.current=!0;let e=!1;try{e=await a(r,i)===!0}catch(e){console.warn(`[kit] could not follow the changed file; reopening it`,e)}finally{p.current=!1}if(e){u.current===r&&(f.current=i,await r.refreshInfo().catch(()=>{}),u.current===r&&re());return}}t()&&await ie(t)}catch{}},[e,ie,n,re,se]);(0,j.useEffect)(()=>{let e=!0,t=window.setInterval(()=>void L(()=>e),oy);return()=>{e=!1,window.clearInterval(t)}},[r,L]);let ce=(0,j.useRef)(null),le=(0,j.useCallback)(e=>ce.current?ce.current(e):e(),[]),ue=(0,j.useCallback)(async(e,t,n,r)=>{let i=u.current;if(!i)return null;let a=r.skipUnchangedPaint?{revision:i.info.revision,inspected:JSON.stringify(i.info.inspected)}:null,o=await i.execute(e,t,r.origin,r.agent);if(u.current===i){if(i.closed)return i.dispose(),u.current=null,h(null),_(null),y(null),C(!1),M(!1),o;let e=r.refresh??`all`,t=a!=null&&i.info.revision===a.revision&&JSON.stringify(i.info.inspected)===a.inspected;e===`all`?re(t?Xv:n):e===`repaint`&&F.bump(n)}return o},[re,F]),de=(0,j.useCallback)(async(e,t={},n=null,r={})=>u.current?oe(le(()=>ue(e,t,n,r))):null,[le,ue,oe]),R=(0,j.useCallback)(async(e,t=[],n=!1)=>{let r=u.current;if(!r)return null;let i=r.info.revision,{value:a,changed:o}=await oe(r.tool(e,t,n));return u.current===r&&o&&re(r.info.revision===i?Xv:ty(a)),a},[re,oe]);iy.has(R)||iy.set(R,ce);let z=(0,j.useCallback)(async()=>u.current?u.current.commands():[],[]),fe=(0,j.useCallback)(async()=>le(async()=>u.current?u.current.disabledCommands():[]),[le]),pe=(0,j.useCallback)(async()=>{let t=u.current;if(t){if(o)throw new Vv(`Save`);k(!0),p.current=!0;try{let r=f.current,i=r?await e.stamp(n).catch(()=>null):null;if(r&&i&&i!==r)throw M(!0),new ay(n);let{bytes:a,replica:o,revision:s}=await le(async()=>e.replicaWrite?t.saveWithReplica():{...await t.serialize(),replica:null});f.current=await ey(e,n,a,o,r),u.current===t&&await t.markSaved(s),M(!1),re()}finally{p.current=!1,k(!1)}}},[e,le,n,o,re]),me=(0,j.useMemo)(()=>{let e=()=>{if(!u.current)throw Error(`the document is still opening`);return u.current};return{version:()=>e().replicaVersion(),exportChanges:t=>e().replicaExport(t),importChanges:async(t,n)=>{let r=e(),i=await r.replicaImport(t,n);return u.current===r&&re(),i},docId:()=>e().replicaDocId()}},[re]),he=(0,j.useMemo)(()=>{let e=()=>{if(!u.current)throw Error(`the document is still opening`);return u.current};return{describe:t=>e().modelDescribe(t),version:()=>le(()=>e().modelVersion()),changes:(t,n)=>le(()=>e().modelChanges(t,n)),batch:(t,n)=>le(async()=>{let r=e();try{return await r.modelBatch(t,n)}finally{u.current===r&&re()}})}},[le,re]),ge=(0,j.useMemo)(()=>{let r=()=>{if(!u.current)throw Error(`the document is still opening`);return u.current};return{open:()=>le(async()=>{let i=r();if(o)throw new Vv(`a draft`);let a=await i.replicaVersion(),{bytes:s,replica:c}=await i.saveWithReplica();if(!c)throw Error(`the kit's engine keeps no replica to draft on`);let l=n.split(`/`).filter(Boolean).pop()||n,u=s.slice().buffer;return{engine:await qv.open(t,l,u,e.lend?.(n)??null,{stored:c,follow:!0},!1),base:a}}),merge:(e,t,n,i)=>le(async()=>{let a=r();try{return await a.replicaMerge(e,t,n,i)}finally{u.current===a&&re()}}),compare:(e,t)=>r().replicaCompare(e,t)}},[e,t,le,n,o,re]),_e=(0,j.useCallback)(()=>ee(e=>e+1),[]),ve=(0,j.useCallback)(async t=>{t&&(f.current=t,await e.stamp(n).catch(()=>null)===t&&M(!1))},[e,n]),ye=(0,j.useCallback)(async()=>{M(!1);let t=await e.stamp(n).catch(()=>null);t&&(f.current=t)},[e,n]);return{path:n,manifest:t,doc:m,info:g,state:v,change:b,repaints:(0,j.useMemo)(()=>{let e={get:F.get,subscribe:F.subscribe};return ny.set(e,F),e},[F]),dirty:S,failure:w,openMs:E,saving:O,conflict:A,run:de,tool:R,commands:z,disabledCommands:fe,save:pe,replica:me,model:he,draft:ge,reopen:_e,keepMine:ye,checkFile:L,holdFile:ve}}async function ly(e,t){let n=Math.min(1,t/Math.max(1,e.width,e.height)),r=Math.max(1,Math.round(e.width*n)),i=Math.max(1,Math.round(e.height*n)),a=await e.render(0,0,n,r,i),o=document.createElement(`canvas`);return o.width=r,o.height=i,o.getContext(`2d`)?.putImageData(new ImageData(new Uint8ClampedArray(a.buffer,a.byteOffset,a.byteLength),r,i),0,0),o.toDataURL(`image/png`).replace(/^data:image\/png;base64,/,``)}async function uy(e,t){try{return await ly(e,t)}catch{return null}}var dy="there is no draft of this document: run the agent with `draft: true` first",fy=class{constructor(e){this.host=e}current=null;queue=Promise.resolve();closed=!1;info(){let e=this.current;return e?{state:e.state,revision:e.engine.info.revision}:{state:`none`,revision:null}}serial(e){let t=this.queue.then(e,e);return this.queue=t.catch(()=>{}),t}tell(){this.host.changed(this.info())}need(){if(!this.current)throw Error(dy);return this.current}engine(e){return this.serial(async()=>{if(this.closed)throw Error(`the document was closed`);if(!this.current){if(!e)throw Error(dy);let{engine:t,base:n}=await this.host.open();if(this.closed)throw t.dispose(),Error(`the document was closed`);this.current={engine:t,base:n,state:`open`},this.tell()}return this.current.engine})}edited(){this.current&&(this.current.state=`open`,this.tell())}ready(){return this.serial(async()=>(this.need().state=`ready`,this.tell(),this.info()))}reopen(){return this.serial(async()=>(this.need().state=`open`,this.tell(),this.info()))}changes(e){return e.engine.replicaExport(e.base.slice(0))}compare(e,t){return this.serial(async()=>{let n=this.need(),{changes:r}=await this.changes(n),i=await this.host.compare(r,t),[a,o]=[await this.host.preview(e),await uy(n.engine,e)];return{summary:i,before:a,after:o}})}merge(e,t){return this.serial(async()=>{let n=this.need(),{changes:r,blobs:i}=await this.changes(n),a=await this.host.merge(r,i,e,t);return this.close(),{merged:!0,summary:a}})}discard(){return this.serial(async()=>(this.close(),this.info()))}close(){let e=this.current;e&&(this.current=null,e.engine.dispose(),this.tell())}attach(){this.closed=!1}dispose(){this.closed=!0;let e=this.current;this.current=null,e?.engine.dispose()}},py=[[/^tool-selection$/,Ho],[/^tool-page$/,za],[/^tool-gap$/,ya],[/^tool-(collector|placer)/,Zo],[/^tool-(rect-frame|ellipse-frame|polygon-frame)/,Qa],[/^tool-note/,nc],[/^tool-color-theme/,es],[/^tool-gradient-feather/,Hi],[/^tool-(direct|group-select|live-select|perspective-select)/,Vo],[/^tool-magic-wand/,Oc],[/^tool-lasso/,_o],[/^tool-(pen|anchor)/,as],[/^tool-curvature/,Ks],[/^tool-(type|touch-type)/,_c],[/^tool-line$/,Bo],[/^tool-arc/,_s],[/^tool-spiral/,zs],[/^tool-(rect-grid|polar-grid|perspective)/,ro],[/^tool-(rect|rounded-rect|polygon|star|flare)/,Js],[/^tool-ellipse/,sa],[/^tool-(brush|blob-brush)/,Yi],[/^tool-(pencil|smooth|shaper|join|path-eraser)/,os],[/^tool-eraser?$/,Pa],[/^tool-(scissors|knife|mirror-cut|line-cut|rect-cut)/,Ms],[/^tool-(rotate|reflect)/,Es],[/^tool-scale/,js],[/^tool-shear/,ho],[/^tool-reshape/,wc],[/^tool-free-transform/,Tc],[/^tool-puppet/,Ac],[/^tool-(width|warp|twirl|pucker|bloat|scallop|crystallize|wrinkle)/,kc],[/^tool-shape-builder/,Ls],[/^tool-bucket/,Qo],[/^tool-mesh/,Go],[/^tool-gradient/,Hi],[/^tool-eyedropper/,ds],[/^tool-measure/,Os],[/^tool-blend/,Hi],[/^tool-artboard/,Qa],[/^tool-slice/,Ea],[/^tool-move$/,Wo],[/^tool-copy$/,Ca],[/^tool-offset$/,wa],[/^tool-extend$/,Ko],[/^tool-fillet$/,Ta],[/^tool-hand/,so],[/^tool-zoom/,Fc]],my=[[/^dim-?linear$/,ks],[/^dim-?aligned$/,Os],[/^dim-?radius$/,gs],[/^dim-?diameter$/,ka]];function hy(e,t){return(t?my.find(([e])=>e.test(t))?.[1]:void 0)??py.find(([t])=>t.test(e))?.[1]??Ls}var gy=[[/pivot/,lc],[/sparkline/,Di],[/chart|graph/,$i],[/table/,sc],[/picture|image|photo/,po],[/\bicons?\b|sticker/,tc],[/shape|drawing/,Ls],[/header/,ns],[/footer/,ts],[/hyperlink|\blink/,Co],[/bookmark/,Gi],[/equation|formula|function/,Zs],[/sum|sigma/,Vs],[/symbol|special char/,Xo],[/check ?box|checkbox/,Ys],[/comment|note/,Ro],[/text|word ?art|caption/,_c],[/signature/,Hs],[/date|time/,Xi],[/number|numbering/,co],[/video|movie|media/,Ec],[/audio|sound|music/,Jo],[/qr|barcode/,hs],[/block|object|3d|model/,Ki],[/layer/,vo],[/layout|template|theme/,bo],[/page|section|break|sheet|slide/,Ha],[/rows?\b/,Ds],[/columns?\b/,ya],[/filter/,$a],[/sort/,Bi],[/ungroup/,bc],[/group/,oo],[/find|search/,Ns],[/replace/,Cs],[/spell|proof/,Gs],[/translat|language/,go],[/print/,ms],[/paste/,ha],[/copy|duplicate/,Ca],[/cut\b/,Ms],[/delete|remove|clear/,hc],[/refresh|recalc/,xs],[/protect|lock/,jo],[/name|label|tag/,uc],[/show|hide|view/,Ia],[/option|setting|propert/,Fs],[/\bfile\b|document/,za]],_y=[[/^(?:bold)$/,Ui],[/^(?:italic)$/,ho],[/^(?:underline)$/,vc],[/^(?:strike|strikethrough)$/,rc],[/^(?:subscript)$/,ic],[/^(?:superscript)$/,ac],[/^(?:deselect|none)$/,Xs],[/^(?:inverse|invert)$/,Sa],[/^(?:pan)$/,so],[/^(?:measure)$/,Os],[/^(?:collapse)$/,aa],[/^(?:expand)$/,oa],[/^(?:bind|attach)$/,Co],[/^(?:audit|check|verify|validate)$/,Bs],[/^(?:recover|repair)$/,xo],[/^(?:purge)$/,hc],[/^(?:sketch)$/,os],[/^(?:read)$/,Wi],[/^(?:left)$/,Mi],[/^(?:right)$/,Fi],[/^(?:up)$/,zi],[/^(?:down)$/,ki],[/^(?:home|start)$/,Pi],[/^(?:end)$/,Ri],[/^(?:lift)$/,fa],[/^(?:extract)$/,da],[/^(?:shuttle)$/,Ra],[/^(?:tick|advance)$/,ec],[/^(?:batch)$/,vo],[/^(?:redact)$/,La],[/^(?:reselect)$/,Ho],[/^(?:click|tap|press)$/,Uo],[/^(?:undo)$/,yc],[/^(?:redo)$/,ys],[/^(?:save)$/,As],[/^(?:export|publish)$/,Va],[/^(?:import|place)$/,Ba],[/^(?:open|browse)$/,Za],[/^(?:close)$/,Nc],[/^(?:print)$/,ms],[/^(?:delete|remove|clear|erase)$/,hc],[/^(?:duplicate|copy|clone)$/,Ca],[/^(?:cut)$/,Ms],[/^(?:paste)$/,ha],[/^(?:rename)$/,ss],[/^(?:find|search|locate)$/,Ns],[/^(?:replace)$/,Cs],[/^(?:align|distribute)$/,Oi],[/^(?:rotate)$/,Es],[/^(?:flip|mirror|reflect)$/,Ja],[/^(?:move|nudge|offset|shift)$/,Wo],[/^(?:scale|resize|transform|warp|distort)$/,js],[/^(?:merge|join|combine|flatten)$/,Lo],[/^(?:split|divide|separate)$/,qs],[/^(?:group)$/,oo],[/^(?:ungroup)$/,bc],[/^(?:lock)$/,jo],[/^(?:unlock)$/,Mo],[/^(?:hide)$/,La],[/^(?:show|reveal|view)$/,Ia],[/^(?:zoom)$/,Fc],[/^(?:play|preview)$/,fs],[/^(?:pause)$/,rs],[/^(?:stop)$/,Js],[/^(?:record|capture)$/,ja],[/^(?:render|bake|encode)$/,ua],[/^(?:reset|revert|restore|default)$/,ws],[/^(?:apply|commit|confirm|accept)$/,ea],[/^(?:cancel|reject|discard)$/,Nc],[/^(?:toggle|enable|disable|switch)$/,mc],[/^(?:next|forward)$/,ra],[/^(?:previous|prev|back)$/,na],[/^(?:step)$/,ec],[/^(?:go|jump|seek)$/,Fi],[/^(?:trim|crop)$/,Ea],[/^(?:insert|add|new|create|make)$/,ps],[/^(?:select|pick)$/,Ho],[/^(?:list|inspect|info|get|query|state)$/,To],[/^(?:convert|change)$/,Ss],[/^(?:sort)$/,Bi],[/^(?:filter)$/,$a],[/^(?:link)$/,Co],[/^(?:unlink)$/,xc],[/^(?:increase|grow|raise)$/,zi],[/^(?:decrease|shrink|lower)$/,ki],[/^(?:refresh|reload|update|sync)$/,xs],[/^(?:define|edit|modify|configure)$/,os],[/^(?:arrange|order|bring|send)$/,Ji],[/^(?:snap)$/,No],[/^(?:smooth|simplify)$/,Ks],[/^(?:stroke|outline)$/,is],[/^(?:fill)$/,Qo],[/^(?:mask)$/,Xs]],vy=[[/\b(?:heading|title)\b/,lo],[/\b(?:level|outline|tree)\b/,ko],[/\b(?:code)\b/,va],[/\b(?:direction)\b/,Li],[/\b(?:waypoints?|bends?)\b/,Ac],[/\b(?:stats|statistics|performance)\b/,to],[/\b(?:mixer)\b/,Us],[/\b(?:clipboard)\b/,pa],[/\b(?:cache)\b/,Oa],[/\b(?:values?)\b/,co],[/\b(?:autofill|series)\b/,ji],[/\b(?:flash)\b/,Pc],[/\b(?:painter)\b/,$o],[/\b(?:field|form)\b/,fc],[/\b(?:tab order)\b/,Do],[/\b(?:smart ?graphics?|diagram)\b/,Yo],[/\b(?:action button|button)\b/,Uo],[/\b(?:pen)\b/,as],[/\b(?:pencil)\b/,os],[/\b(?:highlighter)\b/,fo],[/\b(?:word)\b/,jc],[/\b(?:caret|cursor)\b/,dc],[/\b(?:distance|perimeter|area)\b/,Os],[/\b(?:work area)\b/,ua],[/\b(?:brush|paint)\b/,Yi],[/\b(?:gradient)\b/,Hi],[/\b(?:transparen|opacity|blend)\b/,Hi],[/\b(?:colou?rs?|swatch|palette)\b/,es],[/\b(?:font|character|typograph|text|type)\b/,_c],[/\b(?:para(graph)?)\b/,cs],[/\b(?:presets?|styles?)\b/,oc],[/\b(?:layers?)\b/,vo],[/\b(?:paths?|anchor|point|bezier|curve)\b/,Ks],[/\b(?:camera)\b/,Qi],[/\b(?:track)\b/,Ds],[/\b(?:clip|footage|sequence|timeline|multicam)\b/,Ka],[/\b(?:markers?|bookmark)\b/,Gi],[/\b(?:keys?|keyframe)\b/,Aa],[/\b(?:channel)\b/,Us],[/\b(?:perspective|3d)\b/,Ki],[/\b(?:grid|guide)\b/,ro],[/\b(?:frame|artboard)\b/,Qa],[/\b(?:data|database|source)\b/,Oa],[/\b(?:queue)\b/,Do],[/\b(?:project)\b/,Xa],[/\b(?:comp(osition)?)\b/,vo],[/\b(?:playhead|time|duration)\b/,ga],[/\b(?:audio|sound|volume)\b/,Dc],[/\b(?:video)\b/,Ec],[/\b(?:preferences|settings|options)\b/,Fs],[/\b(?:shape|rectangle|ellipse|polygon)\b/,Ls],[/\b(?:light|lamp)\b/,So],[/\b(?:solid)\b/,Js],[/\b(?:null)\b/,Da],[/\b(?:adjustment)\b/,Us],[/\b(?:footage|media)\b/,Ka],[/\b(?:folder)\b/,Xa],[/\b(?:mosaic)\b/,no],[/\b(?:gradient mesh|mesh)\b/,ro],[/\b(?:line|arrow)\b/,qo],[/\b(?:comment|note)\b/,Ro],[/\b(?:page)\b/,za],[/\b(?:cell|row|column)\b/,sc],[/\b(?:formula|function)\b/,Zs],[/\b(?:symbol)\b/,xa],[/\b(?:effect|filter)\b/,Oc],[/\b(?:selection)\b/,Ho]],yy=ba,by=/^(?:insert|add|new|create|make)$/,xy=new Map;function Sy(e){let t=xy.get(e.id);if(t)return t;let n=e=>e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/[._-]/g,` `).toLowerCase(),r=n(e.id.split(`.`).pop()??``).split(` `)[0],i=(e.title??``).trim().split(/\s+/)[0]?.toLowerCase()??``,a=`${n(e.id)} ${(e.title??``).toLowerCase()}`;if(by.test(r)||by.test(i)){let t=`${n(e.id.split(`.`).pop()??``)} ${(e.title??``).toLowerCase()}`,r=vy.find(([e])=>e.test(t))?.[1];if(r)return r}return _y.find(([e])=>e.test(r)||e.test(i))?.[1]||(vy.find(([e])=>e.test(a))?.[1]??gy.find(([e])=>e.test(a))?.[1]??yy)}function Cy(e){return Object.values(e.schema??{}).some(e=>e.required)}var wy=6,Ty=e=>typeof e==`string`?e:JSON.stringify(e);function Ey(e,t){return t===void 0?e.default===void 0?e.enum?.length?e.required?String(e.enum[0]):``:e.type===`boolean`?`false`:``:Ty(e.default):Ty(t)}function Dy(e,t){switch(e.type){case`number`:case`integer`:return t.trim()===``?void 0:Number(t);case`boolean`:return t===`true`;case`string`:return t===``?void 0:t;default:if(t.trim()===``)return;try{return JSON.parse(t)}catch{return t}}}function Oy({command:e,onRun:t,onClose:n,labels:r,values:i={},title:a}){let o=e.schema??{},[s,c]=(0,j.useState)(()=>Object.fromEntries(Object.entries(o).map(([e,t])=>[e,Ey(t,i[e])]))),l=Object.entries(o),u=l.length>wy,d=([e,t])=>!u||t.required||i[e]!==void 0,f=l.filter(d),p=l.filter(e=>!d(e)),m=([e,t])=>{let n=t=>c(n=>({...n,[e]:t})),i=`param-${e}`;return[(0,I.jsxs)(`label`,{htmlFor:i,title:t.description,children:[e,t.required?(0,I.jsx)(`span`,{title:r.required,children:` *`}):null]},`${e}-label`),t.enum?.length?(0,I.jsxs)(`select`,{id:i,className:`kui-field`,value:s[e],onChange:e=>n(e.target.value),children:[t.required?null:(0,I.jsx)(`option`,{value:``}),t.enum.map(e=>(0,I.jsx)(`option`,{value:String(e),children:String(e)},String(e)))]},e):t.type===`boolean`?(0,I.jsx)(`input`,{id:i,type:`checkbox`,checked:s[e]===`true`,onChange:e=>n(String(e.target.checked))},e):(0,I.jsx)(`input`,{id:i,className:`kui-field`,type:t.type===`number`||t.type===`integer`?`number`:`text`,value:s[e],placeholder:t.description,onChange:e=>n(e.target.value)},e)]},h=Object.entries(o).some(([e,t])=>t.required&&(s[e]??``).trim()===``),g=()=>{let e={};for(let[t,n]of Object.entries(o)){let r=Dy(n,s[t]??``);r!==void 0&&(e[t]=r)}t(e)};return(0,I.jsx)(gl,{title:a??e.title,onClose:n,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Rc,{onClick:n,children:r.cancel}),(0,I.jsx)(Rc,{variant:`primary`,disabled:h,onClick:g,"data-testid":`command-dialog-run`,children:r.run})]}),children:(0,I.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h||g()},children:[(0,I.jsx)(`div`,{className:`kui-param-grid`,children:f.map(m)}),p.length?(0,I.jsxs)(`details`,{children:[(0,I.jsx)(`summary`,{children:r.more??`More options`}),(0,I.jsx)(`div`,{className:`kui-param-grid`,children:p.map(m)})]}):null,(0,I.jsx)(`button`,{type:`submit`,hidden:!0})]})})}function ky(e,t){let n=[t,t.split(`-`)[0],`en-US`].map(t=>e[t]??Object.entries(e).find(([e])=>e.split(`-`)[0]===t)?.[1]).filter(e=>!!e);return(e,t)=>{let r=n.find(t=>e in t)?.[e]??e;return t?r.replace(/\{(\w+)\}/g,(e,n)=>n in t?String(t[n]):e):r}}var Ay=new Set([`Cmd+N`,`Cmd+W`,`Cmd+O`,`Cmd+P`,`Cmd+Q`,`Cmd+,`,`Cmd+S`,`Cmd+Shift+S`,`Cmd+T`,`Cmd+.`]),jy={"[":`BracketLeft`,"]":`BracketRight`,",":`Comma`,".":`Period`,"/":`Slash`,"\\":`Backslash`,"-":`Minus`,"=":`Equal`,";":`Semicolon`,"'":`Quote`,"`":`Backquote`};function My(){return typeof navigator<`u`&&/Mac|iPhone|iPad/i.test(navigator.platform)}function Ny(e,t,n=My(),r=!1){let i=e.split(`+`),a=i.length>1&&i[i.length-1]===``?`+`:i.pop()??``,o=new Set(i.filter(Boolean)),s=o.has(`Cmd`),c=n?t.metaKey:t.ctrlKey,l=n?t.ctrlKey:!1;return s!==c||o.has(`Ctrl`)!==l||o.has(`Shift`)!==t.shiftKey||o.has(`Alt`)!==t.altKey?!1:/^[A-Za-z]$/.test(a)?t.code===`Key${a.toUpperCase()}`:/^[0-9]$/.test(a)?t.code===`Digit${a}`:jy[a]?t.code===jy[a]:a===`Delete`?t.key===`Delete`||!r&&t.key===`Backspace`:t.key===a}function Py(e){return!e||Ay.has(e)?!1:e.includes(`+`)||/^(Delete|Backspace|PageUp|PageDown|F[0-9]{1,2})$/.test(e)}function Fy(e,t,n=My()){let r=e.filter(e=>Py(e.shortcut));return r.find(e=>Ny(e.shortcut,t,n,!0))??r.find(e=>Ny(e.shortcut,t,n))}var Iy=`kit:`;function Ly(e){return e.startsWith(Iy)?`control:${e.slice(4)}`:`command:${e}`}function Ry(e){let t=[],n=new Set;for(let r of e){for(let e=1;e<=r.path.length;e+=1){let i=`menu:${r.path.slice(0,e).join(`/`)}`;n.has(i)||(n.add(i),t.push({id:i,kind:`menu`,label:r.path[e-1],parent:e>1?`menu:${r.path.slice(0,e-1).join(`/`)}`:null,menu:[]}))}if(r.command===`---`)continue;let e=Ly(r.command);t.push({id:e,kind:e.startsWith(`control:`)?`control`:`command`,label:r.label,parent:r.path.length?`menu:${r.path.join(`/`)}`:null,menu:r.path})}return t}var zy=[{id:`action:undo`,label:`undo`},{id:`action:redo`,label:`redo`},{id:`action:agent`,label:`askAgent`},{id:`action:mode`,label:`modeMenu`},{id:`action:save`,label:`save`},{id:`action:more`,label:`more`}],By={tools:`tool`,panels:`panel`,tabs:`tab`,groups:`group`,controls:`control`};function Vy(e){if(!e)return null;let t=Object.keys(By).flatMap(t=>(e[t]??[]).map(e=>e.id));return new Set([...Ry(e.menus??[]).map(e=>e.id),...t,...zy.map(e=>e.id)])}function Hy({commands:e,declaration:t,engineTools:n,agent:r,t:i,phrase:a,config:o}){let s=[],c=new Set,l=(e,t,n,r,i=[])=>{if(c.has(e))return;c.add(e);let a=bv(o,e,i);s.push({id:e,kind:t,label:n,parent:r,hidden:a.hidden,disabled:a.disabled})};for(let e of Ry(t?.menus??[]))l(e.id,e.kind,a(e.label),e.parent,e.menu);for(let t of e){for(let e=1;e<=t.menu.length;e+=1){let n=e>1?`menu:${t.menu.slice(0,e-1).join(`/`)}`:null;l(`menu:${t.menu.slice(0,e).join(`/`)}`,`menu`,a(t.menu[e-1]),n)}l(`command:${t.id}`,`command`,a(t.title),t.menu.length?`menu:${t.menu.join(`/`)}`:null,t.menu)}for(let e of n)l(`tool:${e.id}`,`tool`,a(e.label),null);for(let e of Object.keys(By))for(let n of t?.[e]??[])l(n.id,By[e],i(n.label),n.parent??null);for(let e of zy)(r||e.id!==`action:agent`)&&l(e.id,`action`,i(e.label),null);return s}var Uy=()=>!1,Wy=(0,j.createContext)(null),Gy=Ev(av,null,()=>{});function Ky(){let e=(0,j.useContext)(Wy),t=e?.store??Gy,n=(0,j.useSyncExternalStore)(t.subscribe,t.get);return{config:n,store:t,locale:e?.locale??`en-US`,declared:e?.declared??null,state:(t,r)=>{let i=t.startsWith(`command:`),a=bv(n,t,r??(i?e?.menuOf(t.slice(8))??[]:[]));return i&&!a.hidden&&e?.sessionHidden?.(t.slice(8))?{...a,hidden:!0}:a},sessionHidden:e?.sessionHidden??Uy,buttons:e=>xv(n,e),press:e?.press??(()=>{}),offerHide:e?.offerHide??null,openCustomize:e?.openCustomize??null,hide:e?.hide??null,renderButtons:e?.renderButtons??(()=>null)}}function qy({value:e,children:t}){return(0,I.jsx)(Wy.Provider,{value:e,children:(0,I.jsx)(Jy,{children:t})})}function Jy({children:e}){let t=(0,j.useContext)(Wy),n=Ky(),{config:r}=n,i=(0,j.useMemo)(()=>({state:e=>n.state(e),renderExtras:(e,t)=>n.renderButtons(e,t),drawn:e=>{e.startsWith(`menu:`)||n.declared}}),[r,t]);return(0,I.jsx)(R,{elements:i,children:e})}var Yy={bell:Vi,check:ea,download:Ma,eye:Ia,flag:qa,help:la,info:mo,link:Co,lock:jo,mail:Po,message:Ro,plus:ps,printer:ms,send:Ps,settings:Fs,share:Rs,star:$s,upload:Sc,x:Nc},Xy=new Map,Zy=32;function Qy(e){if(!e)return;if(!e.startsWith(`data:image/`))return Object.hasOwn(Yy,e)?Yy[e]:Js;let t=Xy.get(e);if(t)return Xy.delete(e),Xy.set(e,t),t;if(Xy.size>=Zy){let e=Xy.keys().next().value;e!==void 0&&Xy.delete(e)}let n=(({size:t=16})=>(0,I.jsx)(`img`,{src:e,width:t,height:t,alt:``,"aria-hidden":`true`}));return Xy.set(e,n),n}function $y({place:e,as:t}){let n=Ky();return(0,I.jsx)(I.Fragment,{children:n.buttons(e).map(e=>{let r=Sv(e,n.locale),i=Qy(e.icon),a=`host:${e.id}`;return t===`menu`?(0,I.jsx)(dl,{icon:i,label:r,shortcut:e.shortcut,disabled:e.disabled,onSelect:()=>n.press(e.id),uiId:a},e.id):t===`ribbon`?(0,I.jsx)(il,{icon:i,label:r,pressed:e.pressed,disabled:e.disabled,onClick:()=>n.press(e.id),"data-kit-ui-id":a},e.id):(0,I.jsxs)(Rc,{variant:`ghost`,"aria-pressed":e.pressed,disabled:e.disabled,onClick:()=>n.press(e.id),"data-kit-ui-id":a,children:[i?(0,I.jsx)(i,{size:15,strokeWidth:Lc,"aria-hidden":`true`}):null,r]},e.id)})})}var eb=new Set;function tb(e,t){let n=new Map(e.map(e=>[e.id,e])),r=e=>{let t=new Set;for(let r=e.parent;r!==null&&!t.has(r);){t.add(r);let e=n.get(r);if(!e)return!1;if(e.hidden)return!0;r=e.parent}return!1},i=e.filter(e=>!e.hidden&&e.id!==yv&&(e.kind!==`command`||e.parent!==null)&&!r(e)),a=new Map(i.map(e=>[e.id,e])),o=new Map;for(let e of i){if(e.parent===null)continue;let t=o.get(e.parent);t?t.push(e):o.set(e.parent,[e])}let s=(e,t)=>{let n=new Set(t);return n.add(e.id),{element:e,children:(o.get(e.id)??[]).filter(e=>!n.has(e.id)||(eb.has(e.id)||(eb.add(e.id),console.warn(`[kit-editor] ${e.id} is its own ancestor in the declared elements`)),!1)).map(e=>s(e,n))}},c=[],l=new Set;for(let e of i){if(l.has(e.id))continue;let t=[],n=e;for(;n!==void 0;){let e=n;if(l.has(e.id)){for(let e of t)l.add(e);break}let r=t.indexOf(e.id);if(r!==-1){c.push(a.get(t[r]));for(let e of t)l.add(e);break}t.push(e.id);let i=e.parent===null?void 0:a.get(e.parent);if(i===void 0){c.push(e);for(let e of t)l.add(e);break}n=i}}let u=t.trim().toLowerCase(),d=e=>{let t=e.children.map(d).filter(e=>e!==null);return u&&!e.element.label.toLowerCase().includes(u)&&!t.length?null:{element:e.element,children:t}};return c.map(e=>d(s(e,new Set))).filter(e=>e!==null)}function nb({catalog:e,personal:t,labels:n,onSave:r,onClose:i}){let[a,o]=(0,j.useState)([...t]),[s,c]=(0,j.useState)(``),l=(0,j.useMemo)(()=>tb(e,s),[e,s]),u=e=>o(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),d=(e,t)=>{let n=a.includes(e.element.id);return(0,I.jsxs)(`li`,{children:[(0,I.jsxs)(`label`,{className:`kui-customize-row`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:!n,disabled:t,onChange:()=>u(e.element.id),"data-element":e.element.id}),(0,I.jsx)(`span`,{children:e.element.label})]}),e.children.length?(0,I.jsx)(`ul`,{children:e.children.map(e=>d(e,t||n))}):null]},e.element.id)};return(0,I.jsxs)(gl,{title:n.title,onClose:i,actions:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Rc,{variant:`ghost`,onClick:()=>o([]),"data-action":`restore`,children:n.restore}),(0,I.jsx)(`span`,{style:{flex:1}}),(0,I.jsx)(Rc,{variant:`ghost`,onClick:i,children:n.cancel}),(0,I.jsx)(Rc,{variant:`primary`,onClick:()=>r(a),"data-action":`save`,children:n.save})]}),children:[(0,I.jsx)(`input`,{className:`kui-field kui-customize-search`,type:`search`,placeholder:n.search,"aria-label":n.search,value:s,onChange:e=>c(e.target.value)}),(0,I.jsx)(`ul`,{className:`kui-customize-tree`,"data-testid":`kit-customize-tree`,children:l.map(e=>d(e,!1))})]})}var rb={"en-US":{undo:`Undo`,redo:`Redo`,askAgent:`Ask Agent`,save:`Save`,saved:`Saved`,saveFailed:`Could not save`,commandFailed:`The command failed`,run:`Run`,cancel:`Cancel`,required:`Required`,zoomOut:`Zoom out`,zoomIn:`Zoom in`,fit:`Fit`,opening:`Opening…`,openFailed:`This file could not be opened`,renderFailed:`This view could not be rendered`,retryRender:`Retry`,unsaved:`Unsaved changes`,fileChanged:`This file changed outside the editor, and you have unsaved edits.`,keepMine:`Keep my edits`,reloadFile:`Load the new version`,noHost:`This editor runs inside a host, such as Kition.`,selected:`{count} selected`,moreOptions:`More options`,menuBar:`Menu`,ribbonScrollStart:`Scroll ribbon left`,ribbonScrollEnd:`Scroll ribbon right`,menusScrollStart:`Scroll menus left`,menusScrollEnd:`Scroll menus right`,optionsScrollStart:`Scroll tool options left`,optionsScrollEnd:`Scroll tool options right`,agentEdited:`Edited by the agent`,hostEdited:`Edited by the app`,agentLeaseHeld:`{name} is editing this part of the document, so the agent's edit was not made. Try again when they are done.`,someone:`Someone`,viewOnly:`View only`,viewOnlyRefused:`This document is view only`,commentOnly:`Can comment`,commentOnlyRefused:`You can only comment on this document`,more:`More`,customize:`Customize interface…`,customizeTitle:`Customize interface`,customizeSearch:`Search`,customizeRestore:`Restore defaults`,customizeSave:`Save`,customizeFailed:`Could not keep your customization`,hideElement:`Hide`,expandPanelGroup:`Expand panel group`,collapsePanelGroup:`Collapse panel group`,closePanel:`Close Panel`,maximizeFrame:`Maximize Frame`,restoreWorkspace:`Restore Workspace`,panelMenu:`Panel menu`,moreTabs:`More tabs`,resizePanels:`Resize panels`,colorPickerSquare:`Saturation and brightness`,colorPickerHue:`Hue`,colorPickerHex:`Hex color`,railTwoColumns:`Show tools in two columns`,railOneColumn:`Show tools in one column`,transportControls:`Transport controls`,levelMeter:`Audio levels`,keyframeLane:`Keyframes`,keyframeAt:`Keyframe at {time}`,previewDialogOk:`OK`,previewDialogCancel:`Cancel`,previewDialogReset:`Reset`,previewDialogPreview:`Preview`,previewDialogPending:`Updating the preview…`,previewDialogOff:`Preview is off: {error}`,curveEditor:`Curve`,curveEditorPoint:`Point {index}: {x}, {y}`,colorWheel:`color wheel`,colorWheelLightness:`{label} lightness`,colorWheelOffset:`{label}: {x}, {y}`,floatingPanelClose:`Close {title}`,floatingPanelResize:`Resize`,drawingIllustrations:`Illustrations`,drawingShapes:`Shapes`,drawingTextBox:`Text Box`,drawingRect:`Rectangle`,drawingRoundRect:`Rounded Rectangle`,drawingEllipse:`Oval`,drawingTriangle:`Triangle`,drawingDiamond:`Diamond`,drawingArrow:`Arrow`,drawingStar:`Star`,drawingLine:`Line`,drawingShapeStyles:`Shape Styles`,drawingFill:`Shape Fill`,drawingNoFill:`No Fill`,drawingOutline:`Shape Outline`,drawingNoOutline:`No Outline`,drawingWeight:`{value} pt`,drawingArrange:`Arrange`,drawingChangeShape:`Change Shape`,drawingRotateRight:`Rotate Right 90°`,drawingBringForward:`Bring Forward`,drawingBringToFront:`Bring to Front`,drawingSendBackward:`Send Backward`,drawingSendToBack:`Send to Back`,drawingGroup:`Group`,drawingConnect:`Connect`,drawingEffects:`Shape Effects`,drawingShadowBottomRight:`Shadow: Offset Bottom Right`,drawingShadowBottom:`Shadow: Offset Bottom`,drawingShadowAround:`Shadow: Around`,drawingNoShadow:`No Shadow`,drawingGlow:`Glow`,drawingNoGlow:`No Glow`,drawingTransform:`Transform`,drawingWarpArchUp:`Arch Up`,drawingWarpArchDown:`Arch Down`,drawingWarpCircle:`Circle`,drawingWarpWave1:`Wave 1`,drawingWarpWave2:`Wave 2`,drawingWarpInflate:`Inflate`,drawingWarpDeflate:`Deflate`,drawingWarpSlantUp:`Slant Up`,drawingWarpSlantDown:`Slant Down`,drawingWarpTriangle:`Triangle Up`,drawingWarpChevron:`Chevron Up`,drawingWarpCurveUp:`Curve Up`,drawingWarpCurveDown:`Curve Down`,drawingWarpCanUp:`Can Up`,drawingNoTransform:`No Transform`,drawingGradientDown:`Gradient: Linear Down`,drawingGradientRight:`Gradient: Linear Right`,drawingGradientDiagonal:`Gradient: Linear Diagonal`,drawingGradientCenter:`Gradient: From Center`,drawingUngroup:`Ungroup`,drawingDelete:`Delete`,drawingShapeFormat:`Shape Format`,chartInsert:`Chart`,chartColumn:`Clustered Column`,chartStackedColumn:`Stacked Column`,chartBar:`Clustered Bar`,chartLine:`Line`,chartLineMarkers:`Line with Markers`,chartArea:`Area`,chartPie:`Pie`,chartDoughnut:`Doughnut`,chartScatter:`Scatter`,chartRadar:`Radar`,chartType:`Type`,chartChangeType:`Change Chart Type`,chartElements:`Chart Elements`,chartTitle:`Chart Title`,chartTitleText:`Chart Title`,chartLegend:`Legend`,chartLegend_top:`Top`,chartLegend_bottom:`Bottom`,chartLegend_left:`Left`,chartLegend_right:`Right`,chartLegendNone:`None`,chartDataLabels:`Data Labels`,chartGridlines:`Gridlines`,chartAxisTitles:`Axis Titles`,chartTrendline:`Trendline`,chartTrendLinear:`Linear`,chartTrendExp:`Exponential`,chartTrendForecast:`Linear Forecast`,chartTrendMovingAvg:`Two-Period Moving Average`,chartErrorBars:`Error Bars`,chartErrStdErr:`Standard Error`,chartErrPercent:`Percentage`,chartErrStdDev:`Standard Deviation`,chartNone:`None`,chartSeriesType:`Chart Type`,chartSeriesTypeChart:`The chart's`,chartSecondaryAxis:`Secondary Axis`,chartAxisTitleText:`Axis Title`,chartData:`Data`,chartEditData:`Edit Data`,chartSeriesName:`Series {n} name`,chartCategoryName:`Category {n}`,chartValue:`{series}, {category}`,chartCategoryText:`Category {n}`,chartSeriesText:`Series {n}`,chartAddCategory:`Add Category`,chartAddSeries:`Add Series`,chartRemoveCategory:`Remove Category`,chartRemoveSeries:`Remove Series`,chartOk:`OK`,chartFormat:`Format`,chartFormatAxis:`Format Axis`,chartAxis:`Axis`,chartAxisValue:`Vertical (Value) Axis`,chartAxisCategory:`Horizontal (Category) Axis`,chartAxisMin:`Minimum`,chartAxisMax:`Maximum`,chartAxisMajor:`Major unit`,chartAxisNumberFormat:`Number format`,chartAxisAuto:`Auto`,chartAxisShow:`Show axis`,chartLabelPosition:`Label Position`,chartLabel_bestFit:`Best Fit`,chartLabel_ctr:`Center`,chartLabel_inBase:`Inside Base`,chartLabel_inEnd:`Inside End`,chartLabel_outEnd:`Outside End`,chartLabel_l:`Left`,chartLabel_r:`Right`,chartLabel_t:`Above`,chartLabel_b:`Below`,chartFormatSeries:`Format Series`,chartSeries:`Series`,chartLineWidth:`Line width (pt)`,chartMarker:`Marker`,chartMarker_auto:`Automatic`,chartMarker_none:`None`,chartMarker_circle:`Circle`,chartMarker_dash:`Dash`,chartMarker_diamond:`Diamond`,chartMarker_dot:`Dot`,chartMarker_plus:`Plus`,chartMarker_square:`Square`,chartMarker_star:`Star`,chartMarker_triangle:`Triangle`,chartMarker_x:`X`,chartSmooth:`Smoothed line`,inkTools:`Tools`,inkPens:`Pens`,inkSelect:`Select`,inkPen:`Pen`,inkPencil:`Pencil`,inkHighlighter:`Highlighter`,inkEraser:`Eraser`,inkColor:`Ink Color`,inkWeight:`Thickness`,modeMenu:`Display mode`,modeButton:`Display mode: {mode}`,modeStepped:`Display mode: {mode} (showing {shown} to fit the window)`,mode_menus:`Menus`,mode_line:`Single line`,mode_classic:`Classic`,mode_focus:`Focus`,focusBar:`Focus`,exitFocus:`Exit focus`,lineMore:`More: {group}`},"zh-CN":{undo:`撤销`,redo:`重做`,askAgent:`询问 Agent`,save:`保存`,saved:`已保存`,saveFailed:`无法保存`,commandFailed:`命令执行失败`,run:`运行`,cancel:`取消`,required:`必填`,zoomOut:`缩小`,zoomIn:`放大`,fit:`适应窗口`,opening:`正在打开…`,openFailed:`无法打开此文件`,renderFailed:`无法渲染此视图`,retryRender:`重试`,unsaved:`有未保存的更改`,fileChanged:`此文件在编辑器外被修改,而你有未保存的更改。`,keepMine:`保留我的更改`,reloadFile:`加载新版本`,noHost:`此编辑器需在宿主(如 Kition)中运行。`,selected:`已选 {count} 项`,moreOptions:`更多选项`,menuBar:`菜单`,ribbonScrollStart:`向左滚动功能区`,ribbonScrollEnd:`向右滚动功能区`,menusScrollStart:`向左滚动菜单`,menusScrollEnd:`向右滚动菜单`,optionsScrollStart:`向左滚动工具选项`,optionsScrollEnd:`向右滚动工具选项`,agentEdited:`由 Agent 编辑`,hostEdited:`由应用编辑`,agentLeaseHeld:`{name} 正在编辑文档的这一部分,因此未执行 Agent 的编辑。请等其完成后再试。`,someone:`有人`,viewOnly:`仅查看`,viewOnlyRefused:`此文档仅供查看`,commentOnly:`可评论`,commentOnlyRefused:`你只能评论此文档`,more:`更多`,customize:`自定义界面…`,customizeTitle:`自定义界面`,customizeSearch:`搜索`,customizeRestore:`恢复默认`,customizeSave:`保存`,customizeFailed:`无法保存你的自定义设置`,hideElement:`隐藏`,expandPanelGroup:`展开面板组`,collapsePanelGroup:`折叠面板组`,closePanel:`关闭面板`,maximizeFrame:`最大化框架`,restoreWorkspace:`恢复工作区`,panelMenu:`面板菜单`,moreTabs:`更多选项卡`,resizePanels:`调整面板大小`,colorPickerSquare:`饱和度和明度`,colorPickerHue:`色相`,colorPickerHex:`十六进制颜色`,railTwoColumns:`以两列显示工具`,railOneColumn:`以一列显示工具`,transportControls:`播放控件`,levelMeter:`音频电平`,keyframeLane:`关键帧`,keyframeAt:`{time} 处的关键帧`,previewDialogOk:`确定`,previewDialogCancel:`取消`,previewDialogReset:`重置`,previewDialogPreview:`预览`,previewDialogPending:`正在更新预览…`,previewDialogOff:`预览已关闭:{error}`,curveEditor:`曲线`,curveEditorPoint:`点 {index}:{x},{y}`,colorWheel:`色轮`,colorWheelLightness:`{label}亮度`,colorWheelOffset:`{label}:{x},{y}`,floatingPanelClose:`关闭{title}`,floatingPanelResize:`调整大小`,drawingIllustrations:`插图`,drawingShapes:`形状`,drawingTextBox:`文本框`,drawingRect:`矩形`,drawingRoundRect:`圆角矩形`,drawingEllipse:`椭圆`,drawingTriangle:`三角形`,drawingDiamond:`菱形`,drawingArrow:`箭头`,drawingStar:`星形`,drawingLine:`直线`,drawingShapeStyles:`形状样式`,drawingFill:`形状填充`,drawingNoFill:`无填充`,drawingOutline:`形状轮廓`,drawingNoOutline:`无轮廓`,drawingWeight:`{value} 磅`,drawingArrange:`排列`,drawingChangeShape:`更改形状`,drawingRotateRight:`向右旋转 90°`,drawingBringForward:`上移一层`,drawingBringToFront:`置于顶层`,drawingSendBackward:`下移一层`,drawingSendToBack:`置于底层`,drawingGroup:`组合`,drawingConnect:`连接`,drawingEffects:`形状效果`,drawingShadowBottomRight:`阴影:右下偏移`,drawingShadowBottom:`阴影:下方偏移`,drawingShadowAround:`阴影:四周`,drawingNoShadow:`无阴影`,drawingGlow:`发光`,drawingNoGlow:`无发光`,drawingTransform:`转换`,drawingWarpArchUp:`上弯弧`,drawingWarpArchDown:`下弯弧`,drawingWarpCircle:`圆`,drawingWarpWave1:`波形 1`,drawingWarpWave2:`波形 2`,drawingWarpInflate:`膨胀`,drawingWarpDeflate:`收缩`,drawingWarpSlantUp:`上斜`,drawingWarpSlantDown:`下斜`,drawingWarpTriangle:`正三角`,drawingWarpChevron:`V 形:正`,drawingWarpCurveUp:`上弯`,drawingWarpCurveDown:`下弯`,drawingWarpCanUp:`桶形:正`,drawingNoTransform:`无转换`,drawingGradientDown:`渐变:线性向下`,drawingGradientRight:`渐变:线性向右`,drawingGradientDiagonal:`渐变:线性对角`,drawingGradientCenter:`渐变:从中心`,drawingUngroup:`取消组合`,drawingDelete:`删除`,drawingShapeFormat:`形状格式`,chartInsert:`图表`,chartColumn:`簇状柱形图`,chartStackedColumn:`堆积柱形图`,chartBar:`簇状条形图`,chartLine:`折线图`,chartLineMarkers:`带数据标记的折线图`,chartArea:`面积图`,chartPie:`饼图`,chartDoughnut:`圆环图`,chartScatter:`散点图`,chartRadar:`雷达图`,chartType:`类型`,chartChangeType:`更改图表类型`,chartElements:`图表元素`,chartTitle:`图表标题`,chartTitleText:`图表标题`,chartLegend:`图例`,chartLegend_top:`顶部`,chartLegend_bottom:`底部`,chartLegend_left:`左侧`,chartLegend_right:`右侧`,chartLegendNone:`无`,chartDataLabels:`数据标签`,chartGridlines:`网格线`,chartAxisTitles:`坐标轴标题`,chartTrendline:`趋势线`,chartTrendLinear:`线性`,chartTrendExp:`指数`,chartTrendForecast:`线性预测`,chartTrendMovingAvg:`双周期移动平均`,chartErrorBars:`误差线`,chartErrStdErr:`标准误差`,chartErrPercent:`百分比`,chartErrStdDev:`标准偏差`,chartNone:`无`,chartSeriesType:`图表类型`,chartSeriesTypeChart:`与图表相同`,chartSecondaryAxis:`次坐标轴`,chartAxisTitleText:`坐标轴标题`,chartData:`数据`,chartEditData:`编辑数据`,chartSeriesName:`系列 {n} 名称`,chartCategoryName:`类别 {n}`,chartValue:`{series},{category}`,chartCategoryText:`类别 {n}`,chartSeriesText:`系列 {n}`,chartAddCategory:`添加类别`,chartAddSeries:`添加系列`,chartRemoveCategory:`删除类别`,chartRemoveSeries:`删除系列`,chartOk:`确定`,chartFormat:`格式`,chartFormatAxis:`设置坐标轴格式`,chartAxis:`坐标轴`,chartAxisValue:`垂直(值)轴`,chartAxisCategory:`水平(类别)轴`,chartAxisMin:`最小值`,chartAxisMax:`最大值`,chartAxisMajor:`主要单位`,chartAxisNumberFormat:`数字格式`,chartAxisAuto:`自动`,chartAxisShow:`显示坐标轴`,chartLabelPosition:`标签位置`,chartLabel_bestFit:`最佳匹配`,chartLabel_ctr:`居中`,chartLabel_inBase:`轴内侧`,chartLabel_inEnd:`数据标签内`,chartLabel_outEnd:`数据标签外`,chartLabel_l:`靠左`,chartLabel_r:`靠右`,chartLabel_t:`靠上`,chartLabel_b:`靠下`,chartFormatSeries:`设置数据系列格式`,chartSeries:`系列`,chartLineWidth:`线条宽度(磅)`,chartMarker:`数据标记`,chartMarker_auto:`自动`,chartMarker_none:`无`,chartMarker_circle:`圆形`,chartMarker_dash:`短划线`,chartMarker_diamond:`菱形`,chartMarker_dot:`圆点`,chartMarker_plus:`加号`,chartMarker_square:`正方形`,chartMarker_star:`星形`,chartMarker_triangle:`三角形`,chartMarker_x:`X 形`,chartSmooth:`平滑线`,inkTools:`工具`,inkPens:`笔`,inkSelect:`选择`,inkPen:`笔`,inkPencil:`铅笔`,inkHighlighter:`荧光笔`,inkEraser:`橡皮擦`,inkColor:`墨迹颜色`,inkWeight:`粗细`,modeMenu:`显示模式`,modeButton:`显示模式:{mode}`,modeStepped:`显示模式:{mode}(为适应窗口,显示为{shown})`,mode_menus:`菜单`,mode_line:`单行`,mode_classic:`经典`,mode_focus:`专注`,focusBar:`专注`,exitFocus:`退出专注`,lineMore:`更多:{group}`}};function ib(e,t){let n={...rb};for(let[t,r]of Object.entries(e))n[t]={...n[t],...r};return ky(n,t)}var ab=new Set;function ob(e){return e instanceof Error?e.message:String(e)}function sb(e){return Hv(e)||e?.data?.reason===`read-only`}function cb(e,t,n){e.report?e.report(t,n):El(`error`,t,ob(n))}var lb={"edit.undo":`undo`,"edit.redo":`redo`};function ub(e,t,n,r,i=e=>e,a,o={}){let s=(0,j.useRef)(o.report);s.current=o.report;let c=(0,j.useCallback)((e,t)=>s.current?s.current(e,t):El(`error`,e,ob(t)),[]),{doc:l,change:u}=e,[d,f]=(0,j.useState)([]),[p,m]=(0,j.useState)(new Set),[h,g]=(0,j.useState)(null),_=(0,j.useRef)(a);_.current=a;let v=(0,j.useCallback)((e,t={})=>g(e?{command:e,values:{..._.current?.(e),...t}}:null),[]),y=(0,j.useRef)(e);y.current=e;let b=(0,j.useSyncExternalStore)(t.ui.subscribe,t.ui.get),x=o.history??null,[,S]=(0,j.useState)(0);(0,j.useEffect)(()=>x?.subscribe(()=>S(e=>e+1)),[x]);let C=(0,j.useRef)(x);C.current=x;let w=t.readOnly===!0,T=e.comments??ab,E=(0,j.useCallback)(e=>w&&zv(e,T),[T,w]);(0,j.useEffect)(()=>{l&&l.commands().then(f)},[l]),(0,j.useEffect)(()=>{if(!l)return;let e=!1;return l.disabledCommands().catch(()=>[]).then(t=>{e||m(new Set(t))}),()=>{e=!0}},[u.revision,l]);let D=(0,j.useCallback)(async(e,n={})=>{let r=y.current.doc;if(!r)return null;let i=k.current.get(e);if(i?.mutates&&bv(t.ui.get(),`command:${e}`,i.menu).denied||i&&E(i))return null;try{return JSON.parse(await r.execute(e,n))}catch{return null}},[t,E]),O=(0,j.useMemo)(()=>new Map(d.map(e=>[e.id,e])),[d]),k=(0,j.useRef)(O);k.current=O;let A=(0,j.useCallback)(async(e,r)=>{let i=O.get(e),a=C.current,o=a?lb[e]:void 0;if(a&&o){if(bv(t.ui.get(),`command:${e}`,i?.menu).denied||bv(t.ui.get(),`action:${o}`).denied)return null;try{return JSON.stringify({done:await a[o]()!==!1})}catch(e){return c(n(`commandFailed`),e),null}}if(!r&&i&&Cy(i)&&!bv(t.ui.get(),`command:${e}`,i.menu).denied&&!E(i))return v(i),null;try{return await y.current.run(e,r??{})}catch(e){return w&&sb(e)?El(`info`,n(T.size?`commentOnlyRefused`:`viewOnlyRefused`)):c(n(`commandFailed`),e),null}},[O,T,t,w,E,c,v,n]),M=x?x.canUndo():l?.info?.canUndo??!1,N=x?x.canRedo():l?.info?.canRedo??!1,ee=(0,j.useCallback)((e,t)=>{let n=O.get(e);if(!n||bv(b,`command:${e}`,n.menu).denied)return!1;let r=x?lb[e]:void 0;if(r)return r===`undo`?M:N;if(t.has(e)||E(n))return!1;let i=w?Rv(e,T):null;return i===null||(i===`undo`?M:N)},[O,N,M,T,x,w,E,b]),P=(0,j.useCallback)(e=>ee(e,p),[p,ee]),F=(0,j.useCallback)(async e=>{let t=y.current.doc;if(!t)return!1;let n=await y.current.disabledCommands().catch(()=>null);return n!=null&&y.current.doc===t&&ee(e,new Set(n))},[ee]),te=(0,j.useCallback)(async()=>{try{await y.current.save(),El(`success`,n(`saved`))}catch(e){c(n(`saveFailed`),e)}},[c,n]);return{session:e,host:t,t:n,phrase:i,testId:r,commands:d,byId:O,enabled:P,enabledNow:F,run:A,ask:(0,j.useCallback)((e,n)=>{bv(t.ui.get(),`command:${e}`,O.get(e)?.menu).denied?A(e,n??{}):v(O.get(e)??null,n)},[O,t,A,v]),query:D,save:te,report:c,dialog:h,setDialog:v,comments:T,canUndo:M,canRedo:N}}var db=(0,j.createContext)(null);function fb({editor:e,tools:t=null,children:n}){let r=(0,j.useMemo)(()=>({editor:e,tools:t}),[e,t]),{host:i,byId:a,session:o}=e,s=(0,j.useSyncExternalStore)(i.ui.subscribe,i.ui.get),c=t?.setDenied,l=i.readOnly===!0;(0,j.useLayoutEffect)(()=>{c?.(e=>l||bv(s,`tool:${e}`).denied)},[s,l,c]);let u=(0,j.useMemo)(()=>Vy(i.declaration),[i]),d=(0,j.useRef)(o.doc);d.current=o.doc;let f=e.comments??ab,p=(0,j.useMemo)(()=>({store:i.ui,locale:i.init.locale,menuOf:e=>a.get(e)?.menu??[],declared:u,press:e=>i.ui.action({id:e,document:{path:i.init.document.path,dirty:d.current?.info.dirty??!1,revision:d.current?.info.revision??0}}),offerHide:null,openCustomize:null,hide:null,renderButtons:(e,t)=>(0,I.jsx)($y,{place:e,as:t}),sessionHidden:f.size?e=>Bv(a.get(e)??{id:e},f):void 0}),[a,f,u,i]),m=(0,j.useRef)(async()=>[]);return m.current=async()=>{let n=await o.commands(),r=t&&!t.tools.length?await o.tool(`tools`)??[]:t?.tools??[];return Hy({commands:n,declaration:i.declaration,engineTools:r,agent:i.init.capabilities.includes(`agent`),t:e.t,phrase:e.phrase,config:i.ui.get()})},(0,j.useEffect)(()=>{i.declaration&&i.peer.handle(`ui/elements`,()=>m.current())},[i]),(0,I.jsx)(db.Provider,{value:r,children:(0,I.jsx)(L,{strings:e.t,children:(0,I.jsx)(qy,{value:p,children:n})})})}function pb(){let e=(0,j.useContext)(db);if(!e)throw Error(`useKitEditor outside KitEditorProvider`);return e.editor}function mb(){return(0,j.useContext)(db)?.tools??null}function hb(e){let{offerHide:t}=Ky();return t?n=>{n.preventDefault(),t(e,n.clientX,n.clientY)}:void 0}function gb({command:e,params:t,label:n,icon:r,ask:i,shortcut:a,checked:o,path:s,onRun:c}){let l=pb(),{enabled:u,byId:d,testId:f,phrase:p}=l,m=Ky(),h=hb(`command:${e}`),g=s?m.state(`command:${e}`,s):null;if(m.state(`command:${e}`).hidden||g?.hidden)return null;let _=d.get(e);return(0,I.jsx)(`div`,{onContextMenu:h,style:{display:`contents`},children:(0,I.jsx)(dl,{icon:r,label:n??p(_?.title??e),shortcut:a===void 0?_?.shortcut:a,disabled:!u(e)||!!g?.disabled,checked:o,onSelect:()=>{i?l.ask(e):c&&t===void 0&&!(_&&Cy(_))?c(e):l.run(e,t)},testId:`${f}-cmd-${e}`,uiId:`command:${e}`})})}var _b=1.25,vb=new Set([`checkbox`,`radio`,`button`,`submit`,`reset`,`range`,`color`,`file`,`image`]);function yb(e){return e instanceof HTMLInputElement?!vb.has(e.type):e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement&&!e.classList.contains(`kui-text-sink`)}function bb(){let e=pb(),t=Ky(),n=e.host.readOnly===!0,r=n&&(e.comments?.size??0)>0,i=(e,i,a)=>{let o=t.state(`action:${e}`),s=t.state(`command:${i}`);return{hidden:o.hidden||s.hostHidden||n&&!r,disabled:!a||o.disabled||s.denied}};return{undo:i(`undo`,`edit.undo`,e.canUndo),redo:i(`redo`,`edit.redo`,e.canRedo),readOnly:n,commenting:r}}function xb({before:e,mode:t}){let n=pb(),r=Ky(),{session:i,host:a,t:o,testId:s}=n,{dirty:c}=i,l=e=>r.state(`action:${e}`),{undo:u,redo:d,readOnly:f,commenting:p}=bb();return(0,I.jsxs)(I.Fragment,{children:[e,(0,I.jsx)($y,{place:`action`,as:`action`}),f?(0,I.jsx)(`span`,{className:`kui-view-only`,"data-testid":`${s}-view-only`,"data-comment-only":p?`true`:void 0,children:o(p?`commentOnly`:`viewOnly`)}):null,u.hidden?null:(0,I.jsx)(Bc,{icon:yc,label:o(`undo`),disabled:u.disabled,onClick:()=>void n.run(`edit.undo`,{}),"data-testid":`${s}-undo`,"data-kit-ui-id":`action:undo`}),d.hidden?null:(0,I.jsx)(Bc,{icon:ys,label:o(`redo`),disabled:d.disabled,onClick:()=>void n.run(`edit.redo`,{}),"data-testid":`${s}-redo`,"data-kit-ui-id":`action:redo`}),a.init.capabilities.includes(`agent`)&&!l(`agent`).hidden?(0,I.jsxs)(Rc,{variant:`ghost`,disabled:l(`agent`).disabled,onClick:()=>void a.openAgent(),"data-testid":`${s}-ask-agent`,"data-kit-ui-id":`action:agent`,children:[(0,I.jsx)(Ws,{size:15,strokeWidth:Lc,"aria-hidden":`true`}),o(`askAgent`)]}):null,t,l(`save`).hidden||f?null:(0,I.jsxs)(Rc,{variant:`primary`,disabled:!c||i.saving||l(`save`).disabled,onClick:()=>void n.save(),"data-testid":`${s}-save`,"data-kit-ui-id":`action:save`,children:[(0,I.jsx)(As,{size:15,strokeWidth:Lc,"aria-hidden":`true`}),o(`save`)]}),r.openCustomize&&!l(`more`).hidden?(0,I.jsx)(ul,{align:`end`,trigger:({toggle:e,open:t})=>(0,I.jsx)(Bc,{icon:Na,label:o(`more`),pressed:t,disabled:l(`more`).disabled,onClick:e,"data-testid":`${s}-more`,"data-kit-ui-id":`action:more`}),children:(0,I.jsx)(dl,{label:o(`customize`),onSelect:()=>r.openCustomize?.(),testId:`${s}-customize`,uiId:`action:more`})}):null]})}function Sb({x:e,y:t,label:n,testId:r,onHide:i,onClose:a}){let o=(0,j.useRef)(null),[s,c]=(0,j.useState)(null);return(0,j.useLayoutEffect)(()=>{let n=o.current?.offsetWidth??160,r=o.current?.offsetHeight??40;c({left:Math.max(4,Math.min(e,window.innerWidth-n-4)),top:Math.max(4,Math.min(t,window.innerHeight-r-4))})},[e,t]),(0,j.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),a())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[a]),(0,I.jsx)(`div`,{className:`kui-dialog-backdrop kui-hide-menu-backdrop`,onPointerDown:a,children:(0,I.jsx)(`div`,{ref:o,className:`kui-popover kui-hide-menu`,role:`menu`,style:s??{left:e,top:t,visibility:`hidden`},onPointerDown:e=>e.stopPropagation(),children:(0,I.jsx)(dl,{label:n,onSelect:i,testId:r})})})}function Cb({top:e,status:n,statusEnd:r,onStatusClick:i,canvas:a,zoom:o,onKeyDown:s,statusBar:c=!0,hiddenCommands:l,fileChangedBar:u=!0,frame:d,children:f}){let p=pb(),m=mb(),{session:h,t:g,testId:_}=p,{dirty:v}=h,y=(0,j.useContext)(Wy),b=Ky(),[x,S]=(0,j.useState)(null),[C,w]=(0,j.useState)(null),T=(0,j.useCallback)(()=>w(null),[]),E=(0,j.useRef)(async()=>{});E.current=async e=>{try{await b.store.setPersonal(e)}catch(e){cb(p,g(`customizeFailed`),e)}};let D=(0,j.useRef)(()=>[]);D.current=()=>Hy({commands:p.commands,declaration:p.host.declaration,engineTools:m?.tools??[],agent:p.host.init.capabilities.includes(`agent`),t:g,phrase:p.phrase,config:{...b.store.get(),personal:[]}});let{store:O}=b,k=O.customizable&&p.host.declaration!==null,A=(0,j.useMemo)(()=>y&&k?{...y,offerHide:(e,t,n)=>w({id:e,x:t,y:n}),openCustomize:()=>S(D.current()),hide:e=>void E.current([...O.get().personal,e])}:y,[k,y,O]),M=e=>e.currentTarget.ownerDocument.querySelector(`.kui-dialog-backdrop`)!=null||e.target instanceof Element&&e.target.closest(`.kui-dialog`)!=null,N=e=>{!d||e.nativeEvent.isComposing||M(e)||d.keyDown(e)&&(e.preventDefault(),e.stopPropagation())},ee=e=>{P(e);let t=!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey;d&&t&&e.key===`Escape`&&!e.defaultPrevented&&!e.nativeEvent.isComposing&&!M(e)&&!yb(e.target)&&d.escape()&&e.preventDefault()},P=e=>{if(M(e))return;let n=e.target,r=yb(n);if(r&&(!e.metaKey&&!e.ctrlKey||e.altKey||e.key.toLowerCase()!==`s`))return;let i=n instanceof HTMLTextAreaElement;if(i&&e.defaultPrevented||!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&(e.key===` `||e.key===`Enter`)&&n instanceof Element&&n.matches(`button, [role="menuitem"], input[type="checkbox"], input[type="radio"]`))return;if(!r&&!i&&m?.keyDown(e)||!r&&s?.(e)){e.preventDefault();return}let o=b.config.add.find(n=>n.shortcut&&!n.disabled&&t(n.shortcut,e,kv()));if(o){e.preventDefault(),b.press(o.id);return}let c=e.metaKey||e.ctrlKey,u=e.key.toLowerCase();if(c&&u===`s`){e.preventDefault(),!b.state(`action:save`).denied&&!p.host.readOnly&&p.save();return}if(a?.current&&c&&(u===`0`||u===`=`||u===`+`||u===`-`)){e.preventDefault(),u===`0`?a.current.fit():a.current.zoomBy(u===`-`?1/_b:_b);return}let d=Fy(l?p.commands.filter(e=>!l(e.id)):p.commands,e);if(d&&p.enabled(d.id)){e.preventDefault(),p.run(d.id,{});return}if(d&&!c&&!(e.key.length===1&&m?.toolForKey(e.key,e.shiftKey))){e.preventDefault();let t=d.id;p.enabledNow(t).then(e=>e?p.run(t,{}):void 0);return}let f=!c&&!e.altKey&&e.key.length===1&&!i?m?.toolForKey(e.key,e.shiftKey):null;f&&!b.state(`tool:${f}`).denied&&(e.preventDefault(),m?.select(f))};return(0,I.jsx)(qy,{value:A,children:(0,I.jsxs)(`div`,{ref:d?.ref,className:`kui-app`,"data-mode":d?.mode,"data-chosen-mode":d?.chosen,"data-density":d?.touch?`touch`:void 0,"data-view-only":d?.viewOnly||void 0,onKeyDownCapture:N,onKeyDown:ee,tabIndex:-1,children:[e,u&&h.conflict&&h.doc?(0,I.jsxs)(`div`,{className:`kui-file-changed`,role:`alert`,"data-testid":`${_}-file-changed`,children:[(0,I.jsx)(`span`,{children:g(`fileChanged`)}),(0,I.jsx)(Rc,{variant:`ghost`,size:`sm`,onClick:()=>void h.keepMine().catch(e=>cb(p,g(`saveFailed`),e)),"data-testid":`${_}-keep-mine`,children:g(`keepMine`)}),(0,I.jsx)(Rc,{variant:`primary`,size:`sm`,onClick:()=>h.reopen(),"data-testid":`${_}-reload`,children:g(`reloadFile`)})]}):null,f,c?(0,I.jsxs)(pl,{onClick:i?e=>!(e.target instanceof Element&&e.target.closest(`button, input, select, [role="menuitem"]`))&&i():void 0,children:[n,v?(0,I.jsx)(`span`,{"data-testid":`${_}-unsaved`,children:g(`unsaved`)}):null,h.editedBy?.by===`agent`?(0,I.jsxs)(`span`,{className:`kui-agent-edited`,"data-testid":`${_}-agent-edited`,children:[(0,I.jsx)(Ws,{size:12,strokeWidth:Lc,"aria-hidden":`true`}),g(`agentEdited`)]}):h.editedBy?.by===`system`?(0,I.jsx)(`span`,{className:`kui-host-edited`,"data-testid":`${_}-host-edited`,title:h.editedBy.originLabel,children:g(`hostEdited`)}):null,(0,I.jsx)(ml,{}),r,a&&o!=null?(0,I.jsx)(hl,{zoom:o,onZoom:e=>a.current?.zoomTo(e),onFit:()=>a.current?.fit(),labels:{out:g(`zoomOut`),in:g(`zoomIn`),fit:g(`fit`)}}):null]}):null,p.dialog?(0,I.jsx)(Oy,{command:p.dialog.command,values:p.dialog.values,title:p.phrase(p.dialog.command.title),labels:{run:g(`run`),cancel:g(`cancel`),required:g(`required`),more:g(`moreOptions`)},onClose:()=>p.setDialog(null),onRun:e=>{let t=p.dialog.command.id;p.setDialog(null),p.run(t,e)}},p.dialog.command.id):null,x?(0,I.jsx)(nb,{catalog:x,personal:b.config.personal,labels:{title:g(`customizeTitle`),search:g(`customizeSearch`),restore:g(`customizeRestore`),cancel:g(`cancel`),save:g(`customizeSave`)},onSave:e=>{S(null),E.current(e)},onClose:()=>S(null)}):null,C?(0,I.jsx)(Sb,{x:C.x,y:C.y,label:g(`hideElement`),testId:`${_}-hide-element`,onHide:()=>{w(null),E.current([...b.store.get().personal,C.id])},onClose:T}):null,(0,I.jsx)(Dl,{})]})})}function wb({label:e,path:t,children:n,uiId:r,testId:i}){let a=r??`menu:${t}`,{phrase:o}=pb(),s=(0,j.useRef)(null),c=(0,j.useRef)(null),l=(0,j.useRef)(null),[u,d]=(0,j.useState)(null),f=(0,j.useRef)(!1),p=()=>{let e=s.current?.getBoundingClientRect();e&&d({left:e.right-2,top:e.top-4,maxHeight:Math.max(0,window.innerHeight-16)})},m=()=>{l.current?.contains(document.activeElement)&&c.current?.focus(),d(null)},h=(0,j.useCallback)(()=>{let e=s.current?.getBoundingClientRect(),t=l.current;if(!e||!t)return;let n=Math.max(0,window.innerHeight-16),r=Math.min(t.scrollHeight,n),i=t.offsetWidth,a=e.right-2,o=a+i<=window.innerWidth-4?a:e.left+2-i>=4?e.left+2-i:a,c=Math.max(4,Math.min(o,window.innerWidth-i-4)),u=Math.max(8,Math.min(e.top-4,window.innerHeight-8-r));d(e=>!e||e.left===c&&e.top===u&&e.maxHeight===n?e:{left:c,top:u,maxHeight:n})},[]),g=u!=null;return(0,j.useLayoutEffect)(()=>{if(!g)return;h();let e=l.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>h());t.observe(e);for(let n of e.children)t.observe(n);return()=>t.disconnect()},[g,h]),(0,j.useLayoutEffect)(()=>{!u||!f.current||!l.current||(f.current=!1,l.current.querySelector(`[role^="menuitem"]:not(:disabled)`)?.focus())},[u]),(0,I.jsxs)(`div`,{ref:s,className:`kui-submenu`,onPointerEnter:p,onPointerLeave:m,children:[(0,I.jsxs)(`div`,{ref:c,className:`kui-menu-item`,role:`menuitem`,"aria-haspopup":`menu`,"aria-expanded":u!=null,tabIndex:-1,"data-kit-ui-id":a,"data-testid":i,onKeyDown:e=>{e.target!==e.currentTarget||![`ArrowRight`,`Enter`,` `].includes(e.key)||(e.preventDefault(),e.stopPropagation(),f.current=!0,p())},children:[(0,I.jsx)(`span`,{style:{width:15}}),(0,I.jsx)(`span`,{children:o(e)}),(0,I.jsx)(ra,{size:13,strokeWidth:Lc,"aria-hidden":`true`,style:{marginLeft:`auto`,opacity:.6}})]}),u?(0,I.jsxs)(`div`,{ref:l,className:`kui-popover kui-submenu-popover`,role:`menu`,style:{left:u.left,top:u.top,maxHeight:u.maxHeight},onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),e.stopPropagation(),m()):cl(e,m)},children:[n,(0,I.jsx)($y,{place:a,as:`menu`})]}):null]})}function Tb({children:e}){let{t}=pb();return(0,I.jsx)(Wc,{className:`kui-options-strip`,panelClassName:`kui-options-bar`,labels:{start:t(`optionsScrollStart`),end:t(`optionsScrollEnd`)},testId:`options-scroll`,children:e})}function Eb(e,t){return e===t||e===`*`||t===`*`}function Db(e,t){return e.find(e=>!e.holder.self&&Eb(e.scope,t))??null}var Ob=[],kb=new WeakMap;function Ab(e){return Array.isArray(e)?e.filter(e=>!!e&&typeof e.scope==`string`&&typeof e.holder?.name==`string`):Ob}function jb(e){let t=e.init.capabilities.includes(`lease`),n=Ob,r=new Set,i=e=>{n=e.length?e:Ob;for(let e of[...r])e()};if(t){let t=!1;e.peer.on(`lease/changed`,e=>{t=!0,i(Ab(e?.leases))}),e.peer.request(`host/leases`,{}).then(e=>{t||i(Ab(e?.leases))},()=>{})}return{available:t,list:()=>n,subscribe:e=>(r.add(e),()=>r.delete(e)),heldByOther:e=>Db(n,e),acquire:async(n,r)=>{if(e.readOnly)return{granted:!1,reason:`read-only`,holder:null};if(!t)return{granted:!0,lease:null};try{let{lease:t}=await e.peer.request(`host/leaseAcquire`,r===void 0?{scope:n}:{scope:n,ttl:r});return{granted:!0,lease:t??null}}catch(e){let t=e instanceof o?e.data:void 0;return t?.reason===`held`?{granted:!1,reason:`held`,holder:t.lease?.holder??null}:t?.reason===`read-only`?{granted:!1,reason:`read-only`,holder:null}:{granted:!0,lease:null}}},release:async n=>{t&&await e.peer.request(`host/leaseRelease`,{scope:n}).catch(()=>{})}}}function Mb(e){let t=kb.get(e);return t||kb.set(e,t=jb(e)),t}function Nb(e,t){let n=t==null?`\`${e}\``:`step ${t} (\`${e}\`)`;return new o(-32e3,`${n} is not allowed: the document is read-only`,t==null?{reason:Pv,command:e}:{reason:Pv,command:e,step:t})}function Pb(e){return new o(-32e3,e.message,e)}function Fb(e){return e instanceof Error?e.message:String(e)}function Ib(e){let{origin:t,originLabel:n,draft:r}=e;if(t===void 0){if(n!==void 0)throw new o(-32602,'`originLabel` names a host feature: it needs `origin: "system"`');return{by:`agent`}}if(t!==`system`)throw new o(-32602,`\`origin\` is "system" or absent, not ${JSON.stringify(t)}`);if(r===!0)throw new o(-32602,`a host's change (\`origin: "system"\`) is made on the document, not on the agent's draft`);if(n!==void 0&&(typeof n!=`string`||!s.test(n)))throw new o(-32602,`\`originLabel\` is 1 to 64 letters, digits, \`.\`, \`_\` or \`-\`, not ${JSON.stringify(n)}`);return{by:`system`,originLabel:n??`host`}}function Lb(e,t,n){let r=`step ${n} (\`${t}\`) failed`;return e instanceof Wv?new o(-32e3,`${r}: ${e.message}`,{reason:i,command:t,step:n,errors:e.errors}):e instanceof Gv?new o(-32e3,`${r}: ${e.message}`,{reason:e.reason,command:t,step:n}):e instanceof o?new o(e.code,`${r}: ${e.message}`,e.data):Error(`${r}: ${Fb(e)}`)}var Rb=new Set([`edit.undo`,`edit.redo`]),zb={scope:`agent`};function Bb(e,t){return new o(-32e3,`step ${t} (\`${e}\`) cannot run in a call context: this kit's engine keeps no editor state of the agent's own, so its \`on\`, \`part\` and \`time\` cannot be set without moving the person's`,{reason:Uv,command:e,step:t})}function Vb(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);return e.filter(e=>{let t=`${e.id} ${e.title} ${e.description??``} ${e.params??``}`.toLowerCase();return n.every(e=>t.includes(e))}).map(e=>({id:e.id,title:e.title,description:e.description,enabled:e.enabled,mutates:e.mutates,schema:e.schema??null}))}function Hb(e,t,n,r){let i=r?.name||`another session`;return new o(-32e3,`step ${t} (\`${e}\`) is not allowed: ${i} holds the lease on \`${n}\``,{reason:d,command:e,step:t,scope:n,...r?{holder:r}:{}})}async function Ub(e,t,n,r,i,a){if(!t){let t=n?e.list().find(e=>!e.holder.self&&e.scope===`*`):void 0;if(t)throw a(`*`,t.holder);return i()}let o=await e.acquire(t,r);if(!o.granted){let e=o;if(e.reason===`read-only`)return i();throw a(t,e.holder)}try{return await i()}finally{o.lease&&await e.release(t)}}function Wb(e,t,n,r={}){let a=e.init.document.path,s=e.readOnly===!0,c=s&&e.init.document.comments?.canComment===!0,l=t.commentCommands,u=(0,j.useMemo)(()=>Lv(l,c),[c,l]),d=cy(e.files,t,a,!0,n,{readOnly:s,canComment:c,replicaMergesFile:r.replicaMergesFile,followFile:r.followFile}),{doc:f,failure:p}=d,m=f?.info.revision??null,h=f?.info.dirty??!1,g=(0,j.useRef)(d);g.current=d;let _=(0,j.useRef)({doc:null,map:null,commands:null,loading:null}),v=(0,j.useCallback)(e=>{let t=_.current;if(t.doc===e&&t.loading)return t.loading;let n=e.commands().then(t=>{let r=new Map(t.map(e=>[e.id,e.menu]));return _.current.loading===n&&(_.current={doc:e,map:r,commands:new Map(t.map(e=>[e.id,e])),loading:n}),r});return n.catch(()=>{_.current.loading===n&&(_.current={doc:null,map:null,commands:null,loading:null})}),_.current={doc:e,map:null,commands:null,loading:n},n},[]);(0,j.useEffect)(()=>{f&&v(f).catch(()=>{})},[f,v]);let y=(0,j.useCallback)(e=>{let t=_.current.commands?.get(e);return zv(t??{id:e},u)},[u]),b=(0,j.useCallback)(async(t,n={},r=null,i={})=>{let a=g.current.doc;if(!a)return null;let o=_.current,c=o.doc===a&&o.map?o.map:await v(a);if(bv(e.ui.get(),`command:${t}`,c.get(t)??[]).denied)throw Cv(t);if(s&&y(t))throw Nb(t);try{return await d.run(t,n,r,i)}catch(e){throw Hv(e)?Nb(t):e}},[y,e,v,s,d.run]),x=r.agentSkipsUnchangedPaint===!0,S=(0,j.useRef)(r);S.current=r;let C=(0,j.useMemo)(()=>ky(rb,e.init.locale),[e]),w=r.agentLeaseScope!=null;(0,j.useEffect)(()=>{w&&Mb(e)},[e,w]);let T=(0,j.useRef)(Promise.resolve()),E=(0,j.useRef)(null),D=(0,j.useRef)(null),[O,k]=(0,j.useState)(null),A=(0,j.useCallback)((e,t)=>{D.current={edit:e,revision:t},k(e)},[]),M=(0,j.useRef)(!1),N=(0,j.useRef)({doc:null,version:null}),ee=(0,j.useRef)(null);ee.current??=new fy({open:()=>g.current.draft.open(),merge:(e,t,n,r)=>g.current.draft.merge(e,t,n,r),compare:(e,t)=>g.current.draft.compare(e,t),preview:async e=>{let t=g.current.doc;return t?ly(t,e).catch(()=>null):null},changed:t=>e.peer.notify(`draft/changed`,t)}),(0,j.useEffect)(()=>{let e=ee.current;return e.attach(),()=>e.dispose()},[]),(0,j.useEffect)(()=>{M.current||(f?(M.current=!0,e.opened([...f.info.model?[`model`,`draft`,`draft-model`,`check`]:[`check`],...f.info.context?[`context`]:[],...f.info.changes?[`changes`]:[],...f.info.premises?[`premises`]:[]])):p&&(M.current=!0,e.failed(Error(p))))},[f,p,e]),(0,j.useEffect)(()=>{if(!f)return;let t=E.current??(D.current?.revision===f.info.revision?D.current.edit:{by:`person`});t.by===`person`&&D.current&&(D.current=null,k(null)),e.changed({dirty:f.info.dirty,revision:f.info.revision,title:e.init.document.name,...t})},[f,e,m,h]);let P=f?.info.schema?.reads??null,F=f?.info.schema?.newestAuthor??null,te=(0,j.useRef)(null);return(0,j.useEffect)(()=>{if(P===null||F===null||F<=P)return;let t=`${P}:${F}`;te.current!==t&&(te.current=t,e.peer.notify(`document/schema`,{reads:P,newestAuthor:F}))},[e,F,P]),(0,j.useEffect)(()=>{if(!e.replica||!f)return;let t=f.info.replica??null,n=t?t.join(`,`):null,r=N.current;N.current={doc:f,version:n},r.doc===f&&t&&n!==r.version&&e.peer.notify(`replica/changed`,{version:t.slice().buffer})},[f,e,m]),(0,j.useEffect)(()=>{let{peer:n}=e;n.handle(`document/state`,()=>{let t=g.current.doc;return{dirty:t?.info.dirty??!1,revision:t?.info.revision??0,title:e.init.document.name}}),n.handle(`document/save`,async()=>{if(s)throw new o(-32e3,`the document is read-only`,{reason:Pv});return await g.current.save(),{saved:!(g.current.doc?.info.dirty??!0),version:null}});let r=()=>{let e=g.current.doc;if(!e)throw Error(`the document is still opening`);return e},c=ee.current,l=e=>{if(s)throw new o(-32e3,`a draft is not allowed: the document is read-only`,{reason:Pv});return c.engine(e)};n.handle(`ai/inspect`,async e=>{let n=e?.draft===!0,i=n?await l(!1):r(),{width:o,height:s,dirty:u,canUndo:d,canRedo:f,inspected:p}=i.info,m=`${o} × ${s}${n?`, draft`:u?`, unsaved`:``}`,h=e.context?await i.inspectAt(e.context,e.part):{details:p};return i.agentReply({path:a,kit:t.kitId,revision:i.info.revision,summary:m,dirty:!n&&u,canUndo:d,canRedo:f,...h,...n?{draft:c.info()}:{}})}),n.handle(`document/check`,async e=>{let t=e?.draft===!0?await l(!1):r();return t.agentReply({diagnostics:await t.check()})}),n.handle(`ai/commands`,async({query:t})=>{let n=Tv(e.ui.get(),await r().commands());return Vb(s?n.map(e=>zv(e,u)?{...e,enabled:!1}:e):n,t)}),n.handle(`ai/run`,async t=>{let{steps:n,save:i,draft:a}=t,o=Ib(t),c=r(),u=await v(c),f=wv(e.ui.get(),n,e=>u.get(e)??[]);if(f>=0)throw Cv(n[f].command,f);let m=s?n.findIndex(e=>y(e.command)):-1;if(m>=0)throw Nb(n[m].command,m);if(a===!0)return h(await l(!0),n);let g=c.info.context===!0?-1:n.findIndex(e=>e.context!=null);if(g>=0)throw Bb(n[g].command,g);return p(()=>d(c,n,i,o))});let d=async(t,n,r,i)=>{let a=[],c=i.by===`system`?{kind:`system`,principal:`kdm`,label:i.originLabel}:{kind:`agent`,principal:e.init.document.comments?.me??`agent`,label:`ai/run`},l={last:null,meanwhile:!1},u=t.info.context===!0?{state:null}:null,d=e=>({...x?{skipUnchangedPaint:!0}:{},origin:c,...u?{agent:{state:u,set:e}}:{}});E.current=i;try{for(let[e,r]of n.entries()){let s=t.info.revision,c;try{c=await m(t,r.command,r.params??{},e,()=>(s=t.info.revision,l.last!==null&&s!==l.last&&(l.meanwhile=!0),b(r.command,r.params??{},null,d(r.context??null))),i)}catch(n){if(n instanceof o&&n.data?.reason===`held`)throw n;let s=n instanceof o&&n.data?.reason===`not-allowed`?Cv(r.command,e):n instanceof o&&n.data?.reason===`read-only`?Nb(r.command,e):Lb(n,r.command,e);throw i.by===`system`?s:await f(t,a,s,r.command,e,l,d(null),i)}let u=c;try{u=c==null?null:JSON.parse(c)}catch{}if(l.last=t.info.revision,a.push({command:r.command,changed:t.info.revision!==s,result:u}),typeof u==`object`&&u&&`closed`in u&&u.closed===!0)return{completed:a,closed:!0,saved:!1,notRun:n.length-a.length}}}finally{E.current=null}a.some(e=>e.changed)&&A(i,t.info.revision);let p=!s&&!bv(e.ui.get(),`action:save`).denied;return r&&p&&t.info.dirty&&await g.current.save(),t.agentReply({completed:a,saved:r&&p&&!t.info.dirty})},f=async(e,t,n,r,i,a,s,c)=>{let l=n instanceof o&&n.data&&typeof n.data==`object`?n.data:{},u=n instanceof o?n.code:-32e3,d=(e,t,s)=>{let c={...l,command:r,step:i,completed:t,...s?{rolledBack:s}:{}};return a.meanwhile&&(c.editedMeanwhile=!0),new o(u,`${n.message}${e}`,c)},f=t.filter(e=>e.changed).length,p=e=>d(` The ${t.length} step(s) before it could not be rolled back (${e}): they stay in the document; undo them (\`edit.undo\`) or keep them.`,t,null);if(a.last!==null&&e.info.revision!==a.last&&(a.meanwhile=!0),f===0)return d(t.length?` The ${t.length} step(s) before it were rolled back: the document is as it was before the run.`:``,[],t);if(t.some(e=>Rb.has(e.command)))return p(`the steps undid or redid edits themselves`);if(a.meanwhile&&e.info.origins!==!0)return p(`someone else edited the document while the run was under way, and this kit's engine cannot take back the agent's steps alone: it does not run commands as an origin`);let h=0,g=``;for(;h<f;){let t=e.info.revision;a.last!==null&&t!==a.last&&(a.meanwhile=!0);try{await m(e,`edit.undo`,zb,i,()=>b(`edit.undo`,zb,null,s),c)}catch(e){g=Fb(e);break}if(e.info.revision===t){g=`the kit had nothing more to undo`;break}h+=1,a.last=e.info.revision}if(h===0)return p(g);if(h<f){let e=f-h,n=0;for(;e>0;)t[n++].changed&&--e;return d(` Only ${h} of the ${f} step(s) that changed the document could be rolled back (${g}): the first ${n} step(s) stay in the document.`,t.slice(0,n),t.slice(n))}return a.meanwhile?d(` The ${t.length} step(s) before it were rolled back in the agent's undo scope, but someone else edited the document while the run was under way: their edits stay, and where they changed what those steps made or changed, their change was kept (an object a step created went, with what they did to it). Inspect the document before going on.`,[],t):d(` The ${t.length} step(s) before it were rolled back: the document is as it was before the run.`,[],t)},p=e=>{let t=T.current.then(e,e);return T.current=t.then(()=>{},()=>{}),t},m=async(t,n,r,i,a,o)=>{let s=S.current.agentLeaseScope,c=s?Mb(e):null;if(!s||!c?.available)return a();let l=``;try{l=await s(n,r,t)||``}catch{l=``}let u=_.current.commands?.get(n)?.mutates??!0;return Ub(c,l,u,S.current.agentLeaseTtl,a,(t,r)=>(o.by===`agent`&&e.notify({level:`warning`,title:C(`agentLeaseHeld`,{name:r?.name||C(`someone`)})}),Hb(n,i,t,r)))};n.handle(`ai/preview`,async({maxSize:e,draft:t})=>({png:await ly(t===!0?await l(!1):r(),e)}));let h=async(e,t)=>{let n=[],r=!1;try{for(let[a,s]of t.entries()){let c=e.info.revision,l;try{l=await e.execute(s.command,s.params??{})}catch(e){throw e instanceof Wv?new o(-32e3,`step ${a} (\`${s.command}\`) failed on the draft: ${e.message}`,{reason:i,command:s.command,step:a,errors:e.errors}):Error(`step ${a} (\`${s.command}\`) failed on the draft: ${Fb(e)}`)}let u=l;try{u=l==null||l===``?null:JSON.parse(l)}catch{}if(n.push({command:s.command,changed:e.info.revision!==c,result:u}),typeof u==`object`&&u&&`closed`in u&&u.closed===!0)return r=!0,{completed:n,closed:!0,saved:!1,notRun:t.length-n.length}}}finally{!r&&n.some(e=>e.changed)&&c.edited()}return{completed:n,saved:!1}};n.handle(`draft/state`,()=>c.info()),n.handle(`draft/ready`,()=>c.ready()),n.handle(`draft/reopen`,()=>c.reopen()),n.handle(`draft/compare`,e=>c.compare(Math.max(1,Number(e?.maxSize)||1024),e?.schema??null)),n.handle(`draft/merge`,async({origin:e,schema:t=null})=>{if(s)throw new o(-32e3,`the document is read-only`,{reason:Pv});let n={kind:`agent`,principal:String(e?.principal??``),...e?.label?{label:String(e.label)}:{}};E.current={by:`agent`};try{let e=await c.merge(n,t),r=g.current.doc;return r&&A({by:`agent`},r.info.revision),e.merged&&S.current.draftMerged?.({summary:e.summary}),e}catch(e){throw e instanceof jv?Pb(e.data):e}finally{E.current=null}}),n.handle(`draft/discard`,()=>c.discard());let w=async e=>{if(!r().info.model)throw new o(-32601,`the kit's engine does not answer the object model`);try{return await e()}catch(e){throw e instanceof jv?Pb(e.data):e}};n.handle(`model/describe`,e=>w(()=>g.current.model.describe(e?.schema??null)));let D=e=>{if(r().info.changes!==!0)throw new o(-32601,`the kit's engine keeps no replica, so it cannot say what changed`);return e()};n.handle(`ai/version`,()=>D(async()=>({version:await g.current.model.version()}))),n.handle(`ai/changes`,e=>D(()=>g.current.model.changes(String(e?.since??``),e?.schema??null))),n.handle(`ai/premise`,({method:e,params:t})=>r().premiseRead(e,t)),n.handle(`model/batch`,t=>w(async()=>{let{schema:n=null,draft:i,...a}=t??{},o=Array.isArray(a.ops)?a.ops:[];if(s&&o.length)throw new jv({code:Pv,index:null,message:`the document is read-only`});let u=await v(r());if(o.forEach((t,n)=>{if(t?.op===`command`&&typeof t.id==`string`&&bv(e.ui.get(),`command:${t.id}`,u.get(t.id)??[]).denied)throw new jv({code:`command-failed`,index:n,message:Cv(t.id).message})}),i!==!0)return g.current.model.batch(a,n);let d=await(await l(o.length>0)).modelBatch(a,n);return o.length&&c.edited(),d}));let O=n.on(`document/fileChanged`,()=>void g.current.checkFile()),k=n.on(`document/held`,e=>{typeof e?.version==`string`&&g.current.holdFile(e.version)});return e.replica&&(n.handle(`replica/version`,async()=>({version:await g.current.replica.version()})),n.handle(`replica/export`,({since:e})=>g.current.replica.exportChanges(e)),n.handle(`replica/import`,async({changes:e,blobs:t})=>({damage:await g.current.replica.importChanges(e,t)})),n.handle(`replica/info`,async()=>({docId:await g.current.replica.docId()}))),()=>{O(),k()}},[u,A,y,e,t.kitId,v,a,s,b,x,C]),{...d,run:b,editedBy:O,comments:u}}var Gb=4e3;function Kb({tool:e,onExit:t}){let n=pb(),r=mb(),i=Ky(),{undo:a}=bb(),{host:o,t:s,testId:c,phrase:l}=n,u=r?.tools.find(e=>e.id===r.active),d=e??(u?{label:l(u.label),icon:hy(u.icon,u.id)}:null),f=i.state(`action:agent`),p=d?.icon,[m,h]=(0,j.useState)(!0);return(0,j.useEffect)(()=>{let e=setTimeout(()=>h(!1),Gb);return()=>clearTimeout(e)},[]),(0,I.jsxs)(`div`,{className:`kui-focus-bar`,role:`toolbar`,"aria-label":s(`focusBar`),"data-fresh":m||void 0,"data-testid":`${c}-focus-bar`,children:[(0,I.jsxs)(Rc,{variant:`ghost`,className:`kui-focus-exit`,title:`${s(`exitFocus`)} (Esc)`,onClick:t,"data-testid":`${c}-focus-exit`,"data-kit-ui-id":`action:mode`,children:[(0,I.jsx)(zo,{size:16,strokeWidth:Lc,"aria-hidden":`true`}),s(`exitFocus`),(0,I.jsx)(`kbd`,{children:`Esc`})]}),a.hidden?null:(0,I.jsx)(Bc,{icon:yc,label:s(`undo`),disabled:a.disabled,onClick:()=>void n.run(`edit.undo`,{}),"data-testid":`${c}-focus-undo`,"data-kit-ui-id":`action:undo`}),o.init.capabilities.includes(`agent`)&&!f.hidden?(0,I.jsx)(Bc,{icon:Ws,label:s(`askAgent`),disabled:f.disabled,onClick:()=>void o.openAgent(),"data-testid":`${c}-focus-ask`,"data-kit-ui-id":`action:agent`}):null,d&&p?(0,I.jsxs)(`span`,{className:`kui-focus-tool`,"data-testid":`${c}-focus-tool`,children:[(0,I.jsx)(p,{size:16,strokeWidth:Lc,"aria-hidden":`true`}),d.label]}):null]})}var qb=`---`;function Jb(e){let t=[];for(let n of e)n.kind===`separator`&&(t.length===0||t.at(-1)?.kind===`separator`)||t.push(n);return t.at(-1)?.kind===`separator`&&t.pop(),t}function Yb(e,t,n,r){let i=[],a=new Set;for(let o of e){if(o.path.length===t){o.command===qb?i.push({kind:`separator`}):n(o)&&i.push({kind:`row`,row:o});continue}let s=o.path[t];if(a.has(s))continue;a.add(s);let c=o.path.slice(0,t+1).join(`/`),l=Yb(e.filter(e=>e.path.length>t&&e.path[t]===s),t+1,n,r);(l.length||r(c))&&i.push({kind:`submenu`,label:s,path:c,children:l})}return Jb(i)}function Xb(e,t,n=()=>!1){let r=[];for(let t of e){let e=t.path[0];e&&!r.includes(e)&&r.push(e)}return r.map(r=>({label:r,children:Yb(e.filter(e=>e.path[0]===r),1,t,n)})).filter(e=>e.children.length>0||n(e.label))}function Zb({row:e,checked:t,onKitCommand:n}){let{phrase:r,testId:i}=pb(),a=Ky(),o=Ly(e.command);a.declared;let s=a.state(o,e.path);return(0,I.jsx)(dl,{label:r(e.label),shortcut:e.shortcut,disabled:s.disabled,checked:t,onSelect:()=>!s.denied&&n?.(e.command),testId:`${i}-${o.replace(`:`,`-`)}`,uiId:o})}function Qb({nodes:e,checked:t,onKitCommand:n,onCommand:r}){let{phrase:i}=pb();return(0,I.jsx)(I.Fragment,{children:e.map((e,a)=>{if(e.kind===`separator`)return(0,I.jsx)(fl,{},`---${a}`);if(e.kind===`submenu`)return(0,I.jsx)(wb,{label:e.label,path:e.path,children:(0,I.jsx)(Qb,{nodes:e.children,checked:t,onKitCommand:n,onCommand:r})},`menu:${e.path}`);let{row:o}=e,s=`${o.command}@${a}`;return o.command.startsWith(Iy)?(0,I.jsx)(Zb,{row:o,checked:t?.(o.command),onKitCommand:n},s):(0,I.jsx)(gb,{command:o.command,path:o.path,label:i(o.label),shortcut:o.shortcut??void 0,checked:t?.(o.command),onRun:r},s)})})}function $b({tree:e,nodes:t}){return(0,I.jsxs)(I.Fragment,{children:[e.before?.map(e=>(0,I.jsx)(dl,{icon:e.icon,label:e.label,onSelect:e.onSelect,testId:e.testId},e.label)),e.before?.length&&t.length?(0,I.jsx)(fl,{}):null,(0,I.jsx)(Qb,{nodes:t,checked:e.checked,onKitCommand:e.onKitCommand,onCommand:e.onCommand})]})}function ex(e){let{byId:t}=pb(),{config:n,sessionHidden:r}=Ky(),i=(0,j.useRef)(new WeakMap);return(0,j.useMemo)(()=>{let a=new Map,o=e=>xv(n,`menu:${e}`).length>0&&!bv(n,`menu:${e}`).hidden;for(let s of e){if(!s.menu)continue;let{rows:e,hidden:c}=s.menu,l=i.current.get(e);if(l&&l.hidden===c&&l.config===n&&l.byId===t&&l.sessionHidden===r){a.set(s.id,l.nodes);continue}let u=Xb(e,e=>{if(c?.(e)||!e.command.startsWith(Iy)&&r(e.command))return!1;let i=Ly(e.command);return!bv(n,i,e.path).hidden&&!bv(n,i,t.get(e.command)?.menu??[]).hidden},o).find(e=>e.label===s.id)?.children??[];i.current.set(e,{hidden:c,config:n,byId:t,sessionHidden:r,nodes:u}),a.set(s.id,u)}return a},[t,n,r,e])}var tx=e=>e.flatMap(e=>e.kind===`row`?[e.row]:e.kind===`submenu`?tx(e.children):[]),nx=5;function rx({row:e,tree:t,primary:n}){let r=pb(),i=Ky(),{byId:a,phrase:o,testId:s}=r,c=o(e.label);if(e.command.startsWith(Iy)){let r=Ly(e.command),a=i.state(r,e.path),o=Sy({id:e.command.slice(4),title:e.label});return(0,I.jsx)(il,{icon:o,lineLabel:o===yy,primary:n,label:c,pressed:t.checked?.(e.command),disabled:a.disabled,onClick:()=>!a.denied&&t.onKitCommand?.(e.command),"data-testid":`${s}-${r.replace(`:`,`-`)}`,"data-kit-ui-id":r})}let l=a.get(e.command),u=i.state(`command:${e.command}`,e.path),d=Sy(l??{id:e.command,title:e.label});return(0,I.jsx)(il,{icon:d,lineLabel:d===yy,primary:n,label:c,pressed:t.checked?.(e.command),disabled:!r.enabled(e.command)||u.disabled,onClick:()=>{t.onCommand&&!(l&&Cy(l))?t.onCommand(e.command):r.run(e.command)},"data-testid":`${s}-cmd-${e.command}`,"data-kit-ui-id":`command:${e.command}`})}function ix({tab:e,nodes:t}){let{byId:n,phrase:r}=pb(),i=bb(),a=new Set([...i.undo.hidden?[]:[`edit.undo`],...i.redo.hidden?[]:[`edit.redo`]]),o=e=>e.filter(e=>!a.has(e.command)),s=e=>{let t=e.find(e=>e.command!==`---`);return t?Sy(n.get(t.command)??{id:t.command.replace(Iy,``),title:t.label}):void 0},c=e.menu;if(!c)return null;let l=o(t.flatMap(e=>e.kind===`row`?[e.row]:[])),u=t.flatMap(e=>e.kind===`submenu`&&o(tx(e.children)).length?[e]:[]),d=c.primary?null:new Set([...l,...u.flatMap(e=>o(tx(e.children)))].filter(e=>e.command!==`---`).slice(0,nx).map(e=>e.command)),f=e=>d?d.has(e.command):c.primary?.includes(e.command);return(0,I.jsxs)(I.Fragment,{children:[l.length||c.before?.length?(0,I.jsx)(el,{id:`menu:${e.id}`,label:e.label,icon:s(l),children:(0,I.jsxs)(`div`,{className:`kui-command-grid`,children:[c.before?.map(e=>{let t=e.icon??Sy({id:e.testId??e.label,title:e.label});return(0,I.jsx)(il,{icon:t,lineLabel:!e.icon&&t===yy,primary:e.primary,label:e.label,onClick:e.onSelect,"data-testid":e.testId},e.label)}),l.map((e,t)=>(0,I.jsx)(rx,{row:e,tree:c,primary:f(e)},`${e.command}@${t}`))]})}):null,u.map(e=>(0,I.jsx)(el,{id:`menu:${e.path}`,label:r(e.label),icon:s(o(tx(e.children))),children:(0,I.jsx)(`div`,{className:`kui-command-grid`,children:o(tx(e.children)).map((e,t)=>(0,I.jsx)(rx,{row:e,tree:c,primary:f(e)},`${e.command}@${t}`))})},e.path))]})}var ax={menus:Io,line:vs,classic:ns,focus:Ya},ox=()=>kv()?`Cmd+\\`:`Ctrl+\\`;function sx({display:e,shown:t,areas:n=!0}){let{t:r,testId:i}=pb(),a=Ky().state(`action:mode`);if(a.hidden||e.allowed.length<2)return null;if(!n){let t=`${r(`mode_focus`)} (${ox()})`;return(0,I.jsx)(Bc,{icon:Ya,label:t,className:`kui-mode-button`,disabled:a.disabled,onClick:()=>e.choose(`focus`),"data-testid":`${i}-mode-focus`,"data-kit-ui-id":`action:mode`})}let o=ax[e.chosen],s=t!==e.chosen,c=s?r(`modeStepped`,{mode:r(`mode_${e.chosen}`),shown:r(`mode_${t}`)}):r(`modeButton`,{mode:r(`mode_${e.chosen}`)});return(0,I.jsx)(ul,{align:`end`,trigger:({toggle:e,open:t})=>(0,I.jsx)(`button`,{type:`button`,className:`kui-icon-button kui-mode-button`,"aria-label":c,title:c,"aria-haspopup":`menu`,"aria-expanded":t,"data-stepped":s||void 0,disabled:a.disabled,onClick:e,"data-testid":`${i}-mode`,"data-kit-ui-id":`action:mode`,children:(0,I.jsx)(o,{size:16,strokeWidth:Lc,"aria-hidden":`true`})}),children:e.allowed.map(t=>(0,I.jsx)(dl,{icon:ax[t],label:r(`mode_${t}`),shortcut:t===`focus`?ox():null,checked:t===e.chosen,onSelect:()=>e.choose(t),testId:`${i}-mode-${t}`,uiId:`action:mode`},t))})}function cx(e){return e.menu?`menu:${e.id}`:`tab:${e.id}`}function lx(e,t=!0){let{modes:n}=(0,j.useSyncExternalStore)(e.ui.subscribe,e.ui.get),r=e.kit.id,[i,a]=(0,j.useState)(()=>Z_(r)),[o,s]=(0,j.useState)(()=>n.default===`focus`),c=ev(n),l=t?c:c.filter(e=>e===`menus`||e===`focus`),u=t?tv({stored:i,rules:n,kit:e.display,readOnly:e.readOnly===!0}):`menus`,d=(0,j.useCallback)(e=>{e===`focus`?s(!0):(Q_(r,e),a(e),s(!1))},[r]),f=(0,j.useCallback)(()=>s(e=>!e),[]),p=(0,j.useCallback)(()=>s(!1),[]);return{chosen:u,focus:o&&l.includes(`focus`),allowed:l,choose:d,toggleFocus:f,exitFocus:p}}function ux(e,t,n,r){let[i,a]=(0,j.useState)(1/0),[o,s]=(0,j.useState)(()=>new Map);return(0,j.useLayoutEffect)(()=>{let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;t!=null&&a(t)});return n.observe(t),()=>n.disconnect()},[e]),{effective:nv(t,i,{classic:o.get(`classic:${n}`),line:o.get(`line:${n}`)},r),measure:(0,j.useCallback)((t,r)=>{let i=e.current;if(!r||!i||typeof ResizeObserver>`u`)return;let a=i.getBoundingClientRect().width,o=r.scrollWidth-r.clientWidth,c=`${t}:${n}`;s(e=>{let t=e.get(c);if(o>1){let n=Math.ceil(a+o);return t!==void 0&&Math.abs(t-n)<=1?e:new Map(e).set(c,n)}return t===void 0||t<=a?e:new Map(e).set(c,Math.floor(a))})},[e,n])}}var dx=`(pointer: coarse)`;function fx(){let[e,t]=(0,j.useState)(()=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(dx).matches);return(0,j.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(dx),n=()=>t(e.matches);return e.addEventListener?.(`change`,n),()=>e.removeEventListener?.(`change`,n)},[]),e}var px=(0,j.createContext)(null),mx=(0,j.createContext)(null);function hx(){return(0,j.useContext)(px)}function gx({children:e}){return hx()===`focus`?null:(0,I.jsx)(I.Fragment,{children:e})}var _x=32,vx=2;function yx(e,t,n,r){let i=e=>(t.get(e)??0)+vx;if(e.reduce((e,t)=>e+i(t),0)<=n)return null;let a=n-_x-vx,o=new Set;r!==null&&e.includes(r)&&(o.add(r),a-=i(r));for(let t of e)if(!o.has(t)){if(i(t)>a)break;o.add(t),a-=i(t)}return o}function bx({tabs:e,active:t,onTab:n}){let{t:r}=pb(),i=(0,j.useRef)(null),a=(0,j.useRef)(new Map),[o,s]=(0,j.useState)(null),c=(0,j.useRef)(()=>{});c.current=()=>{let n=i.current;if(!n)return;let r=e=>`${e.id}
54
- ${e.label}`;for(let t of n.querySelectorAll(`.kui-ribbon-tab`)){let n=e.find(e=>e.id===t.dataset.tab);n&&!t.hidden&&a.current.set(r(n),t.offsetWidth)}let o=e.every(e=>a.current.has(r(e)))?yx(e.map(e=>e.id),new Map(e.map(e=>[e.id,a.current.get(r(e))??0])),n.clientWidth,t):null;s(e=>xx(e,o)?e:o)},(0,j.useLayoutEffect)(()=>c.current(),[e,t,o]),(0,j.useLayoutEffect)(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>c.current());return t.observe(e),()=>t.disconnect()},[]);let l=o===null?[]:e.filter(e=>!o.has(e.id));return(0,I.jsxs)(`div`,{ref:i,className:`kui-frame-tabs`,children:[(0,I.jsx)(`div`,{className:`kui-ribbon-tabs`,role:`tablist`,children:e.map(e=>(0,I.jsx)(`button`,{type:`button`,role:`tab`,className:`kui-ribbon-tab`,"aria-selected":e.id===t,hidden:o!==null&&!o.has(e.id),onClick:()=>n(e.id),"data-tab":e.id,"data-testid":`ribbon-tab-${e.id}`,"data-kit-ui-id":cx(e),children:e.label},e.id))}),l.length>0?(0,I.jsx)(ul,{align:`end`,trigger:({toggle:e,open:t})=>(0,I.jsx)(`button`,{type:`button`,className:`kui-frame-tabs-more`,"aria-label":r(`moreTabs`),title:r(`moreTabs`),"aria-haspopup":`menu`,"aria-expanded":t,onClick:e,"data-testid":`ribbon-tabs-more`,children:(0,I.jsx)(ta,{size:14,strokeWidth:Lc,"aria-hidden":`true`})}),children:l.map(e=>(0,I.jsx)(dl,{label:e.label,onSelect:()=>n(e.id),testId:`ribbon-tabs-more-${e.id}`,uiId:cx(e)},e.id))}):null]})}function xx(e,t){return e===null||t===null?e===t:e.size===t.size&&[...e].every(e=>t.has(e))}function Sx({tab:e}){let[t,n]=(0,j.useState)(!1),r=(0,j.useRef)(null),i=Ky(),{t:a}=pb(),o=i.state(cx(e));return(0,I.jsxs)(`span`,{ref:r,style:{display:`inline-flex`},children:[(0,I.jsx)(`button`,{type:`button`,className:`kui-menu-bar-item`,"aria-expanded":t,"aria-haspopup":`dialog`,onClick:()=>n(e=>!e),"data-testid":`ribbon-tab-${e.id}`,"data-kit-ui-id":cx(e),children:e.label}),(0,I.jsx)(pe,{open:t,anchor:r,onClose:()=>n(!1),label:e.label,className:`kui-drop-ribbon`,testId:`ribbon-drop-${e.id}`,children:(0,I.jsx)(Wc,{className:`kui-drop-ribbon-strip`,panelClassName:`kui-ribbon-panel`,resetKey:e.id,labels:{start:a(`ribbonScrollStart`),end:a(`ribbonScrollEnd`)},testId:`ribbon-drop-${e.id}-scroll`,children:(0,I.jsx)(`fieldset`,{className:`kui-element`,disabled:o.disabled,children:(0,I.jsx)(Gc.Provider,{value:`full`,children:e.ribbon})})})})]})}function Cx({tabs:e,menus:t}){let{t:n,testId:r}=pb();return(0,I.jsx)(`nav`,{className:`kui-menu-nav`,"aria-label":n(`menuBar`),"data-testid":`${r}-menu-bar`,children:(0,I.jsx)(Wc,{className:`kui-menu-strip`,panelClassName:`kui-menu-bar`,labels:{start:n(`menusScrollStart`),end:n(`menusScrollEnd`)},testId:`${r}-menu-bar-scroll`,children:e.map(e=>e.menu?(0,I.jsxs)(ul,{trigger:({toggle:t,open:n})=>(0,I.jsx)(`button`,{type:`button`,className:`kui-menu-bar-item`,"aria-expanded":n,onClick:t,"data-testid":`${r}-menu-${e.id}`,"data-kit-ui-id":`menu:${e.id}`,children:e.label}),children:[(0,I.jsx)($b,{tree:e.menu,nodes:t.get(e.id)??[]}),(0,I.jsx)($y,{place:`menu:${e.id}`,as:`menu`})]},e.id):(0,I.jsx)(Sx,{tab:e},e.id))})})}function wx(e,t){if(e<=0)return qc;let n=t.length,r=Math.min(n,e-1),i=Math.min(n,Math.max(0,e-1-n)),a=e=>new Set(t.slice(n-e));return{size:r===n&&n>0?`icon`:`small`,icons:a(r),collapsed:a(i)}}function Tx(e){return 1+2*e}function Ex(e){return[...e.querySelectorAll(`[data-ribbon-group]`)].filter(e=>!e.closest(`.kui-drop-panel`))}function Dx(e){return Ex(e).map(e=>e.dataset.ribbonGroup??``)}function Ox(e){return Ex(e).reduce((e,t)=>e+t.offsetWidth,0)}function kx({mode:e,tab:t,nodes:n,panel:r,measure:i}){let{t:a}=pb(),o=Ky(),s=t.ribbon??(t.menu?(0,I.jsx)(ix,{tab:t,nodes:n}):null),c=(0,j.useCallback)(e=>a(`lineMore`,{group:e}),[a]),l=e===`line`,u=`${e}:${t.id}`,[d,f]=(0,j.useState)({key:u,level:0,groups:[],fresh:0}),p=d.key===u?d.level:0,m=d.key===u?d.groups:[],h=(0,j.useMemo)(()=>l?qc:wx(p,m),[m,p,l]),g=(0,j.useRef)({width:0,content:0}),_=(0,j.useRef)(null);return(0,j.useLayoutEffect)(()=>{let t=r.current;if(!l&&t){let e=Dx(t);if(t.scrollWidth-t.clientWidth>1&&p<Tx(e.length)){f(t=>({key:u,level:p+1,groups:e,fresh:t.fresh}));return}g.current={width:t.clientWidth,content:Ox(t)};let n=_.current;if(n){n.disconnect(),n.observe(t);for(let e of Ex(t))n.observe(e)}}i(e,t)}),(0,j.useLayoutEffect)(()=>{let e=r.current;if(l||!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{let t=g.current;(e.clientWidth>t.width+1||Math.abs(Ox(e)-t.content)>1)&&f(e=>({key:u,level:0,groups:e.groups,fresh:e.fresh+1}))});return _.current=t,t.observe(e),()=>{t.disconnect(),_.current=null}},[u,l,r]),s?(0,I.jsx)(Wc,{className:l?`kui-line`:`kui-ribbon-body`,panelClassName:l?`kui-line-panel`:`kui-ribbon-panel`,role:`tabpanel`,resetKey:t.id,labels:{start:a(`ribbonScrollStart`),end:a(`ribbonScrollEnd`)},testId:`ribbon-scroll`,panelRef:r,children:(0,I.jsx)(`fieldset`,{className:`kui-element`,disabled:o.state(cx(t)).disabled,children:(0,I.jsx)(Kc.Provider,{value:c,children:(0,I.jsx)(Gc.Provider,{value:l?`line`:`full`,children:(0,I.jsx)(Jc.Provider,{value:h,children:s})})})})}):null}function Ax({tabs:e,tab:t,onTab:n,defaultTab:r,title:i,actions:a,options:o,rail:s,sidebar:c,panels:l,focusTool:u,statusBar:d=!0,children:f,...p}){let{host:m,phrase:h,testId:g}=pb(),_=Ky(),v=(0,j.useRef)(null),y=(0,j.useRef)(null),b=m.readOnly===!0,x=fx(),S=_.config.add,C=(0,j.useMemo)(()=>{if(!e.some(e=>e.menu))return e;let t=S.map(e=>e.place).filter(e=>e.startsWith(`menu:`)&&!e.includes(`/`)).map(e=>e.slice(5)).filter((t,n,r)=>r.indexOf(t)===n&&!e.some(e=>e.id===t));return t.length?[...e,...t.map(e=>({id:e,label:h(e),menu:{rows:[]}}))]:e},[S,h,e]),w=ex(C),T=C.filter(e=>_.state(cx(e)).hidden||b&&!e.view?!1:!e.menu||e.ribbon?!0:(w.get(e.id)?.length??0)>0||(e.menu.before?.length??0)>0||_.buttons(`menu:${e.id}`).length>0),E=lx(m,T.length>0),[D,O]=(0,j.useState)(r??null),k=t??D,A=T.find(e=>e.id===k)??T.find(e=>e.id===r)??T.find(e=>e.id.toLowerCase()!==`file`)??T[0]??null,M=A?.id??null,N=(0,j.useCallback)(e=>{O(e),n?.(e)},[n]);(0,j.useLayoutEffect)(()=>{t!==void 0&&M!==null&&M!==t&&n?.(M)},[M,n,t]);let ee=ux(v,E.chosen,M??``,E.allowed),P=E.focus?`focus`:ee.effective,F=e=>(kv()?e.metaKey:e.ctrlKey)&&!e.shiftKey&&!e.altKey&&e.code===`Backslash`?!E.allowed.includes(`focus`)||_.state(`action:mode`).denied?!1:(E.toggleFocus(),!0):!1,te=()=>E.focus?(E.exitFocus(),!0):!1,ne=P===`focus`,re=(0,j.useRef)(ne);(0,j.useLayoutEffect)(()=>{if(re.current===ne)return;re.current=ne;let e=document.activeElement;e&&e!==document.body&&e.isConnected||((ne?null:v.current?.querySelector(`.kui-mode-button`))??v.current)?.focus({preventScroll:!0})},[ne]);let ie=ne?(0,I.jsx)(Kb,{tool:u,onExit:E.exitFocus}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`kui-frame-top`,"data-testid":`${g}-top-bar`,children:[i?(0,I.jsx)(`div`,{className:`kui-frame-title`,children:i}):null,P===`menus`?(0,I.jsx)(Cx,{tabs:T,menus:w}):(0,I.jsx)(bx,{tabs:T,active:M,onTab:N}),(0,I.jsx)(`div`,{className:`kui-ribbon-end`,children:(0,I.jsx)(xb,{before:a,mode:(0,I.jsx)(sx,{display:E,shown:P,areas:T.length>0})})})]}),(P===`line`||P===`classic`)&&A?(0,I.jsx)(kx,{mode:P,tab:A,nodes:w.get(A.id)??[],panel:y,measure:ee.measure}):null,o?(0,I.jsx)(Tb,{children:o}):null]});return(0,I.jsx)(px.Provider,{value:P,children:(0,I.jsx)(mx.Provider,{value:E,children:(0,I.jsx)(Cb,{...p,statusBar:d&&!ne,top:ie,frame:{ref:v,mode:P,chosen:E.chosen,touch:x,viewOnly:b,keyDown:F,escape:te},children:(0,I.jsxs)(`div`,{className:`kui-frame-body`,children:[s&&!b&&!ne?s:null,c&&!ne?c:null,(0,I.jsx)(`div`,{className:`kui-frame-main`,children:f}),l&&!ne?l:null]})})})})}Object.freeze({accent:`#5645d4`,surface:`#ffffff`,ink:`#1f1d2b`,font:`11px ui-sans-serif, system-ui, sans-serif`,marquee:{fill:null,fillOpacity:.08,stroke:null,width:1,dash:[4,3],inside:!1},path:{minWidth:1,dash:[4,3]},line:{width:1,dash:[4,3]},anchor:{shape:`square`,radius:0,size:6,fill:null,ringWidth:1},handle:{radius:3,fill:null,ringWidth:0},label:{font:null,dx:4,dy:-4},measure:{fill:null,color:null,font:null,padX:6,height:18,padY:2,radius:4,dx:12,dy:12,align:`start`},swatch:{size:12,radius:3,ringWidth:2,ring:null,selectedRing:null}});var jx=e=>typeof e==`string`,Mx=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},Nx=e=>e==null?``:String(e),Px=(e,t,n)=>{e.forEach(e=>{t[e]&&(n[e]=t[e])})},Fx=/###/g,Ix=e=>e&&e.includes(`###`)?e.replace(Fx,`.`):e,Lx=e=>!e||jx(e),Rx=(e,t,n)=>{let r=jx(t)?t.split(`.`):t,i=0;for(;i<r.length-1;){if(Lx(e))return{};let t=Ix(r[i]);!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++i}return Lx(e)?{}:{obj:e,k:Ix(r[i])}},zx=(e,t,n)=>{let{obj:r,k:i}=Rx(e,t,Object);if(r!==void 0||t.length===1){r[i]=n;return}let a=t[t.length-1],o=t.slice(0,t.length-1),s=Rx(e,o,Object);for(;s.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),s=Rx(e,o,Object),s?.obj&&s.obj[`${s.k}.${a}`]!==void 0&&(s.obj=void 0);s.obj[`${s.k}.${a}`]=n},Bx=(e,t,n,r)=>{let{obj:i,k:a}=Rx(e,t,Object);i[a]=i[a]||[],i[a].push(n)},Vx=(e,t)=>{let{obj:n,k:r}=Rx(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Hx=(e,t,n)=>{let r=Vx(e,n);return r===void 0?Vx(t,n):r},Ux=(e,t,n)=>{for(let r in t)r!==`__proto__`&&r!==`constructor`&&(Object.prototype.hasOwnProperty.call(e,r)?jx(e[r])||e[r]instanceof String||jx(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):Ux(e[r],t[r],n):e[r]=t[r]);return e},Wx=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,`\\$&`),Gx={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`,"/":`&#x2F;`},Kx=e=>jx(e)?e.replace(/[&<>"'\/]/g,e=>Gx[e]):e,qx=class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(t!==void 0)return t;let n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}},Jx=[` `,`,`,`?`,`!`,`;`],Yx=new qx(20),Xx=(e,t,n)=>{t||=``,n||=``;let r=Jx.filter(e=>!t.includes(e)&&!n.includes(e));if(r.length===0)return!0;let i=Yx.getRegExp(`(${r.map(e=>e===`?`?`\\?`:e).join(`|`)})`),a=!i.test(e);if(!a){let t=e.indexOf(n);t>0&&!i.test(e.substring(0,t))&&(a=!0)}return a},Zx=(e,t,n=`.`)=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let r=t.split(n),i=e;for(let e=0;e<r.length;){if(!i||typeof i!=`object`)return;let t,a=``;for(let o=e;o<r.length;++o)if(o!==e&&(a+=n),a+=r[o],t=i[a],t!==void 0){if([`string`,`number`,`boolean`].includes(typeof t)&&o<r.length-1)continue;e+=o-e+1;break}i=t}return i},Qx=e=>e?.replace(/_/g,`-`),$x={type:`logger`,log(e){this.output(`log`,e)},warn(e){this.output(`warn`,e)},error(e){this.output(`error`,e)},output(e,t){console?.[e]?.apply?.(console,t)}},eS=new class e{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||`i18next:`,this.logger=e||$x,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,`log`,``,!0)}warn(...e){return this.forward(e,`warn`,``,!0)}error(...e){return this.forward(e,`error`,``)}deprecate(...e){return this.forward(e,`warn`,`WARNING DEPRECATED: `,!0)}forward(e,t,n,r){return r&&!this.debug?null:(e=e.map(e=>jx(e)?e.replace(/[\r\n\x00-\x1F\x7F]/g,` `):e),jx(e[0])&&(e[0]=`${n}${this.prefix} ${e[0]}`),this.logger[t](e))}create(t){return new e(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t||=this.options,t.prefix=t.prefix||this.prefix,new e(this.logger,t)}},tS=class{constructor(){this.observers={}}on(e,t){return e.split(` `).forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let n=this.observers[e].get(t)||0;this.observers[e].set(t,n+1)}),this}off(e,t){this.observers[e]&&(t?this.observers[e].delete(t):delete this.observers[e])}once(e,t){let n=(...r)=>{t(...r),this.off(e,n)};return this.on(e,n),this}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,n])=>{for(let r=0;r<n;r++)e(...t)}),this.observers[`*`]&&Array.from(this.observers[`*`].entries()).forEach(([n,r])=>{for(let i=0;i<r;i++)n(e,...t)})}},nS=new WeakSet,rS=class extends tS{constructor(e,t={ns:[`translation`],defaultNS:`translation`}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,n,r={}){let i=r.keySeparator===void 0?this.options.keySeparator:r.keySeparator,a=r.ignoreJSONStructure===void 0?this.options.ignoreJSONStructure:r.ignoreJSONStructure,o;e.includes(`.`)?o=e.split(`.`):(o=[e,t],n&&(Array.isArray(n)?o.push(...n):jx(n)&&i?o.push(...n.split(i)):o.push(n)));let s=Vx(this.data,o);return!s&&!t&&!n&&e.includes(`.`)&&(e=o[0],t=o[1],n=o.slice(2).join(`.`)),s||!a||!jx(n)?s:Zx(this.data?.[e]?.[t],n,i)}addResource(e,t,n,r,i={silent:!1}){let a=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.includes(`.`)&&(o=e.split(`.`),r=t,t=o[1]),this.addNamespaces(t),zx(this.data,o,r),i.silent||this.emit(`added`,e,t,n,r)}addResources(e,t,n,r={silent:!1}){for(let r in n)(jx(n[r])||Array.isArray(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});r.silent||this.emit(`added`,e,t,n)}addResourceBundle(e,t,n,r,i,a={silent:!1,skipCopy:!1}){let o=[e,t];e.includes(`.`)&&(o=e.split(`.`),r=n,n=t,t=o[1]),this.addNamespaces(t);let s=Vx(this.data,o)||{};a.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?Ux(s,n,i):s={...s,...n},zx(this.data,o,s),a.silent||this.emit(`added`,e,t,n)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit(`removed`,e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||=this.options.defaultNS,this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>{let n=t[e];return nS.has(n)?!0:!n||Object.keys(n).length===0?!1:(typeof n==`object`&&nS.add(n),!0)})}toJSON(){return this.data}},iS={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach(e=>{t=this.processors[e]?.process(t,n,r,i)??t}),t}},aS=Symbol(`i18next/PATH_KEY`);function oS(){let e=[],t=Object.create(null),n;return t.get=(r,i)=>(n?.revoke?.(),i===aS?e:(e.push(i),n=Proxy.revocable(r,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function sS(e,t){let{[aS]:n}=e(oS()),r=t?.keySeparator??`.`,i=t?.nsSeparator??`:`,a=t?.enableSelector===`strict`;if(n.length>1&&i){let e=t?.ns,o=a?Array.isArray(e)?e:e?[e]:null:Array.isArray(e)?e:null;if(o&&(a?o:o.length>1?o.slice(1):[]).includes(n[0]))return`${n[0]}${i}${n.slice(1).join(r)}`}return n.join(r)}var cS=e=>!jx(e)&&typeof e!=`boolean`&&typeof e!=`number`,lS=class e extends tS{constructor(e,t={}){super(),Px([`resourceStore`,`languageUtils`,`pluralResolver`,`interpolator`,`backendConnector`,`i18nFormat`,`utils`],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.logger=eS.create(`translator`),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let n={...t};if(e==null)return!1;let r=this.resolve(e,n);if(r?.res===void 0)return!1;let i=cS(r.res);return!(n.returnObjects===!1&&i)}extractFromKey(e,t){let n=t.nsSeparator===void 0?this.options.nsSeparator:t.nsSeparator;n===void 0&&(n=`:`);let r=t.keySeparator===void 0?this.options.keySeparator:t.keySeparator,i=t.ns||this.options.defaultNS||[],a=n&&e.includes(n),o=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!Xx(e,n,r);if(a&&!o){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:jx(i)?[i]:i};let a=e.split(n);(n!==r||n===r&&this.options.ns.includes(a[0]))&&(i=a.shift()),e=a.join(r)}return{key:e,namespaces:jx(i)?[i]:i}}translate(t,n,r){let i=typeof n==`object`?{...n}:n;if(typeof i!=`object`&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i==`object`&&(i={...i}),i||={},t==null)return``;typeof t==`function`&&(t=sS(t,{...this.options,...i})),Array.isArray(t)||(t=[String(t)]),t=t.map(e=>typeof e==`function`?sS(e,{...this.options,...i}):String(e));let a=i.returnDetails===void 0?this.options.returnDetails:i.returnDetails,o=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,{key:s,namespaces:c}=this.extractFromKey(t[t.length-1],i),l=c[c.length-1],u=i.nsSeparator===void 0?this.options.nsSeparator:i.nsSeparator;u===void 0&&(u=`:`);let d=i.lng||this.language,f=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d?.toLowerCase()===`cimode`)return f?a?{res:`${l}${u}${s}`,usedKey:s,exactUsedKey:s,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:`${l}${u}${s}`:a?{res:s,usedKey:s,exactUsedKey:s,usedLng:d,usedNS:l,usedParams:this.getUsedParamsDetails(i)}:s;let p=this.resolve(t,i),m=p?.res,h=p?.usedKey||s,g=p?.exactUsedKey||s,_=[`[object Number]`,`[object Function]`,`[object RegExp]`],v=i.joinArrays===void 0?this.options.joinArrays:i.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject,b=i.count!==void 0&&!jx(i.count),x=e.hasDefaultValue(i),S=b?this.pluralResolver.getSuffix(d,i.count,i):``,C=i.ordinal&&b?this.pluralResolver.getSuffix(d,i.count,{ordinal:!1}):``,w=b&&!i.ordinal&&i.count===0,T=w&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${S}`]||i[`defaultValue${C}`]||i.defaultValue,E=m;y&&!m&&x&&(E=T);let D=cS(E),O=Object.prototype.toString.apply(E);if(y&&E&&D&&!_.includes(O)&&!(jx(v)&&Array.isArray(E))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn(`accessing an object - but returnObjects options is not enabled!`);let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,E,{...i,ns:c}):`key '${s} (${this.language})' returned an object instead of string.`;return a?(p.res=e,p.usedParams=this.getUsedParamsDetails(i),p):e}if(o){let e=Array.isArray(E),t=e?[]:{},n=e?g:h;for(let e in E)if(Object.prototype.hasOwnProperty.call(E,e)){let r=`${n}${o}${e}`;t[e]=x&&!m?this.translate(r,{...i,defaultValue:cS(T)?T[e]:void 0,joinArrays:!1,ns:c}):this.translate(r,{...i,joinArrays:!1,ns:c}),t[e]===r&&(t[e]=E[e])}m=t}}else if(y&&jx(v)&&Array.isArray(m))m=m.join(v),m&&=this.extendTranslation(m,t,i,r);else{let e=!1,n=!1;!this.isValidLookup(m)&&x&&(e=!0,m=T),this.isValidLookup(m)||(n=!0,m=s);let a=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&n?void 0:m,c=x&&T!==m&&this.options.updateMissing;if(n||e||c){if(this.logger.log(c?`updateKey`:`missingKey`,d,l,b&&!c?`${s}${this.pluralResolver.getSuffix(d,i.count,i)}`:s,c?T:m),o){let e=this.resolve(s,{...i,keySeparator:!1});e&&e.res&&this.logger.warn(`Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.`)}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo===`fallback`&&t&&t[0])for(let n=0;n<t.length;n++)e.push(t[n]);else this.options.saveMissingTo===`all`?e=this.languageUtils.toResolveHierarchy(i.lng||this.language):e.push(i.lng||this.language);let n=(e,t,n)=>{let r=x&&n!==m?n:a;this.options.missingKeyHandler?this.options.missingKeyHandler(e,l,t,r,c,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,l,t,r,c,i),this.emit(`missingKey`,e,l,t,m)};this.options.saveMissing&&(this.options.saveMissingPlurals&&b?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,i);w&&i[`defaultValue${this.options.pluralSeparator}zero`]&&!t.includes(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{n([e],s+t,i[`defaultValue${t}`]||T)})}):n(e,s,T))}m=this.extendTranslation(m,t,i,p,r),n&&m===s&&this.options.appendNamespaceToMissingKey&&(m=`${l}${u}${s}`),(n||e)&&this.options.parseMissingKeyHandler&&(m=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${l}${u}${s}`:s,e?m:void 0,i))}return a?(p.res=m,p.usedParams=this.getUsedParamsDetails(i),p):m}extendTranslation(e,t,n,r,i){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});let a=jx(e)&&(n?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:n.interpolation.skipOnVariables),o;if(a){let t=e.match(this.interpolator.nestingRegexp);o=t&&t.length}let s=n.replace&&!jx(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),e=this.interpolator.interpolate(e,s,n.lng||this.language||r.usedLng,n),a){let t=e.match(this.interpolator.nestingRegexp),r=t&&t.length;o<r&&(n.nest=!1)}!n.lng&&r&&r.res&&(n.lng=this.language||r.usedLng),n.nest!==!1&&(e=this.interpolator.nest(e,(...e)=>i?.[0]===e[0]&&!n.context?(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null):this.translate(...e,t),n)),n.interpolation&&this.interpolator.reset()}let a=n.postProcess||this.options.postProcess,o=jx(a)?[a]:a;return e!=null&&o?.length&&n.applyPostProcessor!==!1&&(e=iS.handle(o,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e,t={}){let n,r,i,a,o;return jx(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(e=>typeof e==`function`?sS(e,{...this.options,...t}):e)),e.forEach(e=>{if(this.isValidLookup(n))return;let s=this.extractFromKey(e,t),c=s.key;r=c;let l=s.namespaces;this.options.fallbackNS&&(l=l.concat(this.options.fallbackNS));let u=t.count!==void 0&&!jx(t.count),d=u&&!t.ordinal&&t.count===0,f=t.context!==void 0&&(jx(t.context)||typeof t.context==`number`)&&t.context!==``,p=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);l.forEach(e=>{this.isValidLookup(n)||(o=e,!this.checkedLoadedFor[`${p[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(this.checkedLoadedFor[`${p[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${p.join(`, `)}" won't get resolved as namespace "${o}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`)),p.forEach(r=>{if(this.isValidLookup(n))return;a=r;let o=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(o,c,r,e,t);else{let e;u&&(e=this.pluralResolver.getSuffix(r,t.count,t));let n=`${this.options.pluralSeparator}zero`,i=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(t.ordinal&&e.startsWith(i)&&o.push(c+e.replace(i,this.options.pluralSeparator)),o.push(c+e),d&&o.push(c+n)),f){let r=`${c}${this.options.contextSeparator||`_`}${t.context}`;o.push(r),u&&(t.ordinal&&e.startsWith(i)&&o.push(r+e.replace(i,this.options.pluralSeparator)),o.push(r+e),d&&o.push(r+n))}}let s;for(;s=o.pop();)this.isValidLookup(n)||(i=s,n=this.getResource(r,e,s,t))}))})}),{res:n,usedKey:r,exactUsedKey:i,usedLng:a,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e===``)}getResource(e,t,n,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(e={}){let t=[`defaultValue`,`ordinal`,`context`,`replace`,`lng`,`lngs`,`fallbackLng`,`ns`,`keySeparator`,`nsSeparator`,`returnObjects`,`returnDetails`,`joinArrays`,`postProcess`,`interpolation`],n=e.replace&&!jx(e.replace),r=n?e.replace:e;if(n&&e.count!==void 0&&(r={...r,count:e.count}),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!n){r={...r};for(let e of t)delete r[e]}return r}static hasDefaultValue(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.startsWith(`defaultValue`)&&e[t]!==void 0)return!0;return!1}},uS=class{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=eS.create(`languageUtils`),this.resolveHierarchyCache={}}clearCache(){this.resolveHierarchyCache={}}getScriptPartFromCode(e){if(e=Qx(e),!e||!e.includes(`-`))return null;let t=e.split(`-`);return t.length===2||(t.pop(),t[t.length-1].toLowerCase()===`x`)?null:this.formatLanguageCode(t.join(`-`))}getLanguagePartFromCode(e){if(e=Qx(e),!e||!e.includes(`-`))return e;let t=e.split(`-`);return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(jx(e)&&e.includes(`-`)){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load===`languageOnly`||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;let n=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(n))&&(t=n)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let n=this.getScriptPartFromCode(e);if(this.isSupportedCode(n))return t=n;let r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(e=>e===r?!0:!e.includes(`-`)&&!r.includes(`-`)?!1:!!(e.includes(`-`)&&!r.includes(`-`)&&e.slice(0,e.indexOf(`-`))===r||e.startsWith(r)&&r.length>1))}),t||=this.getFallbackCodes(this.options.fallbackLng)[0],t}getFallbackCodes(e,t){if(!e)return[];if(typeof e==`function`&&(e=e(t)),jx(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let n=e[t];return n||=e[this.getScriptPartFromCode(t)],n||=e[this.formatLanguageCode(t)],n||=e[this.getLanguagePartFromCode(t)],n||=e.default,n||[]}toResolveHierarchy(e,t){let n=this.options.fallbackLng,r=Array.isArray(n)?n.join(`|`):n;r!==this._cachedFallbackLng&&(this.resolveHierarchyCache={},this._cachedFallbackLng=r);let i=t===void 0||t===!1||jx(t),a=t===void 0&&typeof this.options.fallbackLng==`function`,o=jx(e)&&i&&!a,s=null;if(o){let n;n=t===void 0?`undefined`:t===!1?`boolean:false`:`string:${t}`,s=`${e.length}:${e}|${n}`}if(s!==null){let e=this.resolveHierarchyCache[s];if(e!==void 0)return e.slice()}let c=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),l=[],u=e=>{e&&(this.isSupportedCode(e)?l.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return jx(e)&&(e.includes(`-`)||e.includes(`_`))?(this.options.load!==`languageOnly`&&u(this.formatLanguageCode(e)),this.options.load!==`languageOnly`&&this.options.load!==`currentOnly`&&u(this.getScriptPartFromCode(e)),this.options.load!==`currentOnly`&&u(this.getLanguagePartFromCode(e))):jx(e)&&u(this.formatLanguageCode(e)),c.forEach(e=>{let t=this.formatLanguageCode(e);l.includes(t)||u(t)}),s===null?l:(this.resolveHierarchyCache[s]=l,l.slice())}},dS={zero:0,one:1,two:2,few:3,many:4,other:5},fS={select:e=>e===1?`one`:`other`,resolvedOptions:()=>({pluralCategories:[`one`,`other`]})},pS=class{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=eS.create(`pluralResolver`),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let n=Qx(e===`dev`?`en`:e),r=t.ordinal?`ordinal`:`cardinal`,i=JSON.stringify({cleanedCode:n,type:r});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(n,{type:r})}catch{if(typeof Intl>`u`)return this.logger.error(`No Intl support, please use an Intl polyfill!`),fS;if(!e.match(/-|_/))return fS;let n=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(n,t)}return this.pluralRulesCache[i]=a,a}needsPlural(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,n={}){return this.getSuffixes(e,n).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?n.resolvedOptions().pluralCategories.sort((e,t)=>dS[e]-dS[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:``}${e}`):[]}getSuffix(e,t,n={}){let r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:``}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix(`dev`,t,n))}},mS=(e,t,n,r=`.`,i=!0)=>{let a=Hx(e,t,n);return!a&&i&&jx(n)&&(a=Zx(e,n,r),a===void 0&&(a=Zx(t,n,r))),a},hS=e=>e.replace(/\$/g,`$$$$`),gS=class{constructor(e={}){this.logger=eS.create(`interpolator`),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||={escapeValue:!0};let{escape:t,escapeValue:n,useRawValueToEscape:r,prefix:i,prefixEscaped:a,suffix:o,suffixEscaped:s,formatSeparator:c,unescapeSuffix:l,unescapePrefix:u,nestingPrefix:d,nestingPrefixEscaped:f,nestingSuffix:p,nestingSuffixEscaped:m,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:_}=e.interpolation;this.escape=t===void 0?Kx:t,this.escapeValue=n===void 0||n,this.useRawValueToEscape=r!==void 0&&r,this.prefix=i?Wx(i):a||`{{`,this.suffix=o?Wx(o):s||`}}`,this.formatSeparator=c||`,`,this.unescapePrefix=l?``:u?Wx(u):`-`,this.unescapeSuffix=this.unescapePrefix?``:l?Wx(l):``,this.nestingPrefix=d?Wx(d):f||Wx(`$t(`),this.nestingSuffix=p?Wx(p):m||Wx(`)`),this.nestingOptionsSeparator=h||`,`,this.maxReplaces=g||1e3,this.alwaysFormat=_!==void 0&&_,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,`g`);this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']|"[^"]*"|'[^']*'|\\((?:[^()"']|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,n,r){let i,a,o,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=e=>{if(!e.includes(this.formatSeparator)){let i=mS(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(i,void 0,n,{...r,...t,interpolationkey:e}):i}let i=e.split(this.formatSeparator),a=i.shift().trim(),o=i.join(this.formatSeparator).trim();return this.format(mS(t,s,a,this.options.keySeparator,this.options.ignoreJSONStructure),o,n,{...r,...t,interpolationkey:a})};this.resetRegExp(),!this.escapeValue&&typeof e==`string`&&/\$t\([^)]*\{[^}]*\{\{/.test(e)&&this.logger.warn(`nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.`);let l=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=r?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:r.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e):e}].forEach(t=>{for(o=0;i=t.regex.exec(e);){let n=i[1].trim();if(a=c(n),a===void 0){if(typeof l==`function`){let t=l(e,i,r);a=jx(t)?t:``}else if(r&&Object.prototype.hasOwnProperty.call(r,n))a=``;else if(u){a=i[0];continue}else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),a=``}else!jx(a)&&!this.useRawValueToEscape&&(a=Nx(a));let s=t.safeValue(a);if(e=e.replace(i[0],hS(s)),u?(t.regex.lastIndex+=s.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,t,n={}){let r,i,a,o=(e,t)=>{let n=this.nestingOptionsSeparator;if(!e.includes(n))return e;let r=e.split(RegExp(`${Wx(n)}[ ]*{`)),i=`{${r[1]}`;e=r[0],i=this.interpolate(i,a);let o=i.match(/'/g),s=i.match(/"/g);((o?.length??0)%2==0&&!s||(s?.length??0)%2!=0)&&(i=i.replace(/'/g,`"`));try{a=JSON.parse(i),t&&(a={...t,...a})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${i}`}return a.defaultValue&&a.defaultValue.includes(this.prefix)&&delete a.defaultValue,e},s=new RegExp(this.nestingRegexp),c=``,l=0;for(;r=s.exec(e);){let u=[];a={...n},a=a.replace&&!jx(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let d=/{.*}/s.test(r[1])?r[1].lastIndexOf(`}`)+1:r[1].indexOf(this.formatSeparator);if(d!==-1&&(u=r[1].slice(d).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),r[1]=r[1].slice(0,d)),i=t(o.call(this,r[1].trim(),a),a),i&&r[0]===e&&!jx(i))return i;jx(i)||(i=Nx(i)),i||=(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),``),u.length&&(i=u.reduce((e,t)=>this.format(e,t,n.lng,{...n,interpolationkey:r[1].trim()}),i.trim())),c+=e.slice(l,r.index)+Nx(i),l=s.lastIndex,this.regexp.lastIndex=0}return l?c+e.slice(l):e}},_S=e=>{let t=e.toLowerCase().trim(),n={};if(e.includes(`(`)){let r=e.split(`(`);t=r[0].toLowerCase().trim();let i=r[1].slice(0,-1);t===`currency`&&!i.includes(`:`)?n.currency||=i.trim():t===`relativetime`&&!i.includes(`:`)?n.range||=i.trim():i.split(`;`).forEach(e=>{if(e){let[t,...r]=e.split(`:`),i=r.join(`:`).trim().replace(/^'+|'+$/g,``),a=t.trim();n[a]||(n[a]=i),i===`false`&&(n[a]=!1),i===`true`&&(n[a]=!0),isNaN(i)||(n[a]=parseInt(i,10))}})}return{formatName:t,formatOptions:n}},vS=e=>{let t={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});let o=r+JSON.stringify(a),s=t[o];return s||(s=e(Qx(r),i),t[o]=s),s(n)}},yS=e=>(t,n,r)=>e(Qx(n),r)(t),bS=class{constructor(e={}){this.logger=eS.create(`formatter`),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||`,`;let n=t.cacheInBuiltFormats?vS:yS;this.formats={number:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)}),currency:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t,style:`currency`});return e=>n.format(e)}),datetime:n((e,t)=>{let n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)}),relativetime:n((e,t)=>{let n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||`day`)}),list:n((e,t)=>{let n=new Intl.ListFormat(e,{...t});return e=>n.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=vS(t)}format(e,t,n,r={}){if(!t||e==null)return e;let i=t.split(this.formatSeparator),a=[];for(let e=0;e<i.length;e++){let t=i[e];for(;t.indexOf(`(`)>-1&&!t.includes(`)`)&&e+1<i.length;)t=`${t}${this.formatSeparator}${i[++e]}`;a.push(t)}return a.reduce((e,t)=>{let{formatName:i,formatOptions:a}=_S(t);if(this.formats[i]){let t=e;try{let o=r?.formatParams?.[r.interpolationkey]||{},s=o.locale||o.lng||r.locale||r.lng||n;t=this.formats[i](e,s,{...a,...r,...o})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${i}`),e},e)}},xS=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)},SS=class extends tS{constructor(e,t,n,r={}){super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=eS.create(`backendConnector`),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,r.backend,r)}queueLoad(e,t,n,r){let i={},a={},o={},s={};return e.forEach(e=>{let r=!0;t.forEach(t=>{let o=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[o]=2:this.state[o]<0||(this.state[o]===1?a[o]===void 0&&(a[o]=!0):(this.state[o]=1,r=!1,a[o]===void 0&&(a[o]=!0),i[o]===void 0&&(i[o]=!0),s[t]===void 0&&(s[t]=!0)))}),r||(o[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){let r=e.split(`|`),i=r[0],a=r[1];t&&this.emit(`failedLoading`,i,a,t),!t&&n&&this.store.addResourceBundle(i,a,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);let o={};this.queue.forEach(n=>{Bx(n.loaded,[i],a),xS(n,e),t&&n.errors.push(t),n.pendingCount===0&&!n.done&&(Object.keys(n.loaded).forEach(e=>{o[e]||(o[e]={});let t=n.loaded[e];t.length&&t.forEach(t=>{o[e][t]===void 0&&(o[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit(`loaded`,o),this.queue=this.queue.filter(e=>!e.done)}read(e,t,n,r=0,i=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:i,callback:a});return}this.readingCalls++;let o=(o,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}o&&s&&r<this.maxRetries?setTimeout(()=>{this.read(e,t,n,r+1,i*2,a)},i):a(o,s)},s=this.backend[n].bind(this.backend);if(s.length===2)try{let n=s(e,t);n&&typeof n.then==`function`?n.then(e=>o(null,e)).catch(o):o(null,n)}catch(e){o(e)}else return s(e,t,o)}prepareLoading(e,t,n={},r){if(!this.backend)return this.logger.warn(`No backend was added via i18next.use. Will not load resources.`),r&&r();jx(e)&&(e=this.languageUtils.toResolveHierarchy(e)),jx(t)&&(t=[t]);let i=this.queueLoad(e,t,n,r);if(!i.toLoad.length)return i.pending.length||r(),null;i.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e,t=``){let n=e.split(`|`),r=n[0],i=n[1];this.read(r,i,`read`,void 0,void 0,(n,a)=>{n&&this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`,n),!n&&a&&this.logger.log(`${t}loaded namespace ${i} for language ${r}`,a),this.loaded(e,n,a)})}saveMissing(e,t,n,r,i,a={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t))this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`);else if(n!=null&&n!==``){if(this.backend?.create){let s={...a,isUpdate:i},c=this.backend.create.bind(this.backend);if(c.length<6)try{let i;i=c.length===5?c(e,t,n,r,s):c(e,t,n,r),i&&typeof i.then==`function`?i.then(e=>o(null,e)).catch(o):o(null,i)}catch(e){o(e)}else c(e,t,n,r,o,s)}e&&e[0]&&this.store.addResource(e[0],t,n,r)}}},CS=()=>({debug:!1,initAsync:!0,ns:[`translation`],defaultNS:[`translation`],fallbackLng:[`dev`],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:`all`,preload:!1,keySeparator:`.`,nsSeparator:`:`,pluralSeparator:`_`,contextSeparator:`_`,enableSelector:!1,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:`fallback`,saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]==`object`&&(t=e[1]),jx(e[1])&&(t.defaultValue=e[1]),jx(e[2])&&(t.tDescription=e[2]),typeof e[2]==`object`||typeof e[3]==`object`){let n=e[3]||e[2];Object.keys(n).forEach(e=>{t[e]=n[e]})}return t},interpolation:{escapeValue:!0,prefix:`{{`,suffix:`}}`,formatSeparator:`,`,unescapePrefix:`-`,nestingPrefix:`$t(`,nestingSuffix:`)`,nestingOptionsSeparator:`,`,maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),wS=e=>(jx(e.ns)&&(e.ns=[e.ns]),jx(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),jx(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&!e.supportedLngs.includes(`cimode`)&&(e.supportedLngs=e.supportedLngs.concat([`cimode`])),e),TS=()=>{},ES=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{typeof e[t]==`function`&&(e[t]=e[t].bind(e))})},DS=class e extends tS{constructor(e={},t){if(super(),this.options=wS(e),this.services={},this.logger=eS,this.modules={external:[]},ES(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,typeof e==`function`&&(t=e,e={}),e.defaultNS==null&&e.ns&&(jx(e.ns)?e.defaultNS=e.ns:e.ns.includes(`translation`)||(e.defaultNS=e.ns[0]));let n=CS();this.options={...n,...this.options,...wS(e)},this.options.interpolation={...n.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!=`function`&&(this.options.overloadTranslationOptionHandler=n.overloadTranslationOptionHandler);let r=e=>e?typeof e==`function`?new e:e:null;if(!this.options.isClone){this.modules.logger?eS.init(r(this.modules.logger),this.options):eS.init(null,this.options);let e;e=this.modules.formatter?this.modules.formatter:bS;let t=new uS(this.options);this.store=new rS(this.options.resources,this.options);let n=this.services;n.logger=eS,n.resourceStore=this.store,n.languageUtils=t,n.pluralResolver=new pS(t,{prepend:this.options.pluralSeparator}),e&&(n.formatter=r(e),n.formatter.init&&n.formatter.init(n,this.options),this.options.interpolation.format=n.formatter.format.bind(n.formatter)),n.interpolator=new gS(this.options),n.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},n.backendConnector=new SS(r(this.modules.backend),n.resourceStore,n,this.options),n.backendConnector.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(n.languageDetector=r(this.modules.languageDetector),n.languageDetector.init&&n.languageDetector.init(n,this.options.detection,this.options)),this.modules.i18nFormat&&(n.i18nFormat=r(this.modules.i18nFormat),n.i18nFormat.init&&n.i18nFormat.init(this)),this.translator=new lS(this.services,this.options),this.translator.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||=TS,this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&e[0]!==`dev`&&(this.options.lng=e[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn(`init: no languageDetector is used and no lng is defined`),[`getResource`,`hasResourceBundle`,`getResourceBundle`,`getDataByLanguage`].forEach(e=>{this[e]=(...t)=>this.store[e](...t)}),[`addResource`,`addResources`,`addResourceBundle`,`removeResourceBundle`].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let i=Mx(),a=()=>{let e=(e,n)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn(`init: i18next is already initialized. You should call init just once!`),this.isInitialized=!0,this.options.isClone||this.logger.log(`initialized`,this.options),this.emit(`initialized`,this.options),i.resolve(n),t(e,n)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?a():setTimeout(a,0),i}loadResources(e,t=TS){let n=t,r=jx(e)?e:this.language;if(typeof e==`function`&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.toLowerCase()===`cimode`&&(!this.options.preload||this.options.preload.length===0))return n();let e=[],t=t=>{t&&t!==`cimode`&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{t!==`cimode`&&(e.includes(t)||e.push(t))})};r?t(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{!e&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),n(e)})}else n(null)}reloadResources(e,t,n){let r=Mx();return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e||=this.languages,t||=this.options.ns,n||=TS,this.services.backendConnector.reload(e,t,e=>{r.resolve(),n(e)}),r}use(e){if(!e)throw Error(`You are passing an undefined module! Please check the object you are passing to i18next.use()`);if(!e.type)throw Error(`You are passing a wrong module! Please check the object you are passing to i18next.use()`);return e.type===`backend`&&(this.modules.backend=e),(e.type===`logger`||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type===`languageDetector`&&(this.modules.languageDetector=e),e.type===`i18nFormat`&&(this.modules.i18nFormat=e),e.type===`postProcessor`&&iS.addPostProcessor(e),e.type===`formatter`&&(this.modules.formatter=e),e.type===`3rdParty`&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&![`cimode`,`dev`].includes(e)){for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(![`cimode`,`dev`].includes(t)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&!this.languages.includes(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let n=Mx();this.emit(`languageChanging`,e);let r=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},i=(i,a)=>{a?this.isLanguageChangingTo===e&&(r(a),this.translator.changeLanguage(a),this.isLanguageChangingTo=void 0,this.emit(`languageChanged`,a),this.logger.log(`languageChanged`,a)):this.isLanguageChangingTo=void 0,n.resolve((...e)=>this.t(...e)),t&&t(i,(...e)=>this.t(...e))},a=t=>{!e&&!t&&this.services.languageDetector&&(t=[]);let n=jx(t)?t:t&&t[0],a=this.store.hasLanguageSomeTranslations(n)?n:this.services.languageUtils.getBestMatchFromCodes(jx(t)?[t]:t);a&&(this.language||r(a),this.translator.language||this.translator.changeLanguage(a),this.services.languageDetector?.cacheUserLanguage?.(a)),this.loadResources(a,e=>{i(e,a)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?a(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(a):this.services.languageDetector.detect(a):a(e),n}getFixedT(e,t,n,r){let i=r?.scopeNs,a=(e,t,...r)=>{let o;o=typeof t==`object`?{...t}:this.options.overloadTranslationOptionHandler([e,t].concat(r)),o.lng=o.lng||a.lng,o.lngs=o.lngs||a.lngs;let s=o.ns!==void 0&&o.ns!==null;o.ns=o.ns||a.ns,o.keyPrefix!==``&&(o.keyPrefix=o.keyPrefix||n||a.keyPrefix);let c={...this.options,...o};Array.isArray(i)&&!s&&(c.ns=i),typeof o.keyPrefix==`function`&&(o.keyPrefix=sS(o.keyPrefix,c));let l=this.options.keySeparator||`.`,u;return o.keyPrefix&&Array.isArray(e)?u=e.map(e=>(typeof e==`function`&&(e=sS(e,c)),`${o.keyPrefix}${l}${e}`)):(typeof e==`function`&&(e=sS(e,c)),u=o.keyPrefix?`${o.keyPrefix}${l}${e}`:e),this.t(u,o)};return jx(e)?a.lng=e:a.lngs=e,a.ns=t,a.keyPrefix=n,a}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn(`hasLoadedNamespace: i18next was not initialized`,this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn(`hasLoadedNamespace: i18n.languages were undefined or empty`,this.languages),!1;let n=t.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(n.toLowerCase()===`cimode`)return!0;let a=(e,t)=>{let n=this.services.backendConnector.state[`${e}|${t}`];return n===-1||n===0||n===2};if(t.precheck){let e=t.precheck(this,a);if(e!==void 0)return e}if(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages)return!0;let{languageUtils:o}=this.services,s=t.lng?o.isSupportedCode(n)&&o.toResolveHierarchy(n,!1)[0]:n;return!(s&&!a(s,e)||r&&!a(i,e))}loadNamespaces(e,t){let n=Mx();return this.options.ns?(jx(e)&&(e=[e]),e.forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)}),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}loadLanguages(e,t){let n=Mx();jx(e)&&(e=[e]);let r=this.options.preload||[],i=e.filter(e=>!r.includes(e)&&this.services.languageUtils.isSupportedCode(e));return i.length?(this.options.preload=r.concat(i),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}dir(e){if(e||=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language),!e)return`rtl`;try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch{}let t=`ar.shu.sqr.ssh.xaa.yhd.yud.aao.abh.abv.acm.acq.acw.acx.acy.adf.ads.aeb.aec.afb.ajp.apc.apd.arb.arq.ars.ary.arz.auz.avl.ayh.ayl.ayn.ayp.bbz.pga.he.iw.ps.pbt.pbu.pst.prp.prd.ug.ur.ydd.yds.yih.ji.yi.hbo.men.xmn.fa.jpr.peo.pes.prs.dv.sam.ckb`.split(`.`),n=this.services?.languageUtils||new uS(CS());return e.toLowerCase().indexOf(`-latn`)>1?`ltr`:t.includes(n.getLanguagePartFromCode(e))||e.toLowerCase().indexOf(`-arab`)>1?`rtl`:`ltr`}static createInstance(t={},n){let r=new e(t,n);return r.createInstance=e.createInstance,r}cloneInstance(t={},n=TS){let r=t.forkResourceStore;r&&delete t.forkResourceStore;let i={...this.options,preload:!1,...t,isClone:!0},a=new e(i);if((t.debug!==void 0||t.prefix!==void 0)&&(a.logger=a.logger.clone(t)),[`store`,`services`,`language`].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r&&(a.store=new rS(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((n,r)=>(n[r]={...e[t][r]},n),e[t]),e),{}),i),a.services.resourceStore=a.store),t.interpolation){let e={...CS().interpolation,...this.options.interpolation,...t.interpolation},n={...i,interpolation:e};a.services.interpolator=new gS(n)}return a.translator=new lS(a.services,i),a.translator.on(`*`,(e,...t)=>{a.emit(e,...t)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}.createInstance(),OS=DS.createInstance;DS.dir,DS.init,DS.loadResources,DS.reloadResources,DS.use,DS.changeLanguage,DS.getFixedT,DS.t,DS.exists,DS.setDefaultNamespace,DS.hasLoadedNamespace,DS.loadNamespaces,DS.loadLanguages;var kS=(e,t,n,r)=>{let i=[n,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(i,`warn`,`react-i18next::`,!0);IS(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...i):console?.warn&&console.warn(...i)},AS={},jS=(e,t,n,r)=>{IS(n)&&AS[n]||(IS(n)&&(AS[n]=new Date),kS(e,t,n,r))},MS=(e,t)=>()=>{if(e.isInitialized)t();else{let n=()=>{setTimeout(()=>{e.off(`initialized`,n)},0),t()};e.on(`initialized`,n)}},NS=(e,t,n)=>{e.loadNamespaces(t,MS(e,n))},PS=(e,t,n,r)=>{if(IS(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return NS(e,n,r);n.forEach(t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)}),e.loadLanguages(t,MS(e,r))},FS=(e,t,n={})=>!t.languages||!t.languages.length?(jS(t,`NO_LANGUAGES`,`i18n.languages were undefined or empty`,{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(t,r)=>{if(n.bindI18n&&n.bindI18n.indexOf(`languageChanging`)>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}),IS=e=>typeof e==`string`,LS=e=>typeof e==`object`&&!!e,RS=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,zS={"&amp;":`&`,"&#38;":`&`,"&lt;":`<`,"&#60;":`<`,"&gt;":`>`,"&#62;":`>`,"&apos;":`'`,"&#39;":`'`,"&quot;":`"`,"&#34;":`"`,"&nbsp;":`\xA0`,"&#160;":`\xA0`,"&copy;":`©`,"&#169;":`©`,"&reg;":`®`,"&#174;":`®`,"&hellip;":`…`,"&#8230;":`…`,"&#x2F;":`/`,"&#47;":`/`},BS=e=>zS[e],VS={bindI18n:`languageChanged`,bindI18nStore:``,transEmptyNodeValue:``,transSupportBasicHtmlNodes:!0,transWrapTextNodes:``,transKeepBasicHtmlNodesFor:[`br`,`strong`,`i`,`p`],useSuspense:!0,unescape:e=>e.replace(RS,BS),transDefaultProps:void 0},HS=(e={})=>{VS={...VS,...e}},US=()=>VS,WS,GS=e=>{WS=e},KS=()=>WS,qS={type:`3rdParty`,init(e){HS(e.options.react),GS(e)}},JS=(0,j.createContext)(),YS=class{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}},XS=Xf(),ZS={t:(e,t)=>{if(IS(t))return t;if(LS(t)&&IS(t.defaultValue))return t.defaultValue;if(typeof e==`function`)return``;if(Array.isArray(e)){let t=e[e.length-1];return typeof t==`function`?``:t}return e},ready:!1},QS=()=>()=>{},U=(e,t={})=>{let{i18n:n}=t,{i18n:r,defaultNS:i}=(0,j.useContext)(JS)||{},a=n||r||KS();a&&!a.reportNamespaces&&(a.reportNamespaces=new YS),a||jS(a,`NO_I18NEXT_INSTANCE`,`useTranslation: You will need to pass in an i18next instance by using initReactI18next or by passing it via props or context. In monorepo setups, make sure there is only one instance of react-i18next.`);let o=(0,j.useMemo)(()=>({...US(),...a?.options?.react,...t}),[a,t]),{useSuspense:s,keyPrefix:c,bindI18n:l,bindI18nStore:u}=o,d=e||i||a?.options?.defaultNS,f=IS(d)?[d]:d||[`translation`],p=(0,j.useMemo)(()=>f,f);a?.reportNamespaces?.addUsedNamespaces?.(p);let m=(0,j.useRef)(0),h=(0,j.useCallback)(e=>{if(!a)return QS;let t=()=>{m.current+=1,e()};return l&&a.on(l,t),u&&a.store.on(u,t),()=>{l&&l.split(` `).forEach(e=>a.off(e,t)),u&&u.split(` `).forEach(e=>a.store.off(e,t))}},[a,l,u]),g=(0,j.useRef)(),_=(0,j.useCallback)(()=>{if(!a)return ZS;let e=!!(a.isInitialized||a.initializedStoreOnce)&&p.every(e=>FS(e,a,o)),n=t.lng||a.language,r=m.current,i=typeof c==`function`?sS(c,{...a.options,ns:p}):c,s=g.current;if(s&&s.i18n===a&&s.ready===e&&s.lng===n&&s.namespaces===p&&s.keyPrefix===i&&s.revision===r)return s;let l={t:a.getFixedT(n,o.nsMode===`fallback`?p:p[0],c,{scopeNs:p}),i18n:a,ready:e,lng:n,namespaces:p,keyPrefix:i,revision:r};return g.current=l,l},[a,p,c,o,t.lng]),[v,y]=(0,j.useState)(0),{t:b,ready:x}=(0,XS.useSyncExternalStore)(h,_,_),S;a&&s&&!x&&(S=new Promise(e=>{let n=()=>e();t.lng?PS(a,t.lng,p,n):NS(a,p,n)}),{t:b,ready:x}=_()),(0,j.useEffect)(()=>{if(a&&!x&&!s){let e=()=>y(e=>e+1);t.lng?PS(a,t.lng,p,e):NS(a,p,e)}},[a,t.lng,p,x,s,v]);let C=a||{},w=(0,j.useRef)(null),T=(0,j.useRef)(),E=e=>`${e.language}|${e.resolvedLanguage}|${e.languages?.join(`,`)}`,D=e=>{let t=Object.getOwnPropertyDescriptors(e);t.__original&&delete t.__original;let n=Object.create(Object.getPrototypeOf(e),t);if(!Object.prototype.hasOwnProperty.call(n,`__original`))try{Object.defineProperty(n,"__original",{value:e,writable:!1,enumerable:!1,configurable:!1})}catch{}return n},O=(0,j.useMemo)(()=>{let e=C,t=e&&E(e),n=e;e&&(w.current&&w.current.__original===e&&T.current===t?n=w.current:(n=D(e),w.current=n,T.current=t));let r=!x&&!s?(...e)=>(jS(a,`USE_T_BEFORE_READY`,`useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t.`),b(...e)):b,i=[r,n,x];return i.t=r,i.i18n=n,i.ready=x,i},[b,C,x,C.resolvedLanguage,C.language,C.languages]);if(a&&s&&!x){let e=!1;try{e=!1}catch{}throw e&&jS(a,`SUSPENDED_WHILE_LOADING`,`useTranslation: suspended while translations are loading (useSuspense is true by default). Add a <Suspense> boundary above this component, or set react.useSuspense: false in the i18next init options. https://react.i18next.com/latest/usetranslation-hook`),S}return O};function $S({i18n:e,defaultNS:t,children:n}){let r=(0,j.useMemo)(()=>({i18n:e,defaultNS:t}),[e,t]);return(0,j.createElement)(JS.Provider,{value:r},n)}function eC(e){if(!e||e.type!==`image_generation`&&e.type!==`image_customization`||!(`size`in e))return e;let t={...e};return delete t.size,t}function tC(e){return!!e&&(e.type===`image_generation`||e.type===`image_customization`)}function nC(e){if(typeof e==`number`)return Number.isFinite(e)?e:NaN;if(typeof e!=`string`||!e.trim())return NaN;let t=e.trim();return/^-?\d+$/.test(t)?Number(t):Date.parse(t)}var rC=(0,j.createContext)(null),iC=rC.Provider;function aC(){let e=(0,j.useContext)(rC);if(!e)throw Error(`The table editor needs a TableDataSourceProvider.`);return e}var oC=(0,j.createContext)({}),sC=oC.Provider;function cC(){return(0,j.useContext)(oC)}var lC=/^(https?:|data:|blob:)/i;function uC(e,t){return e.resolveFileURL?e.resolveFileURL(t):lC.test(t)?t:``}var dC={success:()=>void 0,error:()=>void 0,dismiss:()=>void 0};function fC(){return cC().notify??dC}function pC(){let e=cC(),{i18n:t}=U();return e.locale?.()??t.language}var mC=`kition:data-table-action`;function hC(e,t){return t.map(t=>{let n=e.tables?.find(e=>e.name===t.source_table_name||e.title===t.source_table_name);if(!n)throw Error(`Dashboard source table was not created: ${t.source_table_name}`);let{source_table_name:r,...i}=t;return{...i,source_table_id:n.id}})}var gC=/^kition-blob:([0-9a-f]{64})$/;function _C(e){return typeof e==`string`?gC.exec(e.trim())?.[1]??null:null}var vC=class{read;documentId;onLoaded;entries=new Map;disposed=!1;constructor(e,t,n){this.read=e,this.documentId=t,this.onLoaded=n}url(e){let t=this.entries.get(e);return t?t.state===`ready`?t.url:``:(this.entries.set(e,{state:`loading`}),this.load(e),``)}async load(e){try{let t=await this.read({documentId:this.documentId,hash:e});if(this.disposed)return;let n=t.data.slice(),r=t.mimeType||`application/octet-stream`,i=URL.createObjectURL(new Blob([n.buffer],{type:r}));this.entries.set(e,{state:`ready`,url:i}),this.onLoaded()}catch{this.disposed||this.entries.set(e,{state:`failed`})}}dispose(){this.disposed=!0;for(let e of this.entries.values())e.state===`ready`&&URL.revokeObjectURL(e.url);this.entries.clear()}},yC=(0,j.createContext)(null);function bC(e){let t=(0,j.useContext)(yC);(0,j.useEffect)(()=>{t?.(e)},[e,t])}function xC({children:e}){let t=cC(),n=aC(),[r,i]=(0,j.useState)(null),[a,o]=(0,j.useState)(0),s=n.attachments?.read,c=(0,j.useMemo)(()=>{if(r==null||!s||t.resolveBlobURL)return null;let e=!1;return new vC(s,r,()=>{e||(e=!0,queueMicrotask(()=>{e=!1,o(e=>e+1)}))})},[r,s,t.resolveBlobURL]);(0,j.useEffect)(()=>()=>c?.dispose(),[c]);let l=(0,j.useMemo)(()=>{let e=n.attachments?.put;return{...t,resolveFileURL:e=>{let n=_C(e);return n?r==null?``:t.resolveBlobURL?t.resolveBlobURL({documentId:r,hash:n}):c?c.url(n):``:uC(t,e)},uploadAttachment:t.uploadAttachment??(e?t=>e(t):void 0)}},[t,n,r,c,a]);return(0,I.jsx)(yC.Provider,{value:i,children:(0,I.jsx)(sC,{value:l,children:e})})}function SC(e,t){let n=e.options??{},r=typeof n.label==`string`&&n.label?n.label:e.title||t,i=n.action??{};return(i.kind===`run_workflow`?`run_workflow`:`open_url`)==`open_url`?{label:r,action:{kind:`open_url`,url:typeof i.url==`string`?i.url:void 0}}:{label:r,action:{kind:`run_workflow`,workflow_id:typeof i.workflow_id==`number`?i.workflow_id:void 0}}}function CC({activeTableId:e,activeViewId:t,loadRecords:n,refreshDocument:r,refreshHistoryState:i}){function a(t){return e!=null&&t.includes(e)}return{onRecords:(t,r)=>{[...t,...r].some(([t])=>t===e)&&n(),i()},onSchema:e=>{a(e)&&r(),i()},onViews:e=>{t!=null&&e.includes(t)&&r(),i()},onReorder:e=>{a(e)&&n(),i()},onDashboards:()=>{i()},onResync:()=>{r(),n(),i()}}}function wC(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=wC(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function TC(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=wC(e))&&(r&&(r+=` `),r+=t);return r}var EC=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},DC=(e,t)=>({classGroupId:e,validator:t}),OC=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),kC=`-`,AC=[],jC=`arbitrary..`,MC=e=>{let t=FC(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return PC(e);let n=e.split(kC);return NC(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?EC(i,t):t:i||AC}return n[e]||AC}}},NC=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=NC(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(kC):e.slice(t).join(kC),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},PC=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?jC+r:void 0})(),FC=e=>{let{theme:t,classGroups:n}=e;return IC(n,t)},IC=(e,t)=>{let n=OC();for(let r in e){let i=e[r];LC(i,n,r,t)}return n},LC=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];RC(i,t,n,r)}},RC=(e,t,n,r)=>{typeof e==`string`?zC(e,t,n):typeof e==`function`?BC(e,t,n,r):VC(e,t,n,r)},zC=(e,t,n)=>{let r=e===``?t:HC(t,e);r.classGroupId=n},BC=(e,t,n,r)=>{UC(e)?LC(e(r),t,n,r):(t.validators===null&&(t.validators=[]),t.validators.push(DC(n,e)))},VC=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];LC(o,HC(t,a),n,r)}},HC=(e,t)=>{let n=e,r=t.split(kC),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=OC(),n.nextPart.set(t,i)),n=i}return n},UC=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,WC=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},GC=`!`,KC=`:`,qC=[],JC=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),YC=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===KC){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(GC)?(c=s.slice(0,-1),l=!0):s.startsWith(GC)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return JC(t,l,c,u)};if(t){let e=t+KC,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):JC(qC,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},XC=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},ZC=e=>({cache:WC(e.cacheSize),parseClassName:YC(e),sortModifiers:XC(e),postfixLookupClassGroupIds:QC(e),...MC(e)}),QC=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},$C=/\s+/,ew=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split($C),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h||(g=r(p),!g)){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+GC:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},tw=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=nw(n))&&(i&&(i+=` `),i+=r);return i},nw=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=nw(e[r]))&&(n&&(n+=` `),n+=t);return n},rw=(e,...t)=>{let n,r,i,a,o=o=>(n=ZC(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=ew(e,n);return i(e,a),a};return a=o,(...e)=>a(tw(...e))},iw=[],aw=e=>{let t=t=>t[e]||iw;return t.isThemeGetter=!0,t.themeKey=e,t},ow=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,sw=/^\((?:(\w[\w-]*):)?(.+)\)$/i,cw=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,lw=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,uw=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,dw=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,fw=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,pw=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,mw=e=>cw.test(e),hw=e=>!!e&&!Number.isNaN(Number(e)),gw=e=>!!e&&Number.isInteger(Number(e)),_w=e=>e.endsWith(`%`)&&hw(e.slice(0,-1)),vw=e=>lw.test(e),yw=()=>!0,bw=e=>uw.test(e)&&!dw.test(e),xw=()=>!1,Sw=e=>fw.test(e),Cw=e=>pw.test(e),ww=e=>!W(e)&&!G(e),Tw=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),Ew=e=>Vw(e,Gw,xw),W=e=>ow.test(e),Dw=e=>Vw(e,Kw,bw),Ow=e=>Vw(e,qw,hw),kw=e=>Vw(e,Yw,yw),Aw=e=>Vw(e,Jw,xw),jw=e=>Vw(e,Uw,xw),Mw=e=>Vw(e,Ww,Cw),Nw=e=>Vw(e,Xw,Sw),G=e=>sw.test(e),Pw=e=>Hw(e,Kw),Fw=e=>Hw(e,Jw),Iw=e=>Hw(e,Uw),Lw=e=>Hw(e,Gw),Rw=e=>Hw(e,Ww),zw=e=>Hw(e,Xw,!0),Bw=e=>Hw(e,Yw,!0),Vw=(e,t,n)=>{let r=ow.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Hw=(e,t,n=!1)=>{let r=sw.exec(e);return r?r[1]?t(r[1]):n:!1},Uw=e=>e===`position`||e===`percentage`,Ww=e=>e===`image`||e===`url`,Gw=e=>e===`length`||e===`size`||e===`bg-size`,Kw=e=>e===`length`,qw=e=>e===`number`,Jw=e=>e===`family-name`,Yw=e=>e===`number`||e===`weight`,Xw=e=>e===`shadow`,Zw=rw(()=>{let e=aw(`color`),t=aw(`font`),n=aw(`text`),r=aw(`font-weight`),i=aw(`tracking`),a=aw(`leading`),o=aw(`breakpoint`),s=aw(`container`),c=aw(`spacing`),l=aw(`radius`),u=aw(`shadow`),d=aw(`inset-shadow`),f=aw(`text-shadow`),p=aw(`drop-shadow`),m=aw(`blur`),h=aw(`perspective`),g=aw(`aspect`),_=aw(`ease`),v=aw(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),G,W],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[G,W,c],T=()=>[mw,`full`,`auto`,...w()],E=()=>[gw,`none`,`subgrid`,G,W],D=()=>[`auto`,{span:[`full`,gw,G,W]},gw,G,W],O=()=>[gw,`auto`,G,W],k=()=>[`auto`,`min`,`max`,`fr`,G,W],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[mw,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],ee=()=>[s,mw,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],P=()=>[mw,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],F=()=>[e,G,W],te=()=>[...b(),Iw,jw,{position:[G,W]}],ne=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],I=()=>[`auto`,`cover`,`contain`,Lw,Ew,{size:[G,W]}],re=()=>[_w,Pw,Dw],ie=()=>[``,`none`,`full`,l,G,W],ae=()=>[``,hw,Pw,Dw],oe=()=>[`solid`,`dashed`,`dotted`,`double`],se=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],L=()=>[hw,_w,Iw,jw],ce=()=>[``,`none`,m,G,W],le=()=>[`none`,hw,G,W],ue=()=>[`none`,hw,G,W],de=()=>[hw,G,W],R=()=>[mw,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[vw],breakpoint:[vw],color:[yw],container:[vw],"drop-shadow":[vw],ease:[`in`,`out`,`in-out`],font:[ww],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[vw],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[vw],shadow:[vw],spacing:[`px`,hw],text:[vw],"text-shadow":[vw],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,mw,W,G,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,G,W]}],"container-named":[Tw],columns:[{columns:[hw,`auto`,W,G,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[gw,`auto`,G,W]}],basis:[{basis:[mw,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[hw,mw,`auto`,`initial`,`none`,W]}],grow:[{grow:[``,hw,G,W]}],shrink:[{shrink:[``,hw,G,W]}],order:[{order:[gw,`first`,`last`,`none`,G,W]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mbs:[{mbs:M()}],mbe:[{mbe:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],"inline-size":[{inline:[`auto`,...ee()]}],"min-inline-size":[{"min-inline":[`auto`,...ee()]}],"max-inline-size":[{"max-inline":[`none`,...ee()]}],"block-size":[{block:[`auto`,...P()]}],"min-block-size":[{"min-block":[`auto`,...P()]}],"max-block-size":[{"max-block":[`none`,...P()]}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,`none`,...N()]}],"font-size":[{text:[`base`,n,Pw,Dw]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,Bw,kw]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,_w,W]}],"font-family":[{font:[Fw,Aw,t]}],"font-features":[{"font-features":[W]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,G,W]}],"line-clamp":[{"line-clamp":[hw,`none`,G,Ow]}],leading:[{leading:[`none`,a,...w()]}],"list-image":[{"list-image":[`none`,G,W]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,G,W]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:F()}],"text-color":[{text:F()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...oe(),`wavy`]}],"text-decoration-thickness":[{decoration:[hw,`from-font`,`auto`,G,Dw]}],"text-decoration-color":[{decoration:F()}],"underline-offset":[{"underline-offset":[hw,`auto`,G,W]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[gw,G,W]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,G,W]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,G,W]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:te()}],"bg-repeat":[{bg:ne()}],"bg-size":[{bg:I()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},gw,G,W],radial:[``,G,W],conic:[``,gw,G,W]},Rw,Mw]}],"bg-color":[{bg:F()}],"gradient-from-pos":[{from:re()}],"gradient-via-pos":[{via:re()}],"gradient-to-pos":[{to:re()}],"gradient-from":[{from:F()}],"gradient-via":[{via:F()}],"gradient-to":[{to:F()}],rounded:[{rounded:ie()}],"rounded-s":[{"rounded-s":ie()}],"rounded-e":[{"rounded-e":ie()}],"rounded-t":[{"rounded-t":ie()}],"rounded-r":[{"rounded-r":ie()}],"rounded-b":[{"rounded-b":ie()}],"rounded-l":[{"rounded-l":ie()}],"rounded-ss":[{"rounded-ss":ie()}],"rounded-se":[{"rounded-se":ie()}],"rounded-ee":[{"rounded-ee":ie()}],"rounded-es":[{"rounded-es":ie()}],"rounded-tl":[{"rounded-tl":ie()}],"rounded-tr":[{"rounded-tr":ie()}],"rounded-br":[{"rounded-br":ie()}],"rounded-bl":[{"rounded-bl":ie()}],"border-w":[{border:ae()}],"border-w-x":[{"border-x":ae()}],"border-w-y":[{"border-y":ae()}],"border-w-s":[{"border-s":ae()}],"border-w-e":[{"border-e":ae()}],"border-w-bs":[{"border-bs":ae()}],"border-w-be":[{"border-be":ae()}],"border-w-t":[{"border-t":ae()}],"border-w-r":[{"border-r":ae()}],"border-w-b":[{"border-b":ae()}],"border-w-l":[{"border-l":ae()}],"divide-x":[{"divide-x":ae()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":ae()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...oe(),`hidden`,`none`]}],"divide-style":[{divide:[...oe(),`hidden`,`none`]}],"border-color":[{border:F()}],"border-color-x":[{"border-x":F()}],"border-color-y":[{"border-y":F()}],"border-color-s":[{"border-s":F()}],"border-color-e":[{"border-e":F()}],"border-color-bs":[{"border-bs":F()}],"border-color-be":[{"border-be":F()}],"border-color-t":[{"border-t":F()}],"border-color-r":[{"border-r":F()}],"border-color-b":[{"border-b":F()}],"border-color-l":[{"border-l":F()}],"divide-color":[{divide:F()}],"outline-style":[{outline:[...oe(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[hw,G,W]}],"outline-w":[{outline:[``,hw,Pw,Dw]}],"outline-color":[{outline:F()}],shadow:[{shadow:[``,`inner`,`none`,u,zw,Nw]}],"shadow-color":[{shadow:F()}],"inset-shadow":[{"inset-shadow":[`none`,d,zw,Nw]}],"inset-shadow-color":[{"inset-shadow":F()}],"ring-w":[{ring:ae()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:F()}],"ring-offset-w":[{"ring-offset":[hw,Dw]}],"ring-offset-color":[{"ring-offset":F()}],"inset-ring-w":[{"inset-ring":ae()}],"inset-ring-color":[{"inset-ring":F()}],"text-shadow":[{"text-shadow":[`none`,f,zw,Nw]}],"text-shadow-color":[{"text-shadow":F()}],opacity:[{opacity:[hw,G,W]}],"mix-blend":[{"mix-blend":[...se(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":se()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[hw]}],"mask-image-linear-from-pos":[{"mask-linear-from":L()}],"mask-image-linear-to-pos":[{"mask-linear-to":L()}],"mask-image-linear-from-color":[{"mask-linear-from":F()}],"mask-image-linear-to-color":[{"mask-linear-to":F()}],"mask-image-t-from-pos":[{"mask-t-from":L()}],"mask-image-t-to-pos":[{"mask-t-to":L()}],"mask-image-t-from-color":[{"mask-t-from":F()}],"mask-image-t-to-color":[{"mask-t-to":F()}],"mask-image-r-from-pos":[{"mask-r-from":L()}],"mask-image-r-to-pos":[{"mask-r-to":L()}],"mask-image-r-from-color":[{"mask-r-from":F()}],"mask-image-r-to-color":[{"mask-r-to":F()}],"mask-image-b-from-pos":[{"mask-b-from":L()}],"mask-image-b-to-pos":[{"mask-b-to":L()}],"mask-image-b-from-color":[{"mask-b-from":F()}],"mask-image-b-to-color":[{"mask-b-to":F()}],"mask-image-l-from-pos":[{"mask-l-from":L()}],"mask-image-l-to-pos":[{"mask-l-to":L()}],"mask-image-l-from-color":[{"mask-l-from":F()}],"mask-image-l-to-color":[{"mask-l-to":F()}],"mask-image-x-from-pos":[{"mask-x-from":L()}],"mask-image-x-to-pos":[{"mask-x-to":L()}],"mask-image-x-from-color":[{"mask-x-from":F()}],"mask-image-x-to-color":[{"mask-x-to":F()}],"mask-image-y-from-pos":[{"mask-y-from":L()}],"mask-image-y-to-pos":[{"mask-y-to":L()}],"mask-image-y-from-color":[{"mask-y-from":F()}],"mask-image-y-to-color":[{"mask-y-to":F()}],"mask-image-radial":[{"mask-radial":[G,W]}],"mask-image-radial-from-pos":[{"mask-radial-from":L()}],"mask-image-radial-to-pos":[{"mask-radial-to":L()}],"mask-image-radial-from-color":[{"mask-radial-from":F()}],"mask-image-radial-to-color":[{"mask-radial-to":F()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[hw]}],"mask-image-conic-from-pos":[{"mask-conic-from":L()}],"mask-image-conic-to-pos":[{"mask-conic-to":L()}],"mask-image-conic-from-color":[{"mask-conic-from":F()}],"mask-image-conic-to-color":[{"mask-conic-to":F()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:te()}],"mask-repeat":[{mask:ne()}],"mask-size":[{mask:I()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,G,W]}],filter:[{filter:[``,`none`,G,W]}],blur:[{blur:ce()}],brightness:[{brightness:[hw,G,W]}],contrast:[{contrast:[hw,G,W]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,zw,Nw]}],"drop-shadow-color":[{"drop-shadow":F()}],grayscale:[{grayscale:[``,hw,G,W]}],"hue-rotate":[{"hue-rotate":[hw,G,W]}],invert:[{invert:[``,hw,G,W]}],saturate:[{saturate:[hw,G,W]}],sepia:[{sepia:[``,hw,G,W]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,G,W]}],"backdrop-blur":[{"backdrop-blur":ce()}],"backdrop-brightness":[{"backdrop-brightness":[hw,G,W]}],"backdrop-contrast":[{"backdrop-contrast":[hw,G,W]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,hw,G,W]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[hw,G,W]}],"backdrop-invert":[{"backdrop-invert":[``,hw,G,W]}],"backdrop-opacity":[{"backdrop-opacity":[hw,G,W]}],"backdrop-saturate":[{"backdrop-saturate":[hw,G,W]}],"backdrop-sepia":[{"backdrop-sepia":[``,hw,G,W]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,G,W]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[hw,`initial`,G,W]}],ease:[{ease:[`linear`,`initial`,_,G,W]}],delay:[{delay:[hw,G,W]}],animate:[{animate:[`none`,v,G,W]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,G,W]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:le()}],"rotate-x":[{"rotate-x":le()}],"rotate-y":[{"rotate-y":le()}],"rotate-z":[{"rotate-z":le()}],scale:[{scale:ue()}],"scale-x":[{"scale-x":ue()}],"scale-y":[{"scale-y":ue()}],"scale-z":[{"scale-z":ue()}],"scale-3d":[`scale-3d`],skew:[{skew:de()}],"skew-x":[{"skew-x":de()}],"skew-y":[{"skew-y":de()}],transform:[{transform:[G,W,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:R()}],"translate-x":[{"translate-x":R()}],"translate-y":[{"translate-y":R()}],"translate-z":[{"translate-z":R()}],"translate-none":[`translate-none`],zoom:[{zoom:[gw,G,W]}],accent:[{accent:F()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:F()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,G,W]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":F()}],"scrollbar-track-color":[{"scrollbar-track":F()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,G,W]}],fill:[{fill:[`none`,...F()]}],"stroke-w":[{stroke:[hw,Pw,Dw,Ow]}],stroke:[{stroke:[`none`,...F()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`start`,`end`,`right`,`left`],"inset-y":[`inset-bs`,`inset-be`,`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`ps`,`pe`,`pr`,`pl`],py:[`pbs`,`pbe`,`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`ms`,`me`,`mr`,`ml`],my:[`mbs`,`mbe`,`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-s`,`border-w-e`,`border-w-r`,`border-w-l`],"border-w-y":[`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-s`,`border-color-e`,`border-color-r`,`border-color-l`],"border-color-y":[`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-ms`,`scroll-me`,`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-ps`,`scroll-pe`,`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function K(...e){return Zw(TC(e))}function Qw({menu:e,field:t,busy:n,onClose:r,onEditField:i,onDuplicateField:a,onRunAIBatch:o,onDownloadAllFiles:s,onAddColumnToChat:c,onInsertField:l,onAddFilterForField:u,onAddSortForField:d,onSetGroupField:f,onFreezeUpTo:p,onHideField:m,onDeleteField:h}){let{t:g}=U(`table`),_=(0,j.useRef)(null);if((0,j.useEffect)(()=>{if(!e)return;function t(e){_.current?.contains(e.target)||r()}function n(e){e.key===`Escape`&&(e.preventDefault(),r())}return window.addEventListener(`mousedown`,t),window.addEventListener(`keydown`,n,!0),window.addEventListener(`scroll`,r,!0),()=>{window.removeEventListener(`mousedown`,t),window.removeEventListener(`keydown`,n,!0),window.removeEventListener(`scroll`,r,!0)}},[e,r]),!e||!t)return null;let v=!!t.ai_config?.enabled,y=t.type===`attachment`,b=!!t.is_primary,x=typeof window>`u`?e.x:Math.min(e.x,Math.max(12,window.innerWidth-260)),S=typeof window>`u`?e.y:Math.min(e.y,Math.max(12,window.innerHeight-460));function C(e){r(),e()}return(0,I.jsxs)(`div`,{ref:_,className:`data-inline-record-menu data-inline-column-menu`,style:{left:x,top:S},onClick:e=>e.stopPropagation(),onContextMenu:e=>e.preventDefault(),"data-field-id":t.id,"data-testid":`ktable-column-header-menu`,children:[(0,I.jsxs)(`div`,{className:`data-inline-record-menu-section`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,disabled:n,onClick:()=>C(()=>i(t)),children:[(0,I.jsx)(os,{className:`size-4`}),g(`columnMenu.editField`)]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,disabled:n,onClick:()=>C(()=>a(t)),children:[(0,I.jsx)(Ca,{className:`size-4`}),g(`columnMenu.duplicateField`)]})]}),v||y?(0,I.jsxs)(`div`,{className:`data-inline-record-menu-section`,children:[v&&o?(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,disabled:n,onClick:()=>C(()=>o(t)),children:[(0,I.jsx)(Ws,{className:`size-4`}),g(`columnMenu.generate`)]}):null,y?(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,disabled:n,onClick:()=>C(()=>s(t)),children:[(0,I.jsx)(Ma,{className:`size-4`}),g(`columnMenu.downloadAllFiles`)]}):null,v?(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,disabled:n,onClick:()=>C(()=>c(t)),children:[(0,I.jsx)(Ps,{className:`size-4`}),g(`columnMenu.addToChat`)]}):null]}):null,(0,I.jsxs)(`div`,{className:`data-inline-record-menu-section`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,disabled:n,onClick:()=>C(()=>l(`before`,t)),children:[(0,I.jsx)(Ni,{className:`size-4`}),g(`columnMenu.insertLeft`)]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,disabled:n,onClick:()=>C(()=>l(`after`,t)),children:[(0,I.jsx)(Ii,{className:`size-4`}),g(`columnMenu.insertRight`)]})]}),(0,I.jsxs)(`div`,{className:`data-inline-record-menu-section`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,disabled:n,onClick:()=>C(()=>u(t)),children:[(0,I.jsx)($a,{className:`size-4`}),g(`columnMenu.filterByField`)]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,disabled:n,onClick:()=>C(()=>d(t)),children:[(0,I.jsx)(Ai,{className:`size-4`}),g(`columnMenu.sortByField`)]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,disabled:n,onClick:()=>C(()=>f(t)),children:[(0,I.jsx)(oo,{className:`size-4`}),g(`columnMenu.groupByField`)]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,disabled:n,onClick:()=>C(()=>p(t)),children:[(0,I.jsx)(us,{className:`size-4`}),g(`columnMenu.freezeUpToField`)]})]}),(0,I.jsxs)(`div`,{className:`data-inline-record-menu-section`,children:[(0,I.jsxs)(`button`,{type:`button`,className:K(`data-inline-record-menu-item`,b&&`is-disabled`),disabled:n||b,onClick:()=>C(()=>m(t)),children:[(0,I.jsx)(La,{className:`size-4`}),g(`columnMenu.hideField`)]}),(0,I.jsxs)(`button`,{type:`button`,className:K(`data-inline-record-menu-item is-danger`,b&&`is-disabled`),disabled:n||b,onClick:()=>C(()=>h(t)),children:[(0,I.jsx)(hc,{className:`size-4`}),g(`columnMenu.deleteField`)]})]})]})}var $w=0;function eT(e){return $w+=1,`${e}_${Date.now().toString(36)}_${$w}`}function tT(){return{id:eT(`cond`),kind:`condition`,field_name:``,operator:`is`,value:null}}function nT(e=`and`){return{id:eT(`grp`),kind:`group`,conjunction:e,children:[tT()]}}var rT=new Set([`is`,`isNot`,`isEmpty`,`isNotEmpty`,`contains`,`doesNotContain`,`isGreater`,`isGreaterEqual`,`isLess`,`isLessEqual`,`isAnyOf`,`isNoneOf`,`hasAnyOf`,`hasAllOf`,`isExactly`,`isNotExactly`,`hasNoneOf`,`isWithIn`,`isBefore`,`isAfter`,`isOnOrBefore`,`isOnOrAfter`]),iT=[`isEmpty`,`isNotEmpty`];function aT(e){if(!e)return!1;if(e.kind===`condition`){if(iT.includes(e.operator))return!!e.field_name;let t=e.value;return t==null||typeof t==`string`&&t.trim()===``||Array.isArray(t)&&t.length===0?!1:!!e.field_name}return e.children.some(e=>aT(e))}function oT(e){return e?e.kind===`condition`?+!!aT(e):e.children.reduce((e,t)=>e+oT(t),0):0}function sT(e){return e===`and`||e===`or`}function cT(e){if(!e||typeof e!=`object`)return null;let t=e;if(t.kind===`condition`){if(typeof t.id!=`string`||typeof t.field_name!=`string`||typeof t.operator!=`string`||!rT.has(t.operator))return null;let e=t.value;return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||Array.isArray(e)&&e.every(e=>typeof e==`string`)?{id:t.id,kind:`condition`,field_name:t.field_name,operator:t.operator,value:e}:null}if(t.kind===`group`){if(typeof t.id!=`string`||!sT(t.conjunction)||!Array.isArray(t.children))return null;let e=[];for(let n of t.children){let t=cT(n);if(!t)return null;e.push(t)}return{id:t.id,kind:`group`,conjunction:t.conjunction,children:e}}return null}function lT(e){let t=cT(e);return!t||t.kind!==`group`?null:t}var uT=[{value:`text`,label:`Text`,labelKey:`fieldTypes.text`},{value:`long_text`,label:`Long text`,labelKey:`fieldTypes.longText`},{value:`number`,label:`Number`,labelKey:`fieldTypes.number`},{value:`date`,label:`Date`,labelKey:`fieldTypes.date`},{value:`datetime`,label:`Datetime`,labelKey:`fieldTypes.datetime`},{value:`single_select`,label:`Select`,labelKey:`fieldTypes.singleSelect`},{value:`multi_select`,label:`Multi select`,labelKey:`fieldTypes.multiSelect`},{value:`checkbox`,label:`Checkbox`,labelKey:`fieldTypes.checkbox`},{value:`rating`,label:`Rating`,labelKey:`fieldTypes.rating`},{value:`url`,label:`URL`,labelKey:`fieldTypes.url`},{value:`attachment`,label:`Attachment`,labelKey:`fieldTypes.attachment`},{value:`document_link`,label:`Document`,labelKey:`fieldTypes.documentLink`},{value:`user`,label:`User`,labelKey:`fieldTypes.user`},{value:`link_to_record`,label:`Link to record`,labelKey:`fieldTypes.linkToRecord`},{value:`lookup`,label:`Lookup`,labelKey:`fieldTypes.lookup`},{value:`rollup`,label:`Rollup`,labelKey:`fieldTypes.rollup`},{value:`formula`,label:`Formula`,labelKey:`fieldTypes.formula`},{value:`button`,label:`Button`,labelKey:`fieldTypes.button`},{value:`auto_number`,label:`Auto number`,labelKey:`fieldTypes.autoNumber`},{value:`created_time`,label:`Created time`,labelKey:`fieldTypes.createdTime`},{value:`last_modified_time`,label:`Last modified time`,labelKey:`fieldTypes.lastModifiedTime`},{value:`created_by`,label:`Created by`,labelKey:`fieldTypes.createdBy`},{value:`last_modified_by`,label:`Last modified by`,labelKey:`fieldTypes.lastModifiedBy`}],dT=[`green`,`blue`,`yellow`,`red`,`purple`,`gray`],fT=[{value:`slate`,label:`Slate`,labelKey:`colorTones.slate`},{value:`amber`,label:`Amber`,labelKey:`colorTones.amber`},{value:`sky`,label:`Sky`,labelKey:`colorTones.sky`},{value:`violet`,label:`Violet`,labelKey:`colorTones.violet`},{value:`emerald`,label:`Emerald`,labelKey:`colorTones.emerald`},{value:`cyan`,label:`Cyan`,labelKey:`colorTones.cyan`},{value:`blue`,label:`Blue`,labelKey:`colorTones.blue`},{value:`rose`,label:`Rose`,labelKey:`colorTones.rose`}],pT={text:`slate`,long_text:`slate`,number:`amber`,date:`sky`,datetime:`sky`,single_select:`violet`,multi_select:`violet`,checkbox:`emerald`,url:`cyan`,document_link:`blue`},mT=[{type:`grid`,label:`Grid view`,labelKey:`viewTypes.grid`},{type:`gallery`,label:`Gallery view`,labelKey:`viewTypes.gallery`},{type:`kanban`,label:`Kanban view`,labelKey:`viewTypes.kanban`},{type:`calendar`,label:`Calendar view`,labelKey:`viewTypes.calendar`}];function hT(e){return mT.find(t=>t.type===e)?.labelKey||`viewTypes.fallback`}function gT(e){let t=(e.title||``).trim();return e.type===`grid`&&[`all tasks`,`all messages`].includes(t.toLowerCase())?mT.find(e=>e.type===`grid`)?.label||`Grid view`:t}function _T(e){return mT.find(t=>t.type===e)?.label||`View`}function vT(e,t=`size-4`){return e===`kanban`?(0,I.jsx)(Qs,{className:t}):e===`calendar`?(0,I.jsx)(Zi,{className:t}):e===`gallery`?(0,I.jsx)(eo,{className:t}):(0,I.jsx)(cc,{className:t})}function yT(e,t){let n=_T(e),r=t.filter(t=>t.type===e).length;return r>0?`${n} ${r+1}`:n}function bT(e){try{let t=JSON.parse(e);return Number(t.data_document_id||t.id||0)||null}catch{return null}}function xT(e){if(Array.isArray(e))return e.map(e=>xT(e)).filter(Boolean).join(`, `);if(e&&typeof e==`object`){let t=e;return String(t.name||t.title||t.display||t.url||t.href||t.row_key||``)}return e==null?``:String(e)}function ST(e){if(typeof e==`string`){let t=e.trim();if(!t)return``;if(/^(https?:|data:image\/|blob:|file:)/i.test(t)||/\.(png|jpe?g|gif|webp|avif|svg)(\?.*)?$/i.test(t))return t;try{return ST(JSON.parse(t))}catch{return``}}if(Array.isArray(e))for(let t of e){let e=ST(t);if(e)return e}if(e&&typeof e==`object`){let t=e,n=typeof t.mimeType==`string`?t.mimeType:typeof t.type==`string`?t.type:``;if(_C(t.url)&&/^image\//i.test(n))return String(t.url).trim();for(let e of[`url`,`src`,`href`,`download_url`,`thumbnail`,`thumb`]){let n=ST(t[e]);if(n)return n}}return``}function CT(e){try{let t=new URL(e,`http://kition.local`);return decodeURIComponent(t.pathname.split(`/`).filter(Boolean).pop()||``)||`attachment`}catch{return decodeURIComponent(e.split(/[/?#]/)[0]?.split(`/`).filter(Boolean).pop()||``)||`attachment`}}function wT(e){let t=typeof e==`string`?e.trim():xT(e).trim();return t?/^https?:\/\//i.test(t)?{href:t,label:t}:/^[a-z0-9][a-z0-9-]*(?:\.[a-z0-9-]+)+(?:[/?#].*)?$/i.test(t)?{href:`https://${t}`,label:t}:null:null}function TT(e){if(e==null||e===``)return[];if(Array.isArray(e))return e.flatMap(e=>TT(e));if(typeof e==`string`){let t=e.trim();if(!t)return[];try{return TT(JSON.parse(t))}catch{return[{name:CT(t),url:t}]}}if(e&&typeof e==`object`){let t=e,n=ST(t)||String(t.url||t.src||t.href||``).trim();if(!n)return[];let r=typeof t.mimeType==`string`?t.mimeType:typeof t.type==`string`?t.type:void 0,i=typeof t.sizeBytes==`number`?t.sizeBytes:typeof t.size==`number`?t.size:void 0;return[{name:String(t.name||t.filename||t.file_name||CT(n)),url:n,mimeType:r,sizeBytes:i}]}return[]}function ET(e){let t=[];return e&&(Array.from(e.items||[]).forEach(e=>{if(e.kind===`file`){let n=e.getAsFile();n&&t.push(n)}}),Array.from(e.files||[]).forEach(e=>{t.some(t=>t.name===e.name&&t.size===e.size&&t.type===e.type)||t.push(e)})),t}function DT(e,t){if(e.type===`checkbox`)return!!t;if(e.type===`attachment`)return TT(t);if(e.type===`number`){if(typeof t!=`string`||!t.trim())return null;let e=Number(t);return Number.isFinite(e)?e:null}return e.type===`multi_select`?typeof t==`string`?t.split(`,`).map(e=>e.trim()).filter(Boolean):[]:typeof t==`boolean`?String(t):t}function OT(e){let t=e.find(e=>e.is_primary)||e[0];return t?{[t.name]:`New page`}:{}}function kT(e){return e.type===`number`||e.type===`auto_number`?(0,I.jsx)(co,{className:`size-4`}):e.type===`date`||e.type===`datetime`||e.type===`created_time`||e.type===`last_modified_time`?(0,I.jsx)(Zi,{className:`size-4`}):e.type===`url`||e.type===`document_link`||e.type===`link_to_record`?(0,I.jsx)(wo,{className:`size-4`}):e.type===`checkbox`?(0,I.jsx)(ea,{className:`size-4`}):e.type===`long_text`?(0,I.jsx)(Wa,{className:`size-4`}):e.type===`rating`?(0,I.jsx)($s,{className:`size-4`}):e.type===`user`||e.type===`created_by`||e.type===`last_modified_by`?(0,I.jsx)(Cc,{className:`size-4`}):e.type===`button`?(0,I.jsx)(ca,{className:`size-4`}):e.type===`lookup`||e.type===`rollup`?(0,I.jsx)(Mc,{className:`size-4`}):(0,I.jsx)(`span`,{className:`data-inline-field-type-aa`,children:`Aa`})}function AT(e){switch(e){case`text`:case`long_text`:case`url`:case`single_select`:return{asc:`sortDirection.textAsc`,desc:`sortDirection.textDesc`};case`number`:case`rating`:case`auto_number`:return{asc:`sortDirection.numberAsc`,desc:`sortDirection.numberDesc`};case`date`:case`datetime`:case`created_time`:case`last_modified_time`:return{asc:`sortDirection.dateAsc`,desc:`sortDirection.dateDesc`};case`checkbox`:return{asc:`sortDirection.checkboxAsc`,desc:`sortDirection.checkboxDesc`};default:return{asc:`sortDirection.ascending`,desc:`sortDirection.descending`}}}function jT(e){let t=0;for(let n of String(e??``))t=(t+n.charCodeAt(0))%dT.length;return dT[t]}function MT(e){let t=e.options?.choices;if(!Array.isArray(t))return[];let n=new Set,r=[];for(let e of t){let t=xT(e).trim();t&&!n.has(t)&&(n.add(t),r.push(t))}return r}function NT(e){let t=e.options?.choice_tones;return!t||typeof t!=`object`||Array.isArray(t)?{}:t}function PT(e){return dT.some(t=>t===e)?e:``}function FT(e,t){return PT(NT(e)[t]||``)||jT(t)}function IT(e){let t=typeof e.options?.column_tone==`string`?e.options.column_tone:``;return fT.some(e=>e.value===t)?t:pT[e.type]||`slate`}function LT(e){let t=e.replace(/\r/g,``).replace(/\n$/,``);return(t.includes(` `)?` `:`,`)==`,`?t.split(`
55
- `).filter(e=>e.length>0).map(RT):t.replace(/\r/g,``).split(`
56
- `).filter(e=>e.length>0).map(e=>e.split(` `).map(e=>e.trim()))}function RT(e){let t=[],n=``,r=!1;for(let i=0;i<e.length;i+=1){let a=e[i];a===`"`&&e[i+1]===`"`?(n+=`"`,i+=1):a===`"`?r=!r:a===`,`&&!r?(t.push(n.trim()),n=``):n+=a}return t.push(n.trim()),t}function zT(e,t,n){let r=e.findIndex(e=>e.id===t),i=e.findIndex(e=>e.id===n);if(r<0||i<0||r===i)return e;let a=[...e],[o]=a.splice(r,1);return a.splice(i,0,o),a}function BT(e){return e?.config||{}}function VT(e,t){return e.type===`checkbox`?t===`true`:t===`Empty`?``:t}function HT(){let[e,t]=(0,j.useState)(()=>typeof document>`u`?!1:document.documentElement.classList.contains(`dark`));return(0,j.useEffect)(()=>{if(typeof document>`u`)return;let e=document.documentElement,n=()=>t(e.classList.contains(`dark`));n();let r=new MutationObserver(n);return r.observe(e,{attributes:!0,attributeFilter:[`class`]}),()=>r.disconnect()},[]),e}var UT={status:`idle`},WT=new Map,GT=new Map,KT=new Set,qT=0;function JT(e){qT+=1;let t=GT.get(e);if(t)for(let e of t)e();for(let e of KT)e()}function YT(e,t,n){return`${e}:${t}:${n}`}var XT={get(e){return WT.get(e)??UT},start(e,t,n){WT.set(e,{status:`pending`,action:t,startedAt:Date.now(),controller:n}),JT(e)},complete(e){WT.delete(e),JT(e)},fail(e,t){WT.set(e,{status:`error`,message:t,failedAt:Date.now()}),JT(e)},cancel(e){let t=WT.get(e);t?.status===`pending`&&t.controller.abort(),WT.delete(e),JT(e)},subscribe(e,t){let n=GT.get(e);return n||(n=new Set,GT.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&GT.delete(e)}},subscribeAll(e){return KT.add(e),()=>{KT.delete(e)}},getVersion(){return qT},pendingKeys(){return Array.from(WT.entries()).filter(([,e])=>e.status===`pending`).map(([e])=>e)},_resetForTests(){WT.clear(),GT.clear(),KT.clear(),qT=0}};typeof window<`u`&&window.addEventListener(`kition:workspace-reload`,()=>{let e=Array.from(WT.keys());for(let t of e){let e=WT.get(t);e?.status===`pending`&&e.controller.abort(),WT.delete(t),JT(t)}});function ZT(e){return(0,j.useSyncExternalStore)(t=>XT.subscribe(e,t),()=>XT.get(e),()=>UT)}var QT=function(e){return e[e.Record=0]=`Record`,e[e.Group=1]=`Group`,e[e.Append=2]=`Append`,e}({}),$T=`KTRW`,eE=1,tE=16,nE=class extends Error{},rE=class e{epoch;kinds;values;byRecord=null;constructor(e,t,n){this.epoch=e,this.kinds=t,this.values=n}static decode(t){if(t.byteLength<tE||String.fromCharCode(t[0],t[1],t[2],t[3])!==$T)throw new nE(`not grid rows`);let n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=n.getUint16(4,!0);if(r!==eE)throw new nE(`grid rows version ${r}; this build reads version ${eE}`);let i=n.getUint32(8,!0),a=n.getUint32(12,!0),o=tE+Math.ceil(a/8)*8;if(t.byteLength!==o+a*8)throw new nE(`the grid rows have an invalid length`);let s=t.slice(tE,tE+a);for(let e of s)if(e>2)throw new nE(`the grid rows have an invalid kind`);let c=new Float64Array(a);for(let e=0;e<a;e+=1)c[e]=n.getFloat64(o+e*8,!0);return new e(i,s,c)}static of(t,n){return new e(t,Uint8Array.from(n.map(([e])=>e)),Float64Array.from(n.map(([,e])=>e)))}get count(){return this.kinds.length}kind(e){return e>=0&&e<this.kinds.length?this.kinds[e]:null}isRecord(e){return this.kind(e)===0}recordId(e){return this.kind(e)===0?this.values[e]:null}groupIndex(e){return this.kind(e)===1?this.values[e]:null}appendAnchor(e){if(this.kind(e)!==2)return null;let t=this.values[e];return t<0?null:t}rowOf(e){if(!this.byRecord){this.byRecord=new Map;for(let e=0;e<this.kinds.length;e+=1)this.kinds[e]===0&&this.byRecord.set(this.values[e],e)}return this.byRecord.get(e)??-1}recordFrom(e,t){for(let n=e;n>=0&&n<this.kinds.length;n+=t)if(this.kinds[n]===0)return n;return-1}get firstRecord(){return this.recordFrom(0,1)}get lastRecord(){return this.recordFrom(this.kinds.length-1,-1)}},iE=/^kition-blob:([0-9a-f]{64})$/,aE=384;function oE(e,t){let{skeleton:n,overlay:r,groups:i,...a}=e;return{axes:a,skeleton:n,overlay:r,rows:rE.decode(t),groups:i}}function sE(e){return iE.exec(e.trim())?.[1]??null}function cE(e,t,n){let r=Math.min(1,n/Math.max(e,t,1));return e>0&&t>0&&r<1?{resizeWidth:Math.max(1,Math.round(e*r)),resizeHeight:Math.max(1,Math.round(t*r)),resizeQuality:`high`}:{}}async function lE(e,t,n,r,i=aE){let a=null;try{a=await createImageBitmap(e,cE(t,n,i))}catch{return uE(await r(new Uint8Array(await e.arrayBuffer()),i))}let o=cE(a.width,a.height,i);if(!o.resizeWidth)return a;let s=await createImageBitmap(a,o);return a.close(),s}function uE(e){if(e.byteLength<=8)return null;let t=new DataView(e.buffer,e.byteOffset,8),n=t.getUint32(0,!0),r=t.getUint32(4,!0),i=new Uint8ClampedArray(e.buffer,e.byteOffset+8,n*r*4);return createImageBitmap(new ImageData(i,n,r))}function dE(e,t,n){let r={...n};return{get target(){return r},update(e){r={...r,...e}},async open(){let{axis:t,...n}=r;if(!t)throw Error(`the editor has not arranged the view yet`);let{axes:i,rows:a}=await e.grid.layout({...n,axis:t});return oE(i,a)},bands(t,n,r,i,a){let o=new Uint32Array(n.length*3);return n.forEach((e,t)=>o.set([e.layer,e.colBand,e.rowBand],t*3)),e.grid.bands(t,o,r,i,a)},async image(n,r,i){let a=sE(n),o=null;if(a&&e.attachments){let n=await e.attachments.read({documentId:t,hash:a});o=new Blob([n.data],{type:n.mimeType})}else n.startsWith(`data:`)&&(o=await(await fetch(n)).blob());return o?lE(o,r,i,e.grid.picture):null},fonts:e.grid.fonts,opticalSizing:e.grid.opticalSizing}}function fE(e){let{dataSource:t,documentId:n,tableId:r,viewId:i}=e,a=e.writing??(e=>e()),o=t.attachments;return{tableId:r,viewId:i,field:t=>e.fields().find(e=>e.id===t),fields:()=>[...e.fields()].sort((e,t)=>e.order-t.order),records:(e,n)=>e.length?t.grid.records({tableId:r,ids:e,...n?{fields:n}:{}}):Promise.resolve([]),async transact(e){e.length&&await a(()=>t.transact({documentId:n,ops:e}))},async update(e,i){await a(()=>t.records.update({documentId:n,tableId:r,recordId:e,values:i}))},async patchFieldWidth(e,o){i!=null&&await a(()=>t.views.patchField({documentId:n,tableId:r,viewId:i,fieldId:e,width:o}))},async setFrozen(t){e.setFrozen(t)},async blob(e){if(!o)return null;try{let t=await o.read({documentId:n,hash:e});return{bytes:t.data,mimeType:t.mimeType}}catch{return null}},async clear(e,n){await a(()=>t.grid.clear({tableId:r,ids:e,values:n}))},upload:e.upload}}var pE=/^(\d{4})-(\d{2})-(\d{2})$/,mE=[`year_month_day_slash`,`year_month_day_time_slash`,`year_month_day_time_zone_slash`,`year_month_day_dash`,`year_month_day_time_dash`,`year_month_day_time_zone_dash`,`month_day_dash`,`month_day_year_slash`,`day_month_year_slash`],hE=new Set(mE);function gE(e){return String(e).padStart(2,`0`)}function _E(e){let t=pE.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]),i=Number(t[3]),a=new Date(n,r-1,i);return a.getFullYear()!==n||a.getMonth()!==r-1||a.getDate()!==i?null:a}function vE(e){return e===`date`?`year_month_day_slash`:`year_month_day_time_slash`}function yE(e){let t=e.options?.date_format;return typeof t==`string`&&hE.has(t)?t:vE(e.type)}function bE(e,t){if(e.type===`date`&&pE.test(t))return _E(t);let n=new Date(t);return Number.isNaN(n.getTime())?null:n}function xE(e){let t=-e.getTimezoneOffset(),n=t>=0?`+`:`-`,r=Math.abs(t),i=Math.floor(r/60),a=r%60;return`GMT${n}${i}${a?`:${gE(a)}`:``}`}function SE(e,t){let n=String(e.getFullYear()),r=gE(e.getMonth()+1),i=gE(e.getDate()),a=`${gE(e.getHours())}:${gE(e.getMinutes())}`;switch(t){case`year_month_day_time_slash`:return`${n}/${r}/${i} ${a}`;case`year_month_day_time_zone_slash`:return`${n}/${r}/${i} ${a} (${xE(e)})`;case`year_month_day_dash`:return`${n}-${r}-${i}`;case`year_month_day_time_dash`:return`${n}-${r}-${i} ${a}`;case`year_month_day_time_zone_dash`:return`${n}-${r}-${i} ${a} (${xE(e)})`;case`month_day_dash`:return`${r}-${i}`;case`month_day_year_slash`:return`${r}/${i}/${n}`;case`day_month_year_slash`:return`${i}/${r}/${n}`;default:return`${n}/${r}/${i}`}}function CE(e,t){let n=xT(t);if(!n)return``;if(e.type!==`date`&&e.type!==`datetime`&&e.type!==`created_time`&&e.type!==`last_modified_time`)return n;let r=bE(e,n);return r?SE(r,yE(e)):n}function wE(e,t){let n=xT(t);if(!n)return``;if(e===`date`&&pE.test(n))return _E(n)?n:``;let r=new Date(n);if(Number.isNaN(r.getTime()))return``;let i=`${r.getFullYear()}-${gE(r.getMonth()+1)}-${gE(r.getDate())}`;return e===`date`?i:`${i}T${gE(r.getHours())}:${gE(r.getMinutes())}:${gE(r.getSeconds())}`}function TE(e,t){if(!t||e===`date`)return t;let n=new Date(t);return Number.isNaN(n.getTime())?t:n.toISOString()}var EE=Array.from({length:48},(e,t)=>`${String(Math.floor(t/2)).padStart(2,`0`)}:${t%2?`30`:`00`}`),DE=e=>String(e).padStart(2,`0`);function OE(e){let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e),n=t?new Date(Number(t[1]),Number(t[2])-1,Number(t[3])):new Date(e);return Number.isNaN(n.getTime())?null:n}var kE=e=>`${e.getFullYear()}-${DE(e.getMonth()+1)}-${DE(e.getDate())}`,AE=(e,t)=>kE(e)===kE(t);function jE(e){let t=new Date(e.getFullYear(),e.getMonth(),1);return t.setDate(1-t.getDay()),Array.from({length:42},(e,n)=>new Date(t.getFullYear(),t.getMonth(),t.getDate()+n))}function ME(e,t){return TE(e,e===`date`?kE(t):`${kE(t)}T${DE(t.getHours())}:${DE(t.getMinutes())}:${DE(t.getSeconds())}`)}function NE({popup:e,locale:t,style:n}){let{t:r}=U(`table`),i=e.field.type===`date`?`date`:`datetime-local`,a=wE(i,e.value),o=(0,j.useMemo)(()=>OE(a),[a]),s=(0,j.useMemo)(()=>new Date,[]),[c,l]=(0,j.useState)(`date`),[u,d]=(0,j.useState)(()=>o??s),f=(0,j.useRef)(null),p=a.slice(0,10),m=a.includes(`T`)?a.slice(11,16):``,h=(0,j.useMemo)(()=>!m||EE.includes(m)?EE:[...EE,m].sort(),[m]),g=(0,j.useMemo)(()=>Array.from({length:7},(e,n)=>new Intl.DateTimeFormat(t,{weekday:`narrow`}).format(new Date(2026,0,4+n))),[t]),_=(0,j.useMemo)(()=>new Intl.DateTimeFormat(t,{year:`numeric`,month:`long`}).format(u),[t,u]);(0,j.useEffect)(()=>{c===`time`&&f.current?.scrollIntoView?.({block:`center`})},[c]);let v=t=>{l(null),e.commit(t===``?null:t)},y=e=>{let t=o??s,n=i===`datetime-local`;v(ME(i,new Date(e.getFullYear(),e.getMonth(),e.getDate(),n?t.getHours():0,n?t.getMinutes():0,n?t.getSeconds():0)))},b=e=>{let[t,n]=e.split(`:`).map(Number),r=new Date(o??s);r.setHours(t,n,0,0),v(ME(`datetime-local`,r))},x=(0,j.useRef)(null);return(0,j.useEffect)(()=>{let t=t=>{t.key===`Escape`&&(t.preventDefault(),e.cancel())},n=t=>{let n=t.target instanceof Element?t.target:null;n&&(x.current?.contains(n)||n.closest(`[data-testid="table-date-calendar"], [data-testid="table-date-time-menu"]`))||e.cancel()};return document.addEventListener(`keydown`,t,!0),document.addEventListener(`pointerdown`,n,!0),()=>{document.removeEventListener(`keydown`,t,!0),document.removeEventListener(`pointerdown`,n,!0)}},[e]),(0,I.jsxs)(`div`,{ref:x,style:n,"data-testid":`table-date-cell-editor`,className:`flex items-center overflow-hidden rounded-[2px] border-2 border-primary bg-background text-[13px] text-foreground`,children:[(0,I.jsxs)(c_,{open:c===`date`,children:[(0,I.jsx)(l_,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,"data-testid":`table-date-trigger`,onClick:()=>l(`date`),className:K(`flex h-full min-w-0 flex-1 cursor-pointer items-center gap-1.5 px-2 text-left outline-none hover:bg-accent/50`,c===`date`&&`bg-accent/45`),children:[(0,I.jsx)(Zi,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,I.jsx)(`span`,{className:K(`truncate tabular-nums`,!p&&`text-muted-foreground`),children:p||`YYYY-MM-DD`})]})}),(0,I.jsxs)(u_,{align:`start`,side:`bottom`,sideOffset:4,collisionPadding:8,"data-testid":`table-date-calendar`,className:`!w-[282px] rounded-lg border border-border bg-popover p-0 shadow-floating`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between px-3 pb-2 pt-3`,children:[(0,I.jsx)(`span`,{className:`text-sm font-semibold text-foreground`,children:_}),(0,I.jsx)(`div`,{className:`flex items-center gap-1`,children:[[-1,`datePicker.previousMonth`,na],[1,`datePicker.nextMonth`,ra]].map(([e,t,n])=>(0,I.jsx)(`button`,{type:`button`,"aria-label":r(t),onClick:()=>d(t=>new Date(t.getFullYear(),t.getMonth()+e,1)),className:`grid size-7 cursor-pointer place-items-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,I.jsx)(n,{className:`size-4`})},e))})]}),(0,I.jsx)(`div`,{className:`grid grid-cols-7 px-3 pb-1 text-center text-[11px] font-medium text-muted-foreground`,children:g.map((e,t)=>(0,I.jsx)(`span`,{children:e},t))}),(0,I.jsx)(`div`,{className:`grid grid-cols-7 gap-y-1 px-3 pb-3`,children:jE(u).map(e=>{let t=o!=null&&AE(e,o),n=AE(e,s);return(0,I.jsx)(`button`,{type:`button`,"data-date":kE(e),onPointerDown:t=>{t.preventDefault(),y(e)},onClick:t=>{t.detail===0&&y(e)},className:K(`mx-auto grid size-8 cursor-pointer place-items-center rounded-full text-xs tabular-nums`,e.getMonth()===u.getMonth()?`text-foreground`:`text-muted-foreground/45`,!t&&`hover:bg-accent`,n&&!t&&`text-primary ring-1 ring-inset ring-primary/70`,t&&`bg-primary font-semibold text-primary-foreground shadow-sm hover:bg-primary/90`),children:e.getDate()},kE(e))})}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border px-3 py-2`,children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>v(``),className:`cursor-pointer rounded-md px-2 py-1 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground`,children:r(`datePicker.clear`)}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>y(new Date),className:`cursor-pointer rounded-md px-2 py-1 text-xs font-semibold text-primary hover:bg-primary/10`,children:r(`datePicker.today`)})]})]})]}),i===`datetime-local`?(0,I.jsxs)(c_,{open:c===`time`,children:[(0,I.jsx)(l_,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,"data-testid":`table-date-time-trigger`,onClick:()=>l(`time`),className:K(`flex h-full w-[78px] shrink-0 cursor-pointer items-center gap-1 border-l border-border px-2 outline-none hover:bg-accent/50`,c===`time`&&`bg-accent/45`),children:[(0,I.jsx)(_a,{className:`size-3.5 shrink-0 text-muted-foreground`}),(0,I.jsx)(`span`,{className:`tabular-nums`,children:m||`00:00`})]})}),(0,I.jsx)(u_,{align:`start`,side:`bottom`,sideOffset:4,collisionPadding:8,"data-testid":`table-date-time-menu`,className:`max-h-[240px] !w-[92px] !overflow-y-auto rounded-lg border border-border bg-popover p-1 shadow-floating`,onOpenAutoFocus:e=>e.preventDefault(),children:h.map(e=>(0,I.jsx)(`button`,{ref:e===m?f:void 0,type:`button`,onPointerDown:t=>{t.preventDefault(),b(e)},onClick:t=>{t.detail===0&&b(e)},className:K(`flex h-8 w-full cursor-pointer items-center justify-center rounded-md text-xs tabular-nums`,e===m?`bg-primary font-semibold text-primary-foreground`:`text-foreground hover:bg-accent`),children:e},e))})]}):null]})}function PE(e){return Array.isArray(e)?e.map(e=>String(e)).filter(Boolean):e==null||e===``?[]:[String(e)]}function FE({popup:e,style:t}){let{t:n}=U(`table`),r=e.field.type===`multi_select`,i=(0,j.useMemo)(()=>MT(e.field),[e.field]),[a,o]=(0,j.useState)(()=>PE(e.value)),[s,c]=(0,j.useState)(e.text??``),[l,u]=(0,j.useState)(0),d=(0,j.useRef)(null),f=(0,j.useMemo)(()=>i.filter(e=>e.toLowerCase().includes(s.trim().toLowerCase())),[i,s]);(0,j.useEffect)(()=>{d.current?.focus({preventScroll:!0})},[]);let p=t=>e.commit(r?t:t[0]??null),m=t=>{if(!r)return p(a[0]===t?[]:[t]);let n=a.includes(t)?a.filter(e=>e!==t):[...a,t];o(n),e.draft(n)};return(0,I.jsxs)(c_,{open:!0,onOpenChange:t=>{t||(r?p(a):e.cancel())},children:[(0,I.jsx)(l_,{asChild:!0,children:(0,I.jsx)(`div`,{style:t,className:`rounded-[2px] border-2 border-primary`})}),(0,I.jsxs)(u_,{align:`start`,side:`bottom`,sideOffset:4,collisionPadding:8,"data-testid":`table-select-cell-editor`,className:`!w-[240px] rounded-lg border border-border bg-popover p-1 shadow-floating`,onOpenAutoFocus:e=>e.preventDefault(),onKeyDown:t=>{t.key===`ArrowDown`||t.key===`ArrowUp`?(t.preventDefault(),u(e=>Math.max(0,Math.min(f.length-1,e+(t.key===`ArrowDown`?1:-1))))):t.key===`Enter`?(t.preventDefault(),f[l]?m(f[l]):r&&p(a)):t.key===`Escape`&&(t.preventDefault(),e.cancel())},children:[(0,I.jsx)(`input`,{ref:d,value:s,onChange:e=>{c(e.target.value),u(0)},placeholder:n(`cell.searchPlaceholder`),className:`mb-1 h-8 w-full rounded-md border border-border bg-background px-2 text-[13px] outline-none`}),(0,I.jsxs)(`div`,{className:`max-h-[240px] overflow-y-auto`,children:[f.length===0?(0,I.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:n(`cell.noMatches`)}):null,f.map((e,t)=>(0,I.jsxs)(`button`,{type:`button`,"data-choice":e,onPointerDown:t=>{t.preventDefault(),m(e)},onClick:t=>{t.detail===0&&m(e)},className:K(`flex h-8 w-full cursor-pointer items-center gap-2 rounded-md px-2 text-left text-[13px]`,t===l?`bg-accent`:`hover:bg-accent`),children:[(0,I.jsx)(`span`,{className:`flex size-4 shrink-0 items-center justify-center text-primary`,children:a.includes(e)?(0,I.jsx)(ea,{className:`size-3.5`}):null}),(0,I.jsx)(`span`,{className:`truncate`,children:e})]},e))]})]})]})}function IE({popup:e,locale:t}){if(!e?.anchor)return null;let{x:n,y:r,width:i,height:a}=e.anchor,o={position:`fixed`,left:n,top:r,width:i,height:a,zIndex:30},s=`${e.recordId}:${e.field.id}`;return e.kind===`date`?(0,I.jsx)(NE,{popup:e,locale:t,style:o},s):(0,I.jsx)(FE,{popup:e,style:o},s)}var LE={kind:`none`};function RE(e,t=e){return{kind:`cells`,anchor:{...e},focus:{...t}}}function zE(e,t){return{top:Math.min(e.row,t.row),bottom:Math.max(e.row,t.row),left:Math.min(e.col,t.col),right:Math.max(e.col,t.col)}}function BE(e,t){return e===t||e!=null&&t!=null&&e.row===t.row&&e.col===t.col}function VE(e,t){if(e.kind!==t.kind)return!1;switch(e.kind){case`none`:return!0;case`cells`:{let n=t;return BE(e.anchor,n.anchor)&&BE(e.focus,n.focus)}case`rows`:{let n=t;return e.ranges.length===n.ranges.length&&e.ranges.every(([e,t],r)=>n.ranges[r][0]===e&&n.ranges[r][1]===t)}case`columns`:{let n=t;return e.anchor===n.anchor&&e.focus===n.focus}}}function HE(e){let t=e.map(([e,t])=>[Math.min(e,t),Math.max(e,t)]).sort((e,t)=>e[0]-t[0]),n=[];for(let e of t){let t=n[n.length-1];t&&e[0]<=t[1]+1?t[1]=Math.max(t[1],e[1]):n.push([e[0],e[1]])}return n}function UE(e,t){return e.kind===`rows`&&e.ranges.some(([e,n])=>t>=e&&t<=n)}function WE(e,t){if(e.kind!==`rows`||t.firstRecord<0)return!1;for(let n=0;n<t.count;n+=1)if(t.isRecord(n)&&!UE(e,n))return!1;return!0}function GE(e){return e.firstRecord<0?LE:{kind:`rows`,ranges:[[e.firstRecord,e.lastRecord]]}}function KE(e,t){return e.firstRecord<0||t<=0?LE:RE({row:e.firstRecord,col:0},{row:e.lastRecord,col:t-1})}function qE(e,t,n=null){let r=e.kind===`rows`?e.ranges.map(([e,t])=>[e,t]):[];if(n!=null)return{kind:`rows`,ranges:HE([...r,[n,t]])};if(!UE(e,t))return{kind:`rows`,ranges:HE([...r,[t,t]])};let i=[];for(let[e,n]of r)t<e||t>n?i.push([e,n]):(e<t&&i.push([e,t-1]),t<n&&i.push([t+1,n]));return i.length?{kind:`rows`,ranges:i}:LE}function JE(e,t){let n=[],r=(e,r)=>{for(let i=Math.max(0,e);i<=Math.min(t.count-1,r);i+=1){let e=t.recordId(i);e!=null&&n.push(e)}};switch(e.kind){case`cells`:{let t=zE(e.anchor,e.focus);r(t.top,t.bottom);break}case`rows`:for(let[t,n]of HE(e.ranges))r(t,n);break;case`columns`:r(0,t.count-1)}return n}function YE(e,t,n,r,i,a=!1){let{row:o,col:s}=n;if(r!==0&&(s=a?r<0?0:t-1:Math.min(t-1,Math.max(0,s+r))),i!==0){if(a)o=i<0?e.firstRecord:e.lastRecord;else{let t=i<0?-1:1,n=o;for(let r=0;r<Math.abs(i);r+=1){let r=e.recordFrom(n+t,t);if(r<0)break;n=r}o=n}}return o<0?n:{row:o,col:s}}var XE=new Set([`auto_number`,`created_time`,`last_modified_time`,`created_by`,`last_modified_by`,`lookup`,`rollup`,`formula`,`link_to_record`,`user`,`button`]);function ZE(e){return e!=null&&!e.readonly&&!XE.has(e.type)}function QE(e,t,n){let r=(e,n,r)=>{for(let i=Math.max(0,e);i<=Math.min(t.count-1,n);i+=1){let e=t.recordId(i);e!=null&&r.push(e)}},i=(e,t)=>Array.from({length:Math.max(0,t-e+1)},(t,n)=>e+n),a=[];switch(e.kind){case`cells`:{let t=zE(e.anchor,e.focus);return r(t.top,t.bottom,a),{recordIds:a,cols:i(Math.max(0,t.left),Math.min(n-1,t.right))}}case`rows`:for(let[t,n]of HE(e.ranges))r(t,n,a);return{recordIds:a,cols:i(0,n-1)};case`columns`:return r(0,t.count-1,a),{recordIds:a,cols:i(Math.max(0,Math.min(e.anchor,e.focus)),Math.min(n-1,Math.max(e.anchor,e.focus)))};case`none`:return{recordIds:a,cols:[]}}}function $E(e,t){let n=CE(e,t).replace(/\r\n?/g,`
57
- `);return/[\t\n"]/.test(n)?`"${n.replace(/"/g,`""`)}"`:n}function eD(e,t){return e.map(e=>t.map(t=>$E(t,e.values[t.name]??null)).join(` `)).join(`
58
- `)}function tD(e,t,n){let r=[],i=e.recordFrom(Math.max(0,t),1);for(;i>=0&&r.length<n;){let t=e.recordId(i);t!=null&&r.push(t),i=i+1<e.count?e.recordFrom(i+1,1):-1}return r}function nD(e,t,n,r){let i=LT(t),a=[],o=[];i.forEach((e,t)=>{let i={};if(e.forEach((e,t)=>{let n=r[t];ZE(n)&&(i[n.name]=DT(n,e))}),!Object.keys(i).length)return;let s=n[t];s?a.push({rowKey:s.row_key,values:i}):o.push(i)});let s=[];return a.length&&s.push({op:`cells.set`,tableId:e,records:a}),o.length&&s.push({op:`records.create`,tableId:e,at:null,records:o}),s}function rD(e){return LT(e).length}function iD(e){return Object.fromEntries(e.filter(ZE).map(e=>[e.name,DT(e,null)]))}function aD(e,t,n){let r=iD(n);return!Object.keys(r).length||!t.length?[]:[{op:`cells.set`,tableId:e,records:t.map(e=>({rowKey:e.row_key,values:{...r}}))}]}function oD(e,t,n,r,i){let a=r.filter(ZE);return!t.length||!n.length||!a.length?[]:[{op:`cells.set`,tableId:e,records:n.map((e,n)=>{let r=i?t[n%t.length]:t[t.length-1-n%t.length],o=Object.fromEntries(a.map(e=>[e.name,r.values[e.name]??null]));return{rowKey:e.row_key,values:o}})}]}function sD(e,t,n){return[{op:`records.move`,tableId:e,rowKeys:[t],before:n}]}function cD(e,t,n){return[{op:`fields.move`,tableId:e,fieldIds:t,toIndex:n}]}function lD(e,t,n,r,i){if(n<0||r>=t.length||n>r||i<0||i>t.length||i>=n&&i<=r+1)return null;let a=t.slice(n,r+1),o=t.filter((e,t)=>t<n||t>r),s=i<n?i:i-a.length,c=[...o.slice(0,s),...a,...o.slice(s)],l=new Set(t),u=0;return e.map(e=>l.has(e)?c[u++]:e).indexOf(a[0])}var uD=function(e){return e[e.Body=0]=`Body`,e[e.Frozen=1]=`Frozen`,e[e.Header=2]=`Header`,e[e.HeaderFrozen=3]=`HeaderFrozen`,e[e.RowHead=4]=`RowHead`,e[e.View=5]=`View`,e}({}),dD=function(e){return e[e.Rect=1]=`Rect`,e[e.RRect=2]=`RRect`,e[e.RRectStroke=3]=`RRectStroke`,e[e.Lines=4]=`Lines`,e[e.Text=5]=`Text`,e[e.Tofu=6]=`Tofu`,e[e.Emoji=7]=`Emoji`,e[e.Icon=8]=`Icon`,e[e.Image=9]=`Image`,e[e.Shadow=10]=`Shadow`,e[e.Clip=11]=`Clip`,e[e.Unclip=12]=`Unclip`,e}({}),fD=function(e){return e[e.Horizontal=0]=`Horizontal`,e[e.Vertical=1]=`Vertical`,e}({}),pD=function(e){return e[e.Sans=0]=`Sans`,e[e.Fallback=1]=`Fallback`,e[e.Hangul=2]=`Hangul`,e[e.Mono=3]=`Mono`,e}({}),mD=function(e){return e[e.Cover=0]=`Cover`,e[e.Contain=1]=`Contain`,e}({}),hD=class extends Error{},gD=new TextDecoder(`utf-8`,{fatal:!0});function _D(e,t,n,r){return r===255?`rgb(${e},${t},${n})`:`rgba(${e},${t},${n},${+(r/255).toFixed(4)})`}function vD(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=t.byteLength,i=(e,t)=>{if(e+t>r)throw new hD(`the display list is cut short`)};if(i(0,56),String.fromCharCode(t[0],t[1],t[2],t[3])!==`KTDL`)throw new hD(`not a display list`);let a=n.getUint16(4,!0);if(a!==1)throw new hD(`display list version ${a}; this build reads version 1`);let o=t[16];if(o>5)throw new hD(`the display list has an invalid layer`);let s={flags:n.getUint16(6,!0),epoch:n.getUint32(8,!0),theme:n.getUint16(12,!0),resources:n.getUint16(14,!0),key:{layer:o,colBand:t[17],rowBand:n.getUint32(20,!0)},x:n.getFloat32(24,!0),y:n.getFloat32(28,!0),width:n.getFloat32(32,!0),height:n.getFloat32(36,!0)},c=n.getUint16(40,!0),l=n.getUint32(44,!0),u=n.getUint32(48,!0),d=n.getUint32(52,!0),f=56;i(f,c*4);let p=t.slice(f,f+c*4),m=Array(c);for(let e=0;e<c;e+=1)m[e]=_D(p[e*4],p[e*4+1],p[e*4+2],p[e*4+3]);f+=c*4,i(f,u);let h=t.subarray(f,f+u);f+=u+3&-4;let g=e=>n.getFloat32(f+e,!0),_=Array(l);for(let e=0;e<l;e+=1){i(f,4);let r=t[f],a=t[f+1],o=n.getUint16(f+2,!0),s,c;switch(r){case 1:c=20,i(f,c),s={op:r,x:g(4),y:g(8),w:g(12),h:g(16),paint:o,snap:(a&1)==1};break;case 2:c=24,i(f,c),s={op:r,x:g(4),y:g(8),w:g(12),h:g(16),r:g(20),paint:o};break;case 3:c=28,i(f,c),s={op:r,x:g(4),y:g(8),w:g(12),h:g(16),r:g(20),width:g(24),paint:o};break;case 4:{if(a>1)throw new hD(`the display list has an invalid axis`);i(f,8);let e=n.getUint32(f+4,!0);c=8+12*e,i(f,c);let t=new Float32Array(e*3);for(let r=0;r<e*3;r+=1)t[r]=n.getFloat32(f+8+4*r,!0);s={op:r,axis:a,paint:o,lines:t};break}case 5:{if(c=32,i(f,c),a>2)throw new hD(`the display list has an invalid align`);let e=t[f+4];if(e>3)throw new hD(`the display list has an invalid face`);let l=n.getUint32(f+24,!0),d=n.getUint16(f+28,!0);if(l+d>u)throw new hD(`the display list has an invalid string reference`);let p;try{p=gD.decode(h.subarray(l,l+d))}catch{throw new hD(`the display list has an invalid string reference`)}s={op:r,align:a,paint:o,face:e,weight:n.getUint16(f+6,!0),x:g(8),y:g(12),size:g(16),width:g(20),text:p};break}case 6:c=20,i(f,c),s={op:r,x:g(4),y:g(8),w:g(12),h:g(16),paint:o};break;case 7:c=20,i(f,c),s={op:r,atlas:n.getUint32(f+4,!0),x:g(8),y:g(12),size:g(16)};break;case 8:c=24,i(f,c),s={op:r,solid:(a&1)==1,paint:o,icon:n.getUint16(f+4,!0),x:g(8),y:g(12),size:g(16),stroke:g(20)};break;case 9:if(c=28,i(f,c),a>1)throw new hD(`the display list has an invalid fit`);s={op:r,fit:a,key:n.getUint32(f+4,!0),x:g(8),y:g(12),w:g(16),h:g(20),radius:g(24)};break;case 10:c=28,i(f,c),s={op:r,x:g(4),y:g(8),w:g(12),h:g(16),r:g(20),blur:g(24),paint:o};break;case 11:c=20,i(f,c),s={op:r,x:g(4),y:g(8),w:g(12),h:g(16)};break;case 12:c=4,s={op:r};break;default:throw new hD(`the display list has an invalid opcode`)}_[e]=s,f+=c}if(d>(r-f)/28)throw new hD(`the display list is cut short`);let v=Array(d);for(let e=0;e<d;e+=1,f+=28){let r=t[f];if(r>12)throw new hD(`the display list has an invalid hit kind`);let i=n.getUint16(f+4,!0),a=n.getUint32(f+8,!0);v[e]={kind:r,part:t[f+1],index:n.getUint16(f+2,!0),col:i===65535?-1:i,row:a===4294967295?-1:a,x:g(12),y:g(16),w:g(20),h:g(24)}}if(f!==r)throw new hD(`the display list has an invalid length`);return{header:s,colors:m,rgba:p,ops:_,hits:v,bytes:r}}var yD=function(e){return e[e.Checkbox=0]=`Checkbox`,e[e.Rating=1]=`Rating`,e[e.Attachment=2]=`Attachment`,e[e.Button=3]=`Button`,e[e.Link=4]=`Link`,e[e.Expand=5]=`Expand`,e[e.DragHandle=6]=`DragHandle`,e[e.GroupToggle=7]=`GroupToggle`,e[e.ColumnMenu=8]=`ColumnMenu`,e[e.ColumnEdge=9]=`ColumnEdge`,e[e.FreezeHandle=10]=`FreezeHandle`,e[e.AppendRow=11]=`AppendRow`,e[e.AppendColumn=12]=`AppendColumn`,e}({}),bD=(e,t)=>({region:`none`,row:-1,col:-1,part:null,docX:e,docY:t,x:e,y:t});function xD(e){let t=e.columns[e.columns.length-1];return t&&t.fieldId==null?e.columns.length-1:e.columns.length}function SD(e,t,n,r){return{docX:n<e.bodyLeft?n:n+t.scrollX,docY:r<e.headerHeight?r:r+t.scrollY}}function CD(e,t,n,r,i){let a=Math.max(0,Math.floor((r-e.bodyLeft)/e.bandWidth));if(t)return n<e.bodyLeft?{layer:uD.HeaderFrozen,colBand:0,rowBand:0}:{layer:uD.Header,colBand:a,rowBand:0};let o=Math.floor(Math.max(0,i)/e.bandRows);return n<e.rowHeadWidth?{layer:uD.RowHead,colBand:0,rowBand:o}:n<e.bodyLeft?{layer:uD.Frozen,colBand:0,rowBand:o}:{layer:uD.Body,colBand:a,rowBand:o}}function wD(e,t,n){if(!e)return null;for(let r of e.hits)if(t>=r.x&&t<r.x+r.w&&n>=r.y&&n<r.y+r.h)return r;return null}function TD(e,t,n){let{axes:r,rows:i,viewport:a}=e;if(t<0||n<0||t>=a.width||n>=a.height)return bD(t,n);let{docX:o,docY:s}=SD(r,a,t,n),c=n<r.headerHeight,l=c?-1:r.rowAt(s);if(!c&&(l<0||l>=r.rows))return{...bD(t,n),docX:o,docY:s};let u=wD(e.list(CD(r,c,t,o,l)),o,s),d=xD(r),f=t<r.rowHeadWidth?-1:r.columnAt(o),p=f>=0&&f<d?f:-1,m={row:l,col:p,part:u,docX:o,docY:s,x:t,y:n};if(c)return t<r.rowHeadWidth?{...m,region:`corner`}:f>=d?{...m,region:`appendColumn`}:{...m,region:p>=0?`header`:`none`};let h=i?i.kind(l):QT.Record;return h===QT.Group?{...m,region:`group`}:h===QT.Append?{...m,region:`appendRow`}:t<r.rowHeadWidth?{...m,region:`rowHead`}:{...m,region:p>=0?`cell`:`none`}}function ED(e,t,n,r,i){let a=xD(e);if(e.rows===0||a===0)return null;let o=Math.min(Math.max(i,e.headerHeight),t.height-1),{docX:s,docY:c}=SD(e,t,Math.min(Math.max(r,e.rowHeadWidth),t.width-1),o),l=Math.min(e.rows-1,Math.max(0,e.rowAt(c)));if(n&&!n.isRecord(l)){let e=n.recordFrom(l,-1);if(l=e>=0?e:n.recordFrom(l,1),l<0)return null}let u=e.columnAt(s);return(u<0||u>=a)&&(u=s<e.rowHeadWidth?0:a-1),{row:l,col:u}}function DD(e,t){let n=e.columns[t.col];return{x:n?.x??0,y:e.rowTop(t.row),width:n?.width??0,height:e.rowHeight(t.row)}}function OD(e,t,n,r,i){let a=e.columns[r],o=e.columns[i],s=a?.x??e.rowHeadWidth,c=e.rowTop(t);return{x:s,y:c,width:(o?o.x+o.width:s)-s,height:e.rowTop(n+1)-c}}function kD(e,t){let n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),i=Math.min(e.x+e.width,t.x+t.width),a=Math.min(e.y+e.height,t.y+t.height);return i>n&&a>r?{x:n,y:r,width:i-n,height:a-r}:null}function AD(e,t,n){let r=[],{width:i,height:a,scrollX:o,scrollY:s}=t,c=[{from:0,to:e.bodyLeft,dx:0,screen:{x:0,width:Math.min(e.bodyLeft,i)}},{from:e.bodyLeft,to:1/0,dx:o,screen:{x:e.bodyLeft,width:Math.max(0,i-e.bodyLeft)}}],l=[{from:0,to:e.headerHeight,dy:0,screen:{y:0,height:Math.min(e.headerHeight,a)}},{from:e.headerHeight,to:1/0,dy:s,screen:{y:e.headerHeight,height:Math.max(0,a-e.headerHeight)}}];for(let e of l)for(let t of c){let i=kD(n,{x:t.from,y:e.from,width:t.to-t.from,height:e.to-e.from});if(!i)continue;let a=kD({x:i.x-t.dx,y:i.y-e.dy,width:i.width,height:i.height},{x:t.screen.x,y:e.screen.y,width:t.screen.width,height:e.screen.height});a&&r.push(a)}return r}function jD(e,t){let{axes:n}=e,r=e.list({layer:uD.RowHead,colBand:0,rowBand:Math.floor(t/n.bandRows)});return r?r.hits.filter(e=>e.row===t&&e.col===-1&&e.kind!==11).sort((e,t)=>e.x-t.x):[]}function MD(e){return e.list({layer:uD.HeaderFrozen,colBand:0,rowBand:0})?.hits.find(e=>e.kind===0&&e.row===-1&&e.col===-1)??null}var ND={sans:`inter/Inter-Variable.ttf`,fallback:`droid-sans-fallback/DroidSansFallbackFull.ttf`,hangul:`nanum-gothic/NanumGothic-Regular.ttf`,emoji:`noto-color-emoji/Noto-COLRv1.ttf`},PD={[pD.Sans]:`KitionTableSans`,[pD.Fallback]:`KitionTableFallback`,[pD.Hangul]:`KitionTableHangul`,[pD.Mono]:`KitionTableMono`},FD={[pD.Sans]:ND.sans,[pD.Fallback]:ND.fallback,[pD.Hangul]:ND.hangul};function ID(e){let t=t=>new URL(t,e).href;return{fonts:[t(ND.sans)],lazyFonts:[ND.fallback,ND.hangul,ND.emoji].map(t)}}var LD=`Quarterly planning review`;function RD(e,t,n){return e.font=`400 ${n}px ${t}`,e.measureText(LD).width/n}var zD=null;function BD(){return zD??=(async()=>{let e=document.createElement(`canvas`).getContext(`2d`);if(!e||!(`fonts`in document))return{sizing:`auto`,ratio:0,em:0,measured:!1};`fontKerning`in e&&(e.fontKerning=`normal`);let t=PD[pD.Sans],n={ratio:0,em:0};for(let r=0;r<3;r+=1){if(document.fonts.check(`400 14px ${t}`,`Quarterly planning review`)){let r=RD(e,t,14),i=RD(e,t,32)/r;if(n={ratio:i,em:r},Math.abs(r-12.1284)<=.03*12.1284)return{sizing:i>.955?`fixed-default`:`auto`,ratio:i,em:r,measured:!0}}await document.fonts.ready,await new Promise(e=>requestAnimationFrame(()=>e(void 0)))}return{sizing:`auto`,...n,measured:!1}})(),zD}var VD=class{fontsBase;onLoad;engine=null;loaded=new Set;loading=new Map;failed=new Set;constructor(e,t){this.fontsBase=e,this.onLoad=t}async start(){await this.load(pD.Sans)}ready(e){return this.loaded.has(e)?!0:(!this.loading.has(e)&&!this.failed.has(e)&&this.load(e).then(()=>this.onLoad(e),()=>void 0),!1)}tofuReady(){return!this.engine?.pending()}async all(){await Promise.all([...[pD.Sans,pD.Fallback,pD.Hangul].map(e=>this.load(e)),this.engine?.loadAll()])}load(e){let t=FD[e];if(!t)return this.failed.add(e),Promise.reject(Error(`no file for face ${e}`));let n=this.loading.get(e);return n||(n=(async()=>{let n=await(await fetch(new URL(t,this.fontsBase))).arrayBuffer(),r=new FontFace(PD[e],n,{weight:`100 900`});await r.load(),document.fonts.add(r),this.loaded.add(e)})(),n.catch(()=>this.failed.add(e)),this.loading.set(e,n)),n}};function HD(e,t,n){return`${e}:${t}:${n}`}function UD(e,t,n,r,i,a){return`${e}:${t}:${n}:${+!!r}:${i}:${a}`}function WD(e,t){let n=t*4;return(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24)>>>0}function GD(e,t){if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(e,t);let n=document.createElement(`canvas`);return n.width=e,n.height=t,n}function KD(e){if(e.width===0||e.height===0)return null;let t=GD(e.width,e.height),n=t.getContext(`2d`);if(!n)return null;let r=new ImageData(e.width,e.height);return r.data.set(e.rgba),n.putImageData(r,0,0),{image:t,left:e.left,top:e.top}}function qD(){return Math.floor(Math.random()*4294967296)>>>0}var JD=class{icons=new Map;tiles=new Map;images=new Map;sessionId=qD();get session(){return this.sessionId}addIcon(e,t){let n=KD(e);n&&this.icons.set(UD(e.id,e.size,e.stroke,e.solid,e.paint,t),n)}icon(e,t,n,r,i,a){return this.icons.get(UD(e,t,n,r,i,a))}addEmoji(e,t){let n=KD(e);n&&this.tiles.set(HD(e.atlas,e.size,t),n)}emoji(e,t,n){return this.tiles.get(HD(e,t,n))}setImage(e,t){this.images.set(e,t)}image(e){return this.images.get(e)}dropTiles(){this.icons.clear(),this.tiles.clear(),this.sessionId=qD()}renewSession(){this.sessionId=qD()}clear(){this.icons.clear(),this.tiles.clear(),this.images.clear(),this.sessionId=qD()}};function YD(e,t,n){return Math.round((e-t)*n)}function XD(e,t,n){return Math.floor((e-t)*n+1e-4)}var ZD=`rgb(240,240,240)`,QD=[`left`,`center`,`right`];function $D(e,t,n,r){let{ctx:i,x:a,y:o,dpr:s}=e,c=t.colors,l={missingFaces:0,missingTiles:0},u=0,d=()=>{u!==1&&(i.setTransform(s,0,0,s,-a*s,-o*s),u=1)},f=()=>{u!==2&&(i.setTransform(1,0,0,1,0,0),u=2)},p=``,m=``,h=-1,g=e=>{p!==e&&(i.fillStyle=e,p=e)};i.save(),i.textBaseline=`alphabetic`,`fontKerning`in i&&(i.fontKerning=`normal`);let _=0;for(let e of t.ops)switch(e.op){case dD.Rect:if(g(c[e.paint]),e.snap){f();let t=YD(e.x,a,s),n=YD(e.y,o,s),r=YD(e.x+e.w,a,s),c=YD(e.y+e.h,o,s);r>t&&c>n&&i.fillRect(t,n,r-t,c-n)}else d(),i.fillRect(e.x,e.y,e.w,e.h);break;case dD.RRect:d(),g(c[e.paint]),i.beginPath(),i.roundRect(e.x,e.y,e.w,e.h,Math.max(0,e.r)),i.fill();break;case dD.RRectStroke:{d();let t=e.width/2;i.strokeStyle=c[e.paint],i.lineWidth=e.width,i.beginPath(),i.roundRect(e.x+t,e.y+t,Math.max(0,e.w-e.width),Math.max(0,e.h-e.width),Math.max(0,e.r-t)),i.stroke();break}case dD.Lines:{f(),g(c[e.paint]);let t=e.lines;for(let n=0;n<t.length;n+=3)if(e.axis===fD.Horizontal){let e=XD(t[n],o,s),r=YD(t[n+1],a,s),c=YD(t[n+2],a,s);c>r&&i.fillRect(r,e,c-r,1)}else{let e=XD(t[n],a,s),r=YD(t[n+1],o,s),c=YD(t[n+2],o,s);c>r&&i.fillRect(e,r,1,c-r)}break}case dD.Text:{if(r&&!r.ready(e.face)){l.missingFaces+=1;break}d();let t=`${e.weight} ${e.size}px ${PD[e.face]}`;m!==t&&(i.font=t,m=t),h!==e.align&&(i.textAlign=QD[e.align]??`left`,h=e.align),g(c[e.paint]),i.fillText(e.text,e.x,o+YD(e.y,o,s)/s);break}case dD.Tofu:{if(r&&!r.tofuReady()){l.missingFaces+=1;break}f(),g(c[e.paint]);let t=YD(e.x,a,s),n=YD(e.y,o,s),u=YD(e.x+e.w,a,s),d=YD(e.y+e.h,o,s);if(u-t<1||d-n<1)break;i.fillRect(t,n,u-t,1),d-n>1&&i.fillRect(t,d-1,u-t,1),d-n>2&&(i.fillRect(t,n+1,1,d-n-2),u-t>1&&i.fillRect(u-1,n+1,1,d-n-2));break}case dD.Emoji:{let t=n.emoji(e.atlas,e.size,s);if(!t){l.missingTiles+=1;break}f(),i.drawImage(t.image,YD(e.x,a,s)+t.left,YD(e.y,o,s)+t.top);break}case dD.Icon:{let r=n.icon(e.icon,e.size,e.stroke,e.solid,WD(t.rgba,e.paint),s);if(!r){l.missingTiles+=1;break}f(),i.drawImage(r.image,YD(e.x,a,s)+r.left,YD(e.y,o,s)+r.top);break}case dD.Image:{d();let t=n.image(e.key);if(i.beginPath(),i.roundRect(e.x,e.y,e.w,e.h,Math.max(0,e.radius)),!t||t.width===0||t.height===0){g(ZD),i.fill();break}let r=e.fit===mD.Cover?Math.max(e.w/t.width,e.h/t.height):Math.min(e.w/t.width,e.h/t.height),a=t.width*r,o=t.height*r;i.save(),i.clip(),i.drawImage(t,e.x+(e.w-a)/2,e.y+(e.h-o)/2,a,o),i.restore();break}case dD.Shadow:{f();let t=1e5;i.save(),i.shadowColor=c[e.paint],i.shadowBlur=2*e.blur*s,i.shadowOffsetX=t,i.fillStyle=`#000`,i.beginPath(),i.roundRect((e.x-a)*s-t,(e.y-o)*s,e.w*s,e.h*s,Math.max(0,e.r*s)),i.fill(),i.restore();break}case dD.Clip:{f(),i.save();let t=YD(e.x,a,s),n=YD(e.y,o,s);i.beginPath(),i.rect(t,n,YD(e.x+e.w,a,s)-t,YD(e.y+e.h,o,s)-n),i.clip(),_+=1;break}case dD.Unclip:_>0&&(i.restore(),--_,u=0,p=``,m=``,h=-1)}for(;_>0;)i.restore(),--_;return i.restore(),l}function eO(e){let t=/^#([0-9a-f]{6})$/i.exec(e);if(t){let e=Number.parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255,255]}let n=/^rgba?\(([^)]*)\)$/.exec(e)?.[1].split(`,`).map(e=>Number(e.trim()));return n&&n.length>=3&&n.every(Number.isFinite)?[n[0],n[1],n[2],n.length>3?Math.round(n[3]*255):255]:[0,0,0,255]}function tO(e,t){return{header:{flags:0,epoch:0,theme:0,resources:0,key:{layer:uD.View,colBand:0,rowBand:0},x:0,y:0,width:0,height:0},colors:e,rgba:new Uint8Array(e.flatMap(eO)),ops:t,hits:[],bytes:0}}function nO(e,t){let{width:n,height:r,scrollX:i,scrollY:a}=t,{bodyLeft:o,headerHeight:s}=e;return[{clip:{x:0,y:s,width:o,height:r-s},ox:0,oy:a},{clip:{x:o,y:s,width:n-o,height:r-s},ox:i,oy:a},{clip:{x:0,y:0,width:o,height:s},ox:0,oy:0},{clip:{x:o,y:0,width:n-o,height:s},ox:i,oy:0}]}function rO(e,t,n,r,i,a){for(let o of nO(n,r)){let n=o.clip;if(n.width<=0||n.height<=0)continue;e.save(),e.setTransform(1,0,0,1,0,0),e.beginPath();let r=Math.round(n.x*t),s=Math.round(n.y*t);e.rect(r,s,Math.round((n.x+n.width)*t)-r,Math.round((n.y+n.height)*t)-s),e.clip(),$D({ctx:e,x:o.ox,y:o.oy,dpr:t},i,a,null),e.restore()}}function iO(e,t){return{x:e.x+(e.w-t)/2,y:e.y+Math.max(0,(e.h-t)/2),width:t,height:t}}function aO(e,t){return e.rows===0?[0,-1]:[Math.max(0,e.rowAt(t.scrollY+e.headerHeight)),Math.min(e.rows-1,e.rowAt(t.scrollY+t.height-.001))]}function oO(e){let{axes:t,rows:n,viewport:r,style:i,selection:a,active:o,hover:s}=e,c=[i.selection,i.border,i.hover,i.rowHead,i.control,i.check,i.checkMark],l=[],u=xD(t),d=t.columns[u-1],f=d?d.x+d.width:t.bodyLeft,p=(e,t)=>{e.width>0&&e.height>0&&l.push({op:dD.Rect,x:e.x,y:e.y,w:e.width,h:e.height,paint:t,snap:!0})},m=(e,t)=>{e.width>0&&e.height>0&&l.push({op:dD.RRectStroke,x:e.x,y:e.y,w:e.width,h:e.height,r:0,width:t,paint:1})},h=(e,t,n)=>{e!=null&&l.push({op:dD.Icon,icon:e,x:t.x,y:t.y,size:t.width,stroke:i.iconStroke,paint:n,solid:!1})},g=(e,t)=>{let n=iO(e,i.controlSize);t?(l.push({op:dD.RRect,x:n.x,y:n.y,w:n.width,h:n.height,r:i.checkboxRadius,paint:5}),l.push({op:dD.RRectStroke,x:n.x,y:n.y,w:n.width,h:n.height,r:i.checkboxRadius,width:i.checkboxBorder,paint:5}),h(i.icons.check,iO(e,i.checkMarkSize),6)):l.push({op:dD.RRectStroke,x:n.x,y:n.y,w:n.width,h:n.height,r:i.checkboxRadius,width:i.checkboxBorder,paint:4})},_=(e,n,r)=>({x:n,y:t.rowTop(e),width:r-n,height:t.rowHeight(e)-1}),v=s&&(s.region===`cell`||s.region===`rowHead`)?s.row:-1,y=o&&a.kind===`cells`?o.row:-1,[b,x]=aO(t,r),S=[];for(let e=b;e<=x;e+=1){if(n&&!n.isRecord(e))continue;let t=e===v||e===y;(t||UE(a,e))&&S.push({row:e,all:t})}for(let{row:e}of S)p(_(e,0,t.rowHeadWidth-1),3);if(v>=0&&(!n||n.isRecord(v))&&p(_(v,0,f),2),s?.region===`header`&&s.col>=0){let e=t.columns[s.col];p({x:e.x,y:0,width:e.width-1,height:t.headerHeight-1},2)}switch(a.kind){case`cells`:{let e=zE(a.anchor,a.focus);if(e.top!==e.bottom||e.left!==e.right){let n=OD(t,e.top,e.bottom,e.left,e.right);p(n,0),m(n,i.rangeWidth)}break}case`rows`:for(let[e,n]of HE(a.ranges)){let r=Math.max(e,b),i=Math.min(n,x);if(r>i)continue;let a=t.rowTop(r);p({x:t.rowHeadWidth,y:a,width:f-t.rowHeadWidth,height:t.rowTop(i+1)-a},0)}break;case`columns`:{let e=Math.min(a.anchor,a.focus),n=Math.max(a.anchor,a.focus),r=OD(t,0,t.rows-1,e,n);p({x:r.x,y:0,width:r.width,height:t.height},0);break}}o&&a.kind===`cells`&&o.col>=0&&o.col<u&&m(DD(t,o),i.activeWidth);for(let{row:t,all:n}of S)for(let r of jD(e.source,t))if(r.kind===yD.Checkbox)g(r,UE(a,t));else if(n)r.kind===yD.DragHandle?h(i.icons.drag,iO(r,i.controlSize),4):r.kind===yD.Expand&&h(i.icons.expand,iO(r,i.controlSize),4);else continue;if(n&&WE(a,n)){let t=MD(e.source);t&&g(t,!0)}return{colors:c,ops:l}}var sO=4;function cO(e,t){return Math.max(100,Math.round(e+t))}function lO(e,t){let n=xD(e);for(let r=0;r<n;r+=1){let n=e.columns[r];if(t<n.x+n.width/2)return r}return n}function uO(e,t,n){let r=e.isRecord(n)?n:e.recordFrom(n,n<t?1:-1);return r<0&&(r=e.recordFrom(n,n<t?-1:1)),r<0||r===t?null:{target:r,after:r>t}}function dO(e,t){let n=e.headerHeight;return{top:n,bottom:Math.max(n,Math.min(t.height,e.height-t.scrollY))}}function fO(e,t,n){let r=xD(e),i=0;for(let a=0;a<r;a+=1){let r=e.columns[a];if((r.frozen?r.x:r.x-t.scrollX)+r.width/2>n)break;i=a+1}return i}function pO(e,t,n){let r=e.columns[n-1];return r?r.x+r.width-(r.frozen?0:t.scrollX):e.rowHeadWidth}function mO(e,t){return t>e.bottom?{down:!0,from:e.bottom+1,to:t}:t<e.top?{down:!1,from:e.top-1,to:t}:null}function hO(e,t){return e.kind!==`cells`||!t?null:zE(e.anchor,e.focus)}function gO(e,t,n){let r=AD(e,t,n);if(!r.length)return null;let i=Math.min(...r.map(e=>e.x)),a=Math.min(...r.map(e=>e.y)),o=Math.max(...r.map(e=>e.x+e.width)),s=Math.max(...r.map(e=>e.y+e.height));return{x:i,y:a,width:o-i,height:s-a}}function _O(e,t){let n=e.view,r=null,i=t=>{r=t,e.invalidateOverlay()},a=[];a.push(e.addPainter(e=>r?.(e),200));let o=()=>n.currentAxes,s=(e,t,n,r,i,a=!1)=>{let o=[e.style.border,e.style.selection];e.play(tO(o,[{op:dD.Rect,x:t,y:n,w:r,h:i,paint:+!!a,snap:!0}]))},c=null;a.push(e.addGesture({down(e,t){let n=o();if(e.region!==`header`||e.part?.kind!==yD.ColumnEdge||!n)return!1;let r=n.columns[e.part.col];return!r||r.fieldId==null?!1:(c={col:e.part.col,fieldId:r.fieldId,width:r.width,startX:t.clientX,now:r.width},i(e=>{if(!c)return;let t=e.axes.columns[c.col];s(e,t.x+c.now-1,0,2,Math.min(e.axes.height,e.viewport.scrollY+e.viewport.height))}),!0)},move(t,n){if(!c)return;let r=cO(c.width,n.clientX-c.startX);r!==c.now&&(c.now=r,e.invalidateOverlay())},up(){let e=c;c=null,i(null),e&&e.now!==e.width&&t.resize(e.col,e.fieldId,e.now)},cancel(){c=null,i(null)},cursor:e=>e.region===`header`&&e.part?.kind===yD.ColumnEdge?`ew-resize`:null}));let l=null;a.push(e.addGesture({down(t,n){let r=o();if(t.region!==`header`||t.col<0||n.shiftKey||!r||t.col>=xD(r)||t.part?.kind===yD.ColumnMenu||t.part?.kind===yD.ColumnEdge)return!1;let a=e.selection,c=t.col,u=t.col;return a.kind===`columns`&&t.col>=Math.min(a.anchor,a.focus)&&t.col<=Math.max(a.anchor,a.focus)?(c=Math.min(a.anchor,a.focus),u=Math.max(a.anchor,a.focus)):e.setSelection({kind:`columns`,anchor:t.col,focus:t.col},e.active),l={cols:Array.from({length:u-c+1},(e,t)=>c+t),startX:n.clientX,grabX:t.docX-r.columns[c].x,dragging:!1,docX:t.docX},i(e=>{if(!l?.dragging)return;let t=e.axes.columns[l.cols[0]],n=e.axes.columns[l.cols[l.cols.length-1]],r=n.x+n.width-t.x,i=Math.min(e.axes.height,e.viewport.scrollY+e.viewport.height);s(e,l.docX-l.grabX,0,r,i,!0);let a=xD(e.axes),o=lO(e.axes,l.docX),c=e.axes.columns[a-1],u=o<a?e.axes.columns[o].x:c.x+c.width;s(e,u-1,0,2,i)}),!0},move(t,n){l&&(!l.dragging&&Math.abs(n.clientX-l.startX)<sO||(l.dragging=!0,l.docX=t.docX,e.invalidateOverlay()))},up(n){let r=l;l=null,i(null);let a=o();r&&a&&(r.dragging?t.moveColumns(r.cols,lO(a,n.docX)):r.cols.length>1&&n.col>=0&&e.setSelection({kind:`columns`,anchor:n.col,focus:n.col},e.active))},cancel(){l=null,i(null)}}));let u=null;a.push(e.addGesture({down(e){let n=o();return e.region!==`rowHead`||e.part?.kind!==yD.DragHandle||!n||!t.canMoveRows()?!1:(u={source:e.row,over:e.row,docY:e.docY,grabY:e.docY-n.rowTop(e.row)},i(e=>{let t=e.rows;if(!u||!t)return;let n=xD(e.axes),r=e.axes.columns[n-1],i=r?r.x+r.width:e.axes.bodyLeft,a=e.axes.rowHeight(u.source);s(e,0,u.docY-u.grabY,i,a,!0);let o=uO(t,u.source,u.over);if(o){let t=o.after?e.axes.rowTop(o.target+1):e.axes.rowTop(o.target);s(e,0,t-1,i,2)}}),!0)},move(t){let r=o();if(!u||!r)return;let i=ED(r,n.viewport,e.rows,Math.max(t.x,r.rowHeadWidth),t.y);u.docY=t.docY,i&&(u.over=i.row),e.invalidateOverlay()},up(){let n=u;u=null,i(null);let r=e.rows;if(!n||!r)return;let a=uO(r,n.source,n.over);a&&t.moveRow(n.source,a.target,a.after)},cancel(){u=null,i(null)},cursor:e=>e.region===`rowHead`&&e.part?.kind===yD.DragHandle&&t.canMoveRows()?`grab`:null}));let d=null,f=e=>{let t=o();return!t||e.y<t.headerHeight||e.y>=Math.min(n.viewport.height,t.height-n.viewport.scrollY)?!1:Math.abs(e.x-t.bodyLeft)<=4},p=(e,t,n)=>{let{top:r,bottom:i}=dO(e.axes,e.viewport),a=e.ctx;a.save(),a.setTransform(e.dpr,0,0,e.dpr,0,0),a.fillStyle=e.style.control,a.fillRect(t-1,r,2,i-r),a.fillStyle=e.style.border,a.beginPath(),a.roundRect(t-3,Math.max(r,Math.min(n-16,i-32)),6,32,3),a.fill(),a.restore()},m=!1,h=0;a.push(()=>window.clearTimeout(h)),a.push(e.addGesture({down(e){return!f(e)||v(e)?!1:(window.clearTimeout(h),d={x:e.x,y:e.y},i(e=>{if(!d)return;let t=pO(e.axes,e.viewport,fO(e.axes,e.viewport,d.x)),n=e.ctx;n.save(),n.setTransform(e.dpr,0,0,e.dpr,0,0),n.fillStyle=e.style.selection,n.fillRect(t-2,0,4,e.viewport.height),n.restore(),p(e,d.x,d.y)}),!0)},move(t){d&&(d.x=t.x,d.y=t.y,e.invalidateOverlay())},up(e){let r=d;d=null,m=!1,i(null);let a=o();if(!r||!a)return;let s=fO(a,n.viewport,e.x);s!==a.columns.filter(e=>e.frozen).length&&t.freeze(s)},cancel(){d=null,i(null)},cursor(e){let t=f(e);return t!==m&&(m=t,window.clearTimeout(h),t?h=window.setTimeout(()=>i(t=>p(t,t.axes.bodyLeft,e.y)),200):i(null)),t?`col-resize`:null}}));let g=null,_=()=>{let t=o(),r=hO(e.selection,e.active);if(!t||!r||e.editing)return null;let i=gO(t,n.viewport,DD(t,{row:r.bottom,col:r.right}));return i?{x:i.x+i.width,y:i.y+i.height}:null},v=e=>{let t=_();return t!=null&&Math.abs(e.x-t.x)<=8&&Math.abs(e.y-t.y)<=8};return a.push(e.addPainter(t=>{let n=hO(e.selection,e.active);if(!n||e.editing)return;let r=t.axes;if(g){let e=mO(g.bounds,g.row);if(e){let n=OD(r,Math.min(e.from,e.to),Math.max(e.from,e.to),g.bounds.left,g.bounds.right);t.play(tO([t.style.border,t.style.selection],[{op:dD.Rect,x:n.x,y:n.y,w:n.width,h:n.height,paint:1,snap:!0},{op:dD.RRectStroke,x:n.x,y:n.y,w:n.width,h:n.height,r:0,width:1,paint:0}]))}}let i=DD(r,{row:n.bottom,col:n.right}),a=i.x+i.width-4,o=i.y+i.height-4;t.play(tO([t.style.border,t.style.checkMark],[{op:dD.Rect,x:a-1,y:o-1,w:10,h:10,paint:1,snap:!0},{op:dD.Rect,x:a,y:o,w:8,h:8,paint:0,snap:!0}]))},110)),a.push(e.addGesture({down(t){let n=hO(e.selection,e.active);return!n||!v(t)?!1:(g={bounds:n,row:n.bottom},!0)},move(t){let r=o();if(!g||!r)return;let i=ED(r,n.viewport,e.rows,t.x,t.y);i&&i.row!==g.row&&(g.row=i.row,e.invalidateOverlay())},up(){let n=g;g=null,e.invalidateOverlay();let r=n?mO(n.bounds,n.row):null;n&&r&&t.fill(n.bounds,r)},cancel(){g=null,e.invalidateOverlay()},cursor:e=>v(e)?`crosshair`:null})),()=>{for(let e of a)e()}}var vO=2e4,yO=/^(https?:|data:|blob:)/i,bO=/^(kition-blob:|data:)/i,xO=new Set([`text`,`long_text`,`number`,`url`]),SO=48;function CO(e){return{x:e.x+6,y:e.y+(e.height-20)/2,width:20,height:20}}function wO(e){return{x:e.x+e.width-18-4,y:e.y+4,width:18,height:18}}var TO=(e,t,n)=>t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height;function EO(e,t){if(t==null)return``;if(e.type===`url`&&typeof t==`object`&&!Array.isArray(t)){let e=t;return String(e.href??e.url??``)}return xT(t)}function DO(e,t,n){return{text:e+t,start:e.length+n.start,end:e.length+n.end}}function OO(e,t){let n=Promise.resolve(t);if(typeof ClipboardItem<`u`&&typeof e.write==`function`){let t=new ClipboardItem({"text/plain":n.then(e=>new Blob([e],{type:`text/plain`}))});return e.write([t]).catch(async()=>e.writeText(await n))}return n.then(t=>e.writeText(t))}var kO=class{data;handlers;options;grid=null;input;session=null;composing=!1;copy=null;keyCopy=!1;copyTimer=0;copyRun=0;generating=new Set;overAIButton=!1;overAddButton=!1;picker=null;picking=null;spinFrame=0;images=new Map;cleanup=[];busy=0;constructor(e,t={},n={}){this.data=e,this.handlers=t,this.options=n;let r=document.createElement(`textarea`);r.dataset.ktableGridInput=`true`,r.setAttribute(`autocomplete`,`off`),r.setAttribute(`autocapitalize`,`off`),r.setAttribute(`autocorrect`,`off`),r.spellcheck=!1,r.rows=1,this.input=r,this.hide()}get gridHandlers(){return{onEdit:(e,t)=>this.edit(e,t),onDelete:e=>void this.clear(e),onCellPart:e=>void this.cellPart(e)}}get interaction(){if(!this.grid)throw Error(`GridEditing is not attached`);return this.grid}get editing(){return this.session!=null}get copyReady(){return this.copy?.key===this.copyKey()}attach(e){this.grid=e;let t=e.view,n=this.input;t.element.append(n);let r=(e,t,n,r=!1)=>{e.addEventListener(t,n,r),this.cleanup.push(()=>e.removeEventListener(t,n,r))};r(t.scroller,`focus`,()=>this.focus()),r(t.scroller,`pointerdown`,()=>{this.session&&this.commit()},!0),r(t.scroller,`click`,e=>this.onClick(e)),r(n,`keydown`,e=>this.onKey(e)),r(n,`compositionstart`,()=>{this.composing=!0,this.session||this.startTyping(``,!0)}),r(n,`compositionend`,e=>{this.composing=!1,!this.session&&e.data?this.startTyping(e.data,!1):this.session?.before!=null&&this.putValueBefore(this.session.before)}),r(n,`input`,()=>{!this.session&&!this.composing&&n.value?this.startTyping(n.value,!1):this.session?.kind===`text`&&this.session.field.type===`long_text`&&this.place()}),r(n,`copy`,e=>this.onCopy(e,!1)),r(n,`cut`,e=>this.onCopy(e,!0));let i=e=>{(e.target===n||document.activeElement===n)&&this.onPaste(e)};window.addEventListener(`paste`,i),this.cleanup.push(()=>window.removeEventListener(`paste`,i)),this.cleanup.push(e.onChange(()=>this.onSelection())),this.cleanup.push(e.onGeometry(()=>this.place())),this.cleanup.push(t.onImages(e=>this.loadImages(e))),this.options.readOnly||this.cleanup.push(_O(e,this.dragActions())),this.cleanup.push(e.addPainter(e=>this.paintAI(e),120)),this.cleanup.push(e.addPainter(e=>this.paintAdd(e),121)),this.cleanup.push(e.addGesture({down:e=>this.addButtonAt(e)!=null,up:e=>{let t=this.addButtonAt(e);t&&this.pickFiles(t.recordId,t.field)},cursor:e=>{let t=this.addButtonAt(e)!=null;return t!==this.overAddButton&&(this.overAddButton=t,this.interaction.invalidateOverlay()),t?`pointer`:null}})),this.cleanup.push(e.addGesture({down:e=>this.aiButtonAt(e)!=null,up:e=>{let t=this.aiButtonAt(e);t&&this.handlers.onRegenerate?.(t)},cursor:e=>{let t=this.aiButtonAt(e)!=null;return t!==this.overAIButton&&(this.overAIButton=t,this.interaction.invalidateOverlay()),t?`pointer`:null}})),this.place()}destroy(){cancelAnimationFrame(this.spinFrame),window.clearTimeout(this.copyTimer);for(let e of this.cleanup)e();this.input.remove(),this.picker?.remove()}focus(){this.session?.kind!==`popup`&&this.input.focus({preventScroll:!0})}hide(){this.input.style.cssText=`position:absolute;left:0;top:0;width:1px;height:1px;margin:0;padding:0;border:0;opacity:0;pointer-events:none;resize:none;overflow:hidden;z-index:2;caret-color:transparent;background:transparent;outline:none;white-space:pre-wrap`}place(){let e=this.grid;if(!e)return;let t=this.session,n=t?.cell??e.active,r=n?e.cellScreenArea(n):null,i=this.input.style;if(t?.kind===`text`){let n=e.style?.border??`currentColor`,a=t.field.type===`long_text`;if(!r){i.visibility=`hidden`;return}i.visibility=`visible`;let o=a&&r.height>SO,s=a&&!o?Math.max(r.height,96):r.height,c=a?6:Math.max(0,(r.height-20)/2-2);if(i.cssText=[`position:absolute`,`left:${r.x}px`,`top:${r.y}px`,`width:${r.width}px`,`height:${s}px`,`margin:0`,`padding:${c}px 8px`,`border:2px solid ${n}`,`border-radius:2px`,`box-sizing:border-box`,`box-shadow:none`,`outline:none`,`resize:none`,`overflow:${o?`auto`:`hidden`}`,`z-index:2`,`opacity:1`,`pointer-events:auto`,`cursor:text`,`background:hsl(var(--background, 0 0% 100%))`,`color:hsl(var(--foreground, 0 0% 10%))`,`font:13px/20px Inter, system-ui, sans-serif`,`text-align:center`,`white-space:pre-wrap`].join(`;`),o){let e=`${this.centredPadding(r.height)}px`;i.paddingTop=e,i.paddingBottom=e}}else t?.kind===`popup`&&t.popup&&(t.popup={...t.popup,anchor:r?this.clientRect(r):null},this.handlers.onPopup?.(t.popup)),r&&(i.left=`${r.x}px`,i.top=`${r.y}px`,i.width=`${Math.max(1,r.width)}px`,i.height=`${Math.max(1,r.height)}px`)}centredPadding(e){let t=this.input.style,[n,r,i]=[t.paddingTop,t.paddingBottom,t.height];t.paddingTop=`0px`,t.paddingBottom=`0px`,t.height=`0px`;let a=Math.max(1,Math.round(this.input.scrollHeight/20));return t.paddingTop=n,t.paddingBottom=r,t.height=i,Math.max(2,(e-4-a*20)/2)}clientRect(e){let t=this.interaction.view.scroller.getBoundingClientRect();return{x:t.left+e.x,y:t.top+e.y,width:e.width,height:e.height}}cellOf(e){let t=this.interaction,n=t.rows?.recordId(e.row),r=t.view.currentAxes?.columns[e.col]?.fieldId,i=r==null?void 0:this.data.field(r);return n!=null&&i?{recordId:n,field:i}:null}async value(e,t){let[n]=await this.data.records([e],[t.name]);return n?.values[t.name]??null}onClick(e){if(this.session||e.button!==0||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;let t=this.interaction,n=t.hitAt(e.clientX,e.clientY),r=t.active,i=t.selection;if(n.region!==`cell`||n.part||!r||r.row!==n.row||r.col!==n.col||i.kind!==`cells`||!BE(i.anchor,i.focus))return;let a=this.cellOf(r);a?.field.type===`document_link`?this.handlers.onOpenLink?.({recordId:a.recordId,fieldId:a.field.id,index:0}):a&&(a.field.type===`date`||a.field.type===`datetime`)&&this.edit(r,null)}edit(e,t){if(this.session||this.options.readOnly)return;let n=this.cellOf(e);if(!n||!ZE(n.field))return;let{recordId:r,field:i}=n;switch(i.type){case`checkbox`:t===null&&this.toggle(r,i);return;case`rating`:t&&/^[0-9]$/.test(t)&&this.write(()=>this.data.update(r,{[i.name]:Number(t)||null}),AO([r]));return;case`date`:case`datetime`:case`single_select`:case`multi_select`:this.openPopup(e,r,i,t);return;case`attachment`:t===null&&this.preview(r,i,0);return}xO.has(i.type)&&this.openText(e,r,i,t)}startTyping(e,t){let n=this.grid?.active;if(!n||this.options.readOnly){this.input.value=``;return}let r=this.cellOf(n);!r||!ZE(r.field)?this.input.value=``:xO.has(r.field.type)?this.openText(n,r.recordId,r.field,t?null:e,!0):t||(this.input.value=``,this.edit(n,e))}openText(e,t,n,r,i=!1){let a=this.interaction,o={kind:`text`,cell:e,recordId:t,field:n,original:``};if(this.session=o,a.setEditing(!0),i||(this.input.value=r??``),this.place(),this.focus(),r!==null||i){this.value(t,n).then(e=>{this.session===o&&(o.original=EO(n,e))});return}this.busy+=1;let s=this.value(t,n).then(e=>EO(n,e));o.loading=s,s.then(e=>{this.session===o&&(o.original=e,o.loading=void 0,this.composing?o.before=e:this.putValueBefore(e))},e=>{this.session===o&&(o.loading=void 0),this.handlers.onError?this.handlers.onError(e):console.error(`grid: a cell could not be read`,e)}).finally(()=>{--this.busy})}putValueBefore(e){let t=this.session;t&&(t.before=void 0);let n=this.input,r=n.value,i=DO(e,r,{start:n.selectionStart??r.length,end:n.selectionEnd??r.length});n.value=i.text,n.setSelectionRange(i.start,i.end)}async openPopup(e,t,n,r){this.interaction.setEditing(!0),this.session={kind:`popup`,cell:e,recordId:t,field:n,original:``},this.busy+=1;try{let i=await this.value(t,n),a=this.session;if(a?.recordId!==t||a.field.id!==n.id)return;a.original=JSON.stringify(i??null);let o=this.interaction.cellScreenArea(e);a.popup={kind:n.type===`date`||n.type===`datetime`?`date`:`select`,field:n,recordId:t,value:i,anchor:o?this.clientRect(o):null,text:r,commit:e=>this.commitValue(e),draft:e=>{this.session===a&&(a.draft=e)},cancel:()=>this.close()},this.input.blur(),this.handlers.onPopup?.(a.popup)}catch(e){this.close(),this.handlers.onError?this.handlers.onError(e):console.error(`grid: a cell could not be read`,e)}finally{--this.busy}}commit(){let e=this.session;if(!e)return;if(e.kind===`popup`){e.draft===void 0?this.close():this.commitValue(e.draft);return}let t=this.input.value,{recordId:n,field:r,original:i,loading:a,before:o}=e;this.close(),a?a.then(e=>this.store(n,r,e,e+t),()=>{}):this.store(n,r,i,o==null?t:o+t)}store(e,t,n,r){if(r===n)return;let i=DT(t,r);this.write(()=>this.data.update(e,{[t.name]:i}),AO([e]))}commitValue(e){let t=this.session;if(!t)return;let{recordId:n,field:r,original:i}=t;this.close();let a=(r.type===`date`||r.type===`datetime`)&&e===``?null:e;JSON.stringify(a??null)!==i&&this.write(()=>this.data.update(n,{[r.name]:a}),AO([n]))}close(){let e=this.session;e&&(this.session=null,this.interaction.setEditing(!1),e.kind===`popup`&&this.handlers.onPopup?.(null),this.input.value=``,this.hide(),this.place(),this.focus())}onKey(e){let t=this.interaction,n=this.session;if(e.isComposing||this.composing||e.keyCode===229)return;if(!n){let n=this.clipboardKey(e);if(n&&this.copyByKey(n===`cut`)){e.preventDefault();return}t.handleKey(e)&&e.preventDefault();return}if(n.kind!==`text`)return;let r=n.field.type===`long_text`;switch(e.key){case`Enter`:if(r&&(e.shiftKey||e.altKey))return;e.preventDefault(),this.commit(),t.moveActive(0,e.shiftKey?-1:1);return;case`Tab`:e.preventDefault(),this.commit(),t.moveActive(e.shiftKey?-1:1,0);return;case`Escape`:e.preventDefault(),this.close();return}}async write(e,t){this.busy+=1;try{await e(),await(this.handlers.onWritten?this.handlers.onWritten(t):this.interaction.view.reopen()),this.copy=null,this.onSelection()}catch(e){this.handlers.onError?this.handlers.onError(e):console.error(`grid: a write failed`,e)}finally{--this.busy}}transact(e,t){return this.write(async()=>{let t=await e();t.length&&await this.data.transact(t)},t)}async toggle(e,t){let n=await this.value(e,t);await this.write(()=>this.data.update(e,{[t.name]:!n}),AO([e]))}fieldsOf(e){let t=this.interaction.view.currentAxes;return e.map(e=>t?.columns[e]?.fieldId).map(e=>e==null?void 0:this.data.field(e)).filter(e=>e!=null)}clear(e){let t=this.interaction,n=t.rows;if(this.session||!n||this.options.readOnly)return Promise.resolve();let{recordIds:r,cols:i}=QE(e,n,t.columnCount),a=this.fieldsOf(i);if(!r.length||!a.length)return Promise.resolve();if(r.length>1e3){let e=iD(a);return Object.keys(e).length?this.write(()=>this.data.clear(r,e),AO(r)):Promise.resolve()}return this.transact(async()=>aD(this.data.tableId,await this.data.records(r,[]),a),AO(r))}copyKey(){let e=this.grid;return e?`${e.view.currentAxes?.epoch}:${JSON.stringify(e.selection)}`:``}async copyText(e=this.interaction.selection){let t=this.interaction,n=t.rows;if(!n)return``;let{recordIds:r,cols:i}=QE(e,n,t.columnCount),a=this.fieldsOf(i);return!r.length||!a.length?``:eD(await this.data.records(r,a.map(e=>e.name)),a)}onSelection(){window.clearTimeout(this.copyTimer),this.session||this.place();let e=this.grid,t=e?.rows;if(!e||!t)return;let n=e.selection,{recordIds:r,cols:i}=QE(n,t,e.columnCount);if(!r.length||!i.length||r.length*i.length>vO)return;let a=this.copyKey();if(this.copy?.key===a)return;let o=++this.copyRun;this.copyTimer=window.setTimeout(()=>{this.copyText(n).then(e=>{o===this.copyRun&&(this.copy={key:a,text:e})})},30)}clipboardKey(e){let t=this.options.mac===!0;if(e.shiftKey||e.altKey||(t?!e.metaKey||e.ctrlKey:!e.ctrlKey||e.metaKey))return null;let n=/^[a-z]$/i.test(e.key)?e.key.toLowerCase():e.code===`KeyC`?`c`:e.code===`KeyX`?`x`:``;return n===`c`?`copy`:n===`x`?`cut`:null}copyByKey(e){let t=typeof navigator<`u`?navigator.clipboard:void 0,n=this.interaction.selection;return!t||n.kind===`none`?!1:(this.keyCopy=!0,window.setTimeout(()=>{this.keyCopy=!1},0),OO(t,(this.copy?.key===this.copyKey()?this.copy.text:null)??this.copyText(n)).then(()=>e?this.clear(n):void 0,e=>console.error(`grid: copy failed`,e)),!0)}onCopy(e,t){if(this.session)return;if(this.keyCopy){e.preventDefault();return}let n=this.interaction.selection;n.kind!==`none`&&(e.preventDefault(),this.copy?.key===this.copyKey()&&e.clipboardData?e.clipboardData.setData(`text/plain`,this.copy.text):navigator.clipboard&&OO(navigator.clipboard,this.copyText(n)).catch(e=>console.error(`grid: copy failed`,e)),t&&this.clear(n))}onPaste(e){if(this.session||this.options.readOnly)return;let t=ET(e.clipboardData),n=this.grid?.active,r=t.length&&n?this.cellOf(n):null;if(r&&r.field.type===`attachment`&&ZE(r.field)&&this.data.upload){e.preventDefault(),this.addFiles(r.recordId,r.field,t);return}let i=e.clipboardData?.getData(`text/plain`)??``;i&&(e.preventDefault(),this.paste(i))}paste(e){if(this.options.readOnly)return Promise.resolve();let t=this.interaction,n=t.rows,r=t.selection,i=r.kind===`cells`?{row:Math.min(r.anchor.row,r.focus.row),col:Math.min(r.anchor.col,r.focus.col)}:t.active;if(!n||!i)return Promise.resolve();let a=rD(e),o=tD(n,i.row,a),s=Array.from({length:Math.max(0,t.columnCount-i.col)},(e,t)=>i.col+t),c=this.fieldsOf(s);return this.transact(async()=>nD(this.data.tableId,e,await this.data.records(o,[]),c),AO(o))}async cellPart(e){let t=e.part;if(!t||e.row<0)return;let n=this.cellOf({row:e.row,col:t.col});if(!n)return;let{recordId:r,field:i}=n;switch(t.kind){case yD.Checkbox:ZE(i)&&await this.toggle(r,i);return;case yD.Rating:{if(!ZE(i))return;let e=Number(await this.value(r,i))||0,n=t.index+1;await this.write(()=>this.data.update(r,{[i.name]:e===n?null:n}),AO([r]));return}case yD.Attachment:await this.preview(r,i,t.index);return;case yD.Button:this.handlers.onButton?.({recordId:r,fieldId:i.id});return;case yD.Link:this.handlers.onOpenLink?.({recordId:r,fieldId:i.id,index:t.index});return}}async preview(e,t,n){let r=TT(await this.value(e,t));r.length&&this.handlers.onPreviewAttachments?.({recordId:e,fieldId:t.id,items:r,index:Math.min(n,r.length-1)})}dragActions(){let e=()=>this.interaction;return{canMoveRows:()=>!0,resize:(e,t,n)=>void this.write(()=>this.data.patchFieldWidth(t,n),jO),freeze:e=>void this.write(()=>this.data.setFrozen(e),jO),moveColumns:(t,n)=>{let r=e().view.currentAxes;if(!r)return;let i=r.columns.slice(0,xD(r)).map(e=>e.fieldId),a=lD(this.data.fields().map(e=>e.id),i,t[0],t[t.length-1],n);if(a==null)return;let o=t.map(e=>i[e]);this.transact(async()=>cD(this.data.tableId,o,a),jO)},moveRow:(t,n,r)=>{let i=e().rows,a=i?.recordId(t),o=i?.recordId(n);if(!i||a==null||o==null)return;let s=r?tD(i,n+1,1)[0]:o;this.transact(async()=>{let e=s==null?[a]:[a,s],t=await this.data.records(e,[]),n=e=>t.find(t=>t.id===e)?.row_key??null,r=n(a);return r?sD(this.data.tableId,r,s==null?null:n(s)):[]},AO([a]))},fill:(t,n)=>{let r=e().rows;if(!r)return;let i=NO(r,t.top,t.bottom),a=n.down?1:-1,o=[];for(let e=n.from;n.down?e<=n.to:e>=n.to;e+=a){let t=r.recordId(e);t!=null&&o.push(t)}let s=this.fieldsOf(Array.from({length:t.right-t.left+1},(e,n)=>t.left+n));this.transact(async()=>{let e=await this.data.records(i,s.map(e=>e.name)),t=new Map(e.map(e=>[e.id,e])),r=i.map(e=>t.get(e)).filter(e=>e!=null);return oD(this.data.tableId,r,await this.data.records(o,[]),s,n.down)},AO(o)).then(()=>{let r=e(),i=n.down?t.top:n.to,a=n.down?n.to:t.bottom,o=RE({row:i,col:t.left},{row:a,col:t.right});VE(o,r.selection)||r.setSelection(o,r.active)})}}}loadImages(e){let t=this.interaction.view.resources;for(let n of e)bO.test(n.url.trim())||this.images.get(n.key)===`loading`||t.image(n.key)||(this.images.set(n.key,`loading`),this.decode(n.url).then(e=>{if(this.images.set(n.key,`done`),!e)return;let t=this.interaction.view;t.resources.setImage(n.key,e),t.invalidate()}))}async decode(e){try{let t=this.handlers.resolveFileURL?this.handlers.resolveFileURL(e):yO.test(e.trim())?e.trim():``;return t?await MO(t):null}catch{return null}}addButtonAt(e){let t=this.interaction,n=t.active;if(e.region!==`cell`||!this.data.upload||!n||e.row!==n.row||e.col!==n.col||this.session)return null;let r=this.cellOf(n);if(!r||r.field.type!==`attachment`||!ZE(r.field))return null;let i=t.cellScreenArea(n);return i&&TO(CO(i),e.x,e.y)?r:null}pickFiles(e,t){let n=this.picker;n||(n=document.createElement(`input`),n.type=`file`,n.multiple=!0,n.dataset.ktableGridFiles=`true`,n.style.display=`none`,n.addEventListener(`change`,()=>{let e=this.picking,t=Array.from(n?.files??[]);this.picking=null,n&&(n.value=``),e&&t.length&&this.addFiles(e.recordId,e.field,t)}),this.interaction.view.element.append(n),this.picker=n),this.picking={recordId:e,field:t},n.click()}addFiles(e,t,n){let r=this.data;return!r.upload||!n.length?Promise.resolve():this.write(async()=>{let i=await Promise.all(n.map(e=>r.upload?.(e))),a=TT(await this.value(e,t));await r.update(e,{[t.name]:[...a,...i.filter(e=>e!=null)]})},AO([e]))}paintAdd(e){let t=this.interaction,n=t.active;if(!n||!this.data.upload||this.session)return;let r=this.cellOf(n);if(!r||r.field.type!==`attachment`||!ZE(r.field))return;let i=t.cellScreenArea(n);if(!i)return;let{ctx:a,dpr:o,style:s}=e,c=CO(i);a.save(),a.setTransform(o,0,0,o,0,0),a.beginPath(),a.rect(i.x,i.y,i.width,i.height),a.clip(),a.fillStyle=s.rowHead,a.beginPath(),a.roundRect(c.x,c.y,c.width,c.height,4),a.fill(),a.fillStyle=this.overAddButton?s.selection:s.hover,a.fill(),a.strokeStyle=this.overAddButton?s.border:s.control,a.lineWidth=1.5,a.lineCap=`round`;let l=c.x+c.width/2,u=c.y+c.height/2,d=c.width/2-5;a.beginPath(),a.moveTo(l-d,u),a.lineTo(l+d,u),a.moveTo(l,u-d),a.lineTo(l,u+d),a.stroke(),a.restore()}setGenerating(e){this.generating=new Set(e.map(e=>`${e.recordId}:${e.fieldId}`)),this.interaction.invalidateOverlay(),this.spin()}spin(){if(this.spinFrame||!this.generating.size)return;let e=()=>{this.spinFrame=0,this.generating.size&&(this.interaction.invalidateOverlay(),this.spinFrame=requestAnimationFrame(e))};this.spinFrame=requestAnimationFrame(e)}isAI(e){return(e==null?void 0:this.data.field(e))?.ai_config?.enabled===!0}aiButtonAt(e){if(e.region!==`cell`||!this.handlers.onRegenerate)return null;let t=this.interaction,n=t.view.currentAxes?.columns[e.col]?.fieldId,r=t.rows?.recordId(e.row);if(n==null||r==null||!this.isAI(n))return null;let i=t.cellScreenArea({row:e.row,col:e.col});return i&&TO(wO(i),e.x,e.y)?{recordId:r,fieldId:n}:null}paintAI(e){let t=this.interaction,{ctx:n,dpr:r,style:i}=e,a=t.hover,o=(e,t)=>{let a=wO(e);n.save(),n.setTransform(r,0,0,r,0,0),n.fillStyle=t?i.selection:i.hover,n.beginPath(),n.roundRect(a.x,a.y,a.width,a.height,4),n.fill(),n.strokeStyle=t?i.border:i.control,n.fillStyle=n.strokeStyle,n.lineWidth=1.4;let o=a.x+a.width/2,s=a.y+a.height/2,c=(a.width-8)/2;n.beginPath(),n.arc(o,s,c,Math.PI*.2,Math.PI*1.8),n.stroke();let l=o+c*Math.cos(Math.PI*1.8),u=s+c*Math.sin(Math.PI*1.8);n.beginPath(),n.moveTo(l,u),n.lineTo(l+3,u-1),n.lineTo(l+1,u+3),n.closePath(),n.fill(),n.restore()};if(a?.region===`cell`&&this.handlers.onRegenerate){let n=e.axes.columns[a.col]?.fieldId,r=this.isAI(n)?t.cellScreenArea({row:a.row,col:a.col}):null;r&&o(r,TO(wO(r),a.x,a.y))}if(!this.generating.size||!e.rows)return;let s=e.rows,c=e.axes,l=xD(c),u=Math.max(0,c.rowAt(e.viewport.scrollY+c.headerHeight)),d=Math.min(c.rows-1,c.rowAt(e.viewport.scrollY+e.viewport.height-.001)),f=performance.now()/1e3*Math.PI*2%(Math.PI*2);for(let e=u;e<=d;e+=1){let a=s.recordId(e);if(a!=null)for(let o=0;o<l;o+=1){if(!this.generating.has(`${a}:${c.columns[o].fieldId}`))continue;let s=t.cellScreenArea({row:e,col:o});if(!s)continue;n.save(),n.setTransform(r,0,0,r,0,0),n.beginPath(),n.rect(s.x,s.y,s.width,s.height),n.clip(),n.fillStyle=i.hover,n.fillRect(s.x,s.y,s.width,s.height-1);let l=Math.min(8,Math.min(s.width,s.height)/3);n.translate(s.x+s.width/2,s.y+s.height/2),n.rotate(f),n.strokeStyle=i.border,n.lineWidth=2,n.lineCap=`round`;for(let e=0;e<8;e+=1)n.globalAlpha=(e+1)/8,n.beginPath(),n.moveTo(0,-l),n.lineTo(0,-l*.55),n.stroke(),n.rotate(Math.PI/4);n.restore()}}}},AO=e=>({kind:`cells`,records:e}),jO={kind:`layout`};async function MO(e){let t=async t=>{let n=new Image;return t&&(n.crossOrigin=`anonymous`),n.decoding=`async`,n.src=e,await n.decode(),createImageBitmap(n)};if(/^(data:|blob:)/i.test(e))return t(!1);try{return await t(!0)}catch{return t(!1)}}function NO(e,t,n){let r=[];for(let i=t;i<=n;i+=1){let t=e.recordId(i);t!=null&&r.push(t)}return r}function PO(e,t,n){let r=new Map,i=i=>{let a=r.get(i);if(a===void 0){a=!1;let o=Math.min(e.count,(i+1)*t);for(let r=i*t;r<o&&!a;r+=1){let t=e.recordId(r);a=t!=null&&(n?.has(t)??!1)}r.set(i,a)}return a};return e=>e.layer!==uD.Header&&e.layer!==uD.HeaderFrozen&&(n===null||i(e.rowBand))}var FO=class{epoch;rows;columns;headerHeight;rowHeadWidth;bandRows;bandWidth;frozenWidth;bodyLeft;width;height;runRow;runTop;runHeight;constructor(e){this.epoch=e.epoch,this.columns=e.columns,this.headerHeight=e.headerHeight,this.rowHeadWidth=e.rowHeadWidth,this.bandRows=Math.max(1,e.bandRows),this.bandWidth=Math.max(1,e.bandWidth);let t=e.rowRuns.filter(([,e])=>e>0);this.runRow=new Float64Array(t.length+1),this.runTop=new Float64Array(t.length+1),this.runHeight=new Float64Array(t.length);let n=0,r=e.headerHeight;t.forEach(([e,t],i)=>{this.runRow[i]=n,this.runTop[i]=r,this.runHeight[i]=e,n+=t,r+=e*t}),this.runRow[t.length]=n,this.runTop[t.length]=r,this.rows=n,this.height=r;let i=e.columns.filter(e=>e.frozen);this.frozenWidth=i.reduce((e,t)=>e+t.width,0),this.bodyLeft=e.rowHeadWidth+this.frozenWidth;let a=e.columns[e.columns.length-1];this.width=a?Math.max(this.bodyLeft,a.x+a.width):this.bodyLeft}run(e){let t=0,n=this.runHeight.length-1;for(;t<n;){let r=t+n+1>>1;this.runRow[r]<=e?t=r:n=r-1}return t}rowTop(e){if(e<=0||this.rows===0)return this.headerHeight;if(e>=this.rows)return this.height;let t=this.run(e);return this.runTop[t]+(e-this.runRow[t])*this.runHeight[t]}rowHeight(e){return e<0||e>=this.rows?0:this.runHeight[this.run(e)]}rowAt(e){if(e<this.headerHeight)return-1;if(e>=this.height)return this.rows;let t=0,n=this.runHeight.length-1;for(;t<n;){let r=t+n+1>>1;this.runTop[r]<=e?t=r:n=r-1}return Math.min(this.runRow[t+1]-1,this.runRow[t]+Math.floor((e-this.runTop[t])/this.runHeight[t]))}columnAt(e){let t=0,n=this.columns.length-1;for(;t<=n;){let r=t+n>>1,i=this.columns[r];if(e<i.x)n=r-1;else if(e>=i.x+i.width)t=r+1;else return r}return-1}get rowBands(){return Math.ceil(this.rows/this.bandRows)}get colBands(){return Math.max(1,Math.ceil((this.width-this.bodyLeft)/this.bandWidth))}bandArea(e){let t=()=>{let t=this.rowTop(e.rowBand*this.bandRows);return[t,this.rowTop((e.rowBand+1)*this.bandRows)-t]},n=()=>{let t=this.bodyLeft+e.colBand*this.bandWidth;return[t,Math.max(0,Math.min(this.bandWidth,this.width-t))]};switch(e.layer){case uD.Body:{let[e,r]=t(),[i,a]=n();return{x:i,y:e,width:a,height:r}}case uD.Frozen:{let[e,n]=t();return{x:this.rowHeadWidth,y:e,width:this.frozenWidth,height:n}}case uD.RowHead:{let[e,n]=t();return{x:0,y:e,width:this.rowHeadWidth,height:n}}case uD.Header:{let[e,t]=n();return{x:e,y:0,width:t,height:this.headerHeight}}case uD.HeaderFrozen:return{x:0,y:0,width:this.bodyLeft,height:this.headerHeight};case uD.View:return{x:0,y:0,width:this.width,height:this.height}}}};function IO(e,t,n,r,i){let a=[];if(e.rows>0){let o=Math.max(0,e.rowAt(Math.max(e.headerHeight,t))),s=Math.min(e.rows-1,e.rowAt(Math.min(e.height-.001,n))),c=Math.floor(o/e.bandRows),l=Math.floor(s/e.bandRows),u=Math.max(0,Math.floor((r-e.bodyLeft)/e.bandWidth)),d=Math.min(e.colBands-1,Math.floor((i-e.bodyLeft)/e.bandWidth));for(let t=c;t<=l;t+=1){for(let e=u;e<=d;e+=1)a.push({layer:uD.Body,colBand:e,rowBand:t});e.frozenWidth>0&&a.push({layer:uD.Frozen,colBand:0,rowBand:t}),a.push({layer:uD.RowHead,colBand:0,rowBand:t})}}return a}function LO(e){return`${e.layer}:${e.colBand}:${e.rowBand}`}var RO=new TextDecoder(`utf-8`,{fatal:!0});function zO(e){return String.fromCharCode(e[0],e[1],e[2],e[3])}function BO(e,t,n,r){let i=e.getUint32(n,!0),a=e.getUint32(n+4,!0),o=n+16;if(o+i*a*4!==r)throw Error(`a resource tile is not its size`);return{width:i,height:a,left:e.getInt32(n+8,!0),top:e.getInt32(n+12,!0),rgba:t.slice(o,r)}}function VO(e){let t=e,n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(t.byteLength<12||zO(t)!==`KTRS`)throw Error(`not a resource table`);let r=n.getUint16(4,!0);if(r!==1)throw Error(`resource table version ${r}; this build reads version 1`);let i={version:n.getUint16(6,!0),icons:[],emoji:[],images:[]},a=n.getUint32(8,!0),o=12;for(let e=0;e<a;e+=1){if(o+8>t.byteLength)throw Error(`the resource table is cut short`);let e=t[o],r=n.getUint32(o+4,!0),a=o+8,s=a+r;if(s>t.byteLength)throw Error(`the resource table is cut short`);if(e===1)i.icons.push({id:n.getUint16(a,!0),solid:t[a+2]!==0,size:n.getFloat32(a+4,!0),stroke:n.getFloat32(a+8,!0),dpr:n.getFloat32(a+12,!0),paint:n.getUint32(a+16,!0),...BO(n,t,a+20,s)});else if(e===2)i.emoji.push({atlas:n.getUint32(a,!0),size:n.getFloat32(a+4,!0),dpr:n.getFloat32(a+8,!0),...BO(n,t,a+12,s)});else if(e===3){let e=n.getUint32(a+12,!0);if(a+16+e!==s)throw Error(`an image entry is not its length`);i.images.push({key:n.getUint32(a,!0),width:n.getUint32(a+4,!0),height:n.getUint32(a+8,!0),url:RO.decode(t.subarray(a+16,s))})}else throw Error(`the resource table has an unknown entry kind ${e}`);o=a+(r+3&-4)}if(o!==t.byteLength)throw Error(`the resource table has bytes after its entries`);return i}function HO(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(t.byteLength<12||zO(t)!==`KTDB`)throw Error(`not a band batch`);let r=n.getUint16(4,!0);if(r!==2)throw Error(`band batch version ${r}; this build reads version 2`);let i=n.getUint32(8,!0),a={bands:[],resources:null,bytes:t.byteLength},o=12;for(let e=0;e<i;e+=1){if(o+8>t.byteLength)throw Error(`the band batch is cut short`);let e=t[o],r=n.getUint32(o+4,!0),i=o+8;if(i+r>t.byteLength)throw Error(`the band batch is cut short`);let s=t.subarray(i,i+r);if(e===1)a.bands.push(vD(s));else if(e===2){if(a.resources)throw Error(`the band batch has two resource tables`);a.resources=VO(s)}else throw Error(`the band batch has an unknown item kind ${e}`);o=i+(r+3&-4)}return a}var UO=2097152,WO=class{maxBands;maxBytes;lists=new Map;stale=new Set;size=0;constructor(e=48,t=UO){this.maxBands=e,this.maxBytes=t}get bytes(){return this.size}get count(){return this.lists.size}has(e){let t=LO(e);return this.lists.has(t)&&!this.stale.has(t)}get(e){let t=LO(e),n=this.lists.get(t);return n&&(this.lists.delete(t),this.lists.set(t,n)),n}peek(e){let t=LO(e);return this.stale.has(t)?void 0:this.lists.get(t)}drawn(e){return this.lists.get(LO(e))}markStale(e){let t=0;for(let[n,r]of this.lists)!this.stale.has(n)&&e(r.header.key)&&(this.stale.add(n),t+=1);return t}put(e,t=new Set){let n=LO(e.header.key),r=this.lists.get(n);r&&(this.size-=r.bytes,this.lists.delete(n)),this.lists.set(n,e),this.stale.delete(n),this.size+=e.bytes;for(let[e,r]of this.lists){if(this.lists.size<=this.maxBands&&this.size<=this.maxBytes)break;e===n||t.has(e)||(this.lists.delete(e),this.stale.delete(e),this.size-=r.bytes)}}delete(e){let t=LO(e),n=this.lists.get(t);n&&(this.size-=n.bytes,this.lists.delete(t),this.stale.delete(t))}keepEpoch(e){for(let[t,n]of this.lists)n.header.epoch!==e&&(this.lists.delete(t),this.stale.delete(t),this.size-=n.bytes)}clear(){this.lists.clear(),this.stale.clear(),this.size=0}},GO=6,KO=.5,qO=15e6,JO=3e3,YO=50,XO=class{source;element;scroller;content;overlay;stats;resources=new JD;cache=new WO;spacer;fonts;axes=null;skeleton={background:`#fff`,line:`#e5e5e5`};dpr=1;width=0;height=0;scrollX=0;scrollY=0;velocity=0;frameY=0;frameReach=0;lastScroll={y:0,at:0};samples=[];perDraft=.8;perRequest=2;frame=0;inFlight=!1;received=0;destroyed=!1;again=0;overlayPainter=null;cleanup=[];axesListeners=new Set;frameListeners=new Set;imageListeners=new Set;pictures=new Set;opened=null;textSizing=null;overlayDraws=0;constructor(e,t,n){this.source=t,this.stats=n.stats?{frames:[],requests:[],firstContent:null,bands:new Map,planned:new Set,requested:new Set}:null,this.fonts=new VD(n.fontsBase,()=>this.invalidate());let r=t.fonts;r&&(this.fonts.engine=r,this.cleanup.push(r.subscribe(()=>{this.cache.markStale(()=>!0),this.invalidate()}))),this.element=document.createElement(`div`),this.element.style.cssText=`position:relative;width:100%;height:100%;overflow:hidden`,this.scroller=document.createElement(`div`),this.scroller.dataset.ktableGridStage=`true`,this.scroller.style.cssText=`position:absolute;inset:0;overflow:auto;overscroll-behavior:contain`,this.spacer=document.createElement(`div`),this.spacer.style.cssText=`width:1px;height:1px`,this.scroller.append(this.spacer),this.content=document.createElement(`canvas`),this.content.dataset.ktableGridContent=`true`,this.overlay=document.createElement(`canvas`),this.overlay.dataset.ktableGridOverlay=`true`;for(let e of[this.content,this.overlay])e.style.cssText=`position:absolute;left:0;top:0;pointer-events:none`;this.element.append(this.scroller,this.content,this.overlay),e.append(this.element);let i=()=>this.onScroll();this.scroller.addEventListener(`scroll`,i,{passive:!0}),this.cleanup.push(()=>this.scroller.removeEventListener(`scroll`,i));let a=new ResizeObserver(()=>this.resize());a.observe(this.scroller),this.cleanup.push(()=>a.disconnect()),this.watchDpr()}async open(){let e=this.fonts.start().then(()=>BD()),[t,n]=await Promise.all([this.source.open(),e]);this.textSizing=n;let r=n.sizing!==`auto`&&this.source.opticalSizing?await this.source.opticalSizing(n.sizing):!1;this.setAxes(r?await this.source.open():t)}async reopen(){this.setAxes(await this.source.open())}setAxes(e){this.axes=new FO(e.axes),this.opened=e,this.skeleton=e.skeleton,this.cache.keepEpoch(this.axes.epoch);for(let t of this.axesListeners)t(e);this.resize()}onAxes(e){return this.axesListeners.add(e),()=>this.axesListeners.delete(e)}onFrame(e){return this.frameListeners.add(e),()=>this.frameListeners.delete(e)}loadImages(e){let t=this.source.image?.bind(this.source);if(t)for(let n of e)this.pictures.has(n.key)||this.resources.image(n.key)||(this.pictures.add(n.key),t(n.url,n.width,n.height).then(e=>{e&&!this.destroyed&&(this.resources.setImage(n.key,e),this.invalidate())}).catch(()=>void 0))}onImages(e){return this.imageListeners.add(e),()=>this.imageListeners.delete(e)}scrollBy(e,t){let n=this.scrollMap();this.scroller.scrollLeft+=e/n.x,this.scroller.scrollTop+=t/n.y,this.onScroll()}redrawOverlay(){this.drawOverlay()}allFonts(){return this.fonts.all()}setOverlay(e){this.overlayPainter=e,this.drawOverlay()}scrollTo(e,t){let n=this.scrollMap();this.scroller.scrollLeft=e/n.x,this.scroller.scrollTop=t/n.y,this.onScroll()}complete(){return this.needed().every(e=>this.exact(e))}exact(e){let t=this.cache.peek(e);return!!t&&!(t.header.flags&1)}get fetching(){return this.inFlight}neededKeys(){return this.needed()}get viewport(){return{scrollX:this.scrollX,scrollY:this.scrollY,width:this.width,height:this.height,dpr:this.dpr}}get currentAxes(){return this.axes}invalidate(){!this.frame&&!this.destroyed&&(this.frame=requestAnimationFrame(e=>this.draw(e)))}destroy(){this.destroyed=!0,this.frame&&cancelAnimationFrame(this.frame),this.again&&clearTimeout(this.again);for(let e of this.cleanup)e();this.element.remove()}watchDpr(){let e=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),t=()=>{e.removeEventListener(`change`,t),this.resources.dropTiles(),this.cache.clear(),this.resize(),this.watchDpr()};e.addEventListener(`change`,t),this.cleanup.push(()=>e.removeEventListener(`change`,t))}scrollMap(){let e=this.axes;if(!e)return{x:1,y:1};let t=(e,t)=>{let n=Math.min(e,qO);return n>t&&e>n?(e-t)/(n-t):1};return{x:t(e.width,this.width),y:t(e.height,this.height)}}resize(){if(!this.destroyed){this.dpr=window.devicePixelRatio||1,this.width=this.scroller.clientWidth,this.height=this.scroller.clientHeight;for(let e of[this.content,this.overlay]){let t=Math.round(this.width*this.dpr),n=Math.round(this.height*this.dpr);e.width!==t&&(e.width=t),e.height!==n&&(e.height=n),e.style.width=`${this.width}px`,e.style.height=`${this.height}px`}this.axes&&(this.spacer.style.width=`${Math.min(this.axes.width,qO)}px`,this.spacer.style.height=`${Math.min(this.axes.height,qO)}px`),this.onScroll(),this.drawOverlay()}}onScroll(){let e=this.scrollMap(),t=e=>Math.round(e*this.dpr)/this.dpr,n=t(this.scroller.scrollTop*e.y),r=performance.now(),i=document.timeline?.currentTime,a=typeof i==`number`?i:r,o=this.samples[this.samples.length-1];for(o&&o.at===a?o.y=n:(!o||o.y!==n)&&this.samples.push({y:n,at:a});this.samples.length>24||this.samples.length>1&&a-this.samples[0].at>200;)this.samples.shift();let s=r-this.lastScroll.at;s>0&&s<250?this.velocity=(n-this.lastScroll.y)/s*1e3:s>=250&&(this.velocity=0),this.lastScroll={y:n,at:r},this.scrollX=t(this.scroller.scrollLeft*e.x),this.scrollY=n,this.invalidate()}regions(e){let{width:t,height:n,scrollX:r,scrollY:i}=this,{rowHeadWidth:a,bodyLeft:o,headerHeight:s}=e,c=[{layer:`body`,clip:{x:o,y:s,width:t-o,height:n-s},ox:r,oy:i},{layer:`rowHead`,clip:{x:0,y:s,width:a,height:n-s},ox:0,oy:i},{layer:`header`,clip:{x:o,y:0,width:t-o,height:s},ox:r,oy:0},{layer:`headerFrozen`,clip:{x:0,y:0,width:o,height:s},ox:0,oy:0}];return e.frozenWidth>0&&c.splice(1,0,{layer:`frozen`,clip:{x:a,y:s,width:e.frozenWidth,height:n-s},ox:0,oy:i}),c}keysFor(e,t,n,r,i){let a=[{layer:uD.HeaderFrozen,colBand:0,rowBand:0}],o=Math.max(0,Math.floor((r-e.bodyLeft)/e.bandWidth)),s=Math.min(e.colBands-1,Math.floor((i-e.bodyLeft)/e.bandWidth));for(let e=o;e<=s;e+=1)a.push({layer:uD.Header,colBand:e,rowBand:0});return a.concat(IO(e,t,n,r,i))}needed(){let e=this.axes;if(!e)return[];let t=this.scrollY+e.headerHeight,n=this.scrollX+e.bodyLeft;return this.keysFor(e,t,this.scrollY+this.height,n,this.scrollX+this.width)}reach(e){return Math.max(1,this.height-e.headerHeight)*(Math.abs(this.velocity)>JO?2:1)}wanted(){let e=this.axes;if(!e)return[];let t=Math.max(1,this.height-e.headerHeight),n=this.reach(e),r=this.velocity>=0,i=this.scrollY+e.headerHeight,a=this.scrollY+this.height,o=this.scrollX+e.bodyLeft,s=this.scrollX+this.width,c=Math.max(1,s-o),l=[this.keysFor(e,i,a,o,s),r?this.keysFor(e,a,a+n,o,s):this.keysFor(e,i-n,i,o,s),r?this.keysFor(e,i-t,i,o,s):this.keysFor(e,a,a+t,o,s),this.keysFor(e,i,a,s,s+c),this.keysFor(e,i,a,o-c,o)],u=new Set,d=[];for(let e of l)for(let t of e){let e=LO(t);u.has(e)||this.exact(t)||(u.add(e),d.push(t))}return d}jump(e){let t=this.samples,n=t[t.length-1],r=t[t.length-2];if(!n||!r)return null;let i=t.slice(1).map((e,n)=>e.at-t[n].at),a=[...i].sort((e,t)=>e-t)[i.length>>1],o=i.filter(e=>e<1.5*a),s=o.reduce((e,t)=>e+t,0)/Math.max(1,o.length);if(!(s>0)||performance.now()-n.at>1.5*s)return null;let c=this.height-e.headerHeight,l=[];for(let e=t.length-1;e>=0&&l.length<GO;--e){let n=t[e-1],r=n!==void 0&&t[e].at-n.at<1.5*s;if(l.push([r?n.at:t[e].at-s,t[e].y]),!r)break}if(l.length>=2){let e=l.reduce((e,[t])=>e+t,0)/l.length,t=l.reduce((e,[,t])=>e+t,0)/l.length,r=0,i=0;for(let[n,a]of l)r+=(n-e)*(a-t),i+=(n-e)**2;let a=r/i,o=l.every(([n,r])=>Math.abs(t+a*(n-e)-r)<=Math.abs(a)*s/4);if(Number.isFinite(a)&&o)return Math.abs(a)*s<=c?null:{v:a,frame:s,span:l[0][0]-l[l.length-1][0],at:n.at,y:r=>t+a*(n.at+(r-1)*s-e)}}let u=(n.y-r.y)/(n.at-r.at);return!Number.isFinite(u)||Math.abs(u)*s<=c?null:{v:u,frame:s,span:n.at-r.at,at:n.at,y:e=>n.y+u*e*s}}predicted(e,t){let n=Math.max(0,e.height-this.height),r=this.scrollX+e.bodyLeft,i=this.scrollX+this.width,a=e=>Math.abs(t.v)*KO*(1+e*t.frame/Math.max(t.span,t.frame)),o=o=>{let s=Math.min(n,Math.max(0,t.y(o))),c=a(o),l=s+(e.headerHeight+this.height)/2,u=t=>{let n=e.bandArea(t);return Math.abs(n.y+n.height/2-l)};return this.keysFor(e,s+e.headerHeight-c,s+this.height+c,r,i).filter(e=>e.layer!==uD.Header&&e.layer!==uD.HeaderFrozen).filter(e=>!this.cache.has(e)).sort((e,t)=>u(e)-u(t))},s=1,c=o(s);for(let e=0;e<2;e+=1){let e=this.perRequest+Math.min(c.length,18)*this.perDraft,n=performance.now()+e*1.15+1;s=Math.max(1,Math.ceil((n-t.at)/t.frame)),c=o(s)}return c.slice(0,18)}leaping(e){let[t,n]=this.samples.slice(-2);if(!t||!n)return!1;let r=n.at-t.at;return performance.now()-n.at<1.5*Math.min(r,17)&&Math.abs(n.y-t.y)>this.height-e.headerHeight}request(){let e=this.axes;if(!e||this.inFlight||this.destroyed)return;let t=this.jump(e),n=!t&&this.leaping(e),r=t?this.predicted(e,t):n?this.needed().filter(e=>!this.cache.has(e)).slice(0,18):this.wanted().slice(0,2);if(!r.length){(t||n)&&this.lookAgain();return}let i=t!==null||n;if(this.stats)for(let e of r)this.stats.requested.add(LO(e));this.inFlight=!0;let a=this.dpr,o=e.epoch,s=performance.now(),c=this.resources.session;this.source.bands(o,r,a,c,i).then(e=>{let t=performance.now()-s,n=HO(e);this.stats?.requests.push({bands:r.length,ms:t,bytes:n.bytes}),i&&(this.perDraft=.7*this.perDraft+.3*Math.max(.1,(t-this.perRequest)/r.length)),this.received+=n.bytes;let o=n.resources;if(o){if(a===this.dpr&&c===this.resources.session){for(let e of o.icons)this.resources.addIcon(e,a);for(let e of o.emoji)this.resources.addEmoji(e,a)}if(o.images.length){this.loadImages(o.images);for(let e of this.imageListeners)e(o.images)}}let l=new Set(this.needed().map(LO));for(let e of n.bands)this.axes&&e.header.epoch===this.axes.epoch&&(e.header.flags&1&&this.exact(e.header.key)||this.cache.put(e,l))}).catch(e=>{this.resources.renewSession(),/is laid out for arrangement/.test(String(e))||console.error(`grid: gridBands failed`,e)}).finally(()=>{this.inFlight=!1,this.invalidate(),this.request()})}lookAgain(){this.again||this.destroyed||(this.again=window.setTimeout(()=>{this.again=0,this.invalidate()},YO))}draw(e){this.frame=0;let t=this.axes,n=this.content.getContext(`2d`);if(!t||!n)return;let r=performance.now(),i=this.dpr;n.setTransform(1,0,0,1,0,0),n.fillStyle=this.skeleton.background,n.fillRect(0,0,this.content.width,this.content.height);let a=!1,o=!1,s=this.needed();for(let e of this.regions(t)){let r=e.clip;if(r.width<=0||r.height<=0)continue;n.save(),n.beginPath();let c=Math.round(r.x*i),l=Math.round(r.y*i);n.rect(c,l,Math.round((r.x+r.width)*i)-c,Math.round((r.y+r.height)*i)-l),n.clip();for(let r of s){if(ZO(r.layer)!==e.layer)continue;let s=this.cache.get(r);s?(s.header.flags&1&&(o=!0),$D({ctx:n,x:e.ox,y:e.oy,dpr:i},s,this.resources,this.fonts)):(a=!0,this.drawSkeleton(n,t,r,e.ox,e.oy))}n.restore()}let c=performance.now()-r;this.stats&&(this.stats.frames.push({at:e,playMs:c,skeleton:a,draft:o,bytes:this.received}),!a&&!o&&this.stats.firstContent===null&&(this.stats.firstContent=performance.now()),this.trackBands(t,e,s)),this.received=0,this.request(),this.drawOverlay();for(let e of this.frameListeners)e()}trackBands(e,t,n){let r=this.stats;if(!r)return;let i=r.bands.size===0,a=i?0:Math.abs(this.scrollY-this.frameY);for(let e of n){let n=LO(e);r.bands.has(n)||r.bands.set(n,{at:t,held:this.cache.peek(e)!==void 0,planned:r.planned.has(n),requested:r.requested.has(n),moved:a,reach:this.frameReach,first:i})}for(let e of this.wanted())r.planned.add(LO(e));this.frameY=this.scrollY,this.frameReach=this.reach(e)}drawSkeleton(e,t,n,r,i){let a=t.bandArea(n),o=this.dpr,s=Math.round((a.x-r)*o),c=Math.round((a.y-i)*o),l=Math.round((a.x+a.width-r)*o),u=Math.round((a.y+a.height-i)*o);if(e.setTransform(1,0,0,1,0,0),e.fillStyle=this.skeleton.background,e.fillRect(s,c,l-s,u-c),e.fillStyle=this.skeleton.line,n.layer!==uD.Header&&n.layer!==uD.HeaderFrozen){let r=n.rowBand*t.bandRows,a=Math.min(t.rows,r+t.bandRows);for(let n=r;n<a;n+=1){let r=t.rowTop(n+1);e.fillRect(s,Math.floor((r-.5-i)*o+1e-4),l-s,1)}}for(let n of t.columns){let t=n.x+n.width;t>a.x&&t<=a.x+a.width&&e.fillRect(Math.floor((t-.5-r)*o+1e-4),c,1,u-c)}}drawOverlay(){let e=this.overlay.getContext(`2d`);e&&(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,this.overlay.width,this.overlay.height),this.overlayDraws+=1,this.overlayPainter?.(e,this.dpr))}};function ZO(e){switch(e){case uD.Body:return`body`;case uD.Frozen:return`frozen`;case uD.RowHead:return`rowHead`;case uD.Header:return`header`;default:return`headerFrozen`}}var QO=2400;function $O(e,t,n,r){let i=e=>e<=0?0:Math.min(QO,e*24);return[i(n-(t.width-32))-i(e.bodyLeft+32-n),i(r-(t.height-32))-i(e.headerHeight+32-r)]}function ek(e,t){if(e.region!==t.region||e.row!==t.row||e.col!==t.col)return!1;let n=e.part,r=t.part;return n===r||n!=null&&r!=null&&n.kind===r.kind&&n.index===r.index&&n.row===r.row&&n.col===r.col}var tk=e=>e?`${e.region}:${e.row}:${e.col}:${e.part?.kind??``}:${e.part?.index??``}`:``,nk=class{view;handlers;state={selection:LE,active:null};hovered=null;isEditing=!1;drag=null;press=null;claimed=null;lastToggled=null;scrollFrame=0;scrollAt=0;activeIds={record:null,field:null};gestures=[];painters=[];changeListeners=new Set;geometryListeners=new Set;cleanup=[];constructor(e,t={}){this.view=e,this.handlers=t;let n=e.scroller;n.tabIndex=0,n.style.outline=`none`;let r=(e,t)=>{n.addEventListener(e,t),this.cleanup.push(()=>n.removeEventListener(e,t))};r(`pointerdown`,e=>this.onDown(e)),r(`pointermove`,e=>this.onMove(e)),r(`pointerup`,e=>this.onUp(e)),r(`pointercancel`,()=>this.endPointer()),r(`pointerleave`,()=>{!this.drag&&!this.claimed&&this.setHover(null)}),r(`dblclick`,e=>this.onDoubleClick(e)),r(`contextmenu`,e=>this.onContextMenu(e)),r(`keydown`,e=>{this.handleKey(e)&&e.preventDefault()}),this.cleanup.push(e.onAxes(()=>this.onAxes())),this.cleanup.push(e.onFrame(()=>{for(let e of this.geometryListeners)e()})),this.addPainter(e=>this.paintSelection(e),0),e.setOverlay((e,t)=>this.paint(e,t))}destroy(){cancelAnimationFrame(this.scrollFrame);for(let e of this.cleanup)e();this.view.setOverlay(null)}get selection(){return this.state.selection}get active(){return this.state.active}get hover(){return this.hovered}get rows(){return this.view.opened?.rows??null}get style(){return this.view.opened?.overlay??null}get editing(){return this.isEditing}setEditing(e){this.isEditing=e}get columnCount(){let e=this.view.currentAxes;return e?xD(e):0}setSelection(e,t=this.state.active){if(!(VE(e,this.state.selection)&&BE(t,this.state.active))){this.state={selection:e,active:t?{...t}:null},this.rememberActive(),this.view.redrawOverlay();for(let e of this.changeListeners)e(this.state)}}setActive(e,t={}){if(!e)return this.setSelection(LE,null);if(t.extend&&this.state.active){let t=this.state.selection.kind===`cells`?this.state.selection.anchor:this.state.active;this.setSelection(RE(t,e))}else this.setSelection(RE(e),e);t.scroll&&this.scrollToCell(e)}moveActive(e,t,n={}){let r=this.rows;if(!r)return;let i=this.state.active??{row:r.firstRecord,col:0};if(i.row<0)return;if(n.extend){let a=this.state.selection.kind===`cells`?this.state.selection.focus:i,o=YE(r,this.columnCount,a,e,t,n.jump);this.setActive(o,{extend:!0}),this.scrollToCell(o);return}let a=this.state.active?YE(r,this.columnCount,i,e,t,n.jump):i;this.setActive(a,{scroll:!0})}onChange(e){return this.changeListeners.add(e),()=>this.changeListeners.delete(e)}onGeometry(e){return this.geometryListeners.add(e),()=>this.geometryListeners.delete(e)}cellScreenArea(e){let t=this.view.currentAxes;if(!t)return null;let n=AD(t,this.view.viewport,DD(t,e));if(!n.length)return null;let r=Math.min(...n.map(e=>e.x)),i=Math.min(...n.map(e=>e.y)),a=Math.max(...n.map(e=>e.x+e.width)),o=Math.max(...n.map(e=>e.y+e.height));return{x:r,y:i,width:a-r,height:o-i}}activeScreenArea(){return this.state.active?this.cellScreenArea(this.state.active):null}scrollToCell(e){let t=this.view.currentAxes;if(!t)return;let{scrollX:n,scrollY:r,width:i,height:a}=this.view.viewport,o=DD(t,e),s=n,c=r;o.x>=t.bodyLeft&&(o.x-s<t.bodyLeft?s=o.x-t.bodyLeft:o.x+o.width-s>i&&(s=Math.min(o.x-t.bodyLeft,o.x+o.width-i))),o.y-c<t.headerHeight?c=o.y-t.headerHeight:o.y+o.height-c>a&&(c=Math.min(o.y-t.headerHeight,o.y+o.height-a)),(s!==n||c!==r)&&this.view.scrollTo(Math.max(0,s),Math.max(0,c))}hitAt(e,t){let n=this.view.scroller.getBoundingClientRect();return this.hitAtViewport(e-n.left,t-n.top)}source(){let e=this.view.currentAxes;return e?{axes:e,rows:this.rows,viewport:this.view.viewport,list:e=>this.view.cache.drawn(e)}:null}hitAtViewport(e,t){let n=this.source();return n?TD(n,e,t):{region:`none`,row:-1,col:-1,part:null,docX:e,docY:t,x:e,y:t}}clientRect(e){let t=this.view.scroller.getBoundingClientRect();return{x:t.left+e.x,y:t.top+e.y,width:e.width,height:e.height}}anchorOf(e){let t=this.view.currentAxes,n=t?AD(t,this.view.viewport,e):[];return this.clientRect(n[0]??{x:0,y:0,width:0,height:0})}addGesture(e){return this.gestures.push(e),()=>{let t=this.gestures.indexOf(e);t>=0&&this.gestures.splice(t,1)}}addPainter(e,t){let n={paint:e,order:t};return this.painters.push(n),this.painters.sort((e,t)=>e.order-t.order),this.view.redrawOverlay(),()=>{let e=this.painters.indexOf(n);e>=0&&this.painters.splice(e,1),this.view.redrawOverlay()}}invalidateOverlay(){this.view.redrawOverlay()}paint(e,t){let n=this.view.currentAxes,r=this.style;if(!n||!r)return;let i=this.view.viewport,a={ctx:e,dpr:t,axes:n,rows:this.rows,viewport:i,style:r,interaction:this,play:r=>rO(e,t,n,i,r,this.view.resources)};for(let{paint:e}of this.painters)e(a)}paintSelection(e){let t=this.source();if(!t)return;let{colors:n,ops:r}=oO({axes:e.axes,rows:e.rows,viewport:e.viewport,style:e.style,selection:this.state.selection,active:this.state.active,hover:this.drag?null:this.hovered,source:t});r.length&&e.play(tO(n,r))}rememberActive(){let e=this.state.active,t=this.view.currentAxes;this.activeIds={record:e?this.rows?.recordId(e.row)??null:null,field:e?t?.columns[e.col]?.fieldId??null:null}}onAxes(){let e=this.rows,t=this.view.currentAxes;if(this.hovered=null,!e||!t)return;let n=xD(t),{record:r,field:i}=this.activeIds,a=null;if(r!=null){let o=e.rowOf(r),s=t.columns.findIndex(e=>e.fieldId===i);o>=0&&s>=0&&s<n&&(a={row:o,col:s})}let o=a?RE(a):LE;this.state.selection.kind===`columns`&&(o={kind:`columns`,anchor:Math.min(this.state.selection.anchor,n-1),focus:Math.min(this.state.selection.focus,n-1)}),this.state={selection:o,active:a},this.rememberActive();for(let e of this.changeListeners)e(this.state);for(let e of this.geometryListeners)e()}checkRecords(e){let t=this.rows;if(!t)return;let n=e.map(e=>t.rowOf(e)).filter(e=>e>=0).map(e=>[e,e]);this.setSelection(n.length?{kind:`rows`,ranges:n}:LE,this.state.active)}viewportPoint(e){let t=this.view.scroller.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}}onDown(e){if(e.button!==0)return;let{x:t,y:n}=this.viewportPoint(e),r=this.hitAtViewport(t,n);if(r.region===`none`&&(t>=this.view.viewport.width||n>=this.view.viewport.height))return;this.view.scroller.focus({preventScroll:!0});for(let t of this.gestures)if(t.down(r,e)){this.claimed={gesture:t,pointer:e.pointerId},this.capture(e),this.setHover(null);return}let i=this.rows,a=r.part,o=t=>{this.press={hit:r,pointer:e.pointerId,act:t},this.capture(e)};switch(r.region){case`cell`:{let i={row:r.row,col:r.col};if(e.shiftKey&&this.state.active?this.setActive(i,{extend:!0}):this.setActive(i),a&&a.col>=0&&a.kind<=yD.Link){o(e=>this.handlers.onCellPart?.(e));return}this.drag={kind:`cells`,pointer:e.pointerId,x:t,y:n},this.capture(e),e.preventDefault();return}case`rowHead`:if(!a)return;if(a.kind===yD.Checkbox){let t=e.shiftKey&&this.lastToggled!=null?this.lastToggled:null;this.setSelection(qE(this.state.selection,r.row,t),this.state.active),this.lastToggled=r.row,e.preventDefault()}else a.kind===yD.Expand&&o(()=>{let e=i?.recordId(r.row);e!=null&&this.handlers.onExpandRecord?.(e)});return;case`corner`:a?.kind===yD.Checkbox&&i&&(this.setSelection(WE(this.state.selection,i)?LE:GE(i),this.state.active),e.preventDefault());return;case`header`:{if(a?.kind===yD.ColumnMenu){o(()=>this.columnMenu(r.col));return}if(a?.kind===yD.ColumnEdge)return;let i=e.shiftKey&&this.state.selection.kind===`columns`?this.state.selection.anchor:r.col;this.setSelection({kind:`columns`,anchor:i,focus:r.col},this.state.active),this.drag={kind:`columns`,pointer:e.pointerId,x:t,y:n},this.capture(e),e.preventDefault();return}case`group`:a?.kind===yD.GroupToggle&&o(()=>this.toggleGroup(r.row));return;case`appendRow`:o(()=>this.handlers.onAppendRecord?.({anchorRecordId:i?.appendAnchor(r.row)??null}));return;case`appendColumn`:{let e=this.view.currentAxes,t=e?.columns[e.columns.length-1];o(()=>this.handlers.onAppendField?.({anchor:this.anchorOf({x:t?.x??0,y:0,width:t?.width??0,height:e?.headerHeight??0})}));return}case`none`:return}}capture(e){try{this.view.scroller.setPointerCapture(e.pointerId)}catch{}}onMove(e){let{x:t,y:n}=this.viewportPoint(e);if(this.claimed){this.claimed.gesture.move?.(this.hitAtViewport(t,n),e);return}if(this.drag){this.drag.x=t,this.drag.y=n,this.extendDrag(),this.autoscroll();return}if(this.press)return;let r=this.hitAtViewport(t,n);this.setHover(r.region===`none`?null:r),this.view.scroller.style.cursor=this.cursorFor(r)}cursorFor(e){for(let t of this.gestures){let n=t.cursor?.(e);if(n)return n}let t=e.part;return e.region===`appendRow`||e.region===`appendColumn`||t&&t.kind!==yD.ColumnEdge&&t.kind!==yD.DragHandle?`pointer`:`default`}onUp(e){let{x:t,y:n}=this.viewportPoint(e),r=this.hitAtViewport(t,n);if(this.claimed){let{gesture:t}=this.claimed;this.claimed=null,t.up?.(r,e);return}let i=this.press;this.endPointer(),i&&ek(i.hit,r)&&i.act(r)}endPointer(){this.claimed&&=(this.claimed.gesture.cancel?.(),null),this.press=null,this.drag&&(this.drag=null,cancelAnimationFrame(this.scrollFrame),this.scrollFrame=0,this.view.redrawOverlay())}extendDrag(){let e=this.drag,t=this.view.currentAxes;if(!e||!t)return;let n=this.view.viewport;if(e.kind===`cells`){let r=ED(t,n,this.rows,e.x,e.y);r&&this.state.active&&this.setActive(r,{extend:!0})}else if(this.state.selection.kind===`columns`){let r=ED(t,n,null,e.x,Math.max(e.y,t.headerHeight));r&&this.setSelection({kind:`columns`,anchor:this.state.selection.anchor,focus:r.col},this.state.active)}}autoscroll(){if(this.scrollFrame||!this.drag)return;this.scrollAt=performance.now();let e=t=>{this.scrollFrame=0;let n=this.drag,r=this.view.currentAxes;if(!n||!r)return;let[i,a]=$O(r,this.view.viewport,n.x,n.kind===`columns`?r.headerHeight+32:n.y);if(i===0&&a===0)return;let o=Math.min(64,t-this.scrollAt)/1e3;this.scrollAt=t,this.view.scrollBy(i*o,a*o),this.extendDrag(),this.scrollFrame=requestAnimationFrame(e)};this.scrollFrame=requestAnimationFrame(e)}setHover(e){tk(e)===tk(this.hovered)?this.hovered=e:(this.hovered=e,this.view.redrawOverlay())}onDoubleClick(e){let{x:t,y:n}=this.viewportPoint(e),r=this.hitAtViewport(t,n);r.region===`cell`&&!(r.part&&r.part.col>=0)&&this.handlers.onEdit?.({row:r.row,col:r.col},null)}onContextMenu(e){let{x:t,y:n}=this.viewportPoint(e),r=this.hitAtViewport(t,n),i=this.rows;if(r.region!==`cell`&&r.region!==`rowHead`||!i)return;e.preventDefault();let a=r.region===`cell`?{row:r.row,col:r.col}:null,o=this.state.selection,s=UE(o,r.row)||o.kind===`cells`&&a!=null&&(()=>{let e=zE(o.anchor,o.focus);return a.row>=e.top&&a.row<=e.bottom&&a.col>=e.left&&a.col<=e.right})();!s&&a&&this.setActive(a);let c=i.recordId(r.row),l=s?JE(this.state.selection,i):c==null?[]:[c];this.handlers.onContextMenu?.({recordIds:l,cell:a,clientX:e.clientX,clientY:e.clientY})}columnMenu(e){let t=this.view.currentAxes,n=t?.columns[e];t&&n&&n.fieldId!=null&&this.handlers.onColumnMenu?.({col:e,fieldId:n.fieldId,anchor:this.anchorOf({x:n.x,y:0,width:n.width,height:t.headerHeight})})}toggleGroup(e){let t=this.rows?.groupIndex(e),n=t==null?void 0:this.view.opened?.groups?.[t];n&&this.handlers.onToggleGroup?.({groupId:n.id,collapsed:!n.collapsed})}handleKey(e){if(this.isEditing||e.isComposing)return!1;let t=e.metaKey||e.ctrlKey,n=e.key,r=n.length===1?n.toLowerCase():n;if(t&&r===`z`)return e.shiftKey?this.handlers.onRedo?.():this.handlers.onUndo?.(),!0;if(e.ctrlKey&&!e.metaKey&&r===`y`)return this.handlers.onRedo?.(),!0;let i=this.rows;if(!i)return!1;if(t&&r===`a`){let e=KE(i,this.columnCount);return e.kind===`cells`&&this.setSelection(e,this.state.active??e.anchor),!0}let a=this.state.active;switch(n){case`ArrowUp`:case`ArrowDown`:case`ArrowLeft`:case`ArrowRight`:{let r=n===`ArrowLeft`?-1:+(n===`ArrowRight`),i=n===`ArrowUp`?-1:+(n===`ArrowDown`);return this.moveActive(r,i,{extend:e.shiftKey,jump:t}),!0}case`Tab`:return a?(this.moveActive(e.shiftKey?-1:1,0),!0):!1;case`PageUp`:case`PageDown`:{if(!a)return!1;let e=this.view.currentAxes,t=this.view.viewport.height-(e?.headerHeight??0),r=Math.max(1,Math.floor(t/Math.max(1,e?.rowHeight(a.row)??1)));return this.view.scrollBy(0,n===`PageUp`?-t:t),this.moveActive(0,n===`PageUp`?-r:r),!0}case`Escape`:{let e=this.state.selection;return e.kind===`cells`&&a&&!(BE(e.anchor,a)&&BE(e.focus,a))?(this.setSelection(RE(a),a),!0):e.kind===`rows`||e.kind===`columns`?(this.setSelection(a?RE(a):LE,a),!0):!1}case`Delete`:case`Backspace`:return this.state.selection.kind!==`none`&&(this.handlers.onDelete?.(this.state.selection),!0);case`Enter`:case`F2`:return!a||this.state.selection.kind!==`cells`?!1:(this.handlers.onEdit?.(a,null),!0);case` `:{let t=a?i.recordId(a.row):null;if(t==null||e.shiftKey)break;return this.handlers.onExpandRecord?.(t),!0}}return a&&this.state.selection.kind===`cells`&&n.length===1&&!t&&!e.altKey?(this.handlers.onEdit?.(a,n),!0):!1}},rk=.22,ik=class{grid;fetch;axis=null;index=new Map;asked=null;cells=new Map;run=0;cleanup=[];constructor(e,t){this.grid=e,this.fetch=t,this.cleanup.push(e.addPainter(e=>this.paint(e),50)),this.cleanup.push(e.view.onFrame(()=>this.follow()))}destroy(){this.run+=1;for(let e of this.cleanup)e()}setAxis(e){e!==this.axis&&(this.axis=e,this.index=new Map(e?.ids.map((e,t)=>[e,t])??[]),this.refresh())}refresh(){this.asked=null,this.follow()}shown(){let e=this.grid.view.currentAxes,t=this.grid.rows;if(!e||!t)return null;let{scrollY:n,height:r}=this.grid.view.viewport,i=Math.max(0,e.rowAt(n+e.headerHeight)),a=Math.min(t.count-1,e.rowAt(n+r-1)),o=1/0,s=-1;for(let e=i;e<=a;e+=1){let n=t.recordId(e),r=n==null?void 0:this.index.get(n);r!==void 0&&(o=Math.min(o,r),s=Math.max(s,r))}return s<0?null:{from:o,to:s}}follow(){let e=this.axis,t=(this.grid.view.currentAxes?.columns??[]).map(e=>e.fieldId).filter(e=>e!=null);if(!e||!t.length){this.cells.size&&(this.cells=new Map,this.grid.invalidateOverlay());return}let n=this.shown();if(!n)return;let r=`${e.epoch}:${t.join(`,`)}`,i=this.asked;if(i&&i.key===r&&n.from>=i.from&&n.to<i.to)return;let a=Math.max(0,n.from-64),o=Math.min(e.ids.length,n.to+1+64);this.asked={from:a,to:o,key:r};let s=++this.run;this.fetch({epoch:e.epoch,from:a,count:o-a,fieldIds:t}).then(t=>{if(s!==this.run)return;let n=new Map;for(let[r,i]of t){let t=e.ids[r];if(t==null)continue;let a=n.get(t);a||n.set(t,a=new Set),a.add(i)}this.cells=n,this.grid.invalidateOverlay()},()=>{s===this.run&&(this.asked=null)})}paint(e){let t=e.rows;if(!this.cells.size||!t)return;let[n,r,i]=eO(e.style.border),a=[];e.axes.columns.forEach((n,r)=>{if(n.fieldId!=null)for(let[i,o]of this.cells){if(!o.has(n.fieldId))continue;let s=t.rowOf(i);if(s<0)continue;let c=DD(e.axes,{row:s,col:r});a.push({op:dD.Rect,x:c.x,y:c.y,w:c.width,h:c.height,paint:0,snap:!0})}}),a.length&&e.play(tO([`rgba(${n},${r},${i},${rk})`],a))}get tinted(){return[...this.cells].flatMap(([e,t])=>[...t].map(t=>`${e}:${t}`))}},ak=6048e5,ok=-864e13,sk=null;function ck(e=1900,t=2100){if(sk&&e===1900&&t===2100)return sk;let n=e=>-new Date(e).getTimezoneOffset(),r=Date.UTC(t,0,1),i=Date.UTC(e,0,1),a=n(i),o=[[ok,a]];for(;i<r;){let e=Math.min(i+ak,r);if(n(e)!==a){let t=i,r=e;for(;r-t>1;){let e=Math.floor((t+r)/2);n(e)===a?t=e:r=e}a=n(r),o.push([r,a]),i=r}else i=e}return e===1900&&t===2100&&(sk=o),o}function lk(){let e=document.documentElement;if(e.dataset.brand!==`host`)return null;let t=getComputedStyle(e).getPropertyValue(`--primary`).trim().split(/\s+/).map(e=>Number.parseFloat(e));if(t.length<3||t.some(e=>!Number.isFinite(e)))return null;let[n,r,i]=[t[0],t[1]/100,t[2]/100],a=r*Math.min(i,1-i),o=e=>{let t=(e+n/30)%12;return Math.round(255*(i-a*Math.max(-1,Math.min(t-3,9-t,1))))};return`#${[o(0),o(8),o(4)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function uk(e){let{i18n:t}=U(`table`),n=aC(),r=cC(),i=fC(),a=HT()?`dark`:`light`,o=(0,j.useRef)(e);o.current=e;let s=(0,j.useRef)({host:r,notify:i});s.current={host:r,notify:i};let c=(0,j.useRef)(null),l=(0,j.useRef)(null),[u,d]=(0,j.useState)(null),f=JSON.stringify(e.config),p=(0,j.useMemo)(()=>JSON.stringify(e.fields.map(e=>[e.id,e.name,e.type,e.order,e.readonly,e.options??null,e.ai_config??null])),[e.fields]),{documentId:m,tableId:h,viewId:g,readOnly:_}=e;(0,j.useEffect)(()=>{let e=c.current;if(!e)return;let t=()=>o.current,r=0,i=dE(n,m,{axis:null,tableId:h,viewId:g,config:{},zone:ck(),theme:`light`,brand:null}),a=new XO(e,i,{fontsBase:new URL(`fonts/`,document.baseURI).href}),u=fE({dataSource:n,documentId:m,tableId:h,viewId:g,fields:()=>t().fields,setFrozen:e=>t().onFrozenColumnCount(e),upload:s.current.host.uploadAttachment?e=>s.current.host.uploadAttachment({documentId:m,tableId:h,file:e}):void 0,writing:async e=>{r+=1;try{return await e()}finally{--r}}}),f=e=>t().fields.find(t=>t.id===e),p={current:null},v=new kO(u,{onPopup:d,onPreviewAttachments:({items:e,index:n})=>t().onPreviewAttachments(e,n),onButton:({recordId:e,fieldId:n})=>{let r=f(n);r&&t().onRunButton(e,r)},onOpenLink:({recordId:e,fieldId:n})=>{let r=f(n);r&&t().onOpenLink(e,r)},onRegenerate:t().onRegenerate?({recordId:e,fieldId:n})=>{let r=f(n);r&&t().onRegenerate?.(e,r)}:void 0,onWritten:e=>x(e),onError:e=>s.current.notify.error(e instanceof Error?e.message:String(e)),resolveFileURL:e=>uC(s.current.host,e)},{readOnly:_,mac:kv()}),y=new nk(a,{...v.gridHandlers,onUndo:()=>t().onUndo(),onRedo:()=>t().onRedo(),onContextMenu:({recordIds:e,cell:n,clientX:r,clientY:i})=>{let a=(n?y.rows?.recordId(n.row):null)??e[0];a!=null&&t().onOpenRecordContextMenu(a,{clientX:r,clientY:i})},onColumnMenu:({fieldId:e,anchor:n})=>{let r=f(e);r&&t().onOpenColumnHeaderMenu?.(r,{x:n.x+n.width,y:n.y+n.height})},onExpandRecord:e=>t().onOpenRecord(e),onAppendRecord:({anchorRecordId:e})=>t().onAddRecord(e),onAppendField:()=>t().onOpenFieldCreator(),onToggleGroup:({groupId:e,collapsed:n})=>{let r=new Set(t().collapsedGroupIds);n?r.add(e):r.delete(e),t().onCollapsedGroupChanged(r)}});v.attach(y);let b=new ik(y,e=>n.grid.hits(e));p.current={view:a,source:i,interaction:y,editing:v,search:b},l.current=p.current;async function x(e){if(e.kind===`layout`)return fk(p.current);let t=a.currentAxes,n=a.opened?.rows;t&&n&&(a.cache.markStale(PO(n,t.bandRows,e.records?new Set(e.records):null)),a.invalidate(),b.refresh())}let S=n.grid.subscribe(()=>{r>0||!a.currentAxes||(a.cache.markStale(()=>!0),a.invalidate(),b.refresh())}),C=y.onChange(e=>{let n=y.rows,r=a.currentAxes,i=e.active,o=i&&n?n.recordId(i.row):null,s=i?r?.columns[i.col]?.fieldId:null,c=s==null?void 0:f(s)?.name;t().onSelectCell(o!=null&&c?{recordId:o,fieldName:c}:null),t().onCheckRecords(n&&e.selection.kind===`rows`?JE(e.selection,n):[])}),w=()=>{let e=XT.pendingKeys().flatMap(e=>{let[t,n,r]=e.split(`:`).map(Number);return t===h?[{recordId:n,fieldId:r}]:[]});v.setGenerating(e)},T=XT.subscribeAll(w);return w(),()=>{S(),C(),T(),b.destroy(),v.destroy(),y.destroy(),a.destroy(),a.element.remove(),l.current=null,d(null)}},[n,m,h,g,_]);let v=e.axis?.bytes??null;return(0,j.useEffect)(()=>{let e=l.current;e&&v&&(e.source.update({axis:v,config:JSON.parse(f),theme:a,brand:lk()}),e.search.setAxis(o.current.searching&&o.current.axis?o.current.axis:null),fk(e))},[v,f,a,p,e.searching,n,m,h,g,_]),(0,j.useEffect)(()=>{let t=l.current;t&&e.checkedCount===0&&t.interaction.selection.kind===`rows`&&t.interaction.setSelection(LE,t.interaction.active)},[e.checkedCount]),(0,I.jsxs)(`div`,{className:`data-inline-grid-canvas relative flex-1 min-h-0`,children:[(0,I.jsx)(`div`,{ref:c,className:`absolute inset-0`,"data-testid":`table-grid`}),(0,I.jsx)(IE,{popup:u,locale:t.language})]})}var dk=new WeakMap;function fk(e){if(!e)return Promise.resolve();let t=(dk.get(e)??Promise.resolve()).then(()=>pk(e)).catch(e=>console.error(`grid: the layout failed`,e));return dk.set(e,t),t}async function pk({view:e,source:t}){if(!e.element.isConnected)return;if(!e.opened)return e.open();let n=await t.open();e.element.isConnected&&(n.axes.epoch===e.currentAxes?.epoch&&e.cache.clear(),e.setAxes(n))}var mk=3;function hk({attachments:e,onPreview:t,className:n}){let{t:r}=U(`table`),i=cC(),[a,o]=(0,j.useState)(!1);if(!e.length)return null;let s=e.slice(0,mk),c=e.length-s.length;return(0,I.jsxs)(`span`,{className:K(`data-inline-attachment-cell-compact`,n),onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[(0,I.jsxs)(`span`,{className:`data-inline-attachment-cell-compact-row`,children:[s.map((e,n)=>{let a=ST(e);return(0,I.jsx)(`button`,{type:`button`,className:`data-inline-attachment-cell-compact-thumb`,"data-testid":`attachment-thumb`,title:e.name||r(`attachment.preview`),onClick:e=>{e.preventDefault(),e.stopPropagation(),t(n)},children:a?(0,I.jsx)(`img`,{src:uC(i,a),alt:e.name||r(`attachment.imageAlt`),loading:`lazy`}):(0,I.jsx)(Wa,{className:`size-3.5`,"aria-hidden":!0})},`${e.url}-${n}`)}),c>0?(0,I.jsxs)(`span`,{className:`data-inline-attachment-cell-compact-overflow`,"data-testid":`attachment-overflow`,"aria-label":r(`attachment.moreCount`,{count:c}),children:[`+`,c]}):null]}),(0,I.jsx)(`button`,{type:`button`,className:K(`data-inline-attachment-cell-compact-expand`,a&&`is-visible`),"data-testid":`attachment-expand`,title:r(`attachment.expandPreview`),"aria-label":r(`attachment.expandPreview`),onClick:e=>{e.preventDefault(),e.stopPropagation(),t(0)},children:(0,I.jsx)(Fo,{className:`size-3.5`,"aria-hidden":!0})})]})}function gk(e){return Array.isArray(e)?e.map(e=>e&&typeof e==`object`?e:null).filter(e=>!!e):[]}function _k(e){return Array.isArray(e)?e.map(e=>e&&typeof e==`object`?e:null).filter(e=>!!e):[]}function vk({field:e,value:t,documentId:n,tableId:r,onReplace:i}){let{t:a}=U(`table`),o=aC(),[s,c]=(0,j.useState)(!1),[l,u]=(0,j.useState)(``),[d,f]=(0,j.useState)([]),[p,m]=(0,j.useState)(!1),h=e.options?.allow_multiple!==!1,g=gk(t);(0,j.useEffect)(()=>{if(!s)return;let t=!1;return m(!0),o.fields.linkCandidates({documentId:n,tableId:r,fieldId:e.id,q:l,limit:25}).then(e=>{t||f(e)}).finally(()=>{t||m(!1)}),()=>{t=!0}},[s,l,o,n,r,e.id]);async function _(e){await i(e)}function v(e){g.some(t=>t.row_key===e)?_(g.map(e=>e.row_key||``).filter(t=>t&&t!==e)):(_(h?[...g.map(e=>e.row_key||``).filter(Boolean),e]:[e]),h||c(!1))}function y(e){_(g.map(e=>e.row_key||``).filter(t=>t&&t!==e))}return(0,I.jsxs)(`div`,{className:`data-inline-link-editor`,children:[(0,I.jsxs)(`div`,{className:`data-inline-link-chip-row`,children:[g.length?g.map(t=>(0,I.jsxs)(`span`,{className:`data-inline-link-chip`,children:[t.display||t.row_key||a(`cell.untitled`),e.readonly?null:(0,I.jsx)(`button`,{type:`button`,className:`data-inline-link-chip-remove`,onClick:()=>y(t.row_key||``),"aria-label":a(`cell.removeLink`),children:(0,I.jsx)(Nc,{className:`size-3`})})]},t.row_key)):(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:a(`cell.noLinks`)}),e.readonly?null:(0,I.jsx)(`button`,{type:`button`,className:`data-inline-link-add`,onClick:()=>c(e=>!e),children:(0,I.jsx)(ps,{className:`size-3.5`})})]}),s&&!e.readonly?(0,I.jsxs)(`div`,{className:`data-inline-link-picker`,children:[(0,I.jsx)(`input`,{className:`data-inline-cell-input`,placeholder:a(`cell.searchPlaceholder`),value:l,autoFocus:!0,onChange:e=>u(e.target.value)}),(0,I.jsxs)(`div`,{className:`data-inline-link-picker-list`,children:[p?(0,I.jsx)(`div`,{className:`data-inline-link-picker-empty`,children:(0,I.jsx)(Ao,{className:`size-3.5 animate-spin`})}):null,!p&&!d.length?(0,I.jsx)(`div`,{className:`data-inline-link-picker-empty`,children:a(`cell.noMatches`)}):null,d.map(e=>{let t=g.some(t=>t.row_key===e.row_key);return(0,I.jsxs)(`button`,{type:`button`,className:K(`data-inline-link-picker-row`,t&&`is-selected`),onClick:()=>v(e.row_key),children:[(0,I.jsx)(`span`,{children:e.display||e.row_key||a(`cell.untitled`)}),t?(0,I.jsx)(ea,{className:`size-3.5`}):null]},e.row_key)})]})]}):null]})}function yk({value:e,placeholder:t}){let{t:n}=U(`table`),r=gk(e);return r.length?(0,I.jsx)(`span`,{className:`data-inline-link-chips`,children:r.map((e,t)=>(0,I.jsx)(`span`,{className:`data-inline-link-chip`,title:e.display||e.row_key,children:e.display||e.row_key||n(`cell.untitled`)},`${e.row_key}-${t}`))}):(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t})}function bk({value:e,placeholder:t}){let{t:n}=U(`table`),r=_k(e);return r.length?(0,I.jsx)(`span`,{className:`data-inline-user-chips`,children:r.map((e,t)=>(0,I.jsxs)(`span`,{className:`data-inline-user-chip`,title:e.name||e.id,children:[(0,I.jsx)(Cc,{className:`size-3.5`}),e.name||e.id||n(`cell.user`)]},`${e.id}-${t}`))}):(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t})}function xk(e){let t=Number(e.options?.max??5);return Number.isFinite(t)&&t>0?Math.min(t,10):5}function Sk(e){let t=e.options?.icon;return t===`heart`||t===`thumbs`?t:`star`}function Ck({kind:e,filled:t}){let n=K(`size-3.5`,t?`text-amber-500`:`text-muted-foreground/40`);return e===`heart`?(0,I.jsx)(uo,{className:n,fill:t?`currentColor`:`none`}):e===`thumbs`?(0,I.jsx)(pc,{className:n,fill:t?`currentColor`:`none`}):(0,I.jsx)($s,{className:n,fill:t?`currentColor`:`none`})}function wk({field:e,value:t,readonly:n,onCommit:r}){let{t:i}=U(`table`),a=xk(e),o=Sk(e),s=Math.max(0,Math.min(a,Number(t??0)));return(0,I.jsx)(`span`,{className:`data-inline-rating-cell`,children:Array.from({length:a},(e,t)=>t+1).map(e=>(0,I.jsx)(`button`,{type:`button`,className:`data-inline-rating-step`,disabled:n,"aria-label":i(`cell.rate`,{step:e}),onClick:t=>{!n&&r&&(t.preventDefault(),t.stopPropagation(),r(s===e?0:e))},children:(0,I.jsx)(Ck,{kind:o,filled:e<=s})},e))})}function Tk(e,t){return e.type===`date`?wE(`date`,t):e.type===`datetime`?wE(`datetime-local`,t):xT(t)}function Ek({field:e,value:t,documentId:n,tableId:r,recordId:i,onPreviewAttachments:a,onOpenDocument:o,onCommit:s}){let{t:c}=U(`table`),l=cC(),u=l.uploadAttachment,[d,f]=(0,j.useState)(()=>Tk(e,t)),[p,m]=(0,j.useState)(!1),[h,g]=(0,j.useState)(``),_=(0,j.useRef)(null);(0,j.useEffect)(()=>{f(Tk(e,t))},[e.type,t]);async function v(i){if(n&&r&&!e.readonly&&i.length&&u){m(!0),g(``);try{let e=await Promise.all(i.map(e=>u({documentId:n,tableId:r,file:e})));s([...TT(t),...e])}catch(e){g(e instanceof Error?e.message:c(`cell.uploadFailed`))}finally{m(!1),_.current&&(_.current.value=``)}}}if(e.ai_config?.enabled&&l.ai)return(0,I.jsx)(Dk,{field:e,value:t,tableId:r,recordId:i,onPreviewAttachments:a,onOpenDocument:o});if(e.type===`checkbox`)return(0,I.jsx)(`input`,{type:`checkbox`,checked:!!t,disabled:e.readonly,onChange:e=>s(e.target.checked)});if(e.type===`attachment`){let i=TT(t);return(0,I.jsxs)(`div`,{className:K(`data-inline-attachment-cell`,p&&`is-uploading`),onPaste:e=>{let t=ET(e.clipboardData);t.length&&(e.preventDefault(),e.stopPropagation(),v(t))},onDragOver:t=>{e.readonly||t.preventDefault()},onDrop:t=>{if(e.readonly)return;let n=Array.from(t.dataTransfer.files||[]);n.length&&(t.preventDefault(),t.stopPropagation(),v(n))},children:[(0,I.jsxs)(`div`,{className:`data-inline-attachment-list`,children:[i.map((t,n)=>{let r=ST(t),o=r&&a;return(0,I.jsxs)(`span`,{className:K(`data-inline-attachment-chip`,o&&`is-previewable`),title:o?c(`cell.attachmentPreviewHint`,{name:t.name||c(`cell.previewImage`)}):t.name,role:o?`button`:void 0,tabIndex:o?0:void 0,onClick:e=>{o&&(e.preventDefault(),e.stopPropagation(),a?.(i,n))},onKeyDown:e=>{!o||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),e.stopPropagation(),a?.(i,n))},children:[r?(0,I.jsx)(`span`,{className:`data-inline-attachment-thumb-button`,children:(0,I.jsx)(`img`,{src:uC(l,r),alt:t.name||c(`attachment.imageAlt`)})}):(0,I.jsx)(Wa,{className:`size-3.5`}),(0,I.jsx)(`span`,{children:t.name||CT(t.url)}),e.readonly?null:(0,I.jsx)(`button`,{type:`button`,className:`data-inline-attachment-remove`,onClick:e=>{e.preventDefault(),e.stopPropagation(),s(i.filter((e,t)=>t!==n))},title:c(`cell.removeAttachment`),children:`×`})]},`${t.url}-${n}`)}),i.length?null:(0,I.jsx)(`span`,{className:`data-inline-attachment-empty`,children:c(`cell.pasteOrUpload`)})]}),!e.readonly&&u?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`data-inline-attachment-add`,disabled:p||!n||!r,onClick:()=>_.current?.click(),children:p?(0,I.jsx)(Ao,{className:`size-3.5 animate-spin`}):(0,I.jsx)(Sc,{className:`size-3.5`})}),(0,I.jsx)(`input`,{ref:_,type:`file`,multiple:!0,hidden:!0,onChange:e=>void v(Array.from(e.target.files||[]))})]}):null,h?(0,I.jsx)(`span`,{className:`data-inline-attachment-error`,children:h}):null]})}if(e.type===`single_select`){let t=MT(e);return(0,I.jsxs)(C_,{value:d,disabled:e.readonly,onChange:e=>{f(e.target.value),s(e.target.value)},children:[(0,I.jsx)(`option`,{value:``,children:c(`cell.empty`)}),t.map(t=>(0,I.jsx)(`option`,{value:t,children:(0,I.jsx)(`span`,{className:K(`data-inline-select-pill`,`tone-${FT(e,t)}`),children:t})},t))]})}if(e.type===`multi_select`){let n=Array.isArray(t)?t.map(String):xT(t).split(`,`).map(e=>e.trim()).filter(Boolean);return(0,I.jsx)(`input`,{className:`data-inline-cell-input`,value:d,readOnly:e.readonly,onChange:e=>f(e.target.value),onBlur:()=>s(d),placeholder:n.length?n.join(`, `):``})}if(e.type===`url`){let t=wT(d);return(0,I.jsxs)(`div`,{className:`data-inline-url-cell`,children:[(0,I.jsx)(`input`,{className:`data-inline-cell-input`,type:`url`,value:d,readOnly:e.readonly,onChange:e=>f(e.target.value),onBlur:()=>s(d),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}}),t?(0,I.jsx)(`a`,{className:`data-inline-url-link`,href:t.href,target:`_blank`,rel:`noreferrer noopener`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),title:c(`cell.openUrl`,{label:t.label}),"aria-label":c(`cell.openLinkNewTab`),children:(0,I.jsx)(Fa,{className:`size-3.5`})}):null]})}if(e.type===`document_link`)return(0,I.jsxs)(`div`,{className:`data-inline-url-cell`,children:[(0,I.jsx)(`input`,{className:`data-inline-cell-input`,value:d,readOnly:e.readonly,onChange:e=>f(e.target.value),onBlur:()=>s(d),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}}),d&&o?(0,I.jsx)(`button`,{type:`button`,className:`data-inline-url-link`,onClick:e=>{e.preventDefault(),e.stopPropagation(),o(d)},title:`Open ${d}`,"aria-label":`Open document ${d}`,children:(0,I.jsx)(Wa,{className:`size-3.5`})}):null]});if(e.type===`rating`)return(0,I.jsx)(wk,{field:e,value:t,readonly:!!e.readonly,onCommit:s});if(e.type===`link_to_record`)return(0,I.jsx)(yk,{value:t,placeholder:c(`cell.noLinksExpand`)});if(e.type===`user`)return(0,I.jsx)(bk,{value:t,placeholder:c(`cell.noUsersExpand`)});if(e.type===`button`){let{label:t,action:n}=SC(e,c(`cell.runButton`)),a=l.runWorkflow;return n.kind===`run_workflow`&&(!a||n.workflow_id==null||!r||!i)?(0,I.jsx)(`span`,{className:`data-inline-readonly-cell`,children:t}):(0,I.jsx)(`button`,{type:`button`,className:`data-inline-button-cell`,onClick:e=>{e.preventDefault(),e.stopPropagation(),n.kind===`open_url`&&n.url?window.open(n.url,`_blank`,`noopener,noreferrer`):n.kind===`run_workflow`&&a&&n.workflow_id!=null&&r&&i&&a({workflowId:n.workflow_id,tableId:r,recordId:i})},children:t})}if(e.type===`auto_number`||e.type===`created_time`||e.type===`last_modified_time`||e.type===`created_by`||e.type===`last_modified_by`||e.type===`lookup`||e.type===`rollup`){let n=CE(e,t);return(0,I.jsx)(`span`,{className:`data-inline-readonly-cell`,title:n,children:n||(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})})}return e.type===`long_text`?(0,I.jsx)(`textarea`,{className:`data-inline-longtext-cell`,value:d,readOnly:e.readonly,onChange:e=>f(e.target.value),onBlur:()=>s(d),rows:4}):(0,I.jsx)(`input`,{className:`data-inline-cell-input`,inputMode:e.type===`number`?`decimal`:void 0,type:e.type===`date`?`date`:e.type===`datetime`?`datetime-local`:`text`,step:e.type===`datetime`?1:void 0,value:d,readOnly:e.readonly,onChange:e=>f(e.target.value),onBlur:()=>s(e.type===`date`?TE(`date`,d):e.type===`datetime`?TE(`datetime-local`,d):d),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}})}function Dk({field:e,value:t,onPreviewAttachments:n,onOpenDocument:r,tableId:i,recordId:a,onRegenerate:o}){let{t:s}=U(`table`);if(e.ai_config?.enabled&&i!=null&&a!=null)return(0,I.jsx)(Ok,{field:e,value:t,tableId:i,recordId:a,onPreviewAttachments:n,onRegenerate:o});if(e.type===`attachment`){let e=TT(t);return e.length?(0,I.jsx)(hk,{attachments:e,onPreview:t=>n?.(e,t)}):(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:s(`cell.empty`)})}if(e.type===`document_link`){let e=xT(t);return e&&r?(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-url-display`,onClick:t=>{t.preventDefault(),t.stopPropagation(),r(e)},title:`Open ${e}`,children:[(0,I.jsx)(Wa,{className:`size-3.5`}),(0,I.jsx)(`span`,{children:e})]}):e?(0,I.jsx)(`span`,{children:e}):(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:s(`cell.empty`)})}if(e.type===`date`||e.type===`datetime`||e.type===`created_time`||e.type===`last_modified_time`){let n=CE(e,t);return n?(0,I.jsx)(`span`,{children:n}):(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:s(`cell.empty`)})}if(e.type===`single_select`){let n=xT(t);return n?(0,I.jsx)(`span`,{className:K(`data-inline-select-pill`,`tone-${FT(e,n)}`),children:n}):(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:s(`cell.empty`)})}if(e.type===`multi_select`){let n=Array.isArray(t)?t.map(String):xT(t).split(`,`).map(e=>e.trim()).filter(Boolean);return(0,I.jsx)(`span`,{className:`data-inline-multi-pills`,children:n.length?n.map(t=>(0,I.jsx)(`span`,{className:K(`data-inline-select-pill`,`tone-${FT(e,t)}`),children:t},t)):(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:s(`cell.empty`)})})}if(e.type===`checkbox`)return t?(0,I.jsx)(ea,{className:`size-4`}):(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:s(`cell.empty`)});if(e.type===`rating`)return(0,I.jsx)(wk,{field:e,value:t,readonly:!0});if(e.type===`link_to_record`)return(0,I.jsx)(yk,{value:t,placeholder:s(`cell.empty`)});if(e.type===`user`)return(0,I.jsx)(bk,{value:t,placeholder:s(`cell.empty`)});if(e.type===`button`){let{label:t}=SC(e,s(`cell.runButton`));return(0,I.jsx)(`span`,{className:`data-inline-readonly-cell`,children:t})}if(e.type===`auto_number`||e.type===`lookup`||e.type===`rollup`){let e=xT(t);return e?(0,I.jsx)(`span`,{className:`data-inline-readonly-cell`,children:e}):(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:s(`cell.empty`)})}if(e.type===`created_by`||e.type===`last_modified_by`){let e=xT(t);return(0,I.jsxs)(`span`,{className:`data-inline-user-chip`,children:[(0,I.jsx)(Cc,{className:`size-3.5`}),e||(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:s(`cell.empty`)})]})}if(e.type===`url`){let e=wT(t);if(!e){let e=xT(t);return e?(0,I.jsx)(`span`,{children:e}):(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:s(`cell.empty`)})}return(0,I.jsx)(`a`,{className:`data-inline-url-display`,href:e.href,target:`_blank`,rel:`noreferrer noopener`,onClick:e=>e.stopPropagation(),children:e.label})}return(0,I.jsx)(`span`,{children:xT(t)||(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:s(`cell.empty`)})})}function Ok({field:e,value:t,tableId:n,recordId:r,onPreviewAttachments:i,onRegenerate:a}){let{t:o}=U(`table`),s=ZT(YT(n,r,e.id)),c=tC(e.ai_config),l=c&&Array.isArray(t)?t.filter(e=>!!(e&&typeof e==`object`&&`url`in e)):[],u=c?l.length>0:!!xT(t),d=s.status===`pending`,f=s.status===`error`;return(0,I.jsxs)(`div`,{className:`data-inline-ai-cell`,children:[u?c?(0,I.jsx)(hk,{attachments:l,onPreview:e=>i?.(l,e)}):(0,I.jsx)(`span`,{children:xT(t)}):!d&&!f?(0,I.jsx)(`span`,{className:`data-inline-ai-cell-empty`,children:o(`cell.notGenerated`)}):null,d?(0,I.jsxs)(`span`,{className:`data-inline-ai-cell-pending`,children:[(0,I.jsx)(Ao,{className:`size-3.5 animate-spin`}),(0,I.jsx)(`span`,{children:o(`cell.generating`)})]}):null,f&&s.status===`error`?(0,I.jsx)(`span`,{className:`data-inline-ai-cell-error`,title:s.message,children:(0,I.jsxs)(`span`,{children:[`⚠ `,s.message]})}):null,a&&!d?(0,I.jsx)(`button`,{type:`button`,className:`data-inline-ai-cell-regenerate`,title:o(`cell.regenerate`),onClick:t=>{t.stopPropagation(),a(e)},children:(0,I.jsx)(bs,{className:`size-3.5`})}):null]})}var kk=768;function Ak({url:e,documentId:t,label:n}){let r=aC(),i=cC(),a=(0,j.useRef)(null),o=_C(e),s=r.attachments?.read,c=r.grid.picture,l=o!=null&&s!=null&&t!=null||e.startsWith(`data:`);return(0,j.useEffect)(()=>{if(!l)return;let n=!0;return(async()=>{let r=await lE(o!=null&&s&&t!=null?await s({documentId:t,hash:o}).then(e=>new Blob([e.data],{type:e.mimeType})):await(await fetch(e)).blob(),0,0,c,kk),i=a.current;r&&(n&&i&&(i.width=r.width,i.height=r.height,i.getContext(`2d`)?.drawImage(r,0,0),i.dataset.ktableGalleryCover=`drawn`),r.close())})().catch(()=>void 0),()=>{n=!1}},[l,o,s,c,t,e]),l?(0,I.jsx)(`canvas`,{ref:a,role:`img`,"aria-label":n,"data-ktable-gallery-cover":`loading`}):(0,I.jsx)(`img`,{src:uC(i,e),alt:n,loading:`lazy`})}function jk({fields:e,groupField:t,groups:n,primaryField:r,canMoveCards:i,draggingRecordId:a,dragOverRecordId:o,dragOverGroup:s,onDragStart:c,onDragEnd:l,onDragOverRecord:u,onDragOverGroup:d,onMoveRecord:f,onAddRecord:p,onOpenRecord:m,onOpenDocument:h,onPreviewAttachments:g,tableId:_,onRegenerate:v}){let{t:y}=U(`table`),b=(0,j.useRef)(!1),x=e.filter(e=>e.name!==r?.name&&e.name!==t?.name).slice(0,3);function S(e,t){if(!i)return;b.current=!0,e.dataTransfer.effectAllowed=`move`,e.dataTransfer.setData(`text/plain`,String(t));let n=e.currentTarget.closest(`.data-inline-kanban-card`);n instanceof HTMLElement&&e.dataTransfer.setDragImage(n,18,18),c(t)}return(0,I.jsx)(`div`,{className:`data-inline-kanban`,children:n.map(([e,t])=>(0,I.jsxs)(`section`,{className:K(`data-inline-kanban-column`,s===e&&`is-drop-target`),onDragOver:t=>{i&&a!==null&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,d(e),u(null))},onDragLeave:()=>{s===e&&d(``)},onDrop:t=>{t.preventDefault();let n=Number(t.dataTransfer.getData(`text/plain`)||a);l(),Number.isFinite(n)&&f(n,e)},children:[(0,I.jsxs)(`header`,{children:[(0,I.jsx)(`span`,{children:e}),(0,I.jsx)(d_,{children:t.length})]}),(0,I.jsxs)(`div`,{className:`data-inline-kanban-cards`,children:[t.map(t=>(0,I.jsxs)(`article`,{className:K(`data-inline-kanban-card`,a===t.id&&`is-dragging`,o===t.id&&`is-drag-over`,i&&`is-draggable`),draggable:i,onDragStart:e=>S(e,t.id),onDragOver:n=>{i&&a!==null&&a!==t.id&&(n.preventDefault(),n.stopPropagation(),n.dataTransfer.dropEffect=`move`,d(e),u(t.id))},onDragLeave:()=>{o===t.id&&u(null)},onDrop:n=>{if(!i||a===null||a===t.id)return;n.preventDefault(),n.stopPropagation();let r=Number(n.dataTransfer.getData(`text/plain`)||a);l(),Number.isFinite(r)&&f(r,e,t.id)},onDragEnd:l,onClick:()=>{b.current?b.current=!1:m(t)},children:[(0,I.jsxs)(`div`,{className:`data-inline-kanban-card-head`,children:[(0,I.jsx)(`button`,{type:`button`,className:`data-inline-kanban-drag-handle`,title:y(i?`views.dragCard`:`views.dragCardDisabled`),draggable:i,onClick:e=>e.stopPropagation(),onDragStart:e=>{e.stopPropagation(),S(e,t.id)},onDragEnd:e=>{e.stopPropagation(),l()},children:(0,I.jsx)(ao,{className:`size-4`})}),(0,I.jsx)(`strong`,{children:r&&xT(t.values?.[r.name]??null)||y(`views.untitled`)})]}),x.map(e=>(0,I.jsxs)(`div`,{className:`data-inline-kanban-meta`,children:[(0,I.jsx)(`span`,{children:e.title}),(0,I.jsx)(Dk,{field:e,value:t.values?.[e.name]??null,onPreviewAttachments:g,onOpenDocument:h,tableId:_,recordId:t.id,onRegenerate:v?e=>v(t,e):void 0})]},e.id))]},t.id)),(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-kanban-add`,onClick:()=>p(e),children:[(0,I.jsx)(ps,{className:`size-4`}),y(`views.new`)]})]})]},e))})}function Mk({records:e,fields:t,primaryField:n,dateField:r,onAddRecord:i,onOpenRecord:a,onOpenDocument:o,onPreviewAttachments:s,tableId:c,onRegenerate:l}){let{t:u}=U(`table`),d=t.filter(e=>e.id!==n?.id&&e.id!==r?.id).slice(0,2);return(0,I.jsxs)(`div`,{className:`data-inline-calendar`,children:[(0,I.jsxs)(`div`,{className:`data-inline-calendar-head`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:r?u(`views.calendarByField`,{title:r.title}):u(`views.calendarNeedsDate`)}),(0,I.jsx)(`span`,{children:u(`views.scheduledRecords`,{count:e.length})})]}),(0,I.jsxs)(Rc,{size:`md`,variant:`secondary`,onClick:i,children:[(0,I.jsx)(ps,{className:`size-4`}),u(`views.new`)]})]}),(0,I.jsx)(`div`,{className:`data-inline-calendar-list`,children:e.map(e=>(0,I.jsxs)(`article`,{className:`data-inline-calendar-item`,onClick:()=>a(e),children:[(0,I.jsx)(`div`,{className:`data-inline-calendar-date`,children:r&&xT(e.values?.[r.name]??null)||u(`views.noDate`)}),(0,I.jsxs)(`div`,{className:`data-inline-calendar-card`,children:[(0,I.jsx)(`strong`,{children:n&&xT(e.values?.[n.name]??null)||u(`views.untitled`)}),(0,I.jsx)(`div`,{children:d.map(t=>(0,I.jsx)(Dk,{field:t,value:e.values?.[t.name]??null,onPreviewAttachments:s,onOpenDocument:o,tableId:c,recordId:e.id,onRegenerate:l?t=>l(e,t):void 0},t.id))})]})]},e.id))})]})}function Nk({documentId:e,records:t,fields:n,primaryField:r,coverField:i,onOpenRecord:a,onOpenDocument:o,onPreviewAttachments:s,tableId:c,onRegenerate:l}){let{t:u}=U(`table`),d=n.filter(e=>e.id!==r?.id&&e.id!==i?.id).slice(0,4);return(0,I.jsx)(`div`,{className:`data-inline-gallery`,children:t.map(t=>{let n=i?t.values?.[i.name]??null:null,f=i?TT(n):[],p=i?f.length?ST(f[0]):ST(n):``;return(0,I.jsxs)(`article`,{className:`data-inline-gallery-card`,onClick:()=>a(t),children:[(0,I.jsx)(`div`,{className:K(`data-inline-gallery-cover`,p&&`has-image`),children:p?(0,I.jsx)(`button`,{type:`button`,className:`data-inline-gallery-cover-button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),f.length?s(f,0):s([{name:r&&xT(t.values?.[r.name]??null)||u(`views.galleryCover`),url:p}],0)},children:(0,I.jsx)(Ak,{url:p,documentId:e,label:r&&xT(t.values?.[r.name]??null)||u(`views.galleryCover`)})}):(0,I.jsx)(eo,{className:`size-5`})}),(0,I.jsx)(`strong`,{children:r&&xT(t.values?.[r.name]??null)||u(`views.untitled`)}),i?(0,I.jsxs)(`div`,{className:`data-inline-gallery-meta`,children:[(0,I.jsx)(`span`,{children:u(`views.cover`)}),(0,I.jsx)(`span`,{className:K(p?`text-emerald-600 dark:text-emerald-300`:`text-muted-foreground`),children:p?i.title:u(`views.empty`)})]}):null,d.map(e=>(0,I.jsxs)(`div`,{className:`data-inline-gallery-meta`,children:[(0,I.jsx)(`span`,{children:e.title}),(0,I.jsx)(Dk,{field:e,value:t.values?.[e.name]??null,onPreviewAttachments:s,onOpenDocument:o,tableId:c,recordId:t.id,onRegenerate:l?e=>l(t,e):void 0})]},e.id))]},t.id)})})}function Pk({tableId:e,viewMode:t,visibleFields:n,groupField:r,groupedRecords:i,primaryField:a,dateField:o,coverField:s,sortedAndFilteredRecords:c,canMoveKanbanCards:l,draggingRecordId:u,dragOverRecordId:d,dragOverGroup:f,onDragStart:p,onDragEnd:m,onDragOverRecord:h,onDragOverGroup:g,onMoveKanbanRecord:_,onAddRecord:v,onOpenRecord:y,onOpenDocument:b,onPreviewAttachments:x,onRegenerate:S,grid:C}){return t===`kanban`?(0,I.jsx)(jk,{fields:n,groupField:r,groups:i,primaryField:a,canMoveCards:l,draggingRecordId:u,dragOverRecordId:d,dragOverGroup:f,onDragStart:p,onDragEnd:m,onDragOverRecord:h,onDragOverGroup:g,onMoveRecord:_,onAddRecord:e=>void v(r?{[r.name]:VT(r,e)}:void 0),onOpenRecord:y,onOpenDocument:b,onPreviewAttachments:x,tableId:e,onRegenerate:S}):t===`calendar`?(0,I.jsx)(Mk,{records:c,fields:n,primaryField:a,dateField:o,onAddRecord:()=>void v(),onOpenRecord:y,onOpenDocument:b,onPreviewAttachments:x,tableId:e,onRegenerate:S}):t===`gallery`?(0,I.jsx)(Nk,{documentId:C.documentId,records:c,fields:n,primaryField:a,coverField:s,onOpenRecord:y,onOpenDocument:b,onPreviewAttachments:x,tableId:e,onRegenerate:S}):(0,I.jsx)(uk,{...C})}function Fk({shownCount:e,numericSummaries:t,selectedRecordCount:n,end:r}){let{t:i}=U(`table`);return(0,I.jsxs)(`div`,{className:`data-inline-footer`,children:[(0,I.jsx)(`span`,{children:i(`footer.recordsCount`,{count:e})}),t.length?(0,I.jsx)(`div`,{className:`data-inline-aggregates`,children:t.map(e=>(0,I.jsx)(`span`,{children:i(`footer.aggregate`,{title:e.field.title,sum:e.sum.toLocaleString(),avg:e.average.toLocaleString(void 0,{maximumFractionDigits:2})})},e.field.id))}):null,r?(0,I.jsxs)(`span`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(`span`,{children:n?i(`footer.selectedCount`,{count:n}):i(`footer.editHint`)}),r]}):n?(0,I.jsx)(`span`,{children:i(`footer.selectedCount`,{count:n})}):(0,I.jsx)(`span`,{children:i(`footer.editHint`)})]})}var Ik=.25,Lk=5,Rk=.25;function zk(e,t){if(!t)return``;let n=ST(t);return n?uC(e,n):``}function Bk({open:e,items:t,index:n,onClose:r,onIndexChange:i}){let{t:a}=U(`table`),o=cC(),s=fC(),c=o.copyImageToClipboard,l=t.length,u=l>0?(n%l+l)%l:0,d=l>0?t[u]:null,[f,p]=(0,j.useState)(1),[m,h]=(0,j.useState)(0),[g,_]=(0,j.useState)({x:0,y:0}),[v,y]=(0,j.useState)(!1),[b,x]=(0,j.useState)({width:0,height:0}),[S,C]=(0,j.useState)(null),w=(0,j.useRef)({x:0,y:0}),T=(0,j.useRef)(null),E=(0,j.useRef)(null);(0,j.useEffect)(()=>{p(1),h(0),_({x:0,y:0}),C(null)},[u,e]),(0,j.useEffect)(()=>{let t=E.current;if(!t||!e)return;let n=new ResizeObserver(e=>{for(let t of e){let{width:e,height:n}=t.contentRect;x({width:e,height:n})}});return n.observe(t),()=>n.disconnect()},[e,u]);let D=(0,j.useCallback)((e,t)=>{if(t<=1||!b.width||!b.height)return{x:0,y:0};let n=b.width/t,r=b.height/t,i=(n*t-n)/2,a=(r*t-r)/2;return{x:Math.max(-i,Math.min(i,e.x)),y:Math.max(-a,Math.min(a,e.y))}},[b.width,b.height]);if((0,j.useEffect)(()=>{_(e=>D(e,f))},[f,D]),(0,j.useEffect)(()=>{if(!e)return;let t=T.current;if(!t)return;function n(e){e.preventDefault(),p(t=>e.deltaY<0?Math.min(t+Rk,Lk):Math.max(t-Rk,Ik))}return t.addEventListener(`wheel`,n,{passive:!1}),()=>t.removeEventListener(`wheel`,n)},[e]),(0,j.useEffect)(()=>{if(!e)return;function t(e){e.key===`Escape`&&(e.preventDefault(),S?C(null):r())}function n(e){if(!(l<=1)){if(e.key===`ArrowRight`)e.preventDefault(),i((u+1)%l);else if(e.key===`ArrowLeft`)e.preventDefault(),i((u-1+l)%l);else if(/^[1-9]$/.test(e.key)){let t=Number(e.key)-1;t<l&&(e.preventDefault(),i(t))}}}return window.addEventListener(`keydown`,t,!0),window.addEventListener(`keydown`,n),()=>{window.removeEventListener(`keydown`,t,!0),window.removeEventListener(`keydown`,n)}},[S,e,l,u,r,i]),!e||!d||typeof document>`u`)return null;let O=zk(o,d),k=d.name||a(`attachment.title`);function A(){p(e=>Math.min(e+Rk,Lk))}function M(){p(e=>Math.max(e-Rk,Ik))}function N(){h(e=>(e+90)%360)}function ee(){h(e=>(e-90+360)%360)}function P(){p(1),h(0),_({x:0,y:0})}function F(){if(!O)return;let e=document.createElement(`a`);e.href=O,e.download=k,e.rel=`noreferrer`,e.target=`_blank`,document.body.appendChild(e),e.click(),e.remove()}async function te(){if(O&&c){C(null);try{await c(O),s.success(a(`attachment.imageCopied`))}catch(e){s.error(a(`attachment.imageCopyFailed`),{description:e instanceof Error?e.message:String(e)})}}}function ne(e){f<=1||(y(!0),w.current={x:e.clientX-g.x,y:e.clientY-g.y})}function re(e){!v||f<=1||_(D({x:e.clientX-w.current.x,y:e.clientY-w.current.y},f))}function ie(){y(!1)}function ae(e){e.stopPropagation()}return(0,td.createPortal)((0,I.jsx)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center bg-black/75 text-white`,"data-testid":`attachment-preview-backdrop`,role:`presentation`,onMouseDown:r,children:(0,I.jsx)(`div`,{className:`flex h-full w-full flex-col`,"data-testid":`attachment-preview-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":a(`attachment.previewLabel`,{name:k}),onMouseDown:ae,children:(0,I.jsxs)(`div`,{className:`flex h-full w-full flex-col`,"data-testid":`attachment-preview-dialog`,onMouseDown:ae,children:[(0,I.jsxs)(`header`,{className:`relative flex h-14 shrink-0 items-center justify-center px-16`,children:[(0,I.jsx)(`button`,{type:`button`,className:`absolute left-4 inline-flex size-9 items-center justify-center rounded-md text-white/80 hover:bg-white/10 hover:text-white`,"data-testid":`attachment-preview-download`,"aria-label":a(`attachment.download`),title:a(`attachment.download`),onClick:F,children:(0,I.jsx)(Ma,{className:`size-5`,"aria-hidden":!0})}),(0,I.jsx)(`span`,{className:`truncate text-sm font-medium`,"data-testid":`attachment-preview-title`,title:k,children:k}),(0,I.jsx)(`button`,{type:`button`,className:`absolute right-4 inline-flex size-9 items-center justify-center rounded-md text-white/80 hover:bg-white/10 hover:text-white`,"data-testid":`attachment-preview-close`,"aria-label":a(`attachment.closePreview`),onClick:r,children:(0,I.jsx)(Nc,{className:`size-5`,"aria-hidden":!0})})]}),(0,I.jsxs)(`div`,{ref:T,className:`relative flex flex-1 select-none items-center justify-center overflow-hidden px-16`,onMouseDown:()=>C(null),children:[l>1?(0,I.jsx)(`button`,{type:`button`,className:`absolute left-2 top-1/2 z-10 inline-flex size-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/40 text-white hover:bg-black/60`,"data-testid":`attachment-preview-prev`,"aria-label":a(`attachment.previousAttachment`),onClick:()=>i((u-1+l)%l),children:(0,I.jsx)(na,{className:`size-6`,"aria-hidden":!0})}):null,(0,I.jsx)(`div`,{className:K(`flex h-full w-full items-center justify-center`,f>1?v?`cursor-grabbing`:`cursor-grab`:`cursor-default`),style:{touchAction:`none`},onMouseDown:ne,onMouseMove:re,onMouseUp:ie,onMouseLeave:ie,children:O?(0,I.jsx)(`img`,{ref:E,src:O,alt:k,draggable:!1,"data-testid":`attachment-preview-image`,className:`max-h-full max-w-full select-none`,onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),c&&C({x:Math.min(e.clientX,Math.max(8,window.innerWidth-180)),y:Math.min(e.clientY,Math.max(8,window.innerHeight-56))})},style:{transform:`translate(${g.x}px, ${g.y}px) scale(${f}) rotate(${m}deg)`,transition:v?`none`:`transform 0.2s ease-out`}}):(0,I.jsx)(`div`,{className:`rounded-md bg-white/5 px-6 py-4 text-sm text-white/70`,children:k})}),S?(0,I.jsx)(`div`,{className:`fixed z-[110] min-w-40 rounded-lg border border-white/15 bg-neutral-900 p-1 shadow-xl`,style:{left:S.x,top:S.y},"data-testid":`attachment-preview-context-menu`,role:`menu`,onMouseDown:e=>e.stopPropagation(),onContextMenu:e=>e.preventDefault(),children:(0,I.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm text-white hover:bg-white/10`,"data-testid":`attachment-preview-copy-image`,role:`menuitem`,onClick:()=>void te(),children:[(0,I.jsx)(Ca,{className:`size-4`,"aria-hidden":!0}),a(`attachment.copyImage`)]})}):null,l>1?(0,I.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 z-10 inline-flex size-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/40 text-white hover:bg-black/60`,"data-testid":`attachment-preview-next`,"aria-label":a(`attachment.nextAttachment`),onClick:()=>i((u+1)%l),children:(0,I.jsx)(ra,{className:`size-6`,"aria-hidden":!0})}):null,(0,I.jsxs)(`div`,{className:`pointer-events-auto absolute bottom-4 left-1/2 flex -translate-x-1/2 items-center gap-1 rounded-lg bg-black/60 px-3 py-1.5`,"data-testid":`attachment-preview-toolbar`,children:[(0,I.jsx)(`button`,{type:`button`,className:`rounded p-1.5 transition-colors hover:bg-white/10`,"data-testid":`attachment-preview-zoom-out`,"aria-label":a(`attachment.zoomOut`),title:a(`attachment.zoomOut`),onClick:M,children:(0,I.jsx)(Ic,{className:`size-4`,"aria-hidden":!0})}),(0,I.jsxs)(`span`,{className:`min-w-[3rem] text-center text-xs font-medium tabular-nums`,"data-testid":`attachment-preview-zoom-percent`,children:[Math.round(f*100),`%`]}),(0,I.jsx)(`button`,{type:`button`,className:`rounded p-1.5 transition-colors hover:bg-white/10`,"data-testid":`attachment-preview-zoom-in`,"aria-label":a(`attachment.zoomIn`),title:a(`attachment.zoomIn`),onClick:A,children:(0,I.jsx)(Fc,{className:`size-4`,"aria-hidden":!0})}),(0,I.jsx)(`div`,{className:`mx-1 h-5 w-px bg-white/20`}),(0,I.jsx)(`button`,{type:`button`,className:`rounded p-1.5 transition-colors hover:bg-white/10`,"data-testid":`attachment-preview-rotate-ccw`,"aria-label":a(`attachment.rotateCcw`),title:a(`attachment.rotateCcw`),onClick:ee,children:(0,I.jsx)(Es,{className:`size-4 -scale-x-100`,"aria-hidden":!0})}),(0,I.jsx)(`button`,{type:`button`,className:`rounded p-1.5 transition-colors hover:bg-white/10`,"data-testid":`attachment-preview-rotate-cw`,"aria-label":a(`attachment.rotateCw`),title:a(`attachment.rotateCw`),onClick:N,children:(0,I.jsx)(Es,{className:`size-4`,"aria-hidden":!0})}),(0,I.jsx)(`div`,{className:`mx-1 h-5 w-px bg-white/20`}),(0,I.jsx)(`button`,{type:`button`,className:`rounded p-1.5 transition-colors hover:bg-white/10`,"data-testid":`attachment-preview-reset`,"aria-label":a(`attachment.reset`),title:a(`attachment.reset`),onClick:P,children:(0,I.jsx)(bs,{className:`size-4`,"aria-hidden":!0})})]})]}),l>1?(0,I.jsx)(`footer`,{className:`flex shrink-0 items-center justify-center gap-2 overflow-x-auto px-6 py-3`,"data-testid":`attachment-preview-footer`,children:t.map((e,t)=>{let n=zk(o,e),r=t===u;return(0,I.jsx)(`button`,{type:`button`,className:K(`group h-12 w-12 shrink-0 overflow-hidden rounded-md border-2 transition`,r?`border-white`:`border-transparent opacity-60 hover:opacity-100`),"data-testid":`attachment-preview-thumb`,"data-active":r?`true`:`false`,"aria-label":a(`attachment.showAttachment`,{index:t+1}),"aria-current":r?`true`:void 0,onClick:()=>{t!==u&&i(t)},children:n?(0,I.jsx)(`img`,{src:n,alt:e.name||a(`attachment.imageAltIndex`,{index:t+1}),className:`h-full w-full object-cover`,draggable:!1}):(0,I.jsx)(`span`,{className:`flex h-full w-full items-center justify-center text-[10px] text-white/70`,children:t+1})},`${e.url||e.name}-${t}`)})}):null]})})}),document.body)}function Vk({tableViews:e,activeViewId:t,onSelectView:n,viewCreateOpen:r,onToggleViewCreate:i,onCloseViewCreate:a,onCreateView:o,onRenameView:s,onDuplicateView:c,onDeleteView:l,busy:u}){let{t:d}=U(`table`),f=(0,j.useRef)(null);return te(f,r,a),(0,I.jsx)(`div`,{className:`data-inline-topbar`,children:(0,I.jsxs)(`div`,{className:`data-inline-header-left`,children:[(0,I.jsx)(`div`,{className:`data-inline-view-tabs`,children:e.map(r=>(0,I.jsx)(Hk,{view:r,active:t===r.id,label:gT(r)||d(hT(r.type)),onSelect:()=>n(r.id),onRename:s,onDuplicate:c,onDelete:l,canDelete:e.length>1,busy:u},r.id))}),(0,I.jsxs)(`div`,{ref:f,className:`data-inline-add-view`,children:[(0,I.jsx)(`button`,{type:`button`,className:`data-inline-add-view-trigger`,title:d(`header.addView`),onClick:i,disabled:u,children:(0,I.jsx)(ps,{className:`size-4`})}),r?(0,I.jsx)(`div`,{className:`data-inline-add-view-menu`,children:mT.map(e=>(0,I.jsxs)(`button`,{type:`button`,onClick:()=>o(e.type),children:[vT(e.type),(0,I.jsx)(`span`,{children:d(e.labelKey)})]},e.type))}):null]})]})})}function Hk({view:e,active:t,label:n,onSelect:r,onRename:i,onDuplicate:a,onDelete:o,canDelete:s,busy:c}){let{t:l}=U(`table`),[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)(!1),[m,h]=(0,j.useState)(n),g=(0,j.useRef)(null);(0,j.useEffect)(()=>{f&&(g.current?.focus(),g.current?.select())},[f]);function _(){let t=m.trim();p(!1),t&&i(e.id,t)}return(0,I.jsxs)(`div`,{className:K(`data-inline-view-tab`,t&&`is-active`),children:[f?(0,I.jsxs)(`div`,{className:`data-inline-view-tab-rename`,children:[vT(e.type),(0,I.jsx)(`input`,{ref:g,value:m,onChange:e=>h(e.target.value),onBlur:_,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&p(!1)},"aria-label":l(`toolbar.viewName`),"data-testid":`data-view-rename-${e.id}`})]}):(0,I.jsxs)(`button`,{type:`button`,className:K(`data-inline-view-tab-select`,t&&`is-active`),onClick:r,"aria-label":n,children:[vT(e.type),(0,I.jsx)(`span`,{children:n})]}),t&&!f?(0,I.jsxs)(c_,{open:u,onOpenChange:d,children:[(0,I.jsx)(l_,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`data-inline-view-tab-menu-trigger`,"aria-label":l(`viewMenu.open`),title:l(`viewMenu.optionsFor`,{title:n}),"aria-expanded":u,disabled:c,"data-testid":`data-view-menu-${e.id}`,children:(0,I.jsx)(Na,{className:`size-4`})})}),(0,I.jsxs)(u_,{align:`start`,sideOffset:6,className:`data-inline-view-tab-menu`,role:`menu`,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,I.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:c||e.locked,onClick:()=>{d(!1),h(n),p(!0)},children:[(0,I.jsx)(os,{className:`size-4`}),(0,I.jsx)(`span`,{children:l(`viewMenu.rename`)})]}),(0,I.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:c,onClick:()=>{d(!1),a(e.id)},children:[(0,I.jsx)(Ca,{className:`size-4`}),(0,I.jsx)(`span`,{children:l(`viewMenu.duplicate`)})]}),(0,I.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`is-destructive`,disabled:c||e.locked||!s,title:s?void 0:l(`viewMenu.keepOne`),onClick:()=>{d(!1),o(e.id)},children:[(0,I.jsx)(hc,{className:`size-4`}),(0,I.jsx)(`span`,{children:l(`viewMenu.delete`)})]})]})]}):null]})}var Uk=[`is`,`isNot`,`contains`,`doesNotContain`,`isEmpty`,`isNotEmpty`],Wk=[`is`,`isNot`,`isGreater`,`isGreaterEqual`,`isLess`,`isLessEqual`,`isEmpty`,`isNotEmpty`],Gk=[`is`,`isNot`,`isWithIn`,`isBefore`,`isAfter`,`isOnOrBefore`,`isOnOrAfter`,`isEmpty`,`isNotEmpty`],Kk=[`is`,`isNot`,`isAnyOf`,`isNoneOf`,`isEmpty`,`isNotEmpty`],qk=[`hasAnyOf`,`hasAllOf`,`isExactly`,`isNotExactly`,`hasNoneOf`,`isEmpty`,`isNotEmpty`],Jk=[`is`,`isNot`,`isAnyOf`,`isNoneOf`,`isEmpty`,`isNotEmpty`],Yk={text:Uk,long_text:Uk,url:Uk,number:Wk,rating:Wk,auto_number:Wk,date:Gk,datetime:Gk,created_time:Gk,last_modified_time:Gk,single_select:Kk,multi_select:qk,user:Jk,created_by:Jk,last_modified_by:Jk,checkbox:[`is`],attachment:[`isEmpty`,`isNotEmpty`]};function Xk(e){return Yk[e.type]??[]}function Zk(e){return Xk(e).length>0}function Qk(e){return`filter.operators.${e}`}var $k=[`isAnyOf`,`isNoneOf`,`hasAnyOf`,`hasAllOf`,`isExactly`,`isNotExactly`,`hasNoneOf`],eA=[`isEmpty`,`isNotEmpty`];function tA(e){return $k.includes(e)}function nA(e){return eA.includes(e)}function rA(e,t){if(nA(t))return null;let n=tA(t),r=Array.isArray(e);return n&&!r?e===null||e===``?[]:[String(e)]:!n&&r?e.length>0?e[0]:null:e}function iA(e){return e?Xk(e)[0]??`is`:`is`}function aA(e,t,n){if(t.field_name!==void 0&&t.field_name!==e.field_name){let r=n.find(e=>e.name===t.field_name);return{...e,field_name:t.field_name,operator:iA(r),value:null}}return t.operator!==void 0&&t.operator!==e.operator?{...e,operator:t.operator,value:rA(e.value,t.operator)}:t.value===void 0?e:{...e,value:t.value}}function oA({open:e,onOpenChange:t,buttonClassName:n,menuClassName:r,active:i,icon:a,label:o,children:s,align:c=`left`,testId:l,menuTestId:u}){let d=(0,j.useRef)(null);return(0,j.useEffect)(()=>{if(!e)return;function n(e){d.current?.contains(e.target)||t(!1)}function r(e){e.key===`Escape`&&(e.preventDefault(),t(!1))}return window.addEventListener(`mousedown`,n),window.addEventListener(`keydown`,r,!0),()=>{window.removeEventListener(`mousedown`,n),window.removeEventListener(`keydown`,r,!0)}},[t,e]),(0,I.jsxs)(`div`,{ref:d,className:`data-inline-toolbar-popover`,children:[(0,I.jsxs)(`button`,{type:`button`,className:K(`data-inline-toolbar-group`,n,i&&`is-active`,e&&`is-open`),onClick:()=>t(!e),"aria-label":o||void 0,title:o||void 0,"data-testid":l,children:[a,o?(0,I.jsx)(`span`,{className:`data-inline-toolbar-group-label`,children:o}):null]}),e?(0,I.jsx)(`div`,{className:K(`data-inline-toolbar-menu`,c===`right`&&`is-right`,r),"data-testid":u,children:s}):null]})}function sA({record:e,position:t,busy:n,canInsert:r,canRegenerateAI:i,onClose:a,onInsertAbove:o,onInsertBelow:s,onDuplicate:c,onCopyURL:l,onCopyImage:u,onHistory:d,onComment:f,onAddToChat:p,onCreateDesign:m,onRegenerateAI:h,onDelete:g}){let _=(0,j.useRef)(null),{t:v}=U(`table`),[y,b]=(0,j.useState)(1),[x,S]=(0,j.useState)(1),C=typeof window>`u`?t.x:Math.min(t.x,Math.max(12,window.innerWidth-270)),w=typeof window>`u`?t.y:Math.min(t.y,Math.max(12,window.innerHeight-330));(0,j.useEffect)(()=>{function e(e){_.current?.contains(e.target)||a()}function t(e){e.key===`Escape`&&(e.preventDefault(),a())}return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t,!0),window.addEventListener(`scroll`,a,!0),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t,!0),window.removeEventListener(`scroll`,a,!0)}},[a]);function T(e){return Math.max(1,Math.min(50,Math.floor(e)||1))}return(0,I.jsxs)(`div`,{ref:_,className:`data-inline-record-menu`,style:{left:C,top:w},onClick:e=>e.stopPropagation(),onContextMenu:e=>e.preventDefault(),"data-record-id":e.id,children:[(0,I.jsxs)(`div`,{className:`data-inline-record-menu-section`,children:[(0,I.jsxs)(`div`,{className:K(`data-inline-record-menu-insert`,!r&&`is-disabled`),children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>o(T(y)),disabled:n||!r,children:(0,I.jsx)(zi,{className:`size-4`})}),(0,I.jsx)(`span`,{children:v(`recordMenu.insert`)}),(0,I.jsx)(`input`,{type:`number`,min:1,max:50,value:y,disabled:n||!r,onChange:e=>b(T(Number(e.target.value))),"aria-label":v(`recordMenu.insertAboveCount`)}),(0,I.jsx)(`span`,{children:v(`recordMenu.recordAbove`)})]}),(0,I.jsxs)(`div`,{className:K(`data-inline-record-menu-insert`,!r&&`is-disabled`),children:[(0,I.jsx)(`button`,{type:`button`,onClick:()=>s(T(x)),disabled:n||!r,children:(0,I.jsx)(ki,{className:`size-4`})}),(0,I.jsx)(`span`,{children:v(`recordMenu.insert`)}),(0,I.jsx)(`input`,{type:`number`,min:1,max:50,value:x,disabled:n||!r,onChange:e=>S(T(Number(e.target.value))),"aria-label":v(`recordMenu.insertBelowCount`)}),(0,I.jsx)(`span`,{children:v(`recordMenu.recordBelow`)})]})]}),(0,I.jsxs)(`div`,{className:`data-inline-record-menu-section`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,onClick:c,disabled:n,children:[(0,I.jsx)(Ca,{className:`size-4`}),v(`recordMenu.duplicateRecord`)]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,onClick:l,disabled:n,children:[(0,I.jsx)(wo,{className:`size-4`}),v(`recordMenu.copyRecordUrl`)]}),u?(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,onClick:u,disabled:n,children:[(0,I.jsx)(po,{className:`size-4`}),v(`recordMenu.copyImage`)]}):null]}),(0,I.jsxs)(`div`,{className:`data-inline-record-menu-section`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,onClick:d,disabled:n,children:[(0,I.jsx)(Ts,{className:`size-4`}),v(`recordMenu.showHistory`)]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,onClick:f,disabled:n,children:[(0,I.jsx)(Ro,{className:`size-4`}),v(`recordMenu.addComment`)]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,onClick:p,disabled:n,children:[(0,I.jsx)(Ps,{className:`size-4`}),v(`recordMenu.addToChat`)]}),m?(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,onClick:m,disabled:n,children:[(0,I.jsx)(bo,{className:`size-4`}),v(`recordMenu.createDesign`)]}):null,i?(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,onClick:h,disabled:n,children:[(0,I.jsx)(Ws,{className:`size-4`}),v(`recordMenu.regenerateAiFields`)]}):null]}),(0,I.jsx)(`div`,{className:`data-inline-record-menu-section`,children:(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item is-danger`,onClick:g,disabled:n,children:[(0,I.jsx)(hc,{className:`size-4`}),v(`recordMenu.deleteRecord`)]})})]})}var cA={and:`filter.conjunction.and`,or:`filter.conjunction.or`};function lA({value:e,onChange:t,className:n}){let{t:r}=U(`table`),[i,a]=(0,j.useState)(!1),o=(0,j.useRef)(null);return(0,j.useEffect)(()=>{if(!i)return;function e(e){o.current?.contains(e.target)||a(!1)}function t(e){e.key===`Escape`&&a(!1)}return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[i]),(0,I.jsxs)(`div`,{ref:o,className:K(`data-inline-filter-conjunction`,n),children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-filter-conjunction-button`,onClick:()=>a(e=>!e),children:[(0,I.jsx)(`span`,{children:r(cA[e])}),(0,I.jsx)(ta,{className:`size-3.5 opacity-70`})]}),i?(0,I.jsx)(`div`,{className:`data-inline-filter-conjunction-menu`,role:`menu`,children:[`and`,`or`].map(n=>(0,I.jsx)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e===n,className:K(`data-inline-filter-conjunction-item`,e===n&&`is-active`),onClick:()=>{t(n),a(!1)},children:r(cA[n])},n))}):null]})}function uA({fields:e,value:t,onChange:n}){let{t:r}=U(`table`),[i,a]=(0,j.useState)(!1),o=(0,j.useRef)(null),s=e.filter(Zk),c=e.find(e=>e.name===t);return(0,j.useEffect)(()=>{if(!i)return;function e(e){o.current?.contains(e.target)||a(!1)}function t(e){e.key===`Escape`&&a(!1)}return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[i]),(0,I.jsxs)(`div`,{ref:o,className:`data-inline-filter-cell`,children:[(0,I.jsxs)(`button`,{type:`button`,className:K(`data-inline-filter-cell-button`,!c&&`is-placeholder`),onClick:()=>a(e=>!e),children:[(0,I.jsx)(`span`,{className:`data-inline-filter-cell-icon`,children:c?kT(c):null}),(0,I.jsx)(`span`,{className:`data-inline-filter-cell-label`,children:c?c.title:r(`filter.chooseField`)}),(0,I.jsx)(ta,{className:`size-3.5 opacity-70`})]}),i?(0,I.jsxs)(`div`,{className:`data-inline-filter-cell-menu`,role:`listbox`,children:[s.map(e=>(0,I.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e.name===t,className:K(`data-inline-filter-cell-menu-item`,e.name===t&&`is-active`),onClick:()=>{n(e.name),a(!1)},children:[(0,I.jsx)(`span`,{className:`data-inline-filter-cell-icon`,children:kT(e)}),(0,I.jsx)(`span`,{className:`data-inline-filter-cell-label`,children:e.title})]},e.id)),s.length===0?(0,I.jsx)(`div`,{className:`data-inline-filter-cell-empty`,children:r(`filter.noFilterableFields`)}):null]}):null]})}function dA({field:e,value:t,onChange:n}){let{t:r}=U(`table`),[i,a]=(0,j.useState)(!1),o=(0,j.useRef)(null),s=e?Xk(e):[],c=!e||s.length===0;return(0,j.useEffect)(()=>{if(!i)return;function e(e){o.current?.contains(e.target)||a(!1)}function t(e){e.key===`Escape`&&a(!1)}return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[i]),(0,I.jsxs)(`div`,{ref:o,className:`data-inline-filter-cell`,children:[(0,I.jsxs)(`button`,{type:`button`,disabled:c,className:K(`data-inline-filter-cell-button`,c&&`is-disabled`),onClick:()=>!c&&a(e=>!e),children:[(0,I.jsx)(`span`,{className:`data-inline-filter-cell-label`,children:r(Qk(t))}),(0,I.jsx)(ta,{className:`size-3.5 opacity-70`})]}),i?(0,I.jsx)(`div`,{className:`data-inline-filter-cell-menu`,role:`listbox`,children:s.map(e=>(0,I.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":e===t,className:K(`data-inline-filter-cell-menu-item`,e===t&&`is-active`),onClick:()=>{n(e),a(!1)},children:r(Qk(e))},e))}):null]})}function fA({value:e,onChange:t}){let{t:n}=U(`table`),r=e===!0;return(0,I.jsxs)(`label`,{className:`data-inline-filter-value-checkbox`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>t(e.target.checked)}),(0,I.jsx)(`span`,{children:n(r?`filter.checked`:`filter.unchecked`)})]})}function pA({value:e,onChange:t}){return(0,I.jsx)(b_,{type:`date`,value:typeof e==`string`?e:``,onChange:e=>t(e.target.value===``?null:e.target.value),className:`data-inline-filter-value-input`})}function mA(e){let t=e.options?.choices;return Array.isArray(t)?t.map(e=>{if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.name==`string`?t.name:null;return n?{id:typeof t.id==`string`?t.id:n,name:n,color:typeof t.color==`string`?t.color:void 0}:null}).filter(e=>e!==null):[]}function hA({field:e,value:t,onChange:n}){let{t:r}=U(`table`),[i,a]=(0,j.useState)(!1),o=(0,j.useRef)(null),s=mA(e),c=Array.isArray(t)?t:[];(0,j.useEffect)(()=>{if(!i)return;function e(e){o.current?.contains(e.target)||a(!1)}function t(e){e.key===`Escape`&&a(!1)}return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[i]);function l(e){let t=new Set(c);t.has(e)?t.delete(e):t.add(e),n(Array.from(t))}function u(e){n(c.filter(t=>t!==e))}return(0,I.jsxs)(`div`,{ref:o,className:`data-inline-filter-value`,children:[(0,I.jsxs)(`button`,{type:`button`,className:K(`data-inline-filter-cell-button`,c.length===0&&`is-placeholder`),onClick:()=>a(e=>!e),children:[c.length===0?(0,I.jsx)(`span`,{className:`data-inline-filter-cell-label`,children:r(`filter.chooseOptions`)}):(0,I.jsx)(`span`,{className:`data-inline-filter-chip-list`,children:c.map(e=>{let t=s.find(t=>t.name===e);return(0,I.jsxs)(`span`,{className:`data-inline-filter-chip`,style:t?.color?{background:t.color}:void 0,children:[e,(0,I.jsx)(`span`,{role:`button`,className:`data-inline-filter-chip-remove`,onClick:t=>{t.stopPropagation(),u(e)},children:(0,I.jsx)(Nc,{className:`size-3`})})]},e)})}),(0,I.jsx)(ta,{className:`size-3.5 opacity-70`})]}),i?(0,I.jsxs)(`div`,{className:`data-inline-filter-cell-menu`,role:`listbox`,children:[s.length===0?(0,I.jsx)(`div`,{className:`data-inline-filter-cell-empty`,children:r(`filter.noOptions`)}):null,s.map(e=>{let t=c.includes(e.name);return(0,I.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,className:K(`data-inline-filter-cell-menu-item`,t&&`is-active`),onClick:()=>l(e.name),children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:t,readOnly:!0,className:`data-inline-filter-cell-menu-check`}),e.color?(0,I.jsx)(`span`,{className:`data-inline-filter-choice-dot`,style:{background:e.color}}):null,(0,I.jsx)(`span`,{className:`data-inline-filter-cell-label`,children:e.name})]},e.id)})]}):null]})}function gA({value:e,onChange:t}){return(0,I.jsx)(b_,{type:`number`,inputMode:`decimal`,value:typeof e==`number`?String(e):``,placeholder:`0`,onChange:e=>{let n=e.target.value;if(n===``)return t(null);let r=Number(n);t(Number.isFinite(r)?r:null)},className:`data-inline-filter-value-input`})}function _A({field:e,value:t,onChange:n}){let{t:r}=U(`table`),[i,a]=(0,j.useState)(!1),o=(0,j.useRef)(null),s=mA(e),c=s.find(e=>e.name===t)||null;return(0,j.useEffect)(()=>{if(!i)return;function e(e){o.current?.contains(e.target)||a(!1)}function t(e){e.key===`Escape`&&a(!1)}return window.addEventListener(`mousedown`,e),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`mousedown`,e),window.removeEventListener(`keydown`,t)}},[i]),(0,I.jsxs)(`div`,{ref:o,className:`data-inline-filter-value`,children:[(0,I.jsxs)(`button`,{type:`button`,className:K(`data-inline-filter-cell-button`,!c&&`is-placeholder`),onClick:()=>a(e=>!e),children:[c?(0,I.jsxs)(I.Fragment,{children:[c.color?(0,I.jsx)(`span`,{className:`data-inline-filter-choice-dot`,style:{background:c.color}}):null,(0,I.jsx)(`span`,{className:`data-inline-filter-cell-label`,children:c.name})]}):(0,I.jsx)(`span`,{className:`data-inline-filter-cell-label`,children:r(`filter.chooseOption`)}),(0,I.jsx)(ta,{className:`size-3.5 opacity-70`})]}),i?(0,I.jsxs)(`div`,{className:`data-inline-filter-cell-menu`,role:`listbox`,children:[s.length===0?(0,I.jsx)(`div`,{className:`data-inline-filter-cell-empty`,children:r(`filter.noOptions`)}):null,s.map(e=>(0,I.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":e.name===t,className:K(`data-inline-filter-cell-menu-item`,e.name===t&&`is-active`),onClick:()=>{n(e.name),a(!1)},children:[e.color?(0,I.jsx)(`span`,{className:`data-inline-filter-choice-dot`,style:{background:e.color}}):null,(0,I.jsx)(`span`,{className:`data-inline-filter-cell-label`,children:e.name})]},e.id))]}):null]})}function vA({operator:e,value:t,onChange:n}){let{t:r}=U(`table`),i=typeof t==`string`?t:``,a=r(e===`contains`||e===`doesNotContain`?`filter.valueContains`:`filter.exactValue`);return(0,I.jsx)(b_,{value:i,placeholder:a,onChange:e=>n(e.target.value===``?null:e.target.value),className:`data-inline-filter-value-input`})}function yA({multi:e,value:t,onChange:n}){let{t:r}=U(`table`);if(e){let e=Array.isArray(t)?t.join(`, `):``;return(0,I.jsx)(b_,{value:e,placeholder:r(`filter.userNamesCommaSeparated`),onChange:e=>{let t=e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean);n(t.length?t:null)},className:`data-inline-filter-value-input`})}return(0,I.jsx)(b_,{value:typeof t==`string`?t:``,placeholder:r(`filter.userName`),onChange:e=>n(e.target.value===``?null:e.target.value),className:`data-inline-filter-value-input`})}var bA=[`isEmpty`,`isNotEmpty`];function xA({field:e,operator:t,value:n,onChange:r}){if(!e||bA.includes(t)||e.type===`attachment`)return null;switch(e.type){case`text`:case`long_text`:case`url`:return(0,I.jsx)(vA,{operator:t,value:n,onChange:r});case`number`:case`rating`:case`auto_number`:return(0,I.jsx)(gA,{value:n,onChange:r});case`date`:case`datetime`:case`created_time`:case`last_modified_time`:return(0,I.jsx)(pA,{value:n,onChange:r});case`checkbox`:return(0,I.jsx)(fA,{value:n,onChange:r});case`single_select`:return t===`isAnyOf`||t===`isNoneOf`?(0,I.jsx)(hA,{field:e,value:n,onChange:r}):(0,I.jsx)(_A,{field:e,value:n,onChange:r});case`multi_select`:return(0,I.jsx)(hA,{field:e,value:n,onChange:r});case`user`:case`created_by`:case`last_modified_by`:return(0,I.jsx)(yA,{multi:t===`isAnyOf`||t===`isNoneOf`,value:n,onChange:r});default:return null}}function SA({fields:e,condition:t,onUpdate:n,onRemove:r}){let{t:i}=U(`table`),a=e.find(e=>e.name===t.field_name);return(0,I.jsxs)(`div`,{className:`data-inline-filter-condition`,children:[(0,I.jsx)(uA,{fields:e,value:t.field_name,onChange:r=>n(aA(t,{field_name:r},e))}),(0,I.jsx)(dA,{field:a,value:t.operator,onChange:r=>n(aA(t,{operator:r},e))}),(0,I.jsx)(`div`,{className:`data-inline-filter-value`,children:(0,I.jsx)(xA,{field:a,operator:t.operator,value:t.value,onChange:r=>n(aA(t,{value:r},e))})}),(0,I.jsx)(`button`,{type:`button`,className:`data-inline-filter-remove`,onClick:r,"aria-label":i(`filter.removeCondition`),title:i(`filter.removeCondition`),children:(0,I.jsx)(hc,{className:`size-3.5`})})]})}function CA({fields:e,group:t,depth:n,onUpdate:r,onRemove:i,showRemove:a}){let{t:o}=U(`table`);function s(e,n){let i=t.children.slice();n===null?i.splice(e,1):i[e]=n,r({...t,children:i})}function c(){r({...t,children:[...t.children,tT()]})}function l(){r({...t,children:[...t.children,nT(`and`)]})}return(0,I.jsxs)(`div`,{className:K(`data-inline-filter-group`,n>0&&`data-inline-filter-group--nested`),children:[(0,I.jsxs)(`div`,{className:`data-inline-filter-group-head`,children:[(0,I.jsx)(lA,{value:t.conjunction,onChange:e=>r({...t,conjunction:e})}),a?(0,I.jsx)(`button`,{type:`button`,className:`data-inline-filter-remove`,onClick:i,"aria-label":o(`filter.removeGroup`),title:o(`filter.removeGroup`),children:(0,I.jsx)(hc,{className:`size-3.5`})}):null]}),(0,I.jsx)(`div`,{className:`data-inline-filter-children`,children:t.children.map((t,r)=>t.kind===`condition`?(0,I.jsx)(SA,{fields:e,condition:t,onUpdate:e=>s(r,e),onRemove:()=>s(r,null)},t.id):(0,I.jsx)(CA,{fields:e,group:t,depth:n+1,onUpdate:e=>s(r,e),onRemove:()=>s(r,null),showRemove:!0},t.id))}),(0,I.jsxs)(`div`,{className:`data-inline-filter-actions`,children:[(0,I.jsxs)(Rc,{variant:`secondary`,size:`sm`,onClick:c,children:[(0,I.jsx)(ps,{className:`size-3.5`}),o(`filter.addCondition`)]}),(0,I.jsxs)(Rc,{variant:`secondary`,size:`sm`,onClick:l,disabled:n>=1,children:[(0,I.jsx)(Oo,{className:`size-3.5`}),o(`filter.addConditionGroup`)]})]})]})}function wA({fields:e,value:t,onChange:n}){let r=t??nT(`and`);return(0,I.jsx)(CA,{fields:e,group:r,depth:0,onUpdate:e=>n(e.children.length===0?null:e),onRemove:()=>n(null),showRemove:!1})}function TA(e,t,n){let r=oT(e);if(!aT(e))return{label:n(`filter.filter`),active:!1};let i=new Set;function a(e){for(let n of e.children)if(n.kind===`group`)a(n);else{let e=t.find(e=>e.name===n.field_name);e&&i.add(e.title)}}if(e&&a(e),i.size===1){let[e]=Array.from(i);return{label:n(`filter.filterByField`,{title:e}),active:!0}}return i.size>1?{label:n(`filter.filterByFields`,{count:i.size}),active:!0}:{label:n(`filter.filterCount`,{count:r}),active:!0}}function EA({open:e,onOpenChange:t,fields:n,value:r,onChange:i}){let{t:a}=U(`table`),{label:o,active:s}=TA(r,n,a);return(0,I.jsx)(oA,{open:e,onOpenChange:t,buttonClassName:`data-inline-toolbar-group--filter`,menuClassName:`data-inline-toolbar-menu--filter`,active:s,icon:(0,I.jsx)($a,{className:`size-4`}),label:o,testId:`ktable-toolbar-filter`,menuTestId:`ktable-toolbar-filter-menu`,children:(0,I.jsx)(`div`,{className:`data-inline-filter-popover`,children:(0,I.jsx)(wA,{fields:n,value:r,onChange:i})})})}function DA({field:e,isPrimary:t,busy:n,visible:r,onEdit:i,onDuplicate:a,onToggleVisibility:o,onDelete:s}){let[c,l]=(0,j.useState)(!1),[u,d]=(0,j.useState)(null),f=(0,j.useRef)(null),p=(0,j.useRef)(null),{t:m}=U(`table`);(0,j.useEffect)(()=>{if(!c){d(null);return}function e(){let e=f.current?.getBoundingClientRect();if(!e)return;let t=window.innerWidth,n=window.innerHeight,r=e.right-192;r<8&&(r=8),r+192>t-8&&(r=t-192-8);let i=e.bottom+4;i+168>n-8&&(i=Math.max(8,e.top-168-4)),d({top:i,left:r})}e();function t(e){let t=e.target;!p.current?.contains(t)&&!f.current?.contains(t)&&l(!1)}return window.addEventListener(`mousedown`,t),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`mousedown`,t),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[c]),(0,j.useEffect)(()=>{if(!c)return;let e=p.current;if(!e)return;function t(e){e.stopPropagation()}return e.addEventListener(`mousedown`,t),()=>e.removeEventListener(`mousedown`,t)},[c,u]);function h(e){l(!1),e()}return(0,I.jsxs)(`div`,{className:`data-inline-field-config-row-menu`,children:[(0,I.jsx)(`button`,{ref:f,type:`button`,className:`data-inline-field-config-row-menu-trigger`,"aria-label":m(`toolbar.moreActions`),onClick:e=>{e.stopPropagation(),l(e=>!e)},children:(0,I.jsx)(Na,{className:`size-4`})}),c&&u?(0,td.createPortal)((0,I.jsxs)(`div`,{ref:p,className:`data-inline-field-config-row-menu-popup`,style:{top:u.top,left:u.left},onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,disabled:n,onClick:()=>h(()=>i(e)),children:[(0,I.jsx)(os,{className:`size-4`}),m(`toolbar.editField`)]}),(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item`,disabled:n,onClick:()=>h(()=>a(e)),children:[(0,I.jsx)(Ca,{className:`size-4`}),m(`toolbar.duplicateField`)]}),t?null:(0,I.jsx)(`button`,{type:`button`,className:`data-inline-record-menu-item`,disabled:n,onClick:()=>h(()=>o(e,!r)),children:r?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(La,{className:`size-4`}),m(`toolbar.hideField`)]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Ia,{className:`size-4`}),m(`toolbar.showField`)]})}),t?null:(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-menu-item is-danger`,disabled:n,onClick:()=>h(()=>s(e)),children:[(0,I.jsx)(hc,{className:`size-4`}),m(`toolbar.deleteField`)]})]}),document.body):null]})}function OA({fields:e,hiddenFieldNames:t,open:n,onOpenChange:r,onResetHiddenFields:i,onToggleFieldVisibility:a,busy:o,onEditField:s,onDuplicateField:c,onDeleteField:l,onOpenAddField:u}){let[d,f]=(0,j.useState)(``),{t:p}=U(`table`);(0,j.useEffect)(()=>{n||f(``)},[n]);let m=(0,j.useMemo)(()=>{let t=d.trim().toLowerCase();return t?e.filter(e=>e.title.toLowerCase().includes(t)):e},[e,d]);function h(e){r(!1),s(e)}function g(e,t){e.is_primary||a(e.name,t)}return(0,I.jsxs)(oA,{open:n,onOpenChange:r,buttonClassName:`data-inline-toolbar-group--field-config`,active:t.size>0,icon:(0,I.jsx)(Is,{className:`size-4`}),label:t.size?p(`toolbar.customizeFieldHidden`,{count:t.size}):p(`toolbar.customizeField`),children:[(0,I.jsxs)(`div`,{className:`data-inline-field-config-search`,children:[(0,I.jsx)(Ns,{className:`size-4`}),(0,I.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:p(`toolbar.searchPlaceholder`),autoFocus:!0}),t.size?(0,I.jsx)(`button`,{type:`button`,className:`data-inline-field-config-show-all`,onClick:i,children:p(`toolbar.showAll`)}):null]}),(0,I.jsx)(`div`,{className:`data-inline-field-config-list`,children:m.length===0?(0,I.jsx)(`div`,{className:`data-inline-field-config-empty`,children:p(`toolbar.noFields`)}):m.map(e=>{let n=!!e.is_primary,i=!t.has(e.name);return(0,I.jsxs)(`div`,{className:`data-inline-field-config-row`,role:`button`,tabIndex:0,onClick:()=>h(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),h(e))},children:[(0,I.jsx)(`span`,{className:`data-inline-field-config-icon`,children:kT(e)}),(0,I.jsx)(`span`,{className:`data-inline-field-config-title`,title:e.title,children:e.title}),(0,I.jsxs)(`span`,{className:`data-inline-field-config-actions`,onClick:e=>e.stopPropagation(),children:[n?(0,I.jsx)(`span`,{className:`data-inline-field-config-lock`,title:p(`toolbar.primaryField`),children:(0,I.jsx)(jo,{className:`size-3.5`})}):(0,I.jsx)(`button`,{type:`button`,className:`data-inline-field-config-eye`,"aria-label":p(i?`toolbar.hideField`:`toolbar.showField`),title:p(i?`toolbar.hideField`:`toolbar.showField`),onClick:t=>{t.stopPropagation(),g(e,!i)},children:i?(0,I.jsx)(Ia,{className:`size-4`}):(0,I.jsx)(La,{className:`size-4`})}),(0,I.jsx)(DA,{field:e,isPrimary:n,busy:o,visible:i,onEdit:e=>{r(!1),s(e)},onDuplicate:c,onToggleVisibility:g,onDelete:l})]})]},e.id)})}),(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-field-config-add`,onClick:()=>{r(!1),u()},children:[(0,I.jsx)(ps,{className:`size-4`}),p(`toolbar.addField`)]})]})}function kA({coverField:e,coverFieldName:t,coverFields:n,open:r,onOpenChange:i,onCoverFieldNameChange:a,onResetCoverField:o}){let{t:s}=U(`table`);return(0,I.jsxs)(oA,{open:r,onOpenChange:i,buttonClassName:`data-inline-toolbar-group--cover`,active:!!e,icon:(0,I.jsx)(eo,{className:`size-4`}),label:e?s(`toolbar.coverWithField`,{title:e.title}):s(`toolbar.coverField`),children:[(0,I.jsxs)(`div`,{className:`data-inline-toolbar-menu-head`,children:[(0,I.jsx)(`strong`,{children:s(`toolbar.galleryCover`)}),(0,I.jsx)(`button`,{type:`button`,onClick:o,children:s(`toolbar.auto`)})]}),(0,I.jsxs)(`div`,{className:`data-inline-toolbar-form`,children:[(0,I.jsxs)(C_,{value:t,onChange:e=>a(e.target.value),children:[(0,I.jsx)(`option`,{value:``,children:s(`toolbar.autoCover`)}),n.map(e=>(0,I.jsx)(`option`,{value:e.name,children:e.title},e.id))]}),(0,I.jsx)(`p`,{className:`data-inline-toolbar-hint`,children:s(`toolbar.coverHint`)})]})]})}var AA=[{value:`short`,labelKey:`toolbar.rowHeight.short`},{value:`medium`,labelKey:`toolbar.rowHeight.medium`},{value:`tall`,labelKey:`toolbar.rowHeight.tall`},{value:`extra_tall`,labelKey:`toolbar.rowHeight.extraTall`}];function jA({rowHeightKey:e,open:t,onOpenChange:n,onRowHeightKeyChange:r}){let{t:i}=U(`table`);return(0,I.jsxs)(oA,{open:t,onOpenChange:n,buttonClassName:`data-inline-toolbar-group--row-height`,active:!1,icon:(0,I.jsx)(Ds,{className:`size-4`}),label:i(`toolbar.rowHeightLabel`),testId:`ktable-toolbar-row-height`,menuTestId:`ktable-toolbar-row-height-menu`,children:[(0,I.jsx)(`div`,{className:`data-inline-toolbar-menu-head`,children:(0,I.jsx)(`strong`,{children:i(`toolbar.rowHeightLabel`)})}),(0,I.jsx)(`div`,{className:`data-inline-check-list`,children:AA.map(t=>(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`input`,{type:`radio`,name:`row-height`,checked:e===t.value,onChange:()=>{r(t.value),n(!1)}}),(0,I.jsx)(`span`,{children:i(t.labelKey)})]},t.value))})]})}function MA({fields:e,frozenColumnCount:t,open:n,onOpenChange:r,onFrozenColumnCountChange:i}){let{t:a}=U(`table`),o=Math.max(0,Math.min(e.length,5)),s=t>0;return(0,I.jsxs)(oA,{open:n,onOpenChange:r,buttonClassName:`data-inline-toolbar-group--freeze`,active:s,icon:(0,I.jsx)(ls,{className:`size-4`}),label:s?String(t):``,testId:`ktable-toolbar-freeze`,menuTestId:`ktable-toolbar-freeze-menu`,children:[(0,I.jsx)(`div`,{className:`data-inline-toolbar-menu-head`,children:(0,I.jsx)(`strong`,{children:a(`toolbar.freezeColumns`)})}),(0,I.jsx)(`div`,{className:`data-inline-check-list`,children:Array.from({length:o+1},(e,n)=>(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`input`,{type:`radio`,name:`freeze-count`,checked:t===n,onChange:()=>{i(n),r(!1)}}),(0,I.jsx)(`span`,{children:n===0?a(`toolbar.freezeNone`):a(`toolbar.freezeColumnsCount`,{count:n})})]},n))})]})}function NA(){return`sort_${Math.random().toString(36).slice(2,10)}`}function PA(){return`group_${Math.random().toString(36).slice(2,10)}`}function FA(e,t,n){if(t===n||t<0||n<0||t>=e.length||n>=e.length)return e;let r=e.slice(),[i]=r.splice(t,1);return r.splice(n,0,i),r}function IA({fields:e,sortItems:t,open:n,onOpenChange:r,onSortItemsChange:i}){let{t:a}=U(`table`),[o,s]=(0,j.useState)(null),c=new Map(e.map(e=>[e.name,e])),l=t.length===0?a(`toolbar.sort`):a(`toolbar.sortCount`,{count:t.length});function u(){let n=new Set(t.map(e=>e.field_name)),r=e.find(e=>!n.has(e.name))||e[0];r&&i([...t,{id:NA(),field_name:r.name,direction:`asc`}])}function d(e){i(t.filter((t,n)=>n!==e))}function f(e,n){i(t.map((t,r)=>r===e?{...t,...n}:t))}return(0,I.jsxs)(oA,{open:n,onOpenChange:r,buttonClassName:`data-inline-toolbar-group--sort`,active:t.length>0,icon:(0,I.jsx)(Bi,{className:`size-4`}),label:l,testId:`ktable-toolbar-sort`,menuTestId:`ktable-toolbar-sort-menu`,menuClassName:`data-inline-toolbar-menu--rules`,children:[(0,I.jsxs)(`div`,{className:`data-inline-toolbar-menu-head`,children:[(0,I.jsx)(`strong`,{children:a(`toolbar.sortRecords`)}),t.length>0?(0,I.jsx)(`button`,{type:`button`,onClick:()=>i([]),children:a(`toolbar.clearAll`)}):null]}),(0,I.jsx)(`div`,{className:`data-inline-sort-list`,children:t.map((n,r)=>{let l=c.get(n.field_name),u=AT(l?.type??`text`);return(0,I.jsxs)(`div`,{className:K(`data-inline-sort-row`,o===r&&`is-dragging`),draggable:!0,onDragStart:()=>s(r),onDragOver:e=>{e.preventDefault(),o!==null&&o!==r&&(i(FA(t,o,r)),s(r))},onDragEnd:()=>s(null),children:[(0,I.jsx)(`span`,{className:`data-inline-sort-handle`,"aria-hidden":!0,children:(0,I.jsx)(ao,{className:`size-3`})}),(0,I.jsxs)(`label`,{className:`data-inline-sort-field`,children:[(0,I.jsx)(`span`,{className:`data-inline-sort-field-icon`,"aria-hidden":!0,children:l?kT(l):null}),(0,I.jsx)(`span`,{className:`data-inline-sort-field-label`,children:l?.title??n.field_name}),(0,I.jsx)(ta,{className:`size-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,I.jsx)(`select`,{value:n.field_name,onChange:e=>f(r,{field_name:e.target.value}),"aria-label":a(`toolbar.sortField`),children:e.map(e=>(0,I.jsx)(`option`,{value:e.name,children:e.title},e.id))})]}),(0,I.jsxs)(C_,{className:`data-inline-sort-direction`,value:n.direction,onChange:e=>f(r,{direction:e.target.value}),"aria-label":a(`toolbar.sortDirection`),children:[(0,I.jsx)(`option`,{value:`asc`,children:a(u.asc)}),(0,I.jsx)(`option`,{value:`desc`,children:a(u.desc)})]}),(0,I.jsx)(`button`,{type:`button`,className:`data-inline-sort-remove`,onClick:()=>d(r),"aria-label":a(`toolbar.removeSort`),children:(0,I.jsx)(hc,{className:`size-3.5`})})]},n.id)})}),(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-sort-add-link`,onClick:u,disabled:t.length>=e.length||e.length===0,children:[(0,I.jsx)(ps,{className:`size-3.5`}),a(`toolbar.addAnotherSort`)]})]})}function LA({groupableFields:e,groupItems:t,open:n,onOpenChange:r,onGroupItemsChange:i}){let{t:a}=U(`table`),[o,s]=(0,j.useState)(null),c=new Map(e.map(e=>[e.name,e])),l=t.length===0?a(`toolbar.groupBy`):a(`toolbar.groupByCount`,{count:t.length});function u(){let n=new Set(t.map(e=>e.field_name)),r=e.find(e=>!n.has(e.name))||e[0];r&&i([...t,{id:PA(),field_name:r.name,direction:`asc`}])}function d(e){i(t.filter((t,n)=>n!==e))}function f(e,n){i(t.map((t,r)=>r===e?{...t,...n}:t))}return(0,I.jsxs)(oA,{open:n,onOpenChange:r,buttonClassName:`data-inline-toolbar-group--group`,active:t.length>0,icon:(0,I.jsx)(oo,{className:`size-4`}),label:l,testId:`ktable-toolbar-group`,menuTestId:`ktable-toolbar-group-menu`,menuClassName:`data-inline-toolbar-menu--rules`,children:[(0,I.jsxs)(`div`,{className:`data-inline-toolbar-menu-head`,children:[(0,I.jsx)(`strong`,{children:a(`toolbar.groupRecords`)}),t.length>0?(0,I.jsx)(`button`,{type:`button`,onClick:()=>i([]),children:a(`toolbar.clearAll`)}):null]}),(0,I.jsx)(`div`,{className:`data-inline-sort-list`,children:t.map((n,r)=>{let l=c.get(n.field_name),u=AT(l?.type??`text`);return(0,I.jsxs)(`div`,{className:K(`data-inline-sort-row`,o===r&&`is-dragging`),draggable:!0,onDragStart:()=>s(r),onDragOver:e=>{e.preventDefault(),o!==null&&o!==r&&(i(FA(t,o,r)),s(r))},onDragEnd:()=>s(null),children:[(0,I.jsx)(`span`,{className:`data-inline-sort-handle`,"aria-hidden":!0,children:(0,I.jsx)(ao,{className:`size-3`})}),(0,I.jsxs)(`label`,{className:`data-inline-sort-field`,children:[(0,I.jsx)(`span`,{className:`data-inline-sort-field-icon`,"aria-hidden":!0,children:l?kT(l):null}),(0,I.jsx)(`span`,{className:`data-inline-sort-field-label`,children:l?.title??n.field_name}),(0,I.jsx)(ta,{className:`size-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,I.jsx)(`select`,{value:n.field_name,onChange:e=>f(r,{field_name:e.target.value}),"aria-label":a(`toolbar.groupField`),children:e.map(e=>(0,I.jsx)(`option`,{value:e.name,children:e.title},e.id))})]}),(0,I.jsxs)(C_,{className:`data-inline-sort-direction`,value:n.direction,onChange:e=>f(r,{direction:e.target.value}),"aria-label":a(`toolbar.groupDirection`),children:[(0,I.jsx)(`option`,{value:`asc`,children:a(u.asc)}),(0,I.jsx)(`option`,{value:`desc`,children:a(u.desc)})]}),(0,I.jsx)(`button`,{type:`button`,className:`data-inline-sort-remove`,onClick:()=>d(r),"aria-label":a(`toolbar.removeGroup`),children:(0,I.jsx)(hc,{className:`size-3.5`})})]},n.id)})}),(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-sort-add-link`,onClick:u,disabled:t.length>=e.length||e.length===0,children:[(0,I.jsx)(ps,{className:`size-3.5`}),a(`toolbar.addAnotherGroup`)]})]})}function RA({busy:e,fields:t,hiddenFieldNames:n,onResetHiddenFields:r,onToggleFieldVisibility:i,onEditField:a,onDuplicateField:o,onDeleteField:s,onAddDefaultField:c,filterTree:l,onFilterTreeChange:u,sortItems:d,onSortItemsChange:f,groupableFields:p,groupItems:m,onGroupItemsChange:h,viewMode:g,coverFieldName:_,coverField:v,coverFields:y,onCoverFieldNameChange:b,onResetCoverField:x,rowHeightKey:S,onRowHeightKeyChange:C,frozenColumnCount:w,onFrozenColumnCountChange:T,toolbarPanel:E,onToolbarPanelChange:D,newFieldTitle:O,newFieldType:k,onNewFieldTitleChange:A,onNewFieldTypeChange:j,onAddField:M,selectedRecordCount:N,onRemoveSelectedRecords:ee,onDuplicateSelectedRecords:P,agentOpen:F,onToggleAgent:te,agentDisabled:ne,query:re,onQueryChange:ie,onAddRecord:ae}){let{t:oe}=U(`table`);return(0,I.jsxs)(`div`,{className:`data-inline-property-bar`,children:[(0,I.jsxs)(Rc,{size:`sm`,variant:`primary`,className:`data-inline-add-record-button`,onClick:ae,disabled:e,children:[(0,I.jsx)(ps,{className:`size-4`}),oe(`propertyBar.addRecord`)]}),(0,I.jsx)(`span`,{className:`data-inline-toolbar-divider`,"aria-hidden":`true`}),(0,I.jsx)(OA,{fields:t,hiddenFieldNames:n,open:E===`hidden`,onOpenChange:e=>D(e?`hidden`:null),onResetHiddenFields:r,onToggleFieldVisibility:i,busy:e,onEditField:a,onDuplicateField:o,onDeleteField:s,onOpenAddField:c}),(0,I.jsx)(EA,{open:E===`filter`,onOpenChange:e=>D(e?`filter`:null),fields:t,value:l,onChange:u}),(0,I.jsx)(IA,{fields:t,sortItems:d,open:E===`sort`,onOpenChange:e=>D(e?`sort`:null),onSortItemsChange:f}),(0,I.jsx)(LA,{groupableFields:p,groupItems:m,open:E===`group`,onOpenChange:e=>D(e?`group`:null),onGroupItemsChange:h}),g===`gallery`?(0,I.jsx)(kA,{coverField:v,coverFieldName:_,coverFields:y,open:E===`cover`,onOpenChange:e=>D(e?`cover`:null),onCoverFieldNameChange:b,onResetCoverField:x}):null,g===`grid`?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(jA,{rowHeightKey:S,open:E===`rowHeight`,onOpenChange:e=>D(e?`rowHeight`:null),onRowHeightKeyChange:C}),(0,I.jsx)(MA,{fields:t,frozenColumnCount:w,open:E===`freeze`,onOpenChange:e=>D(e?`freeze`:null),onFrozenColumnCountChange:T})]}):null,N?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`data-inline-property-divider`}),(0,I.jsxs)(Rc,{size:`sm`,variant:`secondary`,className:`data-inline-add-record-button`,onClick:P,disabled:e,children:[(0,I.jsx)(Ca,{className:`size-4`}),oe(`propertyBar.duplicateCount`,{count:N})]}),(0,I.jsxs)(Rc,{size:`sm`,variant:`ghost`,className:`data-inline-danger-button`,onClick:ee,disabled:e,children:[(0,I.jsx)(hc,{className:`size-4`}),oe(`propertyBar.deleteCount`,{count:N})]})]}):null,(0,I.jsx)(`span`,{className:`data-inline-toolbar-spacer`}),(0,I.jsxs)(`div`,{className:`data-inline-search`,children:[(0,I.jsx)(Ns,{className:`size-4`}),(0,I.jsx)(`input`,{value:re,onChange:e=>ie(e.target.value),placeholder:oe(`propertyBar.searchRecords`),"data-testid":`ktable-toolbar-search`})]})]})}function zA({tableViews:e,activeViewId:t,onSelectView:n,viewCreateOpen:r,onToggleViewCreate:i,onCloseViewCreate:a,onCreateView:o,onRenameView:s,onDuplicateView:c,onDeleteView:l,busy:u,fields:d,hiddenFieldNames:f,onResetHiddenFields:p,onToggleFieldVisibility:m,onEditField:h,onDuplicateField:g,onDeleteField:_,onAddDefaultField:v,filterTree:y,onFilterTreeChange:b,sortItems:x,onSortItemsChange:S,groupableFields:C,groupItems:w,onGroupItemsChange:T,viewMode:E,coverFieldName:D,coverField:O,coverFields:k,onCoverFieldNameChange:A,onResetCoverField:j,rowHeightKey:M,onRowHeightKeyChange:N,frozenColumnCount:ee,onFrozenColumnCountChange:P,toolbarPanel:F,onToolbarPanelChange:te,newFieldTitle:ne,newFieldType:re,onNewFieldTitleChange:ie,onNewFieldTypeChange:ae,onAddField:oe,selectedRecordCount:se,onRemoveSelectedRecords:L,onDuplicateSelectedRecords:ce,agentOpen:le,onToggleAgent:ue,agentDisabled:de,query:R,onQueryChange:z,onAddRecord:fe}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Vk,{tableViews:e,activeViewId:t,onSelectView:n,viewCreateOpen:r,onToggleViewCreate:i,onCloseViewCreate:a,onCreateView:o,onRenameView:s,onDuplicateView:c,onDeleteView:l,busy:u}),(0,I.jsx)(RA,{busy:u,fields:d,hiddenFieldNames:f,onResetHiddenFields:p,onToggleFieldVisibility:m,onEditField:h,onDuplicateField:g,onDeleteField:_,onAddDefaultField:v,filterTree:y,onFilterTreeChange:b,sortItems:x,onSortItemsChange:S,groupableFields:C,groupItems:w,onGroupItemsChange:T,viewMode:E,coverFieldName:D,coverField:O,coverFields:k,onCoverFieldNameChange:A,onResetCoverField:j,rowHeightKey:M,onRowHeightKeyChange:N,frozenColumnCount:ee,onFrozenColumnCountChange:P,toolbarPanel:F,onToolbarPanelChange:te,newFieldTitle:ne,newFieldType:re,onNewFieldTitleChange:ie,onNewFieldTypeChange:ae,onAddField:oe,selectedRecordCount:se,onRemoveSelectedRecords:L,onDuplicateSelectedRecords:ce,agentOpen:le,onToggleAgent:ue,agentDisabled:de,query:R,onQueryChange:z,onAddRecord:fe})]})}var BA=[`text`,`long_text`,`number`,`date`,`datetime`,`single_select`,`multi_select`,`checkbox`,`url`];function VA(e){return e===null?``:String(e)}function HA(e){return e?.name.replace(/\.(?:csv|tsv|xlsx)$/i,``).trim()||`Imported table`}function UA({file:e,onCompleted:t,onOpenChange:n,open:r,target:i}){let{t:a}=U(`table`),{fileImport:o}=cC(),[s,c]=(0,j.useState)(null),[l,u]=(0,j.useState)([]),[d,f]=(0,j.useState)(`append`),[p,m]=(0,j.useState)(``),[h,g]=(0,j.useState)(``),[_,v]=(0,j.useState)(!1),[y,b]=(0,j.useState)(!1),[x,S]=(0,j.useState)(``);(0,j.useEffect)(()=>{if(!r||!e||!o)return;let t=!0;return v(!0),c(null),S(``),o.prepare(e,{sheet:p||void 0}).then(e=>{t&&(c(e),u(e.preview.fields.map(e=>e.type)),!p&&e.preview.selected_sheet&&m(e.preview.selected_sheet))}).catch(e=>{t&&S(e instanceof Error?e.message:a(`fileImport.previewFailed`))}).finally(()=>{t&&v(!1)}),()=>{t=!1}},[e,o,r,p,a]),(0,j.useEffect)(()=>{r&&i.kind===`new_table`&&g(HA(e))},[e,r,i.kind]),(0,j.useEffect)(()=>{r||(c(null),u([]),m(``),S(``))},[r]);async function C(){if(s&&o){b(!0),S(``);try{await t((await o.execute({fieldTypes:l,prepared:s,target:i.kind===`existing_table`?i:{kind:`new_table`,documentId:i.documentId,tableTitle:h.trim()||HA(e)},writeMode:d})).result),n(!1)}catch(e){S(e instanceof Error?e.message:a(`fileImport.importFailed`))}finally{b(!1)}}}let w=s?.preview;return(0,I.jsx)(e_,{open:r,onOpenChange:e=>{(e||!y)&&n(e)},children:(0,I.jsxs)(t_,{size:`3xl`,fixed:!0,hideClose:!0,children:[(0,I.jsx)(i_,{children:(0,I.jsx)(o_,{children:a(`fileImport.title`)})}),(0,I.jsxs)(r_,{className:`gap-5`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border bg-card p-4 shadow-soft`,children:[(0,I.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,I.jsx)(Ua,{className:`size-5`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`p`,{className:`truncate text-sm font-medium`,children:e?.name}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e?a(`fileImport.fileSize`,{size:(e.size/1024).toFixed(1)}):``})]})]}),_?(0,I.jsxs)(`div`,{className:`flex min-h-56 items-center justify-center gap-2 text-sm text-muted-foreground`,children:[(0,I.jsx)(Ao,{className:`size-4 animate-spin`}),a(`fileImport.preparingPreview`)]}):null,x?(0,I.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive`,children:[(0,I.jsx)(gc,{className:`mt-0.5 size-4 shrink-0`}),(0,I.jsx)(`span`,{children:x})]}):null,w&&!_?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[a(`fileImport.format`),w.format.toUpperCase()],[a(`fileImport.rows`),w.row_count.toLocaleString()],[a(`fileImport.fields`),w.field_count.toLocaleString()],[a(`fileImport.sheet`),w.selected_sheet||a(`fileImport.notApplicable`)]].map(([e,t])=>(0,I.jsxs)(`div`,{className:`rounded-xl border bg-card p-3`,children:[(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e}),(0,I.jsx)(`p`,{className:`mt-1 truncate text-sm font-medium`,children:t})]},e))}),w.sheets.length>1?(0,I.jsxs)(`label`,{className:`grid gap-1.5 text-sm sm:max-w-xs`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:a(`fileImport.selectSheet`)}),(0,I.jsx)(C_,{size:`lg`,value:p,onChange:e=>m(e.target.value),disabled:y,children:w.sheets.filter(e=>!e.hidden).map(e=>(0,I.jsxs)(`option`,{value:e.name,children:[e.name,` (`,e.row_count.toLocaleString(),` `,a(`fileImport.rows`).toLocaleLowerCase(),`)`]},e.name))})]}):null,i.kind===`new_table`?(0,I.jsxs)(`label`,{className:`grid gap-1.5 text-sm sm:max-w-md`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:a(`fileImport.newTableTitle`)}),(0,I.jsx)(b_,{size:`lg`,value:h,onChange:e=>g(e.target.value),disabled:y,placeholder:a(`fileImport.newTableTitlePlaceholder`),"data-testid":`table-import-new-title`})]}):null,i.kind===`existing_table`?(0,I.jsxs)(`label`,{className:`grid gap-1.5 text-sm sm:max-w-xs`,children:[(0,I.jsx)(`span`,{className:`font-medium`,children:a(`fileImport.writeMode`)}),(0,I.jsxs)(C_,{size:`lg`,value:d,onChange:e=>f(e.target.value),disabled:y,children:[(0,I.jsx)(`option`,{value:`append`,children:a(`fileImport.append`)}),(0,I.jsx)(`option`,{value:`replace`,children:a(`fileImport.replace`)})]})]}):null,(0,I.jsxs)(`section`,{className:`grid gap-2`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-medium`,children:a(`fileImport.fieldMapping`)}),(0,I.jsx)(`div`,{className:`max-h-64 overflow-auto rounded-xl border`,children:(0,I.jsxs)(`table`,{className:`w-full border-collapse text-sm`,children:[(0,I.jsx)(`thead`,{className:`sticky top-0 bg-muted/95 text-left text-xs text-muted-foreground backdrop-blur`,children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:`border-b px-3 py-2 font-medium`,children:a(`fileImport.fieldName`)}),(0,I.jsx)(`th`,{className:`w-48 border-b px-3 py-2 font-medium`,children:a(`fileImport.fieldType`)}),(0,I.jsx)(`th`,{className:`border-b px-3 py-2 font-medium`,children:a(`fileImport.sample`)})]})}),(0,I.jsx)(`tbody`,{children:w.fields.map((e,t)=>(0,I.jsxs)(`tr`,{className:`border-b last:border-b-0`,children:[(0,I.jsx)(`td`,{className:`px-3 py-2 font-medium`,children:e.title}),(0,I.jsx)(`td`,{className:`px-3 py-2`,children:(0,I.jsx)(C_,{value:l[t]||e.type,onChange:e=>u(n=>n.map((n,r)=>r===t?e.target.value:n)),disabled:y,"aria-label":a(`fileImport.fieldTypeFor`,{field:e.title}),children:BA.map(e=>(0,I.jsx)(`option`,{value:e,children:a(`fileImport.types.${e}`)},e))})}),(0,I.jsx)(`td`,{className:`max-w-80 truncate px-3 py-2 text-muted-foreground`,children:e.sample_values.slice(0,3).map(VA).filter(Boolean).join(`, `)||`—`})]},`${e.index}-${e.title}`))})]})})]}),w.warnings.length?(0,I.jsxs)(`section`,{className:`grid gap-2`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-medium`,children:a(`fileImport.warnings`)}),(0,I.jsx)(`div`,{className:`grid gap-2`,children:w.warnings.map((e,t)=>(0,I.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border bg-muted/30 p-3 text-xs text-muted-foreground`,children:[(0,I.jsx)(gc,{className:`mt-0.5 size-3.5 shrink-0 text-amber-600`}),(0,I.jsx)(`span`,{children:e.message})]},`${e.code}-${t}`))})]}):null]}):null]}),(0,I.jsxs)(a_,{children:[(0,I.jsx)(Rc,{size:`md`,variant:`ghost`,disabled:y,onClick:()=>n(!1),children:a(`fileImport.cancel`)}),(0,I.jsxs)(Rc,{variant:`primary`,size:`md`,onClick:()=>void C(),disabled:!s||_||y||!!x||i.kind===`new_table`&&!h.trim(),children:[y?(0,I.jsx)(Ao,{className:`size-4 animate-spin`}):null,a(y?`fileImport.importing`:`fileImport.import`)]})]}),(0,I.jsx)(n_,{disabled:y})]})})}function WA({name:e,description:t,onNameChange:n,onDescriptionChange:r,onToggleAdvanced:i}){let{t:a}=U(`table`),o=t.length>0;return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:a(`fieldConfig.name`)}),(0,I.jsx)(`button`,{type:`button`,"data-testid":`field-advanced-toggle`,onClick:i,className:`text-xs text-muted-foreground underline-offset-2 hover:underline`,children:a(`fieldConfig.advancedProperties`)})]}),(0,I.jsx)(b_,{size:`lg`,value:e,onChange:e=>n(e.target.value),placeholder:a(`fieldConfig.fieldNamePlaceholder`)}),o?(0,I.jsx)(S_,{"data-testid":`field-description`,value:t,onChange:e=>r(e.target.value),placeholder:a(`fieldConfig.descriptionPlaceholder`),className:`min-h-12 resize-y`}):(0,I.jsx)(`div`,{children:(0,I.jsxs)(Rc,{type:`button`,variant:`secondary`,size:`sm`,"data-testid":`field-description-add`,onClick:()=>r(` `),className:`gap-1`,children:[(0,I.jsx)(ps,{className:`size-4`}),a(`fieldConfig.addDescription`)]})})]})}var GA={attachment:`fieldTypeSubtitles.attachment`,text:`fieldTypeSubtitles.text`,long_text:`fieldTypeSubtitles.longText`,number:`fieldTypeSubtitles.number`,single_select:`fieldTypeSubtitles.singleSelect`,multi_select:`fieldTypeSubtitles.multiSelect`,date:`fieldTypeSubtitles.date`,formula:`fieldTypeSubtitles.formula`};function KA({type:e,onChange:t}){let{t:n}=U(`table`),r=GA[e];return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:n(`fieldConfig.type`)}),(0,I.jsx)(C_,{size:`lg`,value:e,onChange:e=>t(e.target.value),children:uT.map(e=>(0,I.jsx)(`option`,{value:e.value,children:n(e.labelKey)},e.value))}),r?(0,I.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:n(r)}):null]})}function qA({readonly:e,readonlyLocked:t,onReadonlyChange:n}){let{t:r}=U(`table`);return(0,I.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:r(`fieldConfig.validationRules`)}),(0,I.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,I.jsx)(f_,{"data-testid":`field-readonly-switch`,checked:e||t,disabled:t,onCheckedChange:n}),r(`fieldConfig.readonly`)]})]})}function JA({choices:e,choiceTones:t,onChoicesChange:n,onChoiceTonesChange:r}){let{t:i}=U(`table`);function a(i,a){let o=e[i];if(n(e.map((e,t)=>t===i?a:e)),o&&o!==a){let e={...t};e[o]&&!e[a]&&(e[a]=e[o]),delete e[o],r(e)}}function o(e,n){r({...t,[e]:n})}return(0,I.jsxs)(`div`,{className:`data-inline-choice-editor`,children:[(0,I.jsxs)(`div`,{className:`data-inline-choice-editor-head`,children:[(0,I.jsx)(`span`,{children:i(`fieldChoices.options`)}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>n([...e,i(`fieldChoices.optionDefault`,{index:e.length+1})]),children:i(`fieldChoices.addOption`)})]}),(0,I.jsx)(`div`,{className:`data-inline-choice-list`,children:e.map((r,s)=>{let c=`${r}-${s}`,l=PT(t[r]||``)||jT(r||c);return(0,I.jsxs)(`div`,{className:`data-inline-choice-row`,children:[(0,I.jsx)(ao,{className:`size-4 text-muted-foreground`}),(0,I.jsxs)(`div`,{className:`data-inline-choice-tone-menu`,children:[(0,I.jsx)(`button`,{type:`button`,className:K(`data-inline-choice-tone`,`tone-${l}`),title:i(`fieldChoices.optionColor`)}),(0,I.jsx)(`div`,{className:`data-inline-choice-tone-popover`,children:dT.map(e=>(0,I.jsx)(`button`,{type:`button`,className:K(`data-inline-choice-tone`,`tone-${e}`,l===e&&`is-active`),title:i(`fieldChoices.colors.${e}`),onClick:()=>o(r,e)},e))})]}),(0,I.jsx)(b_,{size:`lg`,value:r,onChange:e=>a(s,e.target.value),placeholder:i(`fieldChoices.optionName`)}),(0,I.jsx)(`button`,{type:`button`,className:`data-inline-choice-remove`,onClick:()=>n(e.filter((e,t)=>t!==s)),children:`×`})]},c)})})]})}var YA=[],XA=[];(()=>{let e=`lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5`.split(`,`).map(e=>e?parseInt(e,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?XA:YA).push(n+=e[t])})();function ZA(e){if(e<768)return!1;for(let t=0,n=YA.length;;){let r=t+n>>1;if(e<YA[r])n=r;else if(e>=XA[r])t=r+1;else return!0;if(t==n)return!1}}function QA(e){return e>=127462&&e<=127487}var $A=8205;function ej(e,t,n=!0,r=!0){return(n?tj:nj)(e,t,r)}function tj(e,t,n){if(t==e.length)return t;t&&ij(e.charCodeAt(t))&&aj(e.charCodeAt(t-1))&&t--;let r=rj(e,t);for(t+=oj(r);t<e.length;){let i=rj(e,t);if(r==$A||i==$A||n&&ZA(i))t+=oj(i),r=i;else if(QA(i)){let n=0,r=t-2;for(;r>=0&&QA(rj(e,r));)n++,r-=2;if(n%2==0)break;t+=2}else break}return t}function nj(e,t,n){for(;t>1;){let r=tj(e,t-2,n);if(r<t)return r;t--}return 0}function rj(e,t){let n=e.charCodeAt(t);if(!aj(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return ij(r)?(n-55296<<10)+(r-56320)+65536:n}function ij(e){return e>=56320&&e<57344}function aj(e){return e>=55296&&e<56320}function oj(e){return e<65536?1:2}var sj=class e{lineAt(e){if(e<0||e>this.length)throw RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,n){[e,t]=_j(this,e,t);let r=[];return this.decompose(0,e,r,2),n.length&&n.decompose(0,n.length,r,3),this.decompose(t,this.length,r,1),lj.from(r,this.length-(t-e)+n.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=_j(this,e,t);let n=[];return this.decompose(e,t,n,0),lj.from(n,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),n=this.length-this.scanIdentical(e,-1),r=new pj(this),i=new pj(e);for(let e=t,a=t;;){if(r.next(e),i.next(e),e=0,r.lineBreak!=i.lineBreak||r.done!=i.done||r.value!=i.value)return!1;if(a+=r.value.length,r.done||a>=n)return!0}}iter(e=1){return new pj(this,e)}iterRange(e,t=this.length){return new mj(this,e,t)}iterLines(e,t){let n;if(e==null)n=this.iter();else{t??=this.lines+1;let r=this.line(e).from;n=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new hj(n)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(t){if(t.length==0)throw RangeError(`A document must have at least one line`);return t.length==1&&!t[0]?e.empty:t.length<=32?new cj(t):lj.from(cj.split(t,[]))}},cj=class e extends sj{constructor(e,t=uj(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.text[i],o=r+a.length;if((t?n:o)>=e)return new gj(r,o,n,a);r=o+1,n++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new e(fj(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let t=r.pop(),n=dj(a.text,t.text.slice(),0,a.length);if(n.length<=32)r.push(new e(n,t.length+a.length));else{let t=n.length>>1;r.push(new e(n.slice(0,t)),new e(n.slice(t)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof e))return super.replace(t,n,r);[t,n]=_j(this,t,n);let i=dj(this.text,dj(r.text,fj(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new e(i,a):lj.from(e.split(i,[]),a)}sliceString(e,t=this.length,n=`
59
- `){[e,t]=_j(this,e,t);let r=``;for(let i=0,a=0;i<=t&&a<this.text.length;a++){let o=this.text[a],s=i+o.length;i>e&&a&&(r+=n),e<s&&t>i&&(r+=o.slice(Math.max(0,e-i),t-i)),i=s+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new e(r,i)),r=[],i=-1);return i>-1&&n.push(new e(r,i)),n}},lj=class e extends sj{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let t of e)this.lines+=t.lines}lineInner(e,t,n,r){for(let i=0;;i++){let a=this.children[i],o=r+a.length,s=n+a.lines-1;if((t?s:o)>=e)return a.lineInner(e,t,n,r);r=o+1,n=s+1}}decompose(e,t,n,r){for(let i=0,a=0;a<=t&&i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(e<=s&&t>=a){let i=r&(a<=e|(s>=t?2:0));a>=e&&s<=t&&!i?n.push(o):o.decompose(e-a,t-a,n,i)}a=s+1}}replace(t,n,r){if([t,n]=_j(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let o=this.children[i],s=a+o.length;if(t>=a&&n<=s){let c=o.replace(t-a,n-a,r),l=this.lines-o.lines+c.lines;if(c.lines<l>>4&&c.lines>l>>6){let a=this.children.slice();return a[i]=c,new e(a,this.length-(n-t)+r.length)}return super.replace(a,s,c)}a=s+1}return super.replace(t,n,r)}sliceString(e,t=this.length,n=`
60
- `){[e,t]=_j(this,e,t);let r=``;for(let i=0,a=0;i<this.children.length&&a<=t;i++){let o=this.children[i],s=a+o.length;a>e&&i&&(r+=n),e<s&&t>a&&(r+=o.sliceString(e-a,t-a,n)),a=s+1}return r}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(t,n){if(!(t instanceof e))return 0;let r=0,[i,a,o,s]=n>0?[0,0,this.children.length,t.children.length]:[this.children.length-1,t.children.length-1,-1,-1];for(;;i+=n,a+=n){if(i==o||a==s)return r;let e=this.children[i],c=t.children[a];if(e!=c)return r+e.scanIdentical(c,n);r+=e.length+1}}static from(t,n=t.reduce((e,t)=>e+t.length+1,-1)){let r=0;for(let e of t)r+=e.lines;if(r<32){let e=[];for(let n of t)n.flatten(e);return new cj(e,n)}let i=Math.max(32,r>>5),a=i<<1,o=i>>1,s=[],c=0,l=-1,u=[];function d(t){let n;if(t.lines>a&&t instanceof e)for(let e of t.children)d(e);else t.lines>o&&(c>o||!c)?(f(),s.push(t)):t instanceof cj&&c&&(n=u[u.length-1])instanceof cj&&t.lines+n.lines<=32?(c+=t.lines,l+=t.length+1,u[u.length-1]=new cj(n.text.concat(t.text),n.length+1+t.length)):(c+t.lines>i&&f(),c+=t.lines,l+=t.length+1,u.push(t))}function f(){c!=0&&(s.push(u.length==1?u[0]:e.from(u,l)),l=-1,c=u.length=0)}for(let e of t)d(e);return f(),s.length==1?s[0]:new e(s,n)}};sj.empty=new cj([``],0);function uj(e){let t=-1;for(let n of e)t+=n.length+1;return t}function dj(e,t,n=0,r=1e9){for(let i=0,a=0,o=!0;a<e.length&&i<=r;a++){let s=e[a],c=i+s.length;c>=n&&(c>r&&(s=s.slice(0,r-i)),i<n&&(s=s.slice(n-i)),o?(t[t.length-1]+=s,o=!1):t.push(s)),i=c+1}return t}function fj(e,t,n){return dj(e,[``],t,n)}var pj=class{constructor(e,t=1){this.dir=t,this.done=!1,this.lineBreak=!1,this.value=``,this.nodes=[e],this.offsets=[t>0?1:(e instanceof cj?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let n=this.nodes.length-1,r=this.nodes[n],i=this.offsets[n],a=i>>1,o=r instanceof cj?r.text.length:r.children.length;if(a==(t>0?o:0)){if(n==0)return this.done=!0,this.value=``,this;t>0&&this.offsets[n-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(t>0?0:1)){if(this.offsets[n]+=t,e==0)return this.lineBreak=!0,this.value=`
61
- `,this;e--}else if(r instanceof cj){let i=r.text[a+(t<0?-1:0)];if(this.offsets[n]+=t,i.length>Math.max(0,e))return this.value=e==0?i:t>0?i.slice(e):i.slice(0,i.length-e),this;e-=i.length}else{let i=r.children[a+(t<0?-1:0)];e>i.length?(e-=i.length,this.offsets[n]+=t):(t<0&&this.offsets[n]--,this.nodes.push(i),this.offsets.push(t>0?1:(i instanceof cj?i.text.length:i.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}},mj=class{constructor(e,t,n){this.value=``,this.done=!1,this.cursor=new pj(e,t>n?-1:1),this.pos=t>n?e.length:0,this.from=Math.min(t,n),this.to=Math.max(t,n)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value=``,this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let n=t<0?this.pos-this.from:this.to-this.pos;e>n&&(e=n),n-=e;let{value:r}=this.cursor.next(e);return this.pos+=(r.length+e)*t,this.value=r.length<=n?r:t<0?r.slice(r.length-n):r.slice(0,n),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=``}},hj=class{constructor(e){this.inner=e,this.afterBreak=!0,this.value=``,this.done=!1}next(e=0){let{done:t,lineBreak:n,value:r}=this.inner.next(e);return t&&this.afterBreak?(this.value=``,this.afterBreak=!1):t?(this.done=!0,this.value=``):n?this.afterBreak?this.value=``:(this.afterBreak=!0,this.next()):(this.value=r,this.afterBreak=!1),this}get lineBreak(){return!1}};typeof Symbol<`u`&&(sj.prototype[Symbol.iterator]=function(){return this.iter()},pj.prototype[Symbol.iterator]=mj.prototype[Symbol.iterator]=hj.prototype[Symbol.iterator]=function(){return this});var gj=class{constructor(e,t,n,r){this.from=e,this.to=t,this.number=n,this.text=r}get length(){return this.to-this.from}};function _j(e,t,n){return t=Math.max(0,Math.min(e.length,t)),[t,Math.max(t,Math.min(e.length,n))]}function vj(e,t,n=!0,r=!0){return ej(e,t,n,r)}function yj(e){return e>=56320&&e<57344}function bj(e){return e>=55296&&e<56320}function xj(e,t){let n=e.charCodeAt(t);if(!bj(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return yj(r)?(n-55296<<10)+(r-56320)+65536:n}function Sj(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10)+55296,(e&1023)+56320))}function Cj(e){return e<65536?1:2}var wj=/\r\n?|\n/,Tj=(function(e){return e[e.Simple=0]=`Simple`,e[e.TrackDel=1]=`TrackDel`,e[e.TrackBefore=2]=`TrackBefore`,e[e.TrackAfter=3]=`TrackAfter`,e})(Tj||={}),Ej=class e{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;t<this.sections.length;t+=2)e+=this.sections[t];return e}get newLength(){let e=0;for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t+1];e+=n<0?this.sections[t]:n}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let t=0,n=0,r=0;t<this.sections.length;){let i=this.sections[t++],a=this.sections[t++];a<0?(e(n,r,i),r+=i):r+=a,n+=i}}iterChangedRanges(e,t=!1){Aj(this,e,t)}get invertedDesc(){let t=[];for(let e=0;e<this.sections.length;){let n=this.sections[e++],r=this.sections[e++];r<0?t.push(n,r):t.push(r,n)}return new e(t)}composeDesc(e){return this.empty?e:e.empty?this:Mj(this,e)}mapDesc(e,t=!1){return e.empty?this:jj(this,e,t)}mapPos(e,t=-1,n=Tj.Simple){let r=0,i=0;for(let a=0;a<this.sections.length;){let o=this.sections[a++],s=this.sections[a++],c=r+o;if(s<0){if(c>e)return i+(e-r);i+=o}else{if(n!=Tj.Simple&&c>=e&&(n==Tj.TrackDel&&r<e&&c>e||n==Tj.TrackBefore&&r<e||n==Tj.TrackAfter&&c>e))return null;if(c>e||c==e&&t<0&&!o)return e==r||t<0?i:i+s;i+=s}r=c}if(e>r)throw RangeError(`Position ${e} is out of range for changeset of length ${r}`);return i}touchesRange(e,t=e){for(let n=0,r=0;n<this.sections.length&&r<=t;){let i=this.sections[n++],a=this.sections[n++],o=r+i;if(a>=0&&r<=t&&o>=e)return r<e&&o>t?`cover`:!0;r=o}return!1}toString(){let e=``;for(let t=0;t<this.sections.length;){let n=this.sections[t++],r=this.sections[t++];e+=(e?` `:``)+n+(r>=0?`:`+r:``)}return e}toJSON(){return this.sections}static fromJSON(t){if(!Array.isArray(t)||t.length%2||t.some(e=>typeof e!=`number`))throw RangeError(`Invalid JSON representation of ChangeDesc`);return new e(t)}static create(t){return new e(t)}},Dj=class e extends Ej{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw RangeError(`Applying change set to a document with the wrong length`);return Aj(this,(t,n,r,i,a)=>e=e.replace(r,r+(n-t),a),!1),e}mapDesc(e,t=!1){return jj(this,e,t,!0)}invert(t){let n=this.sections.slice(),r=[];for(let e=0,i=0;e<n.length;e+=2){let a=n[e],o=n[e+1];if(o>=0){n[e]=o,n[e+1]=a;let s=e>>1;for(;r.length<s;)r.push(sj.empty);r.push(a?t.slice(i,i+a):sj.empty)}i+=a}return new e(n,r)}compose(e){return this.empty?e:e.empty?this:Mj(this,e,!0)}map(e,t=!1){return e.empty?this:jj(this,e,t,!0)}iterChanges(e,t=!1){Aj(this,e,t)}get desc(){return Ej.create(this.sections)}filter(t){let n=[],r=[],i=[],a=new Nj(this);done:for(let e=0,o=0;;){let s=e==t.length?1e9:t[e++];for(;o<s||o==s&&a.len==0;){if(a.done)break done;let e=Math.min(a.len,s-o);Oj(i,e,-1);let t=a.ins==-1?-1:a.off==0?a.ins:0;Oj(n,e,t),t>0&&kj(r,n,a.text),a.forward(e),o+=e}let c=t[e++];for(;o<c;){if(a.done)break done;let e=Math.min(a.len,c-o);Oj(n,e,-1),Oj(i,e,a.ins==-1?-1:a.off==0?a.ins:0),a.forward(e),o+=e}}return{changes:new e(n,r),filtered:Ej.create(i)}}toJSON(){let e=[];for(let t=0;t<this.sections.length;t+=2){let n=this.sections[t],r=this.sections[t+1];r<0?e.push(n):r==0?e.push([n]):e.push([n].concat(this.inserted[t>>1].toJSON()))}return e}static of(t,n,r){let i=[],a=[],o=0,s=null;function c(t=!1){if(!t&&!i.length)return;o<n&&Oj(i,n-o,-1);let r=new e(i,a);s=s?s.compose(r.map(s)):r,i=[],a=[],o=0}function l(t){if(Array.isArray(t))for(let e of t)l(e);else if(t instanceof e){if(t.length!=n)throw RangeError(`Mismatched change set length (got ${t.length}, expected ${n})`);c(),s=s?s.compose(t.map(s)):t}else{let{from:e,to:s=e,insert:l}=t;if(e>s||e<0||s>n)throw RangeError(`Invalid change range ${e} to ${s} (in doc of length ${n})`);let u=l?typeof l==`string`?sj.of(l.split(r||wj)):l:sj.empty,d=u.length;if(e==s&&d==0)return;e<o&&c(),e>o&&Oj(i,e-o,-1),Oj(i,s-e,d),kj(a,i,u),o=s}}return l(t),c(!s),s}static empty(t){return new e(t?[t,-1]:[],[])}static fromJSON(t){if(!Array.isArray(t))throw RangeError(`Invalid JSON representation of ChangeSet`);let n=[],r=[];for(let e=0;e<t.length;e++){let i=t[e];if(typeof i==`number`)n.push(i,-1);else if(!Array.isArray(i)||typeof i[0]!=`number`||i.some((e,t)=>t&&typeof e!=`string`))throw RangeError(`Invalid JSON representation of ChangeSet`);else if(i.length==1)n.push(i[0],0);else{for(;r.length<e;)r.push(sj.empty);r[e]=sj.of(i.slice(1)),n.push(i[0],r[e].length)}}return new e(n,r)}static createSet(t,n){return new e(t,n)}};function Oj(e,t,n,r=!1){if(t==0&&n<=0)return;let i=e.length-2;i>=0&&n<=0&&n==e[i+1]?e[i]+=t:i>=0&&t==0&&e[i]==0?e[i+1]+=n:r?(e[i]+=t,e[i+1]+=n):e.push(t,n)}function kj(e,t,n){if(n.length==0)return;let r=t.length-2>>1;if(r<e.length)e[e.length-1]=e[e.length-1].append(n);else{for(;e.length<r;)e.push(sj.empty);e.push(n)}}function Aj(e,t,n){let r=e.inserted;for(let i=0,a=0,o=0;o<e.sections.length;){let s=e.sections[o++],c=e.sections[o++];if(c<0)i+=s,a+=s;else{let l=i,u=a,d=sj.empty;for(;l+=s,u+=c,c&&r&&(d=d.append(r[o-2>>1])),!(n||o==e.sections.length||e.sections[o+1]<0);)s=e.sections[o++],c=e.sections[o++];t(i,l,a,u,d),i=l,a=u}}}function jj(e,t,n,r=!1){let i=[],a=r?[]:null,o=new Nj(e),s=new Nj(t);for(let e=-1;;)if(o.done&&s.len||s.done&&o.len)throw Error(`Mismatched change set lengths`);else if(o.ins==-1&&s.ins==-1){let e=Math.min(o.len,s.len);Oj(i,e,-1),o.forward(e),s.forward(e)}else if(s.ins>=0&&(o.ins<0||e==o.i||o.off==0&&(s.len<o.len||s.len==o.len&&!n))){let t=s.len;for(Oj(i,s.ins,-1);t;){let n=Math.min(o.len,t);o.ins>=0&&e<o.i&&o.len<=n&&(Oj(i,0,o.ins),a&&kj(a,i,o.text),e=o.i),o.forward(n),t-=n}s.next()}else if(o.ins>=0){let t=0,n=o.len;for(;n;)if(s.ins==-1){let e=Math.min(n,s.len);t+=e,n-=e,s.forward(e)}else if(s.ins==0&&s.len<n)n-=s.len,s.next();else break;Oj(i,t,e<o.i?o.ins:0),a&&e<o.i&&kj(a,i,o.text),e=o.i,o.forward(o.len-n)}else if(o.done&&s.done)return a?Dj.createSet(i,a):Ej.create(i);else throw Error(`Mismatched change set lengths`)}function Mj(e,t,n=!1){let r=[],i=n?[]:null,a=new Nj(e),o=new Nj(t);for(let e=!1;;)if(a.done&&o.done)return i?Dj.createSet(r,i):Ej.create(r);else if(a.ins==0)Oj(r,a.len,0,e),a.next();else if(o.len==0&&!o.done)Oj(r,0,o.ins,e),i&&kj(i,r,o.text),o.next();else if(a.done||o.done)throw Error(`Mismatched change set lengths`);else{let t=Math.min(a.len2,o.len),n=r.length;if(a.ins==-1){let n=o.ins==-1?-1:o.off?0:o.ins;Oj(r,t,n,e),i&&n&&kj(i,r,o.text)}else o.ins==-1?(Oj(r,a.off?0:a.len,t,e),i&&kj(i,r,a.textBit(t))):(Oj(r,a.off?0:a.len,o.off?0:o.ins,e),i&&!o.off&&kj(i,r,o.text));e=(a.ins>t||o.ins>=0&&o.len>t)&&(e||r.length>n),a.forward2(t),o.forward(t)}}var Nj=class{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,t=this.i-2>>1;return t>=e.length?sj.empty:e[t]}textBit(e){let{inserted:t}=this.set,n=this.i-2>>1;return n>=t.length&&!e?sj.empty:t[n].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}},Pj=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.flags=n,this.goalColumn=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(t,n=-1){let r,i;return this.empty?r=i=t.mapPos(this.from,n):(r=t.mapPos(this.from,1),i=t.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new e(r,i,this.flags,this.goalColumn)}extend(e,t=e,n=0){if(e<=this.anchor&&t>=this.anchor)return q.range(e,t,void 0,void 0,n);let r=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return q.range(this.anchor,r,void 0,void 0,n)}eq(e,t=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!t||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!=`number`||typeof e.head!=`number`)throw RangeError(`Invalid JSON representation for SelectionRange`);return q.range(e.anchor,e.head)}static create(t,n,r,i){return new e(t,n,r,i)}},q=class e{constructor(e,t){this.ranges=e,this.mainIndex=t}map(t,n=-1){return t.empty?this:e.create(this.ranges.map(e=>e.map(t,n)),this.mainIndex)}eq(e,t=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let n=0;n<this.ranges.length;n++)if(!this.ranges[n].eq(e.ranges[n],t))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new e([this.main],0)}addRange(t,n=!0){return e.create([t].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(t,n=this.mainIndex){let r=this.ranges.slice();return r[n]=t,e.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(t){if(!t||!Array.isArray(t.ranges)||typeof t.main!=`number`||t.main>=t.ranges.length)throw RangeError(`Invalid JSON representation for EditorSelection`);return new e(t.ranges.map(e=>Pj.fromJSON(e)),t.main)}static single(t,n=t){return new e([e.range(t,n)],0)}static create(t,n=0){if(t.length==0)throw RangeError(`A selection needs at least one range`);for(let r=0,i=0;i<t.length;i++){let a=t[i];if(a.empty?a.from<=r:a.from<r)return e.normalized(t.slice(),n);r=a.to}return new e(t,n)}static cursor(e,t=0,n,r){return Pj.create(e,e,(t==0?0:t<0?8:16)|(n==null?7:Math.min(6,n)),r)}static range(e,t,n,r,i){let a=r==null?7:Math.min(6,r);return!i&&e!=t&&(i=t<e?1:-1),i&&(a|=i<0?8:16),t<e?Pj.create(t,e,a|32,n):Pj.create(e,t,a,n)}static undirectionalRange(e,t){return Pj.create(e,t,64,void 0)}static normalized(t,n=0){let r=t[n];t.sort((e,t)=>e.from-t.from),n=t.indexOf(r);for(let r=1;r<t.length;r++){let i=t[r],a=t[r-1];if(i.empty?i.from<=a.to:i.from<a.to){let o=a.from,s=Math.max(i.to,a.to);r<=n&&n--,t.splice(--r,2,i.anchor>i.head?e.range(s,o):e.range(o,s))}}return new e(t,n)}};function Fj(e,t){for(let n of e.ranges)if(n.to>t)throw RangeError(`Selection points outside of document`)}var Ij=0,Lj=class e{constructor(e,t,n,r,i){this.combine=e,this.compareInput=t,this.compare=n,this.isStatic=r,this.id=Ij++,this.default=e([]),this.extensions=typeof i==`function`?i(this):i}get reader(){return this}static define(t={}){return new e(t.combine||(e=>e),t.compareInput||((e,t)=>e===t),t.compare||(t.combine?(e,t)=>e===t:Rj),!!t.static,t.enables)}of(e){return new zj([],this,0,e)}compute(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new zj(e,this,1,t)}computeN(e,t){if(this.isStatic)throw Error(`Can't compute a static facet`);return new zj(e,this,2,t)}from(e,t){return t||=e=>e,this.compute([e],n=>t(n.field(e)))}};function Rj(e,t){return e==t||e.length==t.length&&e.every((e,n)=>e===t[n])}var zj=class{constructor(e,t,n,r){this.dependencies=e,this.facet=t,this.type=n,this.value=r,this.id=Ij++}dynamicSlot(e){let t=this.value,n=this.facet.compareInput,r=this.id,i=e[r]>>1,a=this.type==2,o=!1,s=!1,c=[];for(let t of this.dependencies)t==`doc`?o=!0:t==`selection`?s=!0:(e[t.id]??1)&1||c.push(e[t.id]);return{create(e){return e.values[i]=t(e),1},update(e,r){if(o&&r.docChanged||s&&(r.docChanged||r.selection)||Vj(e,c)){let r=t(e);if(a?!Bj(r,e.values[i],n):!n(r,e.values[i]))return e.values[i]=r,1}return 0},reconfigure:(e,o)=>{let s,c=o.config.address[r];if(c!=null){let r=eM(o,c);if(this.dependencies.every(t=>t instanceof Lj?o.facet(t)===e.facet(t):t instanceof Wj?o.field(t,!1)==e.field(t,!1):!0)||(a?Bj(s=t(e),r,n):n(s=t(e),r)))return e.values[i]=r,0}else s=t(e);return e.values[i]=s,1}}}get extension(){return this}};function Bj(e,t,n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}function Vj(e,t){let n=!1;for(let r of t)$j(e,r)&1&&(n=!0);return n}function Hj(e,t,n){let r=n.map(t=>e[t.id]),i=n.map(e=>e.type),a=r.filter(e=>!(e&1)),o=e[t.id]>>1;function s(e){let n=[];for(let t=0;t<r.length;t++){let a=eM(e,r[t]);if(i[t]==2)for(let e of a)n.push(e);else n.push(a)}return t.combine(n)}return{create(e){for(let t of r)$j(e,t);return e.values[o]=s(e),1},update(e,n){if(!Vj(e,a))return 0;let r=s(e);return t.compare(r,e.values[o])?0:(e.values[o]=r,1)},reconfigure(e,i){let a=Vj(e,r),c=i.config.facets[t.id],l=i.facet(t);if(c&&!a&&Rj(n,c))return e.values[o]=l,0;let u=s(e);return t.compare(u,l)?(e.values[o]=l,0):(e.values[o]=u,1)}}}var Uj=Lj.define({static:!0}),Wj=class e{constructor(e,t,n,r,i){this.id=e,this.createF=t,this.updateF=n,this.compareF=r,this.spec=i,this.provides=void 0}static define(t){let n=new e(Ij++,t.create,t.update,t.compare||((e,t)=>e===t),t);return t.provide&&(n.provides=t.provide(n)),n}create(e){return(e.facet(Uj).find(e=>e.field==this)?.create||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:e=>(e.values[t]=this.create(e),1),update:(e,n)=>{let r=e.values[t],i=this.updateF(r,n);return this.compareF(r,i)?0:(e.values[t]=i,1)},reconfigure:(e,n)=>{let r=e.facet(Uj),i=n.facet(Uj),a;return(a=r.find(e=>e.field==this))&&a!=i.find(e=>e.field==this)?(e.values[t]=a.create(e),1):n.config.address[this.id]==null?(e.values[t]=this.create(e),1):(e.values[t]=n.field(this),0)}}}init(e){return[this,Uj.of({field:this,create:e})]}get extension(){return this}},Gj={lowest:4,low:3,default:2,high:1,highest:0};function Kj(e){return t=>new Jj(t,e)}var qj={highest:Kj(Gj.highest),high:Kj(Gj.high),default:Kj(Gj.default),low:Kj(Gj.low),lowest:Kj(Gj.lowest)},Jj=class{constructor(e,t){this.inner=e,this.prec=t}get extension(){return this}},Yj=class e{of(e){return new Xj(this,e)}reconfigure(t){return e.reconfigure.of({compartment:this,extension:t})}get(e){return e.config.compartments.get(this)}},Xj=class{constructor(e,t){this.compartment=e,this.inner=t}get extension(){return this}},Zj=class e{constructor(e,t,n,r,i,a){for(this.base=e,this.compartments=t,this.dynamicSlots=n,this.address=r,this.staticValues=i,this.facets=a,this.statusTemplate=[];this.statusTemplate.length<n.length;)this.statusTemplate.push(0)}staticFacet(e){let t=this.address[e.id];return t==null?e.default:this.staticValues[t>>1]}static resolve(t,n,r){let i=[],a=Object.create(null),o=new Map;for(let e of Qj(t,n,o))e instanceof Wj?i.push(e):(a[e.facet.id]||(a[e.facet.id]=[])).push(e);let s=Object.create(null),c=[],l=[];for(let e of i)s[e.id]=l.length<<1,l.push(t=>e.slot(t));let u=r?.config.facets;for(let e in a){let t=a[e],n=t[0].facet,i=u&&u[e]||[];if(t.every(e=>e.type==0)){if(s[n.id]=c.length<<1|1,Rj(i,t))c.push(r.facet(n));else{let e=n.combine(t.map(e=>e.value));c.push(r&&n.compare(e,r.facet(n))?r.facet(n):e)}}else{for(let e of t)e.type==0?(s[e.id]=c.length<<1|1,c.push(e.value)):(s[e.id]=l.length<<1,l.push(t=>e.dynamicSlot(t)));s[n.id]=l.length<<1,l.push(e=>Hj(e,n,t))}}let d=l.map(e=>e(s));return new e(t,o,d,s,c,a)}};function Qj(e,t,n){let r=[[],[],[],[],[]],i=new Map;function a(e,o){let s=i.get(e);if(s!=null){if(s<=o)return;let t=r[s].indexOf(e);t>-1&&r[s].splice(t,1),e instanceof Xj&&n.delete(e.compartment)}if(i.set(e,o),Array.isArray(e))for(let t of e)a(t,o);else if(e instanceof Xj){if(n.has(e.compartment))throw RangeError(`Duplicate use of compartment in extensions`);let r=t.get(e.compartment)||e.inner;n.set(e.compartment,r),a(r,o)}else if(e instanceof Jj)a(e.inner,e.prec);else if(e instanceof Wj)r[o].push(e),e.provides&&a(e.provides,o);else if(e instanceof zj)r[o].push(e),e.facet.extensions&&a(e.facet.extensions,Gj.default);else{let t=e.extension;if(!t)throw Error(`Unrecognized extension value in extension set (${e}).`);if(t==e)throw Error(`Unrecognized extension value in extension set (${e}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(t,o)}}return a(e,Gj.default),r.reduce((e,t)=>e.concat(t))}function $j(e,t){if(t&1)return 2;let n=t>>1,r=e.status[n];if(r==4)throw Error(`Cyclic dependency between fields and/or facets`);if(r&2)return r;e.status[n]=4;let i=e.computeSlot(e,e.config.dynamicSlots[n]);return e.status[n]=2|i}function eM(e,t){return t&1?e.config.staticValues[t>>1]:e.values[t>>1]}var tM=Lj.define(),nM=Lj.define({combine:e=>e.some(e=>e),static:!0}),rM=Lj.define({combine:e=>e.length?e[0]:void 0,static:!0}),iM=Lj.define(),aM=Lj.define(),oM=Lj.define(),sM=Lj.define({combine:e=>e.length?e[0]:!1}),cM=class{constructor(e,t){this.type=e,this.value=t}static define(){return new lM}},lM=class{of(e){return new cM(this,e)}},uM=class{constructor(e){this.map=e}of(e){return new dM(this,e)}},dM=class e{constructor(e,t){this.type=e,this.value=t}map(t){let n=this.type.map(this.value,t);return n===void 0?void 0:n==this.value?this:new e(this.type,n)}is(e){return this.type==e}static define(e={}){return new uM(e.map||(e=>e))}static mapEffects(e,t){if(!e.length)return e;let n=[];for(let r of e){let e=r.map(t);e&&n.push(e)}return n}};dM.reconfigure=dM.define(),dM.appendConfig=dM.define();var fM=class e{constructor(t,n,r,i,a,o){this.startState=t,this.changes=n,this.selection=r,this.effects=i,this.annotations=a,this.scrollIntoView=o,this._doc=null,this._state=null,r&&Fj(r,n.newLength),a.some(t=>t.type==e.time)||(this.annotations=a.concat(e.time.of(Date.now())))}static create(t,n,r,i,a,o){return new e(t,n,r,i,a,o)}get newDoc(){return this._doc||=this.changes.apply(this.startState.doc)}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(t){let n=this.annotation(e.userEvent);return!!(n&&(n==t||n.length>t.length&&n.slice(0,t.length)==t&&n[t.length]==`.`))}};fM.time=cM.define(),fM.userEvent=cM.define(),fM.addToHistory=cM.define(),fM.remote=cM.define();function pM(e,t){let n=[];for(let r=0,i=0;;){let a,o;if(r<e.length&&(i==t.length||t[i]>=e[r]))a=e[r++],o=e[r++];else if(i<t.length)a=t[i++],o=t[i++];else return n;!n.length||n[n.length-1]<a?n.push(a,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function mM(e,t,n){let r,i,a;return n?(r=t.changes,i=Dj.empty(t.changes.length),a=e.changes.compose(t.changes)):(r=t.changes.map(e.changes),i=e.changes.mapDesc(t.changes,!0),a=e.changes.compose(r)),{changes:a,selection:t.selection?t.selection.map(i):e.selection?.map(r),effects:dM.mapEffects(e.effects,r).concat(dM.mapEffects(t.effects,i)),annotations:e.annotations.length?e.annotations.concat(t.annotations):t.annotations,scrollIntoView:e.scrollIntoView||t.scrollIntoView}}function hM(e,t,n){let r=t.selection,i=bM(t.annotations);return t.userEvent&&(i=i.concat(fM.userEvent.of(t.userEvent))),{changes:t.changes instanceof Dj?t.changes:Dj.of(t.changes||[],n,e.facet(rM)),selection:r&&(r instanceof q?r:q.single(r.anchor,r.head)),effects:bM(t.effects),annotations:i,scrollIntoView:!!t.scrollIntoView}}function gM(e,t,n){let r=hM(e,t.length?t[0]:{},e.doc.length);t.length&&t[0].filter===!1&&(n=!1);for(let i=1;i<t.length;i++){t[i].filter===!1&&(n=!1);let a=!!t[i].sequential;r=mM(r,hM(e,t[i],a?r.changes.newLength:e.doc.length),a)}let i=fM.create(e,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return vM(n?_M(i):i)}function _M(e){let t=e.startState,n=!0;for(let r of t.facet(iM)){let t=r(e);if(t===!1){n=!1;break}Array.isArray(t)&&(n=n===!0?t:pM(n,t))}if(n!==!0){let r,i;if(n===!1)i=e.changes.invertedDesc,r=Dj.empty(t.doc.length);else{let t=e.changes.filter(n);r=t.changes,i=t.filtered.mapDesc(t.changes).invertedDesc}e=fM.create(t,r,e.selection&&e.selection.map(i),dM.mapEffects(e.effects,i),e.annotations,e.scrollIntoView)}let r=t.facet(aM);for(let n=r.length-1;n>=0;n--){let i=r[n](e);e=i instanceof fM?i:Array.isArray(i)&&i.length==1&&i[0]instanceof fM?i[0]:gM(t,bM(i),!1)}return e}function vM(e){let t=e.startState,n=t.facet(oM),r=e;for(let i=n.length-1;i>=0;i--){let a=n[i](e);a&&Object.keys(a).length&&(r=mM(r,hM(t,a,e.changes.newLength),!0))}return r==e?e:fM.create(t,e.changes,e.selection,r.effects,r.annotations,r.scrollIntoView)}var yM=[];function bM(e){return e==null?yM:Array.isArray(e)?e:[e]}var xM=(function(e){return e[e.Word=0]=`Word`,e[e.Space=1]=`Space`,e[e.Other=2]=`Other`,e})(xM||={}),SM=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,CM;try{CM=RegExp(`[\\p{Alphabetic}\\p{Number}_]`,`u`)}catch{}function wM(e){if(CM)return CM.test(e);for(let t=0;t<e.length;t++){let n=e[t];if(/\w/.test(n)||n>`€`&&(n.toUpperCase()!=n.toLowerCase()||SM.test(n)))return!0}return!1}function TM(e){return t=>{if(!/\S/.test(t))return xM.Space;if(wM(t))return xM.Word;for(let n=0;n<e.length;n++)if(t.indexOf(e[n])>-1)return xM.Word;return xM.Other}}var EM=class e{constructor(e,t,n,r,i,a){this.config=e,this.doc=t,this.selection=n,this.values=r,this.status=e.statusTemplate.slice(),this.computeSlot=i,a&&(a._state=this);for(let e=0;e<this.config.dynamicSlots.length;e++)$j(this,e<<1);this.computeSlot=null}field(e,t=!0){let n=this.config.address[e.id];if(n==null){if(t)throw RangeError(`Field is not present in this state`)}else return $j(this,n),eM(this,n)}update(...e){return gM(this,e,!0)}applyTransaction(t){let n=this.config,{base:r,compartments:i}=n;for(let e of t.effects)e.is(Yj.reconfigure)?(n&&=(i=new Map,n.compartments.forEach((e,t)=>i.set(t,e)),null),i.set(e.value.compartment,e.value.extension)):e.is(dM.reconfigure)?(n=null,r=e.value):e.is(dM.appendConfig)&&(n=null,r=bM(r).concat(e.value));let a;n?a=t.startState.values.slice():(n=Zj.resolve(r,i,this),a=new e(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(e,t)=>t.reconfigure(e,this),null).values);let o=t.startState.facet(nM)?t.newSelection:t.newSelection.asSingle();new e(n,t.newDoc,o,a,(e,n)=>n.update(e,t),t)}replaceSelection(e){return typeof e==`string`&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:q.cursor(t.from+e.length,-1)}))}changeByRange(e){let t=this.selection,n=e(t.ranges[0]),r=this.changes(n.changes),i=[n.range],a=bM(n.effects);for(let n=1;n<t.ranges.length;n++){let o=e(t.ranges[n]),s=this.changes(o.changes),c=s.map(r);for(let e=0;e<n;e++)i[e]=i[e].map(c);let l=r.mapDesc(s,!0);i.push(o.range.map(l)),r=r.compose(c),a=dM.mapEffects(a,c).concat(dM.mapEffects(bM(o.effects),l))}return{changes:r,selection:q.create(i,t.mainIndex),effects:a}}changes(t=[]){return t instanceof Dj?t:Dj.of(t,this.doc.length,this.facet(e.lineSeparator))}toText(t){return sj.of(t.split(this.facet(e.lineSeparator)||wj))}sliceDoc(e=0,t=this.doc.length){return this.doc.sliceString(e,t,this.lineBreak)}facet(e){let t=this.config.address[e.id];return t==null?e.default:($j(this,t),eM(this,t))}toJSON(e){let t={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let n in e){let r=e[n];r instanceof Wj&&this.config.address[r.id]!=null&&(t[n]=r.spec.toJSON(this.field(e[n]),this))}return t}static fromJSON(t,n={},r){if(!t||typeof t.doc!=`string`)throw RangeError(`Invalid JSON representation for EditorState`);let i=[];if(r){for(let e in r)if(Object.prototype.hasOwnProperty.call(t,e)){let n=r[e],a=t[e];i.push(n.init(e=>n.spec.fromJSON(a,e)))}}return e.create({doc:t.doc,selection:q.fromJSON(t.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(t={}){let n=Zj.resolve(t.extensions||[],new Map),r=t.doc instanceof sj?t.doc:sj.of((t.doc||``).split(n.staticFacet(e.lineSeparator)||wj)),i=t.selection?t.selection instanceof q?t.selection:q.single(t.selection.anchor,t.selection.head):q.single(0);return Fj(i,r.length),n.staticFacet(nM)||(i=i.asSingle()),new e(n,r,i,n.dynamicSlots.map(()=>null),(e,t)=>t.create(e),null)}get tabSize(){return this.facet(e.tabSize)}get lineBreak(){return this.facet(e.lineSeparator)||`
62
- `}get readOnly(){return this.facet(sM)}phrase(t,...n){for(let n of this.facet(e.phrases))if(Object.prototype.hasOwnProperty.call(n,t)){t=n[t];break}return n.length&&(t=t.replace(/\$(\$|\d*)/g,(e,t)=>{if(t==`$`)return`$`;let r=+(t||1);return!r||r>n.length?e:n[r-1]})),t}languageDataAt(e,t,n=-1){let r=[];for(let i of this.facet(tM))for(let a of i(this,t,n))Object.prototype.hasOwnProperty.call(a,e)&&r.push(a[e]);return r}charCategorizer(e){let t=this.languageDataAt(`wordChars`,e);return TM(t.length?t[0]:``)}wordAt(e){let{text:t,from:n,length:r}=this.doc.lineAt(e),i=this.charCategorizer(e),a=e-n,o=e-n;for(;a>0;){let e=vj(t,a,!1);if(i(t.slice(e,a))!=xM.Word)break;a=e}for(;o<r;){let e=vj(t,o);if(i(t.slice(o,e))!=xM.Word)break;o=e}return a==o?null:q.range(a+n,o+n)}};EM.allowMultipleSelections=nM,EM.tabSize=Lj.define({combine:e=>e.length?e[0]:4}),EM.lineSeparator=rM,EM.readOnly=sM,EM.phrases=Lj.define({compare(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length==r.length&&n.every(n=>e[n]==t[n])}}),EM.languageData=tM,EM.changeFilter=iM,EM.transactionFilter=aM,EM.transactionExtender=oM,Yj.reconfigure=dM.define();function DM(e,t,n={}){let r={};for(let t of e)for(let e of Object.keys(t)){let i=t[e],a=r[e];if(a===void 0)r[e]=i;else if(a!==i&&i!==void 0){if(Object.hasOwnProperty.call(n,e))r[e]=n[e](a,i);else throw Error(`Config merge conflict for field `+e)}}for(let e in t)r[e]===void 0&&(r[e]=t[e]);return r}var OM=class{eq(e){return this==e}range(e,t=e){return AM.create(e,t,this)}};OM.prototype.startSide=OM.prototype.endSide=0,OM.prototype.point=!1,OM.prototype.mapMode=Tj.TrackDel;function kM(e,t){return e==t||e.constructor==t.constructor&&e.eq(t)}var AM=class e{constructor(e,t,n){this.from=e,this.to=t,this.value=n}static create(t,n,r){return new e(t,n,r)}};function jM(e,t){return e.from-t.from||e.value.startSide-t.value.startSide}var MM=class e{constructor(e,t,n,r){this.from=e,this.to=t,this.value=n,this.maxPoint=r}get length(){return PM(this.to)}findIndex(e,t,n,r=0){let i=n?this.to:this.from;for(let a=r,o=i.length;;){if(a==o)return a;let r=a+o>>1,s=i[r]-e||(n?this.value[r].endSide:this.value[r].startSide)-t;if(r==a)return s>=0?a:o;s>=0?o=r:a=r+1}}between(e,t,n,r){for(let i=this.findIndex(t,-1e9,!0),a=this.findIndex(n,1e9,!1,i);i<a;i++)if(r(this.from[i]+e,this.to[i]+e,this.value[i])===!1)return!1}map(t,n,r,i,a){let o=[],s=[],c=[],l=-1,u=-1;iter:for(let e=0;e<this.value.length;e++){let d=this.value[e],f=this.from[e]+t,p=this.to[e]+t,m,h;if(f==p){let e=n.mapPos(f,d.startSide,d.mapMode);if(e==null||(m=h=e,d.startSide!=d.endSide&&(h=n.mapPos(f,d.endSide),h<m)))continue}else if(m=n.mapPos(f,d.startSide),h=n.mapPos(p,d.endSide),m>h||m==h&&d.startSide>0&&d.endSide<=0)continue;if(!((h-m||d.endSide-d.startSide)<0)){if(l<0&&(l=m),d.point&&(u=Math.max(u,h-m)),(m-r||d.startSide-i)>=0)o.push(d),s.push(m-l),c.push(h-l),r=h,i=d.endSide;else{if(m==h)for(let e=o.length;e>0;e--){if((m-(c[e-1]+l)||d.startSide-o[e-1].endSide)>=0){o.splice(e,0,d),s.splice(e,0,m-l),c.splice(e,0,h-l);continue iter}if((m-(s[e-1]+l)||d.endSide-o[e-1].startSide)>0)break}a(m,h,d)}}}return{mapped:o.length?new e(s,c,o,u):null,pos:l}}},NM=class e{constructor(e,t,n,r){this.chunkPos=e,this.chunk=t,this.nextLayer=n,this.maxPoint=r}static create(t,n,r,i){return new e(t,n,r,i)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(t){let{add:n=[],sort:r=!1,filterFrom:i=0,filterTo:a=this.length}=t,o=t.filter;if(n.length==0&&!o)return this;if(r&&(n=n.slice().sort(jM)),this.isEmpty)return n.length?e.of(n):this;let s=new RM(this,null,-1).goto(0),c=0,l=[],u=new IM;for(;s.value||c<n.length;)if(c<n.length&&(s.from-n[c].from||s.startSide-n[c].value.startSide)>=0){let e=n[c++];u.addInner(e.from,e.to,e.value,!1)||l.push(e)}else s.rangeIndex==1&&s.chunkIndex<this.chunk.length&&(c==n.length||this.chunkEnd(s.chunkIndex)<n[c].from)&&(!o||i>this.chunkEnd(s.chunkIndex)||a<this.chunkPos[s.chunkIndex])&&u.addChunk(this.chunkPos[s.chunkIndex],this.chunk[s.chunkIndex])?s.nextChunk():((!o||i>s.to||a<s.from||o(s.from,s.to,s.value))&&(u.addInner(s.from,s.to,s.value,!1)||l.push(AM.create(s.from,s.to,s.value))),s.next());return u.finishInner(this.nextLayer.isEmpty&&!l.length?e.empty:this.nextLayer.update({add:l,filter:o,filterFrom:i,filterTo:a}))}map(t){if(t.empty||this.isEmpty)return this;let n=[],r=[],i=-1,a,o=(e,t,n)=>{a||=new IM,a.addRange(e,t,n,!1)};for(let e=0;e<this.chunk.length;e++){let a=this.chunkPos[e],s=this.chunk[e],c=t.touchesRange(a,a+s.length);if(c===!1)i=Math.max(i,s.maxPoint),n.push(s),r.push(t.mapPos(a));else if(c===!0){let[e,c]=n.length?[PM(r)+PM(n).length,PM(PM(n).value).endSide]:[-1,-1],{mapped:l,pos:u}=s.map(a,t,e,c,o);l&&(i=Math.max(i,l.maxPoint),n.push(l),r.push(u))}}let s=this.nextLayer.map(t);return a&&(s=a.finishInner(s)),n.length==0?s:new e(r,n,s||e.empty,i)}between(e,t,n){if(!this.isEmpty){for(let r=0;r<this.chunk.length;r++){let i=this.chunkPos[r],a=this.chunk[r];if(t>=i&&e<=i+a.length&&a.between(i,e-i,t-i,n)===!1)return}this.nextLayer.between(e,t,n)}}iter(e=0){return zM.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return zM.from(e).goto(t)}static compare(e,t,n,r,i=-1){let a=e.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),o=t.filter(e=>e.maxPoint>0||!e.isEmpty&&e.maxPoint>=i),s=LM(a,o,n),c=new VM(a,s,i),l=new VM(o,s,i);n.iterGaps((e,t,n)=>HM(c,e,l,t,n,r)),n.empty&&n.length==0&&HM(c,0,l,0,0,r)}static eq(e,t,n=0,r){r??=1e9-1;let i=e.filter(e=>!e.isEmpty&&t.indexOf(e)<0),a=t.filter(t=>!t.isEmpty&&e.indexOf(t)<0);if(i.length!=a.length)return!1;if(!i.length)return!0;let o=LM(i,a),s=new VM(i,o,0).goto(n),c=new VM(a,o,0).goto(n);for(;;){if(s.to!=c.to||!UM(s.active,c.active)||s.point&&(!c.point||!kM(s.point,c.point)))return!1;if(s.to>r)return!0;s.next(),c.next()}}static spans(e,t,n,r,i=-1){let a=new VM(e,null,i).goto(t),o=t,s=a.openStart;for(;;){let e=Math.min(a.to,n);if(a.point){let n=a.activeForPoint(a.to),i=a.pointFrom<t?n.length+1:a.point.startSide<0?n.length:Math.min(n.length,s);r.point(o,e,a.point,n,i,a.pointRank),s=Math.min(a.openEnd(e),n.length)}else e>o&&(r.span(o,e,a.active,s),s=a.openEnd(e));if(a.to>n)return s+(a.point&&a.to>n?1:0);o=a.to,a.next()}}static of(e,t=!1){let n=new IM;for(let r of e instanceof AM?[e]:t?FM(e):e)n.add(r.from,r.to,r.value);return n.finish()}static join(t){if(!t.length)return e.empty;let n=PM(t);for(let r=t.length-2;r>=0;r--)for(let i=t[r];i!=e.empty;i=i.nextLayer)n=new e(i.chunkPos,i.chunk,n,Math.max(i.maxPoint,n.maxPoint));return n}};NM.empty=new NM([],[],null,-1);function PM(e){return e[e.length-1]}function FM(e){if(e.length>1)for(let t=e[0],n=1;n<e.length;n++){let r=e[n];if(jM(t,r)>0)return e.slice().sort(jM);t=r}return e}NM.empty.nextLayer=NM.empty;var IM=class e{finishChunk(e){this.chunks.push(new MM(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,n){this.addRange(e,t,n,!0)}addRange(t,n,r,i){this.addInner(t,n,r,i)||(this.nextLayer||=new e).addRange(t,n,r,i)}addInner(e,t,n,r){let i=e-this.lastTo||n.startSide-this.last.endSide;if(r&&i<=0&&(e-this.lastFrom||n.startSide-this.last.startSide)<0)throw Error("Ranges must be added sorted by `from` position and `startSide`");return i<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=n,this.lastFrom=e,this.lastTo=t,this.value.push(n),n.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let n=t.value.length-1;return this.last=t.value[n],this.lastFrom=t.from[n]+e,this.lastTo=t.to[n]+e,!0}finish(){return this.finishInner(NM.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=NM.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}};function LM(e,t,n){let r=new Map;for(let t of e)for(let e=0;e<t.chunk.length;e++)t.chunk[e].maxPoint<=0&&r.set(t.chunk[e],t.chunkPos[e]);let i=new Set;for(let e of t)for(let t=0;t<e.chunk.length;t++){let a=r.get(e.chunk[t]);a!=null&&(n?n.mapPos(a):a)==e.chunkPos[t]&&!n?.touchesRange(a,a+e.chunk[t].length)&&i.add(e.chunk[t])}return i}var RM=class{constructor(e,t,n,r=0){this.layer=e,this.skip=t,this.minPoint=n,this.rank=r}get startSide(){return this.value?this.value.startSide:0}get endSide(){return this.value?this.value.endSide:0}goto(e,t=-1e9){return this.chunkIndex=this.rangeIndex=0,this.gotoInner(e,t,!1),this}gotoInner(e,t,n){for(;this.chunkIndex<this.layer.chunk.length;){let t=this.layer.chunk[this.chunkIndex];if(!(this.skip&&this.skip.has(t)||this.layer.chunkEnd(this.chunkIndex)<e||t.maxPoint<this.minPoint))break;this.chunkIndex++,n=!1}if(this.chunkIndex<this.layer.chunk.length){let r=this.layer.chunk[this.chunkIndex].findIndex(e-this.layer.chunkPos[this.chunkIndex],t,!0);(!n||this.rangeIndex<r)&&this.setRangeIndex(r)}this.next()}forward(e,t){(this.to-e||this.endSide-t)<0&&this.gotoInner(e,t,!0)}next(){for(;;)if(this.chunkIndex==this.layer.chunk.length){this.from=this.to=1e9,this.value=null;break}else{let e=this.layer.chunkPos[this.chunkIndex],t=this.layer.chunk[this.chunkIndex],n=e+t.from[this.rangeIndex];if(this.from=n,this.to=e+t.to[this.rangeIndex],this.value=t.value[this.rangeIndex],this.setRangeIndex(this.rangeIndex+1),this.minPoint<0||this.value.point&&this.to-this.from>=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex<this.layer.chunk.length&&this.skip.has(this.layer.chunk[this.chunkIndex]);)this.chunkIndex++;this.rangeIndex=0}else this.rangeIndex=e}nextChunk(){this.chunkIndex++,this.rangeIndex=0,this.next()}compare(e){return this.from-e.from||this.startSide-e.startSide||this.rank-e.rank||this.to-e.to||this.endSide-e.endSide}},zM=class e{constructor(e){this.heap=e}static from(t,n=null,r=-1){let i=[];for(let e=0;e<t.length;e++)for(let a=t[e];!a.isEmpty;a=a.nextLayer)a.maxPoint>=r&&i.push(new RM(a,n,r,e));return i.length==1?i[0]:new e(i)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let n of this.heap)n.goto(e,t);for(let e=this.heap.length>>1;e>=0;e--)BM(this.heap,e);return this.next(),this}forward(e,t){for(let n of this.heap)n.forward(e,t);for(let e=this.heap.length>>1;e>=0;e--)BM(this.heap,e);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),BM(this.heap,0)}}};function BM(e,t){for(let n=e[t];;){let r=(t<<1)+1;if(r>=e.length)break;let i=e[r];if(r+1<e.length&&i.compare(e[r+1])>=0&&(i=e[r+1],r++),n.compare(i)<0)break;e[r]=n,e[t]=i,t=r}}var VM=class{constructor(e,t,n){this.minPoint=n,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=zM.from(e,t,n)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){WM(this.active,e),WM(this.activeTo,e),WM(this.activeRank,e),this.minActive=KM(this.active,this.activeTo)}addActive(e){let t=0,{value:n,to:r,rank:i}=this.cursor;for(;t<this.activeRank.length&&(i-this.activeRank[t]||r-this.activeTo[t])>0;)t++;GM(this.active,t,n),GM(this.activeTo,t,r),GM(this.activeRank,t,i),e&&GM(e,t,this.cursor.from),this.minActive=KM(this.active,this.activeTo)}next(){let e=this.to,t=this.point;this.point=null;let n=this.openStart<0?[]:null;for(;;){let r=this.minActive;if(r>-1&&(this.activeTo[r]-this.cursor.from||this.active[r].endSide-this.cursor.startSide)<0){if(this.activeTo[r]>e){this.to=this.activeTo[r],this.endSide=this.active[r].endSide;break}this.removeActive(r),n&&WM(n,r)}else if(!this.cursor.value){this.to=this.endSide=1e9;break}else if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let e=this.cursor.value;if(!e.point)this.addActive(n),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from<this.cursor.to)this.cursor.next();else{this.point=e,this.pointFrom=this.cursor.from,this.pointRank=this.cursor.rank,this.to=this.cursor.to,this.endSide=e.endSide,this.cursor.next(),this.forward(this.to,this.endSide);break}}}if(n){this.openStart=0;for(let t=n.length-1;t>=0&&n[t]<e;t--)this.openStart++}}activeForPoint(e){if(!this.active.length)return this.active;let t=[];for(let n=this.active.length-1;n>=0&&!(this.activeRank[n]<this.pointRank);n--)(this.activeTo[n]>e||this.activeTo[n]==e&&this.active[n].endSide>=this.point.endSide)&&t.push(this.active[n]);return t.reverse()}openEnd(e){let t=0;for(let n=this.activeTo.length-1;n>=0&&this.activeTo[n]>e;n--)t++;return t}};function HM(e,t,n,r,i,a){e.goto(t),n.goto(r);let o=r+i,s=r,c=r-t,l=!!a.boundChange;for(let t=!1;;){let r=e.to+c-n.to,i=r||e.endSide-n.endSide,u=i<0?e.to+c:n.to,d=Math.min(u,o);if(e.point||n.point?(e.point&&n.point&&kM(e.point,n.point)&&UM(e.activeForPoint(e.to),n.activeForPoint(n.to))||a.comparePoint(s,d,e.point,n.point),t=!1):(t&&=(a.boundChange(s),!1),d>s&&!UM(e.active,n.active)&&a.compareRange(s,d,e.active,n.active),l&&d<o&&(r||e.openEnd(u)!=n.openEnd(u))&&(t=!0)),u>o)break;s=u,i<=0&&e.next(),i>=0&&n.next()}}function UM(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n]&&!kM(e[n],t[n]))return!1;return!0}function WM(e,t){for(let n=t,r=e.length-1;n<r;n++)e[n]=e[n+1];e.pop()}function GM(e,t,n){for(let n=e.length-1;n>=t;n--)e[n+1]=e[n];e[t]=n}function KM(e,t){let n=-1,r=1e9;for(let i=0;i<t.length;i++)(t[i]-r||e[i].endSide-e[n].endSide)<0&&(n=i,r=t[i]);return n}function qM(e,t,n=e.length){let r=0;for(let i=0;i<n&&i<e.length;)e.charCodeAt(i)==9?(r+=t-r%t,i++):(r++,i=vj(e,i));return r}function JM(e,t,n,r){for(let r=0,i=0;;){if(i>=t)return r;if(r==e.length)break;i+=e.charCodeAt(r)==9?n-i%n:1,r=vj(e,r)}return r===!0?-1:e.length}for(var YM=`ͼ`,XM=typeof Symbol>`u`?`__ͼ`:Symbol.for(YM),ZM=typeof Symbol>`u`?`__styleSet`+Math.floor(Math.random()*1e8):Symbol(`styleSet`),QM=typeof globalThis<`u`?globalThis:typeof window<`u`?window:{},$M=class{constructor(e,t){this.rules=[];let{finish:n}=t||{};function r(e){return/^@/.test(e)?[e]:e.split(/,\s*/)}function i(e,t,a,o){let s=[],c=/^@(\w+)\b/.exec(e[0]),l=c&&c[1]==`keyframes`;if(c&&t==null)return a.push(e[0]+`;`);for(let n in t){let o=t[n];if(/&/.test(n))i(n.split(/,\s*/).map(t=>e.map(e=>t.replace(/&/,e))).reduce((e,t)=>e.concat(t)),o,a);else if(o&&typeof o==`object`){if(!c)throw RangeError(`The value of a property (`+n+`) should be a primitive value.`);i(r(n),o,s,l)}else o!=null&&s.push(n.replace(/_.*/,``).replace(/[A-Z]/g,e=>`-`+e.toLowerCase())+`: `+o+`;`)}(s.length||l)&&a.push((n&&!c&&!o?e.map(n):e).join(`, `)+` {`+s.join(` `)+`}`)}for(let t in e)i(r(t),e[t],this.rules)}getRules(){return this.rules.join(`
63
- `)}static newName(){let e=QM[XM]||1;return QM[XM]=e+1,YM+e.toString(36)}static mount(e,t,n){let r=e[ZM],i=n&&n.nonce;r?i&&r.setNonce(i):r=new tN(e,i),r.mount(Array.isArray(t)?t:[t],e)}},eN=new Map,tN=class{constructor(e,t){let n=e.ownerDocument||e,r=n.defaultView;if(!e.head&&e.adoptedStyleSheets&&r.CSSStyleSheet){let t=eN.get(n);if(t)return e[ZM]=t;this.sheet=new r.CSSStyleSheet,eN.set(n,this)}else this.styleTag=n.createElement(`style`),t&&this.styleTag.setAttribute(`nonce`,t);this.modules=[],e[ZM]=this}mount(e,t){let n=this.sheet,r=0,i=0,a=!1;for(let t=0;t<e.length;t++){let o=e[t],s=this.modules.indexOf(o);if(s<i&&s>-1&&(this.modules.splice(s,1),a=!0,i--,s=-1),s==-1){if(this.modules.splice(i++,0,o),a=!0,n)for(let e=0;e<o.rules.length;e++)n.insertRule(o.rules[e],r++)}else{for(;i<s;)r+=this.modules[i++].rules.length;r+=o.rules.length,i++}}if(n)t.adoptedStyleSheets.indexOf(this.sheet)<0&&(t.adoptedStyleSheets=[this.sheet,...t.adoptedStyleSheets]);else{if(a){let e=``;for(let t=0;t<this.modules.length;t++)e+=this.modules[t].getRules()+`
64
- `;this.styleTag.textContent=e}let e=t.head||t;this.styleTag.parentNode!=e&&e.insertBefore(this.styleTag,e.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute(`nonce`)!=e&&this.styleTag.setAttribute(`nonce`,e)}},nN={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},rN={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},iN=typeof navigator<`u`&&/Mac/.test(navigator.platform),aN=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),oN=0;oN<10;oN++)nN[48+oN]=nN[96+oN]=String(oN);for(var oN=1;oN<=24;oN++)nN[oN+111]=`F`+oN;for(var oN=65;oN<=90;oN++)nN[oN]=String.fromCharCode(oN+32),rN[oN]=String.fromCharCode(oN);for(var sN in nN)rN.hasOwnProperty(sN)||(rN[sN]=nN[sN]);function cN(e){var t=!(iN&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||aN&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?rN:nN)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}function lN(){var e=arguments[0];typeof e==`string`&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&typeof n==`object`&&n.nodeType==null&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var i=n[r];typeof i==`string`?e.setAttribute(r,i):i!=null&&(e[r]=i)}t++}for(;t<arguments.length;t++)uN(e,arguments[t]);return e}function uN(e,t){if(typeof t==`string`)e.appendChild(document.createTextNode(t));else if(t!=null){if(t.nodeType!=null)e.appendChild(t);else if(Array.isArray(t))for(var n=0;n<t.length;n++)uN(e,t[n]);else throw RangeError(`Unsupported child node: `+t)}}var dN=typeof navigator<`u`?navigator:{userAgent:``,vendor:``,platform:``},fN=typeof document<`u`?document:{documentElement:{style:{}}},pN=/Edge\/(\d+)/.exec(dN.userAgent),mN=/MSIE \d/.test(dN.userAgent),hN=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(dN.userAgent),gN=!!(mN||hN||pN),_N=!gN&&/gecko\/(\d+)/i.test(dN.userAgent),vN=!gN&&/Chrome\/(\d+)/.exec(dN.userAgent),yN=`webkitFontSmoothing`in fN.documentElement.style,bN=!gN&&/Apple Computer/.test(dN.vendor),xN=bN&&(/Mobile\/\w+/.test(dN.userAgent)||dN.maxTouchPoints>2),J={mac:xN||/Mac/.test(dN.platform),windows:/Win/.test(dN.platform),linux:/Linux|X11/.test(dN.platform),ie:gN,ie_version:mN?fN.documentMode||6:hN?+hN[1]:pN?+pN[1]:0,gecko:_N,gecko_version:_N?+(/Firefox\/(\d+)/.exec(dN.userAgent)||[0,0])[1]:0,chrome:!!vN,chrome_version:vN?+vN[1]:0,ios:xN,android:/Android\b/.test(dN.userAgent),webkit:yN,webkit_version:yN?+(/\bAppleWebKit\/(\d+)/.exec(dN.userAgent)||[0,0])[1]:0,safari:bN,safari_version:bN?+(/\bVersion\/(\d+(\.\d+)?)/.exec(dN.userAgent)||[0,0])[1]:0,tabSize:fN.documentElement.style.tabSize==null?`-moz-tab-size`:`tab-size`};function SN(e,t){for(let n in e)n==`class`&&t.class?t.class+=` `+e.class:n==`style`&&t.style?t.style+=`;`+e.style:t[n]=e[n];return t}var CN=Object.create(null);function wN(e,t,n){if(e==t)return!0;e||=CN,t||=CN;let r=Object.keys(e),i=Object.keys(t);if(r.length-0!=i.length-0)return!1;for(let a of r)if(a!=n&&(i.indexOf(a)==-1||e[a]!==t[a]))return!1;return!0}function TN(e,t){for(let n=e.attributes.length-1;n>=0;n--){let r=e.attributes[n].name;t[r]??e.removeAttribute(r)}for(let n in t){let r=t[n];n==`style`?e.style.cssText=r:e.getAttribute(n)!=r&&e.setAttribute(n,r)}}function EN(e,t,n){let r=!1;if(t)for(let i in t)n&&i in n||(r=!0,i==`style`?e.style.cssText=``:e.removeAttribute(i));if(n)for(let i in n)t&&t[i]==n[i]||(r=!0,i==`style`?e.style.cssText=n[i]:e.setAttribute(i,n[i]));return r}function DN(e){let t=Object.create(null);for(let n=0;n<e.attributes.length;n++){let r=e.attributes[n];t[r.name]=r.value}return t}var ON=class{eq(e){return!1}updateDOM(e,t,n){return!1}compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}get estimatedHeight(){return-1}get lineBreaks(){return 0}ignoreEvent(e){return!0}coordsAt(e,t,n){return null}get isHidden(){return!1}get editable(){return!1}destroy(e){}},kN=(function(e){return e[e.Text=0]=`Text`,e[e.WidgetBefore=1]=`WidgetBefore`,e[e.WidgetAfter=2]=`WidgetAfter`,e[e.WidgetRange=3]=`WidgetRange`,e})(kN||={}),AN=class extends OM{constructor(e,t,n,r){super(),this.startSide=e,this.endSide=t,this.widget=n,this.spec=r}get heightRelevant(){return!1}static mark(e){return new jN(e)}static widget(e){let t=Math.max(-1e4,Math.min(1e4,e.side||0)),n=!!e.block;return t+=n&&!e.inlineOrder?t>0?3e8:-4e8:t>0?1e8:-1e8,new NN(e,t,t,n,e.widget||null,!1)}static replace(e){let t=!!e.block,n,r;if(e.isBlockGap)n=-5e8,r=4e8;else{let{start:i,end:a}=PN(e,t);n=(i?t?-3e8:-1:5e8)-1,r=(a?t?2e8:1:-6e8)+1}return new NN(e,n,r,t,e.widget||null,!0)}static line(e){return new MN(e)}static set(e,t=!1){return NM.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}};AN.none=NM.empty;var jN=class e extends AN{constructor(e){let{start:t,end:n}=PN(e);super(t?-1:5e8,n?1:-6e8,null,e),this.tagName=e.tagName||`span`,this.attrs=e.class&&e.attributes?SN(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||CN}eq(t){return this==t||t instanceof e&&this.tagName==t.tagName&&wN(this.attrs,t.attrs)}range(e,t=e){if(e>=t)throw RangeError(`Mark decorations may not be empty`);return super.range(e,t)}};jN.prototype.point=!1;var MN=class e extends AN{constructor(e){super(-2e8,-2e8,null,e)}eq(t){return t instanceof e&&this.spec.class==t.spec.class&&wN(this.spec.attributes,t.spec.attributes)}range(e,t=e){if(t!=e)throw RangeError(`Line decoration ranges must be zero-length`);return super.range(e,t)}};MN.prototype.mapMode=Tj.TrackBefore,MN.prototype.point=!0;var NN=class e extends AN{constructor(e,t,n,r,i,a){super(t,n,i,e),this.block=r,this.isReplace=a,this.mapMode=r?t<=0?Tj.TrackBefore:Tj.TrackAfter:Tj.TrackDel}get type(){return this.startSide==this.endSide?this.startSide<=0?kN.WidgetBefore:kN.WidgetAfter:kN.WidgetRange}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(t){return t instanceof e&&FN(this.widget,t.widget)&&this.block==t.block&&this.startSide==t.startSide&&this.endSide==t.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw RangeError(`Invalid range for replacement decoration`);if(!this.isReplace&&t!=e)throw RangeError(`Widget decorations can only have zero-length ranges`);return super.range(e,t)}};NN.prototype.point=!0;function PN(e,t=!1){let{inclusiveStart:n,inclusiveEnd:r}=e;return n??=e.inclusive,r??=e.inclusive,{start:n??t,end:r??t}}function FN(e,t){return e==t||!!(e&&t&&e.compare(t))}function IN(e,t,n,r=0){let i=n.length-1;i>=0&&n[i]+r>=e?n[i]=Math.max(n[i],t):n.push(e,t)}var LN=class e extends OM{constructor(e,t,n){super(),this.tagName=e,this.attributes=t,this.rank=n}eq(t){return t==this||t instanceof e&&this.tagName==t.tagName&&wN(this.attributes,t.attributes)}static create(t){return new e(t.tagName,t.attributes||CN,t.rank==null?50:Math.max(0,Math.min(t.rank,100)))}static set(e,t=!1){return NM.of(e,t)}};LN.prototype.startSide=LN.prototype.endSide=-1;var RN=e=>e.nodeType==1,zN=e=>e.nodeType==3;function BN(e){let t;return t=e.nodeType==11?e.getSelection?e:e.ownerDocument:e,t.getSelection()}function VN(e,t){return t?e==t||e.contains(t.nodeType==1?t:t.parentNode):!1}function HN(e,t){if(!t.anchorNode)return!1;try{return VN(e,t.anchorNode)}catch{return!1}}function UN(e){return zN(e)?oP(e,0,e.nodeValue.length).getClientRects():RN(e)?e.getClientRects():[]}function WN(e,t,n,r){return n?qN(e,t,n,r,-1)||qN(e,t,n,r,1):!1}function GN(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t}function KN(e){return RN(e)&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(e.nodeName)}function qN(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:JN(e))){if(e.nodeName==`DIV`)return!1;let n=e.parentNode;if(!n||!RN(n))return!1;t=GN(e)+(i<0?0:1),e=n}else if(RN(e)){if(e=e.childNodes[t+(i<0?-1:0)],RN(e)&&(e.nodeName==`IMG`||e.nodeName==`BR`||e.contentEditable==`false`))return!1;t=i<0?JN(e):0}else return!1}}function JN(e){return zN(e)?e.nodeValue.length:e.childNodes.length}function YN(e,t){let{left:n,right:r}=e;if(n==r)return e;let i=t?n:r;return{left:i,right:i,top:e.top,bottom:e.bottom}}function XN(e){let t=e.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.innerWidth,top:0,bottom:e.innerHeight}}function ZN(e,t){let n=t.width/e.offsetWidth,r=t.height/e.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(t.width-e.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(t.height-e.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function QN(e,t,n,r,i,a,o,s){let c=e.ownerDocument,l=c.defaultView||window;for(let u=e,d=!1;u&&!d;)if(RN(u)){let e,f=u==c.body,p=1,m=1;if(f)e=XN(l);else{if(/^(fixed|sticky)$/.test(getComputedStyle(u).position)&&(d=!0),u.scrollHeight<=u.clientHeight&&u.scrollWidth<=u.clientWidth){u=u.assignedSlot||u.parentNode;continue}let t=u.getBoundingClientRect();({scaleX:p,scaleY:m}=ZN(u,t)),e={left:t.left,right:t.left+u.clientWidth*p,top:t.top,bottom:t.top+u.clientHeight*m}}let h=0,g=0;if(i==`nearest`)t.top<e.top+o?(g=t.top-(e.top+o),n>0&&t.bottom>e.bottom+g&&(g=t.bottom-e.bottom+o)):t.bottom>e.bottom-o&&(g=t.bottom-e.bottom+o,n<0&&t.top-g<e.top&&(g=t.top-(e.top+o)));else{let r=t.bottom-t.top,a=e.bottom-e.top;g=(i==`center`&&r<=a?t.top+r/2-a/2:i==`start`||i==`center`&&n<0?t.top-o:t.bottom-a+o)-e.top}if(r==`nearest`?t.left<e.left+a?(h=t.left-(e.left+a),n>0&&t.right>e.right+h&&(h=t.right-e.right+a)):t.right>e.right-a&&(h=t.right-e.right+a,n<0&&t.left<e.left+h&&(h=t.left-(e.left+a))):h=(r==`center`?t.left+(t.right-t.left)/2-(e.right-e.left)/2:r==`start`==s?t.left-a:t.right-(e.right-e.left)+a)-e.left,h||g){if(f)l.scrollBy(h,g);else{let e=0,n=0;if(g){let e=u.scrollTop;u.scrollTop+=g/m,n=(u.scrollTop-e)*m}if(h){let t=u.scrollLeft;u.scrollLeft+=h/p,e=(u.scrollLeft-t)*p}t={left:t.left-e,top:t.top-n,right:t.right-e,bottom:t.bottom-n},e&&Math.abs(e-h)<1&&(r=`nearest`),n&&Math.abs(n-g)<1&&(i=`nearest`)}}if(f)break;(t.top<e.top||t.bottom>e.bottom||t.left<e.left||t.right>e.right)&&(t={left:Math.max(t.left,e.left),right:Math.min(t.right,e.right),top:Math.max(t.top,e.top),bottom:Math.min(t.bottom,e.bottom)}),u=u.assignedSlot||u.parentNode}else if(u.nodeType==11)u=u.host;else break}function $N(e,t=!0){let n=e.ownerDocument,r=null,i=null;for(let a=e.parentNode;a&&!(a==n.body||(!t||r)&&i);)if(RN(a))!i&&a.scrollHeight>a.clientHeight&&(i=a),t&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:i}}var eP=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:n}=e;this.set(t,Math.min(e.anchorOffset,t?JN(t):0),n,Math.min(e.focusOffset,n?JN(n):0))}set(e,t,n,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=n,this.focusOffset=r}};function tP(e){let t=[];for(let n=e;n;n=n.nodeType==11?n.host:n.parentNode)RN(n)&&t.push({node:n,left:n.scrollLeft,top:n.scrollTop});return t}function nP(e,t=!0){for(let{node:n,left:r,top:i}of e)t&&n.scrollTop!=i&&(n.scrollTop=i),n.scrollLeft!=r&&(n.scrollLeft=r)}var rP=null;J.safari&&J.safari_version>=26&&(rP=!1);function iP(e){if(e.setActive)return e.setActive();if(rP)return e.focus(rP);let t=tP(e);e.focus(rP==null?{get preventScroll(){return rP={preventScroll:!0},!0}}:void 0),rP||(rP=!1,nP(t))}var aP;function oP(e,t,n=t){let r=aP||=document.createRange();return r.setEnd(e,n),r.setStart(e,t),r}function sP(e,t,n,r){let i={key:t,code:t,keyCode:n,which:n,cancelable:!0};r&&({altKey:i.altKey,ctrlKey:i.ctrlKey,shiftKey:i.shiftKey,metaKey:i.metaKey}=r);let a=new KeyboardEvent(`keydown`,i);a.synthetic=!0,e.dispatchEvent(a);let o=new KeyboardEvent(`keyup`,i);return o.synthetic=!0,e.dispatchEvent(o),a.defaultPrevented||o.defaultPrevented}function cP(e){for(;e;){if(e&&(e.nodeType==9||e.nodeType==11&&e.host))return e;e=e.assignedSlot||e.parentNode}return null}function lP(e,t){let n=t.focusNode,r=t.focusOffset;if(!n||t.anchorNode!=n||t.anchorOffset!=r)return!1;for(r=Math.min(r,JN(n));;)if(r){if(!RN(n))return!1;let e=n.childNodes[r-1];e.contentEditable==`false`?r--:(n=e,r=JN(n))}else if(n==e)return!0;else r=GN(n),n=n.parentNode}function uP(e){return e instanceof Window?e.pageYOffset>Math.max(0,e.document.documentElement.scrollHeight-e.innerHeight-4):e.scrollTop>Math.max(1,e.scrollHeight-e.clientHeight-4)}function dP(e,t){for(let n=e,r=t;;)if(zN(n)&&r>0)return{node:n,offset:r};else if(RN(n)&&r>0){if(n.contentEditable==`false`)return null;n=n.childNodes[r-1],r=JN(n)}else if(n.parentNode&&!KN(n))r=GN(n),n=n.parentNode;else return null}function fP(e,t){for(let n=e,r=t;;)if(zN(n)&&r<n.nodeValue.length)return{node:n,offset:r};else if(RN(n)&&r<n.childNodes.length){if(n.contentEditable==`false`)return null;n=n.childNodes[r],r=0}else if(n.parentNode&&!KN(n))r=GN(n)+1,n=n.parentNode;else return null}var pP=class e{constructor(e,t,n=!0){this.node=e,this.offset=t,this.precise=n}static before(t,n){return new e(t.parentNode,GN(t),n)}static after(t,n){return new e(t.parentNode,GN(t)+1,n)}},mP=(function(e){return e[e.LTR=0]=`LTR`,e[e.RTL=1]=`RTL`,e})(mP||={}),hP=mP.LTR,gP=mP.RTL;function _P(e){let t=[];for(let n=0;n<e.length;n++)t.push(1<<e[n]);return t}var vP=_P(`88888888888888888888888888888888888666888888787833333333337888888000000000000000000000000008888880000000000000000000000000088888888888888888888888888888888888887866668888088888663380888308888800000000000000000000000800000000000000000000000000000008`),yP=_P(`4444448826627288999999999992222222222222222222222222222222222222222222222229999999999999999999994444444444644222822222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222999999949999999229989999223333333333`),bP=Object.create(null),xP=[];for(let e of[`()`,`[]`,`{}`]){let t=e.charCodeAt(0),n=e.charCodeAt(1);bP[t]=n,bP[n]=-t}function SP(e){return e<=247?vP[e]:1424<=e&&e<=1524?2:1536<=e&&e<=1785?yP[e-1536]:1774<=e&&e<=2220?4:8192<=e&&e<=8204?256:64336<=e&&e<=65023?4:1}var CP=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac\ufb50-\ufdff]/,wP=class{get dir(){return this.level%2?gP:hP}constructor(e,t,n){this.from=e,this.to=t,this.level=n}side(e,t){return this.dir==t==e?this.to:this.from}forward(e,t){return e==(this.dir==t)}static find(e,t,n,r){let i=-1;for(let a=0;a<e.length;a++){let o=e[a];if(o.from<=t&&o.to>=t){if(o.level==n)return a;(i<0||(r==0?e[i].level>o.level:r<0?o.from<t:o.to>t))&&(i=a)}}if(i<0)throw RangeError(`Index out of range`);return i}};function TP(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.direction!=i.direction||!TP(r.inner,i.inner))return!1}return!0}var EP=[];function DP(e,t,n,r,i){for(let a=0;a<=r.length;a++){let o=a?r[a-1].to:t,s=a<r.length?r[a].from:n,c=a?256:i;for(let t=o,n=c,r=c;t<s;t++){let i=SP(e.charCodeAt(t));i==512?i=n:i==8&&r==4&&(i=16),EP[t]=i==4?2:i,i&7&&(r=i),n=i}for(let e=o,t=c,r=c;e<s;e++){let i=EP[e];if(i==128)e<s-1&&t==EP[e+1]&&t&24?i=EP[e]=t:EP[e]=256;else if(i==64){let i=e+1;for(;i<s&&EP[i]==64;)i++;let a=e&&t==8||i<n&&EP[i]==8?r==1?1:8:256;for(let t=e;t<i;t++)EP[t]=a;e=i-1}else i==8&&r==1&&(EP[e]=1);t=i,i&7&&(r=i)}}}function OP(e,t,n,r,i){let a=i==1?2:1;for(let o=0,s=0,c=0;o<=r.length;o++){let l=o?r[o-1].to:t,u=o<r.length?r[o].from:n;for(let t=l,n,r,o;t<u;t++)if(r=bP[n=e.charCodeAt(t)]){if(r<0){for(let e=s-3;e>=0;e-=3)if(xP[e+1]==-r){let n=xP[e+2],r=n&2?i:n&4?n&1?a:i:0;r&&(EP[t]=EP[xP[e]]=r),s=e;break}}else if(xP.length==189)break;else xP[s++]=t,xP[s++]=n,xP[s++]=c}else if((o=EP[t])==2||o==1){let e=o==i;c=+!e;for(let t=s-3;t>=0;t-=3){let n=xP[t+2];if(n&2)break;if(e)xP[t+2]|=2;else{if(n&4)break;xP[t+2]|=4}}}}}function kP(e,t,n,r){for(let i=0,a=r;i<=n.length;i++){let o=i?n[i-1].to:e,s=i<n.length?n[i].from:t;for(let c=o;c<s;){let o=EP[c];if(o==256){let o=c+1;for(;;)if(o==s){if(i==n.length)break;o=n[i++].to,s=i<n.length?n[i].from:t}else if(EP[o]==256)o++;else break;let l=a==1,u=l==((o<t?EP[o]:r)==1)?l?1:2:r;for(let t=o,r=i,a=r?n[r-1].to:e;t>c;)t==a&&(t=n[--r].from,a=r?n[r-1].to:e),EP[--t]=u;c=o}else a=o,c++}}}function AP(e,t,n,r,i,a,o){let s=r%2?2:1;if(r%2==i%2)for(let c=t,l=0;c<n;){let t=!0,u=!1;if(l==a.length||c<a[l].from){let e=EP[c];e!=s&&(t=!1,u=e==16)}let d=!t&&s==1?[]:null,f=t?r:r+1,p=c;run:for(;;)if(l<a.length&&p==a[l].from){if(u)break run;let m=a[l];if(!t)for(let e=m.to,t=l+1;;){if(e==n)break run;if(t<a.length&&a[t].from==e)e=a[t++].to;else if(EP[e]==s)break run;else break}l++,d?d.push(m):(m.from>c&&o.push(new wP(c,m.from,f)),jP(e,m.direction==hP==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.to),p=m.to}else if(p==n||(t?EP[p]!=s:EP[p]==s))break;else p++;d?AP(e,c,p,r+1,i,d,o):c<p&&o.push(new wP(c,p,f)),c=p}else for(let c=n,l=a.length;c>t;){let n=!0,u=!1;if(!l||c>a[l-1].to){let e=EP[c-1];e!=s&&(n=!1,u=e==16)}let d=!n&&s==1?[]:null,f=n?r:r+1,p=c;run:for(;;)if(l&&p==a[l-1].to){if(u)break run;let m=a[--l];if(!n)for(let e=m.from,n=l;;){if(e==t)break run;if(n&&a[n-1].to==e)e=a[--n].from;else if(EP[e-1]==s)break run;else break}d?d.push(m):(m.to<c&&o.push(new wP(m.to,c,f)),jP(e,m.direction==hP==!(f%2)?r:r+1,i,m.inner,m.from,m.to,o),c=m.from),p=m.from}else if(p==t||(n?EP[p-1]!=s:EP[p-1]==s))break;else p--;d?AP(e,p,c,r+1,i,d,o):p<c&&o.push(new wP(p,c,f)),c=p}}function jP(e,t,n,r,i,a,o){let s=t%2?2:1;DP(e,i,a,r,s),OP(e,i,a,r,s),kP(i,a,r,s),AP(e,i,a,t,n,r,o)}function MP(e,t,n){if(!e)return[new wP(0,0,+(t==gP))];if(t==hP&&!n.length&&!CP.test(e))return NP(e.length);if(n.length)for(;e.length>EP.length;)EP[EP.length]=256;let r=[],i=t==hP?0:1;return jP(e,i,i,n,0,e.length,r),r}function NP(e){return[new wP(0,e,0)]}var PP=``;function FP(e,t,n,r,i){if(!e.length)return null;let a=r.head-e.from,o;if(r.head==e.from&&r.assoc<0){if(!i)return null;a=t[o=0].side(!1,n)}else if(r.head==e.to&&r.assoc>0){if(i)return null;a=t[o=t.length-1].side(!0,n)}else o=wP.find(t,a,r.bidiLevel??-1,r.assoc);let s=t[o],c=s.side(i,n);if(a==c){let e=o+=i?1:-1;if(e<0||e>=t.length)return null;s=t[o=e],a=s.side(!i,n),c=s.side(i,n)}let l=vj(e.text,a,s.forward(i,n));(l<s.from||l>s.to)&&(l=c),PP=e.text.slice(Math.min(a,l),Math.max(a,l));let u=o==(i?t.length-1:0)?null:t[o+(i?1:-1)];if(l==c){if(!u)return i?q.cursor(e.to,1):q.cursor(e.from,-1);if(u.level+ +!i<s.level)return q.cursor(u.side(!i,n)+e.from,u.forward(i,n)?1:-1,u.level)}return q.cursor(l+e.from,s.forward(i,n)?-1:1,s.level)}function IP(e,t,n){for(let r=t;r<n;r++){let t=SP(e.charCodeAt(r));if(t==1)return hP;if(t==2||t==4)return gP}return hP}var LP=Lj.define(),RP=Lj.define(),zP=Lj.define(),BP=Lj.define(),VP=Lj.define(),HP=Lj.define(),UP=Lj.define(),WP=Lj.define(),GP=Lj.define(),KP=Lj.define({combine:e=>e.some(e=>e)}),qP=Lj.define({combine:e=>e.some(e=>e)}),JP=Lj.define(),YP=class e{constructor(e,t,n,r,i,a=!1){this.range=e,this.y=t,this.x=n,this.yMargin=r,this.xMargin=i,this.isSnapshot=a}map(t){return t.empty?this:new e(this.range.map(t),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(t){return this.range.to<=t.doc.length?this:new e(q.cursor(t.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}},XP=dM.define({map:(e,t)=>e.map(t)}),ZP=dM.define();function QP(e,t,n){let r=e.facet(BP);r.length?r[0](t):window.onerror&&window.onerror(String(t),n,void 0,void 0,t)||(n?console.error(n+`:`,t):console.error(t))}var $P=Lj.define({combine:e=>!e.length||e[0]}),eF=0,tF=Lj.define({combine(e){return e.filter((t,n)=>{for(let r=0;r<n;r++)if(e[r].plugin==t.plugin)return!1;return!0})}}),nF=class e{constructor(e,t,n,r,i){this.id=e,this.create=t,this.domEventHandlers=n,this.domEventObservers=r,this.baseExtensions=i(this),this.extension=this.baseExtensions.concat(tF.of({plugin:this,arg:void 0}))}of(e){return this.baseExtensions.concat(tF.of({plugin:this,arg:e}))}static define(t,n){let{eventHandlers:r,eventObservers:i,provide:a,decorations:o}=n||{};return new e(eF++,t,r,i,e=>{let t=[];return o&&t.push(oF.of(t=>{let n=t.plugin(e);return n?o(n):AN.none})),a&&t.push(a(e)),t})}static fromClass(t,n){return e.define((e,n)=>new t(e,n),n)}},rF=class{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(!this.value){if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(t){QP(e.state,t,`CodeMirror plugin crashed`),this.deactivate()}}else if(this.mustUpdate){let e=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(e)}catch(t){if(QP(e.state,t,`CodeMirror plugin crashed`),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}return this}destroy(e){if(this.value?.destroy)try{this.value.destroy()}catch(t){QP(e.state,t,`CodeMirror plugin crashed`)}}deactivate(){this.spec=this.value=null}},iF=Lj.define(),aF=Lj.define(),oF=Lj.define(),sF=Lj.define(),cF=Lj.define(),lF=Lj.define(),uF=Lj.define();function dF(e,t){let n=e.state.facet(uF);if(!n.length)return n;let r=n.map(t=>t instanceof Function?t(e):t),i=[];return NM.spans(r,t.from,t.to,{point(){},span(e,n,r,a){let o=e-t.from,s=n-t.from,c=i;for(let e=r.length-1;e>=0;e--,a--){let n=r[e].spec.bidiIsolate,i;if(n??=IP(t.text,o,s),a>0&&c.length&&(i=c[c.length-1]).to==o&&i.direction==n)i.to=s,c=i.inner;else{let e={from:o,to:s,direction:n,inner:[]};c.push(e),c=e.inner}}}}),i}var fF=Lj.define();function pF(e){let t=0,n=0,r=0,i=0;for(let a of e.state.facet(fF)){let o=a(e);o&&(o.left!=null&&(t=Math.max(t,o.left)),o.right!=null&&(n=Math.max(n,o.right)),o.top!=null&&(r=Math.max(r,o.top)),o.bottom!=null&&(i=Math.max(i,o.bottom)))}return{left:t,right:n,top:r,bottom:i}}var mF=Lj.define(),hF=class e{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}join(t){return new e(Math.min(this.fromA,t.fromA),Math.max(this.toA,t.toA),Math.min(this.fromB,t.fromB),Math.max(this.toB,t.toB))}addToSet(e){let t=e.length,n=this;for(;t>0;t--){let r=e[t-1];if(!(r.fromA>n.toA)){if(r.toA<n.fromA)break;n=n.join(r),e.splice(t-1,1)}}return e.splice(t,0,n),e}static extendWithRanges(t,n){if(n.length==0)return t;let r=[];for(let i=0,a=0,o=0;;){let s=i<t.length?t[i].fromB:1e9,c=a<n.length?n[a]:1e9,l=Math.min(s,c);if(l==1e9)break;let u=l+o,d=l,f=u;for(;;)if(a<n.length&&n[a]<=d){let e=n[a+1];a+=2,d=Math.max(d,e);for(let e=i;e<t.length&&t[e].fromB<=d;e++)o=t[e].toA-t[e].toB;f=Math.max(f,e+o)}else if(i<t.length&&t[i].fromB<=d){let e=t[i++];d=Math.max(d,e.toB),f=Math.max(f,e.toA),o=e.toA-e.toB}else break;r.push(new e(u,f,l,d))}return r}},gF=class e{constructor(e,t,n){this.view=e,this.state=t,this.transactions=n,this.flags=0,this.startState=e.state,this.changes=Dj.empty(this.startState.doc.length);for(let e of n)this.changes=this.changes.compose(e.changes);let r=[];this.changes.iterChangedRanges((e,t,n,i)=>r.push(new hF(e,t,n,i))),this.changedRanges=r}static create(t,n,r){return new e(t,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}},_F=[],vF=class{constructor(e,t,n=0){this.dom=e,this.length=t,this.flags=n,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return _F}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let e=this.domAttrs;e&&TN(this.dom,e)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:``)+(this.breakAfter?`#`:``)}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,t=this.posAtStart){let n=t;for(let t of this.children){if(t==e)return n;n+=t.length+t.breakAfter}throw RangeError(`Invalid child in posBefore`)}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,t,n){return null}domPosFor(e,t){let n=GN(this.dom),r=this.length?e>0:t>0;return new pP(this.parent.dom,n+ +!!r,e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof xF)return e;return null}static get(e){return e.cmTile}},yF=class extends vF{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let t=this.dom,n=null,r,i=e?.node==t?e:null,a=0;for(let o of this.children){if(o.sync(e),a+=o.length+o.breakAfter,r=n?n.nextSibling:t.firstChild,i&&r!=o.dom&&(i.written=!0),o.dom.parentNode==t)for(;r&&r!=o.dom;)r=bF(r);else t.insertBefore(o.dom,r);n=o.dom}for(r=n?n.nextSibling:t.firstChild,i&&r&&(i.written=!0);r;)r=bF(r);this.length=a}};function bF(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var xF=class extends yF{constructor(e,t){super(t),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let t=vF.get(e);if(t&&this.owns(t))return t;e=e.parentNode}}blockTiles(e){for(let t=[],n=this,r=0,i=0;;)if(r==n.children.length){if(!t.length)return;n=n.parent,n.breakAfter&&i++,r=t.pop()}else{let a=n.children[r++];if(a instanceof SF)t.push(r),n=a,r=0;else{let t=i+a.length,n=e(a,i);if(n!==void 0)return n;i=t+a.breakAfter}}}resolveBlock(e,t){let n,r=-1,i,a=-1;if(this.blockTiles((o,s)=>{let c=s+o.length;if(e>=s&&e<=c){if(o.isWidget()&&t>=-1&&t<=1){if(o.flags&32)return!0;o.flags&16&&(n=void 0)}(s<e||e==c&&(t<-1?o.length:o.covers(1)))&&(!n||!o.isWidget()&&n.isWidget())&&(n=o,r=e-s),(c>e||e==s&&(t>1?o.length:o.covers(-1)))&&(!i||!o.isWidget()&&i.isWidget())&&(i=o,a=e-s)}}),!n&&!i)throw Error(`No tile at position `+e);return n&&t<0||!i?{tile:n,offset:r}:{tile:i,offset:a}}},SF=class e extends yF{constructor(e,t){super(e),this.wrapper=t}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},CF=class e extends yF{constructor(e,t){super(e),this.attrs=t}isLine(){return!0}static start(t,n,r){let i=new e(n||document.createElement(`div`),t);return(!n||!r)&&(i.flags|=4),i}get domAttrs(){return this.attrs}resolveInline(e,t,n=!1){let r=null,i=-1,a=null,o=-1;function s(e,c){for(let l=0,u=0;l<e.children.length&&u<=c;l++){let d=e.children[l],f=u+d.length;f>=c&&(d.isComposite()?s(d,c-u):(!a||n&&a.isHidden&&(t>0&&!(a.flags&32)||n&&TF(a,d)))&&(f>c||d.flags&32&&t<=1)?(a=d,o=c-u):(u<c||d.flags&16&&!(n&&d.isHidden)&&t>=-1)&&(r=d,i=c-u)),u=f}}s(this,e);let c=(t<0?r:a)||r||a;return c?{tile:c,offset:c==r?i:o}:null}coordsIn(e,t,n){let r=this.resolveInline(e,t,!0);return r?r.tile.coordsIn(Math.max(0,r.offset),t,n):wF(this)}domIn(e,t){let n=this.resolveInline(e,t);if(n){let{tile:e,offset:r}=n;if(this.dom.contains(e.dom))return e.isText()?new pP(e.dom,Math.min(e.dom.nodeValue.length,r)):e.domPosFor(r,e.flags&16?1:e.flags&32?-1:t);let i=n.tile.parent,a=!1;for(let e of i.children){if(a)return new pP(e.dom,0);e==n.tile&&(a=!0)}}return new pP(this.dom,0)}};function wF(e){let t=e.dom.lastChild;if(!t)return e.dom.getBoundingClientRect();let n=UN(t);return n[n.length-1]||null}function TF(e,t){let n=e.coordsIn(0,1),r=t.coordsIn(0,1);return n&&r&&r.top<n.bottom}var EF=class e extends yF{constructor(e,t){super(e),this.mark=t}get domAttrs(){return this.mark.attrs}static of(t,n){let r=new e(n||document.createElement(t.tagName),t);return n||(r.flags|=4),r}},DF=class e extends vF{constructor(e,t){super(e,t.length),this.text=t}sync(e){this.flags&2||(super.sync(e),this.dom.nodeValue!=this.text&&(e&&e.node==this.dom&&(e.written=!0),this.dom.nodeValue=this.text))}isText(){return!0}toString(){return JSON.stringify(this.text)}coordsIn(e,t,n){let r=this.dom.nodeValue.length;e>r&&(e=r);let i=e,a=e,o=0;e==0&&t<0||e==r&&t>=0?J.chrome||J.gecko||(e?(i--,o=1):a<r&&(a++,o=-1)):t<0?i--:a<r&&a++;let s=oP(this.dom,i,a).getClientRects();if(!s.length)return null;let c=s[(o?o<0:t>=0)?0:s.length-1];return J.safari&&!o&&c.width==0&&(c=Array.prototype.find.call(s,e=>e.width)||c),n==null?c:YN(c,(o?o>0:t<0)==n)}static of(t,n){let r=new e(n||document.createTextNode(t),t);return n||(r.flags|=2),r}},OF=class e extends vF{constructor(e,t,n,r){super(e,t,r),this.widget=n}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,t){return this.coordsInWidget(e,t,!1)}coordsInWidget(e,t,n){let r=this.widget.coordsAt(this.dom,e,t);if(r)return r;if(n)return YN(this.dom.getBoundingClientRect(),this.length?e==0:t<=0);{let t=this.dom.getClientRects(),n=null;if(!t.length)return null;let r=this.flags&16?!0:this.flags&32?!1:e>0;for(let i=r?t.length-1:0;n=t[i],!(e>0?i==0:i==t.length-1||n.top<n.bottom);i+=r?-1:1);return YN(n,!r)}}get overrideDOMText(){if(!this.length)return sj.empty;let{root:e}=this;if(!e)return sj.empty;let t=this.posAtStart;return e.view.state.doc.slice(t,t+this.length)}destroy(){super.destroy(),this.widget.destroy(this.dom)}static of(t,n,r,i,a){return a||(a=t.toDOM(n),t.editable||(a.contentEditable=`false`)),new e(a,r,t,i)}},kF=class extends vF{constructor(e){let t=document.createElement(`img`);t.className=`cm-widgetBuffer`,t.setAttribute(`aria-hidden`,`true`),super(t,0,e)}get isHidden(){return!0}get overrideDOMText(){return sj.empty}coordsIn(e,t,n){let r=this.dom.getBoundingClientRect();return n==null?r:YN(r,t>0==n)}},AF=class{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,t,n){let{tile:r,index:i,beforeBreak:a,parents:o}=this;for(;e||t>0;)if(!r.isComposite()){let t=r.length;if(i<t&&e){let a=Math.min(e,t-i);n&&n.skip(r,i,i+a),e-=a,i+=a}if(i==t)a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++;else if(!e)break}else if(a){if(!e)break;n&&n.break(),e--,a=!1}else if(i==r.children.length){if(!e&&!o.length)break;n&&n.leave(r),a=!!r.breakAfter,{tile:r,index:i}=o.pop(),i++}else{let s=r.children[i],c=s.breakAfter;(t>0?s.length<=e:s.length<e)&&(!n||n.skip(s,0,s.length)!==!1||!s.isComposite)?(a=!!c,i++,e-=s.length):(o.push({tile:r,index:i}),r=s,i=0,n&&s.isComposite()&&n.enter(s))}return this.tile=r,this.index=i,this.beforeBreak=a,this}get root(){return this.parents.length?this.parents[0].tile:this.tile}},jF=class{constructor(e,t,n,r){this.from=e,this.to=t,this.wrapper=n,this.rank=r}},MF=class{constructor(e,t,n){this.cache=e,this.root=t,this.blockWrappers=n,this.curLine=null,this.lastBlock=null,this.afterWidget=null,this.pos=0,this.wrappers=[],this.wrapperPos=0}addText(e,t,n,r){this.flushBuffer();let i=this.ensureMarks(t,n),a=i.lastChild;if(a&&a.isText()&&!(a.flags&8)&&a.length+e.length<512){this.cache.reused.set(a,2);let t=i.children[i.children.length-1]=new DF(a.dom,a.text+e);t.parent=i}else i.append(r||DF.of(e,this.cache.find(DF)?.dom));this.pos+=e.length,this.afterWidget=null}addComposition(e,t){let n=this.curLine;n.dom!=t.line.dom&&(n.setDOM(this.cache.reused.has(t.line)?HF(t.line.dom):t.line.dom),this.cache.reused.set(t.line,2));let r=n;for(let e=t.marks.length-1;e>=0;e--){let n=t.marks[e],i=r.lastChild;if(i instanceof EF&&i.mark.eq(n.mark))i.dom!=n.dom&&i.setDOM(HF(n.dom)),r=i;else{let{dom:e}=n;this.cache.reused.get(n)&&vF.get(n.dom)&&(e=HF(n.dom));let t=EF.of(n.mark,e);r.append(t),r=t}this.cache.reused.set(n,2)}let i=vF.get(e.text);i&&this.cache.reused.set(i,2);let a=new DF(e.text,e.text.nodeValue);a.flags|=8,this.pos=e.range.toB,r.append(a)}addInlineWidget(e,t,n){let r=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);r||this.flushBuffer();let i=this.ensureMarks(t,n);!r&&!(e.flags&16)&&i.append(this.getBuffer(1)),i.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,t,n){this.flushBuffer(),this.ensureMarks(t,n).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let t=this.afterWidget||this.lastBlock;t.length+=e,this.pos+=e}addLineStart(e,t){e||=zF;let n=CF.start(e,t||this.cache.find(CF)?.dom,!!t);this.getBlockPos().append(this.lastBlock=this.curLine=n)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,t){let n=this.curLine;for(let r=e.length-1;r>=0;r--){let i=e[r],a;if(t>0&&(a=n.lastChild)&&a instanceof EF&&a.mark.eq(i))n=a,t--;else{let e=EF.of(i,this.cache.find(EF,e=>e.mark.eq(i))?.dom);n.append(e),n=e,t=0}}return n}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!LF(this.curLine,!1)||e.dom.nodeName!=`BR`&&e.isWidget()&&!(J.ios&&LF(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(WF,0,32)||new OF(WF.toDOM(),0,WF,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to<this.pos&&this.wrappers.splice(e,1);for(let e=this.blockWrappers;e.value&&e.from<=this.pos;e.next())if(e.to>=this.pos){let t=e.rank*102+e.value.rank,n=new jF(e.from,e.to,e.value,t),r=this.wrappers.length;for(;r>0&&(this.wrappers[r-1].rank-n.rank||this.wrappers[r-1].to-n.to)<0;)r--;this.wrappers.splice(r,0,n)}this.wrapperPos=this.pos}getBlockPos(){this.updateBlockWrappers();let e=this.root;for(let t of this.wrappers){let n=e.lastChild;if(t.from<this.pos&&n instanceof SF&&n.wrapper.eq(t.wrapper))e=n;else{let n=SF.of(t.wrapper,this.cache.find(SF,e=>e.wrapper.eq(t.wrapper))?.dom);e.append(n),e=n}}return e}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let t=2|(e<0?16:32),n=this.cache.find(kF,void 0,1);return n&&(n.flags=t),n||new kF(t)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}},NF=class{constructor(e){this.skipCount=0,this.text=``,this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text=``,this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:t,lineBreak:n,done:r}=this.cursor.next(this.skipCount);if(this.skipCount=0,r)throw Error(`Ran out of text content when drawing inline views`);this.text=t;let i=this.textOff=Math.min(e,t.length);return n?null:t.slice(0,i)}let t=Math.min(this.text.length,this.textOff+e),n=this.text.slice(this.textOff,t);return this.textOff=t,n}},PF=[OF,CF,DF,EF,kF,SF,xF];for(let e=0;e<PF.length;e++)PF[e].bucket=e;var FF=class{constructor(e){this.view=e,this.buckets=PF.map(()=>[]),this.index=PF.map(()=>0),this.reused=new Map}add(e){let t=e.constructor.bucket,n=this.buckets[t];n.length<6?n.push(e):n[this.index[t]=(this.index[t]+1)%6]=e}find(e,t,n=2){let r=e.bucket,i=this.buckets[r],a=this.index[r];for(let e=0;e<i.length;e++){let o=(e+a)%i.length,s=i[o];if((!t||t(s))&&!this.reused.has(s))return i.splice(o,1),o<a&&this.index[r]--,this.reused.set(s,n),s}return null}findWidget(e,t,n){let r=this.buckets[0];if(r.length)for(let i=0,a=0;;i++){if(i==r.length){if(a)return null;a=1,i=0}let o=r[i];if(!this.reused.has(o)&&(a==0?o.widget.compare(e):o.widget.constructor==e.constructor&&e.updateDOM(o.dom,this.view,o.widget)))return r.splice(i,1),i<this.index[0]&&this.index[0]--,o.widget==e&&o.length==t&&(o.flags&497)==n?(this.reused.set(o,1),o):(this.reused.set(o,2),new OF(o.dom,t,e,o.flags&-498|n))}}reuse(e){return this.reused.set(e,1),e}maybeReuse(e,t=2){if(!this.reused.has(e))return this.reused.set(e,t),e.dom}clear(){for(let e=0;e<this.buckets.length;e++)this.buckets[e].length=this.index[e]=0}},IF=class{constructor(e,t,n,r,i){this.view=e,this.decorations=r,this.disallowBlockEffectsFor=i,this.openWidget=!1,this.openMarks=0,this.cache=new FF(e),this.text=new NF(e.state.doc),this.builder=new MF(this.cache,new xF(e,e.contentDOM),NM.iter(n)),this.cache.reused.set(t,2),this.old=new AF(t),this.reuseWalker={skip:(e,t,n)=>{if(this.cache.add(e),e.isComposite())return!1},enter:e=>this.cache.add(e),leave:()=>{},break:()=>{}}}run(e,t){let n=t&&this.getCompositionContext(t.text);for(let r=0,i=0,a=0;;){let o=a<e.length?e[a++]:null,s=o?o.fromA:this.old.root.length;if(s>r){let e=s-r;this.preserve(e,!a,!o),r=s,i+=e}if(!o)break;t&&o.fromA<=t.range.fromA&&o.toA>=t.range.toA?(this.forward(o.fromA,t.range.fromA,t.range.fromA<t.range.toA?1:-1),this.emit(i,t.range.fromB),this.builder.flushBuffer(),this.cache.clear(),this.builder.addComposition(t,n),this.text.skip(t.range.toB-t.range.fromB),this.forward(t.range.fromA,o.toA),this.emit(t.range.toB,o.toB)):(this.forward(o.fromA,o.toA),this.emit(i,o.toB)),i=o.toB,r=o.toA}return this.builder.curLine&&this.builder.endLine(),this.builder.root}preserve(e,t,n){let r=VF(this.old),i=this.openMarks;this.old.advance(e,n?1:-1,{skip:(e,t,n)=>{if(e.isWidget()){if(this.openWidget)this.builder.continueWidget(n-t);else{let a=n>0||t<e.length?OF.of(e.widget,this.view,n-t,e.flags&496,this.cache.maybeReuse(e)):this.cache.reuse(e);a.flags&256?(a.flags&=-2,this.builder.addBlockWidget(a)):(this.builder.ensureLine(null),this.builder.addInlineWidget(a,r,i),i=r.length)}}else if(e.isText())this.builder.ensureLine(null),!t&&n==e.length&&!this.cache.reused.has(e)?this.builder.addText(e.text,r,i,this.cache.reuse(e)):(this.cache.add(e),this.builder.addText(e.text.slice(t,n),r,i)),i=r.length;else if(e.isLine())e.flags&=-2,this.cache.reused.set(e,1),this.builder.addLine(e);else if(e instanceof kF)this.cache.add(e);else if(e instanceof EF)this.builder.ensureLine(null),this.builder.addMark(e,r,i),this.cache.reused.set(e,1),i=r.length;else return!1;this.openWidget=!1},enter:e=>{e.isLine()?this.builder.addLineStart(e.attrs,this.cache.maybeReuse(e)):(this.cache.add(e),e instanceof EF&&r.unshift(e.mark)),this.openWidget=!1},leave:e=>{e.isLine()?r.length&&=i=0:e instanceof EF&&(r.shift(),i=Math.min(i,r.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,t){let n=null,r=this.builder,i=-1,a=NM.spans(this.decorations,e,t,{point:(e,t,a,o,s,c)=>{if(a instanceof NN){if(this.disallowBlockEffectsFor[c]){if(a.block)throw RangeError(`Block decorations may not be specified via plugins`);if(t>this.view.state.doc.lineAt(e).to)throw RangeError(`Decorations that replace line breaks may not be specified via plugins`)}if(i=o.length,s>o.length)r.continueWidget(t-e);else{let i=a.widget||(a.block?UF.block:UF.inline),c=RF(a),l=this.cache.findWidget(i,t-e,c)||OF.of(i,this.view,t-e,c);a.block?(a.startSide>0&&r.addLineStartIfNotCovered(n),r.addBlockWidget(l)):(r.ensureLine(n),r.addInlineWidget(l,o,s))}n=null}else n=BF(n,a);t>e&&this.text.skip(t-e)},span:(e,t,a,o)=>{for(let i=e;i<t;){let s=this.text.next(Math.min(512,t-i));s==null?(r.addLineStartIfNotCovered(n),r.addBreak(),i++):(r.ensureLine(n),r.addText(s,a,i==e?o:a.length),i+=s.length),n=null}i=a.length}});i>-1&&(this.openWidget=a>i),this.openWidget||r.addLineStartIfNotCovered(n),this.openMarks=a}forward(e,t,n=1){t-e<=10?this.old.advance(t-e,n,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(t-e-10,-1),this.old.advance(5,n,this.reuseWalker))}getCompositionContext(e){let t=[],n=null;for(let r=e.parentNode;;r=r.parentNode){let e=vF.get(r);if(r==this.view.contentDOM)break;e instanceof EF?t.push(e):e?.isLine()?n=e:e instanceof SF||(r.nodeName==`DIV`&&!n?n=new CF(r,zF):n||t.push(EF.of(new jN({tagName:r.nodeName.toLowerCase(),attributes:DN(r)}),r)))}return n?{line:n,marks:t}:null}};function LF(e,t){let n=e=>{for(let r of e.children)if((t?r.isText():r.length)||n(r))return!0;return!1};return n(e)}function RF(e){let t=e.isReplace?(e.startSide<0?64:0)|(e.endSide>0?128:0):e.startSide>0?32:16;return e.block&&(t|=256),t}var zF={class:`cm-line`};function BF(e,t){let n=t.spec.attributes,r=t.spec.class;return!n&&!r||(e||={class:`cm-line`},n&&SN(n,e),r&&(e.class+=` `+r)),e}function VF(e){let t=[];for(let n=e.parents.length;n>1;n--){let r=n==e.parents.length?e.tile:e.parents[n].tile;r instanceof EF&&t.push(r.mark)}return t}function HF(e){let t=vF.get(e);return t&&t.setDOM(e.cloneNode()),e}var UF=class extends ON{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}};UF.inline=new UF(`span`),UF.block=new UF(`div`);var WF=new class extends ON{toDOM(){return document.createElement(`br`)}get isHidden(){return!0}get editable(){return!0}},GF=class{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=AN.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new xF(e,e.contentDOM),this.updateInner([new hF(0,0,0,e.state.doc.length)],null)}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:e,toA:t})=>t<this.minWidthFrom||e>this.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.updateEditContextFormatting(e);let n=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(this.domChanged?.newSel?n=this.domChanged.newSel.head:!nI(e.changes,this.hasComposition)&&!e.selectionSet&&(n=e.state.selection.main.head));let r=n>-1?YF(this.view,e.changes,n):null;if(this.domChanged=null,this.hasComposition){let{from:n,to:r}=this.hasComposition;t=new hF(n,r,e.changes.mapPos(n,-1),e.changes.mapPos(r,1)).addToSet(t.slice())}this.hasComposition=r?{from:r.range.fromB,to:r.range.toB}:null,(J.ie||J.chrome)&&!r&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,a=this.blockWrappers;this.updateDeco();let o=QF(i,this.decorations,e.changes);o.length&&(t=hF.extendWithRanges(t,o));let s=eI(a,this.blockWrappers,e.changes);return s.length&&(t=hF.extendWithRanges(t,s)),r&&!t.some(e=>e.fromA<=r.range.fromA&&e.toA>=r.range.toA)&&(t=r.range.addToSet(t.slice())),this.tile.flags&2&&t.length==0?!1:(this.updateInner(t,r),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0;let{observer:n}=this.view;n.ignore(()=>{if(t||e.length){let n=this.tile,r=new IF(this.view,n,this.blockWrappers,this.decorations,this.dynamicDecorationMap);t&&vF.get(t.text)&&r.cache.reused.set(vF.get(t.text),2),this.tile=r.run(e,t),KF(n,r.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+`px`,this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+`px`:``;let r=J.chrome||J.ios?{node:n.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(r),r&&(r.written||n.selectionRange.focusNode!=r.node||!this.tile.dom.contains(r.node))&&(this.forceSelection=!0),this.tile.dom.style.height=``});let r=[];if(this.view.viewport.from||this.view.viewport.to<this.view.state.doc.length)for(let e of this.tile.children)e.isWidget()&&e.widget instanceof rI&&r.push(e.dom);n.updateGaps(r)}updateEditContextFormatting(e){this.editContextFormatting=this.editContextFormatting.map(e.changes);for(let t of e.transactions)for(let e of t.effects)e.is(ZP)&&(this.editContextFormatting=e.value)}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let{dom:n}=this.tile,r=this.view.root.activeElement,i=r==n,a=!i&&!(this.view.state.facet($P)||n.tabIndex>-1)&&HN(n,this.view.observer.selectionRange)&&!(r&&n.contains(r));if(!(i||t||a))return;let o=this.forceSelection;this.forceSelection=!1;let s=this.view.state.selection.main,c,l;if(s.empty?l=c=this.inlineDOMNearPos(s.anchor,s.assoc||1):(l=this.inlineDOMNearPos(s.head,s.head==s.from?1:-1),c=this.inlineDOMNearPos(s.anchor,s.anchor==s.from?1:-1)),J.gecko&&s.empty&&!this.hasComposition&&qF(c)){let e=document.createTextNode(``);this.view.observer.ignore(()=>c.node.insertBefore(e,c.node.childNodes[c.offset]||null)),c=l=new pP(e,0),o=!0}let u=this.view.observer.selectionRange;(o||!u.focusNode||(!WN(c.node,c.offset,u.anchorNode,u.anchorOffset)||!WN(l.node,l.offset,u.focusNode,u.focusOffset))&&!this.suppressWidgetCursorChange(u,s))&&(this.view.observer.ignore(()=>{J.android&&J.chrome&&n.contains(u.focusNode)&&tI(u.focusNode,n)&&(n.blur(),n.focus({preventScroll:!0}));let e=BN(this.view.root);if(e){if(s.empty){if(J.gecko){let e=XF(c.node,c.offset);if(e&&e!=3){let t=(e==1?dP:fP)(c.node,c.offset);t&&(c=new pP(t.node,t.offset))}}e.collapse(c.node,c.offset),s.bidiLevel!=null&&e.caretBidiLevel!==void 0&&(e.caretBidiLevel=s.bidiLevel)}else if(e.extend){e.collapse(c.node,c.offset);try{e.extend(l.node,l.offset)}catch{}}else{let t=document.createRange();s.anchor>s.head&&([c,l]=[l,c]),t.setEnd(l.node,l.offset),t.setStart(c.node,c.offset),e.removeAllRanges(),e.addRange(t)}}a&&this.view.root.activeElement==n&&(n.blur(),r&&r.focus())}),this.view.observer.setSelectionRange(c,l)),this.impreciseAnchor=c.precise?null:new pP(u.anchorNode,u.anchorOffset),this.impreciseHead=l.precise?null:new pP(u.focusNode,u.focusOffset)}suppressWidgetCursorChange(e,t){return this.hasComposition&&t.empty&&WN(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==t.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,t=e.state.selection.main,n=BN(e.root),{anchorNode:r,anchorOffset:i}=e.observer.selectionRange;if(!n||!t.empty||!t.assoc||!n.modify)return;let a=this.lineAt(t.head,t.assoc);if(!a)return;let o=a.posAtStart;if(t.head==o||t.head==o+a.length)return;let s=this.coordsAt(t.head,-1),c=this.coordsAt(t.head,1);if(!s||!c||s.bottom>c.top)return;let l=this.domAtPos(t.head+t.assoc,t.assoc);n.collapse(l.node,l.offset),n.modify(`move`,t.assoc<0?`forward`:`backward`,`lineboundary`),e.observer.readSelectionRange();let u=e.observer.selectionRange;e.docView.posFromDOM(u.anchorNode,u.anchorOffset)!=t.from&&n.collapse(r,i)}posFromDOM(e,t){let n=this.tile.nearest(e);if(!n)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let r=n.posAtStart;if(n.isComposite()){let i;if(e==n.dom)i=n.dom.childNodes[t];else{let r=JN(e)==0?0:t==0?-1:1;for(;;){let t=e.parentNode;if(t==n.dom)break;r==0&&t.firstChild!=t.lastChild&&(r=e==t.firstChild?-1:1),e=t}i=r<0?e:e.nextSibling}if(i==n.dom.firstChild)return r;for(;i&&!vF.get(i);)i=i.nextSibling;if(!i)return r+n.length;for(let e=0,t=r;;e++){let r=n.children[e];if(r.dom==i)return t;t+=r.length+r.breakAfter}}else if(n.isText())return e==n.dom?r+t:r+(t?n.length:0);else return r}domAtPos(e,t){let{tile:n,offset:r}=this.tile.resolveBlock(e,t);return n.isWidget()?n.domPosFor(r,t):n.domIn(r,t)}inlineDOMNearPos(e,t){let n,r=-1,i=!1,a,o=-1,s=!1;return this.tile.blockTiles((t,c)=>{if(t.isWidget()){if(t.flags&32&&c>=e)return!0;t.flags&16&&(i=!0)}else{let l=c+t.length;if(c<=e&&(n=t,r=e-c,i=l<e),l>=e&&!a&&(a=t,o=e-c,s=c>e),c>e&&a)return!0}}),!n&&!a?this.domAtPos(e,t):(i&&a?n=null:s&&n&&(a=null),n&&t<0||!a?n.domIn(r,t):a.domIn(o,t))}coordsAt(e,t,n){let{tile:r,offset:i}=this.tile.resolveBlock(e,t);return r.isWidget()?r.widget instanceof rI?null:r.coordsInWidget(i,t,!0):r.coordsIn(i,t,n)}lineAt(e,t){let{tile:n}=this.tile.resolveBlock(e,t);return n.isLine()?n:null}coordsForChar(e){let{tile:t,offset:n}=this.tile.resolveBlock(e,1);if(!t.isLine())return null;function r(e,t){if(e.isComposite())for(let n of e.children){if(n.length>=t){let e=r(n,t);if(e)return e}if(t-=n.length,t<0)break}else if(e.isText()&&t<e.length){let n=vj(e.text,t);if(n==t)return null;let r=oP(e.dom,t,n).getClientRects();for(let e=0;e<r.length;e++){let t=r[e];if(e==r.length-1||t.top<t.bottom&&t.left<t.right)return t}}return null}return r(t,n)}measureVisibleLineHeights(e){let t=[],{from:n,to:r}=e,i=this.view.contentDOM.clientWidth,a=i>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,o=-1,s=this.view.textDirection==mP.LTR,c=0,l=(e,u,d)=>{for(let f=0;f<e.children.length&&!(u>r);f++){let r=e.children[f],p=u+r.length,m=r.dom.getBoundingClientRect(),{height:h}=m;if(d&&!f&&(c+=m.top-d.top),r instanceof SF)p>n&&l(r,u,m);else if(u>=n&&(c>0&&t.push(-c),t.push(h+c),c=0,a)){let e=r.dom.lastChild,t=e?UN(e):[];if(t.length){let e=t[t.length-1],n=s?e.right-m.left:m.right-e.left;n>o&&(o=n,this.minWidth=i,this.minWidthFrom=u,this.minWidthTo=p)}}d&&f==e.children.length-1&&(c+=d.bottom-m.bottom),u=p+r.breakAfter}};return l(this.tile,0,null),t}textDirectionAt(e){let{tile:t}=this.tile.resolveBlock(e,1);return getComputedStyle(t.dom).direction==`rtl`?mP.RTL:mP.LTR}measureTextSize(){let e=this.tile.blockTiles(e=>{if(e.isLine()&&e.children.length&&e.length<=20){let t=0,n;for(let r of e.children){if(!r.isText()||/[^ -~]/.test(r.text))return;let e=UN(r.dom);if(e.length!=1)return;t+=e[0].width,n=e[0].height}if(t)return{lineHeight:e.dom.getBoundingClientRect().height,charWidth:t/e.length,textHeight:n}}});if(e)return e;let t=document.createElement(`div`),n,r,i;return t.className=`cm-line`,t.style.width=`99999px`,t.style.position=`absolute`,t.textContent=`abc def ghi jkl mno pqr stu`,this.view.observer.ignore(()=>{this.tile.dom.appendChild(t);let e=UN(t.firstChild)[0];n=t.getBoundingClientRect().height,r=e&&e.width?e.width/27:7,i=e&&e.height?e.height:n,t.remove()}),{lineHeight:n,charWidth:r,textHeight:i}}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let n=0,r=0;;r++){let i=r==t.viewports.length?null:t.viewports[r],a=i?i.from-1:this.view.state.doc.length;if(a>n){let r=(t.lineBlockAt(a).bottom-t.lineBlockAt(n).top)/this.view.scaleY;e.push(AN.replace({widget:new rI(r),block:!0,inclusive:!0,isBlockGap:!0}).range(n,a))}if(!i)break;n=i.to+1}return AN.set(e)}updateDeco(){let e=1,t=this.view.state.facet(oF).map(t=>(this.dynamicDecorationMap[e++]=typeof t==`function`)?t(this.view):t),n=!1,r=this.view.state.facet(cF).map((e,t)=>{let r=typeof e==`function`;return r&&(n=!0),r?e(this.view):e});for(r.length&&(this.dynamicDecorationMap[e++]=n,t.push(NM.join(r))),this.decorations=[this.editContextFormatting,...t,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];e<this.decorations.length;)this.dynamicDecorationMap[e++]=!1;this.blockWrappers=this.view.state.facet(sF).map(e=>typeof e==`function`?e(this.view):e)}scrollIntoView(e){if(e.isSnapshot){let t=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=t.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let t of this.view.state.facet(JP))try{if(t(this.view,e.range,e))return!0}catch(e){QP(this.view.state,e,`scroll handler`)}let{range:t}=e,n=this.coordsAt(t.head,t.assoc||(t.head>t.anchor?-1:1)),r;if(!n)return;!t.empty&&(r=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(n={left:Math.min(n.left,r.left),top:Math.min(n.top,r.top),right:Math.max(n.right,r.right),bottom:Math.max(n.bottom,r.bottom)});let i=pF(this.view),a={left:n.left-i.left,top:n.top-i.top,right:n.right+i.right,bottom:n.bottom+i.bottom},{offsetWidth:o,offsetHeight:s}=this.view.scrollDOM;if(QN(this.view.scrollDOM,a,t.head<t.anchor?-1:1,e.x,e.y,Math.max(Math.min(e.xMargin,o),-o),Math.max(Math.min(e.yMargin,s),-s),this.view.textDirection==mP.LTR),window.visualViewport&&window.innerHeight-window.visualViewport.height>1&&(n.top>window.visualViewport.offsetTop+window.visualViewport.height||n.bottom<window.visualViewport.offsetTop)){let e=this.view.docView.lineAt(t.head,1);if(e){let t=tP(e.dom);e.dom.scrollIntoView({block:`nearest`}),nP(t,!1)}}}lineHasWidget(e){let t=e=>e.isWidget()||e.children.some(t);return t(this.tile.resolveBlock(e,1).tile)}destroy(){KF(this.tile)}};function KF(e,t){let n=t?.get(e);if(n!=1){n??e.destroy();for(let n of e.children)KF(n,t)}}function qF(e){return RN(e.node)&&e.node.firstChild&&(e.offset==0||e.node.childNodes[e.offset-1].contentEditable==`false`)&&(e.offset==e.node.childNodes.length||e.node.childNodes[e.offset].contentEditable==`false`)}function JF(e,t){let n=e.observer.selectionRange;if(!n.focusNode)return null;let r=dP(n.focusNode,n.focusOffset),i=fP(n.focusNode,n.focusOffset),a=r||i;if(i&&r&&i.node!=r.node){let t=vF.get(i.node);if(!t||t.isText()&&t.text!=i.node.nodeValue)a=i;else if(e.docView.lastCompositionAfterCursor){let e=vF.get(r.node);!e||e.isText()&&e.text!=r.node.nodeValue||(a=i)}}if(e.docView.lastCompositionAfterCursor=a!=r,!a)return null;let o=t-a.offset;return{from:o,to:o+a.node.nodeValue.length,node:a.node}}function YF(e,t,n){let r=JF(e,n);if(!r)return null;let{node:i,from:a,to:o}=r,s=i.nodeValue;if(/[\n\r]/.test(s)||e.state.doc.sliceString(r.from,r.to)!=s)return null;let c=t.invertedDesc;return{range:new hF(c.mapPos(a),c.mapPos(o),a,o),text:i}}function XF(e,t){return RN(e)?(t&&e.childNodes[t-1].contentEditable==`false`?1:0)|(t<e.childNodes.length&&e.childNodes[t].contentEditable==`false`?2:0):0}var ZF=class{constructor(){this.changes=[]}compareRange(e,t){IN(e,t,this.changes)}comparePoint(e,t){IN(e,t,this.changes)}boundChange(e){IN(e,e,this.changes)}};function QF(e,t,n){let r=new ZF;return NM.compare(e,t,n,r),r.changes}var $F=class{constructor(){this.changes=[]}compareRange(e,t){IN(e,t,this.changes)}comparePoint(){}boundChange(e){IN(e,e,this.changes)}};function eI(e,t,n){let r=new $F;return NM.compare(e,t,n,r),r.changes}function tI(e,t){for(let n=e;n&&n!=t;n=n.assignedSlot||n.parentNode)if(RN(n)&&n.contentEditable==`false`)return!0;return!1}function nI(e,t){let n=!1;return t&&e.iterChangedRanges((e,r)=>{e<t.to&&r>t.from&&(n=!0)}),n}var rI=class extends ON{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement(`div`);return e.className=`cm-gap`,this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+`px`,!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}};function iI(e,t,n=1){let r=e.charCategorizer(t),i=e.doc.lineAt(t),a=t-i.from;if(i.length==0)return q.cursor(t);a==0?n=1:a==i.length&&(n=-1);let o=a,s=a;n<0?o=vj(i.text,a,!1):s=vj(i.text,a);let c=r(i.text.slice(o,s));for(;o>0;){let e=vj(i.text,o,!1);if(r(i.text.slice(e,o))!=c)break;o=e}for(;s<i.length;){let e=vj(i.text,s);if(r(i.text.slice(s,e))!=c)break;s=e}return q.undirectionalRange(o+i.from,s+i.from)}function aI(e,t,n,r,i){let a=Math.round((r-t.left)*e.defaultCharacterWidth);if(e.lineWrapping&&n.height>e.defaultLineHeight*1.5){let t=e.viewState.heightOracle.textHeight,r=Math.floor((i-n.top-(e.defaultLineHeight-t)*.5)/t);a+=r*e.viewState.heightOracle.lineLength}let o=e.state.sliceDoc(n.from,n.to);return n.from+JM(o,a,e.state.tabSize)}function oI(e,t,n){let r=e.lineBlockAt(t);if(Array.isArray(r.type)){let e;for(let i of r.type){if(i.from>t)break;if(!(i.to<t)){if(i.from<t&&i.to>t)return i;(!e||i.type==kN.Text&&(e.type!=i.type||(n<0?i.from<t:i.to>t)))&&(e=i)}}return e||r}return r}function sI(e,t,n,r){let i=oI(e,t.head,t.assoc||-1),a=!r||i.type!=kN.Text||!(e.lineWrapping||i.widgetLineBreaks)?null:e.coordsAtPos(t.assoc<0&&t.head>i.from?t.head-1:t.head);if(a){let t=e.dom.getBoundingClientRect(),r=e.textDirectionAt(i.from),o=e.posAtCoords({x:n==(r==mP.LTR)?t.right-1:t.left+1,y:(a.top+a.bottom)/2});if(o!=null)return q.cursor(o,n?-1:1)}return q.cursor(n?i.to:i.from,n?-1:1)}function cI(e,t,n,r){let i=e.state.doc.lineAt(t.head),a=e.bidiSpans(i),o=e.textDirectionAt(i.from);for(let s=t,c=null;;){let t=FP(i,a,o,s,n),l=PP;if(!t){if(i.number==(n?e.state.doc.lines:1))return s;l=`
65
- `,i=e.state.doc.line(i.number+(n?1:-1)),a=e.bidiSpans(i),t=n?q.cursor(i.from,-1):q.cursor(i.to,1)}if(!c){if(!r)return t;c=r(l)}else if(!c(l))return s;s=t}}function lI(e,t,n){let r=e.state.charCategorizer(t),i=r(n);return e=>{let t=r(e);return i==xM.Space&&(i=t),i==t}}function uI(e,t,n,r){let i=t.head,a=n?1:-1;if(i==(n?e.state.doc.length:0))return q.cursor(i,t.assoc);let o=t.goalColumn,s,c=e.contentDOM.getBoundingClientRect(),l=e.coordsAtPos(i,t.assoc||((t.empty?n:t.head==t.from)?1:-1)),u=e.documentTop;if(l)o??=l.left-c.left,s=a<0?l.top:l.bottom;else{let t=e.viewState.lineBlockAt(i);o??=Math.min(c.right-c.left,e.defaultCharacterWidth*(i-t.from)),s=(a<0?t.top:t.bottom)+u}let d=c.left+o,f=e.viewState.heightOracle.textHeight>>1,p=r??f;for(let t=0;;t+=f){let r=s+(p+t)*a,i=hI(e,{x:d,y:r},!1,a);if(n?r>c.bottom:r<c.top)return q.cursor(i.pos,i.assoc);let l=e.coordsAtPos(i.pos,i.assoc),u=l?(l.top+l.bottom)/2:0;if(!l||(n?u>s:u<s))return q.cursor(i.pos,i.assoc,void 0,o)}}function dI(e,t,n){for(;;){let r=0;for(let i of e)i.between(t-1,t+1,(e,i,a)=>{if(t>e&&t<i){let a=r||n||(t-e<i-t?-1:1);t=a<0?e:i,r=a}});if(!r)return t}}function fI(e,t){let n=null;for(let r=0;r<t.ranges.length;r++){let i=t.ranges[r],a=null;if(i.empty){let t=dI(e,i.from,0);t!=i.from&&(a=q.cursor(t,-1))}else{let t=dI(e,i.from,-1),n=dI(e,i.to,1);(t!=i.from||n!=i.to)&&(a=i.undirectional?q.undirectionalRange(i.from,i.to):q.range(i.from==i.anchor?t:n,i.from==i.head?t:n))}a&&(n||=t.ranges.slice(),n[r]=a)}return n?q.create(n,t.mainIndex):t}function pI(e,t,n){let r=dI(e.state.facet(lF).map(t=>t(e)),n.from,t.head>n.from?-1:1);return r==n.from?n:q.cursor(r,r<n.from?1:-1)}var mI=class{constructor(e,t){this.pos=e,this.assoc=t}};function hI(e,t,n,r){let i=e.contentDOM.getBoundingClientRect(),a=i.top+e.viewState.paddingTop,{x:o,y:s}=t,c=s-a,l;for(;;){if(c<0)return new mI(0,1);if(c>e.viewState.docHeight)return new mI(e.state.doc.length,-1);if(l=e.elementAtHeight(c),r==null)break;if(l.type==kN.Text){if(r<0?l.to<e.viewport.from:l.from>e.viewport.to)break;let t=e.docView.coordsAt(r<0?l.from:l.to,r>0?-1:1);if(t&&(r<0?t.top<=c+a:t.bottom>=c+a))break}let t=e.viewState.heightOracle.textHeight/2;c=r>0?l.bottom+t:l.top-t}if(e.viewport.from>=l.to||e.viewport.to<=l.from){if(n)return null;if(l.type==kN.Text){let t=aI(e,i,l,o,s);return new mI(t,t==l.from?1:-1)}}if(l.type!=kN.Text)return c<(l.top+l.bottom)/2?new mI(l.from,1):new mI(l.to,-1);let u=e.docView.lineAt(l.from,2);return(!u||u.length!=l.length)&&(u=e.docView.lineAt(l.from,-2)),new gI(e,o,s,e.textDirectionAt(l.from)).scanTile(u,l.from)}var gI=class{constructor(e,t,n,r){this.view=e,this.x=t,this.y=n,this.baseDir=r,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to<e)&&(this.line=this.view.state.doc.lineAt(e),this.spans=this.view.bidiSpans(this.line)),this}baseDirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[wP.find(r,e-n.from,-1,t)].level==this.baseDir}dirAt(e,t){let{line:n,spans:r}=this.bidiSpansAt(e);return r[wP.find(r,e-n.from,-1,t)].dir}bidiIn(e,t){let{spans:n,line:r}=this.bidiSpansAt(e);return n.length>1||n.length&&(n[0].level!=this.baseDir||n[0].to+r.from<t)}scan(e,t,n=!1){let r=0,i=e.length-1,a=new Set,o=this.bidiIn(e[0],e[i]),s,c,l=-1,u=1e9,d;search:for(;r<i;){let n=i-r,f=r+i>>1;adjust:if(a.has(f)){for(let e=1;e<n;e++){let t=f+e;if(t>=i&&(t-=n),!a.has(t)){f=t;break adjust}}break search}a.add(f);let p=t(f),m=0;if(p)for(let e=0;e<p.length;e++){let t=p[e];if(!(t.width==0&&p.length>1)){if(t.bottom<this.y)(!s||s.bottom<t.bottom)&&(s=t),m=1;else if(t.top>this.y)(!c||c.top>t.top)&&(c=t),m=-1;else{let e=t.left>this.x?this.x-t.left:t.right<this.x?this.x-t.right:0,n=Math.abs(e);n<u&&(l=f,u=n,d=t),e&&(m=e<0==(this.baseDir==mP.LTR)?-1:1)}}}m==-1&&(!o||this.baseDirAt(e[f],1))?i=f:m==1&&(!o||this.baseDirAt(e[f+1],-1))&&(r=f+1)}if(!d){if(!c&&!s)return{i:0,after:!1};let n=s&&(!c||this.y-s.bottom<c.top-this.y)?s:c;return this.y=(n.top+n.bottom)/2,this.scan(e,t,!0)}if(u&&!n){let{top:n,bottom:r}=d;if(s&&s.bottom>(n+n+r)/3)return this.y=s.bottom-1,this.scan(e,t,!0);if(c&&c.top<(n+r+r)/3)return this.y=c.top+1,this.scan(e,t,!0)}let f=(o?this.dirAt(e[l],1):this.baseDir)==mP.LTR;return{i:l,after:this.x>(d.left+d.right)/2==f}}scanText(e,t){let n=[];for(let r=0;r<e.length;r=vj(e.text,r))n.push(t+r);n.push(t+e.length);let r=this.scan(n,r=>{let i=n[r]-t,a=n[r+1]-t;return oP(e.dom,i,a).getClientRects()});return r.after?new mI(n[r.i+1],-1):new mI(n[r.i],1)}scanTile(e,t){if(!e.length)return new mI(t,1);if(e.children.length==1){let n=e.children[0];if(n.isText())return this.scanText(n,t);if(n.isComposite())return this.scanTile(n,t)}let n=[t];for(let r=0,i=t;r<e.children.length;r++)n.push(i+=e.children[r].length);let r=this.scan(n,t=>{let n=e.children[t];return n.flags&48?null:(RN(n.dom)?n.dom:oP(n.dom,0,n.length)).getClientRects()}),i=e.children[r.i],a=n[r.i];return i.isText()?this.scanText(i,a):i.isComposite()?this.scanTile(i,a):r.after?new mI(n[r.i+1],-1):new mI(a,1)}},_I=`￿`,vI=class{constructor(e,t){this.points=e,this.view=t,this.text=``,this.lineSeparator=t.state.facet(EM.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=_I}readRange(e,t){if(!e)return this;let n=e.parentNode;for(let r=e;;){this.findPointBefore(n,r);let e=this.text.length;this.readNode(r);let i=vF.get(r),a=r.nextSibling;if(a==t){i?.breakAfter&&!a&&n!=this.view.contentDOM&&this.lineBreak();break}let o=vF.get(a);(i&&o?i.breakAfter:(i?i.breakAfter:KN(r))||KN(a)&&(r.nodeName!=`BR`||i?.isWidget())&&this.text.length>e)&&!bI(a,t)&&this.lineBreak(),r=a}return this.findPointBefore(n,t),this}readTextNode(e){let t=e.nodeValue;for(let n of this.points)n.node==e&&(n.pos=this.text.length+Math.min(n.offset,t.length));for(let n=0,r=this.lineSeparator?null:/\r\n?|\n/g;;){let i=-1,a=1,o;if(this.lineSeparator?(i=t.indexOf(this.lineSeparator,n),a=this.lineSeparator.length):(o=r.exec(t))&&(i=o.index,a=o[0].length),this.append(t.slice(n,i<0?t.length:i)),i<0)break;if(this.lineBreak(),a>1)for(let t of this.points)t.node==e&&t.pos>this.text.length&&(t.pos-=a-1);n=i+a}}readNode(e){let t=vF.get(e),n=t&&t.overrideDOMText;if(n!=null){this.findPointInside(e,n.length);for(let e=n.iter();!e.next().done;)e.lineBreak?this.lineBreak():this.append(e.value)}else zN(e)?this.readTextNode(e):e.nodeName==`BR`?e.nextSibling&&this.lineBreak():RN(e)&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let n of this.points)n.node==e&&e.childNodes[n.offset]==t&&(n.pos=this.text.length)}findPointInside(e,t){for(let n of this.points)(zN(e)?n.node==e:e.contains(n.node))&&(n.pos=this.text.length+(yI(e,n.node,n.offset)?t:0))}};function yI(e,t,n){for(;;){if(!t||n<JN(t))return!1;if(t==e)return!0;n=GN(t)+1,t=t.parentNode}}function bI(e,t){let n;for(;e!=t&&e;e=e.nextSibling){let t=vF.get(e);if(!t?.isWidget())return!1;t&&(n||=[]).push(t)}if(n){for(let e of n)if(e.overrideDOMText?.length)return!1}return!0}var xI=class{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}},SI=class{constructor(e,t,n,r){this.typeOver=r,this.bounds=null,this.text=``,this.domChanged=t>-1;let{impreciseHead:i,impreciseAnchor:a}=e.docView,o=e.state.selection;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=CI(e.docView.tile,t,n,0))){let t=i||a?[]:OI(e),n=new vI(t,e);n.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=n.text,this.newSel=kI(t,this.bounds.from)}else{let t=e.observer.selectionRange,n=i&&i.node==t.focusNode&&i.offset==t.focusOffset||!VN(e.contentDOM,t.focusNode)?o.main.head:e.docView.posFromDOM(t.focusNode,t.focusOffset),r=a&&a.node==t.anchorNode&&a.offset==t.anchorOffset||!VN(e.contentDOM,t.anchorNode)?o.main.anchor:e.docView.posFromDOM(t.anchorNode,t.anchorOffset),s=e.viewport;if((J.ios||J.chrome)&&n!=r&&Math.min(n,r)<=o.main.from&&Math.max(n,r)>=o.main.to&&(s.from>0||s.to<e.state.doc.length)){let t=Math.min(n,r),i=Math.max(n,r),a=s.from-t,o=s.to-i;(a==0||a==1||t==0)&&(o==0||o==-1||i==e.state.doc.length)&&(n=0,r=e.state.doc.length)}if(e.inputState.composing>-1&&o.ranges.length>1)this.newSel=o.replaceRange(q.range(r,n));else if(e.lineWrapping&&r==n&&!(o.main.empty&&o.main.head==n)&&e.inputState.lastTouchTime>Date.now()-100){let t=e.coordsAtPos(n,-1),r=0;t&&(r=e.inputState.lastTouchY<=t.bottom?-1:1),this.newSel=q.create([q.cursor(n,r)])}else this.newSel=q.single(r,n)}}};function CI(e,t,n,r){if(e.isComposite()){let i=-1,a=-1,o=-1,s=-1;for(let c=0,l=r,u=r;c<e.children.length;c++){let r=e.children[c],d=l+r.length;if(l<t&&d>n)return CI(r,t,n,l);if(d>=t&&i==-1&&(i=c,a=l),l>n&&r.dom.parentNode==e.dom){o=c,s=u;break}u=d,l=d+r.breakAfter}return{from:a,to:s<0?r+e.length:s,startDOM:(i?e.children[i-1].dom.nextSibling:null)||e.dom.firstChild,endDOM:o<e.children.length&&o>=0?e.children[o].dom:null}}return e.isText()?{from:r,to:r+e.length,startDOM:e.dom,endDOM:e.dom.nextSibling}:null}function wI(e,t){let n,{newSel:r}=t,{state:i}=e,a=i.selection.main,o=e.inputState.lastKeyTime>Date.now()-100?e.inputState.lastKeyCode:-1;if(t.bounds){let{from:e,to:r}=t.bounds,s=a.from,c=null;(o===8||J.android&&t.text.length<r-e)&&(s=a.to,c=`end`);let l=i.doc.sliceString(e,r,_I),u,d;!a.empty&&a.from>=e&&a.to<=r&&(t.typeOver||l!=t.text)&&l.slice(0,a.from-e)==t.text.slice(0,a.from-e)&&l.slice(a.to-e)==t.text.slice(u=t.text.length-(l.length-(a.to-e)))?n={from:a.from,to:a.to,insert:sj.of(t.text.slice(a.from-e,u).split(_I))}:(d=DI(l,t.text,s-e,c))&&(J.chrome&&o==13&&d.toB==d.from+2&&t.text.slice(d.from,d.toB)==`￿￿`&&d.toB--,n={from:e+d.from,to:e+d.toA,insert:sj.of(t.text.slice(d.from,d.toB).split(_I))})}else r&&(!e.hasFocus&&i.facet($P)||AI(r,a))&&(r=null);if(!n&&!r)return!1;if((J.mac||J.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&e.contentDOM.getAttribute(`autocorrect`)==`off`?(r&&n.insert.length==2&&(r=q.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:sj.of([n.insert.toString().replace(`.`,` `)])}):i.doc.lineAt(a.from).to<a.to&&e.docView.lineHasWidget(a.to)&&e.inputState.insertingTextAt>Date.now()-50?n={from:a.from,to:a.to,insert:i.toText(e.inputState.insertingText)}:J.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==`
66
- `&&e.lineWrapping&&(r&&=q.single(r.main.anchor-1,r.main.head-1),n={from:a.from,to:a.to,insert:sj.of([` `])}),n)return TI(e,n,r,o);if(r&&!AI(r,a)){let t=!1,n=`select`;return e.inputState.lastSelectionTime>Date.now()-50&&(e.inputState.lastSelectionOrigin==`select`&&(t=!0),n=e.inputState.lastSelectionOrigin,n==`select.pointer`&&(r=fI(i.facet(lF).map(t=>t(e)),r))),e.dispatch({selection:r,scrollIntoView:t,userEvent:n}),!0}return!1}function TI(e,t,n,r=-1){if(J.ios&&e.inputState.flushIOSKey(t))return!0;let i=e.state.selection.main;if(J.android&&(t.to==i.to&&(t.from==i.from||t.from==i.from-1&&e.state.sliceDoc(t.from,i.from)==` `)&&t.insert.length==1&&t.insert.lines==2&&sP(e.contentDOM,`Enter`,13)||(t.from==i.from-1&&t.to==i.to&&t.insert.length==0||r==8&&t.insert.length<t.to-t.from&&t.to>i.head)&&sP(e.contentDOM,`Backspace`,8)||t.from==i.from&&t.to==i.to+1&&t.insert.length==0&&sP(e.contentDOM,`Delete`,46)))return!0;let a=t.insert.toString();e.inputState.composing>=0&&e.inputState.composing++;let o,s=()=>o||=EI(e,t,n);return e.state.facet(HP).some(n=>n(e,t.from,t.to,a,s))||e.dispatch(s()),!0}function EI(e,t,n){let r,i=e.state,a=i.selection.main,o=-1;if(t.from==t.to&&t.from<a.from||t.from>a.to){let n=t.from<a.from?-1:1,r=n<0?a.from:a.to,s=dI(i.facet(lF).map(t=>t(e)),r,n);t.from==s&&(o=s)}if(o>-1)r={changes:t,selection:q.cursor(t.from+t.insert.length,-1)};else if(t.from>=a.from&&t.to<=a.to&&t.to-t.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==t.from+t.insert.length)&&e.inputState.composing<0){let n=a.from<t.from?i.sliceDoc(a.from,t.from):``,o=a.to>t.to?i.sliceDoc(t.to,a.to):``;r=i.replaceSelection(e.state.toText(n+t.insert.sliceString(0,void 0,e.state.lineBreak)+o))}else{let o=i.changes(t),s=n&&n.main.to<=o.newLength?n.main:void 0;if(i.selection.ranges.length>1&&(e.inputState.composing>=0||e.inputState.compositionPendingChange)&&t.to<=a.to+10&&t.to>=a.to-10){let c=e.state.sliceDoc(t.from,t.to),l,u=n&&JF(e,n.main.head);if(u){let e=t.insert.length-(t.to-t.from);l={from:u.from,to:u.to-e}}else l=e.state.doc.lineAt(a.head);let d=a.to-t.to;r=i.changeByRange(n=>{if(n.from==a.from&&n.to==a.to)return{changes:o,range:s||n.map(o)};let r=n.to-d,u=r-c.length;if(e.state.sliceDoc(u,r)!=c||r>=l.from&&u<=l.to)return{range:n};let f=i.changes({from:u,to:r,insert:t.insert}),p=n.to-a.to;return{changes:f,range:s?q.range(Math.max(0,s.anchor+p),Math.max(0,s.head+p)):n.map(f)}})}else r={changes:o,selection:s&&i.selection.replaceRange(s)}}let s=`input.type`;return(e.composing||e.inputState.compositionPendingChange&&e.inputState.compositionEndedAt>Date.now()-50)&&(e.inputState.compositionPendingChange=!1,s+=`.compose`,e.inputState.compositionFirstChange&&(s+=`.start`,e.inputState.compositionFirstChange=!1)),i.update(r,{userEvent:s,scrollIntoView:!0})}function DI(e,t,n,r){let i=Math.min(e.length,t.length),a=0;for(;a<i&&e.charCodeAt(a)==t.charCodeAt(a);)a++;if(a==i&&e.length==t.length)return null;let o=e.length,s=t.length;for(;o>0&&s>0&&e.charCodeAt(o-1)==t.charCodeAt(s-1);)o--,s--;if(r==`end`){let e=Math.max(0,a-Math.min(o,s));n-=o+e-a}if(o<a&&e.length<t.length){let e=n<=a&&n>=o?a-n:0;a-=e,s=a+(s-o),o=a}else if(s<a){let e=n<=a&&n>=s?a-n:0;a-=e,o=a+(o-s),s=a}return{from:a,toA:o,toB:s}}function OI(e){let t=[];if(e.root.activeElement!=e.contentDOM)return t;let{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}=e.observer.selectionRange;return n&&(t.push(new xI(n,r)),(i!=n||a!=r)&&t.push(new xI(i,a))),t}function kI(e,t){if(e.length==0)return null;let n=e[0].pos,r=e.length==2?e[1].pos:n;return n<0||r<0?null:n==r?q.create([q.cursor(r+t,-1)]):q.single(n+t,r+t)}function AI(e,t){return t.head==e.main.head&&t.anchor==e.main.anchor}var jI=class{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText=``,this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,J.safari&&e.contentDOM.addEventListener(`input`,()=>null),J.gecko&&mL(e.contentDOM.ownerDocument)}handleEvent(e){GI(this.view,e)&&!this.ignoreDuringComposition(e)&&(e.type==`keydown`&&this.keydown(e)||(this.view.updateState==0?this.runHandlers(e.type,e):Promise.resolve().then(()=>this.runHandlers(e.type,e))))}runHandlers(e,t){let n=this.handlers[e];if(n){for(let e of n.observers)e(this.view,t);for(let e of n.handlers){if(t.defaultPrevented)break;if(e(this.view,t)){t.preventDefault();break}}}}ensureHandlers(e){let t=PI(e),n=this.handlers,r=this.view.contentDOM;for(let e in t)if(e!=`scroll`){let i=!t[e].handlers.length,a=n[e];a&&i!=!a.handlers.length&&(r.removeEventListener(e,this.handleEvent),a=null),a||r.addEventListener(e,this.handleEvent,{passive:i})}for(let e in n)e!=`scroll`&&!t[e]&&r.removeEventListener(e,this.handleEvent);this.handlers=t}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&LI.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),J.android&&J.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(J.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(FI.some(t=>t.keyCode==e.keyCode)&&!e.ctrlKey||II.indexOf(e.key)>-1&&e.ctrlKey)){let t={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};t.shiftKey&&J.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&MI(this.view.win)&&(t.shiftKey=!1);let n=this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:t};return setTimeout(()=>{this.pendingIOSKey==n&&this.flushIOSKey()},50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let t=this.pendingIOSKey;return!t||this.view.observer.pendingRecords().length||t.key==`Enter`&&e&&e.from<e.to&&/^\S+$/.test(e.insert.toString())?!1:(this.pendingIOSKey=void 0,sP(this.view.contentDOM,t.key,t.keyCode,t.mods))}ignoreDuringComposition(e){return!/^key/.test(e.type)||e.synthetic?!1:this.composing>0?!0:J.safari&&!J.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}};function MI(e){return e.visualViewport?e.visualViewport.height*e.visualViewport.scale/e.document.documentElement.clientHeight<.85:!1}function NI(e,t){return(n,r)=>{try{return t.call(e,r,n)}catch(e){QP(n.state,e)}}}function PI(e){let t=Object.create(null);function n(e){return t[e]||(t[e]={observers:[],handlers:[]})}for(let t of e){let e=t.spec,r=e&&e.plugin.domEventHandlers,i=e&&e.plugin.domEventObservers;if(r)for(let e in r){let i=r[e];i&&n(e).handlers.push(NI(t.value,i))}if(i)for(let e in i){let r=i[e];r&&n(e).observers.push(NI(t.value,r))}}for(let e in KI)n(e).handlers.push(KI[e]);for(let e in qI)n(e).observers.push(qI[e]);return t}var FI=[{key:`Backspace`,keyCode:8,inputType:`deleteContentBackward`},{key:`Enter`,keyCode:13,inputType:`insertParagraph`},{key:`Enter`,keyCode:13,inputType:`insertLineBreak`},{key:`Delete`,keyCode:46,inputType:`deleteContentForward`}],II=`dthko`,LI=[16,17,18,20,91,92,224,225],RI=6;function zI(e){return Math.max(0,e)*.7+8}function BI(e,t){return Math.max(Math.abs(e.clientX-t.clientX),Math.abs(e.clientY-t.clientY))}var VI=class{constructor(e,t,n,r){this.view=e,this.startEvent=t,this.style=n,this.mustSelect=r,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParents=$N(e.contentDOM),this.atoms=e.state.facet(lF).map(t=>t(e));let i=e.contentDOM.ownerDocument;i.addEventListener(`mousemove`,this.move=this.move.bind(this)),i.addEventListener(`mouseup`,this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(EM.allowMultipleSelections)&&HI(e,t),this.dragging=WI(e,t)&&rL(t)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&BI(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let t=0,n=0,r=0,i=0,a=this.view.win.innerWidth,o=this.view.win.innerHeight;this.scrollParents.x&&({left:r,right:a}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:i,bottom:o}=this.scrollParents.y.getBoundingClientRect());let s=pF(this.view);e.clientX-s.left<=r+RI?t=-zI(r-e.clientX):e.clientX+s.right>=a-RI&&(t=zI(e.clientX-a)),e.clientY-s.top<=i+RI?n=-zI(i-e.clientY):e.clientY+s.bottom>=o-RI&&(n=zI(e.clientY-o)),this.setScrollSpeed(t,n)}up(e){this.dragging??this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener(`mousemove`,this.move),e.removeEventListener(`mouseup`,this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:t}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),t&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=t,t=0),(e||t)&&this.view.win.scrollBy(e,t),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:t}=this,n=fI(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!n.eq(t.state.selection,this.dragging===!1))&&this.view.dispatch({selection:n,userEvent:`select.pointer`}),this.mustSelect=!1}update(e){e.transactions.some(e=>e.isUserEvent(`input.type`))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}};function HI(e,t){let n=e.state.facet(LP);return n.length?n[0](t):J.mac?t.metaKey:t.ctrlKey}function UI(e,t){let n=e.state.facet(RP);return n.length?n[0](t):J.mac?!t.altKey:!t.ctrlKey}function WI(e,t){let{main:n}=e.state.selection;if(n.empty)return!1;let r=BN(e.root);if(!r||r.rangeCount==0)return!0;let i=r.getRangeAt(0).getClientRects();for(let e=0;e<i.length;e++){let n=i[e];if(n.left<=t.clientX&&n.right>=t.clientX&&n.top<=t.clientY&&n.bottom>=t.clientY)return!0}return!1}function GI(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target,r;n!=e.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=vF.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(t))return!1;return!0}var KI=Object.create(null),qI=Object.create(null),JI=J.ie&&J.ie_version<15||J.ios&&J.webkit_version<604;function YI(e){let t=e.dom.parentNode;if(!t)return;let n=t.appendChild(document.createElement(`textarea`));n.style.cssText=`position: fixed; left: -10000px; top: 10px`,n.focus(),setTimeout(()=>{e.focus(),n.remove(),ZI(e,n.value)},50)}function XI(e,t,n){for(let r of e.facet(t))n=r(n,e);return n}function ZI(e,t){t=XI(e.state,WP,t);let{state:n}=e,r,i=1,a=n.toText(t),o=a.lines==n.selection.ranges.length;if(lL!=null&&n.selection.ranges.every(e=>e.empty)&&lL==a.toString()){let e=-1;r=n.changeByRange(r=>{let s=n.doc.lineAt(r.from);if(s.from==e)return{range:r};e=s.from;let c=n.toText((o?a.line(i++).text:t)+n.lineBreak);return{changes:{from:s.from,insert:c},range:q.cursor(r.from+c.length,-1)}})}else r=o?n.changeByRange(e=>{let t=a.line(i++);return{changes:{from:e.from,to:e.to,insert:t.text},range:q.cursor(e.from+t.length,-1)}}):n.replaceSelection(a);e.dispatch(r,{userEvent:`input.paste`,scrollIntoView:!0})}qI.scroll=e=>{let t=e.inputState;t.lastScrollTop=e.scrollDOM.scrollTop,t.lastScrollLeft=e.scrollDOM.scrollLeft,J.ios&&!t.touchActive&&(t.lastIOSMomentumScroll=Date.now())},qI.wheel=qI.mousewheel=e=>{e.inputState.lastWheelEvent=Date.now()},KI.keydown=(e,t)=>(e.inputState.setSelectionOrigin(`select`),t.keyCode==27&&e.inputState.tabFocusMode!=0&&(e.inputState.tabFocusMode=Date.now()+2e3),!1),qI.touchstart=(e,t)=>{let n=e.inputState,r=t.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin(`select.pointer`)},qI.touchmove=e=>{e.inputState.setSelectionOrigin(`select.pointer`)},qI.touchend=(e,t)=>{e.inputState.touchActive=!1},KI.mousedown=(e,t)=>{if(e.observer.flush(),e.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of e.state.facet(zP))if(n=r(e,t),n)break;if(!n&&t.button==0&&(n=iL(e,t)),n){let r=!e.hasFocus;e.inputState.startMouseSelection(new VI(e,t,n,r)),r&&e.observer.ignore(()=>{iP(e.contentDOM);let t=e.root.activeElement;t&&!t.contains(e.contentDOM)&&t.blur()});let i=e.inputState.mouseSelection;if(i)return i.start(t),i.dragging===!1}else e.inputState.setSelectionOrigin(`select.pointer`);return!1};function QI(e,t,n,r){if(r==1)return q.cursor(t,n);if(r==2)return iI(e.state,t,n);{let r=e.docView.lineAt(t,n),i=e.state.doc.lineAt(r?r.posAtEnd:t),a=r?r.posAtStart:i.from,o=r?r.posAtEnd:i.to;return o<e.state.doc.length&&o==i.to&&o++,q.undirectionalRange(a,o)}}var $I=J.ie&&J.ie_version<=11,eL=null,tL=0,nL=0;function rL(e){if(!$I)return e.detail;let t=eL,n=nL;return eL=e,nL=Date.now(),tL=!t||n>Date.now()-400&&Math.abs(t.clientX-e.clientX)<2&&Math.abs(t.clientY-e.clientY)<2?(tL+1)%3:1}function iL(e,t){let n=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),r=rL(t),i=e.state.selection;return{update(e){e.docChanged&&(n.pos=e.changes.mapPos(n.pos),i=i.map(e.changes))},get(t,a,o){let s=e.posAndSideAtCoords({x:t.clientX,y:t.clientY},!1),c,l=QI(e,s.pos,s.assoc,r);if(n.pos!=s.pos&&!a){let t=QI(e,n.pos,n.assoc,r),i=Math.min(t.from,l.from),a=Math.max(t.to,l.to);l=i<l.from?q.range(i,a,l.assoc):q.range(a,i,l.assoc)}return a?i.replaceRange(i.main.extend(l.from,l.to,l.assoc)):o&&r==1&&i.ranges.length>1&&(c=aL(i,s.pos))?c:o?i.addRange(l):q.create([l])}}}function aL(e,t){for(let n=0;n<e.ranges.length;n++){let{from:r,to:i}=e.ranges[n];if(r<=t&&i>=t)return q.create(e.ranges.slice(0,n).concat(e.ranges.slice(n+1)),e.mainIndex==n?0:e.mainIndex-+(e.mainIndex>n))}return null}KI.dragstart=(e,t)=>{let{selection:{main:n}}=e.state;if(t.target.draggable){let r=e.docView.tile.nearest(t.target);if(r&&r.isWidget()){let e=r.posAtStart,t=e+r.length;(e>=n.to||t<=n.from)&&(n=q.undirectionalRange(e,t))}}let{inputState:r}=e;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,t.dataTransfer&&(t.dataTransfer.setData(`Text`,XI(e.state,GP,e.state.sliceDoc(n.from,n.to))),t.dataTransfer.effectAllowed=`copyMove`),!1},KI.dragend=e=>(e.inputState.draggedContent=null,!1);function oL(e,t,n,r){if(n=XI(e.state,WP,n),!n)return;let i=e.posAtCoords({x:t.clientX,y:t.clientY},!1),{draggedContent:a}=e.inputState,o=r&&a&&UI(e,t)?{from:a.from,to:a.to}:null,s={from:i,insert:n},c=e.state.changes(o?[o,s]:s);e.focus(),e.dispatch({changes:c,selection:{anchor:c.mapPos(i,-1),head:c.mapPos(i,1)},userEvent:o?`move.drop`:`input.drop`}),e.inputState.draggedContent=null}KI.drop=(e,t)=>{if(!t.dataTransfer)return!1;if(e.state.readOnly)return!0;let n=t.dataTransfer.files;if(n&&n.length){let r=Array(n.length),i=0,a=()=>{++i==n.length&&oL(e,t,r.filter(e=>e!=null).join(e.state.lineBreak),!1)};for(let e=0;e<n.length;e++){let t=new FileReader;t.onerror=a,t.onload=()=>{/[\x00-\x08\x0e-\x1f]{2}/.test(t.result)||(r[e]=t.result),a()},t.readAsText(n[e])}return!0}{let n=t.dataTransfer.getData(`Text`);if(n)return oL(e,t,n,!0),!0}return!1},KI.paste=(e,t)=>{if(e.state.readOnly)return!0;e.observer.flush();let n=JI?null:t.clipboardData;return n?(ZI(e,n.getData(`text/plain`)||n.getData(`text/uri-list`)),!0):(YI(e),!1)};function sL(e,t){let n=e.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement(`textarea`));r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.value=t,r.focus(),r.selectionEnd=t.length,r.selectionStart=0,setTimeout(()=>{r.remove(),e.focus()},50)}function cL(e){let t=[],n=[],r=!1;for(let r of e.selection.ranges)r.empty||(t.push(e.sliceDoc(r.from,r.to)),n.push(r));if(!t.length){let i=-1;for(let{from:r}of e.selection.ranges){let a=e.doc.lineAt(r);a.number>i&&(t.push(a.text),n.push({from:a.from,to:Math.min(e.doc.length,a.to+1)})),i=a.number}r=!0}return{text:XI(e,GP,t.join(e.lineBreak)),ranges:n,linewise:r}}var lL=null;KI.copy=KI.cut=(e,t)=>{if(!HN(e.contentDOM,e.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:i}=cL(e.state);if(!n&&!i)return!1;lL=i?n:null,t.type==`cut`&&!e.state.readOnly&&e.dispatch({changes:r,scrollIntoView:!0,userEvent:`delete.cut`});let a=JI?null:t.clipboardData;return a?(a.clearData(),a.setData(`text/plain`,n),!0):(sL(e,n),!1)};var uL=cM.define();function dL(e,t){let n=[];for(let r of e.facet(UP)){let i=r(e,t);i&&n.push(i)}return n.length?e.update({effects:n,annotations:uL.of(!0)}):null}function fL(e){setTimeout(()=>{let t=e.hasFocus;if(t!=e.inputState.notifiedFocused){let n=dL(e.state,t);n?e.dispatch(n):e.update([])}},10)}qI.focus=e=>{e.inputState.lastFocusTime=Date.now(),!e.scrollDOM.scrollTop&&(e.inputState.lastScrollTop||e.inputState.lastScrollLeft)&&(e.scrollDOM.scrollTop=e.inputState.lastScrollTop,e.scrollDOM.scrollLeft=e.inputState.lastScrollLeft),fL(e)},qI.blur=e=>{e.observer.clearSelectionRange(),fL(e)},qI.compositionstart=qI.compositionupdate=(e,t)=>{if(!e.observer.editContext&&(e.inputState.compositionFirstChange??(e.inputState.compositionFirstChange=!0),e.inputState.composing<0)){let{main:t}=e.state.selection;!t.empty&&e.lineBlockAt(t.from).from!=e.lineBlockAt(t.to).from&&!e.state.readOnly&&e.dispatch({changes:e.state.selection.ranges.filter(e=>!e.empty).map(e=>({from:e.from,to:e.to})),userEvent:`input`}),e.inputState.composing=0}},qI.compositionend=e=>{e.observer.editContext||(e.inputState.composing=-1,e.inputState.compositionEndedAt=Date.now(),e.inputState.compositionPendingKey=!0,e.inputState.compositionPendingChange=e.observer.pendingRecords().length>0,e.inputState.compositionFirstChange=null,J.chrome&&J.android?e.observer.flushSoon():e.inputState.compositionPendingChange?Promise.resolve().then(()=>e.observer.flush()):setTimeout(()=>{e.inputState.composing<0&&e.docView.hasComposition&&e.update([])},50))},qI.contextmenu=e=>{e.inputState.lastContextMenu=Date.now()},KI.beforeinput=(e,t)=>{if((t.inputType==`insertText`||t.inputType==`insertCompositionText`)&&(e.inputState.insertingText=t.data,e.inputState.insertingTextAt=Date.now()),t.inputType==`insertReplacementText`&&e.observer.editContext){let n=t.dataTransfer?.getData(`text/plain`),r=t.getTargetRanges();if(n&&r.length){let t=r[0];return TI(e,{from:e.posAtDOM(t.startContainer,t.startOffset),to:e.posAtDOM(t.endContainer,t.endOffset),insert:e.state.toText(n)},null),!0}}let n;if(J.chrome&&J.android&&(n=FI.find(e=>e.inputType==t.inputType))&&(e.observer.delayAndroidKey(n.key,n.keyCode),n.key==`Backspace`||n.key==`Delete`)){let t=window.visualViewport?.height||0;setTimeout(()=>{(window.visualViewport?.height||0)>t+10&&e.hasFocus&&(e.contentDOM.blur(),e.focus())},100)}return J.ios&&t.inputType==`deleteContentForward`&&e.observer.flushSoon(),J.safari&&t.inputType==`insertText`&&e.inputState.composing>=0&&setTimeout(()=>qI.compositionend(e,t),20),!1};var pL=new Set;function mL(e){pL.has(e)||(pL.add(e),e.addEventListener(`copy`,()=>{}),e.addEventListener(`cut`,()=>{}))}var hL=[`pre-wrap`,`normal`,`pre-line`,`break-spaces`],gL=!1;function _L(){gL=!1}var vL=class{constructor(e){this.lineWrapping=e,this.doc=sj.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,t){let n=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(n+=Math.max(0,Math.ceil((t-e-n*this.lineLength*.5)/this.lineLength))),this.lineHeight*n}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return hL.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r<0?n++:this.heightSamples[Math.floor(r*10)]||(t=!0,this.heightSamples[Math.floor(r*10)]=!0)}return t}refresh(e,t,n,r,i,a){let o=hL.indexOf(e)>-1,s=Math.abs(t-this.lineHeight)>.3||this.lineWrapping!=o;if(this.lineWrapping=o,this.lineHeight=t,this.charWidth=n,this.textHeight=r,this.lineLength=i,s){this.heightSamples={};for(let e=0;e<a.length;e++){let t=a[e];t<0?e++:this.heightSamples[Math.floor(t*10)]=!0}}return s}},yL=class{constructor(e,t){this.from=e,this.heights=t,this.index=0}get more(){return this.index<this.heights.length}},bL=class e{constructor(e,t,n,r,i){this.from=e,this.length=t,this.top=n,this.height=r,this._content=i}get type(){return typeof this._content==`number`?kN.Text:Array.isArray(this._content)?this._content:this._content.type}get to(){return this.from+this.length}get bottom(){return this.top+this.height}get widget(){return this._content instanceof NN?this._content.widget:null}get widgetLineBreaks(){return typeof this._content==`number`?this._content:0}join(t){let n=(Array.isArray(this._content)?this._content:[this]).concat(Array.isArray(t._content)?t._content:[t]);return new e(this.from,this.length+t.length,this.top,this.height+t.height,n)}},xL=(function(e){return e[e.ByPos=0]=`ByPos`,e[e.ByHeight=1]=`ByHeight`,e[e.ByPosNoHeight=2]=`ByPosNoHeight`,e})(xL||={}),SL=.001,CL=class e{constructor(e,t,n=2){this.length=e,this.height=t,this.flags=n}get outdated(){return(this.flags&2)>0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>SL&&(gL=!0),this.height=e)}replace(t,n,r){return e.of(r)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,n,r){let i=this,a=n.doc;for(let o=r.length-1;o>=0;o--){let{fromA:s,toA:c,fromB:l,toB:u}=r[o],d=i.lineAt(s,xL.ByPosNoHeight,n.setDoc(t),0,0),f=d.to>=c?d:i.lineAt(c,xL.ByPosNoHeight,n,0,0);for(u+=f.to-c,c=f.to;o>0&&d.from<=r[o-1].toA;)s=r[o-1].fromA,l=r[o-1].fromB,o--,s<d.from&&(d=i.lineAt(s,xL.ByPosNoHeight,n,0,0));l+=d.from-s,s=d.from;let p=ML.build(n.setDoc(a),e,l,u);i=wL(i,i.replace(s,c,p))}return i.updateHeight(n,0)}static empty(){return new DL(0,0,0)}static of(t){if(t.length==1)return t[0];let n=0,r=t.length,i=0,a=0;for(;;)if(n==r){if(i>a*2){let e=t[n-1];e.break?t.splice(--n,1,e.left,null,e.right):t.splice(--n,1,e.left,e.right),r+=1+e.break,i-=e.size}else if(a>i*2){let e=t[r];e.break?t.splice(r,1,e.left,null,e.right):t.splice(r,1,e.left,e.right),r+=2+e.break,a-=e.size}else break}else if(i<a){let e=t[n++];e&&(i+=e.size)}else{let e=t[--r];e&&(a+=e.size)}let o=!1;return t[n-1]==null?(o=!0,n--):t[n]??(o=!0,r++),new kL(e.of(t.slice(0,n)),o,e.of(t.slice(r)))}};function wL(e,t){return e==t?e:(e.constructor!=t.constructor&&(gL=!0),t)}CL.prototype.size=1;var TL=AN.replace({}),EL=class extends CL{constructor(e,t,n){super(e,t),this.deco=n,this.spaceAbove=0}mainBlock(e,t){return new bL(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.deco||0)}blockAt(e,t,n,r){return this.spaceAbove&&e<n+this.spaceAbove?new bL(r,0,n,this.spaceAbove,TL):this.mainBlock(n,r)}lineAt(e,t,n,r,i){let a=this.mainBlock(r,i);return this.spaceAbove?this.blockAt(0,n,r,i).join(a):a}forEachLine(e,t,n,r,i,a){e<=i+this.length&&t>=i&&a(this.lineAt(0,xL.ByPos,n,r,i))}setMeasuredHeight(e){let t=e.heights[e.index++];t<0?(this.spaceAbove=-t,t=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(t)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more&&this.setMeasuredHeight(r),this.outdated=!1,this}toString(){return`block(${this.length})`}},DL=class e extends EL{constructor(e,t,n){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=n}mainBlock(e,t){return new bL(t,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(t,n,r){let i=r[0];return r.length==1&&(i instanceof e||i instanceof OL&&i.flags&4)&&Math.abs(this.length-i.length)<10?(i instanceof OL?i=new e(i.length,this.height,this.spaceAbove):i.height=this.height,this.outdated||(i.outdated=!1),i):CL.of(r)}updateHeight(e,t=0,n=!1,r){return r&&r.from<=t&&r.more?this.setMeasuredHeight(r):(n||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:``}${this.widgetHeight?`:`+this.widgetHeight:``})`}},OL=class e extends CL{constructor(e){super(e,0)}heightMetrics(e,t){let n=e.doc.lineAt(t).number,r=e.doc.lineAt(t+this.length).number,i=r-n+1,a,o=0;if(e.lineWrapping){let t=Math.min(this.height,e.lineHeight*i);a=t/i,this.length>i+1&&(o=(this.height-t)/(this.length-i-1))}else a=this.height/i;return{firstLine:n,lastLine:r,perLine:a,perChar:o}}blockAt(e,t,n,r){let{firstLine:i,lastLine:a,perLine:o,perChar:s}=this.heightMetrics(t,r);if(t.lineWrapping){let i=r+(e<t.lineHeight?0:Math.round(Math.max(0,Math.min(1,(e-n)/this.height))*this.length)),a=t.doc.lineAt(i),c=o+a.length*s,l=Math.max(n,e-c/2);return new bL(a.from,a.length,l,c,0)}{let r=Math.max(0,Math.min(a-i,Math.floor((e-n)/o))),{from:s,length:c}=t.doc.line(i+r);return new bL(s,c,n+o*r,o,0)}}lineAt(e,t,n,r,i){if(t==xL.ByHeight)return this.blockAt(e,n,r,i);if(t==xL.ByPosNoHeight){let{from:t,to:r}=n.doc.lineAt(e);return new bL(t,r-t,0,0,0)}let{firstLine:a,perLine:o,perChar:s}=this.heightMetrics(n,i),c=n.doc.lineAt(e),l=o+c.length*s,u=c.number-a,d=r+o*u+s*(c.from-i-u);return new bL(c.from,c.length,Math.max(r,Math.min(d,r+this.height-l)),l,0)}forEachLine(e,t,n,r,i,a){e=Math.max(e,i),t=Math.min(t,i+this.length);let{firstLine:o,perLine:s,perChar:c}=this.heightMetrics(n,i);for(let l=e,u=r;l<=t;){let t=n.doc.lineAt(l);if(l==e){let n=t.number-o;u+=s*n+c*(e-i-n)}let r=s+c*t.length;a(new bL(t.from,t.length,u,r,0)),u+=r,l=t.to+1}}replace(t,n,r){let i=this.length-n;if(i>0){let t=r[r.length-1];t instanceof e?r[r.length-1]=new e(t.length+i):r.push(null,new e(i-1))}if(t>0){let n=r[0];n instanceof e?r[0]=new e(t+n.length):r.unshift(new e(t-1),null)}return CL.of(r)}decomposeLeft(t,n){n.push(new e(t-1),null)}decomposeRight(t,n){n.push(null,new e(this.length-t-1))}updateHeight(t,n=0,r=!1,i){let a=n+this.length;if(i&&i.from<=n+this.length&&i.more){let r=[],o=Math.max(n,i.from),s=-1;for(i.from>n&&r.push(new e(i.from-n-1).updateHeight(t,n));o<=a&&i.more;){let e=t.doc.lineAt(o).length;r.length&&r.push(null);let n=i.heights[i.index++],a=0;n<0&&(a=-n,n=i.heights[i.index++]),s==-1?s=n:Math.abs(n-s)>=SL&&(s=-2);let c=new DL(e,n,a);c.outdated=!1,r.push(c),o+=e+1}o<=a&&r.push(null,new e(a-o).updateHeight(t,o));let c=CL.of(r);return(s<0||Math.abs(c.height-this.height)>=SL||Math.abs(s-this.heightMetrics(t,n).perLine)>=SL)&&(gL=!0),wL(this,c)}return(r||this.outdated)&&(this.setHeight(t.heightForGap(n,n+this.length)),this.outdated=!1),this}toString(){return`gap(${this.length})`}},kL=class extends CL{constructor(e,t,n){super(e.length+ +!!t+n.length,e.height+n.height,+!!t|(e.outdated||n.outdated?2:0)),this.left=e,this.right=n,this.size=e.size+n.size}get break(){return this.flags&1}blockAt(e,t,n,r){let i=n+this.left.height;return e<i?this.left.blockAt(e,t,n,r):this.right.blockAt(e,t,i,r+this.left.length+this.break)}lineAt(e,t,n,r,i){let a=r+this.left.height,o=i+this.left.length+this.break,s=t==xL.ByHeight?e<a:e<o,c=s?this.left.lineAt(e,t,n,r,i):this.right.lineAt(e,t,n,a,o);if(this.break||(s?c.to<o:c.from>o))return c;let l=t==xL.ByPosNoHeight?xL.ByPosNoHeight:xL.ByPos;return s?c.join(this.right.lineAt(o,l,n,a,o)):this.left.lineAt(o,l,n,r,i).join(c)}forEachLine(e,t,n,r,i,a){let o=r+this.left.height,s=i+this.left.length+this.break;if(this.break)e<s&&this.left.forEachLine(e,t,n,r,i,a),t>=s&&this.right.forEachLine(e,t,n,o,s,a);else{let c=this.lineAt(s,xL.ByPos,n,r,i);e<c.from&&this.left.forEachLine(e,Math.min(t,c.from-1),n,r,i,a),c.to>=e&&c.from<=t&&a(c),t>c.to&&this.right.forEachLine(Math.max(e,c.to+1),t,n,o,s,a)}}replace(e,t,n){let r=this.left.length+this.break;if(t<r)return this.balanced(this.left.replace(e,t,n),this.right);if(e>this.left.length)return this.balanced(this.left,this.right.replace(e-r,t-r,n));let i=[];e>0&&this.decomposeLeft(e,i);let a=i.length;for(let e of n)i.push(e);if(e>0&&AL(i,a-1),t<this.length){let e=i.length;this.decomposeRight(t,i),AL(i,e)}return CL.of(i)}decomposeLeft(e,t){let n=this.left.length;if(e<=n)return this.left.decomposeLeft(e,t);t.push(this.left),this.break&&(n++,e>=n&&t.push(null)),e>n&&this.right.decomposeLeft(e-n,t)}decomposeRight(e,t){let n=this.left.length,r=n+this.break;if(e>=r)return this.right.decomposeRight(e-r,t);e<n&&this.left.decomposeRight(e,t),this.break&&e<r&&t.push(null),t.push(this.right)}balanced(e,t){return e.size>2*t.size||t.size>2*e.size?CL.of(this.break?[e,null,t]:[e,t]):(this.left=wL(this.left,e),this.right=wL(this.right,t),this.setHeight(e.height+t.height),this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,n=!1,r){let{left:i,right:a}=this,o=t+i.length+this.break,s=null;return r&&r.from<=t+i.length&&r.more?s=i=i.updateHeight(e,t,n,r):i.updateHeight(e,t,n),r&&r.from<=o+a.length&&r.more?s=a=a.updateHeight(e,o,n,r):a.updateHeight(e,o,n),s?this.balanced(i,a):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?` `:`-`)+this.right}};function AL(e,t){let n,r;e[t]==null&&(n=e[t-1])instanceof OL&&(r=e[t+1])instanceof OL&&e.splice(t-1,3,new OL(n.length+1+r.length))}var jL=5,ML=class e{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let e=Math.min(t,this.lineEnd),n=this.nodes[this.nodes.length-1];n instanceof DL?n.length+=e-this.pos:(e>this.pos||!this.isCovered)&&this.nodes.push(new DL(e-this.pos,-1,0)),this.writtenTo=e,t>e&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,n){if(e<t||n.heightRelevant){let r=n.widget?n.widget.estimatedHeight:0,i=n.widget?n.widget.lineBreaks:0;r<0&&(r=this.oracle.lineHeight);let a=t-e;n.block?this.addBlock(new EL(a,r,n)):(a||i||r>=jL)&&this.addLineDeco(r,i,a)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd<this.pos&&(this.lineEnd=this.oracle.doc.lineAt(this.pos).to)}enterLine(){if(this.lineStart>-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenTo<e&&((this.writtenTo<e-1||this.nodes[this.nodes.length-1]==null)&&this.nodes.push(this.blankContent(this.writtenTo,e-1)),this.nodes.push(null)),this.pos>e&&this.nodes.push(new DL(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,t){let n=new OL(t-e);return this.oracle.doc.lineAt(e).to==t&&(n.flags|=4),n}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof DL)return e;let t=new DL(0,-1,0);return this.nodes.push(t),t}addBlock(e){this.enterLine();let t=e.deco;t&&t.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos+=e.length,t&&t.endSide>0&&(this.covering=e)}addLineDeco(e,t,n){let r=this.ensureLine();r.length+=n,r.collapsed+=n,r.widgetHeight=Math.max(r.widgetHeight,e),r.breaks+=t,this.writtenTo=this.pos+=n}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof DL)&&!this.isCovered?this.nodes.push(new DL(0,-1,0)):(this.writtenTo<this.pos||t==null)&&this.nodes.push(this.blankContent(this.writtenTo,this.pos));let n=e;for(let e of this.nodes)e instanceof DL&&e.updateHeight(this.oracle,n),n+=e?e.length:1;return this.nodes}static build(t,n,r,i){let a=new e(r,t);return NM.spans(n,r,i,a,0),a.finish(r)}};function NL(e,t,n){let r=new PL;return NM.compare(e,t,n,r,0),r.changes}var PL=class{constructor(){this.changes=[]}compareRange(){}comparePoint(e,t,n,r){(e<t||n&&n.heightRelevant||r&&r.heightRelevant)&&IN(e,t,this.changes,5)}};function FL(e,t){let n=e.getBoundingClientRect(),r=e.ownerDocument,i=r.defaultView||window,a=Math.max(0,n.left),o=Math.min(i.innerWidth,n.right),s=Math.max(0,n.top),c=Math.min(i.innerHeight,n.bottom);for(let t=e.parentNode;t&&t!=r.body;)if(RN(t)){let n=window.getComputedStyle(t);if((t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth)&&n.overflow!=`visible`){let n=t.getBoundingClientRect();a=Math.max(a,n.left),o=Math.min(o,n.right),s=Math.max(s,n.top),c=Math.min(t==e.parentNode?i.innerHeight:c,n.bottom)}t=n.position==`absolute`||n.position==`fixed`?t.offsetParent:t.parentNode}else if(t.nodeType==11)t=t.host;else break;return{left:a-n.left,right:Math.max(a,o)-n.left,top:s-(n.top+t),bottom:Math.max(s,c)-(n.top+t)}}function IL(e){let t=e.getBoundingClientRect(),n=e.ownerDocument.defaultView||window;return t.left<n.innerWidth&&t.right>0&&t.top<n.innerHeight&&t.bottom>0}function LL(e,t){let n=e.getBoundingClientRect();return{left:0,right:n.right-n.left,top:t,bottom:n.bottom-(n.top+t)}}var RL=class{constructor(e,t,n,r){this.from=e,this.to=t,this.size=n,this.displaySize=r}static same(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],i=t[n];if(r.from!=i.from||r.to!=i.to||r.size!=i.size)return!1}return!0}draw(e,t){return AN.replace({widget:new zL(this.displaySize*(t?e.scaleY:e.scaleX),t)}).range(this.from,this.to)}},zL=class extends ON{constructor(e,t){super(),this.size=e,this.vertical=t}eq(e){return e.size==this.size&&e.vertical==this.vertical}toDOM(){let e=document.createElement(`div`);return this.vertical?e.style.height=this.size+`px`:(e.style.width=this.size+`px`,e.style.height=`2px`,e.style.display=`inline-block`),e}get estimatedHeight(){return this.vertical?this.size:-1}},BL=class{constructor(e,t){this.view=e,this.state=t,this.pixelViewport={left:0,right:window.innerWidth,top:0,bottom:0},this.inView=!0,this.paddingTop=0,this.paddingBottom=0,this.contentDOMWidth=0,this.contentDOMHeight=0,this.editorHeight=0,this.editorWidth=0,this.scaleX=1,this.scaleY=1,this.scrollOffset=0,this.scrolledToBottom=!1,this.scrollAnchorPos=0,this.scrollAnchorHeight=-1,this.scaler=KL,this.scrollTarget=null,this.printing=!1,this.mustMeasureContent=!0,this.defaultTextDirection=mP.LTR,this.visibleRanges=[],this.mustEnforceCursorAssoc=!1;let n=t.facet(aF).some(e=>typeof e!=`function`&&e.class==`cm-lineWrapping`);this.heightOracle=new vL(n),this.stateDeco=qL(t),this.heightMap=CL.empty().applyChanges(this.stateDeco,sj.empty,this.heightOracle.setDoc(t.doc),[new hF(0,0,0,t.doc.length)]);for(let e=0;e<2&&(this.viewport=this.getViewport(0,null),this.updateForViewport());e++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=AN.set(this.lineGaps.map(e=>e.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let n=0;n<=1;n++){let r=n?t.head:t.anchor;if(!e.some(({from:e,to:t})=>r>=e&&r<=t)){let{from:t,to:n}=this.lineBlockAt(r);e.push(new VL(t,n))}}return this.viewports=e.sort((e,t)=>e.from-t.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?KL:new JL(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(YL(e,this.scaler))})}update(e,t=null){this.state=e.state;let n=this.stateDeco;this.stateDeco=qL(this.state);let r=e.changedRanges,i=hF.extendWithRanges(r,NL(n,this.stateDeco,e?e.changes:Dj.empty(this.state.doc.length))),a=this.heightMap.height,o=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);_L(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),i),(this.heightMap.height!=a||gL)&&(e.flags|=2),o?(this.scrollAnchorPos=e.changes.mapPos(o.from,-1),this.scrollAnchorHeight=o.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=a);let s=i.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.head<s.from||t.range.head>s.to)||!this.viewportIsAppropriate(s))&&(s=this.getViewport(0,t));let c=s.from!=this.viewport.from||s.to!=this.viewport.to;this.viewport=s,e.flags|=this.updateForViewport(),(c||!e.changes.empty||e.flags&2)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(e.changes),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(qP)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,t=e.contentDOM,n=window.getComputedStyle(t),r=this.heightOracle,i=n.whiteSpace;this.defaultTextDirection=n.direction==`rtl`?mP.RTL:mP.LTR;let a=this.heightOracle.mustRefreshForWrapping(i)||this.mustMeasureContent===`refresh`,o=t.getBoundingClientRect(),s=a||this.mustMeasureContent||this.contentDOMHeight!=o.height;this.contentDOMHeight=o.height,this.mustMeasureContent=!1;let c=0,l=0;if(o.width&&o.height){let{scaleX:e,scaleY:n}=ZN(t,o);(e>.005&&Math.abs(this.scaleX-e)>.005||n>.005&&Math.abs(this.scaleY-n)>.005)&&(this.scaleX=e,this.scaleY=n,c|=16,a=s=!0)}let u=(parseInt(n.paddingTop)||0)*this.scaleY,d=(parseInt(n.paddingBottom)||0)*this.scaleY;(this.paddingTop!=u||this.paddingBottom!=d)&&(this.paddingTop=u,this.paddingBottom=d,c|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(r.lineWrapping&&(s=!0),this.editorWidth=e.scrollDOM.clientWidth,c|=16);let f=$N(this.view.contentDOM,!1).y;f!=this.scrollParent&&(this.scrollParent=f,this.scrollAnchorHeight=-1,this.scrollOffset=0);let p=this.getScrollOffset();this.scrollOffset!=p&&(this.scrollAnchorHeight=-1,this.scrollOffset=p),this.scrolledToBottom=uP(this.scrollParent||e.win);let m=(this.printing?LL:FL)(t,this.paddingTop),h=m.top-this.pixelViewport.top,g=m.bottom-this.pixelViewport.bottom;this.pixelViewport=m;let _=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(_!=this.inView&&(this.inView=_,_&&(s=!0)),!this.inView&&!this.scrollTarget&&!IL(e.dom))return 0;let v=o.width;if((this.contentDOMWidth!=v||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=o.width,this.editorHeight=e.scrollDOM.clientHeight,c|=16),s){let t=e.docView.measureVisibleLineHeights(this.viewport);if(r.mustRefreshForHeights(t)&&(a=!0),a||r.lineWrapping&&Math.abs(v-this.contentDOMWidth)>r.charWidth){let{lineHeight:n,charWidth:o,textHeight:s}=e.docView.measureTextSize();a=n>0&&r.refresh(i,n,o,s,Math.max(5,v/o),t),a&&(e.docView.minWidth=0,c|=16)}h>0&&g>0?l=Math.max(h,g):h<0&&g<0&&(l=Math.min(h,g)),_L();for(let n of this.viewports){let i=n.from==this.viewport.from?t:e.docView.measureVisibleLineHeights(n);this.heightMap=(a?CL.empty().applyChanges(this.stateDeco,sj.empty,this.heightOracle,[new hF(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(r,0,a,new yL(n.from,i))}gL&&(c|=2)}let y=!this.viewportIsAppropriate(this.viewport,l)||this.scrollTarget&&(this.scrollTarget.range.head<this.viewport.from||this.scrollTarget.range.head>this.viewport.to);return y&&(c&2&&(c|=this.updateScaler()),this.viewport=this.getViewport(l,this.scrollTarget),c|=this.updateForViewport()),(c&2||y)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(a?[]:this.lineGaps,e)),c|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),c}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let n=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),r=this.heightMap,i=this.heightOracle,{visibleTop:a,visibleBottom:o}=this,s=new VL(r.lineAt(a-n*1e3,xL.ByHeight,i,0,0).from,r.lineAt(o+(1-n)*1e3,xL.ByHeight,i,0,0).to);if(t){let{head:e}=t.range;if(e<s.from||e>s.to){let n=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),a=r.lineAt(e,xL.ByPos,i,0,0),o;o=t.y==`center`?(a.top+a.bottom)/2-n/2:t.y==`start`||t.y==`nearest`&&e<s.from?a.top:a.bottom-n,s=new VL(r.lineAt(o-500,xL.ByHeight,i,0,0).from,r.lineAt(o+n+500,xL.ByHeight,i,0,0).to)}}return s}mapViewport(e,t){let n=t.mapPos(e.from,-1),r=t.mapPos(e.to,1);return new VL(this.heightMap.lineAt(n,xL.ByPos,this.heightOracle,0,0).from,this.heightMap.lineAt(r,xL.ByPos,this.heightOracle,0,0).to)}viewportIsAppropriate({from:e,to:t},n=0){if(!this.inView)return!0;let{top:r}=this.heightMap.lineAt(e,xL.ByPos,this.heightOracle,0,0),{bottom:i}=this.heightMap.lineAt(t,xL.ByPos,this.heightOracle,0,0),{visibleTop:a,visibleBottom:o}=this;return(e==0||r<=a-Math.max(10,Math.min(-n,250)))&&(t==this.state.doc.length||i>=o+Math.max(10,Math.min(n,250)))&&r>a-2e3&&i<o+2e3}mapLineGaps(e,t){if(!e.length||t.empty)return e;let n=[];for(let r of e)t.touchesRange(r.from,r.to)||n.push(new RL(t.mapPos(r.from),t.mapPos(r.to),r.size,r.displaySize));return n}ensureLineGaps(e,t){let n=this.heightOracle.lineWrapping,r=n?1e4:2e3,i=r>>1,a=r<<1;if(this.defaultTextDirection!=mP.LTR&&!n)return[];let o=[],s=(r,a,c,l)=>{if(a-r<i)return;let u=this.state.selection.main,d=[u.from];u.empty||d.push(u.to);for(let e of d)if(e>r&&e<a){s(r,e-10,c,l),s(e+10,a,c,l);return}let f=GL(e,e=>e.from>=c.from&&e.to<=c.to&&Math.abs(e.from-r)<i&&Math.abs(e.to-a)<i&&!d.some(t=>e.from<t&&e.to>t));if(!f){if(a<c.to&&t&&n&&t.visibleRanges.some(e=>e.from<=a&&e.to>=a)){let e=t.moveToLineBoundary(q.cursor(a),!1,!0).head;e>r&&(a=e)}let e=this.gapSize(c,r,a,l);f=new RL(r,a,e,n||e<2e6?e:2e6)}o.push(f)},c=t=>{if(t.length<a||t.type!=kN.Text)return;let i=HL(t.from,t.to,this.stateDeco);if(i.total<a)return;let o=this.scrollTarget?this.scrollTarget.range.head:null,c,l;if(n){let e=r/this.heightOracle.lineLength*this.heightOracle.lineHeight,n,a;if(o!=null){let r=WL(i,o),s=((this.visibleBottom-this.visibleTop)/2+e)/t.height;n=r-s,a=r+s}else n=(this.visibleTop-t.top-e)/t.height,a=(this.visibleBottom-t.top+e)/t.height;c=UL(i,n),l=UL(i,a)}else{let n=i.total*this.heightOracle.charWidth,a=r*this.heightOracle.charWidth,s=0;if(n>2e6)for(let n of e)n.from>=t.from&&n.from<t.to&&n.size!=n.displaySize&&n.from*this.heightOracle.charWidth+s<this.pixelViewport.left&&(s=n.size-n.displaySize);let u=this.pixelViewport.left+s,d=this.pixelViewport.right+s,f,p;if(o!=null){let e=WL(i,o),t=((d-u)/2+a)/n;f=e-t,p=e+t}else f=(u-a)/n,p=(d+a)/n;c=UL(i,f),l=UL(i,p)}c>t.from&&s(t.from,c,t,i),l<t.to&&s(l,t.to,t,i)};for(let e of this.viewportLines)Array.isArray(e.type)?e.type.forEach(c):c(e);return o}gapSize(e,t,n,r){let i=WL(r,n)-WL(r,t);return this.heightOracle.lineWrapping?e.height*i:r.total*this.heightOracle.charWidth*i}updateLineGaps(e){RL.same(e,this.lineGaps)||(this.lineGaps=e,this.lineGapDeco=AN.set(e.map(e=>e.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let t=this.stateDeco;this.lineGaps.length&&(t=t.concat(this.lineGapDeco));let n=[];NM.spans(t,this.viewport.from,this.viewport.to,{span(e,t){n.push({from:e,to:t})},point(){}},20);let r=0;if(n.length!=this.visibleRanges.length)r=12;else for(let t=0;t<n.length&&!(r&8);t++){let i=this.visibleRanges[t],a=n[t];(i.from!=a.from||i.to!=a.to)&&(r|=4,e&&e.mapPos(i.from,-1)==a.from&&e.mapPos(i.to,1)==a.to||(r|=8))}return this.visibleRanges=n,r}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||YL(this.heightMap.lineAt(e,xL.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(t=>t.top<=e&&t.bottom>=e)||YL(this.heightMap.lineAt(this.scaler.fromDOM(e),xL.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let t=this.lineBlockAtHeight(e+8);return t.from>=this.viewport.from||this.viewportLines[0].top-e>200?t:this.viewportLines[0]}elementAtHeight(e){return YL(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}},VL=class{constructor(e,t){this.from=e,this.to=t}};function HL(e,t,n){let r=[],i=e,a=0;return NM.spans(n,e,t,{span(){},point(e,t){e>i&&(r.push({from:i,to:e}),a+=e-i),i=t}},20),i<t&&(r.push({from:i,to:t}),a+=t-i),{total:a,ranges:r}}function UL({total:e,ranges:t},n){if(n<=0)return t[0].from;if(n>=1)return t[t.length-1].to;let r=Math.floor(e*n);for(let e=0;;e++){let{from:n,to:i}=t[e],a=i-n;if(r<=a)return n+r;r-=a}}function WL(e,t){let n=0;for(let{from:r,to:i}of e.ranges){if(t<=i){n+=t-r;break}n+=i-r}return n/e.total}function GL(e,t){for(let n of e)if(t(n))return n}var KL={toDOM(e){return e},fromDOM(e){return e},scale:1,eq(e){return e==this}};function qL(e){let t=e.facet(oF).filter(e=>typeof e!=`function`),n=e.facet(cF).filter(e=>typeof e!=`function`);return n.length&&t.push(NM.join(n)),t}var JL=class e{constructor(e,t,n){let r=0,i=0,a=0;this.viewports=n.map(({from:n,to:i})=>{let a=t.lineAt(n,xL.ByPos,e,0,0).top,o=t.lineAt(i,xL.ByPos,e,0,0).bottom;return r+=o-a,{from:n,to:i,top:a,bottom:o,domTop:0,domBottom:0}}),this.scale=(7e6-r)/(t.height-r);for(let e of this.viewports)e.domTop=a+(e.top-i)*this.scale,a=e.domBottom=e.domTop+(e.bottom-e.top),i=e.bottom}toDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.top)return r+(e-n)*this.scale;if(e<=i.bottom)return i.domTop+(e-i.top);n=i.bottom,r=i.domBottom}}fromDOM(e){for(let t=0,n=0,r=0;;t++){let i=t<this.viewports.length?this.viewports[t]:null;if(!i||e<i.domTop)return n+(e-r)/this.scale;if(e<=i.domBottom)return i.top+(e-i.domTop);n=i.bottom,r=i.domBottom}}eq(t){return t instanceof e&&this.scale==t.scale&&this.viewports.length==t.viewports.length&&this.viewports.every((e,n)=>e.from==t.viewports[n].from&&e.to==t.viewports[n].to)}};function YL(e,t){if(t.scale==1)return e;let n=t.toDOM(e.top),r=t.toDOM(e.bottom);return new bL(e.from,e.length,n,r-n,Array.isArray(e._content)?e._content.map(e=>YL(e,t)):e._content)}var XL=Lj.define({combine:e=>e.join(` `)}),ZL=Lj.define({combine:e=>e.indexOf(!0)>-1}),QL=$M.newName(),$L=$M.newName(),eR=$M.newName(),tR={"&light":`.`+$L,"&dark":`.`+eR};function nR(e,t,n){return new $M(t,{finish(t){return/&/.test(t)?t.replace(/&\w*/,t=>{if(t==`&`)return e;if(!n||!n[t])throw RangeError(`Unsupported selector: ${t}`);return n[t]}):e+` `+t}})}var rR=nR(`.`+QL,{"&":{position:`relative !important`,boxSizing:`border-box`,"&.cm-focused":{outline:`1px dotted #212121`},display:`flex !important`,flexDirection:`column`},".cm-scroller":{display:`flex !important`,alignItems:`flex-start !important`,fontFamily:`monospace`,lineHeight:1.4,height:`100%`,overflowX:`auto`,position:`relative`,zIndex:0,overflowAnchor:`none`},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:`block`,whiteSpace:`pre`,wordWrap:`normal`,boxSizing:`border-box`,minHeight:`100%`,padding:`4px 0`,outline:`none`,"&[contenteditable=true]":{WebkitUserModify:`read-write-plaintext-only`}},".cm-lineWrapping":{whiteSpace_fallback:`pre-wrap`,whiteSpace:`break-spaces`,wordBreak:`break-word`,overflowWrap:`anywhere`,flexShrink:1},"&light .cm-content":{caretColor:`black`},"&dark .cm-content":{caretColor:`white`},".cm-line":{display:`block`,padding:`0 2px 0 6px`},".cm-layer":{userSelect:`none`,position:`absolute`,left:0,top:0,contain:`size style`,"& > *":{position:`absolute`}},"&light .cm-selectionBackground":{background:`#d9d9d9`},"&dark .cm-selectionBackground":{background:`#222`},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#d7d4f0`},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:`#233`},".cm-cursorLayer":{pointerEvents:`none`},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:`steps(1) cm-blink 1.2s infinite`},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:`1.2px solid black`,marginLeft:`-0.6px`,pointerEvents:`none`},".cm-cursor":{display:`none`},"&dark .cm-cursor":{borderLeftColor:`#ddd`},".cm-selectionHandle":{backgroundColor:`currentColor`,width:`1.5px`},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:`""`,backgroundColor:`inherit`,borderRadius:`50%`,width:`8px`,height:`8px`,position:`absolute`,left:`-3.25px`},".cm-selectionHandle-start::before":{top:`-8px`},".cm-selectionHandle-end::before":{bottom:`-8px`},".cm-dropCursor":{position:`absolute`},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:`block`},".cm-iso":{unicodeBidi:`isolate`},".cm-announced":{position:`fixed`,top:`-10000px`},"@media print":{".cm-announced":{display:`none`}},"&light .cm-activeLine":{backgroundColor:`#cceeff44`},"&dark .cm-activeLine":{backgroundColor:`#99eeff33`},"&light .cm-specialChar":{color:`red`},"&dark .cm-specialChar":{color:`#f78`},".cm-gutters":{flexShrink:0,display:`flex`,height:`100%`,boxSizing:`border-box`,zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:`#f5f5f5`,color:`#6c6c6c`,border:`0px solid #ddd`,"&.cm-gutters-before":{borderRightWidth:`1px`},"&.cm-gutters-after":{borderLeftWidth:`1px`}},"&dark .cm-gutters":{backgroundColor:`#333338`,color:`#ccc`},".cm-gutter":{display:`flex !important`,flexDirection:`column`,flexShrink:0,boxSizing:`border-box`,minHeight:`100%`,overflow:`hidden`},".cm-gutterElement":{boxSizing:`border-box`},".cm-lineNumbers .cm-gutterElement":{padding:`0 3px 0 5px`,minWidth:`20px`,textAlign:`right`,whiteSpace:`nowrap`},"&light .cm-activeLineGutter":{backgroundColor:`#e2f2ff`},"&dark .cm-activeLineGutter":{backgroundColor:`#222227`},".cm-panels":{boxSizing:`border-box`,position:`sticky`,left:0,right:0,zIndex:300},"&light .cm-panels":{backgroundColor:`#f5f5f5`,color:`black`},".cm-panels-top":{top:`0`},".cm-panels-bottom":{bottom:`0`},"&light .cm-panels-top":{borderBottom:`1px solid #ddd`},"&light .cm-panels-bottom":{borderTop:`1px solid #ddd`},"&dark .cm-panels":{backgroundColor:`#333338`,color:`white`},".cm-dialog":{padding:`2px 19px 4px 6px`,position:`relative`,"& label":{fontSize:`80%`}},".cm-dialog-close":{position:`absolute`,top:`3px`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,fontSize:`14px`,padding:`0`},".cm-tab":{display:`inline-block`,overflow:`hidden`,verticalAlign:`bottom`},".cm-widgetBuffer":{verticalAlign:`baseline`,height:`1em`,width:0,display:`inline`},".cm-placeholder":{color:`#888`,display:`inline-block`,verticalAlign:`top`,userSelect:`none`},".cm-highlightSpace":{background:`radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat`,backgroundSize:`.4em`,backgroundPosition:`calc(min(50%, 0px)) center`},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="20"><path stroke="%23888" stroke-width="1" fill="none" d="M1 10H196L190 5M190 15L196 10M197 4L197 16"/></svg>')`,backgroundSize:`auto 100%`,backgroundPosition:`right 90%`,backgroundRepeat:`no-repeat`},".cm-trailingSpace":{backgroundColor:`#ff332255`},".cm-button":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,padding:`.2em 1em`,borderRadius:`1px`},"&light .cm-button":{backgroundImage:`linear-gradient(#eff1f5, #d9d9df)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#b4b4b4, #d0d3d6)`}},"&dark .cm-button":{backgroundImage:`linear-gradient(#393939, #111)`,border:`1px solid #888`,"&:active":{backgroundImage:`linear-gradient(#111, #333)`}},".cm-textfield":{verticalAlign:`middle`,color:`inherit`,fontSize:`70%`,border:`1px solid silver`,padding:`.2em .5em`},"&light .cm-textfield":{backgroundColor:`white`},"&dark .cm-textfield":{border:`1px solid #555`,backgroundColor:`inherit`}},tR),iR={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},aR=J.ie&&J.ie_version<=11,oR=class{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new eP,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let e of t)this.queue.push(e);(J.ie&&J.ie_version<=11||J.ios&&e.composing)&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&J.android&&e.constructor.EDIT_CONTEXT!==!1&&!(J.chrome&&J.chrome_version<126)&&(this.editContext=new uR(e),e.state.facet($P)&&(e.contentDOM.editContext=this.editContext.editContext)),aR&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia(`print`)),typeof ResizeObserver==`function`&&(this.resizeScroll=new ResizeObserver(()=>{this.view.docView?.lastUpdate<Date.now()-75&&this.onResize()}),this.resizeScroll.observe(e.scrollDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver==`function`&&(this.intersection=new IntersectionObserver(e=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),e.length>0&&e[e.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent(`Event`)))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(e=>{e.length>0&&e[e.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent(`Event`))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers(`scroll`,e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type!=`change`&&e.type||e.matches)&&(this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500))}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,n)=>t!=e[n]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:n}=this,r=this.selectionRange;if(n.state.facet($P)?n.root.activeElement!=this.dom:!HN(this.dom,r))return;let i=r.anchorNode&&n.docView.tile.nearest(r.anchorNode);i&&i.isWidget()&&i.widget.ignoreEvent(e)?t||(this.selectionChanged=!1):(J.ie&&J.ie_version<=11||J.android&&J.chrome)&&!n.state.selection.main.empty&&r.focusNode&&WN(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=BN(e.root);if(!t)return!1;let n=J.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&lR(this.view,t)||t;if(!n||this.selectionRange.eq(n))return!1;let r=HN(this.dom,n);return r&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime<Date.now()-300&&lP(this.dom,n)?(this.view.inputState.lastFocusTime=0,e.docView.updateSelection(),!1):(this.selectionRange.setRange(n),r&&(this.selectionChanged=!0),!0)}setSelectionRange(e,t){this.selectionRange.set(e.node,e.offset,t.node,t.offset),this.selectionChanged=!1}clearSelectionRange(){this.selectionRange.set(null,0,null,0)}listenForScroll(){this.parentCheck=-1;let e=0,t=null;for(let n=this.dom;n;)if(RN(n))!t&&e<this.scrollTargets.length&&this.scrollTargets[e]==n?e++:t||=this.scrollTargets.slice(0,e),t&&t.push(n),n=n.assignedSlot||n.parentNode;else if(n.nodeType==11)n=n.host;else break;if(e<this.scrollTargets.length&&!t&&(t=this.scrollTargets.slice(0,e)),t){for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);for(let e of this.scrollTargets=t)e.addEventListener(`scroll`,this.onScroll)}}ignore(e){if(!this.active)return e();try{return this.stop(),e()}finally{this.start(),this.clear()}}start(){this.active||=(this.observer.observe(this.dom,iR),aR&&this.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),!0)}stop(){this.active&&(this.active=!1,this.observer.disconnect(),aR&&this.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData))}clear(){this.processRecords(),this.queue.length=0,this.selectionChanged=!1}delayAndroidKey(e,t){if(!this.delayedAndroidKey){let e=()=>{let e=this.delayedAndroidKey;e&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=e.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&e.force&&sP(this.dom,e.key,e.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(e)}(!this.delayedAndroidKey||e==`Enter`)&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange<Date.now()-50||!!this.delayedAndroidKey?.force})}clearDelayedAndroidKey(){this.win.cancelAnimationFrame(this.flushingAndroidKey),this.delayedAndroidKey=null,this.flushingAndroidKey=-1}flushSoon(){this.delayedFlush<0&&(this.delayedFlush=this.view.win.requestAnimationFrame(()=>{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,n=-1,r=!1;for(let i of e){let e=this.readMutation(i);e&&(e.typeOver&&(r=!0),t==-1?{from:t,to:n}=e:(t=Math.min(e.from,t),n=Math.max(e.to,n)))}return{from:t,to:n,typeOver:r}}readChange(){let{from:e,to:t,typeOver:n}=this.processRecords(),r=this.selectionChanged&&HN(this.dom,this.selectionRange);if(e<0&&!r)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let i=new SI(this.view,e,t,n);return this.view.docView.domChanged={newSel:i.newSel?i.newSel.main:null},i}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.selectionChanged,n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,i=wI(this.view,n);return this.view.state==r&&(n.domChanged||t)&&this.view.update([]),i}readMutation(e){let t=this.view.docView.tile.nearest(e.target);if(!t||t.isWidget())return null;if(t.markDirty(e.type==`attributes`),e.type==`childList`){let n=sR(t,e.previousSibling||e.target.previousSibling,-1),r=sR(t,e.nextSibling||e.target.nextSibling,1);return{from:n?t.posAfter(n):t.posAtStart,to:r?t.posBefore(r):t.posAtEnd,typeOver:!1}}return e.type==`characterData`?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener(`change`,this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener(`beforeprint`,this.onPrint),e.addEventListener(`scroll`,this.onScroll),e.document.addEventListener(`selectionchange`,this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener(`scroll`,this.onScroll),e.removeEventListener(`resize`,this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener(`change`,this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener(`beforeprint`,this.onPrint),e.document.removeEventListener(`selectionchange`,this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet($P)!=e.state.facet($P)&&(e.view.contentDOM.editContext=e.state.facet($P)?this.editContext.editContext:null))}destroy(){var e,t,n;this.stop(),(e=this.intersection)==null||e.disconnect(),(t=this.gapIntersection)==null||t.disconnect(),(n=this.resizeScroll)==null||n.disconnect();for(let e of this.scrollTargets)e.removeEventListener(`scroll`,this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}};function sR(e,t,n){for(;t;){let r=vF.get(t);if(r&&r.parent==e)return r;let i=t.parentNode;t=i==e.dom?n>0?t.nextSibling:t.previousSibling:i}return null}function cR(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.docView.domAtPos(e.state.selection.main.anchor,1);return WN(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function lR(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return cR(e,n)}let n=null;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.contentDOM.addEventListener(`beforeinput`,r,!0),e.dom.ownerDocument.execCommand(`indent`),e.contentDOM.removeEventListener(`beforeinput`,r,!0),n?cR(e,n):null}var uR=class{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let t=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=n=>{let r=e.state.selection.main,{anchor:i,head:a}=r,o=this.toEditorPos(n.updateRangeStart),s=this.toEditorPos(n.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:n.updateRangeStart,editorBase:o,drifted:!1});let c=s-o>n.text.length;o==this.from&&i<this.from?o=i:s==this.to&&i>this.to&&(s=i);let l=DI(e.state.sliceDoc(o,s),n.text,(c?r.from:r.to)-o,c?`end`:null);if(!l){let t=q.single(this.toEditorPos(n.selectionStart),this.toEditorPos(n.selectionEnd));AI(t,r)||e.dispatch({selection:t,userEvent:`select`});return}let u={from:l.from+o,to:l.toA+o,insert:sj.of(n.text.slice(l.from,l.toB).split(`
67
- `))};if((J.mac||J.android)&&u.from==a-1&&/^\. ?$/.test(n.text)&&e.contentDOM.getAttribute(`autocorrect`)==`off`&&(u={from:o,to:s,insert:sj.of([n.text.replace(`.`,` `)])}),this.pendingContextChange=u,!e.state.readOnly){let t=this.to-this.from+(u.to-u.from+u.insert.length);TI(e,u,q.single(this.toEditorPos(n.selectionStart,t),this.toEditorPos(n.selectionEnd,t)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),u.from<u.to&&!u.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let r=[],i=null;for(let t=this.toEditorPos(n.rangeStart),a=this.toEditorPos(n.rangeEnd);t<a;t++){let n=e.coordsForChar(t);i=n&&new DOMRect(n.left,n.top,n.right-n.left,n.bottom-n.top)||i||new DOMRect,r.push(i)}t.updateCharacterBounds(n.rangeStart,r)},this.handlers.textformatupdate=t=>{let n=[];for(let e of t.getTextFormats()){let t=e.underlineStyle,r=e.underlineThickness;if(!/none/i.test(t)&&!/none/i.test(r)){let i=this.toEditorPos(e.rangeStart),a=this.toEditorPos(e.rangeEnd);if(i<a){let e=`text-decoration: underline ${/^[a-z]/.test(t)?t+` `:t==`Dashed`?`dashed `:t==`Squiggle`?`wavy `:``}${/thin/i.test(r)?1:2}px`;n.push(AN.mark({attributes:{style:e}}).range(i,a))}}}e.dispatch({effects:ZP.of(AN.set(n))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:t}=this.composing;this.composing=null,t&&this.reset(e.state)}};for(let e in this.handlers)t.addEventListener(e,this.handlers[e]);this.measureReq={read:e=>{let t=BN(e.root);t&&t.rangeCount&&this.editContext.updateSelectionBounds(t.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,r=this.pendingContextChange;return e.changes.iterChanges((i,a,o,s,c)=>{if(n)return;let l=c.length-(a-i);if(r&&a>=r.to){if(r.from==i&&r.to==a&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=l,this.to+=l;return}r=null,this.revertPending(e.state)}if(i+=t,a+=t,a<=this.from)this.from+=l,this.to+=l;else if(i<this.to){if(i<this.from||a>this.to||this.to-this.from+c.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(i),this.toContextPos(a),c.toString()),this.to+=l}t+=l}),r&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(e=>!e.isUserEvent(`input.type`)&&e.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(n,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>3e4)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},Y=class e{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.clearAnnouncement=-1,this.contentDOM=document.createElement(`div`),this.scrollDOM=document.createElement(`div`),this.scrollDOM.tabIndex=-1,this.scrollDOM.className=`cm-scroller`,this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement(`div`),this.announceDOM.className=`cm-announced`,this.announceDOM.setAttribute(`aria-live`,`polite`),this.dom=document.createElement(`div`),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:t}=e;this.dispatchTransactions=e.dispatchTransactions||t&&(e=>e.forEach(e=>t(e,this)))||(e=>this.update(e)),this.dispatch=this.dispatch.bind(this),this._root=e.root||cP(e.parent)||document,this.viewState=new BL(this,e.state||EM.create(e)),e.scrollTo&&e.scrollTo.is(XP)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(tF).map(e=>new rF(e));for(let e of this.plugins)e.update(this);this.observer=new oR(this),this.inputState=new jI(this),this.inputState.ensureHandlers(this.plugins),this.docView=new GF(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),document.fonts?.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent=`refresh`,this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof fM?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(t){if(this.updateState!=0)throw Error(`Calls to EditorView.update are not allowed while an update is in progress`);let n=!1,r=!1,i,a=this.state;for(let e of t){if(e.startState!=a)throw RangeError(`Trying to update state with a transaction that doesn't start from the previous state.`);a=e.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,c=null;t.some(e=>e.annotation(uL))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,c=dL(a,o),c||(s=1));let l=this.observer.delayedAndroidKey,u=null;if(l?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(u=null)):this.observer.clear(),a.facet(EM.phrases)!=this.state.facet(EM.phrases))return this.setState(a);i=gF.create(this,a,t),i.flags|=s;let d=this.viewState.scrollTarget;try{this.updateState=2;for(let n of t){if(d&&=d.map(n.changes),n.scrollIntoView){let{main:t}=n.state.selection,{x:r,y:i}=this.state.facet(e.cursorScrollMargin);d=new YP(t.empty?t:q.cursor(t.head,t.head>t.anchor?-1:1),`nearest`,`nearest`,i,r)}for(let e of n.effects)e.is(XP)&&(d=e.value.clip(this.state))}this.viewState.update(i,d),this.bidiCache=pR.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(mF)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(e=>e.isUserEvent(`select.pointer`)))}finally{this.updateState=0}if(i.startState.facet(XL)!=i.state.facet(XL)&&(this.viewState.mustMeasureContent=!0),(n||r||d||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let e of this.state.facet(VP))try{e(i)}catch(e){QP(this.state,e,`update listener`)}(c||u)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),u&&!wI(this,u)&&l.force&&sP(this.contentDOM,l.key,l.keyCode)})}setState(e){if(this.updateState!=0)throw Error(`Calls to EditorView.setState are not allowed while an update is in progress`);if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let e of this.plugins)e.destroy(this);this.viewState=new BL(this,e),this.plugins=e.facet(tF).map(e=>new rF(e)),this.pluginMap.clear();for(let e of this.plugins)e.update(this);this.docView.destroy(),this.docView=new GF(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(tF),n=e.state.facet(tF);if(t!=n){let r=[];for(let i of n){let n=t.indexOf(i);if(n<0)r.push(new rF(i));else{let t=this.plugins[n];t.mustUpdate=e,r.push(t)}}for(let t of this.plugins)t.mustUpdate!=e&&t.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let t of this.plugins)t.mustUpdate=e;for(let e=0;e<this.plugins.length;e++)this.plugins[e].update(this);t!=n&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(e){QP(this.state,e,`doc view update listener`)}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:i,scrollAnchorHeight:a,scaleY:o}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(a=-1),this.viewState.scrollAnchorHeight=-1;try{for(let e=0;;e++){if(a<0){if(uP(n||this.win))i=-1,a=this.viewState.heightMap.height/this.viewState.scaleY;else{let e=this.viewState.scrollAnchorAt(r);i=e.from,a=e.top}o=this.viewState.scaleY}this.updateState=1;let s=this.viewState.measure();if(!s&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(e>5){console.warn(this.measureRequests.length?`Measure loop restarted more than 5 times`:`Viewport failed to stabilize`);break}let c=[];s&4||([this.measureRequests,c]=[c,this.measureRequests]);let l=c.map(e=>{try{return e.read(this)}catch(e){return QP(this.state,e),fR}}),u=gF.create(this,this.state,[]),d=!1;u.flags|=s,t?t.flags|=s:t=u,this.updateState=2,u.empty||(this.updatePlugins(u),this.inputState.update(u),this.updateAttrs(),d=this.docView.update(u),d&&this.docViewUpdate());for(let e=0;e<c.length;e++)if(l[e]!=fR)try{let t=c[e];t.write&&t.write(l[e],this)}catch(e){QP(this.state,e)}if(d&&this.docView.updateSelection(!0),!u.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight){if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,a=-1;continue}{let e=(i<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(i).top)/this.viewState.scaleY-a/o;if((e>1||e<-1)&&!(J.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(n==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r+=e,n?i<0?n.scrollTop=n.scrollHeight:n.scrollTop+=e:this.win.scrollBy(0,e),a=-1;continue}}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let e of this.state.facet(VP))e(t)}get themeClasses(){return QL+` `+(this.state.facet(ZL)?eR:$L)+` `+this.state.facet(XL)}updateAttrs(){let e=mR(this,iF,{class:`cm-editor`+(this.hasFocus?` cm-focused `:` `)+this.themeClasses}),t={spellcheck:`false`,autocorrect:`off`,autocapitalize:`off`,writingsuggestions:`false`,translate:`no`,contenteditable:this.state.facet($P)?`true`:`false`,class:`cm-content`,style:`${J.tabSize}: ${this.state.tabSize}`,role:`textbox`,"aria-multiline":`true`};this.state.readOnly&&(t[`aria-readonly`]=`true`),mR(this,aF,t);let n=this.observer.ignore(()=>{let n=EN(this.contentDOM,this.contentAttrs,t),r=EN(this.dom,this.editorAttrs,e);return n||r});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(t){let n=!0;for(let r of t)for(let t of r.effects)if(t.is(e.announce)){n&&=(this.announceDOM.textContent=``,this.win.clearTimeout(this.clearAnnouncement),this.clearAnnouncement=this.win.setTimeout(()=>{this.announceDOM.textContent=`\xA0`},200),!1);let e=this.announceDOM.appendChild(document.createElement(`div`));e.textContent=t.value}}mountStyles(){this.styleModules=this.state.facet(mF);let t=this.state.facet(e.cspNonce);$M.mount(this.root,this.styleModules.concat(rR).reverse(),t?{nonce:t}:void 0)}readMeasured(){if(this.updateState==2)throw Error(`Reading the editor layout isn't allowed during an update`);this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(t=>t.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return pI(this,e,cI(this,e,t,n))}moveByGroup(e,t){return pI(this,e,cI(this,e,t,t=>lI(this,e.head,t)))}visualLineSide(e,t){return t?q.cursor(e.to,1):q.cursor(e.from,-1)}moveToLineBoundary(e,t,n=!0){return sI(this,e,t,n)}moveVertically(e,t,n){return pI(this,e,uI(this,e,t,n))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let n=hI(this,e,t);return n&&n.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),hI(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.state.doc.lineAt(e),r=this.bidiSpans(n),i=r[wP.find(r,e-n.from,-1,t)];return n.length&&(e==n.from&&t<0||e==n.to&&t>0)&&i.dir!=this.textDirectionAt(n.from)&&(e==n.to?(e=n.from+i.from,t=1):(e=n.from+i.to,t=-1)),this.docView.coordsAt(e,t,i.dir==mP.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(KP)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>dR)return NP(e.length);let t=this.textDirectionAt(e.from),n;for(let r of this.bidiCache)if(r.from==e.from&&r.dir==t&&(r.fresh||TP(r.isolates,n=dF(this,e))))return r.order;n||=dF(this,e);let r=MP(e.text,t,n);return this.bidiCache.push(new pR(e.from,e.to,t,n,!0,r)),r}get hasFocus(){return(this.dom.ownerDocument.hasFocus()||J.safari&&this.inputState?.lastContextMenu>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{iP(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.win.clearTimeout(this.clearAnnouncement),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return XP.of(new YP(typeof e==`number`?q.cursor(e):e,t.y??`nearest`,t.x??`nearest`,t.yMargin??5,t.xMargin??5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return XP.of(new YP(q.cursor(n.from),`start`,`start`,n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e==`boolean`?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return nF.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return nF.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=$M.newName(),r=[XL.of(n),mF.of(nR(`.${n}`,e))];return t&&t.dark&&r.push(ZL.of(!0)),r}static baseTheme(e){return qj.lowest(mF.of(nR(`.`+QL,e,tR)))}static findFromDOM(e){let t=e.querySelector(`.cm-content`);return(t&&vF.get(t)||vF.get(e))?.root?.view||null}};Y.styleModule=mF,Y.inputHandler=HP,Y.clipboardInputFilter=WP,Y.clipboardOutputFilter=GP,Y.scrollHandler=JP,Y.focusChangeEffect=UP,Y.perLineTextDirection=KP,Y.exceptionSink=BP,Y.updateListener=VP,Y.editable=$P,Y.mouseSelectionStyle=zP,Y.dragMovesSelection=RP,Y.clickAddsSelectionRange=LP,Y.decorations=oF,Y.blockWrappers=sF,Y.outerDecorations=cF,Y.atomicRanges=lF,Y.bidiIsolatedRanges=uF,Y.cursorScrollMargin=Lj.define({combine:e=>{let t=5,n=5;for(let r of e)typeof r==`number`?t=n=r:{x:t,y:n}=r;return{x:t,y:n}}}),Y.scrollMargins=fF,Y.darkTheme=ZL,Y.cspNonce=Lj.define({combine:e=>e.length?e[0]:``}),Y.contentAttributes=aF,Y.editorAttributes=iF,Y.lineWrapping=Y.contentAttributes.of({class:`cm-lineWrapping`}),Y.announce=dM.define();var dR=4096,fR={},pR=class e{constructor(e,t,n,r,i,a){this.from=e,this.to=t,this.dir=n,this.isolates=r,this.fresh=i,this.order=a}static update(t,n){if(n.empty&&!t.some(e=>e.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:mP.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let o=t[a];o.dir==i&&!n.touchesRange(o.from,o.to)&&r.push(new e(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}};function mR(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let t=r[i],a=typeof t==`function`?t(e):t;a&&SN(a,n)}return n}var hR=J.mac?`mac`:J.windows?`win`:J.linux?`linux`:`key`;function gR(e,t){let n=e.split(/-(?!$)/),r=n[n.length-1];r==`Space`&&(r=` `);let i,a,o,s;for(let e=0;e<n.length-1;++e){let r=n[e];if(/^(cmd|meta|m)$/i.test(r))s=!0;else if(/^a(lt)?$/i.test(r))i=!0;else if(/^(c|ctrl|control)$/i.test(r))a=!0;else if(/^s(hift)?$/i.test(r))o=!0;else if(/^mod$/i.test(r))t==`mac`?s=!0:a=!0;else throw Error(`Unrecognized modifier name: `+r)}return i&&(r=`Alt-`+r),a&&(r=`Ctrl-`+r),s&&(r=`Meta-`+r),o&&(r=`Shift-`+r),r}function _R(e,t,n){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n!==!1&&t.shiftKey&&(e=`Shift-`+e),e}var vR=qj.default(Y.domEventHandlers({keydown(e,t){return DR(xR(t.state),e,t,`editor`)}})),yR=Lj.define({enables:vR}),bR=new WeakMap;function xR(e){let t=e.facet(yR),n=bR.get(t);return n||bR.set(t,n=TR(t.reduce((e,t)=>e.concat(t),[]))),n}function SR(e,t,n){return DR(xR(e.state),t,e,n)}var CR=null,wR=4e3;function TR(e,t=hR){let n=Object.create(null),r=Object.create(null),i=(e,t)=>{let n=r[e];if(n==null)r[e]=t;else if(n!=t)throw Error(`Key binding `+e+` is used both as a regular binding and as a multi-stroke prefix`)},a=(e,r,a,o,s)=>{let c=n[e]||(n[e]=Object.create(null)),l=r.split(/ (?!$)/).map(e=>gR(e,t));for(let t=1;t<l.length;t++){let n=l.slice(0,t).join(` `);i(n,!0),c[n]||(c[n]={preventDefault:!0,stopPropagation:!1,run:[t=>{let r=CR={view:t,prefix:n,scope:e};return setTimeout(()=>{CR==r&&(CR=null)},wR),!0}]})}let u=l.join(` `);i(u,!1);let d=c[u]||(c[u]={preventDefault:!1,stopPropagation:!1,run:(c._any?.run)?.slice()||[]});a&&d.run.push(a),o&&(d.preventDefault=!0),s&&(d.stopPropagation=!0)};for(let r of e){let e=r.scope?r.scope.split(` `):[`editor`];if(r.any)for(let t of e){let e=n[t]||(n[t]=Object.create(null));e._any||={preventDefault:!1,stopPropagation:!1,run:[]};let{any:i}=r;for(let t in e)e[t].run.push(e=>i(e,ER))}let i=r[t]||r.key;if(i)for(let t of e)a(t,i,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(t,`Shift-`+i,r.shift,r.preventDefault,r.stopPropagation)}return n}var ER=null;function DR(e,t,n,r){ER=t;let i=cN(t),a=Cj(xj(i,0))==i.length&&i!=` `,o=``,s=!1,c=!1,l=!1;CR&&CR.view==n&&CR.scope==r&&(o=CR.prefix+` `,LI.indexOf(t.keyCode)<0&&(c=!0,CR=null));let u=new Set,d=e=>{if(e){for(let t of e.run)if(!u.has(t)&&(u.add(t),t(n)))return e.stopPropagation&&(l=!0),!0;e.preventDefault&&(e.stopPropagation&&(l=!0),c=!0)}return!1},f=e[r],p,m;return f&&(d(f[o+_R(i,t,!a)])?s=!0:a&&(t.altKey||t.metaKey||t.ctrlKey)&&!(J.windows&&t.ctrlKey&&t.altKey)&&!(J.mac&&t.altKey&&!(t.ctrlKey||t.metaKey))&&(p=nN[t.keyCode])&&p!=i?(d(f[o+_R(p,t,!0)])||t.shiftKey&&(m=rN[t.keyCode])!=i&&m!=p&&d(f[o+_R(m,t,!1)]))&&(s=!0):a&&t.shiftKey&&d(f[o+_R(i,t,!0)])&&(s=!0),!s&&d(f._any)&&(s=!0)),c&&(s=!0),s&&l&&t.stopPropagation(),ER=null,s}var OR=!J.ios,kR=J.gecko&&J.gecko_version==153?`#ffffff01`:`transparent`;({...OR?{"& ::selection, &::selection":{backgroundColor:`${kR} !important`}}:{}}),{...OR?{"&::selection, & ::selection":{backgroundColor:`Highlight !important`}}:{}},/x/.unicode;var AR=class extends ON{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement(`span`);return t.className=`cm-placeholder`,t.style.pointerEvents=`none`,t.appendChild(typeof this.content==`string`?document.createTextNode(this.content):typeof this.content==`function`?this.content(e):this.content.cloneNode(!0)),t.setAttribute(`aria-hidden`,`true`),t}coordsAt(e){let t=e.firstChild?UN(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),r=YN(t[0],n.direction!=`rtl`),i=parseInt(n.lineHeight);return r.bottom-r.top>i*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+i}:r}ignoreEvent(){return!1}};function jR(e){let t=nF.fromClass(class{constructor(t){this.view=t,this.placeholder=e?AN.set([AN.widget({widget:new AR(e),side:1}).range(0)]):AN.none}get decorations(){return this.view.state.doc.length?AN.none:this.placeholder}},{decorations:e=>e.decorations});return typeof e==`string`?[t,Y.contentAttributes.of({"aria-placeholder":e})]:t}var MR=`-10000px`,NR=class{constructor(e,t,n,r){this.facet=t,this.createTooltipView=n,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(e=>e);let i=null;this.tooltipViews=this.tooltips.map(e=>i=n(e,i))}update(e,t){var n;let r=e.state.facet(this.facet),i=r.filter(e=>e);if(r===this.input){for(let t of this.tooltipViews)t.update&&t.update(e);return!1}let a=[],o=t?[]:null;for(let n=0;n<i.length;n++){let r=i[n],s=-1;if(r){for(let e=0;e<this.tooltips.length;e++){let t=this.tooltips[e];t&&t.create==r.create&&(s=e)}if(s<0)a[n]=this.createTooltipView(r,n?a[n-1]:null),o&&(o[n]=!!r.above);else{let r=a[n]=this.tooltipViews[s];o&&(o[n]=t[s]),r.update&&r.update(e)}}}for(let e of this.tooltipViews)a.indexOf(e)<0&&(this.removeTooltipView(e),(n=e.destroy)==null||n.call(e));return t&&(o.forEach((e,n)=>t[n]=e),t.length=o.length),this.input=r,this.tooltips=i,this.tooltipViews=a,!0}};function PR(e){let t=e.dom.ownerDocument.documentElement,n=t.clientWidth,r=getComputedStyle(t);if(!/stable/.test(r.scrollbarGutter||``))return{left:0,right:n};let i=t.getBoundingClientRect(),a=e.win.scrollX;return{left:Math.max(0,i.left+a-parseFloat(r.marginLeft)),right:Math.min(n,i.right+a+parseFloat(r.marginRight))}}function FR(e){let{left:t,right:n}=PR(e);return{top:0,left:t,right:n,bottom:e.dom.ownerDocument.documentElement.clientHeight}}var IR=Lj.define({combine:e=>({position:J.ios?`absolute`:e.find(e=>e.position)?.position||`fixed`,parent:e.find(e=>e.parent)?.parent||null,tooltipSpace:e.find(e=>e.tooltipSpace)?.tooltipSpace||FR})}),LR=new WeakMap,RR=nF.fromClass(class{constructor(e){this.view=e,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let t=e.state.facet(IR);this.position=t.position,this.parent=t.parent,this.classes=e.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver==`function`?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new NR(e,HR,(e,t)=>this.createTooltip(e,t),e=>{this.resizeObserver&&this.resizeObserver.unobserve(e.dom),e.dom.remove()}),this.above=this.manager.tooltips.map(e=>!!e.above),this.intersectionObserver=typeof IntersectionObserver==`function`?new IntersectionObserver(e=>{Date.now()>this.lastTransaction-50&&e.length>0&&e[e.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),e.win.addEventListener(`resize`,this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement(`div`),this.container.style.position=`relative`,this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let e of this.manager.tooltipViews)this.intersectionObserver.observe(e.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(e){e.transactions.length&&(this.lastTransaction=Date.now());let t=this.manager.update(e,this.above);t&&this.observeIntersection();let n=t||e.geometryChanged,r=e.state.facet(IR);if(r.position!=this.position&&!this.madeAbsolute){this.position=r.position;for(let e of this.manager.tooltipViews)e.dom.style.position=this.position;n=!0}if(r.parent!=this.parent){this.parent&&this.container.remove(),this.parent=r.parent,this.createContainer();for(let e of this.manager.tooltipViews)this.container.appendChild(e.dom);n=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);n&&this.maybeMeasure()}createTooltip(e,t){let n=e.create(this.view),r=t?t.dom:null;if(n.dom.classList.add(`cm-tooltip`),e.arrow&&!n.dom.querySelector(`.cm-tooltip > .cm-tooltip-arrow`)){let e=document.createElement(`div`);e.className=`cm-tooltip-arrow`,n.dom.appendChild(e)}return n.dom.style.position=this.position,n.dom.style.top=MR,n.dom.style.left=`0px`,this.container.insertBefore(n.dom,r),n.mount&&n.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(n.dom),n}destroy(){var e,t,n;this.view.win.removeEventListener(`resize`,this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(e=t.destroy)==null||e.call(t);this.parent&&this.container.remove(),(t=this.resizeObserver)==null||t.disconnect(),(n=this.intersectionObserver)==null||n.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let e=1,t=1,n=!1,r=0;if(this.position==`fixed`&&this.manager.tooltipViews.length){let{dom:e}=this.manager.tooltipViews[0];if(J.safari){let t=e.getBoundingClientRect();n=Math.abs(t.top+1e4)>1||Math.abs(t.left)>1}else n=!!e.offsetParent&&e.offsetParent!=this.container.ownerDocument.body}if(n||this.position==`absolute`){if(this.parent){let n=this.parent.getBoundingClientRect();n.width&&n.height&&(e=n.width/this.parent.offsetWidth,t=n.height/this.parent.offsetHeight)}else({scaleX:e,scaleY:t}=this.view.viewState)}else r=PR(this.view).left;let i=this.view.scrollDOM.getBoundingClientRect(),a=pF(this.view);return{visible:{left:i.left+a.left,top:i.top+a.top,right:i.right-a.right,bottom:i.bottom-a.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((e,t)=>{let n=this.manager.tooltipViews[t];return n.getCoords?n.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(IR).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n,fixedLeft:r}}writeMeasure(e){if(e.makeAbsolute){this.madeAbsolute=!0,this.position=`absolute`;for(let e of this.manager.tooltipViews)e.dom.style.position=`absolute`}let{visible:t,space:n,scaleX:r,scaleY:i}=e,a=[];for(let o=0;o<this.manager.tooltips.length;o++){let s=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:l}=c,u=e.pos[o],d=e.size[o];if(!u||s.clip!==!1&&(u.bottom<=Math.max(t.top,n.top)||u.top>=Math.min(t.bottom,n.bottom)||u.right<Math.max(t.left,n.left)-.1||u.left>Math.min(t.right,n.right)+.1)){l.style.top=MR;continue}let f=s.arrow?c.dom.querySelector(`.cm-tooltip-arrow`):null,p=f?7:0,m=d.right-d.left,h=LR.get(c)??d.bottom-d.top,g=c.offset||VR,_=this.view.textDirection==mP.LTR,v=d.width>n.right-n.left?_?n.left:n.right-d.width:_?Math.max(n.left,Math.min(u.left-(f?14:0)+g.x,n.right-m)):Math.min(Math.max(n.left,u.left-m+(f?14:0)-g.x),n.right-m),y=this.above[o];!s.strictSide&&(y?u.top-h-p-g.y<n.top:u.bottom+h+p+g.y>n.bottom)&&y==n.bottom-u.bottom>u.top-n.top&&(y=this.above[o]=!y);let b=(y?u.top-n.top:n.bottom-u.bottom)-p;if(b<h&&c.resize!==!1){if(b<this.view.defaultLineHeight){l.style.top=MR;continue}LR.set(c,h),l.style.height=(h=b)/i+`px`}else l.style.height&&(l.style.height=``);let x=y?u.top-h-p-g.y:u.bottom+p+g.y,S=v+m;if(c.overlap!==!0)for(let e of a)e.left<S&&e.right>v&&e.top<x+h&&e.bottom>x&&(x=y?e.top-h-2-p:e.bottom+p+2);if(this.position==`absolute`?(l.style.top=(x-e.parent.top)/i+`px`,zR(l,(v-e.parent.left)/r)):(l.style.top=x/i+`px`,zR(l,(v-e.fixedLeft)/r)),f){let e=u.left+(_?g.x:-g.x)-(v+14-7);f.style.left=e/r+`px`}c.overlap!==!0&&a.push({left:v,top:x,right:S,bottom:x+h}),l.classList.toggle(`cm-tooltip-above`,y),l.classList.toggle(`cm-tooltip-below`,!y),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=MR}},{eventObservers:{scroll(){this.maybeMeasure()}}});function zR(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+`px`)}var BR=Y.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:`border-box`},"&light .cm-tooltip":{border:`1px solid #bbb`,backgroundColor:`#f5f5f5`},"&light .cm-tooltip-section:not(:first-child)":{borderTop:`1px solid #bbb`},"&dark .cm-tooltip":{backgroundColor:`#333338`,color:`white`},".cm-tooltip-arrow":{height:`7px`,width:`14px`,position:`absolute`,zIndex:-1,overflow:`hidden`,"&:before, &:after":{content:`''`,position:`absolute`,width:0,height:0,borderLeft:`7px solid transparent`,borderRight:`7px solid transparent`},".cm-tooltip-above &":{bottom:`-7px`,"&:before":{borderTop:`7px solid #bbb`},"&:after":{borderTop:`7px solid #f5f5f5`,bottom:`1px`}},".cm-tooltip-below &":{top:`-7px`,"&:before":{borderBottom:`7px solid #bbb`},"&:after":{borderBottom:`7px solid #f5f5f5`,top:`1px`}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:`#333338`,borderBottomColor:`#333338`},"&:after":{borderTopColor:`transparent`,borderBottomColor:`transparent`}}}),VR={x:0,y:0},HR=Lj.define({enables:[RR,BR]});function UR(e,t){let n=e.plugin(RR);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}var WR=Lj.define({combine(e){let t,n;for(let r of e)t||=r.topContainer,n||=r.bottomContainer;return{topContainer:t,bottomContainer:n}}});function GR(e,t){let n=e.plugin(KR),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}var KR=nF.fromClass(class{constructor(e){this.input=e.state.facet(YR),this.specs=this.input.filter(e=>e),this.panels=this.specs.map(t=>t(e));let t=e.state.facet(WR);this.top=new qR(e,!0,t.topContainer),this.bottom=new qR(e,!1,t.bottomContainer),this.top.sync(this.panels.filter(e=>e.top)),this.bottom.sync(this.panels.filter(e=>!e.top));for(let e of this.panels)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}update(e){let t=e.state.facet(WR);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new qR(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new qR(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(YR);if(n!=this.input){let t=n.filter(e=>e),r=[],i=[],a=[],o=[];for(let n of t){let t=this.specs.indexOf(n),s;t<0?(s=n(e.view),o.push(s)):(s=this.panels[t],s.update&&s.update(e)),r.push(s),(s.top?i:a).push(s)}this.specs=t,this.panels=r,this.top.sync(i),this.bottom.sync(a);for(let e of o)e.dom.classList.add(`cm-panel`),e.mount&&e.mount()}else for(let t of this.panels)t.update&&t.update(e)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:e=>Y.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})}),qR=class{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes=``,this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&=(this.dom.remove(),void 0);return}if(!this.dom){this.dom=document.createElement(`div`),this.dom.className=this.top?`cm-panels cm-panels-top`:`cm-panels cm-panels-bottom`;let e=this.container||this.view.dom;e.insertBefore(this.dom,this.top?e.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=JR(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=JR(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(this.container&&this.classes!=this.view.themeClasses){for(let e of this.classes.split(` `))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(` `))e&&this.container.classList.add(e)}}};function JR(e){let t=e.nextSibling;return e.remove(),t}var YR=Lj.define({enables:KR});function XR(e,t){let n,r=new Promise(e=>n=e),i=e=>tz(e,t,n);e.state.field(QR,!1)?e.dispatch({effects:$R.of(i)}):e.dispatch({effects:dM.appendConfig.of(QR.init(()=>[i]))});let a=ez.of(i);return{close:a,result:r.then(t=>((e.win.queueMicrotask||(t=>e.win.setTimeout(t,10)))(()=>{e.state.field(QR).indexOf(i)>-1&&e.dispatch({effects:a})}),t))}}function ZR(e,t){let n=e.state.field(QR,!1)||[];for(let r of n){let n=GR(e,r);if(n&&n.dom.classList.contains(t))return n}return null}var QR=Wj.define({create(){return[]},update(e,t){for(let n of t.effects)n.is($R)?e=[n.value].concat(e):n.is(ez)&&(e=e.filter(e=>e!=n.value));return e},provide:e=>YR.computeN([e],t=>t.field(e))}),$R=dM.define(),ez=dM.define();function tz(e,t,n){let r=t.content?t.content(e,()=>o(null)):null;if(!r){if(r=lN(`form`),t.input){let e=lN(`input`,t.input);/^(text|password|number|email|tel|url)$/.test(e.type)&&e.classList.add(`cm-textfield`),e.name||=`input`,r.appendChild(lN(`label`,(t.label||``)+`: `,e))}else r.appendChild(document.createTextNode(t.label||``));r.appendChild(document.createTextNode(` `)),r.appendChild(lN(`button`,{class:`cm-button`,type:`submit`},t.submitLabel||`OK`))}let i=r.nodeName==`FORM`?[r]:r.querySelectorAll(`form`);for(let e=0;e<i.length;e++){let t=i[e];t.addEventListener(`keydown`,e=>{e.keyCode==27?(e.preventDefault(),o(null)):e.keyCode==13&&(e.preventDefault(),o(t))}),t.addEventListener(`submit`,e=>{e.preventDefault(),o(t)})}let a=lN(`div`,r,lN(`button`,{onclick:()=>o(null),"aria-label":e.state.phrase(`close`),class:`cm-dialog-close`,type:`button`},[`×`]));t.class&&(a.className=t.class),a.classList.add(`cm-dialog`);function o(t){a.contains(a.ownerDocument.activeElement)&&e.focus(),n(t)}return{dom:a,top:t.top,mount:()=>{if(t.focus){let e;e=typeof t.focus==`string`?r.querySelector(t.focus):r.querySelector(`input`)||r.querySelector(`button`),e&&`select`in e?e.select():e&&`focus`in e&&e.focus()}}}}var nz=class extends OM{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};nz.prototype.elementClass=``,nz.prototype.toDOM=void 0,nz.prototype.mapMode=Tj.TrackBefore,nz.prototype.startSide=nz.prototype.endSide=-1,nz.prototype.point=!0;var rz=1024,iz=0,az=class{constructor(e,t){this.from=e,this.to=t}},oz=class{constructor(e={}){this.id=iz++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw Error(`This node type doesn't define a deserialize function`)}),this.combine=e.combine||null}add(e){if(this.perNode)throw RangeError(`Can't add per-node props to node types`);return typeof e!=`function`&&(e=lz.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}};oz.closedBy=new oz({deserialize:e=>e.split(` `)}),oz.openedBy=new oz({deserialize:e=>e.split(` `)}),oz.group=new oz({deserialize:e=>e.split(` `)}),oz.isolate=new oz({deserialize:e=>{if(e&&e!=`rtl`&&e!=`ltr`&&e!=`auto`)throw RangeError(`Invalid value for isolate: `+e);return e||`auto`}}),oz.contextHash=new oz({perNode:!0}),oz.lookAhead=new oz({perNode:!0}),oz.mounted=new oz({perNode:!0});var sz=class{constructor(e,t,n,r=!1){this.tree=e,this.overlay=t,this.parser=n,this.bracketed=r}static get(e){return e&&e.props&&e.props[oz.mounted.id]}},cz=Object.create(null),lz=class e{constructor(e,t,n,r=0){this.name=e,this.props=t,this.id=n,this.flags=r}static define(t){let n=t.props&&t.props.length?Object.create(null):cz,r=+!!t.top|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new e(t.name||``,n,t.id,r);if(t.props){for(let e of t.props)if(Array.isArray(e)||(e=e(i)),e){if(e[0].perNode)throw RangeError(`Can't store a per-node prop on a node type`);n[e[0].id]=e[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e==`string`){if(this.name==e)return!0;let t=this.prop(oz.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let r of n.split(` `))t[r]=e[n];return e=>{for(let n=e.prop(oz.group),r=-1;r<(n?n.length:0);r++){let i=t[r<0?e.name:n[r]];if(i)return i}}}};lz.none=new lz(``,Object.create(null),0,8);var uz=new WeakMap,dz=new WeakMap,fz;(function(e){e[e.ExcludeBuffers=1]=`ExcludeBuffers`,e[e.IncludeAnonymous=2]=`IncludeAnonymous`,e[e.IgnoreMounts=4]=`IgnoreMounts`,e[e.IgnoreOverlays=8]=`IgnoreOverlays`,e[e.EnterBracketed=16]=`EnterBracketed`})(fz||={});var pz=class e{constructor(e,t,n,r,i){if(this.type=e,this.children=t,this.positions=n,this.length=r,this.props=null,i&&i.length){this.props=Object.create(null);for(let[e,t]of i)this.props[typeof e==`number`?e:e.id]=t}}toString(){let e=sz.get(this);if(e&&!e.overlay)return e.tree.toString();let t=``;for(let e of this.children){let n=e.toString();n&&(t&&(t+=`,`),t+=n)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?`(`+t+`)`:``):t}cursor(e=0){return new Dz(this.topNode,e)}cursorAt(e,t=0,n=0){let r=new Dz(uz.get(this)||this.topNode);return r.moveTo(e,t),uz.set(this,r._tree),r}get topNode(){return new yz(this,0,0,null)}resolve(e,t=0){let n=_z(uz.get(this)||this.topNode,e,t,!1);return uz.set(this,n),n}resolveInner(e,t=0){let n=_z(dz.get(this)||this.topNode,e,t,!0);return dz.set(this,n),n}resolveStack(e,t=0){return Ez(this,e,t)}iterate(e){let{enter:t,leave:n,from:r=0,to:i=this.length}=e,a=e.mode||0,o=(a&fz.IncludeAnonymous)>0;for(let e=this.cursor(a|fz.IncludeAnonymous);;){let a=!1;if(e.from<=i&&e.to>=r&&(!o&&e.type.isAnonymous||t(e)!==!1)){if(e.firstChild())continue;a=!0}for(;a&&n&&(o||!e.type.isAnonymous)&&n(e),!e.nextSibling();){if(!e.parent())return;a=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(t={}){return this.children.length<=8?this:Mz(lz.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,r)=>new e(this.type,t,n,r,this.propValues),t.makeTree||((t,n,r)=>new e(lz.none,t,n,r)))}static build(e){return kz(e)}};pz.empty=new pz(lz.none,[],[],0);var mz=class e{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e(this.buffer,this.index)}},hz=class e{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return lz.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(`,`)}childString(e){let t=this.buffer[e],n=this.buffer[e+3],r=this.set.types[t],i=r.name;if(/\W/.test(i)&&!r.isError&&(i=JSON.stringify(i)),e+=4,n==e)return i;let a=[];for(;e<n;)a.push(this.childString(e)),e=this.buffer[e+3];return i+`(`+a.join(`,`)+`)`}findChild(e,t,n,r,i){let{buffer:a}=this,o=-1;for(let s=e;s!=t&&!(gz(i,r,a[s+1],a[s+2])&&(o=s,n>0));s=a[s+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),o=0;for(let e=t,s=0;e<n;){a[s++]=i[e++],a[s++]=i[e++]-r;let n=a[s++]=i[e++]-r;a[s++]=i[e++]-t,o=Math.max(o,n)}return new e(a,o,this.set)}};function gz(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function _z(e,t,n,r){for(;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let t=!r&&e instanceof yz&&e.index<0?null:e.parent;if(!t)return e;e=t}let i=r?0:fz.IgnoreOverlays;if(r)for(let r=e,a=r.parent;a;r=a,a=r.parent)r instanceof yz&&r.index<0&&a.enter(t,n,i)?.from!=r.from&&(e=a);for(;;){let r=e.enter(t,n,i);if(!r)return e;e=r}}var vz=class{cursor(e=0){return new Dz(this,e)}getChild(e,t=null,n=null){let r=bz(this,e,t,n);return r.length?r[0]:null}getChildren(e,t=null,n=null){return bz(this,e,t,n)}resolve(e,t=0){return _z(this,e,t,!1)}resolveInner(e,t=0){return _z(this,e,t,!0)}matchContext(e){return xz(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),n=this;for(;t;){let e=t.lastChild;if(!e||e.to!=t.to)break;e.type.isError&&e.from==e.to?(n=t,t=e.prevSibling):t=e}return n}get node(){return this}get next(){return this.parent}},yz=class e extends vz{constructor(e,t,n,r){super(),this._tree=e,this.from=t,this.index=n,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let o=this;;){for(let{children:s,positions:c}=o._tree,l=n>0?s.length:-1;t!=l;t+=n){let l=s[t],u=c[t]+o.from,d;if(a&fz.EnterBracketed&&l instanceof pz&&(d=sz.get(l))&&!d.overlay&&d.bracketed&&r>=u&&r<=u+l.length||gz(i,r,u,u+l.length)){if(l instanceof hz){if(a&fz.ExcludeBuffers)continue;let e=l.findChild(0,l.buffer.length,n,r-u,i);if(e>-1)return new Cz(new Sz(o,l,t,u),null,e)}else if(a&fz.IncludeAnonymous||!l.type.isAnonymous||Oz(l)){let s;if(!(a&fz.IgnoreMounts)&&(s=sz.get(l))&&!s.overlay)return new e(s.tree,u,t,o);let c=new e(l,u,t,o);return a&fz.IncludeAnonymous||!c.type.isAnonymous?c:c.nextChild(n<0?l.children.length-1:0,n,r,i,a)}}}if(a&fz.IncludeAnonymous||!o.type.isAnonymous||(t=o.index>=0?o.index+n:n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(t,n,r=0){let i;if(!(r&fz.IgnoreOverlays)&&(i=sz.get(this._tree))&&i.overlay){let a=t-this.from,o=r&fz.EnterBracketed&&i.bracketed;for(let{from:t,to:r}of i.overlay)if((n>0||o?t<=a:t<a)&&(n<0||o?r>=a:r>a))return new e(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function bz(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let e=!1;!e;)if(e=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function xz(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}var Sz=class{constructor(e,t,n,r){this.parent=e,this.buffer=t,this.index=n,this.start=r}},Cz=class e extends vz{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new e(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(t,n,r=0){if(r&fz.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new e(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new e(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new e(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,r=this.index+4,i=n.buffer[this.index+3];if(i>r){let a=n.buffer[this.index+1];e.push(n.slice(r,i,a)),t.push(0)}return new pz(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function wz(e){if(!e.length)return null;let t=0,n=e[0];for(let r=1;r<e.length;r++){let i=e[r];(i.from>n.from||i.to<n.to)&&(n=i,t=r)}let r=n instanceof yz&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new Tz(i,n)}var Tz=class{constructor(e,t){this.heads=e,this.node=t}get next(){return wz(this.heads)}};function Ez(e,t,n){let r=e.resolveInner(t,n),i=null;for(let e=r instanceof yz?r:r.context.parent;e;e=e.parent)if(e.index<0){let a=e.parent;(i||=[r]).push(a.resolve(t,n)),e=a}else{let a=sz.get(e.tree);if(a&&a.overlay&&a.overlay[0].from<=t&&a.overlay[a.overlay.length-1].to>=t){let o=new yz(a.tree,a.overlay[0].from+e.from,-1,e);(i||=[r]).push(_z(o,t,n,!1))}}return i?wz(i):r}var Dz=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~fz.EnterBracketed,e instanceof yz)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let t=e._parent;t;t=t._parent)this.stack.unshift(t.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=n+r.buffer[e+1],this.to=n+r.buffer[e+2],!0}yield(e){return e?e instanceof yz?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:r}=this.buffer,i=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,n);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&fz.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&fz.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&fz.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let e=n<0?0:this.stack[n]+4;if(this.index!=e)return this.yieldBuf(t.findChild(e,this.index,-1,0,4))}else{let e=t.buffer[this.index+3];if(e<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(e)}return n<0&&this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode))}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let e=0;e<this.index;e++)if(r.buffer.buffer[e+3]<this.index)return!1;({index:t,parent:n}=r)}else({index:t,_parent:n}=this._tree);for(;n;{index:t,_parent:n}=n)if(t>-1)for(let r=t+e,i=e<0?-1:n._tree.children.length;r!=i;r+=e){let e=n._tree.children[r];if(this.mode&fz.IncludeAnonymous||e instanceof hz||!e.type.isAnonymous||Oz(e))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,n=0;if(e&&e.context==this.buffer)scan:for(let r=this.index,i=this.stack.length;i>=0;){for(let a=e;a;a=a._parent)if(a.index==r){if(r==this.index)return a;t=a,n=i+1;break scan}r=this.stack[--i]}for(let e=n;e<this.stack.length;e++)t=new Cz(this.buffer,t,this.stack[e]);return this.bufferNode=new Cz(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let n=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){n++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!n)return;if(this.nextSibling())break;this.parent(),n--,r=!0}}}matchContext(e){if(!this.buffer)return xz(this.node.parent,e);let{buffer:t}=this.buffer,{types:n}=t.set;for(let r=e.length-1,i=this.stack.length-1;r>=0;i--){if(i<0)return xz(this._tree,e,r);let a=n[t.buffer[this.stack[i]]];if(!a.isAnonymous){if(e[r]&&e[r]!=a.name)return!1;r--}}return!0}};function Oz(e){return e.children.some(e=>e instanceof hz||!e.type.isAnonymous||Oz(e))}function kz(e){let{buffer:t,nodeSet:n,maxBufferLength:r=rz,reused:i=[],minRepeatType:a=n.types.length}=e,o=Array.isArray(t)?new mz(t,t.length):t,s=n.types,c=0,l=0;function u(e,t,_,v,y,b){let{id:x,start:S,end:C,size:w}=o,T=l,E=c;if(w<0){if(o.next(),w==-1){let t=i[x];_.push(t),v.push(S-e);return}if(w==-3){c=x;return}if(w==-4){l=x;return}throw RangeError(`Unrecognized record size: ${w}`)}let D=s[x],O,k,A=S-e;if(C-S<=r&&(k=h(o.pos-t,y))){let t=new Uint16Array(k.size-k.skip),r=o.pos-k.size,i=t.length;for(;o.pos>r;)i=g(k.start,t,i);O=new hz(t,C-k.start,n),A=k.start-e}else{let e=o.pos-w;o.next();let t=[],n=[],i=x>=a?x:-1,s=0,c=C;for(;o.pos>e;)i>=0&&o.id==i&&o.size>=0?(o.end<=c-r&&(p(t,n,S,s,o.end,c,i,T,E),s=t.length,c=o.end),o.next()):b>2500?d(S,e,t,n):u(S,e,t,n,i,b+1);if(i>=0&&s>0&&s<t.length&&p(t,n,S,s,S,c,i,T,E),t.reverse(),n.reverse(),i>-1&&s>0){let e=f(D,E);O=Mz(D,t,n,0,t.length,0,C-S,e,e)}else O=m(D,t,n,C-S,T-C,E)}_.push(O),v.push(A)}function d(e,t,i,a){let s=[],c=0,l=-1;for(;o.pos>t;){let{id:e,start:t,end:n,size:i}=o;if(i>4)o.next();else if(l>-1&&t<l)break;else l<0&&(l=n-r),s.push(e,t,n),c++,o.next()}if(c){let t=new Uint16Array(c*4),r=s[s.length-2];for(let e=s.length-3,n=0;e>=0;e-=3)t[n++]=s[e],t[n++]=s[e+1]-r,t[n++]=s[e+2]-r,t[n++]=n;i.push(new hz(t,s[2]-r,n)),a.push(r-e)}}function f(e,t){return(n,r,i)=>{let a=0,o=n.length-1,s,c;if(o>=0&&(s=n[o])instanceof pz){if(!o&&s.type==e&&s.length==i)return s;(c=s.prop(oz.lookAhead))&&(a=r[o]+s.length+c)}return m(e,n,r,i,a,t)}}function p(e,t,r,i,a,o,s,c,l){let u=[],d=[];for(;e.length>i;)u.push(e.pop()),d.push(t.pop()+r-a);e.push(m(n.types[s],u,d,o-a,c-o,l)),t.push(a-r)}function m(e,t,n,r,i,a,o){if(a){let e=[oz.contextHash,a];o=o?[e].concat(o):[e]}if(i>25){let e=[oz.lookAhead,i];o=o?[e].concat(o):[e]}return new pz(e,t,n,r,o)}function h(e,t){let n=o.fork(),i=0,s=0,c=0,l=n.end-r,u={size:0,start:0,skip:0};scan:for(let r=n.pos-e;n.pos>r;){let e=n.size;if(n.id==t&&e>=0){u.size=i,u.start=s,u.skip=c,c+=4,i+=4,n.next();continue}let o=n.pos-e;if(e<0||o<r||n.start<l)break;let d=n.id>=a?4:0,f=n.start;for(n.next();n.pos>o;){if(n.size<0){if(n.size==-3||n.size==-4)d+=4;else break scan}else n.id>=a&&(d+=4);n.next()}s=f,i+=e,c+=d}return(t<0||i==e)&&(u.size=i,u.start=s,u.skip=c),u.size>4?u:void 0}function g(e,t,n){let{id:r,start:i,end:s,size:u}=o;if(o.next(),u>=0&&r<a){let a=n;if(u>4){let r=o.pos-(u-4);for(;o.pos>r;)n=g(e,t,n)}t[--n]=a,t[--n]=s-e,t[--n]=i-e,t[--n]=r}else u==-3?c=r:u==-4&&(l=r);return n}let _=[],v=[];for(;o.pos>0;)u(e.start||0,e.bufferStart||0,_,v,-1,0);let y=e.length??(_.length?v[0]+_[0].length:0);return new pz(s[e.topID],_.reverse(),v.reverse(),y)}var Az=new WeakMap;function jz(e,t){if(!e.isAnonymous||t instanceof hz||t.type!=e)return 1;let n=Az.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof pz)){n=1;break}n+=jz(e,r)}Az.set(t,n)}return n}function Mz(e,t,n,r,i,a,o,s,c){let l=0;for(let n=r;n<i;n++)l+=jz(e,t[n]);let u=Math.ceil(l*1.5/8),d=[],f=[];function p(t,n,r,i,o){for(let s=r;s<i;){let r=s,l=n[s],m=jz(e,t[s]);for(s++;s<i;s++){let n=jz(e,t[s]);if(m+n>=u)break;m+=n}if(s==r+1){if(m>u){let e=t[r];p(e.children,e.positions,0,e.children.length,n[r]+o);continue}d.push(t[r])}else{let i=n[s-1]+t[s-1].length-l;d.push(Mz(e,t,n,r,s,l,i,null,c))}f.push(l+o-a)}}return p(t,n,r,i,0),(s||c)(d,f,o)}var Nz=class e{constructor(e,t,n,r,i=!1,a=!1){this.from=e,this.to=t,this.tree=n,this.offset=r,this.open=!!i|(a?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new e(0,t.length,t,0,!1,r)];for(let e of n)e.to>t.length&&i.push(e);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,o=t.length?t[0]:null;for(let s=0,c=0,l=0;;s++){let u=s<n.length?n[s]:null,d=u?u.fromA:1e9;if(d-c>=r)for(;o&&o.from<d;){let n=o;if(c>=n.from||d<=n.to||l){let t=Math.max(n.from,c)-l,r=Math.min(n.to,d)-l;n=t>=r?null:new e(t,r,n.tree,n.offset+l,s>0,!!u)}if(n&&i.push(n),o.to>d)break;o=a<t.length?t[a++]:null}if(!u)break;c=u.toA,l=u.toA-u.toB}return i}},Pz=class{startParse(e,t,n){return typeof e==`string`&&(e=new Fz(e)),n=n?n.length?n.map(e=>new az(e.from,e.to)):[new az(0,0)]:[new az(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let r=this.startParse(e,t,n);for(;;){let e=r.advance();if(e)return e}}},Fz=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};new oz({perNode:!0});var Iz=0,Lz=class e{constructor(e,t,n,r){this.name=e,this.set=t,this.base=n,this.modified=r,this.id=Iz++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(t,n){let r=typeof t==`string`?t:`?`;if(t instanceof e&&(n=t),n?.base)throw Error(`Can not derive from a modified tag`);let i=new e(r,[],null,[]);if(i.set.push(i),n)for(let e of n.set)i.set.push(e);return i}static defineModifier(e){let t=new zz(e);return e=>e.modified.indexOf(t)>-1?e:zz.get(e.base||e,e.modified.concat(t).sort((e,t)=>e.id-t.id))}},Rz=0,zz=class e{constructor(e){this.name=e,this.instances=[],this.id=Rz++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(e=>e.base==t&&Bz(n,e.modified));if(r)return r;let i=[],a=new Lz(t.name,i,t,n);for(let e of n)e.instances.push(a);let o=Vz(n);for(let n of t.set)if(!n.modified.length)for(let t of o)i.push(e.get(n,t));return a}};function Bz(e,t){return e.length==t.length&&e.every((e,n)=>e==t[n])}function Vz(e){let t=[[]];for(let n=0;n<e.length;n++)for(let r=0,i=t.length;r<i;r++)t.push(t[r].concat(e[n]));return t.sort((e,t)=>t.length-e.length)}function Hz(e){let t=Object.create(null);for(let n in e){let r=e[n];Array.isArray(r)||(r=[r]);for(let e of n.split(` `))if(e){let n=[],i=2,a=e;for(let t=0;;){if(a==`...`&&t>0&&t+3==e.length){i=1;break}let r=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!r)throw RangeError(`Invalid path: `+e);if(n.push(r[0]==`*`?``:r[0][0]==`"`?JSON.parse(r[0]):r[0]),t+=r[0].length,t==e.length)break;let o=e[t++];if(t==e.length&&o==`!`){i=0;break}if(o!=`/`)throw RangeError(`Invalid path: `+e);a=e.slice(t)}let o=n.length-1,s=n[o];if(!s)throw RangeError(`Invalid path: `+e);t[s]=new Wz(r,i,o>0?n.slice(0,o):null).sort(t[s])}}return Uz.add(t)}var Uz=new oz({combine(e,t){let n,r,i;for(;e||t;){if(!e||t&&e.depth<=t.depth?(i=t,t=t.next):(i=e,e=e.next),n&&n.mode==i.mode&&!i.context&&!n.context)continue;let a=new Wz(i.tags,i.mode,i.context);n?n.next=a:r=a,n=a}return r}}),Wz=class{constructor(e,t,n,r){this.tags=e,this.mode=t,this.context=n,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};Wz.empty=new Wz([],2,null);function Gz(e,t){let n=Object.create(null);for(let t of e)if(!Array.isArray(t.tag))n[t.tag.id]=t.class;else for(let e of t.tag)n[e.id]=t.class;let{scope:r,all:i=null}=t||{};return{style:e=>{let t=i;for(let r of e)for(let e of r.set){let r=n[e.id];if(r){t=t?t+` `+r:r;break}}return t},scope:r}}function Kz(e,t){let n=null;for(let r of e){let e=r.style(t);e&&(n=n?n+` `+e:e)}return n}function qz(e,t,n,r=0,i=e.length){let a=new Jz(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,``,a.highlighters),a.flush(i)}var Jz=class{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=``}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,r,i){let{type:a,from:o,to:s}=e;if(o>=n||s<=t)return;a.isTop&&(i=this.highlighters.filter(e=>!e.scope||e.scope(a)));let c=r,l=Yz(e)||Wz.empty,u=Kz(i,l.tags);if(u&&(c&&(c+=` `),c+=u,l.mode==1&&(r+=(r?` `:``)+u)),this.startSpan(Math.max(t,o),c),l.opaque)return;let d=e.tree&&e.tree.prop(oz.mounted);if(d&&d.overlay){let a=e.node.enter(d.overlay[0].from+o,1),l=this.highlighters.filter(e=>!e.scope||e.scope(d.tree.type)),u=e.firstChild();for(let f=0,p=o;;f++){let m=f<d.overlay.length?d.overlay[f]:null,h=m?m.from+o:s,g=Math.max(t,p),_=Math.min(n,h);if(g<_&&u)for(;e.from<_&&(this.highlightRange(e,g,_,r,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=h||!e.nextSibling())););if(!m||h>n)break;p=m.to+o,p>t&&(this.highlightRange(a.cursor(),Math.max(t,m.from+o),Math.min(n,p),``,l),this.startSpan(Math.min(n,p),c))}u&&e.parent()}else if(e.firstChild()){d&&(r=``);do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,r,i),this.startSpan(Math.min(n,e.to),c)}while(e.nextSibling());e.parent()}}};function Yz(e){let t=e.type.prop(Uz);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}var X=Lz.define,Xz=X(),Zz=X(),Qz=X(Zz),$z=X(Zz),eB=X(),tB=X(eB),nB=X(eB),rB=X(),iB=X(rB),aB=X(),oB=X(),sB=X(),cB=X(sB),lB=X(),Z={comment:Xz,lineComment:X(Xz),blockComment:X(Xz),docComment:X(Xz),name:Zz,variableName:X(Zz),typeName:Qz,tagName:X(Qz),propertyName:$z,attributeName:X($z),className:X(Zz),labelName:X(Zz),namespace:X(Zz),macroName:X(Zz),literal:eB,string:tB,docString:X(tB),character:X(tB),attributeValue:X(tB),number:nB,integer:X(nB),float:X(nB),bool:X(eB),regexp:X(eB),escape:X(eB),color:X(eB),url:X(eB),keyword:aB,self:X(aB),null:X(aB),atom:X(aB),unit:X(aB),modifier:X(aB),operatorKeyword:X(aB),controlKeyword:X(aB),definitionKeyword:X(aB),moduleKeyword:X(aB),operator:oB,derefOperator:X(oB),arithmeticOperator:X(oB),logicOperator:X(oB),bitwiseOperator:X(oB),compareOperator:X(oB),updateOperator:X(oB),definitionOperator:X(oB),typeOperator:X(oB),controlOperator:X(oB),punctuation:sB,separator:X(sB),bracket:cB,angleBracket:X(cB),squareBracket:X(cB),paren:X(cB),brace:X(cB),content:rB,heading:iB,heading1:X(iB),heading2:X(iB),heading3:X(iB),heading4:X(iB),heading5:X(iB),heading6:X(iB),contentSeparator:X(rB),list:X(rB),quote:X(rB),emphasis:X(rB),strong:X(rB),link:X(rB),monospace:X(rB),strikethrough:X(rB),inserted:X(),deleted:X(),changed:X(),invalid:X(),meta:lB,documentMeta:X(lB),annotation:X(lB),processingInstruction:X(lB),definition:Lz.defineModifier(`definition`),constant:Lz.defineModifier(`constant`),function:Lz.defineModifier(`function`),standard:Lz.defineModifier(`standard`),local:Lz.defineModifier(`local`),special:Lz.defineModifier(`special`)};for(let e in Z){let t=Z[e];t instanceof Lz&&(t.name=e)}Gz([{tag:Z.link,class:`tok-link`},{tag:Z.heading,class:`tok-heading`},{tag:Z.emphasis,class:`tok-emphasis`},{tag:Z.strong,class:`tok-strong`},{tag:Z.keyword,class:`tok-keyword`},{tag:Z.atom,class:`tok-atom`},{tag:Z.bool,class:`tok-bool`},{tag:Z.url,class:`tok-url`},{tag:Z.labelName,class:`tok-labelName`},{tag:Z.inserted,class:`tok-inserted`},{tag:Z.deleted,class:`tok-deleted`},{tag:Z.literal,class:`tok-literal`},{tag:Z.string,class:`tok-string`},{tag:Z.number,class:`tok-number`},{tag:[Z.regexp,Z.escape,Z.special(Z.string)],class:`tok-string2`},{tag:Z.variableName,class:`tok-variableName`},{tag:Z.local(Z.variableName),class:`tok-variableName tok-local`},{tag:Z.definition(Z.variableName),class:`tok-variableName tok-definition`},{tag:Z.special(Z.variableName),class:`tok-variableName2`},{tag:Z.definition(Z.propertyName),class:`tok-propertyName tok-definition`},{tag:Z.typeName,class:`tok-typeName`},{tag:Z.namespace,class:`tok-namespace`},{tag:Z.className,class:`tok-className`},{tag:Z.macroName,class:`tok-macroName`},{tag:Z.propertyName,class:`tok-propertyName`},{tag:Z.operator,class:`tok-operator`},{tag:Z.comment,class:`tok-comment`},{tag:Z.meta,class:`tok-meta`},{tag:Z.invalid,class:`tok-invalid`},{tag:Z.punctuation,class:`tok-punctuation`}]);var uB=new oz,dB=new oz,fB=class{constructor(e,t,n=[],r=``){this.data=e,this.name=r,EM.prototype.hasOwnProperty(`tree`)||Object.defineProperty(EM.prototype,"tree",{get(){return mB(this)}}),this.parser=t,this.extension=[CB.of(this),EM.languageData.of((e,t,n)=>{let r=pB(e,t,n),i=r.type.prop(uB);if(!i)return[];let a=e.facet(i),o=r.type.prop(dB);if(o){let i=r.resolve(t-r.from,n);for(let t of o)if(t.test(i,e)){let n=e.facet(t.facet);return t.type==`replace`?n:n.concat(a)}}return a})].concat(n)}isActiveAt(e,t,n=-1){return pB(e,t,n).type.prop(uB)==this.data}findRegions(e){let t=e.facet(CB);if(t?.data==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],r=(e,t)=>{if(e.prop(uB)==this.data){n.push({from:t,to:t+e.length});return}let i=e.prop(oz.mounted);if(i){if(i.tree.prop(uB)==this.data){if(i.overlay)for(let e of i.overlay)n.push({from:e.from+t,to:e.to+t});else n.push({from:t,to:t+e.length});return}if(i.overlay){let e=n.length;if(r(i.tree,i.overlay[0].from+t),n.length>e)return}}for(let n=0;n<e.children.length;n++){let i=e.children[n];i instanceof pz&&r(i,e.positions[n]+t)}};return r(mB(e),0),n}get allowsNesting(){return!0}};fB.setState=dM.define();function pB(e,t,n){let r=e.facet(CB),i=mB(e).topNode;if(!r||r.allowsNesting)for(let e=i;e;e=e.enter(t,n,fz.ExcludeBuffers|fz.EnterBracketed))e.type.isTop&&(i=e);return i}function mB(e){let t=e.field(fB.state,!1);return t?t.tree:pz.empty}var hB=class{constructor(e){this.doc=e,this.cursorPos=0,this.string=``,this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e<n||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}},gB=null,_B=class e{constructor(e,t,n=[],r,i,a,o,s){this.parser=e,this.state=t,this.fragments=n,this.tree=r,this.treeLen=i,this.viewport=a,this.skipped=o,this.scheduleOn=s,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new e(t,n,[],pz.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hB(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=pz.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{if(typeof e==`number`){let t=Date.now()+e;e=()=>Date.now()>t}for(this.parse||=this.startParse(),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let n=this.parse.advance();if(n){if(this.fragments=this.withoutTempSkipped(Nz.addTree(n,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=this.parse.stoppedAt??this.state.doc.length,this.tree=n,this.parse=null,this.treeLen<(t??this.state.doc.length))this.parse=this.startParse();else return!0}if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Nz.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=gB;gB=this;try{return e()}finally{gB=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=vB(e,t.from,t.to);return e}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:o,skipped:s}=this;if(this.takeTree(),!t.empty){let e=[];if(t.iterChangedRanges((t,n,r,i)=>e.push({fromA:t,toA:n,fromB:r,toB:i})),r=Nz.applyChanges(r,e),i=pz.empty,a=0,o={from:t.mapPos(o.from,-1),to:t.mapPos(o.to,1)},this.skipped.length){s=[];for(let e of this.skipped){let n=t.mapPos(e.from,1),r=t.mapPos(e.to,-1);n<r&&s.push({from:n,to:r})}}}return new e(this.parser,n,r,i,a,o,s,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let t=0;t<this.skipped.length;t++){let{from:n,to:r}=this.skipped[t];n<e.to&&r>e.from&&(this.fragments=vB(this.fragments,n,r),this.skipped.splice(t--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&=(this.takeTree(),null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends Pz{createParse(t,n,r){let i=r[0].from,a=r[r.length-1].to;return{parsedPos:i,advance(){let t=gB;if(t){for(let e of r)t.tempSkipped.push(e);e&&(t.scheduleOn=t.scheduleOn?Promise.all([t.scheduleOn,e]):e)}return this.parsedPos=a,new pz(lz.none,[],[],a-i)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return gB}};function vB(e,t,n){return Nz.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}var yB=class e{constructor(e){this.context=e,this.tree=e.tree}apply(t){if(!t.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(t.changes,t.state),r=this.context.treeLen==t.startState.doc.length?void 0:Math.max(t.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new e(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=_B.create(t.facet(CB).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new e(r)}};fB.state=Wj.define({create:yB.init,update(e,t){for(let e of t.effects)if(e.is(fB.setState))return e.value;return t.startState.facet(CB)==t.state.facet(CB)?e.apply(t):yB.init(t.state)}});var bB=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<`u`&&(bB=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});var xB=typeof navigator<`u`&&navigator.scheduling?.isInputPending?()=>navigator.scheduling.isInputPending():null,SB=nF.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(fB.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(fB.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=bB(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:n,viewport:{to:r}}=this.view,i=n.field(fB.state);if(i.tree==i.context.tree&&i.context.isDone(r+1e5))return;let a=Date.now()+Math.min(this.chunkBudget,100,e&&!xB?Math.max(25,e.timeRemaining()-5):1e9),o=i.context.treeLen<r&&n.doc.length>r+1e3,s=i.context.work(()=>xB&&xB()||Date.now()>a,r+(o?0:1e5));this.chunkBudget-=Date.now()-t,(s||this.chunkBudget<=0)&&(i.context.takeTree(),this.view.dispatch({effects:fB.setState.of(new yB(i.context))})),this.chunkBudget>0&&(!s||o)&&this.scheduleWork(),this.checkAsyncSchedule(i.context)}checkAsyncSchedule(e){e.scheduleOn&&=(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(e=>QP(this.view.state,e)).then(()=>this.workScheduled--),null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),CB=Lj.define({combine(e){return e.length?e[0]:null},enables:e=>[fB.state,SB,Y.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]}),wB=Lj.define(),TB=Lj.define({combine:e=>{if(!e.length)return` `;let t=e[0];if(!t||/\S/.test(t)||Array.from(t).some(e=>e!=t[0]))throw Error(`Invalid indent unit: `+JSON.stringify(e[0]));return t}});function EB(e){let t=e.facet(TB);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function DB(e,t){let n=``,r=e.tabSize,i=e.facet(TB)[0];if(i==` `){for(;t>=r;)n+=` `,t-=r;i=` `}for(let e=0;e<t;e++)n+=i;return n}function OB(e,t){e instanceof EM&&(e=new kB(e));for(let n of e.state.facet(wB)){let r=n(e,t);if(r!==void 0)return r}let n=mB(e.state);return n.length>=t?jB(e,n,t):null}var kB=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=EB(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:i}=this.options;return r!=null&&r>=n.from&&r<=n.to?i&&r==e?{text:``,from:e}:(t<0?r<e:r<=e)?{text:n.text.slice(r-n.from),from:r}:{text:n.text.slice(0,r-n.from),from:n.from}:n}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return``;let{text:n,from:r}=this.lineAt(e,t);return n.slice(e-r,Math.min(n.length,e+100-r))}column(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.countColumn(n,e-r),a=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return a>-1&&(i+=a-this.countColumn(n,n.search(/\S|$/))),i}countColumn(e,t=e.length){return qM(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:r}=this.lineAt(e,t),i=this.options.overrideIndentation;if(i){let e=i(r);if(e>-1)return e}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},AB=new oz;function jB(e,t,n){let r=t.resolveStack(n),i=t.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(i!=r.node){let e=[];for(let t=i;t&&!(t.from<r.node.from||t.to>r.node.to||t.from==r.node.from&&t.type==r.node.type);t=t.parent)e.push(t);for(let t=e.length-1;t>=0;t--)r={node:e[t],next:r}}return MB(r,e,n)}function MB(e,t,n){for(let r=e;r;r=r.next){let e=PB(r.node);if(e)return e(IB.create(t,n,r))}return 0}function NB(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function PB(e){let t=e.type.prop(AB);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(oz.closedBy))){let t=e.lastChild,n=t&&r.indexOf(t.name)>-1;return e=>zB(e,!0,1,void 0,n&&!NB(e)?t.from:void 0)}return e.parent==null?FB:null}function FB(){return 0}var IB=class e extends kB{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(t,n,r){return new e(t,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(LB(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return MB(this.context.next,this.base,this.pos)}};function LB(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function RB(e){let t=e.node,n=t.childAfter(t.from),r=t.lastChild;if(!n)return null;let i=e.options.simulateBreak,a=e.state.doc.lineAt(n.from),o=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let e=n.to;;){let i=t.childAfter(e);if(!i||i==r)return null;if(!i.type.isSkipped){if(i.from>=o)return null;let e=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+e}}e=i.to}}function zB(e,t,n,r,i){let a=e.textAfter,o=a.match(/^\s*/)[0].length,s=r&&a.slice(o,o+r.length)==r||i==e.pos+o,c=t?RB(e):null;return c?s?e.column(c.from):e.column(c.to):e.baseIndent+(s?0:e.unit*n)}var BB=class e{constructor(e,t){this.specs=e;let n;function r(e){let t=$M.newName();return(n||=Object.create(null))[`.`+t]=e,t}let i=typeof t.all==`string`?t.all:t.all?r(t.all):void 0,a=t.scope;this.scope=a instanceof fB?e=>e.prop(uB)==a.data:a?e=>e==a:void 0,this.style=Gz(e.map(e=>({tag:e.tag,class:e.class||r(Object.assign({},e,{tag:null}))})),{all:i}).style,this.module=n?new $M(n):null,this.themeType=t.themeType}static define(t,n){return new e(t,n||{})}},VB=Lj.define(),HB=Lj.define({combine(e){return e.length?[e[0]]:null}});function UB(e){let t=e.facet(VB);return t.length?t:e.facet(HB)}function WB(e,t){let n=[KB],r;return e instanceof BB&&(e.module&&n.push(Y.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(HB.of(e)):r?n.push(VB.computeN([Y.darkTheme],t=>t.facet(Y.darkTheme)==(r==`dark`)?[e]:[])):n.push(VB.of(e)),n}var GB=class{constructor(e){this.markCache=Object.create(null),this.tree=mB(e.state),this.decorations=this.buildDeco(e,UB(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=mB(e.state),n=UB(e.state),r=n!=UB(e.startState),{viewport:i}=e.view,a=e.changes.mapPos(this.decoratedTo,1);t.length<i.to&&!r&&t.type==this.tree.type&&a>=i.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=a):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=i.to)}buildDeco(e,t){if(!t||!this.tree.length)return AN.none;let n=new IM;for(let{from:r,to:i}of e.visibleRanges)qz(this.tree,t,(e,t,r)=>{n.add(e,t,this.markCache[r]||(this.markCache[r]=AN.mark({class:r})))},r,i);return n.finish()}},KB=qj.high(nF.fromClass(GB,{decorations:e=>e.decorations})),qB=BB.define([{tag:Z.meta,color:`#404740`},{tag:Z.link,textDecoration:`underline`},{tag:Z.heading,textDecoration:`underline`,fontWeight:`bold`},{tag:Z.emphasis,fontStyle:`italic`},{tag:Z.strong,fontWeight:`bold`},{tag:Z.strikethrough,textDecoration:`line-through`},{tag:Z.keyword,color:`#708`},{tag:[Z.atom,Z.bool,Z.url,Z.contentSeparator,Z.labelName],color:`#219`},{tag:[Z.literal,Z.inserted],color:`#164`},{tag:[Z.string,Z.deleted],color:`#a11`},{tag:[Z.regexp,Z.escape,Z.special(Z.string)],color:`#e40`},{tag:Z.definition(Z.variableName),color:`#00f`},{tag:Z.local(Z.variableName),color:`#30a`},{tag:[Z.typeName,Z.namespace],color:`#085`},{tag:Z.className,color:`#167`},{tag:[Z.special(Z.variableName),Z.macroName],color:`#256`},{tag:Z.definition(Z.propertyName),color:`#00c`},{tag:Z.comment,color:`#940`},{tag:Z.invalid,color:`#f00`}]),JB=1e4,YB=`()[]{}`,XB=new oz;function ZB(e,t,n){let r=e.prop(t<0?oz.openedBy:oz.closedBy);if(r)return r;if(e.name.length==1){let r=n.indexOf(e.name);if(r>-1&&r%2==+(t<0))return[n[r+t]]}return null}function QB(e){let t=e.type.prop(XB);return t?t(e.node):e}function $B(e,t,n,r={}){let i=r.maxScanDistance||JB,a=r.brackets||YB,o=mB(e),s=o.resolveInner(t,n);for(let r=s;r;r=r.parent){let i=ZB(r.type,n,a);if(i&&r.from<r.to){let o=QB(r);if(o&&(n>0?t>=o.from&&t<o.to:t>o.from&&t<=o.to))return eV(e,t,n,r,o,i,a)}}return tV(e,t,n,o,s.type,i,a)}function eV(e,t,n,r,i,a,o){let s=r.parent,c={from:i.from,to:i.to},l=0,u=s?.cursor();if(u&&(n<0?u.childBefore(r.from):u.childAfter(r.to)))do if(n<0?u.to<=r.from:u.from>=r.to){if(l==0&&a.indexOf(u.type.name)>-1&&u.from<u.to){let e=QB(u);return{start:c,end:e?{from:e.from,to:e.to}:void 0,matched:!0}}if(ZB(u.type,n,o))l++;else if(ZB(u.type,-n,o)){if(l==0){let e=QB(u);return{start:c,end:e&&e.from<e.to?{from:e.from,to:e.to}:void 0,matched:!1}}l--}}while(n<0?u.prevSibling():u.nextSibling());return{start:c,matched:!1}}function tV(e,t,n,r,i,a,o){if(n<0?!t:t==e.doc.length)return null;let s=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),c=o.indexOf(s);if(c<0||c%2==0!=n>0)return null;let l={from:n<0?t-1:t,to:n>0?t+1:t},u=e.doc.iterRange(t,n>0?e.doc.length:0),d=0;for(let e=0;!u.next().done&&e<=a;){let a=u.value;n<0&&(e+=a.length);let s=t+e*n;for(let e=n>0?0:a.length-1,t=n>0?a.length:-1;e!=t;e+=n){let t=o.indexOf(a[e]);if(!(t<0||r.resolveInner(s+e,1).type!=i)){if(t%2==0==n>0)d++;else if(d==1)return{start:l,end:{from:s+e,to:s+e+1},matched:t>>1==c>>1};else d--}}n>0&&(e+=a.length)}return u.done?{start:l,matched:!1}:null}var nV=Object.create(null),rV=[lz.none],iV=[],aV=Object.create(null),oV=Object.create(null);for(let[e,t]of[[`variable`,`variableName`],[`variable-2`,`variableName.special`],[`string-2`,`string.special`],[`def`,`variableName.definition`],[`tag`,`tagName`],[`attribute`,`attributeName`],[`type`,`typeName`],[`builtin`,`variableName.standard`],[`qualifier`,`modifier`],[`error`,`invalid`],[`header`,`heading`],[`property`,`propertyName`]])oV[e]=cV(nV,t);function sV(e,t){iV.indexOf(e)>-1||(iV.push(e),console.warn(t))}function cV(e,t){let n=[];for(let r of t.split(` `)){let t=[];for(let n of r.split(`.`)){let r=e[n]||Z[n];r?typeof r==`function`?t.length?t=t.map(r):sV(n,`Modifier ${n} used at start of tag`):t.length?sV(n,`Tag ${n} used as modifier`):t=Array.isArray(r)?r:[r]:sV(n,`Unknown highlighting tag ${n}`)}for(let e of t)n.push(e)}if(!n.length)return 0;let r=t.replace(/ /g,`_`),i=r+` `+n.map(e=>e.id),a=aV[i];if(a)return a.id;let o=aV[i]=lz.define({id:rV.length,name:r,props:[Hz({[r]:n})]});return rV.push(o),o.id}mP.RTL,mP.LTR;var lV=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=mB(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(hV(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function uV(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function dV(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=uV(t)+uV(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function fV(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:dV(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}var pV=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function mV(e){return e.selection.main.from}function hV(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var gV=cM.define();function _V(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:q.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var vV=new WeakMap;function yV(e){if(!Array.isArray(e))return e;let t=vV.get(e);return t||vV.set(e,t=fV(e)),t}var bV=dM.define(),xV=dM.define(),SV=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=xj(e,t),r=Cj(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(xj(a==i?i.toLowerCase():a,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:a}=this;if(t.length==1){let r=xj(e,0),i=Cj(r),a=i==e.length?0:-100;if(r!=t[0]){if(r==n[0])a+=-200;else return null}return this.ret(a,[0,i])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let s=t.length,c=0;if(o<0){for(let i=0,a=Math.min(e.length,200);i<a&&c<s;){let a=xj(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=Cj(a)}if(c<s)return null}let l=0,u=0,d=!1,f=0,p=-1,m=-1,h=/[a-z]/.test(e),g=!0;for(let r=0,c=Math.min(e.length,200),_=0;r<c&&u<s;){let c=xj(e,r);o<0&&(l<s&&c==t[l]&&(i[l++]=r),f<s&&(c==t[f]||c==n[f]?(f==0&&(p=r),m=r+1,f++):f=0));let v,y=c<255?c>=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(v=Sj(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||y==1&&h||_==0&&y!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=y,r+=Cj(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?Cj(xj(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},CV=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},wV=Lj.define({combine(e){return DM(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:EV,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>TV(e(n),t(n)),optionClass:(e,t)=>n=>TV(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function TV(e,t){return e?t?e+` `+t:e:t}function EV(e,t,n,r,i,a){let o=e.textDirection==mP.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-h))-t.top,d=Math.min(400,s?f:p);else{c=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var DV=dM.define();function OV(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function kV(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var AV=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(wV);this.optionContent=OV(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=kV(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:DV.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(wV).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:xV.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=kV(r.length,i,e.state.facet(wV).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=kV(t.options.length,t.selected,this.view.state.facet(wV).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>QP(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&MV(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(wV).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0)){if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function jV(e,t){return n=>new AV(n,e,t)}function MV(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function NV(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function PV(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(wV);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new pV(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new CV(n):new SV(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new pV(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):NV(e.completion)>NV(c)&&(s[s.length-1]=e),c=e.completion}return s}var FV=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,BV(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=PV(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(wV).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,BV(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:YV,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},IV=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(VV,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(wV),i=(r.override||n.languageDataAt(`autocomplete`,mV(n)).map(yV)).map(e=>(this.active.find(t=>t.source==e)||new UV(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(KV));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!LV(i,this.active)||o?a=FV.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new UV(e.source,0):e));for(let e of t.effects)e.is(DV)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?RV:zV}};function LV(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var RV={"aria-autocomplete":`list`},zV={};function BV(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var VV=[];function HV(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(gV);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var UV=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=HV(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(bV))i=new e(i.source,1,n.value);else if(n.is(xV))i=new e(i.source,0);else if(n.is(KV))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(mV(e.state))}},WV=class e extends UV{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=mV(t.state);if(o>a||!r||n&2&&(mV(t.startState)==this.from||o<this.limit))return new UV(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return GV(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new lV(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??mV(t.state)):new UV(this.source,1,this.explicit)}map(t){if(t.empty)return this;let n=this.result.map?this.result.map(this.result,t):this.result;return n?new e(this.source,this.explicit,t.mapPos(this.limit),n,t.mapPos(this.from),t.mapPos(this.to,1)):new UV(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function GV(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):hV(e,!0).test(i)}var KV=dM.define({map(e,t){return e.map(e=>e.map(t))}}),qV=Wj.define({create(){return IV.start()},update(e,t){return e.update(t)},provide:e=>[HR.from(e,e=>e.tooltip),Y.contentAttributes.from(e,e=>e.attrs)]});function JV(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(qV).active.find(e=>e.source==t.source);return r instanceof WV&&(typeof n==`string`?e.dispatch({..._V(e.state,n,r.from,r.to),annotations:gV.of(t.completion)}):n(e,t.completion,r.from,r.to),!0)}var YV=jV(qV,JV);function XV(e,t=`option`){return n=>{let r=n.state.field(qV,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(wV).interactionDelay)return!1;let i=1,a;t==`page`&&(a=UR(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector(`li`).offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:DV.of(s)}),!0}}var ZV=e=>{let t=e.state.field(qV,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(wV).interactionDelay?!1:JV(e,t.open.options[t.open.selected])},QV=e=>e.state.field(qV,!1)?(e.dispatch({effects:bV.of(!0)}),!0):!1,$V=e=>{let t=e.state.field(qV,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:xV.of(null)}),!0)},eH=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},tH=50,nH=1e3,rH=nF.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(qV).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(qV),n=e.state.facet(wV);if(!e.selectionSet&&!e.docChanged&&e.startState.field(qV)==t)return;let r=e.transactions.some(e=>{let t=HV(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>tH&&Date.now()-n.time>nH){for(let e of n.context.abortListeners)try{e()}catch(e){QP(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(bV)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(qV);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(wV).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new lV(t,mV(t),e.explicit,this.view),r=new eH(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:xV.of(null)}),QP(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(wV).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(wV),n=this.view.state.field(qV);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=mV(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new WV(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending){if(i.done==null){let n=new UV(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:KV.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(qV,!1);if(t&&t.tooltip&&this.view.state.facet(wV).closeOnBlur){let n=t.open&&UR(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:xV.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:bV.of(!1)}),20),this.composing=0}}}),iH=typeof navigator==`object`&&/Win/.test(navigator.platform),aH=qj.highest(Y.domEventHandlers({keydown(e,t){let n=t.state.field(qV,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(iH&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&JV(t,r),!1}})),oH=Y.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),sH=new class extends OM{};sH.startSide=1,sH.endSide=-1,typeof navigator==`object`&&navigator.userAgent;function cH(e={}){return[aH,qV,wV.of(e),rH,uH,oH]}var lH=[{key:`Ctrl-Space`,run:QV},{mac:"Alt-`",run:QV},{mac:`Alt-i`,run:QV},{key:`Escape`,run:$V},{key:`ArrowDown`,run:XV(!0)},{key:`ArrowUp`,run:XV(!1)},{key:`PageDown`,run:XV(!0,`page`)},{key:`PageUp`,run:XV(!1,`page`)},{key:`Enter`,run:ZV}],uH=qj.highest(yR.computeN([wV],e=>e.facet(wV).defaultKeymap?[lH]:[])),dH=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=gH(e.state,n.from);return r.line?pH(e):r.block?hH(e):!1};function fH(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var pH=fH(xH,0),mH=fH(bH,0),hH=fH((e,t)=>bH(e,t,yH(t)),0);function gH(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var _H=50;function vH(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-_H,r),o=e.sliceDoc(i,i+_H),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+_H),d=e.sliceDoc(i-_H,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function yH(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function bH(e,t,n=t.selection.ranges){let r=n.map(e=>gH(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>vH(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function xH(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=gH(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var SH=cM.define(),CH=cM.define(),wH=Lj.define(),TH=Lj.define({combine(e){return DM(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),EH=Wj.define({create(){return GH.empty},update(e,t){let n=t.state.facet(TH),r=t.annotation(SH);if(r){let i=NH.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?PH(o,o.length,n.minDepth,i):BH(o,t.startState.selection),new GH(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(CH);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(fM.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=NH.fromTransaction(t),o=t.annotation(fM.time),s=t.annotation(fM.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new GH(e.done.map(NH.fromJSON),e.undone.map(NH.fromJSON))}});function DH(e={}){return[EH,TH.of(e),Y.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?kH:e.inputType==`historyRedo`?AH:null;return n?(e.preventDefault(),n(t)):!1}})]}function OH(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(EH,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var kH=OH(0,!1),AH=OH(1,!1),jH=OH(0,!0),MH=OH(1,!0),NH=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&Dj.fromJSON(t.changes),[],t.mapped&&Ej.fromJSON(t.mapped),t.startSelection&&q.fromJSON(t.startSelection),t.selectionsAfter.map(q.fromJSON))}static fromTransaction(t,n){let r=RH;for(let e of t.startState.facet(wH)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,RH)}static selection(t){return new e(void 0,RH,void 0,void 0,t)}};function PH(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function FH(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function IH(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function LH(e,t){return e.length?t.length?e.concat(t):e:t}var RH=[],zH=200;function BH(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-zH));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),PH(e,e.length-1,1e9,n.setSelAfter(r)))}return[NH.selection([t])]}function VH(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function HH(e,t){if(!e.length)return e;let n=e.length,r=RH;for(;n;){let i=UH(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[NH.selection(r)]:RH}function UH(e,t,n){let r=LH(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):RH,n);if(!e.changes)return NH.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new NH(i,dM.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var WH=/^(input\.type|delete)($|\.)/,GH=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||WH.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,FH(s.changes,t.changes))||r==`input.type.compose`)?PH(o,o.length-1,i.minDepth,new NH(t.changes.compose(s.changes),LH(dM.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,RH)):PH(o,o.length,i.minDepth,t),new e(o,RH,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:RH;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&IH(a[a.length-1],t)?this:new e(BH(this.done,t),this.undone,n,r)}addMapping(t){return new e(HH(this.done,t),HH(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:SH.of({side:e,rest:VH(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?RH:r.slice(0,r.length-1);return i.mapped&&(n=HH(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:SH.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}return null}};GH.empty=new GH(RH,RH);var KH=[{key:`Mod-z`,run:kH,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:AH,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:AH,preventDefault:!0},{key:`Mod-u`,run:jH,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:MH,preventDefault:!0}];function qH(e,t){return q.create(e.ranges.map(t),e.mainIndex)}function JH(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function YH({state:e,dispatch:t},n){let r=qH(e.selection,n);return!r.eq(e.selection,!0)&&(t(JH(e,r)),!0)}function XH(e,t){return q.cursor(t?e.to:e.from)}function ZH(e,t){return YH(e,n=>n.empty?e.moveByChar(n,t):XH(n,t))}function QH(e){return e.textDirectionAt(e.state.selection.main.head)==mP.LTR}var $H=e=>ZH(e,!QH(e)),eU=e=>ZH(e,QH(e));function tU(e,t){return YH(e,n=>n.empty?e.moveByGroup(n,t):XH(n,t))}var nU=e=>tU(e,!QH(e)),rU=e=>tU(e,QH(e));typeof Intl<`u`&&Intl.Segmenter;function iU(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function aU(e,t,n){let r=mB(e).resolveInner(t.head),i=n?oz.closedBy:oz.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;iU(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?$B(e,r.from,1):$B(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,q.cursor(s,n?-1:1)}var oU=e=>YH(e,t=>aU(e.state,t,!QH(e))),sU=e=>YH(e,t=>aU(e.state,t,QH(e)));function cU(e,t){return YH(e,n=>{if(!n.empty)return XH(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var lU=e=>cU(e,!1),uU=e=>cU(e,!0);function dU(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(Y.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function fU(e,t){let n=dU(e),{state:r}=e,i=qH(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):XH(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=Y.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(JH(r,i),{effects:a}),!0}var pU=e=>fU(e,!1),mU=e=>fU(e,!0);function hU(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=q.cursor(r.from+n))}return i}var gU=e=>YH(e,t=>hU(e,t,!0)),_U=e=>YH(e,t=>hU(e,t,!1)),vU=e=>YH(e,t=>hU(e,t,!QH(e))),yU=e=>YH(e,t=>hU(e,t,QH(e))),bU=e=>YH(e,t=>e.moveToLineBoundary(t,!1,!1)),xU=e=>YH(e,t=>e.moveToLineBoundary(t,!0,!1));function SU(e,t,n){let r=!1,i=qH(e.selection,t=>{let i=$B(e,t.head,-1)||$B(e,t.head,1)||t.head>0&&$B(e,t.head-1,1)||t.head<e.doc.length&&$B(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?q.range(t.anchor,a):q.cursor(a)});return r?(t(JH(e,i)),!0):!1}var CU=({state:e,dispatch:t})=>SU(e,t,!1);function wU(e,t,n){let r=qH(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=q.range(e.head,e.anchor));let r=n(e);return q.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(JH(e.state,r)),!0)}function TU(e,t){return wU(e,t,n=>e.moveByChar(n,t))}var EU=e=>TU(e,!QH(e)),DU=e=>TU(e,QH(e));function OU(e,t){return wU(e,t,n=>e.moveByGroup(n,t))}var kU=e=>OU(e,!QH(e)),AU=e=>OU(e,QH(e)),jU=e=>{let t=!QH(e);return wU(e,t,n=>aU(e.state,n,t))},MU=e=>{let t=QH(e);return wU(e,t,n=>aU(e.state,n,t))};function NU(e,t){return wU(e,t,n=>e.moveVertically(n,t))}var PU=e=>NU(e,!1),FU=e=>NU(e,!0);function IU(e,t){return wU(e,t,n=>e.moveVertically(n,t,dU(e).height))}var LU=e=>IU(e,!1),RU=e=>IU(e,!0),zU=e=>wU(e,!0,t=>hU(e,t,!0)),BU=e=>wU(e,!1,t=>hU(e,t,!1)),VU=e=>{let t=!QH(e);return wU(e,t,n=>hU(e,n,t))},HU=e=>{let t=QH(e);return wU(e,t,n=>hU(e,n,t))},UU=e=>wU(e,!1,t=>q.cursor(e.lineBlockAt(t.head).from)),WU=e=>wU(e,!0,t=>q.cursor(e.lineBlockAt(t.head).to)),GU=({state:e,dispatch:t})=>(t(JH(e,{anchor:0})),!0),KU=({state:e,dispatch:t})=>(t(JH(e,{anchor:e.doc.length})),!0),qU=({state:e,dispatch:t})=>(t(JH(e,{anchor:e.selection.main.anchor,head:0})),!0),JU=({state:e,dispatch:t})=>(t(JH(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),YU=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),XU=({state:e,dispatch:t})=>{let n=hW(e).map(({from:t,to:n})=>q.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:q.create(n),userEvent:`select`})),!0},ZU=({state:e,dispatch:t})=>{let n=qH(e.selection,t=>{let n=mB(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return q.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(JH(e,n)),!0)};function QU(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(JH(n,q.create(i,i.length-1))),!0)}var $U=e=>QU(e,!1),eW=e=>QU(e,!0),tW=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=q.create([n.main]):n.main.empty||(r=q.create([q.cursor(n.main.head)])),r?(t(JH(e,r)),!0):!1};function nW(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=rW(e,o,!1)):o>i&&(n=`delete.forward`,o=rW(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=rW(e,i,!1),a=rW(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:q.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?Y.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function rW(e,t,n){if(e instanceof Y)for(let r of e.state.facet(Y.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var iW=(e,t,n)=>nW(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=qM(s,a.tabSize)%EB(a)||EB(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=vj(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=vj(o.text,c-o.from,!1,!1)+o.from);return c}),aW=e=>iW(e,!1,!0),oW=e=>iW(e,!0,!1),sW=(e,t)=>nW(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=vj(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),cW=e=>sW(e,!1),lW=e=>sW(e,!0),uW=e=>nW(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),dW=e=>nW(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),fW=e=>nW(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),pW=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:sj.of([``,``])},range:q.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},mW=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:vj(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:vj(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:q.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function hW(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function gW(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of hW(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(q.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(q.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:q.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var _W=({state:e,dispatch:t})=>gW(e,t,!1),vW=({state:e,dispatch:t})=>gW(e,t,!0);function yW(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of hW(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var bW=({state:e,dispatch:t})=>yW(e,t,!1),xW=({state:e,dispatch:t})=>yW(e,t,!0),SW=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(hW(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=qH(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function CW(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=mB(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(oz.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var wW=EW(!1),TW=EW(!0);function EW(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&CW(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new kB(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=OB(s,r);for(c??=qM(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,DB(t,c)];return o&&l.push(DB(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:sj.of(l)},range:q.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function DW(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:q.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var OW=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new kB(e,{overrideIndentation:e=>n[e]??-1}),i=DW(e,(t,i,a)=>{let o=OB(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=DB(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},kW=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(DW(e,(t,n)=>{n.push({from:t.from,insert:e.facet(TB)})}),{userEvent:`input.indent`})),!0),AW=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(DW(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=qM(r,e.tabSize),a=0,o=DB(e,Math.max(0,i-EB(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),jW=e=>(e.setTabFocusMode(),!0),MW=[{key:`Ctrl-b`,run:$H,shift:EU,preventDefault:!0},{key:`Ctrl-f`,run:eU,shift:DU},{key:`Ctrl-p`,run:lU,shift:PU},{key:`Ctrl-n`,run:uU,shift:FU},{key:`Ctrl-a`,run:bU,shift:UU},{key:`Ctrl-e`,run:xU,shift:WU},{key:`Ctrl-d`,run:oW},{key:`Ctrl-h`,run:aW},{key:`Ctrl-k`,run:uW},{key:`Ctrl-Alt-h`,run:cW},{key:`Ctrl-o`,run:pW},{key:`Ctrl-t`,run:mW},{key:`Ctrl-v`,run:mU}],NW=[{key:`ArrowLeft`,run:$H,shift:EU,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:nU,shift:kU,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:vU,shift:VU,preventDefault:!0},{key:`ArrowRight`,run:eU,shift:DU,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:rU,shift:AU,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:yU,shift:HU,preventDefault:!0},{key:`ArrowUp`,run:lU,shift:PU,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:GU,shift:qU},{mac:`Ctrl-ArrowUp`,run:pU,shift:LU},{key:`ArrowDown`,run:uU,shift:FU,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:KU,shift:JU},{mac:`Ctrl-ArrowDown`,run:mU,shift:RU},{key:`PageUp`,run:pU,shift:LU},{key:`PageDown`,run:mU,shift:RU},{key:`Home`,run:_U,shift:BU,preventDefault:!0},{key:`Mod-Home`,run:GU,shift:qU},{key:`End`,run:gU,shift:zU,preventDefault:!0},{key:`Mod-End`,run:KU,shift:JU},{key:`Enter`,run:wW,shift:wW},{key:`Mod-a`,run:YU},{key:`Backspace`,run:aW,shift:aW,preventDefault:!0},{key:`Delete`,run:oW,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:cW,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:lW,preventDefault:!0},{mac:`Mod-Backspace`,run:dW,preventDefault:!0},{mac:`Mod-Delete`,run:fW,preventDefault:!0}].concat(MW.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),PW=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:oU,shift:jU},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:sU,shift:MU},{key:`Alt-ArrowUp`,run:_W},{key:`Shift-Alt-ArrowUp`,run:bW},{key:`Alt-ArrowDown`,run:vW},{key:`Shift-Alt-ArrowDown`,run:xW},{key:`Mod-Alt-ArrowUp`,run:$U},{key:`Mod-Alt-ArrowDown`,run:eW},{key:`Escape`,run:tW},{key:`Mod-Enter`,run:TW},{key:`Alt-l`,mac:`Ctrl-l`,run:XU},{key:`Mod-i`,run:ZU,preventDefault:!0},{key:`Mod-[`,run:AW},{key:`Mod-]`,run:kW},{key:`Mod-Alt-\\`,run:OW},{key:`Shift-Mod-k`,run:SW},{key:`Shift-Mod-\\`,run:CU},{key:`Mod-/`,run:dH},{key:`Alt-A`,mac:`Ctrl-A`,run:mH},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:jW}].concat(NW),FW=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,IW=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(FW(e)):FW,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return xj(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=Sj(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Cj(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(IW.prototype[Symbol.iterator]=function(){return this});var LW={from:-1,to:-1,match:/.*/.exec(``),precise:!0},RW=`gm`+(/x/.unicode==null?``:`u`),zW=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=LW,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new HW(e,t,n,r,i);this.re=new RegExp(t,RW+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=WW(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=WW(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},BW=new WeakMap,VW=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=BW.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return BW.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),BW.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},HW=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=LW,this.matchPos=WW(e,r),this.re=new RegExp(t,RW+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=VW.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=WW(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=VW.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(zW.prototype[Symbol.iterator]=HW.prototype[Symbol.iterator]=function(){return this});function UW(e){try{return new RegExp(e,RW),!0}catch{return!1}}function WW(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var GW=e=>{let t=ZR(e,`cm-goto-line`);if(t){let e=t.dom.querySelector(`input[type=text]`);return e&&e.select(),!0}let{state:n}=e,r=String(n.doc.lineAt(e.state.selection.main.head).number),{close:i,result:a}=XR(e,{class:`cm-goto-line`,label:n.phrase(`Go to line`),input:{type:`text`,name:`line`,value:r},focus:!0,submitLabel:n.phrase(`go`)});return a.then(t=>{let r=t&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.elements.line.value);if(!r){e.dispatch({effects:i});return}let a=n.doc.lineAt(n.selection.main.head),[,o,s,c,l]=r,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/n.doc.lines),d=Math.round(n.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=n.doc.line(Math.max(1,Math.min(n.doc.lines,d))),p=q.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[i,Y.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},KW=({state:e,dispatch:t})=>{let{selection:n}=e,r=q.create(n.ranges.map(t=>e.wordAt(t.head)||q.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)};function qW(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new IW(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new IW(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var JW=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return KW({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=qW(e,r);return i?(t(e.update({selection:e.selection.addRange(q.range(i.from,i.to),!1),effects:Y.scrollIntoView(i.to)})),!0):!1},YW=Lj.define({combine(e){return DM(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new kG(e),scrollToMatch:e=>Y.scrollIntoView(e)})}}),XW=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||UW(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
68
- `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new sG(this):new tG(this)}getCursor(e,t=0,n){let r=e.doc?e:EM.create({doc:e});return n??=r.doc.length,this.regexp?rG(this,r,t,n):$W(this,r,t,n)}},ZW=class{constructor(e){this.spec=e}};function QW(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function $W(e,t,n,r){let i;return e.wholeWord&&(i=eG(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=QW(e.test,t,i)),new IW(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function eG(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(iG(i,n-a))!=xM.Word||t(aG(i,n-a))!=xM.Word)&&(t(aG(i,r-a))!=xM.Word||t(iG(i,r-a))!=xM.Word))}var tG=class extends ZW{constructor(e){super(e)}nextMatch(e,t,n){let r=$W(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=$W(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=$W(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=$W(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=$W(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function nG(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function rG(e,t,n,r){let i;return e.wholeWord&&(i=oG(t.charCategorizer(t.selection.main.head))),e.test&&(i=nG(e.test,t,i)),new zW(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function iG(e,t){return e.slice(vj(e,t,!1),t)}function aG(e,t){return e.slice(t,vj(e,t))}function oG(e){return(t,n,r)=>!r[0].length||(e(iG(r.input,r.index))!=xM.Word||e(aG(r.input,r.index))!=xM.Word)&&(e(aG(r.input,r.index+r[0].length))!=xM.Word||e(iG(r.input,r.index+r[0].length))!=xM.Word)}var sG=class extends ZW{nextMatch(e,t,n){let r=rG(this.spec,e,n,e.doc.length).next();return r.done&&(r=rG(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=rG(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=rG(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=rG(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},cG=dM.define(),lG=dM.define(),uG=Wj.define({create(e){return new dG(CG(e).create(),null)},update(e,t){for(let n of t.effects)n.is(cG)?e=new dG(n.value.create(),e.panel):n.is(lG)&&(e=new dG(e.query,n.value?SG:null));return e},provide:e=>YR.from(e,e=>e.panel)}),dG=class{constructor(e,t){this.query=e,this.panel=t}},fG=AN.mark({class:`cm-searchMatch`}),pG=AN.mark({class:`cm-searchMatch cm-searchMatch-selected`}),mG=nF.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(uG))}update(e){let t=e.state.field(uG);(t!=e.startState.field(uG)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return AN.none;let{view:n}=this,r=new IM;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?pG:fG)})}return r.finish()}},{decorations:e=>e.decorations});function hG(e){return t=>{let n=t.state.field(uG,!1);return n&&n.query.spec.valid?e(t,n):EG(t)}}var gG=hG((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=q.single(r.from,r.to),a=e.state.facet(YW);return e.dispatch({selection:i,effects:[NG(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),TG(e),!0}),_G=hG((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=q.single(i.from,i.to),o=e.state.facet(YW);return e.dispatch({selection:a,effects:[NG(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),TG(e),!0}),vG=hG((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:q.create(n.map(e=>q.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),yG=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new IW(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(q.range(t.value.from,t.value.to))}return t(e.update({selection:q.create(a,o),userEvent:`select.search.matches`})),!0},bG=hG((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.precise?o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(Y.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=q.single(o.from,o.to).map(d),u.push(NG(e,o)),u.push(n.facet(YW).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),xG=hG((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:Y.announce.of(r),userEvent:`input.replace.all`}),!0});function SG(e){return e.state.facet(YW).createPanel(e)}function CG(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(YW);return new XW({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function wG(e){let t=GR(e,SG);return t&&t.dom.querySelector(`[main-field]`)}function TG(e){let t=wG(e);t&&t==e.root.activeElement&&t.select()}var EG=e=>{let t=e.state.field(uG,!1);if(t&&t.panel){let n=wG(e);if(n&&n!=e.root.activeElement){let r=CG(e.state,t.query.spec);r.valid&&e.dispatch({effects:cG.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[lG.of(!0),t?cG.of(CG(e.state,t.query.spec)):dM.appendConfig.of(FG)]});return!0},DG=e=>{let t=e.state.field(uG,!1);if(!t||!t.panel)return!1;let n=GR(e,SG);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:lG.of(!1)}),!0},OG=[{key:`Mod-f`,run:EG,scope:`editor search-panel`},{key:`F3`,run:gG,shift:_G,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:gG,shift:_G,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:DG,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:yG},{key:`Mod-Alt-g`,run:GW},{key:`Mod-d`,run:JW,preventDefault:!0}],kG=class{constructor(e){this.view=e;let t=this.query=e.state.field(uG).query.spec;this.commit=this.commit.bind(this),this.searchField=lN(`input`,{value:t.search,placeholder:AG(e,`Find`),"aria-label":AG(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=lN(`input`,{value:t.replace,placeholder:AG(e,`Replace`),"aria-label":AG(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=lN(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=lN(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=lN(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return lN(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=lN(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>gG(e),[AG(e,`next`)]),n(`prev`,()=>_G(e),[AG(e,`previous`)]),n(`select`,()=>vG(e),[AG(e,`all`)]),lN(`label`,null,[this.caseField,AG(e,`match case`)]),lN(`label`,null,[this.reField,AG(e,`regexp`)]),lN(`label`,null,[this.wordField,AG(e,`by word`)]),...e.state.readOnly?[]:[lN(`br`),this.replaceField,n(`replace`,()=>bG(e),[AG(e,`replace`)]),n(`replaceAll`,()=>xG(e),[AG(e,`replace all`)])],lN(`button`,{name:`close`,onclick:()=>DG(e),"aria-label":AG(e,`close`),type:`button`},[`×`])])}commit(){let e=new XW({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:cG.of(e)}))}keydown(e){SR(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?_G:gG)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),bG(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(cG)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(YW).top}};function AG(e,t){return e.state.phrase(t)}var jG=30,MG=/[\s\.,:;?!]/;function NG(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-jG),o=Math.min(i,n+jG),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<jG;e++)if(!MG.test(s[e+1])&&MG.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-jG;e--)if(!MG.test(s[e-1])&&MG.test(s[e])){s=s.slice(0,e);break}}return Y.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var PG=Y.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),FG=[uG,qj.low(mG),PG],IG=[`if`,`concat`,`upper`,`lower`,`len`],LG=[`true`,`false`,`null`];function RG({value:e,onChange:t,placeholder:n,fieldNames:r,readOnly:i}){let a=(0,j.useRef)(null),o=(0,j.useRef)(null),s=(0,j.useRef)(t),c=(0,j.useRef)(r);(0,j.useEffect)(()=>{s.current=t},[t]),(0,j.useEffect)(()=>{c.current=r},[r]);let l=(0,j.useMemo)(()=>e??``,[]);return(0,j.useEffect)(()=>{if(!a.current)return;let e=new Y({parent:a.current,state:EM.create({doc:l,extensions:[DH(),jR(n||`{Quantity} * {Unit price}`),cH({override:[zG(()=>c.current)]}),yR.of([...PW,...KH,...OG,...lH]),WB(qB,{fallback:!0}),EM.readOnly.of(!!i),Y.lineWrapping,Y.theme({"&":{fontSize:`13px`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`},".cm-content":{padding:`8px`,minHeight:`64px`},".cm-focused":{outline:`none`}}),Y.updateListener.of(e=>{e.docChanged&&s.current(e.state.doc.toString())})]})});return o.current=e,()=>{e.destroy(),o.current=null}},[l,n,i]),(0,j.useEffect)(()=>{let t=o.current;if(!t)return;let n=t.state.doc.toString();n!==(e??``)&&t.dispatch({changes:{from:0,to:n.length,insert:e??``}})},[e]),(0,I.jsx)(`div`,{ref:a,className:`data-inline-formula-editor`})}function zG(e){return t=>{let n=t.state.doc.sliceString(0,t.pos),r=n.lastIndexOf(`{`);if(r>n.lastIndexOf(`}`))return{from:r+1,options:e().map(e=>({label:e,type:`variable`,apply:`${e}}`})),validFor:/^[\p{L}\p{N}_]*$/u};let i=t.matchBefore(/[a-zA-Z_]\w*/);return!i||i.from===i.to&&!t.explicit?null:{from:i.from,options:[...IG.map(e=>({label:e,type:`function`,apply:`${e}()`})),...LG.map(e=>({label:e,type:`keyword`}))]}}}function BG({formula:e,currentFieldId:t,fields:n,onChange:r}){let{t:i}=U(`table`);return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:i(`fieldConfig.formula`)}),(0,I.jsx)(RG,{value:e,onChange:r,placeholder:i(`fieldConfig.formulaPlaceholder`),fieldNames:n.filter(e=>e.id!==t).map(e=>e.name)})]})}var VG={slate:`hsl(var(--secondary))`,amber:`rgb(253, 230, 138)`,sky:`rgb(186, 230, 253)`,violet:`hsl(var(--tint-lavender))`,emerald:`rgb(167, 243, 208)`,cyan:`rgb(165, 243, 252)`,blue:`hsl(var(--tint-sky))`,rose:`rgb(254, 205, 211)`};function HG({open:e,columnTone:t,fieldId:n,onColumnToneChange:r}){let{t:i}=U(`table`);return e?(0,I.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-md border border-border bg-muted/30 p-3`,children:[(0,I.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:i(`fieldConfig.advancedProperties`)}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:i(`fieldConfig.columnColor`)}),(0,I.jsx)(C_,{size:`lg`,value:t,onChange:e=>r(e.target.value),children:fT.map(e=>(0,I.jsx)(`option`,{value:e.value,children:i(e.labelKey)},e.value))}),(0,I.jsx)(`div`,{className:`mt-1 grid grid-cols-8 gap-2`,children:fT.map(e=>(0,I.jsx)(`button`,{type:`button`,title:i(e.labelKey),onClick:()=>r(e.value),className:K(`h-7 rounded-md border border-transparent ring-offset-2 transition`,t===e.value&&`border-foreground ring-2 ring-ring/30`),style:{backgroundColor:VG[e.value]??`transparent`}},e.value))})]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,I.jsx)(`span`,{children:i(`fieldConfig.fieldId`)}),(0,I.jsx)(`code`,{className:`font-mono`,children:n})]})]}):null}Object.freeze({status:`aborted`});function Q(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var UG=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},WG=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},GG={};function KG(e){return e&&Object.assign(GG,e),GG}function qG(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function JG(e,t){return typeof t==`bigint`?t.toString():t}function YG(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function XG(e){return e==null}function ZG(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function QG(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var $G=Symbol(`evaluating`);function eK(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==$G)return r===void 0&&(r=$G,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function tK(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function nK(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function rK(e){return JSON.stringify(e)}function iK(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var aK=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function oK(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var sK=YG(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function cK(e){if(oK(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return oK(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function lK(e){return cK(e)?{...e}:Array.isArray(e)?[...e]:e}var uK=new Set([`string`,`number`,`symbol`]);function dK(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function fK(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function $(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function pK(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var mK={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function hK(e,t){let n=e._zod.def;return fK(e,nK(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return tK(this,`shape`,e),e},checks:[]}))}function gK(e,t){let n=e._zod.def;return fK(e,nK(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return tK(this,`shape`,r),r},checks:[]}))}function _K(e,t){if(!cK(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");return fK(e,nK(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return tK(this,`shape`,n),n},checks:[]}))}function vK(e,t){if(!cK(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return fK(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return tK(this,`shape`,n),n},checks:e._zod.def.checks})}function yK(e,t){return fK(e,nK(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return tK(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function bK(e,t,n){return fK(t,nK(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return tK(this,`shape`,i),i},checks:[]}))}function xK(e,t,n){return fK(t,nK(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return tK(this,`shape`,i),i},checks:[]}))}function SK(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function CK(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function wK(e){return typeof e==`string`?e:e?.message}function TK(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=wK(e.inst?._zod.def?.error?.(e))??wK(t?.error?.(e))??wK(n.customError?.(e))??wK(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function EK(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function DK(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var OK=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,JG,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},kK=Q(`$ZodError`,OK),AK=Q(`$ZodError`,OK,{Parent:Error});function jK(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function MK(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}var NK=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new UG;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>TK(e,a,KG())));throw aK(t,i?.callee),t}return o.value},PK=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>TK(e,a,KG())));throw aK(t,i?.callee),t}return o.value},FK=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new UG;return a.issues.length?{success:!1,error:new(e??kK)(a.issues.map(e=>TK(e,i,KG())))}:{success:!0,data:a.value}},IK=FK(AK),LK=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>TK(e,i,KG())))}:{success:!0,data:a.value}},RK=LK(AK),zK=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return NK(e)(t,n,i)},BK=e=>(t,n,r)=>NK(e)(t,n,r),VK=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return PK(e)(t,n,i)},HK=e=>async(t,n,r)=>PK(e)(t,n,r),UK=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return FK(e)(t,n,i)},WK=e=>(t,n,r)=>FK(e)(t,n,r),GK=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return LK(e)(t,n,i)},KK=e=>async(t,n,r)=>LK(e)(t,n,r),qK=/^[cC][^\s-]{8,}$/,JK=/^[0-9a-z]+$/,YK=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,XK=/^[0-9a-vA-V]{20}$/,ZK=/^[A-Za-z0-9]{27}$/,QK=/^[a-zA-Z0-9_-]{21}$/,$K=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,eq=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,tq=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,nq=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,rq=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function iq(){return new RegExp(rq,`u`)}var aq=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,oq=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,sq=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,cq=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,lq=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,uq=/^[A-Za-z0-9_-]*$/,dq=/^\+(?:[0-9]){6,14}[0-9]$/,fq=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,pq=RegExp(`^${fq}$`);function mq(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function hq(e){return RegExp(`^${mq(e)}$`)}function gq(e){let t=mq({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${fq}T(?:${r})$`)}var _q=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},vq=/^-?\d+$/,yq=/^-?\d+(?:\.\d+)?/,bq=/^(?:true|false)$/i,xq=/^[^A-Z]*$/,Sq=/^[^a-z]*$/,Cq=Q(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),wq={number:`number`,bigint:`bigint`,object:`date`},Tq=Q(`$ZodCheckLessThan`,(e,t)=>{Cq.init(e,t);let n=wq[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Eq=Q(`$ZodCheckGreaterThan`,(e,t)=>{Cq.init(e,t);let n=wq[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Dq=Q(`$ZodCheckMultipleOf`,(e,t)=>{Cq.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):QG(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Oq=Q(`$ZodCheckNumberFormat`,(e,t)=>{Cq.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=mK[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=vq)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),kq=Q(`$ZodCheckMaxLength`,(e,t)=>{var n;Cq.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!XG(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=EK(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Aq=Q(`$ZodCheckMinLength`,(e,t)=>{var n;Cq.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!XG(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=EK(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),jq=Q(`$ZodCheckLengthEquals`,(e,t)=>{var n;Cq.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!XG(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=EK(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Mq=Q(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Cq.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Nq=Q(`$ZodCheckRegex`,(e,t)=>{Mq.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Pq=Q(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=xq,Mq.init(e,t)}),Fq=Q(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Sq,Mq.init(e,t)}),Iq=Q(`$ZodCheckIncludes`,(e,t)=>{Cq.init(e,t);let n=dK(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Lq=Q(`$ZodCheckStartsWith`,(e,t)=>{Cq.init(e,t);let n=RegExp(`^${dK(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Rq=Q(`$ZodCheckEndsWith`,(e,t)=>{Cq.init(e,t);let n=RegExp(`.*${dK(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),zq=Q(`$ZodCheckOverwrite`,(e,t)=>{Cq.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Bq=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
69
- `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
70
- `))}},Vq={major:4,minor:1,patch:13},Hq=Q(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Vq;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=SK(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new UG;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=SK(e,t))});else{if(e.issues.length===t)continue;r||=SK(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(SK(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new UG;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new UG;return o.then(e=>t(e,r,a))}return t(o,r,a)}}e[`~standard`]={validate:t=>{try{let n=IK(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return RK(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),Uq=Q(`$ZodString`,(e,t)=>{Hq.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??_q(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),Wq=Q(`$ZodStringFormat`,(e,t)=>{Mq.init(e,t),Uq.init(e,t)}),Gq=Q(`$ZodGUID`,(e,t)=>{t.pattern??=eq,Wq.init(e,t)}),Kq=Q(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=tq(e)}else t.pattern??=tq();Wq.init(e,t)}),qq=Q(`$ZodEmail`,(e,t)=>{t.pattern??=nq,Wq.init(e,t)}),Jq=Q(`$ZodURL`,(e,t)=>{Wq.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Yq=Q(`$ZodEmoji`,(e,t)=>{t.pattern??=iq(),Wq.init(e,t)}),Xq=Q(`$ZodNanoID`,(e,t)=>{t.pattern??=QK,Wq.init(e,t)}),Zq=Q(`$ZodCUID`,(e,t)=>{t.pattern??=qK,Wq.init(e,t)}),Qq=Q(`$ZodCUID2`,(e,t)=>{t.pattern??=JK,Wq.init(e,t)}),$q=Q(`$ZodULID`,(e,t)=>{t.pattern??=YK,Wq.init(e,t)}),eJ=Q(`$ZodXID`,(e,t)=>{t.pattern??=XK,Wq.init(e,t)}),tJ=Q(`$ZodKSUID`,(e,t)=>{t.pattern??=ZK,Wq.init(e,t)}),nJ=Q(`$ZodISODateTime`,(e,t)=>{t.pattern??=gq(t),Wq.init(e,t)}),rJ=Q(`$ZodISODate`,(e,t)=>{t.pattern??=pq,Wq.init(e,t)}),iJ=Q(`$ZodISOTime`,(e,t)=>{t.pattern??=hq(t),Wq.init(e,t)}),aJ=Q(`$ZodISODuration`,(e,t)=>{t.pattern??=$K,Wq.init(e,t)}),oJ=Q(`$ZodIPv4`,(e,t)=>{t.pattern??=aq,Wq.init(e,t),e._zod.bag.format=`ipv4`}),sJ=Q(`$ZodIPv6`,(e,t)=>{t.pattern??=oq,Wq.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),cJ=Q(`$ZodCIDRv4`,(e,t)=>{t.pattern??=sq,Wq.init(e,t)}),lJ=Q(`$ZodCIDRv6`,(e,t)=>{t.pattern??=cq,Wq.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function uJ(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var dJ=Q(`$ZodBase64`,(e,t)=>{t.pattern??=lq,Wq.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{uJ(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function fJ(e){if(!uq.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return uJ(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var pJ=Q(`$ZodBase64URL`,(e,t)=>{t.pattern??=uq,Wq.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{fJ(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),mJ=Q(`$ZodE164`,(e,t)=>{t.pattern??=dq,Wq.init(e,t)});function hJ(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var gJ=Q(`$ZodJWT`,(e,t)=>{Wq.init(e,t),e._zod.check=n=>{hJ(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),_J=Q(`$ZodNumber`,(e,t)=>{Hq.init(e,t),e._zod.pattern=e._zod.bag.pattern??yq,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),vJ=Q(`$ZodNumberFormat`,(e,t)=>{Oq.init(e,t),_J.init(e,t)}),yJ=Q(`$ZodBoolean`,(e,t)=>{Hq.init(e,t),e._zod.pattern=bq,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),bJ=Q(`$ZodUnknown`,(e,t)=>{Hq.init(e,t),e._zod.parse=e=>e}),xJ=Q(`$ZodNever`,(e,t)=>{Hq.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function SJ(e,t,n){e.issues.length&&t.issues.push(...CK(n,e.issues)),t.value[n]=e.value}var CJ=Q(`$ZodArray`,(e,t)=>{Hq.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>SJ(t,n,e))):SJ(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function wJ(e,t,n,r){e.issues.length&&t.issues.push(...CK(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function TJ(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=pK(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function EJ(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type;for(let i in t){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>wJ(e,n,i,t))):wJ(a,n,i,t)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var DJ=Q(`$ZodObject`,(e,t)=>{if(Hq.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=YG(()=>TJ(t));eK(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=oK,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e]._zod.run({value:s[e],issues:[]},o);n instanceof Promise?c.push(n.then(n=>wJ(n,t,e,s))):wJ(n,t,e,s)}return i?EJ(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),OJ=Q(`$ZodObjectJIT`,(e,t)=>{DJ.init(e,t);let n=e._zod.parse,r=YG(()=>TJ(t)),i=e=>{let t=new Bq([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=rK(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let e of n.keys){let n=a[e],r=rK(e);t.write(`const ${n} = ${i(e)};`),t.write(`
71
- if (${n}.issues.length) {
72
- payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
73
- ...iss,
74
- path: iss.path ? [${r}, ...iss.path] : [${r}]
75
- })));
76
- }
77
-
78
-
79
- if (${n}.value === undefined) {
80
- if (${r} in input) {
81
- newResult[${r}] = undefined;
82
- }
83
- } else {
84
- newResult[${r}] = ${n}.value;
85
- }
86
-
87
- `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=oK,s=!GG.jitless,c=s&&sK.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?EJ([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function kJ(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!SK(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>TK(e,r,KG())))}),t)}var AJ=Q(`$ZodUnion`,(e,t)=>{Hq.init(e,t),eK(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),eK(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),eK(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),eK(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>ZG(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>kJ(t,i,e,a)):kJ(s,i,e,a)}}),jJ=Q(`$ZodDiscriminatedUnion`,(e,t)=>{AJ.init(e,t);let n=e._zod.parse;eK(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=YG(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!oK(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),MJ=Q(`$ZodIntersection`,(e,t)=>{Hq.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>PJ(e,t,n)):PJ(e,i,a)}});function NJ(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(cK(e)&&cK(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=NJ(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=NJ(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function PJ(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),SK(e))return e;let r=NJ(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}var FJ=Q(`$ZodEnum`,(e,t)=>{Hq.init(e,t);let n=qG(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>uK.has(typeof e)).map(e=>typeof e==`string`?dK(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),IJ=Q(`$ZodLiteral`,(e,t)=>{if(Hq.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?dK(e):e?dK(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),LJ=Q(`$ZodTransform`,(e,t)=>{Hq.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new WG(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new UG;return n.value=i,n}});function RJ(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var zJ=Q(`$ZodOptional`,(e,t)=>{Hq.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,eK(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),eK(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ZG(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>RJ(t,e.value)):RJ(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),BJ=Q(`$ZodNullable`,(e,t)=>{Hq.init(e,t),eK(e._zod,`optin`,()=>t.innerType._zod.optin),eK(e._zod,`optout`,()=>t.innerType._zod.optout),eK(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ZG(e.source)}|null)$`):void 0}),eK(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),VJ=Q(`$ZodDefault`,(e,t)=>{Hq.init(e,t),e._zod.optin=`optional`,eK(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>HJ(e,t)):HJ(r,t)}});function HJ(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var UJ=Q(`$ZodPrefault`,(e,t)=>{Hq.init(e,t),e._zod.optin=`optional`,eK(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),WJ=Q(`$ZodNonOptional`,(e,t)=>{Hq.init(e,t),eK(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>GJ(t,e)):GJ(i,e)}});function GJ(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var KJ=Q(`$ZodCatch`,(e,t)=>{Hq.init(e,t),eK(e._zod,`optin`,()=>t.innerType._zod.optin),eK(e._zod,`optout`,()=>t.innerType._zod.optout),eK(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>TK(e,n,KG()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>TK(e,n,KG()))},input:e.value}),e.issues=[]),e)}}),qJ=Q(`$ZodPipe`,(e,t)=>{Hq.init(e,t),eK(e._zod,`values`,()=>t.in._zod.values),eK(e._zod,`optin`,()=>t.in._zod.optin),eK(e._zod,`optout`,()=>t.out._zod.optout),eK(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>JJ(e,t.in,n)):JJ(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>JJ(e,t.out,n)):JJ(r,t.out,n)}});function JJ(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var YJ=Q(`$ZodReadonly`,(e,t)=>{Hq.init(e,t),eK(e._zod,`propValues`,()=>t.innerType._zod.propValues),eK(e._zod,`values`,()=>t.innerType._zod.values),eK(e._zod,`optin`,()=>t.innerType?._zod?.optin),eK(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(XJ):XJ(r)}});function XJ(e){return e.value=Object.freeze(e.value),e}var ZJ=Q(`$ZodCustom`,(e,t)=>{Cq.init(e,t),Hq.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>QJ(t,n,r,e));QJ(i,n,r,e)}});function QJ(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(DK(e))}}var $J,eY=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function tY(){return new eY}($J=globalThis).__zod_globalRegistry??($J.__zod_globalRegistry=tY());var nY=globalThis.__zod_globalRegistry;function rY(e,t){return new e({type:`string`,...$(t)})}function iY(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...$(t)})}function aY(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...$(t)})}function oY(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...$(t)})}function sY(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...$(t)})}function cY(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...$(t)})}function lY(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...$(t)})}function uY(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...$(t)})}function dY(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...$(t)})}function fY(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...$(t)})}function pY(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...$(t)})}function mY(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...$(t)})}function hY(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...$(t)})}function gY(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...$(t)})}function _Y(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...$(t)})}function vY(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...$(t)})}function yY(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...$(t)})}function bY(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...$(t)})}function xY(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...$(t)})}function SY(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...$(t)})}function CY(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...$(t)})}function wY(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...$(t)})}function TY(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...$(t)})}function EY(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...$(t)})}function DY(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...$(t)})}function OY(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...$(t)})}function kY(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...$(t)})}function AY(e,t){return new e({type:`number`,checks:[],...$(t)})}function jY(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...$(t)})}function MY(e,t){return new e({type:`boolean`,...$(t)})}function NY(e){return new e({type:`unknown`})}function PY(e,t){return new e({type:`never`,...$(t)})}function FY(e,t){return new Tq({check:`less_than`,...$(t),value:e,inclusive:!1})}function IY(e,t){return new Tq({check:`less_than`,...$(t),value:e,inclusive:!0})}function LY(e,t){return new Eq({check:`greater_than`,...$(t),value:e,inclusive:!1})}function RY(e,t){return new Eq({check:`greater_than`,...$(t),value:e,inclusive:!0})}function zY(e,t){return new Dq({check:`multiple_of`,...$(t),value:e})}function BY(e,t){return new kq({check:`max_length`,...$(t),maximum:e})}function VY(e,t){return new Aq({check:`min_length`,...$(t),minimum:e})}function HY(e,t){return new jq({check:`length_equals`,...$(t),length:e})}function UY(e,t){return new Nq({check:`string_format`,format:`regex`,...$(t),pattern:e})}function WY(e){return new Pq({check:`string_format`,format:`lowercase`,...$(e)})}function GY(e){return new Fq({check:`string_format`,format:`uppercase`,...$(e)})}function KY(e,t){return new Iq({check:`string_format`,format:`includes`,...$(t),includes:e})}function qY(e,t){return new Lq({check:`string_format`,format:`starts_with`,...$(t),prefix:e})}function JY(e,t){return new Rq({check:`string_format`,format:`ends_with`,...$(t),suffix:e})}function YY(e){return new zq({check:`overwrite`,tx:e})}function XY(e){return YY(t=>t.normalize(e))}function ZY(){return YY(e=>e.trim())}function QY(){return YY(e=>e.toLowerCase())}function $Y(){return YY(e=>e.toUpperCase())}function eX(){return YY(e=>iK(e))}function tX(e,t,n){return new e({type:`array`,element:t,...$(n)})}function nX(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...$(n)})}function rX(e){let t=iX(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(DK(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(DK(r))}},e(n.value,n)));return t}function iX(e,t){let n=new Cq({check:`custom`,...$(t)});return n._zod.check=e,n}var aX=Q(`ZodISODateTime`,(e,t)=>{nJ.init(e,t),AX.init(e,t)});function oX(e){return EY(aX,e)}var sX=Q(`ZodISODate`,(e,t)=>{rJ.init(e,t),AX.init(e,t)});function cX(e){return DY(sX,e)}var lX=Q(`ZodISOTime`,(e,t)=>{iJ.init(e,t),AX.init(e,t)});function uX(e){return OY(lX,e)}var dX=Q(`ZodISODuration`,(e,t)=>{aJ.init(e,t),AX.init(e,t)});function fX(e){return kY(dX,e)}var pX=Q(`ZodError`,(e,t)=>{kK.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>MK(e,t)},flatten:{value:t=>jK(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,JG,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,JG,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),mX=NK(pX),hX=PK(pX),gX=FK(pX),_X=LK(pX),vX=zK(pX),yX=BK(pX),bX=VK(pX),xX=HK(pX),SX=UK(pX),CX=WK(pX),wX=GK(pX),TX=KK(pX),EX=Q(`ZodType`,(e,t)=>(Hq.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(nK(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]})),e.clone=(t,n)=>fK(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>mX(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>gX(e,t,n),e.parseAsync=async(t,n)=>hX(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>_X(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>vX(e,t,n),e.decode=(t,n)=>yX(e,t,n),e.encodeAsync=async(t,n)=>bX(e,t,n),e.decodeAsync=async(t,n)=>xX(e,t,n),e.safeEncode=(t,n)=>SX(e,t,n),e.safeDecode=(t,n)=>CX(e,t,n),e.safeEncodeAsync=async(t,n)=>wX(e,t,n),e.safeDecodeAsync=async(t,n)=>TX(e,t,n),e.refine=(t,n)=>e.check(zZ(t,n)),e.superRefine=t=>e.check(BZ(t)),e.overwrite=t=>e.check(YY(t)),e.optional=()=>CZ(e),e.nullable=()=>TZ(e),e.nullish=()=>CZ(TZ(e)),e.nonoptional=t=>jZ(e,t),e.array=()=>sZ(e),e.or=t=>dZ([e,t]),e.and=t=>hZ(e,t),e.transform=t=>FZ(e,xZ(t)),e.default=t=>DZ(e,t),e.prefault=t=>kZ(e,t),e.catch=t=>NZ(e,t),e.pipe=t=>FZ(e,t),e.readonly=()=>LZ(e),e.describe=t=>{let n=e.clone();return nY.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return nY.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return nY.get(e);let n=e.clone();return nY.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),DX=Q(`_ZodString`,(e,t)=>{Uq.init(e,t),EX.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(UY(...t)),e.includes=(...t)=>e.check(KY(...t)),e.startsWith=(...t)=>e.check(qY(...t)),e.endsWith=(...t)=>e.check(JY(...t)),e.min=(...t)=>e.check(VY(...t)),e.max=(...t)=>e.check(BY(...t)),e.length=(...t)=>e.check(HY(...t)),e.nonempty=(...t)=>e.check(VY(1,...t)),e.lowercase=t=>e.check(WY(t)),e.uppercase=t=>e.check(GY(t)),e.trim=()=>e.check(ZY()),e.normalize=(...t)=>e.check(XY(...t)),e.toLowerCase=()=>e.check(QY()),e.toUpperCase=()=>e.check($Y()),e.slugify=()=>e.check(eX())}),OX=Q(`ZodString`,(e,t)=>{Uq.init(e,t),DX.init(e,t),e.email=t=>e.check(iY(jX,t)),e.url=t=>e.check(uY(PX,t)),e.jwt=t=>e.check(TY(YX,t)),e.emoji=t=>e.check(dY(FX,t)),e.guid=t=>e.check(aY(MX,t)),e.uuid=t=>e.check(oY(NX,t)),e.uuidv4=t=>e.check(sY(NX,t)),e.uuidv6=t=>e.check(cY(NX,t)),e.uuidv7=t=>e.check(lY(NX,t)),e.nanoid=t=>e.check(fY(IX,t)),e.guid=t=>e.check(aY(MX,t)),e.cuid=t=>e.check(pY(LX,t)),e.cuid2=t=>e.check(mY(RX,t)),e.ulid=t=>e.check(hY(zX,t)),e.base64=t=>e.check(SY(KX,t)),e.base64url=t=>e.check(CY(qX,t)),e.xid=t=>e.check(gY(BX,t)),e.ksuid=t=>e.check(_Y(VX,t)),e.ipv4=t=>e.check(vY(HX,t)),e.ipv6=t=>e.check(yY(UX,t)),e.cidrv4=t=>e.check(bY(WX,t)),e.cidrv6=t=>e.check(xY(GX,t)),e.e164=t=>e.check(wY(JX,t)),e.datetime=t=>e.check(oX(t)),e.date=t=>e.check(cX(t)),e.time=t=>e.check(uX(t)),e.duration=t=>e.check(fX(t))});function kX(e){return rY(OX,e)}var AX=Q(`ZodStringFormat`,(e,t)=>{Wq.init(e,t),DX.init(e,t)}),jX=Q(`ZodEmail`,(e,t)=>{qq.init(e,t),AX.init(e,t)}),MX=Q(`ZodGUID`,(e,t)=>{Gq.init(e,t),AX.init(e,t)}),NX=Q(`ZodUUID`,(e,t)=>{Kq.init(e,t),AX.init(e,t)}),PX=Q(`ZodURL`,(e,t)=>{Jq.init(e,t),AX.init(e,t)}),FX=Q(`ZodEmoji`,(e,t)=>{Yq.init(e,t),AX.init(e,t)}),IX=Q(`ZodNanoID`,(e,t)=>{Xq.init(e,t),AX.init(e,t)}),LX=Q(`ZodCUID`,(e,t)=>{Zq.init(e,t),AX.init(e,t)}),RX=Q(`ZodCUID2`,(e,t)=>{Qq.init(e,t),AX.init(e,t)}),zX=Q(`ZodULID`,(e,t)=>{$q.init(e,t),AX.init(e,t)}),BX=Q(`ZodXID`,(e,t)=>{eJ.init(e,t),AX.init(e,t)}),VX=Q(`ZodKSUID`,(e,t)=>{tJ.init(e,t),AX.init(e,t)}),HX=Q(`ZodIPv4`,(e,t)=>{oJ.init(e,t),AX.init(e,t)}),UX=Q(`ZodIPv6`,(e,t)=>{sJ.init(e,t),AX.init(e,t)}),WX=Q(`ZodCIDRv4`,(e,t)=>{cJ.init(e,t),AX.init(e,t)}),GX=Q(`ZodCIDRv6`,(e,t)=>{lJ.init(e,t),AX.init(e,t)}),KX=Q(`ZodBase64`,(e,t)=>{dJ.init(e,t),AX.init(e,t)}),qX=Q(`ZodBase64URL`,(e,t)=>{pJ.init(e,t),AX.init(e,t)}),JX=Q(`ZodE164`,(e,t)=>{mJ.init(e,t),AX.init(e,t)}),YX=Q(`ZodJWT`,(e,t)=>{gJ.init(e,t),AX.init(e,t)}),XX=Q(`ZodNumber`,(e,t)=>{_J.init(e,t),EX.init(e,t),e.gt=(t,n)=>e.check(LY(t,n)),e.gte=(t,n)=>e.check(RY(t,n)),e.min=(t,n)=>e.check(RY(t,n)),e.lt=(t,n)=>e.check(FY(t,n)),e.lte=(t,n)=>e.check(IY(t,n)),e.max=(t,n)=>e.check(IY(t,n)),e.int=t=>e.check($X(t)),e.safe=t=>e.check($X(t)),e.positive=t=>e.check(LY(0,t)),e.nonnegative=t=>e.check(RY(0,t)),e.negative=t=>e.check(FY(0,t)),e.nonpositive=t=>e.check(IY(0,t)),e.multipleOf=(t,n)=>e.check(zY(t,n)),e.step=(t,n)=>e.check(zY(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function ZX(e){return AY(XX,e)}var QX=Q(`ZodNumberFormat`,(e,t)=>{vJ.init(e,t),XX.init(e,t)});function $X(e){return jY(QX,e)}var eZ=Q(`ZodBoolean`,(e,t)=>{yJ.init(e,t),EX.init(e,t)});function tZ(e){return MY(eZ,e)}var nZ=Q(`ZodUnknown`,(e,t)=>{bJ.init(e,t),EX.init(e,t)});function rZ(){return NY(nZ)}var iZ=Q(`ZodNever`,(e,t)=>{xJ.init(e,t),EX.init(e,t)});function aZ(e){return PY(iZ,e)}var oZ=Q(`ZodArray`,(e,t)=>{CJ.init(e,t),EX.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(VY(t,n)),e.nonempty=t=>e.check(VY(1,t)),e.max=(t,n)=>e.check(BY(t,n)),e.length=(t,n)=>e.check(HY(t,n)),e.unwrap=()=>e.element});function sZ(e,t){return tX(oZ,e,t)}var cZ=Q(`ZodObject`,(e,t)=>{OJ.init(e,t),EX.init(e,t),eK(e,`shape`,()=>t.shape),e.keyof=()=>_Z(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:rZ()}),e.loose=()=>e.clone({...e._zod.def,catchall:rZ()}),e.strict=()=>e.clone({...e._zod.def,catchall:aZ()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>_K(e,t),e.safeExtend=t=>vK(e,t),e.merge=t=>yK(e,t),e.pick=t=>hK(e,t),e.omit=t=>gK(e,t),e.partial=(...t)=>bK(SZ,e,t[0]),e.required=(...t)=>xK(AZ,e,t[0])});function lZ(e,t){return new cZ({type:`object`,shape:e??{},...$(t)})}var uZ=Q(`ZodUnion`,(e,t)=>{AJ.init(e,t),EX.init(e,t),e.options=t.options});function dZ(e,t){return new uZ({type:`union`,options:e,...$(t)})}var fZ=Q(`ZodDiscriminatedUnion`,(e,t)=>{uZ.init(e,t),jJ.init(e,t)});function pZ(e,t,n){return new fZ({type:`union`,options:t,discriminator:e,...$(n)})}var mZ=Q(`ZodIntersection`,(e,t)=>{MJ.init(e,t),EX.init(e,t)});function hZ(e,t){return new mZ({type:`intersection`,left:e,right:t})}var gZ=Q(`ZodEnum`,(e,t)=>{FJ.init(e,t),EX.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new gZ({...t,checks:[],...$(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new gZ({...t,checks:[],...$(r),entries:i})}});function _Z(e,t){return new gZ({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...$(t)})}var vZ=Q(`ZodLiteral`,(e,t)=>{IJ.init(e,t),EX.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function yZ(e,t){return new vZ({type:`literal`,values:Array.isArray(e)?e:[e],...$(t)})}var bZ=Q(`ZodTransform`,(e,t)=>{LJ.init(e,t),EX.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new WG(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(DK(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(DK(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function xZ(e){return new bZ({type:`transform`,transform:e})}var SZ=Q(`ZodOptional`,(e,t)=>{zJ.init(e,t),EX.init(e,t),e.unwrap=()=>e._zod.def.innerType});function CZ(e){return new SZ({type:`optional`,innerType:e})}var wZ=Q(`ZodNullable`,(e,t)=>{BJ.init(e,t),EX.init(e,t),e.unwrap=()=>e._zod.def.innerType});function TZ(e){return new wZ({type:`nullable`,innerType:e})}var EZ=Q(`ZodDefault`,(e,t)=>{VJ.init(e,t),EX.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function DZ(e,t){return new EZ({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():lK(t)}})}var OZ=Q(`ZodPrefault`,(e,t)=>{UJ.init(e,t),EX.init(e,t),e.unwrap=()=>e._zod.def.innerType});function kZ(e,t){return new OZ({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():lK(t)}})}var AZ=Q(`ZodNonOptional`,(e,t)=>{WJ.init(e,t),EX.init(e,t),e.unwrap=()=>e._zod.def.innerType});function jZ(e,t){return new AZ({type:`nonoptional`,innerType:e,...$(t)})}var MZ=Q(`ZodCatch`,(e,t)=>{KJ.init(e,t),EX.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function NZ(e,t){return new MZ({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var PZ=Q(`ZodPipe`,(e,t)=>{qJ.init(e,t),EX.init(e,t),e.in=t.in,e.out=t.out});function FZ(e,t){return new PZ({type:`pipe`,in:e,out:t})}var IZ=Q(`ZodReadonly`,(e,t)=>{YJ.init(e,t),EX.init(e,t),e.unwrap=()=>e._zod.def.innerType});function LZ(e){return new IZ({type:`readonly`,innerType:e})}var RZ=Q(`ZodCustom`,(e,t)=>{ZJ.init(e,t),EX.init(e,t)});function zZ(e,t={}){return nX(RZ,e,t)}function BZ(e){return rX(e)}var VZ=lZ({enabled:tZ(),auto_update:tZ(),runtime_model:kX().optional()}),HZ=_Z([`1:1`,`16:9`,`9:16`,`4:3`,`3:4`,`21:9`,`2:3`,`3:2`]),UZ=_Z([`1K`,`2K`,`4K`]),WZ=_Z([`low`,`medium`,`high`]),GZ=_Z([`cover_illustration`,`inline_illustration`,`infographic_diagram`,`product_showcase`,`icon_brand`,`other`]);pZ(`type`,[VZ.extend({type:yZ(`image_generation`),source_field_id:ZX().int().positive(),n:ZX().int().min(1).max(5).default(1),quality:WZ.default(`medium`),aspect_ratio:HZ.default(`1:1`),resolution:UZ.default(`1K`),image_use_case:GZ.default(`inline_illustration`)}),VZ.extend({type:yZ(`image_customization`),prompt:kX().min(1),source_field_id:ZX().int().positive().optional(),n:ZX().int().min(1).max(5).default(1),quality:WZ.default(`medium`),aspect_ratio:HZ.default(`1:1`),resolution:UZ.default(`1K`),image_use_case:GZ.default(`inline_illustration`)})]),pZ(`type`,[VZ.extend({type:yZ(`text_generation`),prompt:kX().min(1)}),VZ.extend({type:yZ(`summarize`),source_field_id:ZX().int().positive(),max_words:ZX().int().positive().optional()}),VZ.extend({type:yZ(`extract`),source_field_id:ZX().int().positive(),schema:kX().optional()}),VZ.extend({type:yZ(`translate`),source_field_id:ZX().int().positive(),target_language:kX().min(2)}),VZ.extend({type:yZ(`classify`),source_field_id:ZX().int().positive(),categories:sZ(kX()).min(2)}),VZ.extend({type:yZ(`customize`),prompt:kX().min(1)})]);function KZ({fields:e,currentFieldId:t,value:n,onChange:r}){let{t:i}=U(`table`),a=e.filter(e=>e.id!==t);return(0,I.jsxs)(`select`,{role:`combobox`,className:`data-inline-ai-source-picker`,value:n==null?``:String(n),onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&r(t)},children:[(0,I.jsx)(`option`,{value:``,disabled:!0,children:i(`aiConfig.selectSourceField`)}),a.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.title||e.name},e.id))]})}var qZ=[`1:1`,`16:9`,`9:16`,`4:3`,`3:4`,`21:9`,`2:3`,`3:2`],JZ=[`1K`,`2K`,`4K`],YZ=[`low`,`medium`,`high`],XZ=GZ.options;function ZZ({fields:e,currentFieldId:t,value:n,onChange:r}){let{t:i}=U(`table`);function a(e){r({...n,...e})}return(0,I.jsxs)(`div`,{className:`data-inline-ai-config-form`,children:[(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.useCase`)}),(0,I.jsx)(`select`,{"aria-label":i(`aiConfig.useCase`),value:n.image_use_case??`inline_illustration`,onChange:e=>a({image_use_case:e.target.value}),children:XZ.map(e=>(0,I.jsx)(`option`,{value:e,children:i(`aiConfig.useCases.${e}`)},e))})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.sourceField`)}),(0,I.jsx)(KZ,{fields:e,currentFieldId:t,value:n.source_field_id,onChange:e=>a({source_field_id:e})})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.aspectRatio`)}),(0,I.jsx)(`select`,{"aria-label":i(`aiConfig.aspectRatio`),value:n.aspect_ratio,onChange:e=>a({aspect_ratio:e.target.value}),children:qZ.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.resolution`)}),(0,I.jsx)(`select`,{"aria-label":i(`aiConfig.resolution`),value:n.resolution,onChange:e=>a({resolution:e.target.value}),children:JZ.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.quality`)}),(0,I.jsx)(`select`,{"aria-label":i(`aiConfig.quality`),value:n.quality,onChange:e=>a({quality:e.target.value}),children:YZ.map(e=>(0,I.jsx)(`option`,{value:e,children:i(`aiConfig.qualities.${e}`)},e))})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.variants`)}),(0,I.jsx)(`input`,{"aria-label":i(`aiConfig.variants`),type:`number`,min:1,max:5,value:n.n,onChange:e=>a({n:Math.max(1,Math.min(5,Number(e.target.value)||1))})})]}),(0,I.jsxs)(`label`,{className:`data-inline-ai-config-checkbox`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:n.auto_update,onChange:e=>a({auto_update:e.target.checked})}),(0,I.jsx)(`span`,{children:i(`aiConfig.autoRegenerateSourceField`)})]})]})}var QZ=[`1:1`,`16:9`,`9:16`,`4:3`,`3:4`,`21:9`,`2:3`,`3:2`],$Z=[`1K`,`2K`,`4K`],eQ=[`low`,`medium`,`high`],tQ=GZ.options;function nQ({fields:e,currentFieldId:t,value:n,onChange:r}){let{t:i}=U(`table`);function a(e){r({...n,...e})}return(0,I.jsxs)(`div`,{className:`data-inline-ai-config-form`,children:[(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.useCase`)}),(0,I.jsx)(`select`,{"aria-label":i(`aiConfig.useCase`),value:n.image_use_case??`inline_illustration`,onChange:e=>a({image_use_case:e.target.value}),children:tQ.map(e=>(0,I.jsx)(`option`,{value:e,children:i(`aiConfig.useCases.${e}`)},e))})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.prompt`)}),(0,I.jsx)(`textarea`,{"aria-label":i(`aiConfig.prompt`),rows:3,value:n.prompt,onChange:e=>a({prompt:e.target.value})})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.sourceImageField`)}),(0,I.jsx)(KZ,{fields:e,currentFieldId:t,value:n.source_field_id??null,onChange:e=>a({source_field_id:e})})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.aspectRatio`)}),(0,I.jsx)(`select`,{"aria-label":i(`aiConfig.aspectRatio`),value:n.aspect_ratio,onChange:e=>a({aspect_ratio:e.target.value}),children:QZ.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.resolution`)}),(0,I.jsx)(`select`,{"aria-label":i(`aiConfig.resolution`),value:n.resolution,onChange:e=>a({resolution:e.target.value}),children:$Z.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.quality`)}),(0,I.jsx)(`select`,{"aria-label":i(`aiConfig.quality`),value:n.quality,onChange:e=>a({quality:e.target.value}),children:eQ.map(e=>(0,I.jsx)(`option`,{value:e,children:i(`aiConfig.qualities.${e}`)},e))})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.variants`)}),(0,I.jsx)(`input`,{"aria-label":i(`aiConfig.variants`),type:`number`,min:1,max:5,value:n.n,onChange:e=>a({n:Math.max(1,Math.min(5,Number(e.target.value)||1))})})]}),(0,I.jsxs)(`label`,{className:`data-inline-ai-config-checkbox`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:n.auto_update,onChange:e=>a({auto_update:e.target.checked})}),(0,I.jsx)(`span`,{children:i(`aiConfig.autoRegenerateSourceField`)})]})]})}function rQ({value:e,onChange:t}){let{t:n}=U(`table`);return(0,I.jsxs)(`div`,{className:`data-inline-ai-config-form`,children:[(0,I.jsxs)(`label`,{children:[(0,I.jsxs)(`span`,{children:[n(`aiConfig.promptSupports`),` `,(0,I.jsx)(`code`,{children:`{{column_name}}`}),n(`aiConfig.promptSupportsSuffix`)]}),(0,I.jsx)(`textarea`,{"aria-label":n(`aiConfig.prompt`),rows:4,value:e.prompt,onChange:n=>t({...e,prompt:n.target.value})})]}),(0,I.jsxs)(`label`,{className:`data-inline-ai-config-checkbox`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:e.auto_update,onChange:n=>t({...e,auto_update:n.target.checked})}),(0,I.jsx)(`span`,{children:n(`aiConfig.autoRegenerateColumns`)})]})]})}function iQ({fields:e,currentFieldId:t,value:n,onChange:r}){let{t:i}=U(`table`);return(0,I.jsxs)(`div`,{className:`data-inline-ai-config-form`,children:[(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.sourceField`)}),(0,I.jsx)(KZ,{fields:e,currentFieldId:t,value:n.source_field_id,onChange:e=>r({...n,source_field_id:e})})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.maxWords`)}),(0,I.jsx)(`input`,{"aria-label":i(`aiConfig.maxWords`),type:`number`,min:10,value:n.max_words??``,onChange:e=>{let t=Number(e.target.value);r({...n,max_words:Number.isFinite(t)&&t>0?t:void 0})}})]}),(0,I.jsxs)(`label`,{className:`data-inline-ai-config-checkbox`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:n.auto_update,onChange:e=>r({...n,auto_update:e.target.checked})}),(0,I.jsx)(`span`,{children:i(`aiConfig.autoRegenerateSource`)})]})]})}function aQ({fields:e,currentFieldId:t,value:n,onChange:r}){let{t:i}=U(`table`);return(0,I.jsxs)(`div`,{className:`data-inline-ai-config-form`,children:[(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.sourceField`)}),(0,I.jsx)(KZ,{fields:e,currentFieldId:t,value:n.source_field_id,onChange:e=>r({...n,source_field_id:e})})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.outputSchema`)}),(0,I.jsx)(`textarea`,{"aria-label":i(`aiConfig.schema`),rows:5,value:n.schema??``,onChange:e=>r({...n,schema:e.target.value||void 0})})]}),(0,I.jsxs)(`label`,{className:`data-inline-ai-config-checkbox`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:n.auto_update,onChange:e=>r({...n,auto_update:e.target.checked})}),(0,I.jsx)(`span`,{children:i(`aiConfig.autoRegenerateSource`)})]})]})}var oQ=[{code:`zh`,labelKey:`aiConfig.languages.zh`},{code:`en`,labelKey:`aiConfig.languages.en`},{code:`ja`,labelKey:`aiConfig.languages.ja`},{code:`ko`,labelKey:`aiConfig.languages.ko`},{code:`es`,labelKey:`aiConfig.languages.es`},{code:`fr`,labelKey:`aiConfig.languages.fr`},{code:`de`,labelKey:`aiConfig.languages.de`}];function sQ({fields:e,currentFieldId:t,value:n,onChange:r}){let{t:i}=U(`table`);return(0,I.jsxs)(`div`,{className:`data-inline-ai-config-form`,children:[(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.sourceField`)}),(0,I.jsx)(KZ,{fields:e,currentFieldId:t,value:n.source_field_id,onChange:e=>r({...n,source_field_id:e})})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.targetLanguage`)}),(0,I.jsx)(`select`,{"aria-label":i(`aiConfig.targetLanguage`),value:n.target_language,onChange:e=>r({...n,target_language:e.target.value}),children:oQ.map(e=>(0,I.jsx)(`option`,{value:e.code,children:i(e.labelKey)},e.code))})]}),(0,I.jsxs)(`label`,{className:`data-inline-ai-config-checkbox`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:n.auto_update,onChange:e=>r({...n,auto_update:e.target.checked})}),(0,I.jsx)(`span`,{children:i(`aiConfig.autoRegenerateSource`)})]})]})}function cQ({fields:e,currentFieldId:t,value:n,onChange:r}){let{t:i}=U(`table`),a=n.categories.join(`
88
- `);return(0,I.jsxs)(`div`,{className:`data-inline-ai-config-form`,children:[(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.sourceField`)}),(0,I.jsx)(KZ,{fields:e,currentFieldId:t,value:n.source_field_id,onChange:e=>r({...n,source_field_id:e})})]}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:i(`aiConfig.categoriesLabel`)}),(0,I.jsx)(`textarea`,{"aria-label":i(`aiConfig.categories`),rows:5,value:a,onChange:e=>r({...n,categories:e.target.value.split(`
89
- `).map(e=>e.trim()).filter(Boolean)})})]}),(0,I.jsxs)(`label`,{className:`data-inline-ai-config-checkbox`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:n.auto_update,onChange:e=>r({...n,auto_update:e.target.checked})}),(0,I.jsx)(`span`,{children:i(`aiConfig.autoRegenerateSource`)})]})]})}function lQ({value:e,onChange:t}){let{t:n}=U(`table`);return(0,I.jsxs)(`div`,{className:`data-inline-ai-config-form`,children:[(0,I.jsxs)(`label`,{children:[(0,I.jsxs)(`span`,{children:[n(`aiConfig.promptSupports`),` `,(0,I.jsx)(`code`,{children:`{{column_name}}`}),n(`aiConfig.promptSupportsSuffix`)]}),(0,I.jsx)(`textarea`,{"aria-label":n(`aiConfig.prompt`),rows:5,value:e.prompt,onChange:n=>t({...e,prompt:n.target.value})})]}),(0,I.jsxs)(`label`,{className:`data-inline-ai-config-checkbox`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:e.auto_update,onChange:n=>t({...e,auto_update:n.target.checked})}),(0,I.jsx)(`span`,{children:n(`aiConfig.autoRegenerateColumns`)})]})]})}function uQ({value:e,capability:t,onChange:n}){let{t:r}=U(`table`),{ai:i}=cC(),[a,o]=(0,j.useState)([]),[s,c]=(0,j.useState)(!0),[l,u]=(0,j.useState)(null);(0,j.useEffect)(()=>{let e=!1;if(!i)c(!1);else return c(!0),u(null),i.loadModelOptions(t).then(t=>{e||o(t)}).catch(t=>{e||u(t instanceof Error?t.message:r(`aiConfig.model.loadFailed`))}).finally(()=>{e||c(!1)}),()=>{e=!0}},[i,t,r]);let d=e&&a.some(t=>t.value===e);return(0,I.jsxs)(`select`,{"aria-label":r(`aiConfig.runtimeModelOverride`),className:`data-inline-ai-model-picker`,value:e??``,onChange:e=>n(e.target.value||void 0),disabled:s,children:[(0,I.jsx)(`option`,{value:``,children:s?r(`aiConfig.model.loading`):l?r(`aiConfig.model.defaultWithError`,{error:l}):a.length?r(`aiConfig.model.default`):r(`aiConfig.model.defaultNoDesktop`)}),e&&!d&&!s?(0,I.jsx)(`option`,{value:e,children:r(`aiConfig.model.unavailable`,{model:e})}):null,a.map(e=>(0,I.jsx)(`option`,{value:e.value,children:e.label},e.value))]})}var dQ=[{value:`image_generation`,labelKey:`aiConfig.actions.imageGeneration`},{value:`image_customization`,labelKey:`aiConfig.actions.imageCustomization`}],fQ=[{value:`text_generation`,labelKey:`aiConfig.actions.textGeneration`},{value:`summarize`,labelKey:`aiConfig.actions.summarize`},{value:`extract`,labelKey:`aiConfig.actions.extract`},{value:`translate`,labelKey:`aiConfig.actions.translate`},{value:`classify`,labelKey:`aiConfig.actions.classify`},{value:`customize`,labelKey:`aiConfig.actions.customize`}];function pQ(e){return e.type===`attachment`}function mQ(e){return e.type===`text`||e.type===`long_text`}function hQ(e,t,n){let r=t.find(e=>e.id!==n)?.id??1;switch(e){case`image_generation`:return{type:`image_generation`,enabled:!0,auto_update:!1,source_field_id:r,n:1,quality:`medium`,aspect_ratio:`1:1`,resolution:`1K`,image_use_case:`inline_illustration`};case`image_customization`:return{type:`image_customization`,enabled:!0,auto_update:!1,prompt:``,n:1,quality:`medium`,aspect_ratio:`1:1`,resolution:`1K`,image_use_case:`inline_illustration`};case`text_generation`:return{type:`text_generation`,enabled:!0,auto_update:!1,prompt:``};case`summarize`:return{type:`summarize`,enabled:!0,auto_update:!1,source_field_id:r};case`extract`:return{type:`extract`,enabled:!0,auto_update:!1,source_field_id:r};case`translate`:return{type:`translate`,enabled:!0,auto_update:!1,source_field_id:r,target_language:`en`};case`classify`:return{type:`classify`,enabled:!0,auto_update:!1,source_field_id:r,categories:[`Category A`,`Category B`]};case`customize`:return{type:`customize`,enabled:!0,auto_update:!1,prompt:``};default:return null}}function gQ({field:e,fields:t,value:n,onChange:r,chrome:i=`standalone`}){let{t:a}=U(`table`),o=pQ(e),s=mQ(e);if(!o&&!s)return null;let c=o?dQ:fQ,l=!!n?.enabled,u=n&&`source_field_id`in n?n.source_field_id:void 0,d=typeof u==`number`?t.find(e=>e.id===u):void 0,f=!!n&&(n.type===`summarize`||n.type===`extract`||n.type===`translate`||n.type===`classify`)&&d?.type===`attachment`,p=n?.type===`image_generation`||n?.type===`image_customization`?`image`:f?`vision`:`text`,m=l&&n?(0,I.jsxs)(`div`,{className:`data-inline-ai-config-fields`,children:[(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:a(`aiConfig.action`)}),(0,I.jsx)(`select`,{"aria-label":a(`aiConfig.action`),value:n.type,onChange:n=>{let i=hQ(n.target.value,t,e.id);i&&r(i)},children:c.map(e=>(0,I.jsx)(`option`,{value:e.value,children:a(e.labelKey)},e.value))})]}),n.type===`image_generation`&&(0,I.jsx)(ZZ,{fields:t,currentFieldId:e.id,value:n,onChange:r}),n.type===`image_customization`&&(0,I.jsx)(nQ,{fields:t,currentFieldId:e.id,value:n,onChange:r}),n.type===`text_generation`&&(0,I.jsx)(rQ,{value:n,onChange:r}),n.type===`summarize`&&(0,I.jsx)(iQ,{fields:t,currentFieldId:e.id,value:n,onChange:r}),n.type===`extract`&&(0,I.jsx)(aQ,{fields:t,currentFieldId:e.id,value:n,onChange:r}),n.type===`translate`&&(0,I.jsx)(sQ,{fields:t,currentFieldId:e.id,value:n,onChange:r}),n.type===`classify`&&(0,I.jsx)(cQ,{fields:t,currentFieldId:e.id,value:n,onChange:r}),n.type===`customize`&&(0,I.jsx)(lQ,{value:n,onChange:r}),(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:a(`aiConfig.runtimeModelOverride`)}),(0,I.jsx)(uQ,{value:n.runtime_model,capability:p,onChange:e=>r({...n,runtime_model:e})})]}),f&&(0,I.jsx)(`p`,{className:`data-inline-ai-config-hint`,role:`note`,children:a(`aiConfig.visionModelHint`)})]}):null;return i===`embedded`?l?m:(0,I.jsx)(`div`,{className:`data-inline-ai-config-fields`,children:(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:a(`aiConfig.action`)}),(0,I.jsxs)(`select`,{"aria-label":a(`aiConfig.action`),value:``,onChange:n=>{let i=hQ(n.target.value,t,e.id);i&&r(i)},children:[(0,I.jsx)(`option`,{value:``,disabled:!0,children:a(`aiConfig.chooseAction`)}),c.map(e=>(0,I.jsx)(`option`,{value:e.value,children:a(e.labelKey)},e.value))]})]})}):(0,I.jsxs)(`div`,{className:`data-inline-ai-config-panel`,children:[(0,I.jsxs)(`header`,{className:`data-inline-ai-config-panel-head`,children:[(0,I.jsx)(`strong`,{children:a(`aiConfig.title`)}),(0,I.jsxs)(`label`,{className:`data-inline-ai-config-checkbox`,children:[(0,I.jsx)(`input`,{"aria-label":a(`aiConfig.enable`),type:`checkbox`,checked:l,onChange:i=>{if(i.target.checked){let n=hQ(c[0].value,t,e.id);n&&r(n)}else n&&r({...n,enabled:!1})}}),(0,I.jsx)(`span`,{children:a(`aiConfig.enable`)})]})]}),m]})}function _Q({field:e,fields:t,value:n,onChange:r}){let{t:i}=U(`table`),a=!!n?.enabled,[o,s]=(0,j.useState)(a);return(0,j.useEffect)(()=>{s(!!n?.enabled)},[n?.enabled]),(0,I.jsxs)(`div`,{className:`w-full rounded-md border border-border text-sm`,children:[(0,I.jsxs)(`button`,{type:`button`,"data-testid":`field-ai-config-toggle`,onClick:()=>s(e=>!e),className:K(`group flex w-full cursor-pointer select-none items-center justify-between`,`rounded-sm px-3 py-2 transition-all duration-500 ease-in-out`,`bg-gradient-to-r from-teal-100 via-blue-50 to-rose-50`,`hover:from-teal-100/70 hover:via-blue-50/70 hover:to-rose-50/70`,`dark:bg-none dark:bg-primary/15 dark:text-foreground dark:hover:bg-primary/20`,o&&`rounded-b-none`),children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-x-1`,children:[(0,I.jsx)(Ws,{className:`size-4 text-amber-500 dark:text-primary`}),i(`fieldConfig.aiConfig`)]}),(0,I.jsxs)(`span`,{className:`flex items-center gap-x-3`,children:[a?(0,I.jsx)(`span`,{"data-testid":`field-ai-config-remove`,role:`button`,tabIndex:0,onClick:e=>{e.stopPropagation(),r(void 0)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),r(void 0))},className:`cursor-pointer truncate rounded-sm border-b border-muted-foreground/80 text-xs text-muted-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:i(`fieldConfig.removeConfig`)}):null,o?(0,I.jsx)(ta,{className:`size-4 shrink-0`}):(0,I.jsx)(ra,{className:`size-4 shrink-0`})]})]}),o?(0,I.jsx)(`div`,{className:`space-y-4 border-t border-border p-4`,children:(0,I.jsx)(gQ,{chrome:`embedded`,field:e,fields:t,value:n,onChange:r})}):null]})}function vQ({value:e,onChange:t}){let{t:n}=U(`table`);return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:n(`fieldConfig.showAs`)}),(0,I.jsxs)(`div`,{role:`tablist`,"aria-label":n(`fieldConfig.showAs`),className:`inline-flex w-full rounded-md border border-border bg-muted p-1`,children:[(0,I.jsx)(yQ,{value:`text`,current:e,onSelect:t,children:n(`fieldConfig.showAsText`)}),(0,I.jsx)(yQ,{value:`markdown`,current:e,onSelect:t,children:n(`fieldConfig.showAsMarkdown`)})]})]})}function yQ({value:e,current:t,onSelect:n,children:r}){let i=t===e;return(0,I.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":i,"data-testid":`field-show-as-${e}`,onClick:()=>n(e),className:K(`flex-1 rounded-sm px-3 py-1.5 text-sm transition`,i?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`),children:r})}var bQ=new Date(2026,0,30,14,0,0).toISOString();function xQ({value:e,onChange:t}){let{t:n}=U(`table`),r=(0,j.useMemo)(()=>mE.map(e=>({format:e,label:CE({type:`datetime`,options:{date_format:e}},bQ)})),[]);return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium`,children:n(`fieldConfig.dateFormat`,{defaultValue:`Date format`})}),(0,I.jsx)(C_,{size:`lg`,value:e,"data-testid":`field-date-format`,onChange:e=>t(e.target.value),children:r.map(e=>(0,I.jsx)(`option`,{value:e.format,children:e.label},e.format))})]})}function SQ(e){let t=e.options?.showAs,n=t===`markdown`||t===`text`?t:`text`;return{title:e.title,description:typeof e.options?.description==`string`?e.options.description:``,type:e.type,readonly:e.readonly,choices:MT(e),choiceTones:NT(e),formula:e.formula||``,aiConfig:eC(e.ai_config)??void 0,columnTone:IT(e),longTextShowAs:n,dateFormat:yE(e)}}function CQ(e){return JSON.stringify(e)}function wQ({field:e,fields:t,busy:n,onClose:r,onSave:i}){let{t:a}=U([`table`,`common`]),{ai:o}=cC(),[s,c]=(0,j.useState)(()=>SQ(e)),[l,u]=(0,j.useState)(()=>CQ(SQ(e))),[d,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)(!1),h=(0,j.useMemo)(()=>CQ(s)!==l,[s,l]);(0,j.useEffect)(()=>{if(h)return;let t=SQ(e);c(t),u(CQ(t))},[e,h]);function g(e){c(t=>({...t,...e}))}let _=s.type===`attachment`||s.type===`text`||s.type===`long_text`,v=s.type===`single_select`||s.type===`multi_select`,y=s.type===`formula`,b=s.type===`long_text`,x=s.type===`date`||s.type===`datetime`;function S(e){g({type:e,...s.type!==`date`&&s.type!==`datetime`&&(e===`date`||e===`datetime`)?{dateFormat:yE({type:e})}:{}})}function C(){let t=s.choices.map(e=>e.trim()).filter(Boolean),n=t.reduce((e,t)=>(e[t]=PT(s.choiceTones[t]||``)||jT(t),e),{});return{title:s.title.trim()||e.title,type:s.type,readonly:s.readonly||y,options:{...e.options||{},column_tone:s.columnTone,description:s.description.trim()||void 0,...v?{choices:t,choice_tones:n}:{},ai_config:_?s.aiConfig??null:null,showAs:b?s.longTextShowAs:void 0,date_format:x?s.dateFormat:void 0},formula:y?s.formula.trim():e.formula}}async function w(){await i(C()),u(CQ(s)),r()}function T(){h?m(!0):r()}function E(){let t=SQ(e);c(t),u(CQ(t)),m(!1),r()}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(p_,{open:!0,testId:`right-sheet`,onClose:r,dirty:h,onRequestClose:T,title:a(`fieldConfigPanel.editField`),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Rc,{size:`md`,variant:`ghost`,onClick:T,disabled:n,children:a(`common:actions.cancel`)}),(0,I.jsx)(Rc,{variant:`primary`,size:`md`,onClick:()=>void w(),disabled:n||!h,children:a(`common:actions.save`)})]}),children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,I.jsx)(WA,{name:s.title,description:s.description,onNameChange:e=>g({title:e}),onDescriptionChange:e=>g({description:e}),onToggleAdvanced:()=>f(e=>!e)}),(0,I.jsx)(HG,{open:d,columnTone:s.columnTone,fieldId:e.id,onColumnToneChange:e=>g({columnTone:e})}),(0,I.jsx)(KA,{type:s.type,onChange:S}),x?(0,I.jsx)(xQ,{value:s.dateFormat,onChange:e=>g({dateFormat:e})}):null,(0,I.jsx)(`hr`,{className:`border-border`}),(0,I.jsx)(qA,{readonly:s.readonly,readonlyLocked:y,onReadonlyChange:e=>g({readonly:e})}),v?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`hr`,{className:`border-border`}),(0,I.jsx)(JA,{choices:s.choices,choiceTones:s.choiceTones,onChoicesChange:e=>g({choices:e}),onChoiceTonesChange:e=>g({choiceTones:e})})]}):null,y?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`hr`,{className:`border-border`}),(0,I.jsx)(BG,{formula:s.formula,currentFieldId:e.id,fields:t,onChange:e=>g({formula:e})})]}):null,_&&o?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`hr`,{className:`border-border`}),(0,I.jsx)(_Q,{field:{...e,type:s.type},fields:t,value:s.aiConfig,onChange:e=>g({aiConfig:e})})]}):null,b?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`hr`,{className:`border-border`}),(0,I.jsx)(vQ,{value:s.longTextShowAs,onChange:e=>g({longTextShowAs:e})})]}):null]})}),(0,I.jsx)(e_,{open:p,onOpenChange:m,children:(0,I.jsxs)(t_,{size:`sm`,children:[(0,I.jsxs)(i_,{children:[(0,I.jsx)(o_,{children:a(`fieldConfigPanel.saveChangesTitle`)}),(0,I.jsx)(s_,{children:a(`fieldConfigPanel.unsavedChanges`)})]}),(0,I.jsxs)(a_,{children:[(0,I.jsx)(Rc,{size:`md`,variant:`ghost`,onClick:()=>m(!1),children:a(`fieldConfigPanel.continueEditing`)}),(0,I.jsx)(Rc,{size:`md`,variant:`danger`,onClick:E,children:a(`fieldConfigPanel.discard`)}),(0,I.jsx)(Rc,{variant:`primary`,size:`md`,onClick:()=>void w().then(()=>m(!1)),disabled:n,children:a(`common:actions.save`)})]})]})})]})}function TQ({menu:e,record:t,busy:n,canInsert:r,fields:i,selectedFieldName:a,onClose:o,onInsertRecords:s,onDuplicateRecord:c,onCopyRecordURL:l,onOpenRecord:u,onCopyRecordForChat:d,onDeleteRecord:f,onRegenerateAIField:p,onStatus:m}){let{t:h}=U(`table`),g=cC(),_=fC(),{copyImageToClipboard:v,requestDesignFromRecord:y}=g;if(!e||!t)return null;function b(e){o(),e()}let x=i.filter(e=>e.ai_config?.enabled),S=i.find(e=>e.type===`attachment`),C=a?i.find(e=>e.name===a):null,w=C?.type===`attachment`&&TT(t.values?.[C.name]??null).map(e=>ST(e)).find(Boolean)||``;async function T(){if(w&&v)try{await v(uC(g,w)),m(h(`recordMenu.imageCopied`))}catch(e){_.error(h(`recordMenu.imageCopyFailed`),{description:e instanceof Error?e.message:String(e)})}}return(0,I.jsx)(sA,{record:t,position:e,busy:n,canInsert:r,canRegenerateAI:x.length>0&&!!g.ai,onClose:o,onInsertAbove:e=>b(()=>s(t,e,`before`)),onInsertBelow:e=>b(()=>s(t,e,`after`)),onDuplicate:()=>b(()=>c(t)),onCopyURL:()=>b(()=>l(t)),onCopyImage:w&&v?()=>b(T):void 0,onHistory:()=>{o(),m(h(`recordMenu.historyUnavailable`))},onComment:()=>{o(),u(t),m(h(`recordMenu.commentsHint`))},onAddToChat:()=>b(()=>d(t)),onCreateDesign:y?()=>b(()=>y({title:h(`recordMenu.designTitle`,{id:t.auto_number??t.id}),fields:t.values??{},record:S?{documentId:t.document_id,tableId:t.table_id,recordId:t.id,field:S.name}:void 0})):void 0,onRegenerateAI:()=>{o();for(let e of x)p(t,e)},onDelete:()=>b(()=>f(t.id))})}function EQ(e,t,n){return`kition://doc/${e}/table/${t}/record/${encodeURIComponent(n)}`}function DQ({record:e,fields:t,primaryField:n,documentId:r,tableId:i,navIndex:a,navTotal:o,canNavigatePrev:s,canNavigateNext:c,onPreviewAttachments:l,onOpenDocument:u,onClose:d,onDelete:f,onUpdate:p,onReplaceLinks:m,onNavigatePrev:h,onNavigateNext:g}){let{t:_}=U(`table`),[v,y]=(0,j.useState)(!1),[b,x]=(0,j.useState)(!1),S=(0,j.useCallback)(async()=>{let t=EQ(r,i,e.row_key);try{await navigator.clipboard.writeText(t),x(!0),setTimeout(()=>x(!1),1500)}catch{x(!1)}},[r,i,e.row_key]);return(0,I.jsxs)(`aside`,{className:`data-inline-record-drawer`,children:[(0,I.jsxs)(`header`,{children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`strong`,{children:n&&xT(e.values?.[n.name]??null)||_(`drawer.untitled`)}),(0,I.jsx)(`span`,{children:_(`drawer.recordId`,{id:e.id})})]}),(0,I.jsxs)(`div`,{className:`data-inline-record-drawer-actions`,children:[typeof a==`number`&&typeof o==`number`?(0,I.jsxs)(`span`,{className:`data-inline-record-drawer-nav-count`,children:[a+1,` / `,o]}):null,(0,I.jsx)(`button`,{type:`button`,className:`data-inline-record-drawer-nav-btn`,disabled:!s||!h,onClick:()=>h?.(),"aria-label":_(`drawer.previousRecord`),children:(0,I.jsx)(ia,{className:`size-4`})}),(0,I.jsx)(`button`,{type:`button`,className:`data-inline-record-drawer-nav-btn`,disabled:!c||!g,onClick:()=>g?.(),"aria-label":_(`drawer.nextRecord`),children:(0,I.jsx)(ta,{className:`size-4`})}),(0,I.jsx)(`button`,{type:`button`,className:`data-inline-record-drawer-nav-btn`,onClick:()=>void S(),"aria-label":_(`drawer.copyRecordLink`),title:_(b?`drawer.copied`:`drawer.copyRecordLink`),children:(0,I.jsx)(Co,{className:`size-4`})}),(0,I.jsx)(`button`,{onClick:d,"aria-label":_(`drawer.close`),children:`×`})]})]}),(0,I.jsx)(`div`,{className:`data-inline-record-fields`,children:t.map(t=>(0,I.jsxs)(`label`,{children:[(0,I.jsx)(`span`,{children:t.title}),t.type===`link_to_record`&&m?(0,I.jsx)(vk,{field:t,value:e.values?.[t.name]??null,documentId:r,tableId:i,onReplace:e=>m(t,e)}):(0,I.jsx)(Ek,{field:t,value:e.values?.[t.name]??null,documentId:r,tableId:i,recordId:e.id,onPreviewAttachments:l,onOpenDocument:u,onCommit:e=>p(t,e)})]},t.id))}),(0,I.jsxs)(`button`,{type:`button`,className:`data-inline-record-history-toggle`,onClick:()=>y(e=>!e),children:[(0,I.jsx)(ma,{className:`size-4`}),(0,I.jsx)(`span`,{children:_(`drawer.history`)}),v?(0,I.jsx)(ia,{className:`size-4`}):(0,I.jsx)(ta,{className:`size-4`})]}),v?(0,I.jsx)(OQ,{documentId:r,tableId:i,recordId:e.id,fields:t}):null,(0,I.jsxs)(Rc,{size:`md`,variant:`danger`,onClick:f,children:[(0,I.jsx)(hc,{className:`size-4`}),_(`drawer.deleteRecord`)]})]})}function OQ({documentId:e,tableId:t,recordId:n,fields:r}){let{t:i}=U(`table`),a=pC(),o=aC(),[s,c]=(0,j.useState)([]),[l,u]=(0,j.useState)(!1),[d,f]=(0,j.useState)(null);(0,j.useEffect)(()=>{let r=!1;return u(!0),f(null),o.records.history({documentId:e,tableId:t,recordId:n,limit:50}).then(e=>{r||c(e.items||[])}).catch(e=>{r||f(e instanceof Error?e.message:i(`drawer.loadHistoryFailed`))}).finally(()=>{r||u(!1)}),()=>{r=!0}},[o,e,t,n]);let p=new Map(r.map(e=>[e.id,e]));return l?(0,I.jsx)(`div`,{className:`data-inline-record-history-empty`,children:i(`drawer.loadingHistory`)}):d?(0,I.jsx)(`div`,{className:`data-inline-record-history-empty`,children:d}):s.length===0?(0,I.jsx)(`div`,{className:`data-inline-record-history-empty`,children:i(`drawer.noHistory`)}):(0,I.jsx)(`ol`,{className:`data-inline-record-history-list`,children:s.map(e=>{let t=(e.field_id?p.get(e.field_id):null)?.title||(e.field_id?i(`drawer.fieldId`,{id:e.field_id}):null);return(0,I.jsxs)(`li`,{className:`data-inline-record-history-item`,children:[(0,I.jsxs)(`div`,{className:`data-inline-record-history-meta`,children:[(0,I.jsx)(`span`,{className:`data-inline-record-history-action data-inline-record-history-action--${e.action}`,children:i(`drawer.historyAction.${e.action}`,{defaultValue:e.action})}),t?(0,I.jsx)(`span`,{className:`data-inline-record-history-field`,children:t}):null,(0,I.jsx)(`span`,{className:`data-inline-record-history-time`,children:kQ(e.created_at,a)})]}),e.action===`update`&&e.field_id?(0,I.jsxs)(`div`,{className:`data-inline-record-history-diff`,children:[(0,I.jsx)(`span`,{className:`data-inline-record-history-before`,children:xT(e.before)||`∅`}),(0,I.jsx)(`span`,{className:`data-inline-record-history-arrow`,children:`→`}),(0,I.jsx)(`span`,{className:`data-inline-record-history-after`,children:xT(e.after)||`∅`})]}):null]},e.id)})})}function kQ(e,t){if(!e)return``;let n=new Date(nC(e));return Number.isNaN(n.getTime())?String(e):n.toLocaleString(t)}function AQ({patches:e,fields:t,setRecords:n}){let r=(0,j.useRef)(0);(0,j.useEffect)(()=>{if(!e||e.length===0){r.current=0;return}if(e.length<=r.current||t.length===0)return;let i=new Map;for(let e of t)i.set(e.id,e.name);let a=e.slice(r.current);r.current=e.length;try{n(e=>{let t=!1,n=e.map(e=>{let n=null;for(let t of a){if(t.recordId!==e.id)continue;let r=i.get(t.fieldId);if(!r)continue;let a=n??e;n={...a,values:{...a.values??{},[r]:t.value}}}return n?(t=!0,n):e});return t?n:e})}catch(e){console.warn(`[useApplyAICellPatches] failed to apply patches`,e)}},[e,t,n])}function jQ({document:e,activeTable:t,allRecords:n,visibleFields:r,sortItems:i,setBusy:a,setError:o,setEditingField:s,setFilterTree:c,setSortItems:l,setGroupItems:u,setFrozenColumnCount:d,setHiddenFieldNames:f,setToolbarPanel:p,refreshDocument:m,copyTextToClipboard:h,setStatus:g,refreshHistoryState:_}){let{t:v}=U(`table`),y=aC(),b=cC();async function x(n){if(e&&t){a(!0);try{let r=await y.fields.duplicate({documentId:e.id,tableId:t.id,fieldId:n.id}),i=r.required?await y.fields.update({documentId:e.id,tableId:t.id,fieldId:r.id,required:!1}):r;await m(t.id),g(v(`feedback.fieldDuplicated`)),s(i),_?.()}catch(e){o(e instanceof Error?e.message:`Failed to duplicate field`)}finally{a(!1)}}}async function S(n,r){if(e&&t){a(!0);try{let i=n===`before`?r.order:r.order+1,a=await y.fields.create({documentId:e.id,tableId:t.id,title:`New field`,type:`text`,required:!1,order:i});await m(t.id),s(a),_?.()}catch(e){o(e instanceof Error?e.message:`Failed to insert field`)}finally{a(!1)}}}async function C(e){let t=(await n()).map(t=>t.values?.[e.name]).filter(e=>e!=null&&e!==``);await h(JSON.stringify({[e.title]:t},null,2),`Column copied for chat`)}async function w(e){let t=0;for(let r of await n()){let n=TT(r.values?.[e.name]);for(let e of n){let n=e.url?uC(b,e.url):``;if(!n)continue;let r=window.document.createElement(`a`);r.href=n,r.download=e.name||``,r.rel=`noreferrer`,window.document.body.appendChild(r),r.click(),r.remove(),t+=1}}g(t===0?v(`feedback.noFilesToDownload`):`Downloading ${t} file${t===1?``:`s`}`)}function T(e){c(t=>{let n=t?{...t,children:[...t.children]}:nT(`and`),r=tT();return r.field_name=e.name,n.children=[...n.children.filter(e=>e.kind!==`condition`||e.field_name!==``||e.value!==``),r],n}),p(`filter`)}function E(e){if(i.some(t=>t.field_name===e.name)){p(`sort`);return}let t={id:`sort_${Date.now().toString(36)}_${e.id}`,field_name:e.name,direction:`asc`};l([...i,t]),p(`sort`)}function D(e){u([{id:`grp_${Date.now().toString(36)}_${e.id}`,field_name:e.name,direction:`asc`}]),p(`group`)}function O(e){let t=r.findIndex(t=>t.id===e.id);t<0||d(t+1)}function k(e){e.is_primary||f(t=>{let n=new Set(t);return n.add(e.name),n})}return{addFilterForField:T,addSortForField:E,copyColumnValuesForChat:C,downloadAllFiles:w,duplicateField:x,freezeUpToField:O,hideField:k,insertField:S,setGroupField:D}}function MQ(e){return e==null?!0:typeof e==`string`?e.trim()===``:Array.isArray(e)?e.length===0:typeof e==`object`&&Object.keys(e).length===0}function NQ(e,t){let n=e.ai_config;if(!n?.enabled)return[];let r=new Set;if(`source_field_id`in n&&n.source_field_id&&r.add(n.source_field_id),`prompt`in n){let i=new Map(t.map(e=>[e.name,e]));for(let t of n.prompt.matchAll(/{{\s*([^{}]+?)\s*}}/g)){let n=i.get(t[1].trim());n&&n.id!==e.id&&r.add(n.id)}}return Array.from(r)}function PQ(e,t){return e.order-t.order||e.id-t.id}function FQ(e,t){let n=e.filter(e=>t.has(e.id)).sort(PQ),r=new Set(n.map(e=>e.id)),i=new Map(n.map(t=>[t.id,NQ(t,e).filter(e=>r.has(e))])),a=new Map,o=new Map;for(let e of n){let t=i.get(e.id)||[];o.set(e.id,t.length);for(let n of t){let t=a.get(n)||[];t.push(e.id),a.set(n,t)}}let s=new Map(n.map(e=>[e.id,e])),c=n.filter(e=>o.get(e.id)===0),l=[];for(;c.length&&l.length<32;){c.sort(PQ);let e=c.shift();l.push(e);for(let t of a.get(e.id)||[]){let e=(o.get(t)||0)-1;if(o.set(t,e),e===0){let e=s.get(t);e&&c.push(e)}}}let u=new Set(l.map(e=>e.id));return{fields:l,cyclicFieldIds:n.filter(e=>!u.has(e.id)).map(e=>e.id)}}function IQ(e){return FQ(e,new Set(e.filter(e=>e.ai_config?.enabled&&e.ai_config.auto_update).map(e=>e.id)))}function LQ(e,t){let n=new Set(t),r=e.filter(e=>e.ai_config?.enabled&&e.ai_config.auto_update),i=new Set,a=!0;for(;a;){a=!1;for(let t of r)i.has(t.id)||NQ(t,e).some(e=>n.has(e)||i.has(e))&&(i.add(t.id),a=!0)}return FQ(e,i)}function RQ(e,t,n){let r=NQ(t,n).map(e=>n.find(t=>t.id===e)).filter(e=>!!e);if(!r.length)return!1;let i=t.ai_config&&`source_field_id`in t.ai_config?t.ai_config.source_field_id:void 0,a=r.filter(e=>e.required||!!e.ai_config?.enabled||i===e.id);return a.length?a.every(t=>!MQ(e.values?.[t.name])):r.some(t=>!MQ(e.values?.[t.name]))}var zQ=/{{\s*([^{}]+?)\s*}}/g;function BQ(e){let t=Array.isArray(e)?e.length:+!!e;return t===0?`no reference image provided`:t===1?`the attached reference image`:`the attached reference images`}function VQ(e){return String(e.display||e.name||e.title||e.label||e.row_key||``).trim()}function HQ(e,t){return e.type===`attachment`?BQ(t):t==null||t===``?`not provided`:Array.isArray(t)?t.map(e=>e&&typeof e==`object`?VQ(e):String(e??``).trim()).filter(Boolean).join(`, `)||`not provided`:typeof t==`object`?VQ(t)||`not provided`:typeof t==`boolean`?t?`Yes`:`No`:String(t).trim()||`not provided`}function UQ(e){return`prompt`in e&&/{{\s*[^{}]+?\s*}}/.test(e.prompt)}function WQ(e,t,n){if(!(`prompt`in e)||!UQ(e))return e;let r=new Map;for(let e of n)r.set(e.name,e),r.set(e.title,e);let i=e.prompt.replace(zQ,(e,n)=>{let i=r.get(n.trim());return i?HQ(i,t.values?.[i.name]):`not provided`});return{...e,prompt:i}}async function GQ(e,t,n){let r=[...e],i=[],a=Array.from({length:Math.max(1,Math.min(t,e.length||1))},async()=>{for(;r.length;){let e=r.shift();i.push(await n(e))}});return await Promise.all(a),i}function KQ({document:e,activeTable:t,fields:n,records:r,groupField:i,canReorderRows:a,canMoveKanbanCards:o,selectedRecordIds:s,setBusy:c,setError:l,setRecords:u,setSelectedRecord:d,setSelectedRecordIds:f,setRecordContextMenu:p,loadRecords:m,setStatus:h,copyTextToClipboard:g,refreshHistoryState:_}){let{t:v}=U(`table`),y=aC(),{ai:b}=cC();async function x(r){if(!e||!t)return null;let i=await y.records.create({documentId:e.id,tableId:t.id,values:{...OT(n),...r}});return u(e=>[...e,i]),window.dispatchEvent(new CustomEvent(`kition:data-document:record:upsert`,{detail:{vaultPath:e.path,tableId:t.id,recordIds:[i.id]}})),S(i),i}async function S(r){if(!e||!t)return;let i=IQ(n);if(i.cyclicFieldIds.length){l(`AI field dependency cycle detected`);return}let a=r;for(let e of i.fields){if(!RQ(a,e,n))continue;let t=await A(a,e);t&&(a=t)}}async function C(n={}){if(e&&t){c(!0);try{await x(n),_?.()}catch(e){l(e instanceof Error?e.message:`Failed to create record`)}finally{c(!1)}}}async function w(n,r,i,o,s){if(!e||!t)return;let u=Math.max(1,Math.min(50,Math.floor(r)||1)),d=a&&n.row_key?i===`after`?{after:n.row_key}:{before:n.row_key}:null;c(!0);try{await y.transact({documentId:e.id,ops:[{op:`records.create`,tableId:t.id,at:d,records:Array.from({length:u},()=>o())}]}),await m(),h(s),_?.()}catch(e){l(e instanceof Error?e.message:`Record creation failed`),m()}finally{c(!1)}}async function T(e,t,r){await w(e,t,r,()=>OT(n),t>1?`${t} records inserted`:`Record inserted`)}async function E(e){await w(e,1,`after`,()=>({...e.values||{}}),`Record duplicated`)}async function D(r,i){if(!e||!t)return r;let a=LQ(n,[i.id]);if(a.cyclicFieldIds.length)return l(`AI field dependency cycle detected`),r;let o=r;for(let e of a.fields){if(!RQ(o,e,n))continue;let t=await A(o,e);t&&(o=t)}return o}async function O(n,r,i){if(!e||!t||r.readonly)return!1;let a=DT(r,i),o={...n,values:{...n.values,[r.name]:a}};u(e=>e.map(e=>e.id===n.id?o:e)),d(e=>e?.id===n.id?o:e);try{return await y.records.update({documentId:e.id,tableId:t.id,recordId:n.id,values:{[r.name]:a}}),window.dispatchEvent(new CustomEvent(`kition:data-document:record:upsert`,{detail:{vaultPath:e.path,tableId:t.id,recordIds:[n.id]}})),_?.(),await D(o,r),!0}catch(e){return l(e instanceof Error?e.message:`Save failed`),m(),!1}}async function k(e,t){let n=await A(e,t);return n?D(n,t):null}async function A(r,i){if(!e||!t||!b)return;let a=eC(i.ai_config);if(!a?.enabled)return;let o=new AbortController,s=YT(t.id,r.id,i.id);XT.cancel(s),XT.start(s,a.type,o);try{let c=await b.resolveRuntimeModel(a),l=WQ(a,r,n),f=await b.runCell({documentId:e.id,tableId:t.id,recordId:r.id,fieldId:i.id,action:l.type,config:l,force:!0,runtime_model:c},{signal:o.signal});return u(e=>e.map(e=>e.id===r.id?f.record:e)),d(e=>e?.id===r.id?f.record:e),XT.complete(s),h(`${i.title} generated`),f.record}catch(e){if(e instanceof DOMException&&e.name===`AbortError`){XT.complete(s);return}let t=e instanceof Error?e.message:`AI generation failed`;return XT.fail(s,t),l(`${i.title}: ${t}`),null}}async function j(r,i,a){if(!e||!t||!b)return;let o=eC(r.ai_config);if(!o?.enabled)return;let s=Array.from(new Set(i.filter(e=>Number.isFinite(e)&&e>0))).slice(0,100);if(!s.length){l(v(`feedback.selectRecordsToGenerate`));return}c(!0);let f=new AbortController;for(let e of s){let n=YT(t.id,e,r.id);XT.cancel(n),XT.start(n,o.type,f)}h(`${r.title}: generating ${s.length} record${s.length===1?``:`s`}…`);try{let i=await b.resolveRuntimeModel(o);if(UQ(o)){let a=new Map((await N(s)).map(e=>[e.id,e])),c=await GQ(s,3,async s=>{let c=a.get(s);if(!c)return{recordId:s,error:`Record is not loaded`};try{let a=WQ(o,c,n);return{recordId:s,record:(await b.runCell({documentId:e.id,tableId:t.id,recordId:c.id,fieldId:r.id,action:a.type,config:a,force:!0,runtime_model:i},{signal:f.signal})).record}}catch(e){return{recordId:s,error:e instanceof Error?e.message:`AI generation failed`}}}),p=c.flatMap(e=>`record`in e?[e.record]:[]),m=c.flatMap(e=>`error`in e?[e]:[]);if(p.length){let e=new Map(p.map(e=>[e.id,e]));u(t=>t.map(t=>e.get(t.id)||t)),d(t=>t&&(e.get(t.id)||t));for(let e of p)await D(e,r)}for(let e of s){let n=YT(t.id,e,r.id),i=m.find(t=>t.recordId===e);i?XT.fail(n,i.error):XT.complete(n)}m.length?l(`${r.title}: ${p.length} generated, ${m.length} failed. ${m[0].error}`):h(`${r.title}: ${p.length} generated`);return}let c=await b.runBatch({documentId:e.id,tableId:t.id,fieldId:r.id,action:o.type,config:o,record_ids:s,scope:a,force:!0,limit:100,runtime_model:i},{signal:f.signal});if(c.items.length){let e=new Map(c.items.map(e=>[e.record.id,e.record]));u(t=>t.map(t=>e.get(t.id)||t)),d(t=>t&&(e.get(t.id)||t));for(let e of c.items)await D(e.record,r)}for(let e of s){let n=YT(t.id,e,r.id),i=c.errors?.find(t=>t.record_id===e);i?XT.fail(n,i.message):XT.complete(n)}if(c.failed){let e=c.errors?.[0]?.message||`Some records failed to generate`;l(`${r.title}: ${c.completed} generated, ${c.failed} failed. ${e}`)}else h(`${r.title}: ${c.completed} generated`)}catch(e){let n=e instanceof Error?e.message:`AI batch generation failed`;for(let e of s){let i=YT(t.id,e,r.id);XT.fail(i,n)}l(n)}finally{c(!1)}}async function M(n){if(e&&t){c(!0);try{await y.records.delete({documentId:e.id,tableId:t.id,recordId:n}),u(e=>e.filter(e=>e.id!==n)),f(e=>{let t=new Set(e);return t.delete(n),t}),p(e=>e?.recordId===n?null:e),window.dispatchEvent(new CustomEvent(`kition:data-document:record:delete`,{detail:{vaultPath:e.path,tableId:t.id,recordIds:[n]}})),_?.()}catch(e){l(e instanceof Error?e.message:`Delete failed`)}finally{c(!1)}}}async function N(e){if(!t)return[];let n=new Map(r.map(e=>[e.id,e])),i=e.filter(e=>!n.has(e));if(i.length)for(let e of await y.grid.records({tableId:t.id,ids:i}))n.set(e.id,e);return e.flatMap(e=>n.get(e)??[])}async function ee(){return(await N(Array.from(s))).map(e=>e.row_key).filter(Boolean)}async function P(){if(!e||!t||!s.size)return;let n=await ee();if(!n.length)return;let r=new Set(s);c(!0);try{n.length>1?await y.records.bulkDelete({documentId:e.id,tableId:t.id,row_keys:n}):await Promise.all(Array.from(r).map(n=>y.records.delete({documentId:e.id,tableId:t.id,recordId:n}))),u(e=>e.filter(e=>!r.has(e.id))),f(new Set),window.dispatchEvent(new CustomEvent(`kition:data-document:record:delete`,{detail:{vaultPath:e.path,tableId:t.id,recordIds:Array.from(r)}})),_?.()}catch(e){l(e instanceof Error?e.message:`Bulk delete failed`)}finally{c(!1)}}async function F(){if(!e||!t||!s.size)return;let n=await ee();if(n.length){c(!0);try{await y.records.bulkCopy({documentId:e.id,tableId:t.id,row_keys:n}),await m(),_?.()}catch(e){l(e instanceof Error?e.message:`Bulk copy failed`)}finally{c(!1)}}}async function te(n,a,s){if(!e||!t||!i||!o)return;let c=r.find(e=>e.id===n);if(!c?.row_key)return;let d=VT(i,a),f=xT(d)||`Empty`,p=r.map(e=>e.id===n?{...e,values:{...e.values,[i.name]:d}}:e);if(s&&s!==n)p=zT(p,n,s);else{let e=p.find(e=>e.id===n);if(e){let t=p.filter(e=>e.id!==n),r=t.reduce((e,t,n)=>(xT(t.values?.[i.name]??null)||`Empty`)===f?n+1:e,t.length);p=[...t.slice(0,r),e,...t.slice(r)]}}u(p);let h=p.findIndex(e=>e.id===n),g=p[h+1]?.row_key??null;try{await y.transact({documentId:e.id,ops:[{op:`cells.set`,tableId:t.id,records:[{rowKey:c.row_key,values:{[i.name]:d}}]},{op:`records.move`,tableId:t.id,rowKeys:[c.row_key],before:g}]}),_?.()}catch(e){l(e instanceof Error?e.message:`Failed to save card move`),m()}}async function ne(e){let t=window.location.href.split(`#`)[0];await g(`${t}#record-${e.id}`,`Record URL copied`)}return{addRecord:C,copyRecordURL:ne,duplicateRecord:E,duplicateSelectedRecords:F,insertRecordsNear:T,moveKanbanRecord:te,removeRecord:M,removeSelectedRecords:P,runAIField:k,runAIFieldBatchForRecords:j,updateCell:O}}function qQ({documentPath:e,document:t,activeTable:n,tableViews:r,fields:i,allRecords:a,newFieldTitle:o,newFieldType:s,importInputRef:c,setBusy:l,setError:u,setDocument:d,setRecords:f,setEditingField:p,setNewFieldTitle:m,setViewCreateOpen:h,setActiveViewId:g,refreshDocument:_,loadRecords:v,setStatus:y,copyTextToClipboard:b,refreshHistoryState:x}){let S=v_(),C=aC(),{exportTable:w,notify:T}=cC(),{t:E}=U(`table`);function D(e){return{title:e.title,name:e.name,type:e.type,primary:e.is_primary,required:!1,readonly:e.readonly,options:e.options,formula:e.formula}}function O(e){return{title:e.title,type:e.type,config:e.config}}async function k(r){if(!t||!n)return;let i=n.title,a=r.trim();if(a&&a!==i)try{let r=await C.tables.update({documentId:t.id,tableId:n.id,title:a});d(e=>e&&{...e,tables:e.tables?.map(e=>e.id===r.id?{...e,...r}:e)||[]}),window.dispatchEvent(new CustomEvent(`kition:data-document:table:rename`,{detail:{vaultPath:e,tableId:n.id,newName:r.title}})),x?.()}catch(e){u(e instanceof Error?e.message:`Failed to save table name`)}}async function A(){if(t&&n){l(!0);try{let o=await C.tables.create({documentId:t.id,title:`${n.title} copy`,description:n.description,fields:i.map(D),views:r.map(O)}),s=await a();s.length&&await Promise.all(s.map(e=>C.records.create({documentId:t.id,tableId:o.id,values:e.values||{}}))),window.dispatchEvent(new CustomEvent(`kition:data-document:table:create`,{detail:{vaultPath:e,tableId:o.id}})),await _(o.id),y(E(`feedback.tableDuplicated`)),x?.()}catch(e){u(e instanceof Error?e.message:`Failed to duplicate table`)}finally{l(!1)}}}async function j(e){if(n&&w){l(!0);try{let t=await w(e,{id:n.id,title:n.title});y(E(`feedback.exported`,{path:t}))}catch(e){T?.error(E(`feedback.exportFailed`),{description:e instanceof Error?e.message:String(e)})}finally{l(!1)}}}async function M(){if(t&&n&&await S({message:`Delete table "${n.title}"?`,variant:`danger`})){l(!0);try{await C.tables.delete({documentId:t.id,tableId:n.id}),window.dispatchEvent(new CustomEvent(`kition:data-document:table:delete`,{detail:{vaultPath:e,tableId:n.id}})),await _(null),f([]),y(E(`feedback.tableDeleted`)),x?.()}catch(e){u(e instanceof Error?e.message:`Failed to delete table`)}finally{l(!1)}}}function N(r){if(r===`rename`){let e=window.prompt(E(`toolbar.renameTablePrompt`),n?.title||``);e!==null&&k(e)}else r===`duplicate`?A():r===`export_csv`||r===`export_markdown`?j(r===`export_csv`?`csv`:`md`):r===`import_csv`?c.current?.click():r===`copy_api`?t&&n&&b(`/v1/data-documents/${t.id}/tables/${n.id}`,`API path copied`):r===`history`?y(E(`feedback.historyUnavailable`)):r===`share`?b(t?.path||e,`Table link copied`):r===`delete`&&M()}async function ee(i){if(t&&n){l(!0),h(!1);try{let a=await C.views.create({documentId:t.id,tableId:n.id,title:yT(i,r),type:i});d(e=>e&&{...e,tables:e.tables?.map(e=>e.id===n.id?{...e,views:[...e.views||[],a].sort((e,t)=>e.order-t.order||e.id-t.id)}:e)}),g(a.id),window.dispatchEvent(new CustomEvent(`kition:data-document:view:upsert`,{detail:{vaultPath:e,tableId:n.id,viewId:a.id}})),x?.()}catch(e){u(e instanceof Error?e.message:`Failed to create view`)}finally{l(!1)}}}async function P(i,a){if(!t||!n)return;let o=r.find(e=>e.id===i),s=a.trim();if(o&&s&&s!==o.title)try{let r=await C.views.update({documentId:t.id,tableId:n.id,viewId:i,title:s});d(e=>e&&{...e,tables:e.tables?.map(e=>e.id===n.id?{...e,views:e.views?.map(e=>e.id===i?r:e)}:e)}),window.dispatchEvent(new CustomEvent(`kition:data-document:view:upsert`,{detail:{vaultPath:e,tableId:n.id,viewId:i}})),x?.()}catch(e){u(e instanceof Error?e.message:`Failed to rename view`)}}async function F(i){if(!t||!n)return;let a=r.find(e=>e.id===i);if(!a)return;let o=gT(a)||E(hT(a.type)),s=E(`viewMenu.copyTitle`,{title:o}),c=new Set(r.map(e=>e.title.trim().toLowerCase())),f=s,p=2;for(;c.has(f.toLowerCase());)f=`${s} ${p++}`;l(!0);try{let r=await C.views.listFields({documentId:t.id,tableId:n.id,viewId:a.id}).catch(()=>({items:[]})),i=await C.views.create({documentId:t.id,tableId:n.id,title:f,type:a.type,config:a.config?structuredClone(a.config):a.config});await Promise.allSettled(r.items.map(e=>C.views.patchField({documentId:t.id,tableId:n.id,viewId:i.id,fieldId:e.field_id,visible:e.visible,width:e.width,position:e.position,frozen:e.frozen}))),d(e=>e&&{...e,tables:e.tables?.map(e=>e.id===n.id?{...e,views:[...e.views||[],i].sort((e,t)=>e.order-t.order||e.id-t.id)}:e)}),g(i.id),window.dispatchEvent(new CustomEvent(`kition:data-document:view:upsert`,{detail:{vaultPath:e,tableId:n.id,viewId:i.id}})),y(E(`feedback.viewDuplicated`)),x?.()}catch(e){u(e instanceof Error?e.message:`Failed to duplicate view`)}finally{l(!1)}}async function te(i){if(!t||!n||r.length<=1)return;let a=r.findIndex(e=>e.id===i),o=r[a];if(!o||o.locked)return;let s=gT(o)||E(hT(o.type));if(await S({message:E(`viewMenu.deleteConfirm`,{title:s}),variant:`danger`})){l(!0);try{await C.views.delete({documentId:t.id,tableId:n.id,viewId:o.id});let i=r.filter(e=>e.id!==o.id),s=i[Math.min(a,i.length-1)]||i[0];d(e=>e&&{...e,tables:e.tables?.map(e=>e.id===n.id?{...e,views:e.views?.filter(e=>e.id!==o.id)}:e)}),g(s?.id??null),window.dispatchEvent(new CustomEvent(`kition:data-document:view:delete`,{detail:{vaultPath:e,tableId:n.id,viewId:o.id}})),y(E(`feedback.viewDeleted`)),x?.()}catch(e){u(e instanceof Error?e.message:`Failed to delete view`)}finally{l(!1)}}}async function ne(){if(t&&n&&o.trim()){l(!0);try{await C.fields.create({documentId:t.id,tableId:n.id,title:o.trim(),type:s,required:!1,readonly:s===`formula`,options:s===`single_select`||s===`multi_select`?{choices:[`Not started`,`In progress`,`Done`]}:void 0}),m(``),await _(n.id),x?.()}catch(e){u(e instanceof Error?e.message:`Failed to add property`)}finally{l(!1)}}}async function I(){if(t&&n){l(!0);try{let e=new Set(i.map(e=>e.title)),r=`New property`,a=2;for(;e.has(r);)r=`New property ${a++}`;await C.fields.create({documentId:t.id,tableId:n.id,title:r,type:`text`,required:!1}),await _(n.id),x?.()}catch(e){u(e instanceof Error?e.message:`Failed to add property`)}finally{l(!1)}}}async function re(r,i){if(t&&n)try{let a=await C.fields.update({documentId:t.id,tableId:n.id,fieldId:r.id,...i,required:!1});d(e=>e&&{...e,tables:e.tables?.map(e=>e.id===n.id?{...e,fields:e.fields?.map(e=>e.id===r.id?a:e)}:e)}),p(a),window.dispatchEvent(new CustomEvent(`kition:data-document:field:upsert`,{detail:{vaultPath:e,tableId:n.id,fieldId:r.id}})),x?.()}catch(e){u(e instanceof Error?e.message:`Failed to save field`)}}async function ie(r){if(t&&n&&!r.is_primary){l(!0);try{await C.fields.delete({documentId:t.id,tableId:n.id,fieldId:r.id}),p(null),await _(n.id),v(),window.dispatchEvent(new CustomEvent(`kition:data-document:field:delete`,{detail:{vaultPath:e,tableId:n.id,fieldId:r.id}})),x?.()}catch(e){u(e instanceof Error?e.message:`Failed to delete field`)}finally{l(!1)}}}return{addField:ne,addDefaultField:I,createView:ee,deleteView:te,duplicateView:F,renameView:P,removeField:ie,runTableAction:N,saveField:re}}function JQ({documentPath:e,document:t,activeTable:n,tableViews:r,fields:i,records:a,allRecords:o,groupField:s,canReorderRows:c,canMoveKanbanCards:l,newFieldTitle:u,newFieldType:d,selectedRecordIds:f,importInputRef:p,setBusy:m,setError:h,setDocument:g,setRecords:_,setSelectedRecord:v,setSelectedRecordIds:y,setRecordContextMenu:b,setEditingField:x,setNewFieldTitle:S,setViewCreateOpen:C,setActiveViewId:w,setImagePreview:T,refreshDocument:E,loadRecords:D,refreshHistoryState:O}){let k=fC();function A(e){k.success(e)}function j(e,t){e.length&&T({items:e,index:Math.min(Math.max(t,0),e.length-1)})}async function M(e,t){try{await navigator.clipboard.writeText(e),A(t)}catch{A(e)}}let N=qQ({documentPath:e,document:t,activeTable:n,tableViews:r,fields:i,allRecords:o,newFieldTitle:u,newFieldType:d,importInputRef:p,setBusy:m,setError:h,setDocument:g,setRecords:_,setEditingField:x,setNewFieldTitle:S,setViewCreateOpen:C,setActiveViewId:w,refreshDocument:E,loadRecords:D,setStatus:A,copyTextToClipboard:M,refreshHistoryState:O}),ee=KQ({document:t,activeTable:n,fields:i,records:a,groupField:s,canReorderRows:c,canMoveKanbanCards:l,selectedRecordIds:f,setBusy:m,setError:h,setRecords:_,setSelectedRecord:v,setSelectedRecordIds:y,setRecordContextMenu:b,loadRecords:D,setStatus:A,copyTextToClipboard:M,refreshHistoryState:O});return{...N,...ee,copyTextToClipboard:M,openAttachmentPreview:j}}var YQ=`kition.table.grid.collapsed-groups.v1`,XQ=new Map,ZQ=new Set,QQ=!1;function $Q(){try{let e=localStorage.getItem(YQ);if(!e)return{};let t=JSON.parse(e);return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}function e$(){if(QQ)return;QQ=!0;let e=$Q();for(let[t,n]of Object.entries(e))Array.isArray(n)&&XQ.set(t,new Set(n))}function t$(){let e={};for(let[t,n]of XQ.entries())n.size>0&&(e[t]=Array.from(n));try{localStorage.setItem(YQ,JSON.stringify(e))}catch{}}var n$=new Set;function r$(e){return e$(),XQ.get(e)??n$}function i$(e,t){e$(),XQ.set(e,new Set(t)),t$();for(let e of ZQ)e()}function a$(e){return ZQ.add(e),()=>{ZQ.delete(e)}}function o$(e){return(0,j.useSyncExternalStore)(a$,()=>r$(e),()=>n$)}var s$=`__no_view__`;function c$(e){let t=e==null?s$:String(e);return{collapsedGroupIds:o$(t),setCollapsedGroupIds:(0,j.useCallback)(n=>{e!=null&&i$(t,n)},[t,e])}}function l$({documentPath:e,markerContent:t,pinnedTableId:n,onRecordsLoaded:r}){let i=aC(),a=(0,j.useRef)(``),[o,s]=(0,j.useState)(null),[c,l]=(0,j.useState)(null),[u,d]=(0,j.useState)(null),[f,p]=(0,j.useState)([]),[m,h]=(0,j.useState)(!0),[g,_]=(0,j.useState)(``);async function v(){h(!0),_(``);try{let r=bT(t),a=null;if(r)try{a=await i.documents.get({documentId:r})}catch{a=null}if(!a)try{a=await i.documents.open({path:e})}catch{a=(await i.documents.list({query:e})).items.find(t=>t.path===e)||null}s(a),l(e=>{let t=a?.tables??[];return n==null?e&&t.some(t=>t.id===e)?e:t[0]?.id??null:t.some(e=>e.id===n)?n:null})}catch(e){_(e instanceof Error?e.message:`Failed to load table`)}finally{h(!1)}}async function y(e=c,t=u){if(!o)return;let r=await i.documents.get({documentId:o.id});s(r);let a=r?.tables??[],f=n==null?e&&a.some(t=>t.id===e)?e:a[0]?.id??null:a.some(e=>e.id===n)?n:null;l(f);let p=f?a.find(e=>e.id===f):n==null?a[0]:void 0;d(t&&p?.views?.some(e=>e.id===t)?t:p?.views?.[0]?.id??null)}async function b(){if(!o||!c){p([]);return}let e=`${o.id}:${c}`;if(a.current!==e){a.current=e;try{let e=await i.records.list({documentId:o.id,tableId:c});p(e.items),r?.()}catch(e){_(e instanceof Error?e.message:`Failed to load records`)}finally{a.current===e&&(a.current=``)}}}return(0,j.useEffect)(()=>{v()},[e,t,n]),{document:o,setDocument:s,activeTableId:c,setActiveTableId:l,activeViewId:u,setActiveViewId:d,records:f,setRecords:p,loading:m,setLoading:h,error:g,setError:_,loadDocument:v,refreshDocument:y,loadRecords:b}}function u$({axis:e,fields:t,hiddenFieldNames:n,coverFieldName:r,groupFieldName:i,groupItems:a,recordContextMenuRecordId:o,records:s,sortDirection:c,sortFieldName:l,sortItems:u,viewMode:d}){let f=(0,j.useMemo)(()=>t.filter(e=>!n.has(e.name)),[t,n]),p=(0,j.useMemo)(()=>t.find(e=>e.is_primary)||t[0]||null,[t]),m=(0,j.useMemo)(()=>t.find(e=>e.type===`date`||e.type===`datetime`)||null,[t]),h=(0,j.useMemo)(()=>t.filter(e=>e.type===`single_select`||e.type===`checkbox`||e.type===`text`),[t]),g=(0,j.useMemo)(()=>t.filter(e=>e.type===`attachment`||e.type===`url`||e.type===`text`),[t]),_=(0,j.useMemo)(()=>u&&u.length>0?u.filter(e=>t.some(t=>t.name===e.field_name)):l?[{id:`legacy:${l}`,field_name:l,direction:c}]:[],[t,u,l,c]),v=(0,j.useMemo)(()=>a&&a.length>0?a.filter(e=>t.some(t=>t.name===e.field_name)):i?[{id:`legacy:${i}`,field_name:i,direction:`asc`}]:[],[t,a,i]),y=v[0]?.field_name||``,b=(0,j.useMemo)(()=>t.find(e=>e.name===y)||t.find(e=>e.type===`single_select`)||p,[t,y,p]),x=(0,j.useMemo)(()=>t.find(e=>e.name===r)||t.find(e=>e.type===`attachment`)||t.find(e=>e.type===`url`)||null,[r,t]),S=(0,j.useMemo)(()=>new Map(s.map(e=>[e.id,e])),[s]),C=(0,j.useMemo)(()=>{if(!e)return[];let t=[];for(let n of e.ids){let e=S.get(n);e&&t.push(e)}return t},[e,S]),w=e?.ids.length??0,T=(0,j.useMemo)(()=>{let e=new Map;return b?.type===`single_select`&&MT(b).forEach(t=>e.set(t,[])),b?.type===`checkbox`&&(e.set(`true`,[]),e.set(`false`,[])),C.forEach(t=>{let n=b?xT(t.values?.[b.name]??null)||`Empty`:`All records`;e.set(n,[...e.get(n)||[],t])}),Array.from(e.entries())},[b,C]),E=(0,j.useMemo)(()=>o&&s.find(e=>e.id===o)||null,[o,s]),D=d===`grid`&&_.length===0&&v.length===0;return{canMoveKanbanCards:!!(b&&!b.readonly&&h.some(e=>e.name===b.name)),canReorderRows:D,contextMenuRecord:E,coverField:x,coverFields:g,dateField:m,groupField:b,groupFieldNames:(0,j.useMemo)(()=>v.map(e=>e.field_name),[v]),groupedRecords:T,groupableFields:h,primaryField:p,shownCount:w,sortedAndFilteredRecords:C,visibleFields:f}}var d$=[],f$=3;function p$(e,t){let n=aC().grid,[r,i]=(0,j.useState)(d$),[a,o]=(0,j.useState)(0),s=t.filter(e=>e.type===`number`),c=s.map(e=>`${e.id}:${e.name}`).join(`,`);return(0,j.useEffect)(()=>n.subscribe(()=>o(e=>e+1)),[n]),(0,j.useEffect)(()=>{if(!e||!s.length){i(d$);return}let t=!0;return n.summary({fields:s.map(e=>e.name)}).then(e=>{if(!t)return;let n=s.map((t,n)=>{let{count:r,sum:i}=e[n]??{count:0,sum:0};return{field:t,count:r,sum:i,average:r?i/r:0}}).filter(e=>e.count>0).slice(0,f$);i(n.length?n:d$)},()=>{}),()=>{t=!1}},[n,e,c,a]),r}function m$(){let[e,t]=(0,j.useState)(new Set),[n,r]=(0,j.useState)(null),[i,a]=(0,j.useState)(null),[o,s]=(0,j.useState)(null),[c,l]=(0,j.useState)(null),[u,d]=(0,j.useState)(null),[f,p]=(0,j.useState)(``),[m,h]=(0,j.useState)(null),[g,_]=(0,j.useState)(null),[v,y]=(0,j.useState)(null),[b,x]=(0,j.useState)(null);function S(){t(new Set)}function C(e,n){n.preventDefault(),n.stopPropagation(),t(t=>t.has(e.id)?t:new Set([e.id])),h({recordId:e.id,x:n.clientX,y:n.clientY})}function w(e,t){_({fieldId:e.id,x:t.x,y:t.y})}function T(){_(null)}function E(){l(null),d(null),p(``)}return{clearKanbanDrag:E,closeColumnHeaderMenu:T,columnHeaderMenu:g,editingField:o,imagePreview:b,kanbanDragOverGroup:f,kanbanDragOverRecordId:u,kanbanDraggingRecordId:c,openColumnHeaderMenu:w,openRecordContextMenu:C,recordContextMenu:m,resetSelectedRecordIds:S,selectedGridCell:i,selectedRecord:n,selectedRecordIds:e,setColumnHeaderMenu:_,setEditingField:s,setImagePreview:x,setKanbanDragOverGroup:p,setKanbanDragOverRecordId:d,setKanbanDraggingRecordId:l,setRecordContextMenu:h,setSelectedGridCell:a,setSelectedRecord:r,setSelectedRecordIds:t,setToolbarPanel:y,toolbarPanel:v}}function h$({documentId:e,onApplyChange:t}){let n=aC(),[r,i]=(0,j.useState)(!1),[a,o]=(0,j.useState)(!1),[s,c]=(0,j.useState)(!1),l=(0,j.useRef)(t);l.current=t;let u=(0,j.useCallback)(()=>e==null?(i(!1),o(!1),Promise.resolve()):n.historyState({documentId:e}).then(e=>{i(e.canUndo),o(e.canRedo)}).catch(()=>{}),[n,e]);(0,j.useEffect)(()=>{u()},[u]);let d=(0,j.useCallback)(async t=>{if(e==null)return!1;c(!0);try{let r=t===`undo`?await n.undo({documentId:e}):await n.redo({documentId:e});return r.done&&await l.current?.(r.change),r.done}finally{await u(),c(!1)}},[n,e,u]);return{canUndo:r,canRedo:a,historyBusy:s,refreshHistoryState:u,undo:(0,j.useCallback)(()=>d(`undo`),[d]),redo:(0,j.useCallback)(()=>d(`redo`),[d])}}function g$(e,t){let n=aC(),r=(0,j.useRef)(t);r.current=t,(0,j.useEffect)(()=>{if(e!=null)return n.onChange(e,e=>{let t=r.current;if(e.type===`resync`){t.onResync?.();return}let n=e.change;(n.recordsUpserted.length>0||n.recordsDeleted.length>0)&&t.onRecords?.(n.recordsUpserted,n.recordsDeleted),(n.tables.length>0||n.schema.length>0)&&t.onSchema?.([...new Set([...n.tables,...n.schema])]),n.views.length>0&&t.onViews?.(n.views),n.recordsReordered.length>0&&t.onReorder?.(n.recordsReordered),n.dashboards&&t.onDashboards?.()})},[n,e])}function _$(e){let t=BT(e);return{hiddenFieldNames:new Set(t.hidden_field_names||[]),filterFieldName:t.filter?.field_name||``,filterOperator:t.filter?.operator||`contains`,filterValue:t.filter?.value||``,filterTree:lT(t.filter_tree),sortFieldName:t.sort?.field_name||``,sortDirection:t.sort?.direction||`asc`,sortItems:Array.isArray(t.sort_items)?t.sort_items:[],groupFieldName:t.group_field_name||``,groupItems:Array.isArray(t.group_items)?t.group_items:[],coverFieldName:t.cover_field_name||``,rowHeightKey:t.row_height||`medium`,frozenColumnCount:typeof t.frozen_column_count==`number`?t.frozen_column_count:1}}function v$(e){return{hidden_field_names:Array.from(e.hiddenFieldNames),filter:e.filterFieldName?{field_name:e.filterFieldName,operator:e.filterOperator,value:e.filterValue}:void 0,filter_tree:e.filterTree&&e.filterTree.children.length>0?e.filterTree:void 0,sort:e.sortFieldName?{field_name:e.sortFieldName,direction:e.sortDirection}:void 0,sort_items:e.sortItems.length?e.sortItems:void 0,group_field_name:e.groupFieldName||void 0,group_items:e.groupItems.length?e.groupItems:void 0,cover_field_name:e.coverFieldName||void 0,row_height:e.rowHeightKey,frozen_column_count:e.frozenColumnCount}}function y$(e,t){return JSON.stringify(v$(_$(e)))===JSON.stringify(t)}function b$({document:e,activeTable:t,activeView:n,tableViews:r,setDocument:i,setActiveViewId:a}){let o=aC(),[s,c]=(0,j.useState)(new Set),[l,u]=(0,j.useState)(``),[d,f]=(0,j.useState)(`asc`),[p,m]=(0,j.useState)([]),[h,g]=(0,j.useState)(``),[_,v]=(0,j.useState)([]),[y,b]=(0,j.useState)(``),[x,S]=(0,j.useState)(``),[C,w]=(0,j.useState)(`contains`),[T,E]=(0,j.useState)(``),[D,O]=(0,j.useState)(null),[k,A]=(0,j.useState)(`medium`),[M,N]=(0,j.useState)(1),ee=(0,j.useRef)(null),P=(0,j.useRef)(0),F=(0,j.useRef)({viewId:null,config:``}),te=(0,j.useRef)(new WeakSet),ne=n?.type||`grid`;return(0,j.useEffect)(()=>{a(e=>e&&r.some(t=>t.id===e)?e:r[0]?.id??null)},[t?.id,a,r]),(0,j.useEffect)(()=>{if(n&&te.current.delete(n))return;n&&(ee.current=n.id);let e=_$(n);F.current={viewId:n?.id??null,config:JSON.stringify(v$(e))},c(new Set(e.hiddenFieldNames)),S(e.filterFieldName),w(e.filterOperator),E(e.filterValue),O(e.filterTree),u(e.sortFieldName),f(e.sortDirection),m(e.sortItems),g(e.groupFieldName),v(e.groupItems),b(e.coverFieldName),A(e.rowHeightKey),N(e.frozenColumnCount)},[t?.id,n]),(0,j.useEffect)(()=>{if(!e||!t||!n)return;if(ee.current===n.id){ee.current=null;return}let r=v$({hiddenFieldNames:s,filterFieldName:x,filterOperator:C,filterValue:T,filterTree:D,sortFieldName:l,sortDirection:d,sortItems:p,groupFieldName:h,groupItems:_,coverFieldName:y,rowHeightKey:k,frozenColumnCount:M}),a=JSON.stringify(r);if(F.current={viewId:n.id,config:a},y$(n,r))return;let c=e.id,u=t.id,f=n.id,m=window.setTimeout(()=>{let e=++P.current;o.views.update({documentId:c,tableId:u,viewId:f,config:r}).then(t=>{if(e!==P.current)return;let n=F.current;n.viewId===t.id&&n.config!==a&&te.current.add(t),i(e=>e&&{...e,tables:e.tables?.map(e=>e.id===u?{...e,views:e.views?.map(e=>e.id===t.id?t:e)}:e)})}).catch(()=>{})},500);return()=>window.clearTimeout(m)},[t?.id,n,y,e?.id,x,C,D,T,M,h,_,s,k,i,d,l,p]),{coverFieldName:y,filterFieldName:x,filterOperator:C,filterTree:D,filterValue:T,frozenColumnCount:M,groupFieldName:h,groupItems:_,hiddenFieldNames:s,rowHeightKey:k,setCoverFieldName:b,setFilterFieldName:S,setFilterOperator:w,setFilterTree:O,setFilterValue:E,setFrozenColumnCount:N,setGroupFieldName:g,setGroupItems:v,setHiddenFieldNames:c,setRowHeightKey:A,setSortDirection:f,setSortFieldName:u,setSortItems:m,sortDirection:d,sortFieldName:l,sortItems:p,viewMode:ne}}function x$({tableId:e,viewId:t,config:n,query:r,collapsedGroupIds:i,revision:a}){let o=aC().grid,[s,c]=(0,j.useState)(null),l=(0,j.useRef)(null),u=JSON.stringify(n),d=JSON.stringify(Array.from(i).sort());(0,j.useEffect)(()=>{if(e==null){l.current=null,c(null);return}let n={tableId:e,viewId:t,config:JSON.parse(u),query:r,collapsed:JSON.parse(d)},i=l.current;l.current=n,i&&(i.tableId!==e||i.viewId!==t)&&c(null);let a=!0;return o.open(n).then(e=>{a&&f(e)},()=>{}),()=>{a=!1}},[o,e,t,u,r,d]);function f(e){c(e)}function p(){if(!l.current)return;let e=l.current;o.sync().then(t=>{t&&l.current===e&&f(t)},()=>{l.current===e&&o.open(e).then(t=>{l.current===e&&f(t)},()=>{})})}let m=(0,j.useRef)(p);return m.current=p,(0,j.useEffect)(()=>o.subscribe(()=>m.current()),[o]),(0,j.useEffect)(()=>{m.current()},[a]),s}function S$({agentOpen:e,aiCellPatches:t,documentPath:n,markerContent:r,pinnedTableId:i,footerEnd:a,onOpenDocument:o,onAgentContextChange:s,onAgentOpenChange:c,readOnly:l=!1}){let{t:u}=U(`table`),d=aC(),f=cC(),p=fC(),m=(0,j.useRef)(null),[h,g]=(0,j.useState)(null),{clearKanbanDrag:_,closeColumnHeaderMenu:v,columnHeaderMenu:y,editingField:b,imagePreview:x,kanbanDragOverGroup:S,kanbanDragOverRecordId:C,kanbanDraggingRecordId:w,openColumnHeaderMenu:T,openRecordContextMenu:E,recordContextMenu:D,resetSelectedRecordIds:O,selectedGridCell:k,selectedRecord:A,selectedRecordIds:M,setEditingField:N,setImagePreview:ee,setKanbanDragOverGroup:P,setKanbanDragOverRecordId:F,setKanbanDraggingRecordId:te,setRecordContextMenu:ne,setSelectedGridCell:re,setSelectedRecord:ie,setSelectedRecordIds:ae,setToolbarPanel:oe,toolbarPanel:se}=m$(),{document:L,setDocument:ce,activeTableId:le,activeViewId:ue,setActiveViewId:de,records:R,setRecords:z,loading:fe,error:pe,setError:me,refreshDocument:he,loadRecords:ge}=l$({documentPath:n,markerContent:r,pinnedTableId:i,onRecordsLoaded:O}),[_e,ve]=(0,j.useState)(!1),[ye,B]=(0,j.useState)(``),[be,xe]=(0,j.useState)(``),[Se,Ce]=(0,j.useState)(`text`),[we,Te]=(0,j.useState)(!1),[Ee,De]=(0,j.useState)(!1),Oe=typeof e==`boolean`?e:Ee,ke=(0,j.useMemo)(()=>L?.tables?.find(e=>e.id===le)||L?.tables?.[0]||null,[L,le]),Ae=(0,j.useMemo)(()=>ke?.views||[],[ke?.views]),je=(0,j.useMemo)(()=>Ae.find(e=>e.id===ue)||Ae[0]||null,[ue,Ae]),{coverFieldName:Me,filterFieldName:Ne,filterOperator:Pe,filterTree:Fe,filterValue:Ie,frozenColumnCount:Le,groupFieldName:Re,groupItems:ze,hiddenFieldNames:Be,rowHeightKey:Ve,setCoverFieldName:He,setFilterFieldName:Ue,setFilterOperator:We,setFilterTree:Ge,setFilterValue:Ke,setFrozenColumnCount:qe,setGroupFieldName:Je,setGroupItems:Ye,setHiddenFieldNames:Xe,setRowHeightKey:Ze,setSortDirection:Qe,setSortFieldName:$e,setSortItems:et,sortDirection:tt,sortFieldName:nt,sortItems:rt,viewMode:it}=b$({document:L,activeTable:ke,activeView:je,tableViews:Ae,setDocument:ce,setActiveViewId:de}),at=ke?.fields||[];AQ({patches:t,fields:at,setRecords:z});let{collapsedGroupIds:ot,setCollapsedGroupIds:st}=c$(je?.id??null),ct=(0,j.useMemo)(()=>v$({hiddenFieldNames:Be,filterFieldName:Ne,filterOperator:Pe,filterValue:Ie,filterTree:Fe,sortFieldName:nt,sortDirection:tt,sortItems:rt,groupFieldName:Re,groupItems:ze,coverFieldName:Me,rowHeightKey:Ve,frozenColumnCount:Le}),[Be,Ne,Pe,Ie,Fe,nt,tt,rt,Re,ze,Me,Ve,Le]),lt=(0,j.useMemo)(()=>{let e=v$({hiddenFieldNames:Be,filterFieldName:Ne,filterOperator:Pe,filterValue:Ie,filterTree:Fe,sortFieldName:nt,sortDirection:tt,sortItems:rt,groupFieldName:Re,groupItems:ze,coverFieldName:Me,rowHeightKey:Ve,frozenColumnCount:Le});return{filter_tree:e.filter_tree,sort:e.sort,sort_items:e.sort_items,group_field_name:e.group_field_name,group_items:e.group_items}},[Be,Ne,Pe,Ie,Fe,nt,tt,rt,Re,ze,Me,Ve,Le]),ut=(0,j.useMemo)(()=>({}),[R,at]),dt=x$({tableId:ke?.id??null,viewId:je?.id??null,config:lt,query:ye,collapsedGroupIds:ot,revision:ut}),{canMoveKanbanCards:ft,canReorderRows:pt,contextMenuRecord:mt,coverField:ht,coverFields:gt,dateField:_t,groupField:vt,groupFieldNames:yt,groupedRecords:bt,groupableFields:xt,primaryField:St,shownCount:Ct,sortedAndFilteredRecords:wt,visibleFields:Tt}=u$({axis:dt,fields:at,hiddenFieldNames:Be,coverFieldName:Me,groupFieldName:Re,groupItems:ze,recordContextMenuRecordId:D?.recordId??null,records:R,sortDirection:tt,sortFieldName:nt,sortItems:rt,viewMode:it}),Et=p$(dt,Tt),Dt=it===`grid`,Ot=(0,j.useRef)({gridMode:Dt,records:R});Ot.current={gridMode:Dt,records:R};let kt=(0,j.useCallback)(async e=>{let t=ke?.id,n=L?.id;if(t==null||n==null||!e.length)return[];let r=(await d.grid.records({tableId:t,ids:e})).map(e=>({...e,table_id:t,document_id:n,user_id:0,order:0,created_at:``,updated_at:``}));return z(e=>{let t=new Map(e.map(e=>[e.id,e]));for(let e of r)t.set(e.id,e);return[...t.values()]}),r},[ke?.id,L?.id,d,z]),At=(0,j.useCallback)(async()=>{if(!Ot.current.gridMode)return ge();let e=Ot.current.records.map(e=>e.id);if(!e.length)return;let t=await kt(e),n=new Set(t.map(e=>e.id));z(e=>e.filter(e=>n.has(e.id)))},[ge,kt,z]);async function jt(){return Dt?!L||!ke?[]:(await d.records.list({documentId:L.id,tableId:ke.id})).items:R}function Mt(e){p.success(e)}async function Nt(){await he(ke?.id??le,je?.id??ue),await At()}let Pt=L?.id??null;bC(Pt);let{historyBusy:Ft,refreshHistoryState:It,undo:Lt,redo:Rt}=h$({documentId:Pt,onApplyChange:(0,j.useCallback)(()=>Nt(),[ke?.id,le,je?.id,ue,he,At])});g$(Pt,CC({activeTableId:ke?.id??le,activeViewId:je?.id??ue,loadRecords:()=>void At(),refreshDocument:()=>void he(ke?.id??le,je?.id??ue),refreshHistoryState:It})),(0,j.useEffect)(()=>(s?.({documentPath:n,activeDocument:L,activeTable:ke,onTableChanged:L&&ke?Nt:void 0}),()=>{s?.({documentPath:n,activeDocument:null,activeTable:null})}),[ke,L,n,s]),(0,j.useEffect)(()=>{Dt?z([]):ge()},[L?.id,ke?.id,Dt]),(0,j.useEffect)(()=>{N(null)},[ke?.id,N]),(0,j.useEffect)(()=>{let e=`table-sync:${le??`unknown`}`;!pe||!Pt||!le?p.dismiss(e):p.error(pe,{id:e})},[pe,Pt,le,p]);let{addField:zt,addDefaultField:Bt,addRecord:Vt,copyTextToClipboard:Ht,copyRecordURL:Ut,createView:Wt,deleteView:Gt,duplicateRecord:Kt,duplicateView:qt,insertRecordsNear:Jt,moveKanbanRecord:Yt,openAttachmentPreview:Xt,renameView:Zt,removeField:Qt,removeRecord:$t,removeSelectedRecords:en,duplicateSelectedRecords:tn,runAIField:nn,runAIFieldBatchForRecords:rn,runTableAction:an,saveField:on,updateCell:sn}=JQ({documentPath:n,document:L,activeTable:ke,tableViews:Ae,fields:at,records:R,allRecords:jt,groupField:vt,canReorderRows:pt,canMoveKanbanCards:ft,newFieldTitle:be,newFieldType:Se,selectedRecordIds:M,importInputRef:m,setBusy:ve,setError:me,setDocument:ce,setRecords:z,setSelectedRecord:ie,setSelectedRecordIds:ae,setRecordContextMenu:ne,setEditingField:N,setNewFieldTitle:xe,setViewCreateOpen:Te,setActiveViewId:de,setImagePreview:ee,refreshDocument:he,loadRecords:At,refreshHistoryState:It}),cn=jQ({document:L,activeTable:ke,allRecords:jt,visibleFields:Tt,sortItems:rt,setBusy:ve,setError:me,setEditingField:N,setFilterTree:Ge,setSortItems:et,setGroupItems:Ye,setFrozenColumnCount:qe,setHiddenFieldNames:Xe,setToolbarPanel:oe,refreshDocument:he,copyTextToClipboard:Ht,setStatus:Mt,refreshHistoryState:It});function ln(e){rn(e,dt?.ids??[],`column-menu`)}async function un(e){return R.find(t=>t.id===e)??(await kt([e]))[0]??null}function dn(e,t){let{action:n}=SC(t,``);n.kind===`open_url`&&n.url?window.open(n.url,`_blank`,`noopener,noreferrer`):n.kind===`run_workflow`&&n.workflow_id!=null&&f.runWorkflow?.({workflowId:n.workflow_id,tableId:t.table_id,recordId:e})}async function fn(e,t){if(t.type!==`document_link`||!o)return;let n=(await un(e))?.values?.[t.name];typeof n==`string`&&n&&o(n)}async function pn(e){let t=e!=null&&yt.length?await un(e):null;if(!t)return void Vt();let n={};for(let e of yt)n[e]=t.values?.[e]??null;Vt(n)}(0,j.useEffect)(()=>{function e(e){let t=e.detail;t&&t.documentPath===n&&an(t.action)}return window.addEventListener(mC,e),()=>window.removeEventListener(mC,e)},[n,an]);function mn(){ne(null)}function hn(t){let n=typeof t==`function`?t(Oe):t;typeof e!=`boolean`&&De(n),c?.(n)}async function gn(e){await Ht(JSON.stringify(e.values||{},null,2),u(`editor.recordCopiedForChat`))}let V=e=>l?(()=>void 0):e,_n=l?at.map(e=>({...e,readonly:!0})):at,vn=l?Tt.map(e=>({...e,readonly:!0})):Tt;return fe?(0,I.jsxs)(`div`,{"data-testid":`table-editor-skeleton`,"aria-busy":`true`,"aria-label":u(`editor.loadingTable`),className:`flex h-full w-full flex-col gap-3 p-4`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`skeleton h-7 w-32`}),(0,I.jsx)(`span`,{className:`skeleton h-7 w-20`}),(0,I.jsx)(`span`,{className:`skeleton ml-auto h-7 w-24`})]}),(0,I.jsx)(`div`,{className:`skeleton h-9 w-full`}),Array.from({length:8}).map((e,t)=>(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(`span`,{className:`skeleton h-5 w-6`}),(0,I.jsx)(`span`,{className:`skeleton h-5 flex-[2]`}),(0,I.jsx)(`span`,{className:`skeleton h-5 flex-1`}),(0,I.jsx)(`span`,{className:`skeleton h-5 flex-1`}),(0,I.jsx)(`span`,{className:`skeleton h-5 flex-[1.5]`})]},t))]}):!L||!ke?(0,I.jsx)(`div`,{className:`data-inline-state`,children:pe||u(`editor.tableNotFound`)}):(0,I.jsxs)(`div`,{className:`data-inline-shell`,"data-testid":`ktable-editor`,"data-read-only":l?`true`:void 0,children:[f.fileImport?(0,I.jsx)(`input`,{ref:m,type:`file`,accept:`.csv,.tsv,.xlsx,text/csv,text/tab-separated-values,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,className:`hidden`,onChange:e=>{g(e.target.files?.[0]||null),e.currentTarget.value=``}}):null,(0,I.jsx)(UA,{open:!!h,file:h,target:{kind:`existing_table`,documentId:L.id,table:ke},onOpenChange:e=>{e||g(null)},onCompleted:async e=>{await he(ke.id),await At(),p.success(u(`fileImport.completedSummary`,{fields:e.fields_created+e.fields_updated,rows:e.rows_created+e.rows_updated}))}}),(0,I.jsxs)(`div`,{className:`data-inline-editor`,children:[(0,I.jsx)(gx,{children:(0,I.jsx)(zA,{tableViews:Ae,activeViewId:je?.id??null,onSelectView:e=>{de(e),Te(!1)},viewCreateOpen:we,onToggleViewCreate:()=>Te(e=>!e),onCloseViewCreate:()=>Te(!1),onCreateView:V(e=>void Wt(e)),onRenameView:V((e,t)=>void Zt(e,t)),onDuplicateView:V(e=>void qt(e)),onDeleteView:V(e=>void Gt(e)),busy:_e||Ft||l,fields:at,hiddenFieldNames:Be,onResetHiddenFields:V(()=>Xe(new Set)),onToggleFieldVisibility:V((e,t)=>{Xe(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})}),onEditField:V(N),onDuplicateField:V(cn.duplicateField),onDeleteField:V(Qt),onAddDefaultField:V(()=>void Bt()),filterTree:Fe,onFilterTreeChange:V(Ge),sortItems:rt,onSortItemsChange:V(et),groupableFields:xt,groupItems:ze,onGroupItemsChange:V(Ye),viewMode:it,coverFieldName:Me,coverField:ht,coverFields:gt,onCoverFieldNameChange:V(He),onResetCoverField:V(()=>He(``)),rowHeightKey:Ve,onRowHeightKeyChange:V(Ze),frozenColumnCount:Le,onFrozenColumnCountChange:V(qe),toolbarPanel:se,onToolbarPanelChange:oe,newFieldTitle:be,newFieldType:Se,onNewFieldTitleChange:xe,onNewFieldTypeChange:Ce,onAddField:V(()=>{zt(),oe(null)}),selectedRecordCount:M.size,onRemoveSelectedRecords:V(()=>void en()),onDuplicateSelectedRecords:V(()=>void tn()),agentOpen:Oe,onToggleAgent:()=>hn(e=>!e),agentDisabled:!L||!ke,query:ye,onQueryChange:B,onAddRecord:V(()=>void Vt())})}),(0,I.jsx)(Pk,{tableId:ke.id,viewMode:it,visibleFields:vn,groupField:vt,groupedRecords:bt,primaryField:St,dateField:_t,coverField:ht,sortedAndFilteredRecords:wt,canMoveKanbanCards:ft,draggingRecordId:w,dragOverRecordId:C,dragOverGroup:S,onDragStart:te,onDragEnd:_,onDragOverRecord:F,onDragOverGroup:P,onMoveKanbanRecord:V((e,t,n)=>void Yt(e,t,n)),onAddRecord:V(e=>void Vt(e)),onOpenRecord:ie,onOpenDocument:o,onPreviewAttachments:Xt,onRegenerate:f.ai?V((e,t)=>void nn(e,t)):void 0,grid:{documentId:L.id,tableId:ke.id,viewId:je?.id??null,fields:_n,axis:dt,config:ct,searching:!!ye.trim(),readOnly:l,collapsedGroupIds:ot,checkedCount:M.size,onCollapsedGroupChanged:st,onFrozenColumnCount:V(qe),onSelectCell:re,onCheckRecords:e=>ae(t=>e.length===t.size&&e.every(e=>t.has(e))?t:new Set(e)),onOpenRecord:e=>void un(e).then(e=>e&&ie(e)),onOpenRecordContextMenu:(e,t)=>void un(e).then(e=>e&&E(e,{...t,preventDefault:()=>void 0,stopPropagation:()=>void 0})),onOpenColumnHeaderMenu:T,onAddRecord:V(e=>void pn(e)),onOpenFieldCreator:V(()=>void Bt()),onPreviewAttachments:Xt,onRegenerate:f.ai&&!l?(e,t)=>void un(e).then(e=>e&&nn(e,t)):void 0,onRunButton:V(dn),onOpenLink:(e,t)=>void fn(e,t),onUndo:V(()=>void Lt()),onRedo:V(()=>void Rt())}}),(0,I.jsx)(TQ,{menu:D?{x:D.x,y:D.y}:null,record:mt,busy:_e,canInsert:pt,fields:at,selectedFieldName:k&&mt&&k.recordId===mt.id?k.fieldName:null,onClose:mn,onInsertRecords:V((e,t,n)=>Jt(e,t,n)),onDuplicateRecord:V(Kt),onCopyRecordURL:Ut,onOpenRecord:ie,onCopyRecordForChat:gn,onDeleteRecord:V($t),onRegenerateAIField:V((e,t)=>void nn(e,t)),onStatus:Mt}),(0,I.jsx)(Qw,{menu:y?{x:y.x,y:y.y}:null,field:y?at.find(e=>e.id===y.fieldId)??null:null,busy:_e,onClose:v,onEditField:V(N),onDuplicateField:V(cn.duplicateField),onRunAIBatch:f.ai?V(ln):void 0,onDownloadAllFiles:cn.downloadAllFiles,onAddColumnToChat:cn.copyColumnValuesForChat,onInsertField:V(cn.insertField),onAddFilterForField:V(cn.addFilterForField),onAddSortForField:V(cn.addSortForField),onSetGroupField:V(cn.setGroupField),onFreezeUpTo:V(cn.freezeUpToField),onHideField:V(cn.hideField),onDeleteField:V(Qt)}),(0,I.jsx)(gx,{children:(0,I.jsx)(Fk,{shownCount:Ct,numericSummaries:Et,selectedRecordCount:M.size,end:a})})]}),b?(0,I.jsx)(wQ,{field:b,fields:at,busy:_e,onClose:()=>N(null),onSave:V(e=>on(b,e))}):null,A?(()=>{let e=dt?.ids??[],t=e.indexOf(A.id),n=t>0,r=t>=0&&t<e.length-1,i=e=>void un(e).then(e=>e&&ie(e));return(0,I.jsx)(DQ,{record:R.find(e=>e.id===A.id)||A,fields:_n,primaryField:St,documentId:L.id,tableId:ke.id,navIndex:t>=0?t:void 0,navTotal:e.length||void 0,canNavigatePrev:n,canNavigateNext:r,onNavigatePrev:n?()=>i(e[t-1]):void 0,onNavigateNext:r?()=>i(e[t+1]):void 0,onPreviewAttachments:Xt,onOpenDocument:o,onClose:()=>ie(null),onDelete:V(()=>{$t(A.id),ie(null)}),onUpdate:V((e,t)=>void sn(A,e,t)),onReplaceLinks:V(async(e,t)=>{try{let n=await d.links.replace({documentId:L.id,tableId:ke.id,recordId:A.id,field_id:e.id,target_row_keys:t});return z(t=>t.map(t=>t.id===A.id?{...t,values:{...t.values||{},[e.name]:n}}:t)),n}catch(e){return console.error(`replaceRecordLinks failed`,e),p.error(u(`editor.replaceLinksFailed`),{description:e instanceof Error?e.message:String(e)}),null}})})})():null,(0,I.jsx)(Bk,{open:!!x,items:x?.items??[],index:x?.index??0,onClose:()=>ee(null),onIndexChange:e=>ee(t=>t&&{...t,index:e})})]})}function C$(e){return(0,I.jsx)(xC,{children:(0,I.jsx)(S$,{...e})})}function w$(e){let{margin:t,containerPadding:n,containerWidth:r,cols:i}=e;return(r-t[0]*(i-1)-n[0]*2)/i}function T$(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function E$(e,t,n,r,i,a,o){let{margin:s,containerPadding:c,rowHeight:l}=e,u=w$(e),d,f,p,m;if(o?(d=Math.round(o.width),f=Math.round(o.height)):(d=T$(r,u,s[0]),f=T$(i,l,s[1])),a?(p=Math.round(a.top),m=Math.round(a.left)):o?(p=Math.round(o.top),m=Math.round(o.left)):(p=Math.round((l+s[1])*n+c[1]),m=Math.round((u+s[0])*t+c[0])),!a&&!o){if(Number.isFinite(r)){let e=Math.round((u+s[0])*(t+r)+c[0])-m-d;e!==s[0]&&(d+=e-s[0])}if(Number.isFinite(i)){let e=Math.round((l+s[1])*(n+i)+c[1])-p-f;e!==s[1]&&(f+=e-s[1])}}return{top:p,left:m,width:d,height:f}}function D$(e,t,n,r,i){let{margin:a,containerPadding:o,cols:s,rowHeight:c,maxRows:l}=e,u=w$(e),d=Math.round((n-o[0])/(u+a[0])),f=Math.round((t-o[1])/(c+a[1]));return d=A$(d,0,s-r),f=A$(f,0,l-i),{x:d,y:f}}function O$(e,t,n){let{margin:r,containerPadding:i,rowHeight:a}=e,o=w$(e);return{x:Math.round((n-i[0])/(o+r[0])),y:Math.round((t-i[1])/(a+r[1]))}}function k$(e,t,n){let{margin:r,rowHeight:i}=e,a=w$(e);return{w:Math.max(1,Math.round((t+r[0])/(a+r[0]))),h:Math.max(1,Math.round((n+r[1])/(i+r[1])))}}function A$(e,t,n){return Math.max(Math.min(e,n),t)}function j$(e,t){return!(e.i===t.i||e.x+e.w<=t.x||e.x>=t.x+t.w||e.y+e.h<=t.y||e.y>=t.y+t.h)}function M$(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0&&j$(r,t))return r}}function N$(e,t){return e.filter(e=>j$(e,t))}function P$(e,t){return t===`horizontal`?I$(e):t===`vertical`||t===`wrap`?F$(e):[...e]}function F$(e){return[...e].sort((e,t)=>e.y===t.y?e.x-t.x:e.y-t.y)}function I$(e){return[...e].sort((e,t)=>e.x===t.x?e.y-t.y:e.x-t.x)}function L$(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0){let e=r.y+r.h;e>t&&(t=e)}}return t}function R$(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0&&r.i===t)return r}}function z$(e){return e.filter(e=>e.static===!0)}function B$(e){return{i:e.i,x:e.x,y:e.y,w:e.w,h:e.h,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,moved:!!e.moved,static:!!e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,constraints:e.constraints,isBounded:e.isBounded}}function V$(e){let t=Array(e.length);for(let n=0;n<e.length;n++){let r=e[n];r!==void 0&&(t[n]=B$(r))}return t}function H$(e,t){let n=Array(e.length);for(let r=0;r<e.length;r++){let i=e[r];i!==void 0&&(t.i===i.i?n[r]=t:n[r]=i)}return n}function U$(e,t,n){let r=R$(e,t);return r?(r=n(B$(r)),[H$(e,r),r]):[[...e],null]}function W$(e,t){let n=z$(e);for(let r=0;r<e.length;r++){let i=e[r];if(i!==void 0){if(i.x+i.w>t.cols&&(i.x=t.cols-i.w),i.x<0&&(i.x=0,i.w=t.cols),i.y===1/0&&(i.y=L$(n)),!i.static)n.push(i);else for(;M$(n,i);)i.y++}}return e}function G$(e,t,n,r,i,a,o,s,c){if(t.static&&t.isDraggable!==!0||t.y===r&&t.x===n)return[...e];let l=t.x,u=t.y;typeof n==`number`&&(t.x=n),typeof r==`number`&&(t.y=r),t.moved=!0;let d=P$(e,o);(o===`vertical`&&typeof r==`number`?u>=r:o===`horizontal`&&typeof n==`number`&&l>=n)&&(d=d.reverse());let f=N$(d,t),p=f.length>0;if(p&&c)return V$(e);if(p&&a)return t.x=l,t.y=u,t.moved=!1,e;let m=[...e];for(let e=0;e<f.length;e++){let n=f[e];n!==void 0&&(n.moved||(m=n.static?K$(m,n,t,i,o):K$(m,t,n,i,o)))}return m}function K$(e,t,n,r,i,a){let o=i===`horizontal`||i===`wrap`,s=i===`vertical`,c=t.static;if(r){r=!1;let a={x:o?Math.max(t.x-n.w,0):n.x,y:s?Math.max(t.y-n.h,0):n.y,w:n.w,h:n.h,i:`-1`},l=M$(e,a),u=l!==void 0&&l.y+l.h>t.y,d=l!==void 0&&t.x+t.w>l.x;if(!l)return G$(e,n,o?a.x:void 0,s?a.y:void 0,r,c,i);if(u&&s)return G$(e,n,void 0,n.y+1,r,c,i);if(u&&i===null){let r=n.y;return t.y=r,n.y=r+t.h,[...e]}if(d&&o)return G$(e,t,n.x,void 0,r,c,i)}let l=o?n.x+1:void 0,u=s?n.y+1:void 0;return l===void 0&&u===void 0?[...e]:G$(e,n,l,u,r,c,i)}function q$(e,t,n){return Math.max(t,Math.min(n,e))}var J$=[{name:`gridBounds`,constrainPosition(e,t,n,{cols:r,maxRows:i}){return{x:q$(t,0,Math.max(0,r-e.w)),y:q$(n,0,Math.max(0,i-e.h))}},constrainSize(e,t,n,r,{cols:i,maxRows:a}){let o=r===`w`||r===`nw`||r===`sw`?e.x+e.w:i-e.x,s=r===`n`||r===`nw`||r===`ne`?e.y+e.h:a-e.y;return{w:q$(t,1,Math.max(1,o)),h:q$(n,1,Math.max(1,s))}}},{name:`minMaxSize`,constrainSize(e,t,n){return{w:q$(t,e.minW??1,e.maxW??1/0),h:q$(n,e.minH??1,e.maxH??1/0)}}}];function Y$(e,t,n,r,i){let a={x:n,y:r};for(let n of e)n.constrainPosition&&(a=n.constrainPosition(t,a.x,a.y,i));if(t.constraints)for(let e of t.constraints)e.constrainPosition&&(a=e.constrainPosition(t,a.x,a.y,i));return a}function X$(e,t,n,r,i,a){let o={w:n,h:r};for(let n of e)n.constrainSize&&(o=n.constrainSize(t,o.w,o.h,i,a));if(t.constraints)for(let e of t.constraints)e.constrainSize&&(o=e.constrainSize(t,o.w,o.h,i,a));return o}function Z$({top:e,left:t,width:n,height:r}){let i=`translate(${t}px,${e}px)`;return{transform:i,WebkitTransform:i,MozTransform:i,msTransform:i,OTransform:i,width:`${n}px`,height:`${r}px`,position:`absolute`}}function Q$({top:e,left:t,width:n,height:r}){return{top:`${e}px`,left:`${t}px`,width:`${n}px`,height:`${r}px`,position:`absolute`}}function $$(e){return e*100+`%`}function e1(e,t,n,r){return e+n>r?t:n}function t1(e,t,n){return e<0?t:n}function n1(e){return Math.max(0,e)}function r1(e){return Math.max(0,e)}var i1=(e,t,n)=>{let{left:r,height:i,width:a}=t,o=e.top-(i-e.height);return{left:r,width:a,height:t1(o,e.height,i),top:r1(o)}},a1=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{top:r,height:a,width:e1(e.left,e.width,o,n),left:n1(i)}},o1=(e,t,n)=>{let{top:r,height:i,width:a}=t,o=e.left+e.width-a;return o<0?{height:i,width:e.left+e.width,top:r1(r),left:0}:{height:i,width:a,top:r1(r),left:o}},s1=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{width:o,left:i,height:t1(r,e.height,a),top:r1(r)}},c1={n:i1,ne:(e,t,n)=>i1(e,a1(e,t,n)),e:a1,se:(e,t,n)=>s1(e,a1(e,t,n)),s:s1,sw:(e,t,n)=>s1(e,o1(e,t)),w:o1,nw:(e,t,n)=>i1(e,o1(e,t))};function l1(e,t,n,r){let i=c1[e];return i?i(t,{...t,...n},r):n}var u1={type:`transform`,scale:1,calcStyle(e){return Z$(e)}},d1={type:`absolute`,scale:1,calcStyle(e){return Q$(e)}};function f1(e){return{type:`transform`,scale:e,calcStyle(e){return Z$(e)},calcDragPosition(t,n,r,i){return{left:(t-r)/e,top:(n-i)/e}}}}var p1=u1,m1={cols:12,rowHeight:150,margin:[10,10],containerPadding:null,maxRows:1/0},h1={enabled:!0,bounded:!1,threshold:3},g1={enabled:!0,handles:[`se`]},_1={enabled:!1,defaultItem:{w:1,h:1},touchEnabled:!0,touchDragSource:`[data-rgl-draggable]`};function v1(e,t,n,r,i){let a=r===`x`?`w`:`h`;t[r]+=1;let o=e.findIndex(e=>e.i===t.i),s=i??z$(e).length>0;for(let i=o+1;i<e.length;i++){let o=e[i];if(o!==void 0&&!o.static){if(!s&&o.y>t.y+t.h)break;j$(t,o)&&v1(e,o,n+t[a],r,s)}}t[r]=n}function y1(e,t,n,r){for(t.x=Math.max(t.x,0),t.y=Math.max(t.y,0),t.y=Math.min(r,t.y);t.y>0&&!M$(e,t);)t.y--;let i;for(;(i=M$(e,t))!==void 0;)v1(n,t,i.y+i.h,`y`);return t.y=Math.max(t.y,0),t}function b1(e,t,n,r){for(t.x=Math.max(t.x,0),t.y=Math.max(t.y,0);t.x>0&&!M$(e,t);)t.x--;let i;for(;(i=M$(e,t))!==void 0;)if(v1(r,t,i.x+i.w,`x`),t.x+t.w>n)for(t.x=n-t.w,t.y++;t.x>0&&!M$(e,t);)t.x--;return t.x=Math.max(t.x,0),t}var x1={type:`vertical`,allowOverlap:!1,compact(e,t){let n=z$(e),r=L$(n),i=F$(e),a=Array(e.length);for(let t=0;t<i.length;t++){let o=i[t];if(o===void 0)continue;let s=B$(o);s.static||(s=y1(n,s,i,r),r=Math.max(r,s.y+s.h),n.push(s));let c=e.indexOf(o);a[c]=s,s.moved=!1}return a}},S1={type:`horizontal`,allowOverlap:!1,compact(e,t){let n=z$(e),r=I$(e),i=Array(e.length);for(let a=0;a<r.length;a++){let o=r[a];if(o===void 0)continue;let s=B$(o);s.static||(s=b1(n,s,t,r),n.push(s));let c=e.indexOf(o);i[c]=s,s.moved=!1}return i}},C1={type:null,allowOverlap:!1,compact(e,t){return V$(e)}},w1={...x1,allowOverlap:!0,compact(e,t){return V$(e)}},T1={...S1,allowOverlap:!0,compact(e,t){return V$(e)}},E1={...C1,allowOverlap:!0};function D1(e,t=!1,n=!1){let r;return r=t?e===`vertical`?w1:e===`horizontal`?T1:E1:e===`vertical`?x1:e===`horizontal`?S1:C1,n?{...r,preventCollision:n}:r}function O1(e){return Object.keys(e).sort((t,n)=>e[t]-e[n])}function k1(e,t){let n=O1(e),r=n[0];if(r===void 0)throw Error(`No breakpoints defined`);for(let i=1;i<n.length;i++){let a=n[i];a!==void 0&&t>e[a]&&(r=a)}return r}function A1(e,t){let n=t[e];if(n===void 0)throw Error(`ResponsiveReactGridLayout: \`cols\` entry for breakpoint ${String(e)} is missing!`);return n}function j1(e,t,n,r,i,a){let o=e[n];if(o)return V$(o);let s=e[r],c=O1(t),l=c.slice(c.indexOf(n));for(let t=0;t<l.length;t++){let n=l[t];if(n===void 0)continue;let r=e[n];if(r){s=r;break}}let u=W$(V$(s||[]),{cols:i});return(typeof a==`object`&&a?a:D1(a)).compact(u,i)}function M1(e,t){if(Array.isArray(e))return e;let n=e,r=n[t];if(r!==void 0)return r;let i=Object.keys(n);for(let e of i){let t=n[e];if(t!==void 0)return t}return[10,10]}var N1=b(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),P1=b(((e,t)=>{var n=N1();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),F1=b(((e,t)=>{t.exports=P1()()})),I1=S(F1(),1);function L1(e,t){for(let n=0,r=e.length;n<r;n++)if(t.apply(t,[e[n],n,e]))return e[n]}function R1(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Function]`}function z1(e){return typeof e==`number`&&!isNaN(e)}function B1(e){return parseInt(e,10)}function V1(e,t,n){if(e[t])return Error(`Invalid prop ${t} passed to ${n} - do not set this, set it on the child.`)}var H1=[`Moz`,`Webkit`,`O`,`ms`];function U1(e=`transform`){if(typeof window>`u`)return``;let t=window.document?.documentElement?.style;if(!t||e in t)return``;for(let n=0;n<H1.length;n++)if(W1(e,H1[n])in t)return H1[n];return``}function W1(e,t){return t?`${t}${G1(e)}`:e}function G1(e){let t=``,n=!0;for(let r=0;r<e.length;r++)n?(t+=e[r].toUpperCase(),n=!1):e[r]===`-`?n=!0:t+=e[r];return t}var K1=U1(),q1=``;function J1(e,t){q1||=L1([`matches`,`webkitMatchesSelector`,`mozMatchesSelector`,`msMatchesSelector`,`oMatchesSelector`],function(t){return R1(e[t])})??``;let n=e[q1];return R1(n)?!!n.call(e,t):!1}function Y1(e,t,n){let r=e;do{if(J1(r,t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function X1(e,t,n,r){if(!e)return;let i={capture:!0,...r},a=n;e.addEventListener?e.addEventListener(t,a,i):e.attachEvent?e.attachEvent(`on`+t,a):e[`on`+t]=a}function Z1(e,t,n,r){if(!e)return;let i={capture:!0,...r},a=n;e.removeEventListener?e.removeEventListener(t,a,i):e.detachEvent?e.detachEvent(`on`+t,a):e[`on`+t]=null}function Q1(e){let t=e.clientHeight,n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=B1(n.borderTopWidth),t+=B1(n.borderBottomWidth),t}function $1(e){let t=e.clientWidth,n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=B1(n.borderLeftWidth),t+=B1(n.borderRightWidth),t}function e0(e){let t=e.clientHeight,n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=B1(n.paddingTop),t-=B1(n.paddingBottom),t}function t0(e){let t=e.clientWidth,n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=B1(n.paddingLeft),t-=B1(n.paddingRight),t}function n0(e,t,n){let r=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect();return{x:(e.clientX+t.scrollLeft-r.left)/n,y:(e.clientY+t.scrollTop-r.top)/n}}function r0(e,t){let n=a0(e,t,`px`);return{[W1(`transform`,K1)]:n}}function i0(e,t){return a0(e,t,``)}function a0({x:e,y:t},n,r){let i=`translate(${e}${r},${t}${r})`;return n&&(i=`translate(${`${typeof n.x==`string`?n.x:n.x+r}`}, ${`${typeof n.y==`string`?n.y:n.y+r}`})`+i),i}function o0(e,t){return e.targetTouches&&L1(e.targetTouches,e=>t===e.identifier)||e.changedTouches&&L1(e.changedTouches,e=>t===e.identifier)}function s0(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function c0(){return typeof __webpack_nonce__<`u`?__webpack_nonce__:void 0}function l0(e,t){if(!e)return;let n=e.getElementById(`react-draggable-style-el`);if(!n){n=e.createElement(`style`),n.type=`text/css`,n.id=`react-draggable-style-el`;let r=t??c0();r&&n.setAttribute(`nonce`,r),n.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;}
90
- `,n.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;}
91
- `,e.getElementsByTagName(`head`)[0].appendChild(n)}e.body&&f0(e.body,`react-draggable-transparent-selection`)}function u0(e){window.requestAnimationFrame?window.requestAnimationFrame(()=>{d0(e)}):d0(e)}function d0(e){if(e)try{e.body&&p0(e.body,`react-draggable-transparent-selection`);let t=e.selection;if(t)t.empty();else{let t=(e.defaultView||window).getSelection();t&&t.type!==`Caret`&&t.removeAllRanges()}}catch{}}function f0(e,t){e.classList?e.classList.add(t):e.className.match(RegExp(`(?:^|\\s)${t}(?!\\S)`))||(e.className+=` ${t}`)}function p0(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(RegExp(`(?:^|\\s)${t}(?!\\S)`,`g`),``)}function m0(e,t,n){if(!e.props.bounds)return[t,n];let{bounds:r}=e.props;r=typeof r==`string`?r:x0(r);let i=S0(e);if(typeof r==`string`){let{ownerDocument:e}=i,t=e.defaultView;if(!t)throw Error(`Cannot resolve the owner window of the draggable node.`);let n;if(n=r===`parent`?i.parentNode:i.getRootNode().querySelector(r),!(n instanceof t.HTMLElement))throw Error(`Bounds selector "`+r+`" could not find an element.`);let a=n,o=t.getComputedStyle(i),s=t.getComputedStyle(a);r={left:-i.offsetLeft+B1(s.paddingLeft)+B1(o.marginLeft),top:-i.offsetTop+B1(s.paddingTop)+B1(o.marginTop),right:t0(a)-$1(i)-i.offsetLeft+B1(s.paddingRight)-B1(o.marginRight),bottom:e0(a)-Q1(i)-i.offsetTop+B1(s.paddingBottom)-B1(o.marginBottom)}}return z1(r.right)&&(t=Math.min(t,r.right)),z1(r.bottom)&&(n=Math.min(n,r.bottom)),z1(r.left)&&(t=Math.max(t,r.left)),z1(r.top)&&(n=Math.max(n,r.top)),[t,n]}function h0(e,t,n){return[Math.round(t/e[0])*e[0],Math.round(n/e[1])*e[1]]}function g0(e){return e.props.axis===`both`||e.props.axis===`x`}function _0(e){return e.props.axis===`both`||e.props.axis===`y`}function v0(e,t,n){let r=typeof t==`number`?o0(e,t):null;if(typeof t==`number`&&!r)return null;let i=S0(n),a=n.props.offsetParent||i.offsetParent||i.ownerDocument.body;return n0(r||e,a,n.props.scale)}function y0(e,t,n){let r=!z1(e.lastX),i=S0(e);return r?{node:i,deltaX:0,deltaY:0,lastX:t,lastY:n,x:t,y:n}:{node:i,deltaX:t-e.lastX,deltaY:n-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:n}}function b0(e,t){let n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}}function x0(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function S0(e){let t=e.findDOMNode();if(!t)throw Error(`<DraggableCore>: Unmounted during event!`);return t}var C0=typeof process<`u`&&{}.DRAGGABLE_DEBUG?console.log.bind(console):function(){},w0={touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`},mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`}},T0=w0.mouse,E0=class extends j.Component{constructor(){super(...arguments),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,this.touchIdentifier=null,this.mounted=!1,this.handleDragStart=e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&(typeof e.button==`number`&&e.button!==0||e.ctrlKey))return!1;let t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw Error(`<DraggableCore> not mounted on DragStart!`);let{ownerDocument:n}=t;if(this.props.disabled||!(e.target instanceof n.defaultView.Node)||this.props.handle&&!Y1(e.target,this.props.handle,t)||this.props.cancel&&Y1(e.target,this.props.cancel,t))return;e.type===`touchstart`&&!this.props.allowMobileScroll&&e.preventDefault();let r=s0(e);this.touchIdentifier=r;let i=v0(e,r,this);if(i==null)return;let{x:a,y:o}=i,s=y0(this,a,o);C0(`DraggableCore: handleDragStart: %j`,s),C0(`calling`,this.props.onStart),this.props.onStart(e,s)!==!1&&this.mounted!==!1&&(this.props.enableUserSelectHack&&l0(n,this.props.nonce),this.dragging=!0,this.lastX=a,this.lastY=o,X1(n,T0.move,this.handleDrag),X1(n,T0.stop,this.handleDragStop))},this.handleDrag=e=>{let t=v0(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX,t=r-this.lastY;if([e,t]=h0(this.props.grid,e,t),!e&&!t)return;n=this.lastX+e,r=this.lastY+t}let i=y0(this,n,r);if(C0(`DraggableCore: handleDrag: %j`,i),this.props.onDrag(e,i)===!1||this.mounted===!1)try{this.handleDragStop(new MouseEvent(`mouseup`))}catch{let e=document.createEvent(`MouseEvents`);e.initMouseEvent(`mouseup`,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(e)}else this.lastX=n,this.lastY=r},this.handleDragStop=e=>{if(!this.dragging)return;let t=v0(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX||0,t=r-this.lastY||0;[e,t]=h0(this.props.grid,e,t),n=this.lastX+e,r=this.lastY+t}let i=y0(this,n,r);if(this.props.onStop(e,i)===!1||this.mounted===!1)return!1;let a=this.findDOMNode();a&&this.props.enableUserSelectHack&&u0(a.ownerDocument),C0(`DraggableCore: handleDragStop: %j`,i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,a&&(C0(`DraggableCore: Removing handlers`),Z1(a.ownerDocument,T0.move,this.handleDrag),Z1(a.ownerDocument,T0.stop,this.handleDragStop))},this.onMouseDown=e=>(T0=w0.mouse,this.handleDragStart(e)),this.onMouseUp=e=>(T0=w0.mouse,this.handleDragStop(e)),this.onTouchStart=e=>(T0=w0.touch,this.handleDragStart(e)),this.onTouchEnd=e=>(T0=w0.touch,this.handleDragStop(e))}componentDidMount(){this.mounted=!0;let e=this.findDOMNode();e&&X1(e,w0.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;let e=this.findDOMNode();if(e){let{ownerDocument:t}=e;Z1(t,w0.mouse.move,this.handleDrag),Z1(t,w0.touch.move,this.handleDrag),Z1(t,w0.mouse.stop,this.handleDragStop),Z1(t,w0.touch.stop,this.handleDragStop),Z1(e,w0.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&u0(t)}}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=td.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):(C0(`react-draggable: ReactDOM.findDOMNode is not available in React 19+. You must provide a nodeRef prop. See: https://github.com/react-grid-layout/react-draggable#noderef`),null)}render(){return j.cloneElement(j.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};E0.displayName=`DraggableCore`,E0.propTypes={allowAnyClick:I1.default.bool,allowMobileScroll:I1.default.bool,children:I1.default.node.isRequired,disabled:I1.default.bool,enableUserSelectHack:I1.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw Error(`Draggable's offsetParent must be a DOM Node.`)},grid:I1.default.arrayOf(I1.default.number),handle:I1.default.string,cancel:I1.default.string,nodeRef:I1.default.object,nonce:I1.default.string,onStart:I1.default.func,onDrag:I1.default.func,onStop:I1.default.func,onMouseDown:I1.default.func,scale:I1.default.number,className:V1,style:V1,transform:V1},E0.defaultProps={allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1};var D0=class extends j.Component{constructor(e){super(e),this.onDragStart=(e,t)=>{if(C0(`Draggable: onDragStart: %j`,t),this.props.onStart(e,b0(this,t))===!1)return!1;this.setState({dragging:!0,dragged:!0})},this.onDrag=(e,t)=>{if(!this.state.dragging)return!1;C0(`Draggable: onDrag: %j`,t);let n=b0(this,t),r={x:n.x,y:n.y,slackX:0,slackY:0};if(this.props.bounds){let{x:e,y:t}=r;r.x+=this.state.slackX,r.y+=this.state.slackY;let[i,a]=m0(this,r.x,r.y);r.x=i,r.y=a,r.slackX=this.state.slackX+(e-r.x),r.slackY=this.state.slackY+(t-r.y),n.x=r.x,n.y=r.y,n.deltaX=r.x-this.state.x,n.deltaY=r.y-this.state.y}if(this.props.onDrag(e,n)===!1)return!1;this.setState(r)},this.onDragStop=(e,t)=>{if(!this.state.dragging||this.props.onStop(e,b0(this,t))===!1)return!1;C0(`Draggable: onDragStop: %j`,t);let n={dragging:!1,slackX:0,slackY:0};if(this.props.position){let{x:e,y:t}=this.props.position;n.x=e,n.y=t}this.setState(n)},this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},e.position&&!(e.onDrag||e.onStop)&&console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}static getDerivedStateFromProps({position:e},{prevPropsPosition:t}){return e&&(!t||e.x!==t.x||e.y!==t.y)?(C0(`Draggable: getDerivedStateFromProps %j`,{position:e,prevPropsPosition:t}),{x:e.x,y:e.y,prevPropsPosition:{...e}}):null}componentDidMount(){window.SVGElement!==void 0&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=td.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):null}render(){let{axis:e,bounds:t,children:n,defaultPosition:r,defaultClassName:i,defaultClassNameDragging:a,defaultClassNameDragged:o,position:s,positionOffset:c,scale:l,...u}=this.props,d={},f=null,p=!s||this.state.dragging,m=s||r,h={x:g0(this)&&p?this.state.x:m.x,y:_0(this)&&p?this.state.y:m.y};this.state.isElementSVG?f=i0(h,c):d=r0(h,c);let g=j.Children.only(n),_=TC(g.props.className||``,i,{[a]:this.state.dragging,[o]:this.state.dragged});return j.createElement(E0,{...u,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop},j.cloneElement(g,{className:_,style:{...g.props.style,...d},transform:f}))}};D0.displayName=`Draggable`,D0.propTypes={...E0.propTypes,axis:I1.default.oneOf([`both`,`x`,`y`,`none`]),bounds:I1.default.oneOfType([I1.default.shape({left:I1.default.number,right:I1.default.number,top:I1.default.number,bottom:I1.default.number}),I1.default.string,I1.default.oneOf([!1])]),defaultClassName:I1.default.string,defaultClassNameDragging:I1.default.string,defaultClassNameDragged:I1.default.string,defaultPosition:I1.default.shape({x:I1.default.number,y:I1.default.number}),positionOffset:I1.default.shape({x:I1.default.oneOfType([I1.default.number,I1.default.string]),y:I1.default.oneOfType([I1.default.number,I1.default.string])}),position:I1.default.shape({x:I1.default.number,y:I1.default.number}),className:V1,style:V1,transform:V1},D0.defaultProps={...E0.defaultProps,axis:`both`,bounds:!1,defaultClassName:`react-draggable`,defaultClassNameDragging:`react-draggable-dragging`,defaultClassNameDragged:`react-draggable-dragged`,defaultPosition:{x:0,y:0},scale:1};var O0=b(((e,t)=>{function n(e){var t,r,i=``;if(typeof e==`string`||typeof e==`number`)i+=e;else if(typeof e==`object`){if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=n(e[t]))&&(i&&(i+=` `),i+=r)}else for(r in e)e[r]&&(i&&(i+=` `),i+=r)}return i}function r(){for(var e,t,r=0,i=``,a=arguments.length;r<a;r++)(e=arguments[r])&&(t=n(e))&&(i&&(i+=` `),i+=t);return i}t.exports=r,t.exports.clsx=r})),k0=b(((e,t)=>{var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},l=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of a(t))!s.call(e,c)&&c!==n&&r(e,c,{get:()=>t[c],enumerable:!(o=i(t,c))||o.enumerable});return e},u=(e,t,i)=>(i=e==null?{}:n(o(e)),l(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e)),d=e=>l(r({},`__esModule`,{value:!0}),e),f={};c(f,{DraggableCore:()=>we,default:()=>Te}),t.exports=d(f);var p=u(E()),m=u(F1()),h=u(O()),g=O0();function _(e,t){for(let n=0,r=e.length;n<r;n++)if(t.apply(t,[e[n],n,e]))return e[n]}function v(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Function]`}function y(e){return typeof e==`number`&&!isNaN(e)}function b(e){return parseInt(e,10)}function x(e,t,n){if(e[t])return Error(`Invalid prop ${t} passed to ${n} - do not set this, set it on the child.`)}var S=[`Moz`,`Webkit`,`O`,`ms`];function C(e=`transform`){if(typeof window>`u`)return``;let t=window.document?.documentElement?.style;if(!t||e in t)return``;for(let n=0;n<S.length;n++)if(w(e,S[n])in t)return S[n];return``}function w(e,t){return t?`${t}${T(e)}`:e}function T(e){let t=``,n=!0;for(let r=0;r<e.length;r++)n?(t+=e[r].toUpperCase(),n=!1):e[r]===`-`?n=!0:t+=e[r];return t}var D=C(),k=``;function A(e,t){k||=_([`matches`,`webkitMatchesSelector`,`mozMatchesSelector`,`msMatchesSelector`,`oMatchesSelector`],function(t){return v(e[t])})??``;let n=e[k];return v(n)?!!n.call(e,t):!1}function j(e,t,n){let r=e;do{if(A(r,t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function M(e,t,n,r){if(!e)return;let i={capture:!0,...r},a=n;e.addEventListener?e.addEventListener(t,a,i):e.attachEvent?e.attachEvent(`on`+t,a):e[`on`+t]=a}function N(e,t,n,r){if(!e)return;let i={capture:!0,...r},a=n;e.removeEventListener?e.removeEventListener(t,a,i):e.detachEvent?e.detachEvent(`on`+t,a):e[`on`+t]=null}function ee(e){let t=e.clientHeight,n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=b(n.borderTopWidth),t+=b(n.borderBottomWidth),t}function P(e){let t=e.clientWidth,n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=b(n.borderLeftWidth),t+=b(n.borderRightWidth),t}function F(e){let t=e.clientHeight,n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=b(n.paddingTop),t-=b(n.paddingBottom),t}function te(e){let t=e.clientWidth,n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=b(n.paddingLeft),t-=b(n.paddingRight),t}function ne(e,t,n){let r=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect();return{x:(e.clientX+t.scrollLeft-r.left)/n,y:(e.clientY+t.scrollTop-r.top)/n}}function I(e,t){let n=ie(e,t,`px`);return{[w(`transform`,D)]:n}}function re(e,t){return ie(e,t,``)}function ie({x:e,y:t},n,r){let i=`translate(${e}${r},${t}${r})`;return n&&(i=`translate(${`${typeof n.x==`string`?n.x:n.x+r}`}, ${`${typeof n.y==`string`?n.y:n.y+r}`})`+i),i}function ae(e,t){return e.targetTouches&&_(e.targetTouches,e=>t===e.identifier)||e.changedTouches&&_(e.changedTouches,e=>t===e.identifier)}function oe(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function se(){return typeof __webpack_nonce__<`u`?__webpack_nonce__:void 0}function L(e,t){if(!e)return;let n=e.getElementById(`react-draggable-style-el`);if(!n){n=e.createElement(`style`),n.type=`text/css`,n.id=`react-draggable-style-el`;let r=t??se();r&&n.setAttribute(`nonce`,r),n.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;}
92
- `,n.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;}
93
- `,e.getElementsByTagName(`head`)[0].appendChild(n)}e.body&&ue(e.body,`react-draggable-transparent-selection`)}function ce(e){window.requestAnimationFrame?window.requestAnimationFrame(()=>{le(e)}):le(e)}function le(e){if(e)try{e.body&&de(e.body,`react-draggable-transparent-selection`);let t=e.selection;if(t)t.empty();else{let t=(e.defaultView||window).getSelection();t&&t.type!==`Caret`&&t.removeAllRanges()}}catch{}}function ue(e,t){e.classList?e.classList.add(t):e.className.match(RegExp(`(?:^|\\s)${t}(?!\\S)`))||(e.className+=` ${t}`)}function de(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(RegExp(`(?:^|\\s)${t}(?!\\S)`,`g`),``)}function R(e,t,n){if(!e.props.bounds)return[t,n];let{bounds:r}=e.props;r=typeof r==`string`?r:_e(r);let i=ve(e);if(typeof r==`string`){let{ownerDocument:e}=i,t=e.defaultView;if(!t)throw Error(`Cannot resolve the owner window of the draggable node.`);let n;if(n=r===`parent`?i.parentNode:i.getRootNode().querySelector(r),!(n instanceof t.HTMLElement))throw Error(`Bounds selector "`+r+`" could not find an element.`);let a=n,o=t.getComputedStyle(i),s=t.getComputedStyle(a);r={left:-i.offsetLeft+b(s.paddingLeft)+b(o.marginLeft),top:-i.offsetTop+b(s.paddingTop)+b(o.marginTop),right:te(a)-P(i)-i.offsetLeft+b(s.paddingRight)-b(o.marginRight),bottom:F(a)-ee(i)-i.offsetTop+b(s.paddingBottom)-b(o.marginBottom)}}return y(r.right)&&(t=Math.min(t,r.right)),y(r.bottom)&&(n=Math.min(n,r.bottom)),y(r.left)&&(t=Math.max(t,r.left)),y(r.top)&&(n=Math.max(n,r.top)),[t,n]}function z(e,t,n){return[Math.round(t/e[0])*e[0],Math.round(n/e[1])*e[1]]}function fe(e){return e.props.axis===`both`||e.props.axis===`x`}function pe(e){return e.props.axis===`both`||e.props.axis===`y`}function me(e,t,n){let r=typeof t==`number`?ae(e,t):null;if(typeof t==`number`&&!r)return null;let i=ve(n),a=n.props.offsetParent||i.offsetParent||i.ownerDocument.body;return ne(r||e,a,n.props.scale)}function he(e,t,n){let r=!y(e.lastX),i=ve(e);return r?{node:i,deltaX:0,deltaY:0,lastX:t,lastY:n,x:t,y:n}:{node:i,deltaX:t-e.lastX,deltaY:n-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:n}}function ge(e,t){let n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}}function _e(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function ve(e){let t=e.findDOMNode();if(!t)throw Error(`<DraggableCore>: Unmounted during event!`);return t}var ye=u(E()),B=u(F1()),be=u(O()),xe=typeof process<`u`&&{}.DRAGGABLE_DEBUG?console.log.bind(console):function(){},Se={touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`},mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`}},Ce=Se.mouse,we=class extends ye.Component{constructor(){super(...arguments),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,this.touchIdentifier=null,this.mounted=!1,this.handleDragStart=e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&(typeof e.button==`number`&&e.button!==0||e.ctrlKey))return!1;let t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw Error(`<DraggableCore> not mounted on DragStart!`);let{ownerDocument:n}=t;if(this.props.disabled||!(e.target instanceof n.defaultView.Node)||this.props.handle&&!j(e.target,this.props.handle,t)||this.props.cancel&&j(e.target,this.props.cancel,t))return;e.type===`touchstart`&&!this.props.allowMobileScroll&&e.preventDefault();let r=oe(e);this.touchIdentifier=r;let i=me(e,r,this);if(i==null)return;let{x:a,y:o}=i,s=he(this,a,o);xe(`DraggableCore: handleDragStart: %j`,s),xe(`calling`,this.props.onStart),this.props.onStart(e,s)!==!1&&this.mounted!==!1&&(this.props.enableUserSelectHack&&L(n,this.props.nonce),this.dragging=!0,this.lastX=a,this.lastY=o,M(n,Ce.move,this.handleDrag),M(n,Ce.stop,this.handleDragStop))},this.handleDrag=e=>{let t=me(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX,t=r-this.lastY;if([e,t]=z(this.props.grid,e,t),!e&&!t)return;n=this.lastX+e,r=this.lastY+t}let i=he(this,n,r);if(xe(`DraggableCore: handleDrag: %j`,i),this.props.onDrag(e,i)===!1||this.mounted===!1)try{this.handleDragStop(new MouseEvent(`mouseup`))}catch{let e=document.createEvent(`MouseEvents`);e.initMouseEvent(`mouseup`,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(e)}else this.lastX=n,this.lastY=r},this.handleDragStop=e=>{if(!this.dragging)return;let t=me(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX||0,t=r-this.lastY||0;[e,t]=z(this.props.grid,e,t),n=this.lastX+e,r=this.lastY+t}let i=he(this,n,r);if(this.props.onStop(e,i)===!1||this.mounted===!1)return!1;let a=this.findDOMNode();a&&this.props.enableUserSelectHack&&ce(a.ownerDocument),xe(`DraggableCore: handleDragStop: %j`,i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,a&&(xe(`DraggableCore: Removing handlers`),N(a.ownerDocument,Ce.move,this.handleDrag),N(a.ownerDocument,Ce.stop,this.handleDragStop))},this.onMouseDown=e=>(Ce=Se.mouse,this.handleDragStart(e)),this.onMouseUp=e=>(Ce=Se.mouse,this.handleDragStop(e)),this.onTouchStart=e=>(Ce=Se.touch,this.handleDragStart(e)),this.onTouchEnd=e=>(Ce=Se.touch,this.handleDragStop(e))}componentDidMount(){this.mounted=!0;let e=this.findDOMNode();e&&M(e,Se.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;let e=this.findDOMNode();if(e){let{ownerDocument:t}=e;N(t,Se.mouse.move,this.handleDrag),N(t,Se.touch.move,this.handleDrag),N(t,Se.mouse.stop,this.handleDragStop),N(t,Se.touch.stop,this.handleDragStop),N(e,Se.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&ce(t)}}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=be.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):(xe(`react-draggable: ReactDOM.findDOMNode is not available in React 19+. You must provide a nodeRef prop. See: https://github.com/react-grid-layout/react-draggable#noderef`),null)}render(){return ye.cloneElement(ye.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};we.displayName=`DraggableCore`,we.propTypes={allowAnyClick:B.default.bool,allowMobileScroll:B.default.bool,children:B.default.node.isRequired,disabled:B.default.bool,enableUserSelectHack:B.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw Error(`Draggable's offsetParent must be a DOM Node.`)},grid:B.default.arrayOf(B.default.number),handle:B.default.string,cancel:B.default.string,nodeRef:B.default.object,nonce:B.default.string,onStart:B.default.func,onDrag:B.default.func,onStop:B.default.func,onMouseDown:B.default.func,scale:B.default.number,className:x,style:x,transform:x},we.defaultProps={allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1};var Te=class extends p.Component{constructor(e){super(e),this.onDragStart=(e,t)=>{if(xe(`Draggable: onDragStart: %j`,t),this.props.onStart(e,ge(this,t))===!1)return!1;this.setState({dragging:!0,dragged:!0})},this.onDrag=(e,t)=>{if(!this.state.dragging)return!1;xe(`Draggable: onDrag: %j`,t);let n=ge(this,t),r={x:n.x,y:n.y,slackX:0,slackY:0};if(this.props.bounds){let{x:e,y:t}=r;r.x+=this.state.slackX,r.y+=this.state.slackY;let[i,a]=R(this,r.x,r.y);r.x=i,r.y=a,r.slackX=this.state.slackX+(e-r.x),r.slackY=this.state.slackY+(t-r.y),n.x=r.x,n.y=r.y,n.deltaX=r.x-this.state.x,n.deltaY=r.y-this.state.y}if(this.props.onDrag(e,n)===!1)return!1;this.setState(r)},this.onDragStop=(e,t)=>{if(!this.state.dragging||this.props.onStop(e,ge(this,t))===!1)return!1;xe(`Draggable: onDragStop: %j`,t);let n={dragging:!1,slackX:0,slackY:0};if(this.props.position){let{x:e,y:t}=this.props.position;n.x=e,n.y=t}this.setState(n)},this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},e.position&&!(e.onDrag||e.onStop)&&console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}static getDerivedStateFromProps({position:e},{prevPropsPosition:t}){return e&&(!t||e.x!==t.x||e.y!==t.y)?(xe(`Draggable: getDerivedStateFromProps %j`,{position:e,prevPropsPosition:t}),{x:e.x,y:e.y,prevPropsPosition:{...e}}):null}componentDidMount(){window.SVGElement!==void 0&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=h.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):null}render(){let{axis:e,bounds:t,children:n,defaultPosition:r,defaultClassName:i,defaultClassNameDragging:a,defaultClassNameDragged:o,position:s,positionOffset:c,scale:l,...u}=this.props,d={},f=null,m=!s||this.state.dragging,h=s||r,_={x:fe(this)&&m?this.state.x:h.x,y:pe(this)&&m?this.state.y:h.y};this.state.isElementSVG?f=re(_,c):d=I(_,c);let v=p.Children.only(n),y=(0,g.clsx)(v.props.className||``,i,{[a]:this.state.dragging,[o]:this.state.dragged});return p.createElement(we,{...u,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop},p.cloneElement(v,{className:y,style:{...v.props.style,...d},transform:f}))}};Te.displayName=`Draggable`,Te.propTypes={...we.propTypes,axis:m.default.oneOf([`both`,`x`,`y`,`none`]),bounds:m.default.oneOfType([m.default.shape({left:m.default.number,right:m.default.number,top:m.default.number,bottom:m.default.number}),m.default.string,m.default.oneOf([!1])]),defaultClassName:m.default.string,defaultClassNameDragging:m.default.string,defaultClassNameDragged:m.default.string,defaultPosition:m.default.shape({x:m.default.number,y:m.default.number}),positionOffset:m.default.shape({x:m.default.oneOfType([m.default.number,m.default.string]),y:m.default.oneOfType([m.default.number,m.default.string])}),position:m.default.shape({x:m.default.number,y:m.default.number}),className:x,style:x,transform:x},Te.defaultProps={...we.defaultProps,axis:`both`,bounds:!1,defaultClassName:`react-draggable`,defaultClassNameDragging:`react-draggable-dragging`,defaultClassNameDragged:`react-draggable-dragged`,defaultPosition:{x:0,y:0},scale:1},0&&(t.exports={DraggableCore:we})})),A0=b(((e,t)=>{var n=k0(),r=n.DraggableCore,i=n.default||n;t.exports=i,t.exports.default=i,t.exports.DraggableCore=r})),j0=b((e=>{e.__esModule=!0,e.cloneElement=c;var t=n(E());function n(e){return e&&e.__esModule?e:{default:e}}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?r(Object(n),!0).forEach(function(t){a(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function a(e,t,n){return(t=o(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e){var t=s(e,`string`);return typeof t==`symbol`?t:t+``}function s(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 c(e,n){return n.style&&e.props.style&&(n.style=i(i({},e.props.style),n.style)),n.className&&e.props.className&&(n.className=e.props.className+` `+n.className),t.default.cloneElement(e,n)}})),M0=b((e=>{e.__esModule=!0,e.resizableProps=void 0;var t=n(F1());A0();function n(e){return e&&e.__esModule?e:{default:e}}e.resizableProps={axis:t.default.oneOf([`both`,`x`,`y`,`none`]),className:t.default.string,children:t.default.element.isRequired,draggableOpts:t.default.shape({allowAnyClick:t.default.bool,cancel:t.default.string,children:t.default.node,disabled:t.default.bool,enableUserSelectHack:t.default.bool,offsetParent:typeof Element<`u`?t.default.instanceOf(Element):t.default.any,grid:t.default.arrayOf(t.default.number),handle:t.default.string,nodeRef:t.default.object,onStart:t.default.func,onDrag:t.default.func,onStop:t.default.func,onMouseDown:t.default.func,scale:t.default.number}),height:function(){var e=[...arguments];let n=e[0];return n.axis===`both`||n.axis===`y`?t.default.number.isRequired(...e):t.default.number(...e)},handle:t.default.oneOfType([t.default.node,t.default.func]),handleSize:t.default.arrayOf(t.default.number),lockAspectRatio:t.default.bool,maxConstraints:t.default.arrayOf(t.default.number),minConstraints:t.default.arrayOf(t.default.number),onResizeStop:t.default.func,onResizeStart:t.default.func,onResize:t.default.func,resizeHandles:t.default.arrayOf(t.default.oneOf([`s`,`w`,`e`,`n`,`sw`,`nw`,`se`,`ne`])),transformScale:t.default.number,width:function(){var e=[...arguments];let n=e[0];return n.axis===`both`||n.axis===`x`?t.default.number.isRequired(...e):t.default.number(...e)}}})),N0=b((e=>{e.__esModule=!0,e.default=void 0;var t=o(E()),n=A0(),r=j0(),i=M0(),a=[`children`,`className`,`draggableOpts`,`width`,`height`,`handle`,`handleSize`,`lockAspectRatio`,`axis`,`minConstraints`,`maxConstraints`,`onResize`,`onResizeStop`,`onResizeStart`,`resizeHandles`,`transformScale`];function o(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(o=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!=="default"&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function s(){return s=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},s.apply(null,arguments)}function c(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?l(Object(n),!0).forEach(function(t){d(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function d(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e){var t=p(e,`string`);return typeof t==`symbol`?t:t+``}function p(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)}var m=class extends t.Component{constructor(){super(...arguments),this.handleRefs={},this.lastHandleRect=null,this.slack=null,this.lastSize=null}componentWillUnmount(){this.resetData()}resetData(){this.lastHandleRect=this.slack=this.lastSize=null}runConstraints(e,t){let n=this.props,r=n.minConstraints,i=n.maxConstraints,a=n.lockAspectRatio;if(!r&&!i&&!a)return[e,t];if(a){let n=this.props.width/this.props.height,r=e-this.props.width,i=t-this.props.height;Math.abs(r)>Math.abs(i*n)?t=e/n:e=t*n}let o=e,s=t,c=this.slack||[0,0],l=c[0],u=c[1];return e+=l,t+=u,r&&(e=Math.max(r[0],e),t=Math.max(r[1],t)),i&&(e=Math.min(i[0],e),t=Math.min(i[1],t)),this.slack=[l+(o-e),u+(s-t)],[e,t]}resizeHandler(e,t){return(n,r)=>{let i=r.node,a=r.deltaX,o=r.deltaY;e===`onResizeStart`&&this.resetData();let s=(this.props.axis===`both`||this.props.axis===`x`)&&t!==`n`&&t!==`s`,c=(this.props.axis===`both`||this.props.axis===`y`)&&t!==`e`&&t!==`w`;if(!s&&!c)return;let l=t[0],u=t[t.length-1],d=i.getBoundingClientRect();if(this.lastHandleRect!=null){if(u===`w`){let e=d.left-this.lastHandleRect.left;a+=e}if(l===`n`){let e=d.top-this.lastHandleRect.top;o+=e}}this.lastHandleRect=d,u===`w`&&(a=-a),l===`n`&&(o=-o);let f=this.lastSize?.width??this.props.width,p=this.lastSize?.height??this.props.height,m=f+(s?a/this.props.transformScale:0),h=p+(c?o/this.props.transformScale:0);var g=this.runConstraints(m,h);if(m=g[0],h=g[1],e===`onResizeStop`&&this.lastSize){var _=this.lastSize;m=_.width,h=_.height}let v=m!==f||h!==p;e!==`onResizeStop`&&(this.lastSize={width:m,height:h});let y=typeof this.props[e]==`function`?this.props[e]:null;y&&(e!==`onResize`||v)&&(n.persist==null||n.persist(),y(n,{node:i,size:{width:m,height:h},handle:t})),e===`onResizeStop`&&this.resetData()}}renderResizeHandle(e,n){let r=this.props.handle;if(!r)return t.createElement(`span`,{className:`react-resizable-handle react-resizable-handle-`+e,ref:n});if(typeof r==`function`)return r(e,n);let i=typeof r.type==`string`,a=u({ref:n},i?{}:{handleAxis:e});return t.cloneElement(r,a)}render(){let e=this.props,i=e.children,o=e.className,l=e.draggableOpts;e.width,e.height,e.handle,e.handleSize,e.lockAspectRatio,e.axis,e.minConstraints,e.maxConstraints,e.onResize,e.onResizeStop,e.onResizeStart;let d=e.resizeHandles;e.transformScale;let f=c(e,a);return(0,r.cloneElement)(i,u(u({},f),{},{className:(o?o+` `:``)+`react-resizable`,children:[...t.Children.toArray(i.props.children),...d.map(e=>{let r=this.handleRefs[e]??(this.handleRefs[e]=t.createRef());return t.createElement(n.DraggableCore,s({},l,{nodeRef:r,key:`resizableHandle-`+e,onStop:this.resizeHandler(`onResizeStop`,e),onStart:this.resizeHandler(`onResizeStart`,e),onDrag:this.resizeHandler(`onResize`,e)}),this.renderResizeHandle(e,r))})]}))}};e.default=m,m.propTypes=i.resizableProps,m.defaultProps={axis:`both`,handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:[`se`],transformScale:1}})),P0=b((e=>{e.__esModule=!0,e.default=void 0;var t=s(E()),n=o(F1()),r=o(N0()),i=M0(),a=[`handle`,`handleSize`,`onResize`,`onResizeStart`,`onResizeStop`,`draggableOpts`,`minConstraints`,`maxConstraints`,`lockAspectRatio`,`axis`,`width`,`height`,`resizeHandles`,`style`,`transformScale`];function o(e){return e&&e.__esModule?e:{default:e}}function s(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(s=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!=="default"&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function c(){return c=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},c.apply(null,arguments)}function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?l(Object(n),!0).forEach(function(t){d(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function d(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e){var t=p(e,`string`);return typeof t==`symbol`?t:t+``}function p(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 m(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var h=class extends t.Component{constructor(){super(...arguments),this.state={width:this.props.width,height:this.props.height,propsWidth:this.props.width,propsHeight:this.props.height},this.onResize=(e,t)=>{let n=t.size;this.props.onResize?(e.persist==null||e.persist(),this.setState(n,()=>this.props.onResize&&this.props.onResize(e,t))):this.setState(n)}}static getDerivedStateFromProps(e,t){return t.propsWidth!==e.width||t.propsHeight!==e.height?{width:e.width,height:e.height,propsWidth:e.width,propsHeight:e.height}:null}render(){let e=this.props,n=e.handle,i=e.handleSize;e.onResize;let o=e.onResizeStart,s=e.onResizeStop,l=e.draggableOpts,d=e.minConstraints,f=e.maxConstraints,p=e.lockAspectRatio,h=e.axis;e.width,e.height;let g=e.resizeHandles,_=e.style,v=e.transformScale,y=m(e,a);return t.createElement(r.default,{axis:h,draggableOpts:l,handle:n,handleSize:i,height:this.state.height,lockAspectRatio:p,maxConstraints:f,minConstraints:d,onResizeStart:o,onResize:this.onResize,onResizeStop:s,resizeHandles:g,transformScale:v,width:this.state.width},t.createElement(`div`,c({},y,{style:u(u({},_),{},{width:this.state.width+`px`,height:this.state.height+`px`})})))}};e.default=h,h.propTypes=u(u({},i.resizableProps),{},{children:n.default.element})})),F0=b(((e,t)=>{t.exports=function(){throw Error(`Don't instantiate Resizable directly! Use require('react-resizable').Resizable`)},t.exports.Resizable=N0().default,t.exports.ResizableBox=P0().default})),I0=b(((e,t,n)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):(n=typeof globalThis<`u`?globalThis:n||self,r(n[`fast-equals`]={}))})(n,(function(e){function t(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function n(e){return function(t,n,r,i){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r,i);var a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);var s=e(t,n,r,i);return i.delete(t),i.delete(n),s}}function r(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n}function i(e){return e.constructor===Object||e.constructor==null}function a(e){return typeof e.then==`function`}function o(e,t){return e===t||e!==e&&t!==t}var s=Object.prototype.toString;function c(e){var t=e.areArraysEqual,n=e.areDatesEqual,r=e.areMapsEqual,c=e.areObjectsEqual,l=e.areRegExpsEqual,u=e.areSetsEqual,d=e.createIsNestedEqual,f=d(p);function p(e,d,p){if(e===d)return!0;if(!e||!d||typeof e!=`object`||typeof d!=`object`)return e!==e&&d!==d;if(i(e)&&i(d))return c(e,d,f,p);var m=Array.isArray(e),h=Array.isArray(d);if(m||h)return m===h&&t(e,d,f,p);var g=s.call(e);return g===s.call(d)?g===`[object Date]`?n(e,d,f,p):g===`[object RegExp]`?l(e,d,f,p):g===`[object Map]`?r(e,d,f,p):g===`[object Set]`?u(e,d,f,p):g===`[object Object]`||g===`[object Arguments]`?a(e)||a(d)?!1:c(e,d,f,p):g===`[object Boolean]`||g===`[object Number]`||g===`[object String]`?o(e.valueOf(),d.valueOf()):!1:!1}return p}function l(e,t,n,r){var i=e.length;if(t.length!==i)return!1;for(;i-->0;)if(!n(e[i],t[i],i,i,e,t,r))return!1;return!0}var u=n(l);function d(e,t){return o(e.valueOf(),t.valueOf())}function f(e,t,n,r){var i=e.size===t.size;if(!i)return!1;if(!e.size)return!0;var a={},o=0;return e.forEach(function(s,c){if(i){var l=!1,u=0;t.forEach(function(i,d){!l&&!a[u]&&(l=n(c,d,o,u,e,t,r)&&n(s,i,c,d,e,t,r))&&(a[u]=!0),u++}),o++,i=l}}),i}var p=n(f),m=`_owner`,h=Object.prototype.hasOwnProperty;function g(e,t,n,r){var i=Object.keys(e),a=i.length;if(Object.keys(t).length!==a)return!1;for(var o;a-->0;){if(o=i[a],o===m){var s=!!e.$$typeof,c=!!t.$$typeof;if((s||c)&&s!==c)return!1}if(!h.call(t,o)||!n(e[o],t[o],o,o,e,t,r))return!1}return!0}var _=n(g);function v(e,t){return e.source===t.source&&e.flags===t.flags}function y(e,t,n,r){var i=e.size===t.size;if(!i)return!1;if(!e.size)return!0;var a={};return e.forEach(function(o,s){if(i){var c=!1,l=0;t.forEach(function(i,u){!c&&!a[l]&&(c=n(o,i,s,u,e,t,r))&&(a[l]=!0),l++}),i=c}}),i}var b=n(y),x=Object.freeze({areArraysEqual:l,areDatesEqual:d,areMapsEqual:f,areObjectsEqual:g,areRegExpsEqual:v,areSetsEqual:y,createIsNestedEqual:t}),S=Object.freeze({areArraysEqual:u,areDatesEqual:d,areMapsEqual:p,areObjectsEqual:_,areRegExpsEqual:v,areSetsEqual:b,createIsNestedEqual:t}),C=c(x);function w(e,t){return C(e,t,void 0)}var T=c(r(x,{createIsNestedEqual:function(){return o}}));function E(e,t){return T(e,t,void 0)}var D=c(S);function O(e,t){return D(e,t,new WeakMap)}var k=c(r(S,{createIsNestedEqual:function(){return o}}));function A(e,t){return k(e,t,new WeakMap)}function j(e){return c(r(x,e(x)))}function M(e){var t=c(r(S,e(S)));return(function(e,n,r){return r===void 0&&(r=new WeakMap),t(e,n,r)})}e.circularDeepEqual=O,e.circularShallowEqual=A,e.createCustomCircularEqual=M,e.createCustomEqual=j,e.deepEqual=w,e.sameValueZeroEqual=o,e.shallowEqual=E,Object.defineProperty(e,"__esModule",{value:!0})}))})),L0=F0(),R0=I0(),z0=50,B0=12;function V0(e){let t=e;for(;t;){let e=window.getComputedStyle(t).overflowY;if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}function H0(e){let t=V0(e),n=null,r=0,i=0,a=!1;function o(){let e=t;if(!e)return;let s=e.getBoundingClientRect(),{clientHeight:c,scrollTop:l,scrollHeight:u}=e,{scrollLeft:d,scrollWidth:f,clientWidth:p}=e,m=0,h=0;i<s.top+z0&&l>0?m=-B0:i>s.bottom-z0&&l+c<u&&(m=B0),r<s.left+z0&&d>0?h=-B0:r>s.right-z0&&d+p<f&&(h=B0),(m!==0||h!==0)&&(e.scrollTop+=m,e.scrollLeft+=h),a&&(n=requestAnimationFrame(o))}return{feed(e,t){r=e,i=t,a||(a=!0,n=requestAnimationFrame(o))},stop(){a=!1,n!==null&&(cancelAnimationFrame(n),n=null)}}}function U0(e){let{children:t,cols:n,containerWidth:r,margin:i,containerPadding:a,rowHeight:o,maxRows:s,isDraggable:c,isResizable:l,isBounded:u,allowMobileScroll:d,static:f,useCSSTransforms:p=!0,usePercentages:m=!1,transformScale:h=1,positionStrategy:g,dragThreshold:_=0,droppingPosition:v,className:y=``,style:b,handle:x=``,cancel:S=``,x:C,y:w,w:T,h:E,minW:D=1,maxW:O=1/0,minH:k=1,maxH:A=1/0,i:M,resizeHandles:N,resizeHandle:ee,constraints:P=J$,layoutItem:F,layout:te=[],onDragStart:ne,onDrag:re,onDragStop:ie,onResizeStart:ae,onResize:oe,onResizeStop:se}=e,[L,ce]=(0,j.useState)(!1),[le,ue]=(0,j.useState)(!1),de=(0,j.useRef)(null),R=(0,j.useRef)({left:0,top:0}),z=(0,j.useRef)({top:0,left:0,width:0,height:0}),fe=(0,j.useRef)(void 0),pe=(0,j.useRef)(te);pe.current=te;let me=(0,j.useRef)(null),he=(0,j.useRef)(null),ge=(0,j.useRef)(!1),_e=(0,j.useRef)({x:0,y:0}),ve=(0,j.useRef)(!1),ye=(0,j.useRef)(null),B=(0,j.useMemo)(()=>({cols:n,containerPadding:a,containerWidth:r,margin:i,maxRows:s,rowHeight:o}),[n,a,r,i,s,o]),be=(0,j.useMemo)(()=>({cols:n,maxRows:s,containerWidth:r,containerHeight:0,rowHeight:o,margin:i,layout:[]}),[n,s,r,o,i]),xe=(0,j.useCallback)(e=>({...be,containerHeight:e??be.containerHeight,layout:pe.current}),[be]),Se=(0,j.useMemo)(()=>F??{i:M,x:C,y:w,w:T,h:E,minW:D,maxW:O,minH:k,maxH:A},[F,M,C,w,T,E,D,O,k,A]),Ce=(0,j.useCallback)(e=>{if(g?.calcStyle)return g.calcStyle(e);if(p)return Z$(e);let t=Q$(e);return m?{...t,left:$$(e.left/r),width:$$(e.width/r)}:t},[g,p,m,r]),we=(0,j.useCallback)((e,{node:t})=>{if(!ne)return;let{offsetParent:n}=t;if(!n)return;let r=n.getBoundingClientRect(),i=t.getBoundingClientRect(),a=i.left/h,o=r.left/h,s=i.top/h,c=r.top/h,l;if(g?.calcDragPosition){let t=e;l=g.calcDragPosition(t.clientX,t.clientY,t.clientX-i.left,t.clientY-i.top)}else l={left:a-o+n.scrollLeft,top:s-c+n.scrollTop};if(R.current=l,ye.current||=H0(t instanceof HTMLElement?t:null),_>0){let t=e;_e.current={x:t.clientX,y:t.clientY},ge.current=!0,ve.current=!1,ce(!0);return}ce(!0);let u=O$(B,l.top,l.left),{x:d,y:f}=Y$(P,Se,u.x,u.y,xe());ne(M,d,f,{e,node:t,newPosition:l})},[ne,h,B,g,_,P,Se,xe,M]),Te=(0,j.useCallback)((e,{node:t,deltaX:n,deltaY:a})=>{if(!re||!L)return;let s=e;if(ge.current&&!ve.current){let n=s.clientX-_e.current.x,r=s.clientY-_e.current.y;if(Math.hypot(n,r)<_)return;if(ve.current=!0,ge.current=!1,ne){let n=O$(B,R.current.top,R.current.left),{x:r,y:i}=Y$(P,Se,n.x,n.y,xe());ne(M,r,i,{e,node:t,newPosition:R.current})}}ye.current?.feed(s.clientX,s.clientY);let c=R.current.top+a,l=R.current.left+n;if(u){let{offsetParent:e}=t;if(e){let t=e.clientHeight-T$(E,o,i[1]);c=A$(c,0,t);let n=w$(B),a=r-T$(T,n,i[0]);l=A$(l,0,a)}}let d={top:c,left:l};R.current=d;let f=O$(B,c,l),{x:p,y:m}=Y$(P,Se,f.x,f.y,xe());re(M,p,m,{e,node:t,newPosition:d})},[re,ne,L,_,u,E,o,i,B,r,T,M,P,Se,xe]),Ee=(0,j.useCallback)((e,{node:t})=>{if(!ie||!L)return;ye.current?.stop(),ye.current=null;let n=ge.current;if(ge.current=!1,ve.current=!1,_e.current={x:0,y:0},n){ce(!1),R.current={left:0,top:0};return}let{left:r,top:i}=R.current,a={top:i,left:r};ce(!1),R.current={left:0,top:0};let o=O$(B,i,r),{x:s,y:c}=Y$(P,Se,o.x,o.y,xe());ie(M,s,c,{e,node:t,newPosition:a})},[ie,L,B,P,Se,xe,M]);me.current=we,he.current=Te;let De=(0,j.useCallback)((e,{node:t,size:n,handle:i},a,o)=>{let s=o===`onResizeStart`?ae:o===`onResize`?oe:se;if(!s)return;let c;c=t?l1(i,a,n,r):{...n,top:a.top,left:a.left},z.current=c;let l=t?.offsetParent?.clientHeight??0,u=k$(B,c.width,c.height),{w:d,h:f}=X$(P,Se,u.w,u.h,i,xe(l));s(M,d,f,{e:e.nativeEvent??e,node:t,size:c,handle:i})},[ae,oe,se,r,B,M,P,Se,xe]),Oe=(0,j.useCallback)((e,t)=>{ue(!0);let n=E$(B,C,w,T,E),r={...t,handle:t.handle};De(e,r,n,`onResizeStart`)},[De,B,C,w,T,E]),ke=(0,j.useCallback)((e,t)=>{let n=E$(B,C,w,T,E),r={...t,handle:t.handle};De(e,r,n,`onResize`)},[De,B,C,w,T,E]),Ae=(0,j.useCallback)((e,t)=>{ue(!1),z.current={top:0,left:0,width:0,height:0};let n=E$(B,C,w,T,E),r={...t,handle:t.handle};De(e,r,n,`onResizeStop`)},[De,B,C,w,T,E]);(0,j.useEffect)(()=>{if(!v)return;let e=de.current;if(!e)return;let t=fe.current||{left:0,top:0},n=L&&(v.left!==t.left||v.top!==t.top);if(!L){let t={node:e,deltaX:v.left,deltaY:v.top,lastX:0,lastY:0,x:v.left,y:v.top};me.current?.(v.e,t)}else if(n){let t={node:e,deltaX:v.left-R.current.left,deltaY:v.top-R.current.top,lastX:R.current.left,lastY:R.current.top,x:v.left,y:v.top};he.current?.(v.e,t)}fe.current=v},[v,L,M]);let je=E$(B,C,w,T,E,L?R.current:null,le?z.current:null),Me=j.Children.only(t),Ne=w$(B),Pe=[T$(D,Ne,i[0]),T$(k,o,i[1])],Fe=[T$(O,Ne,i[0]),T$(A,o,i[1])],Ie=Me.props,Le=Ie.className,Re=Ie.style,ze=j.cloneElement(Me,{ref:de,className:TC(`react-grid-item`,Le,y,{static:f,resizing:le,"react-draggable":c,"react-draggable-dragging":L,dropping:!!v,cssTransforms:p}),style:{...b,...Re,...Ce(je)}}),Be=ee;return ze=(0,I.jsx)(L0.Resizable,{draggableOpts:{disabled:!l},className:l?void 0:`react-resizable-hide`,width:je.width,height:je.height,minConstraints:Pe,maxConstraints:Fe,onResizeStart:Oe,onResize:ke,onResizeStop:Ae,transformScale:h,resizeHandles:N,handle:Be,children:ze}),ze=(0,I.jsx)(E0,{disabled:!c,onStart:we,onDrag:Te,onStop:Ee,handle:x,cancel:`.react-resizable-handle`+(S?`,`+S:``),scale:h,allowMobileScroll:d,nodeRef:de,children:ze}),ze}var W0=j.memo(U0,(e,t)=>e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h&&e.minW===t.minW&&e.maxW===t.maxW&&e.minH===t.minH&&e.maxH===t.maxH&&e.cols===t.cols&&e.containerWidth===t.containerWidth&&e.rowHeight===t.rowHeight&&e.maxRows===t.maxRows&&e.margin===t.margin&&e.containerPadding===t.containerPadding&&e.transformScale===t.transformScale&&e.isDraggable===t.isDraggable&&e.isResizable===t.isResizable&&e.isBounded===t.isBounded&&e.allowMobileScroll===t.allowMobileScroll&&e.useCSSTransforms===t.useCSSTransforms&&e.usePercentages===t.usePercentages&&e.children===t.children&&e.onDrag===t.onDrag&&e.onDragStop===t.onDragStop&&e.onResize===t.onResize&&e.onResizeStop===t.onResizeStop&&e.droppingPosition===t.droppingPosition);W0.displayName=`GridItem`;function G0(e){let{clientX:t,clientY:n,gridElement:r,droppingItem:i,event:a,dragOffsetX:o=0,dragOffsetY:s=0,transformScale:c,cols:l,margin:u,maxRows:d,rowHeight:f,width:p,containerPadding:m}=e,h=r.getBoundingClientRect(),g={cols:l,margin:u,maxRows:d,rowHeight:f,containerWidth:p,containerPadding:m},_=w$(g),v=T$(i.w,_,u[0]),y=T$(i.h,f,u[1]),b=v/2,x=y/2,S=r.scrollLeft??0,C=r.scrollTop??0,w=t-h.left+S+o-b,T=n-h.top+C+s-x,E=Math.max(0,w),D=Math.max(0,T);return{newDroppingPosition:{left:E/c,top:D/c,e:a},calculatedXY:D$(g,D,E,i.w,i.h)}}var K0=()=>{},q0=`react-grid-layout`,J0=!1;try{J0=/firefox/i.test(navigator.userAgent)}catch{}function Y0(e,t){let n=j.Children.toArray(e),r=j.Children.toArray(t);if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(t?.key!==i?.key)return!1}return!0}function X0(e,t,n,r){let i=[],a=new Set;j.Children.forEach(t,t=>{if(!j.isValidElement(t)||t.key===null)return;let n=String(t.key);a.add(n);let r=e.find(e=>e.i===n);if(r)i.push(B$(r));else{let e=t.props[`data-grid`];e?i.push({i:n,x:e.x??0,y:e.y??0,w:e.w??1,h:e.h??1,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,static:e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}):i.push({i:n,x:0,y:L$(i),w:1,h:1})}});let o=W$(i,{cols:n});return r.compact(o,n)}function Z0(e){let{children:t,width:n,gridConfig:r,dragConfig:i,resizeConfig:a,dropConfig:o,positionStrategy:s=p1,compactor:c,constraints:l=J$,layout:u=[],droppingItem:d,autoSize:f=!0,className:p=``,style:m={},innerRef:h,onLayoutChange:g=K0,onDragStart:_=K0,onDrag:v=K0,onDragStop:y=K0,onResizeStart:b=K0,onResize:x=K0,onResizeStop:S=K0,onDrop:C=K0,onDropDragOver:w=K0}=e,T=(0,j.useMemo)(()=>({...m1,...r}),[r]),E=(0,j.useMemo)(()=>({...h1,...i}),[i]),D=(0,j.useMemo)(()=>({...g1,...a}),[a]),O=(0,j.useMemo)(()=>({..._1,...o}),[o]),{cols:k,rowHeight:A,maxRows:M,margin:N,containerPadding:ee}=T,{enabled:P,bounded:F,handle:te,cancel:ne,threshold:re,allowMobileScroll:ie}=E,{enabled:ae,handles:oe,handleComponent:se}=D,{enabled:L,defaultItem:ce,onDragOver:le,touchEnabled:ue=!0,touchDragSource:de=`[data-rgl-draggable]`}=O,R=c??D1(`vertical`),z=R.type,fe=R.allowOverlap,pe=R.preventCollision??!1,me=(0,j.useMemo)(()=>d??{i:`__dropping-elem__`,...ce},[d,ce]),he=s.type===`transform`,ge=s.scale,_e=ee??N,[ve,ye]=(0,j.useState)(!1),[B,be]=(0,j.useState)(()=>X0(u,t,k,R)),[xe,Se]=(0,j.useState)(null),[Ce,we]=(0,j.useState)(!1),[Te,Ee]=(0,j.useState)(null),[De,Oe]=(0,j.useState)(),ke=(0,j.useRef)(void 0);ke.current=De;let Ae=(0,j.useRef)(null),je=(0,j.useRef)(null),Me=(0,j.useRef)(null),Ne=(0,j.useRef)(0),Pe=(0,j.useRef)(B),Fe=(0,j.useRef)(u),Ie=(0,j.useRef)(t),Le=(0,j.useRef)(z),Re=(0,j.useRef)(null),ze=(0,j.useRef)(!1),Be=(0,j.useRef)(null),Ve=(0,j.useRef)(null);Ve.current=Te;let He=(0,j.useRef)(C);(0,j.useLayoutEffect)(()=>{He.current=C});let Ue=(0,j.useRef)(B);Ue.current=B,(0,j.useEffect)(()=>{ye(!0),(0,R0.deepEqual)(B,u)||g(B)},[]),(0,j.useEffect)(()=>{if(xe||Te)return;let e=!(0,R0.deepEqual)(u,Fe.current),n=!Y0(t,Ie.current),r=z!==Le.current;if(e||n||r){let n=X0(e?u:B,t,k,R);(0,R0.deepEqual)(n,B)||be(n)}Fe.current=u,Ie.current=t,Le.current=z},[u,t,k,z,R,xe,Te,B]),(0,j.useEffect)(()=>{if(!xe&&!Te&&!(0,R0.deepEqual)(B,Pe.current)){Pe.current=B;let e=B.filter(e=>e.i!==me.i);g(e)}},[B,xe,Te,g,me.i]);let We=(0,j.useMemo)(()=>{if(!f)return;let e=L$(B),t=_e[1];return e*A+(e-1)*N[1]+t*2+`px`},[f,B,A,N,_e]),Ge=(0,j.useCallback)((e,t,n,r)=>{let i=Ue.current,a=R$(i,e);if(!a)return;let o={w:a.w,h:a.h,x:a.x,y:a.y,i:e};Ae.current=B$(a),Me.current=i,Se(o),_(i,a,a,null,r.e,r.node)},[_]),Ke=(0,j.useCallback)((e,t,n,r)=>{let i=Ue.current,a=Ae.current,o=R$(i,e);if(!o)return;let s={w:o.w,h:o.h,x:o.x,y:o.y,i:e},c=G$(i,o,t,n,!0,pe,z,k,fe);v(c,a,o,s,r.e,r.node),be(R.compact(c,k)),Se(s)},[pe,z,k,fe,R,v]),qe=(0,j.useCallback)((e,t,n,r)=>{if(!Ae.current)return;let i=Ue.current,a=Ae.current,o=R$(i,e);if(!o)return;let s=G$(i,o,t,n,!0,pe,z,k,fe),c=R.compact(s,k);y(c,a,o,null,r.e,r.node);let l=Me.current;Ae.current=null,Me.current=null,Se(null),be(c),l&&!(0,R0.deepEqual)(l,c)&&g(c)},[pe,z,k,fe,R,y,g]),Je=(0,j.useCallback)((e,t,n,r)=>{let i=Ue.current,a=R$(i,e);a&&(je.current=B$(a),Me.current=i,we(!0),b(i,a,a,null,r.e,r.node))},[b]),Ye=(0,j.useCallback)((e,t,n,r)=>{let i=Ue.current,a=je.current,{handle:o}=r,s=!1,c,l,[u,d]=U$(i,e,e=>(c=e.x,l=e.y,[`sw`,`w`,`nw`,`n`,`ne`].includes(o)&&([`sw`,`nw`,`w`].includes(o)&&(c=e.x+(e.w-t),t=e.x!==c&&c<0?e.w:t,c=c<0?0:c),[`ne`,`n`,`nw`].includes(o)&&(l=e.y+(e.h-n),n=e.y!==l&&l<0?e.h:n,l=l<0?0:l),s=!0),pe&&!fe&&N$(i,{...e,w:t,h:n,x:c??e.x,y:l??e.y}).filter(t=>t.i!==e.i).length>0&&(l=e.y,n=e.h,c=e.x,t=e.w,s=!1),e.w=t,e.h=n,(o===`n`||o===`nw`||o===`ne`)&&(e.y=l??e.y),e));if(!d)return;let f=u;s&&c!==void 0&&l!==void 0&&(f=G$(u,d,c,l,!0,pe,z,k,fe));let p={w:d.w,h:d.h,x:d.x,y:d.y,i:e,static:!0};x(f,a,d,p,r.e,r.node);let m=R.compact(f,k);if(o===`n`||o===`nw`||o===`ne`){let t=m.find(t=>t.i===e);t&&(t.y=d.y)}be(m),Se(p)},[pe,z,k,fe,R,x]),Xe=(0,j.useCallback)((e,t,n,r)=>{let i=Ue.current,a=je.current,o=R$(i,e),s=R.compact(i,k);S(s,a,o??null,null,r.e,r.node);let c=Me.current;je.current=null,Me.current=null,Se(null),we(!1),be(s),c&&!(0,R0.deepEqual)(c,s)&&g(s)},[k,R,S,g]),Ze=(0,j.useCallback)((e,t,n,r)=>{if(r)ke.current&&(ke.current.left!==t.left||ke.current.top!==t.top)&&(Oe(t),be(t=>t.map(t=>t.i===e.i&&(t.x!==n.x||t.y!==n.y)?{...t,x:n.x,y:n.y}:t)));else{Ee((0,I.jsx)(`div`,{},e.i)),Oe(t);let r=Ue.current.filter(t=>t.i!==e.i);be([...r,{...e,x:n.x,y:n.y,static:!1,isDraggable:!0}])}},[]),Qe=(0,j.useCallback)((e,t,r)=>{let i=Re.current;if(!i)return;let{newDroppingPosition:a,calculatedXY:o}=G0({clientX:e,clientY:t,gridElement:i,droppingItem:me,event:r,transformScale:ge,cols:k,margin:N,maxRows:M,rowHeight:A,width:n,containerPadding:_e});Ze(me,a,o,!!Ve.current)},[me,ge,k,N,M,A,n,_e,Ze]),$e=(0,j.useCallback)(()=>{let e=Ue.current;if(!e.some(e=>e.i===me.i)){Ee(null),Se(null),Oe(void 0);return}let t=R.compact(e.filter(e=>e.i!==me.i),k);be(t),Ee(null),Se(null),Oe(void 0)},[me.i,k,R]),et=(0,j.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),J0&&!e.nativeEvent.target?.classList.contains(q0))return!1;let t=le?le(e.nativeEvent):w(e);if(t===!1)return Te&&$e(),!1;let{dragOffsetX:r=0,dragOffsetY:i=0,...a}=t??{},o={...me,...a},{newDroppingPosition:s,calculatedXY:c}=G0({clientX:e.clientX,clientY:e.clientY,gridElement:e.currentTarget,droppingItem:o,event:e.nativeEvent,dragOffsetX:r,dragOffsetY:i,transformScale:ge,cols:k,margin:N,maxRows:M,rowHeight:A,width:n,containerPadding:_e});Ze(o,s,c,!!Te)},[Te,me,le,w,$e,Ze,ge,k,N,M,A,n,_e]),tt=(0,j.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),Ne.current--,Ne.current<0&&(Ne.current=0),Ne.current===0&&$e()},[$e]),nt=(0,j.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),Ne.current++},[]),rt=(0,j.useCallback)(e=>{let t=Ue.current,n=t.find(e=>e.i===me.i);$e(),He.current(t,n,e)},[me.i,$e]),it=(0,j.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),Ne.current=0,rt(e.nativeEvent)},[rt]);(0,j.useEffect)(()=>{if(!L||!ue)return;let e=Re.current;if(!e)return;let t=(t,n)=>{let r=document.elementFromPoint(t,n);return r?e.contains(r):!1},n=e=>e instanceof HTMLElement&&e.closest(de)!==null,r=e=>{let t=e.changedTouches;if(!t||t.length===0)return;let n=Be.current;if(n===null)return t[0];for(let e=0;e<t.length;e++){let r=t[e];if(r&&r.identifier===n)return r}},i=e=>{if(!n(e.target)||Be.current!==null)return;e.preventDefault();let t=e.changedTouches?.[0];t&&(Be.current=t.identifier,ze.current=!0)},a=e=>{if(!ze.current)return;e.preventDefault();let n=r(e);n&&(t(n.clientX,n.clientY)?Qe(n.clientX,n.clientY,e):Ve.current&&$e())},o=e=>{if(!ze.current)return;e.preventDefault();let n=r(e);ze.current=!1,Be.current=null,n&&(t(n.clientX,n.clientY)?rt(e):$e())},s=()=>{ze.current&&(ze.current=!1,Be.current=null,$e())},c={passive:!1};return document.addEventListener(`touchstart`,i,c),document.addEventListener(`touchmove`,a,c),document.addEventListener(`touchend`,o,c),document.addEventListener(`touchcancel`,s,c),()=>{document.removeEventListener(`touchstart`,i,c),document.removeEventListener(`touchmove`,a,c),document.removeEventListener(`touchend`,o,c),document.removeEventListener(`touchcancel`,s,c)}},[L,ue,de,Qe,$e,rt,me.i]);let at=(0,j.useCallback)((e,t)=>{if(!e||!e.key)return null;let r=R$(B,String(e.key));if(!r)return null;let i=typeof r.isDraggable==`boolean`?r.isDraggable:!r.static&&P,a=typeof r.isResizable==`boolean`?r.isResizable:!r.static&&ae,o=r.resizeHandles||[...oe],c=i&&F&&r.isBounded!==!1,u=se;return(0,I.jsx)(W0,{containerWidth:n,cols:k,margin:N,containerPadding:_e,maxRows:M,rowHeight:A,cancel:ne,handle:te,onDragStart:Ge,onDrag:Ke,onDragStop:qe,onResizeStart:Je,onResize:Ye,onResizeStop:Xe,isDraggable:i,isResizable:a,isBounded:c,allowMobileScroll:ie,useCSSTransforms:he&&ve,usePercentages:!ve,transformScale:ge,positionStrategy:s,dragThreshold:re,w:r.w,h:r.h,x:r.x,y:r.y,i:r.i,minH:r.minH,minW:r.minW,maxH:r.maxH,maxW:r.maxW,static:r.static,droppingPosition:t?De:void 0,resizeHandles:o,resizeHandle:u,constraints:l,layoutItem:r,layout:B,children:e},r.i)},[B,n,k,N,_e,M,A,ne,te,Ge,Ke,qe,Je,Ye,Xe,P,ae,F,he,ve,ge,s,re,De,oe,se,l]),ot=()=>xe?(0,I.jsx)(W0,{w:xe.w,h:xe.h,x:xe.x,y:xe.y,i:xe.i,className:`react-grid-placeholder ${Ce?`placeholder-resizing`:``}`,containerWidth:n,cols:k,margin:N,containerPadding:_e,maxRows:M,rowHeight:A,isDraggable:!1,isResizable:!1,isBounded:!1,useCSSTransforms:he,transformScale:ge,constraints:l,layout:B,children:(0,I.jsx)(`div`,{})}):null,st=(0,j.useCallback)(e=>{Re.current=e,typeof h==`function`?h(e):h&&`current`in h&&(h.current=e)},[h]),ct=TC(q0,p),lt={height:We,...m};return(0,I.jsxs)(`div`,{ref:st,className:ct,style:lt,onDrop:L?it:void 0,onDragLeave:L?tt:void 0,onDragEnter:L?nt:void 0,onDragOver:L?et:void 0,children:[j.Children.map(t,e=>j.isValidElement(e)?at(e):null),L&&Te&&at(Te,!0),ot()]})}var Q0={lg:1200,md:996,sm:768,xs:480,xxs:0},$0={lg:12,md:10,sm:6,xs:4,xxs:2},e2=()=>{};function t2(e,t,n,r,i=!1){let a=[];j.Children.forEach(t,t=>{if(!j.isValidElement(t)||t.key===null)return;let n=String(t.key),r=t.props[`data-grid`],o=e.find(e=>e.i===n);o?i&&r?a.push({...o,i:n,w:r.w??o.w,h:r.h??o.h,minW:r.minW??o.minW,maxW:r.maxW??o.maxW,minH:r.minH??o.minH,maxH:r.maxH??o.maxH}):a.push({...o,i:n}):r?a.push({i:n,x:r.x??0,y:r.y??0,w:r.w??1,h:r.h??1,minW:r.minW,maxW:r.maxW,minH:r.minH,maxH:r.maxH,static:r.static,isDraggable:r.isDraggable,isResizable:r.isResizable,resizeHandles:r.resizeHandles,isBounded:r.isBounded}):a.push({i:n,x:0,y:L$(a),w:1,h:1})});let o=W$(a,{cols:n});return r.compact(o,n)}function n2(e){let{children:t,width:n,breakpoint:r,breakpoints:i=Q0,cols:a=$0,layouts:o={},rowHeight:s=150,maxRows:c=1/0,margin:l=[10,10],containerPadding:u=null,compactor:d,onBreakpointChange:f=e2,onLayoutChange:p=e2,onWidthChange:m=e2,...h}=e,g=d??D1(`vertical`),_=g.type,v=g.allowOverlap,y=(0,j.useMemo)(()=>r??k1(i,n),[]),b=(0,j.useMemo)(()=>A1(y,a),[y,a]),x=(0,j.useMemo)(()=>j1(o,i,y,y,b,_),[]),[S,C]=(0,j.useState)(y),[w,T]=(0,j.useState)(b),[E,D]=(0,j.useState)(x),[O,k]=(0,j.useState)(o),A=(0,j.useRef)(n),M=(0,j.useRef)(r),N=(0,j.useRef)(i),ee=(0,j.useRef)(a),P=(0,j.useRef)(o),F=(0,j.useRef)(_),te=(0,j.useRef)(O);(0,j.useEffect)(()=>{te.current=O},[O]);let ne=(0,j.useMemo)(()=>(0,R0.deepEqual)(o,P.current)?null:j1(o,i,S,S,w,g),[o,i,S,w,g]),re=ne??E;(0,j.useEffect)(()=>{ne!==null&&(D(ne),k(o),te.current=o,P.current=o)},[ne,o]),(0,j.useEffect)(()=>{if(_!==F.current){let e=g.compact(V$(re),w),t={...te.current,[S]:e};D(e),k(t),te.current=t,p(e,t),F.current=_}},[_,g,re,w,v,S,p]),(0,j.useEffect)(()=>{let e=n!==A.current,o=r!==M.current,s=!(0,R0.deepEqual)(i,N.current),c=!(0,R0.deepEqual)(a,ee.current);if(e||o||s||c){let e=r??k1(i,n),o=A1(e,a),d=S;if(d!==e||s||c){let n={...te.current};n[d]||(n[d]=V$(E));let r=j1(n,i,e,d,o,g),a=!n[e];r=t2(r,t,o,g,a),n[e]=r,C(e),T(o),D(r),k(n),te.current=n,f(e,o),p(r,n)}let h=M1(l,e),_=u?M1(u,e):null;m(n,h,o,_),A.current=n,M.current=r,N.current=i,ee.current=a}},[n,r,i,a,S,w,E,t,g,_,v,l,u,f,p,m]);let ie=(0,j.useCallback)(e=>{let t={...te.current,[S]:e};D(e),k(t),te.current=t,p(e,t)},[S,p]),ae=(0,j.useMemo)(()=>M1(l,S),[l,S]),oe=(0,j.useMemo)(()=>u===null?null:M1(u,S),[u,S]),se=(0,j.useMemo)(()=>({cols:w,rowHeight:s,maxRows:c,margin:ae,containerPadding:oe}),[w,s,c,ae,oe]);return(0,I.jsx)(Z0,{...h,width:n,gridConfig:se,compactor:g,onLayoutChange:ie,layout:re,children:t})}var r2=j.forwardRef(function(e,t){let{innerRef:n,...r}=e,i=n??t;return(0,I.jsx)(n2,{...r,innerRef:i})});r2.displayName=`ResponsiveGridLayout`;function i2(e){let{children:t,width:n,breakpoint:r,breakpoints:i,cols:a,layouts:o,onBreakpointChange:s,onLayoutChange:c,onWidthChange:l,rowHeight:u,maxRows:d,margin:f,containerPadding:p,droppingItem:m,compactType:h,preventCollision:g=!1,allowOverlap:_=!1,verticalCompact:v,isDraggable:y=!0,isBounded:b=!1,draggableHandle:x,draggableCancel:S,allowMobileScroll:C,isResizable:w=!0,resizeHandles:T=[`se`],resizeHandle:E,isDroppable:D=!1,useCSSTransforms:O=!0,transformScale:k=1,autoSize:A,className:j,style:M,innerRef:N,onDragStart:ee,onDrag:P,onDragStop:F,onResizeStart:te,onResize:ne,onResizeStop:re,onDrop:ie,onDropDragOver:ae}=e,oe=h===void 0?`vertical`:h;v===!1&&(oe=null);let se={enabled:y,bounded:b,handle:x,cancel:S,allowMobileScroll:C},L={enabled:w,handles:T,handleComponent:E},ce={enabled:D},le;le=O?k===1?u1:f1(k):d1;let ue=D1(oe,_,g);return(0,I.jsx)(r2,{width:n,breakpoint:r,breakpoints:i,cols:a,layouts:o,rowHeight:u,maxRows:d,margin:f,containerPadding:p,compactor:ue,dragConfig:se,resizeConfig:L,dropConfig:ce,positionStrategy:le,droppingItem:m,autoSize:A,className:j,style:M,innerRef:N,onBreakpointChange:s,onLayoutChange:c,onWidthChange:l,onDragStart:ee,onDrag:P,onDragStop:F,onResizeStart:te,onResize:ne,onResizeStop:re,onDrop:ie,onDropDragOver:ae,children:t})}var a2=j.forwardRef(function(e,t){let{innerRef:n,...r}=e,i=n??t;return(0,I.jsx)(i2,{...r,innerRef:i})});a2.displayName=`ResponsiveReactGridLayout`;var o2=a2,s2=`react-grid-layout`;function c2(e){function t(t){let{measureBeforeMount:n=!1,className:r,style:i,...a}=t,[o,s]=(0,j.useState)(1280),[c,l]=(0,j.useState)(!1),u=(0,j.useRef)(null),d=(0,j.useRef)(null);return(0,j.useEffect)(()=>{l(!0)},[]),(0,j.useEffect)(()=>{let e=u.current;if(!(e instanceof HTMLElement))return;let t=null,n=new ResizeObserver(e=>{if(e[0]){let n=Math.round(e[0].contentRect.width);t!==null&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>{s(e=>e===n?e:n),t=null})}});return n.observe(e),d.current=n,()=>{t!==null&&cancelAnimationFrame(t),n.unobserve(e),n.disconnect()}},[c]),n&&!c?(0,I.jsx)(`div`,{className:TC(r,s2),style:i,ref:u}):(0,I.jsx)(e,{innerRef:u,className:r,style:i,...a,width:o})}return t.displayName=`WidthProvider(${e.displayName||e.name||`Component`})`,t}var l2=[`#5645d4`,`#2a9d99`,`#dd5b00`,`#7b3ff2`,`#1aae39`,`#ff64c8`];function u2({editing:e,result:t,widget:n}){return(0,I.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col overflow-hidden rounded-xl border border-border bg-background shadow-sm`,"data-testid":`dashboard-widget-${n.id}`,children:[(0,I.jsxs)(`header`,{className:e?`dashboard-drag-handle flex cursor-move items-start gap-2 border-b border-border px-4 py-3`:`flex items-start gap-2 border-b border-border px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h2`,{className:`truncate text-sm font-semibold text-foreground`,children:n.title}),n.description?(0,I.jsx)(`p`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:n.description}):null]}),e?(0,I.jsx)(io,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`}):null]}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 p-4`,children:(0,I.jsx)(d2,{result:t,widget:n})})]})}function d2({result:e,widget:t}){if(e.kind===`metric`)return(0,I.jsxs)(`div`,{className:`flex h-full flex-col justify-center`,children:[(0,I.jsx)(`div`,{className:`text-4xl font-semibold tracking-[-0.04em] text-foreground`,style:{color:t.config?.color},children:e.value.toLocaleString()}),(0,I.jsx)(`div`,{className:`mt-2 text-sm text-muted-foreground`,children:t.config?.value_label||`items`})]});if(e.kind===`table`)return(0,I.jsxs)(`div`,{className:`h-full overflow-auto rounded-lg border border-border`,children:[(0,I.jsxs)(`table`,{className:`w-full min-w-[520px] border-collapse text-left text-xs`,children:[(0,I.jsx)(`thead`,{className:`sticky top-0 z-10 bg-muted/80 backdrop-blur`,children:(0,I.jsx)(`tr`,{children:e.columns.map(e=>(0,I.jsx)(`th`,{className:`border-b border-border px-3 py-2 font-medium text-foreground`,children:e.title},e.name))})}),(0,I.jsx)(`tbody`,{children:e.rows.map(t=>(0,I.jsx)(`tr`,{className:`border-b border-border last:border-b-0 hover:bg-muted/40`,children:e.columns.map(e=>(0,I.jsx)(`td`,{className:`max-w-64 truncate px-3 py-2 text-muted-foreground`,children:f2(t.values[e.name]??null)},e.name))},t.id))})]}),e.rows.length===0?(0,I.jsx)(`div`,{className:`flex h-24 items-center justify-center text-sm text-muted-foreground`,children:`No matching records`}):null]});if(e.points.length===0)return(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`No data to display`});let n=t.config?.color||`#5645d4`;return t.type===`pie`?(0,I.jsx)(L_,{label:t.title,data:e.points,labelField:`label`,valueField:`value`,innerRadius:.64,colors:l2,height:`fill`}):t.type===`line`?(0,I.jsx)(N_,{label:t.title,data:e.points,xField:`label`,yField:`value`,color:n,dots:!0,integers:!0,height:`fill`}):(0,I.jsx)(P_,{label:t.title,data:e.points,xField:`label`,yField:`value`,color:n,integers:!0,height:`fill`})}function f2(e){return e==null||e===``?`—`:Array.isArray(e)?e.map(e=>!e||typeof e!=`object`?e:`display`in e?e.display:`name`in e?e.name:``).join(`, `):typeof e==`object`?e.name:typeof e==`boolean`?e?`Yes`:`No`:String(e)}function p2(e,t,n){let r=t.filter(t=>(e.query.filters||[]).every(e=>{let n=t.values?.[e.field_name]??null;switch(e.operator){case`equals`:return m2(n,e.value??null);case`not_equals`:return!m2(n,e.value??null);case`truthy`:return h2(n);case`falsy`:return!h2(n);default:return!0}}));if(e.type===`table`){let t=new Set(e.query.columns||[]);return{kind:`table`,columns:n.filter(e=>t.has(e.name)).map(e=>({name:e.name,title:e.title})),rows:r.slice(0,e.query.limit||10).map(e=>({id:e.id,values:e.values}))}}let i=e.query.group_by_field_name;if(i){let t=new Map;r.forEach(n=>{let r=g2(n.values?.[i]??null),a=e.query.aggregation===`count_true`?Number(h2(n.values?.[e.query.field_name||``]??null)):1;t.set(r,(t.get(r)||0)+a)});let n=e.config?.category_order||[],a=new Map(n.map((e,t)=>[e,t]));return{kind:`series`,points:Array.from(t,([e,t])=>({label:e,value:t})).sort((t,n)=>{let r=a.get(t.label),i=a.get(n.label);return r!=null||i!=null?(r??2**53-1)-(i??2**53-1):e.type===`line`?t.label.localeCompare(n.label,void 0,{numeric:!0}):n.value-t.value||t.label.localeCompare(n.label)})}}return{kind:`metric`,value:e.query.aggregation===`count_true`?r.filter(t=>h2(t.values?.[e.query.field_name||``]??null)).length:r.length}}function m2(e,t){return e===t||JSON.stringify(e)===JSON.stringify(t)}function h2(e){return Array.isArray(e)?e.length>0:e&&typeof e==`object`?!0:!!e}function g2(e){return e==null||e===``?`Empty`:Array.isArray(e)?e.join(`, `)||`Empty`:typeof e==`object`?`Attachment`:String(e)}var _2=c2(o2),v2=300;function y2({dashboardId:e,documentPath:t,topbarEnd:n}){let r=aC(),[i,a]=(0,j.useState)(null),[o,s]=(0,j.useState)(null),[c,l]=(0,j.useState)([]),[u,d]=(0,j.useState)(null),[f,p]=(0,j.useState)(!1),[m,h]=(0,j.useState)(`lg`),[g,_]=(0,j.useState)(`loading`),[v,y]=(0,j.useState)(``),[b,x]=(0,j.useState)(!1),S=(0,j.useCallback)(async()=>{_(`loading`),y(``);try{let n=await r.documents.open({path:t}),i=((await r.dashboards.list({documentId:n.id})).items||[]).find(t=>t.id===e);if(!i)throw Error(`Dashboard not found`);let o=n.tables?.find(e=>e.id===i.source_table_id)||null;if(!o)throw Error(`Dashboard source table not found`);let c=await r.records.list({documentId:n.id,tableId:o.id,limit:500,offset:0});s(n),a(i),d(o),l(c.items||[]),_(`ready`)}catch(e){y(e instanceof Error?e.message:`Dashboard failed to load`),_(`error`)}},[r,e,t]);(0,j.useEffect)(()=>{S()},[S]),(0,j.useEffect)(()=>{function e(e){let n=e.detail;n?.vaultPath===t&&n.tableId===u?.id&&S()}return window.addEventListener(`kition:data-document:record:upsert`,e),window.addEventListener(`kition:data-document:record:delete`,e),()=>{window.removeEventListener(`kition:data-document:record:upsert`,e),window.removeEventListener(`kition:data-document:record:delete`,e)}},[t,S,u?.id]),g$(o?.id??null,{onDashboards:()=>void S()});let C=(0,j.useRef)(null);(0,j.useEffect)(()=>()=>{C.current&&clearTimeout(C.current)},[]);let w=(0,j.useMemo)(()=>{let e=new Map;return!i||!u||i.widgets.forEach(t=>{e.set(t.id,p2(t,c,u.fields||[]))}),e},[i,c,u]),T=(0,j.useMemo)(()=>{let e=b2(i?.layout||[]),t=S2(i?.layout||[]);return{lg:e,md:e,sm:e,xs:t,xxs:t}},[i?.layout]),E=m===`xs`||m===`xxs`,D=f&&!E,O=(0,j.useCallback)(e=>{if(!i||!o||E)return;let t={...i,layout:e.map(e=>({widget_id:e.i,x:e.x,y:e.y,w:e.w,h:e.h,...e.minW==null?{}:{min_w:e.minW},...e.minH==null?{}:{min_h:e.minH}}))};a(t),x(!0),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>{r.dashboards.upsert({documentId:o.id,dashboardId:t.id,...t}).then(e=>{s(o),a(e)}).catch(e=>{y(e instanceof Error?e.message:`Dashboard layout could not be saved`)}).finally(()=>x(!1))},v2)},[i,r,o,E]);return g===`loading`?(0,I.jsxs)(`div`,{className:`flex h-full items-center justify-center bg-muted/30`,role:`status`,children:[(0,I.jsx)(`span`,{className:`workspace-pane-spinner`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`sr-only`,children:`Loading dashboard`})]}):g===`error`||!i||!u?(0,I.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-4 bg-muted/30 p-8 text-center`,children:[(0,I.jsx)(yo,{className:`size-9 text-muted-foreground`}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{className:`text-base font-semibold text-foreground`,children:`Dashboard unavailable`}),(0,I.jsx)(`p`,{className:`mt-1 max-w-md text-sm text-muted-foreground`,children:v||`Dashboard not found`})]}),(0,I.jsxs)(Rc,{variant:`secondary`,size:`sm`,onClick:()=>void S(),children:[(0,I.jsx)(xs,{}),`Try again`]})]}):(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-muted/30`,"data-testid":`dashboard-editor-pane`,children:[(0,I.jsx)(gx,{children:(0,I.jsxs)(`header`,{className:`dashboard-editor-topbar flex min-h-14 shrink-0 items-center gap-3 border-b border-border bg-background px-5 py-3`,children:[(0,I.jsx)(`div`,{className:`dashboard-editor-topbar__icon flex size-8 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,I.jsx)(yo,{className:`size-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`h1`,{className:`dashboard-editor-topbar__title truncate text-base font-semibold text-foreground`,children:i.title}),(0,I.jsxs)(`p`,{className:`truncate text-xs text-muted-foreground`,children:[`Live from `,u.title,` · `,c.length.toLocaleString(),` records`]})]}),b?(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Saving layout…`}):null,n?(0,I.jsx)(`span`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:n}):null,(0,I.jsxs)(Rc,{variant:`secondary`,size:`sm`,onClick:()=>void S(),children:[(0,I.jsx)(xs,{}),`Refresh`]}),(0,I.jsxs)(Rc,{variant:D?`primary`:`secondary`,size:`sm`,disabled:E,title:E?`Layout editing is available on wider screens`:void 0,onClick:()=>p(e=>!e),children:[D?(0,I.jsx)(Mo,{}):(0,I.jsx)(jo,{}),D?`Finish layout`:`Customize layout`]})]})}),v?(0,I.jsx)(`div`,{className:`border-b border-destructive/20 bg-destructive/5 px-5 py-2 text-xs text-destructive`,children:v}):null,(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,I.jsx)(_2,{className:`dashboard-grid`,layouts:T,breakpoints:{lg:1200,md:996,sm:768,xs:480,xxs:0},cols:{lg:12,md:12,sm:12,xs:1,xxs:1},rowHeight:80,margin:[16,16],containerPadding:[20,20],compactType:`vertical`,draggableHandle:`.dashboard-drag-handle`,isDraggable:D,isResizable:D,onBreakpointChange:e=>h(e),onDragStop:e=>O(e),onResizeStop:e=>O(e),children:i.layout.map(e=>{let t=i.widgets.find(t=>t.id===e.widget_id),n=t?w.get(t.id):void 0;return!t||!n?null:(0,I.jsx)(`div`,{"data-grid":x2(e),children:(0,I.jsx)(u2,{editing:D,result:n,widget:t})},t.id)})})})]})}function b2(e){return e.map(x2)}function x2(e){return{i:e.widget_id,x:e.x,y:e.y,w:e.w,h:e.h,minW:e.min_w,minH:e.min_h}}function S2(e){let t=0;return e.map(e=>{let n={i:e.widget_id,x:0,y:t,w:1,h:e.h,minW:1,minH:e.min_h};return t+=e.h,n})}var C2=`KTAX`,w2=2,T2=32;function E2(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.byteLength<T2||String.fromCharCode(...e.subarray(0,4))!==C2)throw Error(`not a grid axis`);let n=t.getUint16(4,!0);if(n!==w2)throw Error(`grid axis version ${n}, not ${w2}`);let[r,i,a,o,s]=[0,1,2,4,5].map(e=>t.getUint32(8+e*4,!0)),c=Array(a);for(let e=0;e<a;e+=1)c[e]=t.getFloat64(T2+e*8,!0);let l=T2+a*8,u=s?JSON.parse(new TextDecoder().decode(e.subarray(l,l+s))):[];if(u.length!==o)throw Error(`the grid axis group headers do not match their count`);return{epoch:r,total:i,ids:c,groups:u}}var D2=`KTHT`,O2=1,k2=24;function A2(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.byteLength<k2||String.fromCharCode(...e.subarray(0,4))!==D2)throw Error(`not grid hits`);let r=n.getUint16(4,!0);if(r!==O2)throw Error(`grid hits version ${r}, not ${O2}`);let[i,a,o]=[12,16,20].map(e=>n.getUint32(e,!0));if(o!==t.length)throw Error(`the grid hits are for other fields`);let s=Math.ceil(o/8);if(e.byteLength<k2+a*s)throw Error(`the grid hits are cut short`);let c=[];for(let n=0;n<a;n+=1)for(let r=0;r<o;r+=1)e[k2+n*s+(r>>3)]&1<<(r&7)&&c.push([i+n,t[r]]);return c}var j2=new Set([`documents.get`,`fields.linkCandidates`,`views.listFields`,`records.list`,`records.history`,`csv.export`,`historyState`,`dashboards.list`,`attachments.read`,`import.preview`,`ai.prepare`,`changes.since`]);function M2(e){let t=``;for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}function N2(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}function P2(e){if(!e)return e;let t=e.options??{},n=`ai_config`in t,r=eC(n?t.ai_config:e.ai_config);if(!n&&r===e.ai_config)return e;let i={...t};return delete i.ai_config,{...e,options:n?i:e.options,ai_config:r??null}}function F2(e){return e&&Array.isArray(e.fields)?{...e,fields:e.fields.map(P2)}:e}var I2=``;function L2(e){return e instanceof Error&&e.message.includes(I2)&&(e.message=e.message.slice(0,e.message.indexOf(I2))),e}function R2({documentId:e,...t}){return t}function z2(e,t){let n=new Set,r=new Set,i=()=>{for(let e of r)e()},a=null;async function o(t,n={}){let r=j2.has(t),o=await e.run(`table.${t}`,n,r?`none`:`all`).catch(e=>{throw L2(e)});if(o==null)throw Error(`The table is not open.`);return r||(a=e.revision(),i()),JSON.parse(o).result}async function s(){let e=await o(`documents.get`);return{...e,path:t,tables:e.tables?.map(F2)}}function c(e){for(let t of n)t(e)}async function l(){let n=JSON.parse(await e.invoke(`takeImported`));if(!n.length)c({type:`resync`});else for(let e of n)c({type:`changed`,change:{...e,documentPath:t}})}return{documents:{get:()=>s(),open:()=>s(),list:async()=>({items:[await s()],total:1,offset:0})},tables:{create:async e=>F2(await o(`tables.create`,R2(e))),update:async e=>F2(await o(`tables.update`,R2(e))),delete:e=>o(`tables.delete`,R2(e))},fields:{create:async e=>P2(await o(`fields.create`,R2(e))),update:async e=>P2(await o(`fields.update`,R2(e))),delete:e=>o(`fields.delete`,R2(e)),duplicate:async e=>P2(await o(`fields.duplicate`,R2(e))),linkCandidates:e=>o(`fields.linkCandidates`,R2(e))},views:{create:e=>o(`views.create`,R2(e)),update:e=>o(`views.update`,R2(e)),delete:e=>o(`views.delete`,R2(e)),listFields:e=>o(`views.listFields`,R2(e)),patchField:e=>o(`views.patchField`,R2(e))},records:{list:e=>o(`records.list`,R2(e)),create:e=>o(`records.create`,R2(e)),update:e=>o(`records.update`,R2(e)),delete:e=>o(`records.delete`,R2(e)),history:e=>o(`records.history`,R2(e)),bulkDelete:e=>o(`records.bulkDelete`,R2(e)),bulkCopy:e=>o(`records.bulkCopy`,R2(e))},links:{replace:e=>o(`links.replace`,R2(e))},transact:e=>o(`transact`,R2(e)),undo:()=>o(`undo`),redo:()=>o(`redo`),historyState:()=>o(`historyState`),dashboards:{list:()=>o(`dashboards.list`),upsert:({documentId:e,dashboardId:t,id:n,...r})=>o(`dashboards.upsert`,{...r,dashboardId:t})},attachments:{read:async({hash:e})=>{let t=await o(`attachments.read`,{hash:e});return{data:N2(t.data),mimeType:t.mimeType,name:t.name}},put:async({tableId:e,file:t})=>{let n=M2(new Uint8Array(await t.arrayBuffer()));return o(`attachments.put`,{tableId:e,name:t.name,mimeType:t.type,data:n})}},onChange(e,t){return n.add(t),()=>{n.delete(t)}},grid:{open:async t=>{let n=await e.invoke(`gridOpen`,JSON.stringify(t));return{...E2(n),bytes:n}},sync:async()=>{let t=await e.invoke(`gridSync`);return t.byteLength?{...E2(t),bytes:t}:null},hits:async t=>A2(await e.invoke(`gridHits`,JSON.stringify(t)),t.fieldIds),subscribe(e){return r.add(e),()=>{r.delete(e)}},layout:async({axis:t,...n})=>({axes:JSON.parse(await e.invoke(`gridAxes`,t,JSON.stringify(n))),rows:await e.invoke(`gridRows`)}),bands:(t,n,r,i,a)=>e.invoke(`gridBands`,t,n,r,i,a),records:async t=>JSON.parse(await e.invoke(`gridRecords`,JSON.stringify(t))),clear:async({ids:t,...n})=>{t.length&&(await e.invoke(`gridClear`,JSON.stringify(n),Float64Array.from(t)).catch(e=>{throw L2(e)}),await e.run(`table.historyState`,{},`all`),a=e.revision(),i())},summary:async t=>JSON.parse(await e.invoke(`gridSummary`,JSON.stringify(t))),picture:(t,n)=>e.invoke(`gridPicture`,t,n),fonts:e.fonts,opticalSizing:t=>e.invoke(`gridOpticalSizing`,t)},command:(e,t)=>o(e,t),observe(e){if(a===e)return;let t=a==null;a=e,t||(i(),l().catch(()=>c({type:`resync`})))},reopened(e){a=e,i(),c({type:`resync`})}}}function B2(){return{kitId:`kit.table`,base:new URL(`./engine/`,document.baseURI).href,module:`kition_table_kit`,documentClass:`TableDocument`,...ID(new URL(`./fonts/`,document.baseURI).href)}}function V2(e){let t=e.inspected;return{tables:t.tables??[],dashboards:t.dashboards??[],readOnly:t.readOnly??null}}function H2(e){let t=new Set(e.init.capabilities??[]),n=e.peer;return{generates:t.has(`generate`),acts:e=>t.has(`action:${e}`),generate:e=>n.request(`host/generate`,e,{transfer:!0}),action:(e,t)=>n.request(`host/action`,{id:e,params:t})}}var U2={"en-US":{openFailed:`The table could not be opened`}},W2=3;function G2(e){if(e?.aborted)throw new DOMException(`AI generation canceled`,`AbortError`)}async function K2(e,t,n){let r=Array(e.length),i=0;return await Promise.all(Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let t=i++;r[t]=await n(e[t])}})),r}function q2(e,t,n){async function r(t){if(t.type===`text`)return t;if(t.hash&&e.attachments){let n=await e.attachments.read({documentId:0,hash:t.hash}),r=n.data.buffer.slice(n.data.byteOffset,n.data.byteOffset+n.data.byteLength);return{type:`image`,mime:t.mime||n.mimeType||`application/octet-stream`,bytes:r}}return t.url&&/^https?:/i.test(t.url)?{type:`image`,url:t.url}:null}async function i(e,i,a){try{G2(a);let n=await Promise.all(i.messages.map(async e=>({role:e.role,parts:(await Promise.all(e.parts.map(r))).filter(e=>e!=null)})));G2(a);let o=()=>t.generate({purpose:`ai-field`,output:e.output,...e.model?{model:e.model}:{},messages:n,...i.options?{options:i.options}:{}});if(e.output===`image`){let e=Math.max(1,Math.min(5,Number(i.options?.count)||1)),t=[];for(let n=0;n<e;n+=1){G2(a);let e=await o();e.image&&t.push({mime:e.image.mime,content:M2(new Uint8Array(e.image.bytes))})}return t.length===0?{recordId:i.recordId,error:`The model answered no image.`}:{recordId:i.recordId,images:t}}let s=await o();return{recordId:i.recordId,text:s.text??``}}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)throw e;let t=e instanceof Error?e.message:`AI generation failed`;return e?.data?.reason===`unavailable`&&n?.(t),{recordId:i.recordId,error:t}}}async function a(t,n){let{tableId:r,fieldId:a,action:o}=t,s=await e.command(`ai.prepare`,{tableId:r,fieldId:a,record_ids:t.record_ids,...t.limit==null?{}:{limit:t.limit},action:o,config:t.config}),c=await K2(s.requests,W2,e=>i(s,e,n));return G2(n),e.command(`ai.apply`,{tableId:r,fieldId:a,action:o,results:c})}return{resolveRuntimeModel:async()=>void 0,loadModelOptions:async()=>[],async runCell({tableId:e,recordId:t,fieldId:n,action:r,config:i},o){let s=await a({tableId:e,fieldId:n,record_ids:[t],action:r,config:i},o?.signal);if(`record`in s)return s;let c=s.items.find(e=>e.record.id===t);if(!c){let e=s.errors?.find(e=>e.record_id===t);throw Error(e?.message||`AI generation failed`)}return{record:c.record,field:s.field,state:c.state}},runBatch:({tableId:e,fieldId:t,record_ids:n,limit:r,action:i,config:o},s)=>a({tableId:e,fieldId:t,record_ids:n,limit:r,action:i,config:o},s?.signal)}}var J2=/\.xls$/i;async function Y2(e){return{fileName:e.name,content:M2(new Uint8Array(await e.arrayBuffer()))}}function X2(e){let t=new WeakMap,n=e=>{let n=t.get(e);return n||t.set(e,n=Y2(e)),n};return{async prepare(t,r){if(J2.test(t.name))throw Error(`Legacy XLS files are not supported. Save the workbook as XLSX and try again.`);let i={source:{kind:`upload`,upload_name:t.name},...r?.sheet?{sheet:r.sheet}:{}};return{file:t,preview:await e.command(`import.preview`,{...i,...await n(t)})}},async execute({fieldTypes:t,prepared:r,target:i,writeMode:a}){let{preview:o}=r,s={import_token:o.import_token,target:i.kind===`existing_table`?{kind:`existing_table`,document_id:i.documentId,table_id:i.table.id}:{kind:`new_table`,document_id:i.documentId,table_title:i.tableTitle},write_mode:i.kind===`new_table`?`append`:a,schema_mode:`auto`,field_overrides:o.fields.map((e,n)=>({index:e.index,title:e.title,type:t[n]||e.type,options:e.options}))};return{result:await e.command(`import.run`,{...s,...await n(r.file)})}}}}var Z2=/^(https?:|data:|blob:)/i;async function Q2(e,t){try{let t=await e();return t.message&&El(t.done?`success`:`error`,t.message),t}catch(e){return El(`error`,t,e instanceof Error?e.message:void 0),{done:!1}}}function $2(e,t){return n=>{let r=e.acts(`settings.open`)?{label:t.aiSetUp,onClick:()=>void Q2(()=>e.action(`settings.open`,{section:`ai`}),t.settingsFailed)}:void 0;El.error(t.aiUnavailable,{id:`table-ai-unavailable`,description:n,...r?{action:r}:{}})}}function e4(e,t,n,r,i){return{exportTable:i,resolveFileURL:e=>Z2.test(e)?e:``,notify:{success:(e,t)=>El(`success`,e,t?.description),error:(e,t)=>El(`error`,e,t?.description),dismiss:()=>void 0},locale:()=>e,fileImport:X2(t),...n.generates?{ai:q2(t,n,$2(n,r))}:{},...n.acts(`design.fromRecord`)?{requestDesignFromRecord:({title:e,fields:t,record:i})=>{let a=i?{tableId:i.tableId,recordId:i.recordId,field:i.field}:void 0;Q2(()=>n.action(`design.fromRecord`,{title:e,fields:t,...a?{record:a}:{}}),r.designFailed)}}:{},...n.acts(`workflow.run`)?{runWorkflow:({workflowId:e,tableId:t,recordId:i})=>Q2(()=>n.action(`workflow.run`,{workflowId:e,tableId:t,recordId:i}),r.workflowFailed)}:{}}}var t4=`table.file.export`;function n4(e,t,n,r=null){let i=e.includes(`/`)?e.slice(0,e.lastIndexOf(`/`)+1):``,a=t||e.slice(e.lastIndexOf(`/`)+1),o=e=>e.replace(/[\\/:*?"<>|]/g,`_`).trim(),s=o(a.replace(/\.[^.]+$/,``))||`Table`,c=r?o(r):``;return`${i}${c?`${s} - ${c}`:s}.${n}`}function r4(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}function i4(e,t){let n=e?JSON.parse(e):null;if(!n||typeof n.data!=`string`||n.extension!==t)throw Error(`the engine answered no ${t===`md`?`Markdown`:`CSV`} file`);return n}async function a4(e,t,n,r,i){let a=i4(await e(t4,{format:n,tableId:r.id}),n),{path:o,name:s}=t.init.document;return t.exportFile(n4(o,s,a.extension,i>1?r.title:null),r4(a.data))}function o4(e){return new URL(e.replace(/^\/+/,``),document.baseURI).href}async function s4(e,t){let n=await fetch(o4(e),{signal:t});if(!n.ok)throw Error(`Template asset could not be loaded: ${e}`);return n}function c4(e){return!!(e&&typeof e==`object`&&!Array.isArray(e)&&Array.isArray(e.assetIds))}function l4(e){let t=new Set;for(let n of e)for(let e of Object.values(n))if(c4(e))for(let n of e.assetIds)t.add(n);return Array.from(t)}async function u4(e){let t=JSON.parse(await(await s4(e)).text());if(!Array.isArray(t.assets)||t.assetCount!==t.assets.length)throw Error(`Template asset manifest is invalid: ${e}`);return t}async function d4({manifest:e,assetIds:t,put:n}){let r=new Map(e.assets.map(e=>[e.id,e])),i=new Map;for(let e of t){let t=r.get(e);if(!t)throw Error(`Template asset is missing from the manifest: ${e}`);let a=await(await s4(t.path)).arrayBuffer();i.set(e,await n(new File([a],t.sourceName,{type:t.mimeType})))}return i}function f4(e,t){return c4(e)?e.assetIds.map(e=>{let n=t.get(e);if(!n)throw Error(`Template asset was not resolved: ${e}`);return n}):e}var p4=[{title:`Title`,type:`text`,primary:!0,required:!1},{title:`Status`,type:`single_select`,required:!1,options:{choices:[`Not started`,`In progress`,`Done`]}},{title:`Notes`,type:`long_text`,required:!1}],m4=[{title:`Grid view`,type:`grid`}],h4=3;function g4(e,t){let n=e;for(let r=2;t.has(n);r+=1)n=`${e} ${r}`;return t.add(n),n}function _4(e,t){let n=e;for(let r=2;t.has(n);r+=1)n=`${e}-${r}`;return t.add(n),n}function v4(e,t){return e.replace(/{{\s*([^{}]+?)\s*}}/g,(e,n)=>{let r=t.get(n.trim());return r?`{{${r.name}}}`:e})}async function y4(e,t,{template:n,table:r}){let i=new Map((r.fields||[]).map(e=>[e.title,e]));for(let a of n.fields){if(!a.aiConfig)continue;let n=i.get(a.title),o=a.aiConfig.sourceFieldTitle,s=o?i.get(o):void 0;if(!n?.id||o&&!s?.id)throw Error(`Template AI field could not be configured: ${a.title}`);let{sourceFieldTitle:c,...l}=a.aiConfig,u={...l,...`prompt`in l?{prompt:v4(l.prompt,i)}:{},...s?.id?{source_field_id:s.id}:{}};await e.fields.update({documentId:t,tableId:r.id,fieldId:n.id,options:{...n.options||{},ai_config:u}})}}async function b4(e,t,{template:n,table:r}){let i=new Map((r.fields||[]).map(e=>[e.title,e])),a=new Map((r.views||[]).map(e=>[e.title,e]));for(let o of n.views){let n=a.get(o.title);if(!n?.id)continue;let s=(o.hiddenFieldTitles||[]).map(e=>{let t=i.get(e);if(!t)throw Error(`Template view field could not be configured: ${e}`);return t.name});if((o.config||s.length)&&await e.views.update({documentId:t,tableId:r.id,viewId:n.id,config:{...n.config||{},...o.config||{},...s.length?{hidden_field_names:s}:{}}}),o.fieldLayouts?.length)for(let{fieldTitle:a,...s}of o.fieldLayouts){let o=i.get(a);if(!o?.id)throw Error(`Template view field could not be configured: ${a}`);await e.views.patchField({documentId:t,tableId:r.id,viewId:n.id,fieldId:o.id,...s})}}}async function x4(e,t,n,r){let{template:i,table:a}=n,o=new Map((a.fields||[]).map(e=>[e.title,e.name])),s=l4(i.records);if(s.length&&!r.assetManifestPath)throw Error(`Template asset manifest was not configured: ${r.id}`);let c=s.length&&r.assetManifestPath&&e.attachments?await d4({manifest:await u4(r.assetManifestPath),assetIds:s,put:n=>e.attachments.put({documentId:t,tableId:a.id,file:n})}):new Map;for(let n of i.records){let r=Object.fromEntries(Object.entries(n).flatMap(([t,n])=>{let r=o.get(t);return!r||!e.attachments&&typeof n==`object`&&n&&`assetIds`in n?[]:[[r,f4(n,c)]]}));await e.records.create({documentId:t,tableId:a.id,values:r})}}async function S4(e,t,n){let r=t.id,i=new Set((t.tables||[]).map(e=>e.title));if(!n){let t=await e.tables.create({documentId:r,title:g4(`Table`,i),fields:p4,views:m4});for(let n=0;n<h4;n+=1)await e.records.create({documentId:r,tableId:t.id,values:{}});return t.id}let a=[];for(let t of n.tables){let{records:n,fields:o,views:s,title:c,description:l}=t,u=await e.tables.create({documentId:r,title:g4(c,i),description:l,fields:o.map(({aiConfig:e,...t})=>({...t,required:!1})),views:s.map(({hiddenFieldTitles:e,fieldLayouts:t,...n})=>n)});a.push({template:t,table:u})}for(let t of a)await y4(e,r,t),await b4(e,r,t),n.snapshot.includeData&&await x4(e,r,t,n);if(n.dashboards?.length){let i={...t,tables:a.map(({template:e,table:t})=>({...t,title:e.title}))},o=new Set((await e.dashboards.list({documentId:r})).items.map(e=>e.id));for(let t of hC(i,n.dashboards)){let n=_4(t.id,o);await e.dashboards.upsert({documentId:r,...t,id:n,dashboardId:n})}}return a[0].table.id}var C4=`Create an original, photorealistic industrial-design orthographic presentation of the exact product shown in the attached reference designs.
94
-
95
- Product: {{Concept}}
96
- Brief: {{Concept description}}
97
-
98
- Preserve the same product geometry, materials, colors, controls, and proportions. Show front, side, rear, and top views aligned on a clean warm-white studio background with consistent scale and neutral lighting. Add only faint construction guide lines; no dimensions, labels, logos, or decorative text.`,w4=`Create an original commercial feature image of the exact product shown in the attached reference designs.
99
-
100
- Product: {{Concept}}
101
- Brief: {{Concept description}}
102
-
103
- Use one premium three-quarter product hero shot on a light neutral background. Surround it with three restrained visual callouts using simple icons and thin leader lines that communicate the product's most important functions. Do not render words, labels, logos, trademarks, or watermarks. Preserve the reference product exactly.`,T4=`Create an original photorealistic lifestyle campaign image featuring the exact product shown in the attached reference designs.
104
-
105
- Product: {{Concept}}
106
- Brief: {{Concept description}}
107
-
108
- Choose a believable everyday setting where this product is naturally useful. Show a person interacting with it in a relaxed, unscripted way, while keeping the product clearly visible and consistent with the reference. Natural daylight, realistic materials and skin texture, balanced commercial composition, no logos, no text, no watermark.`,E4=`Create an original four-panel product style board for the exact product shown in the attached reference designs.
109
-
110
- Product: {{Concept}}
111
- Brief: {{Concept description}}
112
-
113
- Panel 1: clean hero view. Panel 2: close material and control detail. Panel 3: compact lifestyle context. Panel 4: packaging-ready still life with complementary materials. Keep the same product geometry, colors, and materials in every panel. Clean editorial grid, light neutral background, no labels, no logos, no text, no watermark.`,D4=`Act as a product launch editor. Write one clear LinkedIn post for {{Concept}} using this brief: {{Concept description}}.
114
-
115
- Explain the practical user benefit, mention two concrete design details, and close with a concise product point of view. Keep it natural, original, and below 400 characters. Do not use hashtags, invented claims, or placeholder branding. Return only the finished post.`,O4=`Write one original short-form launch post for {{Concept}} using this brief: {{Concept description}}.
116
-
117
- Lead with the user benefit, mention two concrete product details, and keep the full post below 280 characters. Use plain English and restrained line breaks. Do not use hashtags, placeholder branding, or more than one emoji. Return only the finished post.`,k4=(...e)=>({assetIds:e}),A4=[{fieldTitle:`Concept`,position:0,width:180,frozen:!0},{fieldTitle:`Concept description`,position:1,width:300},{fieldTitle:`Designs`,position:2,width:420},{fieldTitle:`Orthographic views`,position:3,width:280},{fieldTitle:`Feature image`,position:4,width:280},{fieldTitle:`Lifestyle shot`,position:5,width:280},{fieldTitle:`Style board`,position:6,width:280},{fieldTitle:`LinkedIn copy`,position:7,width:280},{fieldTitle:`Twitter copy`,position:8,width:280}];function j4(e){return{id:`batch-product-designer`,title:e(`templateLibrary.templates.batchProductDesigner.title`),description:e(`templateLibrary.templates.batchProductDesigner.description`),documentDescription:`Turn original product concepts into consistent design studies, campaign imagery, and launch copy.`,icon:`palette`,color:`amber`,assetManifestPath:`templates/batch-product-designer/manifest.json`,tables:[{title:`Product Concepts`,description:`Original product briefs, generated design assets, campaign imagery, and social copy.`,fields:[{title:`Concept`,name:`concept`,type:`long_text`,primary:!0},{title:`Concept description`,name:`concept_description`,type:`long_text`},{title:`Designs`,name:`designs`,type:`attachment`,aiConfig:{type:`image_generation`,sourceFieldTitle:`Concept description`,enabled:!0,auto_update:!0,n:2,quality:`high`,aspect_ratio:`4:3`,resolution:`1K`,image_use_case:`product_showcase`}},{title:`Orthographic views`,name:`orthographic_views`,type:`attachment`,aiConfig:{type:`image_customization`,sourceFieldTitle:`Designs`,prompt:C4,enabled:!0,auto_update:!0,n:1,quality:`high`,aspect_ratio:`16:9`,resolution:`1K`,image_use_case:`product_showcase`}},{title:`Feature image`,name:`feature_image`,type:`attachment`,aiConfig:{type:`image_customization`,sourceFieldTitle:`Designs`,prompt:w4,enabled:!0,auto_update:!0,n:1,quality:`high`,aspect_ratio:`16:9`,resolution:`1K`,image_use_case:`infographic_diagram`}},{title:`Lifestyle shot`,name:`lifestyle_shot`,type:`attachment`,aiConfig:{type:`image_customization`,sourceFieldTitle:`Designs`,prompt:T4,enabled:!0,auto_update:!0,n:1,quality:`high`,aspect_ratio:`16:9`,resolution:`1K`,image_use_case:`product_showcase`}},{title:`Style board`,name:`style_board`,type:`attachment`,aiConfig:{type:`image_customization`,sourceFieldTitle:`Designs`,prompt:E4,enabled:!0,auto_update:!0,n:1,quality:`high`,aspect_ratio:`16:9`,resolution:`1K`,image_use_case:`product_showcase`}},{title:`LinkedIn copy`,name:`linkedin_copy`,type:`long_text`,aiConfig:{type:`customize`,prompt:D4,enabled:!0,auto_update:!0}},{title:`Twitter copy`,name:`twitter_copy`,type:`long_text`,aiConfig:{type:`customize`,prompt:O4,enabled:!0,auto_update:!0}}],views:[{title:`Grid View`,type:`grid`,config:{row_height:`extra_tall`,frozen_column_count:1},fieldLayouts:A4}],records:[{Concept:`HaloFold Reading Light`,"Concept description":`A portable fold-flat reading lamp built from recycled aluminum. A slim oval light frame pivots around a compact hinge, with warm diffused LEDs, a pebble-gray body, one restrained violet hinge accent, USB-C charging, and a soft-touch base. Clean, quiet, repairable, and designed for bedside reading or travel. No visible branding or text.`,Designs:k4(`record-01-design-01`,`record-01-design-02`),"Orthographic views":k4(`record-01-orthographic-views-01`),"Feature image":k4(`record-01-feature-image-01`),"Lifestyle shot":k4(`record-01-lifestyle-shot-01`),"Style board":k4(`record-01-style-board-01`),"LinkedIn copy":`Meet HaloFold: a recycled-aluminum reading light that folds flat for travel, opens into a warm focused glow, and keeps bedside spaces calm. A tactile hinge, USB-C charging, and repairable construction make quiet design genuinely useful.`,"Twitter copy":`A reading light that folds flat.
118
-
119
- Warm diffused glow, recycled aluminum, tactile hinge, USB-C power. HaloFold is made for calm desks, bedside reading, and travel bags.`},{Concept:`MossDrop Indoor Garden`,"Concept description":`A compact countertop herb garden with four modular hexagonal planting pods. Fog-white recycled plastic shell, removable sage-green grow trays, hidden water reservoir, gentle full-spectrum light arch, and tiny amber status indicators. Friendly domestic design for apartments, with no screen, logo, or decorative text.`,Designs:k4(`record-02-design-01`,`record-02-design-02`),"Orthographic views":k4(`record-02-orthographic-views-01`),"Feature image":k4(`record-02-feature-image-01`),"Lifestyle shot":k4(`record-02-lifestyle-shot-01`),"Style board":k4(`record-02-style-board-01`),"LinkedIn copy":`MossDrop brings a small edible garden to the kitchen counter. Four modular pods, a hidden reservoir, and a gentle light arch make growing herbs approachable without adding another screen to the home.`,"Twitter copy":`Four herb pods. One quiet countertop garden.
120
-
121
- MossDrop uses a hidden reservoir and gentle grow light to make fresh herbs easy in small homes.`},{Concept:`DriftPod Travel Speaker`,"Concept description":`A palm-sized waterproof travel speaker shaped like a softly rounded triangular pebble. Deep plum recycled-aluminum mesh, sand-colored silicone edge, integrated woven carry loop, three tactile top buttons, and a subtle warm-white status line. Rugged but refined, with no logo or text.`,Designs:k4(`record-03-design-01`,`record-03-design-02`),"Orthographic views":k4(`record-03-orthographic-views-01`),"Feature image":k4(`record-03-feature-image-01`),"Lifestyle shot":k4(`record-03-lifestyle-shot-01`),"Style board":k4(`record-03-style-board-01`),"LinkedIn copy":`DriftPod is a travel speaker designed around the moments between destinations: compact, waterproof, easy to clip onto a bag, and tactile enough to use without looking at a screen.`,"Twitter copy":`Pocket-sized sound for the road.
122
-
123
- DriftPod pairs recycled aluminum, a waterproof shell, tactile controls, and a built-in carry loop.`},{Concept:`QuietKey Focus Timer`,"Concept description":`A compact desktop focus timer with an ivory ceramic-like body, rotating brushed-aluminum dial, circular monochrome e-ink display, one small violet progress marker, and silent tactile controls. Minimal, distraction-free, softly rounded, and designed for deep work. No logo or extra text.`,Designs:k4(`record-04-design-01`,`record-04-design-02`),"Orthographic views":k4(`record-04-orthographic-views-01`),"Feature image":k4(`record-04-feature-image-01`),"Lifestyle shot":k4(`record-04-lifestyle-shot-01`),"Style board":k4(`record-04-style-board-01`),"LinkedIn copy":`QuietKey turns focus into a physical ritual. Rotate the aluminum dial, set a session on the e-ink display, and work without notifications, glowing dashboards, or another app competing for attention.`,"Twitter copy":`Turn the dial. Start the session.
124
-
125
- QuietKey is a silent e-ink focus timer with tactile controls and zero notifications.`},{Concept:`BrewFold Tea Bottle`,"Concept description":`A double-wall glass tea bottle with a collapsible terracotta silicone sleeve, magnetic stainless-steel infuser cap, removable fine-mesh basket, and flexible carry loop. The sleeve expands for grip and folds flat for storage. Warm, practical travel design with no logo or printed text.`,Designs:k4(`record-05-design-01`,`record-05-design-02`),"Orthographic views":k4(`record-05-orthographic-views-01`),"Feature image":k4(`record-05-feature-image-01`),"Lifestyle shot":k4(`record-05-lifestyle-shot-01`),"Style board":k4(`record-05-style-board-01`),"LinkedIn copy":`BrewFold makes loose-leaf tea easier to carry. Its protective silicone sleeve expands for grip, folds down for storage, and pairs with a magnetic infuser cap for a cleaner travel ritual.`,"Twitter copy":`Loose-leaf tea, packed smaller.
126
-
127
- BrewFold combines double-wall glass, a magnetic infuser, and a protective sleeve that collapses for travel.`}]}]}}var M4={title:`Grid`,type:`grid`};function N4(e){let t=`${e.id}-table`;return{id:e.id,title:e.title,description:e.description,documentDescription:e.description,coverImage:`templates/table-covers/${e.id}.webp`,icon:e.icon,color:e.color,categories:e.categories,snapshot:{version:1,includeData:!0,defaultResourceId:t,resources:[{id:t,kind:`table`,title:e.tableTitle,description:e.description,tableTitle:e.tableTitle}]},tables:[{title:e.tableTitle,description:e.description,fields:e.fields,views:e.views||[M4],records:e.records}]}}function P4(){return[N4({id:`business-analytics-dashboard`,title:`Business Analytics Dashboard`,description:`Monitor revenue, cost, margin, and collection performance by period.`,categories:[`business`],icon:`chart-no-axes-combined`,color:`sky`,tableTitle:`Business Metrics`,fields:[{title:`Period`,type:`text`,primary:!0},{title:`Revenue`,type:`number`},{title:`Cost`,type:`number`},{title:`Gross margin`,type:`number`},{title:`Cash collected`,type:`number`},{title:`Open receivables`,type:`number`},{title:`Owner`,type:`text`}],records:[{Period:`2026 Q1`,Revenue:48e4,Cost:292e3,"Gross margin":39.2,"Cash collected":451e3,"Open receivables":29e3,Owner:`Finance`},{Period:`2026 Q2`,Revenue:552e3,Cost:318e3,"Gross margin":42.4,"Cash collected":519e3,"Open receivables":33e3,Owner:`Finance`},{Period:`2026 Q3 Forecast`,Revenue:621e3,Cost:354e3,"Gross margin":43,"Cash collected":57e4,"Open receivables":51e3,Owner:`Operations`}]}),N4({id:`project-gantt`,title:`Project Gantt Planner`,description:`Plan project tasks, dependencies, ownership, and delivery dates.`,categories:[`projects`],icon:`gantt-chart`,color:`violet`,tableTitle:`Project Plan`,fields:[{title:`Task`,type:`text`,primary:!0},{title:`Workstream`,type:`single_select`,options:{choices:[`Design`,`Engineering`,`Launch`,`Research`]}},{title:`Owner`,type:`text`},{title:`Start date`,type:`date`},{title:`End date`,type:`date`},{title:`Progress`,type:`number`},{title:`Status`,type:`single_select`,options:{choices:[`Not started`,`In progress`,`Blocked`,`Done`]}},{title:`Dependency`,type:`text`}],views:[M4,{title:`Timeline`,type:`calendar`},{title:`Status board`,type:`kanban`}],records:[{Task:`Customer research synthesis`,Workstream:`Research`,Owner:`Maya Chen`,"Start date":`2026-07-20`,"End date":`2026-07-29`,Progress:90,Status:`In progress`},{Task:`Interaction design`,Workstream:`Design`,Owner:`Sofia Rivera`,"Start date":`2026-07-27`,"End date":`2026-08-07`,Progress:35,Status:`In progress`,Dependency:`Customer research synthesis`},{Task:`Frontend implementation`,Workstream:`Engineering`,Owner:`Eli Brooks`,"Start date":`2026-08-03`,"End date":`2026-08-17`,Progress:0,Status:`Not started`,Dependency:`Interaction design`}]})]}var F4=[{record:1,fileName:`hearth-and-grain-bakery.jpg`,vendor:`HEARTH & GRAIN BAKERY`,addressLines:[`88 Tamarind Walk #01-04`,`Singapore 438912`],category:`Food`,currency:`SGD`,symbol:`S$`,date:`2026-07-14`,time:`09:42`,payment:`NETS`,items:[{description:`Bread flour 2 kg`,quantity:1,unitPrice:8.9},{description:`Wholemeal flour 1 kg`,quantity:1,unitPrice:6.4},{description:`Sourdough loaf`,quantity:1,unitPrice:7.5}],subtotal:22.8,tax:1.88,taxLabel:`GST 9% included`,taxIncluded:!0,total:22.8,width:1024,height:1536,scene:`linen`},{record:2,fileName:`lantern-row-bistro.jpg`,vendor:`LANTERN ROW BISTRO`,addressLines:[`240 Harbor Steps`,`Bayview, CA 94999`],category:`Food`,currency:`USD`,symbol:`$`,date:`2026-07-18`,time:`20:15`,payment:`Visa ending 4417`,items:[{description:`Dinner tasting menu`,quantity:1,unitPrice:85},{description:`Sparkling water`,quantity:1,unitPrice:8}],subtotal:93,tax:8.02,taxLabel:`Sales tax 8.625%`,taxIncluded:!1,total:101.02,width:1024,height:1536,scene:`walnut`},{record:3,fileName:`cirruslane-invoice.png`,vendor:`Cirruslane Software, LLC`,addressLines:[`1200 Byte Avenue, Suite 400`,`Bayview, CA 94999`],category:`Software`,currency:`USD`,symbol:`$`,date:`2026-07-01`,time:``,payment:`Card on file`,items:[{description:`Cloud AI usage`,quantity:1,unitPrice:48},{description:`Service credits`,quantity:1,unitPrice:20}],subtotal:68,tax:0,taxLabel:`Tax`,taxIncluded:!1,total:68,width:1024,height:1536,scene:`desk`,style:`invoice`},{record:4,fileName:`greencrate-market.jpg`,vendor:`GreenCrate Market`,addressLines:[`17 Orchard Loop`,`Fernhill, WA 98999`],category:`Food`,currency:`USD`,symbol:`$`,date:`2026-07-21`,time:`17:08`,payment:`Debit`,items:[{description:`Fresh produce`,quantity:1,unitPrice:24.5},{description:`Rice 5 kg`,quantity:1,unitPrice:18.9},{description:`Kitchen supplies`,quantity:1,unitPrice:12.4}],subtotal:55.8,tax:4.46,taxLabel:`Sales tax 8%`,taxIncluded:!1,total:60.26,width:1024,height:1536,scene:`produce`},{record:5,fileName:`birch-and-bun-burgers.jpg`,vendor:`Birch & Bun Burgers`,addressLines:[`903 Copper Mill Road`,`Easton Hollow, NY 10999`],category:`Food`,currency:`USD`,symbol:`$`,date:`2026-07-22`,time:`12:31`,payment:`Cash`,items:[{description:`Quarter burger meal`,quantity:1,unitPrice:11.49},{description:`Apple turnover`,quantity:1,unitPrice:1.89}],subtotal:13.38,tax:1.19,taxLabel:`Sales tax 8.875%`,taxIncluded:!1,total:14.57,width:1024,height:1536,scene:`tray`},{record:6,fileName:`tallpine-fuel.webp`,vendor:`TALLPINE FUEL 72`,addressLines:[`1510 Cedar Bend Road`,`Riverton, OR 97999`],category:`Fuel`,currency:`USD`,symbol:`$`,date:`2026-07-24`,time:`07:55`,payment:`Visa ending 2093`,items:[{description:`Regular fuel 9.82 gal`,quantity:1,unitPrice:39.18},{description:`Car wash`,quantity:1,unitPrice:10}],subtotal:49.18,tax:0,taxLabel:`Tax`,taxIncluded:!1,total:49.18,width:1024,height:1536,scene:`dashboard`},{record:7,fileName:`benchmark-hardware.jpg`,vendor:`Benchmark Hardware Co.`,addressLines:[`77 Quarry Lane`,`Elmsford, ON L0X 9Z9`],category:`Others`,currency:`CAD`,symbol:`C$`,date:`2026-07-25`,time:`10:20`,payment:`Mastercard ending 5521`,items:[{description:`LED work light`,quantity:1,unitPrice:39.98},{description:`Utility gloves`,quantity:1,unitPrice:14.97},{description:`Wood screws 100 pk`,quantity:1,unitPrice:12.5}],subtotal:67.45,tax:8.77,taxLabel:`HST 13%`,taxIncluded:!1,total:76.22,width:1024,height:1536,scene:`plywood`},{record:8,fileName:`morning-harbor-coffee.jpg`,vendor:`Morning Harbor Coffee`,addressLines:[`44 Pier Road`,`Gull Point, CA 95999`],category:`Food`,currency:`USD`,symbol:`$`,date:`2026-07-27`,time:`08:03`,payment:`Apple Pay`,items:[{description:`Caffe latte, large`,quantity:1,unitPrice:5.45},{description:`Blueberry muffin`,quantity:1,unitPrice:3.65}],subtotal:9.1,tax:.82,taxLabel:`Sales tax 9%`,taxIncluded:!1,total:9.92,width:1024,height:1536,scene:`marble`},{record:9,fileName:`suncrest-station.jpg`,vendor:`SUNCREST STATION`,addressLines:[`6101 Meadowlark Boulevard`,`Sierra Vista Park, CA 90999`],category:`Fuel`,currency:`USD`,symbol:`$`,date:`2026-07-28`,time:`18:47`,payment:`Visa ending 7730`,items:[{description:`Premium fuel 10.24 gal`,quantity:1,unitPrice:49.87},{description:`Bottled water`,quantity:1,unitPrice:2.49}],subtotal:52.36,tax:.24,taxLabel:`Sales tax`,taxIncluded:!1,total:52.6,width:1536,height:1024,scene:`console`},{record:10,fileName:`redrock-gasoline.jpg`,vendor:`REDROCK GASOLINE`,addressLines:[`2211 Canyon Rim Street`,`Mesa Flats, CA 90999`],category:`Fuel`,currency:`USD`,symbol:`$`,date:`2026-07-30`,time:`16:12`,payment:`Debit`,items:[{description:`Regular fuel 8.76 gal`,quantity:1,unitPrice:38.46},{description:`Windshield fluid`,quantity:1,unitPrice:5.99}],subtotal:44.45,tax:.57,taxLabel:`Sales tax`,taxIncluded:!1,total:45.02,width:1024,height:1536,scene:`concrete`}],I4=(e,t)=>`${e.symbol}${t.toFixed(2)}`;function L4(e){return[e.vendor,...e.addressLines,[e.date,e.time].filter(Boolean).join(` `),...e.items.map(t=>`${t.description} ${I4(e,t.quantity*t.unitPrice)}`),`Subtotal ${I4(e,e.subtotal)}`,`${e.taxLabel} ${I4(e,e.tax)}`,`TOTAL ${I4(e,e.total)}`,e.payment]}function R4(e){let t=e.addressLines.join(`, `);return{"File Name":e.fileName,"Receipt Image":z4(e.record),"Vendor Name":e.vendor,Address:t,Category:e.category,"Structured Data":JSON.stringify({merchant_name:e.vendor,address:t,receipt_date:e.date,currency:e.currency,subtotal:e.subtotal,tax:e.tax,total:e.total,payment_method:e.payment,line_items:e.items.map(e=>({description:e.description,quantity:e.quantity,unit_price:e.unitPrice,amount:Number((e.quantity*e.unitPrice).toFixed(2))}))}),"Plain Text":L4(e).join(`
128
- `)}}function z4(e){return{assetIds:[`${`record-${String(e).padStart(2,`0`)}`}-receipt-image`]}}var B4=JSON.stringify({type:`string`,description:`The merchant or vendor name only. Preserve the official capitalization visible on the receipt.`}),V4=JSON.stringify({type:`string`,description:`The merchant street address only. Include city, region, postal code, and country when visible.`}),H4=JSON.stringify({merchant_name:`string or null`,address:`string or null`,receipt_date:`ISO 8601 date string or null`,currency:`ISO 4217 currency code or null`,subtotal:`number or null`,tax:`number or null`,total:`number or null`,payment_method:`string or null`,line_items:[{description:`string`,quantity:`number or null`,unit_price:`number or null`,amount:`number or null`}]}),U4=JSON.stringify({type:`string`,description:`Every visible receipt line in reading order. Preserve line breaks and do not add commentary.`});function W4(e){return{id:`receipt-ocr-database`,title:e(`templateLibrary.templates.receiptOcrDatabase.title`),description:e(`templateLibrary.templates.receiptOcrDatabase.description`),documentDescription:`Upload receipt images and convert them into searchable fields, structured JSON, and plain OCR text.`,icon:`receipt-text`,color:`violet`,assetManifestPath:`templates/receipt-ocr-database/manifest.json`,tables:[{title:`Receipts`,description:`Receipt images with vision-based extraction for vendor details, categories, JSON, and plain text.`,fields:[{title:`File Name`,type:`text`,primary:!0},{title:`Receipt Image`,type:`attachment`},{title:`Vendor Name`,type:`text`,aiConfig:{type:`extract`,sourceFieldTitle:`Receipt Image`,schema:B4,enabled:!0,auto_update:!0}},{title:`Address`,type:`text`,aiConfig:{type:`extract`,sourceFieldTitle:`Receipt Image`,schema:V4,enabled:!0,auto_update:!0}},{title:`Category`,type:`text`,aiConfig:{type:`classify`,sourceFieldTitle:`Receipt Image`,categories:[`Food`,`Fuel`,`Software`,`Travel`,`Office supplies`,`Healthcare`,`Others`],enabled:!0,auto_update:!0}},{title:`Structured Data`,type:`long_text`,aiConfig:{type:`extract`,sourceFieldTitle:`Receipt Image`,schema:H4,enabled:!0,auto_update:!0}},{title:`Plain Text`,type:`long_text`,aiConfig:{type:`extract`,sourceFieldTitle:`Receipt Image`,schema:U4,enabled:!0,auto_update:!0}}],views:[{title:`Overall`,type:`grid`,config:{row_height:`tall`,frozen_column_count:1},fieldLayouts:[{fieldTitle:`File Name`,position:0,width:220,frozen:!0},{fieldTitle:`Receipt Image`,position:1,width:160},{fieldTitle:`Vendor Name`,position:2,width:210},{fieldTitle:`Address`,position:3,width:260},{fieldTitle:`Category`,position:4,width:150},{fieldTitle:`Structured Data`,position:5,width:360},{fieldTitle:`Plain Text`,position:6,width:360}]}],records:F4.map(R4)}]}}function G4(e){return{id:`task-tracker`,title:e(`templateLibrary.templates.taskTracker.title`),description:e(`templateLibrary.templates.taskTracker.description`),documentDescription:`Track delivery progress, ownership, important work, and completion dates.`,icon:`check-square`,color:`violet`,tables:[{title:`Task Management`,description:`Task delivery details, ownership, progress, dates, and status updates.`,fields:[{title:`Task Description`,name:`task_description`,type:`text`,primary:!0},{title:`Task Summary`,name:`task_summary`,type:`text`},{title:`Assignee`,name:`assignee`,type:`text`},{title:`Progress`,name:`progress`,type:`single_select`,options:{choices:[`Completed`,`In Progress`,`Not Started`]}},{title:`Start Date`,name:`start_date`,type:`date`,options:{date_format:`year_month_day_dash`}},{title:`Expected Completion Date`,name:`expected_completion_date`,type:`date`,options:{date_format:`year_month_day_dash`}},{title:`Actual Completion Date`,name:`actual_completion_date`,type:`date`,options:{date_format:`year_month_day_dash`}},{title:`Important`,name:`important`,type:`checkbox`},{title:`Latest Progress Update`,name:`latest_progress_update`,type:`text`},{title:`Notes`,name:`notes`,type:`text`}],views:[{title:`Grid view`,type:`grid`,config:{group_field_name:`progress`,group_items:[{field_name:`progress`,direction:`asc`}],frozen_column_count:1}}],records:[{"Task Description":`User Requirement Research`,"Task Summary":`Collect and analyze user feedback`,Assignee:`Michael`,Progress:`In Progress`,"Start Date":`2024-11-01`,"Expected Completion Date":`2024-11-10`,"Actual Completion Date":`2024-11-08`,Important:!0,"Latest Progress Update":`Completed survey analysis and submitted report`,Notes:`Sync results with marketing team`},{"Task Description":`Product Feature Design`,"Task Summary":`Design core product feature prototype`,Assignee:`Sarah`,Progress:`In Progress`,"Start Date":`2024-11-05`,"Expected Completion Date":`2024-11-15`,"Actual Completion Date":`2024-11-14`,"Latest Progress Update":`Prototype passed internal review`,Notes:`Prepare for user testing`},{"Task Description":`Frontend UI Development`,"Task Summary":`Develop homepage and login UI`,Assignee:`James`,Progress:`In Progress`,"Start Date":`2024-11-10`,"Expected Completion Date":`2025-12-17`,Important:!0,"Latest Progress Update":`Homepage 90% done`,Notes:`Important and urgent`},{"Task Description":`Backend API Development`,"Task Summary":`Develop registration and login APIs`,Assignee:`David`,Progress:`Completed`,"Start Date":`2024-11-08`,"Expected Completion Date":`2024-11-20`,"Actual Completion Date":`2024-11-18`,Important:!0,"Latest Progress Update":`APIs deployed to test environment`,Notes:`Coordinate with frontend for testing`},{"Task Description":`Database Design`,"Task Summary":`Design user data table structure`,Assignee:`Sophia`,Progress:`Completed`,"Start Date":`2024-11-03`,"Expected Completion Date":`2024-11-12`,"Actual Completion Date":`2024-11-10`,"Latest Progress Update":`Table structure designed and approved`,Notes:`Optimize query performance later`},{"Task Description":`User Testing Plan`,"Task Summary":`Create test plan and cases`,Assignee:`Jessica`,Progress:`In Progress`,"Start Date":`2024-11-15`,"Expected Completion Date":`2024-11-28`,Important:!0,"Latest Progress Update":`Test cases 50% complete`,Notes:`Speed up to meet launch timeline`},{"Task Description":`Competitor Analysis`,"Task Summary":`Analyze main competitor products`,Assignee:`Nicole`,Progress:`Completed`,"Start Date":`2024-11-02`,"Expected Completion Date":`2024-11-09`,"Actual Completion Date":`2024-11-10`,"Latest Progress Update":`Submitted competitor analysis report`,Notes:`Discuss differentiation with product team`},{"Task Description":`Product Logo Design`,"Task Summary":`Design company and product logo`,Assignee:`Alex`,Progress:`Completed`,"Start Date":`2024-11-06`,"Expected Completion Date":`2024-11-13`,"Actual Completion Date":`2024-11-12`,Important:!0,"Latest Progress Update":`Logo finalized and delivered`,Notes:`Register trademark`},{"Task Description":`Security Testing`,"Task Summary":`Test system for security vulnerabilities`,Assignee:`Nicole`,Progress:`In Progress`,"Start Date":`2024-11-20`,"Expected Completion Date":`2024-12-03`,"Latest Progress Update":`Initial scan done`,Notes:`Important and urgent`},{"Task Description":`Payment Function Integration`,"Task Summary":`Integrate third-party payment gateway`,Assignee:`Sophia`,Progress:`In Progress`,"Start Date":`2024-11-12`,"Expected Completion Date":`2025-12-30`,Important:!0,"Latest Progress Update":`Payment integration 70% done`,Notes:`Test various payment scenarios`},{"Task Description":`Product Launch Preparation`,"Task Summary":`Prepare server and domain setup`,Assignee:`Sophia`,Progress:`Not Started`,"Start Date":`2024-11-25`,"Expected Completion Date":`2026-01-21`,"Latest Progress Update":`Prepare to purchase cloud services`,Notes:`Contact vendor in advance`},{"Task Description":`Mobile Adaptation`,"Task Summary":`Adapt UI for iOS and Android`,Assignee:`Matthew`,Progress:`In Progress`,"Start Date":`2024-11-18`,"Expected Completion Date":`2025-12-31`,"Latest Progress Update":`iOS adaptation 80% done`,Notes:`Important but not urgent`},{"Task Description":`User Manual Writing`,"Task Summary":`Write product user guide`,Assignee:`Lisa`,Progress:`Not Started`,"Start Date":`2024-11-28`,"Expected Completion Date":`2024-12-15`,"Latest Progress Update":`Plan to start next week`,Notes:`Confirm features with PM`},{"Task Description":`Data Analytics Development`,"Task Summary":`Develop user behavior analytics module`,Assignee:`Matthew`,Progress:`In Progress`,"Start Date":`2024-11-15`,"Expected Completion Date":`2024-12-01`,"Latest Progress Update":`Module 60% complete`,Notes:`Sync data interface with backend`},{"Task Description":`Internal Testing`,"Task Summary":`Test all product features`,Assignee:`Nicole`,Progress:`Completed`,"Start Date":`2024-11-22`,"Expected Completion Date":`2024-12-08`,"Actual Completion Date":`2024-12-09`,Important:!0,"Latest Progress Update":`Testing 30% done`,Notes:`Important and urgent`},{"Task Description":`Promotional Video Creation`,"Task Summary":`Create product promo video`,Assignee:`Nicole`,Progress:`Completed`,"Start Date":`2024-11-07`,"Expected Completion Date":`2024-11-16`,"Actual Completion Date":`2024-11-15`,Important:!0,"Latest Progress Update":`Video uploaded to cloud`,Notes:`Submit to marketing team`},{"Task Description":`Social Media Promotion Plan`,"Task Summary":`Plan promotion strategy and content`,Assignee:`Amanda`,Progress:`Not Started`,"Start Date":`2024-11-30`,"Expected Completion Date":`2025-12-31`,"Latest Progress Update":`Draft prepared`,Notes:`Coordinate materials with designer`},{"Task Description":`Customer Support System Setup`,"Task Summary":`Set up online support system`,Assignee:`Robert`,Progress:`Not Started`,"Start Date":`2024-12-01`,"Expected Completion Date":`2026-01-07`,"Latest Progress Update":`Plan to use third-party tool`,Notes:`Evaluate tool costs`},{"Task Description":`Product Iteration Planning`,"Task Summary":`Plan next version features`,Assignee:`Nicole`,Progress:`In Progress`,"Start Date":`2024-11-25`,"Expected Completion Date":`2024-12-15`,"Latest Progress Update":`Collecting user feedback`,Notes:`Brainstorm with team`},{"Task Description":`Funding Pitch Preparation`,"Task Summary":`Prepare PPT for investors`,Assignee:`Sophia`,Progress:`Completed`,"Start Date":`2024-11-10`,"Expected Completion Date":`2024-11-18`,"Actual Completion Date":`2024-11-17`,"Latest Progress Update":`PPT completed and approved`,Notes:`Practice presentation`}]}],dashboards:[{id:`task-dashboard`,title:`Task Dashboard`,order:0,source_table_name:`Task Management`,layout:[{widget_id:`total-tasks`,x:0,y:0,w:3,h:2,min_w:2,min_h:2},{widget_id:`completed-tasks`,x:3,y:0,w:3,h:2,min_w:2,min_h:2},{widget_id:`important-tasks`,x:6,y:0,w:3,h:2,min_w:2,min_h:2},{widget_id:`not-started-tasks`,x:9,y:0,w:3,h:2,min_w:2,min_h:2},{widget_id:`progress-distribution`,x:0,y:2,w:5,h:4,min_w:4,min_h:3},{widget_id:`assignee-workload`,x:5,y:2,w:7,h:4,min_w:5,min_h:3},{widget_id:`completion-timeline`,x:0,y:6,w:5,h:5,min_w:4,min_h:4},{widget_id:`important-open-tasks`,x:5,y:6,w:7,h:5,min_w:5,min_h:4}],widgets:[{id:`total-tasks`,title:`Total tasks`,description:`All tracked work items`,type:`metric`,query:{aggregation:`count`},config:{value_label:`tasks`,color:`#5645d4`}},{id:`completed-tasks`,title:`Completed`,description:`Tasks marked complete`,type:`metric`,query:{aggregation:`count`,filters:[{field_name:`progress`,operator:`equals`,value:`Completed`}]},config:{value_label:`tasks`,color:`#1aae39`}},{id:`important-tasks`,title:`Important`,description:`Priority work requiring attention`,type:`metric`,query:{aggregation:`count_true`,field_name:`important`},config:{value_label:`tasks`,color:`#dd5b00`}},{id:`not-started-tasks`,title:`Not started`,description:`Tasks waiting to begin`,type:`metric`,query:{aggregation:`count`,filters:[{field_name:`progress`,operator:`equals`,value:`Not Started`}]},config:{value_label:`tasks`,color:`#787671`}},{id:`progress-distribution`,title:`Progress distribution`,description:`Task count by progress state`,type:`pie`,query:{aggregation:`count`,group_by_field_name:`progress`},config:{category_order:[`Completed`,`In Progress`,`Not Started`]}},{id:`assignee-workload`,title:`Tasks by assignee`,description:`Current workload across the team`,type:`bar`,query:{aggregation:`count`,group_by_field_name:`assignee`},config:{color:`#5645d4`}},{id:`completion-timeline`,title:`Completion timeline`,description:`Completed tasks by actual completion date`,type:`line`,query:{aggregation:`count`,group_by_field_name:`actual_completion_date`,filters:[{field_name:`progress`,operator:`equals`,value:`Completed`}]},config:{color:`#2a9d99`}},{id:`important-open-tasks`,title:`Important open tasks`,description:`Important work that is not completed`,type:`table`,query:{aggregation:`count`,filters:[{field_name:`important`,operator:`truthy`},{field_name:`progress`,operator:`not_equals`,value:`Completed`}],columns:[`task_description`,`assignee`,`progress`,`expected_completion_date`],limit:8}}]}]}}var K4=[`Gaming`,`Entertainment & Challenges`,`How-to & Education`,`Tech & Reviews`,`Lifestyle & Vlog`,`News & Commentary`,`Business & Finance`,`Health & Fitness`],q4=[`Confident`,`Curious`,`Excited`,`Shock`,`Urgent`,`Mysterious`,`Funny`,`Serious`,`Angry`,`Winning`,`Relax`],J4=[`Auto`,`Center Face + Big Title`,`Left Face / Right Title`,`Right Face / Left Title`,`Face + Object/Screen Callout`,`Before vs After Split`,`Face Over Blurred Background`],Y4=`Choose how strongly the composition calls attention to one key detail.
129
-
130
- - Auto: match the story and layout.
131
- - Off: clean composition with no callout effects.
132
- - Low: one restrained outline, glow, arrow, or circle.
133
- - High: one bold callout with stronger contrast and impact.`,X4=`Create one original thumbnail title for a YouTube video.
134
-
135
- Story: {{Key Message}}
136
- Category: {{Content Type}}
137
- Desired emotion: {{Core Emotion}}
138
-
139
- Write a concrete, outcome-focused phrase that communicates the story at a glance. Use 3 to 6 words, with a maximum of 8. Keep one idea, use no hashtags or emojis, and avoid vague clickbait. Return only the title.`,Z4=`Create one original cover title for a TikTok video.
140
-
141
- Story: {{Key Message}}
142
- Category: {{Content Type}}
143
- Desired emotion: {{Core Emotion}}
144
-
145
- Write a compact hook plus keyword label that remains readable in a profile grid. Use 2 to 4 words, with a maximum of 6. Keep one idea and use no hashtags, emojis, quotes, or filler. Return only the title.`,Q4=`Create an original, photorealistic YouTube thumbnail in a wide 16:9 composition.
146
-
147
- Story: {{Key Message}}
148
- Exact title: {{Thumbnail Title (16:9)}}
149
- Category: {{Content Type}}
150
- Emotion: {{Core Emotion}}
151
- Layout: {{Thumbnail Layout}}
152
- Hook strength: {{Hook Strength}}
153
-
154
- Identity is mandatory: use the attached Face Photo as the only identity reference. Preserve the same recognizable person, facial structure, age, skin tone, hair, and gender presentation. Do not replace the person with a generic model, celebrity, illustration, avatar, or lookalike.
155
-
156
- Place the person in a believable scene that explains the story immediately. Keep the face large, natural, sharply focused, and separate from the title. Render the exact title once in bold condensed sans-serif lettering inside safe margins. Use strong mobile readability, natural cinematic lighting, one topic-specific object or environmental cue, and minimal clutter. Follow the selected layout and hook strength. No logos, watermarks, UI chrome, template variables, or extra text. Return only the finished thumbnail.`,$4=`Create an original, photorealistic TikTok cover in a vertical 9:16 composition.
157
-
158
- Story: {{Key Message}}
159
- Exact title: {{Thumbnail Title (9:16)}}
160
- Category: {{Content Type}}
161
- Emotion: {{Core Emotion}}
162
- Layout: {{Thumbnail Layout}}
163
- Hook strength: {{Hook Strength}}
164
-
165
- Identity is mandatory: use the attached Face Photo as the only identity reference. Preserve the same recognizable person, facial structure, age, skin tone, hair, and gender presentation. Do not replace the person with a generic model, celebrity, illustration, avatar, or lookalike.
166
-
167
- Place the person in a believable scene that explains the story immediately. Keep the face large and sharply focused in the upper half. Render the exact title once in a compact bold condensed sans-serif block inside the central mobile-safe area, away from the right and bottom interface zones. Use natural cinematic lighting, one topic-specific object or environmental cue, strong separation, and minimal clutter. Follow the selected layout and hook strength. No logos, watermarks, UI chrome, template variables, or extra text. Return only the finished cover.`,e3=(...e)=>({assetIds:e}),t3=[{fieldTitle:`Key Message`,position:0,width:260,frozen:!0},{fieldTitle:`Face Photo`,position:1,width:220},{fieldTitle:`Content Type`,position:2,width:200},{fieldTitle:`Core Emotion`,position:3,width:150},{fieldTitle:`Thumbnail Title (16:9)`,position:4,width:220,visible:!1},{fieldTitle:`Thumbnail Title (9:16)`,position:5,width:210,visible:!1},{fieldTitle:`Thumbnail (16:9)`,position:6,width:520},{fieldTitle:`Thumbnail (9:16)`,position:7,width:240},{fieldTitle:`Thumbnail Layout`,position:8,width:210,visible:!1},{fieldTitle:`Hook Strength`,position:9,width:150,visible:!1}],n3=[{fieldTitle:`Key Message`,position:0,width:220,frozen:!0},{fieldTitle:`Face Photo`,position:1,width:210},{fieldTitle:`Content Type`,position:2,width:190},{fieldTitle:`Core Emotion`,position:3,width:150},{fieldTitle:`Thumbnail Title (16:9)`,position:4,width:220},{fieldTitle:`Thumbnail Title (9:16)`,position:5,width:210},{fieldTitle:`Thumbnail Layout`,position:6,width:210},{fieldTitle:`Hook Strength`,position:7,width:150},{fieldTitle:`Thumbnail (16:9)`,position:8,width:480},{fieldTitle:`Thumbnail (9:16)`,position:9,width:260}];function r3(e){return{id:`thumbnail-generator`,title:e(`templateLibrary.templates.thumbnailGenerator.title`),description:e(`templateLibrary.templates.thumbnailGenerator.description`),documentDescription:`Create original landscape thumbnails and vertical covers from a portrait and a structured story brief.`,icon:`image`,color:`rose`,assetManifestPath:`templates/youtube-tiktok-thumbnail-generator/manifest.json`,tables:[{title:`Video Thumbnail Studio`,description:`Original landscape thumbnails and vertical covers built around a consistent creator identity.`,fields:[{title:`Key Message`,name:`key_message`,type:`long_text`,primary:!0,options:{description:`Describe the specific story the video delivers.`}},{title:`Face Photo`,name:`face_photo`,type:`attachment`,options:{description:`Upload one clear portrait. Generated images must preserve this identity.`}},{title:`Content Type`,name:`content_type`,type:`single_select`,options:{choices:K4,description:`Choose the category that best matches the video.`}},{title:`Core Emotion`,name:`core_emotion`,type:`single_select`,options:{choices:q4,description:`Choose the main emotion the image should communicate.`}},{title:`Thumbnail Title (16:9)`,name:`thumbnail_title_16_9`,type:`long_text`,options:{description:`Short title generated for the landscape thumbnail.`},aiConfig:{type:`customize`,prompt:X4,enabled:!0,auto_update:!0}},{title:`Thumbnail Title (9:16)`,name:`thumbnail_title_9_16`,type:`long_text`,options:{description:`Compact title generated for the vertical cover.`},aiConfig:{type:`customize`,prompt:Z4,enabled:!0,auto_update:!0}},{title:`Thumbnail Layout`,name:`thumbnail_layout`,type:`single_select`,options:{choices:J4,defaultValue:`Auto`,preventAutoNewOptions:!1,description:`Choose how the portrait, title, and story object share the frame.`}},{title:`Hook Strength`,name:`hook_strength`,type:`single_select`,options:{choices:[`Auto`,`Off`,`Low`,`High`],defaultValue:`Auto`,description:Y4}},{title:`Thumbnail (16:9)`,name:`thumbnail_16_9`,type:`attachment`,options:{description:`Two landscape variants generated from the portrait and brief.`},aiConfig:{type:`image_customization`,sourceFieldTitle:`Face Photo`,prompt:Q4,enabled:!0,auto_update:!0,n:2,quality:`high`,aspect_ratio:`16:9`,resolution:`1K`,image_use_case:`cover_illustration`}},{title:`Thumbnail (9:16)`,name:`thumbnail_9_16`,type:`attachment`,options:{description:`Two vertical variants generated from the portrait and brief.`},aiConfig:{type:`image_customization`,sourceFieldTitle:`Face Photo`,prompt:$4,enabled:!0,auto_update:!0,n:2,quality:`high`,aspect_ratio:`9:16`,resolution:`1K`,image_use_case:`cover_illustration`}}],views:[{title:`Quick Start`,type:`grid`,config:{row_height:`extra_tall`,frozen_column_count:1},hiddenFieldTitles:[`Thumbnail Title (16:9)`,`Thumbnail Title (9:16)`,`Thumbnail Layout`,`Hook Strength`],fieldLayouts:t3},{title:`Advanced`,type:`grid`,config:{row_height:`extra_tall`,frozen_column_count:1},fieldLayouts:n3}],records:[{"Key Message":`I built a silent recording studio inside a closet`,"Face Photo":e3(`record-01-face-photo-01`),"Content Type":`How-to & Education`,"Core Emotion":`Curious`,"Thumbnail Title (16:9)":`A Studio in a Closet`,"Thumbnail Title (9:16)":`Closet Studio Build`,"Thumbnail Layout":`Left Face / Right Title`,"Hook Strength":`Low`,"Thumbnail (16:9)":e3(`record-01-thumbnail-16x9-01`,`record-01-thumbnail-16x9-02`),"Thumbnail (9:16)":e3(`record-01-thumbnail-9x16-01`,`record-01-thumbnail-9x16-02`)},{"Key Message":`Can a thirty-dollar solar panel power my entire desk?`,"Face Photo":e3(`record-02-face-photo-01`),"Content Type":`Tech & Reviews`,"Core Emotion":`Shock`,"Thumbnail Title (16:9)":`$30 Solar Desk Test`,"Thumbnail Title (9:16)":`$30 Solar Test`,"Thumbnail Layout":`Face + Object/Screen Callout`,"Hook Strength":`High`,"Thumbnail (16:9)":e3(`record-02-thumbnail-16x9-01`,`record-02-thumbnail-16x9-02`),"Thumbnail (9:16)":e3(`record-02-thumbnail-9x16-01`,`record-02-thumbnail-9x16-02`)},{"Key Message":`I cooked five dinners from one tiny balcony harvest`,"Face Photo":e3(`record-03-face-photo-01`),"Content Type":`Lifestyle & Vlog`,"Core Emotion":`Excited`,"Thumbnail Title (16:9)":`5 Dinners, One Balcony`,"Thumbnail Title (9:16)":`Balcony Harvest Meals`,"Thumbnail Layout":`Right Face / Left Title`,"Hook Strength":`Low`,"Thumbnail (16:9)":e3(`record-03-thumbnail-16x9-01`,`record-03-thumbnail-16x9-02`),"Thumbnail (9:16)":e3(`record-03-thumbnail-9x16-01`,`record-03-thumbnail-9x16-02`)},{"Key Message":`I trained my rescue dog to ring the doorbell`,"Face Photo":e3(`record-04-face-photo-01`),"Content Type":`How-to & Education`,"Core Emotion":`Winning`,"Thumbnail Title (16:9)":`Doorbell Training Worked`,"Thumbnail Title (9:16)":`Dog Rings Doorbell`,"Thumbnail Layout":`Face + Object/Screen Callout`,"Hook Strength":`Auto`,"Thumbnail (16:9)":e3(`record-04-thumbnail-16x9-01`,`record-04-thumbnail-16x9-02`),"Thumbnail (9:16)":e3(`record-04-thumbnail-9x16-01`,`record-04-thumbnail-9x16-02`)},{"Key Message":`I mapped every hidden stairway in my city`,"Face Photo":e3(`record-05-face-photo-01`),"Content Type":`Entertainment & Challenges`,"Core Emotion":`Mysterious`,"Thumbnail Title (16:9)":`Hidden Stairs Nobody Sees`,"Thumbnail Title (9:16)":`Secret City Stairs`,"Thumbnail Layout":`Face Over Blurred Background`,"Hook Strength":`Low`,"Thumbnail (16:9)":e3(`record-05-thumbnail-16x9-01`,`record-05-thumbnail-16x9-02`),"Thumbnail (9:16)":e3(`record-05-thumbnail-9x16-01`,`record-05-thumbnail-9x16-02`)}]}]}}var i3={title:`Grid`,type:`grid`},a3={"task-tracker":{defaultResourceId:`task-management`,resources:[{id:`task-management`,kind:`table`,title:`Task Management`,description:`Grouped task planning and progress tracking.`,tableTitle:`Task Management`},{id:`task-dashboard`,kind:`dashboard`,title:`Task Dashboard`,description:`Live task progress, workload, and priority reporting.`}]},"thumbnail-generator":{defaultResourceId:`thumbnail-workbench`,resources:[{id:`thumbnail-workbench`,kind:`table`,title:`Video Thumbnails Generator`,description:`Structured creative inputs and generated 16:9 and 9:16 outputs.`,tableTitle:`Video Thumbnails Generator`}]},"receipt-ocr-database":{defaultResourceId:`receipt-database`,resources:[{id:`receipt-database`,kind:`table`,title:`Receipts`,description:`Receipt images with searchable fields, structured JSON, and plain OCR text.`,tableTitle:`Receipts`}]},"leads-landing-page":{defaultResourceId:`leads`,resources:[{id:`leads`,kind:`table`,title:`Leads`,description:`Form submissions, qualification details, and follow-up state.`,tableTitle:`Leads`}]},"sdr-cold-call-manager":{defaultResourceId:`call-queue`,resources:[{id:`call-queue`,kind:`table`,title:`Call Queue`,description:`Assigned leads, call priority, attempts, and next actions.`,tableTitle:`Call Queue`}]},"product-launch-website":{defaultResourceId:`website-sections`,resources:[{id:`website-sections`,kind:`table`,title:`Website Sections`,description:`Content, asset, owner, and readiness source of truth.`,tableTitle:`Website Sections`}]},"batch-product-designer":{defaultResourceId:`product-concepts`,resources:[{id:`product-concepts`,kind:`table`,title:`Product Concepts`,description:`Briefs, generated product imagery, and social copy.`,tableTitle:`Product Concepts`}]},"simple-client-crm":{defaultResourceId:`clients`,resources:[{id:`clients`,kind:`table`,title:`Clients`,description:`Prospects and customers moving through the sales pipeline.`,tableTitle:`Clients`},{id:`quotes`,kind:`table`,title:`Quotes`,description:`Commercial proposals and approval progress.`,tableTitle:`Quotes`}]},"lumiere-restaurant":{defaultResourceId:`reservations`,resources:[{id:`reservations`,kind:`table`,title:`Reservations`,description:`Service schedule, guest preferences, and dining status.`,tableTitle:`Reservations`},{id:`private-events`,kind:`table`,title:`Private Events`,description:`Private dining inquiries and delivery details.`,tableTitle:`Private Events`}]}},o3={"task-tracker":[`recommended`,`projects`],"thumbnail-generator":[`recommended`,`ai-workflows`],"receipt-ocr-database":[`recommended`,`ai-workflows`],"leads-landing-page":[`recommended`,`business`],"sdr-cold-call-manager":[`ai-workflows`,`business`],"product-launch-website":[`recommended`,`business`,`projects`],"batch-product-designer":[`ai-workflows`,`business`],"simple-client-crm":[`recommended`,`business`],"lumiere-restaurant":[`business`]};function s3(e){return[...[G4(e),r3(e),W4(e),{id:`leads-landing-page`,title:e(`templateLibrary.templates.leadsLandingPage.title`),description:e(`templateLibrary.templates.leadsLandingPage.description`),documentDescription:`Track qualified leads and manage follow-up.`,icon:`contact`,color:`sky`,tables:[{title:`Leads`,description:`Landing-page submissions and qualification status.`,fields:[{title:`Company`,type:`text`,primary:!0},{title:`Contact name`,type:`text`},{title:`Work email`,type:`text`},{title:`Company size`,type:`single_select`,options:{choices:[`1–10`,`11–50`,`51–200`,`201–1000`,`1000+`]}},{title:`Use case`,type:`multi_select`,options:{choices:[`CRM`,`Operations`,`Content`,`Project management`,`Customer support`]}},{title:`Source`,type:`single_select`,options:{choices:[`Organic search`,`Partner`,`Social`,`Event`,`Referral`]}},{title:`Stage`,type:`single_select`,options:{choices:[`New`,`Qualified`,`Demo booked`,`Nurture`,`Closed`]}},{title:`Estimated value`,type:`number`},{title:`Submitted at`,type:`datetime`},{title:`Notes`,type:`long_text`}],views:[i3,{title:`Pipeline`,type:`kanban`}],records:[{Company:`Northstar Labs`,"Contact name":`Emma Stone`,"Work email":`emma@northstarlabs.example`,"Company size":`51–200`,"Use case":[`Operations`,`Project management`],Source:`Organic search`,Stage:`Demo booked`,"Estimated value":18e3,"Submitted at":`2026-07-28T09:12:00Z`,Notes:`Needs approval workflows and audit history.`},{Company:`Cedar & Finch`,"Contact name":`Theo Martin`,"Work email":`theo@cedarfinch.example`,"Company size":`11–50`,"Use case":[`CRM`],Source:`Referral`,Stage:`Qualified`,"Estimated value":9e3,"Submitted at":`2026-07-27T16:40:00Z`,Notes:`Replacing several disconnected spreadsheets.`},{Company:`Atlas Freight`,"Contact name":`Priya Nair`,"Work email":`priya@atlasfreight.example`,"Company size":`201–1000`,"Use case":[`Operations`,`Customer support`],Source:`Event`,Stage:`New`,"Estimated value":42e3,"Submitted at":`2026-07-28T03:28:00Z`},{Company:`Brightline Studio`,"Contact name":`Milo Grant`,"Work email":`milo@brightline.example`,"Company size":`11–50`,"Use case":[`Content`,`Project management`],Source:`Social`,Stage:`Nurture`,"Estimated value":6e3,"Submitted at":`2026-07-24T11:05:00Z`,Notes:`Revisit after current client delivery cycle.`},{Company:`Harbor Health`,"Contact name":`Leah Cooper`,"Work email":`leah@harborhealth.example`,"Company size":`1000+`,"Use case":[`Customer support`],Source:`Partner`,Stage:`Demo booked`,"Estimated value":68e3,"Submitted at":`2026-07-25T14:22:00Z`,Notes:`Security review required before pilot.`},{Company:`Fieldwork Coffee`,"Contact name":`Jon Bell`,"Work email":`jon@fieldwork.example`,"Company size":`1–10`,"Use case":[`CRM`,`Operations`],Source:`Organic search`,Stage:`Closed`,"Estimated value":2400,"Submitted at":`2026-07-18T08:30:00Z`},{Company:`Signal Ridge`,"Contact name":`Iris Wong`,"Work email":`iris@signalridge.example`,"Company size":`51–200`,"Use case":[`Project management`],Source:`Referral`,Stage:`Qualified`,"Estimated value":15e3,"Submitted at":`2026-07-26T19:14:00Z`},{Company:`Pioneer Works`,"Contact name":`Sam Wilson`,"Work email":`sam@pioneerworks.example`,"Company size":`201–1000`,"Use case":[`Operations`],Source:`Event`,Stage:`New`,"Estimated value":31e3,"Submitted at":`2026-07-28T06:55:00Z`}]}]},{id:`sdr-cold-call-manager`,title:e(`templateLibrary.templates.sdrColdCallManager.title`),description:e(`templateLibrary.templates.sdrColdCallManager.description`),documentDescription:`Manage SDR call queues, attempts, outcomes, and next steps.`,icon:`phone`,color:`violet`,tables:[{title:`Call Queue`,description:`Prioritized outbound calling list for sales development.`,fields:[{title:`Account`,type:`text`,primary:!0},{title:`Contact`,type:`text`},{title:`Phone`,type:`text`},{title:`Territory`,type:`single_select`,options:{choices:[`North America`,`Europe`,`Asia Pacific`,`Latin America`]}},{title:`Priority`,type:`single_select`,options:{choices:[`Low`,`Medium`,`High`]}},{title:`Call stage`,type:`single_select`,options:{choices:[`Ready`,`Attempted`,`Connected`,`Meeting booked`,`Do not call`]}},{title:`Attempts`,type:`number`},{title:`Last call`,type:`datetime`},{title:`Next call`,type:`datetime`},{title:`Owner`,type:`text`},{title:`Call notes`,type:`long_text`}],views:[i3,{title:`Call stages`,type:`kanban`},{title:`Call calendar`,type:`calendar`}],records:[{Account:`Acme Robotics`,Contact:`Daniel Ruiz`,Phone:`+1 555 010 2210`,Territory:`North America`,Priority:`High`,"Call stage":`Ready`,Attempts:0,"Next call":`2026-07-28T15:00:00Z`,Owner:`Alex Carter`,"Call notes":`Recently expanded operations team.`},{Account:`Bluebird Energy`,Contact:`Nora Jensen`,Phone:`+45 70 20 11 44`,Territory:`Europe`,Priority:`High`,"Call stage":`Connected`,Attempts:2,"Last call":`2026-07-27T10:20:00Z`,"Next call":`2026-07-30T09:00:00Z`,Owner:`Alex Carter`,"Call notes":`Interested in workflow automation and reporting.`},{Account:`Canyon Foods`,Contact:`Marcus Hill`,Phone:`+1 555 010 7844`,Territory:`North America`,Priority:`Medium`,"Call stage":`Attempted`,Attempts:1,"Last call":`2026-07-28T08:45:00Z`,"Next call":`2026-07-29T16:30:00Z`,Owner:`Taylor Reed`},{Account:`Delta Marine`,Contact:`Hana Ito`,Phone:`+81 3 5550 3100`,Territory:`Asia Pacific`,Priority:`High`,"Call stage":`Meeting booked`,Attempts:3,"Last call":`2026-07-26T04:10:00Z`,"Next call":`2026-08-01T05:00:00Z`,Owner:`Morgan Blake`,"Call notes":`Discovery with operations director and IT lead.`},{Account:`Evergreen Legal`,Contact:`Amelia Hart`,Phone:`+44 20 7946 0230`,Territory:`Europe`,Priority:`Medium`,"Call stage":`Ready`,Attempts:0,"Next call":`2026-07-29T11:00:00Z`,Owner:`Taylor Reed`},{Account:`Futura Retail`,Contact:`Lucas Silva`,Phone:`+55 11 5555 0199`,Territory:`Latin America`,Priority:`Medium`,"Call stage":`Attempted`,Attempts:2,"Last call":`2026-07-25T17:35:00Z`,"Next call":`2026-07-31T17:00:00Z`,Owner:`Morgan Blake`},{Account:`Granite Systems`,Contact:`Chloe Baker`,Phone:`+1 555 010 9942`,Territory:`North America`,Priority:`Low`,"Call stage":`Do not call`,Attempts:4,"Last call":`2026-07-23T14:15:00Z`,Owner:`Alex Carter`,"Call notes":`Requested removal from outbound list.`},{Account:`Helio Networks`,Contact:`Arjun Mehta`,Phone:`+91 80 5550 6110`,Territory:`Asia Pacific`,Priority:`High`,"Call stage":`Connected`,Attempts:1,"Last call":`2026-07-28T06:10:00Z`,"Next call":`2026-07-30T06:30:00Z`,Owner:`Taylor Reed`,"Call notes":`Send architecture overview before follow-up.`}]}]},{id:`product-launch-website`,title:e(`templateLibrary.templates.productLaunchWebsite.title`),description:e(`templateLibrary.templates.productLaunchWebsite.description`),documentDescription:`Coordinate a premium product launch site from concept through publication.`,icon:`rocket`,color:`slate`,tables:[{title:`Website Sections`,description:`Launch-site sections, content ownership, assets, and readiness.`,fields:[{title:`Section`,type:`text`,primary:!0},{title:`Purpose`,type:`long_text`},{title:`Headline`,type:`text`},{title:`Owner`,type:`text`},{title:`Status`,type:`single_select`,options:{choices:[`Draft`,`Design`,`Review`,`Ready`,`Published`]}},{title:`Publish date`,type:`date`},{title:`Asset URL`,type:`url`},{title:`Mobile ready`,type:`checkbox`},{title:`Notes`,type:`long_text`}],views:[i3,{title:`Production board`,type:`kanban`},{title:`Launch calendar`,type:`calendar`}],records:[{Section:`Hero`,Purpose:`Introduce the product with one clear promise.`,Headline:`A cleaner home, without the daily effort.`,Owner:`Nina Cole`,Status:`Ready`,"Publish date":`2026-08-18`,"Asset URL":`https://example.com/assets/hero`,"Mobile ready":!0,Notes:`Use the side profile as the primary product angle.`},{Section:`Problem`,Purpose:`Show the cost of repeated manual cleaning.`,Headline:`Clean floors should not take over your week.`,Owner:`Omar Lewis`,Status:`Review`,"Publish date":`2026-08-18`,"Mobile ready":!0},{Section:`Feature overview`,Purpose:`Explain navigation, obstacle detection, and quiet mode.`,Headline:`Built to notice what other cleaners miss.`,Owner:`Nina Cole`,Status:`Design`,"Publish date":`2026-08-18`,"Asset URL":`https://example.com/assets/features`,"Mobile ready":!1},{Section:`Product gallery`,Purpose:`Present premium product details and finishes.`,Headline:`Designed to belong in your home.`,Owner:`Jules Kim`,Status:`Ready`,"Publish date":`2026-08-18`,"Asset URL":`https://example.com/assets/gallery`,"Mobile ready":!0},{Section:`Specifications`,Purpose:`Answer practical purchase questions.`,Headline:`Powerful where it matters. Quiet everywhere else.`,Owner:`Omar Lewis`,Status:`Draft`,"Publish date":`2026-08-18`,"Mobile ready":!1},{Section:`Reviews`,Purpose:`Build confidence with early customer feedback.`,Headline:`A small machine that gives time back.`,Owner:`Tessa Moore`,Status:`Review`,"Publish date":`2026-08-18`,"Mobile ready":!0},{Section:`Purchase`,Purpose:`Present packages, shipping, and final call to action.`,Headline:`Choose your finish and start cleaning less.`,Owner:`Tessa Moore`,Status:`Draft`,"Publish date":`2026-08-18`,"Mobile ready":!1,Notes:`Waiting for final bundle pricing.`}]}]},j4(e),{id:`simple-client-crm`,title:e(`templateLibrary.templates.simpleClientCrm.title`),description:e(`templateLibrary.templates.simpleClientCrm.description`),documentDescription:`Track prospects, active clients, quotes, and follow-up in one workspace.`,icon:`handshake`,color:`sky`,tables:[{title:`Clients`,description:`Client relationships from first conversation through renewal.`,fields:[{title:`Company`,type:`text`,primary:!0},{title:`Primary contact`,type:`text`},{title:`Email`,type:`text`},{title:`Stage`,type:`single_select`,options:{choices:[`Lead`,`Discovery`,`Proposal`,`Active`,`Renewal`,`Closed`]}},{title:`Deal value`,type:`number`},{title:`Owner`,type:`text`},{title:`Next follow-up`,type:`date`},{title:`Services`,type:`multi_select`,options:{choices:[`Strategy`,`Design`,`Development`,`Support`,`Training`]}},{title:`Health`,type:`single_select`,options:{choices:[`Strong`,`Watch`,`At risk`]}},{title:`Notes`,type:`long_text`}],views:[i3,{title:`Sales pipeline`,type:`kanban`},{title:`Follow-up calendar`,type:`calendar`}],records:[{Company:`Alpine Goods`,"Primary contact":`Rebecca Hall`,Email:`rebecca@alpinegoods.example`,Stage:`Active`,"Deal value":48e3,Owner:`Chris Lane`,"Next follow-up":`2026-08-03`,Services:[`Strategy`,`Development`],Health:`Strong`,Notes:`Expansion discussion scheduled for Q4.`},{Company:`Beacon Media`,"Primary contact":`Drew Evans`,Email:`drew@beaconmedia.example`,Stage:`Proposal`,"Deal value":22e3,Owner:`Chris Lane`,"Next follow-up":`2026-07-30`,Services:[`Design`,`Development`],Health:`Strong`},{Company:`Clover Finance`,"Primary contact":`Fatima Noor`,Email:`fatima@cloverfinance.example`,Stage:`Discovery`,"Deal value":36e3,Owner:`Robin Fox`,"Next follow-up":`2026-07-31`,Services:[`Strategy`,`Training`],Health:`Watch`,Notes:`Procurement timeline is still unclear.`},{Company:`Drift Hotel Group`,"Primary contact":`Ethan Price`,Email:`ethan@drifthotel.example`,Stage:`Renewal`,"Deal value":64e3,Owner:`Robin Fox`,"Next follow-up":`2026-08-05`,Services:[`Support`,`Development`],Health:`Strong`},{Company:`Elm Education`,"Primary contact":`Zoe King`,Email:`zoe@elmeducation.example`,Stage:`Lead`,"Deal value":12e3,Owner:`Chris Lane`,"Next follow-up":`2026-08-01`,Services:[`Training`],Health:`Watch`},{Company:`Foundry Labs`,"Primary contact":`Ben Ortiz`,Email:`ben@foundrylabs.example`,Stage:`Active`,"Deal value":31e3,Owner:`Morgan Yu`,"Next follow-up":`2026-08-07`,Services:[`Design`,`Development`,`Support`],Health:`At risk`,Notes:`Resolve delivery concerns before the next steering call.`},{Company:`Greenway Market`,"Primary contact":`Alice Young`,Email:`alice@greenway.example`,Stage:`Closed`,"Deal value":8e3,Owner:`Morgan Yu`,"Next follow-up":`2026-09-15`,Services:[`Strategy`],Health:`Strong`},{Company:`Horizon Mobility`,"Primary contact":`Ken Adams`,Email:`ken@horizonmobility.example`,Stage:`Proposal`,"Deal value":57e3,Owner:`Robin Fox`,"Next follow-up":`2026-07-29`,Services:[`Strategy`,`Development`,`Training`],Health:`Strong`}]},{title:`Quotes`,description:`Commercial quotes and approval progress.`,fields:[{title:`Quote`,type:`text`,primary:!0},{title:`Client`,type:`text`},{title:`Amount`,type:`number`},{title:`Status`,type:`single_select`,options:{choices:[`Draft`,`Sent`,`Accepted`,`Declined`,`Expired`]}},{title:`Sent date`,type:`date`},{title:`Valid until`,type:`date`},{title:`Owner`,type:`text`}],views:[i3,{title:`Quote status`,type:`kanban`}],records:[{Quote:`Q-2026-104`,Client:`Beacon Media`,Amount:22e3,Status:`Sent`,"Sent date":`2026-07-24`,"Valid until":`2026-08-14`,Owner:`Chris Lane`},{Quote:`Q-2026-105`,Client:`Horizon Mobility`,Amount:57e3,Status:`Draft`,"Valid until":`2026-08-20`,Owner:`Robin Fox`},{Quote:`Q-2026-097`,Client:`Alpine Goods`,Amount:48e3,Status:`Accepted`,"Sent date":`2026-06-12`,"Valid until":`2026-07-03`,Owner:`Chris Lane`},{Quote:`Q-2026-099`,Client:`Greenway Market`,Amount:8e3,Status:`Declined`,"Sent date":`2026-06-25`,"Valid until":`2026-07-16`,Owner:`Morgan Yu`}]}]},{id:`lumiere-restaurant`,title:e(`templateLibrary.templates.lumiereRestaurant.title`),description:e(`templateLibrary.templates.lumiereRestaurant.description`),documentDescription:`Coordinate reservations, guest preferences, private events, and service follow-up.`,icon:`utensils`,color:`amber`,tables:[{title:`Reservations`,description:`Dining reservations, service details, and guest preferences.`,fields:[{title:`Guest`,type:`text`,primary:!0},{title:`Reservation time`,type:`datetime`},{title:`Party size`,type:`number`},{title:`Experience`,type:`single_select`,options:{choices:[`Dining room`,`Chef counter`,`Terrace`,`Private room`]}},{title:`Status`,type:`single_select`,options:{choices:[`Requested`,`Confirmed`,`Seated`,`Completed`,`Cancelled`]}},{title:`Phone`,type:`text`},{title:`Occasion`,type:`single_select`,options:{choices:[`None`,`Birthday`,`Anniversary`,`Business`,`Celebration`]}},{title:`Dietary notes`,type:`long_text`},{title:`VIP`,type:`checkbox`},{title:`Table`,type:`text`}],views:[{title:`Service calendar`,type:`calendar`},i3,{title:`Service status`,type:`kanban`}],records:[{Guest:`Aisha Morgan`,"Reservation time":`2026-08-03T18:00:00Z`,"Party size":2,Experience:`Terrace`,Status:`Confirmed`,Phone:`+1 555 016 2201`,Occasion:`Anniversary`,"Dietary notes":`One guest requests a dairy-free menu.`,VIP:!0,Table:`T3`},{Guest:`Daniel Kim`,"Reservation time":`2026-08-03T18:45:00Z`,"Party size":4,Experience:`Dining room`,Status:`Seated`,Phone:`+1 555 016 2202`,Occasion:`Business`,VIP:!1,Table:`D8`},{Guest:`Priya Shah`,"Reservation time":`2026-08-03T19:15:00Z`,"Party size":3,Experience:`Chef counter`,Status:`Requested`,Phone:`+1 555 016 2203`,Occasion:`Birthday`,"Dietary notes":`Vegetarian menu for the full party.`,VIP:!1,Table:`Counter 3`},{Guest:`Noah Williams`,"Reservation time":`2026-08-03T20:00:00Z`,"Party size":2,Experience:`Dining room`,Status:`Completed`,Phone:`+1 555 016 2204`,Occasion:`None`,VIP:!1,Table:`D4`},{Guest:`Elena Torres`,"Reservation time":`2026-08-04T18:30:00Z`,"Party size":7,Experience:`Private room`,Status:`Confirmed`,Phone:`+1 555 016 2205`,Occasion:`Celebration`,"Dietary notes":`Gluten-free bread and a nut-free dessert.`,VIP:!0,Table:`Private B`},{Guest:`Marcus Lee`,"Reservation time":`2026-08-04T19:00:00Z`,"Party size":5,Experience:`Terrace`,Status:`Confirmed`,Phone:`+1 555 016 2206`,Occasion:`Business`,VIP:!1,Table:`T6`},{Guest:`Grace Miller`,"Reservation time":`2026-08-04T20:15:00Z`,"Party size":2,Experience:`Chef counter`,Status:`Cancelled`,Phone:`+1 555 016 2207`,Occasion:`Birthday`,VIP:!1,Table:`Counter 1`},{Guest:`Owen Parker`,"Reservation time":`2026-08-05T19:30:00Z`,"Party size":6,Experience:`Dining room`,Status:`Requested`,Phone:`+1 555 016 2208`,Occasion:`Celebration`,"Dietary notes":`Wheelchair-accessible seating required.`,VIP:!0,Table:`D14`}]},{title:`Private Events`,description:`Private dining inquiries and event delivery details.`,fields:[{title:`Event`,type:`text`,primary:!0},{title:`Host`,type:`text`},{title:`Email`,type:`text`},{title:`Phone`,type:`text`},{title:`Event date`,type:`datetime`},{title:`Guests`,type:`number`},{title:`Room`,type:`single_select`,options:{choices:[`Salon`,`Terrace`,`Full venue`]}},{title:`Status`,type:`single_select`,options:{choices:[`Inquiry`,`Qualified`,`Proposal`,`Confirmed`,`Completed`,`Declined`]}},{title:`Budget`,type:`number`},{title:`Menu notes`,type:`long_text`}],views:[i3,{title:`Event calendar`,type:`calendar`},{title:`Event pipeline`,type:`kanban`}],records:[{Event:`Northstar quarterly dinner`,Host:`Maya Collins`,"Event date":`2026-08-14T18:00:00Z`,Guests:20,Room:`Salon`,Status:`Confirmed`,Budget:6200,"Menu notes":`Seasonal shared menu with non-alcoholic pairings.`},{Event:`Harbor Foundation fundraiser`,Host:`Ethan Brooks`,"Event date":`2026-08-27T17:30:00Z`,Guests:64,Room:`Full venue`,Status:`Proposal`,Budget:19500,"Menu notes":`Reception stations, short program, and accessible seating plan.`},{Event:`Cedar Studio product preview`,Host:`Lena Ortiz`,"Event date":`2026-09-10T18:30:00Z`,Guests:38,Room:`Terrace`,Status:`Qualified`,Budget:12400,"Menu notes":`Passed plates, branded menu cards, and a zero-proof cocktail bar.`},{Event:`Lakeside family reception`,Host:`Jordan Blake`,"Event date":`2026-09-19T19:00:00Z`,Guests:28,Room:`Salon`,Status:`Inquiry`,Budget:8400,"Menu notes":`Family-style dinner with a children menu for six guests.`}]}]}].map(e=>({...e,coverImage:`templates/table-covers/${e.id}.webp`,categories:o3[e.id]||[`recommended`],snapshot:{version:e.id===`thumbnail-generator`?5:e.id===`batch-product-designer`?3:e.id===`lumiere-restaurant`||e.id===`task-tracker`?2:1,includeData:!0,...a3[e.id]}})),...P4()]}var c3=`!h-[min(700px,calc(100vh-4rem))] !max-h-none !w-[calc(100vw-2rem)] max-w-none !gap-0 !overflow-hidden !p-0 md:!w-[min(1040px,calc(100vw-8rem))]`;function l3({title:e,description:t,icon:n,query:r,onQueryChange:i,searchPlaceholder:a=`Search templates`,categories:o,activeCategory:s,onCategoryChange:c,children:l}){return(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,I.jsxs)(`header`,{className:`flex h-14 shrink-0 items-center gap-4 border-b px-5`,children:[(0,I.jsx)(`span`,{className:`grid size-8 place-items-center rounded-lg bg-primary text-primary-foreground`,children:(0,I.jsx)(n,{className:`size-4`})}),(0,I.jsx)(o_,{className:`text-lg font-semibold text-foreground`,children:e}),(0,I.jsx)(s_,{className:`sr-only`,children:t})]}),(0,I.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[208px_minmax(0,1fr)] max-lg:grid-cols-[196px_minmax(0,1fr)] max-md:grid-cols-1`,children:[(0,I.jsxs)(`aside`,{className:`flex min-h-0 flex-col border-r bg-sidebar px-3 py-4 text-sidebar-foreground max-md:hidden`,children:[(0,I.jsxs)(`label`,{className:`relative block`,children:[(0,I.jsx)(Ns,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground`}),(0,I.jsx)(`input`,{type:`search`,value:r,onChange:e=>i(e.target.value),placeholder:a,className:`h-9 w-full rounded-lg border border-input bg-background/75 pl-9 pr-3 text-sm outline-none focus:border-primary focus:ring-2 focus:ring-primary/15`})]}),(0,I.jsx)(`nav`,{className:`mt-3 min-h-0 flex-1 space-y-1 overflow-y-auto`,children:o.map(e=>{let t=s===e.id&&!r;return(0,I.jsxs)(`button`,{type:`button`,className:K(`relative flex h-9 w-full items-center gap-2.5 rounded-md px-3 text-left text-sm font-medium transition-colors`,t?`bg-sidebar-accent text-foreground shadow-sm`:`text-sidebar-foreground hover:bg-sidebar-accent/70 hover:text-foreground`),onClick:()=>c(e.id),"data-testid":`workspace-template-category-${e.id}`,children:[(0,I.jsx)(`span`,{className:K(`absolute left-0 h-5 w-0.5 rounded-full bg-primary transition-opacity`,t?`opacity-100`:`opacity-0`)}),(0,I.jsx)(e.icon,{className:K(`size-4 shrink-0`,t?`text-primary`:`text-muted-foreground`)}),e.label]},e.id)})})]}),(0,I.jsx)(`main`,{className:`min-h-0 overflow-y-auto bg-background px-6 pb-8 pt-6`,children:l})]})]})}var u3=[{id:`recommended`,label:`Recommended`,icon:Ws},{id:`ai-workflows`,label:`AI workflows`,icon:Mc},{id:`business`,label:`Business`,icon:qi},{id:`projects`,label:`Projects`,icon:Eo}];function d3({open:e,busy:t=!1,onOpenChange:n,onSelect:r}){let{t:i}=U(`table`),a=(0,j.useMemo)(()=>s3(i),[i]),[o,s]=(0,j.useState)(null),[c,l]=(0,j.useState)(``),[u,d]=(0,j.useState)(null),[f,p]=(0,j.useState)(``),[m,h]=(0,j.useState)(`recommended`),[g,_]=(0,j.useState)(``),v=t||o!==null,y=(0,j.useMemo)(()=>{let e=g.trim().toLowerCase();return a.filter(t=>{let n=e?!0:(t.categories||[`recommended`]).includes(m),r=!e||`${t.title} ${t.description}`.toLowerCase().includes(e);return n&&r})},[m,g,a]),b=e=>{d(e),p(e.snapshot.defaultResourceId),l(``)},x=()=>{v||(d(null),p(``),l(``))},S=async e=>{s(e?.id||`blank`),l(``);try{await r(e)||l(i(`templateLibrary.createFailed`))}finally{s(null)}};return(0,I.jsx)(e_,{open:e,onOpenChange:e=>v?null:n(e),children:(0,I.jsx)(t_,{size:`none`,className:c3,"data-testid":`table-template-library-dialog`,disableAutoFocus:!0,children:u?(0,I.jsx)(m3,{template:u,activeResourceId:f,disabled:v,errorMessage:c,onActiveResourceChange:p,onBack:x,onUse:()=>void S(u)}):(0,I.jsx)(l3,{title:`Template Center`,description:`Choose a template or a blank workspace to create a new table workspace.`,icon:Ws,query:g,onQueryChange:_,categories:u3,activeCategory:m,onCategoryChange:e=>{h(e),_(``)},children:(0,I.jsxs)(`section`,{className:`mx-auto max-w-7xl`,children:[(0,I.jsxs)(`div`,{className:`mb-6 flex items-center justify-between gap-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-xl font-semibold text-foreground`,children:g?`Search results for “${g}”`:u3.find(e=>e.id===m)?.label}),(0,I.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Choose a focused starting point and customize it after creation.`})]}),c?(0,I.jsx)(`span`,{className:`text-xs text-destructive`,role:`alert`,children:c}):null]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-2 xl:grid-cols-3`,children:[!g&&m===`recommended`?(0,I.jsx)(f3,{busy:o===`blank`,disabled:v,onCreate:()=>void S()}):null,y.map(e=>(0,I.jsx)(p3,{template:e,disabled:v,busy:o===e.id,onPreview:()=>b(e),onUse:()=>void S(e)},e.id))]}),y.length?null:(0,I.jsx)(`div`,{className:`mt-16 text-center text-sm text-muted-foreground`,children:`No templates match this search.`})]})})})})}function f3({busy:e,disabled:t,onCreate:n}){let{t:r}=U(`table`);return(0,I.jsxs)(`article`,{className:`group min-w-0`,"data-testid":`table-template-blank-card`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`relative block aspect-[16/9] w-full overflow-hidden rounded-xl border border-border bg-muted/25 transition hover:border-primary/35 hover:shadow-soft disabled:opacity-60`,disabled:t,onClick:n,"data-testid":`table-template-blank`,children:[(0,I.jsx)(`span`,{className:`absolute inset-0 grid place-items-center`,children:(0,I.jsxs)(`span`,{className:`text-center`,children:[(0,I.jsxs)(`span`,{className:`relative mx-auto block size-20`,children:[(0,I.jsx)(`span`,{className:`absolute inset-2 -rotate-6 rounded-xl border border-dashed border-primary/25 bg-background`}),(0,I.jsx)(`span`,{className:`absolute inset-3 rotate-6 rounded-xl border border-border bg-background shadow-sm`}),(0,I.jsx)(`span`,{className:`absolute inset-0 grid place-items-center`,children:(0,I.jsx)(ps,{className:`size-7 text-primary`})})]}),(0,I.jsx)(`span`,{className:`mt-2 block text-xs font-medium text-muted-foreground`,children:r(`templateLibrary.blankWorkspace`)})]})}),e?(0,I.jsx)(`span`,{className:`absolute inset-0 grid place-items-center bg-background/70`,children:(0,I.jsx)(Ao,{className:`size-6 animate-spin text-primary`})}):null]}),(0,I.jsx)(`h4`,{className:`mt-3 text-sm font-semibold text-foreground`,children:r(`templateLibrary.newWorkspace`)}),(0,I.jsx)(`p`,{className:`mt-1 truncate text-xs text-muted-foreground`,children:`Start from a clean data workspace.`})]})}function p3({template:e,disabled:t,busy:n,onPreview:r,onUse:i}){return(0,I.jsxs)(`article`,{className:`group min-w-0`,"data-testid":`table-template-card-${e.id}`,children:[(0,I.jsxs)(`div`,{className:`relative`,children:[(0,I.jsx)(`button`,{type:`button`,className:`block w-full text-left disabled:opacity-60`,disabled:t,onClick:r,"data-testid":`table-template-${e.id}`,children:(0,I.jsx)(v3,{template:e,busy:n})}),(0,I.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center gap-2 rounded-xl bg-foreground/0 opacity-0 transition group-hover:bg-foreground/10 group-hover:opacity-100 group-focus-within:opacity-100`,children:[(0,I.jsx)(Rc,{type:`button`,size:`sm`,variant:`secondary`,className:`pointer-events-auto bg-background`,disabled:t,onClick:r,children:`Preview`}),(0,I.jsx)(Rc,{variant:`primary`,type:`button`,size:`sm`,className:`pointer-events-auto`,disabled:t,onClick:i,children:`Use`})]})]}),(0,I.jsx)(`div`,{className:`mt-3 flex min-w-0 items-center gap-2`,children:(0,I.jsx)(`h4`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:e.title})}),(0,I.jsx)(`p`,{className:`mt-1 line-clamp-2 min-h-8 text-xs leading-4 text-muted-foreground`,children:e.description})]})}function m3({template:e,activeResourceId:t,disabled:n,errorMessage:r,onActiveResourceChange:i,onBack:a,onUse:o}){let{t:s}=U(`table`),c=e.snapshot.resources.find(e=>e.id===t)||e.snapshot.resources[0];return(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`table-template-detail`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-4 border-b px-6 py-4`,children:[(0,I.jsxs)(Rc,{type:`button`,variant:`secondary`,size:`sm`,disabled:n,onClick:a,"data-testid":`table-template-back`,children:[(0,I.jsx)(Mi,{className:`size-4`}),`All templates`]}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(o_,{className:`truncate text-xl`,children:e.title}),(0,I.jsx)(s_,{className:`mt-1 line-clamp-2`,children:e.description}),(0,I.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-muted-foreground`,children:[(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,I.jsx)(Ia,{className:`size-3.5`}),`Read-only preview`]}),(0,I.jsxs)(`span`,{children:[e.snapshot.resources.length,` resources`]}),(0,I.jsx)(`span`,{children:e.snapshot.includeData?`Sample data included`:`Structure only`})]})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3`,children:[r?(0,I.jsx)(`span`,{className:`max-w-48 text-xs text-destructive`,role:`alert`,children:r}):null,(0,I.jsxs)(Rc,{variant:`primary`,size:`md`,type:`button`,disabled:n,onClick:o,"data-testid":`table-template-use`,children:[n?(0,I.jsx)(Ao,{className:`size-4 animate-spin`}):(0,I.jsx)(Ws,{className:`size-4`}),`Use template`]})]})]}),(0,I.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-[240px_minmax(0,1fr)] bg-muted/30 max-md:grid-cols-1`,children:[(0,I.jsxs)(`aside`,{className:`min-h-0 overflow-y-auto border-r bg-background p-3 max-md:border-b max-md:border-r-0`,children:[(0,I.jsx)(`div`,{className:`mb-2 px-2 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground`,children:`Included resources`}),(0,I.jsx)(`div`,{className:`space-y-1`,children:e.snapshot.resources.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:K(`flex w-full items-start gap-2 rounded-lg px-2.5 py-2 text-left transition-colors`,e.id===c?.id?`bg-accent text-accent-foreground`:`text-foreground hover:bg-muted`),onClick:()=>i(e.id),"data-testid":`table-template-resource-${e.id}`,children:[(0,I.jsx)(h3,{resource:e}),(0,I.jsxs)(`span`,{className:`min-w-0`,children:[(0,I.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.title}),(0,I.jsx)(`span`,{className:`mt-0.5 block line-clamp-2 text-[11px] leading-4 text-muted-foreground`,children:e.description})]})]},e.id))})]}),(0,I.jsx)(`main`,{className:`min-h-0 overflow-auto p-5`,children:(0,I.jsx)(`div`,{className:`mx-auto min-h-full max-w-5xl overflow-hidden rounded-xl border border-border bg-background shadow-soft`,children:(0,I.jsx)(g3,{template:e,resource:c})})})]})]})}function h3({resource:e}){return e.kind===`dashboard`?(0,I.jsx)(yo,{className:`mt-0.5 size-4 shrink-0`}):(0,I.jsx)(Oa,{className:`mt-0.5 size-4 shrink-0`})}function g3({template:e,resource:t}){let{t:n}=U(`table`),[r,i]=(0,j.useState)(()=>new Map),[a,o]=(0,j.useState)(`idle`);if((0,j.useEffect)(()=>{let t=e.assetManifestPath;if(!t){i(new Map),o(`idle`);return}let n=!1;return i(new Map),o(`loading`),u4(t).then(e=>{n||(i(new Map(e.assets.map(e=>[e.id,e]))),o(`ready`))}).catch(()=>{n||o(`error`)}),()=>{n=!0}},[e.assetManifestPath]),!t)return null;if(t.kind===`table`){let i=e.tables.find(e=>e.title===t.tableTitle)||e.tables[0];return i?(0,I.jsxs)(`div`,{className:`min-h-[520px] bg-background`,children:[(0,I.jsxs)(`div`,{className:`flex items-center justify-between border-b bg-surface-soft px-4 py-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:t.title}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.description})]}),(0,I.jsx)(`span`,{className:`rounded-md border bg-background px-2 py-1 text-xs text-muted-foreground`,children:n(`templateLibrary.readOnly`)})]}),(0,I.jsx)(`div`,{className:`overflow-x-auto`,children:(0,I.jsxs)(`table`,{className:`w-full min-w-[760px] border-collapse text-left text-xs`,children:[(0,I.jsx)(`thead`,{className:`bg-muted/50 text-muted-foreground`,children:(0,I.jsx)(`tr`,{children:i.fields.slice(0,7).map(e=>(0,I.jsx)(`th`,{className:`border-b border-r px-3 py-2 font-medium last:border-r-0`,children:e.title},e.title))})}),(0,I.jsx)(`tbody`,{children:i.records.slice(0,10).map((e,t)=>(0,I.jsx)(`tr`,{className:`text-foreground`,children:i.fields.slice(0,7).map(t=>{let i=e[t.title],o=c4(i);return(0,I.jsx)(`td`,{className:K(`border-b border-r px-3 py-2.5 last:border-r-0`,o?`min-w-36`:`max-w-56 truncate`),children:_3(i,t.title,r,a,n)},t.title)})},t))})]})})]}):null}if(t.kind===`dashboard`){let r=e.dashboards?.find(e=>e.id===t.id);return(0,I.jsxs)(`div`,{className:`min-h-[520px] bg-muted/30 p-5`,children:[(0,I.jsxs)(`div`,{className:`mb-4 flex items-center gap-3 rounded-xl border bg-background px-4 py-3 shadow-sm`,children:[(0,I.jsx)(`span`,{className:`grid size-9 place-items-center rounded-lg bg-primary/10 text-primary`,children:(0,I.jsx)(yo,{className:`size-4`})}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold text-foreground`,children:r?.title||t.title}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`templateLibrary.liveReporting`)})]})]}),(0,I.jsx)(`div`,{className:`grid grid-cols-4 gap-3`,children:[[`20`,`Total tasks`],[`7`,`Completed`],[`8`,`Important`],[`4`,`Not started`]].map(([e,t])=>(0,I.jsxs)(`div`,{className:`rounded-xl border bg-background p-4 shadow-sm`,children:[(0,I.jsx)(`div`,{className:`text-2xl font-semibold text-primary`,children:e}),(0,I.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground`,children:t})]},t))}),(0,I.jsxs)(`div`,{className:`mt-3 grid grid-cols-[0.8fr_1.2fr] gap-3`,children:[(0,I.jsxs)(`div`,{className:`rounded-xl border bg-background p-4 shadow-sm`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium text-foreground`,children:n(`templateLibrary.progressDistribution`)}),(0,I.jsx)(`div`,{className:`mt-5 flex items-center justify-center`,children:(0,I.jsx)(`div`,{className:`grid size-32 place-items-center rounded-full`,style:{background:`conic-gradient(#5645d4 0 35%, #2a9d99 35% 80%, #dd5b00 80% 100%)`},children:(0,I.jsx)(`div`,{className:`size-20 rounded-full bg-background`})})})]}),(0,I.jsxs)(`div`,{className:`rounded-xl border bg-background p-4 shadow-sm`,children:[(0,I.jsx)(`div`,{className:`text-xs font-medium text-foreground`,children:n(`templateLibrary.tasksByAssignee`)}),(0,I.jsx)(`div`,{className:`mt-5 flex h-32 items-end gap-2`,children:[38,72,48,88,55,34,62].map((e,t)=>(0,I.jsx)(`div`,{className:`flex-1 rounded-t bg-primary/70`,style:{height:`${e}%`}},`${e}-${t}`))})]})]})]})}return null}function _3(e,t,n,r,i){if(c4(e)){let a=e.assetIds.map(e=>n.get(e)).filter(e=>!!e);return a.length?(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[a.slice(0,2).map((e,n)=>e.mimeType.startsWith(`image/`)?(0,I.jsx)(`img`,{alt:`${t} preview ${n+1}`,className:`h-12 w-16 shrink-0 rounded-md border bg-muted object-cover`,loading:`lazy`,src:o4(e.path),"data-testid":`table-template-preview-asset-${e.id}`},e.id):(0,I.jsx)(`span`,{className:`max-w-32 truncate text-xs text-muted-foreground`,children:e.sourceName},e.id)),a.length>2?(0,I.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`+`,a.length-2]}):null]}):r===`loading`?(0,I.jsx)(Ao,{className:`size-4 animate-spin text-muted-foreground`,"aria-label":i(`templateLibrary.previewLoading`)}):(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`templateLibrary.previewUnavailable`)})}return Array.isArray(e)?e.join(`, `):typeof e==`boolean`?e?`Yes`:`No`:e==null?``:String(e)}function v3({template:e,busy:t}){return(0,I.jsxs)(`span`,{className:`relative block aspect-[16/9] overflow-hidden rounded-xl border border-border bg-muted/40 transition group-hover:border-primary/35 group-hover:shadow-soft`,children:[(0,I.jsx)(`img`,{alt:``,className:`size-full object-cover transition duration-300 group-hover:scale-[1.02]`,src:o4(e.coverImage)}),t?(0,I.jsx)(`span`,{className:`absolute inset-0 grid place-items-center bg-background/70 backdrop-blur-[1px]`,children:(0,I.jsx)(Ao,{className:`size-6 animate-spin text-primary`})}):null]})}var y3=`.csv,.tsv,.xlsx,text/csv,text/tab-separated-values,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,b3=`flex h-7 max-w-48 shrink-0 items-center gap-1.5 truncate rounded-lg px-2.5 text-[13px] font-medium transition-colors`;function x3({tables:e,dashboards:t,shown:n,onSelect:r,source:i,readOnly:a,documentPath:o}){let{t:s}=U(`table`),[c,l]=(0,j.useState)(!1),[u,d]=(0,j.useState)(null),[f,p]=(0,j.useState)(0),m=(0,j.useRef)(null),[h,g]=(0,j.useState)(!1);function _(e){g(!1),window.dispatchEvent(new CustomEvent(mC,{detail:{documentPath:o,action:e}}))}async function v(e){try{return r({kind:`table`,id:await S4(i,await i.documents.get({documentId:0}),e)}),l(!1),!0}catch{return!1}}async function y(e){e&&(p((await i.documents.get({documentId:0})).id),d(e))}return(0,I.jsxs)(`nav`,{className:`flex min-w-0 flex-1 items-center gap-1 overflow-x-auto px-2`,"aria-label":s(`kit.tables`),"data-testid":`table-tabs`,children:[e.map(e=>{let t=n?.kind===`table`&&n.id===e.id;return(0,I.jsx)(`button`,{type:`button`,className:K(b3,t?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`),"aria-current":t?`page`:void 0,onClick:()=>r({kind:`table`,id:e.id}),"data-testid":`table-tab-${e.id}`,children:(0,I.jsx)(`span`,{className:`truncate`,children:e.title})},`table-${e.id}`)}),t.map(e=>{let t=n?.kind===`dashboard`&&n.id===e.id;return(0,I.jsxs)(`button`,{type:`button`,className:K(b3,t?`bg-accent text-accent-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`),"aria-current":t?`page`:void 0,onClick:()=>r({kind:`dashboard`,id:e.id}),"data-testid":`dashboard-tab-${e.id}`,children:[(0,I.jsx)(yo,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`truncate`,children:e.title})]},`dashboard-${e.id}`)}),n?.kind===`table`?(0,I.jsxs)(c_,{open:h,onOpenChange:g,children:[(0,I.jsx)(l_,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`grid size-7 shrink-0 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,title:s(`kit.export`),"aria-label":s(`kit.export`),"aria-expanded":h,"data-testid":`table-export`,children:(0,I.jsx)(Ma,{className:`size-4`})})}),(0,I.jsxs)(u_,{align:`start`,sideOffset:6,className:`data-inline-view-tab-menu`,role:`menu`,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>_(`export_csv`),"data-testid":`table-export-csv`,children:(0,I.jsx)(`span`,{children:s(`kit.exportCsv`)})}),(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>_(`export_markdown`),"data-testid":`table-export-md`,children:(0,I.jsx)(`span`,{children:s(`kit.exportMarkdown`)})})]})]}):null,a?null:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,className:`grid size-7 shrink-0 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,title:s(`kit.addTable`),"aria-label":s(`kit.addTable`),onClick:()=>l(!0),"data-testid":`table-add`,children:(0,I.jsx)(ps,{className:`size-4`})}),(0,I.jsx)(`button`,{type:`button`,className:`grid size-7 shrink-0 place-items-center rounded-lg text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,title:s(`kit.importTable`),"aria-label":s(`kit.importTable`),onClick:()=>m.current?.click(),"data-testid":`table-import`,children:(0,I.jsx)(Ga,{className:`size-4`})}),(0,I.jsx)(`input`,{ref:m,type:`file`,accept:y3,className:`hidden`,onChange:e=>{y(e.target.files?.[0]||null),e.currentTarget.value=``}}),c?(0,I.jsx)(d3,{open:!0,onOpenChange:l,onSelect:v}):null,(0,I.jsx)(UA,{open:!!u,file:u,target:{kind:`new_table`,documentId:f},onOpenChange:e=>{e||d(null)},onCompleted:e=>{e.table_id!=null&&r({kind:`table`,id:e.table_id})}})]})]})}function S3(e){let t=/^(tables|dashboards)\/(.+)$/.exec(e?.path??``);if(!t)return null;if(t[1]===`dashboards`)return{kind:`dashboard`,id:t[2]};let n=Number(t[2]);return Number.isInteger(n)&&n>0?{kind:`table`,id:n}:null}function C3(e,t,n){return e?.kind===`table`&&t.some(t=>t.id===e.id)||e?.kind===`dashboard`&&n.some(t=>t.id===e.id)?e:t[0]?{kind:`table`,id:t[0].id}:n[0]?{kind:`dashboard`,id:n[0].id}:null}var w3=e=>e===`edit.undo`||e===`edit.redo`,T3=[];function E3(){(0,j.useEffect)(()=>{let e=document.documentElement,t=()=>e.classList.toggle(`dark`,e.dataset.colorScheme===`dark`);t();let n=new MutationObserver(t);return n.observe(e,{attributes:!0,attributeFilter:[`data-color-scheme`]}),()=>n.disconnect()},[])}function D3({host:e,i18n:t}){E3();let n=(0,j.useMemo)(()=>ib(U2,e.init.locale),[e]),r=Wb(e,(0,j.useMemo)(B2,[]),V2),i=ub(r,e,n,`table`),a=e.init.document.path,o=e.readOnly===!0||r.state?.readOnly!=null,s=(0,j.useRef)(r);s.current=r;let c=(0,j.useMemo)(()=>new Set,[]);(0,j.useEffect)(()=>r.doc?.onFonts(()=>c.forEach(e=>e())),[r.doc,c]);let l=(0,j.useMemo)(()=>z2({run:(e,t,n)=>s.current.run(e,t,null,{refresh:n}),invoke:async(e,...t)=>{let n=s.current.doc;if(!n)throw Error(`The table is not open.`);return n.invoke(e,...t)},revision:()=>s.current.doc?.info.revision??0,fonts:{pending:()=>(s.current.doc?.fontsPending??0)>0,subscribe:e=>(c.add(e),()=>c.delete(e)),loadAll:async()=>s.current.doc?.loadFonts()}},a),[a,c]),u=r.doc,d=(0,j.useRef)(u);(0,j.useEffect)(()=>{u&&(d.current&&d.current!==u&&l.reopened(u.info.revision),d.current=u)},[u,l]);let f=r.doc?.info.revision;(0,j.useEffect)(()=>{f!=null&&l.observe(f)},[l,f]);let p=(0,j.useMemo)(()=>(t,n)=>a4(async(e,t)=>{let n=await s.current.run(e,t,null,{refresh:`none`});if(n==null)throw Error(`The table is not open.`);return n},e,t,n,s.current.state?.tables?.length??1),[e]),m=(0,j.useMemo)(()=>{let n=t.getFixedT(null,`table`);return e4(e.init.locale,l,H2(e),{designFailed:n(`kit.designFailed`),workflowFailed:n(`kit.workflowFailed`),aiUnavailable:n(`kit.aiUnavailable`),aiSetUp:n(`kit.aiSetUp`),settingsFailed:n(`kit.settingsFailed`)},p)},[e,t,l,p]),h=r.state?.tables??[],g=r.state?.dashboards??[],[_,v]=(0,j.useState)(()=>S3(e.view));(0,j.useEffect)(()=>e.onReveal(e=>{let t=S3(e);t&&v(t)}),[e]);let y=C3(_,h,g);return(0,I.jsx)($S,{i18n:t,children:(0,I.jsx)(__,{children:(0,I.jsx)(iC,{value:l,children:(0,I.jsx)(sC,{value:m,children:(0,I.jsx)(fb,{editor:i,children:(0,I.jsxs)(Ax,{tabs:T3,title:(0,I.jsx)(`span`,{className:`table-kit-title`,"data-testid":`table-title`,children:e.init.document.name}),hiddenCommands:w3,statusBar:!1,children:[r.doc?(0,I.jsx)(gx,{children:(0,I.jsx)(`div`,{className:`table-kit-tabs`,children:(0,I.jsx)(x3,{tables:h,dashboards:g,shown:y,onSelect:v,source:l,readOnly:o,documentPath:a})})}):null,(0,I.jsx)(`div`,{className:`table-kit-body`,"data-testid":`table-body`,children:r.doc&&y?.kind===`dashboard`?(0,I.jsx)(y2,{dashboardId:y.id,documentPath:a,topbarEnd:(0,I.jsx)(O3,{})},y.id):r.doc?(0,I.jsx)(C$,{documentPath:a,markerContent:``,pinnedTableId:y?.kind===`table`?y.id:void 0,readOnly:o,footerEnd:(0,I.jsx)(O3,{})}):r.failure?(0,I.jsxs)(`div`,{className:`kui-message`,"data-testid":`table-failed`,children:[n(`openFailed`),`: `,r.failure]}):(0,I.jsx)(`div`,{className:`kui-message kui-muted`,children:n(`opening`)})})]})})})})})})}function O3(){let{session:e,t,testId:n}=pb();return(0,I.jsxs)(I.Fragment,{children:[e.dirty?(0,I.jsx)(`span`,{"data-testid":`${n}-unsaved`,children:t(`unsaved`)}):null,e.editedBy?.by===`agent`?(0,I.jsxs)(`span`,{className:`kui-agent-edited`,"data-testid":`${n}-agent-edited`,children:[(0,I.jsx)(Ws,{size:12,strokeWidth:Lc,"aria-hidden":`true`}),t(`agentEdited`)]}):e.editedBy?.by===`system`?(0,I.jsx)(`span`,{className:`kui-host-edited`,"data-testid":`${n}-host-edited`,title:e.editedBy.originLabel,children:t(`hostEdited`)}):null]})}var k3=[`ai`,`replica`],A3=`modulepreload`,j3=function(e,t){return new URL(e,t).href},M3={},N3=function(e){return e.pathname.endsWith(`.css`)},P3=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},F3=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,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}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=j3(t,n);let r=s(t),i=N3(r);return P3(M3,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:A3,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}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)})},I3=Object.assign({"../locales/en-US/common.json":()=>F3(()=>import(`./common-DBFkHMZV.js`).then(e=>e.default),[],import.meta.url),"../locales/en-US/table.json":()=>F3(()=>import(`./table-DpGGBEXD.js`).then(e=>e.default),[],import.meta.url),"../locales/es-ES/common.json":()=>F3(()=>import(`./common-CrgxgxUu.js`).then(e=>e.default),[],import.meta.url),"../locales/es-ES/table.json":()=>F3(()=>import(`./table-Bpba-GrO.js`).then(e=>e.default),[],import.meta.url),"../locales/fr-FR/common.json":()=>F3(()=>import(`./common-BMUmnQ1g.js`).then(e=>e.default),[],import.meta.url),"../locales/fr-FR/table.json":()=>F3(()=>import(`./table--j5_5jI6.js`).then(e=>e.default),[],import.meta.url),"../locales/pt-BR/common.json":()=>F3(()=>import(`./common-B-bp9Ip3.js`).then(e=>e.default),[],import.meta.url),"../locales/pt-BR/table.json":()=>F3(()=>import(`./table-CpZGkC_z.js`).then(e=>e.default),[],import.meta.url),"../locales/ru-RU/common.json":()=>F3(()=>import(`./common-Bhm8gfvH.js`).then(e=>e.default),[],import.meta.url),"../locales/ru-RU/table.json":()=>F3(()=>import(`./table-B5yY2dYW.js`).then(e=>e.default),[],import.meta.url),"../locales/zh-CN/common.json":()=>F3(()=>import(`./common-CeDowx6y.js`).then(e=>e.default),[],import.meta.url),"../locales/zh-CN/table.json":()=>F3(()=>import(`./table-CqH5qF2L.js`).then(e=>e.default),[],import.meta.url)});function L3(){return[...new Set(Object.keys(I3).map(e=>e.split(`/`).at(-2)??``))].filter(Boolean)}function R3(e){let t=L3();if(t.includes(e))return e;let n=e.split(`-`)[0];return t.find(e=>e.split(`-`)[0]===n)??`en-US`}async function z3(e){let t={};for(let n of[`table`,`common`]){let r=I3[`../locales/${e}/${n}.json`];r&&(t[n]=await r())}return t}async function B3(e){let t=R3(e),n={"en-US":await z3(`en-US`)};t!==`en-US`&&(n[t]=await z3(t));let r=OS();return await r.use(qS).init({resources:n,lng:t,fallbackLng:`en-US`,defaultNS:`table`,ns:[`table`,`common`],interpolation:{escapeValue:!1},returnNull:!1,react:{useSuspense:!1}}),r}var V3={$schema:`https://github.com/KitionAI/kition-sdk/schemas/kit.schema.json`,khp:`1.0`,level:`basic`,id:`kit.table`,name:`Table`,version:`0.1.1`,license:`Apache-2.0`,distribution:`default`,capabilities:[`kdm`],engine:{runtime:`rust-wasm`,module:`kition_table_kit`,class:`TableDocument`,contract:2,crate:`kition-table-kit`,editorState:[]},formats:[{id:`ktable`,extensions:[`ktable`],mime:`application/vnd.kition.table+sqlite3`,role:`edit`}],creates:[{id:`table`,extension:`ktable`,baseName:`Untitled table`,size:{width:640,height:420}}],exports:[{extension:`csv`,mime:`text/csv`,command:`table.file.export`},{extension:`md`,mime:`text/markdown`,command:`table.file.export`}],outline:{command:`table.file.outline`},extras:{call:{params:[`method`,`paramsJson`],returns:`string`,description:`One data-document request (kition-table-api): answers { result, change } as JSON.`},takeImported:{params:[],returns:`string`,description:`The TableChanges of replica changes imported since the last call, as a JSON array of table/changed params.`},gridOpen:{params:[`paramsJson`],returns:`Uint8Array`,description:`Arranges a view for the editor ({tableId, viewId?, config?, query?, collapsed?}): the axis (kition-table-arrange format v2: record ids in order, group headers with counts).`},gridHits:{params:[`paramsJson`],returns:`Uint8Array`,description:`Which cells of a run of the arrangement's rows hold the search ({epoch, from, count, fieldIds}): kition-table-arrange hits format v1, a bitmask over the fields per row; an error for an epoch that is not the latest.`},gridSync:{params:[],returns:`Uint8Array`,description:`The editor's arrangement brought to the document's current state: the new axis, or no bytes when it is the same.`},gridStats:{params:[],returns:`string`,description:`How long arranging took (whole arrangements and relocations) and how long the grid's bands took (bands), as JSON, for performance tests.`},gridAxes:{params:[`axis`,`paramsJson`],returns:`string`,description:`Lays out an axis from gridOpen or gridSync for the grid ({tableId, viewId?, config?, zone?, theme?, brand?}; config is the view config as the editor holds it, unsaved keys first; zone the page's time zone as [from ms, minutes east of UTC] changes, where dates are read): row heights as runs, columns, header and row head sizes, band sizes, skeleton colors, the overlay's colors, sizes and row head control icons, and the group headers' ids, as JSON.`},gridRecords:{params:[`paramsJson`],returns:`string`,description:`The records of some ids for the grid to edit ({tableId, ids, fields?}): [{id, row_key, values}] in the order asked, values only of the fields named when some are, ids that name no record left out.`},gridClear:{params:[`paramsJson`,`ids`],returns:`string`,description:`Clears many records for the grid ({tableId, values}, the records' ids as a Float64Array): values (field name to empty value) set on each record of the table in one transact of one cells.set, the row keys found by the engine; answers { result, change } as JSON, result.cleared the records written.`},gridRows:{params:[],returns:`Uint8Array`,description:`What each linear row of the grid gridAxes laid out is (a record and its id, a group header, an add row), for the page's hit testing and selection.`},gridBands:{params:[`epoch`,`keys`,`dpr`,`session`,`draft`],returns:`Uint8Array`,description:`The grid's bands (layer, column band, row band triples, as a Uint32Array) of arrangement epoch at dpr as display lists (format v1), drafts when draft, with the resources (icon and emoji tiles, pictures) page session session does not hold yet, in one batch.`},gridRaster:{params:[`epoch`,`layer`,`colBand`,`rowBand`,`dpr`],returns:`Uint8Array`,description:`One band as the engine rasterizes it (width, height, RGBA8), for the parity test.`},gridPicture:{params:[`bytes`,`maxSide`],returns:`Uint8Array`,description:`A picture's bytes decoded as the headless picture decodes them (PNG, JPEG, WebP, GIF's first frame, SVG drawn by resvg, HEIC): width and height (u32 each), then straight RGBA8, at most maxSide on its longest side; no bytes for another format. For the pictures the page's browser does not decode.`},gridMeasure:{params:[`asksJson`],returns:`string`,description:`How the grid splits text into runs of one face and how wide each run is, as JSON, for the width test.`},gridSpecimen:{params:[`asksJson`,`dpr`],returns:`Uint8Array`,description:`Text of any size and weight ([{text, weight, size}]) set one line each by the grid's shaping and text ops, as one display list (format v1), and that list rasterized as gridRaster rasterizes a band (list length u32, the list padded to 4 bytes, width, height, RGBA8), for the parity test: the grid's own text is under Inter's optical size floor.`},gridOpticalSizing:{params:[`sizing`],returns:`boolean`,description:`The optical sizing the grid measures and draws Inter with, the one the page's Canvas uses: auto (the default; the optical size follows the font size) or fixed-default (Inter's default optical size at every size); its bands, drafts, gridMeasure and gridRaster use it. Answers whether it changed; an error for another name.`},gridSummary:{params:[`paramsJson`],returns:`string`,description:`The numbers of some fields over the editor's arrangement ({fields}): [{field, count, sum}] as JSON, for the footer's sums and averages.`}},ui:{mode:`embedded`,entry:`ui/index.html`,menus:[`Edit`],layout:`canvas`,brand:{light:`#0c8375`,dark:`#3fd1bf`}},agent:{prefix:`table`,tools:`document`,drafts:!0,objectModel:!0,layout:!1,parts:[`table`,`view`],render:`table.file.render`,export:{command:`table.file.export`,data:`data`},describe:{noun:`table file`,fileTypes:`.ktable`,reports:"its tables with their fields (names, types, choices, link targets), views (filters, sorts, groups), record counts and first records (ids and values, by the ids the commands take; the rest a page at a time with `table.read`), and its dashboards",covers:"tables, fields, records, views, filters, sorting, grouping, links, dashboards, and more; `table.records.create` adds a record; a new file holds one starter table (table 1, `Table`: title, status, notes) that `table.tables.delete` removes",queries:"`records`, `fields`, or `views`",example:`table.records.create`,use:`structured, spreadsheet-like results`}},headless:{executable:`kition-table`,protocol:`kition-kit/1`,features:[`view.describe`,`document.check`,`document.identity`,`model.open`,`model.import`,`model.export`,`model.save`,`model.describe`,`model.batch`]},model:{schema:`model/schema.json`,schemaVersion:1},collaboration:{merge:[`database`,`binary`],leases:[],serverValidation:!1},objectModel:{namespace:`Table`}},H3=(0,me.createRoot)(document.getElementById(`root`)),U3=window.setTimeout(()=>{let e=ib(U2,navigator.language);H3.render((0,I.jsx)(`div`,{className:`kui-alone`,children:e(`noHost`)}))},3e3);Av({id:`kit.table`,version:V3.version,capabilities:k3,brand:V3.ui.brand}).then(async e=>{window.clearTimeout(U3);let t=await B3(e.init.locale);H3.render((0,I.jsx)(D3,{host:e,i18n:t}))});