@hattoriai/poney 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,944 @@
1
+ var FA=Object.defineProperty;var BA=(t,e,n)=>e in t?FA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var sn=(t,e,n)=>BA(t,typeof e!="symbol"?e+"":e,n);function VA(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in t)){const i=Object.getOwnPropertyDescriptor(r,s);i&&Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var KG=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function KS(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var JS={exports:{}},cp={},GS={exports:{}},Fe={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var jd=Symbol.for("react.element"),WA=Symbol.for("react.portal"),UA=Symbol.for("react.fragment"),ZA=Symbol.for("react.strict_mode"),HA=Symbol.for("react.profiler"),qA=Symbol.for("react.provider"),KA=Symbol.for("react.context"),JA=Symbol.for("react.forward_ref"),GA=Symbol.for("react.suspense"),YA=Symbol.for("react.memo"),QA=Symbol.for("react.lazy"),G0=Symbol.iterator;function XA(t){return t===null||typeof t!="object"?null:(t=G0&&t[G0]||t["@@iterator"],typeof t=="function"?t:null)}var YS={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},QS=Object.assign,XS={};function Nl(t,e,n){this.props=t,this.context=e,this.refs=XS,this.updater=n||YS}Nl.prototype.isReactComponent={};Nl.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};Nl.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function eC(){}eC.prototype=Nl.prototype;function kv(t,e,n){this.props=t,this.context=e,this.refs=XS,this.updater=n||YS}var wv=kv.prototype=new eC;wv.constructor=kv;QS(wv,Nl.prototype);wv.isPureReactComponent=!0;var Y0=Array.isArray,tC=Object.prototype.hasOwnProperty,bv={current:null},nC={key:!0,ref:!0,__self:!0,__source:!0};function rC(t,e,n){var r,s={},i=null,o=null;if(e!=null)for(r in e.ref!==void 0&&(o=e.ref),e.key!==void 0&&(i=""+e.key),e)tC.call(e,r)&&!nC.hasOwnProperty(r)&&(s[r]=e[r]);var a=arguments.length-2;if(a===1)s.children=n;else if(1<a){for(var l=Array(a),c=0;c<a;c++)l[c]=arguments[c+2];s.children=l}if(t&&t.defaultProps)for(r in a=t.defaultProps,a)s[r]===void 0&&(s[r]=a[r]);return{$$typeof:jd,type:t,key:i,ref:o,props:s,_owner:bv.current}}function e5(t,e){return{$$typeof:jd,type:t.type,key:e,ref:t.ref,props:t.props,_owner:t._owner}}function Sv(t){return typeof t=="object"&&t!==null&&t.$$typeof===jd}function t5(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(n){return e[n]})}var Q0=/\/+/g;function um(t,e){return typeof t=="object"&&t!==null&&t.key!=null?t5(""+t.key):e.toString(36)}function Uu(t,e,n,r,s){var i=typeof t;(i==="undefined"||i==="boolean")&&(t=null);var o=!1;if(t===null)o=!0;else switch(i){case"string":case"number":o=!0;break;case"object":switch(t.$$typeof){case jd:case WA:o=!0}}if(o)return o=t,s=s(o),t=r===""?"."+um(o,0):r,Y0(s)?(n="",t!=null&&(n=t.replace(Q0,"$&/")+"/"),Uu(s,e,n,"",function(c){return c})):s!=null&&(Sv(s)&&(s=e5(s,n+(!s.key||o&&o.key===s.key?"":(""+s.key).replace(Q0,"$&/")+"/")+t)),e.push(s)),1;if(o=0,r=r===""?".":r+":",Y0(t))for(var a=0;a<t.length;a++){i=t[a];var l=r+um(i,a);o+=Uu(i,e,n,l,s)}else if(l=XA(t),typeof l=="function")for(t=l.call(t),a=0;!(i=t.next()).done;)i=i.value,l=r+um(i,a++),o+=Uu(i,e,n,l,s);else if(i==="object")throw e=String(t),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.");return o}function eu(t,e,n){if(t==null)return t;var r=[],s=0;return Uu(t,r,"","",function(i){return e.call(n,i,s++)}),r}function n5(t){if(t._status===-1){var e=t._result;e=e(),e.then(function(n){(t._status===0||t._status===-1)&&(t._status=1,t._result=n)},function(n){(t._status===0||t._status===-1)&&(t._status=2,t._result=n)}),t._status===-1&&(t._status=0,t._result=e)}if(t._status===1)return t._result.default;throw t._result}var En={current:null},Zu={transition:null},r5={ReactCurrentDispatcher:En,ReactCurrentBatchConfig:Zu,ReactCurrentOwner:bv};function sC(){throw Error("act(...) is not supported in production builds of React.")}Fe.Children={map:eu,forEach:function(t,e,n){eu(t,function(){e.apply(this,arguments)},n)},count:function(t){var e=0;return eu(t,function(){e++}),e},toArray:function(t){return eu(t,function(e){return e})||[]},only:function(t){if(!Sv(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};Fe.Component=Nl;Fe.Fragment=UA;Fe.Profiler=HA;Fe.PureComponent=kv;Fe.StrictMode=ZA;Fe.Suspense=GA;Fe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=r5;Fe.act=sC;Fe.cloneElement=function(t,e,n){if(t==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var r=QS({},t.props),s=t.key,i=t.ref,o=t._owner;if(e!=null){if(e.ref!==void 0&&(i=e.ref,o=bv.current),e.key!==void 0&&(s=""+e.key),t.type&&t.type.defaultProps)var a=t.type.defaultProps;for(l in e)tC.call(e,l)&&!nC.hasOwnProperty(l)&&(r[l]=e[l]===void 0&&a!==void 0?a[l]:e[l])}var l=arguments.length-2;if(l===1)r.children=n;else if(1<l){a=Array(l);for(var c=0;c<l;c++)a[c]=arguments[c+2];r.children=a}return{$$typeof:jd,type:t.type,key:s,ref:i,props:r,_owner:o}};Fe.createContext=function(t){return t={$$typeof:KA,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},t.Provider={$$typeof:qA,_context:t},t.Consumer=t};Fe.createElement=rC;Fe.createFactory=function(t){var e=rC.bind(null,t);return e.type=t,e};Fe.createRef=function(){return{current:null}};Fe.forwardRef=function(t){return{$$typeof:JA,render:t}};Fe.isValidElement=Sv;Fe.lazy=function(t){return{$$typeof:QA,_payload:{_status:-1,_result:t},_init:n5}};Fe.memo=function(t,e){return{$$typeof:YA,type:t,compare:e===void 0?null:e}};Fe.startTransition=function(t){var e=Zu.transition;Zu.transition={};try{t()}finally{Zu.transition=e}};Fe.unstable_act=sC;Fe.useCallback=function(t,e){return En.current.useCallback(t,e)};Fe.useContext=function(t){return En.current.useContext(t)};Fe.useDebugValue=function(){};Fe.useDeferredValue=function(t){return En.current.useDeferredValue(t)};Fe.useEffect=function(t,e){return En.current.useEffect(t,e)};Fe.useId=function(){return En.current.useId()};Fe.useImperativeHandle=function(t,e,n){return En.current.useImperativeHandle(t,e,n)};Fe.useInsertionEffect=function(t,e){return En.current.useInsertionEffect(t,e)};Fe.useLayoutEffect=function(t,e){return En.current.useLayoutEffect(t,e)};Fe.useMemo=function(t,e){return En.current.useMemo(t,e)};Fe.useReducer=function(t,e,n){return En.current.useReducer(t,e,n)};Fe.useRef=function(t){return En.current.useRef(t)};Fe.useState=function(t){return En.current.useState(t)};Fe.useSyncExternalStore=function(t,e,n){return En.current.useSyncExternalStore(t,e,n)};Fe.useTransition=function(){return En.current.useTransition()};Fe.version="18.3.1";GS.exports=Fe;var b=GS.exports;const _r=KS(b),El=VA({__proto__:null,default:_r},[b]);/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var s5=b,i5=Symbol.for("react.element"),o5=Symbol.for("react.fragment"),a5=Object.prototype.hasOwnProperty,l5=s5.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c5={key:!0,ref:!0,__self:!0,__source:!0};function iC(t,e,n){var r,s={},i=null,o=null;n!==void 0&&(i=""+n),e.key!==void 0&&(i=""+e.key),e.ref!==void 0&&(o=e.ref);for(r in e)a5.call(e,r)&&!c5.hasOwnProperty(r)&&(s[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)s[r]===void 0&&(s[r]=e[r]);return{$$typeof:i5,type:t,key:i,ref:o,props:s,_owner:l5.current}}cp.Fragment=o5;cp.jsx=iC;cp.jsxs=iC;JS.exports=cp;var f=JS.exports,oC={exports:{}},Xn={},aC={exports:{}},lC={};/**
18
+ * @license React
19
+ * scheduler.production.min.js
20
+ *
21
+ * Copyright (c) Facebook, Inc. and its affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */(function(t){function e(A,V){var J=A.length;A.push(V);e:for(;0<J;){var X=J-1>>>1,z=A[X];if(0<s(z,V))A[X]=V,A[J]=z,J=X;else break e}}function n(A){return A.length===0?null:A[0]}function r(A){if(A.length===0)return null;var V=A[0],J=A.pop();if(J!==V){A[0]=J;e:for(var X=0,z=A.length,F=z>>>1;X<F;){var U=2*(X+1)-1,K=A[U],O=U+1,P=A[O];if(0>s(K,J))O<z&&0>s(P,K)?(A[X]=P,A[O]=J,X=O):(A[X]=K,A[U]=J,X=U);else if(O<z&&0>s(P,J))A[X]=P,A[O]=J,X=O;else break e}}return V}function s(A,V){var J=A.sortIndex-V.sortIndex;return J!==0?J:A.id-V.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var o=Date,a=o.now();t.unstable_now=function(){return o.now()-a}}var l=[],c=[],d=1,u=null,h=3,m=!1,g=!1,p=!1,x=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function k(A){for(var V=n(c);V!==null;){if(V.callback===null)r(c);else if(V.startTime<=A)r(c),V.sortIndex=V.expirationTime,e(l,V);else break;V=n(c)}}function w(A){if(p=!1,k(A),!g)if(n(l)!==null)g=!0,T(C);else{var V=n(c);V!==null&&M(w,V.startTime-A)}}function C(A,V){g=!1,p&&(p=!1,y(S),S=-1),m=!0;var J=h;try{for(k(V),u=n(l);u!==null&&(!(u.expirationTime>V)||A&&!I());){var X=u.callback;if(typeof X=="function"){u.callback=null,h=u.priorityLevel;var z=X(u.expirationTime<=V);V=t.unstable_now(),typeof z=="function"?u.callback=z:u===n(l)&&r(l),k(V)}else r(l);u=n(l)}if(u!==null)var F=!0;else{var U=n(c);U!==null&&M(w,U.startTime-V),F=!1}return F}finally{u=null,h=J,m=!1}}var E=!1,_=null,S=-1,j=5,$=-1;function I(){return!(t.unstable_now()-$<j)}function L(){if(_!==null){var A=t.unstable_now();$=A;var V=!0;try{V=_(!0,A)}finally{V?D():(E=!1,_=null)}}else E=!1}var D;if(typeof v=="function")D=function(){v(L)};else if(typeof MessageChannel<"u"){var B=new MessageChannel,H=B.port2;B.port1.onmessage=L,D=function(){H.postMessage(null)}}else D=function(){x(L,0)};function T(A){_=A,E||(E=!0,D())}function M(A,V){S=x(function(){A(t.unstable_now())},V)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(A){A.callback=null},t.unstable_continueExecution=function(){g||m||(g=!0,T(C))},t.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):j=0<A?Math.floor(1e3/A):5},t.unstable_getCurrentPriorityLevel=function(){return h},t.unstable_getFirstCallbackNode=function(){return n(l)},t.unstable_next=function(A){switch(h){case 1:case 2:case 3:var V=3;break;default:V=h}var J=h;h=V;try{return A()}finally{h=J}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(A,V){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var J=h;h=A;try{return V()}finally{h=J}},t.unstable_scheduleCallback=function(A,V,J){var X=t.unstable_now();switch(typeof J=="object"&&J!==null?(J=J.delay,J=typeof J=="number"&&0<J?X+J:X):J=X,A){case 1:var z=-1;break;case 2:z=250;break;case 5:z=1073741823;break;case 4:z=1e4;break;default:z=5e3}return z=J+z,A={id:d++,callback:V,priorityLevel:A,startTime:J,expirationTime:z,sortIndex:-1},J>X?(A.sortIndex=J,e(c,A),n(l)===null&&A===n(c)&&(p?(y(S),S=-1):p=!0,M(w,J-X))):(A.sortIndex=z,e(l,A),g||m||(g=!0,T(C))),A},t.unstable_shouldYield=I,t.unstable_wrapCallback=function(A){var V=h;return function(){var J=h;h=V;try{return A.apply(this,arguments)}finally{h=J}}}})(lC);aC.exports=lC;var d5=aC.exports;/**
26
+ * @license React
27
+ * react-dom.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var u5=b,Gn=d5;function ee(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n<arguments.length;n++)e+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+t+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var cC=new Set,Fc={};function Ho(t,e){Za(t,e),Za(t+"Capture",e)}function Za(t,e){for(Fc[t]=e,t=0;t<e.length;t++)cC.add(e[t])}var Os=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Zg=Object.prototype.hasOwnProperty,f5=/^[: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]*$/,X0={},ek={};function h5(t){return Zg.call(ek,t)?!0:Zg.call(X0,t)?!1:f5.test(t)?ek[t]=!0:(X0[t]=!0,!1)}function p5(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function m5(t,e,n,r){if(e===null||typeof e>"u"||p5(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function _n(t,e,n,r,s,i,o){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=i,this.removeEmptyString=o}var nn={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){nn[t]=new _n(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];nn[e]=new _n(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){nn[t]=new _n(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){nn[t]=new _n(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){nn[t]=new _n(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){nn[t]=new _n(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){nn[t]=new _n(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){nn[t]=new _n(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){nn[t]=new _n(t,5,!1,t.toLowerCase(),null,!1,!1)});var Cv=/[\-:]([a-z])/g;function Nv(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(Cv,Nv);nn[e]=new _n(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(Cv,Nv);nn[e]=new _n(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(Cv,Nv);nn[e]=new _n(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){nn[t]=new _n(t,1,!1,t.toLowerCase(),null,!1,!1)});nn.xlinkHref=new _n("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){nn[t]=new _n(t,1,!1,t.toLowerCase(),null,!0,!0)});function Ev(t,e,n,r){var s=nn.hasOwnProperty(e)?nn[e]:null;(s!==null?s.type!==0:r||!(2<e.length)||e[0]!=="o"&&e[0]!=="O"||e[1]!=="n"&&e[1]!=="N")&&(m5(e,n,s,r)&&(n=null),r||s===null?h5(e)&&(n===null?t.removeAttribute(e):t.setAttribute(e,""+n)):s.mustUseProperty?t[s.propertyName]=n===null?s.type===3?!1:"":n:(e=s.attributeName,r=s.attributeNamespace,n===null?t.removeAttribute(e):(s=s.type,n=s===3||s===4&&n===!0?"":""+n,r?t.setAttributeNS(r,e,n):t.setAttribute(e,n))))}var Bs=u5.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,tu=Symbol.for("react.element"),ka=Symbol.for("react.portal"),wa=Symbol.for("react.fragment"),_v=Symbol.for("react.strict_mode"),Hg=Symbol.for("react.profiler"),dC=Symbol.for("react.provider"),uC=Symbol.for("react.context"),jv=Symbol.for("react.forward_ref"),qg=Symbol.for("react.suspense"),Kg=Symbol.for("react.suspense_list"),$v=Symbol.for("react.memo"),Gs=Symbol.for("react.lazy"),fC=Symbol.for("react.offscreen"),tk=Symbol.iterator;function zl(t){return t===null||typeof t!="object"?null:(t=tk&&t[tk]||t["@@iterator"],typeof t=="function"?t:null)}var mt=Object.assign,fm;function tc(t){if(fm===void 0)try{throw Error()}catch(n){var e=n.stack.trim().match(/\n( *(at )?)/);fm=e&&e[1]||""}return`
34
+ `+fm+t}var hm=!1;function pm(t,e){if(!t||hm)return"";hm=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(e)if(e=function(){throw Error()},Object.defineProperty(e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(e,[])}catch(c){var r=c}Reflect.construct(t,[],e)}else{try{e.call()}catch(c){r=c}t.call(e.prototype)}else{try{throw Error()}catch(c){r=c}t()}}catch(c){if(c&&r&&typeof c.stack=="string"){for(var s=c.stack.split(`
35
+ `),i=r.stack.split(`
36
+ `),o=s.length-1,a=i.length-1;1<=o&&0<=a&&s[o]!==i[a];)a--;for(;1<=o&&0<=a;o--,a--)if(s[o]!==i[a]){if(o!==1||a!==1)do if(o--,a--,0>a||s[o]!==i[a]){var l=`
37
+ `+s[o].replace(" at new "," at ");return t.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",t.displayName)),l}while(1<=o&&0<=a);break}}}finally{hm=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?tc(t):""}function g5(t){switch(t.tag){case 5:return tc(t.type);case 16:return tc("Lazy");case 13:return tc("Suspense");case 19:return tc("SuspenseList");case 0:case 2:case 15:return t=pm(t.type,!1),t;case 11:return t=pm(t.type.render,!1),t;case 1:return t=pm(t.type,!0),t;default:return""}}function Jg(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case wa:return"Fragment";case ka:return"Portal";case Hg:return"Profiler";case _v:return"StrictMode";case qg:return"Suspense";case Kg:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case uC:return(t.displayName||"Context")+".Consumer";case dC:return(t._context.displayName||"Context")+".Provider";case jv:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case $v:return e=t.displayName||null,e!==null?e:Jg(t.type)||"Memo";case Gs:e=t._payload,t=t._init;try{return Jg(t(e))}catch{}}return null}function y5(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Jg(e);case 8:return e===_v?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function Oi(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function hC(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function x5(t){var e=hC(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return s.call(this)},set:function(o){r=""+o,i.call(this,o)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(o){r=""+o},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function nu(t){t._valueTracker||(t._valueTracker=x5(t))}function pC(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=hC(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function gf(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Gg(t,e){var n=e.checked;return mt({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function nk(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=Oi(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function mC(t,e){e=e.checked,e!=null&&Ev(t,"checked",e,!1)}function Yg(t,e){mC(t,e);var n=Oi(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Qg(t,e.type,n):e.hasOwnProperty("defaultValue")&&Qg(t,e.type,Oi(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function rk(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Qg(t,e,n){(e!=="number"||gf(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var nc=Array.isArray;function Ia(t,e,n,r){if(t=t.options,e){e={};for(var s=0;s<n.length;s++)e["$"+n[s]]=!0;for(n=0;n<t.length;n++)s=e.hasOwnProperty("$"+t[n].value),t[n].selected!==s&&(t[n].selected=s),s&&r&&(t[n].defaultSelected=!0)}else{for(n=""+Oi(n),e=null,s=0;s<t.length;s++){if(t[s].value===n){t[s].selected=!0,r&&(t[s].defaultSelected=!0);return}e!==null||t[s].disabled||(e=t[s])}e!==null&&(e.selected=!0)}}function Xg(t,e){if(e.dangerouslySetInnerHTML!=null)throw Error(ee(91));return mt({},e,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function sk(t,e){var n=e.value;if(n==null){if(n=e.children,e=e.defaultValue,n!=null){if(e!=null)throw Error(ee(92));if(nc(n)){if(1<n.length)throw Error(ee(93));n=n[0]}e=n}e==null&&(e=""),n=e}t._wrapperState={initialValue:Oi(n)}}function gC(t,e){var n=Oi(e.value),r=Oi(e.defaultValue);n!=null&&(n=""+n,n!==t.value&&(t.value=n),e.defaultValue==null&&t.defaultValue!==n&&(t.defaultValue=n)),r!=null&&(t.defaultValue=""+r)}function ik(t){var e=t.textContent;e===t._wrapperState.initialValue&&e!==""&&e!==null&&(t.value=e)}function yC(t){switch(t){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function ey(t,e){return t==null||t==="http://www.w3.org/1999/xhtml"?yC(e):t==="http://www.w3.org/2000/svg"&&e==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var ru,xC=function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,n,r,s){MSApp.execUnsafeLocalFunction(function(){return t(e,n,r,s)})}:t}(function(t,e){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=e;else{for(ru=ru||document.createElement("div"),ru.innerHTML="<svg>"+e.valueOf().toString()+"</svg>",e=ru.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Bc(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var mc={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},v5=["Webkit","ms","Moz","O"];Object.keys(mc).forEach(function(t){v5.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),mc[e]=mc[t]})});function vC(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||mc.hasOwnProperty(t)&&mc[t]?(""+e).trim():e+"px"}function kC(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=vC(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,s):t[n]=s}}var k5=mt({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ty(t,e){if(e){if(k5[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(ee(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(ee(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(ee(61))}if(e.style!=null&&typeof e.style!="object")throw Error(ee(62))}}function ny(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ry=null;function Mv(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var sy=null,Pa=null,Da=null;function ok(t){if(t=Td(t)){if(typeof sy!="function")throw Error(ee(280));var e=t.stateNode;e&&(e=pp(e),sy(t.stateNode,t.type,e))}}function wC(t){Pa?Da?Da.push(t):Da=[t]:Pa=t}function bC(){if(Pa){var t=Pa,e=Da;if(Da=Pa=null,ok(t),e)for(t=0;t<e.length;t++)ok(e[t])}}function SC(t,e){return t(e)}function CC(){}var mm=!1;function NC(t,e,n){if(mm)return t(e,n);mm=!0;try{return SC(t,e,n)}finally{mm=!1,(Pa!==null||Da!==null)&&(CC(),bC())}}function Vc(t,e){var n=t.stateNode;if(n===null)return null;var r=pp(n);if(r===null)return null;n=r[e];e:switch(e){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(t=t.type,r=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!r;break e;default:t=!1}if(t)return null;if(n&&typeof n!="function")throw Error(ee(231,e,typeof n));return n}var iy=!1;if(Os)try{var Ll={};Object.defineProperty(Ll,"passive",{get:function(){iy=!0}}),window.addEventListener("test",Ll,Ll),window.removeEventListener("test",Ll,Ll)}catch{iy=!1}function w5(t,e,n,r,s,i,o,a,l){var c=Array.prototype.slice.call(arguments,3);try{e.apply(n,c)}catch(d){this.onError(d)}}var gc=!1,yf=null,xf=!1,oy=null,b5={onError:function(t){gc=!0,yf=t}};function S5(t,e,n,r,s,i,o,a,l){gc=!1,yf=null,w5.apply(b5,arguments)}function C5(t,e,n,r,s,i,o,a,l){if(S5.apply(this,arguments),gc){if(gc){var c=yf;gc=!1,yf=null}else throw Error(ee(198));xf||(xf=!0,oy=c)}}function qo(t){var e=t,n=t;if(t.alternate)for(;e.return;)e=e.return;else{t=e;do e=t,e.flags&4098&&(n=e.return),t=e.return;while(t)}return e.tag===3?n:null}function EC(t){if(t.tag===13){var e=t.memoizedState;if(e===null&&(t=t.alternate,t!==null&&(e=t.memoizedState)),e!==null)return e.dehydrated}return null}function ak(t){if(qo(t)!==t)throw Error(ee(188))}function N5(t){var e=t.alternate;if(!e){if(e=qo(t),e===null)throw Error(ee(188));return e!==t?null:t}for(var n=t,r=e;;){var s=n.return;if(s===null)break;var i=s.alternate;if(i===null){if(r=s.return,r!==null){n=r;continue}break}if(s.child===i.child){for(i=s.child;i;){if(i===n)return ak(s),t;if(i===r)return ak(s),e;i=i.sibling}throw Error(ee(188))}if(n.return!==r.return)n=s,r=i;else{for(var o=!1,a=s.child;a;){if(a===n){o=!0,n=s,r=i;break}if(a===r){o=!0,r=s,n=i;break}a=a.sibling}if(!o){for(a=i.child;a;){if(a===n){o=!0,n=i,r=s;break}if(a===r){o=!0,r=i,n=s;break}a=a.sibling}if(!o)throw Error(ee(189))}}if(n.alternate!==r)throw Error(ee(190))}if(n.tag!==3)throw Error(ee(188));return n.stateNode.current===n?t:e}function _C(t){return t=N5(t),t!==null?jC(t):null}function jC(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var e=jC(t);if(e!==null)return e;t=t.sibling}return null}var $C=Gn.unstable_scheduleCallback,lk=Gn.unstable_cancelCallback,E5=Gn.unstable_shouldYield,_5=Gn.unstable_requestPaint,wt=Gn.unstable_now,j5=Gn.unstable_getCurrentPriorityLevel,Tv=Gn.unstable_ImmediatePriority,MC=Gn.unstable_UserBlockingPriority,vf=Gn.unstable_NormalPriority,$5=Gn.unstable_LowPriority,TC=Gn.unstable_IdlePriority,dp=null,Qr=null;function M5(t){if(Qr&&typeof Qr.onCommitFiberRoot=="function")try{Qr.onCommitFiberRoot(dp,t,void 0,(t.current.flags&128)===128)}catch{}}var jr=Math.clz32?Math.clz32:A5,T5=Math.log,O5=Math.LN2;function A5(t){return t>>>=0,t===0?32:31-(T5(t)/O5|0)|0}var su=64,iu=4194304;function rc(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function kf(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,s=t.suspendedLanes,i=t.pingedLanes,o=n&268435455;if(o!==0){var a=o&~s;a!==0?r=rc(a):(i&=o,i!==0&&(r=rc(i)))}else o=n&~s,o!==0?r=rc(o):i!==0&&(r=rc(i));if(r===0)return 0;if(e!==0&&e!==r&&!(e&s)&&(s=r&-r,i=e&-e,s>=i||s===16&&(i&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0<e;)n=31-jr(e),s=1<<n,r|=t[n],e&=~s;return r}function R5(t,e){switch(t){case 1:case 2:case 4:return e+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function I5(t,e){for(var n=t.suspendedLanes,r=t.pingedLanes,s=t.expirationTimes,i=t.pendingLanes;0<i;){var o=31-jr(i),a=1<<o,l=s[o];l===-1?(!(a&n)||a&r)&&(s[o]=R5(a,e)):l<=e&&(t.expiredLanes|=a),i&=~a}}function ay(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function OC(){var t=su;return su<<=1,!(su&4194240)&&(su=64),t}function gm(t){for(var e=[],n=0;31>n;n++)e.push(t);return e}function $d(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-jr(e),t[e]=n}function P5(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0<n;){var s=31-jr(n),i=1<<s;e[s]=0,r[s]=-1,t[s]=-1,n&=~i}}function Ov(t,e){var n=t.entangledLanes|=e;for(t=t.entanglements;n;){var r=31-jr(n),s=1<<r;s&e|t[r]&e&&(t[r]|=e),n&=~s}}var Qe=0;function AC(t){return t&=-t,1<t?4<t?t&268435455?16:536870912:4:1}var RC,Av,IC,PC,DC,ly=!1,ou=[],pi=null,mi=null,gi=null,Wc=new Map,Uc=new Map,si=[],D5="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function ck(t,e){switch(t){case"focusin":case"focusout":pi=null;break;case"dragenter":case"dragleave":mi=null;break;case"mouseover":case"mouseout":gi=null;break;case"pointerover":case"pointerout":Wc.delete(e.pointerId);break;case"gotpointercapture":case"lostpointercapture":Uc.delete(e.pointerId)}}function Fl(t,e,n,r,s,i){return t===null||t.nativeEvent!==i?(t={blockedOn:e,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[s]},e!==null&&(e=Td(e),e!==null&&Av(e)),t):(t.eventSystemFlags|=r,e=t.targetContainers,s!==null&&e.indexOf(s)===-1&&e.push(s),t)}function z5(t,e,n,r,s){switch(e){case"focusin":return pi=Fl(pi,t,e,n,r,s),!0;case"dragenter":return mi=Fl(mi,t,e,n,r,s),!0;case"mouseover":return gi=Fl(gi,t,e,n,r,s),!0;case"pointerover":var i=s.pointerId;return Wc.set(i,Fl(Wc.get(i)||null,t,e,n,r,s)),!0;case"gotpointercapture":return i=s.pointerId,Uc.set(i,Fl(Uc.get(i)||null,t,e,n,r,s)),!0}return!1}function zC(t){var e=oo(t.target);if(e!==null){var n=qo(e);if(n!==null){if(e=n.tag,e===13){if(e=EC(n),e!==null){t.blockedOn=e,DC(t.priority,function(){IC(n)});return}}else if(e===3&&n.stateNode.current.memoizedState.isDehydrated){t.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}t.blockedOn=null}function Hu(t){if(t.blockedOn!==null)return!1;for(var e=t.targetContainers;0<e.length;){var n=cy(t.domEventName,t.eventSystemFlags,e[0],t.nativeEvent);if(n===null){n=t.nativeEvent;var r=new n.constructor(n.type,n);ry=r,n.target.dispatchEvent(r),ry=null}else return e=Td(n),e!==null&&Av(e),t.blockedOn=n,!1;e.shift()}return!0}function dk(t,e,n){Hu(t)&&n.delete(e)}function L5(){ly=!1,pi!==null&&Hu(pi)&&(pi=null),mi!==null&&Hu(mi)&&(mi=null),gi!==null&&Hu(gi)&&(gi=null),Wc.forEach(dk),Uc.forEach(dk)}function Bl(t,e){t.blockedOn===e&&(t.blockedOn=null,ly||(ly=!0,Gn.unstable_scheduleCallback(Gn.unstable_NormalPriority,L5)))}function Zc(t){function e(s){return Bl(s,t)}if(0<ou.length){Bl(ou[0],t);for(var n=1;n<ou.length;n++){var r=ou[n];r.blockedOn===t&&(r.blockedOn=null)}}for(pi!==null&&Bl(pi,t),mi!==null&&Bl(mi,t),gi!==null&&Bl(gi,t),Wc.forEach(e),Uc.forEach(e),n=0;n<si.length;n++)r=si[n],r.blockedOn===t&&(r.blockedOn=null);for(;0<si.length&&(n=si[0],n.blockedOn===null);)zC(n),n.blockedOn===null&&si.shift()}var za=Bs.ReactCurrentBatchConfig,wf=!0;function F5(t,e,n,r){var s=Qe,i=za.transition;za.transition=null;try{Qe=1,Rv(t,e,n,r)}finally{Qe=s,za.transition=i}}function B5(t,e,n,r){var s=Qe,i=za.transition;za.transition=null;try{Qe=4,Rv(t,e,n,r)}finally{Qe=s,za.transition=i}}function Rv(t,e,n,r){if(wf){var s=cy(t,e,n,r);if(s===null)Em(t,e,r,bf,n),ck(t,r);else if(z5(s,t,e,n,r))r.stopPropagation();else if(ck(t,r),e&4&&-1<D5.indexOf(t)){for(;s!==null;){var i=Td(s);if(i!==null&&RC(i),i=cy(t,e,n,r),i===null&&Em(t,e,r,bf,n),i===s)break;s=i}s!==null&&r.stopPropagation()}else Em(t,e,r,null,n)}}var bf=null;function cy(t,e,n,r){if(bf=null,t=Mv(r),t=oo(t),t!==null)if(e=qo(t),e===null)t=null;else if(n=e.tag,n===13){if(t=EC(e),t!==null)return t;t=null}else if(n===3){if(e.stateNode.current.memoizedState.isDehydrated)return e.tag===3?e.stateNode.containerInfo:null;t=null}else e!==t&&(t=null);return bf=t,null}function LC(t){switch(t){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(j5()){case Tv:return 1;case MC:return 4;case vf:case $5:return 16;case TC:return 536870912;default:return 16}default:return 16}}var ci=null,Iv=null,qu=null;function FC(){if(qu)return qu;var t,e=Iv,n=e.length,r,s="value"in ci?ci.value:ci.textContent,i=s.length;for(t=0;t<n&&e[t]===s[t];t++);var o=n-t;for(r=1;r<=o&&e[n-r]===s[i-r];r++);return qu=s.slice(t,1<r?1-r:void 0)}function Ku(t){var e=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&e===13&&(t=13)):t=e,t===10&&(t=13),32<=t||t===13?t:0}function au(){return!0}function uk(){return!1}function er(t){function e(n,r,s,i,o){this._reactName=n,this._targetInst=s,this.type=r,this.nativeEvent=i,this.target=o,this.currentTarget=null;for(var a in t)t.hasOwnProperty(a)&&(n=t[a],this[a]=n?n(i):i[a]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?au:uk,this.isPropagationStopped=uk,this}return mt(e.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=au)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=au)},persist:function(){},isPersistent:au}),e}var _l={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Pv=er(_l),Md=mt({},_l,{view:0,detail:0}),V5=er(Md),ym,xm,Vl,up=mt({},Md,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Dv,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==Vl&&(Vl&&t.type==="mousemove"?(ym=t.screenX-Vl.screenX,xm=t.screenY-Vl.screenY):xm=ym=0,Vl=t),ym)},movementY:function(t){return"movementY"in t?t.movementY:xm}}),fk=er(up),W5=mt({},up,{dataTransfer:0}),U5=er(W5),Z5=mt({},Md,{relatedTarget:0}),vm=er(Z5),H5=mt({},_l,{animationName:0,elapsedTime:0,pseudoElement:0}),q5=er(H5),K5=mt({},_l,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),J5=er(K5),G5=mt({},_l,{data:0}),hk=er(G5),Y5={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Q5={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"},X5={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function e3(t){var e=this.nativeEvent;return e.getModifierState?e.getModifierState(t):(t=X5[t])?!!e[t]:!1}function Dv(){return e3}var t3=mt({},Md,{key:function(t){if(t.key){var e=Y5[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=Ku(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?Q5[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Dv,charCode:function(t){return t.type==="keypress"?Ku(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?Ku(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),n3=er(t3),r3=mt({},up,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),pk=er(r3),s3=mt({},Md,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Dv}),i3=er(s3),o3=mt({},_l,{propertyName:0,elapsedTime:0,pseudoElement:0}),a3=er(o3),l3=mt({},up,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),c3=er(l3),d3=[9,13,27,32],zv=Os&&"CompositionEvent"in window,yc=null;Os&&"documentMode"in document&&(yc=document.documentMode);var u3=Os&&"TextEvent"in window&&!yc,BC=Os&&(!zv||yc&&8<yc&&11>=yc),mk=" ",gk=!1;function VC(t,e){switch(t){case"keyup":return d3.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function WC(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var ba=!1;function f3(t,e){switch(t){case"compositionend":return WC(e);case"keypress":return e.which!==32?null:(gk=!0,mk);case"textInput":return t=e.data,t===mk&&gk?null:t;default:return null}}function h3(t,e){if(ba)return t==="compositionend"||!zv&&VC(t,e)?(t=FC(),qu=Iv=ci=null,ba=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1<e.char.length)return e.char;if(e.which)return String.fromCharCode(e.which)}return null;case"compositionend":return BC&&e.locale!=="ko"?null:e.data;default:return null}}var p3={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 yk(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e==="input"?!!p3[t.type]:e==="textarea"}function UC(t,e,n,r){wC(r),e=Sf(e,"onChange"),0<e.length&&(n=new Pv("onChange","change",null,n,r),t.push({event:n,listeners:e}))}var xc=null,Hc=null;function m3(t){tN(t,0)}function fp(t){var e=Na(t);if(pC(e))return t}function g3(t,e){if(t==="change")return e}var ZC=!1;if(Os){var km;if(Os){var wm="oninput"in document;if(!wm){var xk=document.createElement("div");xk.setAttribute("oninput","return;"),wm=typeof xk.oninput=="function"}km=wm}else km=!1;ZC=km&&(!document.documentMode||9<document.documentMode)}function vk(){xc&&(xc.detachEvent("onpropertychange",HC),Hc=xc=null)}function HC(t){if(t.propertyName==="value"&&fp(Hc)){var e=[];UC(e,Hc,t,Mv(t)),NC(m3,e)}}function y3(t,e,n){t==="focusin"?(vk(),xc=e,Hc=n,xc.attachEvent("onpropertychange",HC)):t==="focusout"&&vk()}function x3(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return fp(Hc)}function v3(t,e){if(t==="click")return fp(e)}function k3(t,e){if(t==="input"||t==="change")return fp(e)}function w3(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var Or=typeof Object.is=="function"?Object.is:w3;function qc(t,e){if(Or(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;var n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var s=n[r];if(!Zg.call(e,s)||!Or(t[s],e[s]))return!1}return!0}function kk(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function wk(t,e){var n=kk(t);t=0;for(var r;n;){if(n.nodeType===3){if(r=t+n.textContent.length,t<=e&&r>=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=kk(n)}}function qC(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?qC(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function KC(){for(var t=window,e=gf();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=gf(t.document)}return e}function Lv(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function b3(t){var e=KC(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&qC(n.ownerDocument.documentElement,n)){if(r!==null&&Lv(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!t.extend&&i>r&&(s=r,r=i,i=s),s=wk(n,i);var o=wk(n,r);s&&o&&(t.rangeCount!==1||t.anchorNode!==s.node||t.anchorOffset!==s.offset||t.focusNode!==o.node||t.focusOffset!==o.offset)&&(e=e.createRange(),e.setStart(s.node,s.offset),t.removeAllRanges(),i>r?(t.addRange(e),t.extend(o.node,o.offset)):(e.setEnd(o.node,o.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<e.length;n++)t=e[n],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var S3=Os&&"documentMode"in document&&11>=document.documentMode,Sa=null,dy=null,vc=null,uy=!1;function bk(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;uy||Sa==null||Sa!==gf(r)||(r=Sa,"selectionStart"in r&&Lv(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}),vc&&qc(vc,r)||(vc=r,r=Sf(dy,"onSelect"),0<r.length&&(e=new Pv("onSelect","select",null,e,n),t.push({event:e,listeners:r}),e.target=Sa)))}function lu(t,e){var n={};return n[t.toLowerCase()]=e.toLowerCase(),n["Webkit"+t]="webkit"+e,n["Moz"+t]="moz"+e,n}var Ca={animationend:lu("Animation","AnimationEnd"),animationiteration:lu("Animation","AnimationIteration"),animationstart:lu("Animation","AnimationStart"),transitionend:lu("Transition","TransitionEnd")},bm={},JC={};Os&&(JC=document.createElement("div").style,"AnimationEvent"in window||(delete Ca.animationend.animation,delete Ca.animationiteration.animation,delete Ca.animationstart.animation),"TransitionEvent"in window||delete Ca.transitionend.transition);function hp(t){if(bm[t])return bm[t];if(!Ca[t])return t;var e=Ca[t],n;for(n in e)if(e.hasOwnProperty(n)&&n in JC)return bm[t]=e[n];return t}var GC=hp("animationend"),YC=hp("animationiteration"),QC=hp("animationstart"),XC=hp("transitionend"),eN=new Map,Sk="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Hi(t,e){eN.set(t,e),Ho(e,[t])}for(var Sm=0;Sm<Sk.length;Sm++){var Cm=Sk[Sm],C3=Cm.toLowerCase(),N3=Cm[0].toUpperCase()+Cm.slice(1);Hi(C3,"on"+N3)}Hi(GC,"onAnimationEnd");Hi(YC,"onAnimationIteration");Hi(QC,"onAnimationStart");Hi("dblclick","onDoubleClick");Hi("focusin","onFocus");Hi("focusout","onBlur");Hi(XC,"onTransitionEnd");Za("onMouseEnter",["mouseout","mouseover"]);Za("onMouseLeave",["mouseout","mouseover"]);Za("onPointerEnter",["pointerout","pointerover"]);Za("onPointerLeave",["pointerout","pointerover"]);Ho("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Ho("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Ho("onBeforeInput",["compositionend","keypress","textInput","paste"]);Ho("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Ho("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Ho("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var sc="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(" "),E3=new Set("cancel close invalid load scroll toggle".split(" ").concat(sc));function Ck(t,e,n){var r=t.type||"unknown-event";t.currentTarget=n,C5(r,e,void 0,t),t.currentTarget=null}function tN(t,e){e=(e&4)!==0;for(var n=0;n<t.length;n++){var r=t[n],s=r.event;r=r.listeners;e:{var i=void 0;if(e)for(var o=r.length-1;0<=o;o--){var a=r[o],l=a.instance,c=a.currentTarget;if(a=a.listener,l!==i&&s.isPropagationStopped())break e;Ck(s,a,c),i=l}else for(o=0;o<r.length;o++){if(a=r[o],l=a.instance,c=a.currentTarget,a=a.listener,l!==i&&s.isPropagationStopped())break e;Ck(s,a,c),i=l}}}if(xf)throw t=oy,xf=!1,oy=null,t}function st(t,e){var n=e[gy];n===void 0&&(n=e[gy]=new Set);var r=t+"__bubble";n.has(r)||(nN(e,t,2,!1),n.add(r))}function Nm(t,e,n){var r=0;e&&(r|=4),nN(n,t,r,e)}var cu="_reactListening"+Math.random().toString(36).slice(2);function Kc(t){if(!t[cu]){t[cu]=!0,cC.forEach(function(n){n!=="selectionchange"&&(E3.has(n)||Nm(n,!1,t),Nm(n,!0,t))});var e=t.nodeType===9?t:t.ownerDocument;e===null||e[cu]||(e[cu]=!0,Nm("selectionchange",!1,e))}}function nN(t,e,n,r){switch(LC(e)){case 1:var s=F5;break;case 4:s=B5;break;default:s=Rv}n=s.bind(null,e,n,t),s=void 0,!iy||e!=="touchstart"&&e!=="touchmove"&&e!=="wheel"||(s=!0),r?s!==void 0?t.addEventListener(e,n,{capture:!0,passive:s}):t.addEventListener(e,n,!0):s!==void 0?t.addEventListener(e,n,{passive:s}):t.addEventListener(e,n,!1)}function Em(t,e,n,r,s){var i=r;if(!(e&1)&&!(e&2)&&r!==null)e:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var a=r.stateNode.containerInfo;if(a===s||a.nodeType===8&&a.parentNode===s)break;if(o===4)for(o=r.return;o!==null;){var l=o.tag;if((l===3||l===4)&&(l=o.stateNode.containerInfo,l===s||l.nodeType===8&&l.parentNode===s))return;o=o.return}for(;a!==null;){if(o=oo(a),o===null)return;if(l=o.tag,l===5||l===6){r=i=o;continue e}a=a.parentNode}}r=r.return}NC(function(){var c=i,d=Mv(n),u=[];e:{var h=eN.get(t);if(h!==void 0){var m=Pv,g=t;switch(t){case"keypress":if(Ku(n)===0)break e;case"keydown":case"keyup":m=n3;break;case"focusin":g="focus",m=vm;break;case"focusout":g="blur",m=vm;break;case"beforeblur":case"afterblur":m=vm;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":m=fk;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=U5;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=i3;break;case GC:case YC:case QC:m=q5;break;case XC:m=a3;break;case"scroll":m=V5;break;case"wheel":m=c3;break;case"copy":case"cut":case"paste":m=J5;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=pk}var p=(e&4)!==0,x=!p&&t==="scroll",y=p?h!==null?h+"Capture":null:h;p=[];for(var v=c,k;v!==null;){k=v;var w=k.stateNode;if(k.tag===5&&w!==null&&(k=w,y!==null&&(w=Vc(v,y),w!=null&&p.push(Jc(v,w,k)))),x)break;v=v.return}0<p.length&&(h=new m(h,g,null,n,d),u.push({event:h,listeners:p}))}}if(!(e&7)){e:{if(h=t==="mouseover"||t==="pointerover",m=t==="mouseout"||t==="pointerout",h&&n!==ry&&(g=n.relatedTarget||n.fromElement)&&(oo(g)||g[As]))break e;if((m||h)&&(h=d.window===d?d:(h=d.ownerDocument)?h.defaultView||h.parentWindow:window,m?(g=n.relatedTarget||n.toElement,m=c,g=g?oo(g):null,g!==null&&(x=qo(g),g!==x||g.tag!==5&&g.tag!==6)&&(g=null)):(m=null,g=c),m!==g)){if(p=fk,w="onMouseLeave",y="onMouseEnter",v="mouse",(t==="pointerout"||t==="pointerover")&&(p=pk,w="onPointerLeave",y="onPointerEnter",v="pointer"),x=m==null?h:Na(m),k=g==null?h:Na(g),h=new p(w,v+"leave",m,n,d),h.target=x,h.relatedTarget=k,w=null,oo(d)===c&&(p=new p(y,v+"enter",g,n,d),p.target=k,p.relatedTarget=x,w=p),x=w,m&&g)t:{for(p=m,y=g,v=0,k=p;k;k=ea(k))v++;for(k=0,w=y;w;w=ea(w))k++;for(;0<v-k;)p=ea(p),v--;for(;0<k-v;)y=ea(y),k--;for(;v--;){if(p===y||y!==null&&p===y.alternate)break t;p=ea(p),y=ea(y)}p=null}else p=null;m!==null&&Nk(u,h,m,p,!1),g!==null&&x!==null&&Nk(u,x,g,p,!0)}}e:{if(h=c?Na(c):window,m=h.nodeName&&h.nodeName.toLowerCase(),m==="select"||m==="input"&&h.type==="file")var C=g3;else if(yk(h))if(ZC)C=k3;else{C=x3;var E=y3}else(m=h.nodeName)&&m.toLowerCase()==="input"&&(h.type==="checkbox"||h.type==="radio")&&(C=v3);if(C&&(C=C(t,c))){UC(u,C,n,d);break e}E&&E(t,h,c),t==="focusout"&&(E=h._wrapperState)&&E.controlled&&h.type==="number"&&Qg(h,"number",h.value)}switch(E=c?Na(c):window,t){case"focusin":(yk(E)||E.contentEditable==="true")&&(Sa=E,dy=c,vc=null);break;case"focusout":vc=dy=Sa=null;break;case"mousedown":uy=!0;break;case"contextmenu":case"mouseup":case"dragend":uy=!1,bk(u,n,d);break;case"selectionchange":if(S3)break;case"keydown":case"keyup":bk(u,n,d)}var _;if(zv)e:{switch(t){case"compositionstart":var S="onCompositionStart";break e;case"compositionend":S="onCompositionEnd";break e;case"compositionupdate":S="onCompositionUpdate";break e}S=void 0}else ba?VC(t,n)&&(S="onCompositionEnd"):t==="keydown"&&n.keyCode===229&&(S="onCompositionStart");S&&(BC&&n.locale!=="ko"&&(ba||S!=="onCompositionStart"?S==="onCompositionEnd"&&ba&&(_=FC()):(ci=d,Iv="value"in ci?ci.value:ci.textContent,ba=!0)),E=Sf(c,S),0<E.length&&(S=new hk(S,t,null,n,d),u.push({event:S,listeners:E}),_?S.data=_:(_=WC(n),_!==null&&(S.data=_)))),(_=u3?f3(t,n):h3(t,n))&&(c=Sf(c,"onBeforeInput"),0<c.length&&(d=new hk("onBeforeInput","beforeinput",null,n,d),u.push({event:d,listeners:c}),d.data=_))}tN(u,e)})}function Jc(t,e,n){return{instance:t,listener:e,currentTarget:n}}function Sf(t,e){for(var n=e+"Capture",r=[];t!==null;){var s=t,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=Vc(t,n),i!=null&&r.unshift(Jc(t,i,s)),i=Vc(t,e),i!=null&&r.push(Jc(t,i,s))),t=t.return}return r}function ea(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function Nk(t,e,n,r,s){for(var i=e._reactName,o=[];n!==null&&n!==r;){var a=n,l=a.alternate,c=a.stateNode;if(l!==null&&l===r)break;a.tag===5&&c!==null&&(a=c,s?(l=Vc(n,i),l!=null&&o.unshift(Jc(n,l,a))):s||(l=Vc(n,i),l!=null&&o.push(Jc(n,l,a)))),n=n.return}o.length!==0&&t.push({event:e,listeners:o})}var _3=/\r\n?/g,j3=/\u0000|\uFFFD/g;function Ek(t){return(typeof t=="string"?t:""+t).replace(_3,`
38
+ `).replace(j3,"")}function du(t,e,n){if(e=Ek(e),Ek(t)!==e&&n)throw Error(ee(425))}function Cf(){}var fy=null,hy=null;function py(t,e){return t==="textarea"||t==="noscript"||typeof e.children=="string"||typeof e.children=="number"||typeof e.dangerouslySetInnerHTML=="object"&&e.dangerouslySetInnerHTML!==null&&e.dangerouslySetInnerHTML.__html!=null}var my=typeof setTimeout=="function"?setTimeout:void 0,$3=typeof clearTimeout=="function"?clearTimeout:void 0,_k=typeof Promise=="function"?Promise:void 0,M3=typeof queueMicrotask=="function"?queueMicrotask:typeof _k<"u"?function(t){return _k.resolve(null).then(t).catch(T3)}:my;function T3(t){setTimeout(function(){throw t})}function _m(t,e){var n=e,r=0;do{var s=n.nextSibling;if(t.removeChild(n),s&&s.nodeType===8)if(n=s.data,n==="/$"){if(r===0){t.removeChild(s),Zc(e);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);Zc(e)}function yi(t){for(;t!=null;t=t.nextSibling){var e=t.nodeType;if(e===1||e===3)break;if(e===8){if(e=t.data,e==="$"||e==="$!"||e==="$?")break;if(e==="/$")return null}}return t}function jk(t){t=t.previousSibling;for(var e=0;t;){if(t.nodeType===8){var n=t.data;if(n==="$"||n==="$!"||n==="$?"){if(e===0)return t;e--}else n==="/$"&&e++}t=t.previousSibling}return null}var jl=Math.random().toString(36).slice(2),qr="__reactFiber$"+jl,Gc="__reactProps$"+jl,As="__reactContainer$"+jl,gy="__reactEvents$"+jl,O3="__reactListeners$"+jl,A3="__reactHandles$"+jl;function oo(t){var e=t[qr];if(e)return e;for(var n=t.parentNode;n;){if(e=n[As]||n[qr]){if(n=e.alternate,e.child!==null||n!==null&&n.child!==null)for(t=jk(t);t!==null;){if(n=t[qr])return n;t=jk(t)}return e}t=n,n=t.parentNode}return null}function Td(t){return t=t[qr]||t[As],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function Na(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(ee(33))}function pp(t){return t[Gc]||null}var yy=[],Ea=-1;function qi(t){return{current:t}}function at(t){0>Ea||(t.current=yy[Ea],yy[Ea]=null,Ea--)}function rt(t,e){Ea++,yy[Ea]=t.current,t.current=e}var Ai={},pn=qi(Ai),Rn=qi(!1),So=Ai;function Ha(t,e){var n=t.type.contextTypes;if(!n)return Ai;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=e[i];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=s),s}function In(t){return t=t.childContextTypes,t!=null}function Nf(){at(Rn),at(pn)}function $k(t,e,n){if(pn.current!==Ai)throw Error(ee(168));rt(pn,e),rt(Rn,n)}function rN(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in e))throw Error(ee(108,y5(t)||"Unknown",s));return mt({},n,r)}function Ef(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||Ai,So=pn.current,rt(pn,t),rt(Rn,Rn.current),!0}function Mk(t,e,n){var r=t.stateNode;if(!r)throw Error(ee(169));n?(t=rN(t,e,So),r.__reactInternalMemoizedMergedChildContext=t,at(Rn),at(pn),rt(pn,t)):at(Rn),rt(Rn,n)}var ks=null,mp=!1,jm=!1;function sN(t){ks===null?ks=[t]:ks.push(t)}function R3(t){mp=!0,sN(t)}function Ki(){if(!jm&&ks!==null){jm=!0;var t=0,e=Qe;try{var n=ks;for(Qe=1;t<n.length;t++){var r=n[t];do r=r(!0);while(r!==null)}ks=null,mp=!1}catch(s){throw ks!==null&&(ks=ks.slice(t+1)),$C(Tv,Ki),s}finally{Qe=e,jm=!1}}return null}var _a=[],ja=0,_f=null,jf=0,or=[],ar=0,Co=null,bs=1,Ss="";function no(t,e){_a[ja++]=jf,_a[ja++]=_f,_f=t,jf=e}function iN(t,e,n){or[ar++]=bs,or[ar++]=Ss,or[ar++]=Co,Co=t;var r=bs;t=Ss;var s=32-jr(r)-1;r&=~(1<<s),n+=1;var i=32-jr(e)+s;if(30<i){var o=s-s%5;i=(r&(1<<o)-1).toString(32),r>>=o,s-=o,bs=1<<32-jr(e)+s|n<<s|r,Ss=i+t}else bs=1<<i|n<<s|r,Ss=t}function Fv(t){t.return!==null&&(no(t,1),iN(t,1,0))}function Bv(t){for(;t===_f;)_f=_a[--ja],_a[ja]=null,jf=_a[--ja],_a[ja]=null;for(;t===Co;)Co=or[--ar],or[ar]=null,Ss=or[--ar],or[ar]=null,bs=or[--ar],or[ar]=null}var Kn=null,Hn=null,ct=!1,Nr=null;function oN(t,e){var n=cr(5,null,null,0);n.elementType="DELETED",n.stateNode=e,n.return=t,e=t.deletions,e===null?(t.deletions=[n],t.flags|=16):e.push(n)}function Tk(t,e){switch(t.tag){case 5:var n=t.type;return e=e.nodeType!==1||n.toLowerCase()!==e.nodeName.toLowerCase()?null:e,e!==null?(t.stateNode=e,Kn=t,Hn=yi(e.firstChild),!0):!1;case 6:return e=t.pendingProps===""||e.nodeType!==3?null:e,e!==null?(t.stateNode=e,Kn=t,Hn=null,!0):!1;case 13:return e=e.nodeType!==8?null:e,e!==null?(n=Co!==null?{id:bs,overflow:Ss}:null,t.memoizedState={dehydrated:e,treeContext:n,retryLane:1073741824},n=cr(18,null,null,0),n.stateNode=e,n.return=t,t.child=n,Kn=t,Hn=null,!0):!1;default:return!1}}function xy(t){return(t.mode&1)!==0&&(t.flags&128)===0}function vy(t){if(ct){var e=Hn;if(e){var n=e;if(!Tk(t,e)){if(xy(t))throw Error(ee(418));e=yi(n.nextSibling);var r=Kn;e&&Tk(t,e)?oN(r,n):(t.flags=t.flags&-4097|2,ct=!1,Kn=t)}}else{if(xy(t))throw Error(ee(418));t.flags=t.flags&-4097|2,ct=!1,Kn=t}}}function Ok(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;Kn=t}function uu(t){if(t!==Kn)return!1;if(!ct)return Ok(t),ct=!0,!1;var e;if((e=t.tag!==3)&&!(e=t.tag!==5)&&(e=t.type,e=e!=="head"&&e!=="body"&&!py(t.type,t.memoizedProps)),e&&(e=Hn)){if(xy(t))throw aN(),Error(ee(418));for(;e;)oN(t,e),e=yi(e.nextSibling)}if(Ok(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(ee(317));e:{for(t=t.nextSibling,e=0;t;){if(t.nodeType===8){var n=t.data;if(n==="/$"){if(e===0){Hn=yi(t.nextSibling);break e}e--}else n!=="$"&&n!=="$!"&&n!=="$?"||e++}t=t.nextSibling}Hn=null}}else Hn=Kn?yi(t.stateNode.nextSibling):null;return!0}function aN(){for(var t=Hn;t;)t=yi(t.nextSibling)}function qa(){Hn=Kn=null,ct=!1}function Vv(t){Nr===null?Nr=[t]:Nr.push(t)}var I3=Bs.ReactCurrentBatchConfig;function Wl(t,e,n){if(t=n.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(ee(309));var r=n.stateNode}if(!r)throw Error(ee(147,t));var s=r,i=""+t;return e!==null&&e.ref!==null&&typeof e.ref=="function"&&e.ref._stringRef===i?e.ref:(e=function(o){var a=s.refs;o===null?delete a[i]:a[i]=o},e._stringRef=i,e)}if(typeof t!="string")throw Error(ee(284));if(!n._owner)throw Error(ee(290,t))}return t}function fu(t,e){throw t=Object.prototype.toString.call(e),Error(ee(31,t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t))}function Ak(t){var e=t._init;return e(t._payload)}function lN(t){function e(y,v){if(t){var k=y.deletions;k===null?(y.deletions=[v],y.flags|=16):k.push(v)}}function n(y,v){if(!t)return null;for(;v!==null;)e(y,v),v=v.sibling;return null}function r(y,v){for(y=new Map;v!==null;)v.key!==null?y.set(v.key,v):y.set(v.index,v),v=v.sibling;return y}function s(y,v){return y=wi(y,v),y.index=0,y.sibling=null,y}function i(y,v,k){return y.index=k,t?(k=y.alternate,k!==null?(k=k.index,k<v?(y.flags|=2,v):k):(y.flags|=2,v)):(y.flags|=1048576,v)}function o(y){return t&&y.alternate===null&&(y.flags|=2),y}function a(y,v,k,w){return v===null||v.tag!==6?(v=Im(k,y.mode,w),v.return=y,v):(v=s(v,k),v.return=y,v)}function l(y,v,k,w){var C=k.type;return C===wa?d(y,v,k.props.children,w,k.key):v!==null&&(v.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Gs&&Ak(C)===v.type)?(w=s(v,k.props),w.ref=Wl(y,v,k),w.return=y,w):(w=tf(k.type,k.key,k.props,null,y.mode,w),w.ref=Wl(y,v,k),w.return=y,w)}function c(y,v,k,w){return v===null||v.tag!==4||v.stateNode.containerInfo!==k.containerInfo||v.stateNode.implementation!==k.implementation?(v=Pm(k,y.mode,w),v.return=y,v):(v=s(v,k.children||[]),v.return=y,v)}function d(y,v,k,w,C){return v===null||v.tag!==7?(v=xo(k,y.mode,w,C),v.return=y,v):(v=s(v,k),v.return=y,v)}function u(y,v,k){if(typeof v=="string"&&v!==""||typeof v=="number")return v=Im(""+v,y.mode,k),v.return=y,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case tu:return k=tf(v.type,v.key,v.props,null,y.mode,k),k.ref=Wl(y,null,v),k.return=y,k;case ka:return v=Pm(v,y.mode,k),v.return=y,v;case Gs:var w=v._init;return u(y,w(v._payload),k)}if(nc(v)||zl(v))return v=xo(v,y.mode,k,null),v.return=y,v;fu(y,v)}return null}function h(y,v,k,w){var C=v!==null?v.key:null;if(typeof k=="string"&&k!==""||typeof k=="number")return C!==null?null:a(y,v,""+k,w);if(typeof k=="object"&&k!==null){switch(k.$$typeof){case tu:return k.key===C?l(y,v,k,w):null;case ka:return k.key===C?c(y,v,k,w):null;case Gs:return C=k._init,h(y,v,C(k._payload),w)}if(nc(k)||zl(k))return C!==null?null:d(y,v,k,w,null);fu(y,k)}return null}function m(y,v,k,w,C){if(typeof w=="string"&&w!==""||typeof w=="number")return y=y.get(k)||null,a(v,y,""+w,C);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case tu:return y=y.get(w.key===null?k:w.key)||null,l(v,y,w,C);case ka:return y=y.get(w.key===null?k:w.key)||null,c(v,y,w,C);case Gs:var E=w._init;return m(y,v,k,E(w._payload),C)}if(nc(w)||zl(w))return y=y.get(k)||null,d(v,y,w,C,null);fu(v,w)}return null}function g(y,v,k,w){for(var C=null,E=null,_=v,S=v=0,j=null;_!==null&&S<k.length;S++){_.index>S?(j=_,_=null):j=_.sibling;var $=h(y,_,k[S],w);if($===null){_===null&&(_=j);break}t&&_&&$.alternate===null&&e(y,_),v=i($,v,S),E===null?C=$:E.sibling=$,E=$,_=j}if(S===k.length)return n(y,_),ct&&no(y,S),C;if(_===null){for(;S<k.length;S++)_=u(y,k[S],w),_!==null&&(v=i(_,v,S),E===null?C=_:E.sibling=_,E=_);return ct&&no(y,S),C}for(_=r(y,_);S<k.length;S++)j=m(_,y,S,k[S],w),j!==null&&(t&&j.alternate!==null&&_.delete(j.key===null?S:j.key),v=i(j,v,S),E===null?C=j:E.sibling=j,E=j);return t&&_.forEach(function(I){return e(y,I)}),ct&&no(y,S),C}function p(y,v,k,w){var C=zl(k);if(typeof C!="function")throw Error(ee(150));if(k=C.call(k),k==null)throw Error(ee(151));for(var E=C=null,_=v,S=v=0,j=null,$=k.next();_!==null&&!$.done;S++,$=k.next()){_.index>S?(j=_,_=null):j=_.sibling;var I=h(y,_,$.value,w);if(I===null){_===null&&(_=j);break}t&&_&&I.alternate===null&&e(y,_),v=i(I,v,S),E===null?C=I:E.sibling=I,E=I,_=j}if($.done)return n(y,_),ct&&no(y,S),C;if(_===null){for(;!$.done;S++,$=k.next())$=u(y,$.value,w),$!==null&&(v=i($,v,S),E===null?C=$:E.sibling=$,E=$);return ct&&no(y,S),C}for(_=r(y,_);!$.done;S++,$=k.next())$=m(_,y,S,$.value,w),$!==null&&(t&&$.alternate!==null&&_.delete($.key===null?S:$.key),v=i($,v,S),E===null?C=$:E.sibling=$,E=$);return t&&_.forEach(function(L){return e(y,L)}),ct&&no(y,S),C}function x(y,v,k,w){if(typeof k=="object"&&k!==null&&k.type===wa&&k.key===null&&(k=k.props.children),typeof k=="object"&&k!==null){switch(k.$$typeof){case tu:e:{for(var C=k.key,E=v;E!==null;){if(E.key===C){if(C=k.type,C===wa){if(E.tag===7){n(y,E.sibling),v=s(E,k.props.children),v.return=y,y=v;break e}}else if(E.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Gs&&Ak(C)===E.type){n(y,E.sibling),v=s(E,k.props),v.ref=Wl(y,E,k),v.return=y,y=v;break e}n(y,E);break}else e(y,E);E=E.sibling}k.type===wa?(v=xo(k.props.children,y.mode,w,k.key),v.return=y,y=v):(w=tf(k.type,k.key,k.props,null,y.mode,w),w.ref=Wl(y,v,k),w.return=y,y=w)}return o(y);case ka:e:{for(E=k.key;v!==null;){if(v.key===E)if(v.tag===4&&v.stateNode.containerInfo===k.containerInfo&&v.stateNode.implementation===k.implementation){n(y,v.sibling),v=s(v,k.children||[]),v.return=y,y=v;break e}else{n(y,v);break}else e(y,v);v=v.sibling}v=Pm(k,y.mode,w),v.return=y,y=v}return o(y);case Gs:return E=k._init,x(y,v,E(k._payload),w)}if(nc(k))return g(y,v,k,w);if(zl(k))return p(y,v,k,w);fu(y,k)}return typeof k=="string"&&k!==""||typeof k=="number"?(k=""+k,v!==null&&v.tag===6?(n(y,v.sibling),v=s(v,k),v.return=y,y=v):(n(y,v),v=Im(k,y.mode,w),v.return=y,y=v),o(y)):n(y,v)}return x}var Ka=lN(!0),cN=lN(!1),$f=qi(null),Mf=null,$a=null,Wv=null;function Uv(){Wv=$a=Mf=null}function Zv(t){var e=$f.current;at($f),t._currentValue=e}function ky(t,e,n){for(;t!==null;){var r=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,r!==null&&(r.childLanes|=e)):r!==null&&(r.childLanes&e)!==e&&(r.childLanes|=e),t===n)break;t=t.return}}function La(t,e){Mf=t,Wv=$a=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(An=!0),t.firstContext=null)}function ur(t){var e=t._currentValue;if(Wv!==t)if(t={context:t,memoizedValue:e,next:null},$a===null){if(Mf===null)throw Error(ee(308));$a=t,Mf.dependencies={lanes:0,firstContext:t}}else $a=$a.next=t;return e}var ao=null;function Hv(t){ao===null?ao=[t]:ao.push(t)}function dN(t,e,n,r){var s=e.interleaved;return s===null?(n.next=n,Hv(e)):(n.next=s.next,s.next=n),e.interleaved=n,Rs(t,r)}function Rs(t,e){t.lanes|=e;var n=t.alternate;for(n!==null&&(n.lanes|=e),n=t,t=t.return;t!==null;)t.childLanes|=e,n=t.alternate,n!==null&&(n.childLanes|=e),n=t,t=t.return;return n.tag===3?n.stateNode:null}var Ys=!1;function qv(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function uN(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function Es(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function xi(t,e,n){var r=t.updateQueue;if(r===null)return null;if(r=r.shared,He&2){var s=r.pending;return s===null?e.next=e:(e.next=s.next,s.next=e),r.pending=e,Rs(t,n)}return s=r.interleaved,s===null?(e.next=e,Hv(r)):(e.next=s.next,s.next=e),r.interleaved=e,Rs(t,n)}function Ju(t,e,n){if(e=e.updateQueue,e!==null&&(e=e.shared,(n&4194240)!==0)){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Ov(t,n)}}function Rk(t,e){var n=t.updateQueue,r=t.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var o={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=o:i=i.next=o,n=n.next}while(n!==null);i===null?s=i=e:i=i.next=e}else s=i=e;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},t.updateQueue=n;return}t=n.lastBaseUpdate,t===null?n.firstBaseUpdate=e:t.next=e,n.lastBaseUpdate=e}function Tf(t,e,n,r){var s=t.updateQueue;Ys=!1;var i=s.firstBaseUpdate,o=s.lastBaseUpdate,a=s.shared.pending;if(a!==null){s.shared.pending=null;var l=a,c=l.next;l.next=null,o===null?i=c:o.next=c,o=l;var d=t.alternate;d!==null&&(d=d.updateQueue,a=d.lastBaseUpdate,a!==o&&(a===null?d.firstBaseUpdate=c:a.next=c,d.lastBaseUpdate=l))}if(i!==null){var u=s.baseState;o=0,d=c=l=null,a=i;do{var h=a.lane,m=a.eventTime;if((r&h)===h){d!==null&&(d=d.next={eventTime:m,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var g=t,p=a;switch(h=e,m=n,p.tag){case 1:if(g=p.payload,typeof g=="function"){u=g.call(m,u,h);break e}u=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=p.payload,h=typeof g=="function"?g.call(m,u,h):g,h==null)break e;u=mt({},u,h);break e;case 2:Ys=!0}}a.callback!==null&&a.lane!==0&&(t.flags|=64,h=s.effects,h===null?s.effects=[a]:h.push(a))}else m={eventTime:m,lane:h,tag:a.tag,payload:a.payload,callback:a.callback,next:null},d===null?(c=d=m,l=u):d=d.next=m,o|=h;if(a=a.next,a===null){if(a=s.shared.pending,a===null)break;h=a,a=h.next,h.next=null,s.lastBaseUpdate=h,s.shared.pending=null}}while(!0);if(d===null&&(l=u),s.baseState=l,s.firstBaseUpdate=c,s.lastBaseUpdate=d,e=s.shared.interleaved,e!==null){s=e;do o|=s.lane,s=s.next;while(s!==e)}else i===null&&(s.shared.lanes=0);Eo|=o,t.lanes=o,t.memoizedState=u}}function Ik(t,e,n){if(t=e.effects,e.effects=null,t!==null)for(e=0;e<t.length;e++){var r=t[e],s=r.callback;if(s!==null){if(r.callback=null,r=n,typeof s!="function")throw Error(ee(191,s));s.call(r)}}}var Od={},Xr=qi(Od),Yc=qi(Od),Qc=qi(Od);function lo(t){if(t===Od)throw Error(ee(174));return t}function Kv(t,e){switch(rt(Qc,e),rt(Yc,t),rt(Xr,Od),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:ey(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=ey(e,t)}at(Xr),rt(Xr,e)}function Ja(){at(Xr),at(Yc),at(Qc)}function fN(t){lo(Qc.current);var e=lo(Xr.current),n=ey(e,t.type);e!==n&&(rt(Yc,t),rt(Xr,n))}function Jv(t){Yc.current===t&&(at(Xr),at(Yc))}var ut=qi(0);function Of(t){for(var e=t;e!==null;){if(e.tag===13){var n=e.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var $m=[];function Gv(){for(var t=0;t<$m.length;t++)$m[t]._workInProgressVersionPrimary=null;$m.length=0}var Gu=Bs.ReactCurrentDispatcher,Mm=Bs.ReactCurrentBatchConfig,No=0,ht=null,Tt=null,Ft=null,Af=!1,kc=!1,Xc=0,P3=0;function on(){throw Error(ee(321))}function Yv(t,e){if(e===null)return!1;for(var n=0;n<e.length&&n<t.length;n++)if(!Or(t[n],e[n]))return!1;return!0}function Qv(t,e,n,r,s,i){if(No=i,ht=e,e.memoizedState=null,e.updateQueue=null,e.lanes=0,Gu.current=t===null||t.memoizedState===null?F3:B3,t=n(r,s),kc){i=0;do{if(kc=!1,Xc=0,25<=i)throw Error(ee(301));i+=1,Ft=Tt=null,e.updateQueue=null,Gu.current=V3,t=n(r,s)}while(kc)}if(Gu.current=Rf,e=Tt!==null&&Tt.next!==null,No=0,Ft=Tt=ht=null,Af=!1,e)throw Error(ee(300));return t}function Xv(){var t=Xc!==0;return Xc=0,t}function Br(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ft===null?ht.memoizedState=Ft=t:Ft=Ft.next=t,Ft}function fr(){if(Tt===null){var t=ht.alternate;t=t!==null?t.memoizedState:null}else t=Tt.next;var e=Ft===null?ht.memoizedState:Ft.next;if(e!==null)Ft=e,Tt=t;else{if(t===null)throw Error(ee(310));Tt=t,t={memoizedState:Tt.memoizedState,baseState:Tt.baseState,baseQueue:Tt.baseQueue,queue:Tt.queue,next:null},Ft===null?ht.memoizedState=Ft=t:Ft=Ft.next=t}return Ft}function ed(t,e){return typeof e=="function"?e(t):e}function Tm(t){var e=fr(),n=e.queue;if(n===null)throw Error(ee(311));n.lastRenderedReducer=t;var r=Tt,s=r.baseQueue,i=n.pending;if(i!==null){if(s!==null){var o=s.next;s.next=i.next,i.next=o}r.baseQueue=s=i,n.pending=null}if(s!==null){i=s.next,r=r.baseState;var a=o=null,l=null,c=i;do{var d=c.lane;if((No&d)===d)l!==null&&(l=l.next={lane:0,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null}),r=c.hasEagerState?c.eagerState:t(r,c.action);else{var u={lane:d,action:c.action,hasEagerState:c.hasEagerState,eagerState:c.eagerState,next:null};l===null?(a=l=u,o=r):l=l.next=u,ht.lanes|=d,Eo|=d}c=c.next}while(c!==null&&c!==i);l===null?o=r:l.next=a,Or(r,e.memoizedState)||(An=!0),e.memoizedState=r,e.baseState=o,e.baseQueue=l,n.lastRenderedState=r}if(t=n.interleaved,t!==null){s=t;do i=s.lane,ht.lanes|=i,Eo|=i,s=s.next;while(s!==t)}else s===null&&(n.lanes=0);return[e.memoizedState,n.dispatch]}function Om(t){var e=fr(),n=e.queue;if(n===null)throw Error(ee(311));n.lastRenderedReducer=t;var r=n.dispatch,s=n.pending,i=e.memoizedState;if(s!==null){n.pending=null;var o=s=s.next;do i=t(i,o.action),o=o.next;while(o!==s);Or(i,e.memoizedState)||(An=!0),e.memoizedState=i,e.baseQueue===null&&(e.baseState=i),n.lastRenderedState=i}return[i,r]}function hN(){}function pN(t,e){var n=ht,r=fr(),s=e(),i=!Or(r.memoizedState,s);if(i&&(r.memoizedState=s,An=!0),r=r.queue,e1(yN.bind(null,n,r,t),[t]),r.getSnapshot!==e||i||Ft!==null&&Ft.memoizedState.tag&1){if(n.flags|=2048,td(9,gN.bind(null,n,r,s,e),void 0,null),Ut===null)throw Error(ee(349));No&30||mN(n,e,s)}return s}function mN(t,e,n){t.flags|=16384,t={getSnapshot:e,value:n},e=ht.updateQueue,e===null?(e={lastEffect:null,stores:null},ht.updateQueue=e,e.stores=[t]):(n=e.stores,n===null?e.stores=[t]:n.push(t))}function gN(t,e,n,r){e.value=n,e.getSnapshot=r,xN(e)&&vN(t)}function yN(t,e,n){return n(function(){xN(e)&&vN(t)})}function xN(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!Or(t,n)}catch{return!0}}function vN(t){var e=Rs(t,1);e!==null&&$r(e,t,1,-1)}function Pk(t){var e=Br();return typeof t=="function"&&(t=t()),e.memoizedState=e.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ed,lastRenderedState:t},e.queue=t,t=t.dispatch=L3.bind(null,ht,t),[e.memoizedState,t]}function td(t,e,n,r){return t={tag:t,create:e,destroy:n,deps:r,next:null},e=ht.updateQueue,e===null?(e={lastEffect:null,stores:null},ht.updateQueue=e,e.lastEffect=t.next=t):(n=e.lastEffect,n===null?e.lastEffect=t.next=t:(r=n.next,n.next=t,t.next=r,e.lastEffect=t)),t}function kN(){return fr().memoizedState}function Yu(t,e,n,r){var s=Br();ht.flags|=t,s.memoizedState=td(1|e,n,void 0,r===void 0?null:r)}function gp(t,e,n,r){var s=fr();r=r===void 0?null:r;var i=void 0;if(Tt!==null){var o=Tt.memoizedState;if(i=o.destroy,r!==null&&Yv(r,o.deps)){s.memoizedState=td(e,n,i,r);return}}ht.flags|=t,s.memoizedState=td(1|e,n,i,r)}function Dk(t,e){return Yu(8390656,8,t,e)}function e1(t,e){return gp(2048,8,t,e)}function wN(t,e){return gp(4,2,t,e)}function bN(t,e){return gp(4,4,t,e)}function SN(t,e){if(typeof e=="function")return t=t(),e(t),function(){e(null)};if(e!=null)return t=t(),e.current=t,function(){e.current=null}}function CN(t,e,n){return n=n!=null?n.concat([t]):null,gp(4,4,SN.bind(null,e,t),n)}function t1(){}function NN(t,e){var n=fr();e=e===void 0?null:e;var r=n.memoizedState;return r!==null&&e!==null&&Yv(e,r[1])?r[0]:(n.memoizedState=[t,e],t)}function EN(t,e){var n=fr();e=e===void 0?null:e;var r=n.memoizedState;return r!==null&&e!==null&&Yv(e,r[1])?r[0]:(t=t(),n.memoizedState=[t,e],t)}function _N(t,e,n){return No&21?(Or(n,e)||(n=OC(),ht.lanes|=n,Eo|=n,t.baseState=!0),e):(t.baseState&&(t.baseState=!1,An=!0),t.memoizedState=n)}function D3(t,e){var n=Qe;Qe=n!==0&&4>n?n:4,t(!0);var r=Mm.transition;Mm.transition={};try{t(!1),e()}finally{Qe=n,Mm.transition=r}}function jN(){return fr().memoizedState}function z3(t,e,n){var r=ki(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},$N(t))MN(e,n);else if(n=dN(t,e,n,r),n!==null){var s=bn();$r(n,t,r,s),TN(n,e,r)}}function L3(t,e,n){var r=ki(t),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if($N(t))MN(e,s);else{var i=t.alternate;if(t.lanes===0&&(i===null||i.lanes===0)&&(i=e.lastRenderedReducer,i!==null))try{var o=e.lastRenderedState,a=i(o,n);if(s.hasEagerState=!0,s.eagerState=a,Or(a,o)){var l=e.interleaved;l===null?(s.next=s,Hv(e)):(s.next=l.next,l.next=s),e.interleaved=s;return}}catch{}finally{}n=dN(t,e,s,r),n!==null&&(s=bn(),$r(n,t,r,s),TN(n,e,r))}}function $N(t){var e=t.alternate;return t===ht||e!==null&&e===ht}function MN(t,e){kc=Af=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function TN(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Ov(t,n)}}var Rf={readContext:ur,useCallback:on,useContext:on,useEffect:on,useImperativeHandle:on,useInsertionEffect:on,useLayoutEffect:on,useMemo:on,useReducer:on,useRef:on,useState:on,useDebugValue:on,useDeferredValue:on,useTransition:on,useMutableSource:on,useSyncExternalStore:on,useId:on,unstable_isNewReconciler:!1},F3={readContext:ur,useCallback:function(t,e){return Br().memoizedState=[t,e===void 0?null:e],t},useContext:ur,useEffect:Dk,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,Yu(4194308,4,SN.bind(null,e,t),n)},useLayoutEffect:function(t,e){return Yu(4194308,4,t,e)},useInsertionEffect:function(t,e){return Yu(4,2,t,e)},useMemo:function(t,e){var n=Br();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=Br();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=z3.bind(null,ht,t),[r.memoizedState,t]},useRef:function(t){var e=Br();return t={current:t},e.memoizedState=t},useState:Pk,useDebugValue:t1,useDeferredValue:function(t){return Br().memoizedState=t},useTransition:function(){var t=Pk(!1),e=t[0];return t=D3.bind(null,t[1]),Br().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=ht,s=Br();if(ct){if(n===void 0)throw Error(ee(407));n=n()}else{if(n=e(),Ut===null)throw Error(ee(349));No&30||mN(r,e,n)}s.memoizedState=n;var i={value:n,getSnapshot:e};return s.queue=i,Dk(yN.bind(null,r,i,t),[t]),r.flags|=2048,td(9,gN.bind(null,r,i,n,e),void 0,null),n},useId:function(){var t=Br(),e=Ut.identifierPrefix;if(ct){var n=Ss,r=bs;n=(r&~(1<<32-jr(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=Xc++,0<n&&(e+="H"+n.toString(32)),e+=":"}else n=P3++,e=":"+e+"r"+n.toString(32)+":";return t.memoizedState=e},unstable_isNewReconciler:!1},B3={readContext:ur,useCallback:NN,useContext:ur,useEffect:e1,useImperativeHandle:CN,useInsertionEffect:wN,useLayoutEffect:bN,useMemo:EN,useReducer:Tm,useRef:kN,useState:function(){return Tm(ed)},useDebugValue:t1,useDeferredValue:function(t){var e=fr();return _N(e,Tt.memoizedState,t)},useTransition:function(){var t=Tm(ed)[0],e=fr().memoizedState;return[t,e]},useMutableSource:hN,useSyncExternalStore:pN,useId:jN,unstable_isNewReconciler:!1},V3={readContext:ur,useCallback:NN,useContext:ur,useEffect:e1,useImperativeHandle:CN,useInsertionEffect:wN,useLayoutEffect:bN,useMemo:EN,useReducer:Om,useRef:kN,useState:function(){return Om(ed)},useDebugValue:t1,useDeferredValue:function(t){var e=fr();return Tt===null?e.memoizedState=t:_N(e,Tt.memoizedState,t)},useTransition:function(){var t=Om(ed)[0],e=fr().memoizedState;return[t,e]},useMutableSource:hN,useSyncExternalStore:pN,useId:jN,unstable_isNewReconciler:!1};function Sr(t,e){if(t&&t.defaultProps){e=mt({},e),t=t.defaultProps;for(var n in t)e[n]===void 0&&(e[n]=t[n]);return e}return e}function wy(t,e,n,r){e=t.memoizedState,n=n(r,e),n=n==null?e:mt({},e,n),t.memoizedState=n,t.lanes===0&&(t.updateQueue.baseState=n)}var yp={isMounted:function(t){return(t=t._reactInternals)?qo(t)===t:!1},enqueueSetState:function(t,e,n){t=t._reactInternals;var r=bn(),s=ki(t),i=Es(r,s);i.payload=e,n!=null&&(i.callback=n),e=xi(t,i,s),e!==null&&($r(e,t,s,r),Ju(e,t,s))},enqueueReplaceState:function(t,e,n){t=t._reactInternals;var r=bn(),s=ki(t),i=Es(r,s);i.tag=1,i.payload=e,n!=null&&(i.callback=n),e=xi(t,i,s),e!==null&&($r(e,t,s,r),Ju(e,t,s))},enqueueForceUpdate:function(t,e){t=t._reactInternals;var n=bn(),r=ki(t),s=Es(n,r);s.tag=2,e!=null&&(s.callback=e),e=xi(t,s,r),e!==null&&($r(e,t,r,n),Ju(e,t,r))}};function zk(t,e,n,r,s,i,o){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(r,i,o):e.prototype&&e.prototype.isPureReactComponent?!qc(n,r)||!qc(s,i):!0}function ON(t,e,n){var r=!1,s=Ai,i=e.contextType;return typeof i=="object"&&i!==null?i=ur(i):(s=In(e)?So:pn.current,r=e.contextTypes,i=(r=r!=null)?Ha(t,s):Ai),e=new e(n,i),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=yp,t.stateNode=e,e._reactInternals=t,r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=s,t.__reactInternalMemoizedMaskedChildContext=i),e}function Lk(t,e,n,r){t=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(n,r),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(n,r),e.state!==t&&yp.enqueueReplaceState(e,e.state,null)}function by(t,e,n,r){var s=t.stateNode;s.props=n,s.state=t.memoizedState,s.refs={},qv(t);var i=e.contextType;typeof i=="object"&&i!==null?s.context=ur(i):(i=In(e)?So:pn.current,s.context=Ha(t,i)),s.state=t.memoizedState,i=e.getDerivedStateFromProps,typeof i=="function"&&(wy(t,e,i,n),s.state=t.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof s.getSnapshotBeforeUpdate=="function"||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(e=s.state,typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount(),e!==s.state&&yp.enqueueReplaceState(s,s.state,null),Tf(t,n,s,r),s.state=t.memoizedState),typeof s.componentDidMount=="function"&&(t.flags|=4194308)}function Ga(t,e){try{var n="",r=e;do n+=g5(r),r=r.return;while(r);var s=n}catch(i){s=`
39
+ Error generating stack: `+i.message+`
40
+ `+i.stack}return{value:t,source:e,stack:s,digest:null}}function Am(t,e,n){return{value:t,source:null,stack:n??null,digest:e??null}}function Sy(t,e){try{console.error(e.value)}catch(n){setTimeout(function(){throw n})}}var W3=typeof WeakMap=="function"?WeakMap:Map;function AN(t,e,n){n=Es(-1,n),n.tag=3,n.payload={element:null};var r=e.value;return n.callback=function(){Pf||(Pf=!0,Ay=r),Sy(t,e)},n}function RN(t,e,n){n=Es(-1,n),n.tag=3;var r=t.type.getDerivedStateFromError;if(typeof r=="function"){var s=e.value;n.payload=function(){return r(s)},n.callback=function(){Sy(t,e)}}var i=t.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){Sy(t,e),typeof r!="function"&&(vi===null?vi=new Set([this]):vi.add(this));var o=e.stack;this.componentDidCatch(e.value,{componentStack:o!==null?o:""})}),n}function Fk(t,e,n){var r=t.pingCache;if(r===null){r=t.pingCache=new W3;var s=new Set;r.set(e,s)}else s=r.get(e),s===void 0&&(s=new Set,r.set(e,s));s.has(n)||(s.add(n),t=rR.bind(null,t,e,n),e.then(t,t))}function Bk(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function Vk(t,e,n,r,s){return t.mode&1?(t.flags|=65536,t.lanes=s,t):(t===e?t.flags|=65536:(t.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(e=Es(-1,1),e.tag=2,xi(n,e,1))),n.lanes|=1),t)}var U3=Bs.ReactCurrentOwner,An=!1;function xn(t,e,n,r){e.child=t===null?cN(e,null,n,r):Ka(e,t.child,n,r)}function Wk(t,e,n,r,s){n=n.render;var i=e.ref;return La(e,s),r=Qv(t,e,n,r,i,s),n=Xv(),t!==null&&!An?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~s,Is(t,e,s)):(ct&&n&&Fv(e),e.flags|=1,xn(t,e,r,s),e.child)}function Uk(t,e,n,r,s){if(t===null){var i=n.type;return typeof i=="function"&&!c1(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(e.tag=15,e.type=i,IN(t,e,i,r,s)):(t=tf(n.type,null,r,e,e.mode,s),t.ref=e.ref,t.return=e,e.child=t)}if(i=t.child,!(t.lanes&s)){var o=i.memoizedProps;if(n=n.compare,n=n!==null?n:qc,n(o,r)&&t.ref===e.ref)return Is(t,e,s)}return e.flags|=1,t=wi(i,r),t.ref=e.ref,t.return=e,e.child=t}function IN(t,e,n,r,s){if(t!==null){var i=t.memoizedProps;if(qc(i,r)&&t.ref===e.ref)if(An=!1,e.pendingProps=r=i,(t.lanes&s)!==0)t.flags&131072&&(An=!0);else return e.lanes=t.lanes,Is(t,e,s)}return Cy(t,e,n,r,s)}function PN(t,e,n){var r=e.pendingProps,s=r.children,i=t!==null?t.memoizedState:null;if(r.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},rt(Ta,Wn),Wn|=n;else{if(!(n&1073741824))return t=i!==null?i.baseLanes|n:n,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,rt(Ta,Wn),Wn|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,rt(Ta,Wn),Wn|=r}else i!==null?(r=i.baseLanes|n,e.memoizedState=null):r=n,rt(Ta,Wn),Wn|=r;return xn(t,e,s,n),e.child}function DN(t,e){var n=e.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(e.flags|=512,e.flags|=2097152)}function Cy(t,e,n,r,s){var i=In(n)?So:pn.current;return i=Ha(e,i),La(e,s),n=Qv(t,e,n,r,i,s),r=Xv(),t!==null&&!An?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~s,Is(t,e,s)):(ct&&r&&Fv(e),e.flags|=1,xn(t,e,n,s),e.child)}function Zk(t,e,n,r,s){if(In(n)){var i=!0;Ef(e)}else i=!1;if(La(e,s),e.stateNode===null)Qu(t,e),ON(e,n,r),by(e,n,r,s),r=!0;else if(t===null){var o=e.stateNode,a=e.memoizedProps;o.props=a;var l=o.context,c=n.contextType;typeof c=="object"&&c!==null?c=ur(c):(c=In(n)?So:pn.current,c=Ha(e,c));var d=n.getDerivedStateFromProps,u=typeof d=="function"||typeof o.getSnapshotBeforeUpdate=="function";u||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==r||l!==c)&&Lk(e,o,r,c),Ys=!1;var h=e.memoizedState;o.state=h,Tf(e,r,o,s),l=e.memoizedState,a!==r||h!==l||Rn.current||Ys?(typeof d=="function"&&(wy(e,n,d,r),l=e.memoizedState),(a=Ys||zk(e,n,a,r,h,l,c))?(u||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount()),typeof o.componentDidMount=="function"&&(e.flags|=4194308)):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=r,e.memoizedState=l),o.props=r,o.state=l,o.context=c,r=a):(typeof o.componentDidMount=="function"&&(e.flags|=4194308),r=!1)}else{o=e.stateNode,uN(t,e),a=e.memoizedProps,c=e.type===e.elementType?a:Sr(e.type,a),o.props=c,u=e.pendingProps,h=o.context,l=n.contextType,typeof l=="object"&&l!==null?l=ur(l):(l=In(n)?So:pn.current,l=Ha(e,l));var m=n.getDerivedStateFromProps;(d=typeof m=="function"||typeof o.getSnapshotBeforeUpdate=="function")||typeof o.UNSAFE_componentWillReceiveProps!="function"&&typeof o.componentWillReceiveProps!="function"||(a!==u||h!==l)&&Lk(e,o,r,l),Ys=!1,h=e.memoizedState,o.state=h,Tf(e,r,o,s);var g=e.memoizedState;a!==u||h!==g||Rn.current||Ys?(typeof m=="function"&&(wy(e,n,m,r),g=e.memoizedState),(c=Ys||zk(e,n,c,r,h,g,l)||!1)?(d||typeof o.UNSAFE_componentWillUpdate!="function"&&typeof o.componentWillUpdate!="function"||(typeof o.componentWillUpdate=="function"&&o.componentWillUpdate(r,g,l),typeof o.UNSAFE_componentWillUpdate=="function"&&o.UNSAFE_componentWillUpdate(r,g,l)),typeof o.componentDidUpdate=="function"&&(e.flags|=4),typeof o.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof o.componentDidUpdate!="function"||a===t.memoizedProps&&h===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&h===t.memoizedState||(e.flags|=1024),e.memoizedProps=r,e.memoizedState=g),o.props=r,o.state=g,o.context=l,r=c):(typeof o.componentDidUpdate!="function"||a===t.memoizedProps&&h===t.memoizedState||(e.flags|=4),typeof o.getSnapshotBeforeUpdate!="function"||a===t.memoizedProps&&h===t.memoizedState||(e.flags|=1024),r=!1)}return Ny(t,e,n,r,i,s)}function Ny(t,e,n,r,s,i){DN(t,e);var o=(e.flags&128)!==0;if(!r&&!o)return s&&Mk(e,n,!1),Is(t,e,i);r=e.stateNode,U3.current=e;var a=o&&typeof n.getDerivedStateFromError!="function"?null:r.render();return e.flags|=1,t!==null&&o?(e.child=Ka(e,t.child,null,i),e.child=Ka(e,null,a,i)):xn(t,e,a,i),e.memoizedState=r.state,s&&Mk(e,n,!0),e.child}function zN(t){var e=t.stateNode;e.pendingContext?$k(t,e.pendingContext,e.pendingContext!==e.context):e.context&&$k(t,e.context,!1),Kv(t,e.containerInfo)}function Hk(t,e,n,r,s){return qa(),Vv(s),e.flags|=256,xn(t,e,n,r),e.child}var Ey={dehydrated:null,treeContext:null,retryLane:0};function _y(t){return{baseLanes:t,cachePool:null,transitions:null}}function LN(t,e,n){var r=e.pendingProps,s=ut.current,i=!1,o=(e.flags&128)!==0,a;if((a=o)||(a=t!==null&&t.memoizedState===null?!1:(s&2)!==0),a?(i=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(s|=1),rt(ut,s&1),t===null)return vy(e),t=e.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?(e.mode&1?t.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(o=r.children,t=r.fallback,i?(r=e.mode,i=e.child,o={mode:"hidden",children:o},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=o):i=kp(o,r,0,null),t=xo(t,r,n,null),i.return=e,t.return=e,i.sibling=t,e.child=i,e.child.memoizedState=_y(n),e.memoizedState=Ey,t):n1(e,o));if(s=t.memoizedState,s!==null&&(a=s.dehydrated,a!==null))return Z3(t,e,o,r,a,s,n);if(i){i=r.fallback,o=e.mode,s=t.child,a=s.sibling;var l={mode:"hidden",children:r.children};return!(o&1)&&e.child!==s?(r=e.child,r.childLanes=0,r.pendingProps=l,e.deletions=null):(r=wi(s,l),r.subtreeFlags=s.subtreeFlags&14680064),a!==null?i=wi(a,i):(i=xo(i,o,n,null),i.flags|=2),i.return=e,r.return=e,r.sibling=i,e.child=r,r=i,i=e.child,o=t.child.memoizedState,o=o===null?_y(n):{baseLanes:o.baseLanes|n,cachePool:null,transitions:o.transitions},i.memoizedState=o,i.childLanes=t.childLanes&~n,e.memoizedState=Ey,r}return i=t.child,t=i.sibling,r=wi(i,{mode:"visible",children:r.children}),!(e.mode&1)&&(r.lanes=n),r.return=e,r.sibling=null,t!==null&&(n=e.deletions,n===null?(e.deletions=[t],e.flags|=16):n.push(t)),e.child=r,e.memoizedState=null,r}function n1(t,e){return e=kp({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function hu(t,e,n,r){return r!==null&&Vv(r),Ka(e,t.child,null,n),t=n1(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function Z3(t,e,n,r,s,i,o){if(n)return e.flags&256?(e.flags&=-257,r=Am(Error(ee(422))),hu(t,e,o,r)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(i=r.fallback,s=e.mode,r=kp({mode:"visible",children:r.children},s,0,null),i=xo(i,s,o,null),i.flags|=2,r.return=e,i.return=e,r.sibling=i,e.child=r,e.mode&1&&Ka(e,t.child,null,o),e.child.memoizedState=_y(o),e.memoizedState=Ey,i);if(!(e.mode&1))return hu(t,e,o,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var a=r.dgst;return r=a,i=Error(ee(419)),r=Am(i,r,void 0),hu(t,e,o,r)}if(a=(o&t.childLanes)!==0,An||a){if(r=Ut,r!==null){switch(o&-o){case 4:s=2;break;case 16:s=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(r.suspendedLanes|o)?0:s,s!==0&&s!==i.retryLane&&(i.retryLane=s,Rs(t,s),$r(r,t,s,-1))}return l1(),r=Am(Error(ee(421))),hu(t,e,o,r)}return s.data==="$?"?(e.flags|=128,e.child=t.child,e=sR.bind(null,t),s._reactRetry=e,null):(t=i.treeContext,Hn=yi(s.nextSibling),Kn=e,ct=!0,Nr=null,t!==null&&(or[ar++]=bs,or[ar++]=Ss,or[ar++]=Co,bs=t.id,Ss=t.overflow,Co=e),e=n1(e,r.children),e.flags|=4096,e)}function qk(t,e,n){t.lanes|=e;var r=t.alternate;r!==null&&(r.lanes|=e),ky(t.return,e,n)}function Rm(t,e,n,r,s){var i=t.memoizedState;i===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(i.isBackwards=e,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=s)}function FN(t,e,n){var r=e.pendingProps,s=r.revealOrder,i=r.tail;if(xn(t,e,r.children,n),r=ut.current,r&2)r=r&1|2,e.flags|=128;else{if(t!==null&&t.flags&128)e:for(t=e.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&qk(t,n,e);else if(t.tag===19)qk(t,n,e);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}r&=1}if(rt(ut,r),!(e.mode&1))e.memoizedState=null;else switch(s){case"forwards":for(n=e.child,s=null;n!==null;)t=n.alternate,t!==null&&Of(t)===null&&(s=n),n=n.sibling;n=s,n===null?(s=e.child,e.child=null):(s=n.sibling,n.sibling=null),Rm(e,!1,s,n,i);break;case"backwards":for(n=null,s=e.child,e.child=null;s!==null;){if(t=s.alternate,t!==null&&Of(t)===null){e.child=s;break}t=s.sibling,s.sibling=n,n=s,s=t}Rm(e,!0,n,null,i);break;case"together":Rm(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function Qu(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function Is(t,e,n){if(t!==null&&(e.dependencies=t.dependencies),Eo|=e.lanes,!(n&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(ee(153));if(e.child!==null){for(t=e.child,n=wi(t,t.pendingProps),e.child=n,n.return=e;t.sibling!==null;)t=t.sibling,n=n.sibling=wi(t,t.pendingProps),n.return=e;n.sibling=null}return e.child}function H3(t,e,n){switch(e.tag){case 3:zN(e),qa();break;case 5:fN(e);break;case 1:In(e.type)&&Ef(e);break;case 4:Kv(e,e.stateNode.containerInfo);break;case 10:var r=e.type._context,s=e.memoizedProps.value;rt($f,r._currentValue),r._currentValue=s;break;case 13:if(r=e.memoizedState,r!==null)return r.dehydrated!==null?(rt(ut,ut.current&1),e.flags|=128,null):n&e.child.childLanes?LN(t,e,n):(rt(ut,ut.current&1),t=Is(t,e,n),t!==null?t.sibling:null);rt(ut,ut.current&1);break;case 19:if(r=(n&e.childLanes)!==0,t.flags&128){if(r)return FN(t,e,n);e.flags|=128}if(s=e.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),rt(ut,ut.current),r)break;return null;case 22:case 23:return e.lanes=0,PN(t,e,n)}return Is(t,e,n)}var BN,jy,VN,WN;BN=function(t,e){for(var n=e.child;n!==null;){if(n.tag===5||n.tag===6)t.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};jy=function(){};VN=function(t,e,n,r){var s=t.memoizedProps;if(s!==r){t=e.stateNode,lo(Xr.current);var i=null;switch(n){case"input":s=Gg(t,s),r=Gg(t,r),i=[];break;case"select":s=mt({},s,{value:void 0}),r=mt({},r,{value:void 0}),i=[];break;case"textarea":s=Xg(t,s),r=Xg(t,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(t.onclick=Cf)}ty(n,r);var o;n=null;for(c in s)if(!r.hasOwnProperty(c)&&s.hasOwnProperty(c)&&s[c]!=null)if(c==="style"){var a=s[c];for(o in a)a.hasOwnProperty(o)&&(n||(n={}),n[o]="")}else c!=="dangerouslySetInnerHTML"&&c!=="children"&&c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&c!=="autoFocus"&&(Fc.hasOwnProperty(c)?i||(i=[]):(i=i||[]).push(c,null));for(c in r){var l=r[c];if(a=s!=null?s[c]:void 0,r.hasOwnProperty(c)&&l!==a&&(l!=null||a!=null))if(c==="style")if(a){for(o in a)!a.hasOwnProperty(o)||l&&l.hasOwnProperty(o)||(n||(n={}),n[o]="");for(o in l)l.hasOwnProperty(o)&&a[o]!==l[o]&&(n||(n={}),n[o]=l[o])}else n||(i||(i=[]),i.push(c,n)),n=l;else c==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,a=a?a.__html:void 0,l!=null&&a!==l&&(i=i||[]).push(c,l)):c==="children"?typeof l!="string"&&typeof l!="number"||(i=i||[]).push(c,""+l):c!=="suppressContentEditableWarning"&&c!=="suppressHydrationWarning"&&(Fc.hasOwnProperty(c)?(l!=null&&c==="onScroll"&&st("scroll",t),i||a===l||(i=[])):(i=i||[]).push(c,l))}n&&(i=i||[]).push("style",n);var c=i;(e.updateQueue=c)&&(e.flags|=4)}};WN=function(t,e,n,r){n!==r&&(e.flags|=4)};function Ul(t,e){if(!ct)switch(t.tailMode){case"hidden":e=t.tail;for(var n=null;e!==null;)e.alternate!==null&&(n=e),e=e.sibling;n===null?t.tail=null:n.sibling=null;break;case"collapsed":n=t.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:r.sibling=null}}function an(t){var e=t.alternate!==null&&t.alternate.child===t.child,n=0,r=0;if(e)for(var s=t.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags&14680064,r|=s.flags&14680064,s.return=t,s=s.sibling;else for(s=t.child;s!==null;)n|=s.lanes|s.childLanes,r|=s.subtreeFlags,r|=s.flags,s.return=t,s=s.sibling;return t.subtreeFlags|=r,t.childLanes=n,e}function q3(t,e,n){var r=e.pendingProps;switch(Bv(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return an(e),null;case 1:return In(e.type)&&Nf(),an(e),null;case 3:return r=e.stateNode,Ja(),at(Rn),at(pn),Gv(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(t===null||t.child===null)&&(uu(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,Nr!==null&&(Py(Nr),Nr=null))),jy(t,e),an(e),null;case 5:Jv(e);var s=lo(Qc.current);if(n=e.type,t!==null&&e.stateNode!=null)VN(t,e,n,r,s),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!r){if(e.stateNode===null)throw Error(ee(166));return an(e),null}if(t=lo(Xr.current),uu(e)){r=e.stateNode,n=e.type;var i=e.memoizedProps;switch(r[qr]=e,r[Gc]=i,t=(e.mode&1)!==0,n){case"dialog":st("cancel",r),st("close",r);break;case"iframe":case"object":case"embed":st("load",r);break;case"video":case"audio":for(s=0;s<sc.length;s++)st(sc[s],r);break;case"source":st("error",r);break;case"img":case"image":case"link":st("error",r),st("load",r);break;case"details":st("toggle",r);break;case"input":nk(r,i),st("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},st("invalid",r);break;case"textarea":sk(r,i),st("invalid",r)}ty(n,i),s=null;for(var o in i)if(i.hasOwnProperty(o)){var a=i[o];o==="children"?typeof a=="string"?r.textContent!==a&&(i.suppressHydrationWarning!==!0&&du(r.textContent,a,t),s=["children",a]):typeof a=="number"&&r.textContent!==""+a&&(i.suppressHydrationWarning!==!0&&du(r.textContent,a,t),s=["children",""+a]):Fc.hasOwnProperty(o)&&a!=null&&o==="onScroll"&&st("scroll",r)}switch(n){case"input":nu(r),rk(r,i,!0);break;case"textarea":nu(r),ik(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=Cf)}r=s,e.updateQueue=r,r!==null&&(e.flags|=4)}else{o=s.nodeType===9?s:s.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=yC(n)),t==="http://www.w3.org/1999/xhtml"?n==="script"?(t=o.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=o.createElement(n,{is:r.is}):(t=o.createElement(n),n==="select"&&(o=t,r.multiple?o.multiple=!0:r.size&&(o.size=r.size))):t=o.createElementNS(t,n),t[qr]=e,t[Gc]=r,BN(t,e,!1,!1),e.stateNode=t;e:{switch(o=ny(n,r),n){case"dialog":st("cancel",t),st("close",t),s=r;break;case"iframe":case"object":case"embed":st("load",t),s=r;break;case"video":case"audio":for(s=0;s<sc.length;s++)st(sc[s],t);s=r;break;case"source":st("error",t),s=r;break;case"img":case"image":case"link":st("error",t),st("load",t),s=r;break;case"details":st("toggle",t),s=r;break;case"input":nk(t,r),s=Gg(t,r),st("invalid",t);break;case"option":s=r;break;case"select":t._wrapperState={wasMultiple:!!r.multiple},s=mt({},r,{value:void 0}),st("invalid",t);break;case"textarea":sk(t,r),s=Xg(t,r),st("invalid",t);break;default:s=r}ty(n,s),a=s;for(i in a)if(a.hasOwnProperty(i)){var l=a[i];i==="style"?kC(t,l):i==="dangerouslySetInnerHTML"?(l=l?l.__html:void 0,l!=null&&xC(t,l)):i==="children"?typeof l=="string"?(n!=="textarea"||l!=="")&&Bc(t,l):typeof l=="number"&&Bc(t,""+l):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(Fc.hasOwnProperty(i)?l!=null&&i==="onScroll"&&st("scroll",t):l!=null&&Ev(t,i,l,o))}switch(n){case"input":nu(t),rk(t,r,!1);break;case"textarea":nu(t),ik(t);break;case"option":r.value!=null&&t.setAttribute("value",""+Oi(r.value));break;case"select":t.multiple=!!r.multiple,i=r.value,i!=null?Ia(t,!!r.multiple,i,!1):r.defaultValue!=null&&Ia(t,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(t.onclick=Cf)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(e.flags|=4)}e.ref!==null&&(e.flags|=512,e.flags|=2097152)}return an(e),null;case 6:if(t&&e.stateNode!=null)WN(t,e,t.memoizedProps,r);else{if(typeof r!="string"&&e.stateNode===null)throw Error(ee(166));if(n=lo(Qc.current),lo(Xr.current),uu(e)){if(r=e.stateNode,n=e.memoizedProps,r[qr]=e,(i=r.nodeValue!==n)&&(t=Kn,t!==null))switch(t.tag){case 3:du(r.nodeValue,n,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&du(r.nodeValue,n,(t.mode&1)!==0)}i&&(e.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[qr]=e,e.stateNode=r}return an(e),null;case 13:if(at(ut),r=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(ct&&Hn!==null&&e.mode&1&&!(e.flags&128))aN(),qa(),e.flags|=98560,i=!1;else if(i=uu(e),r!==null&&r.dehydrated!==null){if(t===null){if(!i)throw Error(ee(318));if(i=e.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(ee(317));i[qr]=e}else qa(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;an(e),i=!1}else Nr!==null&&(Py(Nr),Nr=null),i=!0;if(!i)return e.flags&65536?e:null}return e.flags&128?(e.lanes=n,e):(r=r!==null,r!==(t!==null&&t.memoizedState!==null)&&r&&(e.child.flags|=8192,e.mode&1&&(t===null||ut.current&1?At===0&&(At=3):l1())),e.updateQueue!==null&&(e.flags|=4),an(e),null);case 4:return Ja(),jy(t,e),t===null&&Kc(e.stateNode.containerInfo),an(e),null;case 10:return Zv(e.type._context),an(e),null;case 17:return In(e.type)&&Nf(),an(e),null;case 19:if(at(ut),i=e.memoizedState,i===null)return an(e),null;if(r=(e.flags&128)!==0,o=i.rendering,o===null)if(r)Ul(i,!1);else{if(At!==0||t!==null&&t.flags&128)for(t=e.child;t!==null;){if(o=Of(t),o!==null){for(e.flags|=128,Ul(i,!1),r=o.updateQueue,r!==null&&(e.updateQueue=r,e.flags|=4),e.subtreeFlags=0,r=n,n=e.child;n!==null;)i=n,t=r,i.flags&=14680066,o=i.alternate,o===null?(i.childLanes=0,i.lanes=t,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=o.childLanes,i.lanes=o.lanes,i.child=o.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=o.memoizedProps,i.memoizedState=o.memoizedState,i.updateQueue=o.updateQueue,i.type=o.type,t=o.dependencies,i.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),n=n.sibling;return rt(ut,ut.current&1|2),e.child}t=t.sibling}i.tail!==null&&wt()>Ya&&(e.flags|=128,r=!0,Ul(i,!1),e.lanes=4194304)}else{if(!r)if(t=Of(o),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),Ul(i,!0),i.tail===null&&i.tailMode==="hidden"&&!o.alternate&&!ct)return an(e),null}else 2*wt()-i.renderingStartTime>Ya&&n!==1073741824&&(e.flags|=128,r=!0,Ul(i,!1),e.lanes=4194304);i.isBackwards?(o.sibling=e.child,e.child=o):(n=i.last,n!==null?n.sibling=o:e.child=o,i.last=o)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=wt(),e.sibling=null,n=ut.current,rt(ut,r?n&1|2:n&1),e):(an(e),null);case 22:case 23:return a1(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Wn&1073741824&&(an(e),e.subtreeFlags&6&&(e.flags|=8192)):an(e),null;case 24:return null;case 25:return null}throw Error(ee(156,e.tag))}function K3(t,e){switch(Bv(e),e.tag){case 1:return In(e.type)&&Nf(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Ja(),at(Rn),at(pn),Gv(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Jv(e),null;case 13:if(at(ut),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(ee(340));qa()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return at(ut),null;case 4:return Ja(),null;case 10:return Zv(e.type._context),null;case 22:case 23:return a1(),null;case 24:return null;default:return null}}var pu=!1,cn=!1,J3=typeof WeakSet=="function"?WeakSet:Set,pe=null;function Ma(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){xt(t,e,r)}else n.current=null}function $y(t,e,n){try{n()}catch(r){xt(t,e,r)}}var Kk=!1;function G3(t,e){if(fy=wf,t=KC(),Lv(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var o=0,a=-1,l=-1,c=0,d=0,u=t,h=null;t:for(;;){for(var m;u!==n||s!==0&&u.nodeType!==3||(a=o+s),u!==i||r!==0&&u.nodeType!==3||(l=o+r),u.nodeType===3&&(o+=u.nodeValue.length),(m=u.firstChild)!==null;)h=u,u=m;for(;;){if(u===t)break t;if(h===n&&++c===s&&(a=o),h===i&&++d===r&&(l=o),(m=u.nextSibling)!==null)break;u=h,h=u.parentNode}u=m}n=a===-1||l===-1?null:{start:a,end:l}}else n=null}n=n||{start:0,end:0}}else n=null;for(hy={focusedElem:t,selectionRange:n},wf=!1,pe=e;pe!==null;)if(e=pe,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,pe=t;else for(;pe!==null;){e=pe;try{var g=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(g!==null){var p=g.memoizedProps,x=g.memoizedState,y=e.stateNode,v=y.getSnapshotBeforeUpdate(e.elementType===e.type?p:Sr(e.type,p),x);y.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var k=e.stateNode.containerInfo;k.nodeType===1?k.textContent="":k.nodeType===9&&k.documentElement&&k.removeChild(k.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(ee(163))}}catch(w){xt(e,e.return,w)}if(t=e.sibling,t!==null){t.return=e.return,pe=t;break}pe=e.return}return g=Kk,Kk=!1,g}function wc(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&t)===t){var i=s.destroy;s.destroy=void 0,i!==void 0&&$y(e,n,i)}s=s.next}while(s!==r)}}function xp(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function My(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function UN(t){var e=t.alternate;e!==null&&(t.alternate=null,UN(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[qr],delete e[Gc],delete e[gy],delete e[O3],delete e[A3])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function ZN(t){return t.tag===5||t.tag===3||t.tag===4}function Jk(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||ZN(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Ty(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=Cf));else if(r!==4&&(t=t.child,t!==null))for(Ty(t,e,n),t=t.sibling;t!==null;)Ty(t,e,n),t=t.sibling}function Oy(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(Oy(t,e,n),t=t.sibling;t!==null;)Oy(t,e,n),t=t.sibling}var Yt=null,Cr=!1;function Hs(t,e,n){for(n=n.child;n!==null;)HN(t,e,n),n=n.sibling}function HN(t,e,n){if(Qr&&typeof Qr.onCommitFiberUnmount=="function")try{Qr.onCommitFiberUnmount(dp,n)}catch{}switch(n.tag){case 5:cn||Ma(n,e);case 6:var r=Yt,s=Cr;Yt=null,Hs(t,e,n),Yt=r,Cr=s,Yt!==null&&(Cr?(t=Yt,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):Yt.removeChild(n.stateNode));break;case 18:Yt!==null&&(Cr?(t=Yt,n=n.stateNode,t.nodeType===8?_m(t.parentNode,n):t.nodeType===1&&_m(t,n),Zc(t)):_m(Yt,n.stateNode));break;case 4:r=Yt,s=Cr,Yt=n.stateNode.containerInfo,Cr=!0,Hs(t,e,n),Yt=r,Cr=s;break;case 0:case 11:case 14:case 15:if(!cn&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,o=i.destroy;i=i.tag,o!==void 0&&(i&2||i&4)&&$y(n,e,o),s=s.next}while(s!==r)}Hs(t,e,n);break;case 1:if(!cn&&(Ma(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){xt(n,e,a)}Hs(t,e,n);break;case 21:Hs(t,e,n);break;case 22:n.mode&1?(cn=(r=cn)||n.memoizedState!==null,Hs(t,e,n),cn=r):Hs(t,e,n);break;default:Hs(t,e,n)}}function Gk(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new J3),e.forEach(function(r){var s=iR.bind(null,t,r);n.has(r)||(n.add(r),r.then(s,s))})}}function kr(t,e){var n=e.deletions;if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];try{var i=t,o=e,a=o;e:for(;a!==null;){switch(a.tag){case 5:Yt=a.stateNode,Cr=!1;break e;case 3:Yt=a.stateNode.containerInfo,Cr=!0;break e;case 4:Yt=a.stateNode.containerInfo,Cr=!0;break e}a=a.return}if(Yt===null)throw Error(ee(160));HN(i,o,s),Yt=null,Cr=!1;var l=s.alternate;l!==null&&(l.return=null),s.return=null}catch(c){xt(s,e,c)}}if(e.subtreeFlags&12854)for(e=e.child;e!==null;)qN(e,t),e=e.sibling}function qN(t,e){var n=t.alternate,r=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(kr(e,t),Lr(t),r&4){try{wc(3,t,t.return),xp(3,t)}catch(p){xt(t,t.return,p)}try{wc(5,t,t.return)}catch(p){xt(t,t.return,p)}}break;case 1:kr(e,t),Lr(t),r&512&&n!==null&&Ma(n,n.return);break;case 5:if(kr(e,t),Lr(t),r&512&&n!==null&&Ma(n,n.return),t.flags&32){var s=t.stateNode;try{Bc(s,"")}catch(p){xt(t,t.return,p)}}if(r&4&&(s=t.stateNode,s!=null)){var i=t.memoizedProps,o=n!==null?n.memoizedProps:i,a=t.type,l=t.updateQueue;if(t.updateQueue=null,l!==null)try{a==="input"&&i.type==="radio"&&i.name!=null&&mC(s,i),ny(a,o);var c=ny(a,i);for(o=0;o<l.length;o+=2){var d=l[o],u=l[o+1];d==="style"?kC(s,u):d==="dangerouslySetInnerHTML"?xC(s,u):d==="children"?Bc(s,u):Ev(s,d,u,c)}switch(a){case"input":Yg(s,i);break;case"textarea":gC(s,i);break;case"select":var h=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var m=i.value;m!=null?Ia(s,!!i.multiple,m,!1):h!==!!i.multiple&&(i.defaultValue!=null?Ia(s,!!i.multiple,i.defaultValue,!0):Ia(s,!!i.multiple,i.multiple?[]:"",!1))}s[Gc]=i}catch(p){xt(t,t.return,p)}}break;case 6:if(kr(e,t),Lr(t),r&4){if(t.stateNode===null)throw Error(ee(162));s=t.stateNode,i=t.memoizedProps;try{s.nodeValue=i}catch(p){xt(t,t.return,p)}}break;case 3:if(kr(e,t),Lr(t),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Zc(e.containerInfo)}catch(p){xt(t,t.return,p)}break;case 4:kr(e,t),Lr(t);break;case 13:kr(e,t),Lr(t),s=t.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(i1=wt())),r&4&&Gk(t);break;case 22:if(d=n!==null&&n.memoizedState!==null,t.mode&1?(cn=(c=cn)||d,kr(e,t),cn=c):kr(e,t),Lr(t),r&8192){if(c=t.memoizedState!==null,(t.stateNode.isHidden=c)&&!d&&t.mode&1)for(pe=t,d=t.child;d!==null;){for(u=pe=d;pe!==null;){switch(h=pe,m=h.child,h.tag){case 0:case 11:case 14:case 15:wc(4,h,h.return);break;case 1:Ma(h,h.return);var g=h.stateNode;if(typeof g.componentWillUnmount=="function"){r=h,n=h.return;try{e=r,g.props=e.memoizedProps,g.state=e.memoizedState,g.componentWillUnmount()}catch(p){xt(r,n,p)}}break;case 5:Ma(h,h.return);break;case 22:if(h.memoizedState!==null){Qk(u);continue}}m!==null?(m.return=h,pe=m):Qk(u)}d=d.sibling}e:for(d=null,u=t;;){if(u.tag===5){if(d===null){d=u;try{s=u.stateNode,c?(i=s.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(a=u.stateNode,l=u.memoizedProps.style,o=l!=null&&l.hasOwnProperty("display")?l.display:null,a.style.display=vC("display",o))}catch(p){xt(t,t.return,p)}}}else if(u.tag===6){if(d===null)try{u.stateNode.nodeValue=c?"":u.memoizedProps}catch(p){xt(t,t.return,p)}}else if((u.tag!==22&&u.tag!==23||u.memoizedState===null||u===t)&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===t)break e;for(;u.sibling===null;){if(u.return===null||u.return===t)break e;d===u&&(d=null),u=u.return}d===u&&(d=null),u.sibling.return=u.return,u=u.sibling}}break;case 19:kr(e,t),Lr(t),r&4&&Gk(t);break;case 21:break;default:kr(e,t),Lr(t)}}function Lr(t){var e=t.flags;if(e&2){try{e:{for(var n=t.return;n!==null;){if(ZN(n)){var r=n;break e}n=n.return}throw Error(ee(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(Bc(s,""),r.flags&=-33);var i=Jk(t);Oy(t,i,s);break;case 3:case 4:var o=r.stateNode.containerInfo,a=Jk(t);Ty(t,a,o);break;default:throw Error(ee(161))}}catch(l){xt(t,t.return,l)}t.flags&=-3}e&4096&&(t.flags&=-4097)}function Y3(t,e,n){pe=t,KN(t)}function KN(t,e,n){for(var r=(t.mode&1)!==0;pe!==null;){var s=pe,i=s.child;if(s.tag===22&&r){var o=s.memoizedState!==null||pu;if(!o){var a=s.alternate,l=a!==null&&a.memoizedState!==null||cn;a=pu;var c=cn;if(pu=o,(cn=l)&&!c)for(pe=s;pe!==null;)o=pe,l=o.child,o.tag===22&&o.memoizedState!==null?Xk(s):l!==null?(l.return=o,pe=l):Xk(s);for(;i!==null;)pe=i,KN(i),i=i.sibling;pe=s,pu=a,cn=c}Yk(t)}else s.subtreeFlags&8772&&i!==null?(i.return=s,pe=i):Yk(t)}}function Yk(t){for(;pe!==null;){var e=pe;if(e.flags&8772){var n=e.alternate;try{if(e.flags&8772)switch(e.tag){case 0:case 11:case 15:cn||xp(5,e);break;case 1:var r=e.stateNode;if(e.flags&4&&!cn)if(n===null)r.componentDidMount();else{var s=e.elementType===e.type?n.memoizedProps:Sr(e.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=e.updateQueue;i!==null&&Ik(e,i,r);break;case 3:var o=e.updateQueue;if(o!==null){if(n=null,e.child!==null)switch(e.child.tag){case 5:n=e.child.stateNode;break;case 1:n=e.child.stateNode}Ik(e,o,n)}break;case 5:var a=e.stateNode;if(n===null&&e.flags&4){n=a;var l=e.memoizedProps;switch(e.type){case"button":case"input":case"select":case"textarea":l.autoFocus&&n.focus();break;case"img":l.src&&(n.src=l.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(e.memoizedState===null){var c=e.alternate;if(c!==null){var d=c.memoizedState;if(d!==null){var u=d.dehydrated;u!==null&&Zc(u)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(ee(163))}cn||e.flags&512&&My(e)}catch(h){xt(e,e.return,h)}}if(e===t){pe=null;break}if(n=e.sibling,n!==null){n.return=e.return,pe=n;break}pe=e.return}}function Qk(t){for(;pe!==null;){var e=pe;if(e===t){pe=null;break}var n=e.sibling;if(n!==null){n.return=e.return,pe=n;break}pe=e.return}}function Xk(t){for(;pe!==null;){var e=pe;try{switch(e.tag){case 0:case 11:case 15:var n=e.return;try{xp(4,e)}catch(l){xt(e,n,l)}break;case 1:var r=e.stateNode;if(typeof r.componentDidMount=="function"){var s=e.return;try{r.componentDidMount()}catch(l){xt(e,s,l)}}var i=e.return;try{My(e)}catch(l){xt(e,i,l)}break;case 5:var o=e.return;try{My(e)}catch(l){xt(e,o,l)}}}catch(l){xt(e,e.return,l)}if(e===t){pe=null;break}var a=e.sibling;if(a!==null){a.return=e.return,pe=a;break}pe=e.return}}var Q3=Math.ceil,If=Bs.ReactCurrentDispatcher,r1=Bs.ReactCurrentOwner,dr=Bs.ReactCurrentBatchConfig,He=0,Ut=null,jt=null,tn=0,Wn=0,Ta=qi(0),At=0,nd=null,Eo=0,vp=0,s1=0,bc=null,Mn=null,i1=0,Ya=1/0,xs=null,Pf=!1,Ay=null,vi=null,mu=!1,di=null,Df=0,Sc=0,Ry=null,Xu=-1,ef=0;function bn(){return He&6?wt():Xu!==-1?Xu:Xu=wt()}function ki(t){return t.mode&1?He&2&&tn!==0?tn&-tn:I3.transition!==null?(ef===0&&(ef=OC()),ef):(t=Qe,t!==0||(t=window.event,t=t===void 0?16:LC(t.type)),t):1}function $r(t,e,n,r){if(50<Sc)throw Sc=0,Ry=null,Error(ee(185));$d(t,n,r),(!(He&2)||t!==Ut)&&(t===Ut&&(!(He&2)&&(vp|=n),At===4&&ii(t,tn)),Pn(t,r),n===1&&He===0&&!(e.mode&1)&&(Ya=wt()+500,mp&&Ki()))}function Pn(t,e){var n=t.callbackNode;I5(t,e);var r=kf(t,t===Ut?tn:0);if(r===0)n!==null&&lk(n),t.callbackNode=null,t.callbackPriority=0;else if(e=r&-r,t.callbackPriority!==e){if(n!=null&&lk(n),e===1)t.tag===0?R3(ew.bind(null,t)):sN(ew.bind(null,t)),M3(function(){!(He&6)&&Ki()}),n=null;else{switch(AC(r)){case 1:n=Tv;break;case 4:n=MC;break;case 16:n=vf;break;case 536870912:n=TC;break;default:n=vf}n=nE(n,JN.bind(null,t))}t.callbackPriority=e,t.callbackNode=n}}function JN(t,e){if(Xu=-1,ef=0,He&6)throw Error(ee(327));var n=t.callbackNode;if(Fa()&&t.callbackNode!==n)return null;var r=kf(t,t===Ut?tn:0);if(r===0)return null;if(r&30||r&t.expiredLanes||e)e=zf(t,r);else{e=r;var s=He;He|=2;var i=YN();(Ut!==t||tn!==e)&&(xs=null,Ya=wt()+500,yo(t,e));do try{tR();break}catch(a){GN(t,a)}while(!0);Uv(),If.current=i,He=s,jt!==null?e=0:(Ut=null,tn=0,e=At)}if(e!==0){if(e===2&&(s=ay(t),s!==0&&(r=s,e=Iy(t,s))),e===1)throw n=nd,yo(t,0),ii(t,r),Pn(t,wt()),n;if(e===6)ii(t,r);else{if(s=t.current.alternate,!(r&30)&&!X3(s)&&(e=zf(t,r),e===2&&(i=ay(t),i!==0&&(r=i,e=Iy(t,i))),e===1))throw n=nd,yo(t,0),ii(t,r),Pn(t,wt()),n;switch(t.finishedWork=s,t.finishedLanes=r,e){case 0:case 1:throw Error(ee(345));case 2:ro(t,Mn,xs);break;case 3:if(ii(t,r),(r&130023424)===r&&(e=i1+500-wt(),10<e)){if(kf(t,0)!==0)break;if(s=t.suspendedLanes,(s&r)!==r){bn(),t.pingedLanes|=t.suspendedLanes&s;break}t.timeoutHandle=my(ro.bind(null,t,Mn,xs),e);break}ro(t,Mn,xs);break;case 4:if(ii(t,r),(r&4194240)===r)break;for(e=t.eventTimes,s=-1;0<r;){var o=31-jr(r);i=1<<o,o=e[o],o>s&&(s=o),r&=~i}if(r=s,r=wt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Q3(r/1960))-r,10<r){t.timeoutHandle=my(ro.bind(null,t,Mn,xs),r);break}ro(t,Mn,xs);break;case 5:ro(t,Mn,xs);break;default:throw Error(ee(329))}}}return Pn(t,wt()),t.callbackNode===n?JN.bind(null,t):null}function Iy(t,e){var n=bc;return t.current.memoizedState.isDehydrated&&(yo(t,e).flags|=256),t=zf(t,e),t!==2&&(e=Mn,Mn=n,e!==null&&Py(e)),t}function Py(t){Mn===null?Mn=t:Mn.push.apply(Mn,t)}function X3(t){for(var e=t;;){if(e.flags&16384){var n=e.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var s=n[r],i=s.getSnapshot;s=s.value;try{if(!Or(i(),s))return!1}catch{return!1}}}if(n=e.child,e.subtreeFlags&16384&&n!==null)n.return=e,e=n;else{if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return!0;e=e.return}e.sibling.return=e.return,e=e.sibling}}return!0}function ii(t,e){for(e&=~s1,e&=~vp,t.suspendedLanes|=e,t.pingedLanes&=~e,t=t.expirationTimes;0<e;){var n=31-jr(e),r=1<<n;t[n]=-1,e&=~r}}function ew(t){if(He&6)throw Error(ee(327));Fa();var e=kf(t,0);if(!(e&1))return Pn(t,wt()),null;var n=zf(t,e);if(t.tag!==0&&n===2){var r=ay(t);r!==0&&(e=r,n=Iy(t,r))}if(n===1)throw n=nd,yo(t,0),ii(t,e),Pn(t,wt()),n;if(n===6)throw Error(ee(345));return t.finishedWork=t.current.alternate,t.finishedLanes=e,ro(t,Mn,xs),Pn(t,wt()),null}function o1(t,e){var n=He;He|=1;try{return t(e)}finally{He=n,He===0&&(Ya=wt()+500,mp&&Ki())}}function _o(t){di!==null&&di.tag===0&&!(He&6)&&Fa();var e=He;He|=1;var n=dr.transition,r=Qe;try{if(dr.transition=null,Qe=1,t)return t()}finally{Qe=r,dr.transition=n,He=e,!(He&6)&&Ki()}}function a1(){Wn=Ta.current,at(Ta)}function yo(t,e){t.finishedWork=null,t.finishedLanes=0;var n=t.timeoutHandle;if(n!==-1&&(t.timeoutHandle=-1,$3(n)),jt!==null)for(n=jt.return;n!==null;){var r=n;switch(Bv(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Nf();break;case 3:Ja(),at(Rn),at(pn),Gv();break;case 5:Jv(r);break;case 4:Ja();break;case 13:at(ut);break;case 19:at(ut);break;case 10:Zv(r.type._context);break;case 22:case 23:a1()}n=n.return}if(Ut=t,jt=t=wi(t.current,null),tn=Wn=e,At=0,nd=null,s1=vp=Eo=0,Mn=bc=null,ao!==null){for(e=0;e<ao.length;e++)if(n=ao[e],r=n.interleaved,r!==null){n.interleaved=null;var s=r.next,i=n.pending;if(i!==null){var o=i.next;i.next=s,r.next=o}n.pending=r}ao=null}return t}function GN(t,e){do{var n=jt;try{if(Uv(),Gu.current=Rf,Af){for(var r=ht.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}Af=!1}if(No=0,Ft=Tt=ht=null,kc=!1,Xc=0,r1.current=null,n===null||n.return===null){At=1,nd=e,jt=null;break}e:{var i=t,o=n.return,a=n,l=e;if(e=tn,a.flags|=32768,l!==null&&typeof l=="object"&&typeof l.then=="function"){var c=l,d=a,u=d.tag;if(!(d.mode&1)&&(u===0||u===11||u===15)){var h=d.alternate;h?(d.updateQueue=h.updateQueue,d.memoizedState=h.memoizedState,d.lanes=h.lanes):(d.updateQueue=null,d.memoizedState=null)}var m=Bk(o);if(m!==null){m.flags&=-257,Vk(m,o,a,i,e),m.mode&1&&Fk(i,c,e),e=m,l=c;var g=e.updateQueue;if(g===null){var p=new Set;p.add(l),e.updateQueue=p}else g.add(l);break e}else{if(!(e&1)){Fk(i,c,e),l1();break e}l=Error(ee(426))}}else if(ct&&a.mode&1){var x=Bk(o);if(x!==null){!(x.flags&65536)&&(x.flags|=256),Vk(x,o,a,i,e),Vv(Ga(l,a));break e}}i=l=Ga(l,a),At!==4&&(At=2),bc===null?bc=[i]:bc.push(i),i=o;do{switch(i.tag){case 3:i.flags|=65536,e&=-e,i.lanes|=e;var y=AN(i,l,e);Rk(i,y);break e;case 1:a=l;var v=i.type,k=i.stateNode;if(!(i.flags&128)&&(typeof v.getDerivedStateFromError=="function"||k!==null&&typeof k.componentDidCatch=="function"&&(vi===null||!vi.has(k)))){i.flags|=65536,e&=-e,i.lanes|=e;var w=RN(i,a,e);Rk(i,w);break e}}i=i.return}while(i!==null)}XN(n)}catch(C){e=C,jt===n&&n!==null&&(jt=n=n.return);continue}break}while(!0)}function YN(){var t=If.current;return If.current=Rf,t===null?Rf:t}function l1(){(At===0||At===3||At===2)&&(At=4),Ut===null||!(Eo&268435455)&&!(vp&268435455)||ii(Ut,tn)}function zf(t,e){var n=He;He|=2;var r=YN();(Ut!==t||tn!==e)&&(xs=null,yo(t,e));do try{eR();break}catch(s){GN(t,s)}while(!0);if(Uv(),He=n,If.current=r,jt!==null)throw Error(ee(261));return Ut=null,tn=0,At}function eR(){for(;jt!==null;)QN(jt)}function tR(){for(;jt!==null&&!E5();)QN(jt)}function QN(t){var e=tE(t.alternate,t,Wn);t.memoizedProps=t.pendingProps,e===null?XN(t):jt=e,r1.current=null}function XN(t){var e=t;do{var n=e.alternate;if(t=e.return,e.flags&32768){if(n=K3(n,e),n!==null){n.flags&=32767,jt=n;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{At=6,jt=null;return}}else if(n=q3(n,e,Wn),n!==null){jt=n;return}if(e=e.sibling,e!==null){jt=e;return}jt=e=t}while(e!==null);At===0&&(At=5)}function ro(t,e,n){var r=Qe,s=dr.transition;try{dr.transition=null,Qe=1,nR(t,e,n,r)}finally{dr.transition=s,Qe=r}return null}function nR(t,e,n,r){do Fa();while(di!==null);if(He&6)throw Error(ee(327));n=t.finishedWork;var s=t.finishedLanes;if(n===null)return null;if(t.finishedWork=null,t.finishedLanes=0,n===t.current)throw Error(ee(177));t.callbackNode=null,t.callbackPriority=0;var i=n.lanes|n.childLanes;if(P5(t,i),t===Ut&&(jt=Ut=null,tn=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||mu||(mu=!0,nE(vf,function(){return Fa(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=dr.transition,dr.transition=null;var o=Qe;Qe=1;var a=He;He|=4,r1.current=null,G3(t,n),qN(n,t),b3(hy),wf=!!fy,hy=fy=null,t.current=n,Y3(n),_5(),He=a,Qe=o,dr.transition=i}else t.current=n;if(mu&&(mu=!1,di=t,Df=s),i=t.pendingLanes,i===0&&(vi=null),M5(n.stateNode),Pn(t,wt()),e!==null)for(r=t.onRecoverableError,n=0;n<e.length;n++)s=e[n],r(s.value,{componentStack:s.stack,digest:s.digest});if(Pf)throw Pf=!1,t=Ay,Ay=null,t;return Df&1&&t.tag!==0&&Fa(),i=t.pendingLanes,i&1?t===Ry?Sc++:(Sc=0,Ry=t):Sc=0,Ki(),null}function Fa(){if(di!==null){var t=AC(Df),e=dr.transition,n=Qe;try{if(dr.transition=null,Qe=16>t?16:t,di===null)var r=!1;else{if(t=di,di=null,Df=0,He&6)throw Error(ee(331));var s=He;for(He|=4,pe=t.current;pe!==null;){var i=pe,o=i.child;if(pe.flags&16){var a=i.deletions;if(a!==null){for(var l=0;l<a.length;l++){var c=a[l];for(pe=c;pe!==null;){var d=pe;switch(d.tag){case 0:case 11:case 15:wc(8,d,i)}var u=d.child;if(u!==null)u.return=d,pe=u;else for(;pe!==null;){d=pe;var h=d.sibling,m=d.return;if(UN(d),d===c){pe=null;break}if(h!==null){h.return=m,pe=h;break}pe=m}}}var g=i.alternate;if(g!==null){var p=g.child;if(p!==null){g.child=null;do{var x=p.sibling;p.sibling=null,p=x}while(p!==null)}}pe=i}}if(i.subtreeFlags&2064&&o!==null)o.return=i,pe=o;else e:for(;pe!==null;){if(i=pe,i.flags&2048)switch(i.tag){case 0:case 11:case 15:wc(9,i,i.return)}var y=i.sibling;if(y!==null){y.return=i.return,pe=y;break e}pe=i.return}}var v=t.current;for(pe=v;pe!==null;){o=pe;var k=o.child;if(o.subtreeFlags&2064&&k!==null)k.return=o,pe=k;else e:for(o=v;pe!==null;){if(a=pe,a.flags&2048)try{switch(a.tag){case 0:case 11:case 15:xp(9,a)}}catch(C){xt(a,a.return,C)}if(a===o){pe=null;break e}var w=a.sibling;if(w!==null){w.return=a.return,pe=w;break e}pe=a.return}}if(He=s,Ki(),Qr&&typeof Qr.onPostCommitFiberRoot=="function")try{Qr.onPostCommitFiberRoot(dp,t)}catch{}r=!0}return r}finally{Qe=n,dr.transition=e}}return!1}function tw(t,e,n){e=Ga(n,e),e=AN(t,e,1),t=xi(t,e,1),e=bn(),t!==null&&($d(t,1,e),Pn(t,e))}function xt(t,e,n){if(t.tag===3)tw(t,t,n);else for(;e!==null;){if(e.tag===3){tw(e,t,n);break}else if(e.tag===1){var r=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(vi===null||!vi.has(r))){t=Ga(n,t),t=RN(e,t,1),e=xi(e,t,1),t=bn(),e!==null&&($d(e,1,t),Pn(e,t));break}}e=e.return}}function rR(t,e,n){var r=t.pingCache;r!==null&&r.delete(e),e=bn(),t.pingedLanes|=t.suspendedLanes&n,Ut===t&&(tn&n)===n&&(At===4||At===3&&(tn&130023424)===tn&&500>wt()-i1?yo(t,0):s1|=n),Pn(t,e)}function eE(t,e){e===0&&(t.mode&1?(e=iu,iu<<=1,!(iu&130023424)&&(iu=4194304)):e=1);var n=bn();t=Rs(t,e),t!==null&&($d(t,e,n),Pn(t,n))}function sR(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),eE(t,n)}function iR(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,s=t.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(ee(314))}r!==null&&r.delete(e),eE(t,n)}var tE;tE=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Rn.current)An=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return An=!1,H3(t,e,n);An=!!(t.flags&131072)}else An=!1,ct&&e.flags&1048576&&iN(e,jf,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;Qu(t,e),t=e.pendingProps;var s=Ha(e,pn.current);La(e,n),s=Qv(null,e,r,t,s,n);var i=Xv();return e.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,In(r)?(i=!0,Ef(e)):i=!1,e.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,qv(e),s.updater=yp,e.stateNode=s,s._reactInternals=e,by(e,r,t,n),e=Ny(null,e,r,!0,i,n)):(e.tag=0,ct&&i&&Fv(e),xn(null,e,s,n),e=e.child),e;case 16:r=e.elementType;e:{switch(Qu(t,e),t=e.pendingProps,s=r._init,r=s(r._payload),e.type=r,s=e.tag=aR(r),t=Sr(r,t),s){case 0:e=Cy(null,e,r,t,n);break e;case 1:e=Zk(null,e,r,t,n);break e;case 11:e=Wk(null,e,r,t,n);break e;case 14:e=Uk(null,e,r,Sr(r.type,t),n);break e}throw Error(ee(306,r,""))}return e;case 0:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:Sr(r,s),Cy(t,e,r,s,n);case 1:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:Sr(r,s),Zk(t,e,r,s,n);case 3:e:{if(zN(e),t===null)throw Error(ee(387));r=e.pendingProps,i=e.memoizedState,s=i.element,uN(t,e),Tf(e,r,null,n);var o=e.memoizedState;if(r=o.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},e.updateQueue.baseState=i,e.memoizedState=i,e.flags&256){s=Ga(Error(ee(423)),e),e=Hk(t,e,r,n,s);break e}else if(r!==s){s=Ga(Error(ee(424)),e),e=Hk(t,e,r,n,s);break e}else for(Hn=yi(e.stateNode.containerInfo.firstChild),Kn=e,ct=!0,Nr=null,n=cN(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(qa(),r===s){e=Is(t,e,n);break e}xn(t,e,r,n)}e=e.child}return e;case 5:return fN(e),t===null&&vy(e),r=e.type,s=e.pendingProps,i=t!==null?t.memoizedProps:null,o=s.children,py(r,s)?o=null:i!==null&&py(r,i)&&(e.flags|=32),DN(t,e),xn(t,e,o,n),e.child;case 6:return t===null&&vy(e),null;case 13:return LN(t,e,n);case 4:return Kv(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Ka(e,null,r,n):xn(t,e,r,n),e.child;case 11:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:Sr(r,s),Wk(t,e,r,s,n);case 7:return xn(t,e,e.pendingProps,n),e.child;case 8:return xn(t,e,e.pendingProps.children,n),e.child;case 12:return xn(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,s=e.pendingProps,i=e.memoizedProps,o=s.value,rt($f,r._currentValue),r._currentValue=o,i!==null)if(Or(i.value,o)){if(i.children===s.children&&!Rn.current){e=Is(t,e,n);break e}}else for(i=e.child,i!==null&&(i.return=e);i!==null;){var a=i.dependencies;if(a!==null){o=i.child;for(var l=a.firstContext;l!==null;){if(l.context===r){if(i.tag===1){l=Es(-1,n&-n),l.tag=2;var c=i.updateQueue;if(c!==null){c=c.shared;var d=c.pending;d===null?l.next=l:(l.next=d.next,d.next=l),c.pending=l}}i.lanes|=n,l=i.alternate,l!==null&&(l.lanes|=n),ky(i.return,n,e),a.lanes|=n;break}l=l.next}}else if(i.tag===10)o=i.type===e.type?null:i.child;else if(i.tag===18){if(o=i.return,o===null)throw Error(ee(341));o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),ky(o,n,e),o=i.sibling}else o=i.child;if(o!==null)o.return=i;else for(o=i;o!==null;){if(o===e){o=null;break}if(i=o.sibling,i!==null){i.return=o.return,o=i;break}o=o.return}i=o}xn(t,e,s.children,n),e=e.child}return e;case 9:return s=e.type,r=e.pendingProps.children,La(e,n),s=ur(s),r=r(s),e.flags|=1,xn(t,e,r,n),e.child;case 14:return r=e.type,s=Sr(r,e.pendingProps),s=Sr(r.type,s),Uk(t,e,r,s,n);case 15:return IN(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,s=e.pendingProps,s=e.elementType===r?s:Sr(r,s),Qu(t,e),e.tag=1,In(r)?(t=!0,Ef(e)):t=!1,La(e,n),ON(e,r,s),by(e,r,s,n),Ny(null,e,r,!0,t,n);case 19:return FN(t,e,n);case 22:return PN(t,e,n)}throw Error(ee(156,e.tag))};function nE(t,e){return $C(t,e)}function oR(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function cr(t,e,n,r){return new oR(t,e,n,r)}function c1(t){return t=t.prototype,!(!t||!t.isReactComponent)}function aR(t){if(typeof t=="function")return c1(t)?1:0;if(t!=null){if(t=t.$$typeof,t===jv)return 11;if(t===$v)return 14}return 2}function wi(t,e){var n=t.alternate;return n===null?(n=cr(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function tf(t,e,n,r,s,i){var o=2;if(r=t,typeof t=="function")c1(t)&&(o=1);else if(typeof t=="string")o=5;else e:switch(t){case wa:return xo(n.children,s,i,e);case _v:o=8,s|=8;break;case Hg:return t=cr(12,n,e,s|2),t.elementType=Hg,t.lanes=i,t;case qg:return t=cr(13,n,e,s),t.elementType=qg,t.lanes=i,t;case Kg:return t=cr(19,n,e,s),t.elementType=Kg,t.lanes=i,t;case fC:return kp(n,s,i,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case dC:o=10;break e;case uC:o=9;break e;case jv:o=11;break e;case $v:o=14;break e;case Gs:o=16,r=null;break e}throw Error(ee(130,t==null?t:typeof t,""))}return e=cr(o,n,e,s),e.elementType=t,e.type=r,e.lanes=i,e}function xo(t,e,n,r){return t=cr(7,t,r,e),t.lanes=n,t}function kp(t,e,n,r){return t=cr(22,t,r,e),t.elementType=fC,t.lanes=n,t.stateNode={isHidden:!1},t}function Im(t,e,n){return t=cr(6,t,null,e),t.lanes=n,t}function Pm(t,e,n){return e=cr(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function lR(t,e,n,r,s){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=gm(0),this.expirationTimes=gm(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=gm(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function d1(t,e,n,r,s,i,o,a,l){return t=new lR(t,e,n,a,l),e===1?(e=1,i===!0&&(e|=8)):e=0,i=cr(3,null,null,e),t.current=i,i.stateNode=t,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},qv(i),t}function cR(t,e,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:ka,key:r==null?null:""+r,children:t,containerInfo:e,implementation:n}}function rE(t){if(!t)return Ai;t=t._reactInternals;e:{if(qo(t)!==t||t.tag!==1)throw Error(ee(170));var e=t;do{switch(e.tag){case 3:e=e.stateNode.context;break e;case 1:if(In(e.type)){e=e.stateNode.__reactInternalMemoizedMergedChildContext;break e}}e=e.return}while(e!==null);throw Error(ee(171))}if(t.tag===1){var n=t.type;if(In(n))return rN(t,n,e)}return e}function sE(t,e,n,r,s,i,o,a,l){return t=d1(n,r,!0,t,s,i,o,a,l),t.context=rE(null),n=t.current,r=bn(),s=ki(n),i=Es(r,s),i.callback=e??null,xi(n,i,s),t.current.lanes=s,$d(t,s,r),Pn(t,r),t}function wp(t,e,n,r){var s=e.current,i=bn(),o=ki(s);return n=rE(n),e.context===null?e.context=n:e.pendingContext=n,e=Es(i,o),e.payload={element:t},r=r===void 0?null:r,r!==null&&(e.callback=r),t=xi(s,e,o),t!==null&&($r(t,s,o,i),Ju(t,s,o)),o}function Lf(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function nw(t,e){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var n=t.retryLane;t.retryLane=n!==0&&n<e?n:e}}function u1(t,e){nw(t,e),(t=t.alternate)&&nw(t,e)}function dR(){return null}var iE=typeof reportError=="function"?reportError:function(t){console.error(t)};function f1(t){this._internalRoot=t}bp.prototype.render=f1.prototype.render=function(t){var e=this._internalRoot;if(e===null)throw Error(ee(409));wp(t,e,null,null)};bp.prototype.unmount=f1.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var e=t.containerInfo;_o(function(){wp(null,t,null,null)}),e[As]=null}};function bp(t){this._internalRoot=t}bp.prototype.unstable_scheduleHydration=function(t){if(t){var e=PC();t={blockedOn:null,target:t,priority:e};for(var n=0;n<si.length&&e!==0&&e<si[n].priority;n++);si.splice(n,0,t),n===0&&zC(t)}};function h1(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function Sp(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function rw(){}function uR(t,e,n,r,s){if(s){if(typeof r=="function"){var i=r;r=function(){var c=Lf(o);i.call(c)}}var o=sE(e,r,t,0,null,!1,!1,"",rw);return t._reactRootContainer=o,t[As]=o.current,Kc(t.nodeType===8?t.parentNode:t),_o(),o}for(;s=t.lastChild;)t.removeChild(s);if(typeof r=="function"){var a=r;r=function(){var c=Lf(l);a.call(c)}}var l=d1(t,0,!1,null,null,!1,!1,"",rw);return t._reactRootContainer=l,t[As]=l.current,Kc(t.nodeType===8?t.parentNode:t),_o(function(){wp(e,l,n,r)}),l}function Cp(t,e,n,r,s){var i=n._reactRootContainer;if(i){var o=i;if(typeof s=="function"){var a=s;s=function(){var l=Lf(o);a.call(l)}}wp(e,o,t,s)}else o=uR(n,e,t,s,r);return Lf(o)}RC=function(t){switch(t.tag){case 3:var e=t.stateNode;if(e.current.memoizedState.isDehydrated){var n=rc(e.pendingLanes);n!==0&&(Ov(e,n|1),Pn(e,wt()),!(He&6)&&(Ya=wt()+500,Ki()))}break;case 13:_o(function(){var r=Rs(t,1);if(r!==null){var s=bn();$r(r,t,1,s)}}),u1(t,1)}};Av=function(t){if(t.tag===13){var e=Rs(t,134217728);if(e!==null){var n=bn();$r(e,t,134217728,n)}u1(t,134217728)}};IC=function(t){if(t.tag===13){var e=ki(t),n=Rs(t,e);if(n!==null){var r=bn();$r(n,t,e,r)}u1(t,e)}};PC=function(){return Qe};DC=function(t,e){var n=Qe;try{return Qe=t,e()}finally{Qe=n}};sy=function(t,e,n){switch(e){case"input":if(Yg(t,n),e=n.name,n.type==="radio"&&e!=null){for(n=t;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+e)+'][type="radio"]'),e=0;e<n.length;e++){var r=n[e];if(r!==t&&r.form===t.form){var s=pp(r);if(!s)throw Error(ee(90));pC(r),Yg(r,s)}}}break;case"textarea":gC(t,n);break;case"select":e=n.value,e!=null&&Ia(t,!!n.multiple,e,!1)}};SC=o1;CC=_o;var fR={usingClientEntryPoint:!1,Events:[Td,Na,pp,wC,bC,o1]},Zl={findFiberByHostInstance:oo,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},hR={bundleType:Zl.bundleType,version:Zl.version,rendererPackageName:Zl.rendererPackageName,rendererConfig:Zl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:Bs.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=_C(t),t===null?null:t.stateNode},findFiberByHostInstance:Zl.findFiberByHostInstance||dR,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var gu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!gu.isDisabled&&gu.supportsFiber)try{dp=gu.inject(hR),Qr=gu}catch{}}Xn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=fR;Xn.createPortal=function(t,e){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h1(e))throw Error(ee(200));return cR(t,e,null,n)};Xn.createRoot=function(t,e){if(!h1(t))throw Error(ee(299));var n=!1,r="",s=iE;return e!=null&&(e.unstable_strictMode===!0&&(n=!0),e.identifierPrefix!==void 0&&(r=e.identifierPrefix),e.onRecoverableError!==void 0&&(s=e.onRecoverableError)),e=d1(t,1,!1,null,null,n,!1,r,s),t[As]=e.current,Kc(t.nodeType===8?t.parentNode:t),new f1(e)};Xn.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var e=t._reactInternals;if(e===void 0)throw typeof t.render=="function"?Error(ee(188)):(t=Object.keys(t).join(","),Error(ee(268,t)));return t=_C(e),t=t===null?null:t.stateNode,t};Xn.flushSync=function(t){return _o(t)};Xn.hydrate=function(t,e,n){if(!Sp(e))throw Error(ee(200));return Cp(null,t,e,!0,n)};Xn.hydrateRoot=function(t,e,n){if(!h1(t))throw Error(ee(405));var r=n!=null&&n.hydratedSources||null,s=!1,i="",o=iE;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(o=n.onRecoverableError)),e=sE(e,null,t,1,n??null,s,!1,i,o),t[As]=e.current,Kc(t),r)for(t=0;t<r.length;t++)n=r[t],s=n._getVersion,s=s(n._source),e.mutableSourceEagerHydrationData==null?e.mutableSourceEagerHydrationData=[n,s]:e.mutableSourceEagerHydrationData.push(n,s);return new bp(e)};Xn.render=function(t,e,n){if(!Sp(e))throw Error(ee(200));return Cp(null,t,e,!1,n)};Xn.unmountComponentAtNode=function(t){if(!Sp(t))throw Error(ee(40));return t._reactRootContainer?(_o(function(){Cp(null,null,t,!1,function(){t._reactRootContainer=null,t[As]=null})}),!0):!1};Xn.unstable_batchedUpdates=o1;Xn.unstable_renderSubtreeIntoContainer=function(t,e,n,r){if(!Sp(n))throw Error(ee(200));if(t==null||t._reactInternals===void 0)throw Error(ee(38));return Cp(t,e,n,!1,r)};Xn.version="18.3.1-next-f1338f8080-20240426";function oE(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(oE)}catch(t){console.error(t)}}oE(),oC.exports=Xn;var Ad=oC.exports;const pR=KS(Ad);var aE,sw=Ad;aE=sw.createRoot,sw.hydrateRoot;function jo(t,e=8){if(t.length<2)return"";let n=`M ${t[0].x} ${t[0].y}`;for(let s=1;s<t.length-1;s++){const i=t[s-1],o=t[s],a=t[s+1],l=Math.hypot(o.x-i.x,o.y-i.y),c=Math.hypot(a.x-o.x,a.y-o.y),d=Math.min(e,l/2,c/2);if(d<.5){n+=` L ${o.x} ${o.y}`;continue}const u={x:o.x-(o.x-i.x)/l*d,y:o.y-(o.y-i.y)/l*d},h={x:o.x+(a.x-o.x)/c*d,y:o.y+(a.y-o.y)/c*d};n+=` L ${u.x} ${u.y} Q ${o.x} ${o.y} ${h.x} ${h.y}`}const r=t[t.length-1];return`${n} L ${r.x} ${r.y}`}function lE(t,e){if(t.length<2||e<=0)return t;const n=t.slice(),r=n[n.length-2],s=n[n.length-1],i=Math.hypot(s.x-r.x,s.y-r.y);return i<=e||(n[n.length-1]={x:s.x-(s.x-r.x)/i*e,y:s.y-(s.y-r.y)/i*e}),n}function cE(t){const e=t[t.length-2],n=t[t.length-1];return Math.atan2(n.y-e.y,n.x-e.x)}function mR(t){const e=t[1],n=t[0];return Math.atan2(n.y-e.y,n.x-e.x)}function gR(t){let e=0,n=-1;for(let i=0;i<t.length-1;i++){const o=Math.hypot(t[i+1].x-t[i].x,t[i+1].y-t[i].y);o>n&&(n=o,e=i)}const r=t[e],s=t[e+1]??r;return{x:(r.x+s.x)/2,y:(r.y+s.y)/2,horizontal:Math.abs(s.x-r.x)>=Math.abs(s.y-r.y)}}function Ri(t){if(t.length===0)return{x:0,y:0,w:0,h:0};const e=Math.min(...t.map(i=>i.x)),n=Math.min(...t.map(i=>i.y)),r=Math.max(...t.map(i=>i.x+i.w)),s=Math.max(...t.map(i=>i.y+i.h));return{x:e,y:n,w:r-e,h:s-n}}const yR=(t,e,n,r)=>t.length*e*(r==="mono"?.6:n>=600?.56:.52);let xR={sans:'"Hanken Grotesk Variable", ui-sans-serif, system-ui, sans-serif',mono:'"JetBrains Mono Variable", ui-monospace, monospace'};function vR(){if(typeof document>"u")return;const t=document.createElement("canvas").getContext("2d");if(t)return(e,n,r,s)=>(t.font=`${r} ${n}px ${xR[s]}`,t.measureText(e).width)}let iw;function Re(t,e=13,n=400,r="sans"){return iw??(iw=vR()??yR),iw(t,e,n,r)}function Ff(t,e,n=13,r=400,s=2){const i=t.split(/\s+/).filter(Boolean),o=[];let a="";for(const d of i){const u=a?`${a} ${d}`:d;Re(u,n,r)<=e||!a?a=u:(o.push(a),a=d)}if(a&&o.push(a),o.length<=s)return o;const l=o.slice(0,s);let c=l[s-1];for(;c.length>1&&Re(`${c}…`,n,r)>e;)c=c.slice(0,-1).trimEnd();return l[s-1]=`${c}…`,l}function Ot(t,e,n=13,r=400,s="sans"){if(Re(t,n,r,s)<=e)return t;let i=t;for(;i.length>1&&Re(`${i}…`,n,r,s)>e;)i=i.slice(0,-1);return`${i.trimEnd()}…`}const kR="modulepreload",wR=function(t){return"/"+t},ow={},p1=function(e,n,r){let s=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));s=Promise.allSettled(n.map(l=>{if(l=wR(l),l in ow)return;ow[l]=!0;const c=l.endsWith(".css"),d=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${d}`))return;const u=document.createElement("link");if(u.rel=c?"stylesheet":kR,c||(u.as="script"),u.crossOrigin="",u.href=l,a&&u.setAttribute("nonce",a),document.head.appendChild(u),c)return new Promise((h,m)=>{u.addEventListener("load",h),u.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${l}`)))})}))}function i(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return s.then(o=>{for(const a of o||[])a.status==="rejected"&&i(a.reason);return e().catch(i)})};let bR;const SR=()=>bR??(bR=p1(()=>import("./elk.bundled-DY947aeZ.js").then(t=>t.e),[]).then(t=>new t.default)),Rd={"elk.algorithm":"layered","elk.edgeRouting":"ORTHOGONAL","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.crossingMinimization.strategy":"LAYER_SWEEP","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"};async function Id(t){var a;const e=await(await SR()).layout(t),n=new Map,r=new Map([[e.id,{x:0,y:0}]]),s=(l,c,d,u)=>{var g;const h=c+(l.x??0),m=d+(l.y??0);r.set(l.id,{x:h,y:m}),n.set(l.id,{id:l.id,parent:u,x:h,y:m,w:l.width??0,h:l.height??0}),(g=l.children)==null||g.forEach(p=>s(p,h,m,l.id))};(a=e.children)==null||a.forEach(l=>s(l,0,0));const i=new Map,o=l=>{var c,d;(c=l.edges)==null||c.forEach(u=>{var v;const h=u.container??l.id,m=r.get(h)??{x:0,y:0},g=k=>({x:k.x+m.x,y:k.y+m.y}),p=(v=u.sections)==null?void 0:v[0],x=p?[p.startPoint,...p.bendPoints??[],p.endPoint].map(g):[],y=(u.labels??[]).map(k=>({text:k.text??"",x:(k.x??0)+m.x,y:(k.y??0)+m.y,w:k.width??0,h:k.height??0}));i.set(u.id,{id:u.id,points:x,labels:y})}),(d=l.children)==null||d.forEach(o)};return o(e),{width:e.width??0,height:e.height??0,nodes:n,edges:i}}var Ze;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{const i={};for(const o of s)i[o]=o;return i},t.getValidEnumValues=s=>{const i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(const a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(const o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Ze||(Ze={}));var aw;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(aw||(aw={}));const me=Ze.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Qs=t=>{switch(typeof t){case"undefined":return me.undefined;case"string":return me.string;case"number":return Number.isNaN(t)?me.nan:me.number;case"boolean":return me.boolean;case"function":return me.function;case"bigint":return me.bigint;case"symbol":return me.symbol;case"object":return Array.isArray(t)?me.array:t===null?me.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?me.promise:typeof Map<"u"&&t instanceof Map?me.map:typeof Set<"u"&&t instanceof Set?me.set:typeof Date<"u"&&t instanceof Date?me.date:me.object;default:return me.unknown}},te=Ze.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);let $o=class dE extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(o))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return s(this),r}static assert(e){if(!(e instanceof dE))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ze.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},r=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};$o.create=t=>new $o(t);const Dy=(t,e)=>{let n;switch(t.code){case te.invalid_type:t.received===me.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case te.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,Ze.jsonStringifyReplacer)}`;break;case te.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ze.joinValues(t.keys,", ")}`;break;case te.invalid_union:n="Invalid input";break;case te.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ze.joinValues(t.options)}`;break;case te.invalid_enum_value:n=`Invalid enum value. Expected ${Ze.joinValues(t.options)}, received '${t.received}'`;break;case te.invalid_arguments:n="Invalid function arguments";break;case te.invalid_return_type:n="Invalid function return type";break;case te.invalid_date:n="Invalid date";break;case te.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:Ze.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case te.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case te.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case te.custom:n="Invalid input";break;case te.invalid_intersection_types:n="Intersection results could not be merged";break;case te.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case te.not_finite:n="Number must be finite";break;default:n=e.defaultError,Ze.assertNever(t)}return{message:n}};let CR=Dy;function NR(){return CR}const ER=t=>{const{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)a=c(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}};function ae(t,e){const n=NR(),r=ER({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Dy?void 0:Dy].filter(s=>!!s)});t.common.issues.push(r)}let Yn=class uE{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const s of n){if(s.status==="aborted")return Ee;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const s of n){const i=await s.key,o=await s.value;r.push({key:i,value:o})}return uE.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const s of n){const{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return Ee;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}};const Ee=Object.freeze({status:"aborted"}),ic=t=>({status:"dirty",value:t}),mr=t=>({status:"valid",value:t}),lw=t=>t.status==="aborted",cw=t=>t.status==="dirty",Qa=t=>t.status==="valid",Bf=t=>typeof Promise<"u"&&t instanceof Promise;var xe;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(xe||(xe={}));let ts=class{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const dw=(t,e)=>{if(Qa(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new $o(t.common.issues);return this._error=n,this._error}}};function Ie(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{const{message:l}=t;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:s}}let We=class{get description(){return this._def.description}_getType(e){return Qs(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:Qs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Yn,ctx:{common:e.parent.common,data:e.data,parsedType:Qs(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(Bf(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Qs(e)},s=this._parseSync({data:e,path:r.path,parent:r});return dw(r,s)}"~validate"(e){var r,s;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Qs(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:n});return Qa(i)?{value:i.value}:{issues:n.common.issues}}catch(i){(s=(r=i==null?void 0:i.message)==null?void 0:r.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(i=>Qa(i)?{value:i.value}:{issues:n.common.issues})}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Qs(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(Bf(s)?s:Promise.resolve(s));return dw(r,i)}refine(e,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const o=e(s),a=()=>i.addIssue({code:te.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new Mo({schema:this,typeName:_e.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return _s.create(this,this._def)}nullable(){return To.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Xa.create(this)}promise(){return Kf.create(this,this._def)}or(e){return Wf.create([this,e],this._def)}and(e){return Uf.create(this,e,this._def)}transform(e){return new Mo({...Ie(this._def),schema:this,typeName:_e.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new Jf({...Ie(this._def),innerType:this,defaultValue:n,typeName:_e.ZodDefault})}brand(){return new yE({typeName:_e.ZodBranded,type:this,...Ie(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new Gf({...Ie(this._def),innerType:this,catchValue:n,typeName:_e.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return JR.create(this,e)}readonly(){return Yf.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const _R=/^c[^\s-]{8,}$/i,jR=/^[0-9a-z]+$/,$R=/^[0-9A-HJKMNP-TV-Z]{26}$/i,MR=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,TR=/^[a-z0-9_-]{21}$/i,OR=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,AR=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,RR=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,IR="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Dm;const PR=/^(?:(?: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])$/,DR=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,zR=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,LR=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,FR=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,BR=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,fE="((\\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])))",VR=new RegExp(`^${fE}$`);function hE(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function WR(t){return new RegExp(`^${hE(t)}$`)}function UR(t){let e=`${fE}T${hE(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function ZR(t,e){return!!((e==="v4"||!e)&&PR.test(t)||(e==="v6"||!e)&&zR.test(t))}function HR(t,e){if(!OR.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function qR(t,e){return!!((e==="v4"||!e)&&DR.test(t)||(e==="v6"||!e)&&LR.test(t))}let Vf=class oc extends We{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==me.string){const i=this._getOrReturnCtx(e);return ae(i,{code:te.invalid_type,expected:me.string,received:i.parsedType}),Ee}const r=new Yn;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),ae(s,{code:te.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),ae(s,{code:te.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?ae(s,{code:te.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&ae(s,{code:te.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")RR.test(e.data)||(s=this._getOrReturnCtx(e,s),ae(s,{validation:"email",code:te.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Dm||(Dm=new RegExp(IR,"u")),Dm.test(e.data)||(s=this._getOrReturnCtx(e,s),ae(s,{validation:"emoji",code:te.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")MR.test(e.data)||(s=this._getOrReturnCtx(e,s),ae(s,{validation:"uuid",code:te.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")TR.test(e.data)||(s=this._getOrReturnCtx(e,s),ae(s,{validation:"nanoid",code:te.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")_R.test(e.data)||(s=this._getOrReturnCtx(e,s),ae(s,{validation:"cuid",code:te.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")jR.test(e.data)||(s=this._getOrReturnCtx(e,s),ae(s,{validation:"cuid2",code:te.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")$R.test(e.data)||(s=this._getOrReturnCtx(e,s),ae(s,{validation:"ulid",code:te.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),ae(s,{validation:"url",code:te.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),ae(s,{validation:"regex",code:te.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),ae(s,{code:te.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),ae(s,{code:te.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),ae(s,{code:te.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?UR(i).test(e.data)||(s=this._getOrReturnCtx(e,s),ae(s,{code:te.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?VR.test(e.data)||(s=this._getOrReturnCtx(e,s),ae(s,{code:te.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?WR(i).test(e.data)||(s=this._getOrReturnCtx(e,s),ae(s,{code:te.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?AR.test(e.data)||(s=this._getOrReturnCtx(e,s),ae(s,{validation:"duration",code:te.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?ZR(e.data,i.version)||(s=this._getOrReturnCtx(e,s),ae(s,{validation:"ip",code:te.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?HR(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),ae(s,{validation:"jwt",code:te.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?qR(e.data,i.version)||(s=this._getOrReturnCtx(e,s),ae(s,{validation:"cidr",code:te.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?FR.test(e.data)||(s=this._getOrReturnCtx(e,s),ae(s,{validation:"base64",code:te.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?BR.test(e.data)||(s=this._getOrReturnCtx(e,s),ae(s,{validation:"base64url",code:te.invalid_string,message:i.message}),r.dirty()):Ze.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:te.invalid_string,...xe.errToObj(r)})}_addCheck(e){return new oc({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...xe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...xe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...xe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...xe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...xe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...xe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...xe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...xe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...xe.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...xe.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...xe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...xe.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...xe.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...xe.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...xe.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...xe.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...xe.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...xe.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...xe.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...xe.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...xe.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...xe.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...xe.errToObj(n)})}nonempty(e){return this.min(1,xe.errToObj(e))}trim(){return new oc({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new oc({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new oc({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Vf.create=t=>new Vf({checks:[],typeName:_e.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...Ie(t)});function KR(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}let zy=class Ly extends We{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==me.number){const i=this._getOrReturnCtx(e);return ae(i,{code:te.invalid_type,expected:me.number,received:i.parsedType}),Ee}let r;const s=new Yn;for(const i of this._def.checks)i.kind==="int"?Ze.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),ae(r,{code:te.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),ae(r,{code:te.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),ae(r,{code:te.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?KR(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),ae(r,{code:te.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),ae(r,{code:te.not_finite,message:i.message}),s.dirty()):Ze.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,xe.toString(n))}gt(e,n){return this.setLimit("min",e,!1,xe.toString(n))}lte(e,n){return this.setLimit("max",e,!0,xe.toString(n))}lt(e,n){return this.setLimit("max",e,!1,xe.toString(n))}setLimit(e,n,r,s){return new Ly({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:xe.toString(s)}]})}_addCheck(e){return new Ly({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:xe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:xe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:xe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:xe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:xe.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:xe.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:xe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:xe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:xe.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Ze.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};zy.create=t=>new zy({checks:[],typeName:_e.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...Ie(t)});let uw=class Fy extends We{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==me.bigint)return this._getInvalidInput(e);let r;const s=new Yn;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),ae(r,{code:te.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),ae(r,{code:te.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),ae(r,{code:te.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Ze.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return ae(n,{code:te.invalid_type,expected:me.bigint,received:n.parsedType}),Ee}gte(e,n){return this.setLimit("min",e,!0,xe.toString(n))}gt(e,n){return this.setLimit("min",e,!1,xe.toString(n))}lte(e,n){return this.setLimit("max",e,!0,xe.toString(n))}lt(e,n){return this.setLimit("max",e,!1,xe.toString(n))}setLimit(e,n,r,s){return new Fy({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:xe.toString(s)}]})}_addCheck(e){return new Fy({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:xe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:xe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:xe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:xe.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:xe.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};uw.create=t=>new uw({checks:[],typeName:_e.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...Ie(t)});let By=class extends We{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==me.boolean){const r=this._getOrReturnCtx(e);return ae(r,{code:te.invalid_type,expected:me.boolean,received:r.parsedType}),Ee}return mr(e.data)}};By.create=t=>new By({typeName:_e.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...Ie(t)});let fw=class pE extends We{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==me.date){const i=this._getOrReturnCtx(e);return ae(i,{code:te.invalid_type,expected:me.date,received:i.parsedType}),Ee}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return ae(i,{code:te.invalid_date}),Ee}const r=new Yn;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),ae(s,{code:te.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),ae(s,{code:te.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):Ze.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new pE({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:xe.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:xe.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};fw.create=t=>new fw({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:_e.ZodDate,...Ie(t)});let hw=class extends We{_parse(e){if(this._getType(e)!==me.symbol){const r=this._getOrReturnCtx(e);return ae(r,{code:te.invalid_type,expected:me.symbol,received:r.parsedType}),Ee}return mr(e.data)}};hw.create=t=>new hw({typeName:_e.ZodSymbol,...Ie(t)});let Vy=class extends We{_parse(e){if(this._getType(e)!==me.undefined){const r=this._getOrReturnCtx(e);return ae(r,{code:te.invalid_type,expected:me.undefined,received:r.parsedType}),Ee}return mr(e.data)}};Vy.create=t=>new Vy({typeName:_e.ZodUndefined,...Ie(t)});let Wy=class extends We{_parse(e){if(this._getType(e)!==me.null){const r=this._getOrReturnCtx(e);return ae(r,{code:te.invalid_type,expected:me.null,received:r.parsedType}),Ee}return mr(e.data)}};Wy.create=t=>new Wy({typeName:_e.ZodNull,...Ie(t)});let pw=class extends We{constructor(){super(...arguments),this._any=!0}_parse(e){return mr(e.data)}};pw.create=t=>new pw({typeName:_e.ZodAny,...Ie(t)});let Uy=class extends We{constructor(){super(...arguments),this._unknown=!0}_parse(e){return mr(e.data)}};Uy.create=t=>new Uy({typeName:_e.ZodUnknown,...Ie(t)});let Ii=class extends We{_parse(e){const n=this._getOrReturnCtx(e);return ae(n,{code:te.invalid_type,expected:me.never,received:n.parsedType}),Ee}};Ii.create=t=>new Ii({typeName:_e.ZodNever,...Ie(t)});let mw=class extends We{_parse(e){if(this._getType(e)!==me.undefined){const r=this._getOrReturnCtx(e);return ae(r,{code:te.invalid_type,expected:me.void,received:r.parsedType}),Ee}return mr(e.data)}};mw.create=t=>new mw({typeName:_e.ZodVoid,...Ie(t)});let Xa=class nf extends We{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==me.array)return ae(n,{code:te.invalid_type,expected:me.array,received:n.parsedType}),Ee;if(s.exactLength!==null){const o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(ae(n,{code:o?te.too_big:te.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(ae(n,{code:te.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(ae(n,{code:te.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new ts(n,o,n.path,a)))).then(o=>Yn.mergeArray(r,o));const i=[...n.data].map((o,a)=>s.type._parseSync(new ts(n,o,n.path,a)));return Yn.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new nf({...this._def,minLength:{value:e,message:xe.toString(n)}})}max(e,n){return new nf({...this._def,maxLength:{value:e,message:xe.toString(n)}})}length(e,n){return new nf({...this._def,exactLength:{value:e,message:xe.toString(n)}})}nonempty(e){return this.min(1,e)}};Xa.create=(t,e)=>new Xa({type:t,minLength:null,maxLength:null,exactLength:null,typeName:_e.ZodArray,...Ie(e)});function la(t){if(t instanceof Ps){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=_s.create(la(r))}return new Ps({...t._def,shape:()=>e})}else return t instanceof Xa?new Xa({...t._def,type:la(t.element)}):t instanceof _s?_s.create(la(t.unwrap())):t instanceof To?To.create(la(t.unwrap())):t instanceof rd?rd.create(t.items.map(e=>la(e))):t}let Ps=class wr extends We{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=Ze.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==me.object){const c=this._getOrReturnCtx(e);return ae(c,{code:te.invalid_type,expected:me.object,received:c.parsedType}),Ee}const{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ii&&this._def.unknownKeys==="strip"))for(const c in s.data)o.includes(c)||a.push(c);const l=[];for(const c of o){const d=i[c],u=s.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new ts(s,u,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof Ii){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of a)l.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(c==="strict")a.length>0&&(ae(s,{code:te.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of a){const u=s.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new ts(s,u,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of l){const u=await d.key,h=await d.value;c.push({key:u,value:h,alwaysSet:d.alwaysSet})}return c}).then(c=>Yn.mergeObjectSync(r,c)):Yn.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return xe.errToObj,new wr({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{var i,o;const s=((o=(i=this._def).errorMap)==null?void 0:o.call(i,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:xe.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new wr({...this._def,unknownKeys:"strip"})}passthrough(){return new wr({...this._def,unknownKeys:"passthrough"})}extend(e){return new wr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new wr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_e.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new wr({...this._def,catchall:e})}pick(e){const n={};for(const r of Ze.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new wr({...this._def,shape:()=>n})}omit(e){const n={};for(const r of Ze.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new wr({...this._def,shape:()=>n})}deepPartial(){return la(this)}partial(e){const n={};for(const r of Ze.objectKeys(this.shape)){const s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new wr({...this._def,shape:()=>n})}required(e){const n={};for(const r of Ze.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof _s;)i=i._def.innerType;n[r]=i}return new wr({...this._def,shape:()=>n})}keyof(){return gE(Ze.objectKeys(this.shape))}};Ps.create=(t,e)=>new Ps({shape:()=>t,unknownKeys:"strip",catchall:Ii.create(),typeName:_e.ZodObject,...Ie(e)});Ps.strictCreate=(t,e)=>new Ps({shape:()=>t,unknownKeys:"strict",catchall:Ii.create(),typeName:_e.ZodObject,...Ie(e)});Ps.lazycreate=(t,e)=>new Ps({shape:t,unknownKeys:"strip",catchall:Ii.create(),typeName:_e.ZodObject,...Ie(e)});let Wf=class extends We{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(const a of i)if(a.result.status==="valid")return a.result;for(const a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(a=>new $o(a.ctx.common.issues));return ae(n,{code:te.invalid_union,unionErrors:o}),Ee}if(n.common.async)return Promise.all(r.map(async i=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i;const o=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},d=l._parseSync({data:n.data,path:n.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!i&&(i={result:d,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const a=o.map(l=>new $o(l));return ae(n,{code:te.invalid_union,unionErrors:a}),Ee}}get options(){return this._def.options}};Wf.create=(t,e)=>new Wf({options:t,typeName:_e.ZodUnion,...Ie(e)});const gs=t=>t instanceof Hf?gs(t.schema):t instanceof Mo?gs(t.innerType()):t instanceof qf?[t.value]:t instanceof Np?t.options:t instanceof Ky?Ze.objectValues(t.enum):t instanceof Jf?gs(t._def.innerType):t instanceof Vy?[void 0]:t instanceof Wy?[null]:t instanceof _s?[void 0,...gs(t.unwrap())]:t instanceof To?[null,...gs(t.unwrap())]:t instanceof yE||t instanceof Yf?gs(t.unwrap()):t instanceof Gf?gs(t._def.innerType):[];class m1 extends We{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==me.object)return ae(n,{code:te.invalid_type,expected:me.object,received:n.parsedType}),Ee;const r=this.discriminator,s=n.data[r],i=this.optionsMap.get(s);return i?n.common.async?i._parseAsync({data:n.data,path:n.path,parent:n}):i._parseSync({data:n.data,path:n.path,parent:n}):(ae(n,{code:te.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Ee)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,r){const s=new Map;for(const i of n){const o=gs(i.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const a of o){if(s.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,i)}}return new m1({typeName:_e.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:s,...Ie(r)})}}function Zy(t,e){const n=Qs(t),r=Qs(e);if(t===e)return{valid:!0,data:t};if(n===me.object&&r===me.object){const s=Ze.objectKeys(e),i=Ze.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(const a of i){const l=Zy(t[a],e[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===me.array&&r===me.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<t.length;i++){const o=t[i],a=e[i],l=Zy(o,a);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return n===me.date&&r===me.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}let Uf=class extends We{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(lw(i)||lw(o))return Ee;const a=Zy(i.value,o.value);return a.valid?((cw(i)||cw(o))&&n.dirty(),{status:n.value,value:a.data}):(ae(r,{code:te.invalid_intersection_types}),Ee)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};Uf.create=(t,e,n)=>new Uf({left:t,right:e,typeName:_e.ZodIntersection,...Ie(n)});let rd=class mE extends We{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==me.array)return ae(r,{code:te.invalid_type,expected:me.array,received:r.parsedType}),Ee;if(r.data.length<this._def.items.length)return ae(r,{code:te.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ee;!this._def.rest&&r.data.length>this._def.items.length&&(ae(r,{code:te.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((o,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new ts(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>Yn.mergeArray(n,o)):Yn.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new mE({...this._def,rest:e})}};rd.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new rd({items:t,typeName:_e.ZodTuple,rest:null,...Ie(e)})};class Zf extends We{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==me.object)return ae(r,{code:te.invalid_type,expected:me.object,received:r.parsedType}),Ee;const s=[],i=this._def.keyType,o=this._def.valueType;for(const a in r.data)s.push({key:i._parse(new ts(r,a,r.path,a)),value:o._parse(new ts(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Yn.mergeObjectAsync(n,s):Yn.mergeObjectSync(n,s)}get element(){return this._def.valueType}static create(e,n,r){return n instanceof We?new Zf({keyType:e,valueType:n,typeName:_e.ZodRecord,...Ie(r)}):new Zf({keyType:Vf.create(),valueType:e,typeName:_e.ZodRecord,...Ie(n)})}}let gw=class extends We{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==me.map)return ae(r,{code:te.invalid_type,expected:me.map,received:r.parsedType}),Ee;const s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,l],c)=>({key:s._parse(new ts(r,a,r.path,[c,"key"])),value:i._parse(new ts(r,l,r.path,[c,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of o){const c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return Ee;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(c.value,d.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const l of o){const c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return Ee;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(c.value,d.value)}return{status:n.value,value:a}}}};gw.create=(t,e,n)=>new gw({valueType:e,keyType:t,typeName:_e.ZodMap,...Ie(n)});let yw=class Hy extends We{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==me.set)return ae(r,{code:te.invalid_type,expected:me.set,received:r.parsedType}),Ee;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(ae(r,{code:te.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(ae(r,{code:te.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function o(l){const c=new Set;for(const d of l){if(d.status==="aborted")return Ee;d.status==="dirty"&&n.dirty(),c.add(d.value)}return{status:n.value,value:c}}const a=[...r.data.values()].map((l,c)=>i._parse(new ts(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(e,n){return new Hy({...this._def,minSize:{value:e,message:xe.toString(n)}})}max(e,n){return new Hy({...this._def,maxSize:{value:e,message:xe.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};yw.create=(t,e)=>new yw({valueType:t,minSize:null,maxSize:null,typeName:_e.ZodSet,...Ie(e)});let Hf=class extends We{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};Hf.create=(t,e)=>new Hf({getter:t,typeName:_e.ZodLazy,...Ie(e)});let qf=class extends We{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return ae(n,{received:n.data,code:te.invalid_literal,expected:this._def.value}),Ee}return{status:"valid",value:e.data}}get value(){return this._def.value}};qf.create=(t,e)=>new qf({value:t,typeName:_e.ZodLiteral,...Ie(e)});function gE(t,e){return new Np({values:t,typeName:_e.ZodEnum,...Ie(e)})}let Np=class qy extends We{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return ae(n,{expected:Ze.joinValues(r),received:n.parsedType,code:te.invalid_type}),Ee}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),r=this._def.values;return ae(n,{received:n.data,code:te.invalid_enum_value,options:r}),Ee}return mr(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return qy.create(e,{...this._def,...n})}exclude(e,n=this._def){return qy.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};Np.create=gE;let Ky=class extends We{_parse(e){const n=Ze.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==me.string&&r.parsedType!==me.number){const s=Ze.objectValues(n);return ae(r,{expected:Ze.joinValues(s),received:r.parsedType,code:te.invalid_type}),Ee}if(this._cache||(this._cache=new Set(Ze.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=Ze.objectValues(n);return ae(r,{received:r.data,code:te.invalid_enum_value,options:s}),Ee}return mr(e.data)}get enum(){return this._def.values}};Ky.create=(t,e)=>new Ky({values:t,typeName:_e.ZodNativeEnum,...Ie(e)});let Kf=class extends We{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==me.promise&&n.common.async===!1)return ae(n,{code:te.invalid_type,expected:me.promise,received:n.parsedType}),Ee;const r=n.parsedType===me.promise?n.data:Promise.resolve(n.data);return mr(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};Kf.create=(t,e)=>new Kf({type:t,typeName:_e.ZodPromise,...Ie(e)});let Mo=class extends We{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_e.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{ae(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return Ee;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?Ee:l.status==="dirty"||n.value==="dirty"?ic(l.value):l});{if(n.value==="aborted")return Ee;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?Ee:a.status==="dirty"||n.value==="dirty"?ic(a.value):a}}if(s.type==="refinement"){const o=a=>{const l=s.refinement(a,i);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Ee:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Ee:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!Qa(o))return Ee;const a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>Qa(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):Ee);Ze.assertNever(s)}};Mo.create=(t,e,n)=>new Mo({schema:t,typeName:_e.ZodEffects,effect:e,...Ie(n)});Mo.createWithPreprocess=(t,e,n)=>new Mo({schema:e,effect:{type:"preprocess",transform:t},typeName:_e.ZodEffects,...Ie(n)});let _s=class extends We{_parse(e){return this._getType(e)===me.undefined?mr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};_s.create=(t,e)=>new _s({innerType:t,typeName:_e.ZodOptional,...Ie(e)});let To=class extends We{_parse(e){return this._getType(e)===me.null?mr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};To.create=(t,e)=>new To({innerType:t,typeName:_e.ZodNullable,...Ie(e)});let Jf=class extends We{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===me.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};Jf.create=(t,e)=>new Jf({innerType:t,typeName:_e.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Ie(e)});let Gf=class extends We{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Bf(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new $o(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new $o(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Gf.create=(t,e)=>new Gf({innerType:t,typeName:_e.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Ie(e)});let xw=class extends We{_parse(e){if(this._getType(e)!==me.nan){const r=this._getOrReturnCtx(e);return ae(r,{code:te.invalid_type,expected:me.nan,received:r.parsedType}),Ee}return{status:"valid",value:e.data}}};xw.create=t=>new xw({typeName:_e.ZodNaN,...Ie(t)});let yE=class extends We{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},JR=class xE extends We{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Ee:i.status==="dirty"?(n.dirty(),ic(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Ee:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new xE({in:e,out:n,typeName:_e.ZodPipeline})}},Yf=class extends We{_parse(e){const n=this._def.innerType._parse(e),r=s=>(Qa(s)&&(s.value=Object.freeze(s.value)),s);return Bf(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};Yf.create=(t,e)=>new Yf({innerType:t,typeName:_e.ZodReadonly,...Ie(e)});var _e;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(_e||(_e={}));const q=Vf.create,Dn=zy.create,Mr=By.create,vE=Uy.create;Ii.create;const he=Xa.create,Cc=Ps.create,Ko=Wf.create,g1=m1.create;Uf.create;rd.create;const oi=Zf.create,kE=Hf.create,mn=qf.create,vt=Np.create;Kf.create;_s.create;To.create;const Ne=t=>Cc(t).strict(),oe=q().regex(/^[a-z0-9][a-z0-9-_.]*$/,'Identifiers use lowercase letters, digits, "-", "_" and "."'),wE=Ne({path:q(),line:Dn().int().positive().optional(),symbol:q().optional(),repository:q().optional()}),bE=oi(q(),Ko([q(),Dn(),Mr()])),Pd=oi(q(),vE()),SE=q().regex(/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/,'Extension kinds look like "extension/kind"'),CE=vt(["person","system","web-app","service","gateway","database","cache","message-broker","external","component","interface","library"]),GR=Ko([CE,SE]),Qf=Ne({id:oe,kind:GR,name:q().min(1),summary:q(),description:q().optional(),parent:oe.optional(),technology:q().optional(),tags:he(q()).default([]),sourceRefs:he(wE).default([]),metadata:bE.default({}),ext:Pd.default({})}),NE=vt(["uses","calls","reads","writes","reads-writes","publishes","subscribes","depends-on","implements"]),YR=Ko([NE,SE]),Xf=Ne({id:oe,kind:YR,source:oe,target:oe,label:q(),description:q().optional(),protocol:q().optional(),data:he(oe).default([]),metadata:bE.default({}),ext:Pd.default({})}),QR=Ne({name:q(),type:q(),description:q().optional(),primaryKey:Mr().default(!1),nullable:Mr().default(!1),unique:Mr().default(!1),references:Ne({dataType:oe,field:q()}).optional()}),XR=vt(["table","record","event","document"]),eI=Ne({id:oe,kind:XR,name:q(),summary:q(),description:q().optional(),fields:he(QR).default([]),ownedBy:oe.optional(),storedIn:oe.optional(),sourceRefs:he(wE).default([]),ext:Pd.default({})}),vw=vt(["exactly-one","zero-or-one","one-or-many","zero-or-many"]),tI=Ne({id:oe,from:oe,to:oe,fromCardinality:vw,toCardinality:vw,label:q(),via:q().optional(),logical:Mr().default(!1)}),nI=Ne({id:oe,source:oe,target:oe,data:he(oe).min(1),label:q(),description:q().optional(),via:oe.optional()}),rI=vt(["call","return","async","self"]),sI=Ne({type:mn("message"),id:oe,kind:rI,from:oe,to:oe,label:q(),description:q().optional(),relationship:oe.optional(),data:he(oe).default([])}),iI=kE(()=>Ne({type:mn("fragment"),id:oe,kind:vt(["alt","opt","loop","par"]),label:q(),branches:he(Ne({guard:q(),steps:he(EE)})).min(1)})),EE=kE(()=>Ko([sI,iI])),oI=Ne({kind:mn("interaction"),id:oe,name:q(),summary:q(),description:q().optional(),participants:he(oe).min(2),steps:he(EE).min(1)}),aI=Ne({id:oe,kind:vt(["initial","final","action","decision","merge","fork","join"]),label:q(),description:q().optional(),performedBy:oe.optional(),outcome:vt(["success","failure"]).optional()}),lI=Ne({id:oe,from:oe,to:oe,guard:q().optional()}),cI=Ne({kind:mn("activity"),id:oe,name:q(),summary:q(),description:q().optional(),nodes:he(aI).min(2),flows:he(lI).min(1)}),dI=Ne({id:oe,kind:vt(["initial","state","final"]),name:q(),description:q().optional(),entryActions:he(q()).default([]),outcome:vt(["success","failure","neutral"]).default("neutral")}),_E=Ne({id:oe,from:oe,to:oe,event:q(),guard:q().optional(),actions:he(q()).default([]),description:q().optional(),triggeredBy:oe.optional()}),uI=Ne({kind:mn("state-machine"),id:oe,name:q(),summary:q(),description:q().optional(),subject:oe.optional(),owner:oe.optional(),states:he(dI).min(2),transitions:he(_E).min(1)}),fI=g1("kind",[oI,cI,uI]),hI=Ne({id:oe,name:q(),summary:q(),area:q(),actors:he(oe).min(1),supporting:he(oe).default([]),realizedBy:he(oe).default([]),behaviors:he(oe).default([]),includes:he(oe).default([]),ext:Pd.default({})}),pI=Ne({entities:he(Qf).default([]),relationships:he(Xf).default([]),dataTypes:he(eI).default([]),dataRelations:he(tI).default([]),dataFlows:he(nI).default([]),behaviors:he(fI).default([]),useCases:he(hI).default([])});vt(["extension","map","architecture","sequence","dataflow","activity","erd","state","usecase","dependency"]);const kw=["overview","behavior","data","structure","use-cases"],jE=q().min(1),$E=vt(["right","down"]),mI=Ne({x:Dn(),y:Dn()}),ls=Ne({id:oe,title:q(),description:q(),category:jE,positions:oi(q(),mI).default({}),ext:Pd.default({})}),ME=Ne({id:oe,label:q(),description:q().optional(),members:he(oe)}),TE=ls.extend({type:mn("architecture"),entities:he(oe).min(1),relationships:he(oe).optional(),groups:he(ME).default([]),collapsed:he(oe).default([]),layout:Ne({direction:$E.default("right")}).default({})}),OE=ls.extend({type:mn("map"),entities:he(oe).min(1),relationships:he(oe).optional(),passThrough:he(oe).default([]),collapsed:he(oe).default([]),layout:Ne({direction:$E.default("right")}).default({})}),AE=ls.extend({type:mn("sequence"),interaction:oe}),RE=ls.extend({type:mn("dataflow"),flows:he(oe).min(1),showControlFlow:Mr().default(!0)}),IE=ls.extend({type:mn("activity"),activity:oe,swimlanes:Mr().default(!0)}),PE=ls.extend({type:mn("erd"),dataTypes:he(oe).min(1),groupByStore:Mr().default(!0),fieldLimit:Dn().int().positive().default(6)}),DE=ls.extend({type:mn("state"),stateMachine:oe}),zE=ls.extend({type:mn("usecase"),useCases:he(oe).min(1)}),LE=ls.extend({type:mn("dependency"),entities:he(oe).min(1),relationships:he(oe).optional(),layers:he(ME).min(1)}),gI=ls.extend({type:mn("extension"),extension:q().regex(/^[a-z][a-z0-9-]*\/[a-z][a-z0-9-]*$/),entities:he(oe).default([]),data:vE()}),yI=g1("type",[TE,OE,AE,RE,IE,PE,DE,zE,LE,gI]),us={id:oe.optional(),title:q().optional(),description:q().default(""),category:jE.default("walkthrough")},FE=g1("type",[OE.extend(us),AE.extend(us),DE.extend(us),IE.extend(us),TE.extend(us),RE.extend(us),PE.extend(us),zE.extend(us),LE.extend(us)]),xI=vt(["lapis","malachite","ochre","umber","tyrian","slate","accent","verdigris"]),Ep=Ko([xI,q().regex(/^#[0-9a-fA-F]{6}$/)]),vI=vt(["card","cylinder","person","stack","frame","chip"]),kI=Ne({shape:vI,tone:Ep,icon:q(),label:q()}),wI=Ne({pattern:vt(["solid","dashed","dotted"]),head:vt(["arrow","open-arrow","none","triangle"])}),ww=Ne({tone:Ep.optional(),icon:q().optional(),width:Dn().positive().optional(),height:Dn().positive().optional(),emphasis:Mr().optional()}),bI=Ne({kinds:oi(q(),kI),relationships:oi(q(),wI),elements:oi(q(),ww).default({}),views:oi(q(),oi(q(),ww)).default({})}),el=q().regex(/^[a-zA-Z]+:[a-z0-9][a-z0-9-_.:#]*$/,'A ref looks like "entity:order-service"'),SI=vt(["new","changed","removed"]),CI=Ne({ref:el,state:SI,note:q().optional()}),NI=Ne({kind:vt(["add","del","ctx"]),old:Dn().int().positive().optional(),new:Dn().int().positive().optional(),text:q()}),EI=Ne({header:q().optional(),lines:he(NI).min(1)}),_I=Cc({path:q(),title:q().optional(),hunks:he(EI).min(1).optional(),start:Dn().int().positive().optional(),text:q().optional(),notes:he(Ne({line:Dn().int().positive(),text:q()})).default([])}).refine(t=>t.hunks?t.text===void 0&&t.start===void 0:t.text!==void 0&&t.start!==void 0,{message:'Give "hunks" (a diff), or "start" and "text" (an excerpt), not both'}).transform(({start:t,text:e,hunks:n,...r})=>({...r,hunks:n??[{lines:e.replace(/\n$/,"").split(`
41
+ `).map((s,i)=>({kind:"ctx",new:t+i,text:s}))}]})),BE=vt(["look","routine"]),jI=vt(["flow","attention","hot-path","slow","failing","blocked"]),$I=Ne({target:el,as:jI,tone:Ep.optional()}),MI=Ne({target:el,text:q().min(1),tone:Ep.optional()}),TI=Ne({ref:el,caption:q().optional()}),OI=Ne({id:oe,title:q(),text:q(),risk:BE.default("routine"),view:Ko([oe,FE]).optional(),focus:he(el).default([]),callouts:he(Ne({target:el,text:q()})).default([]),cases:he(Ne({when:q(),then:q(),note:q().optional()})).default([]),proof:he(Ne({text:q(),source:q().optional(),test:q().optional(),missing:Mr().default(!1)})).default([]),question:q().optional(),questions:he(q()).default([]),code:he(_I).default([]),trace:he(TI).default([]),effects:he($I).default([]),badges:he(MI).default([])}),AI=vt(["change","tour"]),RI=Ne({id:oe,kind:AI.default("change"),title:q(),summary:q(),source:Cc({kind:q(),ref:q().optional(),head:q().optional(),url:q().optional(),repository:q().optional(),base:q().optional(),author:q().optional(),files:Dn().int().nonnegative().optional(),added:Dn().int().nonnegative().optional(),removed:Dn().int().nonnegative().optional()}).optional(),story:Ne({text:q(),before:q().optional(),after:q().optional()}),overview:Ko([oe,FE]).optional(),verdict:Cc({risk:BE,facts:he(Ne({label:q(),value:q()})).default([]),findings:he(Ne({text:q(),severity:vt(["risk","note"]).default("risk"),scene:oe.optional()})).default([])}).optional(),marks:he(CI).default([]),removed:Cc({entities:he(Qf).default([]),relationships:he(Xf).default([]),transitions:he(Ne({stateMachine:oe,transition:_E})).default([])}).default({}),scenes:he(OI).min(1)}),VE={kinds:{person:{shape:"person",tone:"slate",icon:"user-round",label:"Person"},system:{shape:"frame",tone:"slate",icon:"boxes",label:"Software system"},"web-app":{shape:"card",tone:"tyrian",icon:"app-window",label:"Web app"},gateway:{shape:"card",tone:"slate",icon:"route",label:"Gateway"},service:{shape:"card",tone:"lapis",icon:"server",label:"Service"},database:{shape:"cylinder",tone:"malachite",icon:"database",label:"Database"},cache:{shape:"cylinder",tone:"verdigris",icon:"zap",label:"Cache"},"message-broker":{shape:"stack",tone:"ochre",icon:"waypoints",label:"Message broker"},external:{shape:"card",tone:"umber",icon:"globe",label:"External system"},component:{shape:"chip",tone:"lapis",icon:"box",label:"Component"},interface:{shape:"chip",tone:"tyrian",icon:"plug",label:"Interface"},library:{shape:"chip",tone:"slate",icon:"library",label:"Library"}},relationships:{uses:{pattern:"solid",head:"arrow"},calls:{pattern:"solid",head:"arrow"},reads:{pattern:"solid",head:"arrow"},writes:{pattern:"solid",head:"arrow"},"reads-writes":{pattern:"solid",head:"none"},publishes:{pattern:"dashed",head:"open-arrow"},subscribes:{pattern:"dashed",head:"open-arrow"},"depends-on":{pattern:"solid",head:"arrow"},implements:{pattern:"dashed",head:"triangle"}},elements:{},views:{}},WE="0.2.0",II=Ne({id:oe,name:q(),description:q().default(""),repository:q().optional(),defaultView:oe.optional()}),PI=Ne({name:q().regex(/^[a-z][a-z0-9-]*$/),version:q(),required:Mr().default(!1)}),DI=Ne({poneyVersion:mn(WE),project:II,extensions:he(PI).default([]),model:pI.default({}),views:he(yI).default([]),walkthroughs:he(RI).default([]),presentation:bI.default(VE)}),zI=DI.transform(t=>{const e=[...t.views],n=(s,i,o)=>{if(s===void 0||typeof s=="string")return s;const a={...s,id:s.id??i,title:s.title??o};return e.push(a),a.id},r=t.walkthroughs.map(s=>({...s,overview:n(s.overview,`${s.id}.overview`,s.title),scenes:s.scenes.map(i=>({...i,view:n(i.view,`${s.id}.${i.id}`,i.title)}))}));return{...t,views:e,walkthroughs:r}});function bw(t){const e=t.indexOf("/");return e>0?t.slice(0,e):void 0}function Jr(t,e,n){var o,a;const r=(o=t.facets)==null?void 0:o[e],s=(a=n==null?void 0:n.ext)==null?void 0:a[t.name];if(!r||s===void 0)return;const i=r.safeParse(s);return i.success?i.data:void 0}const LI={shape:"card",tone:"slate",icon:"box",label:"Element"};class FI{constructor(e){sn(this,"entities",new Map);sn(this,"relationships",new Map);sn(this,"dataTypes",new Map);sn(this,"dataRelations",new Map);sn(this,"dataFlows",new Map);sn(this,"behaviors",new Map);sn(this,"useCases",new Map);sn(this,"views",new Map);sn(this,"out",new Map);sn(this,"in",new Map);sn(this,"kids",new Map);sn(this,"flatCache",new Map);sn(this,"outgoing",e=>this.out.get(e)??[]);sn(this,"incoming",e=>this.in.get(e)??[]);sn(this,"children",e=>this.kids.get(e)??[]);this.doc=e;const n=e.model;n.entities.forEach(r=>this.entities.set(r.id,r)),n.relationships.forEach(r=>{this.relationships.set(r.id,r),Hl(this.out,r.source,r),Hl(this.in,r.target,r)}),n.dataTypes.forEach(r=>this.dataTypes.set(r.id,r)),n.dataRelations.forEach(r=>this.dataRelations.set(r.id,r)),n.dataFlows.forEach(r=>this.dataFlows.set(r.id,r)),n.behaviors.forEach(r=>this.behaviors.set(r.id,r)),n.useCases.forEach(r=>this.useCases.set(r.id,r)),n.entities.forEach(r=>r.parent&&Hl(this.kids,r.parent,r)),e.views.forEach(r=>this.views.set(r.id,r))}ancestors(e){var s;const n=[];let r=(s=this.entities.get(e))==null?void 0:s.parent;for(;r;){const i=this.entities.get(r);if(!i)break;n.push(i),r=i.parent}return n}style(e,n){var l;const r=typeof e=="string"?this.entities.get(e):e,s=this.doc.presentation,i=(r&&s.kinds[r.kind])??LI,o=(r?s.elements[r.id]:void 0)??{},a=(r&&n?(l=s.views[n])==null?void 0:l[r.id]:void 0)??{};return{...i,tone:a.tone??o.tone??i.tone,icon:a.icon??o.icon??i.icon,emphasis:a.emphasis??o.emphasis??!1}}interaction(e){const n=this.behaviors.get(e);return(n==null?void 0:n.kind)==="interaction"?n:void 0}activity(e){const n=this.behaviors.get(e);return(n==null?void 0:n.kind)==="activity"?n:void 0}stateMachine(e){const n=this.behaviors.get(e);return(n==null?void 0:n.kind)==="state-machine"?n:void 0}messages(e){const n=this.flatCache.get(e);if(n)return n;const r=[],s=(o,a)=>{for(const l of o)l.type==="message"?r.push({message:l,number:r.length+1,context:a}):l.branches.forEach(c=>s(c.steps,[...a,{fragment:l,guard:c.guard}]))},i=this.interaction(e);return i&&s(i.steps,[]),this.flatCache.set(e,r),r}findFragment(e,n){let r;const s=o=>o.forEach(a=>{a.type==="fragment"&&(a.id===n&&(r=a),a.branches.forEach(l=>s(l.steps)))}),i=this.interaction(e);return i&&s(i.steps),r}behaviorsInvolving(e){return this.doc.model.behaviors.filter(n=>n.kind==="interaction"?n.participants.includes(e):n.kind==="activity"?n.nodes.some(r=>r.performedBy===e):n.owner===e||n.transitions.some(r=>r.triggeredBy===e))}dataOf(e){const n=new Map,r=new Map;for(const i of this.doc.model.dataFlows)i.target===e&&i.data.forEach(o=>Hl(n,o,i)),i.source===e&&i.data.forEach(o=>Hl(r,o,i));const s=this.doc.model.dataTypes.filter(i=>i.ownedBy===e||i.storedIn===e);return{consumed:n,produced:r,owned:s}}useCasesOf(e){return this.doc.model.useCases.filter(n=>n.actors.includes(e)||n.supporting.includes(e)||n.realizedBy.includes(e))}usagesOfData(e){const n=this.doc.model.dataFlows.filter(a=>a.data.includes(e)),r=this.doc.model.relationships.filter(a=>a.data.includes(e)),s=[];for(const a of this.doc.model.behaviors)if(a.kind==="interaction")for(const l of this.messages(a.id))l.message.data.includes(e)&&s.push({interaction:a,item:l});const i=this.doc.model.behaviors.filter(a=>a.kind==="state-machine"&&a.subject===e),o=this.doc.model.dataRelations.filter(a=>a.from===e||a.to===e);return{flows:n,relationships:r,messages:s,lifecycles:i,relations:o}}messagesAlong(e){const n=[];for(const r of this.doc.model.behaviors)if(r.kind==="interaction")for(const s of this.messages(r.id))s.message.relationship===e&&n.push({interaction:r,item:s});return n}viewShows(e,n){var r;switch(e.type){case"architecture":case"map":case"dependency":{if(n.kind==="entity")return e.entities.includes(n.id);if(n.kind==="relationship"){const s=this.relationships.get(n.id);return s?e.relationships?e.relationships.includes(s.id):e.type==="map"&&(e.passThrough.includes(s.source)||e.passThrough.includes(s.target))?!0:e.entities.includes(s.source)&&e.entities.includes(s.target):!1}return n.kind==="group"?n.view===e.id&&e.type!=="map":!1}case"sequence":{const s=this.messages(e.interaction);return n.kind==="entity"?!!((r=this.interaction(e.interaction))!=null&&r.participants.includes(n.id)):n.kind==="behavior"?n.id===e.interaction:n.kind==="message"||n.kind==="fragment"?n.behavior===e.interaction:n.kind==="relationship"?s.some(i=>i.message.relationship===n.id):n.kind==="dataType"?s.some(i=>i.message.data.includes(n.id)):!1}case"dataflow":{const s=e.flows.map(i=>this.dataFlows.get(i)).filter(Oo);return n.kind==="entity"?s.some(i=>i.source===n.id||i.target===n.id):n.kind==="dataFlow"?e.flows.includes(n.id):n.kind==="dataType"?s.some(i=>i.data.includes(n.id)):n.kind==="relationship"?s.some(i=>i.via===n.id):!1}case"activity":{const s=this.activity(e.activity);return n.kind==="entity"?!!(s!=null&&s.nodes.some(i=>i.performedBy===n.id)):n.kind==="behavior"?n.id===e.activity:n.kind==="activityNode"||n.kind==="activityFlow"?n.behavior===e.activity:!1}case"erd":{if(n.kind==="dataType")return e.dataTypes.includes(n.id);if(n.kind==="dataRelation"){const s=this.dataRelations.get(n.id);return!!s&&e.dataTypes.includes(s.from)&&e.dataTypes.includes(s.to)}return n.kind==="entity"?e.dataTypes.some(s=>{var i;return((i=this.dataTypes.get(s))==null?void 0:i.storedIn)===n.id}):!1}case"state":{const s=this.stateMachine(e.stateMachine);return s?n.kind==="behavior"?n.id===s.id:n.kind==="state"||n.kind==="transition"?n.behavior===s.id:n.kind==="entity"?s.transitions.some(i=>i.triggeredBy===n.id):n.kind==="dataType"?n.id===s.subject:!1:!1}case"extension":return n.kind==="entity"&&e.entities.includes(n.id);case"usecase":{const s=e.useCases.map(i=>this.useCases.get(i)).filter(Oo);return n.kind==="useCase"?e.useCases.includes(n.id):n.kind==="entity"?s.some(i=>i.actors.includes(n.id)||i.supporting.includes(n.id)):!1}}}viewsShowing(e){return this.doc.views.filter(n=>this.viewShows(n,e))}bestViewFor(e,n){const r=n?this.views.get(n):void 0;if(r&&this.viewShows(r,e))return r;const s=this.viewsShowing(e),i=["architecture","dependency","sequence","state","activity","dataflow","erd","usecase","map","extension"];return s.sort((o,a)=>{const l=i.indexOf(o.type)-i.indexOf(a.type);if(l!==0)return l;const c=o.type==="architecture"?o.collapsed.length:0,d=a.type==="architecture"?a.collapsed.length:0;return c-d})[0]}viewsForBehavior(e){return this.doc.views.filter(n=>n.type==="sequence"&&n.interaction===e||n.type==="activity"&&n.activity===e||n.type==="state"&&n.stateMachine===e)}exists(e){var n,r,s,i;switch(e.kind){case"entity":return this.entities.has(e.id);case"relationship":return this.relationships.has(e.id);case"dataType":{const o=this.dataTypes.get(e.id);return!!o&&(!e.field||o.fields.some(a=>a.name===e.field))}case"dataRelation":return this.dataRelations.has(e.id);case"dataFlow":return this.dataFlows.has(e.id);case"useCase":return this.useCases.has(e.id);case"behavior":return this.behaviors.has(e.id);case"message":return this.messages(e.behavior).some(o=>o.message.id===e.id);case"fragment":return!!this.findFragment(e.behavior,e.id);case"activityNode":return!!((n=this.activity(e.behavior))!=null&&n.nodes.some(o=>o.id===e.id));case"activityFlow":return!!((r=this.activity(e.behavior))!=null&&r.flows.some(o=>o.id===e.id));case"state":return!!((s=this.stateMachine(e.behavior))!=null&&s.states.some(o=>o.id===e.id));case"transition":return!!((i=this.stateMachine(e.behavior))!=null&&i.transitions.some(o=>o.id===e.id));case"group":{const o=this.views.get(e.view);return((o==null?void 0:o.type)==="architecture"?o.groups:(o==null?void 0:o.type)==="dependency"?o.layers:[]).some(l=>l.id===e.id)}}}describe(e){var n,r,s,i,o,a,l,c,d,u,h,m,g;switch(e.kind){case"entity":{const p=this.entities.get(e.id);return{title:(p==null?void 0:p.name)??e.id,kind:p?this.style(p).label:"Entity",summary:p==null?void 0:p.summary}}case"relationship":{const p=this.relationships.get(e.id);if(!p)return{title:e.id,kind:"Relationship"};const x=((n=this.entities.get(p.source))==null?void 0:n.name)??p.source,y=((r=this.entities.get(p.target))==null?void 0:r.name)??p.target;return{title:`${x} → ${y}`,kind:p.protocol?`Connection · ${p.protocol}`:"Connection",summary:p.label}}case"group":{const p=this.views.get(e.view),y=((p==null?void 0:p.type)==="architecture"?p.groups:(p==null?void 0:p.type)==="dependency"?p.layers:[]).find(v=>v.id===e.id);return{title:(y==null?void 0:y.label)??e.id,kind:"Group",summary:y==null?void 0:y.description}}case"dataType":{const p=this.dataTypes.get(e.id);if(e.field){const x=p==null?void 0:p.fields.find(y=>y.name===e.field);return{title:`${(p==null?void 0:p.name)??e.id}.${e.field}`,kind:`Field · ${(x==null?void 0:x.type)??""}`,summary:x==null?void 0:x.description}}return{title:(p==null?void 0:p.name)??e.id,kind:p?BI(p.kind):"Data",summary:p==null?void 0:p.summary}}case"dataRelation":{const p=this.dataRelations.get(e.id);return p?{title:`${(s=this.dataTypes.get(p.from))==null?void 0:s.name} ${p.label} ${(i=this.dataTypes.get(p.to))==null?void 0:i.name}`,kind:p.logical?"Logical relation":"Foreign key"}:{title:e.id,kind:"Relation"}}case"dataFlow":{const p=this.dataFlows.get(e.id);return p?{title:p.label,kind:"Data flow",summary:`${(o=this.entities.get(p.source))==null?void 0:o.name} → ${(a=this.entities.get(p.target))==null?void 0:a.name}`}:{title:e.id,kind:"Data flow"}}case"message":{const p=this.messages(e.behavior).find(y=>y.message.id===e.id);if(!p)return{title:e.id,kind:"Message"};const x=p.message;return{title:x.label,kind:`Message ${p.number}`,summary:`${(l=this.entities.get(x.from))==null?void 0:l.name} → ${(c=this.entities.get(x.to))==null?void 0:c.name}`}}case"fragment":{const p=this.findFragment(e.behavior,e.id);return{title:(p==null?void 0:p.label)??e.id,kind:p?Dd(p.kind):"Fragment",summary:p==null?void 0:p.branches.map(x=>x.guard).join(" · ")}}case"activityNode":{const p=(d=this.activity(e.behavior))==null?void 0:d.nodes.find(x=>x.id===e.id);return{title:(p==null?void 0:p.label)??e.id,kind:p?VI(p.kind):"Step",summary:p==null?void 0:p.description}}case"activityFlow":{const p=this.activity(e.behavior),x=p==null?void 0:p.flows.find(k=>k.id===e.id),y=(u=p==null?void 0:p.nodes.find(k=>k.id===(x==null?void 0:x.from)))==null?void 0:u.label,v=(h=p==null?void 0:p.nodes.find(k=>k.id===(x==null?void 0:x.to)))==null?void 0:h.label;return{title:x!=null&&x.guard?`${x.guard}: ${v}`:`${y} → ${v}`,kind:"Flow"}}case"state":{const p=(m=this.stateMachine(e.behavior))==null?void 0:m.states.find(x=>x.id===e.id);return{title:(p==null?void 0:p.name)??e.id,kind:"State",summary:p==null?void 0:p.description}}case"transition":{const p=(g=this.stateMachine(e.behavior))==null?void 0:g.transitions.find(x=>x.id===e.id);return{title:(p==null?void 0:p.event)??e.id,kind:"Transition",summary:p!=null&&p.guard?`Only when ${p.guard}`:p==null?void 0:p.description}}case"useCase":{const p=this.useCases.get(e.id);return{title:(p==null?void 0:p.name)??e.id,kind:`Use case · ${(p==null?void 0:p.area)??""}`,summary:p==null?void 0:p.summary}}case"behavior":{const p=this.behaviors.get(e.id);return{title:(p==null?void 0:p.name)??e.id,kind:p?WI(p.kind):"Behavior",summary:p==null?void 0:p.summary}}}}}const Sw=new WeakMap;function gt(t){let e=Sw.get(t);return e||(e=new FI(t),Sw.set(t,e)),e}function Hl(t,e,n){const r=t.get(e);r?r.push(n):t.set(e,[n])}function Oo(t){return t!=null}function BI(t){return{table:"Table",record:"Record",event:"Event",document:"Document"}[t]}function Dd(t){return{alt:"Alternatives",opt:"Optional",loop:"Loop",par:"In parallel"}[t]}function VI(t){return{initial:"Initial node",final:"Final node",action:"Action",decision:"Decision",merge:"Merge",fork:"Fork",join:"Join"}[t]}function WI(t){return{interaction:"Interaction",activity:"Activity","state-machine":"State machine"}[t]}function fe(t){switch(t.kind){case"group":return`group:${t.view}:${t.id}`;case"dataType":return t.field?`dataType:${t.id}#${t.field}`:`dataType:${t.id}`;case"message":case"fragment":case"activityNode":case"activityFlow":case"state":case"transition":return`${t.kind}:${t.behavior}:${t.id}`;default:return`${t.kind}:${t.id}`}}function un(t){const[e,...n]=t.split(":"),r=n.join(":");if(!r)return null;switch(e){case"entity":case"relationship":case"useCase":case"dataFlow":case"dataRelation":case"behavior":return{kind:e,id:r};case"dataType":{const[s,i]=r.split("#");return i?{kind:e,id:s,field:i}:{kind:e,id:s}}case"group":return n.length>=2?{kind:e,view:n[0],id:n.slice(1).join(":")}:null;case"message":case"fragment":case"state":case"transition":case"activityNode":case"activityFlow":return n.length>=2?{kind:e,behavior:n[0],id:n.slice(1).join(":")}:null;default:return null}}const Xs=t=>!!t&&typeof t=="object"&&!Array.isArray(t),qs=t=>Array.isArray(t)?t.filter(Xs):[],zm={module:"component",queue:"message-broker"},Cw={module:["Module","Component"],queue:["Event bus","Message broker"]},Nw={one:"exactly-one",many:"zero-or-many"};function UI(t){if(!Xs(t)||t.poneyVersion!=="0.1.0")return t;const e=JSON.parse(JSON.stringify(t));e.poneyVersion="0.2.0";const n=Xs(e.model)?e.model:void 0;for(const o of qs(n==null?void 0:n.entities))typeof o.kind=="string"&&zm[o.kind]&&(o.kind=zm[o.kind]);for(const o of qs(n==null?void 0:n.dataRelations))for(const a of["fromCardinality","toCardinality"])typeof o[a]=="string"&&Nw[o[a]]&&(o[a]=Nw[o[a]]);n&&"capabilities"in n&&(n.useCases=n.capabilities,delete n.capabilities);for(const o of qs(n==null?void 0:n.behaviors)){if(o.kind==="process"){o.kind="activity";for(const a of qs(o.nodes))a.kind=a.kind==="start"?"initial":a.kind==="end"?"final":a.kind}if(o.kind==="state-machine")for(const a of qs(o.states))a.kind==="normal"&&(a.kind="state")}const r=Xs(e.presentation)?e.presentation:void 0,s=Xs(r==null?void 0:r.kinds)?r.kinds:void 0;if(s)for(const[o,a]of Object.entries(zm)){if(!(o in s))continue;const l=s[o];Xs(l)&&l.label===Cw[o][0]&&(l.label=Cw[o][1]),s[a]=l,delete s[o]}const i=[...qs(e.views),...qs(e.walkthroughs).flatMap(o=>[o.overview,...qs(o.scenes).map(a=>a.view)]).filter(Xs)];for(const o of i)o.type==="usecase"&&"capabilities"in o&&(o.useCases=o.capabilities,delete o.capabilities),o.category==="capabilities"&&(o.category="use-cases"),o.type==="activity"&&"process"in o&&(o.activity=o.process,delete o.process);return Jy(e)}function Jy(t,e){if(typeof t=="string")return t.startsWith("capability:")?`useCase:${t.slice(11)}`:e==="tone"&&t==="poney"?"accent":t;if(Array.isArray(t))return t.map(n=>Jy(n,e));if(Xs(t)){for(const[n,r]of Object.entries(t))t[n]=Jy(r,n);return t}return t}function ZI(t,e,n=3){var i;const r=[];for(const o of e){const a=HI(t,o),l=Math.max(2,Math.floor(Math.max(t.length,o.length)/3));(a<=l||o.includes(t)||t.includes(o))&&r.push([a,o])}r.sort((o,a)=>o[0]-a[0]);const s=((i=r[0])==null?void 0:i[0])??0;return r.filter(([o])=>o<=s+1).slice(0,n).map(([,o])=>o)}function HI(t,e){const n=Array.from({length:e.length+1},(r,s)=>s);for(let r=1;r<=t.length;r++){let s=n[0];n[0]=r;for(let i=1;i<=e.length;i++){const o=n[i];n[i]=Math.min(n[i]+1,n[i-1]+1,s+(t[r-1]===e[i-1]?0:1)),s=o}}return n[e.length]}const Js=(t,e,n)=>{const r=ZI(t,e);return r.length?`Did you mean ${r.map(s=>`"${s}"`).join(" or ")}?`:`Add a ${n} with this id, or use an existing one.`};function $l(t,e={}){const n=zI.safeParse(UI(t));if(!n.success)return{ok:!1,issues:n.error.issues.flatMap(qI)};const r=[...UE(n.data),...JI(n.data,e.extensions??[])];return r.some(s=>s.severity==="error")?{ok:!1,document:n.data,issues:r}:{ok:!0,document:n.data,issues:r}}function qI(t){return t.code==="unrecognized_keys"?t.keys.map(e=>({path:[...t.path,e].join("."),message:`Unknown member "${e}"`,severity:"error",hint:`Remove "${e}": this place has no such member.`})):[{path:t.path.join("."),message:t.message,severity:"error",hint:KI(t)}]}function KI(t){const e=t;if(e.code==="invalid_union_discriminator"&&Array.isArray(e.options))return`Use one of: ${e.options.join(", ")}.`;if(e.code==="invalid_enum_value"&&Array.isArray(e.options))return`Use one of: ${e.options.join(", ")}.`;if(e.code==="invalid_type"&&e.received==="undefined")return`Add "${e.path[e.path.length-1]}".`;if(e.code==="invalid_string"&&/lowercase|ref/.test(e.message))return'Ids are lowercase letters, digits, "-", "_" and ".", e.g. "order-service".'}function UE(t){const e=[],n=t.model,r=(p,x,y)=>e.push({path:p,message:x,severity:"error",...y?{hint:y}:{}}),s=(p,x)=>{const y=new Map;return p.forEach((v,k)=>{y.has(v.id)&&r(`${x}.${k}.id`,`Duplicate id "${v.id}"`),y.set(v.id,v)}),y},i=s(n.entities,"model.entities"),o=s(n.relationships,"model.relationships"),a=s(n.dataTypes,"model.dataTypes");s(n.dataRelations,"model.dataRelations"),s(n.dataFlows,"model.dataFlows");const l=s(n.behaviors,"model.behaviors"),c=s(n.useCases,"model.useCases");s(t.views,"views");const d=(p,x)=>{p!==void 0&&!i.has(p)&&r(x,`Unknown entity "${p}"`,Js(p,i.keys(),"entity to model.entities"))},u=(p,x)=>{p!==void 0&&!a.has(p)&&r(x,`Unknown data type "${p}"`,Js(p,a.keys(),"data type to model.dataTypes"))},h=(p,x)=>{p!==void 0&&!o.has(p)&&r(x,`Unknown relationship "${p}"`,Js(p,o.keys(),"relationship to model.relationships"))};n.entities.forEach((p,x)=>{d(p.parent,`model.entities.${x}.parent`);const y=new Set([p.id]);let v=p.parent?i.get(p.parent):void 0;for(;v;){if(y.has(v.id)){r(`model.entities.${x}.parent`,`Containment cycle through "${v.id}"`);break}y.add(v.id),v=v.parent?i.get(v.parent):void 0}}),n.relationships.forEach((p,x)=>{d(p.source,`model.relationships.${x}.source`),d(p.target,`model.relationships.${x}.target`),p.data.forEach((y,v)=>u(y,`model.relationships.${x}.data.${v}`))}),n.dataTypes.forEach((p,x)=>{d(p.ownedBy,`model.dataTypes.${x}.ownedBy`),d(p.storedIn,`model.dataTypes.${x}.storedIn`);const y=new Set;p.fields.forEach((v,k)=>{const w=`model.dataTypes.${x}.fields.${k}`;if(y.has(v.name)&&r(w,`Duplicate field "${v.name}" in "${p.id}"`),y.add(v.name),v.references){const C=a.get(v.references.dataType);C?C.fields.some(E=>E.name===v.references.field)||r(`${w}.references`,`"${C.id}" has no field "${v.references.field}"`):r(`${w}.references`,`Unknown data type "${v.references.dataType}"`)}})}),n.dataRelations.forEach((p,x)=>{u(p.from,`model.dataRelations.${x}.from`),u(p.to,`model.dataRelations.${x}.to`),p.via&&([p.from,p.to].some(v=>{var k;return(k=a.get(v))==null?void 0:k.fields.some(w=>w.name===p.via)})||r(`model.dataRelations.${x}.via`,`Neither end has field "${p.via}"`))}),n.dataFlows.forEach((p,x)=>{d(p.source,`model.dataFlows.${x}.source`),d(p.target,`model.dataFlows.${x}.target`),h(p.via,`model.dataFlows.${x}.via`),p.data.forEach((y,v)=>u(y,`model.dataFlows.${x}.data.${v}`))}),n.behaviors.forEach((p,x)=>{const y=`model.behaviors.${x}`;if(p.kind==="interaction"){p.participants.forEach((C,E)=>d(C,`${y}.participants.${E}`));const v=new Set(p.participants),k=new Set,w=(C,E)=>C.forEach((_,S)=>{const j=`${E}.${S}`;k.has(_.id)&&r(`${j}.id`,`Duplicate step id "${_.id}"`),k.add(_.id),_.type==="message"?(v.has(_.from)||r(`${j}.from`,`"${_.from}" is not a participant`,`Add "${_.from}" to participants, or send from one of: ${[...v].join(", ")}.`),v.has(_.to)||r(`${j}.to`,`"${_.to}" is not a participant`,`Add "${_.to}" to participants, or send to one of: ${[...v].join(", ")}.`),h(_.relationship,`${j}.relationship`),_.data.forEach(($,I)=>u($,`${j}.data.${I}`))):_.branches.forEach(($,I)=>w($.steps,`${j}.branches.${I}.steps`))});w(p.steps,`${y}.steps`)}else if(p.kind==="activity"){const v=s(p.nodes,`${y}.nodes`);p.nodes.forEach((k,w)=>d(k.performedBy,`${y}.nodes.${w}.performedBy`)),p.nodes.filter(k=>k.kind==="initial").length!==1&&r(`${y}.nodes`,"A process needs exactly one start node"),p.flows.forEach((k,w)=>{v.has(k.from)||r(`${y}.flows.${w}.from`,`Unknown node "${k.from}"`,Js(k.from,v.keys(),"node")),v.has(k.to)||r(`${y}.flows.${w}.to`,`Unknown node "${k.to}"`,Js(k.to,v.keys(),"node"))})}else{u(p.subject,`${y}.subject`),d(p.owner,`${y}.owner`);const v=s(p.states,`${y}.states`);p.states.filter(k=>k.kind==="initial").length!==1&&r(`${y}.states`,"A state machine needs exactly one initial state"),p.transitions.forEach((k,w)=>{v.has(k.from)||r(`${y}.transitions.${w}.from`,`Unknown state "${k.from}"`,Js(k.from,v.keys(),"state")),v.has(k.to)||r(`${y}.transitions.${w}.to`,`Unknown state "${k.to}"`,Js(k.to,v.keys(),"state")),d(k.triggeredBy,`${y}.transitions.${w}.triggeredBy`)})}}),n.useCases.forEach((p,x)=>{const y=`model.useCases.${x}`;p.actors.forEach((v,k)=>d(v,`${y}.actors.${k}`)),p.supporting.forEach((v,k)=>d(v,`${y}.supporting.${k}`)),p.realizedBy.forEach((v,k)=>d(v,`${y}.realizedBy.${k}`)),p.behaviors.forEach((v,k)=>{l.has(v)||r(`${y}.behaviors.${k}`,`Unknown behavior "${v}"`)}),p.includes.forEach((v,k)=>{c.has(v)||r(`${y}.includes.${k}`,`Unknown use case "${v}"`)})});const m=(p,x,y)=>{const v=l.get(p);v?v.kind!==x&&r(y,`"${p}" is a ${v.kind}, expected ${x}`):r(y,`Unknown behavior "${p}"`)};return t.views.forEach((p,x)=>{var v;const y=`views.${x}`;switch(p.type){case"architecture":case"map":case"dependency":{p.entities.forEach((C,E)=>d(C,`${y}.entities.${E}`)),(v=p.relationships)==null||v.forEach((C,E)=>h(C,`${y}.relationships.${E}`));const k=new Set(p.entities),w=p.type==="architecture"?p.groups:p.type==="dependency"?p.layers:[];w.forEach((C,E)=>C.members.forEach((_,S)=>{k.has(_)||r(`${y}.groups.${E}.members.${S}`,`"${_}" is not in this view`)})),p.type==="map"&&(p.passThrough.forEach((C,E)=>d(C,`${y}.passThrough.${E}`)),p.collapsed.forEach((C,E)=>{k.has(C)?p.entities.some(_=>{var S;return((S=i.get(_))==null?void 0:S.parent)===C})||r(`${y}.collapsed.${E}`,`"${C}" has nothing inside it in this view`,'A group is an entity whose children (entities with "parent" set to it) are also in the map.'):r(`${y}.collapsed.${E}`,`"${C}" is not in this view`)})),p.type==="architecture"&&p.collapsed.forEach((C,E)=>{!k.has(C)&&!w.some(_=>_.id===C)&&r(`${y}.collapsed.${E}`,`"${C}" is not in this view`)});break}case"sequence":m(p.interaction,"interaction",`${y}.interaction`);break;case"activity":m(p.activity,"activity",`${y}.activity`);break;case"state":m(p.stateMachine,"state-machine",`${y}.stateMachine`);break;case"erd":p.dataTypes.forEach((k,w)=>u(k,`${y}.dataTypes.${w}`));break;case"dataflow":{const k=new Set(n.dataFlows.map(w=>w.id));p.flows.forEach((w,C)=>{k.has(w)||r(`${y}.flows.${C}`,`Unknown data flow "${w}"`)});break}case"extension":p.entities.forEach((k,w)=>d(k,`${y}.entities.${w}`));break;case"usecase":p.useCases.forEach((k,w)=>{c.has(k)||r(`${y}.useCases.${w}`,`Unknown use case "${k}"`)});break}}),GI(t,r),t.project.defaultView&&!t.views.some(p=>p.id===t.project.defaultView)&&r("project.defaultView",`Unknown view "${t.project.defaultView}"`),new Set(n.entities.map(p=>p.kind)).forEach(p=>{t.presentation.kinds[p]||e.push({path:`presentation.kinds.${p}`,message:`No style for entity kind "${p}"; readers use a default`,severity:"warning"})}),e}function JI(t,e){var d;const n=[],r=(u,h)=>n.push({path:u,message:h,severity:"error"}),s=(u,h)=>n.push({path:u,message:h,severity:"warning"}),i=new Map(t.extensions.map(u=>[u.name,u])),o=new Map(e.map(u=>[u.name,u]));t.extensions.forEach((u,h)=>{o.has(u.name)||(u.required?r(`extensions.${h}`,`This document requires the "${u.name}" extension, which this reader does not know`):s(`extensions.${h}`,`Extension "${u.name}" is not known here; its data is kept but not checked`))});const a=(u,h,m,g)=>{var y;if(m.includes(u))return;const p=bw(u);if(!p)return r(h,`Unknown kind "${u}"`);if(!i.has(p))return r(h,`Kind "${u}" uses the undeclared extension "${p}"`);const x=o.get(p);x&&!((y=x[g])!=null&&y[u.slice(p.length+1)])&&r(h,`Extension "${p}" does not define the kind "${u}"`)},l=(u,h,m)=>{var g,p;for(const[x,y]of Object.entries(u)){if(!i.has(x)){r(`${h}.ext.${x}`,`Data for the undeclared extension "${x}"`);continue}const v=(p=(g=o.get(x))==null?void 0:g.facets)==null?void 0:p[m];if(!o.has(x))continue;if(!v){r(`${h}.ext.${x}`,`Extension "${x}" defines no data for a ${m}`);continue}const k=v.safeParse(y);k.success||k.error.issues.forEach(w=>r(`${h}.ext.${x}.${w.path.join(".")}`,w.message))}};if(t.model.entities.forEach((u,h)=>{a(u.kind,`model.entities.${h}.kind`,CE.options,"entityKinds"),l(u.ext,`model.entities.${h}`,"entity")}),t.model.relationships.forEach((u,h)=>{a(u.kind,`model.relationships.${h}.kind`,NE.options,"relationshipKinds"),l(u.ext,`model.relationships.${h}`,"relationship")}),t.model.dataTypes.forEach((u,h)=>l(u.ext,`model.dataTypes.${h}`,"dataType")),t.model.useCases.forEach((u,h)=>l(u.ext,`model.useCases.${h}`,"useCase")),t.views.forEach((u,h)=>{var y;if(l(u.ext,`views.${h}`,"view"),u.type!=="extension")return;const m=bw(u.extension);if(!i.has(m))return r(`views.${h}.extension`,`View uses the undeclared extension "${m}"`);const g=o.get(m);if(!g)return;const p=(y=g.views)==null?void 0:y[u.extension.slice(m.length+1)];if(!p)return r(`views.${h}.extension`,`Extension "${m}" does not define the view "${u.extension}"`);const x=p.schema.safeParse(u.data);x.success||x.error.issues.forEach(v=>r(`views.${h}.data.${v.path.join(".")}`,v.message))}),n.some(u=>u.severity==="error"))return n;const c=gt(t);for(const u of e)i.has(u.name)&&((d=u.validate)==null||d.call(u,t,{index:c,report:r}));return n}function GI(t,e){const n=gt(t),r=new Set(t.views.map(s=>s.id));t.walkthroughs.forEach((s,i)=>{const o=`walkthroughs.${i}`,a=new Set([...s.removed.entities.map(d=>fe({kind:"entity",id:d.id})),...s.removed.relationships.map(d=>fe({kind:"relationship",id:d.id})),...s.removed.transitions.map(d=>fe({kind:"transition",behavior:d.stateMachine,id:d.transition.id}))]),l=new Set(s.removed.entities.map(d=>d.id));s.removed.entities.forEach((d,u)=>{n.entities.has(d.id)&&e(`${o}.removed.entities.${u}.id`,`"${d.id}" is removed but still in the model`)}),s.removed.relationships.forEach((d,u)=>{n.relationships.has(d.id)&&e(`${o}.removed.relationships.${u}.id`,`"${d.id}" is removed but still in the model`);for(const h of["source","target"])!n.entities.has(d[h])&&!l.has(d[h])&&e(`${o}.removed.relationships.${u}.${h}`,`Unknown entity "${d[h]}"`)}),s.removed.transitions.forEach((d,u)=>{const h=n.stateMachine(d.stateMachine);if(!h)return e(`${o}.removed.transitions.${u}.stateMachine`,`Unknown state machine "${d.stateMachine}"`);for(const m of["from","to"])h.states.some(g=>g.id===d.transition[m])||e(`${o}.removed.transitions.${u}.transition.${m}`,`Unknown state "${d.transition[m]}"`)});const c=(d,u)=>{const h=un(d);if(!h)return e(u,`"${d}" is not a ref`,'Write refs as "entity:<id>", "relationship:<id>", "state:<machine>:<id>", "transition:<machine>:<id>", "message:<interaction>:<id>" or "dataType:<id>#<field>".');!n.exists(h)&&!a.has(fe(h))&&e(u,`Nothing in the model matches "${d}"`,Js(d,YI(n,a),"element"))};if(s.kind==="change")for(const d of["before","after"])s.story[d]||e(`${o}.story.${d}`,`A change walkthrough needs "story.${d}"`,`Say in one line how it is ${d} the change, or set "kind": "tour" for a tour of code as it is.`);s.kind==="tour"&&s.marks.forEach((d,u)=>e(`${o}.marks.${u}`,"A tour has no marks",'A tour shows code as it is. Remove the marks, or set "kind": "change".')),s.overview&&!r.has(s.overview)&&e(`${o}.overview`,`Unknown view "${s.overview}"`),s.marks.forEach((d,u)=>{c(d.ref,`${o}.marks.${u}.ref`);const h=un(d.ref);h&&d.state==="removed"!==a.has(fe(h))&&e(`${o}.marks.${u}.state`,d.state==="removed"?`"${d.ref}" is marked removed but is not in "removed"`:`"${d.ref}" is in "removed" but marked ${d.state}`)}),s.scenes.forEach((d,u)=>{s.kind==="tour"&&d.code.forEach((h,m)=>h.hunks.forEach((g,p)=>g.lines.forEach((x,y)=>{x.kind!=="ctx"&&e(`${o}.scenes.${u}.code.${m}.hunks.${p}.lines.${y}.kind`,`A tour shows code as it is, but this line is "${x.kind}"`,'Show an excerpt with "start" and "text", or use "ctx" lines.')}))),d.view&&!r.has(d.view)&&e(`${o}.scenes.${u}.view`,`Unknown view "${d.view}"`),d.focus.forEach((h,m)=>c(h,`${o}.scenes.${u}.focus.${m}`)),d.callouts.forEach((h,m)=>c(h.target,`${o}.scenes.${u}.callouts.${m}.target`)),d.trace.forEach((h,m)=>c(h.ref,`${o}.scenes.${u}.trace.${m}.ref`)),d.effects.forEach((h,m)=>c(h.target,`${o}.scenes.${u}.effects.${m}.target`)),d.badges.forEach((h,m)=>c(h.target,`${o}.scenes.${u}.badges.${m}.target`))})})}function YI(t,e){const n=[...e];return t.entities.forEach((r,s)=>n.push(`entity:${s}`)),t.relationships.forEach((r,s)=>n.push(`relationship:${s}`)),t.dataTypes.forEach((r,s)=>{n.push(`dataType:${s}`),r.fields.forEach(i=>n.push(`dataType:${s}#${i.name}`))}),t.useCases.forEach((r,s)=>n.push(`useCase:${s}`)),t.behaviors.forEach((r,s)=>{n.push(`behavior:${s}`),r.kind==="interaction"&&t.messages(s).forEach(i=>n.push(`message:${s}:${i.message.id}`)),r.kind==="activity"&&r.nodes.forEach(i=>n.push(`activityNode:${s}:${i.id}`)),r.kind==="state-machine"&&(r.states.forEach(i=>n.push(`state:${s}:${i.id}`)),r.transitions.forEach(i=>n.push(`transition:${s}:${i.id}`)))}),n}function ZE(t){const e=new Map;for(const n of t.marks){const r=un(n.ref);r&&e.set(fe(r),n.state)}return e}function QI(t,e){return t.walkthroughs.filter(n=>n.overview===e||n.scenes.some(r=>r.view===e))}class vn extends Error{constructor(e,n=[]){super(e),this.issues=n}}function XI(t,e){const n=eP(t,e),r=UE(n).filter(s=>s.severity==="error");if(r.length>0)throw new vn(`"${e.type}" would break the model: ${r[0].message}`,r);return n}function eP(t,e){const n=t.model;switch(e.type){case"entity.add":{const r=Qf.parse(e.entity);return{...t,model:{...n,entities:[...n.entities,r]}}}case"entity.update":{Lm(t,e.id);const r=n.entities.map(s=>s.id===e.id?Qf.parse({...s,...e.changes,id:s.id}):s);return{...t,model:{...n,entities:r}}}case"entity.remove":{if(Lm(t,e.id),n.entities.some(d=>d.parent===e.id))throw new vn(`Move or remove the children of "${e.id}" first`);const r=tP(t,e.id);if(r)throw new vn(`"${e.id}" takes part in "${r}". Change that behavior first`);const s=n.relationships.filter(d=>d.source!==e.id&&d.target!==e.id),i=new Set(n.relationships.filter(d=>!s.includes(d)).map(d=>d.id)),o=n.dataFlows.filter(d=>d.source!==e.id&&d.target!==e.id).map(d=>d.via&&i.has(d.via)?{...d,via:void 0}:d),a=new Set(n.dataFlows.filter(d=>!o.some(u=>u.id===d.id)).map(d=>d.id)),l=n.useCases.map(d=>({...d,supporting:d.supporting.filter(u=>u!==e.id),realizedBy:d.realizedBy.filter(u=>u!==e.id)}));if(l.some(d=>d.actors.includes(e.id)))throw new vn(`"${e.id}" is an actor of a use case. Change the use case first`);const c=t.views.map(d=>d.type==="dataflow"?{...d,flows:d.flows.filter(u=>!a.has(u))}:Ew(d,e.id,i));return{...t,model:{...n,entities:n.entities.filter(d=>d.id!==e.id),relationships:s,dataFlows:o,useCases:l},views:c}}case"relationship.add":{const r=Xf.parse(e.relationship);return{...t,model:{...n,relationships:[...n.relationships,r]}}}case"relationship.update":{if(!n.relationships.some(s=>s.id===e.id))throw new vn(`Unknown relationship "${e.id}"`);const r=n.relationships.map(s=>s.id===e.id?Xf.parse({...s,...e.changes,id:s.id}):s);return{...t,model:{...n,relationships:r}}}case"relationship.remove":{if(!n.relationships.some(s=>s.id===e.id))throw new vn(`Unknown relationship "${e.id}"`);const r=new Set([e.id]);return{...t,model:{...n,relationships:n.relationships.filter(s=>s.id!==e.id)},views:t.views.map(s=>(s.type==="architecture"||s.type==="dependency"||s.type==="map")&&s.relationships?{...s,relationships:s.relationships.filter(i=>!r.has(i))}:s)}}case"view.addEntity":case"view.removeEntity":{const r=t.views.map(s=>{if(s.id!==e.viewId)return s;if(s.type!=="architecture"&&s.type!=="dependency"&&s.type!=="map")throw new vn(`Entities are added to ${s.type} views through their behavior, not directly`);return e.type==="view.addEntity"?(Lm(t,e.entityId),s.entities.includes(e.entityId)?s:{...s,entities:[...s.entities,e.entityId]}):Ew(s,e.entityId,new Set)});return{...t,views:r}}case"layout.move":{const r=t.views.map(s=>{if(s.id!==e.viewId)return s;const i={...s.positions};return e.position?i[e.elementId]=e.position:delete i[e.elementId],{...s,positions:i}});return{...t,views:r}}case"presentation.override":{const r={...t.presentation.elements};return e.changes?r[e.elementId]={...r[e.elementId],...e.changes}:delete r[e.elementId],{...t,presentation:{...t.presentation,elements:r}}}case"behavior.rename":{const r=e.value.trim();if(!r)throw new vn("A name cannot be empty");let s=!1;const i=n.behaviors.map(o=>{if(o.id!==e.behaviorId)return o;if(o.kind==="interaction"&&e.element==="message"){const a=l=>l.map(c=>c.type==="message"&&c.id===e.id?(s=!0,{...c,label:r}):c.type==="fragment"?{...c,branches:c.branches.map(d=>({...d,steps:a(d.steps)}))}:c);return{...o,steps:a(o.steps)}}return o.kind==="state-machine"&&e.element==="state"?{...o,states:o.states.map(a=>a.id===e.id?(s=!0,{...a,name:r}):a)}:o.kind==="state-machine"&&e.element==="transition"?{...o,transitions:o.transitions.map(a=>a.id===e.id?(s=!0,{...a,event:r}):a)}:o.kind==="activity"&&e.element==="activityNode"?{...o,nodes:o.nodes.map(a=>a.id===e.id?(s=!0,{...a,label:r}):a)}:o});if(!s)throw new vn(`No ${e.element} "${e.id}" in "${e.behaviorId}"`);return{...t,model:{...n,behaviors:i}}}case"walkthrough.setText":{const r=t.walkthroughs.findIndex(i=>i.id===e.walkthroughId);if(r<0)throw new vn(`Unknown walkthrough "${e.walkthroughId}"`);const s=HE(t.walkthroughs[r],e.path,e.value);return{...t,walkthroughs:t.walkthroughs.map((i,o)=>o===r?s:i)}}}}function HE(t,e,n){const[r,...s]=e;if(r===void 0||t===null||typeof t!="object")throw new vn(`No text at "${e.join(".")}"`);const i=t[r];if(s.length===0){if(i!==void 0&&typeof i!="string")throw new vn(`"${r}" is not text`);if(i===void 0&&Array.isArray(t))throw new vn(`No item ${r}`)}else if(i===null||typeof i!="object")throw new vn(`No text at "${e.join(".")}"`);const o=s.length===0?n:HE(i,s,n);return Array.isArray(t)?t.map((a,l)=>l===r?o:a):{...t,[r]:o}}function Lm(t,e){if(!t.model.entities.some(n=>n.id===e))throw new vn(`Unknown entity "${e}"`)}function tP(t,e){var n;return(n=t.model.behaviors.find(r=>r.kind==="interaction"?r.participants.includes(e):r.kind==="activity"?r.nodes.some(s=>s.performedBy===e):r.owner===e||r.transitions.some(s=>s.triggeredBy===e)))==null?void 0:n.id}function Ew(t,e,n){var s,i;const r={...t.positions};return delete r[e],t.type==="architecture"?{...t,positions:r,entities:t.entities.filter(o=>o!==e),relationships:(s=t.relationships)==null?void 0:s.filter(o=>!n.has(o)),groups:t.groups.map(o=>({...o,members:o.members.filter(a=>a!==e)})),collapsed:t.collapsed.filter(o=>o!==e)}:t.type==="dependency"?{...t,positions:r,entities:t.entities.filter(o=>o!==e),relationships:(i=t.relationships)==null?void 0:i.filter(o=>!n.has(o)),layers:t.layers.map(o=>({...o,members:o.members.filter(a=>a!==e)}))}:t.type==="extension"||t.type==="map"?{...t,positions:r,entities:t.entities.filter(o=>o!==e)}:t}const _w=t=>({past:[],present:t,future:[]});function nP(t,e){const n=XI(t.present,e);return{past:[...t.past,{doc:t.present,command:e}],present:n,future:[]}}function rP(t){const e=t.past[t.past.length-1];return e?{past:t.past.slice(0,-1),present:e.doc,future:[{doc:t.present,command:e.command},...t.future]}:t}function sP(t){const[e,...n]=t.future;return e?{past:[...t.past,{doc:t.present,command:e.command}],present:e.doc,future:n}:t}function y1(t){return`${JSON.stringify(t,null,2)}
42
+ `}function iP(t,e={}){let n;try{n=JSON.parse(t)}catch(r){return{ok:!1,issues:[{path:"",message:`Not valid JSON: ${r.message}`,severity:"error"}]}}return $l(n,e)}function oP(t){const e=t.trimStart();return e.startsWith("{")&&/"poneyVersion"\s*:/.test(e)}class dn extends Error{constructor(e,n){super(n?`Line ${n}: ${e}`:e),this.line=n}}function qE(t){var n;const e=((n=KE(t)[0])==null?void 0:n.text)??"";if(/^sequenceDiagram\b/.test(e))return"sequence";if(/^(flowchart|graph)\b/.test(e))return"flowchart";if(/^stateDiagram(-v2)?\b/.test(e))return"state";if(/^erDiagram\b/.test(e))return"er"}function aP(t,e={}){const n=qE(t);if(!n)throw new dn("Not a supported Mermaid diagram. Start with sequenceDiagram, flowchart, stateDiagram or erDiagram.");const r=KE(t).filter(a=>!/^(title|accTitle|accDescr)\b/.test(a.text)),s=e.name??lP(t),i={sequence:dP,flowchart:pP,state:mP,er:yP}[n](r.slice(1),s),o=$l(i);if(!o.ok){const a=o.issues.find(l=>l.severity==="error");throw new dn(`The diagram converted to an invalid model (${a==null?void 0:a.path}: ${a==null?void 0:a.message})`)}return{kind:n,document:o.document}}function KE(t){const e=[];let n=!1;return t.split(/\r?\n/).forEach((r,s)=>{const i=r.trim();if(s===0&&i==="---")return void(n=!0);if(n){i==="---"&&(n=!1);return}!i||i.startsWith("%%")||e.push({text:i,no:s+1})}),e}function lP(t){var e,n;return(n=(e=/^\s*title:?\s+(.+)$/m.exec(t))==null?void 0:e[1])==null?void 0:n.trim()}function JE(t){const e=t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return e&&/^[a-z0-9]/.test(e)?e:`x-${e||"item"}`}function sd(t){const e=t.trim();return e.length>=2&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))?e.slice(1,-1):e}function _p(){const t=new Set;return e=>{const n=JE(e);let r=n;for(let s=2;t.has(r);s++)r=`${n}-${s}`;return t.add(r),r}}function jp(t,e){return{poneyVersion:WE,project:{id:JE(t),name:t,description:e},model:{entities:[],relationships:[]},views:[],presentation:VE}}const cP=/^(.+?)\s*(-->>|->>|--x|-x|--\)|-\)|-->|->)\s*([+-]?)\s*(.+?)\s*:\s*(.*)$/;function dP(t,e){const n=e??"Imported sequence",r=jp(n,"Imported from a Mermaid sequence diagram."),s=_p(),i=new Map,o=r.model.entities,a=(m,g,p=!1)=>{const x=m.trim();let y=i.get(x);return y||(y=s(x),i.set(x,y),o.push({id:y,kind:p?"person":"service",name:g??x,summary:""})),y},l=[],c=[{steps:l}],d=()=>c[c.length-1];let u=0,h=0;for(const{text:m,no:g}of t){let p;if(!/^(autonumber|activate|deactivate|title|Note|note|create|destroy|links?|properties)\b/.test(m)){if(p=/^(participant|actor)\s+(.+?)(?:\s+as\s+(.+))?$/.exec(m)){a(p[2],p[3]?sd(p[3]):void 0,p[1]==="actor");continue}if(/^(box|rect)\b/.test(m)){c.push({steps:d().steps,ignore:!0});continue}if(p=/^(alt|opt|loop|par|critical|break)\b\s*(.*)$/.exec(m)){const x=p[1]==="critical"||p[1]==="break"?"opt":p[1],y=p[2]||p[1],v={type:"fragment",id:`f${++h}`,kind:x,label:{alt:"Alternatives",opt:"Optional",loop:"Loop",par:"In parallel"}[x],branches:[{guard:y,steps:[]}]};d().steps.push(v),c.push({fragment:v,steps:v.branches[0].steps});continue}if(p=/^(else|and|option)\b\s*(.*)$/.exec(m)){const x=d();if(!x.fragment)throw new dn(`"${p[1]}" outside of a block`,g);const y={guard:p[2]||"otherwise",steps:[]};x.fragment.branches.push(y),x.steps=y.steps;continue}if(m==="end"){if(c.length===1)throw new dn('"end" without a block',g);c.pop();continue}if(p=cP.exec(m)){const x=a(p[1]),y=a(p[4]),v=p[2],k=x===y?"self":v.startsWith("--")&&v.endsWith(">")?"return":v.endsWith(")")?"async":"call";d().steps.push({type:"message",id:`m${++u}`,kind:k,from:x,to:y,label:p[5]||"(message)",data:[]});continue}throw new dn(`Cannot read "${m}"`,g)}}if(c.length>1)throw new dn('A block is missing its "end"');if(o.length<2)throw new dn("A sequence needs at least two participants");if(l.length===0)throw new dn("The sequence has no messages");return r.model.behaviors=[{kind:"interaction",id:"sequence",name:n,summary:"",participants:[...i.values()],steps:l}],r.views=[{id:"sequence",type:"sequence",category:"behavior",title:n,description:"Imported from Mermaid.",interaction:"sequence"}],r.project.defaultView="sequence",r}const uP=/^([A-Za-z0-9_][\w\-.]*)\s*(\(\[[\s\S]*\]\)|\[\[[\s\S]*\]\]|\[\([\s\S]*\)\]|\(\([\s\S]*\)\)|\{\{[\s\S]*\}\}|\[\/[\s\S]*\/\]|\[\\[\s\S]*\\\]|\[[\s\S]*\]|\([\s\S]*\)|\{[\s\S]*\}|>[\s\S]*\])?\s*(?::::[\w-]+)?$/,fP=/\s*(<-->|-->|---|-\.->|-\.-|==>|===|--x|--o)\s*(?:\|([^|]*)\|)?\s*/;function hP(t,e){const n=uP.exec(t.trim());if(!n)throw new dn(`Cannot read the node "${t.trim()}"`,e);const r=n[2];if(!r)return{key:n[1],shape:"rect"};const s=[["([","])","stadium"],["((","))","circle"],["{{","}}","other"],["[[","]]","rect"],["[(",")]","other"],["[/","/]","other"],["[\\","\\]","other"],["[","]","rect"],["(",")","round"],["{","}","diamond"],[">","]","other"]];for(const[i,o,a]of s)if(r.startsWith(i)&&r.endsWith(o))return{key:n[1],label:sd(r.slice(i.length,-o.length)),shape:a};return{key:n[1],shape:"rect"}}function pP(t,e){var x;const n=e??"Imported flowchart",r=jp(n,"Imported from a Mermaid flowchart."),s=_p(),i=new Map,o=[],a=[],l=[],c=(y,v)=>{const k=hP(y,v);let w=i.get(k.key);return w?k.label&&(w.label=k.label,w.shape=k.shape):(w={id:s(k.key),label:k.label??k.key,shape:k.shape,lane:l[l.length-1]},i.set(k.key,w)),w};for(const{text:y,no:v}of t){let k;if(/^(classDef|class|style|linkStyle|click|direction|accTitle|accDescr|title)\b/.test(y))continue;if(k=/^subgraph\s+(.+)$/.exec(y)){const S=/^([\w-]+)\s*\[(.+)\]$/.exec(k[1].trim()),j=sd(S?S[2]:k[1]),$=s(`lane-${S?S[1]:j}`);a.push({id:$,name:j}),l.push($);continue}if(y==="end"){l.pop();continue}const C=y.replace(/;$/,"").replace(/--\s+([^-|>][^>]*?)\s+-->/g,"-->|$1|").replace(/-\.\s+([^.]+?)\s+\.->/g,"-.->|$1|").replace(/==\s+([^=]+?)\s+==>/g,"==>|$1|").split(fP),E=S=>S.split(/\s*&\s*/);let _=E(C[0]).map(S=>c(S,v));for(let S=1;S+2<C.length+1&&C[S+2]!==void 0;S+=3){const j=(x=C[S+1])==null?void 0:x.trim(),$=E(C[S+2]).map(I=>c(I,v));for(const I of _)for(const L of $)o.push({from:I.id,to:L.id,guard:j?sd(j):void 0});_=$}}if(i.size===0)throw new dn("The flowchart has no nodes");const d=new Set(o.map(y=>y.to)),u=new Set(o.map(y=>y.from)),h=[...i.values()],m=y=>y.shape==="diamond"?"decision":(y.shape==="circle"||y.shape==="stadium")&&!d.has(y.id)?"initial":(y.shape==="circle"||y.shape==="stadium")&&!u.has(y.id)?"final":"action",g=h.map(y=>({id:y.id,kind:m(y),label:y.label,performedBy:y.lane})),p=g.filter(y=>y.kind==="initial");if(p.length!==1){p.forEach(k=>k.kind="action");const y=g.filter(k=>!d.has(k.id)),v={id:s("start"),kind:"initial",label:"Start",performedBy:(y[0]??g[0]).performedBy};g.unshift(v);for(const k of y.length?y:[g[1]])o.push({from:v.id,to:k.id})}return r.model.entities=a.map(y=>({id:y.id,kind:"component",name:y.name,summary:""})),r.model.behaviors=[{kind:"activity",id:"flow",name:n,summary:"",nodes:g,flows:o.map((y,v)=>({id:`e${v+1}`,...y}))}],r.views=[{id:"flow",type:"activity",category:"behavior",title:n,description:"Imported from Mermaid.",activity:"flow",swimlanes:a.length>0}],r.project.defaultView="flow",r}function mP(t,e){var g;const n=e??"Imported lifecycle",r=jp(n,"Imported from a Mermaid state diagram."),s=_p(),i=new Map,o=[],a="[*]:initial",l="[*]:final",c=p=>{let x=i.get(p);return x||(x={id:s(p===a?"start":p===l?"end":p),name:p===a?"Start":p===l?"End":p},i.set(p,x)),x};for(const{text:p,no:x}of t){let y;if(!(/^(note|direction|classDef|class|style)\b/i.test(p)||p==="}"||p==="--")){if(y=/^state\s+"([^"]+)"\s+as\s+([\w-]+)/.exec(p)){c(y[2]).name=y[1];continue}if(y=/^state\s+([\w-]+)/.exec(p)){c(y[1]);continue}if(y=/^(\[\*\]|[\w-]+)\s*-->\s*(\[\*\]|[\w-]+)\s*(?::\s*(.*))?$/.exec(p)){const v=y[1]==="[*]"?a:y[1],k=y[2]==="[*]"?l:y[2];c(v),c(k),o.push({from:v,to:k,label:(g=y[3])==null?void 0:g.trim()});continue}if(y=/^([\w-]+)\s*:\s*(.+)$/.exec(p)){c(y[1]).description=y[2];continue}throw new dn(`Cannot read "${p}"`,x)}}if(o.length===0)throw new dn("The state diagram has no transitions");if(!i.has(a)){const p=o[0].from;c(a),o.unshift({from:a,to:p})}const d=new Set,u=o.filter(p=>p.to===l);for(const p of u)o.some(x=>x.from===p.from&&x.to!==l)||d.add(p.from);const h=o.filter(p=>!(p.to===l&&d.has(p.from)));h.some(p=>p.to===l)||i.delete(l);const m=p=>{if(!p)return{event:"Next"};const x=/^(.*?)\s*(?:\[(.*?)\])?\s*(?:\/\s*(.*))?$/.exec(p);return{event:x[1]||p,guard:x[2]||void 0,actions:x[3]?x[3].split(/\s*[;,]\s*/).filter(Boolean):[]}};return r.model.behaviors=[{kind:"state-machine",id:"lifecycle",name:n,summary:"",states:[...i.entries()].map(([p,x])=>({id:x.id,kind:p===a?"initial":p===l||d.has(p)?"final":"state",name:x.name,description:x.description})),transitions:h.map((p,x)=>({id:`t${x+1}`,from:i.get(p.from).id,to:i.get(p.to).id,...m(p.label)}))}],r.views=[{id:"lifecycle",type:"state",category:"behavior",title:n,description:"Imported from Mermaid.",stateMachine:"lifecycle"}],r.project.defaultView="lifecycle",r}const jw="(\\|\\||\\|o|o\\||\\}\\||\\|\\{|\\}o|o\\{)",gP=new RegExp(`^([\\w-]+)\\s*${jw}(--|\\.\\.)${jw}\\s*([\\w-]+)\\s*:\\s*(.+)$`);function $w(t){return t==="||"?"exactly-one":t==="|o"||t==="o|"?"zero-or-one":t==="}|"||t==="|{"?"one-or-many":"zero-or-many"}function yP(t,e){const n=e??"Imported data model",r=jp(n,"Imported from a Mermaid ER diagram."),s=_p(),i=new Map,o=[];let a=null;function l(c){let d=i.get(c);return d||(d={id:s(c),name:c,fields:[]},i.set(c,d)),d}for(const{text:c,no:d}of t){let u;if(a){if(c==="}"){a=null;continue}const h=/^([\w<>[\](),.-]+)\s+([\w-]+)(?:\s+((?:PK|FK|UK)(?:\s*,\s*(?:PK|FK|UK))*))?(?:\s+"([^"]*)")?$/.exec(c);if(!h)throw new dn(`Cannot read the attribute "${c}"`,d);const m=(h[3]??"").split(/\s*,\s*/);a.fields.push({name:h[2],type:h[1],primaryKey:m.includes("PK")||void 0,unique:m.includes("UK")||void 0,description:[m.includes("FK")?"Foreign key.":"",h[4]??""].filter(Boolean).join(" ")||void 0});continue}if(u=/^([\w-]+)(?:\["?([^"\]]+)"?\])?\s*\{$/.exec(c)){a=l(u[1]),u[2]&&(a.name=u[2]);continue}if(u=gP.exec(c)){const h=l(u[1]),m=l(u[5]);o.push({id:s(`rel-${u[1]}-${u[5]}`),from:h.id,to:m.id,fromCardinality:$w(u[2]),toCardinality:$w(u[4]),label:sd(u[6]),logical:u[3]===".."});continue}if(u=/^([\w-]+)$/.exec(c)){l(u[1]);continue}throw new dn(`Cannot read "${c}"`,d)}if(i.size===0)throw new dn("The ER diagram has no entities");return r.model.dataTypes=[...i.values()].map(c=>({id:c.id,kind:"table",name:c.name,summary:"",fields:c.fields})),r.model.dataRelations=o,r.views=[{id:"data-model",type:"erd",category:"data",title:n,description:"Imported from Mermaid.",dataTypes:[...i.values()].map(c=>c.id)}],r.project.defaultView="data-model",r}const yu=t=>`g:${t}`;function xP(t,e,n={}){const r=gt(t),s=new Set(e.entities.filter(k=>r.entities.has(k))),i=new Set(n.collapsed??e.collapsed),o=k=>{var w;return(w=r.ancestors(k).find(C=>s.has(C.id)))==null?void 0:w.id},a=new Map;for(const k of e.groups)for(const w of k.members)s.has(w)&&a.set(w,k.id);const l=new Map;for(const k of e.groups){const w=k.members.find(C=>s.has(C));w&&l.set(k.id,o(w))}const c=new Map;for(const k of s){const w=a.get(k);c.set(k,w?yu(w):o(k))}for(const[k,w]of l)c.set(yu(k),w);const d=new Map;for(const[k,w]of c){const C=d.get(w)??[];C.push(k),d.set(w,C)}const u=new Map;e.entities.forEach((k,w)=>u.set(k,w)),e.groups.forEach(k=>u.set(yu(k.id),Math.min(...k.members.map(w=>u.get(w)??1/0))));for(const k of d.values())k.sort((w,C)=>(u.get(w)??0)-(u.get(C)??0));const h=k=>(d.get(k)??[]).reduce((C,E)=>C+(E.startsWith("g:")?0:1)+h(E),0),m=k=>{const w=k.startsWith("g:"),C=w?k.slice(2):k,E=d.get(k)??[],_=E.length>0&&i.has(C);return{id:k,type:w?"group":"entity",entityId:w?void 0:k,groupId:w?C:void 0,parent:c.get(k),children:_?[]:E.map(m),collapsed:_,hiddenCount:_?h(k):0}},g=(d.get(void 0)??[]).map(m),p={};for(const k of s){let w=k,C=c.get(k);for(;C;){const E=C.startsWith("g:")?C.slice(2):C;i.has(E)&&(w=C),C=c.get(C)}p[k]=w}for(const k of e.groups){const w=yu(k.id);let C=w,E=c.get(w);for(;E;)i.has(E.startsWith("g:")?E.slice(2):E)&&(C=E),E=c.get(E);p[w]=C}const x=e.relationships??t.model.relationships.filter(k=>s.has(k.source)&&s.has(k.target)).map(k=>k.id),y=new Map;for(const k of x){const w=r.relationships.get(k);if(!w||!s.has(w.source)||!s.has(w.target))continue;const C=p[w.source],E=p[w.target];if(C===E)continue;const _=`${C}->${E}`,S=C!==w.source||E!==w.target,j=y.get(_);j?(j.relationships.push(w.id),j.lifted||(j.lifted=S)):y.set(_,{id:w.id,source:C,target:E,relationships:[w.id],lifted:S})}const v=[...y.values()].map(k=>k.relationships.length>1?{...k,id:`lifted:${k.source}->${k.target}`}:k);return{roots:g,edges:v,representative:p,direction:e.layout.direction}}function vP(t){return t==="person"||t==="external"?"terminator":t==="database"||t==="cache"||t==="message-broker"?"store":"process"}function kP(t,e,n={}){const r=gt(t),s=e.flows.map(g=>r.dataFlows.get(g)).filter(Oo),i=[];for(const g of s)for(const p of[g.source,g.target])i.includes(p)||i.push(p);const o=new Set(i),a=new Set(s.map(g=>g.via).filter(Oo)),c=n.controlFlow??e.showControlFlow?t.model.relationships.filter(g=>o.has(g.source)&&o.has(g.target)&&!a.has(g.id)&&g.kind!=="depends-on"&&g.kind!=="implements").map(g=>({id:g.id,source:g.source,target:g.target})):[],d=g=>{var p;return vP(((p=r.entities.get(g))==null?void 0:p.kind)??"service")},u=new Set(s.map(g=>g.source)),h=new Set(i.filter(g=>{if(d(g)!=="terminator"||!u.has(g))return!1;const p=s.filter(x=>x.target===g);return p.length>0&&p.every(x=>d(x.source)==="terminator")})),m=i.map(g=>({id:g,entityId:g,role:d(g)}));for(const g of h)m.push({id:`${g}~in`,entityId:g,role:"terminator"});return{nodes:m,flows:s.map(g=>({id:g.id,source:g.source,target:h.has(g.target)?`${g.target}~in`:g.target,label:g.label,data:g.data})),control:c}}function wP(t,e,n={}){const r=gt(t),s=new Set(e.dataTypes),i=new Set(n.expanded??[]),o=t.model.dataRelations.filter(c=>s.has(c.from)&&s.has(c.to)),a=e.dataTypes.map(c=>r.dataTypes.get(c)).filter(Oo).map(c=>{const d=x=>x.primaryKey||!!x.references||o.some(y=>y.via===x.name&&(y.from===c.id||y.to===c.id)),u=c.fields.filter(d),h=c.fields.filter(x=>!d(x)),g=i.has(c.id)||c.fields.length<=e.fieldLimit+1?c.fields:[...u,...h.slice(0,Math.max(0,e.fieldLimit-u.length))],p=c.fields.filter(x=>g.includes(x));return{dataTypeId:c.id,name:c.name,store:e.groupByStore?c.storedIn:void 0,fields:p,hiddenCount:c.fields.length-p.length,expanded:i.has(c.id)}}),l=[...new Set(a.map(c=>c.store).filter(Oo))];return{tables:a,relations:o,stores:l}}const bP=new RegExp("`([^`\\n]+)`|\\[([^\\]\\n]+)\\]\\(([^)\\s]+)\\)|\\*\\*(.+?)\\*\\*|(?<![\\w*])\\*(?!\\s)(.+?)(?<!\\s)\\*(?![\\w*])|(?<![\\w_])_(?!\\s)(.+?)(?<!\\s)_(?![\\w_])","gs");function Ba(t,e=[],n){const r=[];let s=0;for(const i of t.matchAll(bP))i.index>s&&r.push({text:t.slice(s,i.index),marks:e,...n?{href:n}:{}}),i[1]!==void 0?r.push({text:i[1],marks:[...e,"code"],...n?{href:n}:{}}):i[2]!==void 0?r.push(...Ba(i[2],e,i[3])):i[4]!==void 0?r.push(...Ba(i[4],Mw(e,"bold"),n)):r.push(...Ba(i[5]??i[6],Mw(e,"italic"),n)),s=i.index+i[0].length;return s<t.length&&r.push({text:t.slice(s),marks:e,...n?{href:n}:{}}),GE(r)}const x1=t=>t.split(/\n{2,}/).map(e=>e.trim()).filter(Boolean),Ar=t=>x1(t).map(e=>Ba(e).map(n=>n.text).join("")).join(`
43
+
44
+ `);function SP(t){const e=[];for(const n of GE(t)){const r=e[e.length-1];r&&r[0].href===n.href?r.push(n):e.push([n])}return e.map(n=>{const r=n.map(CP).join("");return n[0].href?`[${r}](${n[0].href})`:r}).join("")}function CP(t){if(!t.text)return"";const[,e,n,r]=/^(\s*)(.*?)(\s*)$/s.exec(t.text);if(!n)return t.text;let s=n;return t.marks.includes("code")&&(s=`\`${s}\``),t.marks.includes("italic")&&(s=`*${s}*`),t.marks.includes("bold")&&(s=`**${s}**`),`${e}${s}${r}`}const Mw=(t,e)=>t.includes(e)?t:[...t,e],NP=(t,e)=>t.href===e.href&&t.marks.length===e.marks.length&&t.marks.every(n=>e.marks.includes(n));function GE(t){const e=[];for(const n of t){if(!n.text)continue;const r=e[e.length-1];r&&NP(r,n)?r.text+=n.text:e.push({...n,marks:[...n.marks]})}return e}const Tw={card:{w:248,h:104},cylinder:{w:240,h:112},stack:{w:240,h:104},person:{w:176,h:120},frame:{w:330,h:150},chip:{w:220,h:64},group:{w:248,h:104}},Ow={container:56,group:38};async function EP(t,e,n={}){var y;const r=gt(t),s=xP(t,e,n),i=v=>{var j;const k=v.children.length>0,w=v.type==="group"?"group":r.style(v.entityId,e.id).shape,C=v.collapsed&&v.type==="entity"?Tw.frame:Tw[w],E=e.positions[v.id],_={id:v.id};if(k){const $=v.type==="group"?Ow.group:Ow.container;_.layoutOptions={"elk.padding":`[top=${$},left=24,bottom=24,right=24]`,"elk.spacing.nodeNode":"28"},_.children=v.children.map(i)}else _.width=C.w,_.height=C.h;const S=v.entityId?(j=r.entities.get(v.entityId))==null?void 0:j.kind:void 0;return!k&&(S==="person"||S==="external")&&(_.layoutOptions={"elk.layered.layering.layerConstraint":S==="person"?"FIRST":"LAST"}),E&&(_.x=E.x,_.y=E.y),_},o=v=>{var k;return(k=r.entities.get(v))==null?void 0:k.kind},a=new Set(s.edges.filter(v=>o(v.source)==="external"&&o(v.target)!=="external").map(v=>v.id)),l={id:"root",layoutOptions:{...Rd,"elk.direction":s.direction==="down"?"DOWN":"RIGHT","elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.spacing.nodeNode":"36","elk.layered.spacing.nodeNodeBetweenLayers":"84","elk.spacing.edgeNode":"22","elk.spacing.edgeEdge":"14","elk.layered.spacing.edgeNodeBetweenLayers":"26","elk.layered.spacing.edgeEdgeBetweenLayers":"14","elk.padding":"[top=24,left=24,bottom=24,right=24]"},children:s.roots.map(i),edges:s.edges.map(v=>a.has(v.id)?{id:v.id,sources:[v.target],targets:[v.source]}:{id:v.id,sources:[v.source],targets:[v.target]})},c=await Id(l),d=new Map,u=new Map,h=(v,k)=>{d.set(v.id,v),u.set(v.id,k),v.children.forEach(w=>h(w,k+1))};s.roots.forEach(v=>h(v,0));const m=[...c.nodes.values()].map(v=>{const k=d.get(v.id);return{id:v.id,type:k.type,entityId:k.entityId,groupId:k.groupId,parent:k.parent,compound:k.children.length>0,collapsed:k.collapsed,expandable:k.collapsed||k.children.length>0,hiddenCount:k.hiddenCount,depth:u.get(v.id)??0,x:v.x,y:v.y,w:v.w,h:v.h}}).sort((v,k)=>v.depth-k.depth),g=s.edges.map(v=>{var w;const k=((w=c.edges.get(v.id))==null?void 0:w.points)??[];return{...v,points:a.has(v.id)?k.slice().reverse():k}}).filter(v=>v.points.length>=2),p=new Map(m.map(v=>[v.id,v])),x={};for(const v of m)v.entityId&&(x[fe({kind:"entity",id:v.entityId})]=v),v.groupId&&(x[fe({kind:"group",view:e.id,id:v.groupId})]=v);for(const[v,k]of Object.entries(s.representative)){const w=p.get(k);w&&!v.startsWith("g:")&&(x[y=fe({kind:"entity",id:v})]??(x[y]=w))}for(const v of g){const k=Ri(v.points.map(w=>({x:w.x,y:w.y,w:1,h:1})));for(const w of v.relationships)x[fe({kind:"relationship",id:w})]=k}return{width:c.width,height:c.height,nodes:m,edges:g,anchors:x}}const Lt={headerH:64,headerGap:30,row:44,selfRow:58,fragmentHeader:34,branchHeader:30,fragmentEnd:14,activationW:10,margin:32,labelSize:12.5};function YE(t,e){const n=[];for(const r of t){if(r.type==="message"){e.has(r.id)&&n.push(r);continue}const s=r.branches.map(i=>({...i,steps:YE(i.steps,e)})).filter(i=>i.steps.length>0);s.length&&n.push({...r,branches:s})}return n}function _P(t,e,n={}){var O;const r=gt(t),s=r.interaction(e.interaction);if(!s)throw new Error(`Unknown interaction "${e.interaction}"`);const i=new Map(r.messages(s.id).map(P=>[P.message.id,P.number])),o=(O=n.only)!=null&&O.length?new Set(n.only):void 0,a=o?YE(s.steps,o):s.steps,l=new Set,c=P=>P.forEach(W=>W.type==="message"?(l.add(W.from),l.add(W.to)):W.branches.forEach(G=>c(G.steps)));c(a);const d={...s,steps:a,participants:o?s.participants.filter(P=>l.has(P)):s.participants},u=[],h=P=>P.forEach(W=>W.type==="message"?u.push({message:W}):W.branches.forEach(G=>h(G.steps)));h(a);const m=d.participants,g=new Map(m.map((P,W)=>[P,W])),p=!!n.compact,x=m.map(P=>{var W;return Math.max(p?128:156,Re(((W=r.entities.get(P))==null?void 0:W.name)??P,14.5,650)+(p?60:70))}),y=m.map((P,W)=>W===0?0:x[W-1]/2+x[W]/2+(p?28:36)),v=P=>(Re(P.label,Lt.labelSize,500)+44+(p?60:0))*(p?.62:1);for(const{message:P}of u){const W=g.get(P.from),G=g.get(P.to);if(W===G){W+1<m.length&&(y[W+1]=Math.max(y[W+1],v(P)+(p?40:56)));continue}const[se,Ae]=W<G?[W,G]:[G,W],Ve=y.slice(se+1,Ae+1).reduce((kt,rn)=>kt+rn,0),Ye=v(P)+24;if(Ve<Ye)for(let kt=se+1;kt<=Ae;kt++)y[kt]+=(Ye-Ve)/(Ae-se)}const k=[];m.forEach((P,W)=>k.push(W===0?Lt.margin+40+x[0]/2:k[W-1]+y[W]));const w=P=>k[g.get(P)],C=[],E=[],_=[],S=new Map(m.map(P=>[P,[]])),j=P=>S.get(P).length,$=(P,W)=>w(P)-Lt.activationW/2+Math.max(0,W-1)*4,I=(P,W)=>{const G=j(P);if(G===0)return w(P);const se=$(P,G);return W?se+Lt.activationW:se},L=(P,W)=>S.get(P).push(W),D=(P,W)=>{const G=S.get(P),se=G.pop();se!==void 0&&_.push({entityId:P,x:$(P,G.length+1),y1:se,y2:Math.max(W,se+12)})},B=()=>new Map([...S].map(([P,W])=>[P,W.length])),H=(P,W)=>{for(const G of m){for(;j(G)>0;)D(G,W);for(let se=0;se<(P.get(G)??0);se++)L(G,W)}};let T=Lt.headerH+Lt.headerGap,M=k[k.length-1]+x[x.length-1]/2;const A=(P,W=new Set)=>{for(const G of P)G.type==="message"?(W.add(G.from),W.add(G.to)):G.branches.forEach(se=>A(se.steps,W));return W},V=P=>Math.max(0,...P.map(W=>W.type==="fragment"?1+Math.max(...W.branches.map(G=>V(G.steps))):0)),J=(P,W,G)=>{for(const se of P){if(se.type==="message"){const de=se;if(de.kind==="self"){const Gt=I(de.from,!0);L(de.from,T+6);const vr=34;C.push({id:de.id,number:i.get(de.id),kind:de.kind,from:de.from,to:de.to,label:de.label,y:T,x1:Gt,x2:Gt,loop:{x:Gt,y1:T-2,y2:T+20,w:vr},fragments:W}),M=Math.max(M,Gt+vr+Re(de.label,Lt.labelSize,500)+48),D(de.from,T+28),T+=Lt.selfRow;continue}const lt=w(de.to)>w(de.from);if(de.kind==="call"){j(de.from)===0&&!p&&L(de.from,T-10);const Gt=I(de.from,lt);L(de.to,T);const vr=I(de.to,!lt);C.push({id:de.id,number:i.get(de.id),kind:de.kind,from:de.from,to:de.to,label:de.label,y:T,x1:Gt,x2:vr,fragments:W})}else if(de.kind==="return"){const Gt=I(de.from,lt);D(de.from,T);const vr=I(de.to,!lt);C.push({id:de.id,number:i.get(de.id),kind:de.kind,from:de.from,to:de.to,label:de.label,y:T,x1:Gt,x2:vr,fragments:W})}else{const Gt=I(de.from,lt),vr=I(de.to,!lt);C.push({id:de.id,number:i.get(de.id),kind:de.kind,from:de.from,to:de.to,label:de.label,y:T,x1:Gt,x2:vr,fragments:W})}T+=Lt.row;continue}const Ae=se,Ve=T-18,Ye=[...A([Ae])].map(de=>g.get(de)).sort((de,lt)=>de-lt),kt=30+(V([Ae])-1)*12,rn=k[Ye[0]]-kt;let Kt=k[Ye[Ye.length-1]]+kt;T=Ve+Lt.fragmentHeader+18;const zt=[],tt=B(),Vn=C.length;Ae.branches.forEach((de,lt)=>{if(lt>0){const Gt=T-18;zt.push({guard:de.guard,y:Gt}),H(tt,Gt),T=Gt+Lt.branchHeader+18}else zt.push({guard:de.guard,y:Ve});J(de.steps,[...W,Ae.id],G+1)});for(const de of C.slice(Vn))de.loop&&(Kt=Math.max(Kt,de.loop.x+de.loop.w+Re(de.label,Lt.labelSize,500)+48));const Jt=T-18+Lt.fragmentEnd;E.push({id:Ae.id,kind:Ae.kind,label:Ae.label,depth:G,branches:zt,x:rn,y:Ve,w:Kt-rn,h:Jt-Ve}),M=Math.max(M,Kt),T=Jt+26}};J(d.steps,[],0);const X=T+4;for(const P of m)for(;j(P)>0;)D(P,X-18);const z=m.map((P,W)=>({entityId:P,x:k[W],header:{x:k[W]-x[W]/2,y:0,w:x[W],h:Lt.headerH},lifeline:{y1:Lt.headerH,y2:X}})),U=-Math.min(0,...E.map(P=>P.x-Lt.margin));U&&(z.forEach(P=>{P.x+=U,P.header.x+=U}),C.forEach(P=>{P.x1+=U,P.x2+=U,P.loop&&(P.loop.x+=U)}),_.forEach(P=>P.x+=U),E.forEach(P=>P.x+=U),M+=U);const K={};K[fe({kind:"behavior",id:d.id})]={x:0,y:0,w:M+Lt.margin,h:X};for(const P of z)K[fe({kind:"entity",id:P.entityId})]=P.header;for(const P of C){const W=Math.min(P.x1,P.x2),G=Math.max(Math.abs(P.x2-P.x1),P.loop?P.loop.w+120:0);K[fe({kind:"message",behavior:d.id,id:P.id})]={x:W,y:P.y-22,w:G,h:32}}for(const P of E)K[fe({kind:"fragment",behavior:d.id,id:P.id})]=P;return{interactionId:d.id,width:M+Lt.margin,height:X+24,participants:z,messages:C,activations:_,fragments:E,anchors:K}}const Aw={terminator:{w:184,h:64},process:{w:196,h:64},store:{w:204,h:52}};async function jP(t,e,n={}){var d,u;const r=gt(t),s=kP(t,e,n),i=h=>{var y;if(((y=s.nodes.find(v=>v.id===h))==null?void 0:y.role)!=="terminator")return{};const g=s.flows.some(v=>v.target===h),p=s.flows.some(v=>v.source===h),x=g?p?void 0:"LAST":"FIRST";return x?{layoutOptions:{"elk.layered.layering.layerConstraint":x}}:{}},o=await Id({id:"root",layoutOptions:{...Rd,"elk.direction":"DOWN","elk.spacing.nodeNode":"48","elk.layered.spacing.nodeNodeBetweenLayers":"48","elk.spacing.edgeNode":"24","elk.spacing.edgeEdge":"16","elk.spacing.edgeLabel":"6","elk.edgeLabels.placement":"CENTER","elk.padding":"[top=32,left=32,bottom=32,right=32]"},children:s.nodes.map(h=>({id:h.id,width:Aw[h.role].w,height:Aw[h.role].h,...e.positions[h.id],...i(h.id)})),edges:[...s.flows.map(h=>({id:h.id,sources:[h.source],targets:[h.target],labels:[{text:h.label,width:Re(h.label,11.5,500)+26,height:22}]})),...s.control.map(h=>({id:h.id,sources:[h.source],targets:[h.target],layoutOptions:{"elk.layered.priority.direction":"0"}}))]}),a=s.nodes.map(h=>({...o.nodes.get(h.id),id:h.id,entityId:h.entityId,role:h.role})),l=[...s.control.map(h=>{var m;return{id:h.id,control:!0,source:h.source,target:h.target,points:((m=o.edges.get(h.id))==null?void 0:m.points)??[],data:[]}}),...s.flows.map(h=>{const m=o.edges.get(h.id);return{id:h.id,control:!1,source:h.source,target:h.target.replace(/~in$/,""),points:(m==null?void 0:m.points)??[],label:m==null?void 0:m.labels[0],data:h.data}})].filter(h=>h.points.length>=2),c={};for(const h of a)c[d=fe({kind:"entity",id:h.entityId})]??(c[d]=h);for(const h of l){const m=Ri([...h.points.map(p=>({x:p.x,y:p.y,w:1,h:1})),...h.label?[h.label]:[]]);c[fe(h.control?{kind:"relationship",id:h.id}:{kind:"dataFlow",id:h.id})]=m;const g=r.dataFlows.get(h.id);g!=null&&g.via&&(c[u=fe({kind:"relationship",id:g.via})]??(c[u]=m))}return{width:o.width,height:o.height,nodes:a,edges:l,anchors:c}}const $P=92,Gy=52,MP=Gy+40,xu=212;function TP(t,e){var H;const n=gt(t),r=n.activity(e.activity);if(!r)throw new Error(`Unknown activity "${e.activity}"`);const s=r.nodes,i=new Map,o=new Map;for(const T of r.flows)i.set(T.from,[...i.get(T.from)??[],T.to]),o.set(T.to,[...o.get(T.to)??[],T.from]);const a=s.find(T=>T.kind==="initial")??s[0],l=new Set,c=new Map,d=T=>{c.set(T,"open");for(const M of r.flows.filter(A=>A.from===T)){const A=c.get(M.to);A==="open"?l.add(M.id):A||d(M.to)}c.set(T,"done")};d(a.id),s.forEach(T=>!c.has(T.id)&&d(T.id));const u=r.flows.filter(T=>!l.has(T.id)),h=new Map(s.map(T=>[T.id,0])),m=new Map(s.map(T=>[T.id,0]));u.forEach(T=>m.set(T.to,(m.get(T.to)??0)+1));const g=s.filter(T=>(m.get(T.id)??0)===0).map(T=>T.id);for(;g.length;){const T=g.shift();for(const M of u.filter(A=>A.from===T))h.set(M.to,Math.max(h.get(M.to),h.get(T)+1)),m.set(M.to,m.get(M.to)-1),m.get(M.to)===0&&g.push(M.to)}const p=[];if(e.swimlanes)for(const T of s)p.includes(T.performedBy)||p.push(T.performedBy);p.length===0&&p.push(void 0);const x=T=>e.swimlanes?p.indexOf(T.performedBy):0,y=new Map;for(const T of s){const M=`${x(T)}:${h.get(T.id)}`;y.set(M,[...y.get(M)??[],T.id])}const v=p.map((T,M)=>Math.max(240,...[...y.entries()].filter(([A])=>A.startsWith(`${M}:`)).map(([,A])=>A.length*xu+28))),k=[];let w=0;p.forEach((T,M)=>{var A;k.push({entityId:T,label:T?((A=n.entities.get(T))==null?void 0:A.name)??T:e.swimlanes?"Unassigned":r.name,x:w,w:v[M]}),w+=v[M]});const C=new Map;for(const T of s){const M=x(T),A=h.get(T.id),V=y.get(`${M}:${A}`),J=V.indexOf(T.id),X=k[M].x+k[M].w/2+(J-(V.length-1)/2)*xu,z=MP+A*$P;let F=0,U=0,K=[T.label];switch(T.kind){case"initial":F=U=22;break;case"final":F=U=26;break;case"fork":case"join":F=120,U=6;break;case"decision":case"merge":F=Math.max(96,Re(T.label,12.5,600)+60),U=54;break;default:K=Ff(T.label,156,13,500,2),F=Math.min(188,Math.max(124,Math.max(...K.map(O=>Re(O,13,500)))+32)),U=K.length>1?58:42}C.set(T.id,{id:T.id,kind:T.kind,label:T.label,lines:K,outcome:T.outcome,lane:M,rank:A,x:X-F/2,y:z-U/2,w:F,h:U})}for(const T of C.values()){if(T.kind!=="fork"&&T.kind!=="join")continue;const M=((H=T.kind==="fork"?i.get(T.id):o.get(T.id))==null?void 0:H.map(X=>C.get(X)))??[];if(M.length<2)continue;const A=M.map(X=>X.x+X.w/2),V=Math.min(...A,T.x+T.w/2)-28,J=Math.max(...A,T.x+T.w/2)+28;T.x=V,T.w=J-V}const E=T=>T.x+T.w/2,_=T=>T.y+T.h/2,S=new Map;for(const T of C.values()){if(T.kind!=="decision")continue;const A=r.flows.filter(X=>X.from===T.id&&!l.has(X.id)).slice().sort((X,z)=>E(C.get(X.to))-E(C.get(z.to))),V=new Set(["left","bottom","right"]),J=X=>{const z=E(C.get(X.to))-E(T);return Math.abs(z)<2?"bottom":z<0?"left":"right"};for(const X of A){const z=J(X),U=(z==="left"?["left","bottom","right"]:z==="right"?["right","bottom","left"]:["bottom","left","right"]).find(K=>V.has(K))??"bottom";V.delete(U),S.set(X.id,U)}for(const X of r.flows.filter(z=>z.from===T.id&&l.has(z.id)))S.set(X.id,V.has("right")?"right":"bottom")}const j=[];let $=0;for(const T of r.flows){const M=C.get(T.from),A=C.get(T.to);if(l.has(T.id)){const U=Math.min(A.rank,M.rank),K=Math.max(A.rank,M.rank),O=Math.min(M.x,A.x),P=Math.max(M.x+M.w,A.x+A.w),W=[...C.values()].filter(Ye=>Ye.rank>=U&&Ye.rank<=K&&Ye.x+Ye.w>=O-xu/2&&Ye.x<=P+xu/2),G=Math.max(...W.map(Ye=>Ye.x+Ye.w))+28+$++*14,se=M.y+M.h+16+($-1)*6,Ae=S.get(T.id)==="right"?{x:M.x+M.w,y:_(M)}:{x:E(M),y:M.y+M.h},Ve=S.get(T.id)==="right"?[Ae,{x:G,y:Ae.y},{x:G,y:_(A)},{x:A.x+A.w,y:_(A)}]:[Ae,{x:Ae.x,y:se},{x:G,y:se},{x:G,y:_(A)},{x:A.x+A.w,y:_(A)}];j.push({id:T.id,from:T.from,to:T.to,points:Ve,guard:T.guard,guardAt:T.guard?{x:Ae.x+8,y:Ae.y+14,anchor:"start"}:void 0,back:!0});continue}const V=A.kind==="join"?E(M):E(A),J={x:V,y:A.y};let X,z;const F=M.kind==="decision"?S.get(T.id):void 0;if(F==="left"||F==="right"){const U={x:F==="right"?M.x+M.w:M.x,y:_(M)};X=Math.abs(V-U.x)<1?[U,J]:[U,{x:V,y:U.y},J],z={x:U.x+(F==="right"?10:-10),y:U.y-9,anchor:F==="right"?"start":"end"}}else{const K={x:M.kind==="fork"?E(A):E(M),y:M.y+M.h},O=J.y-22;X=Math.abs(K.x-J.x)<1?[K,J]:[K,{x:K.x,y:O},{x:J.x,y:O},J],z={x:K.x+8,y:K.y+16,anchor:"start"}}j.push({id:T.id,from:T.from,to:T.to,points:X,guard:T.guard,guardAt:T.guard?z:void 0,back:!1})}const I=[...C.values()],L=Math.max(w,...j.flatMap(T=>T.points.map(M=>M.x+24))),D=Math.max(...I.map(T=>T.y+T.h))+72;L>w&&(k[k.length-1].w+=L-w);const B={};for(const T of I)B[fe({kind:"activityNode",behavior:r.id,id:T.id})]=T;for(const T of j)B[fe({kind:"activityFlow",behavior:r.id,id:T.id})]=Ri(T.points.map(M=>({...M,w:1,h:1})));return k.forEach(T=>{T.entityId&&(B[fe({kind:"entity",id:T.entityId})]={x:T.x,y:0,w:T.w,h:Gy})}),B[fe({kind:"behavior",id:r.id})]={x:0,y:0,w:L,h:D},{processId:r.id,width:Math.max(w,L),height:D,lanes:k,laneHeader:Gy,nodes:I,edges:j,anchors:B}}const dt={header:40,row:26,more:28,bottom:6};function OP(t){const e=Re(t.name,13.5,650)+64,n=Math.max(0,...t.fields.map(i=>Re(i.name,12.5,500,"mono")+Re(i.type,11.5,400,"mono")+78)),r=Math.ceil(Math.max(232,e,n)),s=dt.header+t.fields.length*dt.row+(t.hiddenCount>0||t.expanded?dt.more:0)+dt.bottom;return{w:r,h:s}}async function AP(t,e,n={}){const r=wP(t,e,n),s=m=>{const g=OP(m);return{id:m.dataTypeId,width:g.w,height:g.h,...e.positions[m.dataTypeId]}},i=await Id({id:"root",layoutOptions:{...Rd,"elk.direction":"RIGHT","elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.spacing.nodeNode":"36","elk.layered.spacing.nodeNodeBetweenLayers":"96","elk.spacing.edgeNode":"24","elk.spacing.edgeEdge":"16","elk.padding":"[top=32,left=32,bottom=32,right=32]"},children:[...r.stores.map(m=>({id:`store:${m}`,layoutOptions:{"elk.padding":"[top=44,left=20,bottom=20,right=20]","elk.spacing.nodeNode":"28"},children:r.tables.filter(g=>g.store===m).map(s)})),...r.tables.filter(m=>!m.store).map(s)],edges:r.relations.map(m=>({id:m.id,sources:[m.from],targets:[m.to]}))}),o=r.tables.map(m=>{const g=i.nodes.get(m.dataTypeId),p=new Set(r.relations.filter(x=>x.via&&(x.from===m.dataTypeId||x.to===m.dataTypeId)).map(x=>x.via));return{...g,dataTypeId:m.dataTypeId,name:m.name,store:m.store,hiddenCount:m.hiddenCount,expanded:m.expanded,rows:m.fields.map((x,y)=>({...x,y:g.y+dt.header+y*dt.row,foreign:!!x.references||p.has(x.name)&&!x.primaryKey}))}}),a=new Map(o.map(m=>[m.dataTypeId,m])),l=(m,g)=>{const p=m.rows.find(x=>x.name===g)??m.rows.find(x=>x.primaryKey);return p?p.y+dt.row/2:void 0},c=(m,g,p)=>{if(p===void 0||m.length<2)return m;const x=m[m.length-1],y=m[m.length-2];if(Math.abs(y.y-x.y)>.5||Math.abs(x.y-p)<.5)return m;const v=Math.abs(x.x-g.x)<2,k=x.x+(v?-18:18);return v&&y.x>k||!v&&y.x<k?m:[...m.slice(0,-1),{x:k,y:x.y},{x:k,y:p},{x:x.x,y:p}]},d=r.relations.map(m=>{var v;let g=((v=i.edges.get(m.id))==null?void 0:v.points)??[];const p=a.get(m.from),x=a.get(m.to),y=p.rows.some(k=>k.name===m.via)&&m.from!==m.to?m.via:void 0;return g=c(g,x,l(x,m.via)),g=c(g.slice().reverse(),p,l(p,y)).reverse(),{...m,points:g}}).filter(m=>m.points.length>=2),u=r.stores.map(m=>({...i.nodes.get(`store:${m}`),entityId:m})),h={};for(const m of o){h[fe({kind:"dataType",id:m.dataTypeId})]=m;for(const g of m.rows)h[fe({kind:"dataType",id:m.dataTypeId,field:g.name})]={x:m.x,y:g.y,w:m.w,h:dt.row}}for(const m of u)h[fe({kind:"entity",id:m.entityId})]=m;for(const m of d)h[fe({kind:"dataRelation",id:m.id})]=Ri(m.points.map(g=>({...g,w:1,h:1})));return{width:i.width,height:i.height,stores:u,tables:o,relations:d,anchors:h}}function RP(t,e){const n=Math.max(Re(t,11.5,600),e?Re(`[${e}]`,10.5,400):0)+16;return{width:Math.ceil(n),height:e?34:22}}async function IP(t,e,n={}){const s=gt(t).stateMachine(e.stateMachine);if(!s)throw new Error(`Unknown state machine "${e.stateMachine}"`);const i={...s,transitions:[...s.transitions,...n.extraTransitions??[]]},o=u=>{if(u.kind==="initial")return{w:22,h:22};const h=u.entryActions.length?`On entry: ${u.entryActions[0]}${u.entryActions.length>1?` +${u.entryActions.length-1}`:""}`:"",m=Math.max(148,Re(u.name,14,600)+52,h?Re(h,11,400)+36:0);return{w:Math.ceil(m),h:h?64:48}},a=await Id({id:"root",layoutOptions:{...Rd,"elk.direction":"DOWN","elk.spacing.nodeNode":"56","elk.layered.spacing.nodeNodeBetweenLayers":"44","elk.spacing.edgeNode":"22","elk.spacing.edgeEdge":"18","elk.spacing.edgeLabel":"6","elk.edgeLabels.placement":"CENTER","elk.padding":"[top=40,left=40,bottom=40,right=40]"},children:i.states.map(u=>({id:u.id,width:o(u).w,height:o(u).h,...e.positions[u.id]})),edges:i.transitions.map(u=>({id:u.id,sources:[u.from],targets:[u.to],labels:[{text:u.event,...RP(u.event,u.guard)}]}))}),l=i.states.map(u=>({...a.nodes.get(u.id),id:u.id,kind:u.kind,name:u.name,outcome:u.outcome,entryActions:u.entryActions})),c=i.transitions.map(u=>{const h=a.edges.get(u.id);return{id:u.id,from:u.from,to:u.to,event:u.event,guard:u.guard,points:(h==null?void 0:h.points)??[],label:h==null?void 0:h.labels[0]}}).filter(u=>u.points.length>=2),d={};for(const u of l)d[fe({kind:"state",behavior:i.id,id:u.id})]=u;for(const u of c)d[fe({kind:"transition",behavior:i.id,id:u.id})]=Ri([...u.points.map(h=>({...h,w:1,h:1})),...u.label?[u.label]:[]]);return d[fe({kind:"behavior",id:i.id})]={x:0,y:0,w:a.width,h:a.height},i.subject&&(d[fe({kind:"dataType",id:i.subject})]={x:0,y:0,w:a.width,h:a.height}),{machineId:i.id,width:a.width,height:a.height,states:l,transitions:c,anchors:d}}const ql={w:168,h:96},PP=40,DP=52;function zP(t,e){const n=gt(t),r=e.useCases.map(S=>n.useCases.get(S)).filter(Oo),s=[];for(const S of r)s.includes(S.area)||s.push(S.area);const i=Math.min(340,Math.max(240,...r.map(S=>Re(S.name,13.5,600)+56))),o=ql.w+200,a=i+140,l=o+(a-i)/2;let c=76;const d=[],u=[];for(const S of s){const j=c;c+=34;for(const $ of r.filter(I=>I.area===S))u.push({id:$.id,name:$.name,x:l,y:c,w:i,h:PP}),c+=DP;c+=6,d.push({label:S,x:o+16,y:j,w:a-32,h:c-j}),c+=14}const h={x:o,y:24,w:a,h:c+4-24,title:t.project.name},m=new Map(u.map(S=>[S.id,S])),g=(S,j)=>{const $=j==="left"?24:o+a+176,I=S.map(D=>{const B=r.filter(T=>(j==="left"?T.actors:T.supporting).includes(D)).map(T=>m.get(T.id)),H=B.reduce((T,M)=>T+M.y+M.h/2,0)/Math.max(1,B.length);return{id:D,cy:H}});I.sort((D,B)=>D.cy-B.cy);let L=0;return I.map(({id:D,cy:B})=>{const H=Math.max(L,B-ql.h/2);return L=H+ql.h+28,{entityId:D,side:j,x:$,y:H,w:ql.w,h:ql.h}})},p=[...new Set(r.flatMap(S=>S.actors))],x=[...new Set(r.flatMap(S=>S.supporting))].filter(S=>!p.includes(S)),y=[...g(p,"left"),...g(x,"right")],v=new Map(y.map(S=>[S.entityId,S])),k=[];for(const S of r){const j=m.get(S.id);for(const $ of S.actors){const I=v.get($);I&&k.push({id:`${$}->${S.id}`,actor:$,useCase:S.id,side:"left",from:{x:I.x+I.w-22,y:I.y+30},to:{x:j.x,y:j.y+j.h/2}})}for(const $ of S.supporting){const I=v.get($);(I==null?void 0:I.side)==="right"&&k.push({id:`${$}->${S.id}`,actor:$,useCase:S.id,side:"right",from:{x:I.x+22,y:I.y+30},to:{x:j.x+j.w,y:j.y+j.h/2}})}}const w=[];for(const S of r)for(const j of S.includes){const $=m.get(S.id),I=m.get(j);!$||!I||w.push({id:`${S.id}=>${j}`,from:S.id,to:j,a:{x:$.x+$.w-24,y:$.y+$.h},b:{x:I.x+I.w-24,y:I.y},bulge:0})}const C=Math.max(...y.map(S=>S.x+S.w),h.x+h.w)+32,E=Math.max(h.y+h.h,...y.map(S=>S.y+S.h))+32,_={};for(const S of u)_[fe({kind:"useCase",id:S.id})]=S;for(const S of y)_[fe({kind:"entity",id:S.entityId})]=S;return{width:C,height:E,boundary:h,areas:d,useCases:u,actors:y,associations:k,includes:w,anchors:_}}const Qi=132,Fm=168,vu=58,Bm=28,ku=14,LP=9;function FP(t,e){const n=gt(t),r=new Set(e.entities),s=new Map;e.layers.forEach((D,B)=>D.members.forEach(H=>r.has(H)&&s.set(H,B)));for(const D of e.entities)s.has(D)||s.set(D,e.layers.length-1);const i=(e.relationships??t.model.relationships.filter(D=>r.has(D.source)&&r.has(D.target)).map(D=>D.id)).map(D=>n.relationships.get(D)).filter(D=>!!D&&r.has(D.source)&&r.has(D.target)),o=D=>{var B;return Math.ceil(Math.max(184,Re(((B=n.entities.get(D))==null?void 0:B.name)??D,13.5,600)+70))},a=e.layers.map((D,B)=>e.entities.filter(H=>s.get(H)===B)),l=new Map;a.forEach(D=>D.forEach((B,H)=>l.set(B,H/Math.max(1,D.length-1))));const d=D=>i.flatMap(B=>B.source===D?[B.target]:B.target===D?[B.source]:[]),u=D=>{for(const B of D){const H=a[B],T=new Map(H.map(M=>{const A=d(M).filter(V=>s.get(V)!==B);return[M,A.length?A.reduce((V,J)=>V+l.get(J),0)/A.length:l.get(M)]}));H.sort((M,A)=>T.get(M)-T.get(A)),H.forEach((M,A)=>l.set(M,A/Math.max(1,H.length-1)))}},h=a.map((D,B)=>B);u(h.slice(1)),u(h.slice(0,-1).reverse()),u(h.slice(1));const m=a.map(D=>D.reduce((B,H)=>B+o(H),0)+Math.max(0,D.length-1)*Bm),g=Math.max(...m,400),p=[];a.forEach((D,B)=>{let H=Fm+24+(g-m[B])/2;for(const T of D)p.push({entityId:T,band:B,x:H,y:B*Qi+(Qi-vu)/2,w:o(T),h:vu}),H+=o(T)+Bm});const x=new Map(p.map(D=>[D.entityId,D])),y=Fm+24+g+40,v=e.layers.map((D,B)=>({id:D.id,label:D.label,description:D.description,x:0,y:B*Qi,w:y,h:Qi})),k=new Map,w=(D,B)=>`${D}:${B}`,C=i.map(D=>{const B=x.get(D.source),H=x.get(D.target),T=H.band>B.band?"down":H.band<B.band?"up":"across",M=T==="down"?"bottom":"top",A=T==="down"?"top":T==="up"?"bottom":"top";return k.set(w(D.source,M),[...k.get(w(D.source,M))??[],D.id]),k.set(w(D.target,A),[...k.get(w(D.target,A))??[],D.id]),{r:D,a:B,b:H,direction:T,out:M,inn:A}}),E=(D,B,H,T)=>{const M=x.get(D),A=(k.get(w(D,B))??[]).slice(),V=z=>{const F=n.relationships.get(z),U=x.get(F.source===D?F.target:F.source);return U.x+U.w/2};A.sort((z,F)=>V(z)-V(F));const J=A.indexOf(H),X=Math.min(M.w*.6,(A.length-1)*18);return M.x+M.w/2-X/2+(A.length>1?J/(A.length-1)*X:0)},_=new Map,S=a.map(D=>{const B=D.map(M=>x.get(M)).sort((M,A)=>M.x-A.x),H=[];let T=Fm+24-Bm;for(const M of B)H.push({from:T+ku,to:M.x-ku}),T=M.x+M.w;return H.push({from:T+ku,to:y-ku}),H.filter(M=>M.to>=M.from)}),j=(D,B)=>{let H={gap:0,x:B,cost:1/0};S[D].forEach((J,X)=>{const z=Math.min(J.to,Math.max(J.from,B));Math.abs(z-B)<H.cost&&(H={gap:X,x:z,cost:Math.abs(z-B)})});const T=`${D}:${H.gap}`,M=_.get(T)??0;_.set(T,M+1);const A=S[D][H.gap],V=H.x+(M===0?0:(M%2?1:-1)*Math.ceil(M/2)*LP);return Math.min(A.to,Math.max(A.from,V))},$=(D,B)=>{const H=Math.max(20,Math.abs(B.y-D.y)*.45)*(B.y>=D.y?1:-1);return[{x:D.x,y:D.y+H},{x:B.x,y:B.y-H},B]},I=C.map(({r:D,a:B,b:H,direction:T,out:M,inn:A})=>{const V={x:E(D.source,M,D.id),y:M==="bottom"?B.y+B.h:B.y},J={x:E(D.target,A,D.id),y:A==="top"?H.y:H.y+H.h};if(T==="across")return{id:D.id,source:D.source,target:D.target,kind:D.kind,d:[V,{x:V.x,y:V.y-46},{x:J.x,y:J.y-46},J],direction:T};const X=T==="down"?1:-1,z=[];for(let K=B.band+X;K!==H.band;K+=X)z.push(K);const F=[V];let U=V;return z.forEach((K,O)=>{const P=(O+1)/(z.length+1),W=j(K,V.x+(J.x-V.x)*P),G=K*Qi+(Qi-vu)/2-6,se=G+vu+12,Ae={x:W,y:X>0?G:se},Ve={x:W,y:X>0?se:G};F.push(...$(U,Ae),{x:W,y:Ae.y+(Ve.y-Ae.y)/3},{x:W,y:Ae.y+(Ve.y-Ae.y)*2/3},Ve),U=Ve}),F.push(...$(U,J)),{id:D.id,source:D.source,target:D.target,kind:D.kind,d:F,direction:T}}),L={};for(const D of p)L[fe({kind:"entity",id:D.entityId})]=D;for(const D of v)L[fe({kind:"group",view:e.id,id:D.id})]=D;for(const D of I){const B=D.d.map(T=>T.x),H=D.d.map(T=>T.y);L[fe({kind:"relationship",id:D.id})]={x:Math.min(...B),y:Math.min(...H),w:Math.max(...B)-Math.min(...B),h:Math.max(...H)-Math.min(...H)}}return{width:y,height:e.layers.length*Qi,bands:v,nodes:p,edges:I,anchors:L}}const ta={head:52,pad:24},Oa={h:72,gapX:120,gapY:44,minW:184,maxW:260},Vm={size:12,h:22,subH:36};function BP(t){return Math.round(Math.min(Oa.maxW,Math.max(Oa.minW,Re(t,15,600)+76)))}function VP(t,e){const n=Math.max(Re(t,Vm.size,500),e?Re(e,11,400):0)+18;return{w:Math.ceil(n),h:e?Vm.subH:Vm.h}}async function WP(t,e,n={}){var K;const r=gt(t),s=new Map((n.extraEntities??[]).map(O=>[O.id,O])),i=O=>r.entities.get(O)??s.get(O),o=new Set(e.passThrough),a=[...e.entities.filter(O=>r.entities.has(O)&&!o.has(O)),...[...s.keys()].filter(O=>!e.entities.includes(O))],l=new Set(a),c=e.relationships?new Set(e.relationships):void 0,d=[...t.model.relationships,...n.extraRelationships??[]],u=O=>!c||c.has(O.id)||(n.extraRelationships??[]).includes(O),h=d.filter(O=>u(O)&&l.has(O.source)&&l.has(O.target)).map(O=>({id:O.id,relationships:[O.id],source:O.source,target:O.target,text:O.label}));for(const O of o){const P=d.filter(G=>u(G)&&G.target===O&&l.has(G.source)),W=d.filter(G=>u(G)&&G.source===O&&l.has(G.target));for(const G of P)for(const se of W)h.push({id:G.id,relationships:[G.id,se.id],source:G.source,target:se.target,via:O,text:G.label})}const m=O=>{var W,G;let P=(W=i(O))==null?void 0:W.parent;for(let se=0;P&&!l.has(P)&&se<32;se++)P=(G=i(P))==null?void 0:G.parent;return P&&l.has(P)&&P!==O?P:void 0},g=new Map;for(const O of a){const P=m(O);P&&g.set(P,[...g.get(P)??[],O])}const p=new Set((n.collapsed??e.collapsed).filter(O=>g.has(O))),x=O=>{const P=[];for(let W=m(O);W&&P.length<32&&!P.includes(W);W=m(W))P.push(W);return P},y=O=>[O,...x(O)].filter((P,W)=>W===0||p.has(P)).pop(),v=O=>(g.get(O)??[]).flatMap(P=>[P,...v(P)]),k=a.filter(O=>y(O)===O),w=O=>g.has(O)&&!p.has(O),C=new Map;for(const O of h){const P=y(O.source),W=y(O.target);if(P===W||x(P).includes(W)||x(W).includes(P))continue;const G=`${P}>${W}`,se=C.get(G);se?(se.relationships.push(...O.relationships),se.texts.push(O.text)):C.set(G,{...O,source:P,target:W,relationships:[...O.relationships],texts:[O.text]})}h.length=0;for(const O of C.values()){const P=[...new Set(O.texts)],W=P.join(", "),G=P.length===1?P[0]:W.length<=40?W:`${P[0]} +${P.length-1} more`;h.push({id:O.id,relationships:O.relationships,source:O.source,target:O.target,via:P.length>1?void 0:O.via,text:G})}const E=O=>w(O)?E(g.get(O).find(P=>y(P)===P)??O):O,_=O=>{var G,se;const P=((G=i(O))==null?void 0:G.name)??O;if(!w(O))return{id:O,width:BP(P),height:Oa.h,...e.positions[O]};const W=Math.ceil(Re(P,14,600)+Re(((se=i(O))==null?void 0:se.technology)??"",12,400)+ta.pad*2+40);return{id:O,layoutOptions:{"elk.padding":`[top=${ta.head},left=${ta.pad},bottom=${ta.pad},right=${ta.pad}]`,"elk.nodeSize.constraints":"MINIMUM_SIZE","elk.nodeSize.minimum":`(${W}, ${Oa.h})`},children:g.get(O).filter(Ae=>y(Ae)===Ae).map(_)}},S=e.layout.direction==="down",j=await Id({id:"root",layoutOptions:{...Rd,"elk.direction":S?"DOWN":"RIGHT","elk.spacing.nodeNode":String(S?56:Oa.gapY),"elk.layered.spacing.nodeNodeBetweenLayers":String(S?84:Oa.gapX),"elk.layered.nodePlacement.strategy":"BRANDES_KOEPF","elk.layered.nodePlacement.bk.fixedAlignment":"BALANCED","elk.padding":"[top=48,left=48,bottom=48,right=48]",...g.size?{"elk.hierarchyHandling":"INCLUDE_CHILDREN"}:{}},children:k.filter(O=>!m(O)).map(_),edges:h.flatMap((O,P)=>{const[W,G]=[E(O.source),E(O.target)];return W===G?[]:[{id:`e${P}`,sources:[W],targets:[G]}]})}),$=O=>{const P=j.nodes.get(O);return{x:P.x,y:P.y,w:P.w,h:P.h}},I=k.filter(O=>!w(O)).map(O=>({...$(O),entityId:O,...p.has(O)?{members:v(O)}:{}})),L=k.filter(w).map(O=>({...$(O),entityId:O,members:v(O),depth:x(O).length})).sort((O,P)=>O.depth-P.depth),D=new Map([...I.map(O=>[O.entityId,O]),...L.map(O=>[O.entityId,O])]),B=O=>{const P=D.get(O.source),W=D.get(O.target),G=Math.max(W.x-(P.x+P.w),P.x-(W.x+W.w)),se=Math.max(W.y-(P.y+P.h),P.y-(W.y+W.h));return G>=se&&G>0?W.x>P.x?{out:"right",in:"left"}:{out:"left",in:"right"}:W.y>P.y?{out:"bottom",in:"top"}:{out:"top",in:"bottom"}},H=new Map,T=h.map((O,P)=>{const W=B(O),G=`${O.source}:${W.out}`,se=`${O.target}:${W.in}`;return H.set(G,[...H.get(G)??[],P]),H.set(se,[...H.get(se)??[],P]),{l:O,s:W,k1:G,k2:se,i:P}}),M=O=>{const P=D.get(O);return{x:P.x+P.w/2,y:P.y+P.h/2}},A=(O,P,W,G)=>{const se=D.get(O),Ae=P==="left"||P==="right",Ve=zt=>M(h[zt].source===O?h[zt].target:h[zt].source),Ye=(H.get(W)??[]).slice().sort((zt,tt)=>Ae?Ve(zt).y-Ve(tt).y:Ve(zt).x-Ve(tt).x),kt=Ye.indexOf(G),rn=Math.min((Ae?se.h:se.w)*.55,(Ye.length-1)*14),Kt=Ye.length>1?-rn/2+kt/(Ye.length-1)*rn:0;return P==="right"?{x:se.x+se.w,y:se.y+se.h/2+Kt}:P==="left"?{x:se.x,y:se.y+se.h/2+Kt}:P==="bottom"?{x:se.x+se.w/2+Kt,y:se.y+se.h}:{x:se.x+se.w/2+Kt,y:se.y}},V=[...I.map(O=>({x:O.x-6,y:O.y-6,w:O.w+12,h:O.h+12})),...L.map(O=>({x:O.x,y:O.y,w:O.w,h:ta.head-8}))],J={right:[1,0],left:[-1,0],bottom:[0,1],top:[0,-1]},X=({l:O,s:P,k1:W,k2:G,i:se})=>{const Ae=A(O.source,P.out,W,se),Ve=A(O.target,P.in,G,se),kt=P.out==="left"||P.out==="right"?Math.max(48,Math.abs(Ve.x-Ae.x)*.45):Math.max(36,Math.abs(Ve.y-Ae.y)*.45),[rn,Kt]=J[P.out],[zt,tt]=J[P.in];return[Ae,{x:Ae.x+rn*kt,y:Ae.y+Kt*kt},{x:Ve.x+zt*kt,y:Ve.y+tt*kt},Ve]},z=T.map(X),F=T.map(({l:O,i:P})=>{var zt;const W=z[P],G=O.via?`through ${((zt=i(O.via))==null?void 0:zt.name)??O.via}`:void 0,se=VP(O.text,G),Ae=z.filter((tt,Vn)=>Vn!==P),Ve=tt=>{let Vn=0;for(const Jt of V)Vn+=8*Math.max(0,Math.min(tt.x+tt.w,Jt.x+Jt.w)-Math.max(tt.x,Jt.x))*Math.max(0,Math.min(tt.y+tt.h,Jt.y+Jt.h)-Math.max(tt.y,Jt.y));for(const Jt of Ae)for(let de=1;de<24;de++){const lt=Nc(Jt,de/24);lt.x>tt.x&&lt.x<tt.x+tt.w&&lt.y>tt.y&&lt.y<tt.y+tt.h&&(Vn+=600)}return Vn};let Ye,kt,rn=1/0;const Kt=[.5,.44,.56,.38,.62,.32,.68,.26,.74];for(const tt of[0,1,-1,2,-2,3,-3,4,-4]){for(const Vn of Kt){const Jt=Nc(W,Vn),de=UP(W,Vn),lt=Math.hypot(de.x,de.y)||1,Gt=tt*(Math.abs(de.x/lt)>.7?se.h/2+12:se.w/2+12),vr={x:-de.y/lt,y:de.x/lt},K0={x:Jt.x+vr.x*Gt-se.w/2,y:Jt.y+vr.y*Gt-se.h/2,w:se.w,h:se.h},J0=Ve(K0)+Math.abs(Vn-.5)*40+Math.abs(tt)*250;J0<rn&&(rn=J0,Ye=K0,kt=tt?Jt:void 0)}if(rn<=10)break}return Ye??(Ye={x:0,y:0,...se}),V.push(Ye),{id:O.id,relationships:O.relationships,source:O.source,target:O.target,via:O.via,curve:W,label:{...Ye,text:O.text,sub:G},leader:kt}}),U={};for(const O of I)U[fe({kind:"entity",id:O.entityId})]=O;for(const O of L)U[fe({kind:"entity",id:O.entityId})]=O;for(const O of a)y(O)!==O&&(U[fe({kind:"entity",id:O})]=D.get(y(O)));for(const O of F){const P=O.curve.map(Ve=>Ve.x),W=O.curve.map(Ve=>Ve.y),G=[...P,O.label.x,O.label.x+O.label.w],se=[...W,O.label.y,O.label.y+O.label.h],Ae={x:Math.min(...G),y:Math.min(...se),w:Math.max(...G)-Math.min(...G),h:Math.max(...se)-Math.min(...se)};for(const Ve of O.relationships)U[K=fe({kind:"relationship",id:Ve})]??(U[K]=Ae)}return{width:j.width,height:j.height,nodes:I,groups:L,edges:F,anchors:U}}function Nc([t,e,n,r],s){const i=1-s;return{x:i*i*i*t.x+3*i*i*s*e.x+3*i*s*s*n.x+s*s*s*r.x,y:i*i*i*t.y+3*i*i*s*e.y+3*i*s*s*n.y+s*s*s*r.y}}function UP([t,e,n,r],s){const i=1-s;return{x:3*i*i*(e.x-t.x)+6*i*s*(n.x-e.x)+3*s*s*(r.x-n.x),y:3*i*i*(e.y-t.y)+6*i*s*(n.y-e.y)+3*s*s*(r.y-n.y)}}const QE=new Map;function ZP(t,e){QE.set(t,e)}async function XE(t,e,n={}){switch(e.type){case"architecture":return EP(t,e,n);case"map":return WP(t,e,n);case"sequence":return _P(t,e,n);case"dataflow":return jP(t,e,n);case"activity":return TP(t,e);case"erd":return AP(t,e,n);case"state":return IP(t,e,n);case"usecase":return zP(t,e);case"dependency":return FP(t,e);case"extension":{const r=QE.get(e.extension);if(!r)throw new Error(`No layout registered for "${e.extension}"`);return r(t,e,n)}}}/**
45
+ * @license lucide-react v1.75.0 - ISC
46
+ *
47
+ * This source code is licensed under the ISC license.
48
+ * See the LICENSE file in the root directory of this source tree.
49
+ */const HP=t=>t==null?void 0:t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
50
+ * @license lucide-react v1.75.0 - ISC
51
+ *
52
+ * This source code is licensed under the ISC license.
53
+ * See the LICENSE file in the root directory of this source tree.
54
+ */function qP(t,e,n=[]){if(e==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:HP(t),size:24,node:e,...n.length>0?{aliases:n}:{}}}/**
55
+ * @license lucide-react v1.75.0 - ISC
56
+ *
57
+ * This source code is licensed under the ISC license.
58
+ * See the LICENSE file in the root directory of this source tree.
59
+ */const KP=t=>{let e="",n=!1;for(const r of t){if(r==="-"||r==="_"||r<=" "){n=e.length>0;continue}e.length===0?e+=r.toLowerCase():e+=n?r.toUpperCase():r,n=!1}return e};/**
60
+ * @license lucide-react v1.75.0 - ISC
61
+ *
62
+ * This source code is licensed under the ISC license.
63
+ * See the LICENSE file in the root directory of this source tree.
64
+ */const JP=t=>{const e=KP(t);return e.charAt(0).toUpperCase()+e.slice(1)};/**
65
+ * @license lucide-react v1.75.0 - ISC
66
+ *
67
+ * This source code is licensed under the ISC license.
68
+ * See the LICENSE file in the root directory of this source tree.
69
+ */const Yy=(...t)=>{const e=new Set;for(const n of t)if(typeof n=="string")for(const r of n.split(/\s+/))r&&e.add(r);return[...e].join(" ")};/**
70
+ * @license lucide-react v1.75.0 - ISC
71
+ *
72
+ * This source code is licensed under the ISC license.
73
+ * See the LICENSE file in the root directory of this source tree.
74
+ */const Xi={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};/**
75
+ * @license lucide-react v1.75.0 - ISC
76
+ *
77
+ * This source code is licensed under the ISC license.
78
+ * See the LICENSE file in the root directory of this source tree.
79
+ */function Wm(t){return t!=null}function GP(t,e={}){var h,m;const n=e.attributeNames??{},r=g=>n[g]??g,s=t.size??t.width??Xi.width,i=t.size??t.height??Xi.height,o=((h=t.aliases)==null?void 0:h.filter(g=>typeof g=="string"&&g.trim()!=="").map(g=>`lucide-${g}`))??[],a=[...t.name?[`lucide-${t.name}`]:[],...o],l=((m=e.className)==null?void 0:m.split(" ").filter(Boolean))??[],c=e.includeDefaultClasses===!1?Yy(...l):Yy("lucide",...a,...l),d=e.absoluteStrokeWidth?Number(e.strokeWidth??Xi["stroke-width"])*Number(t.size??t.width??Xi.width)/Number(e.size??e.width??Xi.width):e.strokeWidth??Xi["stroke-width"];return["svg",{...Object.entries(Xi).reduce((g,[p,x])=>(g[r(p)]=x,g),{}),..."color"in e&&e.color&&{[r("stroke")]:e.color},..."size"in e&&Wm(e.size)&&{[r("width")]:e.size,[r("height")]:e.size},..."width"in e&&Wm(e.width)&&{[r("width")]:e.width},..."height"in e&&Wm(e.height)&&{[r("height")]:e.height},[r("stroke-width")]:d,...c&&{[r("class")]:c},[r("viewBox")]:`0 0 ${s} ${i}`,...e.hasA11yProp===!1?{[r("aria-hidden")]:"true"}:{},..."attributes"in e&&e.attributes},t.node.map(g=>{const[p,x,y]=g,v=e.nonScalingStroke?{[r("vector-effect")]:"non-scaling-stroke",...x}:x;return y?[p,v,y]:[p,v]})]}/**
80
+ * @license lucide-react v1.75.0 - ISC
81
+ *
82
+ * This source code is licensed under the ISC license.
83
+ * See the LICENSE file in the root directory of this source tree.
84
+ */function YP(t,e={}){return GP(t,{...e,attributeNames:{...e.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}/**
85
+ * @license lucide-react v1.75.0 - ISC
86
+ *
87
+ * This source code is licensed under the ISC license.
88
+ * See the LICENSE file in the root directory of this source tree.
89
+ */const QP=t=>{if(t==null||typeof t!="object")return!1;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)&&(e.startsWith("aria-")||e==="role"||e==="title")&&t[e]!=null)return!0;return!1},XP=b.createContext({}),eD=()=>b.useContext(XP),tD=b.forwardRef(({color:t,size:e,width:n,height:r,strokeWidth:s,absoluteStrokeWidth:i,nonScalingStroke:o,className:a="",children:l,iconNode:c=[],icon:d={node:c,aliases:[],size:24},...u},h)=>{const{size:m=24,strokeWidth:g=2,absoluteStrokeWidth:p=!1,nonScalingStroke:x=!1,color:y="currentColor",className:v=""}=eD()??{},k=!!l||QP(u),[w,C,E=[]]=YP(d,{color:t??y,width:n??e??m,height:r??e??m,strokeWidth:s??g,absoluteStrokeWidth:i??p,nonScalingStroke:o??x,className:Yy(v,a),hasA11yProp:k,attributes:u});return b.createElement(w,{ref:h,...C},[...E.map(([_,S])=>b.createElement(_,S)),...Array.isArray(l)?l:[l]])});/**
90
+ * @license lucide-react v1.75.0 - ISC
91
+ *
92
+ * This source code is licensed under the ISC license.
93
+ * See the LICENSE file in the root directory of this source tree.
94
+ */function ie(t,e=[],n=[]){const r=typeof t=="string"?qP(t,e,n):t,s=b.forwardRef(({className:i,...o},a)=>b.createElement(tD,{ref:a,icon:r,className:i,...o}));return r.name&&(s.displayName=JP(r.name)),s}/**
95
+ * @license lucide-react v1.75.0 - ISC
96
+ *
97
+ * This source code is licensed under the ISC license.
98
+ * See the LICENSE file in the root directory of this source tree.
99
+ */const e_={name:"activity",size:24,node:[["path",{d:"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",key:"169zse"}]]};e_.node;const nD=ie(e_);/**
100
+ * @license lucide-react v1.75.0 - ISC
101
+ *
102
+ * This source code is licensed under the ISC license.
103
+ * See the LICENSE file in the root directory of this source tree.
104
+ */const t_={name:"arrow-left",size:24,node:[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]};t_.node;const n_=ie(t_);/**
105
+ * @license lucide-react v1.75.0 - ISC
106
+ *
107
+ * This source code is licensed under the ISC license.
108
+ * See the LICENSE file in the root directory of this source tree.
109
+ */const r_={name:"arrow-right-left",size:24,node:[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]};r_.node;const rD=ie(r_);/**
110
+ * @license lucide-react v1.75.0 - ISC
111
+ *
112
+ * This source code is licensed under the ISC license.
113
+ * See the LICENSE file in the root directory of this source tree.
114
+ */const s_={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};s_.node;const ns=ie(s_);/**
115
+ * @license lucide-react v1.75.0 - ISC
116
+ *
117
+ * This source code is licensed under the ISC license.
118
+ * See the LICENSE file in the root directory of this source tree.
119
+ */const i_={name:"arrow-up-right",size:24,node:[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]};i_.node;const eh=ie(i_);/**
120
+ * @license lucide-react v1.75.0 - ISC
121
+ *
122
+ * This source code is licensed under the ISC license.
123
+ * See the LICENSE file in the root directory of this source tree.
124
+ */const o_={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};o_.node;const a_=ie(o_);/**
125
+ * @license lucide-react v1.75.0 - ISC
126
+ *
127
+ * This source code is licensed under the ISC license.
128
+ * See the LICENSE file in the root directory of this source tree.
129
+ */const l_={name:"book-open-text",size:24,node:[["path",{d:"M12 5v16",key:"1f6ucr"}],["path",{d:"M16 13h2",key:"weia3s"}],["path",{d:"M16 9h2",key:"1n7gjm"}],["path",{d:"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",key:"1fyvmf"}],["path",{d:"M6 13h2",key:"1cckiz"}],["path",{d:"M6 9h2",key:"1k7j9f"}]]};l_.node;const $p=ie(l_);/**
130
+ * @license lucide-react v1.75.0 - ISC
131
+ *
132
+ * This source code is licensed under the ISC license.
133
+ * See the LICENSE file in the root directory of this source tree.
134
+ */const c_={name:"book-open",size:24,node:[["path",{d:"M12 5v16",key:"1f6ucr"}],["path",{d:"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",key:"1fyvmf"}]]};c_.node;const sD=ie(c_);/**
135
+ * @license lucide-react v1.75.0 - ISC
136
+ *
137
+ * This source code is licensed under the ISC license.
138
+ * See the LICENSE file in the root directory of this source tree.
139
+ */const d_={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};d_.node;const js=ie(d_);/**
140
+ * @license lucide-react v1.75.0 - ISC
141
+ *
142
+ * This source code is licensed under the ISC license.
143
+ * See the LICENSE file in the root directory of this source tree.
144
+ */const u_={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};u_.node;const f_=ie(u_);/**
145
+ * @license lucide-react v1.75.0 - ISC
146
+ *
147
+ * This source code is licensed under the ISC license.
148
+ * See the LICENSE file in the root directory of this source tree.
149
+ */const h_={name:"chevron-left",size:24,node:[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]};h_.node;const p_=ie(h_);/**
150
+ * @license lucide-react v1.75.0 - ISC
151
+ *
152
+ * This source code is licensed under the ISC license.
153
+ * See the LICENSE file in the root directory of this source tree.
154
+ */const m_={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};m_.node;const zd=ie(m_);/**
155
+ * @license lucide-react v1.75.0 - ISC
156
+ *
157
+ * This source code is licensed under the ISC license.
158
+ * See the LICENSE file in the root directory of this source tree.
159
+ */const g_={name:"chevrons-down-up",size:24,node:[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]]};g_.node;const y_=ie(g_);/**
160
+ * @license lucide-react v1.75.0 - ISC
161
+ *
162
+ * This source code is licensed under the ISC license.
163
+ * See the LICENSE file in the root directory of this source tree.
164
+ */const x_={name:"chevrons-up-down",size:24,node:[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]};x_.node;const v_=ie(x_);/**
165
+ * @license lucide-react v1.75.0 - ISC
166
+ *
167
+ * This source code is licensed under the ISC license.
168
+ * See the LICENSE file in the root directory of this source tree.
169
+ */const k_={name:"circle-check",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 9-5.5 5.5L8 12",key:"xofnsj"}]],aliases:["check-circle-2"]};k_.node;const w_=ie(k_);/**
170
+ * @license lucide-react v1.75.0 - ISC
171
+ *
172
+ * This source code is licensed under the ISC license.
173
+ * See the LICENSE file in the root directory of this source tree.
174
+ */const b_={name:"circle-exclamation-point",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],aliases:["alert-circle","circle-alert"]};b_.node;const Ld=ie(b_);/**
175
+ * @license lucide-react v1.75.0 - ISC
176
+ *
177
+ * This source code is licensed under the ISC license.
178
+ * See the LICENSE file in the root directory of this source tree.
179
+ */const S_={name:"circle",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]};S_.node;const iD=ie(S_);/**
180
+ * @license lucide-react v1.75.0 - ISC
181
+ *
182
+ * This source code is licensed under the ISC license.
183
+ * See the LICENSE file in the root directory of this source tree.
184
+ */const C_={name:"clipboard-copy",size:24,node:[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]};C_.node;const N_=ie(C_);/**
185
+ * @license lucide-react v1.75.0 - ISC
186
+ *
187
+ * This source code is licensed under the ISC license.
188
+ * See the LICENSE file in the root directory of this source tree.
189
+ */const E_={name:"clipboard-paste",size:24,node:[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]]};E_.node;const __=ie(E_);/**
190
+ * @license lucide-react v1.75.0 - ISC
191
+ *
192
+ * This source code is licensed under the ISC license.
193
+ * See the LICENSE file in the root directory of this source tree.
194
+ */const j_={name:"code",size:24,node:[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]};j_.node;const oD=ie(j_);/**
195
+ * @license lucide-react v1.75.0 - ISC
196
+ *
197
+ * This source code is licensed under the ISC license.
198
+ * See the LICENSE file in the root directory of this source tree.
199
+ */const $_={name:"compass",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]]};$_.node;const v1=ie($_);/**
200
+ * @license lucide-react v1.75.0 - ISC
201
+ *
202
+ * This source code is licensed under the ISC license.
203
+ * See the LICENSE file in the root directory of this source tree.
204
+ */const M_={name:"copy",size:24,node:[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]};M_.node;const ca=ie(M_);/**
205
+ * @license lucide-react v1.75.0 - ISC
206
+ *
207
+ * This source code is licensed under the ISC license.
208
+ * See the LICENSE file in the root directory of this source tree.
209
+ */const T_={name:"crosshair",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]};T_.node;const O_=ie(T_);/**
210
+ * @license lucide-react v1.75.0 - ISC
211
+ *
212
+ * This source code is licensed under the ISC license.
213
+ * See the LICENSE file in the root directory of this source tree.
214
+ */const A_={name:"database-zap",size:24,node:[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 15 21.84",key:"14ibmq"}],["path",{d:"M21 5V8",key:"1marbg"}],["path",{d:"M21 12L18 17H22L19 22",key:"zafso"}],["path",{d:"M3 12A9 3 0 0 0 14.59 14.87",key:"1y4wr8"}]]};A_.node;const aD=ie(A_);/**
215
+ * @license lucide-react v1.75.0 - ISC
216
+ *
217
+ * This source code is licensed under the ISC license.
218
+ * See the LICENSE file in the root directory of this source tree.
219
+ */const R_={name:"database",size:24,node:[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]};R_.node;const lD=ie(R_);/**
220
+ * @license lucide-react v1.75.0 - ISC
221
+ *
222
+ * This source code is licensed under the ISC license.
223
+ * See the LICENSE file in the root directory of this source tree.
224
+ */const I_={name:"download",size:24,node:[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]};I_.node;const cD=ie(I_);/**
225
+ * @license lucide-react v1.75.0 - ISC
226
+ *
227
+ * This source code is licensed under the ISC license.
228
+ * See the LICENSE file in the root directory of this source tree.
229
+ */const P_={name:"file-code-corner",size:24,node:[["path",{d:"M4 12.15V4a2 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 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],aliases:["file-code-2"]};P_.node;const Mp=ie(P_);/**
230
+ * @license lucide-react v1.75.0 - ISC
231
+ *
232
+ * This source code is licensed under the ISC license.
233
+ * See the LICENSE file in the root directory of this source tree.
234
+ */const D_={name:"file-input",size:24,node:[["path",{d:"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",key:"1q9hii"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M2 15h10",key:"jfw4w8"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]};D_.node;const k1=ie(D_);/**
235
+ * @license lucide-react v1.75.0 - ISC
236
+ *
237
+ * This source code is licensed under the ISC license.
238
+ * See the LICENSE file in the root directory of this source tree.
239
+ */const z_={name:"file-text",size:24,node:[["path",{d:"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",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]};z_.node;const Qy=ie(z_);/**
240
+ * @license lucide-react v1.75.0 - ISC
241
+ *
242
+ * This source code is licensed under the ISC license.
243
+ * See the LICENSE file in the root directory of this source tree.
244
+ */const L_={name:"file-up",size:24,node:[["path",{d:"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",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"m15 15-3-3-3 3",key:"15xj92"}]]};L_.node;const Rw=ie(L_);/**
245
+ * @license lucide-react v1.75.0 - ISC
246
+ *
247
+ * This source code is licensed under the ISC license.
248
+ * See the LICENSE file in the root directory of this source tree.
249
+ */const F_={name:"folder-git-2",size:24,node:[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 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.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]};F_.node;const w1=ie(F_);/**
250
+ * @license lucide-react v1.75.0 - ISC
251
+ *
252
+ * This source code is licensed under the ISC license.
253
+ * See the LICENSE file in the root directory of this source tree.
254
+ */const B_={name:"folder",size:24,node:[["path",{d:"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",key:"1kt360"}]]};B_.node;const V_=ie(B_);/**
255
+ * @license lucide-react v1.75.0 - ISC
256
+ *
257
+ * This source code is licensed under the ISC license.
258
+ * See the LICENSE file in the root directory of this source tree.
259
+ */const W_={name:"git-branch",size:24,node:[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]]};W_.node;const dD=ie(W_);/**
260
+ * @license lucide-react v1.75.0 - ISC
261
+ *
262
+ * This source code is licensed under the ISC license.
263
+ * See the LICENSE file in the root directory of this source tree.
264
+ */const U_={name:"git-merge",size:24,node:[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]};U_.node;const uD=ie(U_);/**
265
+ * @license lucide-react v1.75.0 - ISC
266
+ *
267
+ * This source code is licensed under the ISC license.
268
+ * See the LICENSE file in the root directory of this source tree.
269
+ */const Z_={name:"hash",size:24,node:[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]};Z_.node;const fD=ie(Z_);/**
270
+ * @license lucide-react v1.75.0 - ISC
271
+ *
272
+ * This source code is licensed under the ISC license.
273
+ * See the LICENSE file in the root directory of this source tree.
274
+ */const H_={name:"house",size:24,node:[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],aliases:["home"]};H_.node;const hD=ie(H_);/**
275
+ * @license lucide-react v1.75.0 - ISC
276
+ *
277
+ * This source code is licensed under the ISC license.
278
+ * See the LICENSE file in the root directory of this source tree.
279
+ */const q_={name:"info",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]};q_.node;const pD=ie(q_);/**
280
+ * @license lucide-react v1.75.0 - ISC
281
+ *
282
+ * This source code is licensed under the ISC license.
283
+ * See the LICENSE file in the root directory of this source tree.
284
+ */const K_={name:"italic",size:24,node:[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]]};K_.node;const mD=ie(K_);/**
285
+ * @license lucide-react v1.75.0 - ISC
286
+ *
287
+ * This source code is licensed under the ISC license.
288
+ * See the LICENSE file in the root directory of this source tree.
289
+ */const J_={name:"key",size:24,node:[["path",{d:"m2 21 9.6-9.6",key:"9l79m3"}],["path",{d:"m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19",key:"fw8biw"}],["circle",{cx:"15.5",cy:"7.5",r:"5.5",key:"4wxmhb"}]]};J_.node;const gD=ie(J_);/**
290
+ * @license lucide-react v1.75.0 - ISC
291
+ *
292
+ * This source code is licensed under the ISC license.
293
+ * See the LICENSE file in the root directory of this source tree.
294
+ */const G_={name:"keyboard",size:24,node:[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]};G_.node;const Y_=ie(G_);/**
295
+ * @license lucide-react v1.75.0 - ISC
296
+ *
297
+ * This source code is licensed under the ISC license.
298
+ * See the LICENSE file in the root directory of this source tree.
299
+ */const Q_={name:"layout-grid",size:24,node:[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]};Q_.node;const Ao=ie(Q_);/**
300
+ * @license lucide-react v1.75.0 - ISC
301
+ *
302
+ * This source code is licensed under the ISC license.
303
+ * See the LICENSE file in the root directory of this source tree.
304
+ */const X_={name:"letter-b",size:24,node:[["path",{d:"M6 12h9a4 4 0 010 8H7a1 1 0 01-1-1V5a1 1 0 011-1h7a4 4 0 010 8",key:"n8tvfh"}]],aliases:["bold"]};X_.node;const yD=ie(X_);/**
305
+ * @license lucide-react v1.75.0 - ISC
306
+ *
307
+ * This source code is licensed under the ISC license.
308
+ * See the LICENSE file in the root directory of this source tree.
309
+ */const ej={name:"lightbulb",size:24,node:[["path",{d:"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",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]};ej.node;const Um=ie(ej);/**
310
+ * @license lucide-react v1.75.0 - ISC
311
+ *
312
+ * This source code is licensed under the ISC license.
313
+ * See the LICENSE file in the root directory of this source tree.
314
+ */const tj={name:"link-2",size:24,node:[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]};tj.node;const Ec=ie(tj);/**
315
+ * @license lucide-react v1.75.0 - ISC
316
+ *
317
+ * This source code is licensed under the ISC license.
318
+ * See the LICENSE file in the root directory of this source tree.
319
+ */const nj={name:"link",size:24,node:[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]};nj.node;const xD=ie(nj);/**
320
+ * @license lucide-react v1.75.0 - ISC
321
+ *
322
+ * This source code is licensed under the ISC license.
323
+ * See the LICENSE file in the root directory of this source tree.
324
+ */const rj={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],aliases:["loader-2"]};rj.node;const Ro=ie(rj);/**
325
+ * @license lucide-react v1.75.0 - ISC
326
+ *
327
+ * This source code is licensed under the ISC license.
328
+ * See the LICENSE file in the root directory of this source tree.
329
+ */const sj={name:"maximize-2",size:24,node:[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]};sj.node;const vD=ie(sj);/**
330
+ * @license lucide-react v1.75.0 - ISC
331
+ *
332
+ * This source code is licensed under the ISC license.
333
+ * See the LICENSE file in the root directory of this source tree.
334
+ */const ij={name:"maximize",size:24,node:[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]};ij.node;const oj=ie(ij);/**
335
+ * @license lucide-react v1.75.0 - ISC
336
+ *
337
+ * This source code is licensed under the ISC license.
338
+ * See the LICENSE file in the root directory of this source tree.
339
+ */const aj={name:"message-circle-plus",size:24,node:[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]};aj.node;const kD=ie(aj);/**
340
+ * @license lucide-react v1.75.0 - ISC
341
+ *
342
+ * This source code is licensed under the ISC license.
343
+ * See the LICENSE file in the root directory of this source tree.
344
+ */const lj={name:"message-circle-question-mark",size:24,node:[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9 9.5a3 2.5 0 016 0c0 2-2 2-3 3.5",key:"1awbb0"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aliases:["message-circle-question"]};lj.node;const cj=ie(lj);/**
345
+ * @license lucide-react v1.75.0 - ISC
346
+ *
347
+ * This source code is licensed under the ISC license.
348
+ * See the LICENSE file in the root directory of this source tree.
349
+ */const dj={name:"message-circle",size:24,node:[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]]};dj.node;const co=ie(dj);/**
350
+ * @license lucide-react v1.75.0 - ISC
351
+ *
352
+ * This source code is licensed under the ISC license.
353
+ * See the LICENSE file in the root directory of this source tree.
354
+ */const uj={name:"message-square-text",size:24,node:[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]};uj.node;const wD=ie(uj);/**
355
+ * @license lucide-react v1.75.0 - ISC
356
+ *
357
+ * This source code is licensed under the ISC license.
358
+ * See the LICENSE file in the root directory of this source tree.
359
+ */const fj={name:"minus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}]]};fj.node;const hj=ie(fj);/**
360
+ * @license lucide-react v1.75.0 - ISC
361
+ *
362
+ * This source code is licensed under the ISC license.
363
+ * See the LICENSE file in the root directory of this source tree.
364
+ */const pj={name:"moon",size:24,node:[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]};pj.node;const b1=ie(pj);/**
365
+ * @license lucide-react v1.75.0 - ISC
366
+ *
367
+ * This source code is licensed under the ISC license.
368
+ * See the LICENSE file in the root directory of this source tree.
369
+ */const mj={name:"panel-left",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],aliases:["sidebar"]};mj.node;const gj=ie(mj);/**
370
+ * @license lucide-react v1.75.0 - ISC
371
+ *
372
+ * This source code is licensed under the ISC license.
373
+ * See the LICENSE file in the root directory of this source tree.
374
+ */const yj={name:"panel-right",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]};yj.node;const bD=ie(yj);/**
375
+ * @license lucide-react v1.75.0 - ISC
376
+ *
377
+ * This source code is licensed under the ISC license.
378
+ * See the LICENSE file in the root directory of this source tree.
379
+ */const xj={name:"pause",size:24,node:[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]]};xj.node;const SD=ie(xj);/**
380
+ * @license lucide-react v1.75.0 - ISC
381
+ *
382
+ * This source code is licensed under the ISC license.
383
+ * See the LICENSE file in the root directory of this source tree.
384
+ */const vj={name:"pencil",size:24,node:[["path",{d:"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",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]};vj.node;const CD=ie(vj);/**
385
+ * @license lucide-react v1.75.0 - ISC
386
+ *
387
+ * This source code is licensed under the ISC license.
388
+ * See the LICENSE file in the root directory of this source tree.
389
+ */const kj={name:"phone-call",size:24,node:[["path",{d:"M13 2a9 9 0 0 1 9 9",key:"1itnx2"}],["path",{d:"M13 6a5 5 0 0 1 5 5",key:"11nki7"}],["path",{d:"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384",key:"9njp5v"}]]};kj.node;const ND=ie(kj);/**
390
+ * @license lucide-react v1.75.0 - ISC
391
+ *
392
+ * This source code is licensed under the ISC license.
393
+ * See the LICENSE file in the root directory of this source tree.
394
+ */const wj={name:"play",size:24,node:[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]};wj.node;const ED=ie(wj);/**
395
+ * @license lucide-react v1.75.0 - ISC
396
+ *
397
+ * This source code is licensed under the ISC license.
398
+ * See the LICENSE file in the root directory of this source tree.
399
+ */const bj={name:"plug",size:24,node:[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]]};bj.node;const Tp=ie(bj);/**
400
+ * @license lucide-react v1.75.0 - ISC
401
+ *
402
+ * This source code is licensed under the ISC license.
403
+ * See the LICENSE file in the root directory of this source tree.
404
+ */const Sj={name:"plus",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]};Sj.node;const S1=ie(Sj);/**
405
+ * @license lucide-react v1.75.0 - ISC
406
+ *
407
+ * This source code is licensed under the ISC license.
408
+ * See the LICENSE file in the root directory of this source tree.
409
+ */const Cj={name:"puzzle",size:24,node:[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]};Cj.node;const Nj=ie(Cj);/**
410
+ * @license lucide-react v1.75.0 - ISC
411
+ *
412
+ * This source code is licensed under the ISC license.
413
+ * See the LICENSE file in the root directory of this source tree.
414
+ */const Ej={name:"redo-2",size:24,node:[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]};Ej.node;const _D=ie(Ej);/**
415
+ * @license lucide-react v1.75.0 - ISC
416
+ *
417
+ * This source code is licensed under the ISC license.
418
+ * See the LICENSE file in the root directory of this source tree.
419
+ */const _j={name:"rotate-cw",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]};_j.node;const jD=ie(_j);/**
420
+ * @license lucide-react v1.75.0 - ISC
421
+ *
422
+ * This source code is licensed under the ISC license.
423
+ * See the LICENSE file in the root directory of this source tree.
424
+ */const jj={name:"scan",size:24,node:[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]};jj.node;const $j=ie(jj);/**
425
+ * @license lucide-react v1.75.0 - ISC
426
+ *
427
+ * This source code is licensed under the ISC license.
428
+ * See the LICENSE file in the root directory of this source tree.
429
+ */const Mj={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};Mj.node;const Xy=ie(Mj);/**
430
+ * @license lucide-react v1.75.0 - ISC
431
+ *
432
+ * This source code is licensed under the ISC license.
433
+ * See the LICENSE file in the root directory of this source tree.
434
+ */const Tj={name:"settings",size:24,node:[["path",{d:"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",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]};Tj.node;const $D=ie(Tj);/**
435
+ * @license lucide-react v1.75.0 - ISC
436
+ *
437
+ * This source code is licensed under the ISC license.
438
+ * See the LICENSE file in the root directory of this source tree.
439
+ */const Oj={name:"share-2",size:24,node:[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]};Oj.node;const MD=ie(Oj);/**
440
+ * @license lucide-react v1.75.0 - ISC
441
+ *
442
+ * This source code is licensed under the ISC license.
443
+ * See the LICENSE file in the root directory of this source tree.
444
+ */const Aj={name:"share",size:24,node:[["path",{d:"M12 2v13",key:"1km8f5"}],["path",{d:"m16 6-4-4-4 4",key:"13yo43"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}]]};Aj.node;const TD=ie(Aj);/**
445
+ * @license lucide-react v1.75.0 - ISC
446
+ *
447
+ * This source code is licensed under the ISC license.
448
+ * See the LICENSE file in the root directory of this source tree.
449
+ */const Rj={name:"square",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]};Rj.node;const Ij=ie(Rj);/**
450
+ * @license lucide-react v1.75.0 - ISC
451
+ *
452
+ * This source code is licensed under the ISC license.
453
+ * See the LICENSE file in the root directory of this source tree.
454
+ */const Pj={name:"star",size:24,node:[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]};Pj.node;const Dj=ie(Pj);/**
455
+ * @license lucide-react v1.75.0 - ISC
456
+ *
457
+ * This source code is licensed under the ISC license.
458
+ * See the LICENSE file in the root directory of this source tree.
459
+ */const zj={name:"sun",size:24,node:[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]};zj.node;const Lj=ie(zj);/**
460
+ * @license lucide-react v1.75.0 - ISC
461
+ *
462
+ * This source code is licensed under the ISC license.
463
+ * See the LICENSE file in the root directory of this source tree.
464
+ */const Fj={name:"table-2",size:24,node:[["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]};Fj.node;const Bj=ie(Fj);/**
465
+ * @license lucide-react v1.75.0 - ISC
466
+ *
467
+ * This source code is licensed under the ISC license.
468
+ * See the LICENSE file in the root directory of this source tree.
469
+ */const Vj={name:"trash",size:24,node:[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],aliases:["trash-2"]};Vj.node;const OD=ie(Vj);/**
470
+ * @license lucide-react v1.75.0 - ISC
471
+ *
472
+ * This source code is licensed under the ISC license.
473
+ * See the LICENSE file in the root directory of this source tree.
474
+ */const Wj={name:"triangle-exclamation-point",size:24,node:[["path",{d:"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",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],aliases:["alert-triangle","triangle-alert"]};Wj.node;const AD=ie(Wj);/**
475
+ * @license lucide-react v1.75.0 - ISC
476
+ *
477
+ * This source code is licensed under the ISC license.
478
+ * See the LICENSE file in the root directory of this source tree.
479
+ */const Uj={name:"undo-2",size:24,node:[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]};Uj.node;const RD=ie(Uj);/**
480
+ * @license lucide-react v1.75.0 - ISC
481
+ *
482
+ * This source code is licensed under the ISC license.
483
+ * See the LICENSE file in the root directory of this source tree.
484
+ */const Zj={name:"upload",size:24,node:[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]};Zj.node;const ID=ie(Zj);/**
485
+ * @license lucide-react v1.75.0 - ISC
486
+ *
487
+ * This source code is licensed under the ISC license.
488
+ * See the LICENSE file in the root directory of this source tree.
489
+ */const Hj={name:"users",size:24,node:[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]};Hj.node;const PD=ie(Hj);/**
490
+ * @license lucide-react v1.75.0 - ISC
491
+ *
492
+ * This source code is licensed under the ISC license.
493
+ * See the LICENSE file in the root directory of this source tree.
494
+ */const qj={name:"workflow",size:24,node:[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]};qj.node;const Fd=ie(qj);/**
495
+ * @license lucide-react v1.75.0 - ISC
496
+ *
497
+ * This source code is licensed under the ISC license.
498
+ * See the LICENSE file in the root directory of this source tree.
499
+ */const Kj={name:"wrench",size:24,node:[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]};Kj.node;const DD=ie(Kj);/**
500
+ * @license lucide-react v1.75.0 - ISC
501
+ *
502
+ * This source code is licensed under the ISC license.
503
+ * See the LICENSE file in the root directory of this source tree.
504
+ */const Jj={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};Jj.node;const Jo=ie(Jj);/**
505
+ * @license lucide-react v1.75.0 - ISC
506
+ *
507
+ * This source code is licensed under the ISC license.
508
+ * See the LICENSE file in the root directory of this source tree.
509
+ */const Gj={name:"zap",size:24,node:[["path",{d:"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",key:"1v7up4"}]]};Gj.node;const zD=ie(Gj),ft=Symbol.for("poney.fragment");function LD(t,e,n=null){return{$$poney:!0,type:t,props:e,key:n}}const Yj=new WeakMap;function Op(t){const e=Symbol("poney.context"),n=r=>r.children;return Yj.set(n,e),{id:e,fallback:t,Provider:n}}let th=null,rf=!1;function Ji(t){if(!rf)throw new Error("useContext is only for components while they draw");for(let e=th;e;e=e.parent)if(e.id===t.id)return e.value;return t.fallback}const hr=(t,e)=>t(),FD={get:()=>{},has:()=>!1,update:()=>{}},Qj=Op(FD);function Xj(t,e){const n=Ji(Qj);return[n.has(t)?n.get(t):e,i=>n.update(t,o=>typeof i=="function"?i(o===void 0?e:o):i)]}function BD(t){const e={current:th,resolving:rf};rf=!0;try{const n=[];return Aa(t,null,"",n),n}finally{th=e.current,rf=e.resolving}}function Aa(t,e,n,r){if(!Array.isArray(t))return Iw(t,e,n,"0",r);const s=t;for(let i=0;i<s.length;i++){const o=s[i];Array.isArray(o)?Aa(o,e,`${n}${i}.`,r):Iw(o,e,n,String(i),r)}}function Iw(t,e,n,r,s){if(t==null||typeof t=="boolean")return;if(typeof t=="string")return void s.push(t);if(typeof t=="number"||typeof t=="bigint")return void s.push(String(t));const i=t,o=i.key===null?`${n}${r}`:`${n}=${i.key}`,{type:a}=i;if(a===ft)return Aa(i.props.children,e,`${o}/`,s);if(typeof a=="function"){const u=Yj.get(a);if(u)return Aa(i.props.children,{parent:e,id:u,value:i.props.value},`${o}/`,s);th=e;const h=a(i.props);return Aa(h,e,`${o}/`,s)}const{children:l,...c}=i.props,d={tag:a,props:c,key:o,children:[]};Aa(l,e,"",d.children),s.push(d)}function N(t,e,n){return LD(t,e,n??null)}const Z=N,e$=Op({marks:new Map,mode:"after",focus:null,callouts:new Map,hot:null,setHot:()=>{}}),t$=({value:t,children:e})=>N(e$.Provider,{value:t,children:e}),gr=()=>Ji(e$);function Vs(t){return n$(gr(),t)}function Ml(t){var r,s;const e=gr(),n=t.map(i=>n$(e,i));return{state:(r=n.find(i=>i.state))==null?void 0:r.state,hidden:n.every(i=>i.hidden),dim:n.every(i=>i.dim),hot:n.some(i=>i.hot),focused:n.some(i=>i.focused),callout:(s=n.find(i=>i.callout))==null?void 0:s.callout}}function n$(t,e){const n=t.marks.get(e),r=t.mode==="before"&&n==="new"||t.mode==="after"&&n==="removed",s=!t.focus||t.focus.has(e);return{state:t.mode==="change"?n:void 0,hidden:r,dim:!s&&t.hot!==e,hot:t.hot===e,focused:s,callout:t.callouts.get(e)}}const Pr=t=>`poney-story-el ${t.hidden?"poney-story-hidden":t.dim?"poney-story-dim":""}`,Tl=(t,e="var(--poney-story-rule)")=>t?`var(--poney-${t})`:e,C1=(t,e="var(--poney-story-node)")=>t?`var(--poney-${t}-wash)`:e,N1={new:"New",changed:"Changed",removed:"Removed"};function Bd({state:t,x:e,y:n,anchor:r="start"}){if(!t)return null;const s=N1[t],i=Re(s,11,650)+14,o=r==="start"?e:r==="end"?e-i:e-i/2;return Z("g",{pointerEvents:"none",children:[N("rect",{x:o,y:n-9,width:i,height:18,rx:9,fill:`var(--poney-${t}-wash)`,stroke:`var(--poney-${t})`,strokeWidth:1}),N("text",{x:o+i/2,y:n+4,textAnchor:"middle",fontSize:11,fontWeight:650,fill:`var(--poney-${t})`,children:s})]})}function Ol({n:t,x:e,y:n,hot:r}){return Z("g",{pointerEvents:"none",className:"poney-story-el",children:[N("circle",{cx:e,cy:n,r:12,fill:r?"var(--poney-accent)":"var(--poney-ink)",stroke:"var(--poney-paper-raised)",strokeWidth:2.5}),N("text",{x:e,y:n+4.2,textAnchor:"middle",fontSize:12,fontWeight:700,fill:"var(--poney-paper-raised)",className:"poney-numbers",children:t})]})}function nh({x:t,y:e,angle:n,color:r,size:s=7}){const i=Math.cos(n),o=Math.sin(n),a=(l,c)=>`${t+l*i-c*o},${e+l*o+c*i}`;return N("polygon",{points:`${a(0,0)} ${a(-s*1.35,-s*.62)} ${a(-s*1.35,s*.62)}`,fill:r})}const Al=Op(null),VD=({value:t,children:e})=>N(Al.Provider,{value:t,children:e});function gn(){const t=Ji(Al);if(!t)throw new Error("Poney renderers need a RenderProvider with the model index");return t.idx}const WD=(t,e)=>({"data-ref":fe(t),"aria-label":e});function jn(){var t;return((t=Ji(Al))==null?void 0:t.bind)??WD}function Ws(){const t=Ji(Al),e=(t==null?void 0:t.selection)??null,n=(t==null?void 0:t.hover)??null;return{subject:n??e,selection:e,hover:n}}function Ap(t){var a;const e=Ji(Al),[n,r]=Xj(`view:${t}`,{}),s=!!(e!=null&&e.setViewState);return[(s?(a=e.viewState)==null?void 0:a.call(e,t):n)??{},l=>s?e.setViewState(t,l):r(c=>({...c,...l}))]}const r$=Op(1),UD=({value:t,children:e})=>N(r$.Provider,{value:t,children:e}),E1=()=>Ji(r$),ZD=()=>{var t;return!!((t=Ji(Al))!=null&&t.still)};function HD(t,e,n){const r={};if(e&&t.type==="state"&&(r.extraTransitions=e.removed.transitions.filter(s=>s.stateMachine===t.stateMachine).map(s=>s.transition)),e&&t.type==="map"&&(r.extraEntities=e.removed.entities,r.extraRelationships=e.removed.relationships),t.type==="sequence"){r.compact=!0;const s=n.map(un).flatMap(i=>(i==null?void 0:i.kind)==="message"&&i.behavior===t.interaction?[i.id]:[]);s.length&&(r.only=s)}return r}const ex=t=>t.map(un).flatMap(e=>e?[fe(e)]:[]);function _1(t,e,n){var s,i;const r=new Set(ex(t));for(const o of[...r]){const a=un(o);if(a){if(a.kind==="relationship"){const l=(e==null?void 0:e.relationships.get(a.id))??(n==null?void 0:n.removed.relationships.find(c=>c.id===a.id));if(l)for(const c of[l.source,l.target])r.add(`entity:${c}`)}if(a.kind==="transition"){const l=((s=e==null?void 0:e.stateMachine(a.behavior))==null?void 0:s.transitions.find(c=>c.id===a.id))??((i=n==null?void 0:n.removed.transitions.find(c=>c.stateMachine===a.behavior&&c.transition.id===a.id))==null?void 0:i.transition);if(l)for(const c of[l.from,l.to])r.add(`state:${a.behavior}:${c}`)}}}return[...r]}const qD=/^(entity|state|dataType|activityNode|useCase):/;function KD(t,e,n,r,s){const i=_1(n,r,s).map(l=>t.anchors[l]).filter(l=>!!l);if(!i.length||e.type==="sequence")return{x:0,y:0,w:t.width,h:t.height};let o=Ri(i);const a=24;for(let l=0;l<3;l++){const c={x:o.x-a,y:o.y-a,w:o.w+a*2,h:o.h+a*2},d=Object.entries(t.anchors).filter(([u])=>qD.test(u)).map(([,u])=>u).filter(u=>u.x<c.x+c.w&&u.x+u.w>c.x&&u.y<c.y+c.h&&u.y+u.h>c.y).filter(u=>u.x<c.x||u.y<c.y||u.x+u.w>c.x+c.w||u.y+u.h>c.y+c.h);if(!d.length)break;o=Ri([o,...d])}return o}function JD(t,e,n,r,s){const i={x:t.x-r,y:t.y-r,w:t.w+r*2,h:t.h+r*2};let o=Math.max(i.w,e/s),a=Math.max(i.h,n/s);const l=e/Math.max(n,1);return o/a<l?o=a*l:a=o/l,{x:i.x+i.w/2-o/2,y:i.y+i.h/2-a/2,w:o,h:a}}function GD(t,e,n,r=.5,s=.5){const i=Math.min(e.w*4,Math.max(e.w/6,t.w/n)),o=i*(t.h/t.w),a=t.x+r*t.w,l=t.y+s*t.h;return{x:a-r*i,y:l-s*o,w:i,h:o}}function YD(t,e,n,r,s){return{...t,x:t.x-e*t.w/Math.max(r,1),y:t.y-n*t.h/Math.max(s,1)}}function QD(t){var r,s;const e=_1(t.focus,t.idx,t.walkthrough),n=(i=[])=>{const o=new Map;for(const a of i){const l=un(a.target);l&&o.set(fe(l),[...o.get(fe(l))??[],a])}return o};return{marks:t.marks,mode:t.mode,focus:e.length&&t.view.type!=="sequence"?new Set(e):null,callouts:new Map(ex(t.callouts).map((i,o)=>[i,o+1])),hot:t.hot??null,setHot:t.setHot??(()=>{}),allLabels:((r=t.walkthrough)==null?void 0:r.kind)==="tour"&&e.length===0,effects:n(t.effects),badges:n(t.badges),trace:(s=t.trace)!=null&&s.length?{steps:ex(t.trace.map(i=>i.ref)),current:t.traceStep??null,animate:t.animate!==!1,numbered:!!t.numberSteps}:void 0}}function XD(t,e,n,r,s){var m;if(!n)return e;const i=un(n),o=_1([n],r,s);if((i==null?void 0:i.kind)==="message"){const g=(m=r.messages(i.behavior).find(p=>p.message.id===i.id))==null?void 0:m.message;g&&o.push(`entity:${g.from}`,`entity:${g.to}`)}const a=o.map(g=>t.anchors[g]).filter(g=>!!g);if(!a.length)return e;const l=Ri(a),c=Math.min(e.w,Math.max(l.w,620)),d=Math.min(e.h,Math.max(l.h,340)),u=Math.max(e.x+c/2,Math.min(e.x+e.w-c/2,l.x+l.w/2)),h=Math.max(e.y+d/2,Math.min(e.y+e.h-d/2,l.y+l.h/2));return{x:u-c/2,y:h-d/2,w:c,h:d}}/**
510
+ * @license lucide v1.75.0 - ISC
511
+ *
512
+ * This source code is licensed under the ISC license.
513
+ * See the LICENSE file in the root directory of this source tree.
514
+ */const ez=[["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}],["path",{d:"M10 4v4"}],["path",{d:"M2 8h20"}],["path",{d:"M6 4v4"}]];/**
515
+ * @license lucide v1.75.0 - ISC
516
+ *
517
+ * This source code is licensed under the ISC license.
518
+ * See the LICENSE file in the root directory of this source tree.
519
+ */const tz=[["path",{d:"M10 22V7a1 1 0 0 0-1-1H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-5a1 1 0 0 0-1-1H2"}],["rect",{x:"14",y:"2",width:"8",height:"8",rx:"1"}]];/**
520
+ * @license lucide v1.75.0 - ISC
521
+ *
522
+ * This source code is licensed under the ISC license.
523
+ * See the LICENSE file in the root directory of this source tree.
524
+ */const nz=[["path",{d:"M12 5v16"}],["path",{d:"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"}]];/**
525
+ * @license lucide v1.75.0 - ISC
526
+ *
527
+ * This source code is licensed under the ISC license.
528
+ * See the LICENSE file in the root directory of this source tree.
529
+ */const rz=[["path",{d:"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"}],["path",{d:"m3.3 7 8.7 5 8.7-5"}],["path",{d:"M12 22V12"}]];/**
530
+ * @license lucide v1.75.0 - ISC
531
+ *
532
+ * This source code is licensed under the ISC license.
533
+ * See the LICENSE file in the root directory of this source tree.
534
+ */const sz=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z"}],["path",{d:"m7 16.5-4.74-2.85"}],["path",{d:"m7 16.5 5-3"}],["path",{d:"M7 16.5v5.17"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z"}],["path",{d:"m17 16.5-5-3"}],["path",{d:"m17 16.5 4.74-2.85"}],["path",{d:"M17 16.5v5.17"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z"}],["path",{d:"M12 8 7.26 5.15"}],["path",{d:"m12 8 4.74-2.85"}],["path",{d:"M12 13.5V8"}]];/**
535
+ * @license lucide v1.75.0 - ISC
536
+ *
537
+ * This source code is licensed under the ISC license.
538
+ * See the LICENSE file in the root directory of this source tree.
539
+ */const iz=[["path",{d:"m7 20 5-5 5 5"}],["path",{d:"m7 4 5 5 5-5"}]];/**
540
+ * @license lucide v1.75.0 - ISC
541
+ *
542
+ * This source code is licensed under the ISC license.
543
+ * See the LICENSE file in the root directory of this source tree.
544
+ */const oz=[["path",{d:"m7 15 5 5 5-5"}],["path",{d:"m7 9 5-5 5 5"}]];/**
545
+ * @license lucide v1.75.0 - ISC
546
+ *
547
+ * This source code is licensed under the ISC license.
548
+ * See the LICENSE file in the root directory of this source tree.
549
+ */const az=[["circle",{cx:"12",cy:"12",r:"1"}],["circle",{cx:"12",cy:"12",r:"10"}]];/**
550
+ * @license lucide v1.75.0 - ISC
551
+ *
552
+ * This source code is licensed under the ISC license.
553
+ * See the LICENSE file in the root directory of this source tree.
554
+ */const lz=[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}],["path",{d:"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"}],["path",{d:"M12 11h4"}],["path",{d:"M12 16h4"}],["path",{d:"M8 11h.01"}],["path",{d:"M8 16h.01"}]];/**
555
+ * @license lucide v1.75.0 - ISC
556
+ *
557
+ * This source code is licensed under the ISC license.
558
+ * See the LICENSE file in the root directory of this source tree.
559
+ */const cz=[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10"}],["path",{d:"M6 14h2"}]];/**
560
+ * @license lucide v1.75.0 - ISC
561
+ *
562
+ * This source code is licensed under the ISC license.
563
+ * See the LICENSE file in the root directory of this source tree.
564
+ */const dz=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5"}],["path",{d:"M3 12A9 3 0 0 0 21 12"}]];/**
565
+ * @license lucide v1.75.0 - ISC
566
+ *
567
+ * This source code is licensed under the ISC license.
568
+ * See the LICENSE file in the root directory of this source tree.
569
+ */const uz=[["path",{d:"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"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5"}],["path",{d:"M10 9H8"}],["path",{d:"M16 13H8"}],["path",{d:"M16 17H8"}]];/**
570
+ * @license lucide v1.75.0 - ISC
571
+ *
572
+ * This source code is licensed under the ISC license.
573
+ * See the LICENSE file in the root directory of this source tree.
574
+ */const fz=[["path",{d:"M15 6a9 9 0 0 0-9 9V3"}],["circle",{cx:"18",cy:"6",r:"3"}],["circle",{cx:"6",cy:"18",r:"3"}]];/**
575
+ * @license lucide v1.75.0 - ISC
576
+ *
577
+ * This source code is licensed under the ISC license.
578
+ * See the LICENSE file in the root directory of this source tree.
579
+ */const hz=[["circle",{cx:"12",cy:"12",r:"10"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}],["path",{d:"M2 12h20"}]];/**
580
+ * @license lucide v1.75.0 - ISC
581
+ *
582
+ * This source code is licensed under the ISC license.
583
+ * See the LICENSE file in the root directory of this source tree.
584
+ */const pz=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor"}]];/**
585
+ * @license lucide v1.75.0 - ISC
586
+ *
587
+ * This source code is licensed under the ISC license.
588
+ * See the LICENSE file in the root directory of this source tree.
589
+ */const mz=[["path",{d:"M10 18v-7"}],["path",{d:"M11.119 2.205a2 2 0 0 1 1.762 0l7.84 3.846A.5.5 0 0 1 20.5 7h-17a.5.5 0 0 1-.22-.949z"}],["path",{d:"M14 18v-7"}],["path",{d:"M18 18v-7"}],["path",{d:"M3 22h18"}],["path",{d:"M6 18v-7"}]];/**
590
+ * @license lucide v1.75.0 - ISC
591
+ *
592
+ * This source code is licensed under the ISC license.
593
+ * See the LICENSE file in the root directory of this source tree.
594
+ */const gz=[["path",{d:"m16 6 4 14"}],["path",{d:"M12 6v14"}],["path",{d:"M8 8v12"}],["path",{d:"M4 4v16"}]];/**
595
+ * @license lucide v1.75.0 - ISC
596
+ *
597
+ * This source code is licensed under the ISC license.
598
+ * See the LICENSE file in the root directory of this source tree.
599
+ */const yz=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12"}]];/**
600
+ * @license lucide v1.75.0 - ISC
601
+ *
602
+ * This source code is licensed under the ISC license.
603
+ * See the LICENSE file in the root directory of this source tree.
604
+ */const xz=[["path",{d:"M11 5h10"}],["path",{d:"M11 12h10"}],["path",{d:"M11 19h10"}],["path",{d:"M4 4h1v5"}],["path",{d:"M4 9h2"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02"}]];/**
605
+ * @license lucide v1.75.0 - ISC
606
+ *
607
+ * This source code is licensed under the ISC license.
608
+ * See the LICENSE file in the root directory of this source tree.
609
+ */const vz=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}]];/**
610
+ * @license lucide v1.75.0 - ISC
611
+ *
612
+ * This source code is licensed under the ISC license.
613
+ * See the LICENSE file in the root directory of this source tree.
614
+ */const kz=[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z"}],["path",{d:"M15 5.764v15"}],["path",{d:"M9 3.236v15"}]];/**
615
+ * @license lucide v1.75.0 - ISC
616
+ *
617
+ * This source code is licensed under the ISC license.
618
+ * See the LICENSE file in the root directory of this source tree.
619
+ */const wz=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3"}],["path",{d:"M12 12V8"}]];/**
620
+ * @license lucide v1.75.0 - ISC
621
+ *
622
+ * This source code is licensed under the ISC license.
623
+ * See the LICENSE file in the root directory of this source tree.
624
+ */const bz=[["path",{d:"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"}],["path",{d:"M12 22V12"}],["polyline",{points:"3.29 7 12 12 20.71 7"}],["path",{d:"m7.5 4.27 9 5.15"}]];/**
625
+ * @license lucide v1.75.0 - ISC
626
+ *
627
+ * This source code is licensed under the ISC license.
628
+ * See the LICENSE file in the root directory of this source tree.
629
+ */const Sz=[["path",{d:"M12 22v-5"}],["path",{d:"M15 8V2"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z"}],["path",{d:"M9 8V2"}]];/**
630
+ * @license lucide v1.75.0 - ISC
631
+ *
632
+ * This source code is licensed under the ISC license.
633
+ * See the LICENSE file in the root directory of this source tree.
634
+ */const Cz=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478"}],["circle",{cx:"12",cy:"12",r:"2"}]];/**
635
+ * @license lucide v1.75.0 - ISC
636
+ *
637
+ * This source code is licensed under the ISC license.
638
+ * See the LICENSE file in the root directory of this source tree.
639
+ */const Nz=[["path",{d:"M12 17V7"}],["path",{d:"M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8"}],["path",{d:"M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z"}]];/**
640
+ * @license lucide v1.75.0 - ISC
641
+ *
642
+ * This source code is licensed under the ISC license.
643
+ * See the LICENSE file in the root directory of this source tree.
644
+ */const Ez=[["path",{d:"M9 5h8.5a1 1 0 010 7h-11a1 1 0 000 7H15"}],["circle",{cx:"18",cy:"19",r:"3"}],["circle",{cx:"6",cy:"5",r:"3"}]];/**
645
+ * @license lucide v1.75.0 - ISC
646
+ *
647
+ * This source code is licensed under the ISC license.
648
+ * See the LICENSE file in the root directory of this source tree.
649
+ */const _z=[["path",{d:"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"}],["path",{d:"m21.854 2.147-10.94 10.939"}]];/**
650
+ * @license lucide v1.75.0 - ISC
651
+ *
652
+ * This source code is licensed under the ISC license.
653
+ * See the LICENSE file in the root directory of this source tree.
654
+ */const jz=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18"}]];/**
655
+ * @license lucide v1.75.0 - ISC
656
+ *
657
+ * This source code is licensed under the ISC license.
658
+ * See the LICENSE file in the root directory of this source tree.
659
+ */const $z=[["path",{d:"m2.05 2.05 1.099-.028a1 1 0 0 1 1.008.815l2.69 14.347A1 1 0 0 0 7.83 18H18"}],["path",{d:"M4.563 5h16.435a1 1 0 0 1 .981 1.204l-1.026 6.226A2 2 0 0 1 18.962 14H6.25"}],["circle",{cx:"18",cy:"20",r:"2"}],["circle",{cx:"8",cy:"20",r:"2"}]];/**
660
+ * @license lucide v1.75.0 - ISC
661
+ *
662
+ * This source code is licensed under the ISC license.
663
+ * See the LICENSE file in the root directory of this source tree.
664
+ */const Mz=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05"}]];/**
665
+ * @license lucide v1.75.0 - ISC
666
+ *
667
+ * This source code is licensed under the ISC license.
668
+ * See the LICENSE file in the root directory of this source tree.
669
+ */const Tz=[["path",{d:"M3 9h18"}],["path",{d:"M9 3v18"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}]];/**
670
+ * @license lucide v1.75.0 - ISC
671
+ *
672
+ * This source code is licensed under the ISC license.
673
+ * See the LICENSE file in the root directory of this source tree.
674
+ */const Oz=[["line",{x1:"10",x2:"14",y1:"2",y2:"2"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11"}],["circle",{cx:"12",cy:"14",r:"8"}]];/**
675
+ * @license lucide v1.75.0 - ISC
676
+ *
677
+ * This source code is licensed under the ISC license.
678
+ * See the LICENSE file in the root directory of this source tree.
679
+ */const Az=[["path",{d:"M10 15H6a4 4 0 0 0-4 4v2"}],["path",{d:"m14.305 16.53.923-.382"}],["path",{d:"m15.228 13.852-.923-.383"}],["path",{d:"m16.852 12.228-.383-.923"}],["path",{d:"m16.852 17.772-.383.924"}],["path",{d:"m19.148 12.228.383-.923"}],["path",{d:"m19.53 18.696-.382-.924"}],["path",{d:"m20.772 13.852.924-.383"}],["path",{d:"m20.772 16.148.924.383"}],["circle",{cx:"18",cy:"15",r:"3"}],["circle",{cx:"9",cy:"7",r:"4"}]];/**
680
+ * @license lucide v1.75.0 - ISC
681
+ *
682
+ * This source code is licensed under the ISC license.
683
+ * See the LICENSE file in the root directory of this source tree.
684
+ */const Rz=[["circle",{cx:"12",cy:"8",r:"5"}],["path",{d:"M20 21a8 8 0 0 0-16 0"}]];/**
685
+ * @license lucide v1.75.0 - ISC
686
+ *
687
+ * This source code is licensed under the ISC license.
688
+ * See the LICENSE file in the root directory of this source tree.
689
+ */const Iz=[["path",{d:"M18 21a8 8 0 0 0-16 0"}],["circle",{cx:"10",cy:"8",r:"5"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3"}]];/**
690
+ * @license lucide v1.75.0 - ISC
691
+ *
692
+ * This source code is licensed under the ISC license.
693
+ * See the LICENSE file in the root directory of this source tree.
694
+ */const Pz=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}],["circle",{cx:"9",cy:"7",r:"4"}]];/**
695
+ * @license lucide v1.75.0 - ISC
696
+ *
697
+ * This source code is licensed under the ISC license.
698
+ * See the LICENSE file in the root directory of this source tree.
699
+ */const Dz=[["path",{d:"m10.586 5.414-5.172 5.172"}],["path",{d:"m18.586 13.414-5.172 5.172"}],["path",{d:"M6 12h12"}],["circle",{cx:"12",cy:"20",r:"2"}],["circle",{cx:"12",cy:"4",r:"2"}],["circle",{cx:"20",cy:"12",r:"2"}],["circle",{cx:"4",cy:"12",r:"2"}]];/**
700
+ * @license lucide v1.75.0 - ISC
701
+ *
702
+ * This source code is licensed under the ISC license.
703
+ * See the LICENSE file in the root directory of this source tree.
704
+ */const zz=[["path",{d:"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"}]],De=(t,e)=>({name:t,node:e}),St={blocks:De("blocks",tz),chevronsDownUp:De("chevrons-down-up",iz),chevronsUpDown:De("chevrons-up-down",oz),circleDot:De("circle-dot",az),gitBranch:De("git-branch",fz),keyRound:De("key-round",pz),link2:De("link-2",yz),listOrdered:De("list-ordered",xz),map:De("map",kz),network:De("network",wz),table2:De("table-2",Tz),users:De("users",Pz),usersRound:De("users-round",Iz),waypoints:De("waypoints",Dz)},Pw={"app-window":De("app-window",ez),"book-open":De("book-open",nz),box:De("box",rz),boxes:De("boxes",sz),"clipboard-list":De("clipboard-list",lz),"credit-card":De("credit-card",cz),database:De("database",dz),"file-text":De("file-text",uz),globe:De("globe",hz),"key-round":St.keyRound,landmark:De("landmark",mz),library:De("library",gz),mail:De("mail",vz),package:De("package",bz),plug:De("plug",Sz),radio:De("radio",Cz),receipt:De("receipt",Nz),route:De("route",Ez),send:De("send",_z),server:De("server",jz),"shopping-cart":De("shopping-cart",$z),store:De("store",Mz),table:St.table2,timer:De("timer",Oz),"user-cog":De("user-cog",Az),"user-round":De("user-round",Rz),users:St.users,waypoints:St.waypoints,zap:De("zap",zz)};function s$(t){return Pw[t]??Pw.box}const Lz=t=>Object.keys(t).some(e=>(e.startsWith("aria-")||e==="role"||e==="title")&&t[e]!=null);function bi({icon:t,size:e,width:n,height:r,color:s="currentColor",strokeWidth:i=2,className:o,...a}){return N("svg",{xmlns:"http://www.w3.org/2000/svg",width:n??e??24,height:r??e??24,viewBox:"0 0 24 24",fill:"none",stroke:s,strokeWidth:i,strokeLinecap:"round",strokeLinejoin:"round",className:["lucide",`lucide-${t.name}`,...o?o.split(/\s+/):[]].filter(Boolean).join(" "),...Lz(a)?{}:{"aria-hidden":"true"},...a,children:t.node.map(([l,c])=>N(l,{...c}))})}function pr({name:t,x:e,y:n,size:r=16,color:s="currentColor",strokeWidth:i=1.75}){return N(bi,{icon:s$(t),x:e,y:n,width:r,height:r,color:s,strokeWidth:i,"aria-hidden":!0})}const pt=t=>t.startsWith("#")?t:`var(--poney-${t})`,kn=(t,e=10)=>`color-mix(in srgb, ${pt(t)} ${e}%, var(--poney-paper-raised))`;function j1({scene:t,extra:e=[]}){const n=gn(),r=new Map(e.map(i=>[i.id,i])),s=i=>n.entities.get(i)??r.get(i);return Z("g",{children:[(t.groups??[]).map(i=>{const o=s(i.entityId);return o?N(Vz,{group:i,entity:o},i.entityId):null}),t.edges.map(i=>N(Wz,{edge:i},Zm(i))),t.nodes.map(i=>{const o=s(i.entityId);return o?N(Bz,{node:i,entity:o},i.entityId):null}),t.edges.map(i=>N(Uz,{edge:i},`l-${Zm(i)}`)),[...t.groups??[],...t.nodes].map(i=>N(Zz,{node:i},`c-${i.entityId}`)),t.edges.map(i=>N(Hz,{edge:i},`ec-${Zm(i)}`)),t.nodes.filter(i=>{var o;return(o=i.members)==null?void 0:o.length}).map(i=>N(Fz,{node:i,names:i.members.map(o=>{var a;return((a=s(o))==null?void 0:a.name)??o})},`p-${i.entityId}`))]})}function Fz({node:t,names:e}){const{hot:n}=gr();if(n!==`entity:${t.entityId}`)return null;const r=e.slice(0,6),s=e.length-r.length,i=[...r,...s>0?[`and ${s} more`]:[]],o=Math.max(t.w,Math.max(...i.map(d=>Re(d,12.5,500)))+40),a=i.length*22+38,l=t.x+t.w/2-o/2,c=t.y+t.h+12;return Z("g",{pointerEvents:"none",transform:`translate(${l} ${c})`,children:[N("rect",{width:o,height:a,rx:12,fill:"var(--poney-paper-raised)",stroke:"var(--poney-story-rule)"}),N("text",{x:16,y:22,fontSize:11.5,fontWeight:600,fill:"var(--poney-ink-3)",children:"Inside"}),i.map((d,u)=>N("text",{x:16,y:44+u*22,fontSize:12.5,fontWeight:u<r.length?500:400,fill:u<r.length?"var(--poney-ink)":"var(--poney-ink-3)",children:d},u))]})}function Bz({node:t,entity:e}){const n=gn(),r=jn(),s=`entity:${e.id}`,i=t.members??[],o=Ml([s,...i.map(v=>`entity:${v}`)]),a=n.style(e),{setHot:l,toggleGroup:c}=gr(),{x:d,y:u,w:h,h:m}=t,g=o.hot?"var(--poney-accent)":Tl(o.state,o.focused?"var(--poney-story-line)":"var(--poney-story-rule)"),p=o.state==="removed",x=i.length?`${i.length} inside${e.technology?` · ${e.technology}`:""}`:e.technology??a.label,y=r({kind:"entity",id:e.id},`${e.name}. ${e.summary}`);return Z("g",{transform:`translate(${d} ${u})`,...y,className:`poney-el ${Pr(o)}`,onMouseEnter:()=>{var v;(v=y.onMouseEnter)==null||v.call(y),l(s)},onMouseLeave:()=>{var v;(v=y.onMouseLeave)==null||v.call(y),l(null)},children:[i.length>0&&N("rect",{x:5,y:5,width:h,height:m,rx:14,fill:"var(--poney-story-node)",stroke:"var(--poney-story-rule)",strokeWidth:1.2}),N("rect",{width:h,height:m,rx:14,fill:C1(o.state),stroke:g,strokeWidth:o.state||o.hot?1.75:1.2,strokeDasharray:p||e.kind==="external"?"6 4":void 0}),i.length>0&&c&&N(i$,{open:!1,name:e.name,x:h-22,y:m/2,onToggle:()=>c(e.id)}),N(pr,{name:a.icon,x:18,y:m/2-9,size:18,color:o.state?`var(--poney-${o.state})`:pt(a.tone)}),N("text",{x:48,y:m/2-2,fontSize:15,fontWeight:600,fill:"var(--poney-ink)",textDecoration:p?"line-through":void 0,children:Ot(e.name,h-(i.length&&c?92:60),15,600)}),N("text",{x:48,y:m/2+17,fontSize:12.5,fill:"var(--poney-ink-3)",children:Ot(x,h-(i.length&&c?92:60),12.5)}),N(Bd,{state:o.state,x:h-12,y:0,anchor:"end"}),N("rect",{className:"poney-focus",x:-5,y:-5,width:h+10,height:m+10,rx:18,fill:"none",stroke:"var(--poney-accent)",strokeWidth:2,strokeDasharray:"4 3"})]})}function Vz({group:t,entity:e}){const n=gn(),r=jn(),s=`entity:${e.id}`,i=Vs(s),o=Ml(t.members.map(y=>`entity:${y}`)),{setHot:a,toggleGroup:l}=gr(),c=n.style(e),{x:d,y:u,w:h,h:m}=t,g=r({kind:"entity",id:e.id},`${e.name}. ${e.summary}`),p=i.hot?"var(--poney-accent)":Tl(i.state,"var(--poney-story-rule)"),x=e.technology??c.label;return Z("g",{transform:`translate(${d} ${u})`,className:`poney-el ${Pr({...i,dim:i.dim&&o.dim})}`,children:[N("rect",{width:h,height:m,rx:18,fill:i.state?`var(--poney-${i.state}-wash)`:"var(--poney-sunken)",fillOpacity:i.state?.55:.45,stroke:p,strokeWidth:i.state||i.hot?1.6:1.1}),Z("g",{...g,onMouseEnter:()=>{var y;(y=g.onMouseEnter)==null||y.call(g),a(s)},onMouseLeave:()=>{var y;(y=g.onMouseLeave)==null||y.call(g),a(null)},children:[N("rect",{width:h,height:44,rx:18,fill:"transparent"}),N(pr,{name:c.icon,x:16,y:14,size:16,color:i.state?`var(--poney-${i.state})`:pt(c.tone)}),N("text",{x:40,y:27,fontSize:14,fontWeight:600,fill:"var(--poney-ink)",children:Ot(e.name,h-(l?150:110),14,600)}),N("text",{x:40+Math.min(Dw(e.name),h-(l?150:110))+10,y:27,fontSize:12,fill:"var(--poney-ink-3)",children:Ot(x,Math.max(0,h-40-Dw(e.name)-(l?56:24)),12)})]}),N(Bd,{state:i.state,x:h-(l?44:14),y:22,anchor:"end"}),l&&N(i$,{open:!0,name:e.name,x:h-24,y:22,onToggle:()=>l(e.id)})]})}const Dw=t=>Re(t,14,600);function i$({open:t,name:e,x:n,y:r,onToggle:s}){return Z("g",{role:"button",tabIndex:0,"aria-label":`${t?"Close":"Open"} ${e}`,className:"poney-control",onClick:i=>{i.stopPropagation(),s()},onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),s())},children:[N("title",{children:t?`Close ${e}`:`Open ${e}`}),N("circle",{cx:n,cy:r,r:11,fill:"var(--poney-paper-raised)",stroke:"var(--poney-story-line)",strokeWidth:1.1}),N("line",{x1:n-4.5,y1:r,x2:n+4.5,y2:r,stroke:"var(--poney-ink-2)",strokeWidth:1.6,strokeLinecap:"round"}),!t&&N("line",{x1:n,y1:r-4.5,x2:n,y2:r+4.5,stroke:"var(--poney-ink-2)",strokeWidth:1.6,strokeLinecap:"round"})]})}const Zm=t=>t.relationships.join(">");function Wz({edge:t}){const e=gn(),n=jn(),{setHot:r}=gr(),s=`relationship:${t.id}`,i=Ml(t.relationships.map(x=>`relationship:${x}`)),o=e.relationships.get(t.id),[a,l,c,d]=t.curve,u=i.hot?"var(--poney-accent)":Tl(i.state,i.focused?"var(--poney-story-line)":"var(--poney-story-rule)"),h=Math.atan2(d.y-c.y,d.x-c.x),m={x:d.x-Math.cos(h)*8,y:d.y-Math.sin(h)*8},g=(o==null?void 0:o.kind)==="publishes"||(o==null?void 0:o.kind)==="subscribes",p=n({kind:"relationship",id:t.id},(o==null?void 0:o.label)??t.id);return Z("g",{...p,className:`poney-el ${Pr(i)}`,onMouseEnter:()=>{var x;(x=p.onMouseEnter)==null||x.call(p),r(s)},onMouseLeave:()=>{var x;(x=p.onMouseLeave)==null||x.call(p),r(null)},children:[N("path",{d:`M ${a.x} ${a.y} C ${l.x} ${l.y} ${c.x} ${c.y} ${d.x} ${d.y}`,fill:"none",stroke:"transparent",strokeWidth:16}),N("path",{d:`M ${a.x} ${a.y} C ${l.x} ${l.y} ${c.x} ${c.y} ${m.x} ${m.y}`,fill:"none",stroke:u,strokeWidth:i.state||i.hot?2:1.4,strokeDasharray:i.state==="removed"||g?"6 5":void 0,strokeLinecap:"round"}),N(nh,{x:d.x,y:d.y,angle:h,color:u})]})}function Uz({edge:t}){const e=gr(),n=Ml(t.relationships.map(g=>`relationship:${g}`));if(!(!n.hidden&&(n.hot||e.allLabels||!!n.callout||!!e.focus&&n.focused||!e.focus&&!!n.state)))return null;const{x:s,y:i,w:o,h:a,text:l,sub:c}=t.label,d=n.hot?"var(--poney-accent)":n.state?`var(--poney-${n.state})`:"var(--poney-ink-2)",u=n.hot?"var(--poney-accent)":n.state?`var(--poney-${n.state})`:"var(--poney-story-line)",h=t.leader,m=h?{x:Math.max(s,Math.min(s+o,h.x)),y:Math.max(i,Math.min(i+a,h.y))}:void 0;return Z("g",{pointerEvents:"none",className:`poney-story-el ${n.dim?"poney-story-dim":""}`,children:[h&&m&&Z(ft,{children:[N("line",{x1:m.x,y1:m.y,x2:h.x,y2:h.y,stroke:u,strokeWidth:1,strokeDasharray:"2 3"}),N("circle",{cx:h.x,cy:h.y,r:2.5,fill:u})]}),Z("g",{transform:`translate(${s} ${i})`,children:[N("rect",{width:o,height:a,rx:11,fill:"var(--poney-paper-raised)",stroke:n.hot?"var(--poney-accent)":n.state?`var(--poney-${n.state})`:"var(--poney-story-rule)"}),N("text",{x:o/2,y:15,textAnchor:"middle",fontSize:12,fontWeight:500,fill:d,children:l}),c&&N("text",{x:o/2,y:29,textAnchor:"middle",fontSize:11,fill:"var(--poney-ink-3)",children:c})]})]})}function Zz({node:t}){const e=Ml([`entity:${t.entityId}`,...(("depth"in t?[]:t.members)??[]).map(n=>`entity:${n}`)]);return!e.callout||e.hidden?null:N(Ol,{n:e.callout,x:t.x-2,y:t.y-2,hot:e.hot})}function Hz({edge:t}){const e=Ml(t.relationships.map(n=>`relationship:${n}`));return!e.callout||e.hidden?null:N(Ol,{n:e.callout,x:t.label.x-14,y:t.label.y+t.label.h/2,hot:e.hot})}function o$({scene:t}){const e=t.interactionId;return Z("g",{children:[t.fragments.slice().sort((n,r)=>n.depth-r.depth).map(n=>N(Yz,{f:n,behavior:e},n.id)),t.participants.map(n=>N(qz,{p:n},n.entityId)),t.activations.map((n,r)=>N("rect",{x:n.x+1,y:n.y1,width:8,height:n.y2-n.y1,rx:3,fill:"var(--poney-sunken)",stroke:"var(--poney-story-rule)"},r)),t.fragments.map(n=>N(Qz,{f:n,behavior:e},`fl-${n.id}`)),t.messages.map(n=>N(Gz,{m:n,behavior:e},n.id)),t.participants.map(n=>N(Kz,{p:n},`h-${n.entityId}`))]})}function qz({p:t}){const e=Vs(`entity:${t.entityId}`);return N("line",{x1:t.x,x2:t.x,y1:t.lifeline.y1,y2:t.lifeline.y2,stroke:e.hot?"var(--poney-accent)":"var(--poney-story-rule)",strokeWidth:e.hot?1.5:1,className:Pr({...e,dim:!1})})}function Kz({p:t}){const e=gn(),n=jn(),{setHot:r}=gr(),s=`entity:${t.entityId}`,i=Vs(s),o=e.entities.get(t.entityId);if(!o)return null;const a=e.style(o),{x:l,y:c,w:d,h:u}=t.header,h=n({kind:"entity",id:o.id},`${o.name}, ${a.label}`);return Z("g",{transform:`translate(${l} ${c})`,...h,className:`poney-el ${Pr({...i,dim:!1})}`,onMouseEnter:()=>{var m;(m=h.onMouseEnter)==null||m.call(h),r(s)},onMouseLeave:()=>{var m;(m=h.onMouseLeave)==null||m.call(h),r(null)},children:[N("rect",{width:d,height:u,rx:14,fill:C1(i.state),stroke:i.hot?"var(--poney-accent)":Tl(i.state,"var(--poney-story-line)"),strokeWidth:i.state?1.75:1.2,strokeDasharray:o.kind==="external"?"6 4":void 0}),N(pr,{name:a.icon,x:16,y:u/2-9,size:18,color:i.state?`var(--poney-${i.state})`:pt(a.tone)}),N("text",{x:44,y:u/2-1,fontSize:14.5,fontWeight:600,fill:"var(--poney-ink)",children:Ot(o.name,d-54,14.5,600)}),N("text",{x:44,y:u/2+16,fontSize:12,fill:"var(--poney-ink-3)",children:Ot(o.technology??a.label,d-54,12)}),N(Bd,{state:i.state,x:d-10,y:0,anchor:"end"}),i.callout&&N(Ol,{n:i.callout,x:-2,y:-2,hot:i.hot})]})}function Jz(t){return t.hot?"var(--poney-accent)":t.state?`var(--poney-${t.state})`:"var(--poney-ink-2)"}function Gz({m:t,behavior:e}){const n=jn(),{setHot:r}=gr(),s=`message:${e}:${t.id}`,i=Vs(s),o=Jz(i),a=i.state||i.hot?1.9:1.35,l=String(t.number),c=Re(l,11.5,600)+8,d=Re(t.label,13,i.state?600:500),u=n({kind:"message",behavior:e,id:t.id},`Step ${t.number}: ${t.label}`),h={...u,className:`poney-el ${Pr(i)}`,onMouseEnter:()=>{var p;(p=u.onMouseEnter)==null||p.call(u),r(s)},onMouseLeave:()=>{var p;(p=u.onMouseLeave)==null||p.call(u),r(null)}},m=(p,x,y)=>{const v=c+d,k=y==="middle"?p-v/2:p;return Z(ft,{children:[N("text",{x:k,y:x,fontSize:11.5,fontWeight:600,fill:"var(--poney-ink-3)",className:"poney-numbers",stroke:"var(--poney-paper-raised)",strokeWidth:5,paintOrder:"stroke",strokeLinejoin:"round",children:l}),N("text",{x:k+c,y:x,stroke:"var(--poney-paper-raised)",strokeWidth:5,paintOrder:"stroke",strokeLinejoin:"round",fontSize:13,fontWeight:i.state?600:500,fill:i.state||i.hot?o:t.kind==="return"?"var(--poney-ink-2)":"var(--poney-ink)",children:t.label}),N(Bd,{state:i.state,x:k+v+14,y:x-4.5}),i.callout&&N(Ol,{n:i.callout,x:k-18,y:x-4.5,hot:i.hot})]})};if(t.loop){const{x:p,y1:x,y2:y,w:v}=t.loop;return Z("g",{...h,children:[N("rect",{x:p-4,y:x-14,width:v+d+c+90,height:y-x+26,fill:"transparent"}),N("path",{d:`M ${p} ${x} H ${p+v} V ${y} H ${p+8}`,fill:"none",stroke:o,strokeWidth:a,strokeLinejoin:"round"}),N(nh,{x:p+1,y,angle:Math.PI,color:o,size:6}),m(p+v+14,(x+y)/2+4.5,"start")]})}const g=t.x2>t.x1;return Z("g",{...h,children:[N("rect",{x:Math.min(t.x1,t.x2),y:t.y-24,width:Math.abs(t.x2-t.x1),height:32,fill:"transparent"}),N("line",{x1:t.x1,x2:t.x2+(g?-8:8),y1:t.y,y2:t.y,stroke:o,strokeWidth:a,strokeDasharray:t.kind==="return"?"5 4":t.kind==="async"?"2 4":void 0,strokeLinecap:"round"}),N(nh,{x:t.x2,y:t.y,angle:g?0:Math.PI,color:o,size:6}),m((t.x1+t.x2)/2,t.y-9,"middle")]})}function Yz({f:t,behavior:e}){const n=Vs(`fragment:${e}:${t.id}`);return Z("g",{className:Pr(n),children:[N("rect",{x:t.x,y:t.y,width:t.w,height:t.h,rx:14,fill:"var(--poney-paper)",fillOpacity:.55,stroke:"var(--poney-story-rule)"}),t.branches.slice(1).map((r,s)=>N("line",{x1:t.x+10,x2:t.x+t.w-10,y1:r.y,y2:r.y,stroke:"var(--poney-story-rule)",strokeDasharray:"4 4"},s))]})}function Qz({f:t,behavior:e}){var a;const n=Vs(`fragment:${e}:${t.id}`),r=Dd(t.kind),s=((a=t.branches[0])==null?void 0:a.guard)??"",i=Re(r,11.5,650),o={stroke:"var(--poney-paper-raised)",strokeWidth:5,paintOrder:"stroke",strokeLinejoin:"round"};return Z("g",{className:Pr(n),pointerEvents:"none",children:[N("text",{x:t.x+14,y:t.y+19,fontSize:11.5,fontWeight:650,fill:"var(--poney-ink-3)",...o,children:r}),N("text",{x:t.x+24+i,y:t.y+19,fontSize:12,fill:"var(--poney-ink-2)",...o,children:t.kind==="loop"||t.kind==="opt"?s:`if ${s}`}),t.branches.slice(1).map((l,c)=>N("text",{x:t.x+14,y:l.y+18,fontSize:12,fill:"var(--poney-ink-2)",...o,children:t.kind==="par"?`and ${l.guard}`:`else, if ${l.guard}`},c))]})}function a$({scene:t}){return Z("g",{children:[t.transitions.map(e=>N(eL,{t:e,machine:t.machineId},e.id)),t.states.map(e=>N(Xz,{s:e,machine:t.machineId},e.id)),t.transitions.map(e=>N(tL,{t:e,machine:t.machineId},`l-${e.id}`))]})}function l$(t,e,n,r){const s=jn(),{setHot:i}=gr(),o=s(e,n);return{...o,className:`poney-el ${r}`,onMouseEnter:()=>{var a;(a=o.onMouseEnter)==null||a.call(o),i(t)},onMouseLeave:()=>{var a;(a=o.onMouseLeave)==null||a.call(o),i(null)}}}function Xz({s:t,machine:e}){const n=`state:${e}:${t.id}`,r=Vs(n),s=l$(n,{kind:"state",behavior:e,id:t.id},`State ${t.name}`,Pr(r)),i=t.outcome==="success"?"var(--poney-success)":t.outcome==="failure"?"var(--poney-failure)":void 0;if(t.kind==="initial")return N("g",{transform:`translate(${t.x} ${t.y})`,...s,children:N("circle",{cx:t.w/2,cy:t.h/2,r:8,fill:"var(--poney-ink)"})});const o=r.hot?"var(--poney-accent)":Tl(r.state,r.focused?"var(--poney-story-line)":"var(--poney-story-rule)");return Z("g",{transform:`translate(${t.x} ${t.y})`,...s,children:[N("rect",{width:t.w,height:t.h,rx:t.h/2,fill:C1(r.state),stroke:o,strokeWidth:r.state||r.hot?1.8:1.25}),t.kind==="final"&&N("rect",{x:4,y:4,width:t.w-8,height:t.h-8,rx:(t.h-8)/2,fill:"none",stroke:o,strokeWidth:1}),i&&N("circle",{cx:20,cy:t.h/2,r:4,fill:i}),N("text",{x:t.w/2,y:t.entryActions.length?t.h/2-2:t.h/2+5,textAnchor:"middle",fontSize:14.5,fontWeight:600,fill:"var(--poney-ink)",children:t.name}),t.entryActions.length>0&&Z("text",{x:t.w/2,y:t.h/2+15,textAnchor:"middle",fontSize:11.5,fill:"var(--poney-ink-3)",children:[t.entryActions[0],t.entryActions.length>1?`, +${t.entryActions.length-1}`:""]}),N(Bd,{state:r.state,x:t.w-14,y:0,anchor:"end"}),r.callout&&N(Ol,{n:r.callout,x:0,y:0,hot:r.hot})]})}function eL({t,machine:e}){const n=`transition:${e}:${t.id}`,r=Vs(n),s=l$(n,{kind:"transition",behavior:e,id:t.id},`Transition: ${t.event}`,Pr(r)),i=r.hot?"var(--poney-accent)":Tl(r.state,r.focused?"var(--poney-story-line)":"var(--poney-story-rule)"),o=jo(lE(t.points,7),18),a=t.points[t.points.length-1];return Z("g",{...s,children:[N("path",{d:jo(t.points,18),fill:"none",stroke:"transparent",strokeWidth:16}),N("path",{d:o,fill:"none",stroke:i,strokeWidth:r.state||r.hot?2:1.4,strokeDasharray:r.state==="removed"?"6 5":void 0,strokeLinecap:"round"}),N(nh,{x:a.x,y:a.y,angle:cE(t.points),color:i,size:6})]})}function tL({t,machine:e}){const n=`transition:${e}:${t.id}`,r=Vs(n);if(!t.label)return null;const{x:s,y:i,w:o,h:a}=t.label,l=r.hot?"var(--poney-accent)":r.state?`var(--poney-${r.state})`:"var(--poney-ink)";return Z("g",{transform:`translate(${s} ${i})`,pointerEvents:"none",className:Pr(r),children:[N("rect",{width:o,height:a,rx:8,fill:r.state?`var(--poney-${r.state}-wash)`:"var(--poney-paper-raised)",stroke:r.state?`var(--poney-${r.state})`:"var(--poney-story-rule)"}),N("text",{x:o/2,y:15,textAnchor:"middle",fontSize:11.5,fontWeight:600,fill:l,textDecoration:r.state==="removed"?"line-through":void 0,children:t.event}),t.guard&&Z("text",{x:o/2,y:28,textAnchor:"middle",fontSize:10.5,fill:"var(--poney-ink-3)",children:["[",t.guard,"]"]}),r.callout&&N(Ol,{n:r.callout,x:-4,y:a/2,hot:r.hot})]})}function c$(t,e){const n=new Map;if(e.type==="map")for(const r of t.edges){const s=r.curve,i={d:`M ${s[0].x} ${s[0].y} C ${s[1].x} ${s[1].y} ${s[2].x} ${s[2].y} ${s[3].x} ${s[3].y}`,at:o=>{const a=Nc(s,o),l=Nc(s,Math.min(1,o+.01)),c=Nc(s,Math.max(0,o-.01));return{...a,angle:Math.atan2(l.y-c.y,l.x-c.x)}},stepAt:.18,badge:{x:r.label.x+r.label.w/2,y:r.label.y+r.label.h+13},sign:{x:r.label.x+r.label.w+13,y:r.label.y+r.label.h/2}};for(const o of r.relationships)n.set(`relationship:${o}`,i)}if(e.type==="sequence"){const r=t;for(const s of r.messages){const i=s.loop?[{x:s.loop.x,y:s.loop.y1},{x:s.loop.x+s.loop.w,y:s.loop.y1},{x:s.loop.x+s.loop.w,y:s.loop.y2},{x:s.loop.x+8,y:s.loop.y2}]:[{x:s.x1,y:s.y},{x:s.x2,y:s.y}],o=zw(i,0),a=Math.abs(s.x2-s.x1)||60,l=o.at(.5);n.set(`message:${r.interactionId}:${s.id}`,{...o,stepAt:Math.min(.4,22/a),badge:s.loop?{x:s.loop.x+s.loop.w+40,y:s.loop.y2+14}:{x:l.x,y:l.y+15},sign:s.loop?o.at(.5):{x:o.at(.9).x,y:s.y+15}})}}if(e.type==="state"){const r=t;for(const s of r.transitions){const i=zw(s.points,18),o=i.at(.5);n.set(`transition:${r.machineId}:${s.id}`,{...i,stepAt:.22,badge:s.label?{x:s.label.x+s.label.w/2,y:s.label.y+s.label.h+13}:{x:o.x,y:o.y+15},sign:s.label?{x:s.label.x+s.label.w+13,y:s.label.y+s.label.h/2}:i.at(.3)})}}return n}function zw(t,e){const n=t.slice(1).map((s,i)=>Math.hypot(s.x-t[i].x,s.y-t[i].y)),r=n.reduce((s,i)=>s+i,0)||1;return{d:e?jo(t,e):`M ${t.map(s=>`${s.x} ${s.y}`).join(" L ")}`,at(s){let i=Math.max(0,Math.min(1,s))*r;for(let o=0;o<n.length;o++){const a=t[o],l=t[o+1];if(i<=n[o]||o===n.length-1){const c=n[o]?Math.min(1,i/n[o]):0;return{x:a.x+(l.x-a.x)*c,y:a.y+(l.y-a.y)*c,angle:Math.atan2(l.y-a.y,l.x-a.x)}}i-=n[o]}return{...t[0],angle:0}}}}const nL={flow:"var(--poney-lapis)",attention:"var(--poney-accent)","hot-path":"var(--poney-accent)",slow:"var(--poney-ochre)",failing:"var(--poney-failure)",blocked:"var(--poney-failure)"},d$=(t,e)=>e?pt(e):nL[t],rL=t=>/^(entity|state|dataType|activityNode|useCase):/.test(t);function u$({scene:t,view:e}){var i;const n=gr();if(!((i=n.effects)!=null&&i.size))return null;const r=c$(t,e),s=[];return n.effects.forEach((o,a)=>{const l=r.get(a);if(l)for(const c of o){if(c.as==="flow")continue;const d=c.as==="hot-path";s.push(N("path",{d:l.d,fill:"none",stroke:d$(c.as,c.tone),strokeOpacity:d?.3:.2,strokeWidth:d?9:11,strokeLinecap:"round",strokeDasharray:c.as==="slow"?"1 14":void 0,className:c.as==="attention"?"poney-pulse":void 0},`${a}-${c.as}`))}}),N("g",{pointerEvents:"none",children:s})}function f$({scene:t,view:e}){var a,l;const n=gr(),r=c$(t,e),s=c=>{const d=rL(c)?t.anchors[c]:void 0;return d!=null&&d.entityId&&c.startsWith("entity:")&&d.entityId!==c.slice(7)?void 0:d},i=[];(a=n.effects)==null||a.forEach((c,d)=>{const u=r.get(d),h=s(d);c.forEach((m,g)=>{const p=d$(m.as,m.tone),x=`${d}-${m.as}-${g}`;u?(m.as==="flow"&&i.push(N("path",{d:u.d,fill:"none",stroke:p,strokeWidth:3,strokeLinecap:"round",strokeDasharray:"0.1 11",className:"poney-flow"},x)),(m.as==="slow"||m.as==="failing"||m.as==="blocked")&&i.push(N(Lw,{as:m.as,x:u.sign.x,y:u.sign.y,color:p},x))):h&&(i.push(N("rect",{x:h.x-6,y:h.y-6,width:h.w+6*2,height:h.h+6*2,rx:Math.min(20,(h.h+6*2)/2),fill:"none",stroke:p,strokeWidth:m.as==="hot-path"?2.5:2,strokeDasharray:m.as==="blocked"?"6 4":m.as==="slow"?"2 4":void 0,strokeLinecap:"round",className:m.as==="attention"?"poney-pulse":void 0},x)),(m.as==="slow"||m.as==="failing"||m.as==="blocked")&&i.push(N(Lw,{as:m.as,x:h.x+h.w+2,y:h.y+h.h+2,color:p},`${x}-s`)))})}),(l=n.badges)==null||l.forEach((c,d)=>{const u=r.get(d),h=s(d);let m=0,g=0;if(u)m=u.badge.x,g=u.badge.y;else if(h)m=h.x+h.w/2,g=h.y+h.h;else return;const p=c.map(y=>Re(y.text,11,600)+16);let x=m-(p.reduce((y,v)=>y+v,0)+(c.length-1)*4)/2;c.forEach((y,v)=>{const k=y.tone?pt(y.tone):"var(--poney-ink-2)";i.push(Z("g",{transform:`translate(${x} ${g-10})`,children:[N("rect",{width:p[v],height:20,rx:10,fill:"var(--poney-paper-raised)",stroke:k,strokeWidth:1.1}),N("text",{x:p[v]/2,y:14,textAnchor:"middle",fontSize:11,fontWeight:600,fill:k,className:"poney-numbers",children:y.text})]},`b-${d}-${v}`)),x+=p[v]+4})});const o=n.trace;if(o!=null&&o.steps.length){if(o.current===null&&o.numbered)o.steps.forEach((c,d)=>{const u=r.get(c),h=s(c),m=u?u.at(u.stepAt):h?{x:h.x+14,y:h.y+h.h-2}:void 0;m&&i.push(N(sL,{n:d+1,x:m.x,y:m.y},`t-${d}`))});else if(o.current!==null){const c=o.steps[o.current],d=r.get(c),u=s(c);d?i.push(Z("g",{children:[N("circle",{r:7,fill:"var(--poney-accent)",stroke:"var(--poney-paper-raised)",strokeWidth:2.5,children:o.animate?N("animateMotion",{dur:"0.9s",fill:"freeze",path:d.d,keyPoints:"0;1",keyTimes:"0;1",calcMode:"spline",keySplines:"0.4 0 0.2 1"}):null}),!o.animate&&N("circle",{cx:d.at(1).x,cy:d.at(1).y,r:7,fill:"var(--poney-accent)",stroke:"var(--poney-paper-raised)",strokeWidth:2.5})]},`token-${o.current}`)):u&&i.push(N("rect",{x:u.x-7,y:u.y-7,width:u.w+14,height:u.h+14,rx:20,fill:"none",stroke:"var(--poney-accent)",strokeWidth:2.5,className:o.animate?"poney-pulse":void 0},`token-${o.current}`))}}return i.length?N("g",{pointerEvents:"none",children:i}):null}function Lw({as:t,x:e,y:n,color:r}){return Z("g",{children:[N("circle",{cx:e,cy:n,r:10,fill:"var(--poney-paper-raised)",stroke:r,strokeWidth:1.6}),t==="slow"&&N(pr,{name:"timer",x:e-6.5,y:n-6.5,size:13,color:r}),t==="failing"&&N("path",{d:`M ${e-3.6} ${n-3.6} L ${e+3.6} ${n+3.6} M ${e+3.6} ${n-3.6} L ${e-3.6} ${n+3.6}`,stroke:r,strokeWidth:2,strokeLinecap:"round"}),t==="blocked"&&N("path",{d:`M ${e-4.5} ${n} L ${e+4.5} ${n}`,stroke:r,strokeWidth:2.4,strokeLinecap:"round"})]})}const $1=t=>t<26?String.fromCharCode(65+t):`${String.fromCharCode(65+Math.floor(t/26)-1)}${String.fromCharCode(65+t%26)}`;function sL({n:t,x:e,y:n}){return Z("g",{children:[N("rect",{x:e-8.5,y:n-8.5,width:17,height:17,rx:5,fill:"var(--poney-accent)",stroke:"var(--poney-paper-raised)",strokeWidth:1.75}),N("text",{x:e,y:n+3.8,textAnchor:"middle",fontSize:10.5,fontWeight:700,fill:"var(--poney-paper-raised)",className:"poney-numbers",children:$1(t-1)})]})}function iL({view:t,scene:e,extra:n}){const r=t.type==="map"?N(j1,{scene:e,extra:n}):t.type==="sequence"?N(o$,{scene:e}):t.type==="state"?N(a$,{scene:e}):null;return r?Z("g",{children:[N(u$,{scene:e,view:t}),r,N(f$,{scene:e,view:t})]}):null}const h$=t=>t.type==="extension"?t.extension:t.type;function tl({at:t,angle:e,kind:n,color:r,size:s=8}){if(n==="none")return null;const i=n==="triangle"?s*.75:s*.55,o=n==="triangle"?s*1.25:s,a=Math.cos(e),l=Math.sin(e),c=(d,u)=>`${t.x+d*a-u*l},${t.y+d*l+u*a}`;return n==="open-arrow"?N("polyline",{points:`${c(-o,-i)} ${c(0,0)} ${c(-o,i)}`,fill:"none",stroke:r,strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"}):n==="triangle"?N("polygon",{points:`${c(0,0)} ${c(-o,-i)} ${c(-o,i)}`,fill:"var(--poney-paper-raised)",stroke:r,strokeWidth:1.3,strokeLinejoin:"round"}):N("polygon",{points:`${c(0,0)} ${c(-o,-i)} ${c(-o*.72,0)} ${c(-o,i)}`,fill:r})}function Rp({points:t,style:e,radius:n=8}){const r=e.head==="none"?0:e.head==="triangle"?10:6,s=lE(t,r),i=jo(s,n);return Z("g",{opacity:e.opacity??1,children:[N("path",{d:jo(t,n),fill:"none",stroke:"transparent",strokeWidth:14}),N("path",{d:i,className:`poney-edge ${e.flowing?"poney-flowing":""}`,fill:"none",stroke:e.color,strokeWidth:e.width,strokeDasharray:e.flowing?void 0:e.dash,strokeLinecap:"round",strokeLinejoin:"round"}),N(tl,{at:t[t.length-1],angle:cE(t),kind:e.head,color:e.color}),e.tail&&e.tail!=="none"&&N(tl,{at:t[0],angle:mR(t),kind:e.tail,color:e.color})]})}function oL({at:t,text:e,secondary:n,tone:r="var(--poney-ink-2)",strong:s,size:i=11.5}){const o=Re(e,i,s?600:500),a=n?Re(n,i-1,400):0,l=Math.max(o,a)+i*1.2,c=n?i*3:i*1.75;return Z("g",{transform:`translate(${t.x-l/2} ${t.y-c/2})`,pointerEvents:"none",children:[N("rect",{width:l,height:c,rx:i/2,fill:"var(--poney-paper-raised)",stroke:s?r:"var(--poney-rule)",strokeWidth:s?1.2:1}),N("text",{x:l/2,y:i*1.22,textAnchor:"middle",fontSize:i,fontWeight:s?600:500,fill:s?r:"var(--poney-ink-2)",children:e}),n&&N("text",{x:l/2,y:i*2.4,textAnchor:"middle",fontSize:i-1,fill:"var(--poney-ink-3)",children:n})]})}function _c(t,e=11.5,n=30){const r=E1(),s=e/r;return s<=t?t:Math.min(n,Math.ceil(s/2)*2)}function Sn({w:t,h:e,rx:n=12,selected:r}){return Z(ft,{children:[r&&Z(ft,{children:[N("rect",{x:-5,y:-5,width:t+10,height:e+10,rx:n+5,fill:"none",stroke:"var(--poney-accent-ring)",strokeWidth:6}),N("rect",{x:-2.5,y:-2.5,width:t+5,height:e+5,rx:n+2.5,fill:"none",stroke:"var(--poney-accent)",strokeWidth:1.75})]}),N("rect",{className:"poney-focus",x:-5,y:-5,width:t+10,height:e+10,rx:n+5,fill:"none",stroke:"var(--poney-accent)",strokeWidth:2,strokeDasharray:"4 3"})]})}function Ip({entity:t,style:e,w:n,h:r,emphasis:s,detail:i,footer:o}){const a=pt(e.tone),l=t.kind==="external",c=s==="selected",d=hr(()=>t.summary?Ff(t.summary,e.shape==="person"?n-12:n-30,e.shape==="person"?11.5:12,400,2):[],[t.summary,n,e.shape]),u=t.technology??e.label,h=_c(14,10.5),m=h>14&&e.shape!=="person",g=hr(()=>m?Ff(t.name,n-28,h,650,2):[],[m,t.name,n,h]),p=e.emphasis?`color-mix(in srgb, ${a} 55%, var(--poney-rule-strong))`:"var(--poney-rule-strong)";if(e.shape==="person"){const w=n/2;return Z("g",{children:[N("rect",{width:n,height:r,rx:14,fill:"transparent"}),N("circle",{cx:w,cy:22,r:15,fill:kn(e.tone,16),stroke:a,strokeWidth:1.4}),N("path",{d:`M ${w-27} 64 Q ${w-27} 42 ${w} 42 Q ${w+27} 42 ${w+27} 64 Z`,fill:kn(e.tone,16),stroke:a,strokeWidth:1.4,strokeLinejoin:"round"}),N("text",{x:w,y:70+Math.min(h,20),textAnchor:"middle",fontSize:Math.min(h,20),fontWeight:650,fill:"var(--poney-ink)",children:Ot(t.name,n+40,Math.min(h,20),650)}),i&&!m&&h===14&&d.map((C,E)=>N("text",{x:w,y:101+E*14,textAnchor:"middle",fontSize:11.5,fill:"var(--poney-ink-3)",children:C},E)),N(Sn,{w:n,h:r,rx:14,selected:c})]})}const x=(w=0)=>g.map((C,E)=>N("text",{x:n/2,y:w+r/2+h*.36+(E-(g.length-1)/2)*h*1.1,textAnchor:"middle",fontSize:h,fontWeight:650,fill:"var(--poney-ink)",children:C},E));if(e.shape==="chip"){const w=t.kind==="interface";return Z("g",{children:[N("rect",{className:"poney-body",width:n,height:r,rx:10,fill:t.kind==="library"?"var(--poney-paper)":"var(--poney-paper-raised)",stroke:w?a:p,strokeDasharray:w?"5 3":void 0,strokeWidth:1.1}),m?x():Z(ft,{children:[N("rect",{x:11,y:(r-30)/2,width:30,height:30,rx:8,fill:kn(e.tone,13)}),N(pr,{name:e.icon,x:18,y:(r-30)/2+7,size:16,color:a}),N("text",{x:52,y:r/2-3,fontSize:13.5,fontWeight:600,fill:"var(--poney-ink)",fontFamily:t.kind==="interface"?"var(--poney-font-mono)":void 0,children:Ot(t.name,n-62,13.5,600,t.kind==="interface"?"mono":"sans")}),N("text",{x:52,y:r/2+13,fontSize:11.5,fill:"var(--poney-ink-3)",children:Ot(u,n-62,11.5)})]}),N(Sn,{w:n,h:r,rx:10,selected:c})]})}const y=e.shape==="cylinder"?12:0,v=e.shape==="cylinder"?Z(ft,{children:[N("path",{className:"poney-body",d:`M 0 10 A ${n/2} 10 0 0 1 ${n} 10 V ${r-10} A ${n/2} 10 0 0 1 0 ${r-10} Z`,fill:"var(--poney-paper-raised)",stroke:p,strokeWidth:1.1}),N("ellipse",{cx:n/2,cy:10,rx:n/2,ry:10,fill:kn(e.tone,9),stroke:p,strokeWidth:1.1})]}):Z(ft,{children:[e.shape==="stack"&&Z(ft,{children:[N("rect",{x:8,y:-8,width:n,height:r,rx:12,fill:"var(--poney-paper)",stroke:"var(--poney-rule-strong)",strokeWidth:1}),N("rect",{x:4,y:-4,width:n,height:r,rx:12,fill:"var(--poney-paper)",stroke:"var(--poney-rule-strong)",strokeWidth:1})]}),N("rect",{className:"poney-body",width:n,height:r,rx:e.shape==="frame"?16:12,fill:e.shape==="frame"?kn(e.tone,6):"var(--poney-paper-raised)",stroke:l?a:p,strokeDasharray:l?"6 4":void 0,strokeWidth:e.shape==="frame"?1.5:1.1})]}),k=e.shape==="frame";return Z("g",{children:[v,m&&x(y/2),Z("g",{transform:`translate(0 ${y})`,display:m?"none":void 0,children:[N("rect",{x:14,y:14,width:k?38:32,height:k?38:32,rx:9,fill:kn(e.tone,14)}),N(pr,{name:e.icon,x:k?23:21.5,y:k?23:21.5,size:k?20:17,color:a}),N("text",{x:k?64:56,y:k?31:29,fontSize:k?16:14,fontWeight:650,fill:"var(--poney-ink)",children:Ot(t.name,n-(k?76:68),k?16:14,650)}),N("text",{x:k?64:56,y:k?48:45.5,fontSize:11.5,fill:"var(--poney-ink-3)",children:Ot(u,n-(k?76:68),11.5)}),i&&d.map((w,C)=>N("text",{x:14,y:(k?76:70)+C*15,fontSize:12,fill:"var(--poney-ink-2)",children:w},C)),o&&N("text",{x:14,y:r-y-16,fontSize:12,fontWeight:600,fill:a,children:o})]}),N(Sn,{w:n,h:r,rx:k?16:12,selected:c})]})}function Xt({shape:t,tone:e,label:n,dashed:r}){const s=pt(e),i=kn(e,14);return Z("div",{className:"poney-legend-row",children:[Z("svg",{width:"22",height:"16","aria-hidden":!0,className:"poney-legend-mark",children:[t==="person"&&Z(ft,{children:[N("circle",{cx:"11",cy:"5",r:"3.6",fill:i,stroke:s,strokeWidth:"1.2"}),N("path",{d:"M4.5 15 Q4.5 9.5 11 9.5 Q17.5 9.5 17.5 15 Z",fill:i,stroke:s,strokeWidth:"1.2"})]}),t==="cylinder"&&Z(ft,{children:[N("path",{d:"M2 4 A9 2.6 0 0 1 20 4 V12 A9 2.6 0 0 1 2 12 Z",fill:i,stroke:s,strokeWidth:"1.2"}),N("ellipse",{cx:"11",cy:"4",rx:"9",ry:"2.6",fill:i,stroke:s,strokeWidth:"1.2"})]}),t==="stack"&&Z(ft,{children:[N("rect",{x:"5",y:"1",width:"15",height:"10",rx:"2.5",fill:"none",stroke:s,strokeWidth:"1",opacity:"0.6"}),N("rect",{x:"2",y:"4",width:"15",height:"10",rx:"2.5",fill:i,stroke:s,strokeWidth:"1.2"})]}),(t==="card"||t==="frame"||t==="chip")&&N("rect",{x:"2",y:"2",width:"18",height:"12",rx:"3",fill:i,stroke:s,strokeWidth:"1.2",strokeDasharray:r?"3 2":void 0}),t==="pill"&&N("rect",{x:"1",y:"3",width:"20",height:"10",rx:"5",fill:i,stroke:s,strokeWidth:"1.2"}),t==="diamond"&&N("path",{d:"M11 1 L20 8 L11 15 L2 8 Z",fill:i,stroke:s,strokeWidth:"1.2"}),t==="dot"&&N("circle",{cx:"11",cy:"8",r:"5",fill:s}),t==="bullseye"&&Z(ft,{children:[N("circle",{cx:"11",cy:"8",r:"6",fill:"none",stroke:s,strokeWidth:"1.2"}),N("circle",{cx:"11",cy:"8",r:"3.4",fill:s})]}),t==="store"&&Z(ft,{children:[N("path",{d:"M2 3 H20 M2 13 H20",stroke:s,strokeWidth:"1.2"}),N("rect",{x:"2",y:"3",width:"18",height:"10",fill:i})]}),t==="bar"&&N("rect",{x:"2",y:"6",width:"18",height:"4",rx:"2",fill:s})]}),N("span",{children:n})]})}function qn({line:t,label:e,color:n="var(--poney-ink-3)",head:r=!0}){return Z("div",{className:"poney-legend-row",children:[Z("svg",{width:"22",height:"16","aria-hidden":!0,className:"poney-legend-mark",children:[N("line",{x1:"1",y1:"8",x2:r?15:21,y2:"8",stroke:n,strokeWidth:"1.4",strokeDasharray:t==="dashed"?"4 3":t==="dotted"?"1.4 3":void 0}),r&&N("path",{d:"M14 4.5 L21 8 L14 11.5 Z",fill:n})]}),N("span",{children:e})]})}function aL(t){const[e,n]=Ap(t.id),r=e.collapsed??t.collapsed;return{collapsed:r,toggle:i=>n({collapsed:r.includes(i)?r.filter(o=>o!==i):[...r,i]})}}function wu({x:t,y:e,open:n,label:r,onToggle:s}){return ZD()?null:Z("g",{transform:`translate(${t} ${e})`,role:"button",tabIndex:0,"aria-label":`${n?"Close":"Open"} ${r}`,"aria-expanded":n,className:"poney-control","data-ref":"toggle",onClick:i=>{i.stopPropagation(),s()},onDoubleClick:i=>i.stopPropagation(),onKeyDown:i=>{(i.key==="Enter"||i.key===" ")&&(i.preventDefault(),i.stopPropagation(),s())},children:[N("rect",{width:26,height:26,rx:7,fill:"var(--poney-paper-raised)",stroke:"var(--poney-rule-strong)"}),N("g",{transform:"translate(5 5)",color:"var(--poney-ink-2)",children:n?N(bi,{icon:St.chevronsDownUp,width:16,height:16,strokeWidth:1.8}):N(bi,{icon:St.chevronsUpDown,width:16,height:16,strokeWidth:1.8})}),N("rect",{className:"poney-focus",x:-3,y:-3,width:32,height:32,rx:9,fill:"none",stroke:"var(--poney-accent)",strokeWidth:2})]})}function lL({scene:t,view:e}){var v,k;const n=gn(),r=jn(),s=E1(),{subject:i,selection:o}=Ws(),{toggle:a}=aL(e),l=n.doc.presentation.relationships,c=_c(12.5,11,26),d=_c(15,12,32),u=_c(11.5,10.5,26),h=hr(()=>{if(!i)return null;const w=new Set,C=new Set,E=new Map(t.nodes.map($=>[$.id,$])),_=$=>t.nodes.filter(I=>cL(I,$,E)).forEach(I=>w.add(I.id)),S=$=>{var I;return((I=t.nodes.find(L=>L.entityId===$))==null?void 0:I.id)??j($)},j=$=>{var L;const I=t.anchors[`entity:${$}`];return I?(L=t.nodes.find(D=>D.x===I.x&&D.y===I.y&&D.w===I.w&&D.h===I.h))==null?void 0:L.id:void 0};if(i.kind==="entity"){const $=S(i.id);if(!$)return null;w.add($),_($);const I=new Set(w);for(const L of t.edges)(I.has(L.source)||I.has(L.target))&&(C.add(L.id),w.add(L.source),w.add(L.target))}else if(i.kind==="relationship"){const $=t.edges.find(I=>I.relationships.includes(i.id));if(!$)return null;C.add($.id),w.add($.source),w.add($.target)}else if(i.kind==="group"&&i.view===e.id){const $=`g:${i.id}`;w.add($),_($);const I=new Set(w);for(const L of t.edges)(I.has(L.source)||I.has(L.target))&&C.add(L.id)}else return null;return{nodes:w,edges:C}},[i,t,e.id]),m=(o==null?void 0:o.kind)==="entity"?(v=t.nodes.find(w=>w.entityId===o.id))==null?void 0:v.id:(o==null?void 0:o.kind)==="group"?`g:${o.id}`:void 0,g=(o==null?void 0:o.kind)==="relationship"?(k=t.edges.find(w=>w.relationships.includes(o.id)))==null?void 0:k.id:void 0,p=w=>!!h&&!w.compound&&!h.nodes.has(w.id),x=t.nodes.filter(w=>w.compound),y=t.nodes.filter(w=>!w.compound);return Z("g",{children:[x.map(w=>{if(w.type==="group"){const _=e.groups.find(S=>S.id===w.groupId);return Z("g",{transform:`translate(${w.x} ${w.y})`,...r({kind:"group",view:e.id,id:_.id},`Group ${_.label}`),children:[N("rect",{width:w.w,height:w.h,rx:14,fill:"var(--poney-plaster)",fillOpacity:.55,stroke:"var(--poney-rule-strong)",strokeDasharray:"5 4"}),N("text",{x:16,y:12+c,fontSize:c,fontWeight:600,fill:"var(--poney-ink-2)",children:_.label}),N(wu,{x:w.w-36,y:7,open:!0,label:_.label,onToggle:()=>a(_.id)}),N(Sn,{w:w.w,h:w.h,rx:14,selected:m===w.id})]},w.id)}const C=n.entities.get(w.entityId),E=n.style(C,e.id);return Z("g",{transform:`translate(${w.x} ${w.y})`,...r({kind:"entity",id:C.id},`${C.name}, ${E.label}, contains ${w.hiddenCount||"several"} parts`),children:[N("rect",{width:w.w,height:w.h,rx:18,fill:`color-mix(in srgb, ${pt(E.tone)} 4%, var(--poney-paper))`,stroke:"var(--poney-rule-strong)",strokeWidth:1.25}),N(pr,{name:E.icon,x:20,y:18,size:18,color:pt(E.tone)}),N("text",{x:46,y:d>15?16+d:32,fontSize:d,fontWeight:650,fill:"var(--poney-ink)",children:C.name}),d===15&&N("text",{x:20,y:48,fontSize:12,fill:"var(--poney-ink-3)",children:Ot(C.summary,w.w-80,12)}),N(wu,{x:w.w-40,y:12,open:!0,label:C.name,onToggle:()=>a(C.id)}),N(Sn,{w:w.w,h:w.h,rx:18,selected:m===w.id})]},w.id)}),t.edges.map(w=>{const C=n.relationships.get(w.relationships[0]),E=l[C.kind]??{pattern:"solid",head:"arrow"},_=h==null?void 0:h.edges.has(w.id),S=g===w.id,j=_||S?"var(--poney-accent)":"var(--poney-ink-4)",$=w.relationships.length>1?`${w.relationships.length} connections`:C.label;return N("g",{...r({kind:"relationship",id:w.relationships[0]},`${n.describe({kind:"relationship",id:C.id}).title}: ${$}`),className:`poney-el ${h&&!_?"poney-dim":""}`,children:N(Rp,{points:w.points,style:{color:j,width:_||S?1.9:1.3,dash:E.pattern==="dashed"?"6 4":E.pattern==="dotted"?"1.5 4":void 0,head:E.head,flowing:S&&(C.kind==="publishes"||C.kind==="subscribes")}})},w.id)}),y.map(w=>{if(w.type==="group"){const S=e.groups.find(j=>j.id===w.groupId);return Z("g",{transform:`translate(${w.x} ${w.y})`,...r({kind:"group",view:e.id,id:S.id},`Group ${S.label}, closed`),className:`poney-el ${p(w)?"poney-dim":""}`,children:[N("rect",{x:6,y:-6,width:w.w,height:w.h,rx:12,fill:"var(--poney-paper)",stroke:"var(--poney-rule-strong)"}),N("rect",{width:w.w,height:w.h,rx:12,fill:"var(--poney-paper-raised)",stroke:"var(--poney-rule-strong)",strokeDasharray:"5 4"}),N("text",{x:16,y:30,fontSize:14,fontWeight:650,fill:"var(--poney-ink)",children:S.label}),Z("text",{x:16,y:50,fontSize:12,fill:"var(--poney-ink-3)",children:[w.hiddenCount," parts inside"]}),S.description&&s>.55&&N("text",{x:16,y:74,fontSize:12,fill:"var(--poney-ink-2)",children:Ot(S.description,w.w-32,12)}),N(wu,{x:w.w-36,y:10,open:!1,label:S.label,onToggle:()=>a(S.id)}),N(Sn,{w:w.w,h:w.h,selected:m===w.id})]},w.id)}const C=n.entities.get(w.entityId),E=n.style(C,e.id),_=w.collapsed?{...E,shape:"frame"}:E;return Z("g",{transform:`translate(${w.x} ${w.y})`,...r({kind:"entity",id:C.id},`${C.name}, ${E.label}. ${C.summary}`),className:`poney-el ${p(w)?"poney-dim":""}`,children:[N(Ip,{entity:C,style:_,w:w.w,h:w.h,emphasis:m===w.id?"selected":"normal",detail:s>.55,footer:w.collapsed?`${w.hiddenCount} parts inside`:void 0}),w.collapsed&&N(wu,{x:w.w-40,y:12,open:!1,label:C.name,onToggle:()=>a(C.id)})]},w.id)}),t.edges.filter(w=>(h==null?void 0:h.edges.has(w.id))||g===w.id).map(w=>{const C=n.relationships.get(w.relationships[0]),E=w.relationships.length>1;return N(oL,{at:gR(w.points),text:E?`${w.relationships.length} connections`:C.label,secondary:E?void 0:C.protocol,tone:"var(--poney-accent)",strong:g===w.id,size:u},`l-${w.id}`)})]})}function cL(t,e,n){var s;let r=t.parent;for(;r;){if(r===e)return!0;r=(s=n.get(r))==null?void 0:s.parent}return!1}function dL({view:t}){const e=gn(),n=[...new Set(t.entities.map(r=>{var s;return(s=e.entities.get(r))==null?void 0:s.kind}).filter(Boolean))];return Z("div",{className:"poney-legend",children:[n.map(r=>{const s=e.doc.presentation.kinds[r];return s?N(Xt,{shape:s.shape,tone:s.tone,label:s.label,dashed:r==="external"},r):null}),N(qn,{line:"solid",label:"Request and response"}),N(qn,{line:"dashed",label:"Event, sent and forgotten"})]})}const uL={key:"architecture",label:"Architecture",icon:St.network,howToRead:"Boxes are the running parts of the system; lines show who calls whom. Select a part to see what it talks to. Open or close a group with its corner button.",Renderer:lL,Legend:dL};function fL({scene:t}){const e=gn(),n=jn(),{subject:r,selection:s}=Ws(),i=t.interactionId,o=e.messages(i),a=hr(()=>{if(!r)return null;const u=new Set,h=new Set,m=g=>{var x;const p=(x=o.find(y=>y.message.id===g))==null?void 0:x.message;p&&(u.add(g),h.add(p.from),h.add(p.to))};if(r.kind==="entity"){if(!t.participants.some(g=>g.entityId===r.id))return null;h.add(r.id),o.forEach(g=>(g.message.from===r.id||g.message.to===r.id)&&u.add(g.message.id))}else if(r.kind==="message"&&r.behavior===i)m(r.id);else if(r.kind==="fragment"&&r.behavior===i)o.forEach(g=>g.context.some(p=>p.fragment.id===r.id)&&m(g.message.id));else if(r.kind==="relationship")o.forEach(g=>g.message.relationship===r.id&&m(g.message.id));else if(r.kind==="dataType")o.forEach(g=>g.message.data.includes(r.id)&&m(g.message.id));else return null;return u.size||h.size?{msgs:u,people:h}:null},[r,o,t.participants,i]),l=(s==null?void 0:s.kind)==="message"&&s.behavior===i?s.id:void 0,c=(s==null?void 0:s.kind)==="fragment"&&s.behavior===i?s.id:void 0,d=(s==null?void 0:s.kind)==="entity"?s.id:void 0;return Z("g",{children:[t.fragments.map(u=>{const h=(a==null?void 0:a.msgs.size)&&o.some(m=>a.msgs.has(m.message.id)&&m.context.some(g=>g.fragment.id===u.id));return N("rect",{x:u.x,y:u.y,width:u.w,height:u.h,rx:10,fill:"var(--poney-paper)",fillOpacity:.5,stroke:c===u.id?"var(--poney-accent)":h?"var(--poney-ink-4)":"var(--poney-rule-strong)",strokeWidth:c===u.id?1.6:1},`bg-${u.id}`)}),t.participants.map(u=>{const h=a==null?void 0:a.people.has(u.entityId);return N("line",{x1:u.x,x2:u.x,y1:u.lifeline.y1,y2:u.lifeline.y2,stroke:h&&(r==null?void 0:r.kind)==="entity"?"var(--poney-accent)":"var(--poney-ink-4)",strokeOpacity:h?.8:1,strokeWidth:h&&(r==null?void 0:r.kind)==="entity"?1.6:1,strokeDasharray:"4 5",className:a&&!h?"poney-dim":""},`l-${u.entityId}`)}),t.activations.map((u,h)=>{const m=e.style(u.entityId);return N("rect",{x:u.x,y:u.y1,width:10,height:u.y2-u.y1,rx:2,fill:kn(m.tone,18),stroke:pt(m.tone),strokeWidth:1,className:a&&!a.people.has(u.entityId)?"poney-dim":""},h)}),t.messages.map(u=>{var _,S;const h=a==null?void 0:a.msgs.has(u.id),m=l===u.id,g=m||h&&(r==null?void 0:r.kind)!=="entity"?"var(--poney-accent)":h?"var(--poney-ink)":"var(--poney-ink-2)",p=u.kind==="return"?"5 4":void 0,x=u.kind==="call"?"arrow":"open-arrow",y=Re(u.label,12.5,500),v=(j,$)=>Z("g",{children:[N("circle",{cx:j,cy:$,r:9,fill:m?"var(--poney-accent)":"var(--poney-paper-raised)",stroke:m?"var(--poney-accent)":"var(--poney-rule-strong)"}),N("text",{x:j,y:$+3.5,textAnchor:"middle",fontSize:10,fontWeight:650,fill:m?"var(--poney-paper)":"var(--poney-ink-2)",className:"poney-numbers",children:u.number})]}),k=`Step ${u.number}: ${(_=e.entities.get(u.from))==null?void 0:_.name} to ${(S=e.entities.get(u.to))==null?void 0:S.name}, ${u.label}`;if(u.loop){const{x:j,y1:$,y2:I,w:L}=u.loop;return Z("g",{...n({kind:"message",behavior:i,id:u.id},k),className:`poney-el ${a&&!h?"poney-dim":""}`,children:[N("rect",{x:j-4,y:$-16,width:L+y+60,height:I-$+24,fill:"transparent"}),N("path",{d:`M ${j} ${$} H ${j+L} V ${I} H ${j+6}`,fill:"none",stroke:g,strokeWidth:m?1.8:1.3,strokeLinejoin:"round"}),N(tl,{at:{x:j+2,y:I},angle:Math.PI,kind:"arrow",color:g}),v(j+L+18,($+I)/2),N("text",{x:j+L+32,y:($+I)/2+4.5,fontSize:12.5,fontWeight:m?650:500,fill:m?"var(--poney-accent)":"var(--poney-ink)",children:u.label}),m&&N("rect",{x:j-6,y:$-14,width:L+y+64,height:I-$+22,rx:8,fill:"var(--poney-accent-wash)"})]},u.id)}const w=u.x2>u.x1,C=(u.x1+u.x2)/2,E=y+26;return Z("g",{...n({kind:"message",behavior:i,id:u.id},k),className:`poney-el ${a&&!h?"poney-dim":""}`,children:[N("rect",{x:Math.min(u.x1,u.x2),y:u.y-22,width:Math.abs(u.x2-u.x1),height:30,fill:m?"var(--poney-accent-wash)":"transparent",rx:6}),N("line",{x1:u.x1,x2:u.x2+(w?-6:6),y1:u.y,y2:u.y,stroke:g,strokeWidth:m?1.8:1.3,strokeDasharray:p}),N(tl,{at:{x:u.x2,y:u.y},angle:w?0:Math.PI,kind:x,color:g}),v(C-E/2+9,u.y-12),N("text",{x:C-E/2+24,y:u.y-7.5,fontSize:12.5,fontWeight:m?650:500,fill:m?"var(--poney-accent)":u.kind==="return"?"var(--poney-ink-2)":"var(--poney-ink)",children:u.label})]},u.id)}),[...t.fragments].sort((u,h)=>u.depth-h.depth).map(u=>{var p;const h=Dd(u.kind),m=Re(h,11.5,650)+20,g=(p=u.branches[0])==null?void 0:p.guard;return Z("g",{children:[Z("g",{...n({kind:"fragment",behavior:i,id:u.id},`${h}: ${u.branches.map(x=>x.guard).join(", or ")}`),children:[N("path",{d:`M ${u.x} ${u.y+24} V ${u.y+10} Q ${u.x} ${u.y} ${u.x+10} ${u.y} H ${u.x+m} V ${u.y+16} L ${u.x+m-8} ${u.y+24} Z`,fill:c===u.id?"var(--poney-accent)":"var(--poney-ink-2)"}),N("text",{x:u.x+10,y:u.y+16,fontSize:11.5,fontWeight:650,fill:"var(--poney-paper)",children:h}),N("rect",{x:u.x+m+4,y:u.y+3,width:Re(u.kind==="loop"||u.kind==="opt"?g:`If ${g}`,12,500)+12,height:18,rx:4,fill:"var(--poney-plaster)"}),N("text",{x:u.x+m+10,y:u.y+16,fontSize:12,fontWeight:500,fill:"var(--poney-ink-2)",children:u.kind==="loop"||u.kind==="opt"?g:`If ${g}`})]}),u.branches.slice(1).map((x,y)=>Z("g",{children:[N("line",{x1:u.x,x2:u.x+u.w,y1:x.y,y2:x.y,stroke:"var(--poney-rule-strong)",strokeDasharray:"5 4"}),N("rect",{x:u.x+6,y:x.y+4,width:Re(u.kind==="par"?`And ${x.guard}`:`Else, if ${x.guard}`,12,500)+12,height:18,rx:4,fill:"var(--poney-plaster)"}),N("text",{x:u.x+12,y:x.y+17,fontSize:12,fontWeight:500,fill:"var(--poney-ink-2)",children:u.kind==="par"?`And ${x.guard}`:`Else, if ${x.guard}`})]},y))]},u.id)}),t.participants.map(u=>{const h=e.entities.get(u.entityId),m=e.style(h),g=a==null?void 0:a.people.has(u.entityId),{x:p,y:x,w:y,h:v}=u.header;return Z("g",{transform:`translate(${p} ${x})`,...n({kind:"entity",id:h.id},`${h.name}, ${m.label}`),className:`poney-el ${a&&!g?"poney-dim":""}`,children:[N("rect",{className:"poney-body",width:y,height:v,rx:12,fill:"var(--poney-paper-raised)",stroke:g?pt(m.tone):"var(--poney-rule-strong)",strokeDasharray:h.kind==="external"?"6 4":void 0}),N("rect",{x:12,y:(v-32)/2,width:32,height:32,rx:9,fill:kn(m.tone,14)}),N(pr,{name:m.icon,x:19.5,y:(v-32)/2+7.5,size:17,color:pt(m.tone)}),N("text",{x:54,y:v/2-2,fontSize:14,fontWeight:650,fill:"var(--poney-ink)",children:Ot(h.name,y-64,14,650)}),N("text",{x:54,y:v/2+14,fontSize:11.5,fill:"var(--poney-ink-3)",children:Ot(h.technology??m.label,y-64,11.5)}),N(Sn,{w:y,h:v,selected:d===h.id})]},u.entityId)})]})}function hL(){return Z("div",{className:"poney-legend",children:[N(qn,{line:"solid",label:"Request: the sender waits",color:"var(--poney-ink-2)"}),N(qn,{line:"dashed",label:"Answer to a request",color:"var(--poney-ink-2)"}),Z("div",{className:"poney-legend-row",children:[N("svg",{width:"22",height:"16","aria-hidden":!0,children:N("rect",{x:"7",y:"1",width:"8",height:"14",rx:"2",fill:"var(--poney-sunken)",stroke:"var(--poney-lapis)"})}),"Busy: handling a request"]}),Z("div",{className:"poney-legend-row",children:[Z("svg",{width:"22",height:"16","aria-hidden":!0,children:[N("rect",{x:"1",y:"2",width:"20",height:"12",rx:"3",fill:"none",stroke:"var(--poney-rule-strong)"}),N("rect",{x:"1",y:"2",width:"9",height:"5",rx:"1.5",fill:"var(--poney-ink-2)"})]}),"Condition, loop or parallel paths"]})]})}const pL={key:"sequence",label:"Sequence",icon:St.listOrdered,howToRead:"Time runs down the page. Each column is a participant; arrows are the messages between them, numbered in order. Boxes mark steps that happen only under a condition, repeat, or run in parallel.",Renderer:fL,Legend:hL,initialView:"start"};function mL({scene:t}){const e=gn(),n=jn(),{subject:r,selection:s}=Ws(),i=hr(()=>{if(!r)return null;const l=new Set,c=new Set,d=u=>{c.add(u.id),l.add(u.source),l.add(u.target)};if(r.kind==="entity"){if(!t.nodes.some(u=>u.entityId===r.id))return null;l.add(r.id),t.edges.forEach(u=>(u.source===r.id||u.target===r.id)&&d(u))}else if(r.kind==="dataFlow"||r.kind==="relationship")t.edges.forEach(u=>{var h;return(u.id===r.id||((h=e.dataFlows.get(u.id))==null?void 0:h.via)===r.id)&&d(u)});else if(r.kind==="dataType")t.edges.forEach(u=>u.data.includes(r.id)&&d(u));else return null;return c.size||l.size?{nodes:l,edges:c}:null}),o=(s==null?void 0:s.kind)==="dataFlow"||(s==null?void 0:s.kind)==="relationship"?s.id:void 0,a=(s==null?void 0:s.kind)==="entity"?s.id:void 0;return Z("g",{children:[t.edges.map(l=>{const c=i==null?void 0:i.edges.has(l.id),d=o===l.id,u=l.control?{kind:"relationship",id:l.id}:{kind:"dataFlow",id:l.id},h=d||c?"var(--poney-accent)":l.control?"var(--poney-ink-4)":"var(--poney-ink-2)";return N("g",{...n(u,e.describe(u).title),className:`poney-el ${i&&!c?"poney-dim":""}`,children:N(Rp,{points:l.points,style:{color:h,width:l.control?1:d||c?2:1.6,dash:l.control?"1.5 4":void 0,head:l.control?"open-arrow":"arrow",flowing:!l.control&&(d||c)}})},l.id)}),t.nodes.map(l=>{const c=e.entities.get(l.entityId),d=e.style(c),u=pt(d.tone),h=i&&!i.nodes.has(l.entityId),{w:m,h:g}=l;return Z("g",{transform:`translate(${l.x} ${l.y})`,...n({kind:"entity",id:c.id},`${c.name}, ${l.role}`),className:`poney-el ${h?"poney-dim":""}`,children:[l.role==="process"&&N("rect",{className:"poney-body",width:m,height:g,rx:g/2,fill:"var(--poney-paper-raised)",stroke:u,strokeWidth:1.3}),l.role==="terminator"&&N("rect",{className:"poney-body",width:m,height:g,rx:4,fill:kn(d.tone,10),stroke:u,strokeWidth:1.3}),l.role==="store"&&Z(ft,{children:[N("rect",{width:m,height:g,fill:kn(d.tone,10)}),N("line",{x1:0,x2:m,y1:.5,y2:.5,stroke:u,strokeWidth:1.5}),N("line",{x1:0,x2:m,y1:g-.5,y2:g-.5,stroke:u,strokeWidth:1.5}),N("line",{x1:34,x2:34,y1:0,y2:g,stroke:u,strokeWidth:1})]}),N(pr,{name:d.icon,x:l.role==="store"?9:l.role==="process"?20:14,y:g/2-8,size:16,color:u}),N("text",{x:l.role==="store"?46:l.role==="process"?44:38,y:g/2+(l.role==="store"?4.5:-1),fontSize:13.5,fontWeight:650,fill:"var(--poney-ink)",children:Ot(c.name,m-60,13.5,650)}),l.role!=="store"&&N("text",{x:l.role==="process"?44:38,y:g/2+15,fontSize:11.5,fill:"var(--poney-ink-3)",children:l.role==="process"?"Process":d.label}),N(Sn,{w:m,h:g,rx:l.role==="process"?g/2:4,selected:a===c.id})]},l.id)}),t.edges.map(l=>{if(!l.label)return null;const c=(i==null?void 0:i.edges.has(l.id))||o===l.id,{x:d,y:u,w:h,h:m}=l.label;return Z("g",{transform:`translate(${d} ${u})`,className:i&&!c?"poney-dim":"",pointerEvents:"none",children:[N("rect",{width:h,height:m,rx:m/2,fill:"var(--poney-paper-raised)",stroke:c?"var(--poney-accent)":"var(--poney-rule-strong)"}),N("circle",{cx:11,cy:m/2,r:3,fill:c?"var(--poney-accent)":"var(--poney-malachite)"}),N("text",{x:19,y:m/2+4,fontSize:11.5,fontWeight:c?650:500,fill:c?"var(--poney-accent)":"var(--poney-ink-2)",children:l.label.text})]},`l-${l.id}`)})]})}function gL(){return Z("div",{className:"poney-legend",children:[N(Xt,{shape:"card",tone:"umber",label:"Outside the system: people and providers"}),N(Xt,{shape:"pill",tone:"lapis",label:"Process: code that changes data"}),N(Xt,{shape:"store",tone:"malachite",label:"Store: where data rests"}),N(qn,{line:"solid",label:"Data moving, with what it carries",color:"var(--poney-ink-2)"}),N(qn,{line:"dotted",label:"Control only: a call with no data shown",color:"var(--poney-ink-4)"})]})}const yL={key:"dataflow",label:"Data flow",icon:St.waypoints,howToRead:"Arrows follow the data, not the calls: each one says what moves and in which direction. Select a flow to see its fields.",Renderer:mL,Legend:gL};function xL({scene:t}){const e=gn(),n=jn(),{subject:r,selection:s}=Ws(),i=t.processId,o=hr(()=>{if(!r)return null;const l=new Set,c=new Set;if(r.kind==="activityNode"&&r.behavior===i)l.add(r.id),t.edges.forEach(d=>{(d.from===r.id||d.to===r.id)&&(c.add(d.id),l.add(d.from),l.add(d.to))});else if(r.kind==="activityFlow"&&r.behavior===i){const d=t.edges.find(u=>u.id===r.id);if(!d)return null;c.add(d.id),l.add(d.from),l.add(d.to)}else if(r.kind==="entity"){const d=t.lanes.findIndex(u=>u.entityId===r.id);if(d<0)return null;t.nodes.forEach(u=>u.lane===d&&l.add(u.id)),t.edges.forEach(u=>l.has(u.from)&&l.has(u.to)&&c.add(u.id))}else return null;return{nodes:l,edges:c}}),a=(l,c)=>(s==null?void 0:s.kind)===l&&s.behavior===i&&s.id===c;return Z("g",{children:[t.lanes.map((l,c)=>{const d=l.entityId?e.entities.get(l.entityId):void 0,u=d?e.style(d):void 0,h=(r==null?void 0:r.kind)==="entity"&&r.id===l.entityId;return Z("g",{children:[N("rect",{x:l.x,y:0,width:l.w,height:t.height,fill:c%2?"var(--poney-paper)":"transparent",fillOpacity:.45}),c>0&&N("line",{x1:l.x,x2:l.x,y1:0,y2:t.height,stroke:"var(--poney-rule)"}),Z("g",{...d?n({kind:"entity",id:d.id},`Lane: ${d.name}`):{},children:[N("rect",{x:l.x+8,y:8,width:l.w-16,height:t.laneHeader-16,rx:8,fill:h?"var(--poney-accent-wash)":"var(--poney-paper-raised)",stroke:h?"var(--poney-accent)":"var(--poney-rule)"}),u&&N(pr,{name:u.icon,x:l.x+l.w/2-Re(l.label,13,650)/2-12,y:t.laneHeader/2-7,size:14,color:pt(u.tone)}),N("text",{x:l.x+l.w/2+(u?9:0),y:t.laneHeader/2+4.5,textAnchor:"middle",fontSize:13,fontWeight:650,fill:"var(--poney-ink)",children:l.label})]})]},c)}),t.edges.map(l=>{const c=(o==null?void 0:o.edges.has(l.id))||a("activityFlow",l.id),d=c?"var(--poney-accent)":"var(--poney-ink-3)";return Z("g",{...n({kind:"activityFlow",behavior:i,id:l.id},e.describe({kind:"activityFlow",behavior:i,id:l.id}).title),className:`poney-el ${o&&!c?"poney-dim":""}`,children:[N(Rp,{points:l.points,style:{color:d,width:c?1.9:1.3,head:"arrow",dash:l.back?"6 4":void 0}}),l.guard&&l.guardAt&&Z("g",{pointerEvents:"none",children:[N("rect",{x:l.guardAt.anchor==="end"?l.guardAt.x-Re(l.guard,11.5,650)-12:l.guardAt.x-2,y:l.guardAt.y-11,width:Re(l.guard,11.5,650)+14,height:19,rx:9.5,fill:"var(--poney-plaster)",stroke:c?"var(--poney-accent)":"var(--poney-rule-strong)"}),N("text",{x:l.guardAt.anchor==="end"?l.guardAt.x-5:l.guardAt.x+5,y:l.guardAt.y+2.5,textAnchor:l.guardAt.anchor==="end"?"end":"start",fontSize:11.5,fontWeight:650,fill:c?"var(--poney-accent)":"var(--poney-ink-2)",children:l.guard})]})]},l.id)}),t.nodes.map(l=>{const c=o&&!o.nodes.has(l.id),d=a("activityNode",l.id),u={kind:"activityNode",behavior:i,id:l.id},h=`${e.describe(u).kind}: ${l.label}`,{x:m,y:g,w:p,h:x}=l,y=l.outcome==="failure"?"var(--poney-failure)":l.outcome==="success"?"var(--poney-success)":"var(--poney-ink)";let v;switch(l.kind){case"initial":v=N("circle",{cx:p/2,cy:x/2,r:p/2,fill:"var(--poney-ink)"});break;case"final":v=Z(ft,{children:[N("circle",{cx:p/2,cy:x/2,r:p/2,fill:"var(--poney-paper-raised)",stroke:y,strokeWidth:1.6}),N("circle",{cx:p/2,cy:x/2,r:p/2-5.5,fill:y}),N("text",{x:p/2,y:x+17,textAnchor:"middle",fontSize:12.5,fontWeight:650,fill:y,children:l.label})]});break;case"fork":case"join":v=N("rect",{width:p,height:x,rx:3,fill:"var(--poney-ink)"});break;case"decision":case"merge":v=Z(ft,{children:[N("path",{className:"poney-body",d:`M ${p/2} 0 L ${p} ${x/2} L ${p/2} ${x} L 0 ${x/2} Z`,fill:"var(--poney-paper-raised)",stroke:"var(--poney-ochre)",strokeWidth:1.4,strokeLinejoin:"round"}),N("text",{x:p/2,y:x/2+4.5,textAnchor:"middle",fontSize:12.5,fontWeight:650,fill:"var(--poney-ink)",children:l.label})]});break;default:v=Z(ft,{children:[N("rect",{className:"poney-body",width:p,height:x,rx:10,fill:"var(--poney-paper-raised)",stroke:"var(--poney-rule-strong)",strokeWidth:1.1}),l.lines.map((w,C)=>N("text",{x:p/2,y:x/2+4.5+(C-(l.lines.length-1)/2)*16,textAnchor:"middle",fontSize:13,fontWeight:500,fill:"var(--poney-ink)",children:w},C))]})}const k=l.kind==="fork"||l.kind==="join"?6:0;return Z("g",{transform:`translate(${m} ${g})`,...n(u,h),className:`poney-el ${c?"poney-dim":""}`,children:[k>0&&N("rect",{x:0,y:-k,width:p,height:x+k*2,fill:"transparent"}),v,N(Sn,{w:p,h:x,rx:l.kind==="initial"||l.kind==="final"?p/2:10,selected:d})]},l.id)})]})}function vL(){return Z("div",{className:"poney-legend",children:[N(Xt,{shape:"dot",tone:"ink",label:"Start"}),N(Xt,{shape:"card",tone:"slate",label:"Action"}),N(Xt,{shape:"diamond",tone:"ochre",label:"Decision: one way out per answer"}),N(Xt,{shape:"bar",tone:"ink",label:"Split into, or join, parallel paths"}),N(Xt,{shape:"bullseye",tone:"success",label:"End, in success"}),N(Xt,{shape:"bullseye",tone:"failure",label:"End, in failure"})]})}const kL={key:"activity",label:"Activity",icon:St.gitBranch,howToRead:"Follow the arrows from the black dot. Each column is who does the step. Diamonds ask a question; dashed arrows go back to an earlier step.",Renderer:xL,Legend:vL};function tx({p:t,d:e,card:n,color:r}){const s={x:-e.y,y:e.x},i=(c,d=0)=>({x:t.x-e.x*c+s.x*d,y:t.y-e.y*c+s.y*d}),o=c=>{const d=i(c,6),u=i(c,-6);return N("line",{x1:d.x,y1:d.y,x2:u.x,y2:u.y,stroke:r,strokeWidth:1.4})},a=c=>{const d=i(c);return N("circle",{cx:d.x,cy:d.y,r:4,fill:"var(--poney-paper-raised)",stroke:r,strokeWidth:1.3})},l=()=>{const c=i(13);return N(ft,{children:[-6.5,0,6.5].map(d=>{const u=i(0,d);return N("line",{x1:c.x,y1:c.y,x2:u.x,y2:u.y,stroke:r,strokeWidth:1.3},d)})})};return Z("g",{children:[n==="exactly-one"&&Z(ft,{children:[o(6),o(11)]}),n==="zero-or-one"&&Z(ft,{children:[o(6),a(15)]}),n==="zero-or-many"&&Z(ft,{children:[l(),a(18)]}),n==="one-or-many"&&Z(ft,{children:[l(),o(17)]})]})}const Fw=(t,e)=>{const n=Math.hypot(e.x-t.x,e.y-t.y)||1;return{x:(e.x-t.x)/n,y:(e.y-t.y)/n}};function wL({scene:t,view:e}){const n=gn(),r=jn(),{subject:s,selection:i}=Ws(),[o,a]=Ap(e.id),l=o.expandedTables??[],c=hr(()=>{if(!s)return null;const u=new Set,h=new Set,m=new Set;if(s.kind==="dataType"){if(!t.tables.some(g=>g.dataTypeId===s.id))return null;u.add(s.id);for(const g of t.relations)if(!(g.from!==s.id&&g.to!==s.id)){if(s.field){const x=t.tables.find(v=>v.dataTypeId===s.id).rows.find(v=>v.name===s.field);if(!(g.via===s.field||(x==null?void 0:x.primaryKey)&&g.from===s.id))continue;m.add(`${g.from}#${g.from===s.id?s.field:g.via}`),m.add(`${g.to}#${g.to===s.id?s.field:g.via}`)}h.add(g.id),u.add(g.from),u.add(g.to)}s.field&&m.add(`${s.id}#${s.field}`)}else if(s.kind==="dataRelation"){const g=t.relations.find(p=>p.id===s.id);if(!g)return null;h.add(g.id),u.add(g.from),u.add(g.to),g.via&&(m.add(`${g.to}#${g.via}`),m.add(`${g.from}#${g.via}`))}else if(s.kind==="entity"){if(t.tables.forEach(g=>g.store===s.id&&u.add(g.dataTypeId)),!u.size)return null;t.relations.forEach(g=>u.has(g.from)&&u.has(g.to)&&h.add(g.id))}else return null;return{tables:u,rels:h,rows:m}}),d=u=>a({expandedTables:l.includes(u)?l.filter(h=>h!==u):[...l,u]});return Z("g",{children:[t.stores.map(u=>{const h=n.entities.get(u.entityId),m=n.style(h),g=(i==null?void 0:i.kind)==="entity"&&i.id===h.id;return Z("g",{children:[N("rect",{x:u.x,y:u.y,width:u.w,height:u.h,rx:16,fill:kn(m.tone,5),stroke:"var(--poney-rule-strong)"}),Z("g",{transform:`translate(${u.x} ${u.y})`,...r({kind:"entity",id:h.id},`${h.name}, ${h.technology??"database"}`),children:[N("rect",{x:10,y:8,width:Math.min(u.w-20,320),height:26,rx:7,fill:"transparent"}),N(pr,{name:m.icon,x:18,y:13,size:15,color:pt(m.tone)}),N("text",{x:40,y:25,fontSize:12.5,fontWeight:650,fill:"var(--poney-ink)",children:h.name}),N("text",{x:50+Re(h.name,12.5,650),y:25,fontSize:11.5,fill:"var(--poney-ink-3)",children:h.technology}),g&&N("rect",{x:6,y:4,width:Math.min(u.w-12,330),height:34,rx:9,fill:"none",stroke:"var(--poney-accent)",strokeWidth:1.5})]})]},u.entityId)}),t.relations.map(u=>{const h=c==null?void 0:c.rels.has(u.id),m=(i==null?void 0:i.kind)==="dataRelation"&&i.id===u.id,g=h||m?"var(--poney-accent)":"var(--poney-ink-3)",p=u.points,x=p.length;return Z("g",{...r({kind:"dataRelation",id:u.id},n.describe({kind:"dataRelation",id:u.id}).title),className:`poney-el ${c&&!h?"poney-dim":""}`,children:[N("path",{d:jo(p,8),fill:"none",stroke:"transparent",strokeWidth:14}),N("path",{d:jo(p,8),fill:"none",stroke:g,strokeWidth:h||m?1.8:1.2,strokeDasharray:u.logical?"6 4":void 0,className:"poney-edge"}),N(tx,{p:p[0],d:Fw(p[1],p[0]),card:u.fromCardinality,color:g}),N(tx,{p:p[x-1],d:Fw(p[x-2],p[x-1]),card:u.toCardinality,color:g})]},u.id)}),t.tables.map(u=>{const h=n.dataTypes.get(u.dataTypeId),m=c&&!c.tables.has(u.dataTypeId),g=(i==null?void 0:i.kind)==="dataType"&&i.id===u.dataTypeId&&!i.field,p=h.storedIn?n.style(h.storedIn).tone:"malachite";return Z("g",{transform:`translate(${u.x} ${u.y})`,className:`poney-fade ${m?"poney-dim":""}`,children:[N("rect",{width:u.w,height:u.h,rx:10,fill:"var(--poney-paper-raised)",stroke:c!=null&&c.tables.has(u.dataTypeId)&&(s==null?void 0:s.kind)==="dataType"&&s.id===u.dataTypeId?pt(p):"var(--poney-rule-strong)"}),Z("g",{...r({kind:"dataType",id:u.dataTypeId},`Table ${u.name}, ${h.fields.length} fields`),children:[N("path",{d:`M 0 10 Q 0 0 10 0 H ${u.w-10} Q ${u.w} 0 ${u.w} 10 V ${dt.header} H 0 Z`,fill:kn(p,9)}),N("line",{x1:0,x2:u.w,y1:dt.header,y2:dt.header,stroke:"var(--poney-rule)"}),N("g",{transform:"translate(13 12)",color:pt(p),children:N(bi,{icon:St.table2,width:16,height:16,strokeWidth:1.8})}),N("text",{x:38,y:25,fontSize:13.5,fontWeight:650,fontFamily:"var(--poney-font-mono)",fill:"var(--poney-ink)",children:u.name}),Z("text",{x:u.w-12,y:25,textAnchor:"end",fontSize:11,fill:"var(--poney-ink-3)",className:"poney-numbers",children:[h.fields.length," fields"]})]}),u.rows.map(x=>{const y=x.y-u.y,v=c==null?void 0:c.rows.has(`${u.dataTypeId}#${x.name}`),k=(i==null?void 0:i.kind)==="dataType"&&i.id===u.dataTypeId&&i.field===x.name;return Z("g",{...r({kind:"dataType",id:u.dataTypeId,field:x.name},`Field ${x.name}, ${x.type}${x.primaryKey?", primary key":""}${x.foreign?", foreign key":""}`),children:[N("rect",{x:1,y,width:u.w-2,height:dt.row,fill:k?"var(--poney-accent-wash)":v?kn(p,10):"transparent",className:"poney-row"}),x.primaryKey&&N("g",{transform:`translate(13 ${y+6})`,color:"var(--poney-ochre)",children:N(bi,{icon:St.keyRound,width:13,height:13,strokeWidth:2})}),!x.primaryKey&&x.foreign&&N("g",{transform:`translate(13 ${y+6})`,color:"var(--poney-lapis)",children:N(bi,{icon:St.link2,width:13,height:13,strokeWidth:2})}),N("text",{x:38,y:y+17,fontSize:12.5,fontFamily:"var(--poney-font-mono)",fontWeight:x.primaryKey?600:450,fill:k?"var(--poney-accent)":"var(--poney-ink)",children:x.name}),Z("text",{x:u.w-12,y:y+17,textAnchor:"end",fontSize:11.5,fontFamily:"var(--poney-font-mono)",fill:"var(--poney-ink-3)",children:[Ot(x.type,u.w/2-20,11.5,400,"mono"),x.nullable?"?":""]})]},x.name)}),(u.hiddenCount>0||u.expanded)&&Z("g",{role:"button",tabIndex:0,"data-ref":"toggle","aria-label":u.expanded?`Show fewer fields of ${u.name}`:`Show ${u.hiddenCount} more fields of ${u.name}`,className:"poney-control",onClick:x=>{x.stopPropagation(),d(u.dataTypeId)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),d(u.dataTypeId))},children:[N("rect",{x:1,y:u.h-dt.more-dt.bottom,width:u.w-2,height:dt.more,fill:"transparent"}),N("line",{x1:0,x2:u.w,y1:u.h-dt.more-dt.bottom,y2:u.h-dt.more-dt.bottom,stroke:"var(--poney-rule)"}),N("text",{x:u.w/2,y:u.h-dt.bottom-10,textAnchor:"middle",fontSize:11.5,fontWeight:600,fill:"var(--poney-ink-2)",children:u.expanded?"Show fewer fields":`Show ${u.hiddenCount} more field${u.hiddenCount===1?"":"s"}`}),N("rect",{className:"poney-focus",x:4,y:u.h-dt.more-dt.bottom+2,width:u.w-8,height:dt.more-4,rx:6,fill:"none",stroke:"var(--poney-accent)",strokeWidth:2})]}),N(Sn,{w:u.w,h:u.h,rx:10,selected:g})]},u.dataTypeId)})]})}function bL(){const t=(e,n)=>Z("div",{className:"poney-legend-row",children:[Z("svg",{width:"30",height:"16","aria-hidden":!0,children:[N("line",{x1:"0",y1:"8",x2:"28",y2:"8",stroke:"var(--poney-ink-3)",strokeWidth:"1.2"}),N(tx,{p:{x:28,y:8},d:{x:1,y:0},card:e,color:"var(--poney-ink-2)"})]}),n]});return Z("div",{className:"poney-legend",children:[t("exactly-one","Exactly one"),t("zero-or-one","Zero or one"),t("one-or-many","One or more"),t("zero-or-many","Zero or many"),N(qn,{line:"dashed",label:"Across databases, kept by code",head:!1}),Z("div",{className:"poney-legend-row",children:[N(bi,{icon:St.keyRound,size:13,style:{margin:"0 4px",color:"var(--poney-ochre)"}})," Primary key",N(bi,{icon:St.link2,size:13,style:{marginLeft:8,color:"var(--poney-lapis)"}})," Reference"]})]})}const SL={key:"erd",label:"Entity relationships",icon:St.table2,howToRead:"Each box is a table; the symbols at the line ends say how many rows can be on each side. Tables show their keys first. Select a field to see what it links to.",Renderer:wL,Legend:bL};function CL({scene:t}){const e=gn(),n=jn(),{subject:r,selection:s}=Ws(),i=t.machineId,o=e.stateMachine(i),a=hr(()=>{if(!r)return null;const c=new Set,d=new Set,u=h=>{h&&(d.add(h.id),c.add(h.from),c.add(h.to))};if(r.kind==="state"&&r.behavior===i)c.add(r.id),t.transitions.forEach(h=>(h.from===r.id||h.to===r.id)&&u(h));else if(r.kind==="transition"&&r.behavior===i)u(t.transitions.find(h=>h.id===r.id));else if(r.kind==="entity")o.transitions.forEach(h=>h.triggeredBy===r.id&&u(t.transitions.find(m=>m.id===h.id)));else return null;return d.size||c.size?{states:c,trans:d}:null}),l=(c,d)=>(s==null?void 0:s.kind)===c&&s.behavior===i&&s.id===d;return Z("g",{children:[t.transitions.map(c=>{const d=(a==null?void 0:a.trans.has(c.id))||l("transition",c.id),u=d?"var(--poney-accent)":"var(--poney-ink-3)";return Z("g",{...n({kind:"transition",behavior:i,id:c.id},`Transition: ${c.event}${c.guard?`, when ${c.guard}`:""}`),className:`poney-el ${a&&!d?"poney-dim":""}`,children:[N(Rp,{points:c.points,style:{color:u,width:d?1.9:1.3,head:"arrow"}}),c.label&&Z("g",{transform:`translate(${c.label.x} ${c.label.y})`,children:[N("rect",{width:c.label.w,height:c.label.h,rx:7,fill:"var(--poney-paper-raised)",stroke:d?"var(--poney-accent)":"var(--poney-rule-strong)"}),N("text",{x:c.label.w/2,y:15,textAnchor:"middle",fontSize:11.5,fontWeight:650,fill:d?"var(--poney-accent)":"var(--poney-ink)",children:c.event}),c.guard&&Z("text",{x:c.label.w/2,y:28,textAnchor:"middle",fontSize:10.5,fill:"var(--poney-ink-3)",children:["[",c.guard,"]"]})]})]},c.id)}),t.states.map(c=>{const d=a&&!a.states.has(c.id),u=l("state",c.id),h={kind:"state",behavior:i,id:c.id},m=c.outcome==="success"?"var(--poney-success)":c.outcome==="failure"?"var(--poney-failure)":"var(--poney-rule-strong)";return c.kind==="initial"?Z("g",{transform:`translate(${c.x} ${c.y})`,...n(h,"Start"),className:`poney-el ${d?"poney-dim":""}`,children:[N("circle",{cx:c.w/2,cy:c.h/2,r:c.w/2,fill:"var(--poney-ink)"}),N(Sn,{w:c.w,h:c.h,rx:c.w/2,selected:u})]},c.id):Z("g",{transform:`translate(${c.x} ${c.y})`,...n(h,`State ${c.name}${c.kind==="final"?", final":""}`),className:`poney-el ${d?"poney-dim":""}`,children:[N("rect",{className:"poney-body",width:c.w,height:c.h,rx:16,fill:"var(--poney-paper-raised)",stroke:m,strokeWidth:c.outcome==="neutral"?1.1:1.5}),c.kind==="final"&&N("rect",{x:4,y:4,width:c.w-8,height:c.h-8,rx:12,fill:"none",stroke:m,strokeWidth:1.1}),c.outcome!=="neutral"&&N("circle",{cx:18,cy:c.entryActions.length?22:c.h/2,r:4,fill:m}),N("text",{x:c.w/2,y:c.entryActions.length?27:c.h/2+5,textAnchor:"middle",fontSize:14,fontWeight:650,fill:"var(--poney-ink)",children:c.name}),c.entryActions.length>0&&Z("text",{x:c.w/2,y:46,textAnchor:"middle",fontSize:11,fill:"var(--poney-ink-3)",children:["On entry: ",c.entryActions[0],c.entryActions.length>1?` +${c.entryActions.length-1}`:""]}),N(Sn,{w:c.w,h:c.h,rx:16,selected:u})]},c.id)})]})}function NL(){return Z("div",{className:"poney-legend",children:[N(Xt,{shape:"dot",tone:"ink",label:"Where it starts"}),N(Xt,{shape:"pill",tone:"slate",label:"A state it can be in"}),N(Xt,{shape:"pill",tone:"success",label:"A good outcome"}),N(Xt,{shape:"pill",tone:"failure",label:"A failed or stopped outcome"}),Z("div",{className:"poney-legend-row",children:[Z("svg",{width:"22",height:"16","aria-hidden":!0,children:[N("rect",{x:"1",y:"2",width:"20",height:"12",rx:"5",fill:"none",stroke:"var(--poney-ink-3)"}),N("rect",{x:"3.5",y:"4.5",width:"15",height:"7",rx:"3",fill:"none",stroke:"var(--poney-ink-3)"})]}),"Final: nothing happens after it"]}),N("p",{className:"poney-legend-note",children:"Labels on arrows are events. Text in brackets is the condition that must be true."})]})}const EL={key:"state",label:"State machine",icon:St.circleDot,howToRead:"Each box is a status. Arrows are the events that move it on; select one to see what causes it and what happens next.",Renderer:CL,Legend:NL};function _L({scene:t}){const e=gn(),n=jn(),r=E1(),{subject:s,selection:i}=Ws(),o=hr(()=>{if(!s)return null;const l=new Set,c=new Set;if(s.kind==="entity"&&t.actors.some(d=>d.entityId===s.id))l.add(s.id),t.associations.forEach(d=>d.actor===s.id&&c.add(d.useCase));else if(s.kind==="useCase"&&t.useCases.some(d=>d.id===s.id))c.add(s.id),t.associations.forEach(d=>d.useCase===s.id&&l.add(d.actor)),t.includes.forEach(d=>d.from===s.id&&c.add(d.to));else return null;return{actors:l,caps:c}}),a=l=>!!o&&o.caps.has(l.useCase)&&o.actors.has(l.actor);return Z("g",{children:[N("rect",{x:t.boundary.x,y:t.boundary.y,width:t.boundary.w,height:t.boundary.h,rx:22,fill:"var(--poney-paper)",fillOpacity:.6,stroke:"var(--poney-rule-strong)"}),N("text",{x:t.boundary.x+20,y:t.boundary.y+30,fontSize:13,fontWeight:650,fill:"var(--poney-ink-2)",children:t.boundary.title}),t.areas.map((l,c)=>Z("g",{children:[c>0&&N("line",{x1:l.x,x2:l.x+l.w,y1:l.y-7,y2:l.y-7,stroke:"var(--poney-rule)"}),N("text",{x:l.x+4,y:l.y+18,fontSize:12,fontWeight:650,fill:"var(--poney-ink-3)",children:l.label})]},l.label)),t.associations.map(l=>{const c=a(l),d=(l.from.x+l.to.x)/2;return N("path",{d:`M ${l.from.x} ${l.from.y} C ${d} ${l.from.y} ${d} ${l.to.y} ${l.to.x} ${l.to.y}`,fill:"none",stroke:c?"var(--poney-accent)":"var(--poney-ink-4)",strokeWidth:c?1.8:1.1,strokeDasharray:l.side==="right"?"5 4":void 0,className:`poney-edge ${o&&!c?"poney-dim":""}`},l.id)}),t.includes.map(l=>{const c=(o==null?void 0:o.caps.has(l.from))&&o.caps.has(l.to),d=c?"var(--poney-accent)":"var(--poney-ink-3)",u=`M ${l.a.x} ${l.a.y} C ${l.a.x+48} ${l.a.y+6} ${l.b.x+48} ${l.b.y-6} ${l.b.x+4} ${l.b.y-1}`;return Z("g",{className:o&&!c?"poney-dim":"",children:[N("path",{d:u,fill:"none",stroke:d,strokeDasharray:"4 3",strokeWidth:1.2}),N(tl,{at:{x:l.b.x+2,y:l.b.y},angle:Math.PI*.62,kind:"open-arrow",color:d}),N("text",{x:l.a.x+44,y:(l.a.y+l.b.y)/2+4,fontSize:11,fontStyle:"italic",fill:d,children:"includes"})]},l.id)}),t.useCases.map(l=>{const c=e.useCases.get(l.id),d=o&&!o.caps.has(l.id),u=(i==null?void 0:i.kind)==="useCase"&&i.id===l.id;return Z("g",{transform:`translate(${l.x} ${l.y})`,...n({kind:"useCase",id:l.id},`${c.name}. ${c.summary}`),className:`poney-el ${d?"poney-dim":""}`,children:[N("rect",{className:"poney-body",width:l.w,height:l.h,rx:l.h/2,fill:"var(--poney-paper-raised)",stroke:o!=null&&o.caps.has(l.id)?"var(--poney-tyrian)":"var(--poney-rule-strong)",strokeWidth:1.2}),N("text",{x:l.w/2,y:l.h/2+5,textAnchor:"middle",fontSize:13.5,fontWeight:600,fill:"var(--poney-ink)",children:Ot(c.name,l.w-32,13.5,600)}),N(Sn,{w:l.w,h:l.h,rx:l.h/2,selected:u})]},l.id)}),t.actors.map(l=>{const c=e.entities.get(l.entityId),d=e.style(c),u=o&&!o.actors.has(l.entityId),h=(i==null?void 0:i.kind)==="entity"&&i.id===c.id,m=t.associations.filter(g=>g.actor===c.id).length;return Z("g",{transform:`translate(${l.x} ${l.y})`,...n({kind:"entity",id:c.id},`${c.name}: ${m} things they can do`),className:`poney-el ${u?"poney-dim":""}`,children:[N(Ip,{entity:c,style:d.shape==="person"?d:{...d,shape:"card"},w:l.w,h:l.h,emphasis:h?"selected":"normal",detail:!1}),r>.5&&N("text",{x:l.w/2,y:l.h+16,textAnchor:"middle",fontSize:11.5,fill:"var(--poney-ink-3)",children:l.side==="left"?`Can do ${m} thing${m===1?"":"s"}`:`Supports ${m}`})]},l.entityId)})]})}function jL(){return Z("div",{className:"poney-legend",children:[N(Xt,{shape:"person",tone:"slate",label:"Person who uses the system"}),N(Xt,{shape:"card",tone:"umber",label:"Outside system that helps",dashed:!0}),N(Xt,{shape:"pill",tone:"tyrian",label:"Something a person can do"}),N(qn,{line:"solid",label:"Does it",head:!1}),N(qn,{line:"dashed",label:"Helps with it",head:!1})]})}const $L={key:"usecase",label:"Use cases",icon:St.usersRound,howToRead:"People on the left, the things they can do in the middle, outside services that help on the right. Select a person to see everything they can do.",Renderer:_L,Legend:jL},nx="var(--poney-lapis)",rx="var(--poney-ochre)";function ML({scene:t,view:e}){const n=gn(),r=jn(),{subject:s,selection:i}=Ws(),o=Ap(e.id)[0].transitive??!1,a=n.doc.presentation.relationships,l=_c(13,11,22),c=hr(()=>{if(!s)return null;const u=new Set,h=new Set,m=new Set,g=new Set;if(s.kind==="entity"&&t.nodes.some(p=>p.entityId===s.id)){const p=(x,y)=>{for(const v of t.edges){const k=y?v.source:v.target,w=y?v.target:v.source;if(k!==x)continue;(y?m:g).add(v.id);const C=y?u:h;C.has(w)||w===s.id||(C.add(w),o&&p(w,y))}};return p(s.id,!0),p(s.id,!1),{node:s.id,deps:u,users:h,depEdges:m,userEdges:g,group:null}}if(s.kind==="relationship"){const p=t.edges.find(x=>x.id===s.id);return p?(m.add(p.id),u.add(p.target),h.add(p.source),{node:null,deps:u,users:h,depEdges:m,userEdges:g,group:null}):null}if(s.kind==="group"&&s.view===e.id){const p=t.bands.findIndex(x=>x.id===s.id);return t.nodes.forEach(x=>x.band===p&&u.add(x.entityId)),{node:null,deps:u,users:h,depEdges:m,userEdges:g,group:s.id}}return null},[s,t,o,e.id]),d=u=>c!=null&&c.deps.has(u)?nx:c!=null&&c.users.has(u)?rx:void 0;return Z("g",{children:[t.bands.map((u,h)=>{const m=(i==null?void 0:i.kind)==="group"&&i.id===u.id;return Z("g",{children:[N("rect",{x:u.x,y:u.y,width:u.w,height:u.h,fill:h%2?"var(--poney-paper)":"transparent",fillOpacity:.55}),h>0&&N("line",{x1:u.x,x2:u.x+u.w,y1:u.y,y2:u.y,stroke:"var(--poney-rule)"}),Z("g",{...r({kind:"group",view:e.id,id:u.id},`Layer ${u.label}`),children:[N("rect",{x:12,y:u.y+12,width:148,height:u.h-24,rx:10,fill:m?"var(--poney-accent-wash)":"transparent"}),N("text",{x:24,y:u.y+u.h/2-(u.description&&l===13?4:-4),fontSize:l,fontWeight:650,fill:m?"var(--poney-accent)":"var(--poney-ink-2)",children:u.label}),u.description&&l===13&&N("text",{x:24,y:u.y+u.h/2+13,fontSize:11,fill:"var(--poney-ink-3)",children:Ot(u.description,136,11)})]})]},u.id)}),t.edges.map(u=>{var j,$;const h=a[u.kind]??{pattern:"solid",head:"arrow"},m=c==null?void 0:c.depEdges.has(u.id),g=c==null?void 0:c.userEdges.has(u.id),p=(c==null?void 0:c.group)&&(c.deps.has(u.source)||c.deps.has(u.target)),x=m?nx:g?rx:p?"var(--poney-ink-2)":"var(--poney-ink-4)",y=u.d[u.d.length-1],v=u.d[u.d.length-2],k=Math.atan2(y.y-v.y,y.x-v.x),w=h.head==="triangle"?10:6,C={x:y.x-Math.cos(k)*w,y:y.y-Math.sin(k)*w},E=I=>{let L=`M ${u.d[0].x} ${u.d[0].y}`;for(let D=1;D+2<u.d.length;D+=3){const B=D+2===u.d.length-1?I:u.d[D+2];L+=` C ${u.d[D].x} ${u.d[D].y} ${u.d[D+1].x} ${u.d[D+1].y} ${B.x} ${B.y}`}return L},_=c&&!m&&!g&&!p,S=n.relationships.get(u.id);return Z("g",{...r({kind:"relationship",id:u.id},`${(j=n.entities.get(u.source))==null?void 0:j.name} ${(S==null?void 0:S.kind)==="implements"?"implements":"depends on"} ${($=n.entities.get(u.target))==null?void 0:$.name}`),className:`poney-el ${_?"poney-dim":""}`,children:[N("path",{d:E(y),fill:"none",stroke:"transparent",strokeWidth:12}),N("path",{d:E(C),fill:"none",stroke:x,strokeWidth:m||g?1.9:1.2,strokeDasharray:h.pattern==="dashed"?"5 4":void 0,className:"poney-edge"}),N(tl,{at:y,angle:k,kind:h.head,color:x})]},u.id)}),t.nodes.map(u=>{const h=n.entities.get(u.entityId),m=n.style(h),g=(c==null?void 0:c.node)===u.entityId,p=d(u.entityId),x=c&&!g&&!p,y=(i==null?void 0:i.kind)==="entity"&&i.id===h.id;return Z("g",{transform:`translate(${u.x} ${u.y})`,...r({kind:"entity",id:h.id},`${h.name}, ${m.label}`),className:`poney-el ${x?"poney-dim":""}`,children:[N(Ip,{entity:h,style:{...m,shape:"chip"},w:u.w,h:u.h,emphasis:y?"selected":"normal",detail:!1}),p&&!y&&N("rect",{x:-2,y:-2,width:u.w+4,height:u.h+4,rx:12,fill:"none",stroke:p,strokeWidth:1.6}),N(Sn,{w:u.w,h:u.h,rx:10,selected:!1})]},u.entityId)})]})}function TL(){return Z("div",{className:"poney-legend",children:[N(qn,{line:"solid",label:"Depends on",color:"var(--poney-ink-3)"}),N(qn,{line:"dashed",label:"Implements, or sends events to",color:"var(--poney-ink-3)"}),N(qn,{line:"solid",label:"When selected: what it needs",color:nx}),N(qn,{line:"solid",label:"When selected: what needs it",color:rx}),N("p",{className:"poney-legend-note",children:"Arrows should point down. An arrow that points up is a dependency turned around on purpose, such as an adapter that implements a domain interface."})]})}const OL={key:"dependency",label:"Dependencies",icon:St.blocks,howToRead:"Layers run from the outside in, top to bottom. Select a part: blue shows what it needs, amber shows what needs it. Turn on “follow all the way” to see the full chain.",Renderer:ML,Legend:TL};function AL({scene:t,view:e}){const n=gn().doc,[r,s]=Xj(`map:${e.id}:hot`,null),i=QI(n,e.id)[0],[o,a]=Ap(e.id),l=o.collapsed,c=hr(()=>({marks:i?ZE(i):new Map,mode:"after",focus:null,callouts:new Map,hot:r,setHot:s,toggleGroup:d=>{const u=l??e.collapsed;a({collapsed:u.includes(d)?u.filter(h=>h!==d):[...u,d]})}}));return N(t$,{value:c,children:N(j1,{scene:t})})}const RL={key:"map",label:"Map",icon:St.map,howToRead:"A picture of how parts connect. A part drawn inside another belongs to it; open or close a group with its round button. Hover a line to read what it does.",Renderer:AL},IL=[uL,RL,pL,yL,kL,SL,EL,$L,OL],p$=new Map(IL.map(t=>[t.key,t]));function PL(t){p$.set(t.key,t)}function DL(t){return p$.get(h$(t))}const m$=b.createContext(null),g$=b.createContext(null),y$=b.createContext(1),zL=({value:t,children:e})=>f.jsx(m$.Provider,{value:t,children:e}),x$=({value:t,children:e})=>f.jsx(g$.Provider,{value:t,children:e}),LL=({value:t,children:e})=>f.jsx(y$.Provider,{value:t,children:e});function v$(t){return t.map(e=>typeof e=="string"?e:b.createElement(e.tag,{...e.props,key:e.key},...v$(e.children)))}function FL(t){const e=b.useContext(m$),n=b.useContext(g$),r=b.useContext(y$),[s,i]=b.useState(()=>new Map),o={get:l=>s.get(l),has:l=>s.has(l),update:(l,c)=>i(d=>new Map(d).set(l,c(d.get(l))))};let a=N(Qj.Provider,{value:o,children:t});return a=N(UD,{value:r,children:a}),n&&(a=N(t$,{value:n,children:a})),e&&(a=N(VD,{value:e,children:a})),f.jsx(f.Fragment,{children:v$(BD(a))})}function Pi(t,e=t.name){const n=r=>FL(N(t,r));return n.displayName=e,n}const BL=Pi(iL,"SceneStory");Pi(j1,"MapStory");Pi(o$,"SequenceStory");Pi(a$,"StateStory");const VL=Pi(f$,"EmphasisOver");Pi(u$,"EmphasisUnder");const Bw=new WeakMap;function k$(t){let e=Bw.get(t);return e||Bw.set(t,e=ie(t.name,t.node.map(([n,r],s)=>[n,{...r,key:String(s)}]))),e}const Pp=t=>k$(s$(t)),Vw=new WeakMap;function WL(t){let e=Vw.get(t);return e||(e={...t,icon:k$(t.icon),Renderer:Pi(t.Renderer,`${t.key} diagram`),Legend:t.Legend&&Pi(t.Legend,`${t.key} legend`)},Vw.set(t,e)),e}function rs(t){const e=DL(t);return e&&WL(e)}const M1=[];function w$(t){var e;M1.push(t),(e=t.diagrams)==null||e.forEach(PL),Object.entries(t.layouts??{}).forEach(([n,r])=>ZP(n,r))}const Vd=()=>M1.map(t=>t.core),UL=()=>M1.flatMap(t=>t.inspector??[]);var Je;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{const i={};for(const o of s)i[o]=o;return i},t.getValidEnumValues=s=>{const i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(const a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(const o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Je||(Je={}));var Ww;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Ww||(Ww={}));const ge=Je.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ei=t=>{switch(typeof t){case"undefined":return ge.undefined;case"string":return ge.string;case"number":return Number.isNaN(t)?ge.nan:ge.number;case"boolean":return ge.boolean;case"function":return ge.function;case"bigint":return ge.bigint;case"symbol":return ge.symbol;case"object":return Array.isArray(t)?ge.array:t===null?ge.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?ge.promise:typeof Map<"u"&&t instanceof Map?ge.map:typeof Set<"u"&&t instanceof Set?ge.set:typeof Date<"u"&&t instanceof Date?ge.date:ge.object;default:return ge.unknown}},ne=Je.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);let Io=class b$ extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(o))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return s(this),r}static assert(e){if(!(e instanceof b$))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Je.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},r=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}};Io.create=t=>new Io(t);const sx=(t,e)=>{let n;switch(t.code){case ne.invalid_type:t.received===ge.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case ne.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,Je.jsonStringifyReplacer)}`;break;case ne.unrecognized_keys:n=`Unrecognized key(s) in object: ${Je.joinValues(t.keys,", ")}`;break;case ne.invalid_union:n="Invalid input";break;case ne.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Je.joinValues(t.options)}`;break;case ne.invalid_enum_value:n=`Invalid enum value. Expected ${Je.joinValues(t.options)}, received '${t.received}'`;break;case ne.invalid_arguments:n="Invalid function arguments";break;case ne.invalid_return_type:n="Invalid function return type";break;case ne.invalid_date:n="Invalid date";break;case ne.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:Je.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case ne.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case ne.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case ne.custom:n="Invalid input";break;case ne.invalid_intersection_types:n="Intersection results could not be merged";break;case ne.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case ne.not_finite:n="Number must be finite";break;default:n=e.defaultError,Je.assertNever(t)}return{message:n}};let ZL=sx;function HL(){return ZL}const qL=t=>{const{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)a=c(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}};function le(t,e){const n=HL(),r=qL({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===sx?void 0:sx].filter(s=>!!s)});t.common.issues.push(r)}let Rr=class S${constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const s of n){if(s.status==="aborted")return $e;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const s of n){const i=await s.key,o=await s.value;r.push({key:i,value:o})}return S$.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const s of n){const{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return $e;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}};const $e=Object.freeze({status:"aborted"}),ac=t=>({status:"dirty",value:t}),yr=t=>({status:"valid",value:t}),Uw=t=>t.status==="aborted",Zw=t=>t.status==="dirty",nl=t=>t.status==="valid",rh=t=>typeof Promise<"u"&&t instanceof Promise;var ve;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ve||(ve={}));let Di=class{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const Hw=(t,e)=>{if(nl(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Io(t.common.issues);return this._error=n,this._error}}};function ze(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{const{message:l}=t;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:s}}let qe=class{get description(){return this._def.description}_getType(e){return ei(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:ei(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Rr,ctx:{common:e.parent.common,data:e.data,parsedType:ei(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(rh(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ei(e)},s=this._parseSync({data:e,path:r.path,parent:r});return Hw(r,s)}"~validate"(e){var r,s;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ei(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:n});return nl(i)?{value:i.value}:{issues:n.common.issues}}catch(i){(s=(r=i==null?void 0:i.message)==null?void 0:r.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(i=>nl(i)?{value:i.value}:{issues:n.common.issues})}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ei(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(rh(s)?s:Promise.resolve(s));return Hw(r,i)}refine(e,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const o=e(s),a=()=>i.addIssue({code:ne.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new sl({schema:this,typeName:Te.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Si.create(this,this._def)}nullable(){return il.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return rl.create(this)}promise(){return oh.create(this,this._def)}or(e){return sh.create([this,e],this._def)}and(e){return ih.create(this,e,this._def)}transform(e){return new sl({...ze(this._def),schema:this,typeName:Te.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new fx({...ze(this._def),innerType:this,defaultValue:n,typeName:Te.ZodDefault})}brand(){return new g6({typeName:Te.ZodBranded,type:this,...ze(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new hx({...ze(this._def),innerType:this,catchValue:n,typeName:Te.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return y6.create(this,e)}readonly(){return px.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const KL=/^c[^\s-]{8,}$/i,JL=/^[0-9a-z]+$/,GL=/^[0-9A-HJKMNP-TV-Z]{26}$/i,YL=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,QL=/^[a-z0-9_-]{21}$/i,XL=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,e6=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,t6=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,n6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Hm;const r6=/^(?:(?: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])$/,s6=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,i6=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,o6=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,a6=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,l6=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,C$="((\\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])))",c6=new RegExp(`^${C$}$`);function N$(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function d6(t){return new RegExp(`^${N$(t)}$`)}function u6(t){let e=`${C$}T${N$(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function f6(t,e){return!!((e==="v4"||!e)&&r6.test(t)||(e==="v6"||!e)&&i6.test(t))}function h6(t,e){if(!XL.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function p6(t,e){return!!((e==="v4"||!e)&&s6.test(t)||(e==="v6"||!e)&&o6.test(t))}let ix=class lc extends qe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ge.string){const i=this._getOrReturnCtx(e);return le(i,{code:ne.invalid_type,expected:ge.string,received:i.parsedType}),$e}const r=new Rr;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),le(s,{code:ne.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),le(s,{code:ne.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?le(s,{code:ne.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&le(s,{code:ne.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")t6.test(e.data)||(s=this._getOrReturnCtx(e,s),le(s,{validation:"email",code:ne.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Hm||(Hm=new RegExp(n6,"u")),Hm.test(e.data)||(s=this._getOrReturnCtx(e,s),le(s,{validation:"emoji",code:ne.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")YL.test(e.data)||(s=this._getOrReturnCtx(e,s),le(s,{validation:"uuid",code:ne.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")QL.test(e.data)||(s=this._getOrReturnCtx(e,s),le(s,{validation:"nanoid",code:ne.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")KL.test(e.data)||(s=this._getOrReturnCtx(e,s),le(s,{validation:"cuid",code:ne.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")JL.test(e.data)||(s=this._getOrReturnCtx(e,s),le(s,{validation:"cuid2",code:ne.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")GL.test(e.data)||(s=this._getOrReturnCtx(e,s),le(s,{validation:"ulid",code:ne.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),le(s,{validation:"url",code:ne.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),le(s,{validation:"regex",code:ne.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),le(s,{code:ne.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),le(s,{code:ne.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),le(s,{code:ne.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?u6(i).test(e.data)||(s=this._getOrReturnCtx(e,s),le(s,{code:ne.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?c6.test(e.data)||(s=this._getOrReturnCtx(e,s),le(s,{code:ne.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?d6(i).test(e.data)||(s=this._getOrReturnCtx(e,s),le(s,{code:ne.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?e6.test(e.data)||(s=this._getOrReturnCtx(e,s),le(s,{validation:"duration",code:ne.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?f6(e.data,i.version)||(s=this._getOrReturnCtx(e,s),le(s,{validation:"ip",code:ne.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?h6(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),le(s,{validation:"jwt",code:ne.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?p6(e.data,i.version)||(s=this._getOrReturnCtx(e,s),le(s,{validation:"cidr",code:ne.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?a6.test(e.data)||(s=this._getOrReturnCtx(e,s),le(s,{validation:"base64",code:ne.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?l6.test(e.data)||(s=this._getOrReturnCtx(e,s),le(s,{validation:"base64url",code:ne.invalid_string,message:i.message}),r.dirty()):Je.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:ne.invalid_string,...ve.errToObj(r)})}_addCheck(e){return new lc({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ve.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ve.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ve.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ve.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ve.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ve.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ve.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ve.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ve.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...ve.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...ve.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ve.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...ve.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...ve.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...ve.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...ve.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...ve.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...ve.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...ve.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...ve.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...ve.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...ve.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...ve.errToObj(n)})}nonempty(e){return this.min(1,ve.errToObj(e))}trim(){return new lc({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new lc({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new lc({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};ix.create=t=>new ix({checks:[],typeName:Te.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...ze(t)});function m6(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}let qw=class ox extends qe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==ge.number){const i=this._getOrReturnCtx(e);return le(i,{code:ne.invalid_type,expected:ge.number,received:i.parsedType}),$e}let r;const s=new Rr;for(const i of this._def.checks)i.kind==="int"?Je.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),le(r,{code:ne.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),le(r,{code:ne.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),le(r,{code:ne.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?m6(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),le(r,{code:ne.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),le(r,{code:ne.not_finite,message:i.message}),s.dirty()):Je.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,ve.toString(n))}gt(e,n){return this.setLimit("min",e,!1,ve.toString(n))}lte(e,n){return this.setLimit("max",e,!0,ve.toString(n))}lt(e,n){return this.setLimit("max",e,!1,ve.toString(n))}setLimit(e,n,r,s){return new ox({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:ve.toString(s)}]})}_addCheck(e){return new ox({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ve.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ve.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ve.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ve.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ve.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:ve.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:ve.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ve.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ve.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Je.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}};qw.create=t=>new qw({checks:[],typeName:Te.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...ze(t)});let Kw=class ax extends qe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==ge.bigint)return this._getInvalidInput(e);let r;const s=new Rr;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),le(r,{code:ne.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),le(r,{code:ne.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),le(r,{code:ne.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Je.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return le(n,{code:ne.invalid_type,expected:ge.bigint,received:n.parsedType}),$e}gte(e,n){return this.setLimit("min",e,!0,ve.toString(n))}gt(e,n){return this.setLimit("min",e,!1,ve.toString(n))}lte(e,n){return this.setLimit("max",e,!0,ve.toString(n))}lt(e,n){return this.setLimit("max",e,!1,ve.toString(n))}setLimit(e,n,r,s){return new ax({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:ve.toString(s)}]})}_addCheck(e){return new ax({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ve.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ve.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ve.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ve.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:ve.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}};Kw.create=t=>new Kw({checks:[],typeName:Te.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...ze(t)});let lx=class extends qe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ge.boolean){const r=this._getOrReturnCtx(e);return le(r,{code:ne.invalid_type,expected:ge.boolean,received:r.parsedType}),$e}return yr(e.data)}};lx.create=t=>new lx({typeName:Te.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...ze(t)});let Jw=class E$ extends qe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ge.date){const i=this._getOrReturnCtx(e);return le(i,{code:ne.invalid_type,expected:ge.date,received:i.parsedType}),$e}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return le(i,{code:ne.invalid_date}),$e}const r=new Rr;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),le(s,{code:ne.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),le(s,{code:ne.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):Je.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new E$({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:ve.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:ve.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}};Jw.create=t=>new Jw({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Te.ZodDate,...ze(t)});let Gw=class extends qe{_parse(e){if(this._getType(e)!==ge.symbol){const r=this._getOrReturnCtx(e);return le(r,{code:ne.invalid_type,expected:ge.symbol,received:r.parsedType}),$e}return yr(e.data)}};Gw.create=t=>new Gw({typeName:Te.ZodSymbol,...ze(t)});let Yw=class extends qe{_parse(e){if(this._getType(e)!==ge.undefined){const r=this._getOrReturnCtx(e);return le(r,{code:ne.invalid_type,expected:ge.undefined,received:r.parsedType}),$e}return yr(e.data)}};Yw.create=t=>new Yw({typeName:Te.ZodUndefined,...ze(t)});let Qw=class extends qe{_parse(e){if(this._getType(e)!==ge.null){const r=this._getOrReturnCtx(e);return le(r,{code:ne.invalid_type,expected:ge.null,received:r.parsedType}),$e}return yr(e.data)}};Qw.create=t=>new Qw({typeName:Te.ZodNull,...ze(t)});let Xw=class extends qe{constructor(){super(...arguments),this._any=!0}_parse(e){return yr(e.data)}};Xw.create=t=>new Xw({typeName:Te.ZodAny,...ze(t)});let eb=class extends qe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return yr(e.data)}};eb.create=t=>new eb({typeName:Te.ZodUnknown,...ze(t)});let zi=class extends qe{_parse(e){const n=this._getOrReturnCtx(e);return le(n,{code:ne.invalid_type,expected:ge.never,received:n.parsedType}),$e}};zi.create=t=>new zi({typeName:Te.ZodNever,...ze(t)});let tb=class extends qe{_parse(e){if(this._getType(e)!==ge.undefined){const r=this._getOrReturnCtx(e);return le(r,{code:ne.invalid_type,expected:ge.void,received:r.parsedType}),$e}return yr(e.data)}};tb.create=t=>new tb({typeName:Te.ZodVoid,...ze(t)});let rl=class sf extends qe{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==ge.array)return le(n,{code:ne.invalid_type,expected:ge.array,received:n.parsedType}),$e;if(s.exactLength!==null){const o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(le(n,{code:o?ne.too_big:ne.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(le(n,{code:ne.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(le(n,{code:ne.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new Di(n,o,n.path,a)))).then(o=>Rr.mergeArray(r,o));const i=[...n.data].map((o,a)=>s.type._parseSync(new Di(n,o,n.path,a)));return Rr.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new sf({...this._def,minLength:{value:e,message:ve.toString(n)}})}max(e,n){return new sf({...this._def,maxLength:{value:e,message:ve.toString(n)}})}length(e,n){return new sf({...this._def,exactLength:{value:e,message:ve.toString(n)}})}nonempty(e){return this.min(1,e)}};rl.create=(t,e)=>new rl({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Te.ZodArray,...ze(e)});function da(t){if(t instanceof Ds){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=Si.create(da(r))}return new Ds({...t._def,shape:()=>e})}else return t instanceof rl?new rl({...t._def,type:da(t.element)}):t instanceof Si?Si.create(da(t.unwrap())):t instanceof il?il.create(da(t.unwrap())):t instanceof id?id.create(t.items.map(e=>da(e))):t}let Ds=class br extends qe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=Je.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==ge.object){const c=this._getOrReturnCtx(e);return le(c,{code:ne.invalid_type,expected:ge.object,received:c.parsedType}),$e}const{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof zi&&this._def.unknownKeys==="strip"))for(const c in s.data)o.includes(c)||a.push(c);const l=[];for(const c of o){const d=i[c],u=s.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new Di(s,u,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof zi){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of a)l.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(c==="strict")a.length>0&&(le(s,{code:ne.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of a){const u=s.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new Di(s,u,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of l){const u=await d.key,h=await d.value;c.push({key:u,value:h,alwaysSet:d.alwaysSet})}return c}).then(c=>Rr.mergeObjectSync(r,c)):Rr.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return ve.errToObj,new br({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{var i,o;const s=((o=(i=this._def).errorMap)==null?void 0:o.call(i,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:ve.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new br({...this._def,unknownKeys:"strip"})}passthrough(){return new br({...this._def,unknownKeys:"passthrough"})}extend(e){return new br({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new br({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Te.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new br({...this._def,catchall:e})}pick(e){const n={};for(const r of Je.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new br({...this._def,shape:()=>n})}omit(e){const n={};for(const r of Je.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new br({...this._def,shape:()=>n})}deepPartial(){return da(this)}partial(e){const n={};for(const r of Je.objectKeys(this.shape)){const s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new br({...this._def,shape:()=>n})}required(e){const n={};for(const r of Je.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Si;)i=i._def.innerType;n[r]=i}return new br({...this._def,shape:()=>n})}keyof(){return j$(Je.objectKeys(this.shape))}};Ds.create=(t,e)=>new Ds({shape:()=>t,unknownKeys:"strip",catchall:zi.create(),typeName:Te.ZodObject,...ze(e)});Ds.strictCreate=(t,e)=>new Ds({shape:()=>t,unknownKeys:"strict",catchall:zi.create(),typeName:Te.ZodObject,...ze(e)});Ds.lazycreate=(t,e)=>new Ds({shape:t,unknownKeys:"strip",catchall:zi.create(),typeName:Te.ZodObject,...ze(e)});let sh=class extends qe{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(const a of i)if(a.result.status==="valid")return a.result;for(const a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(a=>new Io(a.ctx.common.issues));return le(n,{code:ne.invalid_union,unionErrors:o}),$e}if(n.common.async)return Promise.all(r.map(async i=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i;const o=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},d=l._parseSync({data:n.data,path:n.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!i&&(i={result:d,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const a=o.map(l=>new Io(l));return le(n,{code:ne.invalid_union,unionErrors:a}),$e}}get options(){return this._def.options}};sh.create=(t,e)=>new sh({options:t,typeName:Te.ZodUnion,...ze(e)});function cx(t,e){const n=ei(t),r=ei(e);if(t===e)return{valid:!0,data:t};if(n===ge.object&&r===ge.object){const s=Je.objectKeys(e),i=Je.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(const a of i){const l=cx(t[a],e[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===ge.array&&r===ge.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<t.length;i++){const o=t[i],a=e[i],l=cx(o,a);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return n===ge.date&&r===ge.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}let ih=class extends qe{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(Uw(i)||Uw(o))return $e;const a=cx(i.value,o.value);return a.valid?((Zw(i)||Zw(o))&&n.dirty(),{status:n.value,value:a.data}):(le(r,{code:ne.invalid_intersection_types}),$e)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};ih.create=(t,e,n)=>new ih({left:t,right:e,typeName:Te.ZodIntersection,...ze(n)});let id=class _$ extends qe{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==ge.array)return le(r,{code:ne.invalid_type,expected:ge.array,received:r.parsedType}),$e;if(r.data.length<this._def.items.length)return le(r,{code:ne.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),$e;!this._def.rest&&r.data.length>this._def.items.length&&(le(r,{code:ne.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((o,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new Di(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>Rr.mergeArray(n,o)):Rr.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new _$({...this._def,rest:e})}};id.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new id({items:t,typeName:Te.ZodTuple,rest:null,...ze(e)})};let nb=class extends qe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==ge.map)return le(r,{code:ne.invalid_type,expected:ge.map,received:r.parsedType}),$e;const s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,l],c)=>({key:s._parse(new Di(r,a,r.path,[c,"key"])),value:i._parse(new Di(r,l,r.path,[c,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of o){const c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return $e;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(c.value,d.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const l of o){const c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return $e;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(c.value,d.value)}return{status:n.value,value:a}}}};nb.create=(t,e,n)=>new nb({valueType:e,keyType:t,typeName:Te.ZodMap,...ze(n)});let rb=class dx extends qe{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==ge.set)return le(r,{code:ne.invalid_type,expected:ge.set,received:r.parsedType}),$e;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(le(r,{code:ne.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(le(r,{code:ne.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function o(l){const c=new Set;for(const d of l){if(d.status==="aborted")return $e;d.status==="dirty"&&n.dirty(),c.add(d.value)}return{status:n.value,value:c}}const a=[...r.data.values()].map((l,c)=>i._parse(new Di(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(e,n){return new dx({...this._def,minSize:{value:e,message:ve.toString(n)}})}max(e,n){return new dx({...this._def,maxSize:{value:e,message:ve.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}};rb.create=(t,e)=>new rb({valueType:t,minSize:null,maxSize:null,typeName:Te.ZodSet,...ze(e)});let sb=class extends qe{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}};sb.create=(t,e)=>new sb({getter:t,typeName:Te.ZodLazy,...ze(e)});let ib=class extends qe{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return le(n,{received:n.data,code:ne.invalid_literal,expected:this._def.value}),$e}return{status:"valid",value:e.data}}get value(){return this._def.value}};ib.create=(t,e)=>new ib({value:t,typeName:Te.ZodLiteral,...ze(e)});function j$(t,e){return new T1({values:t,typeName:Te.ZodEnum,...ze(e)})}let T1=class ux extends qe{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return le(n,{expected:Je.joinValues(r),received:n.parsedType,code:ne.invalid_type}),$e}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),r=this._def.values;return le(n,{received:n.data,code:ne.invalid_enum_value,options:r}),$e}return yr(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return ux.create(e,{...this._def,...n})}exclude(e,n=this._def){return ux.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}};T1.create=j$;let ob=class extends qe{_parse(e){const n=Je.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==ge.string&&r.parsedType!==ge.number){const s=Je.objectValues(n);return le(r,{expected:Je.joinValues(s),received:r.parsedType,code:ne.invalid_type}),$e}if(this._cache||(this._cache=new Set(Je.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=Je.objectValues(n);return le(r,{received:r.data,code:ne.invalid_enum_value,options:s}),$e}return yr(e.data)}get enum(){return this._def.values}};ob.create=(t,e)=>new ob({values:t,typeName:Te.ZodNativeEnum,...ze(e)});let oh=class extends qe{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==ge.promise&&n.common.async===!1)return le(n,{code:ne.invalid_type,expected:ge.promise,received:n.parsedType}),$e;const r=n.parsedType===ge.promise?n.data:Promise.resolve(n.data);return yr(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}};oh.create=(t,e)=>new oh({type:t,typeName:Te.ZodPromise,...ze(e)});let sl=class extends qe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Te.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{le(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return $e;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?$e:l.status==="dirty"||n.value==="dirty"?ac(l.value):l});{if(n.value==="aborted")return $e;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?$e:a.status==="dirty"||n.value==="dirty"?ac(a.value):a}}if(s.type==="refinement"){const o=a=>{const l=s.refinement(a,i);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?$e:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?$e:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!nl(o))return $e;const a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>nl(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):$e);Je.assertNever(s)}};sl.create=(t,e,n)=>new sl({schema:t,typeName:Te.ZodEffects,effect:e,...ze(n)});sl.createWithPreprocess=(t,e,n)=>new sl({schema:e,effect:{type:"preprocess",transform:t},typeName:Te.ZodEffects,...ze(n)});let Si=class extends qe{_parse(e){return this._getType(e)===ge.undefined?yr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Si.create=(t,e)=>new Si({innerType:t,typeName:Te.ZodOptional,...ze(e)});let il=class extends qe{_parse(e){return this._getType(e)===ge.null?yr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};il.create=(t,e)=>new il({innerType:t,typeName:Te.ZodNullable,...ze(e)});let fx=class extends qe{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===ge.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}};fx.create=(t,e)=>new fx({innerType:t,typeName:Te.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ze(e)});let hx=class extends qe{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return rh(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Io(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Io(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};hx.create=(t,e)=>new hx({innerType:t,typeName:Te.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ze(e)});let ab=class extends qe{_parse(e){if(this._getType(e)!==ge.nan){const r=this._getOrReturnCtx(e);return le(r,{code:ne.invalid_type,expected:ge.nan,received:r.parsedType}),$e}return{status:"valid",value:e.data}}};ab.create=t=>new ab({typeName:Te.ZodNaN,...ze(t)});let g6=class extends qe{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}},y6=class $$ extends qe{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?$e:i.status==="dirty"?(n.dirty(),ac(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?$e:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new $$({in:e,out:n,typeName:Te.ZodPipeline})}},px=class extends qe{_parse(e){const n=this._def.innerType._parse(e),r=s=>(nl(s)&&(s.value=Object.freeze(s.value)),s);return rh(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}};px.create=(t,e)=>new px({innerType:t,typeName:Te.ZodReadonly,...ze(e)});var Te;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Te||(Te={}));const qm=ix.create,x6=lx.create;zi.create;const v6=rl.create,M$=Ds.create;sh.create;ih.create;id.create;T1.create;oh.create;Si.create;il.create;const k6=M$({team:oe.optional(),oncall:qm().optional(),channel:qm().optional(),mission:qm().optional()}).strict(),mx=M$({teams:v6(oe).min(1),showUnowned:x6().default(!1)}),ah="ownership/team",Dp={name:"ownership",version:"0.1.0",description:"Teams, who owns what, and how to reach them.",entityKinds:{team:{label:"Team",description:"A group of people who own and run parts of the system."}},facets:{entity:k6},views:{"team-map":{label:"Team map",description:"Every team and the parts of the system it owns.",schema:mx}},validate(t,{index:e,report:n}){t.model.entities.forEach((r,s)=>{const i=Jr(Dp,"entity",r);if(!(i!=null&&i.team))return;const o=e.entities.get(i.team);o?o.kind!==ah&&n(`model.entities.${s}.ext.ownership.team`,`"${i.team}" is not a team`):n(`model.entities.${s}.ext.ownership.team`,`Unknown team "${i.team}"`)}),t.views.forEach((r,s)=>{if(r.type!=="extension"||r.extension!=="ownership/team-map")return;const i=mx.safeParse(r.data);i.success&&i.data.teams.forEach((o,a)=>{var l;((l=e.entities.get(o))==null?void 0:l.kind)!==ah&&n(`views.${s}.data.teams.${a}`,`"${o}" is not a team`)})})}},ol=t=>Jr(Dp,"entity",t);function w6(t,e){var r;const n=(r=ol(e))==null?void 0:r.team;return n?t.model.entities.find(s=>s.id===n):void 0}function T$(t,e){return t.model.entities.filter(n=>{var r;return((r=ol(n))==null?void 0:r.team)===e})}const Kl=248,Km=28,Jm=104,Gm=50,Ym=4;function b6(t,e){const n=mx.safeParse(e.data);if(!n.success)throw new Error(`The ${Dp.name} team map has invalid data`);const r=[],s=[];let i=24;for(let l=0;l<n.data.teams.length;l+=Ym){const c=n.data.teams.slice(l,l+Ym);let d=0;c.forEach((u,h)=>{const m=t.model.entities.find(v=>v.id===u);if(!m)return;const g=ol(m),p=24+h*(Kl+Km),x=T$(t,u);x.forEach((v,k)=>s.push({entityId:v.id,team:u,x:p+12,y:i+Jm+12+k*(Gm+8),w:Kl-24,h:Gm}));const y=Jm+12+x.length*(Gm+8)+8;d=Math.max(d,y),r.push({entityId:u,x:p,y:i,w:Kl,h:y,header:Jm,mission:Ff((g==null?void 0:g.mission)??m.summary,Kl-32,12,400,2),oncall:g==null?void 0:g.oncall,channel:g==null?void 0:g.channel})});for(const u of r.filter(h=>h.y===i))u.h=d;i+=d+Km}const o={};for(const l of r)o[fe({kind:"entity",id:l.entityId})]=l;for(const l of s)o[fe({kind:"entity",id:l.entityId})]=l;const a=Math.min(Ym,n.data.teams.length);return{width:48+a*Kl+(a-1)*Km,height:i,teams:r,owned:s,anchors:o}}function S6({scene:t}){const e=gn(),n=jn(),{subject:r,selection:s}=Ws(),i=hr(()=>{var a;if((r==null?void 0:r.kind)!=="entity")return null;const o=e.entities.get(r.id);return(o==null?void 0:o.kind)===ah?o.id:((a=ol(o))==null?void 0:a.team)??null});return Z("g",{children:[t.teams.map(o=>{const a=e.entities.get(o.entityId),l=e.style(a),c=pt(l.tone),d=i&&i!==o.entityId,u=(s==null?void 0:s.kind)==="entity"&&s.id===o.entityId;return Z("g",{className:`poney-fade ${d?"poney-dim":""}`,children:[N("rect",{x:o.x,y:o.y,width:o.w,height:o.h,rx:16,fill:"var(--poney-paper)",fillOpacity:.6,stroke:"var(--poney-rule-strong)"}),Z("g",{transform:`translate(${o.x} ${o.y})`,...n({kind:"entity",id:a.id},`${a.name}. ${a.summary}`),children:[N("path",{d:`M 0 16 Q 0 0 16 0 H ${o.w-16} Q ${o.w} 0 ${o.w} 16 V ${o.header} H 0 Z`,fill:kn(l.tone,12)}),N(pr,{name:l.icon,x:16,y:16,size:16,color:c}),N("text",{x:40,y:29,fontSize:14,fontWeight:650,fill:"var(--poney-ink)",children:a.name}),o.mission.map((h,m)=>N("text",{x:16,y:52+m*15,fontSize:12,fill:"var(--poney-ink-2)",children:h},m)),Z("text",{x:16,y:o.header-12,fontSize:11,fill:"var(--poney-ink-3)",children:["On call: ",o.oncall??"none"]}),N(Sn,{w:o.w,h:o.header,rx:16,selected:u})]})]},o.entityId)}),t.owned.map(o=>{var d;const a=e.entities.get(o.entityId),l=i&&i!==o.team,c=(s==null?void 0:s.kind)==="entity"&&s.id===a.id;return N("g",{transform:`translate(${o.x} ${o.y})`,...n({kind:"entity",id:a.id},`${a.name}, owned by ${(d=e.entities.get(o.team))==null?void 0:d.name}`),className:`poney-el ${l?"poney-dim":""}`,children:N(Ip,{entity:a,style:{...e.style(a),shape:"chip"},w:o.w,h:o.h,emphasis:c?"selected":"normal",detail:!1})},o.entityId)})]})}const C6={key:"ownership/team-map",label:"Team map",icon:St.users,howToRead:"One column per team, with everything it owns. Select a part anywhere in the studio to see its team and who is on call.",Renderer:S6},lb=t=>{let e;const n=new Set,r=(c,d)=>{const u=typeof c=="function"?c(e):c;if(!Object.is(u,e)){const h=e;e=d??(typeof u!="object"||u===null)?u:Object.assign({},e,u),n.forEach(m=>m(e,h))}},s=()=>e,a={setState:r,getState:s,getInitialState:()=>l,subscribe:c=>(n.add(c),()=>n.delete(c))},l=e=t(r,s,a);return a},N6=t=>t?lb(t):lb,E6=t=>t;function _6(t,e=E6){const n=_r.useSyncExternalStore(t.subscribe,_r.useCallback(()=>e(t.getState()),[t,e]),()=>e(t.getInitialState()));return _r.useDebugValue(n),n}const j6=t=>{const e=N6(t),n=r=>_6(e,r);return Object.assign(n,e),n},$6=t=>j6,bt="__overview",Hr="walk:",zp=t=>t.startsWith(Hr)?t.slice(Hr.length):void 0,Wd=t=>t.live.state==="on"&&(!!t.agent.session||t.agent.listening),bu={get(t,e){try{const n=localStorage.getItem(`poney:${t}`);return n?JSON.parse(n):e}catch{return e}},set(t,e){try{localStorage.setItem(`poney:${t}`,JSON.stringify(e))}catch{}}};let M6=0;const na=(t,e=null)=>({ref:e,mode:t,nonce:++M6}),R=$6()((t,e)=>({projects:[],projectId:"",importOpen:!1,importText:"",shortcutsOpen:!1,setImportOpen:(n,r)=>t({importOpen:n,importText:r??(n?e().importText:"")}),setShortcutsOpen:n=>t({shortcutsOpen:n}),history:void 0,viewId:bt,selection:null,hover:null,focus:null,back:[],forward:[],sidebarOpen:typeof window>"u"||window.innerWidth>900,inspectorOpen:typeof window>"u"||window.innerWidth>1180,paletteOpen:!1,theme:bu.get("theme","light"),pinned:bu.get("pinned",[]),viewUi:{},notice:null,live:{state:"off"},activeScene:null,conversation:[],agent:{session:null,listening:!1},jump:null,startOpen:!0,showStart:n=>t({startOpen:n||!e().history}),setLive:n=>t({live:n}),setActiveScene:n=>t({activeScene:n}),setConversation:n=>t({conversation:n}),putMessage(n){const r=e().conversation,s=r.findIndex(i=>i.id===n.id);t({conversation:s<0?[...r,n]:r.map((i,o)=>o===s?n:i)})},setAgent:n=>t({agent:n}),connectOpen:!1,agentPanelOpen:!1,setConnectOpen:n=>t({connectOpen:n}),setAgentPanelOpen:n=>t({agentPanelOpen:n}),liveFile:null,fileOpen:!1,setLiveFile:n=>t({liveFile:n}),setFileOpen:n=>t({fileOpen:n}),project:null,overlays:{},importCodeOpen:!1,projectOpen:!1,setProject:n=>t({project:n}),setOverlays:n=>t({overlays:n}),setImportCodeOpen:n=>t({importCodeOpen:n}),setProjectOpen:n=>t({projectOpen:n}),renaming:null,setRenaming:n=>t({renaming:n}),chips:[],pointing:!1,contextMenu:null,addChip(n){const r=e().chips,s=r.some(i=>n.ref?i.ref===n.ref:i.quote===n.quote);t({chips:s?r:[...r,n]})},removeChip:n=>t({chips:e().chips.filter((r,s)=>s!==n)}),clearChips:()=>t({chips:[]}),takeChips(){const n=e().chips;return n.length&&t({chips:[]}),n},setPointing:n=>t({pointing:n}),openContextMenu:n=>t({contextMenu:n}),jumpTo:n=>t({jump:{scene:n,nonce:Date.now()}}),reviseDocument(n,r){var h,m;const{viewId:s,selection:i,projectId:o}=e();if(n.project.id!==o)return e().loadDocument(n,r);const a=gt(n),l=(h=e().history)==null?void 0:h.present,d=!(!!l&&l.views.length===0&&l.walkthroughs.length===0)&&(s===bt||a.views.has(s)||n.walkthroughs.some(g=>`${Hr}${g.id}`===s)),u=i&&a.exists(i)?i:null;t({startOpen:!1,projects:[...e().projects.filter(g=>g.id!==n.project.id),{id:n.project.id,doc:n,origin:r}],history:_w(n),viewId:d?s:n.walkthroughs[0]?`${Hr}${n.walkthroughs[0].id}`:n.project.defaultView??((m=n.views[0])==null?void 0:m.id)??bt,selection:u,hover:null})},loadDocument(n,r="imported"){var d;const{projects:s,projectId:i,history:o}=e(),l=s.map(u=>u.id===i&&o?{...u,doc:o.present}:u).filter(u=>u.id!==n.project.id),c=n.walkthroughs[0]?`${Hr}${n.walkthroughs[0].id}`:n.project.defaultView??((d=n.views[0])==null?void 0:d.id)??bt;t({startOpen:!1,projects:[...l,{id:n.project.id,doc:n,origin:r}],projectId:n.project.id,history:_w(n),viewId:c,selection:null,hover:null,back:[],forward:[],viewUi:{},focus:null})},keepProject(n,r){t({projects:[...e().projects.filter(s=>s.id!==n.project.id),{id:n.project.id,doc:n,origin:r}]})},switchProject(n){const r=e().projects.find(s=>s.id===n);!r||n===e().projectId||e().loadDocument(r.doc,r.origin)},dispatch(n){try{t({history:nP(e().history,n)})}catch(r){t({notice:r instanceof Error?r.message:String(r)})}},undo:()=>t({history:rP(e().history)}),redo:()=>t({history:sP(e().history)}),navigate(n,r={}){const{viewId:s,selection:i,history:o}=e(),a=gt(o.present);let l=r.select!==void 0?r.select:i;if(l&&n!==bt&&!n.startsWith(Hr)){const d=a.views.get(n);(!d||!a.viewShows(d,l))&&(l=r.select??null)}(n===bt||n.startsWith(Hr))&&(l=r.select??null);const c=s!==n;c&&n.startsWith(Hr)&&typeof window<"u"&&window.innerWidth<1700&&t({sidebarOpen:!1}),t({viewId:n,selection:l,hover:null,back:c?[...e().back,{viewId:s,selection:i}].slice(-50):e().back,forward:c?[]:e().forward,focus:r.focus?na(r.focus,l):l?na("center",l):null})},goBack(){const{back:n,viewId:r,selection:s}=e(),i=n[n.length-1];i&&t({viewId:i.viewId,selection:i.selection,back:n.slice(0,-1),forward:[{viewId:r,selection:s},...e().forward],focus:i.selection?na("center",i.selection):null})},goForward(){const{forward:n,viewId:r,selection:s}=e(),i=n[0];i&&t({viewId:i.viewId,selection:i.selection,forward:n.slice(1),back:[...e().back,{viewId:r,selection:s}],focus:i.selection?na("center",i.selection):null})},select(n,r={}){const s=e().selection;n&&s&&fe(n)===fe(s)&&!r.focus||(t({selection:n,focus:r.focus?na(r.focus,n):e().focus}),n&&!e().inspectorOpen&&typeof window<"u"&&window.innerWidth>1180&&t({inspectorOpen:!0}))},setHover(n){const r=e().hover;r===n||r&&n&&fe(r)===fe(n)||t({hover:n})},requestFocus:(n,r=null)=>t({focus:na(n,r)}),toggleSidebar:n=>t({sidebarOpen:n??!e().sidebarOpen}),toggleInspector:n=>t({inspectorOpen:n??!e().inspectorOpen}),setPaletteOpen:n=>t({paletteOpen:n}),toggleTheme(){const n=e().theme==="light"?"dark":"light";bu.set("theme",n),t({theme:n})},togglePin(n){const r=e().pinned.includes(n)?e().pinned.filter(s=>s!==n):[...e().pinned,n];bu.set("pinned",r),t({pinned:r})},updateViewUi(n,r){t({viewUi:{...e().viewUi,[n]:{...e().viewUi[n],...r}}})},notify:n=>t({notice:n})})),O1=()=>R(t=>t.history.present),Be=()=>gt(O1());function Ud(t){const e=R.getState(),n=gt(e.history.present),r=e.viewId!==bt?n.views.get(e.viewId):void 0;if(r&&n.viewShows(r,t)){e.select(t,{focus:"center"});return}const s=n.bestViewFor(t);s?e.navigate(s.id,{select:t,focus:"center"}):e.select(t)}function T6(t,e){R.getState().navigate(t,{select:e??null,focus:e?"center":void 0})}function we({title:t,count:e,children:n}){return f.jsxs("section",{className:"border-t border-rule px-4 py-3.5 first:border-t-0",children:[f.jsxs("h3",{className:"mb-2 flex items-center gap-2 text-[12px] font-semibold text-ink-3",children:[t,e!==void 0&&f.jsx("span",{className:"font-tabular font-normal text-ink-4",children:e})]}),n]})}function zn({items:t}){const e=t.filter(([,n])=>n!==void 0&&n!==""&&n!==null);return e.length?f.jsx("dl",{className:"grid grid-cols-[96px_1fr] gap-x-3 gap-y-1.5 text-[12.5px]",children:e.map(([n,r])=>f.jsxs("div",{className:"contents",children:[f.jsx("dt",{className:"text-ink-3",children:n}),f.jsx("dd",{className:"min-w-0 break-words text-ink",children:r})]},n))}):null}function Ct({to:t,label:e,secondary:n,icon:r,tone:s,onClick:i}){return f.jsxs("button",{type:"button",onClick:i??(()=>t&&Ud(t)),className:"group -mx-2 flex w-[calc(100%+16px)] items-start gap-2.5 rounded-md px-2 py-1.5 text-left hover:bg-sunken",children:[r&&f.jsx("span",{className:"mt-[1px] shrink-0",style:{color:s},children:r}),f.jsxs("span",{className:"min-w-0 flex-1",children:[f.jsx("span",{className:"block text-[12.5px] leading-snug text-ink",children:e}),n&&f.jsx("span",{className:"block text-[11.5px] leading-snug text-ink-3",children:n})]}),f.jsx(zd,{size:13,className:"mt-0.5 shrink-0 text-ink-4 opacity-0 transition-opacity group-hover:opacity-100"})]})}function It({id:t,secondary:e}){const n=Be(),r=n.entities.get(t);if(!r)return null;const s=n.style(r),i=Pp(s.icon);return f.jsx(Ct,{to:{kind:"entity",id:t},label:r.name,secondary:e??s.label,icon:f.jsx(i,{size:14}),tone:pt(s.tone)})}function Zd({view:t,select:e,verb:n="Open"}){const r=rs(t),s=(r==null?void 0:r.icon)??Ao;return f.jsxs("button",{type:"button",onClick:()=>T6(t.id,e),className:"group -mx-2 flex w-[calc(100%+16px)] items-center gap-2.5 rounded-md px-2 py-1.5 text-left hover:bg-sunken",children:[f.jsx(s,{size:14,className:"shrink-0 text-ink-3"}),f.jsxs("span",{className:"min-w-0 flex-1 text-[12.5px] text-ink",children:[n," ",t.title.charAt(0).toLowerCase()+t.title.slice(1)]}),f.jsx(eh,{size:13,className:"shrink-0 text-ink-4 group-hover:text-poney"})]})}function O$({refs:t}){return t.length?f.jsx(we,{title:"In the code",count:t.length,children:f.jsx("ul",{className:"space-y-1",children:t.map((e,n)=>f.jsxs("li",{className:"flex items-start gap-2 text-[12px]",children:[f.jsx(Mp,{size:13,className:"mt-0.5 shrink-0 text-ink-3"}),f.jsxs("span",{className:"min-w-0",children:[f.jsxs("code",{className:"block break-all font-mono text-[11.5px] text-ink",children:[e.path,e.line?`:${e.line}`:""]}),e.symbol&&f.jsx("span",{className:"text-ink-3",children:e.symbol})]})]},n))})}):null}function Ht({children:t}){return f.jsx("p",{className:"text-[13px] leading-relaxed text-ink-2",children:t})}function O6({items:t}){return t.length?f.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.map(e=>f.jsx("span",{className:"rounded-md bg-sunken px-1.5 py-0.5 text-[11.5px] text-ink-2",children:e},e))}):null}const A6={core:Dp,diagrams:[C6],layouts:{"ownership/team-map":b6},inspector:[{id:"ownership",title:"Ownership",render({ref:t,doc:e,idx:n}){if(t.kind!=="entity")return null;const r=n.entities.get(t.id);if(!r)return null;if(r.kind===ah){const o=ol(r),a=T$(e,r.id);return f.jsxs("div",{children:[f.jsx(zn,{items:[["On call",(o==null?void 0:o.oncall)&&f.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[f.jsx(ND,{size:12,className:"text-ink-3"}),o.oncall]})],["Channel",(o==null?void 0:o.channel)&&f.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[f.jsx(fD,{size:12,className:"text-ink-3"}),o.channel.replace(/^#/,"")]})]]}),f.jsxs("p",{className:"mb-1 mt-3 text-[11.5px] text-ink-3",children:["Owns ",a.length]}),a.map(l=>f.jsx(It,{id:l.id},l.id))]})}const s=w6(e,r);if(!s)return null;const i=ol(s);return f.jsxs("div",{children:[f.jsx(It,{id:s.id,secondary:"Owning team"}),f.jsx("div",{className:"mt-2",children:f.jsx(zn,{items:[["On call",i==null?void 0:i.oncall],["Channel",i==null?void 0:i.channel]]})})]})}}]};var Ge;(function(t){t.assertEqual=s=>{};function e(s){}t.assertIs=e;function n(s){throw new Error}t.assertNever=n,t.arrayToEnum=s=>{const i={};for(const o of s)i[o]=o;return i},t.getValidEnumValues=s=>{const i=t.objectKeys(s).filter(a=>typeof s[s[a]]!="number"),o={};for(const a of i)o[a]=s[a];return t.objectValues(o)},t.objectValues=s=>t.objectKeys(s).map(function(i){return s[i]}),t.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const i=[];for(const o in s)Object.prototype.hasOwnProperty.call(s,o)&&i.push(o);return i},t.find=(s,i)=>{for(const o of s)if(i(o))return o},t.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function r(s,i=" | "){return s.map(o=>typeof o=="string"?`'${o}'`:o).join(i)}t.joinValues=r,t.jsonStringifyReplacer=(s,i)=>typeof i=="bigint"?i.toString():i})(Ge||(Ge={}));var cb;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(cb||(cb={}));const ye=Ge.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ti=t=>{switch(typeof t){case"undefined":return ye.undefined;case"string":return ye.string;case"number":return Number.isNaN(t)?ye.nan:ye.number;case"boolean":return ye.boolean;case"function":return ye.function;case"bigint":return ye.bigint;case"symbol":return ye.symbol;case"object":return Array.isArray(t)?ye.array:t===null?ye.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?ye.promise:typeof Map<"u"&&t instanceof Map?ye.map:typeof Set<"u"&&t instanceof Set?ye.set:typeof Date<"u"&&t instanceof Date?ye.date:ye.object;default:return ye.unknown}},re=Ge.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class zs extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(i){return i.message},r={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(o))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return s(this),r}static assert(e){if(!(e instanceof zs))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ge.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},r=[];for(const s of this.issues)if(s.path.length>0){const i=s.path[0];n[i]=n[i]||[],n[i].push(e(s))}else r.push(e(s));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}zs.create=t=>new zs(t);const gx=(t,e)=>{let n;switch(t.code){case re.invalid_type:t.received===ye.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case re.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,Ge.jsonStringifyReplacer)}`;break;case re.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ge.joinValues(t.keys,", ")}`;break;case re.invalid_union:n="Invalid input";break;case re.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ge.joinValues(t.options)}`;break;case re.invalid_enum_value:n=`Invalid enum value. Expected ${Ge.joinValues(t.options)}, received '${t.received}'`;break;case re.invalid_arguments:n="Invalid function arguments";break;case re.invalid_return_type:n="Invalid function return type";break;case re.invalid_date:n="Invalid date";break;case re.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:Ge.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case re.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case re.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case re.custom:n="Invalid input";break;case re.invalid_intersection_types:n="Intersection results could not be merged";break;case re.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case re.not_finite:n="Number must be finite";break;default:n=e.defaultError,Ge.assertNever(t)}return{message:n}};let R6=gx;function I6(){return R6}const P6=t=>{const{data:e,path:n,errorMaps:r,issueData:s}=t,i=[...n,...s.path||[]],o={...s,path:i};if(s.message!==void 0)return{...s,path:i,message:s.message};let a="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)a=c(o,{data:e,defaultError:a}).message;return{...s,path:i,message:a}};function ce(t,e){const n=I6(),r=P6({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===gx?void 0:gx].filter(s=>!!s)});t.common.issues.push(r)}class Qn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const s of n){if(s.status==="aborted")return Me;s.status==="dirty"&&e.dirty(),r.push(s.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const s of n){const i=await s.key,o=await s.value;r.push({key:i,value:o})}return Qn.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const s of n){const{key:i,value:o}=s;if(i.status==="aborted"||o.status==="aborted")return Me;i.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet)&&(r[i.value]=o.value)}return{status:e.value,value:r}}}const Me=Object.freeze({status:"aborted"}),cc=t=>({status:"dirty",value:t}),xr=t=>({status:"valid",value:t}),db=t=>t.status==="aborted",ub=t=>t.status==="dirty",al=t=>t.status==="valid",lh=t=>typeof Promise<"u"&&t instanceof Promise;var ke;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(ke||(ke={}));class Li{constructor(e,n,r,s){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const fb=(t,e)=>{if(al(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new zs(t.common.issues);return this._error=n,this._error}}};function Le(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:s}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(o,a)=>{const{message:l}=t;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:s}}class Ke{get description(){return this._def.description}_getType(e){return ti(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:ti(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Qn,ctx:{common:e.parent.common,data:e.data,parsedType:ti(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(lh(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ti(e)},s=this._parseSync({data:e,path:r.path,parent:r});return fb(r,s)}"~validate"(e){var r,s;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ti(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:n});return al(i)?{value:i.value}:{issues:n.common.issues}}catch(i){(s=(r=i==null?void 0:i.message)==null?void 0:r.toLowerCase())!=null&&s.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(i=>al(i)?{value:i.value}:{issues:n.common.issues})}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ti(e)},s=this._parse({data:e,path:r.path,parent:r}),i=await(lh(s)?s:Promise.resolve(s));return fb(r,i)}refine(e,n){const r=s=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(s):n;return this._refinement((s,i)=>{const o=e(s),a=()=>i.addIssue({code:re.custom,...r(s)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(e,n){return this._refinement((r,s)=>e(r)?!0:(s.addIssue(typeof n=="function"?n(r,s):n),!1))}_refinement(e){return new cl({schema:this,typeName:Oe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ci.create(this,this._def)}nullable(){return dl.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return es.create(this)}promise(){return fh.create(this,this._def)}or(e){return dh.create([this,e],this._def)}and(e){return uh.create(this,e,this._def)}transform(e){return new cl({...Le(this._def),schema:this,typeName:Oe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new vx({...Le(this._def),innerType:this,defaultValue:n,typeName:Oe.ZodDefault})}brand(){return new i9({typeName:Oe.ZodBranded,type:this,...Le(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new kx({...Le(this._def),innerType:this,catchValue:n,typeName:Oe.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return A1.create(this,e)}readonly(){return wx.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const D6=/^c[^\s-]{8,}$/i,z6=/^[0-9a-z]+$/,L6=/^[0-9A-HJKMNP-TV-Z]{26}$/i,F6=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,B6=/^[a-z0-9_-]{21}$/i,V6=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,W6=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,U6=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Z6="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Qm;const H6=/^(?:(?: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])$/,q6=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,K6=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,J6=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,G6=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Y6=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,A$="((\\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])))",Q6=new RegExp(`^${A$}$`);function R$(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function X6(t){return new RegExp(`^${R$(t)}$`)}function e9(t){let e=`${A$}T${R$(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function t9(t,e){return!!((e==="v4"||!e)&&H6.test(t)||(e==="v6"||!e)&&K6.test(t))}function n9(t,e){if(!V6.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return!(typeof s!="object"||s===null||"typ"in s&&(s==null?void 0:s.typ)!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function r9(t,e){return!!((e==="v4"||!e)&&q6.test(t)||(e==="v6"||!e)&&J6.test(t))}class ui extends Ke{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==ye.string){const i=this._getOrReturnCtx(e);return ce(i,{code:re.invalid_type,expected:ye.string,received:i.parsedType}),Me}const r=new Qn;let s;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(s=this._getOrReturnCtx(e,s),ce(s,{code:re.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(s=this._getOrReturnCtx(e,s),ce(s,{code:re.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const o=e.data.length>i.value,a=e.data.length<i.value;(o||a)&&(s=this._getOrReturnCtx(e,s),o?ce(s,{code:re.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):a&&ce(s,{code:re.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")U6.test(e.data)||(s=this._getOrReturnCtx(e,s),ce(s,{validation:"email",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")Qm||(Qm=new RegExp(Z6,"u")),Qm.test(e.data)||(s=this._getOrReturnCtx(e,s),ce(s,{validation:"emoji",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")F6.test(e.data)||(s=this._getOrReturnCtx(e,s),ce(s,{validation:"uuid",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="nanoid")B6.test(e.data)||(s=this._getOrReturnCtx(e,s),ce(s,{validation:"nanoid",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")D6.test(e.data)||(s=this._getOrReturnCtx(e,s),ce(s,{validation:"cuid",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")z6.test(e.data)||(s=this._getOrReturnCtx(e,s),ce(s,{validation:"cuid2",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")L6.test(e.data)||(s=this._getOrReturnCtx(e,s),ce(s,{validation:"ulid",code:re.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),ce(s,{validation:"url",code:re.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),ce(s,{validation:"regex",code:re.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(s=this._getOrReturnCtx(e,s),ce(s,{code:re.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(s=this._getOrReturnCtx(e,s),ce(s,{code:re.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(s=this._getOrReturnCtx(e,s),ce(s,{code:re.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?e9(i).test(e.data)||(s=this._getOrReturnCtx(e,s),ce(s,{code:re.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="date"?Q6.test(e.data)||(s=this._getOrReturnCtx(e,s),ce(s,{code:re.invalid_string,validation:"date",message:i.message}),r.dirty()):i.kind==="time"?X6(i).test(e.data)||(s=this._getOrReturnCtx(e,s),ce(s,{code:re.invalid_string,validation:"time",message:i.message}),r.dirty()):i.kind==="duration"?W6.test(e.data)||(s=this._getOrReturnCtx(e,s),ce(s,{validation:"duration",code:re.invalid_string,message:i.message}),r.dirty()):i.kind==="ip"?t9(e.data,i.version)||(s=this._getOrReturnCtx(e,s),ce(s,{validation:"ip",code:re.invalid_string,message:i.message}),r.dirty()):i.kind==="jwt"?n9(e.data,i.alg)||(s=this._getOrReturnCtx(e,s),ce(s,{validation:"jwt",code:re.invalid_string,message:i.message}),r.dirty()):i.kind==="cidr"?r9(e.data,i.version)||(s=this._getOrReturnCtx(e,s),ce(s,{validation:"cidr",code:re.invalid_string,message:i.message}),r.dirty()):i.kind==="base64"?G6.test(e.data)||(s=this._getOrReturnCtx(e,s),ce(s,{validation:"base64",code:re.invalid_string,message:i.message}),r.dirty()):i.kind==="base64url"?Y6.test(e.data)||(s=this._getOrReturnCtx(e,s),ce(s,{validation:"base64url",code:re.invalid_string,message:i.message}),r.dirty()):Ge.assertNever(i);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(s=>e.test(s),{validation:n,code:re.invalid_string,...ke.errToObj(r)})}_addCheck(e){return new ui({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ke.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ke.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ke.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ke.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ke.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ke.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ke.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ke.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ke.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...ke.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...ke.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ke.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...ke.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...ke.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...ke.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...ke.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...ke.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...ke.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...ke.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...ke.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...ke.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...ke.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...ke.errToObj(n)})}nonempty(e){return this.min(1,ke.errToObj(e))}trim(){return new ui({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ui({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ui({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}ui.create=t=>new ui({checks:[],typeName:Oe.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...Le(t)});function s9(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,s=n>r?n:r,i=Number.parseInt(t.toFixed(s).replace(".","")),o=Number.parseInt(e.toFixed(s).replace(".",""));return i%o/10**s}class od extends Ke{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==ye.number){const i=this._getOrReturnCtx(e);return ce(i,{code:re.invalid_type,expected:ye.number,received:i.parsedType}),Me}let r;const s=new Qn;for(const i of this._def.checks)i.kind==="int"?Ge.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),ce(r,{code:re.invalid_type,expected:"integer",received:"float",message:i.message}),s.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),ce(r,{code:re.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),ce(r,{code:re.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),s.dirty()):i.kind==="multipleOf"?s9(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),ce(r,{code:re.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),ce(r,{code:re.not_finite,message:i.message}),s.dirty()):Ge.assertNever(i);return{status:s.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,ke.toString(n))}gt(e,n){return this.setLimit("min",e,!1,ke.toString(n))}lte(e,n){return this.setLimit("max",e,!0,ke.toString(n))}lt(e,n){return this.setLimit("max",e,!1,ke.toString(n))}setLimit(e,n,r,s){return new od({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:ke.toString(s)}]})}_addCheck(e){return new od({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ke.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ke.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ke.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ke.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ke.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:ke.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:ke.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ke.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ke.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Ge.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}}od.create=t=>new od({checks:[],typeName:Oe.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...Le(t)});class ad extends Ke{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==ye.bigint)return this._getInvalidInput(e);let r;const s=new Qn;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),ce(r,{code:re.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),ce(r,{code:re.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),s.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),ce(r,{code:re.not_multiple_of,multipleOf:i.value,message:i.message}),s.dirty()):Ge.assertNever(i);return{status:s.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return ce(n,{code:re.invalid_type,expected:ye.bigint,received:n.parsedType}),Me}gte(e,n){return this.setLimit("min",e,!0,ke.toString(n))}gt(e,n){return this.setLimit("min",e,!1,ke.toString(n))}lte(e,n){return this.setLimit("max",e,!0,ke.toString(n))}lt(e,n){return this.setLimit("max",e,!1,ke.toString(n))}setLimit(e,n,r,s){return new ad({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:ke.toString(s)}]})}_addCheck(e){return new ad({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ke.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ke.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ke.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ke.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:ke.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}ad.create=t=>new ad({checks:[],typeName:Oe.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...Le(t)});class yx extends Ke{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==ye.boolean){const r=this._getOrReturnCtx(e);return ce(r,{code:re.invalid_type,expected:ye.boolean,received:r.parsedType}),Me}return xr(e.data)}}yx.create=t=>new yx({typeName:Oe.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...Le(t)});class ch extends Ke{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==ye.date){const i=this._getOrReturnCtx(e);return ce(i,{code:re.invalid_type,expected:ye.date,received:i.parsedType}),Me}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return ce(i,{code:re.invalid_date}),Me}const r=new Qn;let s;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(s=this._getOrReturnCtx(e,s),ce(s,{code:re.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(s=this._getOrReturnCtx(e,s),ce(s,{code:re.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):Ge.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ch({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:ke.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:ke.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}ch.create=t=>new ch({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Oe.ZodDate,...Le(t)});class hb extends Ke{_parse(e){if(this._getType(e)!==ye.symbol){const r=this._getOrReturnCtx(e);return ce(r,{code:re.invalid_type,expected:ye.symbol,received:r.parsedType}),Me}return xr(e.data)}}hb.create=t=>new hb({typeName:Oe.ZodSymbol,...Le(t)});class pb extends Ke{_parse(e){if(this._getType(e)!==ye.undefined){const r=this._getOrReturnCtx(e);return ce(r,{code:re.invalid_type,expected:ye.undefined,received:r.parsedType}),Me}return xr(e.data)}}pb.create=t=>new pb({typeName:Oe.ZodUndefined,...Le(t)});class mb extends Ke{_parse(e){if(this._getType(e)!==ye.null){const r=this._getOrReturnCtx(e);return ce(r,{code:re.invalid_type,expected:ye.null,received:r.parsedType}),Me}return xr(e.data)}}mb.create=t=>new mb({typeName:Oe.ZodNull,...Le(t)});class gb extends Ke{constructor(){super(...arguments),this._any=!0}_parse(e){return xr(e.data)}}gb.create=t=>new gb({typeName:Oe.ZodAny,...Le(t)});class yb extends Ke{constructor(){super(...arguments),this._unknown=!0}_parse(e){return xr(e.data)}}yb.create=t=>new yb({typeName:Oe.ZodUnknown,...Le(t)});class Fi extends Ke{_parse(e){const n=this._getOrReturnCtx(e);return ce(n,{code:re.invalid_type,expected:ye.never,received:n.parsedType}),Me}}Fi.create=t=>new Fi({typeName:Oe.ZodNever,...Le(t)});class xb extends Ke{_parse(e){if(this._getType(e)!==ye.undefined){const r=this._getOrReturnCtx(e);return ce(r,{code:re.invalid_type,expected:ye.void,received:r.parsedType}),Me}return xr(e.data)}}xb.create=t=>new xb({typeName:Oe.ZodVoid,...Le(t)});class es extends Ke{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),s=this._def;if(n.parsedType!==ye.array)return ce(n,{code:re.invalid_type,expected:ye.array,received:n.parsedType}),Me;if(s.exactLength!==null){const o=n.data.length>s.exactLength.value,a=n.data.length<s.exactLength.value;(o||a)&&(ce(n,{code:o?re.too_big:re.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(s.minLength!==null&&n.data.length<s.minLength.value&&(ce(n,{code:re.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),s.maxLength!==null&&n.data.length>s.maxLength.value&&(ce(n,{code:re.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>s.type._parseAsync(new Li(n,o,n.path,a)))).then(o=>Qn.mergeArray(r,o));const i=[...n.data].map((o,a)=>s.type._parseSync(new Li(n,o,n.path,a)));return Qn.mergeArray(r,i)}get element(){return this._def.type}min(e,n){return new es({...this._def,minLength:{value:e,message:ke.toString(n)}})}max(e,n){return new es({...this._def,maxLength:{value:e,message:ke.toString(n)}})}length(e,n){return new es({...this._def,exactLength:{value:e,message:ke.toString(n)}})}nonempty(e){return this.min(1,e)}}es.create=(t,e)=>new es({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Oe.ZodArray,...Le(e)});function ua(t){if(t instanceof Et){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=Ci.create(ua(r))}return new Et({...t._def,shape:()=>e})}else return t instanceof es?new es({...t._def,type:ua(t.element)}):t instanceof Ci?Ci.create(ua(t.unwrap())):t instanceof dl?dl.create(ua(t.unwrap())):t instanceof Po?Po.create(t.items.map(e=>ua(e))):t}class Et extends Ke{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=Ge.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==ye.object){const c=this._getOrReturnCtx(e);return ce(c,{code:re.invalid_type,expected:ye.object,received:c.parsedType}),Me}const{status:r,ctx:s}=this._processInputParams(e),{shape:i,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Fi&&this._def.unknownKeys==="strip"))for(const c in s.data)o.includes(c)||a.push(c);const l=[];for(const c of o){const d=i[c],u=s.data[c];l.push({key:{status:"valid",value:c},value:d._parse(new Li(s,u,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof Fi){const c=this._def.unknownKeys;if(c==="passthrough")for(const d of a)l.push({key:{status:"valid",value:d},value:{status:"valid",value:s.data[d]}});else if(c==="strict")a.length>0&&(ce(s,{code:re.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const d of a){const u=s.data[d];l.push({key:{status:"valid",value:d},value:c._parse(new Li(s,u,s.path,d)),alwaysSet:d in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const c=[];for(const d of l){const u=await d.key,h=await d.value;c.push({key:u,value:h,alwaysSet:d.alwaysSet})}return c}).then(c=>Qn.mergeObjectSync(r,c)):Qn.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return ke.errToObj,new Et({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{var i,o;const s=((o=(i=this._def).errorMap)==null?void 0:o.call(i,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:ke.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new Et({...this._def,unknownKeys:"strip"})}passthrough(){return new Et({...this._def,unknownKeys:"passthrough"})}extend(e){return new Et({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Et({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Oe.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new Et({...this._def,catchall:e})}pick(e){const n={};for(const r of Ge.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new Et({...this._def,shape:()=>n})}omit(e){const n={};for(const r of Ge.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new Et({...this._def,shape:()=>n})}deepPartial(){return ua(this)}partial(e){const n={};for(const r of Ge.objectKeys(this.shape)){const s=this.shape[r];e&&!e[r]?n[r]=s:n[r]=s.optional()}return new Et({...this._def,shape:()=>n})}required(e){const n={};for(const r of Ge.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let i=this.shape[r];for(;i instanceof Ci;)i=i._def.innerType;n[r]=i}return new Et({...this._def,shape:()=>n})}keyof(){return I$(Ge.objectKeys(this.shape))}}Et.create=(t,e)=>new Et({shape:()=>t,unknownKeys:"strip",catchall:Fi.create(),typeName:Oe.ZodObject,...Le(e)});Et.strictCreate=(t,e)=>new Et({shape:()=>t,unknownKeys:"strict",catchall:Fi.create(),typeName:Oe.ZodObject,...Le(e)});Et.lazycreate=(t,e)=>new Et({shape:t,unknownKeys:"strip",catchall:Fi.create(),typeName:Oe.ZodObject,...Le(e)});class dh extends Ke{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function s(i){for(const a of i)if(a.result.status==="valid")return a.result;for(const a of i)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(a=>new zs(a.ctx.common.issues));return ce(n,{code:re.invalid_union,unionErrors:o}),Me}if(n.common.async)return Promise.all(r.map(async i=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await i._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(s);{let i;const o=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},d=l._parseSync({data:n.data,path:n.path,parent:c});if(d.status==="valid")return d;d.status==="dirty"&&!i&&(i={result:d,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(i)return n.common.issues.push(...i.ctx.common.issues),i.result;const a=o.map(l=>new zs(l));return ce(n,{code:re.invalid_union,unionErrors:a}),Me}}get options(){return this._def.options}}dh.create=(t,e)=>new dh({options:t,typeName:Oe.ZodUnion,...Le(e)});function xx(t,e){const n=ti(t),r=ti(e);if(t===e)return{valid:!0,data:t};if(n===ye.object&&r===ye.object){const s=Ge.objectKeys(e),i=Ge.objectKeys(t).filter(a=>s.indexOf(a)!==-1),o={...t,...e};for(const a of i){const l=xx(t[a],e[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===ye.array&&r===ye.array){if(t.length!==e.length)return{valid:!1};const s=[];for(let i=0;i<t.length;i++){const o=t[i],a=e[i],l=xx(o,a);if(!l.valid)return{valid:!1};s.push(l.data)}return{valid:!0,data:s}}else return n===ye.date&&r===ye.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class uh extends Ke{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=(i,o)=>{if(db(i)||db(o))return Me;const a=xx(i.value,o.value);return a.valid?((ub(i)||ub(o))&&n.dirty(),{status:n.value,value:a.data}):(ce(r,{code:re.invalid_intersection_types}),Me)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([i,o])=>s(i,o)):s(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}uh.create=(t,e,n)=>new uh({left:t,right:e,typeName:Oe.ZodIntersection,...Le(n)});class Po extends Ke{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==ye.array)return ce(r,{code:re.invalid_type,expected:ye.array,received:r.parsedType}),Me;if(r.data.length<this._def.items.length)return ce(r,{code:re.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Me;!this._def.rest&&r.data.length>this._def.items.length&&(ce(r,{code:re.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const i=[...r.data].map((o,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new Li(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(i).then(o=>Qn.mergeArray(n,o)):Qn.mergeArray(n,i)}get items(){return this._def.items}rest(e){return new Po({...this._def,rest:e})}}Po.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Po({items:t,typeName:Oe.ZodTuple,rest:null,...Le(e)})};class vb extends Ke{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==ye.map)return ce(r,{code:re.invalid_type,expected:ye.map,received:r.parsedType}),Me;const s=this._def.keyType,i=this._def.valueType,o=[...r.data.entries()].map(([a,l],c)=>({key:s._parse(new Li(r,a,r.path,[c,"key"])),value:i._parse(new Li(r,l,r.path,[c,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of o){const c=await l.key,d=await l.value;if(c.status==="aborted"||d.status==="aborted")return Me;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(c.value,d.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const l of o){const c=l.key,d=l.value;if(c.status==="aborted"||d.status==="aborted")return Me;(c.status==="dirty"||d.status==="dirty")&&n.dirty(),a.set(c.value,d.value)}return{status:n.value,value:a}}}}vb.create=(t,e,n)=>new vb({valueType:e,keyType:t,typeName:Oe.ZodMap,...Le(n)});class ld extends Ke{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==ye.set)return ce(r,{code:re.invalid_type,expected:ye.set,received:r.parsedType}),Me;const s=this._def;s.minSize!==null&&r.data.size<s.minSize.value&&(ce(r,{code:re.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),n.dirty()),s.maxSize!==null&&r.data.size>s.maxSize.value&&(ce(r,{code:re.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),n.dirty());const i=this._def.valueType;function o(l){const c=new Set;for(const d of l){if(d.status==="aborted")return Me;d.status==="dirty"&&n.dirty(),c.add(d.value)}return{status:n.value,value:c}}const a=[...r.data.values()].map((l,c)=>i._parse(new Li(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(e,n){return new ld({...this._def,minSize:{value:e,message:ke.toString(n)}})}max(e,n){return new ld({...this._def,maxSize:{value:e,message:ke.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}ld.create=(t,e)=>new ld({valueType:t,minSize:null,maxSize:null,typeName:Oe.ZodSet,...Le(e)});class kb extends Ke{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}kb.create=(t,e)=>new kb({getter:t,typeName:Oe.ZodLazy,...Le(e)});class wb extends Ke{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return ce(n,{received:n.data,code:re.invalid_literal,expected:this._def.value}),Me}return{status:"valid",value:e.data}}get value(){return this._def.value}}wb.create=(t,e)=>new wb({value:t,typeName:Oe.ZodLiteral,...Le(e)});function I$(t,e){return new ll({values:t,typeName:Oe.ZodEnum,...Le(e)})}class ll extends Ke{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return ce(n,{expected:Ge.joinValues(r),received:n.parsedType,code:re.invalid_type}),Me}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),r=this._def.values;return ce(n,{received:n.data,code:re.invalid_enum_value,options:r}),Me}return xr(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return ll.create(e,{...this._def,...n})}exclude(e,n=this._def){return ll.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}ll.create=I$;class bb extends Ke{_parse(e){const n=Ge.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==ye.string&&r.parsedType!==ye.number){const s=Ge.objectValues(n);return ce(r,{expected:Ge.joinValues(s),received:r.parsedType,code:re.invalid_type}),Me}if(this._cache||(this._cache=new Set(Ge.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=Ge.objectValues(n);return ce(r,{received:r.data,code:re.invalid_enum_value,options:s}),Me}return xr(e.data)}get enum(){return this._def.values}}bb.create=(t,e)=>new bb({values:t,typeName:Oe.ZodNativeEnum,...Le(e)});class fh extends Ke{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==ye.promise&&n.common.async===!1)return ce(n,{code:re.invalid_type,expected:ye.promise,received:n.parsedType}),Me;const r=n.parsedType===ye.promise?n.data:Promise.resolve(n.data);return xr(r.then(s=>this._def.type.parseAsync(s,{path:n.path,errorMap:n.common.contextualErrorMap})))}}fh.create=(t,e)=>new fh({type:t,typeName:Oe.ZodPromise,...Le(e)});class cl extends Ke{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Oe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:o=>{ce(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(i.addIssue=i.addIssue.bind(i),s.type==="preprocess"){const o=s.transform(r.data,i);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return Me;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?Me:l.status==="dirty"||n.value==="dirty"?cc(l.value):l});{if(n.value==="aborted")return Me;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?Me:a.status==="dirty"||n.value==="dirty"?cc(a.value):a}}if(s.type==="refinement"){const o=a=>{const l=s.refinement(a,i);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Me:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Me:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(s.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!al(o))return Me;const a=s.transform(o.value,i);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>al(o)?Promise.resolve(s.transform(o.value,i)).then(a=>({status:n.value,value:a})):Me);Ge.assertNever(s)}}cl.create=(t,e,n)=>new cl({schema:t,typeName:Oe.ZodEffects,effect:e,...Le(n)});cl.createWithPreprocess=(t,e,n)=>new cl({schema:e,effect:{type:"preprocess",transform:t},typeName:Oe.ZodEffects,...Le(n)});class Ci extends Ke{_parse(e){return this._getType(e)===ye.undefined?xr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ci.create=(t,e)=>new Ci({innerType:t,typeName:Oe.ZodOptional,...Le(e)});class dl extends Ke{_parse(e){return this._getType(e)===ye.null?xr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}dl.create=(t,e)=>new dl({innerType:t,typeName:Oe.ZodNullable,...Le(e)});class vx extends Ke{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===ye.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}vx.create=(t,e)=>new vx({innerType:t,typeName:Oe.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Le(e)});class kx extends Ke{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},s=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return lh(s)?s.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new zs(r.common.issues)},input:r.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new zs(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}kx.create=(t,e)=>new kx({innerType:t,typeName:Oe.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Le(e)});class Sb extends Ke{_parse(e){if(this._getType(e)!==ye.nan){const r=this._getOrReturnCtx(e);return ce(r,{code:re.invalid_type,expected:ye.nan,received:r.parsedType}),Me}return{status:"valid",value:e.data}}}Sb.create=t=>new Sb({typeName:Oe.ZodNaN,...Le(t)});class i9 extends Ke{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class A1 extends Ke{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Me:i.status==="dirty"?(n.dirty(),cc(i.value)):this._def.out._parseAsync({data:i.value,path:r.path,parent:r})})();{const s=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Me:s.status==="dirty"?(n.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:r.path,parent:r})}}static create(e,n){return new A1({in:e,out:n,typeName:Oe.ZodPipeline})}}class wx extends Ke{_parse(e){const n=this._def.innerType._parse(e),r=s=>(al(s)&&(s.value=Object.freeze(s.value)),s);return lh(n)?n.then(s=>r(s)):r(n)}unwrap(){return this._def.innerType}}wx.create=(t,e)=>new wx({innerType:t,typeName:Oe.ZodReadonly,...Le(e)});var Oe;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Oe||(Oe={}));const o9=ui.create,a9=yx.create;Fi.create;const l9=es.create,R1=Et.create;dh.create;uh.create;Po.create;const P$=ll.create;fh.create;Ci.create;dl.create;const c9=P$(["personal","secret","payment","health"]),hh={personal:"Personal data",secret:"Secrets",payment:"Payment data",health:"Health data"},d9=P$(["public","internal","restricted"]),u9=R1({zone:oe.optional(),trust:d9.optional()}).strict(),f9=R1({classes:l9(c9).min(1)}).strict(),h9=R1({encrypted:a9().optional(),auth:o9().min(1).optional()}).strict(),cd="security/zone",Cs={name:"security",version:"0.1.0",description:"Trust zones, sensitive data, and how connections are protected.",entityKinds:{zone:{label:"Trust zone",description:"Where parts trust each other. A line between zones crosses a trust boundary."}},facets:{entity:u9,dataType:f9,relationship:h9},validate(t,{index:e,report:n}){t.model.entities.forEach((r,s)=>{var a;const i=(a=Jr(Cs,"entity",r))==null?void 0:a.zone;if(!i)return;const o=e.entities.get(i);o?o.kind!==cd&&n(`model.entities.${s}.ext.security.zone`,`"${i}" is not a zone (kind "${cd}")`):n(`model.entities.${s}.ext.security.zone`,`Unknown zone "${i}"`)})},lint(t,{warn:e}){var n,r;for(const s of z$(t)){if(!s.classes.length)continue;const i=s.classes.map(a=>hh[a].toLowerCase()).join(" and "),o=`from ${s.from.name} to ${s.to.name}`;((n=s.protection)==null?void 0:n.encrypted)!==!0&&e(`model.relationships.${s.index}`,"security-unencrypted-crossing",`"${s.relationship.label}" carries ${i} ${o} without encryption.`,"If it is encrypted (TLS counts), set ext.security.encrypted to true on the relationship. If not, the data should not cross this boundary as it is."),(r=s.protection)!=null&&r.auth||e(`model.relationships.${s.index}`,"security-unknown-auth",`"${s.relationship.label}" carries ${i} ${o}, and the document does not say how the caller is authenticated.`,'Set ext.security.auth on the relationship, e.g. "mTLS", "OAuth token" or "none".')}t.model.relationships.forEach((s,i)=>{var c,d;const o=(c=Jr(Cs,"relationship",s))==null?void 0:c.auth,a=t.model.entities.find(u=>u.id===s.target),l=ul(t,a);(o==null?void 0:o.toLowerCase())==="none"&&l&&((d=Jr(Cs,"entity",l))==null?void 0:d.trust)==="restricted"&&e(`model.relationships.${i}`,"security-open-restricted",`"${s.label}" reaches the restricted zone ${l.name} with no authentication.`,"Name the authentication, or say why this part of a restricted zone is open.")}),t.model.dataTypes.forEach((s,i)=>{var l;if(!ph(s).length||!s.storedIn)return;const o=t.model.entities.find(c=>c.id===s.storedIn),a=ul(t,o);a&&((l=Jr(Cs,"entity",a))==null?void 0:l.trust)==="public"&&e(`model.dataTypes.${i}`,"security-sensitive-in-public",`${s.name} holds ${ph(s).map(c=>hh[c].toLowerCase()).join(" and ")}, and is stored in ${o.name}, in the public zone ${a.name}.`,"Move the store to a zone that is not public, or check that the zone is right.")})}};function ul(t,e){var s;const n=new Map(t.model.entities.map(i=>[i.id,i])),r=new Set;for(let i=e;i&&!r.has(i.id);i=i.parent?n.get(i.parent):void 0){if(r.add(i.id),i.kind===cd)return i;const o=(s=Jr(Cs,"entity",i))==null?void 0:s.zone;if(o)return n.get(o)}}const ph=t=>{var e;return((e=Jr(Cs,"dataType",t))==null?void 0:e.classes)??[]},D$=t=>Jr(Cs,"relationship",t);function z$(t){const e=new Map(t.model.entities.map(s=>[s.id,s])),n=new Map(t.model.dataTypes.map(s=>[s.id,s])),r=[];return t.model.relationships.forEach((s,i)=>{const o=e.get(s.source),a=e.get(s.target),l=ul(t,o),c=ul(t,a);if(!o||!a||!l||!c||l.id===c.id)return;const d=new Set([...s.data,...t.model.dataFlows.filter(h=>h.via===s.id).flatMap(h=>h.data)]),u=[...new Set([...d].flatMap(h=>ph(n.get(h))))];r.push({index:i,relationship:s,from:o,to:a,fromZone:l,toZone:c,classes:u,protection:D$(s)})}),r}function p9(t,e){return t.model.entities.filter(n=>{var r;return n.id!==e&&n.kind!==cd&&((r=ul(t,n))==null?void 0:r.id)===e})}const m9={public:"Public: anyone can reach it",internal:"Internal",restricted:"Restricted"},g9=(t,e,n)=>t===void 0?"Not stated":t?e:n,y9={core:Cs,inspector:[{id:"security",title:"Security",render({ref:t,doc:e,idx:n}){var r;if(!e.extensions.some(s=>s.name==="security"))return null;if(t.kind==="entity"){const s=n.entities.get(t.id);if(!s)return null;if(s.kind===cd){const o=(r=Jr(Cs,"entity",s))==null?void 0:r.trust,a=p9(e,s.id);return f.jsxs("div",{children:[f.jsx(zn,{items:[["Trust",o&&m9[o]]]}),f.jsxs("p",{className:"mb-1 mt-3 text-[11.5px] text-ink-3",children:["In this zone: ",a.length]}),a.map(l=>f.jsx(It,{id:l.id},l.id))]})}const i=ul(e,s);return i?f.jsx(It,{id:i.id,secondary:"Trust zone"}):null}if(t.kind==="relationship"){const s=z$(e).find(o=>o.relationship.id===t.id),i=D$(n.relationships.get(t.id));return!s&&!i?null:f.jsx(zn,{items:[["Crosses",s&&`${s.fromZone.name} → ${s.toZone.name}`],["Carries",s!=null&&s.classes.length?s.classes.map(o=>hh[o]).join(", "):void 0],["Encrypted",g9(i==null?void 0:i.encrypted,"Yes","No")],["Auth",(i==null?void 0:i.auth)??"Not stated"]]})}if(t.kind==="dataType"){const s=ph(n.dataTypes.get(t.id));return s.length?f.jsx(zn,{items:[["Sensitive",s.map(i=>hh[i]).join(", ")]]}):null}return null}}]};var x9=Object.defineProperty,Rl=(t,e)=>x9(t,"name",{value:e,configurable:!0}),L$=!!(typeof window<"u"&&window.document&&window.document.createElement);function Tn(t,e,{checkForDefaultPrevented:n=!0}={}){return Rl(function(s){if(t==null||t(s),n===!1||!s||!s.defaultPrevented)return e==null?void 0:e(s)},"handleEvent")}Rl(Tn,"composeEventHandlers");function v9(t){var e;if(!L$)throw new Error("Cannot access window outside of the DOM");return((e=t==null?void 0:t.ownerDocument)==null?void 0:e.defaultView)??window}Rl(v9,"getOwnerWindow");function bx(t){if(!L$)throw new Error("Cannot access document outside of the DOM");return(t==null?void 0:t.ownerDocument)??document}Rl(bx,"getOwnerDocument");function F$(t,e=!1){const{activeElement:n}=bx(t);if(!(n!=null&&n.nodeName))return null;if(B$(n)&&n.contentDocument)return F$(n.contentDocument.body,e);if(e){const r=n.getAttribute("aria-activedescendant");if(r){const s=bx(n).getElementById(r);if(s)return s}}return n}Rl(F$,"getActiveElement");function B$(t){return t.tagName==="IFRAME"}Rl(B$,"isFrame");var k9=Object.defineProperty,I1=(t,e)=>k9(t,"name",{value:e,configurable:!0});function Sx(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}I1(Sx,"setRef");function Do(...t){return e=>{let n=!1;const r=t.map(s=>{const i=Sx(s,e);return!n&&typeof i=="function"&&(n=!0),i});if(n)return()=>{for(let s=0;s<r.length;s++){const i=r[s];typeof i=="function"?i():Sx(t[s],null)}}}}I1(Do,"composeRefs");function Dr(...t){return b.useCallback(Do(...t),t)}I1(Dr,"useComposedRefs");var w9=Object.defineProperty,lr=(t,e)=>w9(t,"name",{value:e,configurable:!0});function b9(t,e){const n=b.createContext(e);n.displayName=t+"Context";const r=lr(i=>{const{children:o,...a}=i,l=b.useMemo(()=>a,Object.values(a));return f.jsx(n.Provider,{value:l,children:o})},"Provider");r.displayName=t+"Provider";function s(i,o={}){const{optional:a=!1}=o,l=b.useContext(n);if(l)return l;if(e!==void 0)return e;if(!a)throw new Error(`\`${i}\` must be used within \`${t}\``)}return lr(s,"useContext"),[r,s]}lr(b9,"createContext");function Lp(t,e=[]){let n=[];function r(i,o){const a=b.createContext(o);a.displayName=i+"Context";const l=n.length;n=[...n,o];const c=lr(u=>{var y;const{scope:h,children:m,...g}=u,p=((y=h==null?void 0:h[t])==null?void 0:y[l])||a,x=b.useMemo(()=>g,Object.values(g));return f.jsx(p.Provider,{value:x,children:m})},"Provider");c.displayName=i+"Provider";function d(u,h,m={}){var y;const{optional:g=!1}=m,p=((y=h==null?void 0:h[t])==null?void 0:y[l])||a,x=b.useContext(p);if(x)return x;if(o!==void 0)return o;if(!g)throw new Error(`\`${u}\` must be used within \`${i}\``)}return lr(d,"useContext"),[c,d]}lr(r,"createContext");const s=lr(()=>{const i=n.map(o=>b.createContext(o));return lr(function(a){const l=(a==null?void 0:a[t])||i;return b.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])},"useScope")},"createScope");return s.scopeName=t,[r,V$(s,...e)]}lr(Lp,"createContextScope");function V$(...t){const e=t[0];if(t.length===1)return e;const n=lr(()=>{const r=t.map(s=>({useScope:s(),scopeName:s.scopeName}));return lr(function(i){const o=r.reduce((a,{useScope:l,scopeName:c})=>{const u=l(i)[`__scope${c}`];return{...a,...u}},{});return b.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])},"useComposedScopes")},"createScope");return n.scopeName=e.scopeName,n}lr(V$,"composeContextScopes");var S9=Object.defineProperty,tr=(t,e)=>S9(t,"name",{value:e,configurable:!0});function P1(t){const e=b.forwardRef((n,r)=>{let{children:s,...i}=n,o=null,a=!1;const l=[];s=J$(s),b.Children.forEach(s,h=>{var m;if(q$(h)){a=!0;const g=h;let p="child"in g.props?g.props.child:g.props.children;for(;D1(p)&&typeof mh=="function";)p=mh(p._payload);o=C9(g,p),l.push((m=o==null?void 0:o.props)==null?void 0:m.children)}else l.push(h)}),o?o=b.cloneElement(o,void 0,l):!a&&b.Children.count(s)===1&&b.isValidElement(s)&&(o=s);const c=o?H$(o):void 0,d=Dr(r,c);if(!o){if(s||s===0)throw new Error(a?_9(t):E9(t));return s}const u=Z$(i,o.props??{});return o.type!==b.Fragment&&(u.ref=r?d:c),b.cloneElement(o,u)});return e.displayName=`${t}.Slot`,e}tr(P1,"createSlot");var W$=Symbol.for("radix.slottable");function U$(t){const e=tr(n=>"child"in n?n.children(n.child):n.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=W$,e}tr(U$,"createSlottable");var C9=tr((t,e)=>"child"in t.props?b.isValidElement(e)?b.cloneElement(e,void 0,t.props.children(e.props.children)):null:b.isValidElement(e)?e:null,"getSlottableElementFromSlottable");function Z$(t,e){const n={...e};for(const r in e){const s=t[r],i=e[r];/^on[A-Z]/.test(r)?s&&i?n[r]=(...a)=>{const l=i(...a);return s(...a),l}:s&&(n[r]=s):r==="style"?n[r]={...s,...i}:r==="className"?n[r]=[s,i].filter(Boolean).join(" "):r==="aria-describedby"&&(n[r]=G$(i,s))}return{...t,...n}}tr(Z$,"mergeProps");function H$(t){var r,s;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}tr(H$,"getElementRef");function q$(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===W$}tr(q$,"isSlottable");var N9=Symbol.for("react.lazy");function D1(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===N9&&"_payload"in t&&K$(t._payload)}tr(D1,"isLazyComponent");function K$(t){return typeof t=="object"&&t!==null&&"then"in t}tr(K$,"isPromiseLike");function J$(t){let e=t;for(;D1(e)&&typeof mh=="function";)e=mh(e._payload);return e}tr(J$,"useUnwrappedLazy");function G$(...t){const e=new Set;for(const n of t)if(typeof n=="string")for(const r of String(n).trim().split(/\s+/))r&&e.add(r);return e.size>0?Array.from(e).join(" "):void 0}tr(G$,"concatAriaDescribedby");var E9=tr(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),_9=tr(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),mh=El[" use ".trim().toString()],j9=Object.defineProperty,$9=(t,e)=>j9(t,"name",{value:e,configurable:!0}),M9=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Dt=M9.reduce((t,e)=>{const n=P1(`Primitive.${e}`),r=b.forwardRef((s,i)=>{const{asChild:o,...a}=s,l=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(l,{...a,ref:i})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function Y$(t,e){t&&Ad.flushSync(()=>t.dispatchEvent(e))}$9(Y$,"dispatchDiscreteCustomEvent");var Ln=globalThis!=null&&globalThis.document?b.useLayoutEffect:()=>{},T9=Object.defineProperty,O9=(t,e)=>T9(t,"name",{value:e,configurable:!0}),Cb=El[" useInsertionEffect ".trim().toString()];function zo(t){const e=b.useRef(t);return typeof Cb=="function"?Cb(()=>{e.current=t}):Ln(()=>{e.current=t}),b.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}O9(zo,"useCallbackRef");var A9=Object.defineProperty,Bt=(t,e)=>A9(t,"name",{value:e,configurable:!0}),Cx="dismissableLayer.update",R9="dismissableLayer.pointerDownOutside",I9="dismissableLayer.focusOutside",Nb,Q$=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),X$=b.forwardRef(Bt(function(e,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:s=!1,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...d}=e,u=b.useContext(Q$),[h,m]=b.useState(null),g=(h==null?void 0:h.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=b.useState({}),x=Dr(n,m),y=Array.from(u.layers),[v]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),k=v?y.indexOf(v):-1,w=h?y.indexOf(h):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,E=w>=k,_=b.useRef(!1),S=tM(L=>{o==null||o(L),l==null||l(L),L.defaultPrevented||c==null||c()},{ownerDocument:g,deferPointerDownOutside:s,isDeferredPointerDownOutsideRef:_,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:b.useCallback(L=>{if(!(L instanceof Node))return!1;const D=[...u.branches].some(B=>B.contains(L));return E&&!D},[u.branches,E])}),j=nM(L=>{if(s&&_.current)return;const D=L.target;[...u.branches].some(H=>H.contains(D))||(a==null||a(L),l==null||l(L),L.defaultPrevented||c==null||c())},g),$=h?w===y.length-1:!1,I=zo(L=>{L.key==="Escape"&&(i==null||i(L),!L.defaultPrevented&&c&&(L.preventDefault(),c()))});return b.useEffect(()=>{if($)return g.addEventListener("keydown",I,{capture:!0}),()=>g.removeEventListener("keydown",I,{capture:!0})},[g,$,I]),b.useEffect(()=>{if(h)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Nb=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(h)),u.layers.add(h),Nx(),()=>{r&&(u.layersWithOutsidePointerEventsDisabled.delete(h),u.layersWithOutsidePointerEventsDisabled.size===0&&(g.body.style.pointerEvents=Nb))}},[h,g,r,u]),b.useEffect(()=>()=>{h&&(u.layers.delete(h),u.layersWithOutsidePointerEventsDisabled.delete(h),Nx())},[h,u]),b.useEffect(()=>{const L=Bt(()=>p({}),"handleUpdate");return document.addEventListener(Cx,L),()=>document.removeEventListener(Cx,L)},[]),f.jsx(Dt.div,{...d,ref:x,style:{pointerEvents:C?E?"auto":"none":void 0,...e.style},onFocusCapture:Tn(e.onFocusCapture,j.onFocusCapture),onBlurCapture:Tn(e.onBlurCapture,j.onBlurCapture),onPointerDownCapture:Tn(e.onPointerDownCapture,S.onPointerDownCapture)})},"DismissableLayer"));function eM(){const t=b.useContext(Q$),[e,n]=b.useState(null);return b.useEffect(()=>{if(e)return t.dismissableSurfaces.add(e),()=>{t.dismissableSurfaces.delete(e)}},[e,t.dismissableSurfaces]),n}Bt(eM,"useDismissableLayerSurface");var P9=Bt(()=>!0,"IS_TRUE");function tM(t,e){const{ownerDocument:n=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:s,dismissableSurfaces:i,shouldHandlePointerDownOutside:o=P9}=e,a=zo(t),l=b.useRef(!1),c=b.useRef(!1),d=b.useRef(new Map),u=b.useRef(()=>{});return b.useEffect(()=>{function h(){c.current=!1,s.current=!1,d.current.clear()}Bt(h,"resetOutsideInteraction");function m(){return Array.from(d.current.values()).some(Boolean)}Bt(m,"isOutsideInteractionIntercepted");function g(k){if(!c.current)return;const w=k.target;w instanceof Node&&[...i].some(E=>E.contains(w))||d.current.set(k.type,!0),k.type==="click"&&window.setTimeout(()=>{c.current&&u.current()},0)}Bt(g,"handleInteractionCapture");function p(k){c.current&&d.current.set(k.type,!1)}Bt(p,"handleInteractionBubble");const x=Bt(k=>{if(k.target&&!l.current){let w=function(){n.removeEventListener("click",u.current);const E=m();h(),E||z1(R9,a,C,{discrete:!0})};if(Bt(w,"handleAndDispatchPointerDownOutsideEvent"),!o(k.target)){n.removeEventListener("click",u.current),h(),l.current=!1;return}const C={originalEvent:k};c.current=!0,s.current=r&&k.button===0,d.current.clear(),!r||k.button!==0?w():(n.removeEventListener("click",u.current),u.current=w,n.addEventListener("click",u.current,{once:!0}))}else n.removeEventListener("click",u.current),h();l.current=!1},"handlePointerDown"),y=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const k of y)n.addEventListener(k,g,!0),n.addEventListener(k,p);const v=window.setTimeout(()=>{n.addEventListener("pointerdown",x)},0);return()=>{window.clearTimeout(v),n.removeEventListener("pointerdown",x),n.removeEventListener("click",u.current);for(const k of y)n.removeEventListener(k,g,!0),n.removeEventListener(k,p)}},[n,a,r,s,i,o]),{onPointerDownCapture:Bt(()=>l.current=!0,"onPointerDownCapture")}}Bt(tM,"usePointerDownOutside");function nM(t,e=globalThis==null?void 0:globalThis.document){const n=zo(t),r=b.useRef(!1);return b.useEffect(()=>{const s=Bt(i=>{i.target&&!r.current&&z1(I9,n,{originalEvent:i},{discrete:!1})},"handleFocus");return e.addEventListener("focusin",s),()=>e.removeEventListener("focusin",s)},[e,n]),{onFocusCapture:Bt(()=>r.current=!0,"onFocusCapture"),onBlurCapture:Bt(()=>r.current=!1,"onBlurCapture")}}Bt(nM,"useFocusOutside");function Nx(){const t=new CustomEvent(Cx);document.dispatchEvent(t)}Bt(Nx,"dispatchUpdate");function z1(t,e,n,{discrete:r}){const s=n.originalEvent.target,i=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&s.addEventListener(t,e,{once:!0}),r?Y$(s,i):s.dispatchEvent(i)}Bt(z1,"handleAndDispatchCustomEvent");var D9=Object.defineProperty,$t=(t,e)=>D9(t,"name",{value:e,configurable:!0}),Xm="focusScope.autoFocusOnMount",eg="focusScope.autoFocusOnUnmount",Eb={bubbles:!1,cancelable:!0},z9=b.forwardRef($t(function(e,n){const{loop:r=!1,trapped:s=!1,branches:i,onMountAutoFocus:o,onUnmountAutoFocus:a,...l}=e,[c,d]=b.useState(null),u=zo(o),h=zo(a),m=b.useRef(null),g=Dr(n,d),p=b.useRef(i);b.useEffect(()=>{p.current=i});const x=b.useCallback(k=>{var w;return k?c!=null&&c.contains(k)?!0:!!((w=p.current)!=null&&w.some(C=>C.contains(k))):!1},[c]),y=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(s){let k=function(_){if(y.paused||!c)return;const S=_.target;x(S)?m.current=S:vs(m.current,{select:!0})},w=function(_){if(y.paused||!c)return;const S=_.relatedTarget;S!==null&&(x(S)||vs(m.current,{select:!0}))},C=function(_){if(document.activeElement===document.body)for(const j of _)j.removedNodes.length>0&&vs(c)};$t(k,"handleFocusIn"),$t(w,"handleFocusOut"),$t(C,"handleMutations"),document.addEventListener("focusin",k),document.addEventListener("focusout",w);const E=new MutationObserver(C);return c&&E.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",k),document.removeEventListener("focusout",w),E.disconnect()}}},[s,c,y.paused,x]),b.useEffect(()=>{if(c){_b.add(y);const k=document.activeElement;if(!c.contains(k)){const C=new CustomEvent(Xm,Eb);c.addEventListener(Xm,u),c.dispatchEvent(C),C.defaultPrevented||(aM(fM(L1(c)),{select:!0}),document.activeElement===k&&vs(c))}return()=>{c.removeEventListener(Xm,u);const C=c.ownerDocument,E=CustomEvent;setTimeout(()=>{const _=new E(eg,Eb);c.addEventListener(eg,h),c.dispatchEvent(_),_.defaultPrevented||vs(k??C.body,{select:!0}),c.removeEventListener(eg,h),_b.remove(y)},0)}}},[c,u,h,y]);const v=b.useCallback(k=>{if(!r&&!s||y.paused)return;const w=k.key==="Tab"&&!k.altKey&&!k.ctrlKey&&!k.metaKey,C=document.activeElement;if(w&&C){const E=k.currentTarget,[_,S]=lM(E);_&&S?!k.shiftKey&&C===S?(k.preventDefault(),r&&vs(_,{select:!0})):k.shiftKey&&C===_&&(k.preventDefault(),r&&vs(S,{select:!0})):C===E&&k.preventDefault()}},[r,s,y.paused]);return f.jsx(Dt.div,{tabIndex:-1,...l,ref:g,onKeyDown:v})},"FocusScope")),rM=b.createContext(null);function sM({registry:t,children:e}){return t?f.jsx(rM.Provider,{value:t,children:e}):e}$t(sM,"FocusScopeBranchProvider");function iM(){const[t,e]=b.useState([]),n=b.useMemo(()=>({add:$t(r=>e(s=>s.includes(r)?s:[...s,r]),"add"),remove:$t(r=>e(s=>s.filter(i=>i!==r)),"remove")}),[]);return{nodes:t,registry:n}}$t(iM,"useFocusScopeBranchRegistry");function oM(t){const e=b.useContext(rM);b.useEffect(()=>{if(!(!t||!e))return e.add(t),()=>e.remove(t)},[t,e])}$t(oM,"useFocusScopeBranch");function aM(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(vs(r,{select:e}),document.activeElement!==n)return}$t(aM,"focusFirst");function lM(t){const e=L1(t),n=Ex(e,t),r=Ex(e.reverse(),t);return[n,r]}$t(lM,"getTabbableEdges");function L1(t){const e=[],r=t.ownerDocument.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:$t(s=>{const i=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||i?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;r.nextNode();)e.push(r.currentNode);return e}$t(L1,"getTabbableCandidates");function Ex(t,e){const n=typeof e.checkVisibility=="function"&&e.checkVisibility({checkVisibilityCSS:!0});for(const r of t)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):cM(r,{upTo:e})))return r}$t(Ex,"findVisible");function cM(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}$t(cM,"isHidden");function dM(t){return t.tagName==="INPUT"&&typeof t.select=="function"}$t(dM,"isSelectableInput");function vs(t,{select:e=!1}={}){if(t&&t.focus){const r=(t.ownerDocument??document).activeElement;t.focus({preventScroll:!0}),t!==r&&dM(t)&&e&&t.select()}}$t(vs,"focus");var _b=uM();function uM(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=_x(t,e),t.unshift(e)},remove(e){var n;t=_x(t,e),(n=t[0])==null||n.resume()}}}$t(uM,"createFocusScopesStack");function _x(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}$t(_x,"arrayRemove");function fM(t){return t.filter(e=>e.tagName!=="A")}$t(fM,"removeLinks");var L9=Object.defineProperty,F9=(t,e)=>L9(t,"name",{value:e,configurable:!0}),B9=El[" useId ".trim().toString()]||(()=>{}),V9=0;function Tr(t){const[e,n]=b.useState(B9());return Ln(()=>{t||n(r=>r??String(V9++))},[t]),t||(e?`radix-${e}`:"")}F9(Tr,"useId");const W9=["top","right","bottom","left"],Bi=Math.min,$s=Math.max,gh=Math.round,Su=Math.floor,Ms=t=>({x:t,y:t}),U9={left:"right",right:"left",bottom:"top",top:"bottom"};function hM(t,e,n){return $s(t,Bi(e,n))}function Ls(t,e){return typeof t=="function"?t(e):t}function Vi(t){return t.split("-")[0]}function Il(t){return t.split("-")[1]}function F1(t){return t==="x"?"y":"x"}function B1(t){return t==="y"?"height":"width"}function Gr(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function V1(t){return F1(Gr(t))}function Z9(t,e,n){n===void 0&&(n=!1);const r=Il(t),s=V1(t),i=B1(s);let o=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=yh(o)),[o,yh(o)]}function H9(t){const e=yh(t);return[jx(t),e,jx(e)]}function jx(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const jb=["left","right"],$b=["right","left"],q9=["top","bottom"],K9=["bottom","top"];function J9(t,e,n){switch(t){case"top":case"bottom":return n?e?$b:jb:e?jb:$b;case"left":case"right":return e?q9:K9;default:return[]}}function G9(t,e,n,r){const s=Il(t);let i=J9(Vi(t),n==="start",r);return s&&(i=i.map(o=>o+"-"+s),e&&(i=i.concat(i.map(jx)))),i}function yh(t){const e=Vi(t);return U9[e]+t.slice(e.length)}function Y9(t){var e,n,r,s;return{top:(e=t.top)!=null?e:0,right:(n=t.right)!=null?n:0,bottom:(r=t.bottom)!=null?r:0,left:(s=t.left)!=null?s:0}}function pM(t){return typeof t!="number"?Y9(t):{top:t,right:t,bottom:t,left:t}}function xh(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function Mb(t,e,n){let{reference:r,floating:s}=t;const i=Gr(e),o=V1(e),a=B1(o),l=Vi(e),c=i==="y",d=r.x+r.width/2-s.width/2,u=r.y+r.height/2-s.height/2,h=r[a]/2-s[a]/2;let m;switch(l){case"top":m={x:d,y:r.y-s.height};break;case"bottom":m={x:d,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:u};break;case"left":m={x:r.x-s.width,y:u};break;default:m={x:r.x,y:r.y}}const g=Il(e);return g&&(m[o]+=h*(g==="end"?1:-1)*(n&&c?-1:1)),m}async function Q9(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:i,rects:o,elements:a,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:h=!1,padding:m=0}=Ls(e,t),g=pM(m),x=a[h?u==="floating"?"reference":"floating":u],y=xh(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(x)))==null||n?x:x.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(a.floating)),boundary:c,rootBoundary:d,strategy:l})),v=u==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,k=await(i.getOffsetParent==null?void 0:i.getOffsetParent(a.floating)),w=await(i.isElement==null?void 0:i.isElement(k))&&await(i.getScale==null?void 0:i.getScale(k))||{x:1,y:1},C=xh(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:v,offsetParent:k,strategy:l}):v);return{top:(y.top-C.top+g.top)/w.y,bottom:(C.bottom-y.bottom+g.bottom)/w.y,left:(y.left-C.left+g.left)/w.x,right:(C.right-y.right+g.right)/w.x}}const X9=50,e8=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:o}=n,a=o.detectOverflow?o:{...o,detectOverflow:Q9},l=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:s}),{x:d,y:u}=Mb(c,r,l),h=r,m=0;const g={};for(let p=0;p<i.length;p++){const x=i[p];if(!x)continue;const{name:y,fn:v}=x,{x:k,y:w,data:C,reset:E}=await v({x:d,y:u,initialPlacement:r,placement:h,strategy:s,middlewareData:g,rects:c,platform:a,elements:{reference:t,floating:e}});d=k??d,u=w??u,g[y]={...g[y],...C},E&&m<X9&&(m++,typeof E=="object"&&(E.placement&&(h=E.placement),E.rects&&(c=E.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:s}):E.rects),{x:d,y:u}=Mb(c,h,l)),p=-1)}return{x:d,y:u,placement:h,strategy:s,middlewareData:g}},t8=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:s,rects:i,platform:o,elements:a,middlewareData:l}=e,{element:c,padding:d=0}=Ls(t,e)||{};if(c==null)return{};const u=pM(d),h={x:n,y:r},m=V1(s),g=B1(m),p=await o.getDimensions(c),x=m==="y",y=x?"top":"left",v=x?"bottom":"right",k=x?"clientHeight":"clientWidth",w=i.reference[g]+i.reference[m]-h[m]-i.floating[g],C=h[m]-i.reference[m],E=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let _=E?E[k]:0;(!_||!await(o.isElement==null?void 0:o.isElement(E)))&&(_=a.floating[k]||i.floating[g]);const S=w/2-C/2,j=_/2-p[g]/2-1,$=Bi(u[y],j),I=Bi(u[v],j),L=_-p[g]-I,D=_/2-p[g]/2+S,B=hM($,D,L),H=!l.arrow&&Il(s)!=null&&D!==B&&i.reference[g]/2-(D<$?$:I)-p[g]/2<0,T=H?D<$?D-$:D-L:0;return{[m]:h[m]+T,data:{[m]:B,centerOffset:D-B-T,...H&&{alignmentOffset:T}},reset:H}}}),n8=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:i,rects:o,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:p=!0,...x}=Ls(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=Vi(s),v=Gr(a),k=Vi(a)===a,w=await(l.isRTL==null?void 0:l.isRTL(c.floating)),C=h||(k||!p?[yh(a)]:H9(a)),E=g!=="none";!h&&E&&C.push(...G9(a,p,g,w));const _=[a,...C],S=await l.detectOverflow(e,x),j=[];let $=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&j.push(S[y]),u){const B=Z9(s,o,w);j.push(S[B[0]],S[B[1]])}if($=[...$,{placement:s,overflows:j}],!j.every(B=>B<=0)){var I,L;const B=(((I=i.flip)==null?void 0:I.index)||0)+1,H=_[B];if(H&&(!(u==="alignment"?v!==Gr(H):!1)||$.every(A=>Gr(A.placement)===v?A.overflows[0]>0:!0)))return{data:{index:B,overflows:$},reset:{placement:H}};let T=(L=$.filter(M=>M.overflows[0]<=0).sort((M,A)=>M.overflows[1]-A.overflows[1])[0])==null?void 0:L.placement;if(!T)switch(m){case"bestFit":{var D;const M=(D=$.filter(A=>{if(E){const V=Gr(A.placement);return V===v||V==="y"}return!0}).map(A=>[A.placement,A.overflows.filter(V=>V>0).reduce((V,J)=>V+J,0)]).sort((A,V)=>A[1]-V[1])[0])==null?void 0:D[0];M&&(T=M);break}case"initialPlacement":T=a;break}if(s!==T)return{reset:{placement:T}}}return{}}}};function Tb(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Ob(t){return W9.some(e=>t[e]>=0)}const r8=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:s="referenceHidden",...i}=Ls(t,e);switch(s){case"referenceHidden":{const o=await r.detectOverflow(e,{...i,elementContext:"reference"}),a=Tb(o,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Ob(a)}}}case"escaped":{const o=await r.detectOverflow(e,{...i,altBoundary:!0}),a=Tb(o,n.floating);return{data:{escapedOffsets:a,escaped:Ob(a)}}}default:return{}}}}},mM=new Set(["left","top"]);async function s8(t,e){const{placement:n,platform:r,elements:s}=t,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=Vi(n),a=Il(n),l=Gr(n)==="y",c=mM.has(o)?-1:1,d=i&&l?-1:1,u=Ls(e,t);let{mainAxis:h,crossAxis:m,alignmentAxis:g}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return a&&typeof g=="number"&&(m=a==="end"?g*-1:g),l?{x:m*d,y:h*c}:{x:h*c,y:m*d}}const i8=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:i,placement:o,middlewareData:a}=e,l=await s8(e,t);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:s+l.x,y:i+l.y,data:{...l,placement:o}}}}},o8=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s,platform:i}=e,{mainAxis:o=!0,crossAxis:a=!1,limiter:l={fn:v=>{let{x:k,y:w}=v;return{x:k,y:w}}},...c}=Ls(t,e),d={x:n,y:r},u=await i.detectOverflow(e,c),h=Gr(s),m=F1(h);let g=d[m],p=d[h];const x=(v,k)=>hM(k+u[v==="y"?"top":"left"],k,k-u[v==="y"?"bottom":"right"]);o&&(g=x(m,g)),a&&(p=x(h,p));const y=l.fn({...e,[m]:g,[h]:p});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[m]:o,[h]:a}}}}}},a8=function(t){return t===void 0&&(t={}),{options:t,fn(e){var n,r;const{x:s,y:i,placement:o,rects:a,middlewareData:l}=e,{offset:c=0,mainAxis:d=!0,crossAxis:u=!0}=Ls(t,e),h={x:s,y:i},m=Gr(o),g=F1(m);let p=h[g],x=h[m];const y=Ls(c,e),v=typeof y=="number"?{mainAxis:y,crossAxis:0}:{mainAxis:(n=y.mainAxis)!=null?n:0,crossAxis:(r=y.crossAxis)!=null?r:0};if(d){const C=g==="y"?"height":"width",E=a.reference[g]-a.floating[C]+v.mainAxis,_=a.reference[g]+a.reference[C]-v.mainAxis;p<E?p=E:p>_&&(p=_)}if(u){var k,w;const C=g==="y"?"width":"height",E=mM.has(Vi(o)),_=a.reference[m]-a.floating[C]+(E&&((k=l.offset)==null?void 0:k[m])||0)+(E?0:v.crossAxis),S=a.reference[m]+a.reference[C]+(E?0:((w=l.offset)==null?void 0:w[m])||0)-(E?v.crossAxis:0);x<_?x=_:x>S&&(x=S)}return{[g]:p,[m]:x}}}},l8=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:r,platform:s,elements:i}=e,{apply:o=()=>{},...a}=Ls(t,e),l=await s.detectOverflow(e,a),c=Vi(n),d=Il(n),u=Gr(n)==="y",{width:h,height:m}=r.floating;let g,p;c==="top"||c==="bottom"?(g=c,p=d===(await(s.isRTL==null?void 0:s.isRTL(i.floating))?"start":"end")?"left":"right"):(p=c,g=d==="end"?"top":"bottom");const x=m-l.top-l.bottom,y=h-l.left-l.right,v=Bi(m-l[g],x),k=Bi(h-l[p],y),w=e.middlewareData.shift,C=!w;let E=v,_=k;w!=null&&w.enabled.x&&(_=y),w!=null&&w.enabled.y&&(E=x),C&&!d&&(u?_=h-2*$s(l.left,l.right):E=m-2*$s(l.top,l.bottom)),await o({...e,availableWidth:_,availableHeight:E});const S=await s.getDimensions(i.floating);return h!==S.width||m!==S.height?{reset:{rects:!0}}:{}}}};function Fp(){return typeof window<"u"}function Pl(t){return gM(t)?(t.nodeName||"").toLowerCase():"#document"}function Fn(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Us(t){var e;return(e=(gM(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function gM(t){return Fp()?t instanceof Node||t instanceof Fn(t).Node:!1}function ss(t){return Fp()?t instanceof Element||t instanceof Fn(t).Element:!1}function Gi(t){return Fp()?t instanceof HTMLElement||t instanceof Fn(t).HTMLElement:!1}function Ab(t){return!Fp()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Fn(t).ShadowRoot}function Bp(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=is(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&s!=="inline"&&s!=="contents"}function c8(t){return/^(table|td|th)$/.test(Pl(t))}function Vp(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const d8=/transform|translate|scale|rotate|perspective|filter/,u8=/paint|layout|strict|content/,eo=t=>!!t&&t!=="none";let tg;function W1(t){const e=ss(t)?is(t):t;return eo(e.transform)||eo(e.translate)||eo(e.scale)||eo(e.rotate)||eo(e.perspective)||!U1()&&(eo(e.backdropFilter)||eo(e.filter))||d8.test(e.willChange||"")||u8.test(e.contain||"")}function f8(t){let e=Lo(t);for(;Gi(e)&&!dd(e);){if(W1(e))return e;if(Vp(e))return null;e=Lo(e)}return null}function U1(){return tg==null&&(tg=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),tg}function dd(t){return/^(html|body|#document)$/.test(Pl(t))}function is(t){return Fn(t).getComputedStyle(t)}function Wp(t){return ss(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Lo(t){if(Pl(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Ab(t)&&t.host||Us(t);return Ab(e)?e.host:e}function yM(t){const e=Lo(t);return dd(e)?(t.ownerDocument||t).body:Gi(e)&&Bp(e)?e:yM(e)}function ud(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const s=yM(t),i=s===((r=t.ownerDocument)==null?void 0:r.body),o=Fn(s);if(i){const a=$x(o);return e.concat(o,o.visualViewport||[],Bp(s)?s:[],a&&n?ud(a):[])}else return e.concat(s,ud(s,[],n))}function $x(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function xM(t){const e=is(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=Gi(t),i=s?t.offsetWidth:n,o=s?t.offsetHeight:r,a=gh(n)!==i||gh(r)!==o;return a&&(n=i,r=o),{width:n,height:r,$:a}}function Z1(t){return ss(t)?t:t.contextElement}function Va(t){const e=Z1(t);if(!Gi(e))return Ms(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:i}=xM(e);let o=(i?gh(n.width):n.width)/r,a=(i?gh(n.height):n.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const h8=Ms(0);function vM(t){const e=Fn(t);return!U1()||!e.visualViewport?h8:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function p8(t,e,n){return e===void 0&&(e=!1),!!n&&e&&n===Fn(t)}function Fo(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),i=Z1(t);let o=Ms(1);e&&(r?ss(r)&&(o=Va(r)):o=Va(t));const a=p8(i,n,r)?vM(i):Ms(0);let l=(s.left+a.x)/o.x,c=(s.top+a.y)/o.y,d=s.width/o.x,u=s.height/o.y;if(i&&r){const h=Fn(i),m=ss(r)?Fn(r):r;let g=h,p=$x(g);for(;p&&m!==g;){const x=Va(p),y=p.getBoundingClientRect(),v=is(p),k=y.left+(p.clientLeft+parseFloat(v.paddingLeft))*x.x,w=y.top+(p.clientTop+parseFloat(v.paddingTop))*x.y;l*=x.x,c*=x.y,d*=x.x,u*=x.y,l+=k,c+=w,g=Fn(p),p=$x(g)}}return xh({width:d,height:u,x:l,y:c})}function Up(t,e){const n=Wp(t).scrollLeft;return e?e.left+n:Fo(Us(t)).left+n}function kM(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Up(t,n),s=n.top+e.scrollTop;return{x:r,y:s}}function m8(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const i=s==="fixed",o=Us(r),a=e?Vp(e.floating):!1;if(r===o||a&&i)return n;let l={scrollLeft:0,scrollTop:0},c=Ms(1);const d=Ms(0),u=Gi(r);if((u||!i)&&((Pl(r)!=="body"||Bp(o))&&(l=Wp(r)),u)){const m=Fo(r);c=Va(r),d.x=m.x+r.clientLeft,d.y=m.y+r.clientTop}const h=o&&!u&&!i?kM(o,l):Ms(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+d.x+h.x,y:n.y*c.y-l.scrollTop*c.y+d.y+h.y}}function g8(t){return t.getClientRects?Array.from(t.getClientRects()):[]}function y8(t){const e=Wp(t),n=t.ownerDocument.body,r=$s(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),s=$s(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let i=-e.scrollLeft+Up(t);const o=-e.scrollTop;return is(n).direction==="rtl"&&(i+=$s(t.clientWidth,n.clientWidth)-r),{width:r,height:s,x:i,y:o}}const x8=25;function v8(t,e,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",s=Fn(t),i=Us(t),o=s.visualViewport;let a=i.clientWidth,l=i.clientHeight,c=0,d=0;if(o){const h=!U1()||e==="fixed";r?h||(c=-o.offsetLeft,d=-o.offsetTop):(a=o.width,l=o.height,h&&(c=o.offsetLeft,d=o.offsetTop))}if(Up(i)<=0){const h=i.ownerDocument,m=h.body,g=getComputedStyle(m),p=h.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,x=Math.abs(i.clientWidth-m.clientWidth-p),y=getComputedStyle(i).scrollbarGutter==="stable both-edges"?x/2:x;y<=x8&&(a-=y)}return{width:a,height:l,x:c,y:d}}function k8(t,e){const n=Fo(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,i=Va(t),o=t.clientWidth*i.x,a=t.clientHeight*i.y,l=s*i.x,c=r*i.y;return{width:o,height:a,x:l,y:c}}function Rb(t,e,n){let r;if(e==="viewport"||e==="layoutViewport")r=v8(t,n,e);else if(e==="document")r=y8(Us(t));else if(ss(e))r=k8(e,n);else{const s=vM(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return xh(r)}function w8(t,e){const n=e.get(t);if(n)return n;let r=ud(t,[],!1).filter(a=>ss(a)&&Pl(a)!=="body"),s=null;const i=is(t).position==="fixed";let o=i?Lo(t):t;for(;ss(o)&&!dd(o);){const a=is(o),l=W1(o),c=s?s.position:i?"fixed":"";!l&&(c==="fixed"||c==="absolute"&&a.position==="static")?r=r.filter(u=>u!==o):s=a,o=Lo(o)}return e.set(t,r),r}function b8(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const o=[...n==="clippingAncestors"?Vp(e)?[]:w8(e,this._c):[].concat(n),r],a=Rb(e,o[0],s);let l=a.top,c=a.right,d=a.bottom,u=a.left;for(let h=1;h<o.length;h++){const m=Rb(e,o[h],s);l=$s(m.top,l),c=Bi(m.right,c),d=Bi(m.bottom,d),u=$s(m.left,u)}return{width:c-u,height:d-l,x:u,y:l}}function S8(t){const{width:e,height:n}=xM(t);return{width:e,height:n}}function C8(t,e,n){const r=Gi(e),s=Us(e),i=n==="fixed",o=Fo(t,!0,i,e);let a={scrollLeft:0,scrollTop:0};const l=Ms(0);if((r||!i)&&((Pl(e)!=="body"||Bp(s))&&(a=Wp(e)),r)){const h=Fo(e,!0,i,e);l.x=h.x+e.clientLeft,l.y=h.y+e.clientTop}!r&&s&&(l.x=Up(s));const c=s&&!r&&!i?kM(s,a):Ms(0),d=o.left+a.scrollLeft-l.x-c.x,u=o.top+a.scrollTop-l.y-c.y;return{x:d,y:u,width:o.width,height:o.height}}function ng(t){return is(t).position==="static"}function Ib(t,e){if(!Gi(t)||is(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Us(t)===n&&(n=n.ownerDocument.body),n}function wM(t,e){const n=Fn(t);if(Vp(t))return n;if(!Gi(t)){let s=Lo(t);for(;s&&!dd(s);){if(ss(s)&&!ng(s))return s;s=Lo(s)}return n}let r=Ib(t,e);for(;r&&c8(r)&&ng(r);)r=Ib(r,e);return r&&dd(r)&&ng(r)&&!W1(r)?n:r||f8(t)||n}const N8=async function(t){const e=this.getOffsetParent||wM,n=this.getDimensions,r=await n(t.floating);return{reference:C8(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function E8(t){return is(t).direction==="rtl"}const _8={convertOffsetParentRelativeRectToViewportRelativeRect:m8,getDocumentElement:Us,getClippingRect:b8,getOffsetParent:wM,getElementRects:N8,getClientRects:g8,getDimensions:S8,getScale:Va,isElement:ss,isRTL:E8};function bM(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function j8(t,e,n){let r=null,s;const i=Us(t);function o(){var d;clearTimeout(s),(d=r)==null||d.disconnect(),r=null}function a(d,u){d===void 0&&(d=!1),u===void 0&&(u=1),o();const h=t.getBoundingClientRect(),{left:m,top:g,width:p,height:x}=h;if(d||e(),!p||!x)return;const y=Su(g),v=Su(i.clientWidth-(m+p)),k=Su(i.clientHeight-(g+x)),w=Su(m),E={rootMargin:-y+"px "+-v+"px "+-k+"px "+-w+"px",threshold:$s(0,Bi(1,u))||1};let _=!0;function S(j){const $=j[0].intersectionRatio;if(!bM(h,t.getBoundingClientRect()))return a();if($!==u){if(!_)return a();$?a(!1,$):s=setTimeout(()=>{a(!1,1e-7)},1e3)}_=!1}try{r=new IntersectionObserver(S,{...E,root:i.ownerDocument})}catch{r=new IntersectionObserver(S,E)}r.observe(t)}const l=Fn(t),c=()=>a(n);return l.addEventListener("resize",c),a(!0),()=>{l.removeEventListener("resize",c),o()}}function $8(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Z1(t),d=s||i?[...c?ud(c):[],...e?ud(e):[]]:[];d.forEach(y=>{s&&y.addEventListener("scroll",n),i&&y.addEventListener("resize",n)});const u=c&&a?j8(c,n,i):null;let h=-1,m=null;o&&(m=new ResizeObserver(y=>{let[v]=y;v&&v.target===c&&m&&e&&(m.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var k;(k=m)==null||k.observe(e)})),n()}),c&&!l&&m.observe(c),e&&m.observe(e));let g,p=l?Fo(t):null;l&&x();function x(){const y=Fo(t);p&&!bM(p,y)&&n(),p=y,g=requestAnimationFrame(x)}return n(),()=>{var y;d.forEach(v=>{s&&v.removeEventListener("scroll",n),i&&v.removeEventListener("resize",n)}),u==null||u(),(y=m)==null||y.disconnect(),m=null,l&&cancelAnimationFrame(g)}}const M8=i8,T8=o8,O8=n8,A8=l8,R8=r8,Pb=t8,I8=a8,P8=(t,e,n)=>{const r=new Map,s=n??{},i={..._8,...s.platform,_c:r};return e8(t,e,{...s,platform:i})};var D8=typeof document<"u",z8=function(){},of=D8?b.useLayoutEffect:z8;function vh(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,s;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!vh(t[r],e[r]))return!1;return!0}if(s=Object.keys(t),n=s.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,s[r]))return!1;for(r=n;r--!==0;){const i=s[r];if(!(i==="_owner"&&t.$$typeof)&&!vh(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function SM(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Db(t,e){const n=SM(t);return Math.round(e*n)/n}function rg(t){const e=b.useRef(t);return of(()=>{e.current=t}),e}function L8(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=t,[d,u]=b.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[h,m]=b.useState(r);vh(h,r)||m(r);const[g,p]=b.useState(null),[x,y]=b.useState(null),v=b.useCallback(A=>{A!==E.current&&(E.current=A,p(A))},[]),k=b.useCallback(A=>{A!==_.current&&(_.current=A,y(A))},[]),w=i||g,C=o||x,E=b.useRef(null),_=b.useRef(null),S=b.useRef(d),j=l!=null,$=rg(l),I=rg(s),L=rg(c),D=b.useCallback(()=>{if(!E.current||!_.current)return;const A={placement:e,strategy:n,middleware:h};I.current&&(A.platform=I.current),P8(E.current,_.current,A).then(V=>{const J={...V,isPositioned:L.current!==!1};B.current&&!vh(S.current,J)&&(S.current=J,Ad.flushSync(()=>{u(J)}))})},[h,e,n,I,L]);of(()=>{c===!1&&S.current.isPositioned&&(S.current.isPositioned=!1,u(A=>({...A,isPositioned:!1})))},[c]);const B=b.useRef(!1);of(()=>(B.current=!0,()=>{B.current=!1}),[]),of(()=>{if(w&&(E.current=w),C&&(_.current=C),w&&C){if($.current)return $.current(w,C,D);D()}},[w,C,D,$,j]);const H=b.useMemo(()=>({reference:E,floating:_,setReference:v,setFloating:k}),[v,k]),T=b.useMemo(()=>({reference:w,floating:C}),[w,C]),M=b.useMemo(()=>{const A={position:n,left:0,top:0};if(!T.floating)return A;const V=Db(T.floating,d.x),J=Db(T.floating,d.y);return a?{...A,transform:"translate("+V+"px, "+J+"px)",...SM(T.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:J}},[n,a,T.floating,d.x,d.y]);return b.useMemo(()=>({...d,update:D,refs:H,elements:T,floatingStyles:M}),[d,D,H,T,M])}const F8=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:s}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?Pb({element:r.current,padding:s}).fn(n):{}:r?Pb({element:r,padding:s}).fn(n):{}}}},B8=(t,e)=>{const n=M8(t);return{name:n.name,fn:n.fn,options:[t,e]}},V8=(t,e)=>{const n=T8(t);return{name:n.name,fn:n.fn,options:[t,e]}},W8=(t,e)=>({fn:I8(t).fn,options:[t,e]}),U8=(t,e)=>{const n=O8(t);return{name:n.name,fn:n.fn,options:[t,e]}},Z8=(t,e)=>{const n=A8(t);return{name:n.name,fn:n.fn,options:[t,e]}},H8=(t,e)=>{const n=R8(t);return{name:n.name,fn:n.fn,options:[t,e]}},q8=(t,e)=>{const n=F8(t);return{name:n.name,fn:n.fn,options:[t,e]}};var K8=Object.defineProperty,J8=(t,e)=>K8(t,"name",{value:e,configurable:!0});function CM(t){const[e,n]=b.useState(void 0);return Ln(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});let r=0;const s=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const o=i[0];window.cancelAnimationFrame(r),r=window.requestAnimationFrame(()=>{let a,l;if("borderBoxSize"in o){const c=o.borderBoxSize,d=Array.isArray(c)?c[0]:c;a=d.inlineSize,l=d.blockSize}else a=t.offsetWidth,l=t.offsetHeight;n({width:a,height:l})})});return s.observe(t,{box:"border-box"}),()=>{window.cancelAnimationFrame(r),s.unobserve(t)}}else n(void 0)},[t]),e}J8(CM,"useSize");var G8=Object.defineProperty,Ni=(t,e)=>G8(t,"name",{value:e,configurable:!0}),zb={Partial:"partial"},Lb={Optimized:"optimized",Always:"always"},NM="Popper",[EM,_M]=Lp(NM),[Y8,jM]=EM(NM),Q8=Ni(t=>{const{__scopePopper:e,children:n}=t,[r,s]=b.useState(null),[i,o]=b.useState(void 0);return f.jsx(Y8,{scope:e,anchor:r,onAnchorChange:s,placementState:i,setPlacementState:o,children:n})},"Popper"),X8="PopperAnchor",eF=b.forwardRef(Ni(function(e,n){const{__scopePopper:r,virtualRef:s,...i}=e,o=jM(X8,r),a=b.useRef(null),l=o.onAnchorChange,c=b.useCallback(p=>{a.current=p,p&&l(p)},[l]),d=Dr(n,c),u=b.useRef(null);b.useEffect(()=>{if(!s)return;const p=u.current;u.current=s.current,p!==u.current&&l(u.current)});const h=o.placementState&&Zp(o.placementState),m=h==null?void 0:h[0],g=h==null?void 0:h[1];return s?null:f.jsx(Dt.div,{"data-radix-popper-side":m,"data-radix-popper-align":g,...i,ref:d})},"PopperAnchor")),$M="PopperContent",[tF,ZY]=EM($M),nF=b.forwardRef(Ni(function(e,n){var G,se,Ae,Ve,Ye,kt,rn;const{__scopePopper:r,side:s="bottom",sideOffset:i=0,align:o="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:u=0,sticky:h=zb.Partial,hideWhenDetached:m=!1,updatePositionStrategy:g=Lb.Optimized,onPlaced:p,...x}=e,y=jM($M,r),[v,k]=b.useState(null),w=Dr(n,k),[C,E]=b.useState(null),_=CM(C),S=(_==null?void 0:_.width)??0,j=(_==null?void 0:_.height)??0,$=s+(o!=="center"?"-"+o:""),I=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},L=Array.isArray(d)?d:[d],D=L.length>0,B={padding:I,boundary:L.filter(MM),altBoundary:D},{refs:H,floatingStyles:T,placement:M,isPositioned:A,middlewareData:V}=L8({strategy:"fixed",placement:$,whileElementsMounted:Ni((...Kt)=>$8(...Kt,{animationFrame:g===Lb.Always}),"whileElementsMounted"),elements:{reference:y.anchor},middleware:[B8({mainAxis:i+j,alignmentAxis:a}),c&&V8({mainAxis:!0,crossAxis:!1,...h===zb.Partial?{limiter:W8()}:{},...B}),c&&U8({...B}),Z8({...B,apply:Ni(({elements:Kt,rects:zt,availableWidth:tt,availableHeight:Vn})=>{const{width:Jt,height:de}=zt.reference,lt=Kt.floating.style;lt.setProperty("--radix-popper-available-width",`${tt}px`),lt.setProperty("--radix-popper-available-height",`${Vn}px`),lt.setProperty("--radix-popper-anchor-width",`${Jt}px`),lt.setProperty("--radix-popper-anchor-height",`${de}px`)},"apply")}),C&&q8({element:C,padding:l}),rF({arrowWidth:S,arrowHeight:j}),m&&H8(D?{strategy:"referenceHidden",...B}:{strategy:"referenceHidden",padding:B.padding,altBoundary:B.altBoundary})]}),J=y.setPlacementState;Ln(()=>(J(M),()=>{J(void 0)}),[M,J]);const[X,z]=Zp(M),F=zo(p);Ln(()=>{A&&(F==null||F())},[A,F]);const U=(G=V.arrow)==null?void 0:G.x,K=(se=V.arrow)==null?void 0:se.y,O=((Ae=V.arrow)==null?void 0:Ae.centerOffset)!==0,[P,W]=b.useState();return Ln(()=>{v&&W(window.getComputedStyle(v).zIndex)},[v]),f.jsx("div",{ref:H.setFloating,"data-radix-popper-content-wrapper":"",style:{...T,transform:A?T.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:P,"--radix-popper-transform-origin":[(Ve=V.transformOrigin)==null?void 0:Ve.x,(Ye=V.transformOrigin)==null?void 0:Ye.y].join(" "),...((kt=V.hide)==null?void 0:kt.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:f.jsx(tF,{scope:r,placedSide:X,placedAlign:z,onArrowChange:E,arrowX:U,arrowY:K,shouldHideArrow:O,children:f.jsx(Dt.div,{"data-side":X,"data-align":z,...x,ref:w,style:{...x.style,animation:A?(rn=x.style)==null?void 0:rn.animation:"none"}})})})},"PopperContent"));function MM(t){return t!==null}Ni(MM,"isNotNull");var rF=Ni(t=>({name:"transformOrigin",options:t,fn(e){var x,y,v;const{placement:n,rects:r,middlewareData:s}=e,o=((x=s.arrow)==null?void 0:x.centerOffset)!==0,a=o?0:t.arrowWidth,l=o?0:t.arrowHeight,[c,d]=Zp(n),u={start:"0%",center:"50%",end:"100%"}[d],h=(((y=s.arrow)==null?void 0:y.x)??0)+a/2,m=(((v=s.arrow)==null?void 0:v.y)??0)+l/2;let g="",p="";return c==="bottom"?(g=o?u:`${h}px`,p=`${-l}px`):c==="top"?(g=o?u:`${h}px`,p=`${r.floating.height+l}px`):c==="right"?(g=`${-l}px`,p=o?u:`${m}px`):c==="left"&&(g=`${r.floating.width+l}px`,p=o?u:`${m}px`),{data:{x:g,y:p}}}}),"transformOrigin");function Zp(t){const[e,n="center"]=t.split("-");return[e,n]}Ni(Zp,"getSideAndAlignFromPlacement");var sF=Object.defineProperty,iF=(t,e)=>sF(t,"name",{value:e,configurable:!0}),TM=b.forwardRef(iF(function(e,n){var l;const{container:r,...s}=e,[i,o]=b.useState(!1);Ln(()=>o(!0),[]);const a=r||i&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return a?Ad.createPortal(f.jsx(Dt.div,{...s,ref:n}),a):null},"Portal")),oF=Object.defineProperty,Fs=(t,e)=>oF(t,"name",{value:e,configurable:!0});function OM(t,e){return b.useReducer((n,r)=>e[n][r]??n,t)}Fs(OM,"useStateMachine");var Hd=Fs(t=>{const{present:e,children:n}=t,r=AM(e),s=typeof n=="function"?n({present:r.isPresent}):b.Children.only(n),i=RM(r.ref,IM(s));return typeof n=="function"||r.isPresent?b.cloneElement(s,{ref:i}):null},"Presence");function AM(t){const[e,n]=b.useState(),r=b.useRef(null),s=b.useRef(t),i=b.useRef("none"),o=b.useRef(void 0),a=t?"mounted":"unmounted",[l,c]=OM(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{l==="mounted"?(i.current=o.current??fa(r.current),o.current=void 0):i.current="none"},[l]),Ln(()=>{const d=r.current,u=s.current;if(u!==t){const m=i.current,g=fa(d);t?(o.current=g,c("MOUNT")):g==="none"||(d==null?void 0:d.display)==="none"?c("UNMOUNT"):c(u&&m!==g?"ANIMATION_OUT":"UNMOUNT"),s.current=t}},[t,c]),Ln(()=>{if(e){let d;const u=e.ownerDocument.defaultView??window,h=Fs(g=>{const x=fa(r.current).includes(CSS.escape(g.animationName));if(g.target===e&&x&&(c("ANIMATION_END"),!s.current)){const y=e.style.animationFillMode;e.style.animationFillMode="forwards",d=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=y)})}},"handleAnimationEnd"),m=Fs(g=>{g.target===e&&(i.current=fa(r.current))},"handleAnimationStart");return e.addEventListener("animationstart",m),e.addEventListener("animationcancel",h),e.addEventListener("animationend",h),()=>{u.clearTimeout(d),e.removeEventListener("animationstart",m),e.removeEventListener("animationcancel",h),e.removeEventListener("animationend",h)}}else c("ANIMATION_END")},[e,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:b.useCallback(d=>{if(d){const u=getComputedStyle(d);r.current=u,o.current=fa(u)}else r.current=null;n(d)},[])}}Fs(AM,"usePresence");function Mx(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}Fs(Mx,"setRef");function RM(...t){const e=b.useRef(t);return e.current=t,b.useCallback(n=>{const r=e.current;let s=!1;const i=r.map(o=>{const a=Mx(o,n);return!s&&typeof a=="function"&&(s=!0),a});if(s)return()=>{for(let o=0;o<i.length;o++){const a=i[o];typeof a=="function"?a():Mx(r[o],null)}}},[])}Fs(RM,"useStableComposedRefs");function fa(t){return(t==null?void 0:t.animationName)||"none"}Fs(fa,"getAnimationName");function IM(t){var r,s;let e=(r=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(s=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:s.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}Fs(IM,"getElementRef");var aF=Object.defineProperty,lF=(t,e)=>aF(t,"name",{value:e,configurable:!0}),Fb=El[" useEffectEvent ".trim().toString()],Bb=El[" useInsertionEffect ".trim().toString()];function PM(t){if(typeof Fb=="function")return Fb(t);const e=b.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof Bb=="function"?Bb(()=>{e.current=t}):Ln(()=>{e.current=t}),b.useMemo(()=>(...n)=>{var r;return(r=e.current)==null?void 0:r.call(e,...n)},[])}lF(PM,"useEffectEvent");var cF=Object.defineProperty,qd=(t,e)=>cF(t,"name",{value:e,configurable:!0}),dF=El[" useInsertionEffect ".trim().toString()]||Ln;function H1({prop:t,defaultProp:e,onChange:n=qd(()=>{},"onChange"),caller:r}){const[s,i,o]=DM({defaultProp:e,onChange:n}),a=t!==void 0,l=a?t:s,c=b.useCallback(d=>{var u;if(a){const h=zM(d)?d(t):d;h!==t&&((u=o.current)==null||u.call(o,h))}else i(d)},[a,t,i,o]);return[l,c]}qd(H1,"useControllableState");function DM({defaultProp:t,onChange:e}){const[n,r]=b.useState(t),s=b.useRef(n),i=b.useRef(e);return dF(()=>{i.current=e},[e]),b.useEffect(()=>{var o;s.current!==n&&((o=i.current)==null||o.call(i,n),s.current=n)},[n,s]),[n,r,i]}qd(DM,"useUncontrolledState");function zM(t){return typeof t=="function"}qd(zM,"isFunction");var Vb=Symbol("RADIX:SYNC_STATE");function uF(t,e,n,r){const{prop:s,defaultProp:i,onChange:o,caller:a}=e,l=s!==void 0,c=PM(o),d=[{...n,state:i}];r&&d.push(r);const[u,h]=b.useReducer((x,y)=>{if(y.type===Vb)return{...x,state:y.state};const v=t(x,y);return l&&!Object.is(v.state,x.state)&&c(v.state),v},...d),m=u.state,g=b.useRef(m);b.useEffect(()=>{g.current!==m&&(g.current=m,l||c(m))},[m,g,l]);const p=b.useMemo(()=>s!==void 0?{...u,state:s}:u,[u,s]);return b.useEffect(()=>{l&&!Object.is(s,u.state)&&h({type:Vb,state:s})},[s,u.state,l]),[p,h]}qd(uF,"useControllableStateReducer");var fF=Object.defineProperty,hF=(t,e)=>fF(t,"name",{value:e,configurable:!0}),pF=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"}),mF=b.forwardRef(hF(function(e,n){return f.jsx(Dt.span,{...e,ref:n,style:{...pF,...e.style}})},"VisuallyHidden")),gF=Object.defineProperty,Rt=(t,e)=>gF(t,"name",{value:e,configurable:!0}),[q1,HY]=Lp("Tooltip",[_M]),K1=_M(),yF="TooltipProvider",xF=700,Tx="tooltip.open",[vF,J1]=q1(yF),LM=Rt(t=>{const{__scopeTooltip:e,delayDuration:n=xF,skipDelayDuration:r=300,disableHoverableContent:s=!1,children:i}=t,o=b.useRef(!0),a=b.useRef(!1),l=b.useRef(0);return b.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),f.jsx(vF,{scope:e,isOpenDelayedRef:o,delayDuration:n,onOpen:b.useCallback(()=>{r<=0||(window.clearTimeout(l.current),o.current=!1)},[r]),onClose:b.useCallback(()=>{r<=0||(window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:a,onPointerInTransitChange:b.useCallback(c=>{a.current=c},[]),disableHoverableContent:s,children:i})},"TooltipProvider"),Ox="Tooltip",[kF,Kd]=q1(Ox),wF=Rt(t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:s,onOpenChange:i,disableHoverableContent:o,delayDuration:a}=t,l=J1(Ox,t.__scopeTooltip),c=K1(e),[d,u]=b.useState(null),[h,m]=b.useState(void 0),g=Tr(),p=b.useRef(0),x=o??l.disableHoverableContent,y=a??l.delayDuration,v=b.useRef(!1),[k,w]=H1({prop:r,defaultProp:s??!1,onChange:Rt($=>{$?(l.onOpen(),document.dispatchEvent(new CustomEvent(Tx))):l.onClose(),i==null||i($)},"onChange"),caller:Ox}),C=b.useMemo(()=>k?v.current?"delayed-open":"instant-open":"closed",[k]),E=b.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v.current=!1,w(!0)},[w]),_=b.useCallback(()=>{window.clearTimeout(p.current),p.current=0,w(!1)},[w]),S=b.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{v.current=!0,w(!0),p.current=0},y)},[y,w]);b.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]);const j=h??g;return f.jsx(Q8,{...c,children:f.jsx(kF,{scope:e,contentId:j,setContentId:m,open:k,stateAttribute:C,trigger:d,onTriggerChange:u,onTriggerEnter:b.useCallback(()=>{l.isOpenDelayedRef.current?S():E()},[l.isOpenDelayedRef,S,E]),onTriggerLeave:b.useCallback(()=>{x?_():(window.clearTimeout(p.current),p.current=0)},[_,x]),onOpen:E,onClose:_,disableHoverableContent:x,children:n})})},"Tooltip"),Wb="TooltipTrigger",bF=b.forwardRef(Rt(function(e,n){const{__scopeTooltip:r,"aria-describedby":s,...i}=e,o=Kd(Wb,r),a=J1(Wb,r),l=K1(r),c=b.useRef(null),d=Dr(n,c,o.onTriggerChange),u=b.useRef(!1),h=b.useRef(!1),m=b.useCallback(()=>u.current=!1,[]);return b.useEffect(()=>()=>document.removeEventListener("pointerup",m),[m]),f.jsx(eF,{asChild:!0,...l,children:f.jsx(Dt.button,{"aria-describedby":o.open?KM(s,o.contentId):s,"data-state":o.stateAttribute,...i,ref:d,onPointerMove:Tn(e.onPointerMove,g=>{g.pointerType!=="touch"&&!h.current&&!a.isPointerInTransitRef.current&&(o.onTriggerEnter(),h.current=!0)}),onPointerLeave:Tn(e.onPointerLeave,()=>{o.onTriggerLeave(),h.current=!1}),onPointerDown:Tn(e.onPointerDown,()=>{o.open&&o.onClose(),u.current=!0,document.addEventListener("pointerup",m,{once:!0})}),onFocus:Tn(e.onFocus,()=>{u.current||o.onOpen()}),onBlur:Tn(e.onBlur,o.onClose),onClick:Tn(e.onClick,o.onClose)})})},"TooltipTrigger")),FM="TooltipPortal",[SF,CF]=q1(FM,{forceMount:void 0}),NF=Rt(t=>{const{__scopeTooltip:e,forceMount:n,children:r,container:s}=t,i=Kd(FM,e);return f.jsx(SF,{scope:e,forceMount:n,children:f.jsx(Hd,{present:n||i.open,children:f.jsx(TM,{asChild:!0,container:s,children:r})})})},"TooltipPortal"),fd="TooltipContent",EF=b.forwardRef(Rt(function(e,n){const r=CF(fd,e.__scopeTooltip),{forceMount:s=r.forceMount,side:i="top",...o}=e,a=Kd(fd,e.__scopeTooltip);return f.jsx(Hd,{present:s||a.open,children:a.disableHoverableContent?f.jsx(BM,{side:i,...o,ref:n}):f.jsx(_F,{side:i,...o,ref:n})})},"TooltipContent")),_F=b.forwardRef(Rt(function(e,n){const r=Kd(fd,e.__scopeTooltip),s=J1(fd,e.__scopeTooltip),i=b.useRef(null),o=Dr(n,i),[a,l]=b.useState(null),{trigger:c,onClose:d}=r,u=i.current,{onPointerInTransitChange:h}=s,m=b.useCallback(()=>{l(null),h(!1)},[h]),g=b.useCallback((p,x)=>{const y=p.currentTarget,v={x:p.clientX,y:p.clientY},k=VM(v,y.getBoundingClientRect()),w=WM(v,k),C=UM(x.getBoundingClientRect()),E=HM([...w,...C]);l(E),h(!0)},[h]);return b.useEffect(()=>()=>m(),[m]),b.useEffect(()=>{if(c&&u){const p=Rt(y=>g(y,u),"handleTriggerLeave"),x=Rt(y=>g(y,c),"handleContentLeave");return c.addEventListener("pointerleave",p),u.addEventListener("pointerleave",x),()=>{c.removeEventListener("pointerleave",p),u.removeEventListener("pointerleave",x)}}},[c,u,g,m]),b.useEffect(()=>{if(a){const p=Rt(x=>{const y=x.target,v={x:x.clientX,y:x.clientY},k=(c==null?void 0:c.contains(y))||(u==null?void 0:u.contains(y)),w=!ZM(v,a);k?m():w&&(m(),d())},"handleTrackPointerGrace");return document.addEventListener("pointermove",p),()=>document.removeEventListener("pointermove",p)}},[c,u,a,d,m]),f.jsx(BM,{...e,ref:o})},"TooltipContentHoverable")),jF=U$("TooltipContent"),BM=b.forwardRef(Rt(function(e,n){const{__scopeTooltip:r,children:s,"aria-label":i,id:o,onEscapeKeyDown:a,onPointerDownOutside:l,...c}=e,d=Kd(fd,r),u=K1(r),{onClose:h}=d,[m,g]=b.useState(null),p=Dr(n,g);oM(m),b.useEffect(()=>(document.addEventListener(Tx,h),()=>document.removeEventListener(Tx,h)),[h]),b.useEffect(()=>{if(d.trigger){const y=Rt(v=>{v.target instanceof Node&&v.target.contains(d.trigger)&&h()},"handleScroll");return window.addEventListener("scroll",y,{capture:!0}),()=>window.removeEventListener("scroll",y,{capture:!0})}},[d.trigger,h]);const{setContentId:x}=d;return Ln(()=>(x(o),()=>{x(void 0)}),[o,x]),f.jsx(X$,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:y=>y.preventDefault(),onDismiss:h,children:f.jsxs(nF,{"data-state":d.stateAttribute,role:i?void 0:"tooltip",id:i?void 0:d.contentId,...u,...c,ref:p,style:{...c.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:[f.jsx(jF,{children:s}),i?f.jsx(mF,{id:d.contentId,role:"tooltip",children:i}):null]})})},"TooltipContentImpl"));function VM(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),s=Math.abs(e.right-t.x),i=Math.abs(e.left-t.x);switch(Math.min(n,r,s,i)){case i:return"left";case s:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}Rt(VM,"getExitSideFromRect");function WM(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}Rt(WM,"getPaddedExitPoints");function UM(t){const{top:e,right:n,bottom:r,left:s}=t;return[{x:s,y:e},{x:n,y:e},{x:n,y:r},{x:s,y:r}]}Rt(UM,"getPointsFromRect");function ZM(t,e){const{x:n,y:r}=t;let s=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){const a=e[i],l=e[o],c=a.x,d=a.y,u=l.x,h=l.y;d>r!=h>r&&n<(u-c)*(r-d)/(h-d)+c&&(s=!s)}return s}Rt(ZM,"isPointInPolygon");function HM(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),qM(e)}Rt(HM,"getHull");function qM(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const s=t[r];for(;e.length>=2;){const i=e[e.length-1],o=e[e.length-2];if((i.x-o.x)*(s.y-o.y)>=(i.y-o.y)*(s.x-o.x))e.pop();else break}e.push(s)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const s=t[r];for(;n.length>=2;){const i=n[n.length-1],o=n[n.length-2];if((i.x-o.x)*(s.y-o.y)>=(i.y-o.y)*(s.x-o.x))n.pop();else break}n.push(s)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}Rt(qM,"getHullPresorted");function KM(...t){const e=new Set;for(const n of t)if(typeof n=="string")for(const r of String(n).trim().split(/\s+/))r&&e.add(r);return e.size>0?Array.from(e).join(" "):void 0}Rt(KM,"concatAriaDescribedby");function Hp(t){const e=t.trim();if(!e)return{kind:"unknown",label:"Paste Poney JSON or a Mermaid diagram"};if(oP(e))return{kind:"poney",label:"Poney document"};const n=qE(e);return n?{kind:"mermaid",label:{sequence:"Mermaid sequence diagram",flowchart:"Mermaid flowchart",state:"Mermaid state diagram",er:"Mermaid ER diagram"}[n]}:e.startsWith("{")?{kind:"json",label:'JSON, but not a Poney document (no "poneyVersion")'}:{kind:"unknown",label:"Not recognized"}}function G1(t){const e=Hp(t);if(e.kind==="poney"||e.kind==="json"){const n=iP(t,{extensions:Vd()});return n.ok?{ok:!0,doc:n.document,warnings:n.issues}:{ok:!1,issues:n.issues.filter(r=>r.severity==="error")}}if(e.kind==="mermaid")try{return{ok:!0,doc:aP(t).document,warnings:[]}}catch(n){return{ok:!1,issues:[{path:"",message:n instanceof dn?n.message:String(n)}]}}return{ok:!1,issues:[{path:"",message:'Paste a Poney document (JSON with "poneyVersion") or a Mermaid diagram.'}]}}function JM(t,e){const n=R.getState(),r=G1(t);return r.ok?(n.loadDocument(r.doc,e),n.setImportOpen(!1),n.notify(`Opened “${r.doc.project.name}”.${r.warnings.length?` ${r.warnings.length} note${r.warnings.length>1?"s":""} in the inspector.`:""}`),!0):(n.setImportOpen(!0,t),!1)}async function Y1(){const t=R.getState(),e=y1(t.history.present);try{await navigator.clipboard.writeText(e),t.notify("Copied the model to the clipboard as Poney JSON.")}catch{t.notify("The browser blocked clipboard access. Use “Download JSON” instead.")}}function $F(){const t=R.getState().history.present,e=new Blob([y1(t)],{type:"application/json"}),n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=`${t.project.id}.poney`,r.click(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}const Q1=t=>t instanceof HTMLElement&&(t.isContentEditable||t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT");function MF(){const t=e=>{var s;if(Q1(e.target)||R.getState().importOpen)return;const n=((s=e.clipboardData)==null?void 0:s.getData("text/plain"))??"";if(!n.trim())return;if(Hp(n).kind==="unknown"){R.getState().notify("The clipboard has no Poney JSON or Mermaid diagram.");return}e.preventDefault(),JM(n,"pasted")};return window.addEventListener("paste",t),()=>window.removeEventListener("paste",t)}const TF=new Set(["entity","relationship","message","state","transition","activityNode"]),GM=t=>TF.has(t.kind);function OF(t,e){var n,r,s,i,o,a,l,c;switch(e.kind){case"entity":return(n=t.entities.get(e.id))==null?void 0:n.name;case"relationship":return(r=t.relationships.get(e.id))==null?void 0:r.label;case"message":return(s=t.messages(e.behavior).find(d=>d.message.id===e.id))==null?void 0:s.message.label;case"state":return(o=(i=t.stateMachine(e.behavior))==null?void 0:i.states.find(d=>d.id===e.id))==null?void 0:o.name;case"transition":return(l=(a=t.stateMachine(e.behavior))==null?void 0:a.transitions.find(d=>d.id===e.id))==null?void 0:l.event;case"activityNode":{const d=t.behaviors.get(e.behavior);return(d==null?void 0:d.kind)==="activity"?(c=d.nodes.find(u=>u.id===e.id))==null?void 0:c.label:void 0}default:return}}function AF(t,e){switch(t.kind){case"entity":return{type:"entity.update",id:t.id,changes:{name:e}};case"relationship":return{type:"relationship.update",id:t.id,changes:{label:e}};case"message":case"state":case"transition":case"activityNode":return{type:"behavior.rename",behaviorId:t.behavior,element:t.kind,id:t.id,value:e};default:return}}function X1(t,e){var o;const n=R.getState();if(!n.history||!GM(t))return!1;const r=OF(gt(n.history.present),t);if(r===void 0)return!1;const s=e.getBoundingClientRect(),i=[...e.querySelectorAll("text")].find(a=>{const l=(a.textContent??"").replace(/…$/,"");return l.length>0&&r.startsWith(l)});if(i){const a=i.getBoundingClientRect(),l=((o=i.getScreenCTM())==null?void 0:o.a)??1,c=parseFloat(i.getAttribute("font-size")??getComputedStyle(i).fontSize)*l,d=i.getAttribute("text-anchor")==="middle",u=d?Math.max(a.width,s.width-16*l,280):Math.max(s.right-a.left-12*l,320);n.setRenaming({ref:t,value:r,text:i,rect:{x:a.x,y:a.y,w:a.width,h:a.height},room:u,font:{size:c,weight:i.getAttribute("font-weight")??"600"},align:d?"center":"left"})}else n.setRenaming({ref:t,value:r,rect:{x:s.x,y:s.y,w:s.width,h:s.height},room:Math.max(s.width,160),font:{size:14,weight:"600"},align:"center"});return!0}function Cu(t){const e=R.getState(),n=e.renaming;if(e.setRenaming(null),!n||t===null)return;const r=t.trim();if(!r||r===n.value)return;const s=AF(n.ref,r);s&&e.dispatch(s)}function YM(){const t=/^#\/([^?]*)(?:\?select=(.+))?$/.exec(window.location.hash);if(!t)return;const e=R.getState(),n=gt(e.history.present),r=decodeURIComponent(t[1])||bt,s=r.startsWith("walk:")&&n.doc.walkthroughs.some(o=>`walk:${o.id}`===r);if(r!==bt&&!s&&!n.views.has(r))return;const i=t[2]?un(decodeURIComponent(t[2])):null;e.navigate(r,{select:i})}function RF(t,e,n){const r=`#/${t===bt?"":encodeURIComponent(t)}${e&&n?`?select=${encodeURIComponent(n)}`:""}`;window.location.hash!==r&&window.history.replaceState(null,"",r)}function IF({label:t,shortcut:e,children:n,side:r="top"}){return f.jsxs(wF,{delayDuration:350,children:[f.jsx(bF,{asChild:!0,children:n}),f.jsx(NF,{children:f.jsxs(EF,{side:r,sideOffset:6,className:"fade-in z-50 flex items-center gap-2 rounded-md bg-ink px-2 py-1 text-[11.5px] text-paper shadow-float",children:[t,e&&f.jsx("kbd",{className:"rounded bg-paper/15 px-1 font-sans text-[10.5px] text-paper/80",children:e})]})})]})}function ot({label:t,shortcut:e,onClick:n,active:r,disabled:s,children:i,side:o="top"}){return f.jsx(IF,{label:t,shortcut:e,side:o,children:f.jsx("button",{type:"button","aria-label":t,"aria-pressed":r,disabled:s,onClick:n,className:`grid h-8 min-w-8 place-items-center rounded-md px-1.5 text-ink-2 transition-colors hover:bg-sunken hover:text-ink disabled:pointer-events-none disabled:opacity-35 ${r?"bg-poney-wash !text-poney":""}`,children:i})})}const Ub=()=>f.jsx("span",{className:"mx-1 h-5 w-px bg-rule","aria-hidden":!0}),PF={overview:"Overview",behavior:"Behavior",data:"Data",structure:"Structure","use-cases":"Use cases"};function Jd(t){return PF[t]??t.charAt(0).toUpperCase()+t.slice(1).replace(/-/g," ")}function QM(t){const e=kw.filter(r=>t.includes(r)),n=t.filter(r=>!kw.includes(r)).sort();return[...e,...n]}function DF(){const t=R.getState().live;return t.state==="on"&&t.url?Promise.resolve(t.url):t.state==="off"?Promise.resolve(void 0):new Promise(e=>{const n=window.setTimeout(()=>(r(),e(void 0)),15e3),r=R.subscribe(s=>{s.live.state==="on"&&s.live.url&&(window.clearTimeout(n),r(),e(s.live.url))})})}async function yn(t,e){const n=await DF();if(!n)throw new Error('The Studio cannot reach Poney on this computer. Run "npm run studio" in the Poney folder.');const r=await fetch(`${n}${t}`,e===void 0?void 0:{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),s=await r.json().catch(()=>({}));if(!r.ok)throw new Error(s.error??`Poney answered ${r.status}`);return s}function qp(t,e=[]){var o;const n=R.getState(),r=zp(n.viewId),s=(o=n.history)==null?void 0:o.present,i=s&&n.selection&&gt(s).exists(n.selection)?gt(s).describe(n.selection):void 0;return yn("/api/live/ask",{text:t,walkthrough:n.startOpen?void 0:r,scene:!n.startOpen&&r?n.activeScene??void 0:void 0,selection:!n.startOpen&&n.selection?{ref:fe(n.selection),title:(i==null?void 0:i.title)??"",kind:(i==null?void 0:i.kind)??n.selection.kind}:void 0,...e.length?{context:e}:{}})}const e0=()=>yn("/api/agent"),Ax=(t,e)=>yn("/api/agent/connect",{...t,...e?{folder:e}:{}}),zF=(t,e=!1)=>yn("/api/agent/check",{...t,fresh:e}),LF=()=>yn("/api/agent/disconnect",{}),FF=()=>yn("/api/agent/cancel",{}),BF=(t,e)=>yn("/api/agent/permission",{messageId:t,optionId:e}),VF=t=>yn(`/api/workspace/folders${t?`?path=${encodeURIComponent(t)}`:""}`),Rx=(t,e)=>yn("/api/agent/setting",{id:t,value:e}),WF=t=>yn("/api/project/open",{path:t}),XM=t=>yn("/api/files/open",{path:t}),UF=t=>yn("/api/workspace/clone",{url:t}),eT=()=>yn("/api/plugins"),ZF=t=>yn("/api/import",{importer:t}),HF=t=>yn("/api/overlays/run",{id:t}),qF=t=>yn("/api/overlays/clear",{id:t}),tT=[{label:"Give me a tour of this codebase",prompt:"Give me a Poney tour of this codebase: what it is for, its main parts, one main flow end to end, and where to start a change. Open it in the Studio."},{label:"Walk me through the last commit",prompt:"Write a Poney walkthrough of the last commit in this repository, check it against the code, and open it in the Studio."},{label:"How is this code organised?",prompt:"Show me how this codebase is organised: its parts and how they connect, as a Poney map with groups. Open it in the Studio."}],KF=[{label:"What should I read first?",prompt:"Using the open Poney document and the code, tell me in a few sentences what to read first and why. Do not change the document."},{label:"Explain this scene",prompt:"Explain the scene I am on in plain words: what it shows and why it matters. Do not change the document."},{label:"Add the last commit",prompt:"Add a walkthrough of the last commit in this repository to the open Poney document. Get the document with poney_read first and keep everything in it. Check it against the code, and open it again."}],JF=t=>t&&(t.walkthroughs.length||t.views.length)?KF:tT,nT="poney:agents";function Ix(){try{return JSON.parse(localStorage.getItem(nT)??"[]")}catch{return[]}}function Zb(t){try{localStorage.setItem(nT,JSON.stringify(t))}catch{}}const rT="poney:workspace",kh=()=>{try{return localStorage.getItem(rT)??void 0}catch{return}},sT=t=>{try{localStorage.setItem(rT,t)}catch{}};function iT(){const t=R(e=>{var n;return((n=e.project)==null?void 0:n.root)??null});return t?{root:t,name:t.split("/").pop()??t}:null}function GF(){const t=R(g=>g.live.state==="on"),e=R(g=>g.project),n=R(g=>g.overlays),[r,s]=b.useState(!1),[i,o]=b.useState([]),[a,l]=b.useState(null),[c,d]=b.useState(null),u=b.useRef(null);if(b.useEffect(()=>{if(!r)return;eT().then(x=>o(x.overlays),x=>d(x instanceof Error?x.message:String(x)));const g=x=>{var y;return!((y=u.current)!=null&&y.contains(x.target))&&s(!1)},p=x=>x.key==="Escape"&&s(!1);return window.addEventListener("pointerdown",g,!0),window.addEventListener("keydown",p),()=>{window.removeEventListener("pointerdown",g,!0),window.removeEventListener("keydown",p)}},[r]),!t||!e)return null;const h=Object.keys(n).length,m=async g=>{l(g),d(null);try{await(n[g]?qF(g):HF(g))}catch(p){d(p instanceof Error?p.message:String(p))}finally{l(null)}};return f.jsxs("div",{ref:u,className:"relative mr-1",children:[f.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":r,onClick:()=>s(!r),title:"Live facts on the parts: test coverage, recent changes",className:`inline-flex h-8 items-center gap-1.5 rounded-lg px-2 text-[12.5px] font-medium ${h?"bg-poney-wash text-poney":"text-ink-2 hover:bg-sunken"}`,children:[f.jsx(nD,{size:15}),f.jsxs("span",{className:"hidden lg:inline",children:["Facts",h?` (${h})`:""]})]}),r&&f.jsxs("div",{role:"menu","aria-label":"Facts",className:"fade-in absolute right-0 top-10 z-50 w-80 rounded-xl border border-rule bg-raised p-1 shadow-float",children:[i.map(g=>{const p=!!n[g.id],x=g.files.length>0;return f.jsxs("button",{type:"button",role:"menuitemcheckbox","aria-checked":p,disabled:!x&&!p,onClick:()=>void m(g.id),className:"flex w-full items-start gap-2.5 rounded-lg px-2.5 py-2 text-left hover:bg-sunken disabled:cursor-default disabled:opacity-50 disabled:hover:bg-transparent",children:[f.jsx("span",{className:`mt-0.5 grid h-4 w-4 shrink-0 place-items-center rounded border ${p?"border-poney bg-poney text-paper":"border-rule-strong"}`,children:a===g.id?f.jsx(Ro,{size:11,className:"animate-spin text-ink-3"}):p&&f.jsx(js,{size:11})}),f.jsxs("span",{className:"min-w-0",children:[f.jsx("span",{className:"block text-[13px] font-medium",children:g.name}),f.jsx("span",{className:"block text-[12px] text-ink-3",children:p?n[g.id].notes[0]:x?g.description:"Nothing to read in this folder."})]})]},g.id)}),c&&f.jsx("p",{className:"px-2.5 py-1.5 text-[12px] text-removed",children:c})]})]})}function YF(){const t=Be(),e=R(),n=e.viewId===bt?void 0:t.views.get(e.viewId),r=t.doc.walkthroughs.find(a=>a.id===zp(e.viewId)),s=n?rs(n):void 0,i=e.selection?t.describe(e.selection):void 0,o=n?e.pinned.includes(n.id):!1;return f.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1 border-b border-rule bg-paper px-2",children:[f.jsx(ot,{label:e.sidebarOpen?"Hide sidebar":"Show sidebar",shortcut:"[",onClick:()=>e.toggleSidebar(),side:"bottom",active:!1,children:f.jsx(gj,{size:16})}),f.jsx(ot,{label:"Back",shortcut:"⌥←",onClick:e.goBack,disabled:e.back.length===0,side:"bottom",children:f.jsx(n_,{size:16})}),f.jsx("span",{className:"hidden sm:contents",children:f.jsx(ot,{label:"Forward",shortcut:"⌥→",onClick:e.goForward,disabled:e.forward.length===0,side:"bottom",children:f.jsx(ns,{size:16})})}),f.jsxs("nav",{"aria-label":"Breadcrumb",className:"ml-2 flex min-w-0 items-center gap-1.5 text-[13px]",children:[f.jsx("button",{type:"button",className:`truncate rounded px-1 text-ink-2 hover:text-ink ${n||r?"hidden sm:inline":""}`,onClick:()=>e.navigate(bt),children:t.doc.project.name}),r&&f.jsxs(f.Fragment,{children:[f.jsx(Jl,{className:"hidden sm:inline"}),f.jsx("span",{className:"hidden text-ink-3 sm:inline",children:"Walkthrough"}),f.jsx(Jl,{className:"hidden sm:inline"}),f.jsx("span",{className:"truncate font-semibold text-ink",children:Ar(r.title)})]}),n&&f.jsxs(f.Fragment,{children:[f.jsx(Jl,{className:"hidden sm:inline"}),f.jsx("span",{className:"hidden truncate text-ink-3 sm:inline",children:Jd(n.category)}),f.jsx(Jl,{className:"hidden sm:inline"}),f.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 font-semibold text-ink",children:[s&&f.jsx(s.icon,{size:14,className:"shrink-0 text-ink-3","aria-hidden":!0}),f.jsx("span",{className:"truncate",children:n.title})]})]}),i&&!r&&f.jsxs(f.Fragment,{children:[f.jsx(Jl,{className:"hidden md:inline"}),f.jsx("button",{type:"button",className:"hidden max-w-[220px] truncate rounded px-1 text-poney hover:underline md:inline",onClick:()=>e.selection&&e.requestFocus("zoom",e.selection),title:"Zoom to the selection",children:i.title})]}),n&&f.jsx("span",{className:"hidden sm:contents",children:f.jsx(ot,{label:o?"Unpin this diagram":"Pin this diagram",onClick:()=>e.togglePin(n.id),active:o,side:"bottom",children:f.jsx(Dj,{size:14,fill:o?"currentColor":"none"})})})]}),f.jsx("div",{className:"flex-1"}),f.jsx(XF,{}),f.jsx(ot,{label:"Undo",shortcut:"⌘Z",onClick:e.undo,disabled:!e.history.past.length,side:"bottom",children:f.jsx(RD,{size:16})}),f.jsx(ot,{label:"Redo",shortcut:"⇧⌘Z",onClick:e.redo,disabled:!e.history.future.length,side:"bottom",children:f.jsx(_D,{size:16})}),f.jsx("span",{className:"mx-1 h-5 w-px bg-rule","aria-hidden":!0}),f.jsx(eB,{}),f.jsx(GF,{}),f.jsxs("button",{type:"button",onClick:()=>e.setPaletteOpen(!0),className:"mr-1 hidden h-8 w-64 items-center gap-2 rounded-lg border border-rule bg-plaster px-2.5 text-left text-ink-3 transition-colors hover:border-rule-strong hover:text-ink-2 md:flex",children:[f.jsx(Xy,{size:14}),f.jsx("span",{className:"flex-1",children:"Search this document"}),f.jsx("kbd",{className:"rounded border border-rule bg-raised px-1 text-[11px]",children:"⌘K"})]}),f.jsx("span",{className:"md:hidden",children:f.jsx(ot,{label:"Search",shortcut:"⌘K",onClick:()=>e.setPaletteOpen(!0),side:"bottom",children:f.jsx(Xy,{size:16})})}),f.jsxs("span",{className:"hidden sm:contents",children:[f.jsx(ot,{label:"Open or paste a model",onClick:()=>e.setImportOpen(!0),side:"bottom",children:f.jsx(k1,{size:16})}),f.jsx(QF,{}),f.jsx(ot,{label:e.theme==="light"?"Dark theme":"Light theme",onClick:e.toggleTheme,side:"bottom",children:e.theme==="light"?f.jsx(b1,{size:16}):f.jsx(Lj,{size:16})}),f.jsx(ot,{label:"Keyboard shortcuts",shortcut:"?",onClick:()=>e.setShortcutsOpen(!0),side:"bottom",children:f.jsx(Y_,{size:16})})]}),f.jsx(ot,{label:e.inspectorOpen?"Hide inspector":"Show inspector",shortcut:"]",onClick:()=>e.toggleInspector(),side:"bottom",children:f.jsx(bD,{size:16})})]})}function Jl({className:t=""}){return f.jsx("span",{className:`text-ink-4 ${t}`,"aria-hidden":!0,children:"/"})}function QF(){const[t,e]=b.useState(!1),n=b.useRef(null);b.useEffect(()=>{if(!t)return;const s=o=>{var a;return!((a=n.current)!=null&&a.contains(o.target))&&e(!1)},i=o=>o.key==="Escape"&&e(!1);return window.addEventListener("mousedown",s),window.addEventListener("keydown",i),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",i)}},[t]);const r="flex w-full items-center gap-2.5 rounded-md px-2.5 py-2 text-left text-[13px] hover:bg-sunken";return f.jsxs("div",{className:"relative",ref:n,children:[f.jsx(ot,{label:"Export the model",onClick:()=>e(!t),active:t,side:"bottom",children:f.jsx(TD,{size:16})}),t&&f.jsxs("div",{role:"menu",className:"fade-in absolute right-0 top-10 z-40 w-64 rounded-xl border border-rule bg-raised p-1 shadow-float",children:[f.jsxs("button",{role:"menuitem",type:"button",className:r,onClick:()=>{e(!1),Y1()},children:[f.jsx(N_,{size:15,className:"text-ink-3"}),f.jsx("span",{className:"flex-1",children:"Copy JSON"}),f.jsx("kbd",{className:"text-[11px] text-ink-3",children:"⇧⌘C"})]}),f.jsxs("button",{role:"menuitem",type:"button",className:r,onClick:()=>{e(!1),$F()},children:[f.jsx(cD,{size:15,className:"text-ink-3"}),f.jsx("span",{className:"flex-1",children:"Download .poney"})]}),f.jsx("p",{className:"px-2.5 pb-1.5 pt-1 text-[11.5px] leading-snug text-ink-3",children:"Paste Poney JSON or Mermaid anywhere in the studio to open it."})]})]})}function XF(){const t=R(n=>n.live.state==="on"?n.liveFile:null);return R(n=>n.history.past.length>0||n.history.future.length>0)?f.jsx("span",{className:"mr-1 hidden text-[12px] text-ink-3 lg:inline",title:t?`Every change is saved to ${t}. Undo goes back one change at a time.`:"Changes are kept in this browser. Use Download to keep a file.",children:t?`Saved to ${t.split("/").pop()}`:"Kept in this browser"}):null}function eB(){const t=R(r=>r.live);if(t.state==="off")return null;const e=t.state==="on",n=e?"Live":t.state==="connecting"?"Connecting":"Offline";return f.jsxs("span",{title:e?"Linked to Poney on this computer: agents can open documents here, you can talk to them, and documents are saved to their files.":"Poney on this computer does not answer. Agents and saving to files are off until it is back.",className:`mr-2 hidden items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-[12px] font-semibold sm:inline-flex ${e?"border-new/40 bg-new-wash text-new":"border-rule text-ink-3"}`,children:[f.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${e?"bg-new":"bg-ink-4"}`}),n]})}function oT(){return f.jsxs("a",{href:"https://hattori.ai",target:"_blank",rel:"noopener noreferrer",className:"sticky bottom-0 mt-auto flex shrink-0 items-center gap-2 bg-paper px-4 pb-4 pt-3 text-[12.5px] font-medium text-ink-2 transition-colors hover:text-ink",children:[f.jsx("span",{className:"h-px w-3 bg-poney","aria-hidden":!0}),"Made by Hattori AI"]})}function tB(){const t=R(n=>n.sidebarOpen),e=R(n=>n.toggleSidebar);return f.jsxs(f.Fragment,{children:[t&&f.jsx("div",{className:"fixed inset-0 z-20 bg-ink/20 lg:hidden",onClick:()=>e(!1),"aria-hidden":!0}),f.jsxs("aside",{"aria-label":"Project navigation",className:`scrollbar-quiet z-30 flex w-[264px] shrink-0 flex-col overflow-y-auto border-r border-rule bg-paper transition-[margin] duration-200 max-lg:fixed max-lg:bottom-0 max-lg:top-12 max-lg:shadow-float ${t?"ml-0":"-ml-[264px] max-lg:invisible"}`,children:[f.jsx(nB,{}),f.jsx("div",{className:"px-2 pb-1",children:f.jsxs("button",{type:"button",onClick:()=>R.getState().setPaletteOpen(!0),className:"flex h-8 w-full items-center gap-2 rounded-md px-2 text-ink-3 hover:bg-sunken hover:text-ink-2",children:[f.jsx(Xy,{size:14}),f.jsx("span",{className:"flex-1 text-left",children:"Search"}),f.jsx("kbd",{className:"text-[11px]",children:"/"})]})}),f.jsx(sB,{}),f.jsx(iB,{}),f.jsx(oT,{})]})]})}function nB(){const t=R(o=>o.projects),e=R(o=>o.projectId),n=Be(),[r,s]=b.useState(!1),i=b.useRef(null);return b.useEffect(()=>{if(!r)return;const o=l=>{var c;return!((c=i.current)!=null&&c.contains(l.target))&&s(!1)},a=l=>l.key==="Escape"&&s(!1);return window.addEventListener("mousedown",o),window.addEventListener("keydown",a),()=>{window.removeEventListener("mousedown",o),window.removeEventListener("keydown",a)}},[r]),f.jsxs("div",{className:"relative p-2",ref:i,children:[f.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":r,onClick:()=>s(!r),className:"flex w-full items-center gap-2.5 rounded-lg p-1.5 text-left hover:bg-sunken",children:[f.jsx(aT,{}),f.jsxs("span",{className:"min-w-0 flex-1",children:[f.jsx("span",{className:"block truncate text-[13.5px] font-semibold",children:n.doc.project.name}),f.jsx(rB,{fallback:`Poney ${n.doc.poneyVersion}`})]}),f.jsx(f_,{size:14,className:"text-ink-3"})]}),r&&f.jsxs("div",{role:"listbox","aria-label":"Projects",className:"fade-in absolute left-2 right-2 top-14 z-40 rounded-xl border border-rule bg-raised p-1 shadow-float",children:[t.map(o=>f.jsxs("button",{role:"option","aria-selected":o.id===e,type:"button",className:"flex w-full items-center gap-2 rounded-md px-2.5 py-2 text-left hover:bg-sunken",onClick:()=>{s(!1),R.getState().switchProject(o.id)},children:[f.jsxs("span",{className:"min-w-0 flex-1",children:[f.jsx("span",{className:"block truncate",children:o.doc.project.name}),f.jsx("span",{className:"block text-[11.5px] text-ink-3",children:o.origin==="example"?"Example":o.origin==="pasted"?"Pasted":"Imported"})]}),o.id===e&&f.jsx(js,{size:14,className:"text-poney"})]},o.id)),f.jsx("div",{className:"my-1 h-px bg-rule"}),f.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md px-2.5 py-2 text-left text-ink-2 hover:bg-sunken",onClick:()=>{s(!1),R.getState().setImportOpen(!0)},children:[f.jsx(k1,{size:14}),"Open or paste a model…"]}),R.getState().live.state==="on"&&f.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md px-2.5 py-2 text-left text-ink-2 hover:bg-sunken",onClick:()=>{s(!1),R.getState().setProjectOpen(!0)},children:[f.jsx(w1,{size:14}),"Open a project…"]}),R.getState().live.state==="on"&&R.getState().project&&f.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md px-2.5 py-2 text-left text-ink-2 hover:bg-sunken",onClick:()=>{s(!1),R.getState().setImportCodeOpen(!0)},children:[f.jsx(aD,{size:14}),"Import from the code…"]}),f.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-md px-2.5 py-2 text-left text-ink-2 hover:bg-sunken",onClick:()=>{s(!1),R.getState().showStart(!0)},children:[f.jsx(hD,{size:14}),"Start page"]})]})]})}function rB({fallback:t}){const e=R(r=>r.live.state==="on"?r.liveFile:null);if(!e)return f.jsx("span",{className:"block truncate text-[11.5px] text-ink-3",children:t});const n=e.split("/").slice(-3).join("/");return f.jsxs("span",{className:"block truncate text-[11.5px] text-ink-3",title:`Saved to ${e}`,children:["Saved to ",n]})}function aT(){return f.jsxs("svg",{width:"30",height:"30",viewBox:"-22 -18 156 152","aria-hidden":!0,className:"shrink-0",children:[f.jsx("rect",{x:"-22",y:"-18",width:"156",height:"152",rx:"36",fill:"var(--ink)"}),f.jsx("path",{d:"M40 26V86M40 26H62A17 17 0 0 1 62 60H40",fill:"none",stroke:"var(--paper)",strokeWidth:"6",strokeLinejoin:"round"}),f.jsx("rect",{x:"28",y:"16",width:"24",height:"20",rx:"5",fill:"var(--paper)"}),f.jsx("rect",{x:"28",y:"50",width:"24",height:"20",rx:"5",fill:"var(--paper)"}),f.jsx("rect",{x:"28",y:"76",width:"24",height:"20",rx:"5",fill:"var(--accent)"})]})}function Hb({view:t,active:e}){const n=rs(t),r=(n==null?void 0:n.icon)??Ao;return f.jsxs("button",{type:"button","aria-current":e?"page":void 0,onClick:()=>R.getState().navigate(t.id),className:`group flex h-8 w-full items-center gap-2.5 rounded-md px-2 text-left transition-colors ${e?"bg-sunken font-semibold text-ink":"text-ink-2 hover:bg-sunken/70 hover:text-ink"}`,title:t.description,children:[f.jsx(r,{size:15,className:e?"text-poney":"text-ink-3 group-hover:text-ink-2","aria-hidden":!0}),f.jsx("span",{className:"truncate",children:t.title})]})}function sB(){const t=Be(),e=R(i=>i.viewId),n=R(i=>i.pinned),r=QM([...new Set(t.doc.views.map(i=>i.category))]).filter(i=>i!=="walkthrough"),s=n.map(i=>t.views.get(i)).filter(i=>!!i);return f.jsxs("nav",{"aria-label":"Diagrams",className:"px-2",children:[f.jsxs("button",{type:"button","aria-current":e===bt?"page":void 0,onClick:()=>R.getState().navigate(bt),className:`flex h-8 w-full items-center gap-2.5 rounded-md px-2 text-left ${e===bt?"bg-sunken font-semibold":"text-ink-2 hover:bg-sunken/70 hover:text-ink"}`,children:[f.jsx(Ao,{size:15,className:e===bt?"text-poney":"text-ink-3"}),"Project overview"]}),t.doc.walkthroughs.length>0&&f.jsx(af,{title:"Walkthroughs",children:t.doc.walkthroughs.map(i=>{const o=e===`walk:${i.id}`;return f.jsxs("button",{type:"button","aria-current":o?"page":void 0,onClick:()=>R.getState().navigate(`walk:${i.id}`),className:`group flex w-full items-start gap-2.5 rounded-md px-2 py-1.5 text-left transition-colors ${o?"bg-sunken font-semibold text-ink":"text-ink-2 hover:bg-sunken/70 hover:text-ink"}`,children:[f.jsx($p,{size:15,className:`mt-[2px] shrink-0 ${o?"text-poney":"text-ink-3"}`,"aria-hidden":!0}),f.jsx("span",{className:"leading-snug",children:Ar(i.title)})]},i.id)})}),s.length>0&&f.jsx(af,{title:"Pinned",icon:f.jsx(Dj,{size:11,className:"text-ink-3"}),children:s.map(i=>f.jsx(Hb,{view:i,active:!1},`pin-${i.id}`))}),r.map(i=>f.jsx(af,{title:Jd(i),children:t.doc.views.filter(o=>o.category===i).map(o=>f.jsx(Hb,{view:o,active:o.id===e},o.id))},i))]})}function af({title:t,icon:e,children:n}){return f.jsxs("div",{className:"mt-4",children:[f.jsxs("h2",{className:"mb-1 flex items-center gap-1.5 px-2 text-[11.5px] font-semibold text-ink-3",children:[e,t]}),f.jsx("div",{className:"space-y-px",children:n})]})}function iB(){const t=Be(),e=b.useMemo(()=>t.doc.model.entities.filter(r=>!r.parent&&!r.kind.includes("/")),[t]),n=[{title:"System",items:e.filter(r=>r.kind!=="person"&&r.kind!=="external")},{title:"People",items:e.filter(r=>r.kind==="person")},{title:"Outside services",items:e.filter(r=>r.kind==="external")}].filter(r=>r.items.length);return f.jsx("div",{className:"mt-2 px-2 pb-6",children:n.map(r=>f.jsx(af,{title:r.title,children:f.jsx("ul",{role:"tree","aria-label":r.title,children:r.items.map(s=>f.jsx(lT,{entity:s,depth:0},s.id))})},r.title))})}function lT({entity:t,depth:e}){const n=Be(),r=R(d=>d.selection),s=n.children(t.id),[i,o]=b.useState(e===0),a=n.style(t),l=Pp(a.icon),c=(r==null?void 0:r.kind)==="entity"&&r.id===t.id;return f.jsxs("li",{role:"treeitem","aria-expanded":s.length?i:void 0,"aria-selected":c,children:[f.jsxs("div",{className:`flex h-7 items-center rounded-md ${c?"bg-poney-wash":"hover:bg-sunken/70"}`,style:{paddingLeft:e*14},children:[s.length?f.jsx("button",{type:"button","aria-label":i?`Close ${t.name}`:`Open ${t.name}`,className:"grid h-6 w-5 place-items-center text-ink-3 hover:text-ink",onClick:()=>o(!i),children:f.jsx(zd,{size:13,className:`transition-transform ${i?"rotate-90":""}`})}):f.jsx("span",{className:"w-5"}),f.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-2 pr-2 text-left",onClick:()=>Ud({kind:"entity",id:t.id}),title:t.summary,children:[f.jsx(l,{size:13,style:{color:pt(a.tone)},className:"shrink-0","aria-hidden":!0}),f.jsx("span",{className:`truncate text-[12.5px] ${c?"font-semibold text-poney":"text-ink-2"}`,children:t.name})]})]}),i&&s.length>0&&f.jsx("ul",{role:"group",children:s.map(d=>f.jsx(lT,{entity:d,depth:e+1},d.id))})]})}const oB=t=>t==="table"?f.jsx(Bj,{size:14}):t==="event"?f.jsx(zD,{size:14}):f.jsx(lD,{size:14});function Ei({id:t,secondary:e}){const r=Be().dataTypes.get(t);return r?f.jsx(Ct,{to:{kind:"dataType",id:t},label:f.jsx("span",{className:r.kind==="table"?"font-mono text-[12px]":"",children:r.name}),secondary:e??r.summary,icon:oB(r.kind),tone:"var(--malachite)"}):null}function Kp({refValue:t,title:e="Seen in diagrams",exclude:n=[]}){const r=Be(),s=R(o=>o.viewId),i=r.viewsShowing(t).filter(o=>o.id!==s&&!n.includes(o.id));return i.length?f.jsx(we,{title:e,count:i.length,children:i.map(o=>f.jsx(Zd,{view:o,select:t},o.id))}):null}function aB({refValue:t}){const e=Be();return f.jsx(f.Fragment,{children:UL().map(n=>{const r=n.render({ref:t,doc:e.doc,idx:e});return r?f.jsx(we,{title:n.title,children:r},n.id):null})})}function lB({id:t}){const e=Be(),n=e.entities.get(t);if(!n)return null;const r=e.outgoing(t).filter(h=>h.kind!=="depends-on"&&h.kind!=="implements"),s=e.incoming(t).filter(h=>h.kind!=="depends-on"&&h.kind!=="implements"),i=e.outgoing(t).filter(h=>h.kind==="depends-on"||h.kind==="implements"),o=e.incoming(t).filter(h=>h.kind==="depends-on"||h.kind==="implements"),a=e.behaviorsInvolving(t),l=e.dataOf(t),c=e.useCasesOf(t),d=e.children(t),u=n.parent?e.entities.get(n.parent):void 0;return f.jsxs(f.Fragment,{children:[f.jsxs(we,{title:"About",children:[f.jsx(Ht,{children:n.description??n.summary}),f.jsx("div",{className:"mt-3",children:f.jsx(zn,{items:[["Kind",e.style(n).label],["Technology",n.technology],["Part of",u?f.jsx("button",{className:"text-left hover:text-poney hover:underline",onClick:()=>R.getState().select({kind:"entity",id:u.id}),children:u.name}):void 0]]})}),n.tags.length>0&&f.jsx("div",{className:"mt-3",children:f.jsx(O6,{items:n.tags})})]}),f.jsx(aB,{refValue:{kind:"entity",id:t}}),(r.length>0||s.length>0)&&f.jsxs(we,{title:"Connections",count:r.length+s.length,children:[r.map(h=>{var m;return f.jsx(Ct,{to:{kind:"relationship",id:h.id},label:f.jsxs(f.Fragment,{children:[h.label," ",f.jsxs("span",{className:"text-ink-3",children:["→ ",(m=e.entities.get(h.target))==null?void 0:m.name]})]}),secondary:h.protocol,icon:f.jsx(ns,{size:14}),tone:"var(--ink-3)"},h.id)}),s.map(h=>{var m;return f.jsx(Ct,{to:{kind:"relationship",id:h.id},label:f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:"text-ink-3",children:[(m=e.entities.get(h.source))==null?void 0:m.name," →"]})," ",h.label.charAt(0).toLowerCase()+h.label.slice(1)]}),secondary:h.protocol,icon:f.jsx(ns,{size:14,className:"rotate-180"}),tone:"var(--ink-3)"},h.id)})]}),(i.length>0||o.length>0)&&f.jsxs(we,{title:"Code dependencies",count:i.length+o.length,children:[i.map(h=>f.jsx(It,{id:h.target,secondary:h.kind==="implements"?"Implements this interface":`Uses it: ${h.label.toLowerCase()}`},h.id)),o.map(h=>f.jsx(It,{id:h.source,secondary:h.kind==="implements"?"Implements this":`Depends on this: ${h.label.toLowerCase()}`},h.id))]}),a.length>0&&f.jsx(we,{title:"Takes part in",count:a.length,children:a.map(h=>e.viewsForBehavior(h.id).map(m=>f.jsx(Zd,{view:m,select:{kind:"entity",id:t},verb:"Open"},`${h.id}-${m.id}`)))}),(l.consumed.size>0||l.produced.size>0||l.owned.length>0)&&f.jsxs(we,{title:"Data",children:[l.owned.length>0&&f.jsx("p",{className:"mb-1 text-[11.5px] text-ink-3",children:"Owns or stores"}),l.owned.map(h=>f.jsx(Ei,{id:h.id},`o-${h.id}`)),l.consumed.size>0&&f.jsx("p",{className:"mb-1 mt-2 text-[11.5px] text-ink-3",children:"Receives"}),[...l.consumed.entries()].map(([h,m])=>f.jsx(Ei,{id:h,secondary:`From ${m.map(g=>{var p;return(p=e.entities.get(g.source))==null?void 0:p.name}).join(", ")}`},`c-${h}`)),l.produced.size>0&&f.jsx("p",{className:"mb-1 mt-2 text-[11.5px] text-ink-3",children:"Sends"}),[...l.produced.entries()].map(([h,m])=>f.jsx(Ei,{id:h,secondary:`To ${m.map(g=>{var p;return(p=e.entities.get(g.target))==null?void 0:p.name}).join(", ")}`},`p-${h}`))]}),d.length>0&&f.jsx(we,{title:"Contains",count:d.length,children:d.map(h=>f.jsx(It,{id:h.id},h.id))}),c.length>0&&f.jsx(we,{title:n.kind==="person"?"Can":"Makes possible",count:c.length,children:c.map(h=>f.jsx(Ct,{to:{kind:"useCase",id:h.id},label:h.name,secondary:h.summary,icon:f.jsx(Fd,{size:14}),tone:"var(--tyrian)"},h.id))}),f.jsx(Kp,{refValue:{kind:"entity",id:t},title:"Also seen in",exclude:a.flatMap(h=>e.viewsForBehavior(h.id).map(m=>m.id))}),f.jsx(O$,{refs:n.sourceRefs})]})}function cB({id:t}){var s,i;const e=Be(),n=e.relationships.get(t);if(!n)return null;const r=e.messagesAlong(t);return f.jsxs(f.Fragment,{children:[f.jsxs(we,{title:"About",children:[f.jsx(Ht,{children:n.description??`${(s=e.entities.get(n.source))==null?void 0:s.name} ${n.label.charAt(0).toLowerCase()+n.label.slice(1)} ${(i=e.entities.get(n.target))==null?void 0:i.name}.`}),f.jsx("div",{className:"mt-3",children:f.jsx(zn,{items:[["Kind",dB(n.kind)],["Protocol",n.protocol]]})})]}),f.jsxs(we,{title:"Between",children:[f.jsx(It,{id:n.source,secondary:"From"}),f.jsx(It,{id:n.target,secondary:"To"})]}),n.data.length>0&&f.jsx(we,{title:"Carries",count:n.data.length,children:n.data.map(o=>f.jsx(Ei,{id:o},o))}),r.length>0&&f.jsx(we,{title:"Used in these steps",count:r.length,children:r.map(({interaction:o,item:a})=>f.jsx(Ct,{to:{kind:"message",behavior:o.id,id:a.message.id},label:a.message.label,secondary:`${o.name}, step ${a.number}`,icon:f.jsx(Fd,{size:14}),tone:"var(--lapis)"},`${o.id}-${a.message.id}`))}),f.jsx(Kp,{refValue:{kind:"relationship",id:t}})]})}const dB=t=>({uses:"Used by a person",calls:"Request, waits for an answer",reads:"Reads",writes:"Writes","reads-writes":"Reads and writes",publishes:"Publishes events",subscribes:"Subscribes to events","depends-on":"Code dependency",implements:"Implements an interface"})[t]??t;function uB({id:t,field:e}){var a,l,c;const n=Be(),r=n.dataTypes.get(t);if(!r)return null;const s=n.usagesOfData(t),i=e?r.fields.find(d=>d.name===e):void 0,o=e?s.relations.filter(d=>d.via===e):[];return f.jsxs(f.Fragment,{children:[i&&f.jsxs(we,{title:`Field ${i.name}`,children:[i.description&&f.jsx(Ht,{children:i.description}),f.jsx("div",{className:"mt-2",children:f.jsx(zn,{items:[["Type",f.jsx("code",{className:"font-mono text-[12px]",children:i.type})],["Key",i.primaryKey?"Primary key":i.references?"Foreign key":void 0],["Unique",i.unique?"Yes":void 0],["Can be empty",i.nullable?"Yes":"No"]]})}),i.references&&f.jsx("div",{className:"mt-2",children:f.jsx(Ct,{to:{kind:"dataType",id:i.references.dataType,field:i.references.field},label:f.jsxs("span",{className:"font-mono text-[12px]",children:[(a=n.dataTypes.get(i.references.dataType))==null?void 0:a.name,".",i.references.field]}),secondary:"References",icon:f.jsx(Ec,{size:14}),tone:"var(--lapis)"})}),o.map(d=>{var h;const u=d.from===t?d.to:d.from;return f.jsx(Ct,{to:{kind:"dataType",id:u},label:f.jsx("span",{className:"font-mono text-[12px]",children:(h=n.dataTypes.get(u))==null?void 0:h.name}),secondary:d.logical?"Logical reference across services; no database constraint":"Linked by this field",icon:f.jsx(Ec,{size:14}),tone:"var(--lapis)"},d.id)})]}),f.jsxs(we,{title:i?`About ${r.name}`:"About",children:[f.jsx(Ht,{children:r.description??r.summary}),f.jsx("div",{className:"mt-3",children:f.jsx(zn,{items:[["Kind",r.kind==="table"?"Table":r.kind==="event"?"Event":r.kind==="document"?"Document":"Record"],["Owned by",r.ownedBy?f.jsx("button",{className:"text-left hover:text-poney hover:underline",onClick:()=>R.getState().select({kind:"entity",id:r.ownedBy}),children:(l=n.entities.get(r.ownedBy))==null?void 0:l.name}):void 0],["Stored in",r.storedIn?(c=n.entities.get(r.storedIn))==null?void 0:c.name:void 0]]})})]}),!i&&r.fields.length>0&&f.jsx(we,{title:"Fields",count:r.fields.length,children:f.jsx("ul",{className:"space-y-0.5",children:r.fields.map(d=>f.jsx("li",{children:f.jsxs("button",{type:"button",onClick:()=>R.getState().select({kind:"dataType",id:t,field:d.name}),className:"-mx-2 flex w-[calc(100%+16px)] items-center gap-2 rounded-md px-2 py-1 text-left hover:bg-sunken",children:[f.jsx("span",{className:"w-3.5 shrink-0",children:d.primaryKey?f.jsx(gD,{size:12,className:"text-[color:var(--ochre)]"}):d.references?f.jsx(Ec,{size:12,className:"text-[color:var(--lapis)]"}):null}),f.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink",children:d.name}),f.jsxs("code",{className:"shrink-0 font-mono text-[11px] text-ink-3",children:[d.type,d.nullable?"?":""]})]})},d.name))})}),s.lifecycles.length>0&&f.jsx(we,{title:"Lifecycle",children:s.lifecycles.flatMap(d=>n.viewsForBehavior(d.id)).map(d=>f.jsx(Zd,{view:d,select:{kind:"dataType",id:t}},d.id))}),s.flows.length>0&&f.jsx(we,{title:"Moves between",count:s.flows.length,children:s.flows.map(d=>{var u,h;return f.jsx(Ct,{to:{kind:"dataFlow",id:d.id},label:`${(u=n.entities.get(d.source))==null?void 0:u.name} → ${(h=n.entities.get(d.target))==null?void 0:h.name}`,secondary:d.label,icon:f.jsx(ns,{size:14}),tone:"var(--malachite)"},d.id)})}),s.messages.length>0&&f.jsx(we,{title:"Sent in these steps",count:s.messages.length,children:s.messages.map(({interaction:d,item:u})=>f.jsx(Ct,{to:{kind:"message",behavior:d.id,id:u.message.id},label:u.message.label,secondary:`${d.name}, step ${u.number}`,icon:f.jsx(Fd,{size:14}),tone:"var(--lapis)"},`${d.id}-${u.message.id}`))}),f.jsx(Kp,{refValue:{kind:"dataType",id:t}}),f.jsx(O$,{refs:r.sourceRefs})]})}function fB({id:t}){const e=Be(),n=e.dataRelations.get(t);if(!n)return null;const r=e.dataTypes.get(n.from),s=e.dataTypes.get(n.to),i=o=>({one:"exactly one","zero-or-one":"at most one",many:"any number of","one-or-many":"at least one"})[o];return f.jsxs(f.Fragment,{children:[f.jsxs(we,{title:"Reads as",children:[f.jsxs(Ht,{children:["Each ",f.jsx("code",{className:"font-mono",children:r==null?void 0:r.name})," row ",n.label," ",i(n.toCardinality)," ",f.jsx("code",{className:"font-mono",children:s==null?void 0:s.name})," row",n.toCardinality==="exactly-one"||n.toCardinality==="zero-or-one"?"":"s",". Each ",f.jsx("code",{className:"font-mono",children:s==null?void 0:s.name})," row belongs to ",i(n.fromCardinality)," ",f.jsx("code",{className:"font-mono",children:r==null?void 0:r.name})," row",n.fromCardinality==="exactly-one"||n.fromCardinality==="zero-or-one"?"":"s","."]}),f.jsx("div",{className:"mt-3",children:f.jsx(zn,{items:[["Through",n.via?f.jsx("code",{className:"font-mono text-[12px]",children:n.via}):void 0],["Enforced",n.logical?"No. The tables live in different databases; the services keep it consistent.":"Yes, by a foreign key"]]})})]}),f.jsxs(we,{title:"Tables",children:[f.jsx(Ei,{id:n.from}),f.jsx(Ei,{id:n.to})]})]})}function hB({id:t}){var r,s,i;const e=Be(),n=e.dataFlows.get(t);return n?f.jsxs(f.Fragment,{children:[f.jsx(we,{title:"About",children:f.jsx(Ht,{children:n.description??`${(r=e.entities.get(n.source))==null?void 0:r.name} sends ${n.label.charAt(0).toLowerCase()+n.label.slice(1)} to ${(s=e.entities.get(n.target))==null?void 0:s.name}.`})}),f.jsx(we,{title:"Data",count:n.data.length,children:n.data.map(o=>{const a=e.dataTypes.get(o);return f.jsxs("div",{className:"mb-2",children:[f.jsx(Ei,{id:o}),a&&a.fields.length>0&&f.jsx("p",{className:"ml-6 font-mono text-[11px] leading-relaxed text-ink-3",children:a.fields.map(l=>l.name).join(", ")})]},o)})}),f.jsxs(we,{title:"Between",children:[f.jsx(It,{id:n.source,secondary:"From"}),f.jsx(It,{id:n.target,secondary:"To"}),n.via&&f.jsx(Ct,{to:{kind:"relationship",id:n.via},label:(i=e.relationships.get(n.via))==null?void 0:i.label,secondary:"Carried by this connection",icon:f.jsx(Ec,{size:14}),tone:"var(--ink-3)"})]}),f.jsx(Kp,{refValue:{kind:"dataFlow",id:t}})]}):null}function pB({behavior:t,id:e}){var c,d;const n=Be(),r=n.messages(t).find(u=>u.message.id===e);if(!r)return null;const s=r.message,i=n.messages(t),o=i[r.number-2],a=i[r.number],l={call:"Request, waits for an answer",return:"Answer to an earlier request",async:"Sent without waiting",self:"Work done inside one participant"}[s.kind];return f.jsxs(f.Fragment,{children:[f.jsxs(we,{title:"About",children:[s.description&&f.jsx(Ht,{children:s.description}),f.jsx("div",{className:s.description?"mt-3":"",children:f.jsx(zn,{items:[["Step",`${r.number} of ${i.length}`],["Kind",l],["When",r.context.length?r.context.map(u=>`${Dd(u.fragment.kind).toLowerCase()}: ${u.guard}`).join(", then "):void 0]]})})]}),f.jsxs(we,{title:"Between",children:[f.jsx(It,{id:s.from,secondary:"From"}),s.to!==s.from&&f.jsx(It,{id:s.to,secondary:"To"})]}),s.data.length>0&&f.jsx(we,{title:"Carries",children:s.data.map(u=>f.jsx(Ei,{id:u},u))}),s.relationship&&f.jsx(we,{title:"Connection",children:f.jsx(Ct,{to:{kind:"relationship",id:s.relationship},label:(c=n.relationships.get(s.relationship))==null?void 0:c.label,secondary:(d=n.relationships.get(s.relationship))==null?void 0:d.protocol,icon:f.jsx(Ec,{size:14}),tone:"var(--ink-3)"})}),f.jsx(we,{title:"Step through",children:f.jsxs("div",{className:"flex gap-2",children:[f.jsxs("button",{type:"button",disabled:!o,onClick:()=>o&&R.getState().select({kind:"message",behavior:t,id:o.message.id},{focus:"center"}),className:"flex-1 rounded-md border border-rule px-2 py-1.5 text-[12px] hover:bg-sunken disabled:opacity-35",children:["← Step ",r.number-1||""]}),f.jsxs("button",{type:"button",disabled:!a,onClick:()=>a&&R.getState().select({kind:"message",behavior:t,id:a.message.id},{focus:"center"}),className:"flex-1 rounded-md border border-rule px-2 py-1.5 text-[12px] hover:bg-sunken disabled:opacity-35",children:["Step ",a?r.number+1:""," →"]})]})})]})}function mB({behavior:t,id:e}){const r=Be().findFragment(t,e);if(!r)return null;const s={alt:"Exactly one of these paths happens, depending on the condition.",opt:"This happens only when the condition is true.",loop:"These steps repeat.",par:"These paths happen at the same time."}[r.kind];return f.jsxs(we,{title:Dd(r.kind),children:[f.jsx(Ht,{children:s}),f.jsx("ol",{className:"mt-2 space-y-1.5",children:r.branches.map((i,o)=>f.jsxs("li",{className:"rounded-md bg-sunken px-2.5 py-1.5 text-[12.5px]",children:[f.jsx("span",{className:"text-ink-3",children:r.kind==="loop"?"Repeat":r.kind==="par"?"Path":"If"})," ",i.guard,f.jsxs("span",{className:"text-ink-3",children:[" — ",i.steps.length," step",i.steps.length===1?"":"s"]})]},o))})]})}function gB({behavior:t,id:e}){const n=Be(),r=n.activity(t),s=r==null?void 0:r.nodes.find(l=>l.id===e);if(!r||!s)return null;const i=r.flows.filter(l=>l.from===e),o=r.flows.filter(l=>l.to===e),a=l=>{var c;return(c=r.nodes.find(d=>d.id===l))==null?void 0:c.label};return f.jsxs(f.Fragment,{children:[f.jsxs(we,{title:"About",children:[s.description&&f.jsx(Ht,{children:s.description}),f.jsx("div",{className:s.description?"mt-3":"",children:f.jsx(zn,{items:[["Step",n.describe({kind:"activityNode",behavior:t,id:e}).kind],["Outcome",s.outcome==="failure"?"Ends in failure":s.outcome==="success"?"Ends in success":void 0]]})})]}),s.performedBy&&f.jsx(we,{title:"Done by",children:f.jsx(It,{id:s.performedBy})}),o.length>0&&f.jsx(we,{title:"Comes after",children:o.map(l=>f.jsx(Ct,{to:{kind:"activityNode",behavior:t,id:l.from},label:a(l.from),secondary:l.guard?`When “${l.guard}”`:void 0,icon:f.jsx(ns,{size:14,className:"rotate-180"}),tone:"var(--ink-3)"},l.id))}),i.length>0&&f.jsx(we,{title:s.kind==="decision"?"Branches":"Leads to",children:i.map(l=>f.jsx(Ct,{to:{kind:"activityNode",behavior:t,id:l.to},label:a(l.to),secondary:l.guard?`When “${l.guard}”`:void 0,icon:f.jsx(ns,{size:14}),tone:"var(--ink-3)"},l.id))})]})}function yB({behavior:t,id:e}){var i,o;const r=Be().activity(t),s=r==null?void 0:r.flows.find(a=>a.id===e);return!r||!s?null:f.jsxs(we,{title:"Flow",children:[s.guard&&f.jsxs(Ht,{children:["Taken when the answer is “",s.guard,"”."]}),f.jsxs("div",{className:"mt-2",children:[f.jsx(Ct,{to:{kind:"activityNode",behavior:t,id:s.from},label:(i=r.nodes.find(a=>a.id===s.from))==null?void 0:i.label,secondary:"From"}),f.jsx(Ct,{to:{kind:"activityNode",behavior:t,id:s.to},label:(o=r.nodes.find(a=>a.id===s.to))==null?void 0:o.label,secondary:"To"})]})]})}function xB({behavior:t,id:e}){var l;const n=Be(),r=n.stateMachine(t),s=r==null?void 0:r.states.find(c=>c.id===e);if(!r||!s)return null;const i=c=>{var d;return(d=r.states.find(u=>u.id===c))==null?void 0:d.name},o=r.transitions.filter(c=>c.from===e),a=r.transitions.filter(c=>c.to===e);return f.jsxs(f.Fragment,{children:[f.jsxs(we,{title:"About",children:[s.description&&f.jsx(Ht,{children:s.description}),f.jsx("div",{className:s.description?"mt-3":"",children:f.jsx(zn,{items:[["Kind",s.kind==="initial"?"Where every lifecycle starts":s.kind==="final"?"Final. Nothing happens after this.":"State"],["Stored as",r.subject?f.jsxs("code",{className:"font-mono text-[12px]",children:[(l=n.dataTypes.get(r.subject))==null?void 0:l.name,".status"]}):void 0]]})})]}),s.entryActions.length>0&&f.jsx(we,{title:"On entry",children:f.jsx("ul",{className:"list-disc space-y-0.5 pl-4 text-[12.5px] text-ink-2",children:s.entryActions.map(c=>f.jsx("li",{children:c},c))})}),o.length>0&&f.jsx(we,{title:"Can move to",count:o.length,children:o.map(c=>f.jsx(Ct,{to:{kind:"transition",behavior:t,id:c.id},label:i(c.to),secondary:`${c.event}${c.guard?`, only when ${c.guard}`:""}`,icon:f.jsx(ns,{size:14}),tone:"var(--ink-3)"},c.id))}),a.length>0&&f.jsx(we,{title:"Reached from",count:a.length,children:a.map(c=>f.jsx(Ct,{to:{kind:"transition",behavior:t,id:c.id},label:i(c.from),secondary:c.event,icon:f.jsx(ns,{size:14,className:"rotate-180"}),tone:"var(--ink-3)"},c.id))})]})}function vB({behavior:t,id:e}){var o;const n=Be(),r=n.stateMachine(t),s=r==null?void 0:r.transitions.find(a=>a.id===e);if(!r||!s)return null;const i=a=>{var l;return(l=r.states.find(c=>c.id===a))==null?void 0:l.name};return f.jsxs(f.Fragment,{children:[f.jsxs(we,{title:"What causes it",children:[f.jsxs(Ht,{children:["When ",f.jsx("strong",{className:"text-ink",children:s.event.charAt(0).toLowerCase()+s.event.slice(1)}),s.guard?f.jsxs(f.Fragment,{children:[", and only if ",s.guard,","]}):""," the ",r.subject?(o=n.dataTypes.get(r.subject))==null?void 0:o.name.replace(/s$/,""):"item"," moves from ",f.jsx("strong",{className:"text-ink",children:i(s.from)})," to ",f.jsx("strong",{className:"text-ink",children:i(s.to)}),"."]}),s.description&&f.jsx("p",{className:"mt-2 text-[12.5px] text-ink-2",children:s.description})]}),s.actions.length>0&&f.jsx(we,{title:"What happens then",children:f.jsx("ol",{className:"list-decimal space-y-0.5 pl-4 text-[12.5px] text-ink-2",children:s.actions.map(a=>f.jsx("li",{children:a},a))})}),s.triggeredBy&&f.jsx(we,{title:"Raised by",children:f.jsx(It,{id:s.triggeredBy})}),f.jsxs(we,{title:"States",children:[f.jsx(Ct,{to:{kind:"state",behavior:t,id:s.from},label:i(s.from),secondary:"From"}),f.jsx(Ct,{to:{kind:"state",behavior:t,id:s.to},label:i(s.to),secondary:"To"})]})]})}function kB({id:t}){const e=Be(),n=e.useCases.get(t);if(!n)return null;const r=n.behaviors.flatMap(s=>e.viewsForBehavior(s));return f.jsxs(f.Fragment,{children:[f.jsxs(we,{title:"About",children:[f.jsx(Ht,{children:n.summary}),f.jsx("div",{className:"mt-3",children:f.jsx(zn,{items:[["Area",n.area]]})})]}),f.jsxs(we,{title:"Who",children:[n.actors.map(s=>f.jsx(It,{id:s,secondary:"Does it"},s)),n.supporting.map(s=>f.jsx(It,{id:s,secondary:"Helps"},s))]}),n.realizedBy.length>0&&f.jsx(we,{title:"Built by",count:n.realizedBy.length,children:n.realizedBy.map(s=>f.jsx(It,{id:s},s))}),r.length>0&&f.jsx(we,{title:"See how it works",children:r.map(s=>f.jsx(Zd,{view:s},s.id))}),n.includes.length>0&&f.jsx(we,{title:"Includes",children:n.includes.map(s=>{var i,o;return f.jsx(Ct,{to:{kind:"useCase",id:s},label:(i=e.useCases.get(s))==null?void 0:i.name,secondary:(o=e.useCases.get(s))==null?void 0:o.summary,icon:f.jsx(Fd,{size:14}),tone:"var(--tyrian)"},s)})})]})}function wB({view:t,id:e}){const r=Be().views.get(t),i=((r==null?void 0:r.type)==="architecture"?r.groups:(r==null?void 0:r.type)==="dependency"?r.layers:[]).find(o=>o.id===e);return i?f.jsxs(f.Fragment,{children:[i.description&&f.jsx(we,{title:"About",children:f.jsx(Ht,{children:i.description})}),f.jsx(we,{title:"Members",count:i.members.length,children:i.members.map(o=>f.jsx(It,{id:o},o))})]}):null}function bB({id:t}){const e=Be(),n=e.behaviors.get(t);return n?f.jsxs(f.Fragment,{children:[f.jsx(we,{title:"About",children:f.jsx(Ht,{children:n.description??n.summary})}),f.jsx(we,{title:"Diagrams",children:e.viewsForBehavior(t).map(r=>f.jsx(Zd,{view:r},r.id))})]}):null}function SB(t){switch(t.kind){case"entity":return f.jsx(lB,{id:t.id});case"relationship":return f.jsx(cB,{id:t.id});case"dataType":return f.jsx(uB,{id:t.id,field:t.field});case"dataRelation":return f.jsx(fB,{id:t.id});case"dataFlow":return f.jsx(hB,{id:t.id});case"message":return f.jsx(pB,{behavior:t.behavior,id:t.id});case"fragment":return f.jsx(mB,{behavior:t.behavior,id:t.id});case"activityNode":return f.jsx(gB,{behavior:t.behavior,id:t.id});case"activityFlow":return f.jsx(yB,{behavior:t.behavior,id:t.id});case"state":return f.jsx(xB,{behavior:t.behavior,id:t.id});case"transition":return f.jsx(vB,{behavior:t.behavior,id:t.id});case"useCase":return f.jsx(kB,{id:t.id});case"group":return f.jsx(wB,{view:t.view,id:t.id});case"behavior":return f.jsx(bB,{id:t.id})}}function CB(){const t=R(o=>o.inspectorOpen),e=R(o=>o.selection),n=R(o=>o.viewId),r=R(o=>o.toggleInspector),s=Be(),i=n===bt?void 0:s.views.get(n);return t?f.jsx("aside",{"aria-label":"Inspector",className:"scrollbar-quiet z-20 flex w-[340px] shrink-0 flex-col overflow-y-auto border-l border-rule bg-paper max-xl:fixed max-xl:bottom-0 max-xl:right-0 max-xl:top-12 max-xl:shadow-float max-sm:w-full",children:e?f.jsx(NB,{selection:e,onClose:()=>r(!1)},fe(e)):i?f.jsx(EB,{view:i,onClose:()=>r(!1)}):f.jsx(_B,{onClose:()=>r(!1)})}):null}function t0({kind:t,title:e,icon:n,tone:r,onClose:s,actions:i}){return f.jsxs("div",{className:"sticky top-0 z-10 border-b border-rule bg-paper/95 px-4 pb-3 pt-3.5 backdrop-blur",children:[f.jsxs("div",{className:"flex items-center gap-2 text-[11.5px] text-ink-3",children:[f.jsx("span",{className:"flex-1 truncate",children:t}),i,f.jsx("button",{type:"button","aria-label":"Hide inspector",onClick:s,className:"rounded p-1 hover:bg-sunken hover:text-ink",children:f.jsx(Jo,{size:14})})]}),f.jsxs("h2",{className:"mt-1 flex items-start gap-2 text-[17px] font-semibold leading-snug tracking-[-0.01em]",children:[n&&f.jsx("span",{className:"mt-[3px] shrink-0",style:{color:r},children:n}),f.jsx("span",{className:"min-w-0 break-words",children:e})]})]})}function NB({selection:t,onClose:e}){const n=Be(),r=n.describe(t),s=t.kind==="entity"?n.entities.get(t.id):void 0,i=s?n.style(s):void 0,o=i?Pp(i.icon):void 0;return f.jsxs("div",{className:"fade-in",children:[f.jsx(t0,{kind:r.kind,title:r.title,icon:o?f.jsx(o,{size:17}):void 0,tone:i?pt(i.tone):void 0,onClose:e,actions:f.jsx("button",{type:"button","aria-label":"Zoom to this element",title:"Zoom to this element (F)",onClick:()=>R.getState().requestFocus("zoom",t),className:"rounded p-1 hover:bg-sunken hover:text-ink",children:f.jsx($j,{size:14})})}),SB(t)]})}function EB({view:t,onClose:e}){const n=rs(t),r=Be(),s=n==null?void 0:n.Legend;return f.jsxs("div",{className:"fade-in",children:[f.jsx(t0,{kind:`${Jd(t.category)} · ${(n==null?void 0:n.label)??"Extension view"}`,title:t.title,onClose:e}),f.jsx(we,{title:"What this shows",children:f.jsx(Ht,{children:t.description})}),n&&f.jsx(we,{title:"How to read it",children:f.jsx(Ht,{children:n.howToRead})}),s&&f.jsx(we,{title:"Key",children:f.jsx(s,{view:t})}),t.type==="extension"&&f.jsx(we,{title:"Extension",children:f.jsxs("p",{className:"flex items-center gap-2 text-[12.5px] text-ink-2",children:[f.jsx(Nj,{size:14,className:"text-ink-3"}),"Drawn by the ",f.jsx("code",{className:"font-mono text-[12px]",children:t.extension.split("/")[0]})," extension."]})}),f.jsx(we,{title:"Try this",children:f.jsxs("ul",{className:"list-disc space-y-1 pl-4 text-[12.5px] text-ink-2",children:[f.jsx("li",{children:"Select anything to see what it connects to and where else it appears."}),f.jsx("li",{children:"Double-click a name to change it; it changes in every diagram. Press F to zoom in, Esc to clear."}),f.jsx("li",{children:r.doc.views.length>1?"Use the links in this panel to follow an element into other diagrams.":"Paste another model to open it."})]})})]})}function _B({onClose:t}){const n=Be().doc;return f.jsxs("div",{className:"fade-in",children:[f.jsx(t0,{kind:"Project",title:n.project.name,onClose:t}),f.jsx(we,{title:"About",children:f.jsx(Ht,{children:n.project.description})}),f.jsx(we,{title:"Document",children:f.jsxs("dl",{className:"grid grid-cols-[110px_1fr] gap-y-1 text-[12.5px]",children:[f.jsx("dt",{className:"text-ink-3",children:"Format"}),f.jsxs("dd",{children:["Poney ",n.poneyVersion]}),f.jsx("dt",{className:"text-ink-3",children:"Extensions"}),f.jsx("dd",{children:n.extensions.length?n.extensions.map(r=>`${r.name} ${r.version}`).join(", "):"None"}),n.project.repository&&f.jsxs(f.Fragment,{children:[f.jsx("dt",{className:"text-ink-3",children:"Repository"}),f.jsx("dd",{className:"break-all font-mono text-[11.5px]",children:n.project.repository})]})]})})]})}function cT(t){var s;const e=(s=R.getState().history)==null?void 0:s.present;if(!e)return;const n=gt(e);if(!n.exists(t))return;const r=n.describe(t);return{ref:fe(t),title:Ar(r.title),kind:r.kind.toLowerCase()}}function jB(t){var n;const e=(n=R.getState().history)==null?void 0:n.present.views.find(r=>r.id===t);return e?{ref:`view:${e.id}`,title:e.title,kind:"diagram"}:void 0}const dT=t=>({title:t.length>60?`${t.slice(0,57)}…`:t,kind:"text",quote:t.slice(0,2e3)}),uT=(t,e,n)=>({title:`${t.split("/").slice(-2).join("/")}:${e}`,kind:"code",quote:`${t}:${e}
705
+ ${n}`});function qb(t,e,n,r){return s=>{var i;(i=window.getSelection())!=null&&i.toString().trim()||(s.preventDefault(),R.getState().openContextMenu({on:"code",path:t,line:e,text:n,note:r,x:s.clientX,y:s.clientY}))}}function uo(t){if(!t)return;const e=R.getState();e.addChip(t),e.setAgentPanelOpen(!0),requestAnimationFrame(()=>{var n;return(n=document.querySelector('[aria-label="Your question"]'))==null?void 0:n.focus()})}function fT(t){return e=>{e.target.closest("[data-ref]")||(e.preventDefault(),R.getState().openContextMenu({on:"diagram",viewId:t,x:e.clientX,y:e.clientY}))}}function $B(){window.addEventListener("contextmenu",t=>{var r;if(t.defaultPrevented)return;const e=t.target;if(e.closest('input, textarea, [contenteditable="true"]')||!e.closest("main"))return;const n=(r=window.getSelection())==null?void 0:r.toString().trim();n&&(t.preventDefault(),R.getState().openContextMenu({on:"text",text:n,x:t.clientX,y:t.clientY}))})}function hT(){const t=R(e=>e.overlays);return b.useMemo(()=>{const e=Object.values(t).flatMap(n=>n.marks);return{effects:e.flatMap(n=>n.effect?[{target:n.target,as:n.effect}]:[]),badges:e.flatMap(n=>n.badge?[{target:n.target,text:n.badge.text,tone:n.badge.tone}]:[])}},[t])}function Kb(t){const e=new Map;for(const n of t)e.set(n.target,[...e.get(n.target)??[],n]);return e}function MB({view:t}){const e=Be(),n=R(i=>{var o;return(o=i.viewUi[t.id])==null?void 0:o.collapsed})??t.collapsed,r=R(i=>i.updateViewUi),s=t.entities.filter(i=>e.children(i).some(o=>t.entities.includes(o.id)));return f.jsxs(f.Fragment,{children:[f.jsx(ot,{label:"Open everything",onClick:()=>r(t.id,{collapsed:[]}),disabled:n.length===0,children:f.jsx(v_,{size:15})}),f.jsx(ot,{label:"Show as one system",onClick:()=>r(t.id,{collapsed:[...s]}),disabled:s.every(i=>n.includes(i)),children:f.jsx(y_,{size:15})})]})}function TB({view:t}){const e=R(s=>s.viewUi[t.id]),n=R(s=>s.updateViewUi),r=(e==null?void 0:e.controlFlow)??t.showControlFlow;return f.jsx(ot,{label:r?"Hide calls that carry no data":"Show calls that carry no data",onClick:()=>n(t.id,{controlFlow:!r}),active:r,children:f.jsx(rD,{size:15})})}function OB({view:t}){const e=R(r=>{var s;return((s=r.viewUi[t.id])==null?void 0:s.transitive)??!1}),n=R(r=>r.updateViewUi);return f.jsx(ot,{label:e?"Show direct dependencies only":"Follow dependencies all the way",onClick:()=>n(t.id,{transitive:!e}),active:e,children:f.jsx(MD,{size:15})})}function AB({view:t}){var s;const e=R(i=>i.viewUi[t.id]),n=R(i=>i.updateViewUi),r=((s=e==null?void 0:e.expandedTables)==null?void 0:s.length)===t.dataTypes.length;return f.jsx(ot,{label:r?"Show key fields only":"Show every field",onClick:()=>n(t.id,{expandedTables:r?[]:[...t.dataTypes]}),active:r,children:r?f.jsx(y_,{size:15}):f.jsx(v_,{size:15})})}function RB({view:t}){const e=Be(),n=R(a=>a.selection),r=R(a=>a.select),s=e.messages(t.interaction),i=(n==null?void 0:n.kind)==="message"&&n.behavior===t.interaction?s.findIndex(a=>a.message.id===n.id):-1,o=a=>s[a]&&r({kind:"message",behavior:t.interaction,id:s[a].message.id},{focus:"center"});return f.jsxs(f.Fragment,{children:[f.jsx(ot,{label:"Previous step",onClick:()=>o(i<=0?0:i-1),disabled:i===0,children:f.jsx(p_,{size:15})}),f.jsx("span",{className:"font-tabular min-w-[54px] text-center text-[12px] text-ink-2","aria-live":"polite",children:i>=0?`${i+1} / ${s.length}`:`${s.length} steps`}),f.jsx(ot,{label:i<0?"Start stepping through":"Next step",onClick:()=>o(i+1),disabled:i===s.length-1,children:f.jsx(zd,{size:15})})]})}const IB={architecture:MB,dataflow:TB,dependency:OB,erd:AB,sequence:RB},Jb=new WeakMap,PB=document.fonts?Promise.all([document.fonts.load('400 13px "Hanken Grotesk Variable"'),document.fonts.load('600 13px "Hanken Grotesk Variable"'),document.fonts.load('400 12px "JetBrains Mono Variable"')]).catch(()=>{}):Promise.resolve();function DB(t,e,n){let r=Jb.get(t);r||Jb.set(t,r=new Map);const s=`${e.id}|${JSON.stringify(n)}`;let i=r.get(s);return i||(i=PB.then(()=>XE(t,e,n)),r.set(s,i)),i}function zB(t){const e=O1(),n=R(i=>i.viewUi[t.id]),[r,s]=b.useState({viewId:t.id});return b.useEffect(()=>{let i=!0;const o={collapsed:n==null?void 0:n.collapsed,expanded:n==null?void 0:n.expandedTables,controlFlow:n==null?void 0:n.controlFlow};return DB(e,t,o).then(a=>i&&s({viewId:t.id,scene:a}),a=>i&&s({viewId:t.id,error:a instanceof Error?a.message:String(a)})),()=>{i=!1}},[e,t,n==null?void 0:n.collapsed,n==null?void 0:n.expandedTables,n==null?void 0:n.controlFlow]),r.viewId===t.id?r:{}}function LB(){const t=R(s=>s.select),e=R(s=>s.setHover),n=R(s=>s.selection),r=n?fe(n):null;return b.useCallback((s,i)=>{const o=fe(s);return{"data-ref":o,className:"poney-el",tabIndex:0,role:"button","aria-label":i,"aria-pressed":r===o,onClick:a=>{if(a.stopPropagation(),R.getState().pointing){const l=cT(s);R.getState().setPointing(!1),l&&uo(l);return}a.currentTarget.focus({preventScroll:!0}),t(s)},onDoubleClick:a=>{a.stopPropagation(),t(s),X1(s,a.currentTarget)||t(s,{focus:"zoom"})},onContextMenu:a=>{a.preventDefault(),a.stopPropagation(),t(s),R.getState().openContextMenu({on:"element",ref:s,x:a.clientX,y:a.clientY})},onMouseEnter:()=>e(s),onMouseLeave:()=>e(null),onFocus:()=>e(s),onBlur:()=>e(null),onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),t(s,{focus:"center"}))}}},[t,e,r])}function pT(t,e,n){var c;const r=new Set,s=[...t.querySelectorAll("[data-ref][tabindex]")].filter(d=>{const u=d.getAttribute("data-ref"),h=d.getBoundingClientRect();return r.has(u)||h.width===0||getComputedStyle(d).visibility==="hidden"?!1:(r.add(u),!0)}).map(d=>({el:d,r:d.getBoundingClientRect()})).sort((d,u)=>Math.round((d.r.top+d.r.height/2)/28)-Math.round((u.r.top+u.r.height/2)/28)||d.r.left-u.r.left);if(!s.length)return;const i=(c=e==null?void 0:e.closest("[data-ref]"))==null?void 0:c.getAttribute("data-ref"),o=i?s.findIndex(d=>d.el.getAttribute("data-ref")===i):-1,a=o<0?n?s.length-1:0:o+(n?-1:1);if(a<0||a>=s.length)return;const l=s[a].el;return l.focus({preventScroll:!0}),l}function FB({pointer:t}){const e=R(l=>l.hover),n=R(l=>l.selection),r=Be(),[s,i]=b.useState(null),o=b.useRef(null);if(b.useEffect(()=>{if(i(null),!e)return;const l=setTimeout(()=>i(e),420);return()=>clearTimeout(l)},[e]),b.useEffect(()=>{if(!s)return;let l=0;const c=()=>{const d=o.current;if(d){const u=d.parentElement.getBoundingClientRect(),h=Math.min(t.current.x+14,u.width-d.offsetWidth-8),m=t.current.y+18+d.offsetHeight>u.height?t.current.y-d.offsetHeight-10:t.current.y+18;d.style.transform=`translate(${h}px, ${m}px)`}l=requestAnimationFrame(c)};return l=requestAnimationFrame(c),()=>cancelAnimationFrame(l)},[s,t]),!s||n&&fe(n)===fe(s))return null;const a=r.describe(s);return f.jsxs("div",{ref:o,role:"tooltip",className:"fade-in pointer-events-none absolute left-0 top-0 z-20 max-w-[280px] rounded-lg border border-rule bg-raised px-3 py-2 shadow-float",children:[f.jsx("div",{className:"text-[11px] text-ink-3",children:a.kind}),f.jsx("div",{className:"text-[13px] font-semibold leading-snug text-ink",children:a.title}),a.summary&&f.jsx("div",{className:"mt-0.5 text-[12px] leading-snug text-ink-2",children:a.summary})]})}function mT({size:t=14,className:e=""}){const n=R(i=>i.live.state==="on"),r=R(Wd),s=R(i=>i.pointing);return n?f.jsx("button",{type:"button","aria-label":r?"Point at something for the agent":"Point at something for the agent (connect an agent first)","aria-pressed":r?s:void 0,title:r?"Point at a part, a line, a message or a state, to put it in your question":"No agent is connected. Click to connect one, then point at something to ask about it.",onClick:()=>r?R.getState().setPointing(!s):R.getState().setConnectOpen(!0),className:`grid place-items-center rounded-md ${r?s?"bg-poney-wash text-poney":"text-ink-2 hover:bg-sunken":"text-ink-4 hover:bg-sunken hover:text-ink-3"} ${e}`,children:f.jsx(O_,{size:t})}):null}const Gb=.15,Yb=3,to=56,sg=new Map,Qb=(t,e,n)=>Math.min(n,Math.max(e,t)),BB=()=>typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;function VB({viewId:t,scene:e,label:n,children:r,tools:s,overlay:i,initial:o="fit"}){var T;const a=b.useRef(null),[l,c]=b.useState({w:0,h:0}),[d,u]=b.useState(()=>sg.get(t)??{x:0,y:0,k:1}),h=b.useRef(d),m=b.useRef(0),g=b.useRef(null),p=b.useRef({x:0,y:0}),x=R(M=>M.select),y=R(M=>M.selection),v=R(M=>M.focus),k=b.useRef(0),w=b.useRef(null),C=b.useCallback(M=>{h.current=M,sg.set(t,M),u(M)},[t]),E=b.useCallback(M=>{if(cancelAnimationFrame(m.current),BB())return C(M);const A=h.current,V=performance.now(),J=380,X=z=>{const F=Math.min(1,(z-V)/J),U=1-Math.pow(1-F,3);C({x:A.x+(M.x-A.x)*U,y:A.y+(M.y-A.y)*U,k:A.k+(M.k-A.k)*U}),F<1&&(m.current=requestAnimationFrame(X))};m.current=requestAnimationFrame(X)},[C]),_=b.useCallback((M,A=1.1)=>{const{w:V,h:J}=l,X=Qb(Math.min((V-to*2)/Math.max(M.w,1),(J-to*2)/Math.max(M.h,1),A),Gb,Yb);return{k:X,x:V/2-(M.x+M.w/2)*X,y:J/2-(M.y+M.h/2)*X}},[l]),S=b.useCallback(()=>_({x:0,y:0,w:e.width,h:e.height},1),[_,e.width,e.height]),j=b.useCallback((M,A=l.w/2,V=l.h/2,J=!1)=>{const X=h.current,z=Qb(X.k*M,Gb,Yb),F={k:z,x:A-(A-X.x)/X.k*z,y:V-(V-X.y)/X.k*z};J?E(F):C(F)},[l,C,E]),$=b.useCallback(M=>{const A=e.anchors[fe(M)];if(A)return A;if(M.kind==="dataType"&&M.field)return e.anchors[fe({kind:"dataType",id:M.id})]},[e.anchors]);b.useLayoutEffect(()=>{const M=a.current;if(!M)return;const A=new ResizeObserver(([V])=>c({w:V.contentRect.width,h:V.contentRect.height}));return A.observe(M),()=>A.disconnect()},[]),b.useLayoutEffect(()=>{if(!l.w||!l.h||w.current===t)return;w.current=t;const M=sg.get(t),A=S();C(M??(o==="start"&&A.k<.7?{k:.85,x:to/2,y:to/2}:A))},[l,t,S,C,o]),b.useEffect(()=>{if(!v||!l.w||v.nonce===k.current)return;if(k.current=v.nonce,v.mode==="fit")return E(S());if(v.mode==="reset"){const U=S();return E({k:1,x:l.w/2-e.width/2,y:U.k<1?to:U.y})}if(!v.ref)return;const M=$(v.ref);if(!M)return;const A=h.current,V=U=>({...U,x:Math.min(U.x,to),y:Math.min(U.y,to)});if(v.mode==="zoom")return E(V(_({x:M.x-80,y:M.y-80,w:M.w+160,h:M.h+160},1.6)));const J=M.x*A.k+A.x,X=M.y*A.k+A.y;if(J>40&&X>40&&J+M.w*A.k<l.w-40&&X+M.h*A.k<l.h-40&&A.k>=.6)return;const F=Math.max(A.k,.8);E(V({k:F,x:l.w/2-(M.x+M.w/2)*F,y:l.h/2-(M.y+M.h/2)*F}))},[v,l,$,E,S,_,e.width]),b.useEffect(()=>{const M=a.current;if(!M)return;const A=V=>{V.preventDefault(),cancelAnimationFrame(m.current);const J=M.getBoundingClientRect();if(V.ctrlKey||V.metaKey)j(Math.exp(-V.deltaY*.0045),V.clientX-J.left,V.clientY-J.top);else{const X=h.current;C({...X,x:X.x-V.deltaX,y:X.y-V.deltaY})}};return M.addEventListener("wheel",A,{passive:!1}),()=>M.removeEventListener("wheel",A)},[j,C]);const I=M=>{if(M.key==="Tab"&&!M.altKey&&!M.metaKey&&!M.ctrlKey){const X=(M.target===M.currentTarget?null:M.target)??(y?M.currentTarget.querySelector(`[data-ref="${CSS.escape(fe(y))}"]`):null),z=pT(M.currentTarget,X,M.shiftKey);if(z){M.preventDefault();const F=un(z.getAttribute("data-ref"));F&&R.getState().requestFocus("center",F)}return}if(M.target!==M.currentTarget&&!(M.target instanceof SVGElement))return;const A=M.shiftKey?160:60,V=h.current;switch(M.key){case"+":case"=":j(1.25,void 0,void 0,!0);break;case"-":case"_":j(.8,void 0,void 0,!0);break;case"ArrowLeft":if(M.target!==M.currentTarget)return;C({...V,x:V.x+A});break;case"ArrowRight":if(M.target!==M.currentTarget)return;C({...V,x:V.x-A});break;case"ArrowUp":if(M.target!==M.currentTarget)return;C({...V,y:V.y+A});break;case"ArrowDown":if(M.target!==M.currentTarget)return;C({...V,y:V.y-A});break;default:return}M.preventDefault()},L=M=>{M.button!==0&&M.button!==1||M.target.closest("[data-ref]")&&M.button===0||(cancelAnimationFrame(m.current),g.current={x:M.clientX,y:M.clientY,moved:!1,id:M.pointerId})},D=M=>{const A=a.current.getBoundingClientRect();p.current={x:M.clientX-A.left,y:M.clientY-A.top};const V=g.current;if(!V)return;const J=M.clientX-V.x,X=M.clientY-V.y;if(!V.moved&&Math.hypot(J,X)<3)return;V.moved||a.current.setPointerCapture(V.id),V.moved=!0,V.x=M.clientX,V.y=M.clientY;const z=h.current;C({...z,x:z.x+J,y:z.y+X})},B=()=>{const M=g.current;g.current=null,M&&!M.moved&&x(null)},H=22*d.k;return f.jsx(LL,{value:d.k,children:f.jsxs("div",{ref:a,className:"relative h-full w-full touch-none select-none overflow-hidden outline-none",style:{backgroundColor:"var(--plaster)",backgroundImage:H>7?"radial-gradient(var(--plaster-dot) 1px, transparent 1.2px)":void 0,backgroundSize:`${H}px ${H}px`,backgroundPosition:`${d.x}px ${d.y}px`,cursor:(T=g.current)!=null&&T.moved?"grabbing":"default"},tabIndex:0,role:"application","aria-roledescription":"diagram canvas","aria-label":`${n}. Use Tab to move between elements, Enter to select, plus and minus to zoom, arrow keys to pan.`,onKeyDown:I,onPointerDown:L,onPointerMove:D,onPointerUp:B,onPointerCancel:()=>g.current=null,onDoubleClick:M=>{M.target.closest("[data-ref]")||E(S())},children:[f.jsx("svg",{className:"absolute inset-0 h-full w-full",role:"group","aria-label":n,children:f.jsx("g",{transform:`translate(${d.x} ${d.y}) scale(${d.k})`,children:r})}),i&&f.jsx("div",{className:"pointer-events-none absolute left-4 top-4",children:i}),f.jsx(FB,{pointer:p}),f.jsxs("div",{className:"absolute bottom-4 left-1/2 flex -translate-x-1/2 items-center gap-0.5 rounded-xl border border-rule bg-raised/95 p-1 shadow-float backdrop-blur",children:[f.jsx(ot,{label:"Zoom out",shortcut:"−",onClick:()=>j(.8,void 0,void 0,!0),children:f.jsx(hj,{size:15})}),f.jsxs("button",{type:"button",className:"font-tabular h-8 w-12 rounded-md text-[12px] text-ink-2 hover:bg-sunken",onClick:()=>R.getState().requestFocus("reset"),title:"Reset to 100%","aria-label":`Zoom ${Math.round(d.k*100)} percent. Reset to 100 percent`,children:[Math.round(d.k*100),"%"]}),f.jsx(ot,{label:"Zoom in",shortcut:"+",onClick:()=>j(1.25,void 0,void 0,!0),children:f.jsx(S1,{size:15})}),f.jsx(Ub,{}),f.jsx(ot,{label:"Fit to view",shortcut:"⇧1",onClick:()=>E(S()),children:f.jsx(oj,{size:15})}),f.jsx(ot,{label:"Zoom to selection",shortcut:"F",onClick:()=>{const M=R.getState().selection;M&&R.getState().requestFocus("zoom",M)},children:f.jsx($j,{size:15})}),f.jsx(mT,{size:15,className:"h-8 w-8"}),s&&f.jsxs(f.Fragment,{children:[f.jsx(Ub,{}),s]})]})]})})}function WB({view:t}){return rs(t)?f.jsx(UB,{view:t}):f.jsx(ZB,{view:t})}function UB({view:t}){const e=rs(t),{scene:n,error:r}=zB(t),s=hT(),i=b.useMemo(()=>({marks:new Map,mode:"after",focus:null,callouts:new Map,hot:null,setHot:()=>{},effects:Kb(s.effects),badges:Kb(s.badges)}),[s]);if(r)return f.jsx("div",{className:"grid h-full place-items-center p-8",children:f.jsxs("div",{className:"max-w-md rounded-xl border border-rule bg-raised p-5",children:[f.jsx("h2",{className:"text-[15px] font-semibold",children:"This diagram could not be laid out"}),f.jsx("p",{className:"mt-1 text-ink-2",children:r})]})});if(!n)return f.jsxs("div",{className:"grid h-full place-items-center text-ink-3",role:"status",children:["Arranging ",t.title.toLowerCase(),"…"]});const{Renderer:o,initialView:a}=e,l=IB[h$(t)];return f.jsx("div",{className:"fade-in h-full",onContextMenu:fT(t.id),children:f.jsxs(VB,{viewId:t.id,scene:n,label:`${t.title}, ${e.label.toLowerCase()} diagram`,tools:l?f.jsx(l,{view:t}):void 0,initial:a,children:[f.jsx(o,{scene:n,view:t}),(s.effects.length>0||s.badges.length>0)&&f.jsx(x$,{value:i,children:f.jsx(VL,{scene:n,view:t})})]})})}function ZB({view:t}){const e=t.type==="extension"?t.extension.split("/")[0]:t.type;return f.jsx("div",{className:"grid h-full place-items-center p-8",children:f.jsxs("div",{className:"max-w-md text-center",children:[f.jsx(Nj,{className:"mx-auto text-ink-3",size:28}),f.jsxs("h2",{className:"mt-3 text-[16px] font-semibold",children:["This studio cannot draw “",t.title,"”"]}),f.jsxs("p",{className:"mt-1.5 text-ink-2",children:["The view uses the ",f.jsx("strong",{children:e})," extension, which is not installed here. Its data stays in the document and is kept when you export it."]})]})})}function fl({text:t,multiline:e=!1}){const n=e?x1(t):[t];return n.length<=1?f.jsx(Xb,{text:n[0]??""}):f.jsx(f.Fragment,{children:n.map((r,s)=>f.jsx("span",{className:`block ${s>0?"mt-[0.8em]":""}`,children:f.jsx(Xb,{text:r})},s))})}function Xb({text:t}){return f.jsx(f.Fragment,{children:Ba(t).map((e,n)=>f.jsx(b.Fragment,{children:HB(e)},n))})}function HB(t){let e=t.text;return t.marks.includes("code")&&(e=f.jsx("code",{className:"rounded-[4px] bg-sunken px-1 py-px font-mono text-[0.88em] [font-variant-ligatures:none]",children:e})),t.marks.includes("italic")&&(e=f.jsx("em",{children:e})),t.marks.includes("bold")&&(e=f.jsx("strong",{className:"font-semibold text-ink",children:e})),t.href&&(e=f.jsx("a",{href:t.href,target:"_blank",rel:"noreferrer",className:"text-poney underline decoration-poney/40 underline-offset-2 hover:decoration-poney",children:e})),e}function qB(){const e=Be().doc,n=R(l=>l.navigate),r=b.useMemo(()=>$l(e,{extensions:Vd()}),[e]),s=KB(e.views),o=[...QM([...new Set(e.views.map(l=>l.category))]).filter(l=>l!=="walkthrough").map(l=>({key:l,label:Jd(l),views:e.views.filter(c=>c.category===l)})),...e.walkthroughs.map(l=>{const c=new Set([l.overview,...l.scenes.map(d=>d.view)].filter(Boolean));return{key:`walk:${l.id}`,label:`In “${Ar(l.title)}”`,views:e.views.filter(d=>d.category==="walkthrough"&&c.has(d.id))}})].filter(l=>l.views.length>0),a=[[e.model.entities.length,"parts"],[e.model.relationships.length,"connections"],[e.model.dataTypes.length,"data types"],[e.model.behaviors.length,"behaviors"],[e.model.useCases.length,"use cases"]].filter(([l])=>l>0);return e.views.length===0&&e.walkthroughs.length===0?f.jsx(JB,{name:e.project.name,description:e.project.description}):f.jsx("div",{className:"scrollbar-quiet h-full overflow-y-auto",children:f.jsxs("div",{className:"mx-auto max-w-[920px] px-6 pb-20 pt-12 sm:px-10",children:[f.jsx("p",{className:"text-[13px] text-ink-3",children:"Project"}),f.jsx("h1",{className:"mt-1 text-[34px] font-semibold leading-tight tracking-[-0.02em]",children:e.project.name}),f.jsx("p",{className:"mt-3 max-w-[64ch] text-[16px] leading-relaxed text-ink-2",children:e.project.description}),f.jsxs("p",{className:"font-tabular mt-4 text-[13px] text-ink-3",children:[a.map(([l,c])=>`${l} ${c}`).join(", "),", shown in ",e.views.length," diagram",e.views.length===1?"":"s","."]}),e.walkthroughs.length>0&&f.jsxs("section",{className:"mt-10","aria-labelledby":"walkthroughs",children:[f.jsx("h2",{id:"walkthroughs",className:"text-[15px] font-semibold",children:"Walkthroughs and tours"}),f.jsx("ul",{className:"mt-3 space-y-3",children:e.walkthroughs.map(l=>{var c;return f.jsx("li",{children:f.jsxs("button",{type:"button",onClick:()=>n(`walk:${l.id}`),className:"group flex w-full items-start gap-4 rounded-xl border border-rule bg-raised p-5 text-left transition-colors hover:border-rule-strong",children:[f.jsx($p,{size:20,className:"mt-0.5 shrink-0 text-poney"}),f.jsxs("span",{className:"min-w-0 flex-1",children:[f.jsx("span",{className:"block text-[16px] font-semibold",children:f.jsx(fl,{text:l.title})}),f.jsx("span",{className:"mt-1 block max-w-[70ch] text-[13.5px] leading-snug text-ink-2",children:f.jsx(fl,{text:l.summary})}),f.jsxs("span",{className:"mt-2 block text-[12.5px] text-ink-3",children:[l.scenes.length," scenes",(c=l.source)!=null&&c.ref?`, ${l.source.kind.toLowerCase()} ${l.source.ref}`:""]})]}),f.jsx(eh,{size:16,className:"mt-1 shrink-0 text-ink-4 group-hover:text-poney"})]})},l.id)})})]}),s.length>0&&f.jsxs("section",{className:"mt-10","aria-labelledby":"start-here",children:[f.jsx("h2",{id:"start-here",className:"text-[15px] font-semibold",children:"Start here"}),f.jsx("ol",{className:"mt-3 grid gap-3 md:grid-cols-3",children:s.map(({view:l,why:c},d)=>{const u=rs(l),h=(u==null?void 0:u.icon)??Ao;return f.jsx("li",{children:f.jsxs("button",{type:"button",onClick:()=>n(l.id),className:"group flex h-full w-full flex-col rounded-xl border border-rule bg-raised p-4 text-left transition-colors hover:border-rule-strong",children:[f.jsxs("span",{className:"flex items-center gap-2 text-[12px] text-ink-3",children:[f.jsx("span",{className:"font-tabular grid h-5 w-5 place-items-center rounded-full bg-sunken text-[11px] font-semibold text-ink-2",children:d+1}),u==null?void 0:u.label]}),f.jsxs("span",{className:"mt-3 flex items-center gap-2 text-[15px] font-semibold",children:[f.jsx(h,{size:16,className:"text-poney"}),l.title]}),f.jsx("span",{className:"mt-1 text-[13px] leading-snug text-ink-2",children:c})]})},l.id)})})]}),o.length>0&&f.jsxs("section",{className:"mt-12","aria-labelledby":"all-diagrams",children:[f.jsx("h2",{id:"all-diagrams",className:"text-[15px] font-semibold",children:"Every diagram"}),f.jsx("p",{className:"mt-1 text-[13px] text-ink-2",children:"All of them read from one model. Select something in one diagram, and follow it into the others."}),f.jsx("div",{className:"mt-4 grid gap-x-10 gap-y-6 md:grid-cols-2",children:o.map(l=>f.jsxs("div",{children:[f.jsx("h3",{className:"mb-1.5 text-[12px] font-semibold text-ink-3",children:l.label}),f.jsx("ul",{children:l.views.map(c=>{const d=rs(c),u=(d==null?void 0:d.icon)??Ao;return f.jsx("li",{children:f.jsxs("button",{type:"button",onClick:()=>n(c.id),className:"group -mx-2 flex w-[calc(100%+16px)] items-start gap-3 rounded-lg px-2 py-2 text-left hover:bg-sunken",children:[f.jsx(u,{size:16,className:"mt-0.5 shrink-0 text-ink-3 group-hover:text-poney"}),f.jsxs("span",{className:"min-w-0 flex-1",children:[f.jsx("span",{className:"block text-[13.5px] font-semibold",children:c.title}),f.jsx("span",{className:"block text-[12.5px] leading-snug text-ink-2",children:c.description})]}),f.jsx(eh,{size:14,className:"mt-0.5 shrink-0 text-ink-4 opacity-0 group-hover:opacity-100"})]})},c.id)})})]},l.key))})]}),f.jsxs("section",{className:"mt-12 grid gap-6 border-t border-rule pt-8 md:grid-cols-2","aria-label":"About this document",children:[f.jsxs("div",{children:[f.jsx("h2",{className:"text-[15px] font-semibold",children:"The model"}),r.ok?f.jsxs("p",{className:"mt-2 flex items-start gap-2 text-[13px] text-ink-2",children:[f.jsx(w_,{size:15,className:"mt-0.5 shrink-0 text-[color:var(--success)]"}),"A valid Poney ",e.poneyVersion," document",e.extensions.length?`, using the ${e.extensions.map(l=>l.name).join(", ")} extension`:"",". Every reference resolves."]}):f.jsxs("p",{className:"mt-2 flex items-start gap-2 text-[13px] text-ink-2",children:[f.jsx(AD,{size:15,className:"mt-0.5 shrink-0 text-[color:var(--failure)]"}),r.issues.length," problem",r.issues.length===1?"":"s"," in the model."]}),r.issues.length>0&&f.jsx("ul",{className:"mt-2 space-y-1 text-[12px] text-ink-2",children:r.issues.slice(0,6).map((l,c)=>f.jsxs("li",{children:[f.jsx("code",{className:"font-mono text-[11px] text-ink-3",children:l.path})," ",l.message]},c))})]}),f.jsxs("div",{children:[f.jsx("h2",{className:"text-[15px] font-semibold",children:"Bring your own"}),f.jsxs("p",{className:"mt-2 flex items-start gap-2 text-[13px] text-ink-2",children:[f.jsx(__,{size:15,className:"mt-0.5 shrink-0 text-ink-3"}),f.jsxs("span",{children:["Paste a Poney document or a Mermaid diagram anywhere in the studio to open it."," ",f.jsx("button",{type:"button",className:"font-semibold text-poney hover:underline",onClick:()=>R.getState().setImportOpen(!0),children:"Open or paste a model"})]})]})]})]})]})})}function KB(t){const e=[],n=t.find(i=>i.type==="architecture"&&i.collapsed.length>0),r=t.find(i=>i.type==="architecture"&&i.collapsed.length===0),s=t.find(i=>i.type==="sequence"&&/checkout|order/i.test(i.id))??t.find(i=>i.type==="sequence");return n&&e.push({view:n,why:"The whole system as one box: who uses it and what it depends on."}),r&&e.push({view:r,why:"Open the box: every app, service and store, and how they connect."}),s&&e.push({view:s,why:"Follow one request, step by step, through the services."}),e.length===0&&e.push(...t.slice(0,3).map(i=>({view:i,why:i.description}))),e}function JB({name:t,description:e}){const{session:n,listening:r}=R(o=>o.agent),s=n==null?void 0:n.busy,i=o=>{R.getState().setAgentPanelOpen(!0),qp(o)};return f.jsx("div",{className:"scrollbar-quiet h-full overflow-y-auto",children:f.jsxs("div",{className:"mx-auto max-w-[760px] px-6 pb-20 pt-14 sm:px-10",children:[f.jsx("p",{className:"text-[13px] text-ink-3",children:"Project"}),f.jsx("h1",{className:"mt-1 text-[34px] font-semibold leading-tight tracking-[-0.02em]",children:t}),e&&f.jsx("p",{className:"mt-3 max-w-[64ch] text-[16px] leading-relaxed text-ink-2",children:e}),f.jsx("p",{className:"mt-8 text-[15px] text-ink-2",children:s?"The agent is working on it. What it opens shows here.":"Nothing is drawn yet."}),s?f.jsxs("p",{className:"mt-4 inline-flex items-center gap-2 text-[14px] text-ink-3",children:[f.jsx(Ro,{size:15,className:"animate-spin"})," ",n==null?void 0:n.name," is reading the code…"]}):n||r?f.jsxs("ul",{className:"mt-5 space-y-2",children:[tT.map(o=>f.jsx("li",{children:f.jsxs("button",{type:"button",onClick:()=>i(o.prompt),className:"group flex w-full items-center gap-3 rounded-xl border border-rule bg-raised px-5 py-4 text-left transition-colors hover:border-rule-strong",children:[f.jsx($p,{size:18,className:"shrink-0 text-poney"}),f.jsx("span",{className:"flex-1 text-[15px] font-semibold",children:o.label}),f.jsx(eh,{size:16,className:"shrink-0 text-ink-4 group-hover:text-poney"})]})},o.label)),f.jsx("li",{className:"pt-2 text-[13.5px] text-ink-3",children:"Or ask anything in the agent panel."})]}):f.jsx("div",{className:"mt-5",children:f.jsxs("button",{type:"button",onClick:()=>R.getState().setConnectOpen(!0),className:"inline-flex h-9 items-center gap-2 rounded-lg bg-ink px-3.5 text-[13.5px] font-semibold text-paper hover:opacity-90",children:[f.jsx(Tp,{size:15})," Connect an agent"]})})]})})}var e2=1,GB=.9,YB=.8,QB=.17,ig=.1,og=.999,XB=.9999,eV=.99,tV=/[\\\/_+.#"@\[\(\{&]/,nV=/[\\\/_+.#"@\[\(\{&]/g,rV=/[\s-]/,gT=/[\s-]/g;function Px(t,e,n,r,s,i,o){if(i===e.length)return s===t.length?e2:eV;var a=`${s},${i}`;if(o[a]!==void 0)return o[a];for(var l=r.charAt(i),c=n.indexOf(l,s),d=0,u,h,m,g;c>=0;)u=Px(t,e,n,r,c+1,i+1,o),u>d&&(c===s?u*=e2:tV.test(t.charAt(c-1))?(u*=YB,m=t.slice(s,c-1).match(nV),m&&s>0&&(u*=Math.pow(og,m.length))):rV.test(t.charAt(c-1))?(u*=GB,g=t.slice(s,c-1).match(gT),g&&s>0&&(u*=Math.pow(og,g.length))):(u*=QB,s>0&&(u*=Math.pow(og,c-s))),t.charAt(c)!==e.charAt(i)&&(u*=XB)),(u<ig&&n.charAt(c-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(c-1)!==r.charAt(i))&&(h=Px(t,e,n,r,c+1,i+2,o),h*ig>u&&(u=h*ig)),u>d&&(d=u),c=n.indexOf(l,c+1);return o[a]=d,d}function t2(t){return t.toLowerCase().replace(gT," ")}function sV(t,e,n){return t=n&&n.length>0?`${t+" "+n.join(" ")}`:t,Px(t,e,t2(t),t2(e),0,0,{})}var iV=Object.defineProperty,n0=(t,e)=>iV(t,"name",{value:e,configurable:!0}),Nu=0,Fr=null;function oV(t){return r0(),t.children}n0(oV,"FocusGuards");function r0(){b.useEffect(()=>{Fr||(Fr={start:Dx(),end:Dx()});const{start:t,end:e}=Fr;return document.body.firstElementChild!==t&&document.body.insertAdjacentElement("afterbegin",t),document.body.lastElementChild!==e&&document.body.insertAdjacentElement("beforeend",e),Nu++,()=>{Nu===1&&(Fr==null||Fr.start.remove(),Fr==null||Fr.end.remove(),Fr=null),Nu=Math.max(0,Nu-1)}},[])}n0(r0,"useFocusGuards");function Dx(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}n0(Dx,"createFocusGuard");var Kr=function(){return Kr=Object.assign||function(e){for(var n,r=1,s=arguments.length;r<s;r++){n=arguments[r];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},Kr.apply(this,arguments)};function yT(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n}function aV(t,e,n){if(n||arguments.length===2)for(var r=0,s=e.length,i;r<s;r++)(i||!(r in e))&&(i||(i=Array.prototype.slice.call(e,0,r)),i[r]=e[r]);return t.concat(i||Array.prototype.slice.call(e))}var lf="right-scroll-bar-position",cf="width-before-scroll-bar",lV="with-scroll-bars-hidden",cV="--removed-body-scroll-bar-size";function ag(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function dV(t,e){var n=b.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var s=n.value;s!==r&&(n.value=r,n.callback(r,s))}}}})[0];return n.callback=e,n.facade}var uV=typeof window<"u"?b.useLayoutEffect:b.useEffect,n2=new WeakMap;function fV(t,e){var n=dV(null,function(r){return t.forEach(function(s){return ag(s,r)})});return uV(function(){var r=n2.get(n);if(r){var s=new Set(r),i=new Set(t),o=n.current;s.forEach(function(a){i.has(a)||ag(a,null)}),i.forEach(function(a){s.has(a)||ag(a,o)})}n2.set(n,t)},[t]),n}function hV(t){return t}function pV(t,e){e===void 0&&(e=hV);var n=[],r=!1,s={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(i){var o=e(i,r);return n.push(o),function(){n=n.filter(function(a){return a!==o})}},assignSyncMedium:function(i){for(r=!0;n.length;){var o=n;n=[],o.forEach(i)}n={push:function(a){return i(a)},filter:function(){return n}}},assignMedium:function(i){r=!0;var o=[];if(n.length){var a=n;n=[],a.forEach(i),o=n}var l=function(){var d=o;o=[],d.forEach(i)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(d){o.push(d),c()},filter:function(d){return o=o.filter(d),n}}}};return s}function mV(t){t===void 0&&(t={});var e=pV(null);return e.options=Kr({async:!0,ssr:!1},t),e}var xT=function(t){var e=t.sideCar,n=yT(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return b.createElement(r,Kr({},n))};xT.isSideCarExport=!0;function gV(t,e){return t.useMedium(e),xT}var vT=mV(),lg=function(){},Jp=b.forwardRef(function(t,e){var n=b.useRef(null),r=b.useState({onScrollCapture:lg,onWheelCapture:lg,onTouchMoveCapture:lg}),s=r[0],i=r[1],o=t.forwardProps,a=t.children,l=t.className,c=t.removeScrollBar,d=t.enabled,u=t.shards,h=t.sideCar,m=t.noRelative,g=t.noIsolation,p=t.inert,x=t.allowPinchZoom,y=t.as,v=y===void 0?"div":y,k=t.gapMode,w=yT(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),C=h,E=fV([n,e]),_=Kr(Kr({},w),s);return b.createElement(b.Fragment,null,d&&b.createElement(C,{sideCar:vT,removeScrollBar:c,shards:u,noRelative:m,noIsolation:g,inert:p,setCallbacks:i,allowPinchZoom:!!x,lockRef:n,gapMode:k}),o?b.cloneElement(b.Children.only(a),Kr(Kr({},_),{ref:E})):b.createElement(v,Kr({},_,{className:l,ref:E}),a))});Jp.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Jp.classNames={fullWidth:cf,zeroRight:lf};var yV=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function xV(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=yV();return e&&t.setAttribute("nonce",e),t}function vV(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function kV(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var wV=function(){var t=0,e=null;return{add:function(n){t==0&&(e=xV())&&(vV(e,n),kV(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},bV=function(){var t=wV();return function(e,n){b.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},kT=function(){var t=bV(),e=function(n){var r=n.styles,s=n.dynamic;return t(r,s),null};return e},SV={left:0,top:0,right:0,gap:0},cg=function(t){return parseInt(t||"",10)||0},CV=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],s=e[t==="padding"?"paddingRight":"marginRight"];return[cg(n),cg(r),cg(s)]},NV=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return SV;var e=CV(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},EV=kT(),Wa="data-scroll-locked",_V=function(t,e,n,r){var s=t.left,i=t.top,o=t.right,a=t.gap;return n===void 0&&(n="margin"),`
706
+ .`.concat(lV,` {
707
+ overflow: hidden `).concat(r,`;
708
+ padding-right: `).concat(a,"px ").concat(r,`;
709
+ }
710
+ body[`).concat(Wa,`] {
711
+ overflow: hidden `).concat(r,`;
712
+ overscroll-behavior: contain;
713
+ `).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&`
714
+ padding-left: `.concat(s,`px;
715
+ padding-top: `).concat(i,`px;
716
+ padding-right: `).concat(o,`px;
717
+ margin-left:0;
718
+ margin-top:0;
719
+ margin-right: `).concat(a,"px ").concat(r,`;
720
+ `),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
721
+ }
722
+
723
+ .`).concat(lf,` {
724
+ right: `).concat(a,"px ").concat(r,`;
725
+ }
726
+
727
+ .`).concat(cf,` {
728
+ margin-right: `).concat(a,"px ").concat(r,`;
729
+ }
730
+
731
+ .`).concat(lf," .").concat(lf,` {
732
+ right: 0 `).concat(r,`;
733
+ }
734
+
735
+ .`).concat(cf," .").concat(cf,` {
736
+ margin-right: 0 `).concat(r,`;
737
+ }
738
+
739
+ body[`).concat(Wa,`] {
740
+ `).concat(cV,": ").concat(a,`px;
741
+ }
742
+ `)},r2=function(){var t=parseInt(document.body.getAttribute(Wa)||"0",10);return isFinite(t)?t:0},jV=function(){b.useEffect(function(){return document.body.setAttribute(Wa,(r2()+1).toString()),function(){var t=r2()-1;t<=0?document.body.removeAttribute(Wa):document.body.setAttribute(Wa,t.toString())}},[])},$V=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,s=r===void 0?"margin":r;jV();var i=b.useMemo(function(){return NV(s)},[s]);return b.createElement(EV,{styles:_V(i,!e,s,n?"":"!important")})},zx=!1;if(typeof window<"u")try{var Eu=Object.defineProperty({},"passive",{get:function(){return zx=!0,!0}});window.addEventListener("test",Eu,Eu),window.removeEventListener("test",Eu,Eu)}catch{zx=!1}var ra=zx?{passive:!1}:!1,MV=function(t){return t.tagName==="TEXTAREA"},wT=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!MV(t)&&n[e]==="visible")},TV=function(t){return wT(t,"overflowY")},OV=function(t){return wT(t,"overflowX")},s2=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var s=bT(t,r);if(s){var i=ST(t,r),o=i[1],a=i[2];if(o>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},AV=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},RV=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},bT=function(t,e){return t==="v"?TV(e):OV(e)},ST=function(t,e){return t==="v"?AV(e):RV(e)},IV=function(t,e){return t==="h"&&e==="rtl"?-1:1},PV=function(t,e,n,r,s){var i=IV(t,window.getComputedStyle(e).direction),o=i*r,a=n.target,l=e.contains(a),c=!1,d=o>0,u=0,h=0;do{if(!a)break;var m=ST(t,a),g=m[0],p=m[1],x=m[2],y=p-x-i*g;(g||y)&&bT(t,a)&&(u+=y,h+=g);var v=a.parentNode;a=v&&v.nodeType===Node.DOCUMENT_FRAGMENT_NODE?v.host:v}while(!l&&a!==document.body||l&&(e.contains(a)||e===a));return(d&&Math.abs(u)<1||!d&&Math.abs(h)<1)&&(c=!0),c},_u=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},i2=function(t){return[t.deltaX,t.deltaY]},o2=function(t){return t&&"current"in t?t.current:t},DV=function(t,e){return t[0]===e[0]&&t[1]===e[1]},zV=function(t){return`
743
+ .block-interactivity-`.concat(t,` {pointer-events: none;}
744
+ .allow-interactivity-`).concat(t,` {pointer-events: all;}
745
+ `)},LV=0,sa=[];function FV(t){var e=b.useRef([]),n=b.useRef([0,0]),r=b.useRef(),s=b.useState(LV++)[0],i=b.useState(kT)[0],o=b.useRef(t);b.useEffect(function(){o.current=t},[t]),b.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(s));var p=aV([t.lockRef.current],(t.shards||[]).map(o2),!0).filter(Boolean);return p.forEach(function(x){return x.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),p.forEach(function(x){return x.classList.remove("allow-interactivity-".concat(s))})}}},[t.inert,t.lockRef.current,t.shards]);var a=b.useCallback(function(p,x){if("touches"in p&&p.touches.length===2||p.type==="wheel"&&p.ctrlKey)return!o.current.allowPinchZoom;var y=_u(p),v=n.current,k="deltaX"in p?p.deltaX:v[0]-y[0],w="deltaY"in p?p.deltaY:v[1]-y[1],C,E=p.target,_=Math.abs(k)>Math.abs(w)?"h":"v";if("touches"in p&&_==="h"&&E.type==="range")return!1;var S=window.getSelection(),j=S&&S.anchorNode,$=j?j===E||j.contains(E):!1;if($)return!1;var I=s2(_,E);if(!I)return!0;if(I?C=_:(C=_==="v"?"h":"v",I=s2(_,E)),!I)return!1;if(!r.current&&"changedTouches"in p&&(k||w)&&(r.current=C),!C)return!0;var L=r.current||C;return PV(L,x,p,L==="h"?k:w)},[]),l=b.useCallback(function(p){var x=p;if(!(!sa.length||sa[sa.length-1]!==i)){var y="deltaY"in x?i2(x):_u(x),v=e.current.filter(function(C){return C.name===x.type&&(C.target===x.target||x.target===C.shadowParent)&&DV(C.delta,y)})[0];if(v&&v.should){x.cancelable&&x.preventDefault();return}if(!v){var k=(o.current.shards||[]).map(o2).filter(Boolean).filter(function(C){return C.contains(x.target)}),w=k.length>0?a(x,k[0]):!o.current.noIsolation;w&&x.cancelable&&x.preventDefault()}}},[]),c=b.useCallback(function(p,x,y,v){var k={name:p,delta:x,target:y,should:v,shadowParent:BV(y)};e.current.push(k),setTimeout(function(){e.current=e.current.filter(function(w){return w!==k})},1)},[]),d=b.useCallback(function(p){n.current=_u(p),r.current=void 0},[]),u=b.useCallback(function(p){c(p.type,i2(p),p.target,a(p,t.lockRef.current))},[]),h=b.useCallback(function(p){c(p.type,_u(p),p.target,a(p,t.lockRef.current))},[]);b.useEffect(function(){return sa.push(i),t.setCallbacks({onScrollCapture:u,onWheelCapture:u,onTouchMoveCapture:h}),document.addEventListener("wheel",l,ra),document.addEventListener("touchmove",l,ra),document.addEventListener("touchstart",d,ra),function(){sa=sa.filter(function(p){return p!==i}),document.removeEventListener("wheel",l,ra),document.removeEventListener("touchmove",l,ra),document.removeEventListener("touchstart",d,ra)}},[]);var m=t.removeScrollBar,g=t.inert;return b.createElement(b.Fragment,null,g?b.createElement(i,{styles:zV(s)}):null,m?b.createElement($V,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function BV(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const VV=gV(vT,FV);var CT=b.forwardRef(function(t,e){return b.createElement(Jp,Kr({},t,{ref:e,sideCar:VV}))});CT.classNames=Jp.classNames;var WV=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},ia=new WeakMap,ju=new WeakMap,$u={},dg=0,NT=function(t){return t&&(t.host||NT(t.parentNode))},UV=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=NT(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},ZV=function(t,e,n,r){var s=UV(e,Array.isArray(t)?t:[t]);$u[n]||($u[n]=new WeakMap);var i=$u[n],o=[],a=new Set,l=new Set(s),c=function(u){!u||a.has(u)||(a.add(u),c(u.parentNode))};s.forEach(c);var d=function(u){!u||l.has(u)||Array.prototype.forEach.call(u.children,function(h){if(a.has(h))d(h);else try{var m=h.getAttribute(r),g=m!==null&&m!=="false",p=(ia.get(h)||0)+1,x=(i.get(h)||0)+1;ia.set(h,p),i.set(h,x),o.push(h),p===1&&g&&ju.set(h,!0),x===1&&h.setAttribute(n,"true"),g||h.setAttribute(r,"true")}catch(y){console.error("aria-hidden: cannot operate on ",h,y)}})};return d(e),a.clear(),dg++,function(){o.forEach(function(u){var h=ia.get(u)-1,m=i.get(u)-1;ia.set(u,h),i.set(u,m),h||(ju.has(u)||u.removeAttribute(r),ju.delete(u)),m||u.removeAttribute(n)}),dg--,dg||(ia=new WeakMap,ia=new WeakMap,ju=new WeakMap,$u={})}},HV=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),s=WV(t);return s?(r.push.apply(r,Array.from(s.querySelectorAll("[aria-live], script"))),ZV(r,s,n,"aria-hidden")):function(){return null}},qV=Object.defineProperty,nr=(t,e)=>qV(t,"name",{value:e,configurable:!0}),s0="Dialog",[ET,qY]=Lp(s0),[KV,cs]=ET(s0),_T=nr(t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:s,onOpenChange:i,modal:o=!0}=t,a=b.useRef(null),l=b.useRef(null),{nodes:c,registry:d}=iM(),[u,h]=H1({prop:r,defaultProp:s??!1,onChange:i,caller:s0}),[m,g]=b.useState(0),[p,x]=b.useState(0);return f.jsx(KV,{scope:e,triggerRef:a,contentRef:l,contentId:Tr(),titleId:Tr(),descriptionId:Tr(),titlePresent:m>0,descriptionPresent:p>0,setTitleCount:g,setDescriptionCount:x,open:u,onOpenChange:h,onOpenToggle:b.useCallback(()=>h(y=>!y),[h]),modal:o,branchNodes:c,branchRegistry:d,children:n})},"Dialog"),jT="DialogPortal",[JV,$T]=ET(jT,{forceMount:void 0}),MT=nr(t=>{const{__scopeDialog:e,forceMount:n,children:r,container:s}=t,i=cs(jT,e);return f.jsx(JV,{scope:e,forceMount:n,children:b.Children.map(r,o=>f.jsx(Hd,{present:n||i.open,children:f.jsx(TM,{asChild:!0,container:s,children:o})}))})},"DialogPortal"),Lx="DialogOverlay",TT=b.forwardRef(nr(function(e,n){const r=$T(Lx,e.__scopeDialog),{forceMount:s=r.forceMount,...i}=e,o=cs(Lx,e.__scopeDialog);return o.modal?f.jsx(Hd,{present:s||o.open,children:f.jsx(YV,{...i,ref:n})}):null},"DialogOverlay")),GV=P1("DialogOverlay.RemoveScroll"),YV=b.forwardRef(nr(function(e,n){const{__scopeDialog:r,...s}=e,i=cs(Lx,r),o=eM(),a=Dr(n,o);return f.jsx(CT,{as:GV,allowPinchZoom:!0,shards:b.useMemo(()=>[i.contentRef,...i.branchNodes.map(l=>({current:l}))],[i.contentRef,i.branchNodes]),children:f.jsx(Dt.div,{"data-state":i0(i.open),...s,ref:a,style:{pointerEvents:"auto",...s.style}})})},"DialogOverlayImpl")),hd="DialogContent",OT=b.forwardRef(nr(function(e,n){const r=$T(hd,e.__scopeDialog),{forceMount:s=r.forceMount,...i}=e,o=cs(hd,e.__scopeDialog);return f.jsx(Hd,{present:s||o.open,children:o.modal?f.jsx(QV,{...i,ref:n}):f.jsx(XV,{...i,ref:n})})},"DialogContent")),QV=b.forwardRef(nr(function(e,n){const r=cs(hd,e.__scopeDialog),s=b.useRef(null),i=Dr(n,r.contentRef,s);return b.useEffect(()=>{const o=s.current;if(o)return HV(o)},[]),f.jsx(AT,{...e,ref:i,trapFocus:r.open,disableOutsidePointerEvents:r.open,onCloseAutoFocus:Tn(e.onCloseAutoFocus,o=>{var a;o.preventDefault(),(a=r.triggerRef.current)==null||a.focus()}),onPointerDownOutside:Tn(e.onPointerDownOutside,o=>{const a=o.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0;(a.button===2||l)&&o.preventDefault()}),onFocusOutside:Tn(e.onFocusOutside,o=>o.preventDefault())})},"DialogContentModal")),XV=b.forwardRef(nr(function(e,n){const r=cs(hd,e.__scopeDialog),s=b.useRef(!1),i=b.useRef(!1);return f.jsx(AT,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var a,l;(a=e.onCloseAutoFocus)==null||a.call(e,o),o.defaultPrevented||(s.current||(l=r.triggerRef.current)==null||l.focus(),o.preventDefault()),s.current=!1,i.current=!1},onInteractOutside:o=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,o),o.defaultPrevented||(s.current=!0,o.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=o.target;((d=r.triggerRef.current)==null?void 0:d.contains(a))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&i.current&&o.preventDefault()}})},"DialogContentNonModal")),AT=b.forwardRef(nr(function(e,n){const{__scopeDialog:r,trapFocus:s,onOpenAutoFocus:i,onCloseAutoFocus:o,"aria-describedby":a,children:l,...c}=e,d=cs(hd,r);return r0(),f.jsx(sM,{registry:d.branchRegistry,children:f.jsx(z9,{asChild:!0,loop:!0,trapped:s,branches:d.branchNodes,onMountAutoFocus:i,onUnmountAutoFocus:o,children:f.jsx(X$,{role:"dialog",id:d.contentId,"aria-labelledby":d.titlePresent?d.titleId:void 0,"aria-describedby":d.descriptionPresent?RT(a,d.descriptionId):a,"data-state":i0(d.open),...c,ref:n,deferPointerDownOutside:!0,onDismiss:()=>d.onOpenChange(!1),children:l})})})},"DialogContentImpl")),a2=b.forwardRef(nr(function(e,n){const{__scopeDialog:r,...s}=e,i=cs("DialogTitle",r),{setTitleCount:o}=i;return Ln(()=>(o(a=>a+1),()=>o(a=>a-1)),[o]),f.jsx(Dt.h2,{id:i.titleId,...s,ref:n})},"DialogTitle")),ug=b.forwardRef(nr(function(e,n){const{__scopeDialog:r,...s}=e,i=cs("DialogDescription",r),{setDescriptionCount:o}=i;return Ln(()=>(o(a=>a+1),()=>o(a=>a-1)),[o]),f.jsx(Dt.p,{id:i.descriptionId,...s,ref:n})},"DialogDescription")),e7="DialogClose",t7=b.forwardRef(nr(function(e,n){const{__scopeDialog:r,...s}=e,i=cs(e7,r);return f.jsx(Dt.button,{type:"button",...s,ref:n,onClick:Tn(e.onClick,()=>i.onOpenChange(!1))})},"DialogClose"));function RT(...t){const e=new Set;for(const n of t)if(typeof n=="string")for(const r of String(n).trim().split(/\s+/))r&&e.add(r);return e.size>0?Array.from(e).join(" "):void 0}nr(RT,"concatAriaDescribedby");function i0(t){return t?"open":"closed"}nr(i0,"getState");var Gl='[cmdk-group=""]',fg='[cmdk-group-items=""]',n7='[cmdk-group-heading=""]',IT='[cmdk-item=""]',l2=`${IT}:not([aria-disabled="true"])`,Fx="cmdk-item-select",ha="data-value",r7=(t,e,n)=>sV(t,e,n),PT=b.createContext(void 0),Gd=()=>b.useContext(PT),DT=b.createContext(void 0),o0=()=>b.useContext(DT),zT=b.createContext(void 0),LT=b.forwardRef((t,e)=>{let n=pa(()=>{var z,F;return{search:"",value:(F=(z=t.value)!=null?z:t.defaultValue)!=null?F:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=pa(()=>new Set),s=pa(()=>new Map),i=pa(()=>new Map),o=pa(()=>new Set),a=FT(t),{label:l,children:c,value:d,onValueChange:u,filter:h,shouldFilter:m,loop:g,disablePointerSelection:p=!1,vimBindings:x=!0,...y}=t,v=Tr(),k=Tr(),w=Tr(),C=b.useRef(null),E=p7();Bo(()=>{if(d!==void 0){let z=d.trim();n.current.value=z,_.emit()}},[d]),Bo(()=>{E(6,D)},[]);let _=b.useMemo(()=>({subscribe:z=>(o.current.add(z),()=>o.current.delete(z)),snapshot:()=>n.current,setState:(z,F,U)=>{var K,O,P,W;if(!Object.is(n.current[z],F)){if(n.current[z]=F,z==="search")L(),$(),E(1,I);else if(z==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let G=document.getElementById(w);G?G.focus():(K=document.getElementById(v))==null||K.focus()}if(E(7,()=>{var G;n.current.selectedItemId=(G=B())==null?void 0:G.id,_.emit()}),U||E(5,D),((O=a.current)==null?void 0:O.value)!==void 0){let G=F??"";(W=(P=a.current).onValueChange)==null||W.call(P,G);return}}_.emit()}},emit:()=>{o.current.forEach(z=>z())}}),[]),S=b.useMemo(()=>({value:(z,F,U)=>{var K;F!==((K=i.current.get(z))==null?void 0:K.value)&&(i.current.set(z,{value:F,keywords:U}),n.current.filtered.items.set(z,j(F,U)),E(2,()=>{$(),_.emit()}))},item:(z,F)=>(r.current.add(z),F&&(s.current.has(F)?s.current.get(F).add(z):s.current.set(F,new Set([z]))),E(3,()=>{L(),$(),n.current.value||I(),_.emit()}),()=>{i.current.delete(z),r.current.delete(z),n.current.filtered.items.delete(z);let U=B();E(4,()=>{L(),(U==null?void 0:U.getAttribute("id"))===z&&I(),_.emit()})}),group:z=>(s.current.has(z)||s.current.set(z,new Set),()=>{i.current.delete(z),s.current.delete(z)}),filter:()=>a.current.shouldFilter,label:l||t["aria-label"],getDisablePointerSelection:()=>a.current.disablePointerSelection,listId:v,inputId:w,labelId:k,listInnerRef:C}),[]);function j(z,F){var U,K;let O=(K=(U=a.current)==null?void 0:U.filter)!=null?K:r7;return z?O(z,n.current.search,F):0}function $(){if(!n.current.search||a.current.shouldFilter===!1)return;let z=n.current.filtered.items,F=[];n.current.filtered.groups.forEach(K=>{let O=s.current.get(K),P=0;O.forEach(W=>{let G=z.get(W);P=Math.max(G,P)}),F.push([K,P])});let U=C.current;H().sort((K,O)=>{var P,W;let G=K.getAttribute("id"),se=O.getAttribute("id");return((P=z.get(se))!=null?P:0)-((W=z.get(G))!=null?W:0)}).forEach(K=>{let O=K.closest(fg);O?O.appendChild(K.parentElement===O?K:K.closest(`${fg} > *`)):U.appendChild(K.parentElement===U?K:K.closest(`${fg} > *`))}),F.sort((K,O)=>O[1]-K[1]).forEach(K=>{var O;let P=(O=C.current)==null?void 0:O.querySelector(`${Gl}[${ha}="${encodeURIComponent(K[0])}"]`);P==null||P.parentElement.appendChild(P)})}function I(){let z=H().find(U=>U.getAttribute("aria-disabled")!=="true"),F=z==null?void 0:z.getAttribute(ha);_.setState("value",F||void 0)}function L(){var z,F,U,K;if(!n.current.search||a.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let O=0;for(let P of r.current){let W=(F=(z=i.current.get(P))==null?void 0:z.value)!=null?F:"",G=(K=(U=i.current.get(P))==null?void 0:U.keywords)!=null?K:[],se=j(W,G);n.current.filtered.items.set(P,se),se>0&&O++}for(let[P,W]of s.current)for(let G of W)if(n.current.filtered.items.get(G)>0){n.current.filtered.groups.add(P);break}n.current.filtered.count=O}function D(){var z,F,U;let K=B();K&&(((z=K.parentElement)==null?void 0:z.firstChild)===K&&((U=(F=K.closest(Gl))==null?void 0:F.querySelector(n7))==null||U.scrollIntoView({block:"nearest"})),K.scrollIntoView({block:"nearest"}))}function B(){var z;return(z=C.current)==null?void 0:z.querySelector(`${IT}[aria-selected="true"]`)}function H(){var z;return Array.from(((z=C.current)==null?void 0:z.querySelectorAll(l2))||[])}function T(z){let F=H()[z];F&&_.setState("value",F.getAttribute(ha))}function M(z){var F;let U=B(),K=H(),O=K.findIndex(W=>W===U),P=K[O+z];(F=a.current)!=null&&F.loop&&(P=O+z<0?K[K.length-1]:O+z===K.length?K[0]:K[O+z]),P&&_.setState("value",P.getAttribute(ha))}function A(z){let F=B(),U=F==null?void 0:F.closest(Gl),K;for(;U&&!K;)U=z>0?f7(U,Gl):h7(U,Gl),K=U==null?void 0:U.querySelector(l2);K?_.setState("value",K.getAttribute(ha)):M(z)}let V=()=>T(H().length-1),J=z=>{z.preventDefault(),z.metaKey?V():z.altKey?A(1):M(1)},X=z=>{z.preventDefault(),z.metaKey?T(0):z.altKey?A(-1):M(-1)};return b.createElement(Dt.div,{ref:e,tabIndex:-1,...y,"cmdk-root":"",onKeyDown:z=>{var F;(F=y.onKeyDown)==null||F.call(y,z);let U=z.nativeEvent.isComposing||z.keyCode===229;if(!(z.defaultPrevented||U))switch(z.key){case"n":case"j":{x&&z.ctrlKey&&J(z);break}case"ArrowDown":{J(z);break}case"p":case"k":{x&&z.ctrlKey&&X(z);break}case"ArrowUp":{X(z);break}case"Home":{z.preventDefault(),T(0);break}case"End":{z.preventDefault(),V();break}case"Enter":{z.preventDefault();let K=B();if(K){let O=new Event(Fx);K.dispatchEvent(O)}}}}},b.createElement("label",{"cmdk-label":"",htmlFor:S.inputId,id:S.labelId,style:g7},l),Gp(t,z=>b.createElement(DT.Provider,{value:_},b.createElement(PT.Provider,{value:S},z))))}),s7=b.forwardRef((t,e)=>{var n,r;let s=Tr(),i=b.useRef(null),o=b.useContext(zT),a=Gd(),l=FT(t),c=(r=(n=l.current)==null?void 0:n.forceMount)!=null?r:o==null?void 0:o.forceMount;Bo(()=>{if(!c)return a.item(s,o==null?void 0:o.id)},[c]);let d=BT(s,i,[t.value,t.children,i],t.keywords),u=o0(),h=Wi(E=>E.value&&E.value===d.current),m=Wi(E=>c||a.filter()===!1?!0:E.search?E.filtered.items.get(s)>0:!0);b.useEffect(()=>{let E=i.current;if(!(!E||t.disabled))return E.addEventListener(Fx,g),()=>E.removeEventListener(Fx,g)},[m,t.onSelect,t.disabled]);function g(){var E,_;p(),(_=(E=l.current).onSelect)==null||_.call(E,d.current)}function p(){u.setState("value",d.current,!0)}if(!m)return null;let{disabled:x,value:y,onSelect:v,forceMount:k,keywords:w,...C}=t;return b.createElement(Dt.div,{ref:Do(i,e),...C,id:s,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!h,"data-disabled":!!x,"data-selected":!!h,onPointerMove:x||a.getDisablePointerSelection()?void 0:p,onClick:x?void 0:g},t.children)}),i7=b.forwardRef((t,e)=>{let{heading:n,children:r,forceMount:s,...i}=t,o=Tr(),a=b.useRef(null),l=b.useRef(null),c=Tr(),d=Gd(),u=Wi(m=>s||d.filter()===!1?!0:m.search?m.filtered.groups.has(o):!0);Bo(()=>d.group(o),[]),BT(o,a,[t.value,t.heading,l]);let h=b.useMemo(()=>({id:o,forceMount:s}),[s]);return b.createElement(Dt.div,{ref:Do(a,e),...i,"cmdk-group":"",role:"presentation",hidden:u?void 0:!0},n&&b.createElement("div",{ref:l,"cmdk-group-heading":"","aria-hidden":!0,id:c},n),Gp(t,m=>b.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?c:void 0},b.createElement(zT.Provider,{value:h},m))))}),o7=b.forwardRef((t,e)=>{let{alwaysRender:n,...r}=t,s=b.useRef(null),i=Wi(o=>!o.search);return!n&&!i?null:b.createElement(Dt.div,{ref:Do(s,e),...r,"cmdk-separator":"",role:"separator"})}),a7=b.forwardRef((t,e)=>{let{onValueChange:n,...r}=t,s=t.value!=null,i=o0(),o=Wi(c=>c.search),a=Wi(c=>c.selectedItemId),l=Gd();return b.useEffect(()=>{t.value!=null&&i.setState("search",t.value)},[t.value]),b.createElement(Dt.input,{ref:e,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":a,id:l.inputId,type:"text",value:s?t.value:o,onChange:c=>{s||i.setState("search",c.target.value),n==null||n(c.target.value)}})}),l7=b.forwardRef((t,e)=>{let{children:n,label:r="Suggestions",...s}=t,i=b.useRef(null),o=b.useRef(null),a=Wi(c=>c.selectedItemId),l=Gd();return b.useEffect(()=>{if(o.current&&i.current){let c=o.current,d=i.current,u,h=new ResizeObserver(()=>{u=requestAnimationFrame(()=>{let m=c.offsetHeight;d.style.setProperty("--cmdk-list-height",m.toFixed(1)+"px")})});return h.observe(c),()=>{cancelAnimationFrame(u),h.unobserve(c)}}},[]),b.createElement(Dt.div,{ref:Do(i,e),...s,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":a,"aria-label":r,id:l.listId},Gp(t,c=>b.createElement("div",{ref:Do(o,l.listInnerRef),"cmdk-list-sizer":""},c)))}),c7=b.forwardRef((t,e)=>{let{open:n,onOpenChange:r,overlayClassName:s,contentClassName:i,container:o,...a}=t;return b.createElement(_T,{open:n,onOpenChange:r},b.createElement(MT,{container:o},b.createElement(TT,{"cmdk-overlay":"",className:s}),b.createElement(OT,{"aria-label":t.label,"cmdk-dialog":"",className:i},b.createElement(LT,{ref:e,...a}))))}),d7=b.forwardRef((t,e)=>Wi(n=>n.filtered.count===0)?b.createElement(Dt.div,{ref:e,...t,"cmdk-empty":"",role:"presentation"}):null),u7=b.forwardRef((t,e)=>{let{progress:n,children:r,label:s="Loading...",...i}=t;return b.createElement(Dt.div,{ref:e,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":s},Gp(t,o=>b.createElement("div",{"aria-hidden":!0},o)))}),et=Object.assign(LT,{List:l7,Item:s7,Input:a7,Group:i7,Separator:o7,Dialog:c7,Empty:d7,Loading:u7});function f7(t,e){let n=t.nextElementSibling;for(;n;){if(n.matches(e))return n;n=n.nextElementSibling}}function h7(t,e){let n=t.previousElementSibling;for(;n;){if(n.matches(e))return n;n=n.previousElementSibling}}function FT(t){let e=b.useRef(t);return Bo(()=>{e.current=t}),e}var Bo=typeof window>"u"?b.useEffect:b.useLayoutEffect;function pa(t){let e=b.useRef();return e.current===void 0&&(e.current=t()),e}function Wi(t){let e=o0(),n=()=>t(e.snapshot());return b.useSyncExternalStore(e.subscribe,n,n)}function BT(t,e,n,r=[]){let s=b.useRef(),i=Gd();return Bo(()=>{var o;let a=(()=>{var c;for(let d of n){if(typeof d=="string")return d.trim();if(typeof d=="object"&&"current"in d)return d.current?(c=d.current.textContent)==null?void 0:c.trim():s.current}})(),l=r.map(c=>c.trim());i.value(t,a,l),(o=e.current)==null||o.setAttribute(ha,a),s.current=a}),s}var p7=()=>{let[t,e]=b.useState(),n=pa(()=>new Map);return Bo(()=>{n.current.forEach(r=>r()),n.current=new Map},[t]),(r,s)=>{n.current.set(r,s),e({})}};function m7(t){let e=t.type;return typeof e=="function"?e(t.props):"render"in e?e.render(t.props):t}function Gp({asChild:t,children:e},n){return t&&b.isValidElement(e)?b.cloneElement(m7(e),{ref:e.ref},n(e.props.children)):n(e)}var g7={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};function Go({open:t,onOpenChange:e,title:n,description:r,children:s,width:i=560,hideHeader:o}){return f.jsx(_T,{open:t,onOpenChange:e,children:f.jsxs(MT,{children:[f.jsx(TT,{className:"fade-in fixed inset-0 z-40 bg-ink/25 backdrop-blur-[1px]"}),f.jsxs(OT,{className:"fade-in fixed left-1/2 top-[12vh] z-50 flex max-h-[76vh] w-[calc(100vw-32px)] -translate-x-1/2 flex-col overflow-hidden rounded-2xl border border-rule bg-raised shadow-float",style:{maxWidth:i},"aria-describedby":void 0,children:[o?f.jsx(a2,{className:"sr-only",children:n}):f.jsxs("div",{className:"flex items-start gap-3 border-b border-rule px-5 py-4",children:[f.jsxs("div",{className:"flex-1",children:[f.jsx(a2,{className:"text-[15px] font-semibold",children:n}),r&&f.jsx(ug,{className:"mt-0.5 text-[12.5px] text-ink-2",children:r})]}),f.jsx(t7,{"aria-label":"Close",className:"rounded-md p-1 text-ink-3 hover:bg-sunken hover:text-ink",children:f.jsx(Jo,{size:16})})]}),!r&&!o&&f.jsx(ug,{className:"sr-only",children:n}),o&&f.jsx(ug,{className:"sr-only",children:r??n}),s]})]})})}function y7(){const t=R(l=>l.paletteOpen),e=R(l=>l.setPaletteOpen),n=Be(),r=n.doc,s=l=>{e(!1),l()},i=l=>s(()=>Ud(l)),o="flex cursor-pointer items-center gap-3 rounded-lg px-3 py-2 text-[13px] aria-selected:bg-sunken";return f.jsx(Go,{open:t,onOpenChange:e,title:"Search",description:"Find anything in the open document: parts, states, messages, data and diagrams",width:620,hideHeader:!0,children:f.jsxs(et,{label:"Search the model",loop:!0,filter:x7,className:"flex min-h-0 flex-col",children:[f.jsx(et.Input,{autoFocus:!0,placeholder:"Search parts, states, messages, data, diagrams…",className:"h-12 w-full border-b border-rule bg-transparent px-5 text-[15px] outline-none placeholder:text-ink-3 focus-visible:outline-none"}),f.jsxs(et.List,{className:"scrollbar-quiet max-h-[56vh] overflow-y-auto p-2 [&_[cmdk-group-heading]]:px-3 [&_[cmdk-group-heading]]:pb-1 [&_[cmdk-group-heading]]:pt-3 [&_[cmdk-group-heading]]:text-[11.5px] [&_[cmdk-group-heading]]:font-semibold [&_[cmdk-group-heading]]:text-ink-3",children:[f.jsx(et.Empty,{className:"px-3 py-8 text-center text-ink-3",children:"Nothing in this document matches. Try a part, a state, a message or a diagram name."}),r.walkthroughs.length>0&&f.jsx(et.Group,{heading:"Walkthroughs",children:r.walkthroughs.map(l=>f.jsxs(et.Item,{className:o,value:`${Ar(l.title)} walkthrough change`,onSelect:()=>s(()=>R.getState().navigate(`walk:${l.id}`)),children:[f.jsx($p,{size:15,className:"text-poney"}),f.jsx("span",{className:"flex-1",children:Ar(l.title)}),f.jsxs("span",{className:"text-[12px] text-ink-3",children:[l.scenes.length," scenes"]})]},l.id))}),f.jsxs(et.Group,{heading:"Diagrams",children:[f.jsxs(et.Item,{className:o,value:"Project overview",onSelect:()=>s(()=>R.getState().navigate(bt)),children:[f.jsx(Ao,{size:15,className:"text-ink-3"}),"Project overview"]}),r.views.map(l=>{var d;const c=((d=rs(l))==null?void 0:d.icon)??Ao;return f.jsxs(et.Item,{className:o,value:`${l.title} ${l.type} diagram`,onSelect:()=>s(()=>R.getState().navigate(l.id)),children:[f.jsx(c,{size:15,className:"text-ink-3"}),f.jsx("span",{className:"flex-1",children:l.title}),f.jsx("span",{className:"text-[12px] text-ink-3",children:Jd(l.category)})]},l.id)})]}),f.jsx(et.Group,{heading:"Parts of the system",children:r.model.entities.map(l=>{const c=n.style(l),d=Pp(c.icon);return f.jsxs(et.Item,{className:o,value:`${l.name} ${l.id} ${c.label} ${l.technology??""} ${l.summary}`,onSelect:()=>i({kind:"entity",id:l.id}),children:[f.jsx(d,{size:15,style:{color:pt(c.tone)}}),f.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[l.name," ",f.jsxs("span",{className:"text-ink-3",children:["— ",l.summary]})]}),f.jsx("span",{className:"shrink-0 text-[12px] text-ink-3",children:c.label})]},l.id)})}),f.jsx(et.Group,{heading:"Data",children:r.model.dataTypes.map(l=>f.jsxs(et.Item,{className:o,value:`${l.name} ${l.id} ${l.kind} ${l.summary} ${l.fields.map(c=>c.name).join(" ")}`,onSelect:()=>i({kind:"dataType",id:l.id}),children:[f.jsx(Bj,{size:15,className:"text-ink-3"}),f.jsx("span",{className:`flex-1 ${l.kind==="table"?"font-mono text-[12.5px]":""}`,children:l.name}),f.jsx("span",{className:"text-[12px] text-ink-3",children:l.kind==="table"?"Table":l.kind==="event"?"Event":"Record"})]},l.id))}),f.jsxs(et.Group,{heading:"Behaviors and use cases",children:[r.model.behaviors.map(l=>f.jsxs(et.Item,{className:o,value:`${l.name} ${l.summary}`,onSelect:()=>s(()=>{const c=n.viewsForBehavior(l.id)[0];c?R.getState().navigate(c.id):R.getState().select({kind:"behavior",id:l.id})}),children:[f.jsx(Fd,{size:15,className:"text-ink-3"}),f.jsx("span",{className:"flex-1",children:l.name}),f.jsx("span",{className:"text-[12px] text-ink-3",children:n.describe({kind:"behavior",id:l.id}).kind})]},l.id)),r.model.useCases.map(l=>f.jsxs(et.Item,{className:o,value:`${l.name} ${l.summary} ${l.area} use case`,onSelect:()=>i({kind:"useCase",id:l.id}),children:[f.jsx(PD,{size:15,className:"text-ink-3"}),f.jsx("span",{className:"flex-1",children:l.name}),f.jsx("span",{className:"text-[12px] text-ink-3",children:"Use case"})]},l.id))]}),f.jsx(et.Group,{heading:"States, steps and messages",children:r.model.behaviors.flatMap(l=>l.kind==="state-machine"?[...l.states.filter(c=>c.kind!=="initial").map(c=>f.jsxs(et.Item,{className:o,value:`${c.name} ${c.id} state ${c.description??""} ${l.name}`,onSelect:()=>i({kind:"state",behavior:l.id,id:c.id}),children:[f.jsx(iD,{size:15,className:"text-ink-3"}),f.jsx("span",{className:"min-w-0 flex-1 truncate",children:c.name}),f.jsxs("span",{className:"shrink-0 text-[12px] text-ink-3",children:["State in ",l.name]})]},`s-${l.id}-${c.id}`)),...l.transitions.map(c=>f.jsxs(et.Item,{className:o,value:`${c.event} ${c.guard??""} transition ${l.name}`,onSelect:()=>i({kind:"transition",behavior:l.id,id:c.id}),children:[f.jsx(ns,{size:15,className:"text-ink-3"}),f.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[c.event,c.guard&&f.jsxs("span",{className:"text-ink-3",children:[" [",c.guard,"]"]})]}),f.jsxs("span",{className:"shrink-0 text-[12px] text-ink-3",children:["Transition in ",l.name]})]},`t-${l.id}-${c.id}`))]:l.kind==="interaction"?n.messages(l.id).map(({message:c})=>f.jsxs(et.Item,{className:o,value:`${c.label} ${c.id} message ${l.name}`,onSelect:()=>i({kind:"message",behavior:l.id,id:c.id}),children:[f.jsx(ns,{size:15,className:"text-ink-3"}),f.jsx("span",{className:"min-w-0 flex-1 truncate",children:c.label}),f.jsxs("span",{className:"shrink-0 text-[12px] text-ink-3",children:["Message in ",l.name]})]},`m-${l.id}-${c.id}`)):l.kind==="activity"?l.nodes.filter(c=>c.label).map(c=>f.jsxs(et.Item,{className:o,value:`${c.label} ${c.id} step ${l.name}`,onSelect:()=>i({kind:"activityNode",behavior:l.id,id:c.id}),children:[f.jsx(Ij,{size:15,className:"text-ink-3"}),f.jsx("span",{className:"min-w-0 flex-1 truncate",children:c.label}),f.jsxs("span",{className:"shrink-0 text-[12px] text-ink-3",children:["Step in ",l.name]})]},`n-${l.id}-${c.id}`)):[])}),f.jsxs(et.Group,{heading:"Actions",children:[f.jsxs(et.Item,{className:o,value:"Fit diagram to view",onSelect:()=>s(()=>R.getState().requestFocus("fit")),children:[f.jsx(oj,{size:15,className:"text-ink-3"}),"Fit the diagram to the view"]}),f.jsxs(et.Item,{className:o,value:"Copy JSON export clipboard",onSelect:()=>s(()=>void Y1()),children:[f.jsx(N_,{size:15,className:"text-ink-3"}),"Copy the model as JSON"]}),f.jsxs(et.Item,{className:o,value:"Open paste import Mermaid JSON",onSelect:()=>s(()=>R.getState().setImportOpen(!0)),children:[f.jsx(k1,{size:15,className:"text-ink-3"}),"Open or paste a model (Poney JSON or Mermaid)"]}),f.jsxs(et.Item,{className:o,value:"Toggle dark light theme",onSelect:()=>s(()=>R.getState().toggleTheme()),children:[f.jsx(b1,{size:15,className:"text-ink-3"}),"Switch theme"]}),f.jsxs(et.Item,{className:o,value:"Keyboard shortcuts help",onSelect:()=>s(()=>R.getState().setShortcutsOpen(!0)),children:[f.jsx(Y_,{size:15,className:"text-ink-3"}),"Keyboard shortcuts"]})]})]})]})})}function x7(t,e){const n=e.toLowerCase().split(/\s+/).filter(Boolean);if(!n.length)return 1;const r=t.toLowerCase(),s=r.split(/[^\p{L}\p{N}]+/u).filter(Boolean);let i=0;for(const o of n){const a=s.findIndex(l=>l.startsWith(o));if(a>=0)i+=a===0?1:a<4?.8:.6;else if(r.includes(o))i+=.3;else return 0}return i/n.length}const v7=[{label:"Sequence",text:`sequenceDiagram
746
+ title Password reset
747
+ actor User
748
+ participant Web as Web app
749
+ participant Auth as Auth service
750
+ participant Mail as Email provider
751
+ User->>Web: Ask for a reset link
752
+ Web->>Auth: RequestReset(email)
753
+ alt account exists
754
+ Auth->>Mail: Send reset email
755
+ Mail-->>Auth: Accepted
756
+ else no account
757
+ Auth->>Auth: Wait, to hide the difference
758
+ end
759
+ Auth-->>Web: 202 Accepted
760
+ Web-->>User: Check your inbox`},{label:"Flowchart",text:`flowchart TD
761
+ title Deploy pipeline
762
+ subgraph CI
763
+ A([Push to main]) --> B[Run tests]
764
+ B --> C{Tests pass?}
765
+ end
766
+ subgraph Release
767
+ C -->|Yes| D[Build image]
768
+ D --> E[Deploy to staging]
769
+ E --> F{Smoke tests pass?}
770
+ F -->|Yes| G[Promote to production]
771
+ G --> H([Done])
772
+ end
773
+ C -->|No| I[Notify author]
774
+ F -->|No| J[Roll back]
775
+ J --> I`},{label:"State",text:`stateDiagram-v2
776
+ title Support ticket
777
+ [*] --> Open
778
+ Open --> InProgress : Agent picks up
779
+ InProgress --> Waiting : Needs customer [question asked] / pause SLA
780
+ Waiting --> InProgress : Customer replies / resume SLA
781
+ InProgress --> Resolved : Fix shipped
782
+ Resolved --> Open : Customer reopens [within 7 days]
783
+ Resolved --> [*]`},{label:"ER",text:`erDiagram
784
+ CUSTOMER ||--o{ INVOICE : receives
785
+ INVOICE ||--|{ LINE_ITEM : contains
786
+ PRODUCT ||--o{ LINE_ITEM : "is billed as"
787
+ CUSTOMER {
788
+ uuid id PK
789
+ string email UK
790
+ string name
791
+ }
792
+ INVOICE {
793
+ uuid id PK
794
+ uuid customer_id FK
795
+ date issued_on
796
+ int total_cents
797
+ }
798
+ LINE_ITEM {
799
+ uuid id PK
800
+ uuid invoice_id FK
801
+ uuid product_id FK
802
+ int quantity
803
+ }
804
+ PRODUCT {
805
+ uuid id PK
806
+ string sku UK
807
+ int price_cents
808
+ }`}];function VT(){const t=R(c=>c.importOpen),e=R(c=>c.importText),n=R(c=>c.setImportOpen),[r,s]=b.useState(""),i=b.useRef(null);b.useEffect(()=>{t&&s(e)},[t,e]);const o=Hp(r),a=b.useMemo(()=>r.trim()?G1(r):null,[r]),l=async c=>s(await c.text());return f.jsx(Go,{open:t,onOpenChange:c=>n(c),title:"Open a model",description:"Paste or drop a Poney document, or a Mermaid sequence, flowchart, state or ER diagram. Mermaid is converted to a Poney model.",width:720,children:f.jsxs("div",{className:"flex min-h-0 flex-col gap-3 p-5",onDragOver:c=>c.preventDefault(),onDrop:c=>{c.preventDefault();const d=c.dataTransfer.files[0];d&&l(d)},children:[f.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[f.jsx("span",{className:"text-[12px] text-ink-3",children:"Try a Mermaid example:"}),v7.map(c=>f.jsx("button",{type:"button",className:"rounded-md border border-rule px-2 py-1 text-[12px] text-ink-2 hover:border-rule-strong hover:text-ink",onClick:()=>s(c.text),children:c.label},c.label)),f.jsx("span",{className:"flex-1"}),f.jsxs("button",{type:"button",className:"flex items-center gap-1.5 rounded-md border border-rule px-2 py-1 text-[12px] text-ink-2 hover:border-rule-strong hover:text-ink",onClick:()=>{var c;return(c=i.current)==null?void 0:c.click()},children:[f.jsx(ID,{size:13})," Choose a file"]}),f.jsx("input",{ref:i,type:"file",accept:".poney,.json,.mmd,.mermaid,.txt,application/json",className:"hidden",onChange:c=>{var d;return((d=c.target.files)==null?void 0:d[0])&&void l(c.target.files[0])}})]}),f.jsx("label",{className:"sr-only",htmlFor:"import-text",children:"Model text"}),f.jsx("textarea",{id:"import-text",value:r,onChange:c=>s(c.target.value),spellCheck:!1,placeholder:`{ "poneyVersion": "0.1.0", … }
809
+
810
+ or
811
+
812
+ sequenceDiagram
813
+ Alice->>Bob: Hello`,className:"scrollbar-quiet h-[300px] w-full resize-none rounded-xl border border-rule bg-plaster p-3 font-mono text-[12px] leading-relaxed outline-none focus:border-rule-strong"}),f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsxs("div",{className:"min-w-0 flex-1 text-[12.5px]","aria-live":"polite",children:[(a==null?void 0:a.ok)&&f.jsxs("p",{className:"flex items-center gap-1.5 text-[color:var(--success)]",children:[f.jsx(w_,{size:14})," ",o.label,": “",a.doc.project.name,"”, ",a.doc.views.length," view",a.doc.views.length>1?"s":"","."]}),a&&!a.ok&&f.jsxs("div",{className:"text-[color:var(--failure)]",children:[f.jsxs("p",{className:"flex items-center gap-1.5 font-semibold",children:[f.jsx(Ld,{size:14})," ",o.label,". It cannot be opened yet:"]}),f.jsx("ul",{className:"mt-1 max-h-24 list-disc overflow-y-auto pl-5 text-ink-2",children:a.issues.slice(0,8).map((c,d)=>f.jsxs("li",{children:[c.path&&f.jsx("code",{className:"font-mono text-[11.5px]",children:c.path})," ",c.message]},d))})]}),!a&&f.jsxs("p",{className:"text-ink-3",children:[o.label,"."]})]}),f.jsx("button",{type:"button",disabled:!(a!=null&&a.ok),onClick:()=>JM(r,"imported"),className:"h-9 shrink-0 rounded-lg bg-ink px-4 font-semibold text-paper transition-opacity hover:opacity-90 disabled:opacity-30",children:"Open model"})]})]})})}const k7=[{title:"Find and move",keys:[["⌘K or /","Search this document"],["⌘Z ⇧⌘Z","Undo and redo a change"],["⌥← ⌥→","Back and forward"],["O","Project overview"],["[ ]","Show or hide the sidebar and the inspector"]]},{title:"Canvas",keys:[["Tab","Move between elements"],["Enter","Select the focused element"],["Double-click","Rename a part, a line, a message, a state or a step"],["F","Zoom to the selection"],["Esc","Clear the selection"],["+ −","Zoom in and out"],["⇧1 ⇧0","Fit the diagram, or 100%"],["Arrows","Pan, when the canvas has focus"],["Scroll · ⌘ + scroll","Pan · zoom at the pointer"]]},{title:"Model",keys:[["⇧⌘C","Copy the model as Poney JSON"],["⌘V","Open pasted Poney JSON or Mermaid"]]}];function w7(){const t=R(n=>n.shortcutsOpen),e=R(n=>n.setShortcutsOpen);return f.jsx(Go,{open:t,onOpenChange:e,title:"Keyboard shortcuts",width:520,children:f.jsx("div",{className:"scrollbar-quiet overflow-y-auto px-5 py-4",children:k7.map(n=>f.jsxs("section",{className:"mb-4 last:mb-0",children:[f.jsx("h3",{className:"mb-1.5 text-[12px] font-semibold text-ink-3",children:n.title}),f.jsx("dl",{className:"divide-y divide-rule",children:n.keys.map(([r,s])=>f.jsxs("div",{className:"flex items-center justify-between gap-4 py-1.5",children:[f.jsx("dt",{className:"text-ink-2",children:s}),f.jsx("dd",{className:"shrink-0 rounded-md bg-sunken px-1.5 py-0.5 text-[12px] text-ink",children:r})]},r))})]},n.title))})})}function b7(){const t=R(n=>n.notice),e=R(n=>n.notify);return b.useEffect(()=>{if(!t)return;const n=setTimeout(()=>e(null),4200);return()=>clearTimeout(n)},[t,e]),f.jsx("div",{role:"status","aria-live":"polite",className:"pointer-events-none fixed bottom-20 left-1/2 z-50 -translate-x-1/2",children:t&&f.jsxs("div",{className:"fade-in pointer-events-auto flex max-w-[520px] items-center gap-3 rounded-xl bg-ink px-4 py-2.5 text-[13px] text-paper shadow-float",children:[f.jsx("span",{children:t}),f.jsx("button",{type:"button","aria-label":"Dismiss",className:"text-paper/60 hover:text-paper",onClick:()=>e(null),children:f.jsx(Jo,{size:14})})]})})}const WT=()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches;function S7({frame:t,label:e,children:n,pad:r=56,maxScale:s=1.25}){var _;const i=b.useRef(null),[o,a]=b.useState({w:0,h:0}),[l,c]=b.useState(null),[d,u]=b.useState(!1),h=b.useRef(null),m=b.useRef(0),g=b.useRef(null);b.useLayoutEffect(()=>{const S=i.current;if(!S)return;const j=new ResizeObserver(([$])=>a({w:$.contentRect.width,h:$.contentRect.height}));return j.observe(S),()=>j.disconnect()},[]);const p=b.useMemo(()=>o.w&&o.h?JD(t,o.w,o.h,r,s):null,[t,o,r,s]),x=b.useCallback(S=>{h.current=S,c(S)},[]),y=b.useCallback(S=>{cancelAnimationFrame(m.current);const j=h.current;if(!j||WT())return x(S);const $=performance.now(),I=700,L=D=>{const B=Math.min(1,(D-$)/I),H=B<.5?4*B*B*B:1-Math.pow(-2*B+2,3)/2;x({x:j.x+(S.x-j.x)*H,y:j.y+(S.y-j.y)*H,w:j.w+(S.w-j.w)*H,h:j.h+(S.h-j.h)*H}),B<1&&(m.current=requestAnimationFrame(L))};m.current=requestAnimationFrame(L)},[x]);b.useEffect(()=>{if(p)return u(!1),y(p),()=>cancelAnimationFrame(m.current)},[p,y]);const v=b.useCallback((S,j=.5,$=.5)=>{const I=h.current;!I||!p||(cancelAnimationFrame(m.current),x(GD(I,p,S,j,$)),u(!0))},[p,x]);b.useEffect(()=>{const S=i.current;if(!S)return;const j=I=>{if(!(I.ctrlKey||I.metaKey))return;I.preventDefault();const L=S.getBoundingClientRect();v(Math.exp(-Math.max(-24,Math.min(24,I.deltaY))*.012),(I.clientX-L.left)/L.width,(I.clientY-L.top)/L.height)},$=I=>I.preventDefault();return S.addEventListener("wheel",j,{passive:!1}),S.addEventListener("gesturestart",$),S.addEventListener("gesturechange",$),()=>{S.removeEventListener("wheel",j),S.removeEventListener("gesturestart",$),S.removeEventListener("gesturechange",$)}},[v]);const k=S=>{S.button===0&&(g.current={x:S.clientX,y:S.clientY,id:S.pointerId,moved:!1})},w=S=>{const j=g.current,$=h.current;if(!j||!$||!i.current)return;const I=S.clientX-j.x,L=S.clientY-j.y;if(!j.moved&&Math.hypot(I,L)<4)return;if(!j.moved)try{i.current.setPointerCapture(j.id)}catch{}j.moved=!0,j.x=S.clientX,j.y=S.clientY;const D=i.current.getBoundingClientRect();cancelAnimationFrame(m.current),x(YD($,I,L,D.width,D.height)),u(!0)},C=()=>{var S;if((S=g.current)!=null&&S.moved){const j=$=>{$.stopPropagation(),$.preventDefault()};window.addEventListener("click",j,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener("click",j,{capture:!0}),0)}g.current=null},E=l&&o.w?o.w/l.w:1;return f.jsxs("div",{ref:i,className:`relative h-full w-full touch-none select-none ${(_=g.current)!=null&&_.moved?"cursor-grabbing":"cursor-grab"}`,onPointerDown:k,onPointerMove:w,onPointerUp:C,onPointerCancel:()=>g.current=null,onKeyDown:S=>{S.key!=="Tab"||S.altKey||S.metaKey||S.ctrlKey||!S.target.closest("[data-ref]")||pT(S.currentTarget,S.target,S.shiftKey)&&S.preventDefault()},onDoubleClick:S=>{if(S.target.closest("[data-ref]"))return;const j=i.current.getBoundingClientRect();v(1.6,(S.clientX-j.left)/j.width,(S.clientY-j.top)/j.height)},children:[l&&f.jsx("svg",{className:"absolute inset-0 h-full w-full",viewBox:`${l.x} ${l.y} ${l.w} ${l.h}`,role:"img","aria-label":e,children:n}),f.jsxs("div",{className:"absolute bottom-3 right-3 flex items-center gap-0.5 rounded-lg border border-rule bg-raised/95 p-0.5 shadow-float backdrop-blur",onPointerDown:S=>S.stopPropagation(),children:[f.jsx("button",{type:"button","aria-label":"Zoom out",title:"Zoom out",onClick:()=>v(1/1.3),className:"grid h-7 w-7 place-items-center rounded-md text-ink-2 hover:bg-sunken",children:f.jsx(hj,{size:14})}),f.jsxs("span",{className:"font-tabular w-11 text-center text-[11.5px] text-ink-3",children:[Math.round(E*100),"%"]}),f.jsx("button",{type:"button","aria-label":"Zoom in",title:"Zoom in (or pinch)",onClick:()=>v(1.3),className:"grid h-7 w-7 place-items-center rounded-md text-ink-2 hover:bg-sunken",children:f.jsx(S1,{size:14})}),d&&f.jsx("button",{type:"button",onClick:()=>p?(u(!1),y(p)):void 0,className:"h-7 rounded-md px-2 text-[12px] font-medium text-ink-2 hover:bg-sunken",children:"Reset view"}),f.jsx(mT,{className:"h-7 w-7"})]})]})}const c2=new WeakMap;function C7(t,e){const n=O1(),r=`${t.id}|${JSON.stringify(e)}`,[s,i]=b.useState(null);return b.useEffect(()=>{let o=!0,a=c2.get(n);a||c2.set(n,a=new Map);let l=a.get(r);return l||(l=document.fonts.ready.then(()=>XE(n,t,e)),a.set(r,l)),l.then(c=>o&&i({key:r,scene:c})),()=>{o=!1}},[n,r]),(s==null?void 0:s.key)===r?s.scene:s==null?void 0:s.scene}function Mu({view:t,walkthrough:e,marks:n,mode:r,focus:s,callouts:i,hot:o,setHot:a,maxScale:l,sceneData:c,traceStep:d=null}){var E;const[u,h]=b.useState(void 0);b.useEffect(()=>h(void 0),[t]);const m=b.useCallback(_=>h(S=>{const j=S??(t.type==="map"?t.collapsed:[]);return j.includes(_)?j.filter($=>$!==_):[...j,_]}),[t]),g=b.useMemo(()=>({...HD(t,e,s),...u?{collapsed:u}:{}}),[t,e,s,u]),p=C7(t,g),x=Be(),y=b.useMemo(()=>p?KD(p,t,s,x,e):null,[p,t,s,x,e]),v=d!==null?(E=c==null?void 0:c.trace[d])==null?void 0:E.ref:void 0,k=b.useMemo(()=>p&&y?XD(p,y,v,x,e):y,[p,y,v,x,e]),w=hT(),C=b.useMemo(()=>({...QD({marks:n,mode:r,view:t,focus:s,callouts:i,hot:o,setHot:a,idx:x,walkthrough:e,effects:[...(c==null?void 0:c.effects)??[],...w.effects],badges:[...(c==null?void 0:c.badges)??[],...w.badges],trace:c==null?void 0:c.trace,traceStep:d,animate:!WT()}),...t.type==="map"?{toggleGroup:m}:{}}),[n,r,t,s,i,o,a,x,e,m,c,d,w]);return!p||!k?f.jsx("div",{className:"grid h-full place-items-center text-ink-3",children:"Drawing…"}):f.jsx(x$,{value:C,children:f.jsx("div",{className:"h-full",onContextMenu:fT(t.id),children:f.jsx(S7,{frame:k,label:t.title,maxScale:l,children:t.type==="map"||t.type==="sequence"||t.type==="state"?f.jsx(BL,{view:t,scene:p,extra:e==null?void 0:e.removed.entities}):f.jsx(N7,{view:t,scene:p})})})})}function N7({view:t,scene:e}){const n=rs(t);if(!n)return null;const r=n.Renderer;return f.jsx(r,{view:t,scene:e})}let d2;const hg=new Map,E7={ex:"elixir",exs:"elixir",heex:"html",eex:"html",leex:"html",rb:"ruby",rake:"ruby",gemspec:"ruby",ru:"ruby",erb:"erb",js:"javascript",mjs:"javascript",cjs:"javascript",jsx:"jsx",ts:"typescript",mts:"typescript",cts:"typescript",tsx:"tsx",py:"python",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",php:"php",cs:"csharp",c:"c",h:"c",cc:"cpp",cpp:"cpp",hpp:"cpp",scala:"scala",clj:"clojure",erl:"erlang",hs:"haskell",sql:"sql",graphql:"graphql",gql:"graphql",proto:"proto",json:"json",jsonc:"jsonc",yml:"yaml",yaml:"yaml",toml:"toml",xml:"xml",html:"html",css:"css",scss:"scss",md:"markdown",sh:"shellscript",bash:"shellscript",zsh:"shellscript",vue:"vue",svelte:"svelte",tf:"hcl"},_7={Gemfile:"ruby",Rakefile:"ruby",Dockerfile:"docker",Makefile:"make","mix.lock":"elixir"};function j7(t){const e=t.split("/").pop()??t;return _7[e]??E7[e.includes(".")?e.split(".").pop().toLowerCase():""]}async function $7(t){d2??(d2=p1(()=>import("./dist-CGLReTF9.js"),[]).then(n=>n.createHighlighter({themes:["github-light","github-dark"],langs:[]})));const e=await d2;return hg.has(t)||hg.set(t,e.loadLanguage(t).then(()=>!0,()=>!1)),await hg.get(t)?e:void 0}function M7(t,e,n){return t.codeToTokens(n.join(`
814
+ `),{lang:e,themes:{light:"github-light",dark:"github-dark"},defaultColor:!1}).tokens.map(r=>r.map(s=>({content:s.content,style:s.htmlStyle})))}function T7(t){const[e,n]=b.useState(),r=j7(t.path);return b.useEffect(()=>{if(n(void 0),!r)return;let s=!0;return $7(r).then(i=>{if(!i||!s)return;const o=new Map;t.hunks.forEach((a,l)=>{for(const c of["new","old"]){const d=a.lines.map((h,m)=>({l:h,li:m})).filter(({l:h})=>c==="new"?h.kind!=="del":h.kind!=="add"),u=M7(i,r,d.map(({l:h})=>h.text));d.forEach(({l:h,li:m},g)=>{(c==="new"||h.kind==="del")&&o.set(`${l}:${m}`,u[g]??[])})}}),n(o)}),()=>{s=!1}},[t,r]),e}var UT={exports:{}},ZT={};/**
815
+ * @license React
816
+ * use-sync-external-store-shim.production.js
817
+ *
818
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
819
+ *
820
+ * This source code is licensed under the MIT license found in the
821
+ * LICENSE file in the root directory of this source tree.
822
+ */var hl=b;function O7(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var A7=typeof Object.is=="function"?Object.is:O7,R7=hl.useState,I7=hl.useEffect,P7=hl.useLayoutEffect,D7=hl.useDebugValue;function z7(t,e){var n=e(),r=R7({inst:{value:n,getSnapshot:e}}),s=r[0].inst,i=r[1];return P7(function(){s.value=n,s.getSnapshot=e,pg(s)&&i({inst:s})},[t,n,e]),I7(function(){return pg(s)&&i({inst:s}),t(function(){pg(s)&&i({inst:s})})},[t]),D7(n),n}function pg(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!A7(t,n)}catch{return!0}}function L7(t,e){return e()}var F7=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?L7:z7;ZT.useSyncExternalStore=hl.useSyncExternalStore!==void 0?hl.useSyncExternalStore:F7;UT.exports=ZT;var a0=UT.exports;function Qt(t){this.content=t}Qt.prototype={constructor:Qt,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),i=r.content.slice();return s==-1?i.push(n||t,e):(i[s+1]=e,n&&(i[s]=n)),new Qt(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Qt(n)},addToStart:function(t,e){return new Qt([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Qt(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),i=r.find(t);return s.splice(i==-1?s.length:i,0,e,n),new Qt(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Qt.from(t),t.size?new Qt(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Qt.from(t),t.size?new Qt(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Qt.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Qt.from=function(t){if(t instanceof Qt)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Qt(e)};function HT(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){let o=s.text,a=i.text,l=0;for(;o[l]==a[l];l++)n++;return l&&l<o.length&&l<a.length&&JT(o.charCodeAt(l-1))&&KT(o.charCodeAt(l))&&n--,n}if(s.content.size||i.content.size){let o=HT(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function qT(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),a=e.child(--i),l=o.nodeSize;if(o==a){n-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let c=o.text,d=a.text,u=c.length,h=d.length;for(;u>0&&h>0&&c[u-1]==d[h-1];)u--,h--,n--,r--;return u&&h&&u<c.length&&JT(c.charCodeAt(u-1))&&KT(c.charCodeAt(u))&&(n++,r++),{a:n,b:r}}if(o.content.size||a.content.size){let c=qT(o.content,a.content,n-1,r-1);if(c)return c}n-=l,r-=l}}function KT(t){return t>=56320&&t<57344}function JT(t){return t>=55296&&t<56320}class Y{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,a=0;a<n;o++){let l=this.content[o],c=a+l.nodeSize;if(c>e&&r(l,s+a,i||null,o)!==!1&&l.content.size){let d=a+1;l.nodesBetween(Math.max(0,e-d),Math.min(l.content.size,n-d),r,s+d)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,n-l):a.isLeaf?s?typeof s=="function"?s(a):s:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new Y(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let a=this.content[i],l=o+a.nodeSize;l>e&&((o<e||l>n)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,n-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,n-o-1))),r.push(a),s+=a.nodeSize),o=l}return new Y(r,s)}cutByIndex(e,n){return e==n?Y.empty:e==0&&n==this.content.length?this:new Y(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new Y(s,i)}addToStart(e){return new Y([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Y(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return HT(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return qT(this,e,n,r)}findIndex(e){if(e==0)return Tu(0,e);if(e==this.size)return Tu(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?Tu(n+1,i):Tu(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return Y.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return Y.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Y.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new Y(n||e,r)}static from(e){if(!e)return Y.empty;if(e instanceof Y)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Y([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Y.empty=new Y([],0);const mg={index:0,offset:0};function Tu(t,e){return mg.index=t,mg.offset=e,mg}function wh(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!wh(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!wh(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Xe=class Bx{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&wh(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);return r.create(n.attrs)}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Bx.none;if(e instanceof Bx)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};Xe.none=[];class pd extends Error{}class ue{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=YT(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new ue(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ue(GT(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ue.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ue(Y.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new ue(e,r,s)}}ue.empty=new ue(Y.empty,0,0);function GT(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:a}=t.findIndex(n);if(s==e||i.isText){if(a!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(GT(i.content,e-s-1,n-s-1)))}function YT(t,e,n,r,s,i){let{index:o,offset:a}=t.findIndex(e),l=t.maybeChild(o);if(a==e||l.isText)return i&&r<=0&&s<=0&&!i.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=YT(l.content,e-a-1,n,o==0?r-1:0,o==t.childCount-1?s-1:0,l);return c&&t.replaceChild(o,l.copy(c))}function B7(t,e,n){if(n.openStart>t.depth)throw new pd("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new pd("Inconsistent open depths");return QT(t,e,n,0)}function QT(t,e,n,r){let s=t.index(r),i=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let o=QT(t,e,n,r+1);return i.copy(i.content.replaceChild(s,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,a=o.content;return ko(o,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:o,end:a}=V7(n,t);return ko(i,e4(t,o,a,e,r))}else return ko(i,bh(t,e,r))}function XT(t,e){if(!e.type.compatibleContent(t.type))throw new pd("Cannot join "+e.type.name+" onto "+t.type.name)}function Vx(t,e,n){let r=t.node(n);return XT(r,e.node(n)),r}function vo(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function jc(t,e,n,r){let s=(e||t).node(n),i=0,o=e?e.index(n):s.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(vo(t.nodeAfter,r),i++));for(let a=i;a<o;a++)vo(s.child(a),r);e&&e.depth==n&&e.textOffset&&vo(e.nodeBefore,r)}function ko(t,e){if(!t.type.validContent(e))throw new pd("Invalid content for node "+t.type.name);return t.copy(e)}function e4(t,e,n,r,s){let i=t.depth>s&&Vx(t,e,s+1),o=r.depth>s&&Vx(n,r,s+1),a=[];return jc(null,t,s,a),i&&o&&e.index(s)==n.index(s)?(XT(i,o),vo(ko(i,e4(t,e,n,r,s+1)),a)):(i&&vo(ko(i,bh(t,e,s+1)),a),jc(e,n,s,a),o&&vo(ko(o,bh(n,r,s+1)),a)),jc(r,null,s,a),new Y(a)}function bh(t,e,n){let r=[];if(jc(null,t,n,r),t.depth>n){let s=Vx(t,e,n+1);vo(ko(s,bh(t,e,n+1)),r)}return jc(e,null,n,r),new Y(r)}function V7(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)s=e.node(i).copy(Y.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class md{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Xe.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let a=r;r=s,s=a}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Sh(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,i=n;for(let o=e;;){let{index:a,offset:l}=o.content.findIndex(i),c=i-l;if(r.push(o,a,s+l),!c||(o=o.child(a),o.isText))break;i=c-1,s+=l+1}return new md(n,r,i)}static resolveCached(e,n){let r=u2.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==n)return o}else u2.set(e,r=new W7);let s=r.elts[r.i]=md.resolve(e,n);return r.i=(r.i+1)%U7,s}}class W7{constructor(){this.elts=[],this.i=0}}const U7=12,u2=new WeakMap;class Sh{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Z7=Object.create(null);let _i=class Wx{constructor(e,n,r,s=Xe.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||Y.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,s=0){this.content.nodesBetween(e,n,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,s){return this.content.textBetween(e,n,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&wh(this.attrs,n||e.defaultAttrs||Z7)&&Xe.sameSet(this.marks,r||Xe.none)}copy(e=null){return e==this.content?this:new Wx(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Wx(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return ue.empty;let s=this.resolve(e),i=this.resolve(n),o=r?0:s.sharedDepth(n),a=s.start(o),c=s.node(o).content.cut(s.pos-a,i.pos-a);return new ue(c,s.depth-o,i.depth-o)}replace(e,n,r){return B7(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return md.resolveCached(this,e)}resolveNoCache(e){return md.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),t4(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=Y.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),a=o&&o.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let l=s;l<i;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),h2(this.type.attrs,this.attrs,"node",this.type.name);let e=Xe.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];h2(r.type.attrs,r.attrs,"mark",r.type.name),e=r.addToSet(e)}if(!Xe.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=Y.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,s,r)}};_i.prototype.text=void 0;const f2=(()=>{let{stack:t}=new Error("/");if(!t||!/\n\s*at\s/.test(t))return n=>n;let e=Object.create(null);return n=>(e[n],n)})();class Ch extends _i{constructor(e,n,r,s){if(super(e,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):t4(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return f2(this.text.slice(e,n))}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Ch(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Ch(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(f2(this.text.slice(e,n)))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function t4(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}function h2(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${r}`);for(let s in t)t[s].validate&&t[s].validate(e[s])}class Vo{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new H7(e,n);if(r.next==null)return Vo.empty;let s=n4(r);r.next&&r.err("Unexpected trailing text");let i=X7(Q7(s));return eW(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let i=n;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function i(o,a){let l=o.matchFragment(e,r);if(l&&(!n||l.validEnd))return Y.from(a.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:d,next:u}=o.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(u)==-1){s.push(u);let h=i(u,a.concat(d));if(h)return h}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let a=s;a.type;a=a.via)o.push(a.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:a,next:l}=i.next[o];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in n)&&(!s.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:s}),n[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
823
+ `)}}Vo.empty=new Vo(!0);class H7{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function n4(t){let e=[];do e.push(q7(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function q7(t){let e=[];do e.push(K7(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function K7(t){let e=Y7(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=J7(t,e);else break;return e}function p2(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function J7(t,e){let n=p2(t),r=n;return t.eat(",")&&(t.next!="}"?r=p2(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function G7(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let i in n){let o=n[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function Y7(t){if(t.eat("(")){let e=n4(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=G7(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Q7(t){let e=[[]];return s(i(t,0),n()),e;function n(){return e.push([])-1}function r(o,a,l){let c={term:l,to:a};return e[o].push(c),c}function s(o,a){o.forEach(l=>l.to=a)}function i(o,a){if(o.type=="choice")return o.exprs.reduce((l,c)=>l.concat(i(c,a)),[]);if(o.type=="seq")for(let l=0;;l++){let c=i(o.exprs[l],a);if(l==o.exprs.length-1)return c;s(c,a=n())}else if(o.type=="star"){let l=n();return r(a,l),s(i(o.expr,l),l),[r(l)]}else if(o.type=="plus"){let l=n();return s(i(o.expr,a),l),s(i(o.expr,l),l),[r(l)]}else{if(o.type=="opt")return[r(a)].concat(i(o.expr,a));if(o.type=="range"){let l=a;for(let c=0;c<o.min;c++){let d=n();s(i(o.expr,l),d),l=d}if(o.max==-1)s(i(o.expr,l),l);else for(let c=o.min;c<o.max;c++){let d=n();r(l,d),s(i(o.expr,l),d),l=d}return[r(l)]}else{if(o.type=="name")return[r(a,void 0,o.value)];throw new Error("Unknown expr type")}}}}function r4(t,e){return e-t}function m2(t,e){let n=[];return r(e),n.sort(r4);function r(s){let i=t[s];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(s);for(let o=0;o<i.length;o++){let{term:a,to:l}=i[o];!a&&n.indexOf(l)==-1&&r(l)}}}function X7(t){let e=Object.create(null);return n(m2(t,0));function n(r){let s=[];r.forEach(o=>{t[o].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let d=0;d<s.length;d++)s[d][0]==a&&(c=s[d][1]);m2(t,l).forEach(d=>{c||s.push([a,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[r.join(",")]=new Vo(r.indexOf(t.length-1)>-1);for(let o=0;o<s.length;o++){let a=s[o][1].sort(r4);i.next.push({type:s[o][0],next:e[a.join(",")]||n(a)})}return i}}function eW(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],i=!s.validEnd,o=[];for(let a=0;a<s.next.length;a++){let{type:l,next:c}=s.next[a];o.push(l.name),i&&!(l.isText||l.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function s4(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function i4(t,e){let n=Object.create(null);for(let r in t){let s=t[r],i=e&&e[r];if(i===void 0)if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r);else s.validate&&s.validate(i);n[r]=i}return n}function o4(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new nW(t,r,e[r]);return n}let Ux=class a4{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=o4(e,r.attrs),this.defaultAttrs=s4(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Vo.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:i4(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new _i(this,this.computeAttrs(e),Y.from(n),Xe.setFrom(r))}createChecked(e=null,n,r){return n=Y.from(n),this.checkContent(n),new _i(this,this.computeAttrs(e),n,Xe.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=Y.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let s=this.contentMatch.matchFragment(n),i=s&&s.fillBefore(Y.empty,!0);return i?new _i(this,e,n.append(i),Xe.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:Xe.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,o)=>r[i]=new a4(i,n,o));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function tW(t,e,n){let r=n.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class nW{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?tW(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Yp{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=o4(e,s.attrs),this.excluded=null;let i=s4(this.attrs);this.instance=i?new Xe(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Xe(this,i4(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new Yp(i,s++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}excludes(e){return this.excluded.indexOf(e)>-1}}class l4{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=Qt.from(e.nodes),n.marks=Qt.from(e.marks||{}),this.nodes=Ux.compile(this.spec.nodes,this),this.marks=Yp.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",a=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=Vo.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=a=="_"?null:a?g2(this,a.split(" ")):a==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:g2(this,o.split(" "))}this.nodeFromJSON=s=>_i.fromJSON(this,s),this.markFromJSON=s=>Xe.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Ux){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,s)}text(e,n){let r=this.nodes.text;return new Ch(r,r.defaultAttrs,e,Xe.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function g2(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],i=t.marks[s],o=i;if(i)n.push(i);else for(let a in t.marks){let l=t.marks[a];(s=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=l)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function rW(t){return t.tag!=null}function sW(t){return t.style!=null}class ji{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(rW(s))this.tags.push(s);else if(sW(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new x2(this,n,!1);return r.addAll(e,Xe.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new x2(this,n,!0);return r.addAll(e,Xe.none,n.from,n.to),ue.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(aW(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],a=o.style;if(!(a.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=n))){if(o.getAttrs){let l=o.getAttrs(n);if(l===!1)continue;o.attrs=l||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let a=n[o];if((a.priority==null?50:a.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=v2(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=v2(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new ji(e,ji.schemaRules(e)))}}const c4={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},iW={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},d4={ol:!0,ul:!0},gd=1,Zx=2,$c=4;function y2(t,e,n){return e!=null?(e?gd:0)|(e==="full"?Zx:0):t&&t.whitespace=="pre"?gd|Zx:n&~$c}class Ou{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=Xe.none,this.match=i||(o&$c?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Y.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&gd)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=Y.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Y.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!c4.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class x2{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=y2(null,n.preserveWhitespace,0)|(r?$c:0);s?i=new Ou(s.type,s.attrs,Xe.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new Ou(null,null,Xe.none,!0,null,o):i=new Ou(e.schema.topNodeType,null,Xe.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&Zx?"full":this.localPreserveWS||(s.options&gd)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
824
+ `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(o.linebreakReplacement.create(),n,!0),a[l]&&this.insertNode(o.text(a[l]),n,!/\S/.test(a[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let a=s.content[s.content.length-1],l=e.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),a;d4.hasOwnProperty(o)&&this.parser.normalizeLists&&oW(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:iW.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,d=this.needsBlock;if(c4.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let u=l&&l.skip?n:this.readStyles(e,n);u&&this.addAll(e,u),c&&this.sync(i),this.needsBlock=d}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
825
+ `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let a=void 0;;){let l=this.parser.matchStyle(i,o,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(c=>!l.clearMark(c)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return n}addElementByRule(e,n,r,s){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(o,n.attrs||null,r,n.preserveWhitespace);l&&(i=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let a=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}i&&this.sync(a)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,a=s==null?null:e.childNodes[s];o!=a;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,a=0;o>=0;o--){let l=this.nodes[o],c=l.findWrapping(e);if(c&&(!s||s.length>c.length+a)&&(s=c,i=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=Xe.none;for(let a of s.concat(e.marks))(i.type?i.type.allowsMarkType(a.type):k2(a.type,e.type))&&(o=a.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let a=y2(e,i,o.options);o.options&$c&&o.content.length==0&&(a|=$c);let l=Xe.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):k2(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new Ou(e,n,l,s,null,a)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=gd)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(a,l)=>{for(;a>=0;a--){let c=n[a];if(c==""){if(a==n.length-1||a==0)continue;for(;l>=i;l--)if(o(a-1,l))return!0;return!1}else{let d=l>0||l==0&&s?this.nodes[l].type:r&&l>=i?r.node(l-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;l--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function oW(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&d4.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function aW(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function v2(t){let e={};for(let n in t)e[n]=t[n];return e}function k2(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=a=>{i.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:d}=a.edge(l);if(c==e||i.indexOf(d)<0&&o(d))return!0}};if(o(s.contentMatch))return!0}}class Yo{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Au(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let a=0,l=0;for(;a<i.length&&l<o.marks.length;){let c=o.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(i[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<i.length;)s=i.pop()[1];for(;l<o.marks.length;){let c=o.marks[l++],d=this.serializeMark(c,o.isInline,n);d&&(i.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){if(e.isText)return Au(n).createTextNode(e.text);let{dom:r,contentDOM:s}=df(Au(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&df(Au(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return typeof n=="string"?{dom:e.createTextNode(n)}:df(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Yo(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=w2(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return w2(e.marks)}}function w2(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Au(t){return t.document||window.document}const b2=new WeakMap;function lW(t){let e=b2.get(t);return e===void 0&&b2.set(t,e=cW(t)),e}function cW(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function df(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=lW(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let a,l=n?t.createElementNS(n,s):t.createElement(s),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let h=u.indexOf(" ");h>0?l.setAttributeNS(u.slice(0,h),u.slice(h+1),c[u]):u=="style"&&l.style?l.style.cssText=c[u]:l.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let h=e[u];if(h===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else if(typeof h=="string")l.appendChild(t.createTextNode(h));else{let{dom:m,contentDOM:g}=df(t,h,n,r);if(l.appendChild(m),g){if(a)throw new RangeError("Multiple content holes");a=g}}}return{dom:l,contentDOM:a}}const u4=65535,f4=Math.pow(2,16);function dW(t,e){return t+e*f4}function S2(t){return t&u4}function uW(t){return(t-(t&u4))/f4}const h4=1,p4=2,uf=4,m4=8;class Hx{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&m4)>0}get deletedBefore(){return(this.delInfo&(h4|uf))>0}get deletedAfter(){return(this.delInfo&(p4|uf))>0}get deletedAcross(){return(this.delInfo&uf)>0}}class Zn{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Zn.empty)return Zn.empty}recover(e){let n=0,r=S2(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+uW(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?s:0);if(l>e)break;let c=this.ranges[a+i],d=this.ranges[a+o],u=l+c;if(e<=u){let h=c?e==l?-1:e==u?1:n:n,m=l+s+(h<0?0:d);if(r)return m;let g=e==(n<0?l:u)?null:dW(a/3,e-l),p=0;return c&&(p|=e==l?p4:e==u?h4:uf,(n<0?e!=l:e!=u)&&(p|=m4)),new Hx(m,p,g)}s+=d-c}return r?e+s:new Hx(e+s,0,null)}touches(e,n){let r=0,s=S2(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[a+i],d=l+c;if(e<=d&&a==s*3)return!0;r+=this.ranges[a+o]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],a=o-(this.inverted?i:0),l=o+(this.inverted?0:i),c=this.ranges[s+n],d=this.ranges[s+r];e(a,a+c,l,l+d),i+=d-c}}invert(){return new Zn(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Zn.empty:new Zn(e<0?[0,-e,0]:[0,0,e])}}Zn.empty=new Zn([]);class Nh{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Nh(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=e.from,r=this._maps.length;n<e.to;n++){let s=e.getMirror(n);s!=null&&(s=s<n&&s>=e.from?r+(s-e.from):void 0),this.appendMap(e._maps[n],s)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.to-1,r=this._maps.length+e._maps.length;n>=e.from;n--){let s=e.getMirror(n);s!=null&&(s=s>n&&s<e.to?r-(s-e.from)-1:void 0),this.appendMap(e._maps[n].invert(),s)}}invert(){let e=new Nh;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],a=o.mapResult(e,n);if(a.recover!=null){let l=this.getMirror(i);if(l!=null&&l>i&&l<this.to){i=l,e=this._maps[l].recover(a.recover);continue}}s|=a.delInfo,e=a.pos}return r?e:new Hx(e,s,null)}}const gg=Object.create(null);class Pt{getMap(){return Zn.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=gg[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in gg)throw new RangeError("Duplicate use of step JSON ID "+e);return gg[e]=n,n.prototype.jsonID=e,n}}class Nt{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Nt(e,null)}static fail(e){return new Nt(null,e)}static fromReplace(e,n,r,s){try{return Nt.ok(e.replace(n,r,s))}catch(i){if(i instanceof pd)return Nt.fail(i.message);throw i}}}function l0(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(l0(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return Y.fromArray(r)}class ws extends Pt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new ue(l0(n.content,(o,a)=>!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return Nt.fromReplace(e,this.from,this.to,i)}invert(e){let n=[];return e.nodesBetween(this.from,this.to,(r,s)=>{if(r.isInline&&r.isAtom){let i=this.mark.addToSet(r.marks);if(!Xe.sameSet(i,r.marks)){let o=Math.max(this.from,s),a=Math.min(this.to,s+r.nodeSize);Eh(Yr,o,a,this.mark,n);for(let l of r.marks)l.isInSet(i)||Eh(ws,o,a,l,n)}}}),n.length==1?n[0]:new wo(n)}map(e){let n=e.map(this.from,1),r=e.map(this.to,-1);return n>=r?null:new ws(n,r,this.mark)}merge(e){return e instanceof ws&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ws(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ws(n.from,n.to,e.markFromJSON(n.mark))}}Pt.jsonID("addMark",ws);class Yr extends Pt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new ue(l0(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return Nt.fromReplace(e,this.from,this.to,r)}invert(e){let n=[];return e.nodesBetween(this.from,this.to,(r,s)=>{r.isInline&&r.isAtom&&this.mark.isInSet(r.marks)&&Eh(ws,Math.max(this.from,s),Math.min(this.to,s+r.nodeSize),this.mark,n)}),n.length==1?n[0]:new wo(n)}map(e){let n=e.map(this.from,1),r=e.map(this.to,-1);return n>=r?null:new Yr(n,r,this.mark)}merge(e){return e instanceof Yr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Yr(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Yr(n.from,n.to,e.markFromJSON(n.mark))}}Pt.jsonID("removeMark",Yr);function Eh(t,e,n,r,s){let i=s.length?s[s.length-1]:null;i&&i instanceof t&&i.to==e&&i.mark.eq(r)?s[s.length-1]=new t(i.from,n,r):s.push(new t(e,n,r))}class wo extends Pt{constructor(e){super(),this.steps=e}apply(e){for(let n of this.steps){let r=n.apply(e);if(!r.doc)return r;e=r.doc}return new Nt(e,null)}invert(e){return new wo(this.steps.map(n=>n.invert(e)))}map(e){let n=[];for(let r of this.steps){let s=r.map(e);s&&n.push(s)}return n.length?new wo(n):null}toJSON(){return{stepType:"markSet",steps:this.steps.map(e=>e.toJSON())}}static fromJSON(e,n){if(!Array.isArray(n.steps)||!n.steps.every(r=>r.stepType=="addMark"||r.stepType=="removeMark"))throw new RangeError("Invalid JSON for MarkSetStep");return new wo(n.steps.map(r=>Pt.fromJSON(e,r)))}}Pt.jsonID("markSet",wo);class fi extends Pt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Nt.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Nt.fromReplace(e,this.pos,this.pos+1,new ue(Y.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new fi(this.pos,n.marks[s]);return new fi(this.pos,this.mark)}}return new Wo(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new fi(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new fi(n.pos,e.markFromJSON(n.mark))}}Pt.jsonID("addNodeMark",fi);class Wo extends Pt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Nt.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Nt.fromReplace(e,this.pos,this.pos+1,new ue(Y.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new fi(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Wo(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Wo(n.pos,e.markFromJSON(n.mark))}}Pt.jsonID("removeNodeMark",Wo);class _t extends Pt{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&qx(e,this.from,this.to)?Nt.fail("Structure replace would overwrite content"):Nt.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Zn([this.from,this.to-this.from,this.slice.size])}invert(e){return new _t(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&_t.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new _t(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof _t)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?ue.empty:new ue(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new _t(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?ue.empty:new ue(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new _t(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new _t(n.from,n.to,ue.fromJSON(e,n.slice),!!n.structure)}}_t.MAP_BIAS=1;Pt.jsonID("replace",_t);class Zt extends Pt{constructor(e,n,r,s,i,o,a=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=a}apply(e){if(this.structure&&(qx(e,this.from,this.gapFrom)||qx(e,this.gapTo,this.to)))return Nt.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Nt.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Nt.fromReplace(e,this.from,this.to,r):Nt.fail("Content does not fit in gap")}getMap(){return new Zn([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Zt(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos||s>i?null:new Zt(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Zt(n.from,n.to,n.gapFrom,n.gapTo,ue.fromJSON(e,n.slice),n.insert,!!n.structure)}}Pt.jsonID("replaceAround",Zt);function qx(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function fW(t,e,n,r){let s=[];t.doc.nodesBetween(e,n,(i,o,a)=>{if(!i.isInline)return;let l=i.marks;if(!r.isInSet(l)&&a.type.allowsMarkType(r.type)){let c=Math.max(o,e),d=Math.min(o+i.nodeSize,n);Eh(ws,c,d,r,s)}}),s.forEach(i=>t.step(i))}function hW(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(o,a)=>{if(!o.isInline||!o.isAtom)return;i++;let l=null;if(r instanceof Yp){let c=o.marks,d;for(;d=r.isInSet(c);)(l||(l=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(o.marks)&&(l=[r]):l=o.marks;if(l&&l.length){let c=Math.min(a+o.nodeSize,n);for(let d=0;d<l.length;d++){let u=l[d],h;for(let m=0;m<s.length;m++){let g=s[m];g.step==i-1&&u.eq(s[m].style)&&(h=g)}h?(h.to=c,h.step=i):s.push({style:u,from:Math.max(a,e),to:c,step:i})}}}),s.forEach(o=>t.step(new Yr(o.from,o.to,o.style)))}function c0(t,e,n,r=n.contentMatch,s=!0){let i=t.doc.nodeAt(e),o=[],a=e+1;for(let l=0;l<i.childCount;l++){let c=i.child(l),d=a+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new _t(a,d,ue.empty));else{r=u;for(let h=0;h<c.marks.length;h++)n.allowsMarkType(c.marks[h].type)||t.step(new Yr(a,d,c.marks[h]));if(s&&c.isText&&n.whitespace!="pre"){let h,m=/\r?\n|\r/g,g;for(;h=m.exec(c.text);)g||(g=new ue(Y.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),o.push(new _t(a+h.index,a+h.index+h[0].length,g))}}a=d}if(!r.validEnd){let l=r.fillBefore(Y.empty,!0);t.replace(a,a,new ue(l,0,0))}for(let l=o.length-1;l>=0;l--)t.step(o[l])}function pW(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Dl(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,i=0;;--r){let o=t.$from.node(r),a=t.$from.index(r)+s,l=t.$to.indexAfter(r)-i;if(r<t.depth&&o.canReplace(a,l,n))return r;if(r==0||o.type.spec.isolating||!pW(o,a,l))break;a&&(s=1),l<o.childCount&&(i=1)}return null}function mW(t,e,n){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),a=s.after(i+1),l=o,c=a,d=Y.empty,u=0;for(let g=i,p=!1;g>n;g--)p||r.index(g)>0?(p=!0,d=Y.from(r.node(g).copy(d)),u++):l--;let h=Y.empty,m=0;for(let g=i,p=!1;g>n;g--)p||s.after(g+1)<s.end(g)?(p=!0,h=Y.from(s.node(g).copy(h)),m++):c++;t.step(new Zt(l,c,o,a,new ue(d.append(h),u,m),d.size-u,!0))}function g4(t,e,n=null,r=t){let s=gW(t,e),i=s&&yW(r,e);return i?s.map(C2).concat({type:e,attrs:n}).concat(i.map(C2)):null}function C2(t){return{type:t,attrs:null}}function gW(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return n.canReplaceWith(r,s,o)?i:null}function yW(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let l=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;l&&c<s;c++)l=l.matchType(n.child(c).type);return!l||!l.validEnd?null:o}function xW(t,e,n){let r=Y.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let a=n[o].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Y.from(n[o].type.create(n[o].attrs,r))}let s=e.start,i=e.end;t.step(new Zt(s,i,s,i,new ue(r,0,0),n.length,!0))}function vW(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,a)=>{let l=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,l)&&kW(t.doc,t.mapping.slice(i).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let m=r.whitespace=="pre",g=!!r.contentMatch.matchType(r.schema.linebreakReplacement);m&&!g?c=!1:!m&&g&&(c=!0)}c===!1&&x4(t,o,a,i),c0(t,t.mapping.slice(i).map(a,1),r,void 0,c===null);let d=t.mapping.slice(i),u=d.map(a,1),h=d.map(a+o.nodeSize,1);return t.step(new Zt(u,h,u+1,h-1,new ue(Y.from(r.create(l,null,o.marks)),0,0),1,!0)),c===!0&&y4(t,o,a,i),!1}})}function y4(t,e,n,r){e.forEach((s,i)=>{if(s.isText){let o,a=/\r?\n|\r/g;for(;o=a.exec(s.text);){let l=t.mapping.slice(r).map(n+1+i+o.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function x4(t,e,n,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(`
826
+ `))}})}function kW(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function wW(t,e,n,r,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Zt(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new ue(Y.from(o),0,0),1,!0))}function Ts(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=n-2;c>i;c--,d--){let u=s.node(c),h=s.index(c);if(u.type.spec.isolating)return!1;let m=u.content.cutByIndex(h,u.childCount),g=r&&r[d+1];g&&(m=m.replaceChild(0,g.type.create(g.attrs)));let p=r&&r[d]||u;if(!u.canReplace(h+1,u.childCount)||!p.type.validContent(m))return!1}let a=s.indexAfter(i),l=r&&r[0];return s.node(i).canReplaceWith(a,a,l?l.type:s.node(i+1).type)}function bW(t,e,n=1,r){let s=t.doc.resolve(e),i=Y.empty,o=Y.empty;for(let a=s.depth,l=s.depth-n,c=n-1;a>l;a--,c--){i=Y.from(s.node(a).copy(i));let d=r&&r[c];o=Y.from(d?d.type.create(d.attrs,o):s.node(a).copy(o))}t.step(new _t(e,e,new ue(i.append(o),n,n),!0))}function Qo(t,e){let n=t.resolve(e),r=n.index();return v4(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function SW(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function v4(t,e){return!!(t&&e&&!t.isLeaf&&SW(t,e))}function Qp(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let i,o,a=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):n>0?(i=r.node(s+1),a++,o=r.node(s).maybeChild(a)):(i=r.node(s).maybeChild(a-1),o=r.node(s+1)),i&&!i.isTextblock&&v4(i,o)&&r.node(s).canReplace(a,a+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function CW(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(s&&o.inlineContent){let d=o.whitespace=="pre",u=!!o.contentMatch.matchType(s);d&&!u?r=!1:!d&&u&&(r=!0)}let a=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);x4(t,d.node(),d.before(),a)}o.inlineContent&&c0(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let l=t.mapping.slice(a),c=l.map(e-n);if(t.step(new _t(c,l.map(e+n,-1),ue.empty,!0)),r===!0){let d=t.doc.resolve(c);y4(t,d.node(),d.before(),t.steps.length)}return t}function NW(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,n))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,n))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function EW(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let o=r.depth;o>=0;o--){let a=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1;for(let l=0;l<2;l++){if(l){if(!a)break;a=-a}let c=r.index(o)+(a>0?1:0),d=r.node(o),u=!1;if(i==1)u=d.canReplace(c,c,s);else{let h=d.contentMatchAt(c).findWrapping(s.firstChild.type);u=h&&d.canReplaceWith(c,c,h[0])}if(u)return a==0?r.pos:a<0?r.before(o+1):r.after(o+1)}}return null}function Xp(t,e,n=e,r=ue.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return k4(s,i,r)?new _t(e,n,r):new _W(s,i,r).fit()}function k4(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class _W{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Y.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=Y.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,a=s.depth;for(;o&&a&&i.childCount==1;)i=i.firstChild.content,o--,a--;let l=new ue(i,o,a);return e>-1?new Zt(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new _t(r.pos,s.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=N2(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],d,u=null;if(n==1&&(o?c.matchType(o.type)||(u=c.fillBefore(Y.from(o),!1)):i&&l.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:a,parent:i,inject:u};if(n==2&&o&&(d=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:a,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced;return E2(e,-1)<=n?!1:(this.unplaced.size>1&&E2(e,1)>r&&r++,this.unplaced=new ue(e,n+1,r),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=N2(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new ue(dc(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new ue(dc(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let p=0;p<i.length;p++)this.openFrontierNode(i[p]);let o=this.unplaced,a=r?r.content:o.content,l=o.openStart-e,c=0,d=[],{match:u,type:h}=this.frontier[n];if(s){for(let p=0;p<s.childCount;p++)d.push(s.child(p));u=u.matchFragment(s)}let m=a.size+e-(o.content.size-o.openEnd);for(;c<a.childCount;){let p=a.child(c),x=u.matchType(p.type);if(!x)break;c++,(c>1||l==0||p.content.size)&&(u=x,d.push(w4(p.mark(h.allowedMarks(p.marks)),c==1?l:0,c==a.childCount?m:-1)))}let g=c==a.childCount;g||(m=-1),this.placed=uc(this.placed,n,Y.from(d)),this.frontier[n].match=u,g&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let p=0,x=d[d.length-1];x&&p<m;p++)this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),x=x.lastChild;this.unplaced=g?e==0?ue.empty:new ue(dc(o.content,e-1,1),e-1,m<0?o.openEnd:e-1):new ue(dc(o.content,e,c),e,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!yg(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=yg(e,n,s,r,i);if(o){for(let a=n-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],d=yg(e,a,c,l,!0);if(!d||d.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=uc(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=uc(this.placed,this.depth,Y.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Y.empty,!0);n.childCount&&(this.placed=uc(this.placed,this.frontier.length,n))}}function dc(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(dc(t.firstChild.content,e-1,n)))}function uc(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(uc(t.lastChild.content,e-1,n)))}function N2(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function w4(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,w4(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(Y.empty,!0)))),t.copy(r)}function yg(t,e,n,r,s){let i=t.node(e),o=s?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let a=r.fillBefore(i.content,!0,o);return a&&!jW(n,i.content,o)?a:null}function jW(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function $W(t){return t.spec.defining||t.spec.definingForContent}function E2(t,e){for(let n=0;;n++){let r=e<0?t.firstChild:t.lastChild;if(!r||r.isAtom)return n;t=r.content}}function MW(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(k4(s,i,r))return t.step(new _t(e,n,r));let o=S4(s,i);o[o.length-1]==0&&o.pop();let a=-(s.depth+1);o.unshift(a);for(let h=s.depth,m=s.pos-1;h>0;h--,m--){let g=s.node(h).type.spec;if(g.defining||g.definingAsContext||g.isolating)break;o.indexOf(h)>-1?a=h:s.before(h)==m&&o.splice(1,0,-h)}let l=o.indexOf(a),c=[],d=r.openStart;for(let h=r.content,m=0;;m++){let g=h.firstChild;if(c.push(g),m==r.openStart)break;h=g.content}for(let h=d-1;h>=0;h--){let m=c[h],g=$W(m.type);if(g&&!m.sameMarkup(s.node(Math.abs(a)-1)))d=h;else if(g||!m.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let m=(h+d+1)%(r.openStart+1),g=c[m];if(g)for(let p=0;p<o.length;p++){let x=o[(p+l)%o.length],y=!0;x<0&&(y=!1,x=-x);let v=s.node(x-1),k=s.index(x-1);if(v.canReplaceWith(k,k,g.type,g.marks))return t.replace(s.before(x),y?i.after(x):n,new ue(b4(r.content,0,r.openStart,m),m,r.openEnd))}}let u=t.steps.length;for(let h=o.length-1;h>=0&&(t.replace(e,n,r),!(t.steps.length>u));h--){let m=o[h];m<0||(e=s.before(m),n=i.after(m))}}function b4(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(b4(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(Y.empty,!0))}return t}function TW(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=NW(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new ue(Y.from(r),0,0))}function OW(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n);if(r.parent.isTextblock&&s.parent.isTextblock&&r.start()!=s.start()&&r.parentOffset==0&&s.parentOffset==0){let o=r.sharedDepth(n),a=!1;for(let l=r.depth;l>o;l--)r.node(l).type.spec.isolating&&(a=!0);for(let l=s.depth;l>o;l--)s.node(l).type.spec.isolating&&(a=!0);if(!a){for(let l=r.depth;l>0&&e==r.start(l);l--)e=r.before(l);for(let l=s.depth;l>0&&n==s.start(l);l--)n=s.before(l);r=t.doc.resolve(e),s=t.doc.resolve(n)}}let i=S4(r,s);for(let o=0;o<i.length;o++){let a=i[o],l=o==i.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return t.delete(r.start(a),s.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),s.indexAfter(a-1))))return t.delete(r.before(a),s.after(a))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function S4(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}class Ua extends Pt{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Nt.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return Nt.fromReplace(e,this.pos,this.pos+1,new ue(Y.from(s),0,n.isLeaf?0:1))}getMap(){return Zn.empty}invert(e){return new Ua(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ua(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ua(n.pos,n.attr,n.value)}}Pt.jsonID("attr",Ua);class yd extends Pt{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Nt.ok(r)}getMap(){return Zn.empty}invert(e){return new yd(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new yd(n.attr,n.value)}}Pt.jsonID("docAttr",yd);let pl=class extends Error{};pl=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};pl.prototype=Object.create(Error.prototype);pl.prototype.constructor=pl;pl.prototype.name="TransformError";class C4{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Nh}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new pl(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(e=s.map(e,1),n=s.map(n,-1)),s.forEach((i,o,a,l)=>{e=Math.min(e,a),n=Math.max(n,l)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=ue.empty){let s=Xp(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new ue(Y.from(r),0,0))}delete(e,n){return this.replace(e,n,ue.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return MW(this,e,n,r),this}replaceRangeWith(e,n,r){return TW(this,e,n,r),this}deleteRange(e,n){return OW(this,e,n),this}lift(e,n){return mW(this,e,n),this}join(e,n=1){return CW(this,e,n),this}wrap(e,n){return xW(this,e,n),this}setBlockType(e,n=e,r,s=null){return vW(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return wW(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new Ua(e,n,r)),this}setDocAttribute(e,n){return this.step(new yd(e,n)),this}addNodeMark(e,n){return this.step(new fi(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof Xe)n.isInSet(r.marks)&&this.step(new Wo(e,n));else{let s=r.marks,i,o=[];for(;i=n.isInSet(s);)o.push(new Wo(e,i)),s=i.removeFromSet(s);for(let a=o.length-1;a>=0;a--)this.step(o[a])}return this}split(e,n=1,r){return bW(this,e,n,r),this}addMark(e,n,r){return fW(this,e,n,r),this}removeMark(e,n,r){return hW(this,e,n,r),this}clearIncompatible(e,n,r){return c0(this,e,n,r),this}}const xg=Object.create(null);class Ue{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new AW(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=ue.empty){let r=n.content.lastChild,s=null;for(let a=0;a<n.openEnd;a++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let a=0;a<o.length;a++){let{$from:l,$to:c}=o[a],d=e.mapping.slice(i);e.replaceRange(d.map(l.pos),d.map(c.pos),a?ue.empty:n),a==0&&$2(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:a}=s[i],l=e.mapping.slice(r),c=l.map(o.pos),d=l.map(a.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,n),$2(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new je(e):ma(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?ma(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):ma(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Jn(e.node(0))}static atStart(e){return ma(e,e,0,0,1)||new Jn(e)}static atEnd(e){return ma(e,e,e.content.size,e.childCount,-1)||new Jn(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=xg[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in xg)throw new RangeError("Duplicate use of selection JSON ID "+e);return xg[e]=n,n.prototype.jsonID=e,n}getBookmark(){return je.between(this.$anchor,this.$head).getBookmark()}}Ue.prototype.visible=!0;class AW{constructor(e,n){this.$from=e,this.$to=n}}let _2=!1;function j2(t){!_2&&!t.parent.inlineContent&&(_2=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class je extends Ue{constructor(e,n=e){j2(e),j2(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Ue.near(r);let s=e.resolve(n.map(this.anchor));return new je(s.parent.inlineContent?s:r,r)}replace(e,n=ue.empty){if(super.replace(e,n),n==ue.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof je&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new em(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new je(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=Ue.findFrom(n,r,!0)||Ue.findFrom(n,-r,!0);if(i)n=i.$head;else return Ue.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(Ue.findFrom(e,-r,!0)||Ue.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new je(e,n)}}Ue.jsonID("text",je);class em{constructor(e,n){this.anchor=e,this.head=n}map(e){return new em(e.map(this.anchor),e.map(this.head))}resolve(e){return je.between(e.resolve(this.anchor),e.resolve(this.head))}}class Se extends Ue{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?Ue.near(i):new Se(i)}content(){return new ue(Y.from(this.node),0,0)}eq(e){return e instanceof Se&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new d0(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Se(e.resolve(n.anchor))}static create(e,n){return new Se(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Se.prototype.visible=!1;Ue.jsonID("node",Se);class d0{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new em(r,r):new d0(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Se.isSelectable(r)?new Se(n):Ue.near(n)}}class Jn extends Ue{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=ue.empty){if(n==ue.empty){e.delete(0,e.doc.content.size);let r=Ue.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Jn(e)}map(e){return new Jn(e)}eq(e){return e instanceof Jn}getBookmark(){return RW}}Ue.jsonID("all",Jn);const RW={map(){return this},resolve(t){return new Jn(t)}};function ma(t,e,n,r,s,i=!1){if(e.inlineContent)return je.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let a=e.child(o);if(a.isAtom){if(!i&&Se.isSelectable(a))return Se.create(t,n-(s<0?a.nodeSize:0))}else{let l=ma(t,a,n+s,s<0?a.childCount:0,s,i);if(l)return l}n+=a.nodeSize*s}return null}function $2(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof _t||s instanceof Zt))return;let i=t.mapping.maps[r],o;i.forEach((a,l,c,d)=>{o==null&&(o=d)}),t.setSelection(Ue.near(t.doc.resolve(o),n))}const M2=1,Ru=2,T2=4;class IW extends C4{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|M2)&~Ru,this.storedMarks=null,this}get selectionSet(){return(this.updated&M2)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Ru,this}ensureMarks(e){return Xe.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Ru)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Ru,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Xe.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Ue.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=T2,this}get scrolledIntoView(){return(this.updated&T2)>0}}function O2(t,e){return!e||!t?t:t.bind(e)}class fc{constructor(e,n,r){this.name=e,this.init=O2(n.init,r),this.apply=O2(n.apply,r)}}const PW=[new fc("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new fc("selection",{init(t,e){return t.selection||Ue.atStart(e.doc)},apply(t){return t.selection}}),new fc("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new fc("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class vg{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=PW.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new fc(r.key,r.spec.state,r))})}}class fo{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let a=this.config.plugins[o];if(a.spec.appendTransaction){let l=s?s[o].n:0,c=s?s[o].state:this,d=l<n.length&&a.spec.appendTransaction.call(a,l?n.slice(l):n,c,r);if(d&&r.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<o?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),i=!0}s&&(s[o]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new fo(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new IW(this)}static create(e){let n=new vg(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new fo(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new vg(this.schema,e.plugins),r=n.fields,s=new fo(n);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new vg(e.schema,e.plugins),i=new fo(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=_i.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=Ue.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,a)){i[o.name]=c.fromJSON.call(l,e,n[a],i);return}}i[o.name]=o.init(e,i)}}),i}}function N4(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=N4(s,e,{})),n[r]=s}return n}class Bn{constructor(e){this.spec=e,this.props={},e.props&&N4(e.props,this,this.props),this.key=e.key?e.key.key:E4("plugin")}getState(e){return e[this.key]}}const kg=Object.create(null);function E4(t){return t in kg?t+"$"+ ++kg[t]:(kg[t]=0,t+"$")}class zr{constructor(e="key"){this.key=E4(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const _4=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function j4(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const $4=(t,e,n)=>{let r=j4(t,n);if(!r)return!1;let s=u0(r);if(!s){let o=r.blockRange(),a=o&&Dl(o);return a==null?!1:(e&&e(t.tr.lift(o,a).scrollIntoView()),!0)}let i=s.nodeBefore;if(z4(t,s,e,-1))return!0;if(r.parent.content.size==0&&(ml(i,"end")||Se.isSelectable(i)))for(let o=r.depth;;o--){let a=Xp(t.doc,r.before(o),r.after(o),ue.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=t.tr.step(a);l.setSelection(ml(i,"end")?Ue.findFrom(l.doc.resolve(l.mapping.map(s.pos,-1)),-1):Se.create(l.doc,s.pos-i.nodeSize)),e(l.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},DW=(t,e,n)=>{let r=j4(t,n);if(!r)return!1;let s=u0(r);return s?M4(t,s,e):!1},zW=(t,e,n)=>{let r=O4(t,n);if(!r)return!1;let s=f0(r);return s?M4(t,s,e):!1};function M4(t,e,n){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let d=s.lastChild;if(!d)return!1;s=d}let o=e.nodeAfter,a=o,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let d=a.firstChild;if(!d)return!1;a=d}let c=Xp(t.doc,i,l,ue.empty);if(!c||c.from!=i||c instanceof _t&&c.slice.size>=l-i)return!1;if(n){let d=t.tr.step(c);d.setSelection(je.create(d.doc,i)),n(d.scrollIntoView())}return!0}function ml(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const T4=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=u0(r)}let o=i&&i.nodeBefore;return!o||!Se.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Se.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function u0(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function O4(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const A4=(t,e,n)=>{let r=O4(t,n);if(!r)return!1;let s=f0(r);if(!s)return!1;let i=s.nodeAfter;if(z4(t,s,e,1))return!0;if(r.parent.content.size==0&&(ml(i,"start")||Se.isSelectable(i))){let o=Xp(t.doc,r.before(),r.after(),ue.empty);if(o&&o.slice.size<o.to-o.from){if(e){let a=t.tr.step(o);a.setSelection(ml(i,"start")?Ue.findFrom(a.doc.resolve(a.mapping.map(s.pos)),1):Se.create(a.doc,a.mapping.map(s.pos))),e(a.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},R4=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=f0(r)}let o=i&&i.nodeAfter;return!o||!Se.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Se.create(t.doc,i.pos)).scrollIntoView()),!0)};function f0(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const LW=(t,e)=>{let n=t.selection,r=n instanceof Se,s;if(r){if(n.node.isTextblock||!Qo(t.doc,n.from))return!1;s=n.from}else if(s=Qp(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(Se.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},FW=(t,e)=>{let n=t.selection,r;if(n instanceof Se){if(n.node.isTextblock||!Qo(t.doc,n.to))return!1;r=n.to}else if(r=Qp(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},BW=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&Dl(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},I4=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
827
+ `).scrollIntoView()),!0)};function h0(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const VW=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),i=n.indexAfter(-1),o=h0(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let a=n.after(),l=t.tr.replaceWith(a,a,o.createAndFill());l.setSelection(Ue.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},P4=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof Jn||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=h0(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,a=t.tr.insert(o,i.createAndFill());a.setSelection(je.create(a.doc,o+1)),e(a.scrollIntoView())}return!0},D4=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Ts(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Dl(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function WW(t){return(e,n)=>{if(e.selection instanceof Se&&e.selection.node.isBlock){let{$from:m}=e.selection;return!m.parentOffset||!Ts(e.doc,m.pos)?!1:(n&&n(e.tr.split(m.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof je||e.selection instanceof Jn)&&r.deleteSelection();let{$from:s}=r.selection,i=r.steps.length,o=[],a,l,c=!1,d=!1;for(let m=s.depth;;m--)if(s.node(m).isBlock){c=s.end(m)==s.pos+(s.depth-m),d=s.start(m)==s.pos-(s.depth-m),l=h0(s.node(m-1).contentMatchAt(s.indexAfter(m-1))),o.unshift(c&&l?{type:l}:null),a=m;break}else{if(m==1)return!1;o.unshift(null)}let u=s.pos,h=Ts(r.doc,u,o.length,o);if(h||(o[0]=l?{type:l}:null,h=Ts(r.doc,u,o.length,o)),!h)return!1;if(r.split(u,o.length,o),!c&&d&&s.node(a).type!=l){let m=r.mapping.slice(i),g=m.map(s.before(a)),p=r.doc.resolve(g);l&&s.node(a-1).canReplaceWith(p.index(),p.index()+1,l)&&r.setNodeMarkup(m.map(s.before(a)),l)}return n&&n(r.scrollIntoView()),!0}}const UW=WW(),ZW=(t,e)=>{let{$from:n,to:r}=t.selection,s,i=n.sharedDepth(r);return i==0?!1:(s=n.before(i),e&&e(t.tr.setSelection(Se.create(t.doc,s))),!0)};function HW(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||Qo(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function z4(t,e,n,r){let s=e.nodeBefore,i=e.nodeAfter,o,a,l=s.type.spec.isolating||i.type.spec.isolating;if(!l&&HW(t,e,n))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(a=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&a.matchType(o[0]||i.type).validEnd){if(n){let m=e.pos+i.nodeSize,g=Y.empty;for(let y=o.length-1;y>=0;y--)g=Y.from(o[y].create(null,g));g=Y.from(s.copy(g));let p=t.tr.step(new Zt(e.pos-1,m,e.pos,m,new ue(g,1,0),o.length,!0)),x=p.doc.resolve(m+2*o.length);x.nodeAfter&&x.nodeAfter.type==s.type&&Qo(p.doc,x.pos)&&p.join(x.pos),n(p.scrollIntoView())}return!0}let d=i.type.spec.isolating||r>0&&l?null:Ue.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),h=u&&Dl(u);if(h!=null&&h>=e.depth)return n&&n(t.tr.lift(u,h).scrollIntoView()),!0;if(c&&ml(i,"start",!0)&&ml(s,"end")){let m=s,g=[];for(;g.push(m),!m.isTextblock;)m=m.lastChild;let p=i,x=1;for(;!p.isTextblock;p=p.firstChild)x++;if(m.canReplace(m.childCount,m.childCount,p.content)){if(n){let y=Y.empty;for(let k=g.length-1;k>=0;k--)y=Y.from(g[k].copy(y));let v=t.tr.step(new Zt(e.pos-g.length,e.pos+i.nodeSize,e.pos+x,e.pos+i.nodeSize-x,new ue(y,g.length,0),0,!0));n(v.scrollIntoView())}return!0}}return!1}function L4(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(n&&n(e.tr.setSelection(je.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const qW=L4(-1),KW=L4(1);function JW(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i),a=o&&g4(o,t,e);return a?(r&&r(n.tr.wrap(o,a).scrollIntoView()),!0):!1}}function A2(t,e=null){return function(n,r){let s=!1;for(let i=0;i<n.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:a}}=n.selection.ranges[i];n.doc.nodesBetween(o,a,(l,c)=>{if(s)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)s=!0;else{let d=n.doc.resolve(c),u=d.index();s=d.parent.canReplaceWith(u,u+1,t)}})}if(!s)return!1;if(r){let i=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:a},$to:{pos:l}}=n.selection.ranges[o];i.setBlockType(a,l,t,e)}r(i.scrollIntoView())}return!0}}function p0(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}p0(_4,$4,T4);p0(_4,A4,R4);p0(I4,P4,D4,UW);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function GW(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i);if(!o)return!1;let a=r?n.tr:null;return YW(a,o,t,e)?(r&&r(a.scrollIntoView()),!0):!1}}function YW(t,e,n,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=o.resolve(e.start-2);i=new Sh(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new Sh(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let a=g4(i,n,r,e);return a?(t&&QW(t,e,a,s,n),!0):!1}function QW(t,e,n,r,s){let i=Y.empty;for(let d=n.length-1;d>=0;d--)i=Y.from(n[d].type.create(n[d].attrs,i));t.step(new Zt(e.start-(r?2:0),e.end,e.start,e.end,new ue(i,0,0),n.length,!0));let o=0;for(let d=0;d<n.length;d++)n[d].type==s&&(o=d+1);let a=n.length-o,l=e.start+n.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,h=!0;d<u;d++,h=!1)!h&&a&&Ts(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=c.child(d).nodeSize;return t}function _h(t,e){return t instanceof Ux?e==t:t.indexOf(e)>-1}function XW(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&_h(t,o.firstChild.type));return i?n?_h(t,r.node(i.depth-1).type)?eU(e,n,i):tU(e,n,i):!0:!1}}function eU(t,e,n){let r=t.tr,s=n.end,i=n.$to.end(n.depth),o=n.parent.child(n.endIndex-1).type;s<i&&(r.step(new Zt(s-1,i,s,i,new ue(Y.from(o.create(null,n.parent.copy())),1,0),1,!0)),n=new Sh(r.doc.resolve(n.$from.pos),r.doc.resolve(i),n.depth));const a=Dl(n);if(a==null)return!1;r.lift(n,a);let l=r.doc.resolve(r.mapping.map(s,-1)-1);return Qo(r.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&r.join(l.pos),e(r.scrollIntoView()),!0}function tU(t,e,n){let r=t.tr,s=n.parent;for(let m=n.end,g=n.endIndex-1,p=n.startIndex;g>p;g--)m-=s.child(g).nodeSize,r.delete(m-1,m+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let a=n.startIndex==0,l=n.endIndex==s.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(a?0:1),d+1,o.content.append(l?Y.empty:Y.from(s))))return!1;let u=i.pos,h=u+o.nodeSize;return r.step(new Zt(u-(a?1:0),h+(l?1:0),u+1,h-1,new ue((a?Y.empty:Y.from(s.copy(Y.empty))).append(l?Y.empty:Y.from(s.copy(Y.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function nU(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,c=>c.childCount>0&&_h(t,c.firstChild.type));if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let a=i.parent,l=a.child(o-1);if(!_h(t,l.type))return!1;if(n){let c=l.lastChild&&l.lastChild.type==a.type,d=Y.from(c?l.lastChild.lastChild.type.create():null),u=new ue(Y.from(l.type.create(null,Y.from(a.type.create(null,d)))),c?3:1,0),h=i.start,m=i.end;n(e.tr.step(new Zt(h-(c?3:1),m,h,m,u,1,!0)).scrollIntoView())}return!0}}const fn=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e};function gl(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e}let Kx=null;function Ur(t,e,n){let r=Kx||(Kx=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r}function rU(){Kx=null}function Mc(t,e,n,r){return n&&(I2(t,e,n,r,-1)||I2(t,e,n,r,1))}const R2=/^(img|br|input|textarea|hr)$/i;function I2(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:Wt(t))){let o=t.parentNode;if(!o||!Ce(o)||xd(t)||R2.test(t.nodeName)||t.contentEditable=="false")return!1;e=fn(t)+(s<0?0:1),t=o}else if(Ce(t)){let o=t.childNodes[e+(s<0?-1:0)];if(Ce(o)&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else{if(xd(o)||R2.test(o.nodeName))return!1;t=o,e=s<0?Wt(t):0}}else return!1}}function Wt(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ce(t){return t.nodeType==1}function Mt(t){return t.nodeType==3}function yl(t,e){return e?t.contains(Ce(e)?e:e.parentNode):!1}function m0(t,e){for(;;){if(Mt(t)&&e)return t;if(Ce(t)&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Wt(t)}else if(t.parentNode&&!xd(t,!0))e=fn(t),t=t.parentNode;else return null}}function g0(t,e){for(;;){if(Mt(t)&&e<t.nodeValue.length)return t;if(Ce(t)&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!xd(t,!0))e=fn(t)+1,t=t.parentNode;else return null}}function sU(t,e,n){for(let r=e==0,s=e==Wt(t);r||s;){if(t==n)return!0;let i=fn(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==Wt(t)}}function xd(t,e=!1){let n;for(let r=t;r&&!(n=r.pmViewDesc);r=r.parentNode);return n&&n.node&&(!e||n.node.isBlock)&&(n.dom==t||n.contentDOM==t)}function tm(t){return t.focusNode&&Mc(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)}function F4(t,e){t.collapse(e.anchorNode,e.anchorOffset),(e.focusNode!=e.anchorNode||e.focusOffset!=e.anchorOffset)&&t.extend(e.focusNode,e.focusOffset)}function iU(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function oU(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function aU(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Wt(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Wt(r.startContainer),r.startOffset)}}}const as=typeof navigator<"u"?navigator:null,P2=typeof document<"u"?document:null,xl=as&&as.userAgent||"",Ir=/gecko\/(\d+)/i.test(xl)&&!/edge?\//i.test(xl);Ir&&+(/Firefox\/(\d+)/.exec(xl)||[0,0])[1];const Jx=/Chrome\/(\d+)/.exec(xl),wn=!!Jx,B4=Jx?+Jx[1]:0,hn=!!as&&/Apple Computer/.test(as.vendor),vl=hn&&(/Mobile\/\w+/.test(xl)||!!as&&as.maxTouchPoints>2),ir=vl||(as?/Mac/.test(as.platform):!1),V4=as?/Win/.test(as.platform):!1,Ns=/Android \d/.test(xl),nm=!!P2&&"webkitFontSmoothing"in P2.documentElement.style,lU=nm?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function cU(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function fs(t,e){return typeof t=="number"?t:t[e]}function dU(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function D2(t,e,n){for(;;)if(n<0?e:e<Wt(t)){if(Mt(t))return Zr(Ur(t,e+(n<0?-1:0),e+(n>0?1:0)),-n);let r=t.childNodes[n<0?e-1:e];if(Mt(r))t=r,e=n<0?r.nodeValue.length:0;else return Ce(r)?Zr(r,-n):null}else{if(xd(t,!0)||!t.parentNode)return null;e=fn(t)+(n<0?0:1),t=t.parentNode}}function z2(t,e,n){if(!Gx(e)&&e.left==0)return;let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(!Ce(o)){o=gl(o);continue}let a=o==i.body,l=a?cU(i):dU(o),c=0,d=0;if(e.top<l.top+fs(r,"top")?d=-(l.top-e.top+fs(s,"top")):e.bottom>l.bottom-fs(r,"bottom")&&(d=e.bottom-e.top>l.bottom-l.top?e.top+fs(s,"top")-l.top:e.bottom-l.bottom+fs(s,"bottom")),e.left<l.left+fs(r,"left")?c=-(l.left-e.left+fs(s,"left")):e.right>l.right-fs(r,"right")&&(c=e.right-l.right+fs(s,"right")),c||d)if(a)i.defaultView.scrollBy(c,d);else{let h=o.scrollLeft,m=o.scrollTop;d&&(o.scrollTop+=d),c&&(o.scrollLeft+=c);let g=o.scrollLeft-h,p=o.scrollTop-m;e={left:e.left-g,top:e.top-p,right:e.right-g,bottom:e.bottom-p}}let u=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u=="absolute"?o.offsetParent:gl(o)}}function uU(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let a=t.root.elementFromPoint(i,o);if(!a||a==t.dom||!t.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=n-20){r=a,s=l.top;break}}return{refDOM:r,refTop:s,stack:W4(t.dom)}}function W4(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=gl(r));return e}function fU({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;U4(n,r==0?0:r-e)}function U4(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:i}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let oa=null;function Z4(t){if(t.setActive)return t.setActive();if(oa)return t.focus(oa);let e=W4(t);t.focus(oa==null?{get preventScroll(){return oa={preventScroll:!0},!0}}:void 0),oa||(oa=!1,U4(e,0))}function H4(t,e){let n,r=2e8,s,i=0,o=e.top,a=e.top,l,c;for(let d=t.firstChild,u=0;d;d=d.nextSibling,u++){let h;if(Ce(d))h=d.getClientRects();else if(Mt(d))h=Ur(d).getClientRects();else continue;for(let m=0;m<h.length;m++){let g=h[m];if(g.top<=o&&g.bottom>=a){o=Math.max(g.bottom,o),a=Math.min(g.top,a);let p=g.left>e.left?g.left-e.left:g.right<e.left?e.left-g.right:0;if(p<r){n=d,r=p,s=p&&Mt(n)?{left:g.right<e.left?g.right:g.left,top:e.top}:e,Ce(d)&&p&&(i=u+(e.left>=(g.left+g.right)/2?1:0));continue}}else g.top>e.top&&!l&&g.left<=e.left&&g.right>=e.left&&(l=d,c={left:Math.max(g.left,Math.min(g.right,e.left)),top:g.top});!n&&(e.left>=g.right&&e.top>=g.top||e.left>=g.left&&e.top>=g.bottom)&&(i=u+1)}}return!n&&l&&(n=l,s=c,r=0),n&&Mt(n)?hU(n,s):!n||r?{node:t,offset:i}:H4(n,s)}function hU(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let o=Zr(r,1);if(o.top!=o.bottom&&y0(e,o)){s={node:t,offset:i+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function y0(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function pU(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function mU(t,e,n){let{node:r,offset:s}=H4(e,n),i=-1;if(Ce(r)&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return{pos:t.docView.posFromDOM(r,s,i),affinity:q4(r,s,n)}}function L2(t,e){return t<e.left?e.left-t:t>e.right?t-e.right:0}function q4(t,e,n){let r=D2(t,e,-1),s=D2(t,e,1);return r?s?r.bottom<=s.top?n.top>(r.bottom+s.top)/2?1:-1:L2(n.left,r)<L2(n.left,s)?-1:1:-1:1}function gU(t,e,n,r){let s=-1;for(let i=e;i!=t.dom;){let o=t.docView.nearestDesc(i,!0),a;if(!o)return null;if(Ce(o.dom)&&((a=o.dom.getBoundingClientRect()).width||a.height)){if(!o.contentDOM&&!o.node.isText&&r.left>=a.left&&r.left<=a.right&&r.top>=a.top&&r.top<=a.bottom){let l=o.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2;return{pos:l?o.posBefore:o.posAfter,affinity:l?1:-1}}o.node.isBlock&&o.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(o.dom.nodeName)&&(r.top<a.top||r.top>a.bottom)&&(s=r.top<a.top?o.posBefore:o.posAfter)}i=o.dom.parentNode}return s>-1?{pos:s,affinity:0}:{pos:t.docView.posFromDOM(e,n,-1),affinity:q4(e,n,r)}}function K4(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=s;;){let o=t.childNodes[i];if(Ce(o)){let a=o.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if(y0(e,c))return K4(o,e,c)}}if((i=(i+1)%r)==s)break}return t}function yU(t,e){let n=t.dom.ownerDocument,r,s=0,i=aU(n,e.left,e.top);i&&({node:r,offset:s}=i);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),a,l=0;if(!o||!t.dom.contains(o)){let d=t.dom.getBoundingClientRect();if(!y0(e,d)||(o=K4(t.dom,e,d),!o))return null}if(hn)for(let d=o;r&&d;d=gl(d))d.draggable&&(r=void 0);if(o=pU(o,e),r){if(Ir&&Ce(r)&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let u=r.childNodes[s],h;u.nodeName=="IMG"&&(h=u.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&s++}let d;if(nm&&s&&Ce(r)&&Ce(d=r.childNodes[s-1])&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&Ce(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom)a=t.state.doc.content.size;else if(s==0||!Ce(r)||r.childNodes[s-1].nodeName!="BR"){let u=gU(t,r,s,e);u&&({pos:a,affinity:l}=u)}}a==null&&({pos:a,affinity:l}=mU(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:a,inside:c?c.posAtStart-c.border:-1,affinity:l}}function Gx(t){return t.top<t.bottom||t.left<t.right}function Zr(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Gx(r))return r}return Array.prototype.find.call(n,Gx)||t.getBoundingClientRect()}const xU=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function J4(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),o=nm||Ir;if(Mt(r))if(o&&(xU.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let l=Zr(Ur(r,s,s),n);if(Ir&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=Zr(Ur(r,s-1,s-1),-1);if(c.top==l.top){let d=Zr(Ur(r,s,s+1),-1);if(d.top!=l.top)return Yl(d,d.left<c.left)}}return l}else{let l=s,c=s,d=n<0?1:-1;return n<0&&!s?(c++,d=-1):n>=0&&s==r.nodeValue.length?(l--,d=1):n<0?l--:c++,Yl(Zr(Ur(r,l,c),d),d<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==Wt(r))){let l=r.childNodes[s-1];if(Ce(l))return wg(l.getBoundingClientRect(),!1)}if(i==null&&s<Wt(r)){let l=r.childNodes[s];if(Ce(l))return wg(l.getBoundingClientRect(),!0)}return wg(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==Wt(r))){let l=r.childNodes[s-1],c=Mt(l)?Ur(l,Wt(l)-(o?0:1)):Ce(l)&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Yl(Zr(c,1),!1)}if(i==null&&s<Wt(r)){let l=r.childNodes[s];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?Mt(l)?Ur(l,0,o?0:1):Ce(l)?l:null:null;if(c)return Yl(Zr(c,-1),!0)}return Yl(Zr(Mt(r)?Ur(r):r,-n),n>=0)}function Yl(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function wg(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function G4(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function vU(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return G4(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let a=t.docView.nearestDesc(i,!0);if(!a)break;if(a.node.isBlock){i=a.contentDOM||a.dom;break}i=a.dom.parentNode}let o=J4(t,s.pos,1);for(let a=i.firstChild;a;a=a.nextSibling){let l;if(Ce(a))l=a.getClientRects();else if(Mt(a))l=Ur(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let d=l[c];if(d.bottom>d.top+1&&(n=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const kU=/[\u0590-\u08ac]/;function wU(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,a=t.domSelection();return a?!kU.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?i:o:G4(t,e,()=>{let l=t.domSel.readRange(),c=a.caretBidiLevel;a.modify("move",n,"character");let d=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:u,focusOffset:h}=t.domSel.readRange(),m=u&&!yl(d,u)||l.focusNode==u&&l.focusOffset==h;return F4(a,l),c!=null&&(a.caretBidiLevel=c),m}):r.pos==r.start()||r.pos==r.end()}let F2=null,B2=null,V2=!1;function bU(t,e,n){return F2==e&&B2==n?V2:(F2=e,B2=n,V2=n=="up"||n=="down"?vU(t,e,n):wU(t,e,n))}class Yd{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.damage=0,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let s=this.children[n];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&yl(this.contentDOM,e))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>fn(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let i=e.compareDocumentPosition(this.contentDOM);i&16?s=n>Array.from(e.childNodes).findIndex(o=>o.contains(this.contentDOM)):s=!(i&4)}else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!n||i.node))if(r&&(o=i.nodeDOM)&&!(Ce(o)?yl(o,e):o==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let a=s.children[o];if(a.size){s=a;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],a=i+o.size;if(a>e){s=e-i;break}i=a}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(;r>0;r--){let i=this.children[r-1];if(i.size||!(i instanceof Q4||i instanceof Y4&&i.side>=0))break}if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?fn(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?fn(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,a=0;;a++){let l=this.children[a],c=o+l.size;if(s==-1&&e<=c){let d=o+l.border;if(e>=d&&n<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,d);e=o;for(let u=a;u>0;u--){let h=this.children[u-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){s=fn(h.dom)+1;break}e-=h.size}s==-1&&(s=0)}if(s>-1&&(c>n||a==this.children.length-1)){n=c;for(let d=a+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){i=fn(u.dom);break}n+=u.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(!Ce(n)||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDamage(e){e&&(this.damage|=e,this.markParentDamage())}markParentDamage(){for(let e=this;;){let{parent:n}=e;if(!n||n.damage&1)break;n.damage|=1,e=n}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Y4 extends Yd{constructor(e,n,r,s){let i,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){let a=Ce(o)?o:document.createElement("span");a!=o&&(a.appendChild(o),o=a),a.hasAttribute("contenteditable")||(a.contentEditable="false"),a.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return!this.damage&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class SU extends Yd{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class $i extends Yd{constructor(e,n,r,s,i){super(e,[],r,s),this.mark=n,this.spec=i}static create(e,n,r,s){let i=s.nodeViews[n.type.name],o=i&&i(n,s,r);return(!o||!o.dom)&&(o=Yo.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new $i(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.damage&4||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return!(this.damage&4)&&this.mark.eq(e)}markDamage(e){var n;this.damage|=e,(n=this.parent)===null||n===void 0||n.markDamage(2)}slice(e,n,r){let s=$i.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;n<o&&(i=Yx(i,n,o,r)),e>0&&(i=Yx(i,0,e,r));for(let a=0;a<i.length;a++)i[a].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Mi extends Yd{constructor(e,n,r,s,i,o,a){super(e,[],i,o),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=a}static create(e,n,r,s,i,o){let a=i.nodeViews[n.type.name],l,c=a&&a(n,i,()=>{if(!l)return o;if(l.parent)return l.parent.posBeforeChild(l)},r,s),d=c&&c.dom,u=c&&c.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(!Mt(d))throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Yo.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!u&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let h=d;return d=tO(d,r,n),c?l=new X4(e,n,r,s,d,u||null,h,c):n.isText?new Qd(e,n,r,s,d,h):new Mi(e,n,r,s,d,u||null,h)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(n.preserveWhitespace="full"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let s=this.children[r];if(this.dom.contains(s.dom.parentNode)){n.contentElement=s.dom.parentNode;break}}if(!n.contentElement){let r=e&&e.find(s=>Ce(s)&&e.indexOf(s.parentNode)<0&&this.dom.contains(s));r?n.contentElement=r:n.getContent=()=>Y.empty}}return n}matchesNode(e,n,r){return!this.damage&&e.eq(this.node)&&jh(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,a=i&&i.pos<0,l=new NU(this,o&&o.node,e),c=this.node.inlineContent,d=c&&this.node.isBlock;jU(this.node,this.innerDeco,(u,h,m)=>{u.spec.marks?l.syncToMarks(u.spec.marks,r,e,h):u.type.side>=0&&!m&&l.syncToMarks(h==this.node.childCount?Xe.none:this.node.child(h).marks,r,e,h),l.placeWidget(u,e,s)},(u,h,m,g)=>{l.syncToMarks(u.marks,r,e,g),d&&u.isAtom&&!u.isText&&l.addHackNode("IMG",l.top);let p;l.findNodeMatch(u,h,m,g)||a&&e.state.selection.from>s&&e.state.selection.to<s+u.nodeSize&&(p=l.findIndexWithChild(i.node))>-1&&l.updateNodeAt(u,h,m,p,e,s)||l.updateNextNode(u,h,m,e,g,s)||l.addNode(u,h,m,e,s),s+=u.nodeSize,c&&(d=u.isAtom&&!u.isText)}),l.syncToMarks([],r,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.damage&2)&&(o&&this.protectLocalComposition(e,o),eO(this.contentDOM,this.children,e),vl&&$U(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof je)||r<n||s>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,a=MU(this.node.content,o,r-n,s-n);return a<0?null:{node:i,pos:a,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new SU(this,i,n,s);e.input.compositionNodes.push(o),this.children=Yx(this.children,r,r+s.length,e,o)}update(e,n,r,s,i){return this.damage&4||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s,i),!0)}updateInner(e,n,r,s,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,i+1),this.damage=0}updateOuterDeco(e){if(jh(e,this.outerDeco))return;let n=!Ce(this.nodeDOM),r=this.dom;this.dom=x0(this.dom,this.nodeDOM,vd(this.outerDeco,this.node,n),vd(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){Ce(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){Ce(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function W2(t,e,n,r,s,i){i?x0(r,r,vd(i,t,!1),vd(e,t,!1)):tO(r,e,t);let o=new Mi(void 0,t,e,n,r,r,r);return o.contentDOM&&o.updateChildren(s,0),o}class Qd extends Mi{constructor(e,n,r,s,i,o){super(e,n,r,s,i,null,o)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,s){return this.damage&4||this.damage&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.damage&8||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.damage=0,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return!1}slice(e,n,r){let s=this.node.cut(e,n),i=document.createTextNode(s.text);return new Qd(this.parent,s,this.outerDeco,this.innerDeco,i,i)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Q4 extends Yd{parseRule(){return{ignore:!0}}matchesHack(e){return!this.damage&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class X4 extends Mi{constructor(e,n,r,s,i,o,a,l){super(e,n,r,s,i,o,a),this.spec=l}update(e,n,r,s,i){if(this.damage&4)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,n,r);return o&&this.updateInner(e,n,r,s,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function eO(t,e,n){let r=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],a=o.dom;if(a.parentNode==t){for(;a!=r;)r=U2(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(a,r);if(o instanceof $i){let l=r?r.previousSibling:t.lastChild;eO(o.contentDOM,o.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=U2(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const Tc=function(t){t&&(this.nodeName=t)};Tc.prototype=Object.create(null);const ho=[new Tc];function vd(t,e,n){if(t.length==0)return ho;let r=n?ho[0]:new Tc,s=[r];for(let i=0;i<t.length;i++){let o=t[i].type.attrs;if(o){o.nodeName&&s.push(r=new Tc(o.nodeName));for(let a in o){let l=o[a];l!=null&&(n&&s.length==1&&s.push(r=new Tc(e.isInline?"span":"div")),a=="class"?r.class=(r.class?r.class+" ":"")+l:a=="style"?r.style=(r.style?r.style+";":"")+l:a!="nodeName"&&(r[a]=l))}}}return s}function x0(t,e,n,r){if(n==ho&&r==ho)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],a=n[i];if(i){let l;a&&a.nodeName==o.nodeName&&s!=t&&(l=s.parentNode)&&l.nodeName.toLowerCase()==o.nodeName||(l=document.createElement(o.nodeName),l.pmIsDeco=!0,l.appendChild(s),a=ho[0]),s=l}CU(s,a||ho[0],o)}return s}function CU(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&t.classList.add(s[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function tO(t,e,n){return x0(t,t,ho,vd(e,n,!Ce(t)))}function jh(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function U2(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class NU{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=EU(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,s){let i=0,o=this.stack.length>>1,a=Math.min(o,e.length);for(;i<a&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<o;)this.destroyRest(),this.top.damage=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let l=-1,c=this.top.children.length;s<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let d=this.index;d<c;d++){let u=this.top.children[d];if(u.matchesMark(e[o])&&!this.isLocked(u.dom)){l=d;break}}if(l<0&&this.index<this.top.children.length){let d=this.top.children[this.index];d instanceof $i&&!(d.damage&4)&&d.mark.type==e[o].type&&d.spec.update&&!this.isLocked(d.dom)&&d.spec.update(e[o])&&(d.mark=e[o],l=this.index,this.changed=!0)}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let d=$i.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))i=this.top.children.indexOf(o,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let c=this.top.children[a];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){i=a;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,s,i,o){let a=this.top.children[s];return a.damage&4&&a.dom==a.contentDOM&&(a.damage=2),a.update(e,n,r,i,o)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,i,o){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof Mi){let c=this.preMatch.matched.get(l);if(c!=null&&c!=i)return!1;let d=l.dom,u,h=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&!(l.damage&4)&&jh(n,l.outerDeco));if(!h&&l.update(e,n,r,s,o))return this.destroyBetween(this.index,a),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(u=this.recreateWrapper(l,e,n,r,s,o)))return this.destroyBetween(this.index,a),this.top.children[this.index]=u,u.contentDOM&&(u.damage|=2,u.updateChildren(s,o+1),u.damage=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,i,o){if(e.damage&3||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!jh(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let a=Mi.create(this.top,n,r,s,i,o);if(a.contentDOM){a.children=e.children,e.children=[];for(let l of a.children)l.parent=a}return e.destroy(),a}addNode(e,n,r,s,i){let o=Mi.create(this.top,e,n,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new Y4(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof $i;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Qd)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((hn||wn)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new Q4(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||Ce(e)&&e.contains(this.lock.parentNode))}}function EU(t,e){let n=e,r=n.children.length,s=[],i=t.childCount,o=new Map,a=[];e:for(;i>0;){let l;for(;;)if(r){let d=n.children[r-1];if(d instanceof $i)s.push(r-1),n=d,r=d.children.length;else{l=d,r--;break}}else{if(n==e)break e;r=s.pop(),n=n.parent}let c=l.node;if(c){if(c!=t.child(i-1))break;--i,o.set(l,i),a.push(l)}}return{index:i,matched:o,matches:a.reverse()}}function _U(t,e){return t.type.side-e.type.side}function jU(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let c=0;c<t.childCount;c++){let d=t.child(c);r(d,s,e.forChild(i,d),c),i+=d.nodeSize}return}let o=0,a=[],l=null;for(let c=0;;){let d,u;for(;o<s.length&&s[o].to==i;){let x=s[o++];x.widget&&(d?(u||(u=[d])).push(x):d=x)}if(d)if(u){u.sort(_U);for(let x=0;x<u.length;x++)n(u[x],c,!!l)}else n(d,c,!!l);let h,m;if(l)m=-1,h=l,l=null;else if(c<t.childCount)m=c,h=t.child(c++);else break;for(let x=0;x<a.length;x++)a[x].to<=i&&a.splice(x--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)a.push(s[o++]);let g=i+h.nodeSize;if(h.isText){let x=g;o<s.length&&s[o].from<x&&(x=s[o].from);for(let y=0;y<a.length;y++)a[y].to<x&&(x=a[y].to);x<g&&(l=h.cut(x-i),h=h.cut(0,x-i),g=x,m=-1)}else for(;o<s.length&&s[o].to<g;)o++;let p=h.isInline&&!h.isLeaf?a.filter(x=>!x.inline):a.slice();r(h,p,e.forChild(i,h),m),i=g}}function $U(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function MU(t,e,n,r){for(let s=0,i=0;s<t.childCount&&i<=r;){let o=t.child(s++),a=i;if(i+=o.nodeSize,!o.isText)continue;let l=o.text;for(;s<t.childCount;){let c=t.child(s++);if(i+=c.nodeSize,!c.isText)break;l+=c.text}if(i>=n){if(i>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a<r?l.lastIndexOf(e,r-a-1):-1;if(c>=0&&c+e.length+a>=n)return a+c;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function Yx(t,e,n,r,s){let i=[];for(let o=0,a=0;o<t.length;o++){let l=t[o],c=a,d=a+=l.size;c>=n||d<=e?i.push(l):(c<e&&i.push(l.slice(0,e-c,r)),s&&(i.push(s),s=void 0),d>n&&i.push(l.slice(n-c,l.size,r)))}return i}function Qx(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&Ue.findFrom(i,e)}function ni(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Z2(t,e,n){let r=t.state.selection;if(r instanceof je)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return ni(t,new je(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Qx(t.state,e);return s&&s instanceof Se?ni(t,s):!1}else if(!ir||n.indexOf("m")<0){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let a=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(a))&&!o.contentDOM?Se.isSelectable(i)?ni(t,new Se(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):ni(t,new je(t.state.doc.resolve(e<0?a:a+i.nodeSize))):!1}}else return!1;else{if(r instanceof Se&&r.node.isInline)return ni(t,new je(e>0?r.$to:r.$from));{let s=Qx(t.state,e);return s?ni(t,s):!1}}}function Oc(t,e){let n=t.pmViewDesc;return n?n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR"):Ce(t)&&t.contentEditable=="false"}function aa(t,e){return e<0?TU(t):OU(t)}function TU(t){let e=t.domSel.readRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(Ir&&Ce(n)&&r<Wt(n)&&Oc(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(!Ce(n))break;let a=n.childNodes[r-1];if(Oc(a,-1))s=n,i=--r;else if(Mt(a))n=a,r=n.nodeValue.length;else break}else{if(nO(n))break;{let a=n.previousSibling;for(;a&&Oc(a,-1);)s=n.parentNode,i=fn(a),a=a.previousSibling;if(a)n=a,r=Wt(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Xx(t,n,r):s&&Xx(t,s,i)}function OU(t){let e=t.domSel.readRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=Wt(n),i,o;for(;;)if(r<s){if(!Ce(n))break;let a=n.childNodes[r];if(Oc(a,1))i=n,o=++r;else break}else{if(nO(n))break;{let a=n.nextSibling;for(;a&&Oc(a,1);)i=a.parentNode,o=fn(a)+1,a=a.nextSibling;if(a)n=a,r=0,s=Wt(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&Xx(t,i,o)}function nO(t){for(let e=t;e;e=e.parentNode){let n=e.pmViewDesc;if(n)return n.node?n.node.isBlock:!1}return!1}function Xx(t,e,n){if(!Mt(e)){let o,a;(a=g0(e,n))?(e=a,n=0):(o=m0(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection(),s=t.domSel.readRange();if(!r)return;tm(s)?r.collapse(e,n):r.extend&&(r.collapse(s.anchorNode,s.anchorOffset),r.extend(e,n)),t.domSel.ignore();let{state:i}=t;setTimeout(()=>{t.state==i&&t.domSel.sync()},50)}function H2(t,e){let n=t.state.doc.resolve(e);if(!(wn||V4)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),a=(o.top+o.bottom)/2;if(a>i.top&&a<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<n.end()){let o=t.coordsAtPos(e+1),a=(o.top+o.bottom)/2;if(a>i.top&&a<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}let r=t.dom;for(let i=n.depth;i>0;i--)if(n.node(i).isBlock){r=t.nodeDOM(n.before(i))||r;break}return getComputedStyle(r).direction=="rtl"?"rtl":"ltr"}function q2(t,e,n){let r=t.state.selection;if(r instanceof je&&!r.empty||n.indexOf("s")>-1||ir&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Qx(t.state,e);if(o&&o instanceof Se)return ni(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,a=r instanceof Jn?Ue.near(o,e):Ue.findFrom(o,e);return a?ni(t,a):!1}return!1}function K2(t,e){if(!(t.state.selection instanceof je))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function J2(t,e,n){t.domObserver.stopped(()=>e.contentEditable=n)}function AU(t){if(!hn||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSel.readRange();if(e&&Ce(e)&&n==0&&e.firstChild&&Ce(e.firstChild)&&e.firstChild.contentEditable=="false"){let r=e.firstChild;J2(t,r,"true"),setTimeout(()=>J2(t,r,"false"),20)}return!1}function RU(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function IU(t,e){let n=e.keyCode,r=RU(e);if(n==8||ir&&n==72&&r=="c")return K2(t,-1)||aa(t,-1);if(n==46&&!e.shiftKey||ir&&n==68&&r=="c")return K2(t,1)||aa(t,1);if(n==13||n==27)return!0;if(n==37||ir&&n==66&&r=="c"){let s=n==37?H2(t,t.state.selection.from)=="ltr"?-1:1:-1;return Z2(t,s,r)||aa(t,s)}else if(n==39||ir&&n==70&&r=="c"){let s=n==39?H2(t,t.state.selection.from)=="ltr"?1:-1:1;return Z2(t,s,r)||aa(t,s)}else{if(n==38||ir&&n==80&&r=="c")return q2(t,-1,r)||aa(t,-1);if(n==40||ir&&n==78&&r=="c")return AU(t)||q2(t,1,r)||aa(t,1);if(r==(ir?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function v0(t,e){t.someProp("transformCopied",m=>{e=m(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let o=t.someProp("clipboardSerializer")||Yo.fromSchema(t.state.schema),a=lO(),l=a.createElement("div");l.appendChild(o.serializeFragment(r,{document:a}));let c=l.firstChild,d,u=0;for(;c&&Ce(c)&&(d=aO[c.nodeName.toLowerCase()]);){for(let m=d.length-1;m>=0;m--){let g=a.createElement(d[m]);for(;l.firstChild;)g.appendChild(l.firstChild);l.appendChild(g),u++}c=l.firstChild}c&&Ce(c)&&c.setAttribute("data-pm-slice",`${s} ${i}${u?` -${u}`:""} ${JSON.stringify(n)}`);let h=t.someProp("clipboardTextSerializer",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
828
+
829
+ `);return{dom:l,text:h,slice:e}}function rO(t,e,n,r,s){let i=s.parent.type.spec.code,o,a;if(!n&&!e)return null;let l=!!e&&(r||i||!n);if(l){if(t.someProp("transformPastedText",h=>{e=h(e,i||r,t)}),i)return a=new ue(Y.from(t.state.schema.text(e.replace(/\r\n?/g,`
830
+ `))),0,0),t.someProp("transformPasted",h=>{a=h(a,t,!0)}),a;let u=t.someProp("clipboardTextParser",h=>h(e,s,r,t));if(u)a=u;else{let h=s.marks(),{schema:m}=t.state,g=Yo.fromSchema(m);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(p=>{let x=o.appendChild(document.createElement("p"));p&&x.appendChild(g.serializeNode(m.text(p,h)))})}}else t.someProp("transformPastedHTML",u=>{n=u(n,t)}),o=LU(n),nm&&FU(o);let c=o&&o.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let h=o.firstChild;for(;h&&!Ce(h);)h=h.nextSibling;if(!h)break;o=h}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||ji.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(l||d),context:s,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!PU.test(h.parentNode.nodeName)?{ignore:!0}:null}})),d)a=BU(G2(a,+d[1],+d[2]),d[4]);else if(a=ue.maxOpen(DU(a.content,s),!0),a.openStart||a.openEnd){let u=0,h=0;for(let m=a.content.firstChild;u<a.openStart&&!m.type.spec.isolating;u++,m=m.firstChild);for(let m=a.content.lastChild;h<a.openEnd&&!m.type.spec.isolating;h++,m=m.lastChild);a=G2(a,u,h)}return t.someProp("transformPasted",u=>{a=u(a,t,r)}),a}const PU=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function DU(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(a=>{if(!o)return;let l=s.findWrapping(a.type),c;if(!l)return o=null;if(c=o.length&&i.length&&iO(l,i,a,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=oO(o[o.length-1],i.length));let d=sO(a,l);o.push(d),s=s.matchType(d.type),i=l}}),o)return Y.from(o)}return t}function sO(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,Y.from(t));return t}function iO(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=iO(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(Y.from(sO(n,t,s+1))))}}function oO(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,oO(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(Y.empty,!0);return t.copy(n.append(r))}function ev(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,a=o.content;return t.childCount>1&&(i=0),s<r-1&&(a=ev(a,e,n,r,s+1,i)),s>=n&&(a=e<0?o.contentMatchAt(0).fillBefore(a,i<=s).append(a):a.append(o.contentMatchAt(o.childCount).fillBefore(Y.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(a))}function G2(t,e,n){return e<t.openStart&&(t=new ue(ev(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new ue(ev(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const aO={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function lO(){return document.implementation.createHTMLDocument("title")}let Ql=null;function zU(t){let e=window.trustedTypes;if(!e)return t;if(!Ql){if(Ql=e.defaultPolicy)try{return Ql.createHTML(t)}catch{}Ql=e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})}return Ql.createHTML(t)}function LU(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=lO(),r=n.body,s=/<([a-z][^>\s]+)/i.exec(t),i;if((i=s&&aO[s[1].toLowerCase()])&&(t=i.map(o=>"<"+o+">").join("")+t+i.map(o=>"</"+o+">").reverse().join("")),r.innerHTML=zU(t),i)for(let o=0;o<i.length;o++)r=r.querySelector(i[o])||r;for(let o=0;o<n.styleSheets.length;o++){let a=n.styleSheets[o];for(let l=0;l<a.rules.length;l++){let c=a.rules[l];if(c instanceof CSSStyleRule){let d=r.querySelectorAll(c.selectorText);for(let u=0;u<d.length;u++)d[u].style.cssText+=c.style.cssText}}}return r}function FU(t){let e=t.querySelectorAll(wn?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function BU(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let a=r.length-2;a>=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs()||!l.createAndFill(null,s))break;try{s=Y.from(l.create(r[a+1],s))}catch{break}i++,o++}return new ue(s,i,o)}class $n{constructor(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}static from(e){return e instanceof $n?e:new $n(e.anchorNode,e.anchorOffset,e.focusNode,e.focusOffset)}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}$n.null=new $n(null,0,null,0);class VU{constructor(e){this.view=e,this.range=$n.null,this.active=!1,this.synced=!1,this.suppress=!1,this.currentDocument=null,this.onSelectionChange=this.onSelectionChange.bind(this)}ensureListener(){let e=this.view.dom.ownerDocument;e!=this.currentDocument&&(this.currentDocument&&this.currentDocument.removeEventListener("selectionchange",this.onSelectionChange),this.currentDocument=e,e.addEventListener("selectionchange",this.onSelectionChange))}destroy(){this.currentDocument&&(this.currentDocument.removeEventListener("selectionchange",this.onSelectionChange),this.currentDocument=null),this.active=!1,this.range=$n.null}suppressChanges(){this.suppress=!0,setTimeout(()=>this.suppress=!1,50)}onSelectionChange(){if(this.suppress&&this.view.hasFocus())return this.sync();this.read()&&this.view.domObserver.flush(!1)}readRange(){let{view:e}=this,n=e.dom.isConnected!==!1&&e.domSelection();return n?hn&&e.root.nodeType===11&&oU(e.dom.ownerDocument)==e.dom?$n.from(WU(e,n)||n):$n.from(n):$n.null}read(){this.ensureListener();let e=uO(this.view);if(!e){this.active=!1,this.range=$n.null;return}return this.active=!0,this.range.eq(e)?!1:(this.range=e,this.synced=!1,!0)}sync(e=!1){let{view:n}=this;n.docView&&(this.ensureListener(),n.domObserver.stopped(()=>{KU(n,n.state.selection);let r=n.state.selection;if(n.input.mouseSelecting||cO(n)){let{desc:s,start:i}=dO(n.docView,r.from,r.to,0);n.cursorWrapper?qU(n):s instanceof X4&&s.spec.setSelection?s.spec.setSelection(r.anchor-i,r.head-i,n.root):UU(n,e,s,i),this.synced=this.active=!0}r.visible==n.dom.classList.contains("ProseMirror-hideselection")&&(r.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),HU(n))),this.range=this.readRange()}))}ignore(e=this.readRange()){this.range=$n.from(e),this.synced=!0}deactivate(){this.range=$n.null,this.active=this.synced=!1}}function WU(t,e){if(e.getComposedRanges){let s=e.getComposedRanges({shadowRoots:[t.root]})[0];if(s)return Y2(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Y2(t,n):null}function Y2(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Mc(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),new $n(n,r,s,i)}function k0(t,e,n=null){let r=t.state.doc;if(!e.focusNode)return null;let s=t.docView.nearestDesc(e.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(e.focusNode,e.focusOffset,1);if(o<0)return null;let a=r.resolve(o),l,c;if(tm(e)){for(l=o;s&&!s.node;)s=s.parent;if(s&&s.node.isAtom&&Se.isSelectable(s.node)&&s.parent&&!(s.node.isInline&&sU(e.focusNode,e.focusOffset,s.dom))){let u=s.posBefore;c=new Se(o==u?a:r.resolve(u))}else if(Ir&&n=="key"&&o>t.state.selection.to&&Ce(e.focusNode)&&e.focusOffset==e.focusNode.childNodes.length&&s&&s.posAtStart>t.state.selection.to)for(let u=e.focusNode;;u=u.parentNode){if(getComputedStyle(u).overflow!="visible"){c=Ue.findFrom(r.resolve(s.posAtStart),1);break}if(u==s.dom||u.nextSibling||!u.parentNode||!Ce(u.parentNode))break}}else{if(e instanceof t.dom.ownerDocument.defaultView.Selection&&e.rangeCount>1){let u=o,h=o;for(let m=0;m<e.rangeCount;m++){let g=e.getRangeAt(m);u=Math.min(u,t.docView.posFromDOM(g.startContainer,g.startOffset,1)),h=Math.max(h,t.docView.posFromDOM(g.endContainer,g.endOffset,-1))}if(u<0)return null;[l,o]=h==t.state.selection.anchor?[h,u]:[u,h],a=r.resolve(o)}else l=t.docView.posFromDOM(e.anchorNode,e.anchorOffset,1);if(l<0)return null}let d=r.resolve(l);if(!c){let u=n=="pointer"||t.state.selection.head<a.pos&&!i?1:-1;c=kl(t,d,a,u)}return c}function cO(t){return t.editable?t.hasFocus():fO(t,t.domSel.readRange())&&(!document.activeElement||document.activeElement.contains(t.dom))}function UU(t,e,n,r){let s=t.state.selection,{anchor:i,head:o}=s,a,l;Q2&&!(s instanceof je)&&(s.$from.parent.inlineContent||(a=X2(t,s.from)),!s.empty&&!s.$from.parent.inlineContent&&(l=X2(t,s.to)));let c=n.domFromPos(i-r,i>r?-1:1),d=o==i?c:n.domFromPos(o-r,o>r?-1:1);ZU(i,o,c,d,t,e),Q2&&(a&&eS(a),l&&eS(l))}function dO(t,e,n,r=0){for(let s=0,i=r;s<t.children.length;s++){let o=t.children[s],a=i+o.size;if(e>i&&n<a)return dO(o,e,n,i+o.border);i=a}return{desc:t,start:r}}function ZU(t,e,n,r,s,i){let o=!1;if((Ir||hn)&&t==e){let{node:d,offset:u}=n;if(Mt(d)){if(o=!!(u&&d.nodeValue[u-1]==`
831
+ `),o&&u==d.nodeValue.length)for(let h=d,m;h;h=h.parentNode){if(m=h.nextSibling){m.nodeName=="BR"&&(n=r={node:m.parentNode,offset:fn(m)+1});break}let g=h.pmViewDesc;if(g&&g.node&&g.node.isBlock)break}}else{let h=d.childNodes[u-1];o=h&&(h.nodeName=="BR"||h.contentEditable=="false")}}let a=s.domSel.readRange();if(Ir&&a.focusNode&&a.focusNode!=r.node&&Ce(a.focusNode)){let d=a.focusNode.childNodes[a.focusOffset];d&&d.contentEditable=="false"&&(i=!0)}if(!(i||o&&hn)&&Mc(n.node,n.offset,a.anchorNode,a.anchorOffset)&&Mc(r.node,r.offset,a.focusNode,a.focusOffset))return;let l=s.domSelection(),c=s.input.mouseSelecting;if(c&&c.affinity&&t==e&&c.pos==t){let{affinity:d}=c,{node:u,offset:h}=r,m,g=0;if(Mt(u)&&(d>0?h<Wt(u):h>0)?(m=u,g=h+d):(m=(d>0?g0:m0)(u,h),m&&(g=d>0?1:m.nodeValue.length-1)),m){l.collapse(m,g),l.modify("move",d>0?"backward":"forward","lineboundary");let{focusNode:p,focusOffset:x}=l;if(hn&&s.root.nodeType==11){let y=l.getComposedRanges({shadowRoots:[s.root]});y.length&&(p=y[0].startContainer,x=y[0].startOffset)}if(Mc(u,h,p,x))return}}F4(l,{focusNode:r.node,focusOffset:r.offset,anchorNode:n.node,anchorOffset:n.offset})}const Q2=hn||wn&&B4<63;function X2(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(hn&&s&&s.contentEditable=="false")return bg(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return bg(s);if(i)return bg(i)}}function bg(t){return t.contentEditable="true",hn&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function eS(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function HU(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSel.readRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!cO(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function qU(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom;n.nodeName=="IMG"?e.collapse(n.parentNode,fn(n)+1):e.collapse(n,0)}function KU(t,e){if(e instanceof Se){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(tS(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else tS(t)}function tS(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function kl(t,e,n,r){let s=t.someProp("createSelectionBetween",i=>i(t,e,n))||je.between(e,n,r);return t.someProp("adjustSelectionFromDOM",i=>{s=i(t,s)}),s}function uO(t){if(t.editable&&!t.hasFocus())return null;let e=t.domSel.readRange();return e&&fO(t,e)?e:null}function fO(t,e){if(!e.anchorNode)return!1;try{return yl(t.dom,e.anchorNode)&&(t.editable||yl(t.dom,e.focusNode))}catch{return!1}}const Cn={},Nn={},JU={touchstart:!0,touchmove:!0};class GU{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.mouseSelecting=null,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function YU(t){for(let e in Cn){let n=Cn[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{XU(t,r)&&(t.input.composing&&(r.type=="keydown"||r.type=="beforeinput")&&r.isComposing===!1&&mO(t,!0),!w0(t,r)&&(t.editable||!(r.type in Nn))&&n(t,r))},JU[e]?{passive:!0}:void 0)}hn&&t.dom.addEventListener("input",()=>null),tv(t)}function rm(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function QU(t){t.input.mouseDown&&t.input.mouseDown.done(),t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function tv(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>w0(t,r))})}function w0(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function XU(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function eZ(t,e){!w0(t,e)&&Cn[e.type]&&(t.editable||!(e.type in Nn))&&Cn[e.type](t,e)}function ai(t,e){let{input:n}=t;return n.lastKeyDispatched||t.composing?!1:(n.lastKeyDispatched=!0,typeof e=="string"&&(e=iU(e=="Backspace"?8:13,e)),t.someProp("handleKeyDown",r=>r(t,e)))}Nn.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),t.input.lastKeyDispatched=!1,!(Ns&&wn&&n.keyCode==13)){if(vl&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(ai(t,"Enter"),t.input.lastIOSEnter=0)},200);return}n.keyCode!=229&&t.domObserver.forceFlush(!0),ai(t,n)||IU(t,n)?n.preventDefault():rm(t,"key")}};Nn.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Nn.keypress=(t,e)=>{let n=e;if(cZ(t)||!n.charCode||n.ctrlKey&&!n.altKey||ir&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof je)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function kd(t){return{left:t.clientX,top:t.clientY}}function tZ(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function b0(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,a=>o>i.depth?a(t,n,i.nodeAfter,i.before(o),s,!0):a(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function hO(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function nZ(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Se.isSelectable(r)?(hO(t,new Se(n)),!0):!1}function rZ(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof Se&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let a=o>i.depth?i.nodeAfter:i.node(o);if(Se.isSelectable(a)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(hO(t,Se.create(t.state.doc,s)),!0):!1}function sZ(t,e,n,r,s){return b0(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?rZ(t,n):nZ(t,n))}function iZ(t,e,n,r){return b0(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function oZ(t,e,n,r){return b0(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))}function nS(t,e,n){if(e==-1)return t.inlineContent?je.create(t,0,t.content.size):null;let r=t.resolve(e);for(let s=r.depth+1;s>0;s--){let i=s>r.depth?r.nodeAfter:r.node(s),o=r.before(s);if(i.inlineContent)return je.create(t,o+1,o+1+i.content.size);if(n&&Se.isSelectable(i))return Se.create(t,o)}return null}let nv=/[\w_\u00a1-\uffff]+/g;try{nv=new RegExp("[\\p{L}\\p{N}_]+","gu")}catch{}function rS(t,e){let n=t.resolve(e),r=n.node(),s="",i=e,o=e;for(let p=n.indexAfter(),x=!1;p>0;p--){let y=r.child(p-1);if(!y.text)break;let v=i==e?e-n.posAtIndex(p-1):y.text.length,k=v;for(;k>0;k--)if(/\S/.test(y.text[k-1]))x=!0;else if(x)break;if(s=y.text.slice(k,v)+s,i-=v-k,k||i<e-50)break}for(let p=n.index(),x=!1;p<r.childCount;p++){let y=r.child(p);if(!y.text)break;let v=o==e?e-n.posAtIndex(p):0,k=v;for(;k<y.text.length;k++)if(/\S/.test(y.text[k]))x=!0;else if(x)break;if(s+=y.text.slice(v,k),o+=k-v,k<y.text.length||o>e+50)break}let a=i,l=o;if(Intl.Segmenter){for(let p of new Intl.Segmenter(void 0,{granularity:"word"}).segment(s))if(p.isWordLike){let x=p.index+i,y=x+p.segment.length;if(y<e)a=y;else if(x>e){l=x;break}else return je.create(t,x,y)}}else{nv.lastIndex=0;for(let p;p=nv.exec(s);){let x=p.index+i,y=x+p[0].length;if(y<e)a=y;else if(x>e){l=x;break}else return je.create(t,x,y)}}let c=s.slice(a-i,e-i),d=s.slice(e-i,l-i),u=/\S*$/.exec(c)[0].length,h=/^\S*/.exec(d)[0].length;if(u||h)return je.create(t,e-u,e+h);let m=/\s*$/.exec(c)[0].length,g=/^\s*/.exec(d)[0].length;return je.create(t,e-m,e+g)}const pO=ir?"metaKey":"ctrlKey";Cn.mousedown=(t,e)=>{let n=e,r=Date.now();if(t.input.shiftKey=n.shiftKey,t.input.lastTouch>r-500)return!1;Uo(t);let s="singleClick";r-t.input.lastClick.time<500&&tZ(n,t.input.lastClick)&&!n[pO]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:s,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let i=t.posAtCoords(kd(n));if(i)if(n.button==0){if(!t.hasFocus()){Z4(t.dom);let a=t.root.activeElement;a&&!a.contains(t.dom)&&a.blur()}(t.input.mouseDown=new aZ(t,i,n,s)).mightDrag||n.preventDefault()}else rm(t,"pointer")};class aZ{constructor(e,n,r,s){var i;this.view=e,this.startPos=n,this.event=r,this.type=s,this.didMove=!1,this.lastPos=-1,this.anchorRange=null,this.startDoc=e.state.doc,this.selectNode=!!r[pO],this.extend=r.shiftKey,this.anchorDoc=this.startDoc;let o=sS(e);if(this.extend){let a=e.state.selection;this.anchorRange=a instanceof Se?{from:a.from,to:a.to}:{from:a.anchor,to:a.anchor};let l=a instanceof Se?e.nodeDOM(a.from).getBoundingClientRect():e.coordsAtPos(a.anchor);this.anchorOffset={x:(l.left+l.right)/2-o.x,y:(l.top+l.bottom)/2-o.y}}else this.anchorOffset={x:r.clientX-o.x,y:r.clientY-o.y};if(s=="singleClick"){let{selection:a}=e.state,l,c,d=!1;if(a instanceof Se&&a.from<=n.pos&&a.to>=n.pos)c=a.from,l=a.node,d=!0;else if(n.inside>-1)l=e.state.doc.nodeAt(n.inside),c=n.inside;else{let u=e.state.doc.resolve(n.pos);l=u.parent,c=u.depth?u.before():-1}if(d||c>-1&&l.type.spec.draggable&&l.type.spec.selectable!==!1){let u=(i=e.docView.descAt(c))===null||i===void 0?void 0:i.nodeDOM;this.mightDrag={node:l,elt:u,pos:c,addAttr:!1},u&&!u.draggable&&(this.mightDrag.addAttr=!0,e.domObserver.stopped(()=>u.draggable=!0))}else this.mightDrag=lZ(e,r)}else this.mightDrag=!1;e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),this.mightDrag||this.select(this.startPos,!0)}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null),typeof this.mightDrag=="object"&&this.mightDrag.addAttr&&this.view.domObserver.stopped(()=>this.mightDrag.elt.removeAttribute("draggable"))}maybeRunHandler(e,n){return(this.type=="singleClick"?sZ:this.type=="doubleClick"?iZ:oZ)(this.view,e.pos,e.inside,n,this.selectNode)}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.startPos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(kd(e))),n&&(this.didMove||this.maybeRunHandler(n,e)||this.select(n,!0),e.preventDefault())}move(e){if(e.buttons==0){this.done();return}if(!this.didMove&&(Math.abs(this.event.x-e.clientX)>8||Math.abs(this.event.y-e.clientY)>8)&&(this.didMove=!0,this.mightDrag=!1),!this.mightDrag){let n=this.view.posAtCoords(kd(e));n&&this.select(n,!1)}e.preventDefault()}select(e,n){if(e.pos==this.lastPos)return;this.lastPos=e.pos;let{view:r}=this,{doc:s}=r.state,i=this.type=="singleClick"?iS(r,s,e):this.type=="doubleClick"?rS(s,e.pos):nS(s,e.inside,n);i&&(n&&!this.extend?this.anchorRange=i:(!n||this.extend)&&(s.eq(this.anchorDoc)||this.restoreAnchor(),this.anchorRange&&this.anchorRange.from<i.from?i=kl(r,s.resolve(this.anchorRange.from),s.resolve(i.to)):this.anchorRange&&this.anchorRange.to>i.to&&(i=kl(r,s.resolve(this.anchorRange.to),s.resolve(i.from)))),i.eq(r.state.selection)||(r.input.mouseSelecting=e,r.dispatch(r.state.tr.setSelection(i).setMeta("pointer",!0).scrollIntoView()),r.input.mouseSelecting=null))}restoreAnchor(){let e=sS(this.view),n=this.view.posAtCoords({left:this.anchorOffset.x+e.x,top:this.anchorOffset.y+e.y});if(!n)this.anchorRange=null;else{let{doc:r}=this.view.state;this.anchorRange=this.type=="singleClick"?iS(this.view,r,n):this.type=="doubleClick"?rS(r,n.pos):nS(r,n.inside,!1),this.anchorDoc=this.view.state.doc}}}function sS(t){let e=t.dom.getBoundingClientRect();return{x:e.left-t.dom.scrollLeft,y:e.top-t.dom.scrollTop}}function iS(t,e,n){if(n.inside>-1){let s=e.nodeAt(n.inside);if(s.isAtom&&Se.isSelectable(s))return Se.create(e,n.inside)}let r=e.resolve(n.pos);return kl(t,r,r)}function lZ(t,e){let{selection:n}=t.state;if(n.empty)return!1;let r=t.domSelection();if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let i=0;i<s.length;i++){let o=s[i];if(o.left<=e.clientX&&o.right>=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}Cn.touchstart=t=>{t.input.lastTouch=Date.now(),Uo(t),rm(t,"pointer")};Cn.touchmove=t=>{t.input.lastTouch=Date.now(),rm(t,"pointer")};Cn.contextmenu=t=>Uo(t);function cZ(t,e){return t.composing?!0:hn&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const dZ=Ns?5e3:-1;Nn.compositionstart=Nn.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof je&&e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||wn&&V4&&uZ(t)))t.markCursor=t.state.storedMarks||n.marks(),Uo(t,!0),t.markCursor=null;else if(Uo(t,!e.selection.empty),Ir&&t.domSel.active&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length)for(let{focusNode:r,focusOffset:s}=t.domSel.range;r&&Ce(r)&&s!=0;){let i=s<0?r.lastChild:r.childNodes[s-1];if(!i)break;if(Mt(i)){let o=t.domSelection();o&&o.collapse(i,i.nodeValue.length);break}else r=i,s=-1}t.input.composing=!0}gO(t,dZ)};function uZ(t){let{focusNode:e,focusOffset:n}=t.domSel.range;if(!e||!Ce(e)||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return Ce(r)&&r.contentEditable=="false"}Nn.compositionend=(t,e)=>{t.composing&&mO(t)};function mO(t,e=!1){t.input.composing=!1,t.input.compositionEndedAt=Date.now(),t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,e?Uo(t):gO(t,20)}function gO(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Uo(t),e))}function yO(t){t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());for(let e;e=t.input.compositionNodes.pop();)e.markParentDamage()}function fZ(t){let e=t.domSel.range;if(!t.domSel.active||!e.focusNode)return null;let n=m0(e.focusNode,e.focusOffset),r=g0(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function Uo(t,e=!1){if(!(Ns&&t.domObserver.flushingSoon>=0)&&(t.domObserver.forceFlush(),yO(t),e||t.docView&&t.docView.damage)){let n=k0(t,t.domSel.readRange()),r=t.state.selection;n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state)}}function hZ(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const wd=vl&&lU<604;Cn.copy=Nn.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=wd?null:n.clipboardData,o=r.content(),{dom:a,text:l}=v0(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):hZ(t,a),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function pZ(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function mZ(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?bd(t,r.value,null,s,e):bd(t,r.textContent,r.innerHTML,s,e)},50)}function bd(t,e,n,r,s){let i=rO(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,s,i||ue.empty)))return!0;if(!i)return!1;let o=pZ(i),a=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function xO(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Nn.paste=(t,e)=>{let n=e;if(t.composing&&!Ns)return;let r=wd?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&bd(t,xO(r),r.getData("text/html"),s,n)?n.preventDefault():mZ(t,n)};class vO{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const gZ=ir?"altKey":"ctrlKey";function kO(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[gZ]}Cn.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(kd(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof Se?s.to-1:s.to))){if(r&&typeof r.mightDrag=="object")o=Se.create(t.state.doc,r.mightDrag.pos);else if(n.target&&Ce(n.target)){let u=t.docView.nearestDesc(n.target,!0);u&&u.node.type.spec.draggable&&u!=t.docView&&(o=Se.create(t.state.doc,u.posBefore))}}let a=(o||t.state.selection).content(),{dom:l,text:c,slice:d}=v0(t,a);(!n.dataTransfer.files.length||!wn||B4>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(wd?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",wd||n.dataTransfer.setData("text/plain",c),t.dragging=new vO(d,kO(t,n),o)};Cn.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Nn.dragover=Nn.dragenter=(t,e)=>e.preventDefault();Nn.drop=(t,e)=>{try{yZ(t,e,t.dragging)}finally{t.dragging=null}};function yZ(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(kd(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",m=>{i=m(i,t,!1)}):i=rO(t,xO(e.dataTransfer),wd?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&kO(t,e));if(t.someProp("handleDrop",m=>m(t,e,i||ue.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let a=i?EW(t.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let l=t.state.tr;if(o){let{node:m}=n;m?m.replace(l):l.deleteSelection()}let c=l.mapping.map(a),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,u=l.doc;if(d?l.replaceRangeWith(c,c,i.content.firstChild):l.replaceRange(c,c,i),l.doc.eq(u))return;let h=l.doc.resolve(c);if(d&&Se.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))l.setSelection(new Se(h));else{let m=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((g,p,x,y)=>m=y),l.setSelection(kl(t,h,l.doc.resolve(m)))}t.focus(),t.dispatch(l.setMeta("uiEvent","drop"))}Cn.focus=t=>{if(t.input.lastFocus=Date.now(),!t.focused&&(t.domObserver.stopped(()=>t.dom.classList.add("ProseMirror-focused")),t.focused=!0,t.domSel.read(),!t.domSel.synced)){let e=t.domSel.range;setTimeout(()=>{let n=t.domSel.readRange();n&&e.eq(n)&&t.domSel.sync()},20)}};Cn.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stopped(()=>t.dom.classList.remove("ProseMirror-focused")),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domSel.deactivate(),t.focused=!1)};Cn.beforeinput=(t,e)=>{if(Ns&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||t.domObserver.pendingRecords().length||(t.dom.blur(),t.focus(),ai(t,"Backspace")))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in Nn)Cn[t]=Nn[t];function Sd(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class rv{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let n=this.frag.child(this.index);if(this.off==e)return n;this.off+=n.nodeSize,this.index++}return null}}class $h{constructor(e,n){this.toDOM=e,this.spec=n||bo,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new Er(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof $h&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Sd(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ti{constructor(e,n){this.attrs=e,this.spec=n||bo}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new Er(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Ti&&Sd(this.attrs,e.attrs)&&Sd(this.spec,e.spec)}static is(e){return e.type instanceof Ti}destroy(){}}class S0{constructor(e,n){this.attrs=e,this.spec=n||bo}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new Er(i.pos-r,o.pos-r,this)}valid(e,n,r){let s=r.nodeAt(n.from);return!!s&&!s.isText&&n.from+s.nodeSize==n.to}eq(e){return this==e||e instanceof S0&&Sd(this.attrs,e.attrs)&&Sd(this.spec,e.spec)}destroy(){}}class Er{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Er(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new Er(e,e,new $h(n,r))}static inline(e,n,r,s){return new Er(e,n,new Ti(r,s))}static node(e,n,r,s){return new Er(e,n,new S0(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ti}get widget(){return this.type instanceof $h}}const ga=[],bo={};class Vt{constructor(e,n){this.local=e.length?e:ga,this.children=n.length?n:ga}static create(e,n){return n.length?Mh(n,e,0,bo):ln}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let a=this.local[o];if(a.from>n)break;a.to>=e&&(!i||i(a.spec))&&r.push(a.copy(a.from+s,a.to+s))}for(let o=0;o<this.children.length&&!(this.children[o]>=n);o+=3)if(this.children[o+1]>e){let a=this.children[o]+1;this.children[o+2].findInner(e-a,n-a,r,s+a,i)}}map(e,n,r){return this==ln||e.maps.length==0?this:this.mapInner(e,n,0,0,r||bo)}mapInner(e,n,r,s,i){let o;if(this.local.length){let a=new rv(n.content);for(let l=0;l<this.local.length;l++){let c=this.local[l].map(e,r,s);c&&c.type.valid(n,c,a)?(o||(o=[])).push(c):i.onRemove&&i.onRemove(this.local[l].spec)}}return this.children.length?xZ(this.children,o||[],e,n,r,s,i):o?new Vt(o.sort(hi),ga):ln}add(e,n){return n.length?this==ln?Vt.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((a,l)=>{let c=l+r,d;if(d=bO(n,a,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<l;)i+=3;s[i]==l?s[i+2]=s[i+2].addInner(a,d,c+1):s.splice(i,0,l,l+a.nodeSize,Mh(d,a,c+1,bo)),i+=3}});let o=wO(i?SO(n):n,-r).sort(hi);if(o.length){let a=new rv(e.content);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l],a)||o.splice(l--,1)}return new Vt(o.length?this.local.concat(o).sort(hi):this.local,s||this.children)}remove(e){return e.length==0||this==ln?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,a=r[i]+n,l=r[i+1]+n;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>a&&u.to<l&&(e[d]=null,(o||(o=[])).push(u));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(o,a+1);c!=ln?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let a=0;a<s.length;a++)s[a].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(a--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new Vt(s,r):ln}forChild(e,n){if(this==ln)return this;if(n.isLeaf)return Vt.empty;let r,s,i=0,o=this.children.length/3;for(;i<o;){let c=i+o>>>1,d=c*3,u=this.children[d];if(u<e)i=c+1;else if(u>e)o=c;else{r=this.children[d+2];break}}let a=e+1,l=a+n.content.size;for(let c=0;c<this.local.length;c++){let d=this.local[c];if(d.from<l&&d.to>a&&d.type instanceof Ti){let u=Math.max(a,d.from)-a,h=Math.min(l,d.to)-a;u<h&&(s||(s=[])).push(d.copy(u,h))}}if(s){let c=new Vt(s.sort(hi),ga);return r?new li([c,r]):c}return r||ln}eq(e){if(this==e)return!0;if(!(e instanceof Vt)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return C0(this.localsInner(e))}localsInner(e){if(this==ln)return ga;if(e.inlineContent||!this.local.some(Ti.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ti||n.push(this.local[r]);return n}forEachSet(e){e(this)}}Vt.empty=new Vt([],[]);Vt.removeOverlap=C0;const ln=Vt.empty;class li{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,bo));return li.from(r)}forChild(e,n){if(n.isLeaf)return Vt.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=ln&&(i instanceof li?r=r.concat(i.members):r.push(i))}return li.from(r)}eq(e){if(!(e instanceof li)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?C0(r?n:n.sort(hi)):ga}static from(e){switch(e.length){case 0:return ln;case 1:return e[0];default:return new li(e.every(n=>n instanceof Vt)?e:e.reduce((n,r)=>n.concat(r instanceof Vt?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function xZ(t,e,n,r,s,i,o){let a=t.slice();for(let c=0,d=i;c<n.maps.length;c++){let u=0;n.maps[c].forEach((h,m,g,p)=>{let x=p-g-(m-h);for(let y=0;y<a.length;y+=3){let v=a[y+1];if(v<0||h>v+d-u)continue;let k=a[y]+d-u;m>=k?a[y+1]=h<=k?-2:-1:h>=d&&x&&(a[y]+=x,a[y+1]+=x)}u+=x}),d=n.maps[c].map(d,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let d=n.map(t[c]+i),u=d-s;if(u<0||u>=r.content.size){l=!0;continue}let h=n.map(t[c+1]+i,-1),m=h-s,{index:g,offset:p}=r.content.findIndex(u),x=r.maybeChild(g);if(x&&p==u&&p+x.nodeSize==m){let y=a[c+2].mapInner(n,x,d+1,t[c]+i+1,o);y!=ln?(a[c]=u,a[c+1]=m,a[c+2]=y):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=vZ(a,t,e,n,s,i,o),d=Mh(c,r,0,o);e=d.local;for(let u=0;u<a.length;u+=3)a[u+1]<0&&(a.splice(u,3),u-=3);for(let u=0,h=0;u<d.children.length;u+=3){let m=d.children[u];for(;h<a.length&&a[h]<m;)h+=3;a.splice(h,0,d.children[u],d.children[u+1],d.children[u+2])}}return new Vt(e.sort(hi),a)}function wO(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new Er(s.from+e,s.to+e,s.type))}return n}function vZ(t,e,n,r,s,i,o){function a(l,c){for(let d=0;d<l.local.length;d++){let u=l.local[d].map(r,s,c);u?n.push(u):o.onRemove&&o.onRemove(l.local[d].spec)}for(let d=0;d<l.children.length;d+=3)a(l.children[d+2],l.children[d]+c+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&a(t[l+2],e[l]+i+1);return n}function bO(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function SO(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Mh(t,e,n,r){let s=[],i=!1;e.forEach((a,l)=>{let c=bO(t,a,l+n);if(c){i=!0;let d=Mh(c,a,n+l+1,r);d!=ln&&s.push(l,l+a.nodeSize,d)}});let o=wO(i?SO(t):t,-n).sort(hi);if(o.length){let a=new rv(e.content);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l],a)||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1))}return o.length||s.length?new Vt(o,s):ln}function hi(t,e){return t.from-e.from||t.to-e.to}function C0(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),oS(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),oS(e,s,r.copy(i.from,r.to)));break}}}return e}function oS(t,e,n){for(;e<t.length&&hi(n,t[e])>0;)e++;t.splice(e,0,n)}function Sg(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ln&&e.push(r)}),t.cursorWrapper&&e.push(Vt.create(t.state.doc,[t.cursorWrapper.deco])),li.from(e)}function kZ(t,e,n,r){let{node:s,fromOffset:i,toOffset:o,from:a,to:l}=t.docView.parseRange(e,n),c=t.domSel.range,d,u=c.anchorNode;if(u&&yl(t.dom,u)&&(d=[{node:u,offset:c.anchorOffset}],tm(c)||d.push({node:c.focusNode,offset:c.focusOffset})),wn&&t.input.lastKeyCode===8)for(let y=o;y>i;y--){let v=s.childNodes[y-1],k=v.pmViewDesc;if(v.nodeName=="BR"&&!k){o=y;break}if(!k||k.size)break}let h=t.state.doc,m=t.someProp("domParser")||ji.fromSchema(t.state.schema),g=h.resolve(a),p=null,x=m.parse(s,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:i,to:o,preserveWhitespace:g.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:wZ(r),context:g});if(d&&d[0].pos!=null){let y=d[0].pos,v=d[1]&&d[1].pos;v==null&&(v=y),p={anchor:y+a,head:v+a}}return{doc:x,sel:p,from:a,to:l}}const wZ=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(hn&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||hn&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},bZ=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function SZ(t,e,n,r,s,i){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let S=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,j=k0(t,t.domSel.range,S);if(j&&!t.state.selection.eq(j)&&t.domSel.active){if(wn&&Ns&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&ai(t,"Enter"))return;let $=t.state.tr.setSelection(j);S=="pointer"?$.setMeta("pointer",!0):S=="key"&&$.scrollIntoView(),o&&$.setMeta("composition",o),t.dispatch($)}return}let a=t.state.doc.resolve(e),l=a.sharedDepth(n);e=a.before(l+1),n=t.state.doc.resolve(n).after(l+1);let c=t.state.selection,d=kZ(t,e,n,i),u=t.state.doc,h=u.slice(d.from,d.to),m,g;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(m=t.state.selection.to,g="end"):(m=t.state.selection.from,g="start"),t.input.lastKeyCode=null;let p=_Z(h.content,d.doc.content,d.from,m,g);if(p&&t.input.domChangeCount++,(vl&&t.input.lastIOSEnter>Date.now()-225||Ns)&&i.some(S=>Ce(S)&&!bZ.test(S.nodeName))&&(!p||p.endA>=p.endB)&&ai(t,"Enter")){t.input.lastIOSEnter=0;return}if(!p)if(s&&c instanceof je&&!c.empty&&c.$head.sameParent(c.$anchor)&&!t.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))p={start:c.from,endA:c.to,endB:c.to};else{if(d.sel){let S=aS(t,t.state.doc,d.sel);if(S&&!S.eq(t.state.selection)){let j=t.state.tr.setSelection(S);o&&j.setMeta("composition",o),t.dispatch(j)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof je&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=d.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=d.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to));let x=d.doc.resolveNoCache(p.start-d.from),y=d.doc.resolveNoCache(p.endB-d.from),v=u.resolve(p.start),k=x.sameParent(y)&&x.parent.inlineContent&&v.end()>=p.endA;if((vl&&t.input.lastIOSEnter>Date.now()-225&&(!k||i.some(S=>S.nodeName=="DIV"||S.nodeName=="P"))||!k&&EZ(d.doc,x.pos,y.pos))&&ai(t,"Enter")){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&(k?p.endA>p.start&&p.endB==p.start:NZ(u,p.start,p.endA,x,y))&&ai(t,"Backspace")){Ns&&wn&&t.domSel.suppressChanges();return}wn&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),Ns&&!k&&x.start()!=y.start()&&y.parentOffset==0&&x.depth==y.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==p.endA&&(p.endB-=2,y=d.doc.resolveNoCache(p.endB-d.from),setTimeout(()=>ai(t,"Enter"),20));let w=p.start,C=p.endA,E=S=>{let j=S||t.state.tr.replace(w,C,d.doc.slice(p.start-d.from,p.endB-d.from));if(d.sel){let $=aS(t,j.doc,d.sel);$&&!(wn&&t.composing&&$.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&($.head==w||$.head==j.mapping.map(C)-1))&&j.setSelection($)}return o&&j.setMeta("composition",o),j.scrollIntoView()},_;if(k)if(x.pos==y.pos){let S=E(t.state.tr.delete(w,C)),j=u.resolve(p.start).marksAcross(u.resolve(p.endA));j&&S.ensureMarks(j),t.dispatch(S)}else if(p.endA==p.endB&&(_=CZ(x.parent.content.cut(x.parentOffset,y.parentOffset),v.parent.content.cut(v.parentOffset,p.endA-v.start())))){let S=E(t.state.tr);_.type=="add"?S.addMark(w,C,_.mark):S.removeMark(w,C,_.mark),t.dispatch(S)}else if(x.parent.child(x.index()).isText&&x.index()==y.index()-(y.textOffset?0:1)){let S=x.parent.textBetween(x.parentOffset,y.parentOffset),j=()=>E(t.state.tr.insertText(S,w,C));t.someProp("handleTextInput",$=>$(t,w,C,S,j))||t.dispatch(j())}else t.dispatch(E());else t.dispatch(E())}function aS(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:kl(t,e.resolve(n.anchor),e.resolve(n.head))}function CZ(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,o,a,l;for(let d=0;d<r.length;d++)s=r[d].removeFromSet(s);for(let d=0;d<n.length;d++)i=n[d].removeFromSet(i);if(s.length==1&&i.length==0)a=s[0],o="add",l=d=>d.mark(a.addToSet(d.marks));else if(s.length==0&&i.length==1)a=i[0],o="remove",l=d=>d.mark(a.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(l(e.child(d)));if(Y.from(c).eq(t))return{mark:a,type:o}}function NZ(t,e,n,r,s){if(n-e<=s.pos-r.pos||Cg(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.inlineContent){let a=i.nodeAfter;return a!=null&&n==e+a.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=t.resolve(Cg(i,!0,!0));return!o.parent.isTextblock||o.pos>n||Cg(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function EZ(t,e,n){let r=0,s=0;return t.nodesBetween(e,n,(i,o)=>{i.isTextblock&&o>=e&&o<n?r++:(i.isText?/\S/.test(i.text.slice(Math.max(0,e-o),Math.min(i.nodeSize,n-o))):i.isLeaf)&&s++}),s==0&&r==1}function Cg(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function _Z(t,e,n,r,s){let i=t.findDiffStart(e,n),o=n+t.size,a=n+e.size;if(i==null)return null;let{a:l,b:c}=t.findDiffEnd(e,o,a);if(s=="end"){let d=Math.max(0,i-Math.min(l,c));r-=l+d-i}if(l<i&&o<a){let d=r<=i&&r>=l?i-r:0;i-=d,c=i+(c-l),l=i}else if(c<i){let d=r<=i&&r>=c?i-r:0;i-=d,l=i+(l-c),c=i}return{start:i,endA:l,endB:c}}const jZ={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0};class $Z{constructor(e){this.view=e,this.queue=[],this.flushingSoon=-1,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.started=!1,this.observer=new window.MutationObserver(n=>{for(let r=0;r<n.length;r++)this.queue.push(n[r]);hn&&e.composing&&n.some(r=>r.type=="childList"&&r.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()})}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(e=!1){this.flushingSoon>-1?(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush(!0)):e&&this.flush(!0)}start(){this.observer.takeRecords(),this.observer.observe(this.view.dom,jZ),this.started=!0}stop(){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect(),this.started=!1}stopped(e){if(!this.started)return e();this.stop();try{return e()}finally{this.start()}}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=gl(i))n.add(i);for(let i=e.anchorNode;i;i=gl(i))if(n.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:Mt(r)?r.parentNode:r}))return this.view.domSel.ignore(e),!0}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(e=!0){let{view:n}=this;if(!n.docView||this.flushingSoon>-1)return;let r=this.pendingRecords();r.length&&(this.queue=[]),e&&n.domSel.read();let s=!n.domSel.suppress&&!n.domSel.synced&&!!uO(n)&&!this.ignoreSelectionChange(n.domSel.range),i=-1,o=-1,a=!1,l=[];if(n.editable)for(let d=0;d<r.length;d++){let u=this.registerMutation(r[d],l);u&&(i=i<0?u.from:Math.min(u.from,i),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(a=!0))}if(l.some(d=>d.nodeName=="BR")&&(n.input.lastKeyCode==8||n.input.lastKeyCode==46||wn&&(n.composing||n.input.compositionEndedAt>Date.now()-50)&&r.some(d=>d.type=="childList"&&d.removedNodes.length))){for(let d of l)if(d.nodeName=="BR"&&d.parentNode){let u=d.nextSibling;for(;u&&Ce(u);){if(u.contentEditable=="false"){d.parentNode.removeChild(d);break}u=u.firstChild}}}else if(Ir&&l.length){let d=l.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,h]=d;u.parentNode&&u.parentNode.parentNode==h.parentNode?h.remove():u.remove()}else{let{focusNode:u}=n.domSel.range;for(let h of d){let m=h.parentNode;m&&m.nodeName=="LI"&&(!u||TZ(n,u)!=m)&&h.remove()}}}let c=null;i<0&&s&&n.domSel.active&&n.input.lastFocus>Date.now()-200&&n.input.lastTouch<Date.now()-300&&tm(n.domSel.range)&&(c=k0(n,n.domSel.range))&&c.eq(Ue.near(n.state.doc.resolve(0),1))?(n.input.lastFocus=0,n.domSel.sync(),n.scrollToSelection()):(i>-1||s)&&(i>-1&&MZ(n),n.input.badSafariComposition&&(n.input.badSafariComposition=!1,OZ(n,l)),SZ(this.view,i,o,s,a,l),n.docView&&n.docView.damage?n.updateState(n.state):s&&n.domSel.sync())}registerMutation(e,n){var r;if(n.indexOf(e.target)>-1)return null;let s;for(let i=e.target;i&&!(s=this.view.docView.getDesc(i));i=i.parentNode);if(e.type=="attributes"&&(s==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!s||s.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let h=e.addedNodes[u];n.push(h),Mt(h)&&(this.lastChangedTextNode=h)}if(s.contentDOM&&s.contentDOM!=s.dom&&!s.contentDOM.contains(e.target))return s.markDamage(4),{from:s.posBefore,to:s.posAfter};let i=e.previousSibling,o=e.nextSibling,a=i&&i.parentNode==e.target?fn(i)+1:0,l=s.localPosFromDOM(e.target,a,-1),c=o&&o.parentNode==e.target?fn(o):e.target.childNodes.length,d=s.localPosFromDOM(e.target,c,1);return s.markDamage(!((r=s.contentDOM)===null||r===void 0)&&r.contains(e.target)?2:4),{from:l,to:d}}else return e.type=="attributes"?(s.markDamage(4),{from:s.posAtStart-s.border,to:s.posAtEnd+s.border}):(this.lastChangedTextNode=e.target,s.markDamage(s instanceof Qd&&e.target==s.nodeDOM?8:4),{from:s.posAtStart,to:s.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let lS=new WeakMap,cS=!1;function MZ(t){if(!lS.has(t)&&(lS.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Ir,cS)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),cS=!0}}function TZ(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function OZ(t,e){var n;let{focusNode:r,focusOffset:s}=t.domSel.range;for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=i.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let a=o;for(;;){let l=a.firstChild;if(!l||!Ce(l)||l.contentEditable=="false"||/^(BR|IMG)$/.test(l.nodeName))break;a=l}a.insertBefore(i,a.firstChild),r==i&&t.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}class CO{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new GU,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(pS),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=fS(this),uS(this),this.nodeViews=hS(this),this.docView=W2(this.state.doc,dS(this),Sg(this),this.dom,this),this.domObserver=new $Z(this),this.domSel=new VU(this),this.domObserver.start(),this.domSel.read(),YU(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&tv(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(pS),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(yO(this),o=!0),this.state=e;let a=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(a||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let m=hS(this);RZ(m,this.nodeViews)&&(this.nodeViews=m,i=!0)}(a||n.handleDOMEvents!=this._props.handleDOMEvents)&&tv(this),this.editable=fS(this),uS(this);let l=Sg(this),c=dS(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,l);(u||!e.selection.eq(s.selection))&&(o=!0);let h=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&uU(this);o&&this.domObserver.stopped(()=>{let m=u&&wn&&!this.composing&&!s.selection.empty&&!e.selection.empty&&AZ(s.selection,e.selection);if(u){let g=wn?this.trackWrites=this.domSel.range.focusNode:null;if(this.composing&&(this.input.compositionNode=fZ(this)),i||!this.docView.update(e.doc,c,l,this,-1)){let p=this.docView.outerDeco;this.docView.destroy(),this.docView=W2(e.doc,c,l,this.dom,this,p)}g&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(m=!0)}this.domSel.sync(m)}),this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():h&&fU(h)}scrollToSelection(){let e=this.domSel.range.focusNode;if(!(!e||!this.domSel.active)){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Se){let n=this.docView.domAfterPos(this.state.selection.from);Ce(n)&&z2(this,n.getBoundingClientRect(),e)}else z2(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new vO(e.slice,e.move,s<0?void 0:Se.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let a=this.directPlugins[o].props[e];if(a!=null&&(s=n?n(a):a))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let a=i[o].props[e];if(a!=null&&(s=n?n(a):a))return s}}hasFocus(){return this.root.activeElement==this.dom}focus(){this.editable&&Z4(this.dom),this.domSel.sync()}get root(){let e=this.dom.isConnected!==!1;e||(this._root=null);let n=this._root;if(n==null&&e){for(let r=this.dom.parentNode;r;r=r.parentNode)if(r.nodeType==9||r.nodeType==11&&r.host)return r.getSelection||(Object.getPrototypeOf(r).getSelection=()=>r.ownerDocument.getSelection()),this._root=r}return n||document}updateRoot(){this._root=null}posAtCoords(e){return yU(this,e)}coordsAtPos(e,n=1){return J4(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return bU(this,n||this.state,e)}pasteHTML(e,n){return bd(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return bd(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return v0(this,e)}destroy(){this.docView&&(QU(this),this.domSel.destroy(),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Sg(this),this,-1),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,rU())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return eZ(this,e)}domSelection(){return this.root.getSelection()}}CO.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function dS(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[Er.node(0,t.state.doc.content.size,e)]}function uS(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Er.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function fS(t){return!t.someProp("editable",e=>e(t.state)===!1)}function AZ(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function hS(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function RZ(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function pS(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Ui={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:"'"},Th={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},IZ=typeof navigator<"u"&&/Mac/.test(navigator.platform),PZ=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var en=0;en<10;en++)Ui[48+en]=Ui[96+en]=String(en);for(var en=1;en<=24;en++)Ui[en+111]="F"+en;for(var en=65;en<=90;en++)Ui[en]=String.fromCharCode(en+32),Th[en]=String.fromCharCode(en);for(var Ng in Ui)Th.hasOwnProperty(Ng)||(Th[Ng]=Ui[Ng]);function DZ(t){var e=IZ&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||PZ&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Th:Ui)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const zZ=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),LZ=typeof navigator<"u"&&/Win/.test(navigator.platform);function FZ(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))i=!0;else if(/^mod$/i.test(l))zZ?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function BZ(t){let e=Object.create(null);for(let n in t)e[FZ(n)]=t[n];return e}function Eg(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function VZ(t){return new Bn({props:{handleKeyDown:WZ(t)}})}function WZ(t){let e=BZ(t);return function(n,r){let s=DZ(r),i,o=e[Eg(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let a=e[Eg(s,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(LZ&&r.ctrlKey&&r.altKey)&&(i=Ui[r.keyCode])&&i!=s){let a=e[Eg(i,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}var UZ=Object.defineProperty,N0=(t,e)=>{for(var n in e)UZ(t,n,{get:e[n],enumerable:!0})};function sm(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}var im=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:s}=n,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([o,a])=>[o,(...c)=>{const d=a(...c)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o=[],a=!!t,l=t||s.tr,c=()=>(!a&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(l),o.every(u=>u===!0)),d={...Object.fromEntries(Object.entries(n).map(([u,h])=>[u,(...g)=>{const p=this.buildProps(l,e),x=h(...g)(p);return o.push(x),d}])),run:c};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.tr,i=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...c)=>l(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o={tr:t,editor:r,view:i,state:sm({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([a,l])=>[a,(...c)=>l(...c)(o)]))}};return o}},NO={};N0(NO,{blur:()=>ZZ,clearContent:()=>HZ,clearNodes:()=>qZ,command:()=>KZ,createParagraphNear:()=>JZ,cut:()=>GZ,deleteCurrentNode:()=>YZ,deleteNode:()=>QZ,deleteRange:()=>XZ,deleteSelection:()=>nH,enter:()=>rH,exitCode:()=>sH,extendMarkRange:()=>iH,first:()=>oH,focus:()=>lH,forEach:()=>cH,insertContent:()=>dH,insertContentAt:()=>fH,insertDefaultBlock:()=>hH,joinBackward:()=>gH,joinDown:()=>mH,joinForward:()=>yH,joinItemBackward:()=>xH,joinItemForward:()=>vH,joinTextblockBackward:()=>kH,joinTextblockForward:()=>wH,joinUp:()=>pH,keyboardShortcut:()=>SH,lift:()=>CH,liftEmptyBlock:()=>NH,liftListItem:()=>EH,newlineInCode:()=>_H,resetAttributes:()=>jH,scrollIntoView:()=>$H,selectAll:()=>MH,selectNodeBackward:()=>TH,selectNodeForward:()=>OH,selectParentNode:()=>AH,selectTextblockEnd:()=>RH,selectTextblockStart:()=>IH,setContent:()=>PH,setMark:()=>XH,setMeta:()=>eq,setNode:()=>tq,setNodeSelection:()=>nq,setTextDirection:()=>rq,setTextSelection:()=>sq,sinkListItem:()=>iq,splitBlock:()=>oq,splitListItem:()=>aq,toggleList:()=>cq,toggleMark:()=>dq,toggleNode:()=>uq,toggleWrap:()=>fq,undoInputRule:()=>hq,unsetAllMarks:()=>pq,unsetMark:()=>mq,unsetTextDirection:()=>gq,updateAttributes:()=>yq,wrapIn:()=>xq,wrapInList:()=>vq});var ZZ=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),HZ=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),qZ=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:i,$to:o})=>{t.doc.nodesBetween(i.pos,o.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(l)),h=c.resolve(d.map(l+a.nodeSize)),m=u.blockRange(h);if(!m)return;const g=Dl(m);if(a.type.isTextblock){const{defaultType:p}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(m.start,p)}(g||g===0)&&e.lift(m,g)})}),!0},KZ=t=>e=>t(e),JZ=()=>({state:t,dispatch:e})=>P4(t,e),GZ=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,i=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new je(r.doc.resolve(Math.max(o-1,0)))),!0},YZ=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const a=s.before(i),l=s.after(i);t.delete(a,l).scrollIntoView()}return!0}return!1};function qt(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var QZ=t=>({tr:e,state:n,dispatch:r})=>{const s=qt(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const l=i.before(o),c=i.after(o);e.delete(l,c).scrollIntoView()}return!0}return!1},XZ=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},eH=t=>t.content?/^text(\*|\+)/.test(t.content):!1,mS=(t,e,n)=>{if(!t.parent.isInline||n==="left"&&t.pos>t.start()||n==="right"&&t.pos<t.end())return t.pos;const r=e.nodes[t.parent.type.name].spec;return eH(r)?n==="left"?t.start()-1:t.end()+1:t.pos},tH=(t,e,n)=>{const r=mS(t,n,"left"),s=mS(e,n,"right");return{from:r,to:s}},nH=()=>({state:t,dispatch:e})=>{if(t.selection.empty)return!1;if(e){const n=t.tr,{ranges:r}=t.selection,s=n.steps.length;r.forEach(i=>{const o=n.mapping.slice(s),a=n.doc.resolve(o.map(i.$from.pos)),l=n.doc.resolve(o.map(i.$to.pos)),{from:c,to:d}=tH(a,l,t.schema);n.deleteRange(c,d)}),n.selection.empty||n.setSelection(je.near(n.doc.resolve(n.selection.from))),n.scrollIntoView(),e(n)}return!0},rH=()=>({commands:t})=>t.keyboardShortcut("Enter"),sH=()=>({state:t,dispatch:e})=>VW(t,e);function E0(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Oh(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:E0(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function EO(t,e,n={}){return t.find(r=>r.type===e&&Oh(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function gS(t,e,n={}){return!!EO(t,e,n)}function _0(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(c=>c.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(c=>c.type===e))return;if(!n){const c=r.node.marks.find(d=>d.type===e);c&&(n=c.attrs)}if(!EO([...r.node.marks],e,n))return;let i=r.index,o=t.start()+r.offset,a=i+1,l=o+r.node.nodeSize;for(;i>0&&gS([...t.parent.child(i-1).marks],e,n);)i-=1,o-=t.parent.child(i).nodeSize;for(;a<t.parent.childCount&&gS([...t.parent.child(a).marks],e,n);)l+=t.parent.child(a).nodeSize,a+=1;return{from:o,to:l}}function Zs(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var iH=(t,e)=>({tr:n,state:r,dispatch:s})=>{const i=Zs(t,r.schema),{doc:o,selection:a}=n,{$from:l,from:c,to:d}=a;if(s){const u=_0(l,i,e);if(u&&u.from<=c&&u.to>=d){const h=je.create(o,u.from,u.to);n.setSelection(h)}}return!0},oH=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function _O(t){return t instanceof je}function po(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function sv(t,e=null){if(!e)return null;const n=Ue.atStart(t),r=Ue.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,i=r.to;return e==="all"?je.create(t,po(0,s,i),po(t.content.size,s,i)):je.create(t,po(e,s,i),po(e,s,i))}function yS(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function Ah(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function aH(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var lH=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(Ah()||yS())&&r.dom.focus(),aH()&&!Ah()&&!yS()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!_O(n.state.selection))return o(),!0;const a=sv(s.doc,t)||n.state.selection,l=n.state.selection.eq(a);return i&&(l||s.setSelection(a),l&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},cH=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),dH=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),jO=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&jO(r)}return t};function Iu(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return jO(n)}function wl(t,e,n){if(t instanceof _i||t instanceof Y)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return Y.fromArray(t.map(a=>e.nodeFromJSON(a)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),wl("",e,n)}if(s){if(n.errorOnInvalidContent){let o=!1,a="";const l=new l4({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?ji.fromSchema(l).parseSlice(Iu(t),n.parseOptions):ji.fromSchema(l).parse(Iu(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const i=ji.fromSchema(e);return n.slice?i.parseSlice(Iu(t),n.parseOptions).content:i.parse(Iu(t),n.parseOptions)}return wl("",e,n)}function $O(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof _t||s instanceof Zt))return;const i=t.mapping.maps[r];let o=0;i.forEach((a,l,c,d)=>{o===0&&(o=d)}),t.setSelection(Ue.near(t.doc.resolve(o),n))}var uH=t=>!("type"in t),fH=(t,e,n)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a;const l=x=>{i.emit("contentError",{editor:i,error:x,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{wl(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(x){l(x)}try{a=wl(e,i.schema,{parseOptions:c,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(x){return l(x),!1}let{from:d,to:u}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},h=!0,m=!0;if((uH(a)?a:[a]).forEach(x=>{x.check(),h=h?x.isText&&x.marks.length===0:!1,m=m?x.isBlock:!1}),d===u&&m){const{parent:x}=r.doc.resolve(d);x.isTextblock&&!x.type.spec.code&&!x.childCount&&(d-=1,u+=1)}let p;if(h){if(Array.isArray(e))p=e.map(x=>x.text||"").join("");else if(e instanceof Y){let x="";e.forEach(y=>{y.text&&(x+=y.text)}),p=x}else typeof e=="object"&&e&&e.text?p=e.text:p=e;r.insertText(p,d,u)}else{p=a;const x=r.doc.resolve(d),y=x.node(),v=x.parentOffset===0,k=y.isText||y.isTextblock,w=y.content.size>0;v&&k&&w&&m&&(d=Math.max(0,d-1)),r.replaceWith(d,u,p)}n.updateSelection&&$O(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:p}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:p})}return!0};function MO(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var hH=(t={})=>({tr:e,dispatch:n,editor:r})=>{const{pos:s,attrs:i,content:o,updateSelection:a=!0}=t;let l;typeof s=="number"?l=e.doc.resolve(s):s?l=s:l=e.selection.$from;const c=MO(l.parent.contentMatchAt(l.index()));if(!c)return!1;const d=Object.keys(c.spec.attrs||{}),u=i?Object.fromEntries(Object.entries(i).filter(([m])=>d.includes(m))):{};let h;if(o){const m=wl(o,r.schema);h=c.createAndFill(u,m)}else h=c.createAndFill(u);return h?(n&&(e.insert(l.pos,h),a&&$O(e,e.steps.length-1,-1)),!0):!1},pH=()=>({state:t,dispatch:e})=>LW(t,e),mH=()=>({state:t,dispatch:e})=>FW(t,e),gH=()=>({state:t,dispatch:e})=>$4(t,e),yH=()=>({state:t,dispatch:e})=>A4(t,e),xH=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Qp(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},vH=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Qp(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},kH=()=>({state:t,dispatch:e})=>DW(t,e),wH=()=>({state:t,dispatch:e})=>zW(t,e);function TO(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function bH(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,s,i,o;for(let a=0;a<e.length-1;a+=1){const l=e[a];if(/^(cmd|meta|m)$/i.test(l))o=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))s=!0;else if(/^s(hift)?$/i.test(l))i=!0;else if(/^mod$/i.test(l))Ah()||TO()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var SH=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const i=bH(t).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,a))});return l==null||l.steps.forEach(c=>{const d=c.map(r.mapping);d&&s&&r.maybeStep(d)}),!0};function Cd(t,e,n={}){const{from:r,to:s,empty:i}=t.selection,o=e?qt(e,t.schema):null,a=[];t.doc.nodesBetween(r,s,(u,h)=>{if(u.isText)return;const m=Math.max(r,h),g=Math.min(s,h+u.nodeSize);a.push({node:u,from:m,to:g})});const l=s-r,c=a.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>Oh(u.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((u,h)=>u+h.to-h.from,0)>=l}var CH=(t,e={})=>({state:n,dispatch:r})=>{const s=qt(t,n.schema);return Cd(n,s,e)?BW(n,r):!1},NH=()=>({state:t,dispatch:e})=>D4(t,e),EH=t=>({state:e,dispatch:n})=>{const r=qt(t,e.schema);return XW(r)(e,n)},_H=()=>({state:t,dispatch:e})=>I4(t,e);function om(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function xS(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var jH=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const a=om(typeof t=="string"?t:t.name,r.schema);if(!a)return!1;a==="node"&&(i=qt(t,r.schema)),a==="mark"&&(o=Zs(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(d,u)=>{i&&i===d.type&&(l=!0,s&&n.setNodeMarkup(u,void 0,xS(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(h=>{o===h.type&&(l=!0,s&&n.addMark(u,u+d.nodeSize,o.create(xS(h.attrs,e))))})})}),l},$H=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),MH=()=>({tr:t,dispatch:e})=>{if(e){const n=new Jn(t.doc);t.setSelection(n)}return!0},TH=()=>({state:t,dispatch:e})=>T4(t,e),OH=()=>({state:t,dispatch:e})=>R4(t,e),AH=()=>({state:t,dispatch:e})=>ZW(t,e),RH=()=>({state:t,dispatch:e})=>KW(t,e),IH=()=>({state:t,dispatch:e})=>qW(t,e);function iv(t,e,n={},r={}){return wl(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var PH=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:a})=>{const{doc:l}=i;if(r.preserveWhitespace!=="full"){const c=iv(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return o&&i.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),a.insertContentAt({from:0,to:l.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function OO(t,e){const n=Zs(e,t.schema),{from:r,to:s,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,l=>{o.push(...l.marks)});const a=o.find(l=>l.type.name===n.name);return a?{...a.attrs}:{}}function AO(t,e){const n=new C4(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function DH(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function zH(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function j0(t){return e=>zH(e.$from,t)}function be(t,e,n){return t.config[e]===void 0&&t.parent?be(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?be(t.parent,e,n):null}):t.config[e]}function $0(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=be(e,"addExtensions",n);return r?[e,...$0(r())]:e}).flat(10)}function M0(t,e){const n=Yo.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function RO(t){return typeof t=="function"}function nt(t,e=void 0,...n){return RO(t)?e?t.bind(e)(...n):t(...n):t}function LH(t={}){return Object.keys(t).length===0&&t.constructor===Object}function bl(t){const e=t.filter(s=>s.type==="extension"),n=t.filter(s=>s.type==="node"),r=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function IO(t){const e=[],{nodeExtensions:n,markExtensions:r}=bl(t),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(c=>c.name!=="text").map(c=>c.name),a=r.map(c=>c.name),l=[...o,...a];return t.forEach(c=>{const d={name:c.name,options:c.options,storage:c.storage,extensions:s},u=be(c,"addGlobalAttributes",d);if(!u)return;u().forEach(m=>{let g;Array.isArray(m.types)?g=m.types:m.types==="*"?g=l:m.types==="nodes"?g=o:m.types==="marks"?g=a:g=[],g.forEach(p=>{Object.entries(m.attributes).forEach(([x,y])=>{e.push({type:p,name:x,attribute:{...i,...y}})})})})}),s.forEach(c=>{const d={name:c.name,options:c.options,storage:c.storage},u=be(c,"addAttributes",d);if(!u)return;const h=u();Object.entries(h).forEach(([m,g])=>{const p={...i,...g};typeof(p==null?void 0:p.default)=="function"&&(p.default=p.default()),p!=null&&p.isRequired&&(p==null?void 0:p.default)===void 0&&delete p.default,e.push({type:c.name,name:m,attribute:p})})}),e}function FH(t){const e=[];let n="",r=!1,s=!1,i=0;const o=t.length;for(let a=0;a<o;a+=1){const l=t[a];if(l==="'"&&!s){r=!r,n+=l;continue}if(l==='"'&&!r){s=!s,n+=l;continue}if(!r&&!s){if(l==="("){i+=1,n+=l;continue}if(l===")"&&i>0){i-=1,n+=l;continue}if(l===";"&&i===0){e.push(n),n="";continue}}n+=l}return n&&e.push(n),e}function vS(t){const e=[],n=FH(t||""),r=n.length;for(let s=0;s<r;s+=1){const i=n[s],o=i.indexOf(":");if(o===-1)continue;const a=i.slice(0,o).trim(),l=i.slice(o+1).trim();a&&l&&e.push([a,l])}return e}function Zi(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const a=i?String(i).split(" "):[],l=r[s]?r[s].split(" "):[],c=a.filter(d=>!l.includes(d));r[s]=[...l,...c].join(" ")}else if(s==="style"){const a=new Map([...vS(r[s]),...vS(i)]);r[s]=Array.from(a.entries()).map(([l,c])=>`${l}: ${c}`).join("; ")}else r[s]=i}),r},{})}function Rh(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>Zi(n,r),{})}function BH(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function kS(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const a=o.attribute.parseHTML?o.attribute.parseHTML(n):BH(n.getAttribute(o.name));return a==null?i:{...i,[o.name]:a}},{});return{...r,...s}}}}function wS(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&LH(n)?!1:n!=null))}function bS(t){var e,n;const r={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(r.default=t.attribute.default),((n=t==null?void 0:t.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function VH(t,e){var n;const r=IO(t),{nodeExtensions:s,markExtensions:i}=bl(t),o=(n=s.find(c=>be(c,"topNode")))==null?void 0:n.name,a=Object.fromEntries(s.map(c=>{const d=r.filter(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((y,v)=>{const k=be(v,"extendNodeSchema",u);return{...y,...k?k(c):{}}},{}),m=wS({...h,content:nt(be(c,"content",u)),marks:nt(be(c,"marks",u)),group:nt(be(c,"group",u)),inline:nt(be(c,"inline",u)),atom:nt(be(c,"atom",u)),selectable:nt(be(c,"selectable",u)),draggable:nt(be(c,"draggable",u)),code:nt(be(c,"code",u)),whitespace:nt(be(c,"whitespace",u)),linebreakReplacement:nt(be(c,"linebreakReplacement",u)),defining:nt(be(c,"defining",u)),isolating:nt(be(c,"isolating",u)),attrs:Object.fromEntries(d.map(bS))}),g=nt(be(c,"parseHTML",u));g&&(m.parseDOM=g.map(y=>kS(y,d)));const p=be(c,"renderHTML",u);p&&(m.toDOM=y=>p({node:y,HTMLAttributes:Rh(y,d)}));const x=be(c,"renderText",u);return x&&(m.toText=x),[c.name,m]})),l=Object.fromEntries(i.map(c=>{const d=r.filter(x=>x.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((x,y)=>{const v=be(y,"extendMarkSchema",u);return{...x,...v?v(c):{}}},{}),m=wS({...h,inclusive:nt(be(c,"inclusive",u)),excludes:nt(be(c,"excludes",u)),group:nt(be(c,"group",u)),spanning:nt(be(c,"spanning",u)),code:nt(be(c,"code",u)),attrs:Object.fromEntries(d.map(bS))}),g=nt(be(c,"parseHTML",u));g&&(m.parseDOM=g.map(x=>kS(x,d)));const p=be(c,"renderHTML",u);return p&&(m.toDOM=x=>p({mark:x,HTMLAttributes:Rh(x,d)})),[c.name,m]}));return new l4({topNode:o,nodes:a,marks:l})}function WH(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Ac(t){return t.sort((n,r)=>{const s=be(n,"priority")||100,i=be(r,"priority")||100;return s>i?-1:s<i?1:0})}function PO(t){const e=Ac($0(t)),n=WH(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function DO(t,e,n){const{from:r,to:s}=e,{blockSeparator:i=`
832
+
833
+ `,textSerializers:o={}}=n||{};let a="";return t.nodesBetween(r,s,(l,c,d,u)=>{var h;l.isBlock&&c>r&&(a+=i);const m=o==null?void 0:o[l.type.name];if(m)return d&&(a+=m({node:l,pos:c,parent:d,index:u,range:e})),!1;l.isText&&(a+=(h=l==null?void 0:l.text)==null?void 0:h.slice(Math.max(r,c)-c,s-c))}),a}function UH(t,e){const n={from:0,to:t.content.size};return DO(t,n,e)}function zO(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function ZH(t,e){const n=qt(e,t.schema),{from:r,to:s}=t.selection,i=[];t.doc.nodesBetween(r,s,a=>{i.push(a)});const o=i.reverse().find(a=>a.type.name===n.name);return o?{...o.attrs}:{}}function LO(t,e){const n=om(typeof e=="string"?e:e.name,t.schema);return n==="node"?ZH(t,e):n==="mark"?OO(t,e):{}}function HH(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function qH(t){const e=HH(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,o)=>o!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function FO(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((a,l)=>{o.push({from:a,to:l})});else{const{from:a,to:l}=n[i];if(a===void 0||l===void 0)return;o.push({from:a,to:l})}o.forEach(({from:a,to:l})=>{const c=e.slice(i).map(a,-1),d=e.slice(i).map(l),u=e.invert().map(c,-1),h=e.invert().map(d);r.push({oldRange:{from:u,to:h},newRange:{from:c,to:d}})})}),qH(r)}function T0(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const i=n.resolve(t),o=_0(i,s.type);o&&r.push({mark:s,...o})}):n.nodesBetween(t,e,(s,i)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}function Xl(t,e){return e.nodes[t]||e.marks[t]||null}function ff(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}var KH=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,a)=>{var l,c;const d=((c=(l=s.type.spec).toText)==null?void 0:c.call(l,{node:s,pos:i,parent:o,index:a}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?d:d.slice(0,Math.max(0,r-i))}),n};function ov(t,e,n={}){const{empty:r,ranges:s}=t.selection,i=e?Zs(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>Oh(u.attrs,n,{strict:!1}));let o=0;const a=[];if(s.forEach(({$from:u,$to:h})=>{const m=u.pos,g=h.pos;t.doc.nodesBetween(m,g,(p,x)=>{if(i&&p.inlineContent&&!p.type.allowsMarkType(i))return!1;if(!p.isText&&!p.marks.length)return;const y=Math.max(m,x),v=Math.min(g,x+p.nodeSize),k=v-y;o+=k,a.push(...p.marks.map(w=>({mark:w,from:y,to:v})))})}),o===0)return!1;const l=a.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>Oh(u.mark.attrs,n,{strict:!1})).reduce((u,h)=>u+h.to-h.from,0),c=a.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,h)=>u+h.to-h.from,0);return(l>0?l+c:l)>=o}function JH(t,e,n={}){if(!e)return Cd(t,null,n)||ov(t,null,n);const r=om(e,t.schema);return r==="node"?Cd(t,e,n):r==="mark"?ov(t,e,n):!1}function SS(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function _g(t,e){const{nodeExtensions:n}=bl(e),r=n.find(o=>o.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=nt(be(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function O0(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return!/\S/.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(i=>{s!==!1&&(O0(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}var BO=class VO{constructor(e){this.position=e}static fromJSON(e){return new VO(e.position)}toJSON(){return{position:this.position}}};function GH(t,e){const n=e.mapping.mapResult(t.position);return{position:new BO(n.pos),mapResult:n}}function YH(t){return new BO(t)}function QH(t,e,n){var r;const{selection:s}=e;let i=null;if(_O(s)&&(i=s.$cursor),i){const a=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(a)||!a.some(c=>c.type.excludes(n)))}const{ranges:o}=s;return o.some(({$from:a,$to:l})=>{let c=a.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(a.pos,l.pos,(d,u,h)=>{if(c)return!1;if(d.isInline){const m=!h||h.type.allowsMarkType(n),g=!!n.isInSet(d.marks)||!d.marks.some(p=>p.type.excludes(n));c=m&&g}return!c}),c})}var XH=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:o,ranges:a}=i,l=Zs(t,r.schema);if(s)if(o){const c=OO(r,l);n.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(h,m)=>{const g=Math.max(m,d),p=Math.min(m+h.nodeSize,u);h.marks.find(y=>y.type===l)?h.marks.forEach(y=>{l===y.type&&n.addMark(g,p,l.create({...y.attrs,...e}))}):n.addMark(g,p,l.create(e))})});return QH(r,n,l)},eq=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),tq=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const i=qt(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:a})=>A2(i,{...o,...e})(n)?!0:a.clearNodes()).command(({state:a})=>A2(i,{...o,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},nq=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=po(t,0,r.content.size),i=Se.create(r,s);e.setSelection(i)}return!0},rq=(t,e)=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=r;let o,a;return typeof e=="number"?(o=e,a=e):e&&"from"in e&&"to"in e?(o=e.from,a=e.to):(o=i.from,a=i.to),s&&n.doc.nodesBetween(o,a,(l,c)=>{l.isText||n.setNodeMarkup(c,void 0,{...l.attrs,dir:t})}),!0},sq=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,o=je.atStart(r).from,a=je.atEnd(r).to,l=po(s,o,a),c=po(i,o,a),d=je.create(r,l,c);e.setSelection(d)}return!0},iq=t=>({state:e,dispatch:n})=>{const r=qt(t,e.schema);return nU(r)(e,n)};function CS(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e==null?void 0:e.includes(s.type.name));t.tr.ensureMarks(r)}}var oq=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:a,$to:l}=i,c=s.extensionManager.attributes,d=ff(c,a.node().type.name,a.node().attrs);if(i instanceof Se&&i.node.isBlock)return!a.parentOffset||!Ts(o,a.pos)?!1:(r&&(t&&CS(n,s.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const u=l.parentOffset===l.parent.content.size,h=a.depth===0?void 0:MO(a.node(-1).contentMatchAt(a.indexAfter(-1)));let m=u&&h?[{type:h,attrs:d}]:void 0,g=Ts(e.doc,e.mapping.map(a.pos),1,m);if(!m&&!g&&Ts(e.doc,e.mapping.map(a.pos),1,h?[{type:h}]:void 0)&&(g=!0,m=h?[{type:h,attrs:d}]:void 0),r){if(g&&(i instanceof je&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,m),h&&!u&&!a.parentOffset&&a.parent.type!==h)){const p=e.mapping.map(a.before()),x=e.doc.resolve(p);a.node(-1).canReplaceWith(x.index(),x.index()+1,h)&&e.setNodeMarkup(e.mapping.map(a.before()),h)}t&&CS(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return g},aq=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var o;const a=qt(t,r.schema),{$from:l,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(c))return!1;const u=l.node(-1);if(u.type!==a)return!1;const h=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(s){let y=Y.empty;const v=l.index(-1)?1:l.index(-2)?2:3;for(let S=l.depth-v;S>=l.depth-3;S-=1)y=Y.from(l.node(S).copy(y));const k=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,w={...ff(h,l.node().type.name,l.node().attrs),...e},C=((o=a.contentMatch.defaultType)==null?void 0:o.createAndFill(w))||void 0;y=y.append(Y.from(a.createAndFill(null,C)||void 0));const E=l.before(l.depth-(v-1));n.replace(E,l.after(-k),new ue(y,4-v,0));let _=-1;n.doc.nodesBetween(E,n.doc.content.size,(S,j)=>{if(_>-1)return!1;S.isTextblock&&S.content.size===0&&(_=j+1)}),_>-1&&n.setSelection(je.near(n.doc.resolve(_))),n.scrollIntoView()}return!0}const m=c.pos===l.end()?u.contentMatchAt(0).defaultType:null,g={...ff(h,u.type.name,u.attrs),...e},p={...ff(h,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);const x=m?[{type:a,attrs:g},{type:m,attrs:p}]:[{type:a,attrs:g}];if(!Ts(n.doc,l.pos,2))return!1;if(s){const{selection:y,storedMarks:v}=r,{splittableMarks:k}=i.extensionManager,w=v||y.$to.parentOffset&&y.$from.marks();if(n.split(l.pos,2,x).scrollIntoView(),!w||!s)return!0;const C=w.filter(E=>k.includes(E.type.name));n.ensureMarks(C)}return!0};function NS(t){return!t||t==="1"?null:t}function WO(t,e){return NS(t)===NS(e)}var jg=(t,e)=>{const n=j0(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return!(n.node.type===(s==null?void 0:s.type)&&Qo(t.doc,n.pos))||!WO(n.node.attrs.type,s==null?void 0:s.attrs.type)||t.join(n.pos),!0},$g=(t,e)=>{const n=j0(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return!(n.node.type===(s==null?void 0:s.type)&&Qo(t.doc,r))||!WO(n.node.attrs.type,s==null?void 0:s.attrs.type)||t.join(r),!0};function lq(t){const e=t.doc,n=e.firstChild;if(!n)return null;const r=e.resolve(1),s=e.resolve(n.nodeSize-1);return je.between(r,s)}var cq=(t,e,n,r={})=>({editor:s,tr:i,state:o,dispatch:a,chain:l,commands:c,can:d})=>{const{extensions:u,splittableMarks:h}=s.extensionManager,m=qt(t,o.schema),g=qt(e,o.schema),{selection:p,storedMarks:x}=o,{$from:y,$to:v}=p,k=y.blockRange(v),w=x||p.$to.parentOffset&&p.$from.marks();if(!k)return!1;const C=j0(D=>_g(D.type.name,u))(p),E=p.from===0&&p.to===o.doc.content.size,_=o.doc.content.content,S=_.length===1?_[0]:null,j=E&&S&&_g(S.type.name,u)?{node:S,pos:0}:null,$=C??j,I=!!C&&k.depth>=1&&k.depth-C.depth<=1,L=!!j;if((I||L)&&$){if($.node.type===m)return E&&L?l().command(({tr:D,dispatch:B})=>{const H=lq(D);return H?(D.setSelection(H),B&&B(D),!0):!1}).liftListItem(g).run():c.liftListItem(g);if(_g($.node.type.name,u)&&m.validContent($.node.content))return l().command(()=>(i.setNodeMarkup($.pos,m),!0)).command(()=>jg(i,m)).command(()=>$g(i,m)).run()}return!n||!w||!a?l().command(()=>d().wrapInList(m,r)?!0:c.clearNodes()).wrapInList(m,r).command(()=>jg(i,m)).command(()=>$g(i,m)).run():l().command(()=>{const D=d().wrapInList(m,r),B=w.filter(H=>h.includes(H.type.name));return i.ensureMarks(B),D?!0:c.clearNodes()}).wrapInList(m,r).command(()=>jg(i,m)).command(()=>$g(i,m)).run()},dq=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,o=Zs(t,r.schema);return ov(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},uq=(t,e,n={})=>({state:r,commands:s})=>{const i=qt(t,r.schema),o=qt(e,r.schema),a=Cd(r,i,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?s.setNode(o,l):s.setNode(i,{...l,...n})},fq=(t,e={})=>({state:n,commands:r})=>{const s=qt(t,n.schema);return Cd(n,s,e)?r.lift(s):r.wrapIn(s,e)},hq=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let i;if(s.spec.isInputRules&&(i=s.getState(t))){if(e){const o=t.tr,a=i.transform;for(let l=a.steps.length-1;l>=0;l-=1)o.step(a.steps[l].invert(a.docs[l]));if(i.text){const l=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,t.schema.text(i.text,l))}else o.delete(i.from,i.to)}return!0}}return!1},pq=(t={})=>({tr:e,dispatch:n,editor:r})=>{const{ignoreClearable:s=!1}=t,{selection:i}=e,{empty:o,ranges:a}=i;if(o)return!0;const{nonClearableMarks:l}=r.extensionManager;if(n){const c=Object.values(r.schema.marks).filter(d=>s||!l.includes(d.name));a.forEach(d=>{for(const u of c)e.removeMark(d.$from.pos,d.$to.pos,u)})}return!0},mq=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:a}=n,l=Zs(t,r.schema),{$from:c,empty:d,ranges:u}=a;if(!s)return!0;if(d&&o){let{from:h,to:m}=a;const g=(i=c.marks().find(x=>x.type===l))==null?void 0:i.attrs,p=_0(c,l,g);p&&(h=p.from,m=p.to),n.removeMark(h,m,l)}else u.forEach(h=>{n.removeMark(h.$from.pos,h.$to.pos,l)});return n.removeStoredMark(l),!0},gq=t=>({tr:e,state:n,dispatch:r})=>{const{selection:s}=n;let i,o;return typeof t=="number"?(i=t,o=t):t&&"from"in t&&"to"in t?(i=t.from,o=t.to):(i=s.from,o=s.to),r&&e.doc.nodesBetween(i,o,(a,l)=>{if(a.isText)return;const c={...a.attrs};delete c.dir,e.setNodeMarkup(l,void 0,c)}),!0},yq=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const a=om(typeof t=="string"?t:t.name,r.schema);if(!a)return!1;a==="node"&&(i=qt(t,r.schema)),a==="mark"&&(o=Zs(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;let h,m,g,p;n.selection.empty?r.doc.nodesBetween(d,u,(x,y)=>{i&&i===x.type&&(l=!0,g=Math.max(y,d),p=Math.min(y+x.nodeSize,u),h=y,m=x)}):r.doc.nodesBetween(d,u,(x,y)=>{y<d&&i&&i===x.type&&(l=!0,g=Math.max(y,d),p=Math.min(y+x.nodeSize,u),h=y,m=x),y>=d&&y<=u&&(i&&i===x.type&&(l=!0,s&&n.setNodeMarkup(y,void 0,{...x.attrs,...e})),o&&x.marks.length&&x.marks.forEach(v=>{if(o===v.type&&(l=!0,s)){const k=Math.max(y,d),w=Math.min(y+x.nodeSize,u);n.addMark(k,w,o.create({...v.attrs,...e}))}}))}),m&&(h!==void 0&&s&&n.setNodeMarkup(h,void 0,{...m.attrs,...e}),o&&m.marks.length&&m.marks.forEach(x=>{o===x.type&&s&&n.addMark(g,p,o.create({...x.attrs,...e}))}))}),l},xq=(t,e={})=>({state:n,dispatch:r})=>{const s=qt(t,n.schema);return JW(s,e)(n,r)},vq=(t,e={})=>({state:n,dispatch:r})=>{const s=qt(t,n.schema);return GW(s,e)(n,r)},kq=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}};function wq(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}function bq(t){return typeof t=="number"}function Sq(t){return Object.prototype.toString.call(t).slice(8,-1)}function Pu(t){return Sq(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}var Cq={};N0(Cq,{createAtomBlockMarkdownSpec:()=>Nq,createBlockMarkdownSpec:()=>Eq,createInlineMarkdownSpec:()=>$q,parseAttributes:()=>A0,parseIndentedBlocks:()=>Mq,renderNestedMarkdownContent:()=>Tq,serializeAttributes:()=>R0});function A0(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}__`)),s=r.match(/(?:^|\s)\.([\w-]+)/g);if(s){const c=s.map(d=>d.trim().slice(1));e.class=c.join(" ")}const i=r.match(/(?:^|\s)#([\w-]+)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,c,d])=>{var u;const h=parseInt(((u=d.match(/__QUOTED_(\d+)__/))==null?void 0:u[1])||"0",10),m=n[h];m&&(e[c]=m.slice(1,-1))});const l=r.replace(/(?:^|\s)\.([\w-]+)/g,"").replace(/(?:^|\s)#([\w-]+)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return l&&l.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function R0(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function Nq(t){const{nodeName:e,name:n,parseAttributes:r=A0,serializeAttributes:s=R0,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:a}=t,l=n||e,c=d=>{if(!a)return d;const u={};return a.forEach(h=>{h in d&&(u[h]=d[h])}),u};return{parseMarkdown:(d,u)=>{const h={...i,...d.attributes};return u.createNode(e,h,[])},markdownTokenizer:{name:e,level:"block",start(d){var u;const h=new RegExp(`^:::${l}(?:\\s|$)`,"m"),m=(u=d.match(h))==null?void 0:u.index;return m!==void 0?m:-1},tokenize(d,u,h){const m=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),g=d.match(m);if(!g)return;const p=g[1]||"",x=r(p);if(!o.find(v=>!(v in x)))return{type:e,raw:g[0],attributes:x}}},renderMarkdown:d=>{const u=c(d.attrs||{}),h=s(u),m=h?` {${h}}`:"";return`:::${l}${m} :::`}}}function Eq(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=A0,serializeAttributes:i=R0,defaultAttributes:o={},content:a="block",allowedAttributes:l}=t,c=n||e,d=u=>{if(!l)return u;const h={};return l.forEach(m=>{m in u&&(h[m]=u[m])}),h};return{parseMarkdown:(u,h)=>{let m;if(r){const p=r(u);m=typeof p=="string"?[{type:"text",text:p}]:p}else a==="block"?m=h.parseChildren(u.tokens||[]):m=h.parseInline(u.tokens||[]);const g={...o,...u.attributes};return h.createNode(e,g,m)},markdownTokenizer:{name:e,level:"block",start(u){var h;const m=new RegExp(`^:::${c}`,"m"),g=(h=u.match(m))==null?void 0:h.index;return g!==void 0?g:-1},tokenize(u,h,m){var g;const p=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),x=u.match(p);if(!x)return;const[y,v=""]=x,k=s(v);let w=1;const C=y.length;let E="";const _=/^:::([\w-]*)(\s.*)?/gm,S=u.slice(C);for(_.lastIndex=0;;){const j=_.exec(S);if(j===null)break;const $=j.index,I=j[1];if(!((g=j[2])!=null&&g.endsWith(":::"))){if(I)w+=1;else if(w-=1,w===0){const L=S.slice(0,$);E=L.trim();const D=u.slice(0,C+$+j[0].length);let B=[];if(E)if(a==="block")for(B=m.blockTokens(L),B.forEach(H=>{H.text&&(!H.tokens||H.tokens.length===0)&&(H.tokens=m.inlineTokens(H.text))});B.length>0;){const H=B[B.length-1];if(H.type==="paragraph"&&(!H.text||H.text.trim()===""))B.pop();else break}else B=m.inlineTokens(E);return{type:e,raw:D,attributes:k,content:E,tokens:B}}}}}},renderMarkdown:(u,h)=>{const m=d(u.attrs||{}),g=i(m),p=g?` {${g}}`:"",x=h.renderChildren(u.content||[],`
834
+
835
+ `);return`:::${c}${p}
836
+
837
+ ${x}
838
+
839
+ :::`}}}function _q(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,i,o]=r;e[s]=i||o,r=n.exec(t)}return e}function jq(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function $q(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=_q,serializeAttributes:i=jq,defaultAttributes:o={},selfClosing:a=!1,allowedAttributes:l}=t,c=n||e,d=h=>{if(!l)return h;const m={};return l.forEach(g=>{const p=typeof g=="string"?g:g.name,x=typeof g=="string"?void 0:g.skipIfDefault;if(p in h){const y=h[p];if(x!==void 0&&y===x)return;m[p]=y}}),m},u=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(h,m)=>{const g={...o,...h.attributes};if(a)return m.createNode(e,g);const p=r?r(h):h.content||"";return p?m.createNode(e,g,[m.createTextNode(p)]):m.createNode(e,g,[])},markdownTokenizer:{name:e,level:"inline",start(h){const m=a?new RegExp(`\\[${u}\\s*[^\\]]*\\]`):new RegExp(`\\[${u}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${u}\\]`),g=h.match(m),p=g==null?void 0:g.index;return p!==void 0?p:-1},tokenize(h,m,g){const p=a?new RegExp(`^\\[${u}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${u}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${u}\\]`),x=h.match(p);if(!x)return;let y="",v="";if(a){const[,w]=x;v=w}else{const[,w,C]=x;v=w,y=C||""}const k=s(v.trim());return{type:e,raw:x[0],content:y.trim(),attributes:k}}},renderMarkdown:h=>{let m="";r?m=r(h):h.content&&h.content.length>0&&(m=h.content.filter(y=>y.type==="text").map(y=>y.text).join(""));const g=d(h.attrs||{}),p=i(g),x=p?` ${p}`:"";return a?`[${c}${x}]`:`[${c}${x}]${m}[/${c}]`}}}function Mq(t,e,n){var r,s,i,o;const a=t.split(`
840
+ `),l=[];let c="",d=0;const u=e.baseIndentSize||2;for(;d<a.length;){const h=a[d],m=h.match(e.itemPattern);if(!m){if(l.length>0)break;if(h.trim()===""){d+=1,c=`${c}${h}
841
+ `;continue}else return}const g=e.extractItemData(m),{indentLevel:p,mainContent:x}=g;c=`${c}${h}
842
+ `;const y=[x];for(d+=1;d<a.length;){const C=a[d];if(C.trim()===""){const _=a.slice(d+1).findIndex($=>$.trim()!=="");if(_===-1)break;if((((s=(r=a[d+1+_].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>p){y.push(C),c=`${c}${C}
843
+ `,d+=1;continue}else break}if((((o=(i=C.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:o.length)||0)>p)y.push(C),c=`${c}${C}
844
+ `,d+=1;else break}let v;const k=y.slice(1);if(k.length>0){const C=k.map(E=>E.slice(p+u)).join(`
845
+ `);C.trim()&&(e.customNestedParser?v=e.customNestedParser(C):v=n.blockTokens(C))}const w=e.createToken(g,v);l.push(w)}if(l.length!==0)return{items:l,raw:c}}function Tq(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[i,...o]=t.content,a=e.renderChildren([i]);let l=`${s}${a}`;return o&&o.length>0&&o.forEach((c,d)=>{var u,h;const m=(h=(u=e.renderChild)==null?void 0:u.call(e,c,d+1))!=null?h:e.renderChildren([c]);if(m!=null){const g=m.split(`
846
+ `).map(p=>p?e.indent(p):e.indent("")).join(`
847
+ `);l+=c.type==="paragraph"?`
848
+
849
+ ${g}`:`
850
+ ${g}`}}),l}function UO(t,e){const n={...t};return Pu(t)&&Pu(e)&&Object.keys(e).forEach(r=>{Pu(e[r])&&Pu(t[r])?n[r]=UO(t[r],e[r]):n[r]=e[r]}),n}function Oq(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,o=t;s.descendants((a,l)=>{const c=i.mapping.map(l),d=i.mapping.map(l)+a.nodeSize;let u=null;if(a.marks.forEach(m=>{if(m!==o)return!1;u=m}),!u)return;let h=!1;if(Object.keys(n).forEach(m=>{n[m]!==u.attrs[m]&&(h=!0)}),h){const m=t.type.create({...t.attrs,...n});i.removeMark(c,d,t.type),i.addMark(c,d,m)}}),i.docChanged&&e.view.dispatch(i)}var ZO=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},Aq=(t,e)=>{if(E0(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Du(t){var e;const{editor:n,from:r,to:s,text:i,rules:o,plugin:a}=t,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(h=>h.type.spec.code))return!1;let d=!1;const u=KH(c)+i;return o.forEach(h=>{if(d)return;const m=Aq(u,h.find);if(!m)return;const g=m[0].length-i.length;if(g>0){const E=c.parentOffset-g;if(E<0||c.parent.textBetween(E,c.parentOffset)!==m[0].slice(0,g))return}const p=l.state.tr,x=sm({state:l.state,transaction:p}),y={from:r-(m[0].length-i.length),to:s},{commands:v,chain:k,can:w}=new im({editor:n,state:x});h.handler({state:x,range:y,match:m,commands:v,chain:k,can:w})===null||!p.steps.length||(h.undoable&&p.setMeta(a,{transform:p,from:r,to:s,text:i}),l.dispatch(p),d=!0)}),d}function Rq(t){const{editor:e,rules:n}=t,r=new Bn({state:{init(){return null},apply(s,i,o){const a=s.getMeta(r);if(a)return a;const l=s.getMeta("applyInputRules");return!!l&&setTimeout(()=>{let{text:d}=l;typeof d=="string"?d=d:d=M0(Y.from(d),o.schema);const{from:u}=l,h=u+d.length;Du({editor:e,from:u,to:h,text:d,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,a){return Du({editor:e,from:i,to:o,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&Du({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?Du({editor:e,from:o.pos,to:o.pos,text:`
851
+ `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var I0=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...nt(be(this,"addOptions",{name:this.name}))}}get storage(){return{...nt(be(this,"addStorage",{name:this.name,options:this.options}))}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>UO(this.options,t)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Xd=class HO extends I0{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new HO(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===n.name))return!1;const l=o.find(c=>(c==null?void 0:c.type.name)===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},qO=class{constructor(t){this.find=t.find,this.handler=t.handler}},Iq=(t,e,n)=>{if(E0(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=t,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function Pq(t){const{editor:e,state:n,from:r,to:s,rule:i,pasteEvent:o,dropEvent:a}=t,{commands:l,chain:c,can:d}=new im({editor:e,state:n}),u=[];return n.doc.nodesBetween(r,s,(m,g)=>{var p,x,y,v,k;if((x=(p=m.type)==null?void 0:p.spec)!=null&&x.code||!(m.isText||m.isTextblock||m.isInline))return;const w=(k=(v=(y=m.content)==null?void 0:y.size)!=null?v:m.nodeSize)!=null?k:0,C=Math.max(r,g),E=Math.min(s,g+w);if(C>=E)return;const _=m.isText?m.text||"":m.textBetween(C-g,E-g,void 0,"");Iq(_,i.find,o).forEach(j=>{if(j.index===void 0)return;const $=C+j.index+1,I=$+j[0].length,L={from:n.tr.mapping.map($),to:n.tr.mapping.map(I)},D=i.handler({state:n,range:L,match:j,commands:l,chain:c,can:d,pasteEvent:o,dropEvent:a});u.push(D)})}),u.every(m=>m!==null)}var zu=null,Dq=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function zq(t){const{editor:e,rules:n}=t;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const l=({state:d,from:u,to:h,rule:m,pasteEvt:g})=>{const p=d.tr,x=sm({state:d,transaction:p});if(!(!Pq({editor:e,state:x,from:Math.max(u-1,0),to:h.b-1,rule:m,pasteEvent:g,dropEvent:a})||!p.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,p}};return n.map(d=>new Bn({view(u){const h=g=>{var p;r=(p=u.dom.parentElement)!=null&&p.contains(g.target)?u.dom.parentElement:null,r&&(zu=e)},m=()=>{zu&&(zu=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",m),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",m)}}},props:{handleDOMEvents:{drop:(u,h)=>{if(i=r===u.dom.parentElement,a=h,!i){const m=zu;m!=null&&m.isEditable&&setTimeout(()=>{const g=m.state.selection;g&&m.commands.deleteRange({from:g.from,to:g.to})},10)}return!1},paste:(u,h)=>{var m;const g=(m=h.clipboardData)==null?void 0:m.getData("text/html");return o=h,s=!!(g!=null&&g.includes("data-pm-slice")),!1}}},appendTransaction:(u,h,m)=>{const g=u[0],p=g.getMeta("uiEvent")==="paste"&&!s,x=g.getMeta("uiEvent")==="drop"&&!i,y=g.getMeta("applyPasteRules"),v=!!y;if(!p&&!x&&!v)return;if(v){let{text:C}=y;typeof C=="string"?C=C:C=M0(Y.from(C),m.schema);const{from:E}=y,_=E+C.length,S=Dq(C);return l({rule:d,state:m,from:E,to:{b:_},pasteEvt:S})}const k=h.doc.content.findDiffStart(m.doc.content),w=h.doc.content.findDiffEnd(m.doc.content);if(!(!bq(k)||!w||k===w.b))return l({rule:d,state:m,from:k,to:w,pasteEvt:o})}}))}var am=class{constructor(t,e){this.splittableMarks=[],this.nonClearableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=PO(t),this.schema=VH(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Xl(e.name,this.schema)},r=be(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Ac([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Xl(r.name,this.schema)},i=[],o=be(r,"addKeyboardShortcuts",s);let a={};if(r.type==="mark"&&be(r,"exitable",s)&&(a.ArrowRight=()=>Xd.handleExit({editor:t,mark:r})),o){const h=Object.fromEntries(Object.entries(o()).map(([m,g])=>[m,()=>g({editor:t})]));a={...a,...h}}const l=VZ(a);i.push(l);const c=be(r,"addInputRules",s);if(SS(r,t.options.enableInputRules)&&c){const h=c();if(h&&h.length){const m=Rq({editor:t,rules:h}),g=Array.isArray(m)?m:[m];i.push(...g)}}const d=be(r,"addPasteRules",s);if(SS(r,t.options.enablePasteRules)&&d){const h=d();if(h&&h.length){const m=zq({editor:t,rules:h});i.push(...m)}}const u=be(r,"addProseMirrorPlugins",s);if(u){const h=u();i.push(...h)}return i})}get attributes(){return IO(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=bl(this.extensions);return Object.fromEntries(e.filter(n=>!!be(n,"addNodeView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:qt(n.name,this.schema)},i=be(n,"addNodeView",s);if(!i)return[];const o=i();if(!o)return[];const a=(l,c,d,u,h)=>{const m=Rh(l,r);return o({node:l,view:c,getPos:d,decorations:u,innerDecorations:h,editor:t,extension:n,HTMLAttributes:m})};return[n.name,a]}))}dispatchTransaction(t){const{editor:e}=this;return Ac([...this.extensions].reverse()).reduceRight((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Xl(s.name,this.schema)},o=be(s,"dispatchTransaction",i);return o?a=>{o.call(i,{transaction:a,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return Ac([...this.extensions]).reduce((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:Xl(s.name,this.schema)},o=be(s,"transformPastedHTML",i);return o?(a,l)=>{const c=r(a,l);return o.call(i,c)}:r},t||(r=>r))}get markViews(){const{editor:t}=this,{markExtensions:e}=bl(this.extensions);return Object.fromEntries(e.filter(n=>!!be(n,"addMarkView")).map(n=>{const r=this.attributes.filter(a=>a.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Zs(n.name,this.schema)},i=be(n,"addMarkView",s);if(!i)return[];const o=(a,l,c)=>{const d=Rh(a,r);return i()({mark:a,view:l,inline:c,editor:t,extension:n,HTMLAttributes:d,updateAttributes:u=>{Oq(a,t,u)}})};return[n.name,o]}))}destroy(){this.extensions.forEach(t=>{let e=t;for(;e.parent;){const n=e.parent;n.child===e&&(n.child=null),e=n}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n,r;const s={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Xl(e.name,this.schema)};e.type==="mark"&&(((n=nt(be(e,"keepOnSplit",s)))==null||n)&&this.splittableMarks.push(e.name),(r=nt(be(e,"clearable",s)))==null||r||this.nonClearableMarks.push(e.name));const i=be(e,"onBeforeCreate",s),o=be(e,"onCreate",s),a=be(e,"onUpdate",s),l=be(e,"onSelectionUpdate",s),c=be(e,"onTransaction",s),d=be(e,"onFocus",s),u=be(e,"onBlur",s),h=be(e,"onDestroy",s);i&&this.editor.on("beforeCreate",i),o&&this.editor.on("create",o),a&&this.editor.on("update",a),l&&this.editor.on("selectionUpdate",l),c&&this.editor.on("transaction",c),d&&this.editor.on("focus",d),u&&this.editor.on("blur",u),h&&this.editor.on("destroy",h)})}};am.resolve=PO;am.sort=Ac;am.flatten=$0;var Lq={};N0(Lq,{ClipboardTextSerializer:()=>JO,Commands:()=>GO,Delete:()=>YO,Drop:()=>QO,Editable:()=>XO,FocusEvents:()=>tA,Keymap:()=>nA,Paste:()=>rA,Tabindex:()=>sA,TextDirection:()=>iA,focusEventsPluginKey:()=>eA});var ds=class KO extends I0{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new KO(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},JO=ds.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Bn({key:new zr("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,i=zO(n),{blockSeparator:o}=this.options,a={...o!==void 0?{blockSeparator:o}:{},textSerializers:i};return[...s.ranges].sort((c,d)=>c.$from.pos-d.$from.pos).map(({$from:c,$to:d})=>DO(r,{from:c.pos,to:d.pos},a)).join(o??`
852
+
853
+ `)}}})]}}),GO=ds.create({name:"commands",addCommands(){return{...NO}}}),YO=ds.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,s;const i=()=>{var o,a,l,c;if((c=(l=(a=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:a.filterTransaction)==null?void 0:l.call(a,t))!=null?c:t.getMeta("y-sync$"))return;const d=AO(t.before,[t,...e]);FO(d).forEach(m=>{d.mapping.mapResult(m.oldRange.from).deletedAfter&&d.mapping.mapResult(m.oldRange.to).deletedBefore&&d.before.nodesBetween(m.oldRange.from,m.oldRange.to,(g,p)=>{const x=p+g.nodeSize-2,y=m.oldRange.from<=p&&x<=m.oldRange.to;this.editor.emit("delete",{type:"node",node:g,from:p,to:x,newFrom:d.mapping.map(p),newTo:d.mapping.map(x),deletedRange:m.oldRange,newRange:m.newRange,partial:!y,editor:this.editor,transaction:t,combinedTransform:d})})});const h=d.mapping;d.steps.forEach((m,g)=>{var p,x;if(m instanceof Yr){const y=h.slice(g).map(m.from,-1),v=h.slice(g).map(m.to),k=h.invert().map(y,-1),w=h.invert().map(v),C=y>0?(p=d.doc.nodeAt(y-1))==null?void 0:p.marks.some(_=>_.eq(m.mark)):!1,E=(x=d.doc.nodeAt(v))==null?void 0:x.marks.some(_=>_.eq(m.mark));this.editor.emit("delete",{type:"mark",mark:m.mark,from:m.from,to:m.to,deletedRange:{from:k,to:w},newRange:{from:y,to:v},partial:!!(E||C),editor:this.editor,transaction:t,combinedTransform:d})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(i,0):i()}}),QO=ds.create({name:"drop",addProseMirrorPlugins(){return[new Bn({key:new zr("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),XO=ds.create({name:"editable",addProseMirrorPlugins(){return[new Bn({key:new zr("editable"),props:{editable:()=>this.editor.options.editable}})]}}),eA=new zr("focusEvents"),tA=ds.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Bn({key:eA,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),nA=ds.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:a})=>{const{selection:l,doc:c}=a,{empty:d,$anchor:u}=l,{pos:h,parent:m}=u,g=u.parent.isTextblock&&h>0?a.doc.resolve(h-1):u,p=g.parent.type.spec.isolating,x=u.pos-u.parentOffset,y=p&&g.parent.childCount===1?x===u.pos:Ue.atStart(c).from===h;return!d||!m.type.isTextblock||m.textContent.length||!y||y&&u.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Ah()||TO()?i:s},addProseMirrorPlugins(){return[new Bn({key:new zr("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(p=>p.getMeta("composition")))return;const r=t.some(p=>p.docChanged)&&!e.doc.eq(n.doc),s=t.some(p=>p.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:a}=e.selection,l=Ue.atStart(e.doc).from,c=Ue.atEnd(e.doc).to;if(i||!(o===l&&a===c)||!O0(n.doc))return;const h=n.tr,m=sm({state:n,transaction:h}),{commands:g}=new im({editor:this.editor,state:m});if(g.clearNodes(),!!h.steps.length)return h}})]}}),rA=ds.create({name:"paste",addProseMirrorPlugins(){return[new Bn({key:new zr("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),sA=ds.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new Bn({key:new zr("tabindex"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!=null?t:"0"}}}})]}}),iA=ds.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=bl(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new Bn({key:new zr("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),Fq=class hc{constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new hc(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new hc(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new hc(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=n.isInline,a=this.pos+r+(i?0:1);if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(a);if(!s&&!o&&l.depth<=this.depth)return;const c=new hc(l,this.editor,s,s||o?n:null);s&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){const i=s.node.attrs,o=Object.keys(n);for(let a=0;a<o.length;a+=1){const l=o[a];if(i[l]!==n[l])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(n);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(l=>n[l]===o.node.attrs[l])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,n,r))))}),s}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},Bq=`.ProseMirror {
854
+ position: relative;
855
+ }
856
+
857
+ .ProseMirror {
858
+ word-wrap: break-word;
859
+ white-space: pre-wrap;
860
+ white-space: break-spaces;
861
+ -webkit-font-variant-ligatures: none;
862
+ font-variant-ligatures: none;
863
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
864
+ }
865
+
866
+ .ProseMirror [contenteditable="false"] {
867
+ white-space: normal;
868
+ }
869
+
870
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
871
+ white-space: pre-wrap;
872
+ }
873
+
874
+ .ProseMirror pre {
875
+ white-space: pre-wrap;
876
+ }
877
+
878
+ img.ProseMirror-separator {
879
+ display: inline !important;
880
+ border: none !important;
881
+ margin: 0 !important;
882
+ width: 0 !important;
883
+ height: 0 !important;
884
+ }
885
+
886
+ .ProseMirror-gapcursor {
887
+ display: none;
888
+ pointer-events: none;
889
+ position: absolute;
890
+ margin: 0;
891
+ }
892
+
893
+ .ProseMirror-gapcursor:after {
894
+ content: "";
895
+ display: block;
896
+ position: absolute;
897
+ top: -2px;
898
+ width: 20px;
899
+ border-top: 1px solid black;
900
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
901
+ }
902
+
903
+ @keyframes ProseMirror-cursor-blink {
904
+ to {
905
+ visibility: hidden;
906
+ }
907
+ }
908
+
909
+ .ProseMirror-hideselection *::selection {
910
+ background: transparent;
911
+ }
912
+
913
+ .ProseMirror-hideselection *::-moz-selection {
914
+ background: transparent;
915
+ }
916
+
917
+ .ProseMirror-hideselection * {
918
+ caret-color: transparent;
919
+ }
920
+
921
+ .ProseMirror-focused .ProseMirror-gapcursor {
922
+ display: block;
923
+ }`,Vq=class extends kq{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:n})=>{throw n},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:GH,createMappablePosition:YH},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:n,slice:r,moved:s})=>this.options.onDrop(n,r,s)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),this.on("delete",this.options.onDelete);const e=this.createDoc();if(!this.editorState){const n=sv(e,this.options.autofocus);this.editorState=fo.create({doc:e,schema:this.schema,selection:n||void 0})}this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t!=null&&t.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=wq(Bq,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=RO(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(s=>{const i=typeof s=="string"?`${s}$`:s.key;n=n.filter(o=>!o.key.startsWith(i))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e,n,r;const i=[...this.options.enableCoreExtensions?[XO,JO.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),GO,tA,nA,sA.configure({value:(r=(n=this.options.coreExtensionOptions)==null?void 0:n.tabindex)==null?void 0:r.value}),QO,rA,YO,iA.configure({direction:this.options.textDirection})].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o==null?void 0:o.type));this.extensionManager=new am(i,this)}createCommandManager(){this.commandManager=new im({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=iv(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;const n=iv(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=fo.create({doc:n,schema:this.schema,selection:sv(n,this.options.autofocus)||void 0}),this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(r=>r.name!=="collaboration"),this.createExtensionManager()}}),this.editorState.doc}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=n?this.extensionManager.dispatchTransaction(r):r,i=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(i);this.editorView=new CO(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:s,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();const l=this.view.dom;l.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(c)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),s=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const o=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),a=o==null?void 0:o.getMeta("focus"),l=o==null?void 0:o.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:o}),l&&this.emit("blur",{editor:this,event:l.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return LO(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return JH(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return M0(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
924
+
925
+ `,textSerializers:n={}}=t||{};return UH(this.state.doc,{blockSeparator:e,textSerializers:{...zO(this.schema),...n}})}get isEmpty(){return O0(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t),n=t>0&&e.nodeAfter&&!e.nodeAfter.isText&&e.nodeAfter.isAtom?e.nodeAfter:null;return new Fq(e,this,!1,n)}get $doc(){return this.$pos(0)}};function Sl(t){return new ZO({find:t.find,handler:({state:e,range:n,match:r})=>{const s=nt(t.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],a=r[0];if(o){const l=a.search(/\S/),c=n.from+a.indexOf(o),d=c+o.length;if(T0(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(p=>p===t.type&&p!==m.mark.type)).filter(m=>m.to>c).length)return null;d<n.to&&i.delete(d,n.to),c>n.from&&i.delete(n.from+l,c);const h=n.from+l+o.length;i.addMark(n.from+l,h,t.type.create(s||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}var lm=class oA extends I0{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new oA(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Zo(t){return new qO({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const i=nt(t.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,a=r[r.length-1],l=r[0];let c=n.to;if(a){const d=l.search(/\S/),u=n.from+l.indexOf(a),h=u+a.length;if(T0(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(y=>y===t.type&&y!==p.mark.type)).filter(p=>p.to>u).length)return null;h<n.to&&o.delete(h,n.to),u>n.from&&o.delete(n.from+d,u),c=n.from+d+a.length,o.addMark(n.from+d,c,t.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:Wq,getOwnPropertySymbols:Uq}=Object,{hasOwnProperty:Zq}=Object.prototype;function Mg(t,e){return function(r,s,i){return t(r,s,i)&&e(r,s,i)}}function ec(t){return function(n,r,s){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,s);const{cache:i}=s,o=i.get(n),a=i.get(r);if(o&&a)return o===r&&a===n;i.set(n,r),i.set(r,n);const l=t(n,r,s);return i.delete(n),i.delete(r),l}}function Hq(t){return t!=null?t[Symbol.toStringTag]:void 0}function ES(t){return Wq(t).concat(Uq(t))}const qq=Object.hasOwn||((t,e)=>Zq.call(t,e));function Xo(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const Kq="__v",Jq="__o",Gq="_owner",Yq=64,{getOwnPropertyDescriptor:av,keys:Ih}=Object,{propertyIsEnumerable:hf}=Object.prototype,Qq=av(Object.getPrototypeOf(Int8Array.prototype),Symbol.toStringTag).get;function Xq(t,e){return t.byteLength===e.byteLength&&Ph(new Uint8Array(t),new Uint8Array(e))}function eK(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function tK(t,e){return t.byteLength===e.byteLength&&Ph(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function nK(t,e){return Xo(t.getTime(),e.getTime())}function rK(t,e,n){if(t.name!==e.name||t.message!==e.message||t.stack!==e.stack)return!1;const r=t.cause,s=e.cause;if(r!==s&&!n.equals(r,s,"cause","cause",t,e,n))return!1;const i=t.errors,o=e.errors;if(i!==o&&!n.equals(i,o,"errors","errors",t,e,n))return!1;const a=Ih(t),l=Ih(e);let c=a.length;if(!c&&!l.length)return!0;let d=0,u;for(;c-- >0;)if(u=a[c],!(u==="cause"||u==="errors")){if(u!==l[c]&&!hf.call(e,u)||!n.equals(t[u],e[u],u,u,t,e,n))return!1;++d}const h=l.length-d;return!h||h===(hf.call(e,"cause")?1:0)+(hf.call(e,"errors")?1:0)}function sK(t,e){return t===e}function iK(t,e,n){return t.name===e.name&&t.message===e.message&&t.stack===e.stack&&ya(t,e,n)}function _S(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.entries();let o,a,l=0;for(;(o=i.next())&&!o.done;){const c=e.entries();let d=!1,u=0;for(;(a=c.next())&&!a.done;){if(s[u]){u++;continue}const h=o.value,m=a.value;if(n.equals(h[0],m[0],l,u,t,e,n)&&n.equals(h[1],m[1],h[0],m[0],t,e,n)){d=s[u]=!0;break}u++}if(!d)return!1;l++}return!0}const oK=Xo;function aK(t,e,n){const r=Ih(t),s=Ih(e);let i=r.length;if(s.length!==i)return!1;const o=i<=Yq;let a;for(;i-- >0;)if(a=r[i],!aA(t,e,a)&&(a!==s[i]&&!(o?s.includes(a):hf.call(e,a))||!n.equals(t[a],e[a],a,a,t,e,n)))return!1;return!0}function ya(t,e,n){const r=ES(t);let s=r.length;if(ES(e).length!==s)return!1;let i,o,a;for(;s-- >0;)if(i=r[s],!aA(t,e,i)&&(!qq(e,i)||!n.equals(t[i],e[i],i,i,t,e,n))||(o=av(t,i),a=av(e,i),(o||a)&&(!o||!a||o.configurable!==a.configurable||o.enumerable!==a.enumerable||o.writable!==a.writable)))return!1;return!0}function lK(t,e){return Xo(t.valueOf(),e.valueOf())}function cK(t,e){return t.source===e.source&&t.flags===e.flags}function jS(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.values();let o,a;for(;(o=i.next())&&!o.done;){const l=e.values();let c=!1,d=0;for(;(a=l.next())&&!a.done;){if(!s[d]&&n.equals(o.value,a.value,o.value,a.value,t,e,n)){c=s[d]=!0;break}d++}if(!c)return!1}return!0}function Ph(t,e){let n=t.length;if(e.length!==n||t.byteOffset!==e.byteOffset)return!1;const r=Qq.call(t);if(r==="Float64Array"||r==="Float32Array"||r==="Float16Array"){for(;n-- >0;)if(t[n]!==e[n]&&(t[n]===t[n]||e[n]===e[n]))return!1;return!0}for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function dK(t,e){return t.href===e.href?!0:t.protocol===e.protocol&&t.username===e.username&&t.password===e.password&&t.host===e.host&&t.pathname===e.pathname&&t.hash===e.hash&&uK(t.searchParams,e.searchParams)}function uK(t,e){const n=t.toString(),r=e.toString();return n===r||$S(n)===$S(r)}function $S(t){return t.split("&").sort().join("&")}function aA(t,e,n){return(n===Gq||n===Jq||n===Kq)&&!!(t.$$typeof||e.$$typeof)}const fK="[object ArrayBuffer]",hK="[object Arguments]",pK="[object Boolean]",mK="[object DataView]",gK="[object Date]",yK="[object Error]",xK="[object Map]",vK="[object Number]",kK="[object Object]",wK="[object RegExp]",bK="[object Set]",SK="[object String]",CK={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},NK="[object URL]",EK=Object.prototype.toString;function _K({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:i,areMapsEqual:o,areNumbersEqual:a,areObjectsEqual:l,arePrimitiveWrappersEqual:c,areRegExpsEqual:d,areSetsEqual:u,areTypedArraysEqual:h,areUrlsEqual:m,unknownTagComparators:g}){return function(x,y,v){if(x===y)return!0;if(x==null||y==null)return!1;const k=typeof x;if(k!==typeof y)return!1;if(k!=="object")return k==="number"?a(x,y,v):k==="function"?i(x,y,v):!1;const w=x.constructor;if(w!==y.constructor)return!1;if(w===Object)return l(x,y,v);if(Array.isArray(x))return e(x,y,v);if(w===Date)return r(x,y,v);if(w===RegExp)return d(x,y,v);if(w===Map)return o(x,y,v);if(w===Set)return u(x,y,v);if(w==null)return l(x,y,v);const C=EK.call(x);if(C===gK)return r(x,y,v);if(C===wK)return d(x,y,v);if(C===xK)return o(x,y,v);if(C===bK)return u(x,y,v);if(C===kK)return typeof x.then!="function"&&typeof y.then!="function"&&l(x,y,v);if(C===NK)return m(x,y,v);if(C===yK)return s(x,y,v);if(C===hK)return l(x,y,v);if(CK[C])return h(x,y,v);if(C===fK)return t(x,y,v);if(C===mK)return n(x,y,v);if(C===pK||C===vK||C===SK)return c(x,y,v);if(g){let E=g[C];if(!E){const _=Hq(x);_&&(E=g[_])}if(E)return E(x,y,v)}return!1}}function jK({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:Xq,areArraysEqual:n?ya:eK,areDataViewsEqual:tK,areDatesEqual:nK,areErrorsEqual:n?iK:rK,areFunctionsEqual:sK,areMapsEqual:n?Mg(_S,ya):_S,areNumbersEqual:oK,areObjectsEqual:n?ya:aK,arePrimitiveWrappersEqual:lK,areRegExpsEqual:cK,areSetsEqual:n?Mg(jS,ya):jS,areTypedArraysEqual:n?Mg(Ph,ya):Ph,areUrlsEqual:dK,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const s=ec(r.areArraysEqual),i=ec(r.areErrorsEqual),o=ec(r.areMapsEqual),a=ec(r.areObjectsEqual),l=ec(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areErrorsEqual:i,areMapsEqual:o,areObjectsEqual:a,areSetsEqual:l})}return r}function $K(t){return function(e,n,r,s,i,o,a){return t(e,n,a)}}function MK({circular:t,comparator:e,createState:n,equals:r,strict:s}){if(n)return function(a,l){const{cache:c=t?new WeakMap:void 0,meta:d}=n();return e(a,l,{cache:c,equals:r,meta:d,strict:s})};if(t)return function(a,l){return e(a,l,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const i={cache:void 0,equals:r,meta:void 0,strict:s};return function(a,l){return e(a,l,i)}}const TK=Yi();Yi({strict:!0});Yi({circular:!0});Yi({circular:!0,strict:!0});Yi({createInternalComparator:()=>Xo});Yi({strict:!0,createInternalComparator:()=>Xo});Yi({circular:!0,createInternalComparator:()=>Xo});Yi({circular:!0,createInternalComparator:()=>Xo,strict:!0});function Yi(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:s=!1}=t,i=jK(t),o=_K(i),a=n?n(o):$K(o);return MK({circular:e,comparator:o,createState:r,equals:a,strict:s})}var lA={exports:{}},cA={};/**
926
+ * @license React
927
+ * use-sync-external-store-shim/with-selector.production.js
928
+ *
929
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
930
+ *
931
+ * This source code is licensed under the MIT license found in the
932
+ * LICENSE file in the root directory of this source tree.
933
+ */var cm=b,OK=a0;function AK(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var RK=typeof Object.is=="function"?Object.is:AK,IK=OK.useSyncExternalStore,PK=cm.useRef,DK=cm.useEffect,zK=cm.useMemo,LK=cm.useDebugValue;cA.useSyncExternalStoreWithSelector=function(t,e,n,r,s){var i=PK(null);if(i.current===null){var o={hasValue:!1,value:null};i.current=o}else o=i.current;i=zK(function(){function l(m){if(!c){if(c=!0,d=m,m=r(m),s!==void 0&&o.hasValue){var g=o.value;if(s(g,m))return u=g}return u=m}if(g=u,RK(d,m))return g;var p=r(m);return s!==void 0&&s(g,p)?(d=m,g):(d=m,u=p)}var c=!1,d,u,h=n===void 0?null:n;return[function(){return l(e())},h===null?void 0:function(){return l(h())}]},[e,n,r,s]);var a=IK(t,i[0],i[1]);return DK(function(){o.hasValue=!0,o.value=a},[a]),LK(a),a};lA.exports=cA;var FK=lA.exports,BK=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},VK=({contentComponent:t})=>{const e=a0.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return f.jsx(f.Fragment,{children:Object.values(e)})};function WK(){const t=new Set;let e={},n=!1;const r=()=>{n||!t.size||(n=!0,queueMicrotask(()=>{n=!1,t.forEach(s=>s())}))};return{subscribe(s){return t.add(s),()=>{t.delete(s)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(s,i){e={...e,[s]:pR.createPortal(i.reactElement,i.element,s)},r()},removeRenderer(s){const i={...e};delete i[s],e=i,r()}}}var UK=class extends _r.Component{constructor(t){super(t),this.editorContentRef=_r.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=WK(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){var t;const e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return f.jsxs(f.Fragment,{children:[f.jsx("div",{ref:BK(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&f.jsx(VK,{contentComponent:t.contentComponent})]})}},ZK=b.forwardRef((t,e)=>{const n=_r.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return _r.createElement(UK,{key:n,innerRef:e,...t})}),P0=_r.memo(ZK),HK=typeof window<"u"?b.useLayoutEffect:b.useEffect,qK=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){let e;const n=s=>{(s==null?void 0:s.transaction)!==void 0&&s.transaction===e||(e=s==null?void 0:s.transaction,this.transactionNumber+=1,this.subscribers.forEach(i=>i()))},r=this.editor;return r.on("transaction",n),r.on("update",n),()=>{r.off("transaction",n),r.off("update",n)}}}};function KK(t){var e;const[n]=b.useState(()=>new qK(t.editor)),r=FK.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:TK);return HK(()=>n.watch(t.editor),[t.editor,n]),b.useDebugValue(r),r}var JK=!1,dA=typeof window>"u",GK=dA||!!(typeof window<"u"&&window.next),YK=class uA{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){const e=this.options.current.immediatelyRender;let n=e??!0;return dA?(n&&JK&&console.warn("SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches"),n=!1):GK&&e===void 0&&(n=!1),n?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)==null?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)==null?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)==null?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)==null?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)==null?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)==null?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)==null?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)==null?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)==null?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)==null?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)==null?void 0:i.call(s,...r)},onDelete:(...r)=>{var s,i;return(i=(s=this.options.current).onDelete)==null?void 0:i.call(s,...r)},onMount:(...r)=>{var s,i;return(i=(s=this.options.current).onMount)==null?void 0:i.call(s,...r)},onUnmount:(...r)=>{var s,i;return(i=(s=this.options.current).onUnmount)==null?void 0:i.call(s,...r)}};return new Vq(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((s,i)=>{var o;return s===((o=n.extensions)==null?void 0:o[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?uA.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function fA(t={},e=[]){const n=b.useRef(t);n.current=t;const[r]=b.useState(()=>new YK(n)),s=a0.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return b.useDebugValue(s),b.useEffect(r.onRender(e)),KK({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var hA=b.createContext({editor:null});hA.Consumer;var QK=b.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),XK=()=>b.useContext(QK);_r.forwardRef((t,e)=>{const{onDragStart:n}=XK(),r=t.as||"div";return f.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});_r.createContext({markViewContentRef:()=>{}});var D0=b.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});D0.displayName="TiptapContext";var eJ=()=>b.useContext(D0);function pA({children:t,...e}){const n="editor"in e?e.editor:e.instance;if(!n)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const r=b.useMemo(()=>({editor:n}),[n]),s=b.useMemo(()=>({editor:n}),[n]);return f.jsx(hA.Provider,{value:s,children:f.jsx(D0.Provider,{value:r,children:t})})}pA.displayName="Tiptap";function mA({...t}){const{editor:e}=eJ();return f.jsx(P0,{editor:e,...t})}mA.displayName="Tiptap.Content";Object.assign(pA,{Content:mA});var tJ=lm.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
934
+
935
+ `):""}),gA=tJ,Lu="&nbsp;",Tg=" ",nJ=lm.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Zi(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===Lu||n[0].text===Lu||n[0].raw===Tg||n[0].text===Tg)&&r.length===1&&r[0].type==="text"&&(r[0].text===Lu||r[0].text===Tg)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{var r,s;if(!t)return"";const i=Array.isArray(t.content)?t.content:[];if(i.length===0){const o=Array.isArray((r=n==null?void 0:n.previousNode)==null?void 0:r.content)?n.previousNode.content:[];return((s=n==null?void 0:n.previousNode)==null?void 0:s.type)==="paragraph"&&o.length===0?Lu:""}return e.renderChildren(i)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),yA=nJ,rJ=lm.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),xA=rJ,MS=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},sJ=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,iJ=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,oJ=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,aJ=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,lJ=Xd.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return MS("strong",{...Zi(this.options.HTMLAttributes,t),children:MS("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Sl({find:sJ,type:this.type}),Sl({find:oJ,type:this.type})]},addPasteRules(){return[Zo({find:iJ,type:this.type}),Zo({find:aJ,type:this.type})]}}),cJ=lJ,dJ=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,uJ=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,fJ=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,hJ=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,pJ=Xd.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Zi(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Sl({find:dJ,type:this.type}),Sl({find:fJ,type:this.type})]},addPasteRules(){return[Zo({find:uJ,type:this.type}),Zo({find:hJ,type:this.type})]}}),mJ=pJ,gJ=t=>{const e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},yJ=t=>{const e=/`([^`]+)`(?!`)/g,n=[];let r;for(;(r=e.exec(t))!==null;)r.index>0&&t[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n},xJ=Xd.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Zi(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Sl({find:gJ,type:this.type})]},addPasteRules(){return[Zo({find:yJ,type:this.type})]}}),vJ=xJ;const kJ="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos6kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12b0cam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",wJ="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",lv="numeric",cv="ascii",dv="alpha",Rc="asciinumeric",pc="alphanumeric",uv="domain",vA="emoji",bJ="scheme",SJ="slashscheme",Og="whitespace";function CJ(t,e){return t in e||(e[t]=[]),e[t]}function mo(t,e,n){e[lv]&&(e[Rc]=!0,e[pc]=!0),e[cv]&&(e[Rc]=!0,e[dv]=!0),e[Rc]&&(e[pc]=!0),e[dv]&&(e[pc]=!0),e[pc]&&(e[uv]=!0),e[vA]&&(e[uv]=!0);for(const r in e){const s=CJ(r,n);s.indexOf(t)<0&&s.push(t)}}function NJ(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function On(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}On.groups={};On.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||On.groups;let s;return e&&e.j?s=e:(s=new On(e),n&&r&&mo(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const i=t.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(t[o]);return s.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||On.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const i=e;let o,a=s.go(t);if(a?(o=new On,Object.assign(o.j,a.j),o.jr.push.apply(o.jr,a.jr),o.jd=a.jd,o.t=a.t):o=new On,i){if(r)if(o.t&&typeof o.t=="string"){const l=Object.assign(NJ(o.t,r),n);mo(i,l,r)}else n&&mo(i,n,r);o.t=i}return s.j[t]=o,o}};const Pe=(t,e,n,r,s)=>t.ta(e,n,r,s),yt=(t,e,n,r,s)=>t.tr(e,n,r,s),TS=(t,e,n,r,s)=>t.ts(e,n,r,s),Q=(t,e,n,r,s)=>t.tt(e,n,r,s),ys="WORD",fv="UWORD",kA="ASCIINUMERICAL",wA="ALPHANUMERICAL",Nd="LOCALHOST",hv="TLD",pv="UTLD",pf="SCHEME",xa="SLASH_SCHEME",z0="NUM",mv="WS",L0="NL",Ic="OPENBRACE",Pc="CLOSEBRACE",Dh="OPENBRACKET",zh="CLOSEBRACKET",Lh="OPENPAREN",Fh="CLOSEPAREN",Bh="OPENANGLEBRACKET",Vh="CLOSEANGLEBRACKET",Wh="FULLWIDTHLEFTPAREN",Uh="FULLWIDTHRIGHTPAREN",Zh="LEFTCORNERBRACKET",Hh="RIGHTCORNERBRACKET",qh="LEFTWHITECORNERBRACKET",Kh="RIGHTWHITECORNERBRACKET",Jh="FULLWIDTHLESSTHAN",Gh="FULLWIDTHGREATERTHAN",Yh="AMPERSAND",Qh="APOSTROPHE",Xh="ASTERISK",ri="AT",ep="BACKSLASH",tp="BACKTICK",np="CARET",go="COLON",F0="COMMA",rp="DOLLAR",Vr="DOT",sp="EQUALS",B0="EXCLAMATION",sr="HYPHEN",Dc="PERCENT",ip="PIPE",op="PLUS",Ra="POUND",so="QUERY",V0="QUOTE",bA="FULLWIDTHMIDDLEDOT",W0="SEMI",Wr="SLASH",zc="TILDE",ap="UNDERSCORE",SA="EMOJI",lp="SYM";var CA=Object.freeze({__proto__:null,ALPHANUMERICAL:wA,AMPERSAND:Yh,APOSTROPHE:Qh,ASCIINUMERICAL:kA,ASTERISK:Xh,AT:ri,BACKSLASH:ep,BACKTICK:tp,CARET:np,CLOSEANGLEBRACKET:Vh,CLOSEBRACE:Pc,CLOSEBRACKET:zh,CLOSEPAREN:Fh,COLON:go,COMMA:F0,DOLLAR:rp,DOT:Vr,EMOJI:SA,EQUALS:sp,EXCLAMATION:B0,FULLWIDTHGREATERTHAN:Gh,FULLWIDTHLEFTPAREN:Wh,FULLWIDTHLESSTHAN:Jh,FULLWIDTHMIDDLEDOT:bA,FULLWIDTHRIGHTPAREN:Uh,HYPHEN:sr,LEFTCORNERBRACKET:Zh,LEFTWHITECORNERBRACKET:qh,LOCALHOST:Nd,NL:L0,NUM:z0,OPENANGLEBRACKET:Bh,OPENBRACE:Ic,OPENBRACKET:Dh,OPENPAREN:Lh,PERCENT:Dc,PIPE:ip,PLUS:op,POUND:Ra,QUERY:so,QUOTE:V0,RIGHTCORNERBRACKET:Hh,RIGHTWHITECORNERBRACKET:Kh,SCHEME:pf,SEMI:W0,SLASH:Wr,SLASH_SCHEME:xa,SYM:lp,TILDE:zc,TLD:hv,UNDERSCORE:ap,UTLD:pv,UWORD:fv,WORD:ys,WS:mv});const hs=/[a-z]/;let va=/[a-z]/i,mf=/[\u{1F000}-\u{1FAFF}\u{2600}-\u{27BF}]|\u{FE0F}/u;try{va=new RegExp("\\p{L}","u"),mf=new RegExp("\\p{Emoji}","u")}catch{}const ps=/\d/,Ag=/\s/,OS="\r",Rg=`
936
+ `,EJ="️",_J="‍",Ig="";let Fu=null,Bu=null;function jJ(t=[]){const e={};On.groups=e;const n=new On;Fu==null&&(Fu=AS(kJ)),Bu==null&&(Bu=AS(wJ)),Q(n,"'",Qh),Q(n,"{",Ic),Q(n,"}",Pc),Q(n,"[",Dh),Q(n,"]",zh),Q(n,"(",Lh),Q(n,")",Fh),Q(n,"<",Bh),Q(n,">",Vh),Q(n,"(",Wh),Q(n,")",Uh),Q(n,"「",Zh),Q(n,"」",Hh),Q(n,"『",qh),Q(n,"』",Kh),Q(n,"<",Jh),Q(n,">",Gh),Q(n,"&",Yh),Q(n,"*",Xh),Q(n,"@",ri),Q(n,"`",tp),Q(n,"^",np),Q(n,":",go),Q(n,",",F0),Q(n,"$",rp),Q(n,".",Vr),Q(n,"=",sp),Q(n,"!",B0),Q(n,"-",sr),Q(n,"%",Dc),Q(n,"|",ip),Q(n,"+",op),Q(n,"#",Ra),Q(n,"?",so),Q(n,'"',V0),Q(n,"/",Wr),Q(n,";",W0),Q(n,"~",zc),Q(n,"_",ap),Q(n,"\\",ep),Q(n,"・",bA);const r=yt(n,ps,z0,{[lv]:!0});yt(r,ps,r);const s=yt(r,hs,kA,{[Rc]:!0}),i=yt(r,va,wA,{[pc]:!0}),o=yt(n,hs,ys,{[cv]:!0});yt(o,ps,s),yt(o,hs,o),yt(s,ps,s),yt(s,hs,s);const a=yt(n,va,fv,{[dv]:!0});yt(a,hs),yt(a,ps,i),yt(a,va,a),yt(i,ps,i),yt(i,hs),yt(i,va,i);const l=Q(n,Rg,L0,{[Og]:!0}),c=Q(n,OS,mv,{[Og]:!0}),d=yt(n,Ag,mv,{[Og]:!0});Q(n,Ig,d),Q(c,Rg,l),Q(c,Ig,d),yt(c,Ag,d),Q(d,OS),Q(d,Rg),yt(d,Ag,d),Q(d,Ig,d);const u=yt(n,mf,SA,{[vA]:!0});Q(u,"#"),yt(u,mf,u),Q(u,EJ,u);const h=Q(u,_J);Q(h,"#"),yt(h,mf,u);const m=[[hs,o],[ps,s]],g=[[hs,null],[va,a],[ps,i]];for(let p=0;p<Fu.length;p++)Ks(n,Fu[p],hv,ys,m);for(let p=0;p<Bu.length;p++)Ks(n,Bu[p],pv,fv,g);mo(hv,{tld:!0,ascii:!0},e),mo(pv,{utld:!0,alpha:!0},e),Ks(n,"file",pf,ys,m),Ks(n,"mailto",pf,ys,m),Ks(n,"http",xa,ys,m),Ks(n,"https",xa,ys,m),Ks(n,"ftp",xa,ys,m),Ks(n,"ftps",xa,ys,m),mo(pf,{scheme:!0,ascii:!0},e),mo(xa,{slashscheme:!0,ascii:!0},e),t=t.sort((p,x)=>p[0]>x[0]?1:-1);for(let p=0;p<t.length;p++){const x=t[p][0],v=t[p][1]?{[bJ]:!0}:{[SJ]:!0};x.indexOf("-")>=0?v[uv]=!0:hs.test(x)?ps.test(x)?v[Rc]=!0:v[cv]=!0:v[lv]=!0,TS(n,x,x,v)}return TS(n,"localhost",Nd,{ascii:!0}),n.jd=new On(lp),{start:n,tokens:Object.assign({groups:e},CA)}}function NA(t,e){const n=$J(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=n.length,s=[];let i=0,o=0;for(;o<r;){let a=t,l=null,c=0,d=null,u=-1,h=-1;for(;o<r&&(l=a.go(n[o]));)a=l,a.accepts()?(u=0,h=0,d=a):u>=0&&(u+=n[o].length,h++),c+=n[o].length,i+=n[o].length,o++;i-=u,o-=h,c-=u,s.push({t:d.t,v:e.slice(i-c,i),s:i-c,e:i})}return s}function $J(t){const e=[],n=t.length;let r=0;for(;r<n;){let s=t.charCodeAt(r),i,o=s<55296||s>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Ks(t,e,n,r,s){let i;const o=e.length;for(let a=0;a<o-1;a++){const l=e[a];t.j[l]?i=t.j[l]:(i=new On(r),i.jr=s.slice(),t.j[l]=i),t=i}return i=new On(n),i.jr=s.slice(),t.j[e[o-1]]=i,i}function AS(t){const e=[],n=[];let r=0,s="0123456789";for(;r<t.length;){let i=0;for(;s.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+i),10);o>0;o--)n.pop();r+=i}else n.push(t[r]),r++}return e}const Ed={defaultProtocol:"http",events:null,format:RS,formatHref:RS,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],ignoreClasses:[],render:null};function U0(t,e=null){let n=Object.assign({},Ed);t&&(n=Object.assign(n,t instanceof U0?t.o:t));const r=n.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=s,this.ignoreClasses=n.ignoreClasses.slice()}U0.prototype={o:Ed,ignoreTags:[],ignoreClasses:[],isIgnoredClass(t){if(typeof t!="string"||this.ignoreClasses.length===0)return!1;const e=t.split(/\s+/);for(let n=0;n<e.length;n++)if(this.ignoreClasses.indexOf(e[n])>=0)return!0;return!1},defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let s=this.o[t];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:Ed[t],typeof s=="function"&&r&&(s=s(e,n))):typeof s=="function"&&r&&(s=s(e,n.t,n)),s)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function RS(t){return t}function EA(t,e){this.t="token",this.v=t,this.tk=e}EA.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=Ed.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),s=t.get("tagName",n,e),i=this.toFormattedString(t),o={},a=t.get("className",n,e),l=t.get("target",n,e),c=t.get("rel",n,e),d=t.getObj("attributes",n,e),u=t.getObj("events",n,e);return o.href=r,a&&(o.class=a),l&&(o.target=l),c&&(o.rel=c),d&&Object.assign(o,d),{tagName:s,attributes:o,content:i,eventListeners:u}}};function dm(t,e){class n extends EA{constructor(s,i){super(s,i),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const MJ=dm("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),IS=dm("text"),TJ=dm("nl"),Vu=dm("url",{isLink:!0,toHref(t=Ed.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Nd&&t[1].t===go}}),rr=t=>new On(t);function OJ({groups:t}){const e=t.domain.concat([Yh,Xh,ri,ep,tp,np,rp,sp,sr,z0,Dc,ip,op,Ra,Wr,lp,zc,ap]),n=[Qh,go,F0,Vr,B0,Dc,so,V0,W0,Bh,Vh,Ic,Pc,zh,Dh,Lh,Fh,Wh,Uh,Zh,Hh,qh,Kh,Jh,Gh],r=[Yh,Qh,Xh,ep,tp,np,rp,sp,sr,Ic,Pc,Dc,ip,op,Ra,so,Wr,lp,zc,ap],s=rr(),i=Q(s,zc);Pe(i,r,i),Pe(i,t.domain,i);const o=rr(),a=rr(),l=rr();Pe(s,t.domain,o),Pe(s,t.scheme,a),Pe(s,t.slashscheme,l),Pe(o,r,i),Pe(o,t.domain,o);const c=Q(o,ri);Q(i,ri,c),Q(a,ri,c),Q(l,ri,c);const d=Q(i,Vr);Pe(d,r,i),Pe(d,t.domain,i);const u=rr();Pe(c,t.domain,u),Pe(u,t.domain,u);const h=Q(u,Vr);Pe(h,t.domain,u);const m=rr(MJ);Pe(h,t.tld,m),Pe(h,t.utld,m),Q(c,Nd,m);const g=Q(u,sr);Q(g,sr,g),Pe(g,t.domain,u),Pe(m,t.domain,u),Q(m,Vr,h),Q(m,sr,g);const p=Q(o,sr),x=Q(o,Vr);Q(p,sr,p),Pe(p,t.domain,o),Pe(x,r,i),Pe(x,t.domain,o);const y=rr(Vu);Pe(x,t.tld,y),Pe(x,t.utld,y),Pe(y,t.domain,o),Pe(y,r,i),Q(y,Vr,x),Q(y,sr,p),Q(y,ri,c);const v=Q(y,go),k=rr(Vu);Pe(v,t.numeric,k);const w=rr(Vu),C=rr();Pe(w,e,w),Pe(w,n,C),Pe(C,e,w),Pe(C,n,C),Q(y,Wr,w),Q(k,Wr,w),Q(y,so,C),Q(y,Ra,w),Q(k,so,C),Q(k,Ra,w);const E=Q(a,go),_=Q(l,go),S=Q(_,Wr),j=Q(S,Wr);Pe(a,t.domain,o),Q(a,Vr,x),Q(a,sr,p),Pe(l,t.domain,o),Q(l,Vr,x),Q(l,sr,p),Pe(E,t.domain,w),Q(E,Wr,w),Q(E,so,w),Pe(j,t.domain,w),Pe(j,e,w),Q(j,Wr,w);const $=[[Ic,Pc],[Dh,zh],[Lh,Fh],[Bh,Vh],[Wh,Uh],[Zh,Hh],[qh,Kh],[Jh,Gh]];for(let I=0;I<$.length;I++){const[L,D]=$[I],B=Q(w,L);Q(C,L,B);const H=rr(Vu);Pe(B,e,H);const T=rr();Pe(B,n,T),Q(B,D,w),Pe(H,e,H),Pe(H,n,T),Pe(T,e,H),Pe(T,n,T),Q(H,D,w),Q(T,D,w)}return Q(s,Nd,y),Q(s,L0,TJ),{start:s,tokens:CA}}function AJ(t,e,n){let r=n.length,s=0,i=[],o=[];const a=[];for(;s<r;){let l=t,c=null,d=null,u=0,h=null,m=-1,g=[];for(;s<r&&!(c=l.go(n[s].t));)o.push(n[s++]);for(;s<r&&(d=c||l.go(n[s].t));)if(c=null,l=d,s++,u++,l.accepts())m=0,h=l,g=[];else if(m>=0&&m++,g.push(l),a[s]&&a[s].has(l))break;for(let p=0,x=s-g.length+1;p<g.length;p++,x++)(a[x]||(a[x]=new Set)).add(g[p]);if(m<0)s-=u,s<r&&(o.push(n[s]),s++);else{o.length>0&&(i.push(Pg(IS,e,o)),o=[]),s-=m,u-=m;const p=h.t,x=n.slice(s-u,s);i.push(Pg(p,e,x))}}return o.length>0&&i.push(Pg(IS,e,o)),i}function Pg(t,e,n){const r=n[0].s,s=n[n.length-1].e,i=e.slice(r,s);return new t(i,n)}const RJ=typeof console<"u"&&console&&console.warn||(()=>{}),IJ="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",it={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function PJ(){return On.groups={},it.scanner=null,it.parser=null,it.tokenQueue=[],it.pluginQueue=[],it.customSchemes=[],it.initialized=!1,it}function PS(t,e=!1){if(it.initialized&&RJ(`linkifyjs: already initialized - will not register custom scheme "${t}" ${IJ}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
937
+ 1. Must only contain digits, lowercase ASCII letters or "-"
938
+ 2. Cannot start or end with "-"
939
+ 3. "-" cannot repeat`);it.customSchemes.push([t,e])}function DJ(){it.scanner=jJ(it.customSchemes);for(let t=0;t<it.tokenQueue.length;t++)it.tokenQueue[t][1]({scanner:it.scanner});it.parser=OJ(it.scanner.tokens);for(let t=0;t<it.pluginQueue.length;t++)it.pluginQueue[t][1]({scanner:it.scanner,parser:it.parser});return it.initialized=!0,it}function Z0(t){return it.initialized||DJ(),AJ(it.parser.start,t,NA(it.scanner.start,t))}Z0.scan=NA;function _A(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new U0(n),s=Z0(t),i=[];for(let o=0;o<s.length;o++){const a=s[o];a.isLink&&(!e||a.t===e)&&r.check(a)&&i.push(a.toFormattedObject(r))}return i}var H0="[\0-   ᠎ -\u2029  ]",zJ=new RegExp(H0),LJ=new RegExp(`${H0}$`),FJ=new RegExp(H0,"g");function BJ(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function VJ(t){return new Bn({key:new zr("autolink"),appendTransaction:(e,n,r)=>{const s=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,a=AO(n.doc,[...e]);if(FO(a).forEach(({newRange:c})=>{const d=DH(r.doc,c,m=>m.isTextblock);let u,h;if(d.length>1)u=d[0],h=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){const m=r.doc.textBetween(c.from,c.to," "," ");if(!LJ.test(m))return;u=d[0],h=r.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&h){const m=h.split(zJ).filter(Boolean);if(m.length<=0)return!1;const g=m[m.length-1],p=u.pos+h.lastIndexOf(g);if(!g)return!1;const x=Z0(g).map(y=>y.toObject(t.defaultProtocol));if(!BJ(x))return!1;x.filter(y=>y.isLink).map(y=>({...y,from:p+y.start+1,to:p+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>t.validate(y.value)).filter(y=>t.shouldAutoLink(y.value)).forEach(y=>{T0(y.from,y.to,r.doc).some(v=>v.mark.type===t.type)||o.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function WJ(t){return new Bn({key:new zr("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,i;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{const l=r.target;if(!l)return!1;const c=t.editor.view.dom;o=l.closest("a"),o&&!c.contains(o)&&(o=null)}if(!o)return!1;let a=!1;if(t.enableClickSelection&&(a=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const l=LO(e.state,t.type.name),c=(s=o.href)!=null?s:l.href,d=(i=o.target)!=null?i:l.target;c&&(window.open(c,d),a=!0)}return a}}})}var UJ=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,ZJ=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function jA(t,e){let n=0;for(let r=e-1;r>=0&&t[r]==="\\";r-=1)n+=1;return n%2===1}function HJ(t,e){let n=0,r=0;for(;r<e;){if(t[r]!=="`"){r+=1;continue}if(n===0&&jA(t,r)){r+=1;continue}let s=0;for(;r<e&&t[r]==="`";)s+=1,r+=1;n===0?n=s:s===n&&(n=0)}return n>0}function $A(t,e,n){var r,s;const[,i,o]=e;return(e.index?t[e.index-1]:void 0)==="!"||jA(t,(r=e.index)!=null?r:0)||HJ(t,(s=e.index)!=null?s:0)?!1:!!i.trim()&&n(o)}function MA(t){var e,n;const[r,s,i,,o,a,l]=t,c=(e=o??a)!=null?e:l;return{index:(n=t.index)!=null?n:0,text:r,replaceWith:s,data:{href:i,title:c||null,markdown:!0}}}function qJ(t,e){return t.index<e.index+e.text.length&&e.index<t.index+t.text.length}function TA(t){var e,n,r;return{href:(e=t.data)==null?void 0:e.href,title:(r=(n=t.data)==null?void 0:n.title)!=null?r:null}}function KJ(t){const e=Sl({find:n=>{const r=UJ.exec(n);return!r||!$A(n,r,t.isAllowedHref)?null:MA(r)},type:t.type,getAttributes:TA});return new ZO({find:e.find,handler:n=>{const r=e.handler(n);return r!==null&&n.state.tr.steps.length&&n.state.tr.setMeta("preventAutolink",!0),r}})}function JJ(t){const e=Zo({find:n=>{var r,s;const i=[];for(const a of n.matchAll(ZJ))$A(n,a,t.isAllowedHref)&&i.push(MA(a));const o=((s=(r=t.findPlainUrls)==null?void 0:r.call(t,n))!=null?s:[]).filter(a=>!i.some(l=>qJ(l,a)));return[...i,...o]},type:t.type,getAttributes:TA});return new qO({find:e.find,handler:n=>{var r;const s=e.handler(n);return s!==null&&n.state.tr.steps.length&&((r=n.match.data)!=null&&r.markdown)&&n.state.tr.setMeta("preventAutolink",!0),s}})}function GJ(t){return new Bn({key:new zr("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:i}=e,{selection:o}=i,{empty:a}=o;if(a)return!1;let l="";r.content.forEach(d=>{l+=d.textContent});const c=_A(l,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===l);return!l||!c||s!==void 0&&!s(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function ms(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace(FJ,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}var YJ=Xd.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){PS(t);return}PS(t.scheme,t.optionalSlashes)})},onDestroy(){PJ()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!ms(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const s=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){var t,e,n;return{href:{default:null,parseHTML(r){return r.getAttribute("href")}},target:{default:(t=this.options.HTMLAttributes.target)!=null?t:null},rel:{default:(e=this.options.HTMLAttributes.rel)!=null?e:null},class:{default:(n=this.options.HTMLAttributes.class)!=null?n:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!ms(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!ms(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Zi(this.options.HTMLAttributes,t),0]:["a",Zi(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,s,i;const o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",a=(i=(s=t.attrs)==null?void 0:s.title)!=null?i:"",l=e.renderChildren(t);return a?`[${l}](${o} "${a}")`:`[${l}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!ms(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!ms(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addInputRules(){return this.options.markdownLinks?[KJ({type:this.type,isAllowedHref:t=>this.options.isAllowedUri(t,{defaultValidate:e=>!!ms(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){const t=e=>{const n=[];if(e){const{protocols:r,defaultProtocol:s}=this.options;_A(e).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:a=>!!ms(a,r),protocols:r,defaultProtocol:s})).forEach(o=>{this.options.shouldAutoLink(o.value)&&n.push({text:o.value,data:{href:o.href},index:o.start})})}return n};return this.options.markdownLinks?[JJ({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:n=>!!ms(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:t})]:[Zo({find:t,type:this.type,getAttributes:e=>{var n;return{href:(n=e.data)==null?void 0:n.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(VJ({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!ms(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(WJ({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(GJ({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),QJ=YJ;function Un({value:t,onSave:e,as:n="span",className:r="",multiline:s=!1,label:i,id:o}){const[a,l]=b.useState(!1);if(a)return f.jsx(XJ,{value:t,multiline:s,className:r,label:i,onDone:d=>{l(!1),d!==void 0&&d.trim()&&d!==t&&e(d)}});const c=()=>{var d;(d=window.getSelection())!=null&&d.toString()||l(!0)};return f.jsx(n,{id:o,className:`${r} -mx-1 cursor-text rounded-md px-1 transition-[background-color] hover:bg-sunken/60 focus-visible:bg-sunken/60`,tabIndex:0,title:"Click to edit","aria-description":`${i}. Press Enter to edit.`,onClick:d=>{d.target.closest("a")||c()},onKeyDown:d=>{d.key==="Enter"&&d.target===d.currentTarget&&(d.preventDefault(),l(!0))},children:f.jsx(fl,{text:t,multiline:s})})}function XJ({value:t,multiline:e,className:n,label:r,onDone:s}){const i=b.useRef(null),o=b.useRef(!1),a=(d,u)=>{o.current||(o.current=!0,s(u&&d?nG(d.getJSON()):void 0))},l=fA({extensions:[gA,yA,xA,cJ,mJ,vJ,QJ.configure({openOnClick:!1,autolink:!0,linkOnPaste:!0})],content:tG(t,e),autofocus:"end",immediatelyRender:!0,editorProps:{attributes:{class:"outline-none [&>p+p]:mt-[0.8em]","aria-label":r,role:"textbox","aria-multiline":String(e)},handleKeyDown:(d,u)=>u.key==="Escape"?(a(null,!1),!0):u.key==="Enter"&&!u.shiftKey&&(!e||u.metaKey||u.ctrlKey)?(a(c.current,!0),!0):!1},onBlur:({editor:d,event:u})=>{var h;u.relatedTarget instanceof Node&&((h=i.current)!=null&&h.contains(u.relatedTarget))||a(d,!0)}}),c=b.useRef(null);return c.current=l,f.jsxs("div",{className:`${n} relative -mx-1 rounded-md bg-raised px-1 ring-2 ring-poney/50`,children:[f.jsx(eG,{editor:l,bar:i}),f.jsx(P0,{editor:l})]})}function eG({editor:t,bar:e}){const[n,r]=b.useState(!1),[s,i]=b.useState("");if(!t)return null;const o=(l,c,d,u,h)=>f.jsx("button",{type:"button","aria-label":c,"aria-pressed":l,title:`${c} (${h})`,onMouseDown:m=>m.preventDefault(),onClick:u,className:`grid h-7 w-7 place-items-center rounded-md ${l?"bg-ink text-paper":"text-ink-2 hover:bg-sunken"}`,children:d}),a=/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl+";return f.jsxs("div",{ref:e,className:"absolute -top-10 left-0 z-20 flex items-center gap-0.5 rounded-lg border border-rule bg-raised p-0.5 font-sans text-[13px] font-normal leading-none tracking-normal shadow-float",children:[o(t.isActive("bold"),"Bold",f.jsx(yD,{size:14}),()=>t.chain().focus().toggleBold().run(),`${a}B`),o(t.isActive("italic"),"Italic",f.jsx(mD,{size:14}),()=>t.chain().focus().toggleItalic().run(),`${a}I`),o(t.isActive("code"),"Code",f.jsx(oD,{size:14}),()=>t.chain().focus().toggleCode().run(),`${a}E`),o(t.isActive("link"),"Link",f.jsx(xD,{size:14}),()=>{if(t.isActive("link"))return void t.chain().focus().unsetLink().run();i(""),r(!0)},"paste a URL on a selection"),n&&f.jsx("form",{className:"flex items-center gap-1 pl-1",onSubmit:l=>{l.preventDefault(),s.trim()?t.chain().focus().setLink({href:s.trim()}).run():t.commands.focus(),r(!1)},children:f.jsx("input",{autoFocus:!0,value:s,onChange:l=>i(l.target.value),onKeyDown:l=>l.key==="Escape"&&(r(!1),t.commands.focus()),placeholder:"https://","aria-label":"Link address",className:"h-7 w-56 rounded-md border border-rule bg-paper px-2 text-[12.5px] outline-none focus:border-rule-strong"})})]})}function tG(t,e){const n=e?x1(t):[t.replace(/\n+/g," ")];return{type:"doc",content:(n.length?n:[""]).map(r=>{const s=Ba(r).map(i=>({type:"text",text:i.text,marks:[...i.marks.map(o=>({type:o})),...i.href?[{type:"link",attrs:{href:i.href}}]:[]]}));return s.length?{type:"paragraph",content:s}:{type:"paragraph"}})}}function nG(t){return(t.content??[]).map(e=>SP((e.content??[]).map(n=>{var i,o,a;const r=(n.marks??[]).map(l=>l.type).filter(l=>l==="bold"||l==="italic"||l==="code"),s=(a=(o=(i=n.marks)==null?void 0:i.find(l=>l.type==="link"))==null?void 0:o.attrs)==null?void 0:a.href;return{text:n.text??"",marks:r,...s?{href:s}:{}}})).trim()).filter(Boolean).join(`
940
+
941
+ `)}function rG({block:t,onEditNote:e}){var m,g;const n=T7(t),r=R(Wd),s=t.hunks.flatMap(p=>p.lines),i=s.filter(p=>p.kind==="add").length,o=s.filter(p=>p.kind==="del").length,a=i===0&&o===0&&s.every(p=>p.old===void 0),l=(m=s[0])==null?void 0:m.new,c=(g=s[s.length-1])==null?void 0:g.new,d=new Map;t.notes.forEach((p,x)=>d.set(p.line,[...d.get(p.line)??[],{text:p.text,index:x}]));const u=t.path.split("/").slice(-2).join("/"),h=(p,x)=>uT(t.path,p,x);return f.jsxs("figure",{className:"overflow-hidden rounded-xl border border-rule bg-raised",children:[f.jsxs("figcaption",{className:"flex min-w-0 items-center gap-2 border-b border-rule px-3.5 py-2.5 text-[12.5px]",children:[f.jsx(Mp,{size:14,className:"shrink-0 text-ink-3","aria-hidden":!0}),f.jsx("code",{className:"min-w-0 truncate font-mono text-[12px] text-ink",title:t.path,children:u}),t.title&&f.jsx("span",{className:"shrink-0 text-ink-3",children:t.title}),f.jsx("span",{className:"flex-1"}),a?l!==void 0&&f.jsx("span",{className:"font-tabular shrink-0 font-mono text-[11.5px] text-ink-3",children:l===c?`line ${l}`:`lines ${l}–${c}`}):f.jsxs("span",{className:"font-tabular shrink-0 font-mono text-[11.5px]",children:[f.jsxs("span",{className:"text-new",children:["+",i]})," ",f.jsxs("span",{className:"text-removed",children:["−",o]})]})]}),f.jsx("div",{className:"scrollbar-quiet overflow-x-auto",children:f.jsx("table",{className:"w-full border-collapse font-mono text-[12px] leading-[21px] [font-variant-ligatures:none]",children:f.jsx("tbody",{children:t.hunks.map((p,x)=>f.jsxs(b.Fragment,{children:[p.header&&f.jsx("tr",{children:f.jsx("td",{colSpan:a?2:4,className:"bg-sunken/60 px-3.5 py-1 text-[11px] text-ink-3",children:p.header})}),p.lines.map((y,v)=>{var E;const k=y.kind==="add"?"bg-new-wash":y.kind==="del"?"bg-removed-wash":"",w=y.kind==="add"?"+":y.kind==="del"?"−":"",C=y.kind!=="del"&&y.new?d.get(y.new):void 0;return f.jsxs(b.Fragment,{children:[f.jsxs("tr",{className:`group/line ${k}`,onContextMenu:y.new!==void 0?qb(t.path,y.new,y.text):void 0,children:[!a&&f.jsx("td",{className:"w-10 select-none pr-1 text-right align-top text-ink-4",children:y.old??""}),f.jsxs("td",{className:`relative w-10 select-none text-right align-top text-ink-4 ${a?"pr-4":"pr-2"}`,children:[f.jsx("span",{className:r&&y.new?"group-hover/line:invisible":"",children:y.new??""}),r&&y.new!==void 0&&f.jsx("button",{type:"button",title:"Ask the agent about this line","aria-label":`Ask the agent about line ${y.new}`,onClick:()=>uo(h(y.new,y.text)),className:`absolute inset-y-0 grid place-items-center text-poney opacity-0 focus-visible:opacity-100 group-hover/line:opacity-100 ${a?"right-3":"right-1"}`,children:f.jsx(kD,{size:14})})]}),!a&&f.jsx("td",{className:`w-4 select-none align-top ${y.kind==="add"?"text-new":"text-removed"}`,children:w}),f.jsx("td",{className:"whitespace-pre pr-4 text-ink",children:((E=n==null?void 0:n.get(`${x}:${v}`))==null?void 0:E.map((_,S)=>f.jsx("span",{className:"code-token",style:_.style,children:_.content},S)))??(y.text||" ")})]}),C==null?void 0:C.map(_=>f.jsxs("tr",{onContextMenu:y.new!==void 0?qb(t.path,y.new,y.text,_.text):void 0,children:[f.jsx("td",{colSpan:a?1:3}),f.jsx("td",{className:"py-1.5 pr-4",children:f.jsxs("span",{className:"inline-flex max-w-[56ch] items-start gap-2 whitespace-normal rounded-lg border border-rule bg-paper px-2.5 py-1.5 font-sans text-[12.5px] leading-snug text-ink-2",children:[f.jsx(wD,{size:13,className:"mt-0.5 shrink-0 text-ink-3","aria-hidden":!0}),e?f.jsx(Un,{label:"Note on the code",value:_.text,onSave:S=>e(_.index,S),className:"min-w-[8ch]"}):_.text]})})]},`n${_.index}`))]},v)})]},x))})})})]})}function Dg(t,e){const[n,r]=b.useState(()=>{try{const i=localStorage.getItem(t);return i?JSON.parse(i):e}catch{return e}}),s=b.useCallback(i=>{r(i);try{localStorage.setItem(t,JSON.stringify(i))}catch{}window.dispatchEvent(new Event("poney:local"))},[t]);return[n,s]}function gv({risk:t}){return t==="look"?f.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-changed/40 bg-changed-wash px-2.5 py-0.5 text-[12px] font-semibold text-changed",children:[f.jsx(Ld,{size:12,strokeWidth:2.4})," Look closely"]}):f.jsx("span",{className:"inline-flex items-center rounded-full border border-rule bg-sunken/70 px-2.5 py-0.5 text-[12px] font-semibold text-ink-2",children:"Routine"})}function DS({mode:t,onChange:e}){const n=[{id:"before",label:"Before"},{id:"change",label:"Change"},{id:"after",label:"After"}];return f.jsx("div",{role:"radiogroup","aria-label":"Show the system",className:"inline-flex rounded-lg border border-rule bg-sunken/60 p-0.5",children:n.map(r=>f.jsx("button",{role:"radio","aria-checked":t===r.id,type:"button",onClick:()=>e(r.id),className:`h-7 rounded-md px-3 text-[12.5px] font-medium transition-colors ${t===r.id?"bg-raised text-ink shadow-[0_1px_2px_#0000001a]":"text-ink-3 hover:text-ink"}`,children:r.label},r.id))})}function zS(){return f.jsx("div",{className:"flex items-center gap-3 text-[12px] text-ink-3","aria-label":"Key",children:["new","changed","removed"].map(t=>f.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[f.jsx("span",{className:"h-2.5 w-2.5 rounded-full border-[1.5px]",style:{borderColor:`var(--${t})`,background:`var(--${t}-wash)`}}),N1[t]]},t))})}function LS({walkthrough:t}){var o;const e=Be(),n=R(a=>a.selection),r=R(a=>a.select);if(!n||!e.exists(n))return null;const s=e.describe(n),i=t==null?void 0:t.marks.find(a=>{const l=un(a.ref);return l&&fe(l)===fe(n)});return f.jsxs("div",{className:"fade-in absolute bottom-4 left-4 z-10 w-[300px] rounded-xl border border-rule bg-raised p-3.5 shadow-float",children:[f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:"text-[11.5px] text-ink-3",children:s.kind}),f.jsx("div",{className:"text-[14px] font-semibold leading-snug",children:s.title})]}),f.jsx("button",{type:"button","aria-label":"Close",className:"rounded p-0.5 text-ink-3 hover:bg-sunken hover:text-ink",onClick:()=>r(null),children:f.jsx(Jo,{size:14})})]}),s.summary&&f.jsx("p",{className:"mt-1.5 text-[12.5px] leading-snug text-ink-2",children:s.summary}),n.kind==="entity"&&(((o=e.entities.get(n.id))==null?void 0:o.sourceRefs.length)??0)>0&&f.jsx("ul",{className:"mt-2 space-y-0.5",children:e.entities.get(n.id).sourceRefs.map((a,l)=>f.jsxs("li",{className:"flex min-w-0 items-center gap-1.5 text-ink-3",children:[f.jsx(Mp,{size:12,className:"shrink-0","aria-hidden":!0}),f.jsxs("code",{className:"truncate font-mono text-[11.5px]",title:a.path,children:[a.path,a.line?`:${a.line}`:"",a.symbol?` › ${a.symbol}`:""]})]},l))}),i&&f.jsxs("p",{className:"mt-2 text-[12.5px] leading-snug",children:[f.jsx("span",{className:"font-semibold",style:{color:`var(--${i.state})`},children:N1[i.state]}),i.note?f.jsxs("span",{className:"text-ink-2",children:[": ",i.note]}):" in this change"]}),f.jsxs("button",{type:"button",onClick:()=>Ud(n),className:"mt-3 inline-flex items-center gap-1.5 text-[12.5px] font-semibold text-poney hover:underline",children:[f.jsx(v1,{size:13})," Explore it in the whole system"]})]})}function FS({title:t,onClose:e,children:n}){return b.useEffect(()=>{const r=s=>s.key==="Escape"&&e();return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e]),f.jsx("div",{className:"fade-in fixed inset-0 z-40 bg-ink/30 p-4 backdrop-blur-[2px] sm:p-8",onClick:e,children:f.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":t,className:"flex h-full flex-col overflow-hidden rounded-2xl border border-rule bg-raised shadow-float",onClick:r=>r.stopPropagation(),children:[f.jsxs("div",{className:"flex items-center gap-3 border-b border-rule px-4 py-3",children:[f.jsx("span",{className:"flex-1 text-[14px] font-semibold",children:t}),f.jsx("button",{type:"button",autoFocus:!0,onClick:e,"aria-label":"Close",className:"rounded-md p-1.5 text-ink-3 hover:bg-sunken hover:text-ink",children:f.jsx(Jo,{size:16})})]}),f.jsx("div",{className:"relative min-h-0 flex-1",children:n})]})})}function BS({onClick:t}){return f.jsx("button",{type:"button",onClick:t,"aria-label":"Expand the diagram",title:"Expand",className:"rounded-md p-1.5 text-ink-3 hover:bg-sunken hover:text-ink",children:f.jsx(vD,{size:15})})}function sG({walkthrough:t}){const e=Be(),n=t.kind==="tour",r=b.useMemo(()=>ZE(t),[t]),s=b.useCallback((F,U)=>R.getState().dispatch({type:"walkthrough.setText",walkthroughId:t.id,path:F,value:U}),[t.id]),[i,o]=b.useState(n?"after":"change"),[a,l]=b.useState(n?"after":"change"),[c,d]=b.useState(null),[u,h]=b.useState(0),[m,g]=b.useState(null),[p,x]=Dg(`poney:read:${e.doc.project.id}:${t.id}`,[]),[y,v]=Dg(`poney:answers:${e.doc.project.id}:${t.id}`,{}),[k,w]=Dg(`poney:notes:${e.doc.project.id}:${t.id}`,{}),C=R(F=>F.live.state==="on"),E=R(F=>F.setActiveScene),_=b.useRef(null),S=b.useRef([]),j=t.overview?e.views.get(t.overview):void 0,$=t.scenes[Math.min(u,t.scenes.length-1)];b.useEffect(()=>E($.id),[$.id,E]);const I=$.view?e.views.get($.view):void 0,[L,D]=b.useState(null),[B,H]=b.useState(!1);b.useEffect(()=>{D(null),H(!1)},[$.id]),b.useEffect(()=>{if(!B)return;const F=window.setTimeout(()=>{const U=(L??-1)+1;U>=$.trace.length?H(!1):D(U)},L===null?60:1900);return()=>clearTimeout(F)},[B,L,$.trace.length]);const T=L!==null&&$.trace[L]&&un($.trace[L].ref)?fe(un($.trace[L].ref)):null,M=F=>{H(!1),D(F===null?null:Math.max(0,Math.min($.trace.length-1,F)))};b.useEffect(()=>{const F=_.current;if(!F)return;const U=new IntersectionObserver(K=>{for(const O of K)O.isIntersecting&&h(Number(O.target.dataset.index))},{root:F,rootMargin:"-38% 0px -58% 0px"});return S.current.forEach(K=>K&&U.observe(K)),()=>U.disconnect()},[t]);const A=R(F=>F.jump);b.useEffect(()=>{var U;const F=A?t.scenes.findIndex(K=>K.id===A.scene):-1;F>=0&&((U=S.current[F])==null||U.scrollIntoView({behavior:"smooth",block:"start"}))},[A,t]);const V=F=>{var U;return(U=S.current[F])==null?void 0:U.scrollIntoView({behavior:window.matchMedia("(prefers-reduced-motion: reduce)").matches?"auto":"smooth",block:"start"})},J=F=>x(p.includes(F)?p.filter(U=>U!==F):[...p,F]),X=F=>{const U=un(F);return U?fe(U):F},z=t.source;return f.jsxs("div",{ref:_,className:"scrollbar-quiet relative h-full overflow-y-auto bg-paper",children:[f.jsxs("header",{className:"mx-auto max-w-[1320px] px-6 pt-10 sm:px-10 sm:pt-14",children:[z&&f.jsxs("p",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[13px] text-ink-3",children:[f.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium text-ink-2",children:[n?f.jsx(w1,{size:14}):f.jsx(uD,{size:14})," ",z.kind," ",z.ref??(n?z.repository:void 0)]}),z.head&&f.jsxs("span",{children:["head ",f.jsx("code",{className:"font-mono text-[12px] text-ink-2",children:z.head.slice(0,7)})]}),z.files!==void 0&&f.jsxs("span",{children:[z.files," files"]}),z.added!==void 0&&f.jsxs("span",{className:"font-tabular font-mono text-[12px]",children:[f.jsxs("span",{className:"text-new",children:["+",z.added]})," ",f.jsxs("span",{className:"text-removed",children:["−",z.removed??0]})]}),z.author&&f.jsxs("span",{children:["Walkthrough by ",z.author.charAt(0).toLowerCase()+z.author.slice(1)]})]}),f.jsx(Un,{as:"h1",label:"Title",value:t.title,onSave:F=>s(["title"],F),className:"mt-4 block max-w-[24ch] text-[34px] font-semibold leading-[1.08] tracking-[-0.025em] sm:text-[44px]"}),f.jsx(Un,{as:"p",label:"Summary",value:t.summary,onSave:F=>s(["summary"],F),className:"mt-5 block max-w-[60ch] text-[18px] leading-relaxed text-ink-2"})]}),f.jsxs("section",{"aria-labelledby":"story",className:"mx-auto mt-14 max-w-[1320px] px-6 sm:px-10",children:[f.jsxs("div",{className:`grid gap-x-12 gap-y-6 ${t.story.before||t.story.after?"lg:grid-cols-[minmax(0,7fr)_minmax(0,5fr)]":""}`,children:[f.jsxs("div",{children:[f.jsx("h2",{id:"story",className:"text-[22px] font-semibold tracking-[-0.01em]",children:n?"What this code is for":"What changes for a person"}),f.jsx(Un,{as:"p",multiline:!0,label:"Story",value:t.story.text,onSave:F=>s(["story","text"],F),className:"mt-4 block max-w-[66ch] text-[16.5px] leading-[1.7] text-ink-2"})]}),(t.story.before||t.story.after)&&f.jsxs("dl",{className:"space-y-3 lg:pt-11",children:[f.jsxs("div",{className:"rounded-xl border border-rule bg-raised px-4 py-3.5",children:[f.jsx("dt",{className:"text-[12.5px] font-semibold text-ink-3",children:"Before"}),f.jsx(Un,{as:"dd",label:"Before",value:t.story.before??"",onSave:F=>s(["story","before"],F),className:"mt-1 block text-[15px] leading-snug"})]}),f.jsxs("div",{className:"rounded-xl border border-new/40 bg-new-wash px-4 py-3.5",children:[f.jsx("dt",{className:"text-[12.5px] font-semibold text-new",children:"After"}),f.jsx(Un,{as:"dd",label:"After",value:t.story.after??"",onSave:F=>s(["story","after"],F),className:"mt-1 block text-[15px] leading-snug"})]})]})]}),j&&f.jsxs("figure",{className:"relative mt-8 flex h-[min(620px,72vh)] flex-col overflow-hidden rounded-2xl border border-rule bg-raised",children:[f.jsxs("figcaption",{className:"flex flex-wrap items-center gap-3 border-b border-rule px-4 py-3",children:[f.jsx("span",{className:"text-[13px] font-semibold",children:j.title}),f.jsx("span",{className:"hidden text-[12.5px] text-ink-3 md:inline",children:n?"Open a group to see what is inside it.":"Switch between before and after to see what moves."}),f.jsx("span",{className:"flex-1"}),!n&&f.jsx(zS,{}),!n&&f.jsx(DS,{mode:i,onChange:o}),f.jsx(BS,{onClick:()=>g("hero")})]}),f.jsxs("div",{className:"relative min-h-0 flex-1",children:[f.jsx(Mu,{view:j,walkthrough:t,marks:r,mode:i,focus:[],callouts:[],hot:c,setHot:d,maxScale:1.1}),f.jsx(LS,{walkthrough:t})]})]})]}),t.verdict&&f.jsx("section",{"aria-labelledby":"verdict",className:"mx-auto mt-10 max-w-[1320px] px-6 sm:px-10",children:f.jsxs("div",{className:"rounded-2xl border border-rule bg-raised px-5 py-5 sm:px-6",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("h2",{id:"verdict",className:"text-[16px] font-semibold",children:n?"At a glance":"Verdict"}),(!n||t.verdict.risk==="look")&&f.jsx(gv,{risk:t.verdict.risk})]}),f.jsx("dl",{className:"mt-4 grid gap-x-8 gap-y-4 sm:grid-cols-2 lg:grid-cols-5",children:t.verdict.facts.map(F=>f.jsxs("div",{children:[f.jsx("dt",{className:"text-[12.5px] text-ink-3",children:F.label}),f.jsx("dd",{className:"mt-1 text-[14px] leading-snug",children:F.value})]},F.label))}),t.verdict.findings.length>0&&f.jsxs("div",{className:"mt-5 border-t border-rule pt-4",children:[f.jsx("h3",{className:"text-[13px] font-semibold text-ink-3",children:n?"Good to know":"Findings"}),f.jsx("ul",{className:"mt-2 space-y-1.5",children:t.verdict.findings.map((F,U)=>{const K=F.scene?t.scenes.findIndex(O=>O.id===F.scene):-1;return f.jsxs("li",{className:"flex items-start gap-2.5 text-[14px] leading-snug",children:[F.severity==="risk"?f.jsx(Ld,{size:15,className:"mt-0.5 shrink-0 text-changed"}):f.jsx(pD,{size:15,className:"mt-0.5 shrink-0 text-ink-3"}),f.jsxs("span",{children:[f.jsx(Un,{label:"Finding",value:F.text,onSave:O=>s(["verdict","findings",U,"text"],O)}),K>=0&&f.jsxs("button",{type:"button",onClick:()=>V(K),className:"ml-2 text-[12.5px] font-semibold text-poney hover:underline",children:["See scene ",K+1]})]})]},U)})})]})]})}),f.jsxs("section",{"aria-labelledby":"path",className:"mx-auto mt-14 max-w-[1320px] px-6 sm:px-10",children:[f.jsxs("div",{className:"flex items-end gap-4",children:[f.jsx("h2",{id:"path",className:"text-[22px] font-semibold tracking-[-0.01em]",children:"Read in this order"}),f.jsxs("span",{className:"font-tabular pb-1 text-[13px] text-ink-3",children:[p.length," of ",t.scenes.length," read"]})]}),f.jsx("div",{className:"mt-3 h-1 overflow-hidden rounded-full bg-sunken","aria-hidden":!0,children:f.jsx("div",{className:"h-full rounded-full bg-new transition-[width] duration-500",style:{width:`${p.length/t.scenes.length*100}%`}})}),f.jsx("ol",{className:"mt-5 grid gap-2 md:grid-cols-2 xl:grid-cols-3",children:t.scenes.map((F,U)=>f.jsx("li",{children:f.jsxs("button",{type:"button",onClick:()=>V(U),className:"group flex h-full w-full items-start gap-3 rounded-xl border border-rule bg-raised px-4 py-3.5 text-left transition-colors hover:border-rule-strong",children:[f.jsx("span",{className:`font-tabular mt-0.5 grid h-6 w-6 shrink-0 place-items-center rounded-full text-[12px] font-semibold ${p.includes(F.id)?"bg-new text-paper":"bg-sunken text-ink-2"}`,children:p.includes(F.id)?f.jsx(js,{size:13,strokeWidth:3}):U+1}),f.jsxs("span",{className:"min-w-0 flex-1",children:[f.jsx("span",{className:"block text-[14.5px] font-semibold leading-snug",children:f.jsx(fl,{text:F.title})}),f.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-2 text-[12px] text-ink-3",children:[(!n||F.risk==="look")&&f.jsx(gv,{risk:F.risk}),F.code.map(K=>f.jsx("code",{className:"font-mono text-[11.5px]",children:K.path.split("/").pop()},K.path))]})]})]})},F.id))})]}),f.jsxs("section",{"aria-label":"Scenes",className:"mx-auto mt-16 grid max-w-[1480px] gap-10 px-6 pb-[30vh] sm:px-10 lg:grid-cols-[minmax(360px,500px)_minmax(0,1fr)]",children:[f.jsx("div",{className:"order-2 lg:order-1",children:t.scenes.map((F,U)=>f.jsx(iG,{edit:s,s:F,i:U,count:t.scenes.length,refCb:K=>S.current[U]=K,active:U===u,hot:c,setHot:d,keyOf:X,read:p.includes(F.id),onRead:()=>{J(F.id),!p.includes(F.id)&&U+1<t.scenes.length&&V(U+1)},answers:y,onAnswer:(K,O)=>v({...y,[K]:O}),note:k[F.id]??"",onNote:K=>w({...k,[F.id]:K}),live:C,tour:n,traceStep:U===u?L:null,onTraceStep:K=>U===u?M(K):V(U)},F.id))}),f.jsx("div",{className:"order-1 lg:order-2",children:f.jsxs("figure",{className:"sticky top-4 flex h-[46vh] flex-col overflow-hidden rounded-2xl border border-rule bg-raised lg:top-8 lg:h-[calc(100vh-8rem)]",children:[f.jsxs("figcaption",{className:"flex flex-wrap items-center gap-3 border-b border-rule px-4 py-3",children:[f.jsxs("span",{className:"font-tabular text-[12.5px] text-ink-3",children:[u+1," / ",t.scenes.length]}),f.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] font-semibold",children:(I==null?void 0:I.title)??"Code only"}),$.trace.length>0&&I&&f.jsx(aG,{count:$.trace.length,step:L,playing:B,onPlay:()=>{L!==null&&L>=$.trace.length-1&&D(null),H(!0)},onPause:()=>H(!1),onStep:M}),!n&&f.jsx(zS,{}),!n&&f.jsx(DS,{mode:a,onChange:l}),I&&f.jsx(BS,{onClick:()=>g("scene")})]}),f.jsxs("div",{className:"relative min-h-0 flex-1",children:[I?f.jsx(Mu,{view:I,walkthrough:t,marks:r,mode:a,focus:$.focus,callouts:$.callouts.map(F=>F.target),hot:T??c,setHot:d,sceneData:$,traceStep:L},I.id):f.jsx("div",{className:"grid h-full place-items-center px-8 text-center text-ink-3",children:"This scene is about code only. Read it on the left."}),L!==null&&$.trace[L]&&f.jsxs("p",{className:"fade-in pointer-events-none absolute left-1/2 top-3 z-10 max-w-[80%] -translate-x-1/2 rounded-full border border-rule bg-raised/95 px-3.5 py-1.5 text-center text-[13px] leading-snug shadow-float backdrop-blur","aria-live":"polite",children:[f.jsxs("span",{className:"font-tabular mr-2 font-semibold text-poney",children:[$1(L)," · ",L+1," of ",$.trace.length]}),$.trace[L].caption?f.jsx(fl,{text:$.trace[L].caption}):e.exists(un($.trace[L].ref))?e.describe(un($.trace[L].ref)).title:$.trace[L].ref]}),f.jsx(LS,{walkthrough:t})]})]})})]}),m==="hero"&&j&&f.jsx(FS,{title:j.title,onClose:()=>g(null),children:f.jsx(Mu,{view:j,walkthrough:t,marks:r,mode:i,focus:[],callouts:[],hot:c,setHot:d,maxScale:1.4})}),m==="scene"&&I&&f.jsx(FS,{title:`${u+1}. ${Ar($.title)}`,onClose:()=>g(null),children:f.jsx(Mu,{view:I,walkthrough:t,marks:r,mode:a,focus:$.focus,callouts:$.callouts.map(F=>F.target),hot:T??c,setHot:d,maxScale:1.4,sceneData:$,traceStep:L})}),f.jsx("footer",{className:"mx-auto max-w-[1320px] border-t border-rule px-6 py-10 sm:px-10",children:f.jsxs("button",{type:"button",onClick:()=>R.getState().navigate(bt),className:"inline-flex items-center gap-2 text-[14px] font-semibold text-poney hover:underline",children:[f.jsx(v1,{size:15})," Explore the whole system"]})})]})}function iG({s:t,i:e,count:n,refCb:r,active:s,hot:i,setHot:o,keyOf:a,read:l,onRead:c,answers:d,onAnswer:u,note:h,onNote:m,live:g,tour:p,traceStep:x,onTraceStep:y,edit:v}){const k=(...E)=>_=>v(["scenes",e,...E],_),[w,C]=b.useState(!!h);return f.jsxs("article",{ref:r,"data-index":e,"aria-labelledby":`scene-${t.id}`,className:`scroll-mt-6 border-t border-rule pb-16 pt-10 transition-opacity duration-300 first:border-t-0 first:pt-0 lg:min-h-[85vh] ${s?"":"lg:opacity-55"}`,children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsxs("span",{className:"font-tabular text-[13px] text-ink-3",children:[e+1," of ",n]}),(!p||t.risk==="look")&&f.jsx(gv,{risk:t.risk})]}),f.jsx(Un,{as:"h3",id:`scene-${t.id}`,label:"Scene title",value:t.title,onSave:k("title"),className:"mt-3 block text-[26px] font-semibold leading-tight tracking-[-0.015em]"}),f.jsx(Un,{as:"p",multiline:!0,label:"Scene text",value:t.text,onSave:k("text"),className:"mt-4 block text-[16px] leading-[1.7] text-ink-2"}),t.callouts.length>0&&f.jsx("ol",{className:"mt-6 space-y-1","aria-label":"Notes on the diagram",children:t.callouts.map((E,_)=>{const S=a(E.target);return f.jsxs("li",{onMouseEnter:()=>o(S),onMouseLeave:()=>o(null),onFocus:()=>o(S),onBlur:()=>o(null),tabIndex:0,className:`-mx-2 flex cursor-default gap-3 rounded-lg px-2 py-2 outline-none transition-colors ${i===S?"bg-poney-wash":""}`,children:[f.jsx("span",{className:`font-tabular grid h-[22px] w-[22px] shrink-0 place-items-center rounded-full text-[11.5px] font-bold text-paper ${i===S?"bg-poney":"bg-ink"}`,children:_+1}),f.jsx(Un,{label:`Note ${_+1}`,value:E.text,onSave:k("callouts",_,"text"),className:"text-[14.5px] leading-snug"})]},_)})}),t.trace.length>0&&f.jsxs("div",{className:"mt-8",children:[f.jsx("h4",{className:"text-[13px] font-semibold text-ink-3",children:"Follow the path"}),f.jsx("ol",{className:"mt-2 space-y-0.5",children:t.trace.map((E,_)=>f.jsx("li",{children:f.jsxs("button",{type:"button",onClick:()=>y(_),"aria-current":x===_?"step":void 0,className:`-mx-2 flex w-full items-start gap-3 rounded-lg px-2 py-1.5 text-left transition-colors hover:bg-sunken/70 ${x===_?"bg-poney-wash":""}`,children:[f.jsx("span",{className:`font-tabular mt-px grid h-[19px] w-[19px] shrink-0 place-items-center rounded-[5px] text-[11px] font-bold ${x===_?"bg-poney text-paper":"bg-sunken text-ink-2"}`,children:$1(_)}),f.jsx("span",{className:"text-[14px] leading-snug",children:E.caption?f.jsx(fl,{text:E.caption}):E.ref})]})},_))})]}),t.cases.length>0&&f.jsxs("div",{className:"mt-8",children:[f.jsx("h4",{className:"text-[13px] font-semibold text-ink-3",children:"In each case"}),f.jsxs("table",{className:"mt-2 w-full text-left text-[13.5px]",children:[f.jsx("thead",{className:"sr-only",children:f.jsxs("tr",{children:[f.jsx("th",{children:"When"}),f.jsx("th",{children:"Then"})]})}),f.jsx("tbody",{children:t.cases.map((E,_)=>f.jsxs("tr",{className:"border-b border-rule last:border-b-0",children:[f.jsx("td",{className:"py-2.5 pr-4 align-top text-ink-2",children:f.jsx(Un,{label:"When",value:E.when,onSave:k("cases",_,"when")})}),f.jsxs("td",{className:"py-2.5 align-top",children:[f.jsx(Un,{label:"Then",value:E.then,onSave:k("cases",_,"then"),className:"font-medium"}),E.note&&f.jsx("span",{className:"block text-[12.5px] text-ink-3",children:E.note})]})]},_))})]})]}),t.proof.length>0&&f.jsxs("div",{className:"mt-8",children:[f.jsx("h4",{className:"text-[13px] font-semibold text-ink-3",children:p?"Tests that show it":"Proof"}),f.jsx("ul",{className:"mt-2 space-y-1.5",children:t.proof.map((E,_)=>f.jsxs("li",{className:"flex items-start gap-2.5 text-[13.5px] leading-snug",children:[E.missing?f.jsx(Ld,{size:15,className:"mt-0.5 shrink-0 text-changed"}):f.jsx(js,{size:15,strokeWidth:2.6,className:"mt-0.5 shrink-0 text-new"}),f.jsxs("span",{children:[f.jsx("span",{className:E.missing?"text-changed":"",children:E.missing?`No test yet: ${E.text.charAt(0).toLowerCase()}${E.text.slice(1)}`:E.text}),(E.source||E.test)&&f.jsx("code",{className:"block font-mono text-[11.5px] text-ink-3",children:[E.source,E.test].filter(Boolean).join(" › ")})]})]},_))})]}),[...t.question?[t.question]:[],...t.questions].map((E,_)=>{const S=_===0&&t.question?t.id:`${t.id}#${_}`,j=_===0&&t.question?k("question"):k("questions",t.question?_-1:_),$=d[S];return p?f.jsx(oG,{question:E,answer:$??"",onAnswer:I=>u(S,I),live:g},S):f.jsxs("div",{className:"mt-8 rounded-xl border border-changed/40 bg-changed-wash px-4 py-4",children:[f.jsxs("p",{className:"flex items-start gap-2.5 text-[14.5px] leading-snug",children:[f.jsx(cj,{size:17,className:"mt-0.5 shrink-0 text-changed"}),f.jsx(Un,{label:"Question",value:E,onSave:j})]}),$?f.jsxs("p",{className:"mt-3 flex items-center gap-2 pl-7 text-[13px] text-ink-2",children:[f.jsx(js,{size:14,className:"text-new"})," You answered: ",f.jsx("strong",{className:"font-semibold text-ink",children:$}),f.jsx("button",{type:"button",className:"text-ink-3 underline-offset-2 hover:underline",onClick:()=>u(S,""),children:"Change"})]}):f.jsxs("div",{className:"mt-3 flex gap-2 pl-7",children:[f.jsx("button",{type:"button",onClick:()=>u(S,"Keep it"),className:"h-8 rounded-lg bg-ink px-3 text-[13px] font-semibold text-paper hover:opacity-90",children:"Keep it"}),f.jsx("button",{type:"button",onClick:()=>u(S,"Ask for a change"),className:"h-8 rounded-lg border border-rule-strong bg-raised px-3 text-[13px] font-semibold hover:bg-sunken",children:"Ask for a change"})]})]},S)}),t.code.length>0&&f.jsxs("div",{className:"mt-8 space-y-4",children:[f.jsx("h4",{className:"text-[13px] font-semibold text-ink-3",children:"The code"}),t.code.map((E,_)=>f.jsx(rG,{block:E,onEditNote:(S,j)=>k("code",_,"notes",S,"text")(j)},`${_}:${E.path}`))]}),f.jsx("div",{className:"mt-8",children:w?f.jsxs("label",{className:"block",children:[f.jsx("span",{className:"text-[13px] font-semibold text-ink-3",children:g?"Note for the agent":"Your note"}),f.jsx("textarea",{value:h,onChange:E=>m(E.target.value),rows:3,placeholder:g?"What should change here? The agent reads this.":"What should change here?",className:"mt-1.5 w-full resize-y rounded-xl border border-rule bg-raised px-3 py-2.5 text-[14px] leading-snug outline-none placeholder:text-ink-4 focus:border-rule-strong"})]}):f.jsxs("button",{type:"button",onClick:()=>C(!0),className:"text-[13px] font-semibold text-ink-3 hover:text-ink",children:["+ ",g?"Add a note for the agent":"Add a note"]})}),f.jsxs("button",{type:"button",onClick:c,"aria-pressed":l,className:`mt-8 inline-flex h-9 items-center gap-2 rounded-lg px-3.5 text-[13.5px] font-semibold transition-colors ${l?"bg-new-wash text-new":"border border-rule-strong bg-raised hover:bg-sunken"}`,children:[f.jsx(js,{size:15,strokeWidth:2.6})," ",l?"Read":e+1<n?"Mark as read, then next":"Mark as read"]})]})}function oG({question:t,answer:e,onAnswer:n,live:r}){const[s,i]=b.useState(e),o=e.trim()!==""&&s===e;return f.jsxs("div",{className:"mt-8 rounded-xl border border-rule bg-raised px-4 py-4",children:[f.jsxs("p",{className:"flex items-start gap-2.5 text-[14.5px] font-medium leading-snug",children:[f.jsx(cj,{size:17,className:"mt-0.5 shrink-0 text-poney"}),t]}),f.jsxs("form",{className:"mt-3 pl-7",onSubmit:a=>{a.preventDefault(),n(s.trim())},children:[f.jsx("textarea",{value:s,onChange:a=>i(a.target.value),rows:2,"aria-label":"Your answer",placeholder:"Your answer",className:"w-full resize-y rounded-lg border border-rule bg-paper px-3 py-2 text-[14px] leading-snug outline-none placeholder:text-ink-4 focus:border-rule-strong"}),f.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[f.jsx("button",{type:"submit",disabled:!s.trim()||o,className:"h-8 rounded-lg bg-ink px-3 text-[13px] font-semibold text-paper disabled:opacity-35",children:o?"Saved":"Save answer"}),o&&f.jsx("span",{className:"text-[12.5px] text-ink-3",children:r?"The agent can read it. Ask it whether you are right.":"Kept in this browser."})]})]})]})}function aG({count:t,step:e,playing:n,onPlay:r,onPause:s,onStep:i}){const o="grid h-7 w-7 place-items-center rounded-md text-ink-2 hover:bg-sunken disabled:opacity-30";return f.jsxs("div",{className:"flex items-center gap-0.5 rounded-lg border border-rule bg-sunken/60 p-0.5",role:"group","aria-label":"Play the path",children:[f.jsx("button",{type:"button",className:o,"aria-label":"Previous step",disabled:e===null||e===0,onClick:()=>i((e??0)-1),children:f.jsx(p_,{size:15})}),n?f.jsxs("button",{type:"button",onClick:s,className:"inline-flex h-7 items-center gap-1.5 rounded-md bg-raised px-2.5 text-[12.5px] font-semibold text-ink shadow-[0_1px_2px_#0000001a]",children:[f.jsx(SD,{size:13})," Pause"]}):f.jsxs("button",{type:"button",onClick:r,className:"inline-flex h-7 items-center gap-1.5 rounded-md bg-raised px-2.5 text-[12.5px] font-semibold text-ink shadow-[0_1px_2px_#0000001a]",children:[f.jsx(ED,{size:13})," ",e===null?"Play the path":e>=t-1?"Again":"Play"]}),f.jsx("button",{type:"button",className:o,"aria-label":"Next step",disabled:e!==null&&e>=t-1,onClick:()=>i(e===null?0:e+1),children:f.jsx(zd,{size:15})})]})}function lG(){const t=R(o=>o.theme),e=R(o=>o.viewId),n=R(o=>o.selection),r=Be(),s=e===bt?void 0:r.views.get(e),i=r.doc.walkthroughs.find(o=>o.id===zp(e));return b.useEffect(()=>{document.documentElement.dataset.theme=t,document.documentElement.dataset.poneyTheme=t},[t]),b.useEffect(()=>RF(e,n,n?fe(n):null),[e,n]),b.useEffect(()=>{const o=r.doc.project.name,a=(i?Ar(i.title):void 0)??(s==null?void 0:s.title);document.title=a&&a!==o?`${a} · ${o} · Poney`:`${o} · Poney`},[s,i,r.doc.project.name]),b.useEffect(()=>MF(),[]),b.useEffect(()=>{const o=a=>{const l=R.getState(),c=a.metaKey||a.ctrlKey;if(c&&a.key.toLowerCase()==="k"){a.preventDefault(),l.setPaletteOpen(!l.paletteOpen);return}if(c&&a.shiftKey&&a.key.toLowerCase()==="c"){a.preventDefault(),Y1();return}if(!(Q1(a.target)||l.paletteOpen||l.importOpen||l.shortcutsOpen)){if(a.key==="F2"&&l.selection){const d=document.querySelector(`[data-ref="${CSS.escape(fe(l.selection))}"]`);if(d&&X1(l.selection,d))return void a.preventDefault()}if(c&&a.key.toLowerCase()==="z")return a.preventDefault(),void(a.shiftKey?l.redo():l.undo());if(c&&a.key.toLowerCase()==="y")return a.preventDefault(),void l.redo();if(a.altKey&&a.key==="ArrowLeft")return a.preventDefault(),void l.goBack();if(a.altKey&&a.key==="ArrowRight")return a.preventDefault(),void l.goForward();if(!(c||a.altKey))switch(a.key){case"/":a.preventDefault(),l.setPaletteOpen(!0);break;case"[":l.toggleSidebar();break;case"]":l.toggleInspector();break;case"Escape":l.selection&&l.select(null);break;case"f":case"F":l.selection&&l.requestFocus("zoom",l.selection);break;case"!":l.requestFocus("fit");break;case")":l.requestFocus("reset");break;case"?":l.setShortcutsOpen(!0);break;case"o":l.navigate(bt);break;default:return}}};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[]),f.jsxs(LM,{children:[f.jsxs("div",{className:"flex h-full flex-col bg-plaster text-ink",children:[f.jsx("a",{href:"#main",className:"sr-only focus:not-sr-only focus:absolute focus:left-2 focus:top-2 focus:z-50 focus:rounded focus:bg-raised focus:px-3 focus:py-2",children:"Skip to diagram"}),f.jsx(YF,{}),f.jsxs("div",{className:"flex min-h-0 flex-1",children:[f.jsx(tB,{}),f.jsx("main",{id:"main",className:"relative min-w-0 flex-1","aria-label":i?`Walkthrough: ${Ar(i.title)}`:s?`${s.title} diagram`:"Project overview",children:i?f.jsx(sG,{walkthrough:i},i.id):s?f.jsx(WB,{view:s},s.id):f.jsx(qB,{})}),!i&&f.jsx(CB,{})]})]}),f.jsx(y7,{}),f.jsx(VT,{}),f.jsx(w7,{}),f.jsx(b7,{})]})}const OA="poney:recent",AA="poney:last",cG=8;function Cl(){try{const t=localStorage.getItem(OA);return t?JSON.parse(t):[]}catch{return[]}}function RA(t){try{localStorage.setItem(OA,JSON.stringify(t.slice(0,cG)))}catch{}}function dG(t,e,n){const r={id:t.project.id,name:t.project.name,description:t.project.description,origin:e,at:new Date().toISOString(),json:y1(t),...n?{path:n}:{}};RA([r,...Cl().filter(s=>s.id!==t.project.id)]);try{sessionStorage.setItem(AA,t.project.id)}catch{}}function uG(t){RA(Cl().filter(e=>e.id!==t))}async function IA(t){if(t.path&&R.getState().live.state==="on")try{return await XM(t.path),!0}catch{}const e=$l(JSON.parse(t.json),{extensions:Vd()});return!e.ok||!e.document?!1:(R.getState().loadDocument(e.document,t.origin),!0)}function fG(){let t=new URLSearchParams(window.location.search).get("doc");try{t??(t=sessionStorage.getItem(AA))}catch{if(!t)return!1}const e=Cl().find(n=>n.id===t&&n.origin!=="example");return e?(IA(e),!0):!1}function hG(){let t=0,e;R.subscribe(n=>{var r;pG(n.history&&!n.startOpen&&((r=n.projects.find(s=>s.id===n.projectId))==null?void 0:r.origin)!=="example"?n.projectId:null),!(!n.history||n.startOpen||n.history.present===e)&&(e=n.history.present,clearTimeout(t),t=window.setTimeout(()=>{const s=R.getState(),i=s.projects.find(o=>o.id===s.projectId);s.history&&(i==null?void 0:i.origin)!=="example"&&dG(s.history.present,(i==null?void 0:i.origin)??"imported",s.live.state==="on"?s.liveFile??void 0:void 0)},600))})}function pG(t){const e=new URL(window.location.href);(e.searchParams.get("doc")??null)!==t&&(t?e.searchParams.set("doc",t):e.searchParams.delete("doc"),window.history.replaceState(window.history.state,"",e))}async function PA(){var n,r;const{commerce:t}=await p1(async()=>{const{commerce:s}=await import("./src-DZ2JOWW7.js");return{commerce:s}},[]),e=$l(t,{extensions:Vd()});if(!e.ok||!e.document)throw new Error(`The example is invalid: ${(n=e.issues[0])==null?void 0:n.path} ${(r=e.issues[0])==null?void 0:r.message}`);R.getState().loadDocument(e.document,"example")}const mG={command:"npx",args:["-y","--package=@hattoriai/poney","poney-mcp"]},VS=t=>[t.command,...t.args].map(e=>/\s/.test(e)?`"${e}"`:e).join(" "),zg=[{id:"claude",name:"Claude Code",how:"Run in a terminal:",text:t=>`claude mcp add poney -- ${VS(t)}`},{id:"codex",name:"Codex",how:"Run in a terminal:",text:t=>`codex mcp add poney -- ${VS(t)}`},{id:"opencode",name:"OpenCode",how:"Add to opencode.json:",text:t=>JSON.stringify({mcp:{poney:{type:"local",command:[t.command,...t.args],enabled:!0}}},null,2)},{id:"copilot",name:"Copilot",how:"Add to ~/.copilot/mcp-config.json:",text:t=>JSON.stringify({mcpServers:{poney:{type:"local",command:t.command,args:t.args,tools:["*"]}}},null,2)},{id:"other",name:"Other",how:"Add to its MCP settings:",text:t=>JSON.stringify({mcpServers:{poney:{command:t.command,args:t.args}}},null,2)}];function WS(){const t=R(c=>c.live.state==="on"),[e,n]=b.useState(mG),[r,s]=b.useState(zg[0].id),[i,o]=b.useState(!1);b.useEffect(()=>{t&&e0().then(c=>c.mcpServer&&n(c.mcpServer),()=>{})},[t]);const a=zg.find(c=>c.id===r),l=a.text(e);return f.jsxs("div",{children:[f.jsx("div",{role:"tablist","aria-label":"Your agent",className:"flex flex-wrap gap-1",children:zg.map(c=>f.jsx("button",{type:"button",role:"tab","aria-selected":c.id===r,onClick:()=>(s(c.id),o(!1)),className:`h-7 rounded-md px-2 text-[12.5px] font-medium ${c.id===r?"bg-sunken text-ink":"text-ink-3 hover:text-ink"}`,children:c.name},c.id))}),f.jsx("p",{className:"mt-2 text-[12.5px] text-ink-3",children:a.how}),f.jsxs("div",{className:"relative mt-1",children:[f.jsx("pre",{className:"scrollbar-quiet overflow-x-auto whitespace-pre-wrap break-all rounded-lg bg-sunken py-2 pl-2.5 pr-9 font-mono text-[11.5px] text-ink",children:l}),f.jsx("button",{type:"button","aria-label":"Copy",title:"Copy",onClick:()=>{var c;return void((c=navigator.clipboard)==null?void 0:c.writeText(l).then(()=>o(!0)))},className:"absolute right-1.5 top-1.5 grid h-6 w-6 place-items-center rounded-md text-ink-3 hover:bg-raised hover:text-ink",children:i?f.jsx(js,{size:13}):f.jsx(ca,{size:13})})]})]})}const Lc="#/start";function gG(){const t=R(S=>S.theme),e=R(S=>S.live),n=R(S=>!!S.history),r=R(S=>S.projects),s=R(S=>S.sidebarOpen),[i,o]=b.useState(()=>Cl()),[a,l]=b.useState(null),[c,d]=b.useState(!1),[u,h]=b.useState(!1),m=b.useRef(null);b.useEffect(()=>{document.documentElement.dataset.theme=t,document.documentElement.dataset.poneyTheme=t,document.title="Poney Studio"},[t]),b.useEffect(()=>{window.location.hash!==Lc&&window.history.replaceState(null,"",`${window.location.pathname}${window.location.search}${Lc}`)},[]);const g=(S,j,$)=>{const I=G1(S);if(!I.ok)return l({title:`${$} is not a Poney document`,lines:I.issues.slice(0,6).map(L=>L.path?`${L.path}: ${L.message}`:L.message)});l(null),R.getState().loadDocument(I.doc,j)};b.useEffect(()=>{const S=j=>{var I;if(Q1(j.target)||R.getState().importOpen)return;const $=((I=j.clipboardData)==null?void 0:I.getData("text/plain"))??"";if($.trim()){if(j.preventDefault(),Hp($).kind==="unknown")return l({title:"The clipboard has no Poney document",lines:['Copy Poney JSON (it has "poneyVersion") or a Mermaid diagram, then paste again.']});g($,"pasted","The pasted text")}};return window.addEventListener("paste",S),()=>window.removeEventListener("paste",S)},[]);const p=async S=>g(await S.text(),"imported",`“${S.name}”`),x=async()=>{h(!0);try{await PA()}catch(S){l({title:"The example did not open",lines:[S instanceof Error?S.message:String(S)]})}finally{h(!1)}},y=/Mac|iPhone|iPad/.test(navigator.platform)?"⌘":"Ctrl+",v=()=>{var S;return e.state==="on"?R.getState().setFileOpen(!0):(S=m.current)==null?void 0:S.click()},k="group flex w-full items-start gap-4 rounded-xl px-4 py-3.5 text-left transition-colors hover:bg-sunken/70 focus-visible:bg-sunken/70 outline-none",w=S=>{const j=R.getState();if(j.history&&j.projectId===S.id)return j.showStart(!1);IA(S).then($=>$||l({title:`“${S.name}” no longer opens`,lines:["It may come from an older version of Poney, or its file moved. Remove it from the list."]}))},C=r.filter(S=>S.origin!=="example"),E=i.filter(S=>S.origin!=="example"&&!r.some(j=>j.id===S.id)),_="flex w-full min-w-0 items-center gap-2.5 rounded-md px-2 py-1.5 text-left text-[13.5px] hover:bg-sunken";return f.jsxs(LM,{children:[f.jsxs("div",{className:"flex h-full flex-col bg-plaster text-ink",children:[f.jsxs("header",{className:"flex h-12 shrink-0 items-center gap-1 border-b border-rule bg-paper px-2",children:[f.jsx(ot,{label:s?"Hide sidebar":"Show sidebar",onClick:()=>R.getState().toggleSidebar(),side:"bottom",children:f.jsx(gj,{size:16})}),f.jsx("span",{className:"ml-2 text-[13px] font-semibold",children:"Start"}),f.jsx("span",{className:"flex-1"}),f.jsx(ot,{label:t==="light"?"Dark theme":"Light theme",onClick:()=>R.getState().toggleTheme(),side:"bottom",children:t==="light"?f.jsx(b1,{size:16}):f.jsx(Lj,{size:16})})]}),f.jsxs("div",{className:"flex min-h-0 flex-1",children:[f.jsxs("aside",{"aria-label":"Documents",className:`scrollbar-quiet flex w-[264px] shrink-0 flex-col overflow-y-auto border-r border-rule bg-paper transition-[margin] duration-200 max-lg:hidden ${s?"ml-0":"-ml-[264px]"}`,children:[f.jsxs("div",{className:"flex items-center gap-2.5 p-3.5",children:[f.jsx(aT,{}),f.jsxs("span",{className:"min-w-0",children:[f.jsx("span",{className:"block truncate text-[13.5px] font-semibold",children:"Poney Studio"}),f.jsx("span",{className:"block truncate text-[11.5px] text-ink-3",children:C.length?`${C.length} open`:"Nothing open"})]})]}),f.jsx("div",{className:"px-2",children:f.jsxs("button",{type:"button",className:`${_} text-ink-2`,onClick:v,children:[f.jsx(Rw,{size:14,className:"shrink-0 text-ink-3"})," Open a file…"]})}),C.length>0&&f.jsxs("nav",{"aria-label":"Open documents",className:"mt-4 px-2",children:[f.jsx("h2",{className:"px-2 pb-1 text-[11.5px] font-medium text-ink-3",children:"Open"}),C.map(S=>f.jsxs("button",{type:"button",className:_,onClick:()=>S.id===R.getState().projectId?R.getState().showStart(!1):R.getState().switchProject(S.id),children:[f.jsx(Qy,{size:14,className:"shrink-0 text-ink-3"}),f.jsx("span",{className:"truncate",children:S.doc.project.name})]},S.id))]}),E.length>0&&f.jsxs("nav",{"aria-label":"Recent documents",className:"mt-4 px-2 pb-4",children:[f.jsx("h2",{className:"px-2 pb-1 text-[11.5px] font-medium text-ink-3",children:"Recent"}),E.map(S=>f.jsxs("div",{className:"group relative",children:[f.jsxs("button",{type:"button",className:`${_} pr-8`,onClick:()=>w(S),title:`${S.name}, ${US(S.at)}`,children:[f.jsx(Qy,{size:14,className:"shrink-0 text-ink-3"}),f.jsxs("span",{className:"min-w-0",children:[f.jsx("span",{className:"block truncate",children:S.name}),f.jsxs("span",{className:"block truncate text-[11.5px] text-ink-3",children:[S.origin==="example"?"Example":S.origin==="live"?"From an agent":S.origin==="pasted"?"Pasted":"File",", ",US(S.at)]})]})]}),f.jsx("button",{type:"button","aria-label":`Remove ${S.name} from the list`,title:"Remove from the list",onClick:()=>{uG(S.id),o(Cl())},className:"absolute right-1 top-1/2 -translate-y-1/2 rounded p-1 text-ink-4 opacity-0 hover:bg-raised hover:text-ink focus-visible:opacity-100 group-hover:opacity-100",children:f.jsx(Jo,{size:13})})]},S.id))]}),f.jsx(oT,{})]}),f.jsxs("div",{className:"scrollbar-quiet relative min-w-0 flex-1 overflow-y-auto bg-paper text-ink",onDragOver:S=>{S.preventDefault(),d(!0)},onDragLeave:S=>{S.currentTarget===S.target&&d(!1)},onDrop:S=>{S.preventDefault(),d(!1);const j=S.dataTransfer.files[0];j&&p(j)},children:[f.jsxs("main",{className:"mx-auto grid max-w-[1080px] gap-x-14 gap-y-12 px-6 pb-20 pt-14 sm:px-10 sm:pt-20 xl:grid-cols-[minmax(0,7fr)_minmax(0,5fr)]",children:[f.jsxs("div",{children:[f.jsx("p",{className:"text-[14px] font-semibold text-poney",children:"Poney Studio"}),f.jsx("h1",{className:"mt-3 max-w-[18ch] text-[36px] font-semibold leading-[1.08] tracking-[-0.025em] sm:text-[44px]",children:"Software, explained in diagrams."}),f.jsx("p",{className:"mt-5 max-w-[52ch] text-[17px] leading-relaxed text-ink-2",children:"An agent writes walkthroughs of a change, or tours of a codebase. You read them here, explore the system, and ask the agent questions."}),n&&f.jsxs("button",{type:"button",onClick:()=>R.getState().showStart(!1),className:"mt-6 text-[14px] font-semibold text-poney hover:underline",children:["Back to “",R.getState().history.present.project.name,"”"]}),f.jsxs("section",{"aria-labelledby":"open",className:"mt-12",children:[f.jsx("h2",{id:"open",className:"px-4 text-[13px] font-semibold text-ink-3",children:"Open"}),f.jsxs("div",{className:"mt-2",children:[e.state==="on"&&f.jsxs("button",{type:"button",className:k,onClick:()=>R.getState().setProjectOpen(!0),children:[f.jsx(w1,{size:19,className:"mt-0.5 shrink-0 text-ink-2"}),f.jsxs("span",{children:[f.jsx("span",{className:"block text-[15.5px] font-semibold",children:"Open a project"}),f.jsx("span",{className:"mt-0.5 block text-[13.5px] text-ink-3",children:"A folder or a Git repository. Its Poney document opens."})]})]}),f.jsxs("button",{type:"button",className:k,onClick:v,children:[f.jsx(Rw,{size:19,className:"mt-0.5 shrink-0 text-ink-2"}),f.jsxs("span",{children:[f.jsx("span",{className:"block text-[15.5px] font-semibold",children:"Open a file"}),f.jsx("span",{className:"mt-0.5 block text-[13.5px] text-ink-3",children:"A .poney or Mermaid file. You can also drop it here."})]})]}),f.jsxs("button",{type:"button",className:k,onClick:()=>R.getState().setImportOpen(!0),children:[f.jsx(__,{size:19,className:"mt-0.5 shrink-0 text-ink-2"}),f.jsxs("span",{children:[f.jsx("span",{className:"block text-[15.5px] font-semibold",children:"Paste a document"}),f.jsxs("span",{className:"mt-0.5 block text-[13.5px] text-ink-3",children:["Poney JSON or Mermaid. Or press ",f.jsxs("kbd",{className:"rounded border border-rule bg-raised px-1 font-sans text-[12px]",children:[y,"V"]})," anywhere on this page."]})]})]}),f.jsxs("button",{type:"button",className:k,onClick:()=>void x(),disabled:u,children:[f.jsx(sD,{size:19,className:"mt-0.5 shrink-0 text-ink-2"}),f.jsxs("span",{children:[f.jsx("span",{className:"block text-[15.5px] font-semibold",children:u?"Opening the example…":"Try the example"}),f.jsx("span",{className:"mt-0.5 block text-[13.5px] text-ink-3",children:"Kestrel Commerce, an online store: a walkthrough of one change, and a tour of the code."})]})]})]}),f.jsx("input",{ref:m,type:"file",accept:".poney,.json,.mmd,.mermaid,.txt,application/json",className:"hidden",onChange:S=>{var $;const j=($=S.target.files)==null?void 0:$[0];j&&p(j),S.target.value=""}}),a&&f.jsxs("div",{role:"alert",className:"mx-4 mt-4 rounded-xl border border-removed/40 bg-removed-wash px-4 py-3",children:[f.jsx("p",{className:"text-[14px] font-semibold text-removed",children:a.title}),f.jsx("ul",{className:"mt-1.5 space-y-0.5 font-mono text-[12px] text-ink-2",children:a.lines.map((S,j)=>f.jsx("li",{children:S},j))})]})]})]}),f.jsx("aside",{"aria-labelledby":"agent",className:"xl:pt-[164px]",children:f.jsxs("div",{className:"rounded-2xl border border-rule bg-raised px-5 py-5",children:[f.jsx("h2",{id:"agent",className:"text-[15.5px] font-semibold",children:"Agent"}),f.jsx(yG,{})]})})]}),c&&f.jsx("div",{className:"pointer-events-none fixed inset-3 z-50 grid place-items-center rounded-3xl border-2 border-dashed border-poney bg-poney-wash/80",children:f.jsx("p",{className:"text-[18px] font-semibold text-poney",children:"Drop to open"})})]})]})]}),f.jsx(VT,{})]})}function US(t){const e=new Date(t),n=Math.floor((Date.now()-e.getTime())/864e5);return n<=0?"today":n===1?"yesterday":n<7?`${n} days ago`:e.toLocaleDateString(void 0,{day:"numeric",month:"short"})}function yG(){const t=R(i=>i.live.state==="on"),{session:e,listening:n}=R(i=>i.agent),r="mt-3 inline-flex h-9 items-center gap-2 rounded-lg bg-ink px-3.5 text-[13.5px] font-semibold text-paper hover:opacity-90",s="mt-1.5 block break-all rounded-lg bg-sunken px-2.5 py-2 font-mono text-[11.5px] text-ink";return e||n?f.jsxs("div",{className:"mt-3 text-[14px] leading-snug text-ink-2",children:[f.jsxs("p",{className:"flex items-center gap-2",children:[f.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-new","aria-hidden":!0}),e?f.jsxs("span",{children:[f.jsx("span",{className:"font-semibold text-ink",children:e.name})," is ready in ",e.cwd.split("/").pop(),"."]}):"Linked from your terminal."]}),f.jsxs("button",{type:"button",onClick:()=>R.getState().setAgentPanelOpen(!0),className:r,children:[f.jsx(co,{size:15})," Ask the agent"]})]}):t?f.jsxs("div",{className:"mt-3 text-[14px] leading-snug text-ink-2",children:[f.jsxs("button",{type:"button",onClick:()=>R.getState().setConnectOpen(!0),className:r,children:[f.jsx(Tp,{size:15})," Connect an agent"]}),f.jsx("p",{className:"mt-4 border-t border-rule pt-4 text-[13px] font-semibold text-ink",children:"Or use the one in your terminal"}),f.jsx("div",{className:"mt-2",children:f.jsx(WS,{})})]}):f.jsxs("div",{className:"mt-3 text-[14px] leading-snug text-ink-2",children:[f.jsx("p",{children:"Agents need Poney running on this computer. In the Poney folder, run:"}),f.jsx("code",{className:s,children:"npm run studio"}),f.jsx("p",{className:"mt-4 border-t border-rule pt-4 text-[13px] font-semibold text-ink",children:"Or use the one in your terminal"}),f.jsx("div",{className:"mt-2",children:f.jsx(WS,{})})]})}const xG=lm.create({name:"chip",group:"inline",inline:!0,atom:!0,selectable:!1,addAttributes:()=>({ref:{default:null},title:{default:""},kind:{default:""},quote:{default:null}}),parseHTML:()=>[{tag:"span[data-chip]"}],renderHTML:({node:t,HTMLAttributes:e})=>["span",Zi(e,{"data-chip":"",title:t.attrs.quote??t.attrs.ref??"",class:"mx-px inline-flex max-w-[16rem] items-baseline gap-1 truncate rounded-md border border-poney/30 bg-poney-wash px-1.5 align-baseline text-[12.5px] leading-[1.45]"}),["span",{class:"text-ink-3"},t.attrs.kind==="text"?"“":t.attrs.kind],["span",{class:"font-medium text-ink"},`${t.attrs.title}${t.attrs.kind==="text"?"”":""}`]],renderText:({node:t})=>`“${t.attrs.title}”`});function vG(t){const e=[];return{text:(t.content??[]).map(r=>(r.content??[]).map(s=>{if(s.type!=="chip")return s.text??"";const i=s.attrs;return e.some(o=>i.ref?o.ref===i.ref:o.quote===i.quote)||e.push({...i.ref?{ref:i.ref}:{},title:i.title,kind:i.kind,...i.quote?{quote:i.quote}:{}}),`“${i.title}”`}).join("")).join(`
942
+ `).trim(),context:e}}function kG({placeholder:t,onSend:e,actions:n}){const[r,s]=b.useState(!0),i=b.useRef(()=>{}),o=fA({extensions:[gA,yA,xA,xG],immediatelyRender:!0,autofocus:"end",editorProps:{attributes:{class:"min-h-[112px] max-h-[45vh] overflow-y-auto px-3 py-2.5 text-[14px] leading-snug outline-none",role:"textbox","aria-multiline":"true","aria-label":"Your question"},handleKeyDown:(l,c)=>c.key==="Enter"&&!c.shiftKey&&!c.isComposing?(i.current(),!0):!1},onUpdate:({editor:l})=>s(l.isEmpty)}),a=R(l=>l.chips.length);return b.useEffect(()=>{if(!o)return;const l=R.getState().takeChips();l.length&&(wG(o,l),s(!1))},[a,o]),i.current=()=>{if(!o)return;const l=vG(o.getJSON());l.text&&e(l).then(c=>{c&&(o.commands.clearContent(),s(!0))})},f.jsxs("div",{className:"flex items-end gap-2",children:[f.jsxs("div",{className:"relative min-w-0 flex-1 rounded-xl border border-rule bg-paper focus-within:border-rule-strong [&_p]:m-0",children:[r&&f.jsx("span",{className:"pointer-events-none absolute left-3 top-2.5 text-[14px] text-ink-4",children:t}),f.jsx(P0,{editor:o})]}),n(()=>i.current(),r)]})}function wG(t,e){const n=e.flatMap(r=>[{type:"chip",attrs:{ref:r.ref??null,title:r.title,kind:r.kind,quote:r.quote??null}},{type:"text",text:" "}]);t.chain().focus().insertContent(n).run()}function bG(){const t=R(a=>a.agent.session),[e,n]=b.useState(null);if(!t)return null;const r=a=>a.then(()=>n(null)).catch(l=>n(l instanceof Error?l.message:String(l))),s=t.settings.find(a=>a.category==="model"),i=t.settings.find(a=>a.category==="effort"),o=t.settings.filter(a=>a.category==="speed");return f.jsxs("div",{className:"mt-1.5",children:[f.jsxs("div",{className:"flex items-center gap-1 text-[12.5px]",children:[f.jsx(SG,{session:t,model:s,onError:n,run:r}),f.jsx("span",{className:"flex-1"}),(i||o.length>0)&&f.jsx(zA,{label:i?DA(i):"Options",title:"Effort and options",children:a=>f.jsxs(f.Fragment,{children:[o.map(l=>f.jsx(yv,{title:l.name,children:_d(l).map(c=>f.jsx(io,{on:l.current===c.value,label:c.name,hint:c.description,onClick:()=>(a(),r(Rx(l.id,c.value)))},String(c.value)))},l.id)),i&&f.jsx(yv,{title:i.name,children:_d(i).map(l=>f.jsx(io,{on:i.current===l.value,label:l.name,hint:l.description,onClick:()=>(a(),r(Rx(i.id,l.value)))},String(l.value)))})]})})]}),e&&f.jsx("p",{className:"mt-1 text-[12px] text-removed",children:e})]})}function SG({session:t,model:e,run:n,onError:r}){const[s,i]=b.useState(e?"models":"agents"),[o,a]=b.useState([]),[l,c]=b.useState(""),d=e?`${t.name} · ${DA(e)}`:t.name;return f.jsx(zA,{label:d,title:"Agent and model",align:"left",onOpen:()=>{i(e?"models":"agents"),c(""),e0().then(u=>a(u.providers.filter(h=>h.available)),()=>r("The list of agents is not available."))},children:u=>s==="agents"?f.jsxs(f.Fragment,{children:[f.jsxs(yv,{title:"Agent",children:[o.map(h=>f.jsx(io,{on:h.id===t.providerId,label:h.name,trailing:h.id===t.providerId&&e?f.jsx(zd,{size:13}):void 0,onClick:()=>{if(h.id===t.providerId)return e?i("models"):u();u(),n(Ax({providerId:h.id}))}},h.id)),Ix().map(h=>{const m=`custom:${h.name}`;return f.jsx(io,{on:m===t.providerId,label:h.name,onClick:()=>{u(),m!==t.providerId&&n(Ax({custom:h}))}},m)})]}),f.jsx("div",{className:"my-1 h-px bg-rule"}),f.jsx(io,{label:"Change agent",icon:f.jsx($D,{size:13}),onClick:()=>(u(),R.getState().setConnectOpen(!0))})]}):f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"px-2.5 pb-1 pt-1.5 text-[11.5px] font-semibold text-ink-3",children:t.name}),f.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:_d(e).filter(h=>!l||h.name.toLowerCase().includes(l.toLowerCase())).map(h=>f.jsx(io,{on:e.current===h.value,label:h.name,hint:h.description,tags:[...h.recommended?["Recommended"]:[],...e.initial===h.value&&!h.recommended?["Your setting"]:[]],onClick:()=>(u(),n(Rx(e.id,h.value)))},String(h.value)))}),_d(e).length>8&&f.jsx("input",{autoFocus:!0,value:l,onChange:h=>c(h.target.value),placeholder:"Search models…","aria-label":"Search models",className:"mx-1 my-1 h-8 w-[calc(100%-8px)] rounded-md border border-rule bg-paper px-2 text-[12.5px] focus:border-rule-strong",style:{outline:"none"}}),f.jsx("div",{className:"my-1 h-px bg-rule"}),f.jsx(io,{label:"Other agents",icon:f.jsx(n_,{size:13}),onClick:()=>i("agents")})]})})}const _d=t=>t.kind==="boolean"?[{value:!0,name:"On"},{value:!1,name:"Off"}]:t.options,DA=t=>{var e;return((e=_d(t).find(n=>n.value===t.current))==null?void 0:e.name)??String(t.current)};function zA({label:t,title:e,align:n="right",onOpen:r,children:s}){const[i,o]=b.useState(!1),[a,l]=b.useState(null),c=b.useRef(null),d=b.useRef(null);return b.useEffect(()=>{if(!i)return;const u=m=>{var g;return!((g=c.current)!=null&&g.contains(m.target))&&o(!1)},h=m=>m.key==="Escape"&&o(!1);return window.addEventListener("pointerdown",u,!0),window.addEventListener("keydown",h),()=>{window.removeEventListener("pointerdown",u,!0),window.removeEventListener("keydown",h)}},[i]),f.jsxs("div",{ref:c,className:"relative min-w-0",children:[f.jsxs("button",{ref:d,type:"button","aria-haspopup":"menu","aria-expanded":i,title:e,onClick:()=>{if(!i){r==null||r();const u=d.current.getBoundingClientRect();l({...n==="left"?{left:u.left}:{right:window.innerWidth-u.right},bottom:window.innerHeight-u.top+6,maxHeight:u.top-16})}o(!i)},className:`inline-flex h-7 max-w-full items-center gap-1 rounded-md px-2 font-medium text-ink-2 hover:bg-sunken hover:text-ink ${i?"bg-sunken text-ink":""}`,children:[f.jsx("span",{className:"truncate",children:t}),f.jsx(f_,{size:12,className:"shrink-0"})]}),i&&a&&f.jsx("div",{role:"menu","aria-label":e,className:"fade-in fixed z-50 flex w-72 flex-col overflow-y-auto rounded-xl border border-rule bg-raised p-1 shadow-float",style:a,children:s(()=>o(!1))})]})}function yv({title:t,children:e}){return f.jsxs("div",{className:"[&+&]:mt-1 [&+&]:border-t [&+&]:border-rule [&+&]:pt-1",children:[f.jsx("div",{className:"px-2.5 pb-0.5 pt-1.5 text-[11.5px] font-semibold text-ink-3",children:t}),e]})}function io({label:t,hint:e,tags:n=[],on:r,icon:s,trailing:i,onClick:o}){return f.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":!!r,onClick:o,title:e,className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-[13px] hover:bg-sunken",children:[s&&f.jsx("span",{className:"shrink-0 text-ink-3",children:s}),f.jsx("span",{className:"min-w-0 flex-1",children:f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"truncate",children:t}),n.map(a=>f.jsx("span",{className:`shrink-0 rounded-full px-1.5 text-[10.5px] font-semibold ${a==="Recommended"?"bg-new-wash text-new":"bg-sunken text-ink-3"}`,children:a},a))]})}),r&&f.jsx(js,{size:13,className:"shrink-0 text-poney"}),i&&f.jsx("span",{className:"shrink-0 text-ink-3",children:i})]})}function CG(){const t=R(p=>p.live.state==="on"),e=R(p=>p.agentPanelOpen),n=R(p=>p.setAgentPanelOpen),r=R(p=>p.conversation),{session:s,listening:i}=R(p=>p.agent),[o,a]=b.useState(0),l=b.useRef(null),c=r.filter(p=>p.from==="agent"||p.from==="permission").length,d=e?0:Math.max(0,c-o);b.useEffect(()=>{e&&a(c)},[e,c]),b.useEffect(()=>{var p,x;e&&((x=(p=l.current)==null?void 0:p.lastElementChild)==null||x.scrollIntoView({block:"end"}))},[e,r]);const u=R(p=>{var x;return(x=p.history)==null?void 0:x.present}),h=iT();if(!t)return null;if(!e)return f.jsxs("button",{type:"button",onClick:()=>n(!0),className:"fixed bottom-5 right-5 z-30 inline-flex h-11 items-center gap-2 rounded-full bg-ink pl-4 pr-5 text-[14px] font-semibold text-paper shadow-float hover:opacity-95",children:[s!=null&&s.busy?f.jsx(Ro,{size:17,className:"animate-spin"}):f.jsx(co,{size:17}),"Agent",d>0&&f.jsx("span",{className:"font-tabular ml-1 grid h-5 min-w-5 place-items-center rounded-full bg-poney px-1.5 text-[11.5px] text-paper",children:d})]});const m=JF(u),g=!s&&r.length>0&&r[r.length-1].from==="person";return f.jsxs("section",{"aria-label":"Agent",className:"fade-in fixed bottom-5 right-5 z-30 flex max-h-[min(680px,80vh)] w-[min(420px,calc(100vw-2.5rem))] flex-col overflow-hidden rounded-2xl border border-rule bg-raised shadow-float",children:[f.jsxs("header",{className:"flex items-start gap-3 border-b border-rule px-4 py-3",children:[f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("h2",{className:"text-[14px] font-semibold",children:s?s.name:"Agent"}),f.jsxs("p",{className:"mt-0.5 flex min-w-0 items-center gap-1.5 text-[12px] text-ink-3",children:[f.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${s||i?"bg-new":"bg-ink-4"}`,"aria-hidden":!0}),s?f.jsxs("span",{className:"truncate",title:h==null?void 0:h.root,children:[s.busy?"Working":"Ready",h?` in ${h.name}`:""]}):i?"Linked from another session":g?"Waiting for an agent":"Not connected"]})]}),s&&f.jsx("button",{type:"button",onClick:()=>void LF(),title:"Stop the agent",className:"rounded-md px-2 py-1 text-[12px] font-medium text-ink-3 hover:bg-sunken hover:text-ink",children:"Disconnect"}),f.jsx("button",{type:"button","aria-label":"Close",onClick:()=>n(!1),className:"rounded-md p-1 text-ink-3 hover:bg-sunken hover:text-ink",children:f.jsx(Jo,{size:16})})]}),f.jsxs("ol",{ref:l,className:"scrollbar-quiet min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-4","aria-live":"polite",children:[r.length===0&&f.jsx(NG,{}),r.map(p=>f.jsx(EG,{m:p},p.id)),(s==null?void 0:s.busy)&&f.jsxs("li",{className:"flex items-center gap-2 text-[12.5px] text-ink-3",children:[f.jsx(Ro,{size:13,className:"animate-spin"})," Working…"]})]}),s&&r.filter(p=>p.from==="person").length===0&&f.jsx("div",{className:"flex flex-wrap gap-1.5 border-t border-rule px-3 py-3",children:m.map(p=>f.jsx("button",{type:"button",onClick:()=>void qp(p.prompt),className:"rounded-full border border-rule bg-paper px-3 py-1.5 text-[12.5px] font-medium hover:border-rule-strong",children:p.label},p.label))}),f.jsx(_G,{busy:!!(s!=null&&s.busy)})]})}function NG(){const{session:t,listening:e}=R(n=>n.agent);return t||e?f.jsx("li",{className:"text-[13.5px] leading-snug text-ink-3",children:"It sees the scene you are on and what you select."}):f.jsx("li",{className:"space-y-2.5 text-[13.5px] leading-snug",children:f.jsxs("button",{type:"button",onClick:()=>R.getState().setConnectOpen(!0),className:"inline-flex h-9 items-center gap-2 rounded-lg bg-ink px-3.5 text-[13.5px] font-semibold text-paper hover:opacity-90",children:[f.jsx(Tp,{size:15})," Connect an agent"]})})}function EG({m:t}){var e;switch(t.from){case"person":return f.jsxs("li",{className:"ml-8 rounded-xl bg-sunken px-3 py-2.5",children:[f.jsx("p",{className:"whitespace-pre-wrap text-[13.5px] leading-snug",children:f.jsx(jG,{text:t.text,context:t.context??[]})}),f.jsx(ZS,{walkthrough:t.walkthrough,scene:t.scene,prefix:"On"})]});case"agent":return f.jsxs("li",{className:"mr-4",children:[f.jsx("div",{className:"space-y-2 text-[13.5px] leading-relaxed text-ink",children:t.text.split(/\n{2,}/).map((n,r)=>f.jsx("p",{className:"whitespace-pre-wrap",children:n},r))}),f.jsx(ZS,{walkthrough:t.walkthrough,scene:t.scene,prefix:"Show",link:!0})]});case"tool":return f.jsxs("li",{className:"flex items-center gap-2 text-[12.5px] text-ink-3",children:[t.status==="completed"?f.jsx(js,{size:13,className:"shrink-0 text-new"}):t.status==="failed"?f.jsx(Ld,{size:13,className:"shrink-0 text-removed"}):f.jsx(DD,{size:13,className:"shrink-0"}),f.jsx("span",{className:"truncate",title:t.title,children:t.title})]});case"permission":return f.jsxs("li",{className:"rounded-xl border border-changed/40 bg-changed-wash px-3 py-2.5",children:[f.jsxs("p",{className:"text-[13px] font-medium leading-snug",children:["The agent asks: ",t.title]}),t.chosen?f.jsx("p",{className:"mt-1.5 text-[12px] text-ink-3",children:t.chosen==="cancelled"?"Cancelled":`You chose: ${((e=t.options.find(n=>n.id===t.chosen))==null?void 0:e.name)??t.chosen}`}):f.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.options.map(n=>f.jsx("button",{type:"button",onClick:()=>void BF(t.id,n.id),className:`h-7 rounded-lg px-2.5 text-[12.5px] font-semibold ${n.kind.startsWith("allow")?"bg-ink text-paper hover:opacity-90":"border border-rule-strong bg-raised hover:bg-sunken"}`,children:n.name},n.id))})]});case"notice":return f.jsx("li",{className:`text-center text-[12px] ${t.tone==="error"?"text-removed":"text-ink-3"}`,children:t.text})}}function ZS({walkthrough:t,scene:e,prefix:n,link:r}){const s=R(l=>{var c;return(c=l.history)==null?void 0:c.present});if(!s||!e)return null;const i=t?s.walkthroughs.find(l=>l.id===t):s.walkthroughs.find(l=>l.scenes.some(c=>c.id===e)),o=i?i.scenes.findIndex(l=>l.id===e):-1;if(!i||o<0)return null;const a=`${n} scene ${o+1}: ${Ar(i.scenes[o].title)}`;return r?f.jsx("button",{type:"button",onClick:()=>{const l=R.getState();l.showStart(!1),l.viewId!==`${Hr}${i.id}`&&l.navigate(`${Hr}${i.id}`),setTimeout(()=>R.getState().jumpTo(e),60)},className:"mt-2 text-[12.5px] font-semibold text-poney hover:underline",children:a}):f.jsx("p",{className:"mt-1 text-[11.5px] text-ink-3",children:a})}function _G({busy:t}){const[e,n]=b.useState(null),r=async({text:s,context:i})=>{try{return await qp(s,i),n(null),!0}catch(o){return n(o instanceof Error?o.message:String(o)),!1}};return f.jsxs("div",{className:"border-t border-rule p-3",children:[f.jsx(kG,{placeholder:t?"Ask next; it waits its turn":"Ask about the code",onSend:r,actions:(s,i)=>f.jsxs(f.Fragment,{children:[t&&f.jsx("button",{type:"button","aria-label":"Stop",title:"Stop this request",onClick:()=>void FF(),className:"grid h-10 w-10 shrink-0 place-items-center rounded-full border border-rule-strong bg-raised text-ink hover:bg-sunken",children:f.jsx(Ij,{size:13,fill:"currentColor"})}),f.jsx("button",{type:"button","aria-label":"Send",disabled:i,onClick:s,className:"grid h-10 w-10 shrink-0 place-items-center rounded-full bg-ink text-paper disabled:opacity-35",children:f.jsx(a_,{size:17,strokeWidth:2.4})})]})}),f.jsx(bG,{}),e&&f.jsx("p",{className:"mt-1.5 text-[12px] text-removed",children:e})]})}function jG({text:t,context:e}){if(!e.length)return f.jsx(f.Fragment,{children:t});const n=e.map(s=>`“${s.title}”`),r=t.split(new RegExp(`(${n.map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})`));return f.jsx(f.Fragment,{children:r.map((s,i)=>{const o=e[n.indexOf(s)];return o?f.jsxs("span",{title:o.quote??o.ref,className:"mx-px inline-flex items-baseline gap-1 rounded-md bg-raised px-1.5 text-[12.5px]",children:[f.jsx("span",{className:"text-ink-3",children:o.kind==="text"?"“":o.kind}),f.jsxs("span",{className:"font-medium",children:[o.title,o.kind==="text"?"”":""]})]},i):f.jsx("span",{children:s},i)})})}function q0({start:t,onPickFolder:e,onOpenFile:n}){const[r,s]=b.useState(null),[i,o]=b.useState(null),a=c=>VF(c).then(d=>{s(d),o(null)}).catch(d=>o(d instanceof Error?d.message:String(d)));if(b.useEffect(()=>{a(t)},[]),i)return f.jsx("p",{className:"text-[12.5px] text-removed",children:i});if(!r)return f.jsx("p",{className:"text-[12.5px] text-ink-3",children:"Reading folders…"});const l=n?r.files:[];return f.jsxs("div",{className:"overflow-hidden rounded-xl border border-rule",children:[f.jsxs("div",{className:"flex items-center gap-2 border-b border-rule bg-sunken/50 px-2 py-1.5",children:[f.jsx("button",{type:"button","aria-label":"Up one folder",disabled:!r.parent,onClick:()=>void a(r.parent),className:"grid h-7 w-7 place-items-center rounded-md text-ink-2 hover:bg-raised disabled:opacity-30",children:f.jsx(a_,{size:14})}),f.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-ink-2",title:r.path,children:r.path}),e&&f.jsx("button",{type:"button",onClick:()=>e(r.path),className:"h-7 shrink-0 rounded-md bg-ink px-2.5 text-[12.5px] font-semibold text-paper hover:opacity-90",children:"Use this folder"})]}),f.jsxs("ul",{className:"scrollbar-quiet max-h-[260px] overflow-y-auto py-1",children:[r.folders.length===0&&l.length===0&&f.jsx("li",{className:"px-3 py-2 text-[12.5px] text-ink-3",children:n?"No folders or Poney files here.":"No folders inside."}),l.map(c=>f.jsx("li",{children:f.jsxs("button",{type:"button",onClick:()=>n(c.path),className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-[13px] font-medium hover:bg-sunken",children:[f.jsx(Qy,{size:14,className:"shrink-0 text-poney"}),f.jsx("span",{className:"truncate",children:c.name})]})},c.path)),r.folders.map(c=>f.jsx("li",{children:f.jsxs("button",{type:"button",onDoubleClick:()=>e==null?void 0:e(c.path),onClick:()=>void a(c.path),className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-[13px] hover:bg-sunken",children:[c.git?f.jsx(dD,{size:14,className:"shrink-0 text-poney"}):f.jsx(V_,{size:14,className:"shrink-0 text-ink-3"}),f.jsx("span",{className:"truncate",children:c.name}),c.git&&f.jsx("span",{className:"ml-auto shrink-0 text-[11.5px] text-ink-3",children:"Git repository"})]})},c.path))]})]})}const $G=(t,e)=>"providerId"in t?"providerId"in e&&t.providerId===e.providerId:"custom"in e&&t.custom.name===e.custom.name&&t.custom.command===e.custom.command,Lg=t=>t.kind==="provider"?t.id:`custom:${t.name}`,Fg=t=>t.kind==="provider"?{providerId:t.id}:{custom:{name:t.name,command:t.command}};function MG(){const t=R(I=>I.connectOpen),e=R(I=>I.setConnectOpen),n=iT(),s=R(I=>I.startOpen||!I.history)?null:n,i=b.useRef(!1),[o,a]=b.useState([]),[l,c]=b.useState(()=>Ix()),[d,u]=b.useState(null),[h,m]=b.useState(null),[g,p]=b.useState(null),[x,y]=b.useState({}),[v,k]=b.useState(null),[w,C]=b.useState(null),[E,_]=b.useState(!1),S=(I,L=!1,D=w)=>(y(B=>({...B,[Lg(I)]:"checking"})),zF(Fg(I),L).catch(B=>({state:"error",detail:B instanceof Error?B.message:String(B)})).then(B=>{if(y(H=>({...H,[Lg(I)]:B})),B.state==="ready"){const H=!!D&&$G(Fg(I),D);u(T=>!T||H&&!i.current?I:T)}return B}));b.useEffect(()=>{if(!t)return;p(null),i.current=!1;const I=(s==null?void 0:s.root)??kh()??null;k(I),_(!s&&!I),e0().then(L=>{a(L.providers),C(L.defaultAgent);for(const D of L.providers)D.available&&S({kind:"provider",id:D.id},!1,L.defaultAgent);for(const D of Ix())S({kind:"custom",...D},!1,L.defaultAgent)}).catch(L=>p(L instanceof Error?L.message:String(L)))},[t]);const j=async()=>{if(!(!d||!s&&!v)){m("Starting the agent…"),p(null);try{await Ax(Fg(d),s?void 0:v??void 0),v&&!s&&sT(v),e(!1),R.getState().setAgentPanelOpen(!0)}catch(I){p(I instanceof Error?I.message:String(I))}finally{m(null)}}},$=(!!s||!!v)&&!!d&&HS(x[Lg(d)]);return f.jsxs(Go,{open:t,onOpenChange:e,title:"Choose your agent",description:"It works in each project you open.",width:640,children:[f.jsxs("div",{className:"scrollbar-quiet min-h-0 flex-1 space-y-6 overflow-y-auto px-5 py-5",children:[f.jsxs("section",{"aria-labelledby":"code-folder",children:[f.jsx("h3",{id:"code-folder",className:"text-[13px] font-semibold",children:"Code"}),f.jsxs("div",{className:"mt-2 flex items-center gap-3 rounded-xl bg-sunken px-3.5 py-2.5 text-[13px]",children:[f.jsx(V_,{size:15,className:"shrink-0 text-ink-3"}),f.jsx("span",{className:`min-w-0 flex-1 truncate ${v?"":"text-ink-3"}`,title:v??void 0,children:s?f.jsx("code",{className:"font-mono text-[12px]",children:s.root}):v?f.jsx("code",{className:"font-mono text-[12px]",children:v}):"Choose a folder"}),!s&&!E&&f.jsx("button",{type:"button",onClick:()=>_(!0),className:"shrink-0 font-semibold text-poney hover:underline",children:"Change"})]}),!s&&E&&f.jsx("div",{className:"mt-2",children:f.jsx(q0,{start:v??kh(),onPickFolder:I=>{k(I),_(!1)}})})]}),f.jsxs("section",{"aria-labelledby":"ag",children:[f.jsx("h3",{id:"ag",className:"text-[13px] font-semibold",children:"Agent"}),f.jsxs("ul",{className:"mt-2 divide-y divide-rule rounded-xl border border-rule",children:[o.map(I=>{const L={kind:"provider",id:I.id},D=(d==null?void 0:d.kind)==="provider"&&d.id===I.id,B=x[I.id],H=I.available&&HS(B);return f.jsx("li",{children:f.jsxs("label",{className:`flex items-start gap-3 px-3.5 py-3 ${H?"cursor-pointer":"cursor-default"}`,children:[f.jsx("input",{type:"radio",name:"agent",className:"mt-1 accent-[var(--accent)]",checked:D,disabled:!H,onChange:()=>(i.current=!0,u(L))}),f.jsxs("span",{className:`min-w-0 flex-1 ${I.available?"":"opacity-70"}`,children:[f.jsx("span",{className:"block text-[14px] font-medium",children:I.name}),I.available?f.jsx(qS,{status:B,signIn:I.signIn,onRetry:()=>void S(L,!0)}):f.jsx("span",{className:"block text-[12.5px] text-ink-3",children:I.install})]})]})},I.id)}),l.map(I=>{const L=(d==null?void 0:d.kind)==="custom"&&d.name===I.name;return f.jsxs("li",{className:"flex items-start gap-3 px-3.5 py-3",children:[f.jsx("input",{type:"radio",name:"agent","aria-label":I.name,className:"mt-1 accent-[var(--accent)]",checked:L,onChange:()=>(i.current=!0,u({kind:"custom",...I}))}),f.jsxs("span",{className:"min-w-0 flex-1",children:[f.jsx("span",{className:"block text-[14px] font-medium",children:I.name}),f.jsx("code",{className:"block truncate font-mono text-[11.5px] text-ink-3",children:I.command}),f.jsx(qS,{status:x[`custom:${I.name}`],signIn:"Sign in as the agent's documentation says.",onRetry:()=>void S({kind:"custom",...I},!0)})]}),f.jsx("button",{type:"button","aria-label":`Remove ${I.name}`,onClick:()=>{const D=l.filter(B=>B.name!==I.name);c(D),Zb(D),L&&u(null)},className:"rounded p-1 text-ink-4 hover:bg-sunken hover:text-ink",children:f.jsx(OD,{size:14})})]},I.name)})]}),f.jsx(TG,{onAdd:I=>{const L=[...l.filter(D=>D.name!==I.name),I];c(L),Zb(L),i.current=!0,u({kind:"custom",...I}),S({kind:"custom",...I},!0)}})]})]}),f.jsxs("div",{className:"flex items-center gap-3 border-t border-rule px-5 py-3.5",children:[f.jsx("p",{role:g?"alert":void 0,className:`min-w-0 flex-1 text-[12.5px] ${g?"text-removed":"text-ink-3"}`,children:g??h??(s||v?"":"Choose the folder with the code.")}),f.jsxs("button",{type:"button",disabled:!$||!!h,onClick:()=>void j(),className:"inline-flex h-9 items-center gap-2 rounded-lg bg-ink px-4 text-[13.5px] font-semibold text-paper disabled:opacity-35",children:[h&&f.jsx(Ro,{size:14,className:"animate-spin"})," Connect"]})]})]})}function TG({onAdd:t}){const[e,n]=b.useState(!1),[r,s]=b.useState(""),[i,o]=b.useState("");return e?f.jsxs("form",{className:"mt-3 space-y-2 rounded-xl border border-rule p-3",onSubmit:a=>{a.preventDefault(),t({name:r.trim(),command:i.trim()}),n(!1),s(""),o("")},children:[f.jsxs("label",{className:"block text-[12.5px] font-medium",children:["Name",f.jsx("input",{value:r,onChange:a=>s(a.target.value),placeholder:"My agent",className:"mt-1 h-8 w-full rounded-lg border border-rule bg-paper px-2.5 text-[13px] outline-none focus:border-rule-strong"})]}),f.jsxs("label",{className:"block text-[12.5px] font-medium",children:["Command",f.jsx("input",{value:i,onChange:a=>o(a.target.value),placeholder:"my-agent --acp",className:"mt-1 h-8 w-full rounded-lg border border-rule bg-paper px-2.5 font-mono text-[12.5px] outline-none focus:border-rule-strong"}),f.jsx("span",{className:"mt-1 block font-normal text-ink-3",children:"The command that starts the agent in ACP mode."})]}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx("button",{type:"submit",disabled:!r.trim()||!i.trim(),className:"h-8 rounded-lg bg-ink px-3 text-[12.5px] font-semibold text-paper disabled:opacity-35",children:"Add agent"}),f.jsx("button",{type:"button",onClick:()=>n(!1),className:"h-8 rounded-lg px-3 text-[12.5px] font-semibold text-ink-3 hover:bg-sunken",children:"Cancel"})]})]}):f.jsxs("button",{type:"button",onClick:()=>n(!0),className:"mt-2 inline-flex items-center gap-1.5 text-[12.5px] font-semibold text-ink-3 hover:text-ink",children:[f.jsx(S1,{size:13})," Add another ACP agent"]})}const HS=t=>!!t&&t!=="checking"&&(t.state==="ready"||t.state==="unsure");function qS({status:t,signIn:e,onRetry:n}){if(!t||t==="checking")return f.jsxs("span",{className:"mt-0.5 flex items-center gap-1.5 text-[12.5px] text-ink-3",children:[f.jsx(Ro,{size:12,className:"animate-spin"})," Checking the sign-in…"]});const r=t.state==="ready"?"text-new":t.state==="unsure"?"text-changed":"text-removed",s=t.state==="ready"?"Ready":t.state==="unsure"?"Maybe not signed in":t.state==="sign-in"?"Not signed in":"Cannot start";return f.jsxs("span",{className:"mt-0.5 block text-[12.5px] leading-snug text-ink-3",children:[f.jsxs("span",{className:`font-semibold ${r}`,children:[s,"."]})," ",t.detail,(t.state==="sign-in"||t.state==="unsure")&&f.jsx("span",{className:"block",children:e}),t.state!=="ready"&&f.jsxs("button",{type:"button",onClick:i=>{i.preventDefault(),n()},className:"mt-1 inline-flex items-center gap-1 font-semibold text-ink-2 hover:text-ink",children:[f.jsx(jD,{size:11})," Check again"]})]})}function OG(){const t=R(s=>s.fileOpen),e=R(s=>s.setFileOpen),[n,r]=b.useState(null);return f.jsx(Go,{open:t,onOpenChange:e,title:"Open a Poney file",description:"A .poney file on this computer. Changes are saved to it, and changes made to it elsewhere show here.",width:600,children:f.jsxs("div",{className:"space-y-3 px-5 py-5",children:[f.jsx(q0,{start:kh(),onOpenFile:async s=>{try{await XM(s),r(null),e(!1)}catch(i){r(i instanceof Error?i.message:String(i))}}}),n&&f.jsx("p",{role:"alert",className:"whitespace-pre-wrap text-[12.5px] text-removed",children:n})]})})}function AG(){const t=R(c=>c.projectOpen),e=R(c=>c.setProjectOpen),[n,r]=b.useState("local"),[s,i]=b.useState(null),[o,a]=b.useState(null),l=async c=>{a(null);try{await WF(c),sT(c),e(!1)}catch(d){a(d instanceof Error?d.message:String(d))}};return f.jsx(Go,{open:t,onOpenChange:e,title:"Open a project",description:"A folder on this computer, usually a Git repository. Its Poney document is saved in docs/poney/, and agents work there.",width:620,children:f.jsxs("div",{className:"space-y-3 px-5 py-5",children:[f.jsx("div",{role:"tablist",className:"inline-flex rounded-lg border border-rule bg-sunken/60 p-0.5 text-[12.5px]",children:["local","git"].map(c=>f.jsx("button",{role:"tab",type:"button","aria-selected":n===c,onClick:()=>r(c),className:`h-7 rounded-md px-3 font-medium ${n===c?"bg-raised text-ink shadow-[0_1px_2px_#0000001a]":"text-ink-3 hover:text-ink"}`,children:c==="local"?"On this computer":"From a Git address"},c))}),n==="local"?f.jsx(q0,{start:kh(),onPickFolder:c=>void l(c)}):f.jsx(RG,{onCloned:c=>void l(c),setBusy:i,setError:a}),(o||s)&&f.jsx("p",{role:o?"alert":"status",className:`text-[12.5px] ${o?"text-removed":"text-ink-3"}`,children:o??s})]})})}function RG({onCloned:t,setBusy:e,setError:n}){const[r,s]=b.useState("");return f.jsxs("form",{className:"flex gap-2",onSubmit:async i=>{i.preventDefault(),e("Cloning the repository…"),n(null);try{t((await UF(r)).path)}catch(o){n(o instanceof Error?o.message:String(o))}finally{e(null)}},children:[f.jsx("input",{value:r,onChange:i=>s(i.target.value),"aria-label":"Git address",placeholder:"https://github.com/owner/repository",className:"h-9 min-w-0 flex-1 rounded-lg border border-rule bg-paper px-3 font-mono text-[12.5px] outline-none placeholder:text-ink-4 focus:border-rule-strong"}),f.jsx("button",{type:"submit",disabled:!r.trim(),className:"h-9 shrink-0 rounded-lg border border-rule-strong bg-raised px-3 text-[13px] font-semibold hover:bg-sunken disabled:opacity-35",children:"Clone"})]})}function IG({children:t}){const e=Be(),n=LB(),r=R(l=>l.selection),s=R(l=>l.hover),i=R(l=>l.viewUi),o=R(l=>l.updateViewUi),a=b.useMemo(()=>({idx:e,bind:n,selection:r,hover:s,viewState:l=>i[l],setViewState:o}),[e,n,r,s,i,o]);return f.jsx(zL,{value:a,children:t})}function PG(){const t=R(u=>u.importCodeOpen),e=R(u=>u.setImportCodeOpen),[n,r]=b.useState([]),[s,i]=b.useState(null),[o,a]=b.useState(null),[l,c]=b.useState(null);b.useEffect(()=>{t&&(c(null),eT().then(u=>{r(u.importers),i(u.root)},u=>c(u instanceof Error?u.message:String(u))))},[t]);const d=async u=>{a(u),c(null);try{const{summary:h}=await ZF(u);e(!1),R.getState().notify(h.split(`
943
+ `)[0])}catch(h){c(h instanceof Error?h.message:String(h))}finally{a(null)}};return f.jsxs(Go,{open:t,onOpenChange:e,title:"Import from the code",description:s?`Adds to this document what it reads in ${s.split("/").pop()}. What the document has stays.`:"Connect an agent or open a project first.",children:[f.jsx("ul",{className:"divide-y divide-rule px-5 py-3",children:n.map(u=>f.jsxs("li",{className:"flex items-center gap-4 py-3",children:[f.jsxs("span",{className:"min-w-0 flex-1",children:[f.jsx("span",{className:"block text-[14px] font-semibold",children:u.name}),f.jsx("span",{className:"mt-0.5 block text-[12.5px] text-ink-3",children:u.files.length?`Reads ${u.files.join(", ")}`:"Nothing to read in this folder."})]}),f.jsxs("button",{type:"button",disabled:!u.files.length||!!o,onClick:()=>void d(u.id),className:"inline-flex h-8 items-center gap-1.5 rounded-lg border border-rule-strong px-3 text-[13px] font-semibold hover:bg-sunken disabled:opacity-40",children:[o===u.id&&f.jsx(Ro,{size:13,className:"animate-spin"})," Import"]})]},u.id))}),l&&f.jsx("p",{className:"px-5 pb-4 text-[12.5px] text-removed",children:l})]})}function DG(){const t=R(g=>g.renaming),[e,n]=b.useState(""),r=b.useRef(null),s=b.useRef(null),[i,o]=b.useState(0);if(b.useEffect(()=>{if(!t)return;n(t.value);const g=t.text;g&&(g.style.visibility="hidden"),requestAnimationFrame(()=>{var x;return(x=r.current)==null?void 0:x.select()});const p=()=>{var x;return Cu(((x=r.current)==null?void 0:x.value)??null)};return window.addEventListener("resize",p),window.addEventListener("wheel",p,{passive:!0}),()=>{g&&(g.style.visibility=""),window.removeEventListener("resize",p),window.removeEventListener("wheel",p)}},[t]),b.useLayoutEffect(()=>{t&&s.current&&o(Math.min(Math.max(s.current.offsetWidth+6,t.rect.w+6,40),Math.max(t.room,t.rect.w+6)))},[e,t]),!t)return null;const{rect:a,font:l,align:c}=t,d=Math.round(l.size*1.35),u=c==="center"?a.x+a.w/2-i/2:a.x-2,h=a.y+a.h/2-d/2,m={fontSize:l.size,fontWeight:Number(l.weight)||600,lineHeight:`${d}px`};return f.jsxs(f.Fragment,{children:[f.jsx("span",{ref:s,"aria-hidden":!0,className:"pointer-events-none invisible fixed left-0 top-0 whitespace-pre font-sans",style:m,children:e||" "}),f.jsx("input",{ref:r,value:e,"aria-label":`New name for ${t.value}`,title:"Enter to save, Esc to cancel. The name changes in every diagram.",onChange:g=>n(g.target.value),onKeyDown:g=>{g.key==="Enter"&&Cu(e),g.key==="Escape"&&Cu(null)},onBlur:()=>Cu(e),className:`fixed z-50 rounded-sm border-0 border-b-2 border-poney p-0 px-[2px] font-sans text-ink caret-[var(--accent)] ${c==="center"?"text-center":""}`,style:{...m,left:u,top:h,width:i,height:d+2,outline:"none",boxShadow:"none",background:"var(--story-node)"}})]})}function zG(){const t=R(d=>d.contextMenu),e=()=>R.getState().openContextMenu(null),n=b.useRef(null),[r,s]=b.useState({x:0,y:0}),[i,o]=b.useState(0),a=t?LG(t):[];if(b.useLayoutEffect(()=>{if(!t||!n.current)return;const d=n.current.getBoundingClientRect();s({x:Math.min(t.x,window.innerWidth-d.width-8),y:Math.min(t.y,window.innerHeight-d.height-8)}),o(Math.max(0,a.findIndex(u=>u.label!=="-"&&!u.disabled))),n.current.focus()},[t]),b.useEffect(()=>{if(!t)return;const d=u=>{var h;return!((h=n.current)!=null&&h.contains(u.target))&&e()};return window.addEventListener("pointerdown",d,!0),window.addEventListener("resize",e),window.addEventListener("blur",e),()=>{window.removeEventListener("pointerdown",d,!0),window.removeEventListener("resize",e),window.removeEventListener("blur",e)}},[t]),!t||!a.length)return null;const l=d=>{const u=a[d];!u||u.label==="-"||u.disabled||(e(),u.run())},c=d=>{let u=i;do u=(u+d+a.length)%a.length;while(a[u].label==="-"||a[u].disabled);o(u)};return f.jsx("div",{ref:n,role:"menu",tabIndex:-1,"aria-label":"Actions",className:"fade-in fixed z-50 min-w-[230px] rounded-xl border border-rule bg-raised p-1 shadow-float outline-none",style:{left:r.x,top:r.y},onContextMenu:d=>d.preventDefault(),onKeyDown:d=>{if(d.key==="Escape")e();else if(d.key==="ArrowDown")c(1);else if(d.key==="ArrowUp")c(-1);else if(d.key==="Enter")l(i);else return;d.preventDefault()},children:a.map((d,u)=>d.label==="-"?f.jsx("div",{className:"my-1 h-px bg-rule",role:"separator"},u):f.jsxs("button",{type:"button",role:"menuitem","aria-disabled":d.disabled||void 0,onMouseEnter:()=>!d.disabled&&o(u),onClick:()=>l(u),className:`flex w-full items-center gap-2.5 rounded-lg px-2.5 py-1.5 text-left text-[13px] ${d.disabled?"cursor-default text-ink-4":u===i?"bg-sunken":""}`,children:[f.jsx("span",{className:`shrink-0 ${d.disabled?"text-ink-4":"text-ink-3"}`,children:d.icon}),f.jsx("span",{className:"flex-1",children:d.label}),d.hint&&f.jsx("kbd",{className:"font-sans text-[11.5px] text-ink-4",children:d.hint})]},u))})}const xv={label:"-",icon:null,run:()=>{}};function Wu(t,e){return t?[...e,xv]:[...e.map(n=>({...n,disabled:!0,hint:"No agent"})),{label:"Connect an agent…",icon:f.jsx(Tp,{size:14}),run:()=>R.getState().setConnectOpen(!0)},xv]}function LG(t){const e=R.getState().live.state==="on",n=Wd(R.getState()),r=(i,o)=>{o&&(R.getState().setAgentPanelOpen(!0),qp(i,[o]))};if(t.on==="element"){const i=cT(t.ref),o=(i==null?void 0:i.kind)??"element";return[...e?Wu(n,[{label:"Ask the agent about this",icon:f.jsx(co,{size:14}),run:()=>uo(i)},{label:"Explain this",icon:f.jsx(Um,{size:14}),run:()=>r(`Explain this ${o}: what it does, why it is here, and where its code is.`,i)},{label:"Show its code in a scene",icon:f.jsx(Mp,{size:14}),run:()=>r(`Add a scene to the open document that shows the code of this ${o}, with short excerpts and notes, and open it.`,i)}]):[],...GM(t.ref)?[{label:"Rename",icon:f.jsx(CD,{size:14}),hint:"F2",run:()=>{var c;const l=((c=document.elementFromPoint(t.x,t.y))==null?void 0:c.closest("[data-ref]"))??document.querySelector(`[data-ref="${CSS.escape(fe(t.ref))}"]`);l&&X1(t.ref,l)}}]:[],{label:"Explore in the whole system",icon:f.jsx(v1,{size:14}),run:()=>Ud(t.ref)},{label:"Copy reference",icon:f.jsx(ca,{size:14}),hint:fe(t.ref),run:()=>{var l;return void((l=navigator.clipboard)==null?void 0:l.writeText(fe(t.ref)))}}]}if(t.on==="code"){const i=uT(t.path,t.line,t.text),o=`${t.path}:${t.line}`;return[...e?Wu(n,[{label:t.note?"Ask the agent about this note":"Ask the agent about this line",icon:f.jsx(co,{size:14}),run:()=>uo(t.note?{...i,quote:`${i.quote}
944
+ Note: ${t.note}`}:i)},{label:"Explain this line",icon:f.jsx(Um,{size:14}),run:()=>r("Explain this line of code: what it does and why it is here.",i)}]):[],...t.note?[{label:"Copy note",icon:f.jsx(ca,{size:14}),run:()=>{var a;return void((a=navigator.clipboard)==null?void 0:a.writeText(t.note))}}]:[],{label:"Copy line",icon:f.jsx(ca,{size:14}),run:()=>{var a;return void((a=navigator.clipboard)==null?void 0:a.writeText(t.text.trim()))}},{label:"Copy location",icon:f.jsx(ca,{size:14}),hint:o.split("/").pop(),run:()=>{var a;return void((a=navigator.clipboard)==null?void 0:a.writeText(o))}}]}if(t.on==="text")return[...e?Wu(n,[{label:"Ask the agent about this text",icon:f.jsx(co,{size:14}),run:()=>uo(dT(t.text))}]):[],{label:"Copy",icon:f.jsx(ca,{size:14}),run:()=>{var i;return void((i=navigator.clipboard)==null?void 0:i.writeText(t.text))}}];const s=jB(t.viewId);return e?Wu(n,[{label:"Ask the agent about this diagram",icon:f.jsx(co,{size:14}),run:()=>uo(s)},{label:"Explain this diagram",icon:f.jsx(Um,{size:14}),run:()=>r("Explain what this diagram shows, in a few sentences, and what to look at first.",s)}]).filter(i=>i!==xv):[]}function FG(){const t=R(n=>n.pointing),e=R(Wd);return b.useEffect(()=>{!e&&t&&R.getState().setPointing(!1)},[e,t]),b.useEffect(()=>{if(document.documentElement.classList.toggle("pointing",t),!t)return;const n=r=>r.key==="Escape"&&R.getState().setPointing(!1);return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t]),t?f.jsxs("div",{role:"status",className:"fade-in fixed left-1/2 top-3 z-50 flex -translate-x-1/2 items-center gap-2 rounded-full bg-ink px-4 py-2 text-[13px] font-medium text-paper shadow-float",children:[f.jsx(O_,{size:14})," Click a part, a line, a message or a state to add it to your message.",f.jsx("button",{type:"button",onClick:()=>R.getState().setPointing(!1),className:"ml-1 rounded-full px-2 py-0.5 text-[12px] text-paper/70 hover:bg-paper/15 hover:text-paper",children:"Esc"})]}):null}function BG(){const t=R(Wd),[e,n]=b.useState(null);return b.useEffect(()=>{if(!t)return;const r=()=>{var d;const i=window.getSelection(),o=i==null?void 0:i.toString().trim(),a=(i==null?void 0:i.anchorNode)instanceof Element?i.anchorNode:(d=i==null?void 0:i.anchorNode)==null?void 0:d.parentElement;if(!i||!o||i.rangeCount===0||!(a!=null&&a.closest("main"))||a.closest('input, textarea, [contenteditable="true"], svg'))return n(null);const l=i.getRangeAt(0),c=l.getClientRects()[0]??l.getBoundingClientRect();if(!c.width)return n(null);n({x:c.left+c.width/2,y:c.top,text:o})},s=()=>n(null);return document.addEventListener("selectionchange",r),window.addEventListener("scroll",s,!0),()=>{document.removeEventListener("selectionchange",r),window.removeEventListener("scroll",s,!0)}},[t]),e?f.jsxs("button",{type:"button",onMouseDown:r=>r.preventDefault(),onClick:()=>{var r;uo(dT(e.text)),(r=window.getSelection())==null||r.removeAllRanges(),n(null)},className:"fade-in fixed z-50 inline-flex -translate-x-1/2 -translate-y-full items-center gap-1.5 rounded-full bg-ink px-3 py-1.5 text-[12.5px] font-semibold text-paper shadow-float hover:opacity-95",style:{left:e.x,top:e.y-8},children:[f.jsx(co,{size:13})," Ask the agent"]}):null}const VG=new URLSearchParams(window.location.search).get("doc"),Bg=window.location.hash;function WG(){const t=new URLSearchParams(window.location.search).get("live"),e=t??window.location.origin;fetch(`${e}/api/live`).then(n=>n.ok?n.json():Promise.reject(new Error("no hub"))).then(()=>LA(e)).catch(()=>{t&&R.getState().setLive({state:"lost",url:e})})}function LA(t,e=0){const n=R.getState();e===0&&n.setLive({state:"connecting",url:t});const r=new EventSource(`${t}/api/live/events`);r.onopen=()=>{e=0,R.getState().setLive({...R.getState().live,state:"on",url:t}),UG(t)},r.onerror=()=>{R.getState().setLive({...R.getState().live,state:"lost"}),r.readyState===EventSource.CLOSED&&(r.close(),window.setTimeout(()=>LA(t,e+1),Math.min(1e4,500*2**e)))};let s=!0;r.addEventListener("document",o=>{var p,x;const{revision:a,document:l,source:c}=JSON.parse(o.data),d=$l(l,{extensions:Vd()}),u=R.getState();if(!d.ok||!d.document)return u.notify("The agent sent a document with errors. It was not opened.");const h=s;if(s=!1,h&&u.history&&!u.startOpen&&u.projectId!==d.document.project.id)return u.keepProject(d.document,"live"),u.setLive({state:"on",url:t,revision:a}),u.notify(`“${d.document.project.name}” from Poney on this computer is in the project menu.`);const m=VG===d.document.project.id;if(h&&u.startOpen&&!m)return u.keepProject(d.document,"live"),u.setLive({state:"on",url:t,revision:a});const g=(p=u.projects.find(y=>y.id===d.document.project.id))==null?void 0:p.doc;if(Ug(d.document)&&g&&!Ug(g)){u.reviseDocument(g,"live"),u.setLive({state:"on",url:t,revision:a}),fetch(`${t}/api/live/open`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({document:g})}).catch(()=>{});return}u.reviseDocument(d.document,"live"),h&&m&&Bg.startsWith("#/")&&Bg!=="#/start"&&(window.history.replaceState(window.history.state,"",Bg),YM()),u.setLive({state:"on",url:t,revision:a}),u.notify(Ug(d.document)?`Opened the project “${d.document.project.name}”. Ask the agent for a tour to fill it.`:c==="file"?`Opened “${d.document.project.name}” from its file.`:`The agent opened “${Ar(((x=d.document.walkthroughs[0])==null?void 0:x.title)??d.document.project.name)}” (revision ${a}).`),vv="",Wg(t)}),r.addEventListener("thread",o=>R.getState().setConversation(JSON.parse(o.data).messages)),r.addEventListener("message",o=>R.getState().putMessage(JSON.parse(o.data))),r.addEventListener("agent",o=>R.getState().setAgent(JSON.parse(o.data))),r.addEventListener("project",o=>{const a=JSON.parse(o.data);R.getState().setProject(a.root?{root:a.root,name:a.name??a.root}:null)}),r.addEventListener("overlays",o=>R.getState().setOverlays(JSON.parse(o.data))),r.addEventListener("file",o=>R.getState().setLiveFile(JSON.parse(o.data).path));let i=0;R.subscribe(()=>{clearTimeout(i),i=window.setTimeout(()=>Wg(t),400)}),window.addEventListener("poney:local",()=>{clearTimeout(i),i=window.setTimeout(()=>Wg(t),400)})}let vv="";function Vg(t){try{const e=localStorage.getItem(t);return e?JSON.parse(e):void 0}catch{return}}function Wg(t){const e=R.getState();if(!e.history)return;const n=e.history.present,r=zp(e.viewId),s=c=>`poney:${c}:${n.project.id}:${r??""}`,i=gt(n),o=e.selection&&i.exists(e.selection)?i.describe(e.selection):void 0,a={projectId:n.project.id,viewId:e.viewId,walkthrough:r,scene:r?e.activeScene??void 0:void 0,selection:e.selection?{ref:fe(e.selection),title:(o==null?void 0:o.title)??"",kind:(o==null?void 0:o.kind)??e.selection.kind}:void 0,answers:r?Vg(s("answers")):void 0,notes:r?Vg(s("notes")):void 0,read:r?Vg(s("read")):void 0,document:e.history.past.length||e.history.future.length?n:void 0},l=JSON.stringify(a);l!==vv&&(vv=l,fetch(`${t}/api/live/state`,{method:"POST",headers:{"content-type":"application/json"},body:l}).catch(()=>{}))}const Ug=t=>t.views.length===0&&t.walkthroughs.length===0;async function UG(t){var l,c,d;const e=R.getState(),n=(l=e.history)==null?void 0:l.present,r=(c=e.projects.find(u=>u.id===e.projectId))==null?void 0:c.origin;if(!n||r==="example"||e.startOpen||(await fetch(`${t}/api/live`).then(u=>u.json()).catch(()=>({}))).revision!==0)return;const i=e.liveFile??((d=Cl().find(u=>u.id===n.project.id))==null?void 0:d.path),o=(u,h)=>fetch(`${t}${u}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(h)});(i?await o("/api/files/open",{path:i,document:n}).then(u=>u.ok).catch(()=>!1):!1)||await o("/api/live/open",{document:n}).catch(()=>{})}w$(A6);w$(y9);async function ZG(){new URLSearchParams(window.location.search).get("example")==="kestrel"?await PA():fG();const t=R.getState();!t.history&&window.location.hash!==Lc&&window.history.replaceState(null,"",`${window.location.pathname}${window.location.search}${Lc}`),window.location.hash===Lc?t.showStart(!0):t.history&&(t.viewId.startsWith("walk:")&&window.innerWidth<1700&&t.toggleSidebar(!1),YM()),hG(),WG(),$B()}function HG(){const t=R(e=>!e.history||e.startOpen);return f.jsxs(f.Fragment,{children:[t?f.jsx(gG,{}):f.jsx(IG,{children:f.jsx(lG,{})}),f.jsx(CG,{}),f.jsx(MG,{}),f.jsx(OG,{}),f.jsx(AG,{}),f.jsx(PG,{}),f.jsx(DG,{}),f.jsx(zG,{}),f.jsx(FG,{}),f.jsx(BG,{})]})}window.__poneyStarted?window.location.reload():(window.__poneyStarted=!0,ZG().finally(()=>aE(document.getElementById("root")).render(f.jsx(b.StrictMode,{children:f.jsx(HG,{})}))));export{WE as P,p1 as _,KG as c,KS as g};