@well-played.gg/react-sdk 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react"),di=require("@well-played.gg/typescript-sdk"),Xk=require("react-dom");function Zk(n,e){for(var t=0;t<e.length;t++){const r=e[t];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in n)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(n,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var Ql=function(n,e){return Ql=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])},Ql(n,e)};function zp(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ql(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var Oe=function(){return Oe=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++){t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},Oe.apply(this,arguments)};function Wp(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t}function ni(n,e,t){if(t||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return n.concat(s||Array.prototype.slice.call(e))}var wl="Invariant Violation",Yd=Object.setPrototypeOf,e1=Yd===void 0?function(n,e){return n.__proto__=e,n}:Yd,t1=function(n){zp(e,n);function e(t){t===void 0&&(t=wl);var r=n.call(this,typeof t=="number"?wl+": "+t+" (see https://github.com/apollographql/invariant-packages)":t)||this;return r.framesToPop=1,r.name=wl,e1(r,e.prototype),r}return e}(Error);function hr(n,e){if(!n)throw new t1(e)}var Vp=["debug","log","warn","error","silent"],n1=Vp.indexOf("log");function ro(n){return function(){if(Vp.indexOf(n)>=n1){var e=console[n]||console.log;return e.apply(console,arguments)}}}(function(n){n.debug=ro("debug"),n.log=ro("log"),n.warn=ro("warn"),n.error=ro("error")})(hr||(hr={}));var Hp="3.13.5";function En(n){try{return n()}catch{}}const Xl=En(function(){return globalThis})||En(function(){return window})||En(function(){return self})||En(function(){return global})||En(function(){return En.constructor("return this")()});var Qd=new Map;function r1(n){var e=Qd.get(n)||1;return Qd.set(n,e+1),"".concat(n,":").concat(e,":").concat(Math.random().toString(36).slice(2))}function i1(n,e){var t=r1("stringifyForDisplay");return JSON.stringify(n,function(r,i){return i===void 0?t:i},e).split(JSON.stringify(t)).join("<undefined>")}function io(n){return function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(typeof e=="number"){var i=e;e=Kp(i),e||(e=jp(i,t),t=[])}n.apply(void 0,[e].concat(t))}}var an=Object.assign(function(e,t){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];e||hr(e,Kp(t,r)||jp(t,r))},{debug:io(hr.debug),log:io(hr.log),warn:io(hr.warn),error:io(hr.error)}),Xd=Symbol.for("ApolloErrorMessageHandler_"+Hp);function Up(n){if(typeof n=="string")return n;try{return i1(n,2).slice(0,1e3)}catch{return"<non-serializable>"}}function Kp(n,e){if(e===void 0&&(e=[]),!!n)return Xl[Xd]&&Xl[Xd](n,e.map(Up))}function jp(n,e){if(e===void 0&&(e=[]),!!n)return"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({version:Hp,message:n,args:e.map(Up)})))}var s1=En(function(){return navigator.product})=="ReactNative",o1=typeof Symbol=="function"&&typeof Symbol.for=="function",qp=typeof En(function(){return window.document.createElement})=="function",a1=En(function(){return navigator.userAgent.indexOf("jsdom")>=0})||!1,l1=(qp||s1)&&!a1;function Zl(n){return n!==null&&typeof n=="object"}function ec(){}const c1=ec,u1=typeof WeakRef<"u"?WeakRef:function(n){return{deref:()=>n}},f1=typeof WeakMap<"u"?WeakMap:Map,d1=typeof FinalizationRegistry<"u"?FinalizationRegistry:function(){return{register:ec,unregister:ec}},h1=10024;class Zd{constructor(e=1/0,t=c1){this.max=e,this.dispose=t,this.map=new f1,this.newest=null,this.oldest=null,this.unfinalizedNodes=new Set,this.finalizationScheduled=!1,this.size=0,this.finalize=()=>{const r=this.unfinalizedNodes.values();for(let i=0;i<h1;i++){const s=r.next().value;if(!s)break;this.unfinalizedNodes.delete(s);const a=s.key;delete s.key,s.keyRef=new u1(a),this.registry.register(a,s,s)}this.unfinalizedNodes.size>0?queueMicrotask(this.finalize):this.finalizationScheduled=!1},this.registry=new d1(this.deleteNode.bind(this))}has(e){return this.map.has(e)}get(e){const t=this.getNode(e);return t&&t.value}getNode(e){const t=this.map.get(e);if(t&&t!==this.newest){const{older:r,newer:i}=t;i&&(i.older=r),r&&(r.newer=i),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=i)}return t}set(e,t){let r=this.getNode(e);return r?r.value=t:(r={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=r),this.newest=r,this.oldest=this.oldest||r,this.scheduleFinalization(r),this.map.set(e,r),this.size++,r.value)}clean(){for(;this.oldest&&this.size>this.max;)this.deleteNode(this.oldest)}deleteNode(e){e===this.newest&&(this.newest=e.older),e===this.oldest&&(this.oldest=e.newer),e.newer&&(e.newer.older=e.older),e.older&&(e.older.newer=e.newer),this.size--;const t=e.key||e.keyRef&&e.keyRef.deref();this.dispose(e.value,t),e.keyRef?this.registry.unregister(e):this.unfinalizedNodes.delete(e),t&&this.map.delete(t)}delete(e){const t=this.map.get(e);return t?(this.deleteNode(t),!0):!1}scheduleFinalization(e){this.unfinalizedNodes.add(e),this.finalizationScheduled||(this.finalizationScheduled=!0,queueMicrotask(this.finalize))}}var kl=new WeakSet;function p1(n){n.size<=(n.max||-1)||kl.has(n)||(kl.add(n),setTimeout(function(){n.clean(),kl.delete(n)},100))}var m1=function(n,e){var t=new Zd(n,e);return t.set=function(r,i){var s=Zd.prototype.set.call(this,r,i);return p1(this),s},t},g1=Symbol.for("apollo.cacheSize"),y1=Oe({},Xl[g1]);function Jp(n){return Array.isArray(n)&&n.length>0}function _1(n){var e=new Set([n]);return e.forEach(function(t){Zl(t)&&b1(t)===t&&Object.getOwnPropertyNames(t).forEach(function(r){Zl(t[r])&&e.add(t[r])})}),n}function b1(n){if(globalThis.__DEV__!==!1&&!Object.isFrozen(n))try{Object.freeze(n)}catch(e){if(e instanceof TypeError)return null;throw e}return n}function Gp(n){return globalThis.__DEV__!==!1&&_1(n),n}function tc(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=Object.create(null);return n.forEach(function(r){r&&Object.keys(r).forEach(function(i){var s=r[i];s!==void 0&&(t[i]=s)})}),t}function nc(n,e){return tc(n,e,e.variables&&{variables:tc(Oe(Oe({},n&&n.variables),e.variables))})}var v1=function(n){var e=ni(ni(ni([],n.graphQLErrors,!0),n.clientErrors,!0),n.protocolErrors,!0);return n.networkError&&e.push(n.networkError),e.map(function(t){return Zl(t)&&t.message||"Error message not found."}).join(`
2
- `)},Yp=function(n){zp(e,n);function e(t){var r=t.graphQLErrors,i=t.protocolErrors,s=t.clientErrors,a=t.networkError,c=t.errorMessage,u=t.extraInfo,d=n.call(this,c)||this;return d.name="ApolloError",d.graphQLErrors=r||[],d.protocolErrors=i||[],d.clientErrors=s||[],d.networkError=a||null,d.message=c||v1(d),d.extraInfo=u,d.cause=ni(ni(ni([a],r||[],!0),i||[],!0),s||[],!0).find(function(h){return!!h})||null,d.__proto__=e.prototype,d}return e}(Error);const{toString:eh,hasOwnProperty:S1}=Object.prototype,th=Function.prototype.toString,rc=new Map;function ic(n,e){try{return sc(n,e)}finally{rc.clear()}}function sc(n,e){if(n===e)return!0;const t=eh.call(n),r=eh.call(e);if(t!==r)return!1;switch(t){case"[object Array]":if(n.length!==e.length)return!1;case"[object Object]":{if(rh(n,e))return!0;const i=nh(n),s=nh(e),a=i.length;if(a!==s.length)return!1;for(let c=0;c<a;++c)if(!S1.call(e,i[c]))return!1;for(let c=0;c<a;++c){const u=i[c];if(!sc(n[u],e[u]))return!1}return!0}case"[object Error]":return n.name===e.name&&n.message===e.message;case"[object Number]":if(n!==n)return e!==e;case"[object Boolean]":case"[object Date]":return+n==+e;case"[object RegExp]":case"[object String]":return n==`${e}`;case"[object Map]":case"[object Set]":{if(n.size!==e.size)return!1;if(rh(n,e))return!0;const i=n.entries(),s=t==="[object Map]";for(;;){const a=i.next();if(a.done)break;const[c,u]=a.value;if(!e.has(c)||s&&!sc(u,e.get(c)))return!1}return!0}case"[object Uint16Array]":case"[object Uint8Array]":case"[object Uint32Array]":case"[object Int32Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object ArrayBuffer]":n=new Uint8Array(n),e=new Uint8Array(e);case"[object DataView]":{let i=n.byteLength;if(i===e.byteLength)for(;i--&&n[i]===e[i];);return i===-1}case"[object AsyncFunction]":case"[object GeneratorFunction]":case"[object AsyncGeneratorFunction]":case"[object Function]":{const i=th.call(n);return i!==th.call(e)?!1:!x1(i,k1)}}return!1}function nh(n){return Object.keys(n).filter(w1,n)}function w1(n){return this[n]!==void 0}const k1="{ [native code] }";function x1(n,e){const t=n.length-e.length;return t>=0&&n.indexOf(e,t)===t}function rh(n,e){let t=rc.get(n);if(t){if(t.has(e))return!0}else rc.set(n,t=new Set);return t.add(e),!1}var Er;(function(n){n[n.loading=1]="loading",n[n.setVariables=2]="setVariables",n[n.fetchMore=3]="fetchMore",n[n.refetch=4]="refetch",n[n.poll=6]="poll",n[n.ready=7]="ready",n[n.error=8]="error"})(Er||(Er={}));var Li=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function E1(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Qp={exports:{}};(function(n){n.exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=void 0,n.exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=void 0,n.exports.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=void 0,Object.assign(n.exports,q)})(Qp);var ye=Qp.exports;const O1=E1(ye),Xp=Zk({__proto__:null,default:O1},[ye]);var ih=o1?Symbol.for("__APOLLO_CONTEXT__"):"__APOLLO_CONTEXT__";function Fc(){an("createContext"in Xp,54);var n=ye.createContext[ih];return n||(Object.defineProperty(ye.createContext,ih,{value:n=ye.createContext({}),enumerable:!1,writable:!1,configurable:!0}),n.displayName="ApolloContext"),n}var T1=function(n){var e=n.client,t=n.children,r=Fc(),i=ye.useContext(r),s=ye.useMemo(function(){return Oe(Oe({},i),{client:e||i.client})},[i,e]);return an(s.client,55),ye.createElement(r.Provider,{value:s},t)};function Zp(n){var e=ye.useContext(Fc()),t=n||e.client;return an(!!t,58),t}var sh=!1,A1="useSyncExternalStore",C1=Xp[A1],M1=C1||function(n,e,t){var r=e();globalThis.__DEV__!==!1&&!sh&&r!==e()&&(sh=!0,globalThis.__DEV__!==!1&&an.error(68));var i=ye.useState({inst:{value:r,getSnapshot:e}}),s=i[0].inst,a=i[1];return l1?ye.useLayoutEffect(function(){Object.assign(s,{value:r,getSnapshot:e}),xl(s)&&a({inst:s})},[n,r,e]):Object.assign(s,{value:r,getSnapshot:e}),ye.useEffect(function(){return xl(s)&&a({inst:s}),n(function(){xl(s)&&a({inst:s})})},[n]),r};function xl(n){var e=n.value,t=n.getSnapshot;try{return e!==t()}catch{return!0}}var Tn;(function(n){n[n.Query=0]="Query",n[n.Mutation=1]="Mutation",n[n.Subscription=2]="Subscription"})(Tn||(Tn={}));var Vi;function oh(n){var e;switch(n){case Tn.Query:e="Query";break;case Tn.Mutation:e="Mutation";break;case Tn.Subscription:e="Subscription";break}return e}function em(n){Vi||(Vi=new m1(y1.parser||1e3));var e=Vi.get(n);if(e)return e;var t,r,i;an(!!n&&!!n.kind,70,n);for(var s=[],a=[],c=[],u=[],d=0,h=n.definitions;d<h.length;d++){var p=h[d];if(p.kind==="FragmentDefinition"){s.push(p);continue}if(p.kind==="OperationDefinition")switch(p.operation){case"query":a.push(p);break;case"mutation":c.push(p);break;case"subscription":u.push(p);break}}an(!s.length||a.length||c.length||u.length,71),an(a.length+c.length+u.length<=1,72,n,a.length,u.length,c.length),r=a.length?Tn.Query:Tn.Mutation,!a.length&&!c.length&&(r=Tn.Subscription);var y=a.length?a:c.length?c:u;an(y.length===1,73,n,y.length);var g=y[0];t=g.variableDefinitions||[],g.name&&g.name.kind==="Name"?i=g.name.value:i="data";var _={name:i,type:r,variables:t};return Vi.set(n,_),_}em.resetCache=function(){Vi=void 0};function N1(n,e){var t=em(n),r=oh(e),i=oh(t.type);an(t.type===e,74,r,r,i)}var I1=qp?ye.useLayoutEffect:ye.useEffect,P1=Symbol.for("apollo.hook.wrappers");function R1(n,e,t){var r=t.queryManager,i=r&&r[P1],s=i&&i[n];return s?s(e):e}var D1=Object.prototype.hasOwnProperty;function ah(){}var ho=Symbol();function $c(n,e){return e===void 0&&(e=Object.create(null)),R1("useQuery",L1,Zp(e&&e.client))(n,e)}function L1(n,e){var t=tm(n,e),r=t.result,i=t.obsQueryFields;return ye.useMemo(function(){return Oe(Oe({},r),i)},[r,i])}function B1(n,e,t,r,i){function s(p){var y;N1(e,Tn.Query);var g={client:n,query:e,observable:r&&r.getSSRObservable(i())||n.watchQuery(zc(void 0,n,t,i())),resultData:{previousData:(y=p==null?void 0:p.resultData.current)===null||y===void 0?void 0:y.data}};return g}var a=ye.useState(s),c=a[0],u=a[1];function d(p){var y,g;Object.assign(c.observable,(y={},y[ho]=p,y));var _=c.resultData;u(Oe(Oe({},c),{query:p.query,resultData:Object.assign(_,{previousData:((g=_.current)===null||g===void 0?void 0:g.data)||_.previousData,current:void 0})}))}if(n!==c.client||e!==c.query){var h=s(c);return u(h),[h,d]}return[c,d]}function tm(n,e){var t=Zp(e.client),r=ye.useContext(Fc()).renderPromises,i=!!r,s=t.disableNetworkFetches,a=e.ssr!==!1&&!e.skip,c=e.partialRefetch,u=nm(t,n,e,i),d=B1(t,n,e,r,u),h=d[0],p=h.observable,y=h.resultData,g=d[1],_=u(p);z1(y,p,t,e,_);var w=ye.useMemo(function(){return U1(p)},[p]);$1(p,r,a);var k=F1(y,p,t,e,_,s,c,i,{onCompleted:e.onCompleted||ah,onError:e.onError||ah});return{result:k,obsQueryFields:w,observable:p,resultData:y,client:t,onQueryExecuted:g}}function F1(n,e,t,r,i,s,a,c,u){var d=ye.useRef(u);ye.useEffect(function(){d.current=u});var h=(c||s)&&r.ssr===!1&&!r.skip?rm:r.skip||i.fetchPolicy==="standby"?im:void 0,p=n.previousData,y=ye.useMemo(function(){return h&&So(h,p,e,t)},[t,e,h,p]);return M1(ye.useCallback(function(g){if(c)return function(){};var _=function(){var A=n.current,P=e.getCurrentResult();A&&A.loading===P.loading&&A.networkStatus===P.networkStatus&&ic(A.data,P.data)||oc(P,n,e,t,a,g,d.current)},w=function(A){if(k.current.unsubscribe(),k.current=e.resubscribeAfterError(_,w),!D1.call(A,"graphQLErrors"))throw A;var P=n.current;(!P||P&&P.loading||!ic(A,P.error))&&oc({data:P&&P.data,error:A,loading:!1,networkStatus:Er.error},n,e,t,a,g,d.current)},k={current:e.subscribe(_,w)};return function(){setTimeout(function(){return k.current.unsubscribe()})}},[s,c,e,n,a,t]),function(){return y||lh(n,e,d.current,a,t)},function(){return y||lh(n,e,d.current,a,t)})}function $1(n,e,t){e&&t&&(e.registerSSRObservable(n),n.getCurrentResult().loading&&e.addObservableQueryPromise(n))}function z1(n,e,t,r,i){var s;e[ho]&&!ic(e[ho],i)&&(e.reobserve(zc(e,t,r,i)),n.previousData=((s=n.current)===null||s===void 0?void 0:s.data)||n.previousData,n.current=void 0),e[ho]=i}function nm(n,e,t,r){t===void 0&&(t={});var i=t.skip;t.ssr,t.onCompleted,t.onError;var s=t.defaultOptions,a=Wp(t,["skip","ssr","onCompleted","onError","defaultOptions"]);return function(c){var u=Object.assign(a,{query:e});return r&&(u.fetchPolicy==="network-only"||u.fetchPolicy==="cache-and-network")&&(u.fetchPolicy="cache-first"),u.variables||(u.variables={}),i?(u.initialFetchPolicy=u.initialFetchPolicy||u.fetchPolicy||ac(s,n.defaultOptions),u.fetchPolicy="standby"):u.fetchPolicy||(u.fetchPolicy=(c==null?void 0:c.options.initialFetchPolicy)||ac(s,n.defaultOptions)),u}}function zc(n,e,t,r){var i=[],s=e.defaultOptions.watchQuery;return s&&i.push(s),t.defaultOptions&&i.push(t.defaultOptions),i.push(tc(n&&n.options,r)),i.reduce(nc)}function oc(n,e,t,r,i,s,a){var c=e.current;c&&c.data&&(e.previousData=c.data),!n.error&&Jp(n.errors)&&(n.error=new Yp({graphQLErrors:n.errors})),e.current=So(H1(n,t,i),e.previousData,t,r),s(),W1(n,c==null?void 0:c.networkStatus,a)}function W1(n,e,t){if(!n.loading){var r=V1(n);Promise.resolve().then(function(){r?t.onError(r):n.data&&e!==n.networkStatus&&n.networkStatus===Er.ready&&t.onCompleted(n.data)}).catch(function(i){globalThis.__DEV__!==!1&&an.warn(i)})}}function lh(n,e,t,r,i){return n.current||oc(e.getCurrentResult(),n,e,i,r,function(){},t),n.current}function ac(n,e){var t;return(n==null?void 0:n.fetchPolicy)||((t=e==null?void 0:e.watchQuery)===null||t===void 0?void 0:t.fetchPolicy)||"cache-first"}function V1(n){return Jp(n.errors)?new Yp({graphQLErrors:n.errors}):n.error}function So(n,e,t,r){var i=n.data;n.partial;var s=Wp(n,["data","partial"]),a=Oe(Oe({data:i},s),{client:r,observable:t,variables:t.variables,called:n!==rm&&n!==im,previousData:e});return a}function H1(n,e,t){return n.partial&&t&&!n.loading&&(!n.data||Object.keys(n.data).length===0)&&e.options.fetchPolicy!=="cache-only"?(e.refetch(),Oe(Oe({},n),{loading:!0,networkStatus:Er.refetch})):n}var rm=Gp({loading:!0,data:void 0,error:void 0,networkStatus:Er.loading}),im=Gp({loading:!1,data:void 0,error:void 0,networkStatus:Er.ready});function U1(n){return{refetch:n.refetch.bind(n),reobserve:n.reobserve.bind(n),fetchMore:n.fetchMore.bind(n),updateQuery:n.updateQuery.bind(n),startPolling:n.startPolling.bind(n),stopPolling:n.stopPolling.bind(n),subscribeToMore:n.subscribeToMore.bind(n)}}var K1=["refetch","reobserve","fetchMore","updateQuery","startPolling","stopPolling","subscribeToMore"];function sm(n,e){var t,r=ye.useRef(void 0),i=ye.useRef(void 0),s=ye.useRef(void 0),a=nc(e,r.current||{}),c=(t=a==null?void 0:a.query)!==null&&t!==void 0?t:n;i.current=e,s.current=c;var u=Oe(Oe({},a),{skip:!r.current}),d=tm(c,u),h=d.obsQueryFields,p=d.result,y=d.client,g=d.resultData,_=d.observable,w=d.onQueryExecuted,k=_.options.initialFetchPolicy||ac(u.defaultOptions,y.defaultOptions),A=ye.useReducer(function(K){return K+1},0)[1],P=ye.useMemo(function(){for(var K={},V=function(pt){var We=h[pt];K[pt]=function(){return r.current||(r.current=Object.create(null),A()),We.apply(this,arguments)}},ne=0,ve=K1;ne<ve.length;ne++){var De=ve[ne];V(De)}return K},[A,h]),L=!!r.current,B=ye.useMemo(function(){return Oe(Oe(Oe({},p),P),{called:L})},[p,P,L]),z=ye.useCallback(function(K){r.current=K?Oe(Oe({},K),{fetchPolicy:K.fetchPolicy||k}):{fetchPolicy:k};var V=nc(i.current,Oe({query:s.current},r.current)),ne=j1(g,_,y,c,Oe(Oe({},V),{skip:!1}),w).then(function(ve){return Object.assign(ve,P)});return ne.catch(function(){}),ne},[y,c,P,k,_,g,w]),$=ye.useRef(z);I1(function(){$.current=z});var J=ye.useCallback(function(){for(var K=[],V=0;V<arguments.length;V++)K[V]=arguments[V];return $.current.apply($,K)},[]);return[J,B]}function j1(n,e,t,r,i,s){var a=i.query||r,c=nm(t,a,i,!1)(e),u=e.reobserveAsConcast(zc(e,t,i,c));return s(c),new Promise(function(d){var h;u.subscribe({next:function(p){h=p},error:function(){d(So(e.getCurrentResult(),n.previousData,e,t))},complete:function(){d(So(e.maskResult(h),n.previousData,e,t))}})})}const q1=(n,e)=>{const{data:t,loading:r,refetch:i,fetchMore:s}=$c(n,{...e,notifyOnNetworkStatusChange:!0,variables:{...e==null?void 0:e.variables,page:{first:(e==null?void 0:e.pageSize)??100}}}),a=n.definitions[0].selectionSet.selections[0].name.value;return{data:t,loading:r,loadNextPage:c=>{const u=t==null?void 0:t[a];if(u!=null&&u.pageInfo.hasNextPage)return i({...e==null?void 0:e.variables,...c,page:{first:(e==null?void 0:e.pageSize)??100,after:u.pageInfo.endCursor}})},loadNextPageWithoutAppendingOldData:c=>{const u=t==null?void 0:t[a];return s({variables:{...e==null?void 0:e.variables,...c,page:{first:(e==null?void 0:e.pageSize)??100,after:u==null?void 0:u.pageInfo.endCursor}}})}}},Wc=(n,e)=>{const[t,r]=q.useState(!(e!=null&&e.skip)),[i,s]=q.useState([]),[a]=sm(n,e),c=async u=>{var g;const d=n.definitions[0].selectionSet.selections[0].name.value;r(!0);let h=!0,p=null;const y=[];for(;h;){const{data:_,error:w}=await a({variables:{...e==null?void 0:e.variables,...u,page:{first:100,after:p}}});if(w)throw w;const k=_==null?void 0:_[d];k&&(y.push(...k.nodes??[]),h=k.pageInfo.hasNextPage,p=k.pageInfo.endCursor)}return s(y),(g=e==null?void 0:e.onResults)==null||g.call(e,y),r(!1),y};return q.useEffect(()=>{e!=null&&e.skip||c()},[e==null?void 0:e.skip]),{loading:t,results:i,refetch:c}};var lc={exports:{}},Bi={};/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react"),Er=require("@well-played.gg/typescript-sdk"),Xk=require("react-dom");function Zk(n,e){for(var t=0;t<e.length;t++){const r=e[t];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in n)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(n,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var Ql=function(n,e){return Ql=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])},Ql(n,e)};function zp(n,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Ql(n,e);function t(){this.constructor=n}n.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}var Oe=function(){return Oe=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++){t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},Oe.apply(this,arguments)};function Wp(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t}function ri(n,e,t){if(t||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return n.concat(s||Array.prototype.slice.call(e))}var wl="Invariant Violation",Yd=Object.setPrototypeOf,e1=Yd===void 0?function(n,e){return n.__proto__=e,n}:Yd,t1=function(n){zp(e,n);function e(t){t===void 0&&(t=wl);var r=n.call(this,typeof t=="number"?wl+": "+t+" (see https://github.com/apollographql/invariant-packages)":t)||this;return r.framesToPop=1,r.name=wl,e1(r,e.prototype),r}return e}(Error);function hr(n,e){if(!n)throw new t1(e)}var Vp=["debug","log","warn","error","silent"],n1=Vp.indexOf("log");function ro(n){return function(){if(Vp.indexOf(n)>=n1){var e=console[n]||console.log;return e.apply(console,arguments)}}}(function(n){n.debug=ro("debug"),n.log=ro("log"),n.warn=ro("warn"),n.error=ro("error")})(hr||(hr={}));var Hp="3.13.5";function En(n){try{return n()}catch{}}const Xl=En(function(){return globalThis})||En(function(){return window})||En(function(){return self})||En(function(){return global})||En(function(){return En.constructor("return this")()});var Qd=new Map;function r1(n){var e=Qd.get(n)||1;return Qd.set(n,e+1),"".concat(n,":").concat(e,":").concat(Math.random().toString(36).slice(2))}function i1(n,e){var t=r1("stringifyForDisplay");return JSON.stringify(n,function(r,i){return i===void 0?t:i},e).split(JSON.stringify(t)).join("<undefined>")}function io(n){return function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(typeof e=="number"){var i=e;e=Kp(i),e||(e=jp(i,t),t=[])}n.apply(void 0,[e].concat(t))}}var an=Object.assign(function(e,t){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];e||hr(e,Kp(t,r)||jp(t,r))},{debug:io(hr.debug),log:io(hr.log),warn:io(hr.warn),error:io(hr.error)}),Xd=Symbol.for("ApolloErrorMessageHandler_"+Hp);function Up(n){if(typeof n=="string")return n;try{return i1(n,2).slice(0,1e3)}catch{return"<non-serializable>"}}function Kp(n,e){if(e===void 0&&(e=[]),!!n)return Xl[Xd]&&Xl[Xd](n,e.map(Up))}function jp(n,e){if(e===void 0&&(e=[]),!!n)return"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#".concat(encodeURIComponent(JSON.stringify({version:Hp,message:n,args:e.map(Up)})))}var s1=En(function(){return navigator.product})=="ReactNative",o1=typeof Symbol=="function"&&typeof Symbol.for=="function",qp=typeof En(function(){return window.document.createElement})=="function",a1=En(function(){return navigator.userAgent.indexOf("jsdom")>=0})||!1,l1=(qp||s1)&&!a1;function Zl(n){return n!==null&&typeof n=="object"}function ec(){}const c1=ec,u1=typeof WeakRef<"u"?WeakRef:function(n){return{deref:()=>n}},f1=typeof WeakMap<"u"?WeakMap:Map,d1=typeof FinalizationRegistry<"u"?FinalizationRegistry:function(){return{register:ec,unregister:ec}},h1=10024;class Zd{constructor(e=1/0,t=c1){this.max=e,this.dispose=t,this.map=new f1,this.newest=null,this.oldest=null,this.unfinalizedNodes=new Set,this.finalizationScheduled=!1,this.size=0,this.finalize=()=>{const r=this.unfinalizedNodes.values();for(let i=0;i<h1;i++){const s=r.next().value;if(!s)break;this.unfinalizedNodes.delete(s);const a=s.key;delete s.key,s.keyRef=new u1(a),this.registry.register(a,s,s)}this.unfinalizedNodes.size>0?queueMicrotask(this.finalize):this.finalizationScheduled=!1},this.registry=new d1(this.deleteNode.bind(this))}has(e){return this.map.has(e)}get(e){const t=this.getNode(e);return t&&t.value}getNode(e){const t=this.map.get(e);if(t&&t!==this.newest){const{older:r,newer:i}=t;i&&(i.older=r),r&&(r.newer=i),t.older=this.newest,t.older.newer=t,t.newer=null,this.newest=t,t===this.oldest&&(this.oldest=i)}return t}set(e,t){let r=this.getNode(e);return r?r.value=t:(r={key:e,value:t,newer:null,older:this.newest},this.newest&&(this.newest.newer=r),this.newest=r,this.oldest=this.oldest||r,this.scheduleFinalization(r),this.map.set(e,r),this.size++,r.value)}clean(){for(;this.oldest&&this.size>this.max;)this.deleteNode(this.oldest)}deleteNode(e){e===this.newest&&(this.newest=e.older),e===this.oldest&&(this.oldest=e.newer),e.newer&&(e.newer.older=e.older),e.older&&(e.older.newer=e.newer),this.size--;const t=e.key||e.keyRef&&e.keyRef.deref();this.dispose(e.value,t),e.keyRef?this.registry.unregister(e):this.unfinalizedNodes.delete(e),t&&this.map.delete(t)}delete(e){const t=this.map.get(e);return t?(this.deleteNode(t),!0):!1}scheduleFinalization(e){this.unfinalizedNodes.add(e),this.finalizationScheduled||(this.finalizationScheduled=!0,queueMicrotask(this.finalize))}}var kl=new WeakSet;function p1(n){n.size<=(n.max||-1)||kl.has(n)||(kl.add(n),setTimeout(function(){n.clean(),kl.delete(n)},100))}var m1=function(n,e){var t=new Zd(n,e);return t.set=function(r,i){var s=Zd.prototype.set.call(this,r,i);return p1(this),s},t},g1=Symbol.for("apollo.cacheSize"),y1=Oe({},Xl[g1]);function Jp(n){return Array.isArray(n)&&n.length>0}function _1(n){var e=new Set([n]);return e.forEach(function(t){Zl(t)&&b1(t)===t&&Object.getOwnPropertyNames(t).forEach(function(r){Zl(t[r])&&e.add(t[r])})}),n}function b1(n){if(globalThis.__DEV__!==!1&&!Object.isFrozen(n))try{Object.freeze(n)}catch(e){if(e instanceof TypeError)return null;throw e}return n}function Gp(n){return globalThis.__DEV__!==!1&&_1(n),n}function tc(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=Object.create(null);return n.forEach(function(r){r&&Object.keys(r).forEach(function(i){var s=r[i];s!==void 0&&(t[i]=s)})}),t}function nc(n,e){return tc(n,e,e.variables&&{variables:tc(Oe(Oe({},n&&n.variables),e.variables))})}var v1=function(n){var e=ri(ri(ri([],n.graphQLErrors,!0),n.clientErrors,!0),n.protocolErrors,!0);return n.networkError&&e.push(n.networkError),e.map(function(t){return Zl(t)&&t.message||"Error message not found."}).join(`
2
+ `)},Yp=function(n){zp(e,n);function e(t){var r=t.graphQLErrors,i=t.protocolErrors,s=t.clientErrors,a=t.networkError,c=t.errorMessage,u=t.extraInfo,d=n.call(this,c)||this;return d.name="ApolloError",d.graphQLErrors=r||[],d.protocolErrors=i||[],d.clientErrors=s||[],d.networkError=a||null,d.message=c||v1(d),d.extraInfo=u,d.cause=ri(ri(ri([a],r||[],!0),i||[],!0),s||[],!0).find(function(h){return!!h})||null,d.__proto__=e.prototype,d}return e}(Error);const{toString:eh,hasOwnProperty:S1}=Object.prototype,th=Function.prototype.toString,rc=new Map;function ic(n,e){try{return sc(n,e)}finally{rc.clear()}}function sc(n,e){if(n===e)return!0;const t=eh.call(n),r=eh.call(e);if(t!==r)return!1;switch(t){case"[object Array]":if(n.length!==e.length)return!1;case"[object Object]":{if(rh(n,e))return!0;const i=nh(n),s=nh(e),a=i.length;if(a!==s.length)return!1;for(let c=0;c<a;++c)if(!S1.call(e,i[c]))return!1;for(let c=0;c<a;++c){const u=i[c];if(!sc(n[u],e[u]))return!1}return!0}case"[object Error]":return n.name===e.name&&n.message===e.message;case"[object Number]":if(n!==n)return e!==e;case"[object Boolean]":case"[object Date]":return+n==+e;case"[object RegExp]":case"[object String]":return n==`${e}`;case"[object Map]":case"[object Set]":{if(n.size!==e.size)return!1;if(rh(n,e))return!0;const i=n.entries(),s=t==="[object Map]";for(;;){const a=i.next();if(a.done)break;const[c,u]=a.value;if(!e.has(c)||s&&!sc(u,e.get(c)))return!1}return!0}case"[object Uint16Array]":case"[object Uint8Array]":case"[object Uint32Array]":case"[object Int32Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object ArrayBuffer]":n=new Uint8Array(n),e=new Uint8Array(e);case"[object DataView]":{let i=n.byteLength;if(i===e.byteLength)for(;i--&&n[i]===e[i];);return i===-1}case"[object AsyncFunction]":case"[object GeneratorFunction]":case"[object AsyncGeneratorFunction]":case"[object Function]":{const i=th.call(n);return i!==th.call(e)?!1:!x1(i,k1)}}return!1}function nh(n){return Object.keys(n).filter(w1,n)}function w1(n){return this[n]!==void 0}const k1="{ [native code] }";function x1(n,e){const t=n.length-e.length;return t>=0&&n.indexOf(e,t)===t}function rh(n,e){let t=rc.get(n);if(t){if(t.has(e))return!0}else rc.set(n,t=new Set);return t.add(e),!1}var Or;(function(n){n[n.loading=1]="loading",n[n.setVariables=2]="setVariables",n[n.fetchMore=3]="fetchMore",n[n.refetch=4]="refetch",n[n.poll=6]="poll",n[n.ready=7]="ready",n[n.error=8]="error"})(Or||(Or={}));var Li=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function E1(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Qp={exports:{}};(function(n){n.exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=void 0,n.exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=void 0,n.exports.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=void 0,Object.assign(n.exports,q)})(Qp);var ye=Qp.exports;const O1=E1(ye),Xp=Zk({__proto__:null,default:O1},[ye]);var ih=o1?Symbol.for("__APOLLO_CONTEXT__"):"__APOLLO_CONTEXT__";function Fc(){an("createContext"in Xp,54);var n=ye.createContext[ih];return n||(Object.defineProperty(ye.createContext,ih,{value:n=ye.createContext({}),enumerable:!1,writable:!1,configurable:!0}),n.displayName="ApolloContext"),n}var T1=function(n){var e=n.client,t=n.children,r=Fc(),i=ye.useContext(r),s=ye.useMemo(function(){return Oe(Oe({},i),{client:e||i.client})},[i,e]);return an(s.client,55),ye.createElement(r.Provider,{value:s},t)};function Zp(n){var e=ye.useContext(Fc()),t=n||e.client;return an(!!t,58),t}var sh=!1,A1="useSyncExternalStore",C1=Xp[A1],M1=C1||function(n,e,t){var r=e();globalThis.__DEV__!==!1&&!sh&&r!==e()&&(sh=!0,globalThis.__DEV__!==!1&&an.error(68));var i=ye.useState({inst:{value:r,getSnapshot:e}}),s=i[0].inst,a=i[1];return l1?ye.useLayoutEffect(function(){Object.assign(s,{value:r,getSnapshot:e}),xl(s)&&a({inst:s})},[n,r,e]):Object.assign(s,{value:r,getSnapshot:e}),ye.useEffect(function(){return xl(s)&&a({inst:s}),n(function(){xl(s)&&a({inst:s})})},[n]),r};function xl(n){var e=n.value,t=n.getSnapshot;try{return e!==t()}catch{return!0}}var Tn;(function(n){n[n.Query=0]="Query",n[n.Mutation=1]="Mutation",n[n.Subscription=2]="Subscription"})(Tn||(Tn={}));var Vi;function oh(n){var e;switch(n){case Tn.Query:e="Query";break;case Tn.Mutation:e="Mutation";break;case Tn.Subscription:e="Subscription";break}return e}function em(n){Vi||(Vi=new m1(y1.parser||1e3));var e=Vi.get(n);if(e)return e;var t,r,i;an(!!n&&!!n.kind,70,n);for(var s=[],a=[],c=[],u=[],d=0,h=n.definitions;d<h.length;d++){var p=h[d];if(p.kind==="FragmentDefinition"){s.push(p);continue}if(p.kind==="OperationDefinition")switch(p.operation){case"query":a.push(p);break;case"mutation":c.push(p);break;case"subscription":u.push(p);break}}an(!s.length||a.length||c.length||u.length,71),an(a.length+c.length+u.length<=1,72,n,a.length,u.length,c.length),r=a.length?Tn.Query:Tn.Mutation,!a.length&&!c.length&&(r=Tn.Subscription);var y=a.length?a:c.length?c:u;an(y.length===1,73,n,y.length);var g=y[0];t=g.variableDefinitions||[],g.name&&g.name.kind==="Name"?i=g.name.value:i="data";var _={name:i,type:r,variables:t};return Vi.set(n,_),_}em.resetCache=function(){Vi=void 0};function N1(n,e){var t=em(n),r=oh(e),i=oh(t.type);an(t.type===e,74,r,r,i)}var I1=qp?ye.useLayoutEffect:ye.useEffect,P1=Symbol.for("apollo.hook.wrappers");function R1(n,e,t){var r=t.queryManager,i=r&&r[P1],s=i&&i[n];return s?s(e):e}var D1=Object.prototype.hasOwnProperty;function ah(){}var ho=Symbol();function $c(n,e){return e===void 0&&(e=Object.create(null)),R1("useQuery",L1,Zp(e&&e.client))(n,e)}function L1(n,e){var t=tm(n,e),r=t.result,i=t.obsQueryFields;return ye.useMemo(function(){return Oe(Oe({},r),i)},[r,i])}function B1(n,e,t,r,i){function s(p){var y;N1(e,Tn.Query);var g={client:n,query:e,observable:r&&r.getSSRObservable(i())||n.watchQuery(zc(void 0,n,t,i())),resultData:{previousData:(y=p==null?void 0:p.resultData.current)===null||y===void 0?void 0:y.data}};return g}var a=ye.useState(s),c=a[0],u=a[1];function d(p){var y,g;Object.assign(c.observable,(y={},y[ho]=p,y));var _=c.resultData;u(Oe(Oe({},c),{query:p.query,resultData:Object.assign(_,{previousData:((g=_.current)===null||g===void 0?void 0:g.data)||_.previousData,current:void 0})}))}if(n!==c.client||e!==c.query){var h=s(c);return u(h),[h,d]}return[c,d]}function tm(n,e){var t=Zp(e.client),r=ye.useContext(Fc()).renderPromises,i=!!r,s=t.disableNetworkFetches,a=e.ssr!==!1&&!e.skip,c=e.partialRefetch,u=nm(t,n,e,i),d=B1(t,n,e,r,u),h=d[0],p=h.observable,y=h.resultData,g=d[1],_=u(p);z1(y,p,t,e,_);var w=ye.useMemo(function(){return U1(p)},[p]);$1(p,r,a);var k=F1(y,p,t,e,_,s,c,i,{onCompleted:e.onCompleted||ah,onError:e.onError||ah});return{result:k,obsQueryFields:w,observable:p,resultData:y,client:t,onQueryExecuted:g}}function F1(n,e,t,r,i,s,a,c,u){var d=ye.useRef(u);ye.useEffect(function(){d.current=u});var h=(c||s)&&r.ssr===!1&&!r.skip?rm:r.skip||i.fetchPolicy==="standby"?im:void 0,p=n.previousData,y=ye.useMemo(function(){return h&&So(h,p,e,t)},[t,e,h,p]);return M1(ye.useCallback(function(g){if(c)return function(){};var _=function(){var A=n.current,P=e.getCurrentResult();A&&A.loading===P.loading&&A.networkStatus===P.networkStatus&&ic(A.data,P.data)||oc(P,n,e,t,a,g,d.current)},w=function(A){if(k.current.unsubscribe(),k.current=e.resubscribeAfterError(_,w),!D1.call(A,"graphQLErrors"))throw A;var P=n.current;(!P||P&&P.loading||!ic(A,P.error))&&oc({data:P&&P.data,error:A,loading:!1,networkStatus:Or.error},n,e,t,a,g,d.current)},k={current:e.subscribe(_,w)};return function(){setTimeout(function(){return k.current.unsubscribe()})}},[s,c,e,n,a,t]),function(){return y||lh(n,e,d.current,a,t)},function(){return y||lh(n,e,d.current,a,t)})}function $1(n,e,t){e&&t&&(e.registerSSRObservable(n),n.getCurrentResult().loading&&e.addObservableQueryPromise(n))}function z1(n,e,t,r,i){var s;e[ho]&&!ic(e[ho],i)&&(e.reobserve(zc(e,t,r,i)),n.previousData=((s=n.current)===null||s===void 0?void 0:s.data)||n.previousData,n.current=void 0),e[ho]=i}function nm(n,e,t,r){t===void 0&&(t={});var i=t.skip;t.ssr,t.onCompleted,t.onError;var s=t.defaultOptions,a=Wp(t,["skip","ssr","onCompleted","onError","defaultOptions"]);return function(c){var u=Object.assign(a,{query:e});return r&&(u.fetchPolicy==="network-only"||u.fetchPolicy==="cache-and-network")&&(u.fetchPolicy="cache-first"),u.variables||(u.variables={}),i?(u.initialFetchPolicy=u.initialFetchPolicy||u.fetchPolicy||ac(s,n.defaultOptions),u.fetchPolicy="standby"):u.fetchPolicy||(u.fetchPolicy=(c==null?void 0:c.options.initialFetchPolicy)||ac(s,n.defaultOptions)),u}}function zc(n,e,t,r){var i=[],s=e.defaultOptions.watchQuery;return s&&i.push(s),t.defaultOptions&&i.push(t.defaultOptions),i.push(tc(n&&n.options,r)),i.reduce(nc)}function oc(n,e,t,r,i,s,a){var c=e.current;c&&c.data&&(e.previousData=c.data),!n.error&&Jp(n.errors)&&(n.error=new Yp({graphQLErrors:n.errors})),e.current=So(H1(n,t,i),e.previousData,t,r),s(),W1(n,c==null?void 0:c.networkStatus,a)}function W1(n,e,t){if(!n.loading){var r=V1(n);Promise.resolve().then(function(){r?t.onError(r):n.data&&e!==n.networkStatus&&n.networkStatus===Or.ready&&t.onCompleted(n.data)}).catch(function(i){globalThis.__DEV__!==!1&&an.warn(i)})}}function lh(n,e,t,r,i){return n.current||oc(e.getCurrentResult(),n,e,i,r,function(){},t),n.current}function ac(n,e){var t;return(n==null?void 0:n.fetchPolicy)||((t=e==null?void 0:e.watchQuery)===null||t===void 0?void 0:t.fetchPolicy)||"cache-first"}function V1(n){return Jp(n.errors)?new Yp({graphQLErrors:n.errors}):n.error}function So(n,e,t,r){var i=n.data;n.partial;var s=Wp(n,["data","partial"]),a=Oe(Oe({data:i},s),{client:r,observable:t,variables:t.variables,called:n!==rm&&n!==im,previousData:e});return a}function H1(n,e,t){return n.partial&&t&&!n.loading&&(!n.data||Object.keys(n.data).length===0)&&e.options.fetchPolicy!=="cache-only"?(e.refetch(),Oe(Oe({},n),{loading:!0,networkStatus:Or.refetch})):n}var rm=Gp({loading:!0,data:void 0,error:void 0,networkStatus:Or.loading}),im=Gp({loading:!1,data:void 0,error:void 0,networkStatus:Or.ready});function U1(n){return{refetch:n.refetch.bind(n),reobserve:n.reobserve.bind(n),fetchMore:n.fetchMore.bind(n),updateQuery:n.updateQuery.bind(n),startPolling:n.startPolling.bind(n),stopPolling:n.stopPolling.bind(n),subscribeToMore:n.subscribeToMore.bind(n)}}var K1=["refetch","reobserve","fetchMore","updateQuery","startPolling","stopPolling","subscribeToMore"];function sm(n,e){var t,r=ye.useRef(void 0),i=ye.useRef(void 0),s=ye.useRef(void 0),a=nc(e,r.current||{}),c=(t=a==null?void 0:a.query)!==null&&t!==void 0?t:n;i.current=e,s.current=c;var u=Oe(Oe({},a),{skip:!r.current}),d=tm(c,u),h=d.obsQueryFields,p=d.result,y=d.client,g=d.resultData,_=d.observable,w=d.onQueryExecuted,k=_.options.initialFetchPolicy||ac(u.defaultOptions,y.defaultOptions),A=ye.useReducer(function(K){return K+1},0)[1],P=ye.useMemo(function(){for(var K={},V=function(pt){var We=h[pt];K[pt]=function(){return r.current||(r.current=Object.create(null),A()),We.apply(this,arguments)}},ne=0,ve=K1;ne<ve.length;ne++){var De=ve[ne];V(De)}return K},[A,h]),L=!!r.current,B=ye.useMemo(function(){return Oe(Oe(Oe({},p),P),{called:L})},[p,P,L]),z=ye.useCallback(function(K){r.current=K?Oe(Oe({},K),{fetchPolicy:K.fetchPolicy||k}):{fetchPolicy:k};var V=nc(i.current,Oe({query:s.current},r.current)),ne=j1(g,_,y,c,Oe(Oe({},V),{skip:!1}),w).then(function(ve){return Object.assign(ve,P)});return ne.catch(function(){}),ne},[y,c,P,k,_,g,w]),$=ye.useRef(z);I1(function(){$.current=z});var J=ye.useCallback(function(){for(var K=[],V=0;V<arguments.length;V++)K[V]=arguments[V];return $.current.apply($,K)},[]);return[J,B]}function j1(n,e,t,r,i,s){var a=i.query||r,c=nm(t,a,i,!1)(e),u=e.reobserveAsConcast(zc(e,t,i,c));return s(c),new Promise(function(d){var h;u.subscribe({next:function(p){h=p},error:function(){d(So(e.getCurrentResult(),n.previousData,e,t))},complete:function(){d(So(e.maskResult(h),n.previousData,e,t))}})})}const q1=(n,e)=>{const{data:t,loading:r,refetch:i,fetchMore:s}=$c(n,{...e,notifyOnNetworkStatusChange:!0,variables:{...e==null?void 0:e.variables,page:{first:(e==null?void 0:e.pageSize)??100}}}),a=n.definitions[0].selectionSet.selections[0].name.value;return{data:t,loading:r,loadNextPage:c=>{const u=t==null?void 0:t[a];if(u!=null&&u.pageInfo.hasNextPage)return i({...e==null?void 0:e.variables,...c,page:{first:(e==null?void 0:e.pageSize)??100,after:u.pageInfo.endCursor}})},loadNextPageWithoutAppendingOldData:c=>{const u=t==null?void 0:t[a];return s({variables:{...e==null?void 0:e.variables,...c,page:{first:(e==null?void 0:e.pageSize)??100,after:u==null?void 0:u.pageInfo.endCursor}}})}}},Wc=(n,e)=>{const[t,r]=q.useState(!(e!=null&&e.skip)),[i,s]=q.useState([]),[a]=sm(n,e),c=async u=>{var g;const d=n.definitions[0].selectionSet.selections[0].name.value;r(!0);let h=!0,p=null;const y=[];for(;h;){const{data:_,error:w}=await a({variables:{...e==null?void 0:e.variables,...u,page:{first:100,after:p}}});if(w)throw w;const k=_==null?void 0:_[d];k&&(y.push(...k.nodes??[]),h=k.pageInfo.hasNextPage,p=k.pageInfo.endCursor)}return s(y),(g=e==null?void 0:e.onResults)==null||g.call(e,y),r(!1),y};return q.useEffect(()=>{e!=null&&e.skip||c()},[e==null?void 0:e.skip]),{loading:t,results:i,refetch:c}};var lc={exports:{}},Bi={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
5
5
  *
@@ -15,13 +15,13 @@
15
15
  *
16
16
  * This source code is licensed under the MIT license found in the
17
17
  * LICENSE file in the root directory of this source tree.
18
- */var uh;function G1(){return uh||(uh=1,process.env.NODE_ENV!=="production"&&function(){function n(F){if(F==null)return null;if(typeof F=="function")return F.$$typeof===ne?null:F.displayName||F.name||null;if(typeof F=="string")return F;switch(F){case w:return"Fragment";case A:return"Profiler";case k:return"StrictMode";case z:return"Suspense";case $:return"SuspenseList";case V:return"Activity"}if(typeof F=="object")switch(typeof F.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),F.$$typeof){case _:return"Portal";case L:return(F.displayName||"Context")+".Provider";case P:return(F._context.displayName||"Context")+".Consumer";case B:var te=F.render;return F=F.displayName,F||(F=te.displayName||te.name||"",F=F!==""?"ForwardRef("+F+")":"ForwardRef"),F;case J:return te=F.displayName||null,te!==null?te:n(F.type)||"Memo";case K:te=F._payload,F=F._init;try{return n(F(te))}catch{}}return null}function e(F){return""+F}function t(F){try{e(F);var te=!1}catch{te=!0}if(te){te=console;var xe=te.error,Ve=typeof Symbol=="function"&&Symbol.toStringTag&&F[Symbol.toStringTag]||F.constructor.name||"Object";return xe.call(te,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",Ve),e(F)}}function r(F){if(F===w)return"<>";if(typeof F=="object"&&F!==null&&F.$$typeof===K)return"<...>";try{var te=n(F);return te?"<"+te+">":"<...>"}catch{return"<...>"}}function i(){var F=ve.A;return F===null?null:F.getOwner()}function s(){return Error("react-stack-top-frame")}function a(F){if(De.call(F,"key")){var te=Object.getOwnPropertyDescriptor(F,"key").get;if(te&&te.isReactWarning)return!1}return F.key!==void 0}function c(F,te){function xe(){Ce||(Ce=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",te))}xe.isReactWarning=!0,Object.defineProperty(F,"key",{get:xe,configurable:!0})}function u(){var F=n(this.type);return ot[F]||(ot[F]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),F=this.props.ref,F!==void 0?F:null}function d(F,te,xe,Ve,tn,Je,Nn,pi){return xe=Je.ref,F={$$typeof:g,type:F,key:te,props:Je,_owner:tn},(xe!==void 0?xe:null)!==null?Object.defineProperty(F,"ref",{enumerable:!1,get:u}):Object.defineProperty(F,"ref",{enumerable:!1,value:null}),F._store={},Object.defineProperty(F._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(F,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(F,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Nn}),Object.defineProperty(F,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:pi}),Object.freeze&&(Object.freeze(F.props),Object.freeze(F)),F}function h(F,te,xe,Ve,tn,Je,Nn,pi){var Me=te.children;if(Me!==void 0)if(Ve)if(pt(Me)){for(Ve=0;Ve<Me.length;Ve++)p(Me[Ve]);Object.freeze&&Object.freeze(Me)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else p(Me);if(De.call(te,"key")){Me=n(F);var Mt=Object.keys(te).filter(function(Ir){return Ir!=="key"});Ve=0<Mt.length?"{key: someKey, "+Mt.join(": ..., ")+": ...}":"{key: someKey}",ds[Me+Ve]||(Mt=0<Mt.length?"{"+Mt.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
+ */var uh;function G1(){return uh||(uh=1,process.env.NODE_ENV!=="production"&&function(){function n(F){if(F==null)return null;if(typeof F=="function")return F.$$typeof===ne?null:F.displayName||F.name||null;if(typeof F=="string")return F;switch(F){case w:return"Fragment";case A:return"Profiler";case k:return"StrictMode";case z:return"Suspense";case $:return"SuspenseList";case V:return"Activity"}if(typeof F=="object")switch(typeof F.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),F.$$typeof){case _:return"Portal";case L:return(F.displayName||"Context")+".Provider";case P:return(F._context.displayName||"Context")+".Consumer";case B:var te=F.render;return F=F.displayName,F||(F=te.displayName||te.name||"",F=F!==""?"ForwardRef("+F+")":"ForwardRef"),F;case J:return te=F.displayName||null,te!==null?te:n(F.type)||"Memo";case K:te=F._payload,F=F._init;try{return n(F(te))}catch{}}return null}function e(F){return""+F}function t(F){try{e(F);var te=!1}catch{te=!0}if(te){te=console;var xe=te.error,Ve=typeof Symbol=="function"&&Symbol.toStringTag&&F[Symbol.toStringTag]||F.constructor.name||"Object";return xe.call(te,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",Ve),e(F)}}function r(F){if(F===w)return"<>";if(typeof F=="object"&&F!==null&&F.$$typeof===K)return"<...>";try{var te=n(F);return te?"<"+te+">":"<...>"}catch{return"<...>"}}function i(){var F=ve.A;return F===null?null:F.getOwner()}function s(){return Error("react-stack-top-frame")}function a(F){if(De.call(F,"key")){var te=Object.getOwnPropertyDescriptor(F,"key").get;if(te&&te.isReactWarning)return!1}return F.key!==void 0}function c(F,te){function xe(){Ce||(Ce=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",te))}xe.isReactWarning=!0,Object.defineProperty(F,"key",{get:xe,configurable:!0})}function u(){var F=n(this.type);return ot[F]||(ot[F]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),F=this.props.ref,F!==void 0?F:null}function d(F,te,xe,Ve,tn,Je,Nn,pi){return xe=Je.ref,F={$$typeof:g,type:F,key:te,props:Je,_owner:tn},(xe!==void 0?xe:null)!==null?Object.defineProperty(F,"ref",{enumerable:!1,get:u}):Object.defineProperty(F,"ref",{enumerable:!1,value:null}),F._store={},Object.defineProperty(F._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(F,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(F,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Nn}),Object.defineProperty(F,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:pi}),Object.freeze&&(Object.freeze(F.props),Object.freeze(F)),F}function h(F,te,xe,Ve,tn,Je,Nn,pi){var Me=te.children;if(Me!==void 0)if(Ve)if(pt(Me)){for(Ve=0;Ve<Me.length;Ve++)p(Me[Ve]);Object.freeze&&Object.freeze(Me)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else p(Me);if(De.call(te,"key")){Me=n(F);var Mt=Object.keys(te).filter(function(Pr){return Pr!=="key"});Ve=0<Mt.length?"{key: someKey, "+Mt.join(": ..., ")+": ...}":"{key: someKey}",ds[Me+Ve]||(Mt=0<Mt.length?"{"+Mt.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
19
19
  let props = %s;
20
20
  <%s {...props} />
21
21
  React keys must be passed directly to JSX without using spread:
22
22
  let props = %s;
23
- <%s key={someKey} {...props} />`,Ve,Me,Mt,Me),ds[Me+Ve]=!0)}if(Me=null,xe!==void 0&&(t(xe),Me=""+xe),a(te)&&(t(te.key),Me=""+te.key),"key"in te){xe={};for(var mi in te)mi!=="key"&&(xe[mi]=te[mi])}else xe=te;return Me&&c(xe,typeof F=="function"?F.displayName||F.name||"Unknown":F),d(F,Me,Je,tn,i(),xe,Nn,pi)}function p(F){typeof F=="object"&&F!==null&&F.$$typeof===g&&F._store&&(F._store.validated=1)}var y=q,g=Symbol.for("react.transitional.element"),_=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),L=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),J=Symbol.for("react.memo"),K=Symbol.for("react.lazy"),V=Symbol.for("react.activity"),ne=Symbol.for("react.client.reference"),ve=y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,De=Object.prototype.hasOwnProperty,pt=Array.isArray,We=console.createTask?console.createTask:function(){return null};y={"react-stack-bottom-frame":function(F){return F()}};var Ce,ot={},jt=y["react-stack-bottom-frame"].bind(y,s)(),dn=We(r(s)),ds={};Fi.Fragment=w,Fi.jsx=function(F,te,xe,Ve,tn){var Je=1e4>ve.recentlyCreatedOwnerStacks++;return h(F,te,xe,!1,Ve,tn,Je?Error("react-stack-top-frame"):jt,Je?We(r(F)):dn)},Fi.jsxs=function(F,te,xe,Ve,tn){var Je=1e4>ve.recentlyCreatedOwnerStacks++;return h(F,te,xe,!0,Ve,tn,Je?Error("react-stack-top-frame"):jt,Je?We(r(F)):dn)}}()),Fi}process.env.NODE_ENV==="production"?lc.exports=J1():lc.exports=G1();var Y=lc.exports;let si=class{open(e){window.location.href=e}reload(){window.location.reload()}getCurrentHref(){return window.location.href}getPath(){const e=window.location;return e.pathname+(e.search||"")+(e.hash||"")}getOrigin(){return window.origin}};const fh=2e3,Jr=console;let Y1=class{constructor(e,t,r,i=fh,s=!0){this._callback=e,this._client_id=t,this._url=r,this._interval=i||fh,this._stopOnError=s;const a=r.indexOf("/",r.indexOf("//")+2);this._frame_origin=r.substring(0,a),this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="absolute",this._frame.style.display="none",this._frame.width=0,this._frame.height=0,this._frame.src=r}load(){return new Promise(e=>{this._frame.onload=()=>{e()},window.document.body.appendChild(this._frame),this._boundMessageEvent=this._message.bind(this),window.addEventListener("message",this._boundMessageEvent,!1)})}_message(e){e.origin===this._frame_origin&&e.source===this._frame.contentWindow&&(e.data==="error"?(Jr.error("CheckSessionIFrame: error message from check session op iframe"),this._stopOnError&&this.stop()):e.data==="changed"?(Jr.debug(e),Jr.debug("CheckSessionIFrame: changed message from check session op iframe"),this.stop(),this._callback()):Jr.debug("CheckSessionIFrame: "+e.data+" message from check session op iframe"))}start(e){Jr.debug("CheckSessionIFrame.start :"+e),this.stop();const t=()=>{this._frame.contentWindow.postMessage(this._client_id+" "+e,this._frame_origin)};t(),this._timer=window.setInterval(t,this._interval)}stop(){this._timer&&(Jr.debug("CheckSessionIFrame.stop"),window.clearInterval(this._timer),this._timer=null)}};const ce={service_worker_not_supported_by_browser:"service_worker_not_supported_by_browser",token_acquired:"token_acquired",logout_from_another_tab:"logout_from_another_tab",logout_from_same_tab:"logout_from_same_tab",token_renewed:"token_renewed",token_timer:"token_timer",loginAsync_begin:"loginAsync_begin",loginAsync_error:"loginAsync_error",loginCallbackAsync_begin:"loginCallbackAsync_begin",loginCallbackAsync_end:"loginCallbackAsync_end",loginCallbackAsync_error:"loginCallbackAsync_error",refreshTokensAsync_begin:"refreshTokensAsync_begin",refreshTokensAsync:"refreshTokensAsync",refreshTokensAsync_end:"refreshTokensAsync_end",refreshTokensAsync_error:"refreshTokensAsync_error",refreshTokensAsync_silent_error:"refreshTokensAsync_silent_error",tryKeepExistingSessionAsync_begin:"tryKeepExistingSessionAsync_begin",tryKeepExistingSessionAsync_end:"tryKeepExistingSessionAsync_end",tryKeepExistingSessionAsync_error:"tryKeepExistingSessionAsync_error",silentLoginAsync_begin:"silentLoginAsync_begin",silentLoginAsync:"silentLoginAsync",silentLoginAsync_end:"silentLoginAsync_end",silentLoginAsync_error:"silentLoginAsync_error",syncTokensAsync_begin:"syncTokensAsync_begin",syncTokensAsync_lock_not_available:"syncTokensAsync_lock_not_available",syncTokensAsync_end:"syncTokensAsync_end",syncTokensAsync_error:"syncTokensAsync_error",tokensInvalidAndWaitingActionsToRefresh:"tokensInvalidAndWaitingActionsToRefresh"},Vt=(n,e=sessionStorage)=>{const t=w=>(e[`oidc.${n}`]=JSON.stringify({tokens:null,status:w}),Promise.resolve()),r=async()=>{if(!e[`oidc.${n}`])return e[`oidc.${n}`]=JSON.stringify({tokens:null,status:null}),{tokens:null,status:null};const w=JSON.parse(e[`oidc.${n}`]);return Promise.resolve({tokens:w.tokens,status:w.status})},i=w=>{e[`oidc.${n}`]=JSON.stringify({tokens:w})},s=async w=>{e[`oidc.session_state.${n}`]=w},a=async()=>e[`oidc.session_state.${n}`],c=w=>{e[`oidc.nonce.${n}`]=w.nonce},u=w=>{e[`oidc.jwk.${n}`]=JSON.stringify(w)},d=()=>JSON.parse(e[`oidc.jwk.${n}`]),h=async()=>({nonce:e[`oidc.nonce.${n}`]}),p=async w=>{e[`oidc.dpop_nonce.${n}`]=w},y=()=>e[`oidc.dpop_nonce.${n}`],g=()=>e[`oidc.${n}`]?JSON.stringify({tokens:JSON.parse(e[`oidc.${n}`]).tokens}):null,_={};return{clearAsync:t,initAsync:r,setTokens:i,getTokens:g,setSessionStateAsync:s,getSessionStateAsync:a,setNonceAsync:c,getNonceAsync:h,setLoginParams:w=>{_[n]=w,e[`oidc.login.${n}`]=JSON.stringify(w)},getLoginParams:()=>{const w=e[`oidc.login.${n}`];return w?(_[n]||(_[n]=JSON.parse(w)),_[n]):(console.warn(`storage[oidc.login.${n}] is empty, you should have an bad OIDC or code configuration somewhere.`),null)},getStateAsync:async()=>e[`oidc.state.${n}`],setStateAsync:async w=>{e[`oidc.state.${n}`]=w},getCodeVerifierAsync:async()=>e[`oidc.code_verifier.${n}`],setCodeVerifierAsync:async w=>{e[`oidc.code_verifier.${n}`]=w},setDemonstratingProofOfPossessionNonce:p,getDemonstratingProofOfPossessionNonce:y,setDemonstratingProofOfPossessionJwkAsync:u,getDemonstratingProofOfPossessionJwkAsync:d}};var Yi=(n=>(n.AutomaticBeforeTokenExpiration="AutomaticBeforeTokensExpiration",n.AutomaticOnlyWhenFetchExecuted="AutomaticOnlyWhenFetchExecuted",n))(Yi||{});const Q1=n=>decodeURIComponent(Array.prototype.map.call(atob(n),e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")),X1=n=>JSON.parse(Q1(n.replaceAll(/-/g,"+").replaceAll(/_/g,"/"))),dh=n=>{try{return n&&Z1(n,".")===2?X1(n.split(".")[1]):null}catch(e){console.warn(e)}return null},Z1=(n,e)=>n.split(e).length-1,cc={access_token_or_id_token_invalid:"access_token_or_id_token_invalid",access_token_invalid:"access_token_invalid",id_token_invalid:"id_token_invalid"};function ex(n,e,t){if(n.issuedAt){if(typeof n.issuedAt=="string")return parseInt(n.issuedAt,10)}else return e&&e.iat?e.iat:t&&t.iat?t.iat:new Date().getTime()/1e3;return n.issuedAt}const Vc=(n,e=null,t)=>{if(!n)return null;let r;const i=typeof n.expiresIn=="string"?parseInt(n.expiresIn,10):n.expiresIn;n.accessTokenPayload!==void 0?r=n.accessTokenPayload:r=dh(n.accessToken);let s;e!=null&&"idToken"in e&&!("idToken"in n)?s=e.idToken:s=n.idToken;const a=n.idTokenPayload?n.idTokenPayload:dh(s),c=a&&a.exp?a.exp:Number.MAX_VALUE,u=r&&r.exp?r.exp:n.issuedAt+i;n.issuedAt=ex(n,r,a);let d;n.expiresAt?d=n.expiresAt:t===cc.access_token_invalid?d=u:t===cc.id_token_invalid?d=c:d=c<u?c:u;const h={...n,idTokenPayload:a,accessTokenPayload:r,expiresAt:d,idToken:s};if(e!=null&&"refreshToken"in e&&!("refreshToken"in n)){const p=e.refreshToken;return{...h,refreshToken:p}}return h},Hc=(n,e,t)=>{if(!n)return null;if(!n.issued_at){const i=new Date().getTime()/1e3;n.issued_at=i}const r={accessToken:n.access_token,expiresIn:n.expires_in,idToken:n.id_token,scope:n.scope,tokenType:n.token_type,issuedAt:n.issued_at};return"refresh_token"in n&&(r.refreshToken=n.refresh_token),n.accessTokenPayload!==void 0&&(r.accessTokenPayload=n.accessTokenPayload),n.idTokenPayload!==void 0&&(r.idTokenPayload=n.idTokenPayload),Vc(r,e,t)},ji=(n,e)=>{const t=new Date().getTime()/1e3,r=e-t;return Math.round(r-n)},hh=(n,e=0)=>n?ji(e,n.expiresAt)>0:!1,om=async(n,e=200,t=50)=>{let r=t;if(!n.getTokens())return null;for(;!hh(n.getTokens(),n.configuration.refresh_time_before_tokens_expiration_in_second)&&r>0;){if(n.configuration.token_automatic_renew_mode==Yi.AutomaticOnlyWhenFetchExecuted){await n.renewTokensAsync({});break}else await zo({milliseconds:e});r=r-1}return{isTokensValid:hh(n.getTokens()),tokens:n.getTokens(),numberWaited:r-t}},am=(n,e,t)=>{if(n.idTokenPayload){const r=n.idTokenPayload;if(t.issuer!==r.iss)return{isValid:!1,reason:`Issuer does not match (oidcServerConfiguration issuer) ${t.issuer} !== (idTokenPayload issuer) ${r.iss}`};const i=new Date().getTime()/1e3;if(r.exp&&r.exp<i)return{isValid:!1,reason:`Token expired (idTokenPayload exp) ${r.exp} < (currentTimeUnixSecond) ${i}`};const s=60*60*24*7;if(r.iat&&r.iat+s<i)return{isValid:!1,reason:`Token is used from too long time (idTokenPayload iat + timeInSevenDays) ${r.iat+s} < (currentTimeUnixSecond) ${i}`};if(r.nonce&&r.nonce!==e)return{isValid:!1,reason:`Nonce does not match (idTokenPayload nonce) ${r.nonce} !== (nonce) ${e}`}}return{isValid:!0,reason:""}},oi=function(){const n=typeof window>"u"?global:window;return{setTimeout:setTimeout.bind(n),clearTimeout:clearTimeout.bind(n),setInterval:setInterval.bind(n),clearInterval:clearInterval.bind(n)}}(),ph="7.25.7";let mh=null,wo;const zo=({milliseconds:n})=>new Promise(e=>oi.setTimeout(e,n)),lm=(n="/")=>{try{wo=new AbortController,fetch(`${n}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`,{signal:wo.signal}).catch(e=>{console.log(e)}),zo({milliseconds:150*1e3}).then(lm)}catch(e){console.log(e)}},gh=()=>{wo&&wo.abort()},tx=(n="/")=>fetch(`${n}OidcKeepAliveServiceWorker.json`,{headers:{"oidc-vanilla":"true"}}).then(e=>e.statusText==="oidc-service-worker").catch(e=>{console.log(e)}),nx=n=>async(e,t)=>{t(),await e.update();const r=await e.unregister();console.log(`Service worker unregistration ${r?"successful":"failed"}`),await zo({milliseconds:2e3}),n.reload()},cm=n=>{const e=sessionStorage.getItem(`oidc.tabId.${n}`);if(e)return e;const t=globalThis.crypto.randomUUID();return sessionStorage.setItem(`oidc.tabId.${n}`,t),t},ut=n=>e=>new Promise(function(t,r){const i=new MessageChannel;i.port1.onmessage=function(s){s!=null&&s.data.error?r(s.data.error):t(s.data),i.port1.close(),i.port2.close()},n.active.postMessage({...e,tabId:cm(e.configurationName)},[i.port2])}),Ht=async(n,e)=>{var t;const r=n.service_worker_relative_url;if(typeof window>"u"||typeof navigator>"u"||!navigator.serviceWorker||!r||n.service_worker_activate()===!1)return null;let i=null;n.service_worker_register?i=await n.service_worker_register(r):(i=await navigator.serviceWorker.register(r),i.active&&i.waiting&&(console.log("Detected new service worker waiting, unregistering and reloading"),await((t=n.service_worker_update_require_callback)==null?void 0:t.call(n,i,gh))));try{await navigator.serviceWorker.ready,navigator.serviceWorker.controller||await ut(i)({type:"claim"})}catch(g){return console.warn(`Failed init ServiceWorker ${g.toString()}`),null}const s=async g=>ut(i)({type:"clear",data:{status:g},configurationName:e}),a=async(g,_,w)=>{var k;const A=await ut(i)({type:"init",data:{oidcServerConfiguration:g,where:_,oidcConfiguration:{token_renew_mode:w.token_renew_mode,service_worker_convert_all_requests_to_cors:w.service_worker_convert_all_requests_to_cors}},configurationName:e}),P=A.version;return P!==ph&&(console.warn(`Service worker ${P} version mismatch with js client version ${ph}, unregistering and reloading`),await((k=w.service_worker_update_require_callback)==null?void 0:k.call(w,i,gh))),{tokens:Hc(A.tokens,null,w.token_renew_mode),status:A.status}},c=(g="/")=>{mh==null&&(mh="not_null",lm(g))},u=g=>ut(i)({type:"setSessionState",data:{sessionState:g},configurationName:e}),d=async()=>(await ut(i)({type:"getSessionState",data:null,configurationName:e})).sessionState,h=g=>(sessionStorage[`oidc.nonce.${e}`]=g.nonce,ut(i)({type:"setNonce",data:{nonce:g},configurationName:e})),p=async()=>{let g=(await ut(i)({type:"getNonce",data:null,configurationName:e})).nonce;return g||(g=sessionStorage[`oidc.nonce.${e}`],console.warn("nonce not found in service worker, using sessionStorage")),{nonce:g}},y={};return{clearAsync:s,initAsync:a,startKeepAliveServiceWorker:()=>c(n.service_worker_keep_alive_path),isServiceWorkerProxyActiveAsync:()=>tx(n.service_worker_keep_alive_path),setSessionStateAsync:u,getSessionStateAsync:d,setNonceAsync:h,getNonceAsync:p,setLoginParams:g=>{y[e]=g,localStorage[`oidc.login.${e}`]=JSON.stringify(g)},getLoginParams:()=>{const g=localStorage[`oidc.login.${e}`];return y[e]||(y[e]=JSON.parse(g)),y[e]},getStateAsync:async()=>{let g=(await ut(i)({type:"getState",data:null,configurationName:e})).state;return g||(g=sessionStorage[`oidc.state.${e}`],console.warn("state not found in service worker, using sessionStorage")),g},setStateAsync:async g=>(sessionStorage[`oidc.state.${e}`]=g,ut(i)({type:"setState",data:{state:g},configurationName:e})),getCodeVerifierAsync:async()=>{let g=(await ut(i)({type:"getCodeVerifier",data:null,configurationName:e})).codeVerifier;return g||(g=sessionStorage[`oidc.code_verifier.${e}`],console.warn("codeVerifier not found in service worker, using sessionStorage")),g},setCodeVerifierAsync:async g=>(sessionStorage[`oidc.code_verifier.${e}`]=g,ut(i)({type:"setCodeVerifier",data:{codeVerifier:g},configurationName:e})),setDemonstratingProofOfPossessionNonce:async g=>{await ut(i)({type:"setDemonstratingProofOfPossessionNonce",data:{demonstratingProofOfPossessionNonce:g},configurationName:e})},getDemonstratingProofOfPossessionNonce:async()=>(await ut(i)({type:"getDemonstratingProofOfPossessionNonce",data:null,configurationName:e})).demonstratingProofOfPossessionNonce,setDemonstratingProofOfPossessionJwkAsync:async g=>{const _=JSON.stringify(g);await ut(i)({type:"setDemonstratingProofOfPossessionJwk",data:{demonstratingProofOfPossessionJwkJson:_},configurationName:e})},getDemonstratingProofOfPossessionJwkAsync:async()=>{const g=await ut(i)({type:"getDemonstratingProofOfPossessionJwk",data:null,configurationName:e});return g.demonstratingProofOfPossessionJwkJson?JSON.parse(g.demonstratingProofOfPossessionJwkJson):null}}},Qr={},rx=(n,e=window.sessionStorage,t)=>{if(!Qr[n]&&e){const i=e.getItem(n);i&&(Qr[n]=JSON.parse(i))}const r=1e3*t;return Qr[n]&&Qr[n].timestamp+r>Date.now()?Qr[n].result:null},ix=(n,e,t=window.sessionStorage)=>{const r=Date.now();Qr[n]={result:e,timestamp:r},t&&t.setItem(n,JSON.stringify({result:e,timestamp:r}))};function um(n){return new TextEncoder().encode(n)}function fm(n){return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function sx(n){return encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode(parseInt(t,16))})}const Uc=n=>{let e="";return n.forEach(function(t){e+=String.fromCharCode(t)}),fm(e)};function yh(n){return fm(sx(n))}const ox={importKeyAlgorithm:{name:"ECDSA",namedCurve:"P-256",hash:{name:"ES256"}},signAlgorithm:{name:"ECDSA",hash:{name:"SHA-256"}},generateKeyAlgorithm:{name:"ECDSA",namedCurve:"P-256"},digestAlgorithm:{name:"SHA-256"},jwtHeaderAlgorithm:"ES256"},ax=n=>async(e,t,r,i,s="dpop+jwt")=>{switch(e=Object.assign({},e),t.typ=s,t.alg=i.jwtHeaderAlgorithm,t.alg){case"ES256":t.jwk={kty:e.kty,crv:e.crv,x:e.x,y:e.y};break;case"RS256":t.jwk={kty:e.kty,n:e.n,e:e.e,kid:t.kid};break;default:throw new Error("Unknown or not implemented JWS algorithm")}const a={protected:yh(JSON.stringify(t)),payload:yh(JSON.stringify(r))},c=i.importKeyAlgorithm,u=!0,d=["sign"],h=await n.crypto.subtle.importKey("jwk",e,c,u,d),p=um(`${a.protected}.${a.payload}`),y=i.signAlgorithm,g=await n.crypto.subtle.sign(y,h,p);return a.signature=Uc(new Uint8Array(g)),`${a.protected}.${a.payload}.${a.signature}`},lx={sign:ax},cx=n=>async e=>{const t=e,r=!0,i=["sign","verify"],s=await n.crypto.subtle.generateKey(t,r,i);return await n.crypto.subtle.exportKey("jwk",s.privateKey)},ux=n=>{const e=Object.assign({},n);return delete e.d,e.key_ops=["verify"],e},fx={generate:cx,neuter:ux},dx=n=>async(e,t)=>{let r;switch(e.kty){case"EC":r='{"crv":"CRV","kty":"EC","x":"X","y":"Y"}'.replace("CRV",e.crv).replace("X",e.x).replace("Y",e.y);break;case"RSA":r='{"e":"E","kty":"RSA","n":"N"}'.replace("E",e.e).replace("N",e.n);break;default:throw new Error("Unknown or not implemented JWK type")}const i=await n.crypto.subtle.digest(t,um(r));return Uc(new Uint8Array(i))},hx={thumbprint:dx},px=n=>async e=>await fx.generate(n)(e),dm=n=>e=>async(t,r="POST",i,s={})=>{const a={jti:btoa(mx()),htm:r,htu:i,iat:Math.round(Date.now()/1e3),...s},c=await hx.thumbprint(n)(t,e.digestAlgorithm);return await lx.sign(n)(t,{kid:c},a,e)},mx=()=>{const n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",e="0123456789abcdef";let t=0,r="";for(let i=0;i<36;i++)n[i]!=="-"&&n[i]!=="4"&&(t=Math.random()*16|0),n[i]==="x"?r+=e[t]:n[i]==="y"?(t&=3,t|=8,r+=e[t]):r+=n[i];return r},hm=()=>{const n=typeof window<"u"&&!!window.crypto,e=n&&!!window.crypto.subtle;return{hasCrypto:n,hasSubtleCrypto:e}},uc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",gx=n=>{const e=[];for(let t=0;t<n.byteLength;t+=1){const r=n[t]%uc.length;e.push(uc[r])}return e.join("")},fc=n=>{const e=new Uint8Array(n),{hasCrypto:t}=hm();if(t)window.crypto.getRandomValues(e);else for(let r=0;r<n;r+=1)e[r]=Math.random()*uc.length|0;return gx(e)};function yx(n){const e=new ArrayBuffer(n.length),t=new Uint8Array(e);for(let r=0;r<n.length;r++)t[r]=n.charCodeAt(r);return t}function pm(n){return new Promise((e,t)=>{crypto.subtle.digest("SHA-256",yx(n)).then(r=>e(Uc(new Uint8Array(r))),r=>t(r))})}const _x=n=>{if(n.length<43||n.length>128)return Promise.reject(new Error("Invalid code length."));const{hasSubtleCrypto:e}=hm();return e?pm(n):Promise.reject(new Error("window.crypto.subtle is unavailable."))},bx=60*60,vx=n=>async(e,t=bx,r=window.sessionStorage,i=1e4)=>{const s=`${e}/.well-known/openid-configuration`,a=`oidc.server:${e}`,c=rx(a,r,t);if(c)return new hc(c);const u=await ls(n)(s,{},i);if(u.status!==200)return null;const d=await u.json();return ix(a,d,r),new hc(d)},ls=n=>async(e,t={},r=1e4,i=0)=>{let s;try{const a=new AbortController;setTimeout(()=>a.abort(),r),s=await n(e,{...t,signal:a.signal})}catch(a){if(a.name==="AbortError"||a.message==="Network request failed"){if(i<=1)return await ls(n)(e,t,r,i+1);throw a}else throw console.error(a.message),a}return s},dc={refresh_token:"refresh_token",access_token:"access_token"},_h=n=>async(e,t,r=dc.refresh_token,i,s={},a=1e4)=>{const c={token:t,token_type_hint:r,client_id:i};for(const[h,p]of Object.entries(s))c[h]===void 0&&(c[h]=p);const u=[];for(const h in c){const p=encodeURIComponent(h),y=encodeURIComponent(c[h]);u.push(`${p}=${y}`)}const d=u.join("&");return(await ls(n)(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"},body:d},a)).status!==200?{success:!1}:{success:!0}},Sx=n=>async(e,t,r,i,s={},a,c=1e4)=>{for(const[g,_]of Object.entries(r))t[g]===void 0&&(t[g]=_);const u=[];for(const g in t){const _=encodeURIComponent(g),w=encodeURIComponent(t[g]);u.push(`${_}=${w}`)}const d=u.join("&"),h=await ls(n)(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8",...s},body:d},c);if(h.status!==200)return{success:!1,status:h.status,demonstratingProofOfPossessionNonce:null};const p=await h.json();let y=null;return h.headers.has(ko)&&(y=h.headers.get(ko)),{success:!0,status:h.status,data:Hc(p,i,a),demonstratingProofOfPossessionNonce:y}},wx=(n,e)=>async(t,r)=>{r=r?{...r}:{};const i=fc(128),s=await _x(i);await n.setCodeVerifierAsync(i),await n.setStateAsync(r.state),r.code_challenge=s,r.code_challenge_method="S256";let a="";if(r)for(const[c,u]of Object.entries(r))a===""?a+="?":a+="&",a+=`${c}=${encodeURIComponent(u)}`;e.open(`${t}${a}`)},ko="DPoP-Nonce",kx=n=>async(e,t,r,i,s=1e4)=>{t=t?{...t}:{},t.code_verifier=await n.getCodeVerifierAsync();const a=[];for(const p in t){const y=encodeURIComponent(p),g=encodeURIComponent(t[p]);a.push(`${y}=${g}`)}const c=a.join("&"),u=await ls(fetch)(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8",...r},body:c},s);if(await Promise.all([n.setCodeVerifierAsync(null),n.setStateAsync(null)]),u.status!==200)return{success:!1,status:u.status};let d=null;u.headers.has(ko)&&(d=u.headers.get(ko));const h=await u.json();return{success:!0,data:{state:t.state,tokens:Hc(h,null,i),demonstratingProofOfPossessionNonce:d}}};async function bh(n,e,t,r=null){const i=c=>{n.tokens=c},{tokens:s,status:a}=await po(n)(i,0,e,t,r);return await Ht(n.configuration,n.configurationName)||await Vt(n.configurationName,n.configuration.storage).setTokens(n.tokens),n.tokens?s:(await n.destroyAsync(a),null)}async function mm(n,e=!1,t=null,r=null){const i=n.configuration,s=`${i.client_id}_${n.configurationName}_${i.authority}`;let a;const c=await Ht(n.configuration,n.configurationName);if((i==null?void 0:i.storage)===(window==null?void 0:window.sessionStorage)&&!c||!navigator.locks)a=await bh(n,e,t,r);else{let u="retry";for(;u==="retry";)u=await navigator.locks.request(s,{ifAvailable:!0},async d=>d?await bh(n,e,t,r):(n.publishEvent(An.eventNames.syncTokensAsync_lock_not_available,{lock:"lock not available"}),"retry"));a=u}return a?(n.timeoutId&&(n.timeoutId=Qi(n,n.tokens.expiresAt,t,r)),n.tokens):null}const Qi=(n,e,t=null,r=null)=>{const i=n.configuration.refresh_time_before_tokens_expiration_in_second;return n.timeoutId&&oi.clearTimeout(n.timeoutId),oi.setTimeout(async()=>{const s={timeLeft:ji(i,e)};n.publishEvent(An.eventNames.token_timer,s),await mm(n,!1,t,r)},1e3)},Wn={FORCE_REFRESH:"FORCE_REFRESH",SESSION_LOST:"SESSION_LOST",NOT_CONNECTED:"NOT_CONNECTED",TOKENS_VALID:"TOKENS_VALID",TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID:"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID",LOGOUT_FROM_ANOTHER_TAB:"LOGOUT_FROM_ANOTHER_TAB",REQUIRE_SYNC_TOKENS:"REQUIRE_SYNC_TOKENS"},xx=n=>async(e,t,r,i=!1)=>{const s={nonce:null};if(!r)return{tokens:null,status:"NOT_CONNECTED",nonce:s};let a=s;const c=await n.initAsync(e.authority,e.authority_configuration),u=await Ht(e,t);if(u){const{status:h,tokens:p}=await u.initAsync(c,"syncTokensAsync",e);if(h==="LOGGED_OUT")return{tokens:null,status:"LOGOUT_FROM_ANOTHER_TAB",nonce:s};if(h==="SESSIONS_LOST")return{tokens:null,status:"SESSIONS_LOST",nonce:s};if(!h||!p)return{tokens:null,status:"REQUIRE_SYNC_TOKENS",nonce:s};if(p.issuedAt!==r.issuedAt){const y=ji(e.refresh_time_before_tokens_expiration_in_second,p.expiresAt)>0?"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID":"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID",g=await u.getNonceAsync();return{tokens:p,status:y,nonce:g}}a=await u.getNonceAsync()}else{const h=Vt(t,e.storage??sessionStorage),p=await h.initAsync();let{tokens:y}=p;const{status:g}=p;if(y&&(y=Vc(y,n.tokens,e.token_renew_mode)),y){if(g==="SESSIONS_LOST")return{tokens:null,status:"SESSIONS_LOST",nonce:s};if(y.issuedAt!==r.issuedAt){const _=ji(e.refresh_time_before_tokens_expiration_in_second,y.expiresAt)>0?"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID":"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID",w=await h.getNonceAsync();return{tokens:y,status:_,nonce:w}}}else return{tokens:null,status:"LOGOUT_FROM_ANOTHER_TAB",nonce:s};a=await h.getNonceAsync()}const d=ji(e.refresh_time_before_tokens_expiration_in_second,r.expiresAt)>0?"TOKENS_VALID":"TOKENS_INVALID";return i?{tokens:r,status:"FORCE_REFRESH",nonce:a}:{tokens:r,status:d,nonce:a}},po=n=>async(e,t=0,r=!1,i=null,s=null)=>{if(!navigator.onLine&&document.hidden)return{tokens:n.tokens,status:"GIVE_UP"};let a=6;for(;!navigator.onLine&&a>0;)await zo({milliseconds:1e3}),a--,n.publishEvent(ce.refreshTokensAsync,{message:`wait because navigator is offline try ${a}`});const c=document.hidden,u=c?t:t+1;if(t>4)return c?{tokens:n.tokens,status:"GIVE_UP"}:(e(null),n.publishEvent(ce.refreshTokensAsync_error,{message:"refresh token"}),{tokens:null,status:"SESSION_LOST"});i||(i={});const d=n.configuration,h=(y,g=null,_=null)=>Kc(n.configurationName,n.configuration,n.publishEvent.bind(n))(y,g,_),p=async()=>{try{let y;const g=await Ht(d,n.configurationName);g?y=g.getLoginParams():y=Vt(n.configurationName,d.storage).getLoginParams();const _=await h({...y.extras,...i,prompt:"none",scope:s});return _?_.error?(e(null),n.publishEvent(ce.refreshTokensAsync_error,{message:"refresh token silent"}),{tokens:null,status:"SESSION_LOST"}):(e(_.tokens),n.publishEvent(An.eventNames.token_renewed,{}),{tokens:_.tokens,status:"LOGGED"}):(e(null),n.publishEvent(ce.refreshTokensAsync_error,{message:"refresh token silent not active"}),{tokens:null,status:"SESSION_LOST"})}catch(y){return console.error(y),n.publishEvent(ce.refreshTokensAsync_silent_error,{message:"exceptionSilent",exception:y.message}),await po(n)(e,u,r,i,s)}};try{const{status:y,tokens:g,nonce:_}=await xx(n)(d,n.configurationName,n.tokens,r);switch(y){case Wn.SESSION_LOST:return e(null),n.publishEvent(ce.refreshTokensAsync_error,{message:"refresh token session lost"}),{tokens:null,status:"SESSION_LOST"};case Wn.NOT_CONNECTED:return e(null),{tokens:null,status:null};case Wn.TOKENS_VALID:return e(g),{tokens:g,status:"LOGGED_IN"};case Wn.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID:return e(g),n.publishEvent(An.eventNames.token_renewed,{reason:"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID"}),{tokens:g,status:"LOGGED_IN"};case Wn.LOGOUT_FROM_ANOTHER_TAB:return e(null),n.publishEvent(ce.logout_from_another_tab,{status:"session syncTokensAsync"}),{tokens:null,status:"LOGGED_OUT"};case Wn.REQUIRE_SYNC_TOKENS:return d.token_automatic_renew_mode==Yi.AutomaticOnlyWhenFetchExecuted&&Wn.FORCE_REFRESH!==y?(n.publishEvent(ce.tokensInvalidAndWaitingActionsToRefresh,{}),{tokens:n.tokens,status:"GIVE_UP"}):(n.publishEvent(ce.refreshTokensAsync_begin,{tryNumber:t}),await p());default:{if(d.token_automatic_renew_mode==Yi.AutomaticOnlyWhenFetchExecuted&&Wn.FORCE_REFRESH!==y)return n.publishEvent(ce.tokensInvalidAndWaitingActionsToRefresh,{}),{tokens:n.tokens,status:"GIVE_UP"};if(n.publishEvent(ce.refreshTokensAsync_begin,{refreshToken:g.refreshToken,status:y,tryNumber:t}),!g.refreshToken)return await p();const w=d.client_id,k=d.redirect_uri,A=d.authority,P={...d.token_request_extras?d.token_request_extras:{}};for(const[L,B]of Object.entries(i))L.endsWith(":token_request")&&(P[L.replace(":token_request","")]=B);return await(async()=>{const L={client_id:w,redirect_uri:k,grant_type:"refresh_token",refresh_token:g.refreshToken},B=await n.initAsync(A,d.authority_configuration),z=document.hidden?1e4:3e4*10,$=B.tokenEndpoint,J={};d.demonstrating_proof_of_possession&&(J.DPoP=await n.generateDemonstrationOfProofOfPossessionAsync(g.accessToken,$,"POST"));const K=await Sx(n.getFetch())($,L,P,g,J,d.token_renew_mode,z);if(K.success){const{isValid:V,reason:ne}=am(K.data,_.nonce,B);if(!V)return e(null),n.publishEvent(ce.refreshTokensAsync_error,{message:`refresh token return not valid tokens, reason: ${ne}`}),{tokens:null,status:"SESSION_LOST"};if(e(K.data),K.demonstratingProofOfPossessionNonce){const ve=await Ht(d,n.configurationName);ve?await ve.setDemonstratingProofOfPossessionNonce(K.demonstratingProofOfPossessionNonce):await Vt(n.configurationName,d.storage).setDemonstratingProofOfPossessionNonce(K.demonstratingProofOfPossessionNonce)}return n.publishEvent(ce.refreshTokensAsync_end,{success:K.success}),n.publishEvent(An.eventNames.token_renewed,{reason:"REFRESH_TOKEN"}),{tokens:K.data,status:"LOGGED_IN"}}else return n.publishEvent(ce.refreshTokensAsync_silent_error,{message:"bad request",tokenResponse:K}),K.status>=400&&K.status<500?(e(null),n.publishEvent(ce.refreshTokensAsync_error,{message:`session lost: ${K.status}`}),{tokens:null,status:"SESSION_LOST"}):await po(n)(e,u,r,i,s)})()}}}catch(y){return console.error(y),n.publishEvent(ce.refreshTokensAsync_silent_error,{message:"exception",exception:y.message}),new Promise((g,_)=>{setTimeout(()=>{po(n)(e,u,r,i,s).then(g).catch(_)},1e3)})}},Kc=(n,e,t)=>(r=null,i=null,s=null)=>{if(!e.silent_redirect_uri||!e.silent_login_uri)return Promise.resolve(null);try{t(ce.silentLoginAsync_begin,{});let a="";if(i&&(r==null&&(r={}),r.state=i),s!=null&&(r==null&&(r={}),r.scope=s),r!=null)for(const[p,y]of Object.entries(r))a===""?a=`?${encodeURIComponent(p)}=${encodeURIComponent(y)}`:a+=`&${encodeURIComponent(p)}=${encodeURIComponent(y)}`;const c=e.silent_login_uri+a,u=c.indexOf("/",c.indexOf("//")+2),d=c.substring(0,u),h=document.createElement("iframe");return h.width="0px",h.height="0px",h.id=`${n}_oidc_iframe`,h.setAttribute("src",c),document.body.appendChild(h),new Promise((p,y)=>{let g=!1;const _=()=>{window.removeEventListener("message",w),h.remove(),g=!0},w=k=>{if(k.origin===d&&k.source===h.contentWindow){const A=`${n}_oidc_tokens:`,P=`${n}_oidc_error:`,L=`${n}_oidc_exception:`,B=k.data;if(B&&typeof B=="string"&&!g){if(B.startsWith(A)){const z=JSON.parse(k.data.replace(A,""));t(ce.silentLoginAsync_end,{}),p(z),_()}else if(B.startsWith(P)){const z=JSON.parse(k.data.replace(P,""));t(ce.silentLoginAsync_error,z),p({error:"oidc_"+z.error,tokens:null,sessionState:null}),_()}else if(B.startsWith(L)){const z=JSON.parse(k.data.replace(L,""));t(ce.silentLoginAsync_error,z),y(new Error(z.error)),_()}}}};try{window.addEventListener("message",w);const k=e.silent_login_timeout;setTimeout(()=>{g||(_(),t(ce.silentLoginAsync_error,{reason:"timeout"}),y(new Error("timeout")))},k)}catch(k){_(),t(ce.silentLoginAsync_error,k),y(k)}})}catch(a){throw t(ce.silentLoginAsync_error,a),a}},Ex=(n,e,t,r,i)=>(s=null,a=void 0)=>{s={...s};const c=(u,d,h)=>Kc(e,t,r.bind(i))(u,d,h);return(async()=>{i.timeoutId&&oi.clearTimeout(i.timeoutId);let u;s&&"state"in s&&(u=s.state,delete s.state);try{const d=t.extras?{...t.extras,...s}:s,h=await c({...d,prompt:"none"},u,a);if(h)return i.tokens=h.tokens,r(ce.token_acquired,{}),i.timeoutId=Qi(i,i.tokens.expiresAt,s,a),{}}catch(d){return d}})()},Ox=(n,e,t)=>(r,i,s,a=!1)=>{const c=(u,d=void 0,h=void 0)=>Kc(n.configurationName,t,n.publishEvent.bind(n))(u,d,h);return new Promise((u,d)=>{if(t.silent_login_uri&&t.silent_redirect_uri&&t.monitor_session&&r&&s&&!a){const h=()=>{n.checkSessionIFrame.stop();const p=n.tokens;if(p===null)return;const y=p.idToken,g=p.idTokenPayload;return c({prompt:"none",id_token_hint:y,scope:t.scope||"openid"}).then(_=>{if(_.error)throw new Error(_.error);const w=_.tokens.idTokenPayload;if(g.sub===w.sub){const k=_.sessionState;n.checkSessionIFrame.start(_.sessionState),g.sid===w.sid?console.debug("SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:",k):console.debug("SessionMonitor._callback: Same sub still logged in at OP, session state has changed, restarting check session iframe; session_state:",k)}else console.debug("SessionMonitor._callback: Different subject signed into OP:",w.sub)}).catch(async _=>{console.warn("SessionMonitor._callback: Silent login failed, logging out other tabs:",_);for(const[,w]of Object.entries(e))await w.logoutOtherTabAsync(t.client_id,g.sub)})};n.checkSessionIFrame=new Y1(h,i,r),n.checkSessionIFrame.load().then(()=>{n.checkSessionIFrame.start(s),u(n.checkSessionIFrame)}).catch(p=>{d(p)})}else u(null)})},Tx=n=>!!(n.os==="iOS"&&n.osVersion.startsWith("12")||n.os==="Mac OS X"&&n.osVersion.startsWith("10_15_6")),Ax=n=>{const e=n.appVersion,t=n.userAgent,r="-";let i=r;const s=[{s:"Windows 10",r:/(Windows 10.0|Windows NT 10.0)/},{s:"Windows 8.1",r:/(Windows 8.1|Windows NT 6.3)/},{s:"Windows 8",r:/(Windows 8|Windows NT 6.2)/},{s:"Windows 7",r:/(Windows 7|Windows NT 6.1)/},{s:"Windows Vista",r:/Windows NT 6.0/},{s:"Windows Server 2003",r:/Windows NT 5.2/},{s:"Windows XP",r:/(Windows NT 5.1|Windows XP)/},{s:"Windows 2000",r:/(Windows NT 5.0|Windows 2000)/},{s:"Windows ME",r:/(Win 9x 4.90|Windows ME)/},{s:"Windows 98",r:/(Windows 98|Win98)/},{s:"Windows 95",r:/(Windows 95|Win95|Windows_95)/},{s:"Windows NT 4.0",r:/(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/},{s:"Windows CE",r:/Windows CE/},{s:"Windows 3.11",r:/Win16/},{s:"Android",r:/Android/},{s:"Open BSD",r:/OpenBSD/},{s:"Sun OS",r:/SunOS/},{s:"Chrome OS",r:/CrOS/},{s:"Linux",r:/(Linux|X11(?!.*CrOS))/},{s:"iOS",r:/(iPhone|iPad|iPod)/},{s:"Mac OS X",r:/Mac OS X/},{s:"Mac OS",r:/(Mac OS|MacPPC|MacIntel|Mac_PowerPC|Macintosh)/},{s:"QNX",r:/QNX/},{s:"UNIX",r:/UNIX/},{s:"BeOS",r:/BeOS/},{s:"OS/2",r:/OS\/2/},{s:"Search Bot",r:/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/}];for(const c in s){const u=s[c];if(u.r.test(t)){i=u.s;break}}let a=r;switch(/Windows/.test(i)&&(a=/Windows (.*)/.exec(i)[1],i="Windows"),i){case"Mac OS":case"Mac OS X":case"Android":a=/(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([._\d]+)/.exec(t)[1];break;case"iOS":{const c=/OS (\d+)_(\d+)_?(\d+)?/.exec(e);c!=null&&c.length>2&&(a=c[1]+"."+c[2]+"."+(parseInt(c[3])|0));break}}return{os:i,osVersion:a}};function Cx(){const n=navigator.userAgent;let e,t=n.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];if(/trident/i.test(t[1]))return e=/\brv[ :]+(\d+)/g.exec(n)||[],{name:"ie",version:e[1]||""};if(t[1]==="Chrome"&&(e=n.match(/\bOPR|Edge\/(\d+)/),e!=null)){let r=e[1];if(!r){const i=n.split(e[0]+"/");i.length>1&&(r=i[1])}return{name:"opera",version:r}}return t=t[2]?[t[1],t[2]]:[navigator.appName,navigator.appVersion,"-?"],(e=n.match(/version\/(\d+)/i))!=null&&t.splice(1,1,e[1]),{name:t[0].toLowerCase(),version:t[1]}}const Mx=()=>{const{name:n,version:e}=Cx();if(n==="chrome"&&parseInt(e)<=70||n==="opera"&&(!e||parseInt(e.split(".")[0])<80)||n==="ie")return!1;const t=Ax(navigator);return!Tx(t)},Nx=async n=>{let e;if(n.tokens!=null)return!1;n.publishEvent(ce.tryKeepExistingSessionAsync_begin,{});try{const t=n.configuration,r=await n.initAsync(t.authority,t.authority_configuration);if(e=await Ht(t,n.configurationName),e){const{tokens:i}=await e.initAsync(r,"tryKeepExistingSessionAsync",t);if(i){e.startKeepAliveServiceWorker(),n.tokens=i;const s=e.getLoginParams(n.configurationName);n.timeoutId=Qi(n,n.tokens.expiresAt,s.extras,s.scope);const a=await e.getSessionStateAsync();return await n.startCheckSessionAsync(r.checkSessionIframe,t.client_id,a),t.preload_user_info&&await n.userInfoAsync(),n.publishEvent(ce.tryKeepExistingSessionAsync_end,{success:!0,message:"tokens inside ServiceWorker are valid"}),!0}n.publishEvent(ce.tryKeepExistingSessionAsync_end,{success:!1,message:"no exiting session found"})}else{t.service_worker_relative_url&&n.publishEvent(ce.service_worker_not_supported_by_browser,{message:"service worker is not supported by this browser"});const i=Vt(n.configurationName,t.storage??sessionStorage),{tokens:s}=await i.initAsync();if(s){n.tokens=Vc(s,null,t.token_renew_mode);const a=i.getLoginParams();n.timeoutId=Qi(n,n.tokens.expiresAt,a.extras,a.scope);const c=await i.getSessionStateAsync();return await n.startCheckSessionAsync(r.checkSessionIframe,t.client_id,c),t.preload_user_info&&await n.userInfoAsync(),n.publishEvent(ce.tryKeepExistingSessionAsync_end,{success:!0,message:"tokens inside storage are valid"}),!0}}return n.publishEvent(ce.tryKeepExistingSessionAsync_end,{success:!1,message:e?"service worker sessions not retrieved":"session storage sessions not retrieved"}),!1}catch(t){return console.error(t),e&&await e.clearAsync(),n.publishEvent(ce.tryKeepExistingSessionAsync_error,"tokens inside ServiceWorker are invalid"),!1}},gm=n=>{const e=n.match(/^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);if(!e)throw new Error("Invalid URL");let t=e[6],r=e[7];if(r){const i=r.split("?");i.length===2&&(r=i[0],t=i[1])}return t.startsWith("?")&&(t=t.slice(1)),e&&{href:n,protocol:e[1],host:e[2],hostname:e[3],port:e[4],path:e[5],search:t,hash:r}},$i=n=>{const e=gm(n);let{path:t}=e;t.endsWith("/")&&(t=t.slice(0,-1));let{hash:r}=e;return r==="#_=_"&&(r=""),r&&(t+=r),t},xo=n=>{const e=gm(n),{search:t}=e;return Ix(t)},Ix=n=>{const e={};let t,r,i;const s=n.split("&");for(r=0,i=s.length;r<i;r++)t=s[r].split("="),e[decodeURIComponent(t[0])]=decodeURIComponent(t[1]);return e},Px=(n,e,t,r,i)=>(s=void 0,a=null,c=!1,u=void 0)=>{const d=a;return a={...a},(async()=>{const h=s||i.getPath();if("state"in a||(a.state=fc(16)),t(ce.loginAsync_begin,{}),a)for(const p of Object.keys(a))p.endsWith(":token_request")&&delete a[p];try{const p=c?e.silent_redirect_uri:e.redirect_uri;u||(u=e.scope);const y=e.extras?{...e.extras,...a}:a;y.nonce||(y.nonce=fc(12));const g={nonce:y.nonce},_=await Ht(e,n),w=await r(e.authority,e.authority_configuration);let k;if(_)_.setLoginParams({callbackPath:h,extras:d,scope:u}),await _.initAsync(w,"loginAsync",e),await _.setNonceAsync(g),_.startKeepAliveServiceWorker(),k=_;else{const P=Vt(n,e.storage??sessionStorage);P.setLoginParams({callbackPath:h,extras:d,scope:u}),await P.setNonceAsync(g),k=P}const A={client_id:e.client_id,redirect_uri:p,scope:u,response_type:"code",...y};await wx(k,i)(w.authorizationEndpoint,A)}catch(p){throw t(ce.loginAsync_error,p),p}})()},Rx=n=>async(e=!1)=>{try{n.publishEvent(ce.loginCallbackAsync_begin,{});const t=n.configuration,r=t.client_id,i=e?t.silent_redirect_uri:t.redirect_uri,s=t.authority,a=t.token_request_timeout,c=await n.initAsync(s,t.authority_configuration),u=n.location.getCurrentHref(),d=xo(u),h=d.session_state,p=await Ht(t,n.configurationName);let y,g,_,w;if(p)await p.initAsync(c,"loginCallbackAsync",t),await p.setSessionStateAsync(h),g=await p.getNonceAsync(),_=p.getLoginParams(),w=await p.getStateAsync(),p.startKeepAliveServiceWorker(),y=p;else{const ne=Vt(n.configurationName,t.storage??sessionStorage);await ne.setSessionStateAsync(h),g=await ne.getNonceAsync(),_=ne.getLoginParams(),w=await ne.getStateAsync(),y=ne}if(d.error||d.error_description)throw new Error(`Error from OIDC server: ${d.error} - ${d.error_description}`);if(d.iss&&d.iss!==c.issuer)throw console.error(),new Error(`Issuer not valid (expected: ${c.issuer}, received: ${d.iss})`);if(d.state&&d.state!==w)throw new Error(`State not valid (expected: ${w}, received: ${d.state})`);const k={code:d.code,grant_type:"authorization_code",client_id:t.client_id,redirect_uri:i},A={};if(t.token_request_extras)for(const[ne,ve]of Object.entries(t.token_request_extras))A[ne]=ve;if(_!=null&&_.extras)for(const[ne,ve]of Object.entries(_.extras))ne.endsWith(":token_request")&&(A[ne.replace(":token_request","")]=ve);const P=c.tokenEndpoint,L={};if(t.demonstrating_proof_of_possession)if(p)L.DPoP=`DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${n.configurationName}`;else{const ne=await px(window)(t.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm);await Vt(n.configurationName,t.storage).setDemonstratingProofOfPossessionJwkAsync(ne),L.DPoP=await dm(window)(t.demonstrating_proof_of_possession_configuration)(ne,"POST",P)}const B=await kx(y)(P,{...k,...A},L,n.configuration.token_renew_mode,a);if(!B.success)throw new Error("Token request failed");let z;const $=B.data.tokens,J=B.data.demonstratingProofOfPossessionNonce;if(B.data.state!==A.state)throw new Error("state is not valid");const{isValid:K,reason:V}=am($,g.nonce,c);if(!K)throw new Error(`Tokens are not OpenID valid, reason: ${V}`);if(p){if($.refreshToken&&!$.refreshToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))throw new Error("Refresh token should be hidden by service worker");if(J&&$!=null&&$.accessToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))throw new Error("Demonstration of proof of possession require Access token not hidden by service worker")}if(p)await p.initAsync(c,"syncTokensAsync",t),z=p.getLoginParams(),J&&await p.setDemonstratingProofOfPossessionNonce(J);else{const ne=Vt(n.configurationName,t.storage);z=ne.getLoginParams(),J&&await ne.setDemonstratingProofOfPossessionNonce(J)}return await n.startCheckSessionAsync(c.checkSessionIframe,r,h,e),n.publishEvent(ce.loginCallbackAsync_end,{}),{tokens:$,state:"request.state",callbackPath:z.callbackPath,scope:d.scope,extras:z.extras}}catch(t){throw console.error(t),n.publishEvent(ce.loginCallbackAsync_error,t),t}},vh={access_token:"access_token",refresh_token:"refresh_token"},El=(n,e)=>{const t={};if(n){for(const[r,i]of Object.entries(n))if(r.endsWith(e)){const s=r.replace(e,"");t[s]=i}return t}return t},Dx=n=>{const e={};if(n){for(const[t,r]of Object.entries(n))t.includes(":")||(e[t]=r);return e}return e},Lx=n=>async e=>{oi.clearTimeout(n.timeoutId),n.timeoutId=null,n.checkSessionIFrame&&n.checkSessionIFrame.stop();const t=await Ht(n.configuration,n.configurationName);t?await t.clearAsync(e):await Vt(n.configurationName,n.configuration.storage).clearAsync(e),n.tokens=null,n.userInfo=null},Bx=(n,e,t,r,i)=>async(s=void 0,a=null)=>{var c,u;const d=n.configuration,h=await n.initAsync(d.authority,d.authority_configuration);s&&typeof s!="string"&&(s=void 0,r.warn("callbackPathOrUrl path is not a string"));const p=s??i.getPath();let y=!1;s&&(y=s.includes("https://")||s.includes("http://"));const g=y?s:i.getOrigin()+p,_=n.tokens?n.tokens.idToken:"";try{const P=h.revocationEndpoint;if(P){const L=[],B=n.tokens?n.tokens.accessToken:null;if(B&&d.logout_tokens_to_invalidate.includes(vh.access_token)){const $=El(a,":revoke_access_token"),J=_h(t)(P,B,dc.access_token,d.client_id,$);L.push(J)}const z=n.tokens?n.tokens.refreshToken:null;if(z&&d.logout_tokens_to_invalidate.includes(vh.refresh_token)){const $=El(a,":revoke_refresh_token"),J=_h(t)(P,z,dc.refresh_token,d.client_id,$);L.push(J)}L.length>0&&await Promise.all(L)}}catch(P){r.warn("logoutAsync: error when revoking tokens, if the error persist, you ay configure property logout_tokens_to_invalidate from configuration to avoid this error"),r.warn(P)}const w=((u=(c=n.tokens)==null?void 0:c.idTokenPayload)==null?void 0:u.sub)??null;await n.destroyAsync("LOGGED_OUT");for(const[,P]of Object.entries(e))P!==n?await n.logoutSameTabAsync(n.configuration.client_id,w):n.publishEvent(ce.logout_from_same_tab,{});const k=El(a,":oidc");if(k&&k.no_reload==="true")return;const A=Dx(a);if(h.endSessionEndpoint){"id_token_hint"in A||(A.id_token_hint=_),!("post_logout_redirect_uri"in A)&&s!==null&&(A.post_logout_redirect_uri=g);let P="";for(const[L,B]of Object.entries(A))B!=null&&(P===""?P+="?":P+="&",P+=`${L}=${encodeURIComponent(B)}`);i.open(`${h.endSessionEndpoint}${P}`)}else i.reload()},ym=(n,e,t=!1)=>async(...r)=>{var i;const[s,a,...c]=r,u=a?{...a}:{method:"GET"};let d=new Headers;u.headers&&(d=u.headers instanceof Headers?u.headers:new Headers(u.headers));const h={getTokens:()=>e.tokens,configuration:{token_automatic_renew_mode:e.configuration.token_automatic_renew_mode,refresh_time_before_tokens_expiration_in_second:e.configuration.refresh_time_before_tokens_expiration_in_second},renewTokensAsync:e.renewTokensAsync.bind(e)},p=await om(h),y=(i=p==null?void 0:p.tokens)==null?void 0:i.accessToken;if(d.has("Accept")||d.set("Accept","application/json"),y){if(e.configuration.demonstrating_proof_of_possession&&t){const _=await e.generateDemonstrationOfProofOfPossessionAsync(y,s.toString(),u.method);d.set("Authorization",`DPoP ${y}`),d.set("DPoP",_)}else d.set("Authorization",`Bearer ${y}`);u.credentials||(u.credentials="same-origin")}const g={...u,headers:d};return await n(s,g,...c)},Fx=n=>async(e=!1,t=!1)=>{if(n.userInfo!=null&&!e)return n.userInfo;const r=n.configuration,i=(await n.initAsync(r.authority,r.authority_configuration)).userInfoEndpoint,s=await(async()=>{const a=await ym(fetch,n,t)(i);return a.status!==200?null:a.json()})();return n.userInfo=s,s},_m=()=>fetch;let hc=class{constructor(e){this.authorizationEndpoint=e.authorization_endpoint,this.tokenEndpoint=e.token_endpoint,this.revocationEndpoint=e.revocation_endpoint,this.userInfoEndpoint=e.userinfo_endpoint,this.checkSessionIframe=e.check_session_iframe,this.issuer=e.issuer,this.endSessionEndpoint=e.end_session_endpoint}};const gr={},$x=(n,e=new si)=>(t,r="default")=>(gr[r]||(gr[r]=new An(t,r,n,e)),gr[r]),zx=async n=>{const{parsedTokens:e,callbackPath:t,extras:r,scope:i}=await n.loginCallbackAsync();return n.timeoutId=Qi(n,e.expiresAt,r,i),{callbackPath:t}},Wx=n=>Math.floor(Math.random()*n),pc=class bm{constructor(e,t="default",r,i=new si){this.initPromise=null,this.tryKeepExistingSessionPromise=null,this.loginPromise=null,this.loginCallbackPromise=null,this.loginCallbackWithAutoTokensRenewPromise=null,this.userInfoPromise=null,this.renewTokensPromise=null,this.logoutPromise=null;let s=e.silent_login_uri;e.silent_redirect_uri&&!e.silent_login_uri&&(s=`${e.silent_redirect_uri.replace("-callback","").replace("callback","")}-login`);let a=e.refresh_time_before_tokens_expiration_in_second??120;a>60&&(a=a-Math.floor(Math.random()*40)),this.location=i??new si;const c=e.service_worker_update_require_callback??nx(this.location);this.configuration={...e,silent_login_uri:s,token_automatic_renew_mode:e.token_automatic_renew_mode??Yi.AutomaticBeforeTokenExpiration,monitor_session:e.monitor_session??!1,refresh_time_before_tokens_expiration_in_second:a,silent_login_timeout:e.silent_login_timeout??12e3,token_renew_mode:e.token_renew_mode??cc.access_token_or_id_token_invalid,demonstrating_proof_of_possession:e.demonstrating_proof_of_possession??!1,authority_timeout_wellknowurl_in_millisecond:e.authority_timeout_wellknowurl_in_millisecond??1e4,logout_tokens_to_invalidate:e.logout_tokens_to_invalidate??["access_token","refresh_token"],service_worker_update_require_callback:c,service_worker_activate:e.service_worker_activate??Mx,demonstrating_proof_of_possession_configuration:e.demonstrating_proof_of_possession_configuration??ox,preload_user_info:e.preload_user_info??!1},this.getFetch=r??_m,this.configurationName=t,this.tokens=null,this.userInfo=null,this.events=[],this.timeoutId=null,this.loginCallbackWithAutoTokensRenewAsync.bind(this),this.initAsync.bind(this),this.loginCallbackAsync.bind(this),this.subscribeEvents.bind(this),this.removeEventSubscription.bind(this),this.publishEvent.bind(this),this.destroyAsync.bind(this),this.logoutAsync.bind(this),this.renewTokensAsync.bind(this),this.initAsync(this.configuration.authority,this.configuration.authority_configuration)}subscribeEvents(e){const t=Wx(9999999999999).toString();return this.events.push({id:t,func:e}),t}removeEventSubscription(e){const t=this.events.filter(r=>r.id!==e);this.events=t}publishEvent(e,t){this.events.forEach(r=>{r.func(e,t)})}static get(e="default"){const t=typeof process>"u";if(!Object.prototype.hasOwnProperty.call(gr,e)&&t)throw Error(`OIDC library does seem initialized.
24
- Please checkout that you are using OIDC hook inside a <OidcProvider configurationName="${e}"></OidcProvider> component.`);return gr[e]}_silentLoginCallbackFromIFrame(){if(this.configuration.silent_redirect_uri&&this.configuration.silent_login_uri){const e=this.location,t=xo(e.getCurrentHref());window.parent.postMessage(`${this.configurationName}_oidc_tokens:${JSON.stringify({tokens:this.tokens,sessionState:t.session_state})}`,e.getOrigin())}}_silentLoginErrorCallbackFromIFrame(e=null){if(this.configuration.silent_redirect_uri&&this.configuration.silent_login_uri){const t=this.location,r=xo(t.getCurrentHref());r.error?window.parent.postMessage(`${this.configurationName}_oidc_error:${JSON.stringify({error:r.error})}`,t.getOrigin()):window.parent.postMessage(`${this.configurationName}_oidc_exception:${JSON.stringify({error:e==null?"":e.toString()})}`,t.getOrigin())}}async silentLoginCallbackAsync(){try{await this.loginCallbackAsync(!0),this._silentLoginCallbackFromIFrame()}catch(e){console.error(e),this._silentLoginErrorCallbackFromIFrame(e)}}async initAsync(e,t){if(this.initPromise!==null)return this.initPromise;const r=async()=>{if(t!=null)return new hc({authorization_endpoint:t.authorization_endpoint,end_session_endpoint:t.end_session_endpoint,revocation_endpoint:t.revocation_endpoint,token_endpoint:t.token_endpoint,userinfo_endpoint:t.userinfo_endpoint,check_session_iframe:t.check_session_iframe,issuer:t.issuer});const i=await Ht(this.configuration,this.configurationName)?window.sessionStorage:null;return await vx(this.getFetch())(e,this.configuration.authority_time_cache_wellknowurl_in_second??60*60,i,this.configuration.authority_timeout_wellknowurl_in_millisecond)};return this.initPromise=r(),this.initPromise.finally(()=>{this.initPromise=null})}async tryKeepExistingSessionAsync(){return this.tryKeepExistingSessionPromise!==null?this.tryKeepExistingSessionPromise:(this.tryKeepExistingSessionPromise=Nx(this),this.tryKeepExistingSessionPromise.finally(()=>{this.tryKeepExistingSessionPromise=null}))}async startCheckSessionAsync(e,t,r,i=!1){await Ox(this,gr,this.configuration)(e,t,r,i)}async loginAsync(e=void 0,t=null,r=!1,i=void 0,s=!1){return this.logoutPromise&&await this.logoutPromise,this.loginPromise!==null?this.loginPromise:(s?this.loginPromise=Ex(window,this.configurationName,this.configuration,this.publishEvent.bind(this),this)(t,i):this.loginPromise=Px(this.configurationName,this.configuration,this.publishEvent.bind(this),this.initAsync.bind(this),this.location)(e,t,r,i),this.loginPromise.finally(()=>{this.loginPromise=null}))}async loginCallbackAsync(e=!1){if(this.loginCallbackPromise!==null)return this.loginCallbackPromise;const t=async()=>{const r=await Rx(this)(e),i=r.tokens;return this.tokens=i,await Ht(this.configuration,this.configurationName)||Vt(this.configurationName,this.configuration.storage).setTokens(i),this.publishEvent(bm.eventNames.token_acquired,i),this.configuration.preload_user_info&&await this.userInfoAsync(),{parsedTokens:i,state:r.state,callbackPath:r.callbackPath,scope:r.scope,extras:r.extras}};return this.loginCallbackPromise=t(),this.loginCallbackPromise.finally(()=>{this.loginCallbackPromise=null})}async generateDemonstrationOfProofOfPossessionAsync(e,t,r,i={}){const s=this.configuration,a={ath:await pm(e),...i};if(await Ht(s,this.configurationName))return`DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${cm(this.configurationName)}`;const c=Vt(this.configurationName,s.storage),u=await c.getDemonstratingProofOfPossessionJwkAsync(),d=c.getDemonstratingProofOfPossessionNonce();return d&&(a.nonce=d),await dm(window)(s.demonstrating_proof_of_possession_configuration)(u,r,t,a)}loginCallbackWithAutoTokensRenewAsync(){return this.loginCallbackWithAutoTokensRenewPromise!==null?this.loginCallbackWithAutoTokensRenewPromise:(this.loginCallbackWithAutoTokensRenewPromise=zx(this),this.loginCallbackWithAutoTokensRenewPromise.finally(()=>{this.loginCallbackWithAutoTokensRenewPromise=null}))}userInfoAsync(e=!1,t=!1){return this.userInfoPromise!==null?this.userInfoPromise:(this.userInfoPromise=Fx(this)(e,t),this.userInfoPromise.finally(()=>{this.userInfoPromise=null}))}async renewTokensAsync(e=null,t=null){if(this.renewTokensPromise!==null)return this.renewTokensPromise;if(this.timeoutId)return oi.clearTimeout(this.timeoutId),this.renewTokensPromise=mm(this,!0,e,t),this.renewTokensPromise.finally(()=>{this.renewTokensPromise=null})}async destroyAsync(e){return await Lx(this)(e)}async logoutSameTabAsync(e,t){this.configuration.monitor_session&&this.configuration.client_id===e&&t&&this.tokens&&this.tokens.idTokenPayload&&this.tokens.idTokenPayload.sub===t&&(await this.destroyAsync("LOGGED_OUT"),this.publishEvent(ce.logout_from_same_tab,{mmessage:"SessionMonitor",sub:t}))}async logoutOtherTabAsync(e,t){this.configuration.monitor_session&&this.configuration.client_id===e&&t&&this.tokens&&this.tokens.idTokenPayload&&this.tokens.idTokenPayload.sub===t&&(await this.destroyAsync("LOGGED_OUT"),this.publishEvent(ce.logout_from_another_tab,{message:"SessionMonitor",sub:t}))}async logoutAsync(e=void 0,t=null){return this.logoutPromise?this.logoutPromise:(this.logoutPromise=Bx(this,gr,this.getFetch(),console,this.location)(e,t),this.logoutPromise.finally(()=>{this.logoutPromise=null}))}};pc.getOrCreate=(n,e)=>(t,r="default")=>$x(n,e)(t,r),pc.eventNames=ce;let An=pc;const mo=class vm{constructor(e){this._oidc=e}subscribeEvents(e){return this._oidc.subscribeEvents(e)}removeEventSubscription(e){this._oidc.removeEventSubscription(e)}publishEvent(e,t){this._oidc.publishEvent(e,t)}static get(e="default"){return new vm(An.get(e))}tryKeepExistingSessionAsync(){return this._oidc.tryKeepExistingSessionAsync()}loginAsync(e=void 0,t=null,r=!1,i=void 0,s=!1){return this._oidc.loginAsync(e,t,r,i,s)}logoutAsync(e=void 0,t=null){return this._oidc.logoutAsync(e,t)}silentLoginCallbackAsync(){return this._oidc.silentLoginCallbackAsync()}renewTokensAsync(e=null,t=null){return this._oidc.renewTokensAsync(e,t)}loginCallbackAsync(){return this._oidc.loginCallbackWithAutoTokensRenewAsync()}get tokens(){return this._oidc.tokens}get configuration(){return this._oidc.configuration}async generateDemonstrationOfProofOfPossessionAsync(e,t,r,i={}){return this._oidc.generateDemonstrationOfProofOfPossessionAsync(e,t,r,i)}async getValidTokenAsync(e=200,t=50){const r=this._oidc,i={getTokens:()=>r.tokens,configuration:{token_automatic_renew_mode:r.configuration.token_automatic_renew_mode,refresh_time_before_tokens_expiration_in_second:r.configuration.refresh_time_before_tokens_expiration_in_second},renewTokensAsync:r.renewTokensAsync.bind(r)};return om(i,e,t)}fetchWithTokens(e,t=!1){return ym(e,this._oidc,t)}async userInfoAsync(e=!1,t=!1){return this._oidc.userInfoAsync(e,t)}userInfo(){return this._oidc.userInfo}};mo.getOrCreate=(n,e=new si)=>(t,r="default")=>new mo(An.getOrCreate(n,e)(t,r)),mo.eventNames=An.eventNames;let me=mo;const Sm=()=>Y.jsx("div",{className:"oidc-authenticating",children:Y.jsxs("div",{className:"oidc-authenticating__container",children:[Y.jsx("h1",{className:"oidc-authenticating__title",children:"Error authentication"}),Y.jsx("p",{className:"oidc-authenticating__content",children:"An error occurred during authentication."})]})}),Vx=()=>Y.jsx("div",{className:"oidc-authenticating",children:Y.jsxs("div",{className:"oidc-authenticating__container",children:[Y.jsx("h1",{className:"oidc-authenticating__title",children:"Authentication in progress"}),Y.jsx("p",{className:"oidc-authenticating__content",children:"You will be redirected to the login page."})]})}),Hx=()=>Math.random().toString(36).slice(2,8),Ux=(n,e)=>(t,r)=>{if(typeof n.CustomEvent=="function")return new n.CustomEvent(t,r);const i=r||{bubbles:!1,cancelable:!1,detail:void 0},s=e.createEvent("CustomEvent");return s.initCustomEvent(t,i.bubbles,i.cancelable,i.detail),s.prototype=n.Event.prototype,s},Kx=(n,e,t)=>({replaceState:(r,i)=>{const s=t(),a=i||n.history.state;n.history.replaceState({key:s,state:a},null,r),n.dispatchEvent(e("popstate"))}}),jx=()=>Kx(window,Ux(window,document),Hx),wm=()=>Y.jsx("div",{className:"oidc-callback",children:Y.jsxs("div",{className:"oidc-callback__container",children:[Y.jsx("h1",{className:"oidc-callback__title",children:"Authentication complete"}),Y.jsx("p",{className:"oidc-callback__content",children:"You will be redirected to your application."})]})}),qx=({callBackError:n,callBackSuccess:e,configurationName:t,withCustomHistory:r})=>{const[i,s]=q.useState(!1);q.useEffect(()=>{let u=!0;return(async()=>{const d=me.get;try{const{callbackPath:h}=await d(t).loginCallbackAsync();(r?r():jx()).replaceState(h||"/")}catch(h){u&&(console.warn(h),s(!0))}})(),()=>{u=!1}},[]);const a=n||Sm,c=e||wm;return i?Y.jsx(a,{configurationName:t}):Y.jsx(c,{configurationName:t})},Jx=()=>Y.jsx("span",{className:"oidc-loading",children:"Loading"}),Gx=()=>Y.jsx("div",{className:"oidc-serviceworker",children:Y.jsxs("div",{className:"oidc-serviceworker__container",children:[Y.jsx("h1",{className:"oidc-serviceworker__title",children:"Unable to authenticate on this browser"}),Y.jsx("p",{className:"oidc-serviceworker__content",children:"Your browser is not secure enough to make authentication work. Try updating your browser or use a newer browser."})]})}),Yx=()=>Y.jsx("div",{className:"oidc-session-lost",children:Y.jsxs("div",{className:"oidc-session-lost__container",children:[Y.jsx("h1",{className:"oidc-session-lost__title",children:"Session timed out"}),Y.jsx("p",{className:"oidc-session-lost__content",children:"Your session has expired. Please re-authenticate."})]})}),Qx=({configurationName:n})=>(q.useEffect(()=>{(async()=>{me.get(n).silentLoginCallbackAsync()})().catch(e=>{console.error("Error during silent login callback:",e)})},[n]),null),Xx=({configurationName:n})=>{const e=xo(window.location.href),t=me.get,r=t(n);let i=null;for(const[s,a]of Object.entries(e))s==="state"||s==="scope"||(i===null&&(i={}),i[s]=a);return q.useEffect(()=>{r.tokens||r.loginAsync(null,i,!0,e.scope)},[]),Y.jsx(Y.Fragment,{})},Zx=({callbackErrorComponent:n,callbackSuccessComponent:e,redirect_uri:t,silent_redirect_uri:r,silent_login_uri:i,children:s,configurationName:a,withCustomHistory:c=null})=>{const u=window?$i(window.location.href):"",[d,h]=q.useState(u);q.useEffect(()=>{const y=()=>h($i(window.location.href));return y(),window.addEventListener("popstate",y,!1),()=>window.removeEventListener("popstate",y,!1)},[]);const p=$i(t);if(r&&d===$i(r))return Y.jsx(Qx,{configurationName:a});if(i&&d===$i(i))return Y.jsx(Xx,{configurationName:a});switch(d){case p:return Y.jsx(qx,{callBackError:n,callBackSuccess:e,configurationName:a,withCustomHistory:c});default:return Y.jsx(Y.Fragment,{children:s})}},eE=q.memo(Zx),Sh={name:"",data:null},tE=({loadingComponent:n,children:e,configurationName:t})=>{const[r,i]=q.useState(!0),s=me.get,a=s(t);return q.useEffect(()=>{let c=!0;return a&&a.tryKeepExistingSessionAsync().then(()=>{c&&i(!1)}),()=>{c=!1}},[t]),Y.jsx(Y.Fragment,{children:r?Y.jsx(n,{configurationName:t}):Y.jsx(Y.Fragment,{children:e})})},zi=({isLoading:n,loadingComponent:e,children:t,configurationName:r})=>{const i=e;return n?Y.jsx(i,{configurationName:r,children:t}):Y.jsx(Y.Fragment,{children:t})},nE=({children:n,configuration:e,configurationName:t="default",callbackSuccessComponent:r=wm,authenticatingComponent:i=Vx,loadingComponent:s=Jx,serviceWorkerNotSupportedComponent:a=Gx,authenticatingErrorComponent:c=Sm,sessionLostComponent:u=Yx,onSessionLost:d=null,onLogoutFromAnotherTab:h=null,onLogoutFromSameTab:p=null,withCustomHistory:y=null,onEvent:g=null,getFetch:_=null,location:w=null})=>{const k=(We="default")=>me.getOrCreate(_??_m,w??new si)(e,We),[A,P]=q.useState(!0),[L,B]=q.useState(Sh),[z,$]=q.useState("default");q.useEffect(()=>{const We=k(t).subscribeEvents((Ce,ot)=>{g&&g(t,Ce,ot)});return()=>{k(t).removeEventSubscription(We)}},[t,g]),q.useEffect(()=>{const We=k(t).subscribeEvents((Ce,ot)=>{if(Ce===me.eventNames.refreshTokensAsync_error||Ce===me.eventNames.syncTokensAsync_error){if(d!=null){d();return}B({name:Ce,data:ot})}else if(Ce===me.eventNames.logout_from_another_tab){if(h!=null){h();return}B({name:Ce,data:ot})}else Ce===me.eventNames.logout_from_same_tab?p!=null&&p():Ce===me.eventNames.loginAsync_begin||Ce===me.eventNames.loginCallbackAsync_end||Ce===me.eventNames.loginAsync_error||Ce===me.eventNames.loginCallbackAsync_error?B({name:Ce,data:ot}):Ce===me.eventNames.service_worker_not_supported_by_browser&&e.service_worker_only===!0&&B({name:Ce,data:ot})});return $(t),P(!1),()=>{k(t).removeEventSubscription(We),B(Sh)}},[e,t]);const J=u,K=i,V=s,ne=a,ve=c,De=A||z!==t,pt=k(t);switch(L.name){case me.eventNames.service_worker_not_supported_by_browser:return Y.jsx(zi,{loadingComponent:V,isLoading:De,configurationName:t,children:Y.jsx(ne,{configurationName:t})});case me.eventNames.loginAsync_begin:return Y.jsx(zi,{loadingComponent:V,isLoading:De,configurationName:t,children:Y.jsx(K,{configurationName:t})});case me.eventNames.loginAsync_error:case me.eventNames.loginCallbackAsync_error:return Y.jsx(zi,{loadingComponent:V,isLoading:De,configurationName:t,children:Y.jsx(ve,{configurationName:t})});case me.eventNames.refreshTokensAsync_error:case me.eventNames.syncTokensAsync_error:case me.eventNames.logout_from_another_tab:return Y.jsx(zi,{loadingComponent:V,isLoading:De,configurationName:t,children:Y.jsx(J,{configurationName:t})});default:return Y.jsx(zi,{loadingComponent:V,isLoading:De,configurationName:t,children:Y.jsx(eE,{redirect_uri:pt.configuration.redirect_uri,silent_redirect_uri:pt.configuration.silent_redirect_uri,silent_login_uri:pt.configuration.silent_login_uri,callbackSuccessComponent:r,callbackErrorComponent:c,authenticatingComponent:i,configurationName:t,withCustomHistory:y,location:w??new si,children:Y.jsx(tE,{loadingComponent:V,configurationName:t,children:n})})})}},km="default",Ol=(n,e)=>{let t=!1;return n(e)&&(t=n(e).tokens!=null),t},rE=(n=km)=>{const e=me.get,[t,r]=q.useState(Ol(e,n));return q.useEffect(()=>{let i=!0;const s=e(n);r(Ol(e,n));const a=s.subscribeEvents((c,u)=>{(c===me.eventNames.logout_from_another_tab||c===me.eventNames.logout_from_same_tab||c===me.eventNames.token_acquired)&&i&&r(Ol(e,n))});return()=>{i=!1,s.removeEventSubscription(a)}},[n]),{login:(i=void 0,s=void 0,a=!1,c=void 0)=>e(n).loginAsync(i,s,!1,c,a),logout:(i=void 0,s=void 0)=>e(n).logoutAsync(i,s),renewTokens:async(i=void 0)=>{const s=await e(n).renewTokensAsync(i);return{accessToken:s.accessToken,accessTokenPayload:s.accessTokenPayload,idToken:s.idToken,idTokenPayload:s.idTokenPayload}},isAuthenticated:t}},xm={accessToken:null,accessTokenPayload:null},iE=n=>{const e=me.get,t=e(n);if(t.tokens){const r=t.tokens;return{accessToken:r.accessToken,accessTokenPayload:r.accessTokenPayload,generateDemonstrationOfProofOfPossessionAsync:t.configuration.demonstrating_proof_of_possession?(i,s)=>t.generateDemonstrationOfProofOfPossessionAsync(r.accessToken,i,s):null}}return xm};function sE(n,e){return n.configuration.demonstrating_proof_of_possession?(t,r,i={})=>n.generateDemonstrationOfProofOfPossessionAsync(e.accessToken,t,r,i):null}const oE=(n=km)=>{const e=me.get,[t,r]=q.useState(iE(n));return q.useEffect(()=>{let i=!0;const s=e(n);if(s.tokens){const c=s.tokens;r({accessToken:c.accessToken,accessTokenPayload:c.accessTokenPayload})}const a=s.subscribeEvents((c,u)=>{if((c===me.eventNames.token_renewed||c===me.eventNames.token_acquired||c===me.eventNames.logout_from_another_tab||c===me.eventNames.logout_from_same_tab||c===me.eventNames.refreshTokensAsync_error||c===me.eventNames.syncTokensAsync_error)&&i){const d=s.tokens;r(d!=null?{accessToken:d.accessToken,accessTokenPayload:d.accessTokenPayload,generateDemonstrationOfProofOfPossessionAsync:sE(s,d)}:xm)}});return()=>{i=!1,s.removeEventSubscription(a)}},[n]),t},aE=di.graphql(`
23
+ <%s key={someKey} {...props} />`,Ve,Me,Mt,Me),ds[Me+Ve]=!0)}if(Me=null,xe!==void 0&&(t(xe),Me=""+xe),a(te)&&(t(te.key),Me=""+te.key),"key"in te){xe={};for(var mi in te)mi!=="key"&&(xe[mi]=te[mi])}else xe=te;return Me&&c(xe,typeof F=="function"?F.displayName||F.name||"Unknown":F),d(F,Me,Je,tn,i(),xe,Nn,pi)}function p(F){typeof F=="object"&&F!==null&&F.$$typeof===g&&F._store&&(F._store.validated=1)}var y=q,g=Symbol.for("react.transitional.element"),_=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),A=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),L=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),$=Symbol.for("react.suspense_list"),J=Symbol.for("react.memo"),K=Symbol.for("react.lazy"),V=Symbol.for("react.activity"),ne=Symbol.for("react.client.reference"),ve=y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,De=Object.prototype.hasOwnProperty,pt=Array.isArray,We=console.createTask?console.createTask:function(){return null};y={"react-stack-bottom-frame":function(F){return F()}};var Ce,ot={},jt=y["react-stack-bottom-frame"].bind(y,s)(),dn=We(r(s)),ds={};Fi.Fragment=w,Fi.jsx=function(F,te,xe,Ve,tn){var Je=1e4>ve.recentlyCreatedOwnerStacks++;return h(F,te,xe,!1,Ve,tn,Je?Error("react-stack-top-frame"):jt,Je?We(r(F)):dn)},Fi.jsxs=function(F,te,xe,Ve,tn){var Je=1e4>ve.recentlyCreatedOwnerStacks++;return h(F,te,xe,!0,Ve,tn,Je?Error("react-stack-top-frame"):jt,Je?We(r(F)):dn)}}()),Fi}process.env.NODE_ENV==="production"?lc.exports=J1():lc.exports=G1();var Y=lc.exports;let oi=class{open(e){window.location.href=e}reload(){window.location.reload()}getCurrentHref(){return window.location.href}getPath(){const e=window.location;return e.pathname+(e.search||"")+(e.hash||"")}getOrigin(){return window.origin}};const fh=2e3,Gr=console;let Y1=class{constructor(e,t,r,i=fh,s=!0){this._callback=e,this._client_id=t,this._url=r,this._interval=i||fh,this._stopOnError=s;const a=r.indexOf("/",r.indexOf("//")+2);this._frame_origin=r.substring(0,a),this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="absolute",this._frame.style.display="none",this._frame.width=0,this._frame.height=0,this._frame.src=r}load(){return new Promise(e=>{this._frame.onload=()=>{e()},window.document.body.appendChild(this._frame),this._boundMessageEvent=this._message.bind(this),window.addEventListener("message",this._boundMessageEvent,!1)})}_message(e){e.origin===this._frame_origin&&e.source===this._frame.contentWindow&&(e.data==="error"?(Gr.error("CheckSessionIFrame: error message from check session op iframe"),this._stopOnError&&this.stop()):e.data==="changed"?(Gr.debug(e),Gr.debug("CheckSessionIFrame: changed message from check session op iframe"),this.stop(),this._callback()):Gr.debug("CheckSessionIFrame: "+e.data+" message from check session op iframe"))}start(e){Gr.debug("CheckSessionIFrame.start :"+e),this.stop();const t=()=>{this._frame.contentWindow.postMessage(this._client_id+" "+e,this._frame_origin)};t(),this._timer=window.setInterval(t,this._interval)}stop(){this._timer&&(Gr.debug("CheckSessionIFrame.stop"),window.clearInterval(this._timer),this._timer=null)}};const ce={service_worker_not_supported_by_browser:"service_worker_not_supported_by_browser",token_acquired:"token_acquired",logout_from_another_tab:"logout_from_another_tab",logout_from_same_tab:"logout_from_same_tab",token_renewed:"token_renewed",token_timer:"token_timer",loginAsync_begin:"loginAsync_begin",loginAsync_error:"loginAsync_error",loginCallbackAsync_begin:"loginCallbackAsync_begin",loginCallbackAsync_end:"loginCallbackAsync_end",loginCallbackAsync_error:"loginCallbackAsync_error",refreshTokensAsync_begin:"refreshTokensAsync_begin",refreshTokensAsync:"refreshTokensAsync",refreshTokensAsync_end:"refreshTokensAsync_end",refreshTokensAsync_error:"refreshTokensAsync_error",refreshTokensAsync_silent_error:"refreshTokensAsync_silent_error",tryKeepExistingSessionAsync_begin:"tryKeepExistingSessionAsync_begin",tryKeepExistingSessionAsync_end:"tryKeepExistingSessionAsync_end",tryKeepExistingSessionAsync_error:"tryKeepExistingSessionAsync_error",silentLoginAsync_begin:"silentLoginAsync_begin",silentLoginAsync:"silentLoginAsync",silentLoginAsync_end:"silentLoginAsync_end",silentLoginAsync_error:"silentLoginAsync_error",syncTokensAsync_begin:"syncTokensAsync_begin",syncTokensAsync_lock_not_available:"syncTokensAsync_lock_not_available",syncTokensAsync_end:"syncTokensAsync_end",syncTokensAsync_error:"syncTokensAsync_error",tokensInvalidAndWaitingActionsToRefresh:"tokensInvalidAndWaitingActionsToRefresh"},Vt=(n,e=sessionStorage)=>{const t=w=>(e[`oidc.${n}`]=JSON.stringify({tokens:null,status:w}),Promise.resolve()),r=async()=>{if(!e[`oidc.${n}`])return e[`oidc.${n}`]=JSON.stringify({tokens:null,status:null}),{tokens:null,status:null};const w=JSON.parse(e[`oidc.${n}`]);return Promise.resolve({tokens:w.tokens,status:w.status})},i=w=>{e[`oidc.${n}`]=JSON.stringify({tokens:w})},s=async w=>{e[`oidc.session_state.${n}`]=w},a=async()=>e[`oidc.session_state.${n}`],c=w=>{e[`oidc.nonce.${n}`]=w.nonce},u=w=>{e[`oidc.jwk.${n}`]=JSON.stringify(w)},d=()=>JSON.parse(e[`oidc.jwk.${n}`]),h=async()=>({nonce:e[`oidc.nonce.${n}`]}),p=async w=>{e[`oidc.dpop_nonce.${n}`]=w},y=()=>e[`oidc.dpop_nonce.${n}`],g=()=>e[`oidc.${n}`]?JSON.stringify({tokens:JSON.parse(e[`oidc.${n}`]).tokens}):null,_={};return{clearAsync:t,initAsync:r,setTokens:i,getTokens:g,setSessionStateAsync:s,getSessionStateAsync:a,setNonceAsync:c,getNonceAsync:h,setLoginParams:w=>{_[n]=w,e[`oidc.login.${n}`]=JSON.stringify(w)},getLoginParams:()=>{const w=e[`oidc.login.${n}`];return w?(_[n]||(_[n]=JSON.parse(w)),_[n]):(console.warn(`storage[oidc.login.${n}] is empty, you should have an bad OIDC or code configuration somewhere.`),null)},getStateAsync:async()=>e[`oidc.state.${n}`],setStateAsync:async w=>{e[`oidc.state.${n}`]=w},getCodeVerifierAsync:async()=>e[`oidc.code_verifier.${n}`],setCodeVerifierAsync:async w=>{e[`oidc.code_verifier.${n}`]=w},setDemonstratingProofOfPossessionNonce:p,getDemonstratingProofOfPossessionNonce:y,setDemonstratingProofOfPossessionJwkAsync:u,getDemonstratingProofOfPossessionJwkAsync:d}};var Yi=(n=>(n.AutomaticBeforeTokenExpiration="AutomaticBeforeTokensExpiration",n.AutomaticOnlyWhenFetchExecuted="AutomaticOnlyWhenFetchExecuted",n))(Yi||{});const Q1=n=>decodeURIComponent(Array.prototype.map.call(atob(n),e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")),X1=n=>JSON.parse(Q1(n.replaceAll(/-/g,"+").replaceAll(/_/g,"/"))),dh=n=>{try{return n&&Z1(n,".")===2?X1(n.split(".")[1]):null}catch(e){console.warn(e)}return null},Z1=(n,e)=>n.split(e).length-1,cc={access_token_or_id_token_invalid:"access_token_or_id_token_invalid",access_token_invalid:"access_token_invalid",id_token_invalid:"id_token_invalid"};function ex(n,e,t){if(n.issuedAt){if(typeof n.issuedAt=="string")return parseInt(n.issuedAt,10)}else return e&&e.iat?e.iat:t&&t.iat?t.iat:new Date().getTime()/1e3;return n.issuedAt}const Vc=(n,e=null,t)=>{if(!n)return null;let r;const i=typeof n.expiresIn=="string"?parseInt(n.expiresIn,10):n.expiresIn;n.accessTokenPayload!==void 0?r=n.accessTokenPayload:r=dh(n.accessToken);let s;e!=null&&"idToken"in e&&!("idToken"in n)?s=e.idToken:s=n.idToken;const a=n.idTokenPayload?n.idTokenPayload:dh(s),c=a&&a.exp?a.exp:Number.MAX_VALUE,u=r&&r.exp?r.exp:n.issuedAt+i;n.issuedAt=ex(n,r,a);let d;n.expiresAt?d=n.expiresAt:t===cc.access_token_invalid?d=u:t===cc.id_token_invalid?d=c:d=c<u?c:u;const h={...n,idTokenPayload:a,accessTokenPayload:r,expiresAt:d,idToken:s};if(e!=null&&"refreshToken"in e&&!("refreshToken"in n)){const p=e.refreshToken;return{...h,refreshToken:p}}return h},Hc=(n,e,t)=>{if(!n)return null;if(!n.issued_at){const i=new Date().getTime()/1e3;n.issued_at=i}const r={accessToken:n.access_token,expiresIn:n.expires_in,idToken:n.id_token,scope:n.scope,tokenType:n.token_type,issuedAt:n.issued_at};return"refresh_token"in n&&(r.refreshToken=n.refresh_token),n.accessTokenPayload!==void 0&&(r.accessTokenPayload=n.accessTokenPayload),n.idTokenPayload!==void 0&&(r.idTokenPayload=n.idTokenPayload),Vc(r,e,t)},ji=(n,e)=>{const t=new Date().getTime()/1e3,r=e-t;return Math.round(r-n)},hh=(n,e=0)=>n?ji(e,n.expiresAt)>0:!1,om=async(n,e=200,t=50)=>{let r=t;if(!n.getTokens())return null;for(;!hh(n.getTokens(),n.configuration.refresh_time_before_tokens_expiration_in_second)&&r>0;){if(n.configuration.token_automatic_renew_mode==Yi.AutomaticOnlyWhenFetchExecuted){await n.renewTokensAsync({});break}else await zo({milliseconds:e});r=r-1}return{isTokensValid:hh(n.getTokens()),tokens:n.getTokens(),numberWaited:r-t}},am=(n,e,t)=>{if(n.idTokenPayload){const r=n.idTokenPayload;if(t.issuer!==r.iss)return{isValid:!1,reason:`Issuer does not match (oidcServerConfiguration issuer) ${t.issuer} !== (idTokenPayload issuer) ${r.iss}`};const i=new Date().getTime()/1e3;if(r.exp&&r.exp<i)return{isValid:!1,reason:`Token expired (idTokenPayload exp) ${r.exp} < (currentTimeUnixSecond) ${i}`};const s=60*60*24*7;if(r.iat&&r.iat+s<i)return{isValid:!1,reason:`Token is used from too long time (idTokenPayload iat + timeInSevenDays) ${r.iat+s} < (currentTimeUnixSecond) ${i}`};if(r.nonce&&r.nonce!==e)return{isValid:!1,reason:`Nonce does not match (idTokenPayload nonce) ${r.nonce} !== (nonce) ${e}`}}return{isValid:!0,reason:""}},ai=function(){const n=typeof window>"u"?global:window;return{setTimeout:setTimeout.bind(n),clearTimeout:clearTimeout.bind(n),setInterval:setInterval.bind(n),clearInterval:clearInterval.bind(n)}}(),ph="7.25.7";let mh=null,wo;const zo=({milliseconds:n})=>new Promise(e=>ai.setTimeout(e,n)),lm=(n="/")=>{try{wo=new AbortController,fetch(`${n}OidcKeepAliveServiceWorker.json?minSleepSeconds=150`,{signal:wo.signal}).catch(e=>{console.log(e)}),zo({milliseconds:150*1e3}).then(lm)}catch(e){console.log(e)}},gh=()=>{wo&&wo.abort()},tx=(n="/")=>fetch(`${n}OidcKeepAliveServiceWorker.json`,{headers:{"oidc-vanilla":"true"}}).then(e=>e.statusText==="oidc-service-worker").catch(e=>{console.log(e)}),nx=n=>async(e,t)=>{t(),await e.update();const r=await e.unregister();console.log(`Service worker unregistration ${r?"successful":"failed"}`),await zo({milliseconds:2e3}),n.reload()},cm=n=>{const e=sessionStorage.getItem(`oidc.tabId.${n}`);if(e)return e;const t=globalThis.crypto.randomUUID();return sessionStorage.setItem(`oidc.tabId.${n}`,t),t},ut=n=>e=>new Promise(function(t,r){const i=new MessageChannel;i.port1.onmessage=function(s){s!=null&&s.data.error?r(s.data.error):t(s.data),i.port1.close(),i.port2.close()},n.active.postMessage({...e,tabId:cm(e.configurationName)},[i.port2])}),Ht=async(n,e)=>{var t;const r=n.service_worker_relative_url;if(typeof window>"u"||typeof navigator>"u"||!navigator.serviceWorker||!r||n.service_worker_activate()===!1)return null;let i=null;n.service_worker_register?i=await n.service_worker_register(r):(i=await navigator.serviceWorker.register(r),i.active&&i.waiting&&(console.log("Detected new service worker waiting, unregistering and reloading"),await((t=n.service_worker_update_require_callback)==null?void 0:t.call(n,i,gh))));try{await navigator.serviceWorker.ready,navigator.serviceWorker.controller||await ut(i)({type:"claim"})}catch(g){return console.warn(`Failed init ServiceWorker ${g.toString()}`),null}const s=async g=>ut(i)({type:"clear",data:{status:g},configurationName:e}),a=async(g,_,w)=>{var k;const A=await ut(i)({type:"init",data:{oidcServerConfiguration:g,where:_,oidcConfiguration:{token_renew_mode:w.token_renew_mode,service_worker_convert_all_requests_to_cors:w.service_worker_convert_all_requests_to_cors}},configurationName:e}),P=A.version;return P!==ph&&(console.warn(`Service worker ${P} version mismatch with js client version ${ph}, unregistering and reloading`),await((k=w.service_worker_update_require_callback)==null?void 0:k.call(w,i,gh))),{tokens:Hc(A.tokens,null,w.token_renew_mode),status:A.status}},c=(g="/")=>{mh==null&&(mh="not_null",lm(g))},u=g=>ut(i)({type:"setSessionState",data:{sessionState:g},configurationName:e}),d=async()=>(await ut(i)({type:"getSessionState",data:null,configurationName:e})).sessionState,h=g=>(sessionStorage[`oidc.nonce.${e}`]=g.nonce,ut(i)({type:"setNonce",data:{nonce:g},configurationName:e})),p=async()=>{let g=(await ut(i)({type:"getNonce",data:null,configurationName:e})).nonce;return g||(g=sessionStorage[`oidc.nonce.${e}`],console.warn("nonce not found in service worker, using sessionStorage")),{nonce:g}},y={};return{clearAsync:s,initAsync:a,startKeepAliveServiceWorker:()=>c(n.service_worker_keep_alive_path),isServiceWorkerProxyActiveAsync:()=>tx(n.service_worker_keep_alive_path),setSessionStateAsync:u,getSessionStateAsync:d,setNonceAsync:h,getNonceAsync:p,setLoginParams:g=>{y[e]=g,localStorage[`oidc.login.${e}`]=JSON.stringify(g)},getLoginParams:()=>{const g=localStorage[`oidc.login.${e}`];return y[e]||(y[e]=JSON.parse(g)),y[e]},getStateAsync:async()=>{let g=(await ut(i)({type:"getState",data:null,configurationName:e})).state;return g||(g=sessionStorage[`oidc.state.${e}`],console.warn("state not found in service worker, using sessionStorage")),g},setStateAsync:async g=>(sessionStorage[`oidc.state.${e}`]=g,ut(i)({type:"setState",data:{state:g},configurationName:e})),getCodeVerifierAsync:async()=>{let g=(await ut(i)({type:"getCodeVerifier",data:null,configurationName:e})).codeVerifier;return g||(g=sessionStorage[`oidc.code_verifier.${e}`],console.warn("codeVerifier not found in service worker, using sessionStorage")),g},setCodeVerifierAsync:async g=>(sessionStorage[`oidc.code_verifier.${e}`]=g,ut(i)({type:"setCodeVerifier",data:{codeVerifier:g},configurationName:e})),setDemonstratingProofOfPossessionNonce:async g=>{await ut(i)({type:"setDemonstratingProofOfPossessionNonce",data:{demonstratingProofOfPossessionNonce:g},configurationName:e})},getDemonstratingProofOfPossessionNonce:async()=>(await ut(i)({type:"getDemonstratingProofOfPossessionNonce",data:null,configurationName:e})).demonstratingProofOfPossessionNonce,setDemonstratingProofOfPossessionJwkAsync:async g=>{const _=JSON.stringify(g);await ut(i)({type:"setDemonstratingProofOfPossessionJwk",data:{demonstratingProofOfPossessionJwkJson:_},configurationName:e})},getDemonstratingProofOfPossessionJwkAsync:async()=>{const g=await ut(i)({type:"getDemonstratingProofOfPossessionJwk",data:null,configurationName:e});return g.demonstratingProofOfPossessionJwkJson?JSON.parse(g.demonstratingProofOfPossessionJwkJson):null}}},Xr={},rx=(n,e=window.sessionStorage,t)=>{if(!Xr[n]&&e){const i=e.getItem(n);i&&(Xr[n]=JSON.parse(i))}const r=1e3*t;return Xr[n]&&Xr[n].timestamp+r>Date.now()?Xr[n].result:null},ix=(n,e,t=window.sessionStorage)=>{const r=Date.now();Xr[n]={result:e,timestamp:r},t&&t.setItem(n,JSON.stringify({result:e,timestamp:r}))};function um(n){return new TextEncoder().encode(n)}function fm(n){return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function sx(n){return encodeURIComponent(n).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode(parseInt(t,16))})}const Uc=n=>{let e="";return n.forEach(function(t){e+=String.fromCharCode(t)}),fm(e)};function yh(n){return fm(sx(n))}const ox={importKeyAlgorithm:{name:"ECDSA",namedCurve:"P-256",hash:{name:"ES256"}},signAlgorithm:{name:"ECDSA",hash:{name:"SHA-256"}},generateKeyAlgorithm:{name:"ECDSA",namedCurve:"P-256"},digestAlgorithm:{name:"SHA-256"},jwtHeaderAlgorithm:"ES256"},ax=n=>async(e,t,r,i,s="dpop+jwt")=>{switch(e=Object.assign({},e),t.typ=s,t.alg=i.jwtHeaderAlgorithm,t.alg){case"ES256":t.jwk={kty:e.kty,crv:e.crv,x:e.x,y:e.y};break;case"RS256":t.jwk={kty:e.kty,n:e.n,e:e.e,kid:t.kid};break;default:throw new Error("Unknown or not implemented JWS algorithm")}const a={protected:yh(JSON.stringify(t)),payload:yh(JSON.stringify(r))},c=i.importKeyAlgorithm,u=!0,d=["sign"],h=await n.crypto.subtle.importKey("jwk",e,c,u,d),p=um(`${a.protected}.${a.payload}`),y=i.signAlgorithm,g=await n.crypto.subtle.sign(y,h,p);return a.signature=Uc(new Uint8Array(g)),`${a.protected}.${a.payload}.${a.signature}`},lx={sign:ax},cx=n=>async e=>{const t=e,r=!0,i=["sign","verify"],s=await n.crypto.subtle.generateKey(t,r,i);return await n.crypto.subtle.exportKey("jwk",s.privateKey)},ux=n=>{const e=Object.assign({},n);return delete e.d,e.key_ops=["verify"],e},fx={generate:cx,neuter:ux},dx=n=>async(e,t)=>{let r;switch(e.kty){case"EC":r='{"crv":"CRV","kty":"EC","x":"X","y":"Y"}'.replace("CRV",e.crv).replace("X",e.x).replace("Y",e.y);break;case"RSA":r='{"e":"E","kty":"RSA","n":"N"}'.replace("E",e.e).replace("N",e.n);break;default:throw new Error("Unknown or not implemented JWK type")}const i=await n.crypto.subtle.digest(t,um(r));return Uc(new Uint8Array(i))},hx={thumbprint:dx},px=n=>async e=>await fx.generate(n)(e),dm=n=>e=>async(t,r="POST",i,s={})=>{const a={jti:btoa(mx()),htm:r,htu:i,iat:Math.round(Date.now()/1e3),...s},c=await hx.thumbprint(n)(t,e.digestAlgorithm);return await lx.sign(n)(t,{kid:c},a,e)},mx=()=>{const n="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",e="0123456789abcdef";let t=0,r="";for(let i=0;i<36;i++)n[i]!=="-"&&n[i]!=="4"&&(t=Math.random()*16|0),n[i]==="x"?r+=e[t]:n[i]==="y"?(t&=3,t|=8,r+=e[t]):r+=n[i];return r},hm=()=>{const n=typeof window<"u"&&!!window.crypto,e=n&&!!window.crypto.subtle;return{hasCrypto:n,hasSubtleCrypto:e}},uc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",gx=n=>{const e=[];for(let t=0;t<n.byteLength;t+=1){const r=n[t]%uc.length;e.push(uc[r])}return e.join("")},fc=n=>{const e=new Uint8Array(n),{hasCrypto:t}=hm();if(t)window.crypto.getRandomValues(e);else for(let r=0;r<n;r+=1)e[r]=Math.random()*uc.length|0;return gx(e)};function yx(n){const e=new ArrayBuffer(n.length),t=new Uint8Array(e);for(let r=0;r<n.length;r++)t[r]=n.charCodeAt(r);return t}function pm(n){return new Promise((e,t)=>{crypto.subtle.digest("SHA-256",yx(n)).then(r=>e(Uc(new Uint8Array(r))),r=>t(r))})}const _x=n=>{if(n.length<43||n.length>128)return Promise.reject(new Error("Invalid code length."));const{hasSubtleCrypto:e}=hm();return e?pm(n):Promise.reject(new Error("window.crypto.subtle is unavailable."))},bx=60*60,vx=n=>async(e,t=bx,r=window.sessionStorage,i=1e4)=>{const s=`${e}/.well-known/openid-configuration`,a=`oidc.server:${e}`,c=rx(a,r,t);if(c)return new hc(c);const u=await ls(n)(s,{},i);if(u.status!==200)return null;const d=await u.json();return ix(a,d,r),new hc(d)},ls=n=>async(e,t={},r=1e4,i=0)=>{let s;try{const a=new AbortController;setTimeout(()=>a.abort(),r),s=await n(e,{...t,signal:a.signal})}catch(a){if(a.name==="AbortError"||a.message==="Network request failed"){if(i<=1)return await ls(n)(e,t,r,i+1);throw a}else throw console.error(a.message),a}return s},dc={refresh_token:"refresh_token",access_token:"access_token"},_h=n=>async(e,t,r=dc.refresh_token,i,s={},a=1e4)=>{const c={token:t,token_type_hint:r,client_id:i};for(const[h,p]of Object.entries(s))c[h]===void 0&&(c[h]=p);const u=[];for(const h in c){const p=encodeURIComponent(h),y=encodeURIComponent(c[h]);u.push(`${p}=${y}`)}const d=u.join("&");return(await ls(n)(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"},body:d},a)).status!==200?{success:!1}:{success:!0}},Sx=n=>async(e,t,r,i,s={},a,c=1e4)=>{for(const[g,_]of Object.entries(r))t[g]===void 0&&(t[g]=_);const u=[];for(const g in t){const _=encodeURIComponent(g),w=encodeURIComponent(t[g]);u.push(`${_}=${w}`)}const d=u.join("&"),h=await ls(n)(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8",...s},body:d},c);if(h.status!==200)return{success:!1,status:h.status,demonstratingProofOfPossessionNonce:null};const p=await h.json();let y=null;return h.headers.has(ko)&&(y=h.headers.get(ko)),{success:!0,status:h.status,data:Hc(p,i,a),demonstratingProofOfPossessionNonce:y}},wx=(n,e)=>async(t,r)=>{r=r?{...r}:{};const i=fc(128),s=await _x(i);await n.setCodeVerifierAsync(i),await n.setStateAsync(r.state),r.code_challenge=s,r.code_challenge_method="S256";let a="";if(r)for(const[c,u]of Object.entries(r))a===""?a+="?":a+="&",a+=`${c}=${encodeURIComponent(u)}`;e.open(`${t}${a}`)},ko="DPoP-Nonce",kx=n=>async(e,t,r,i,s=1e4)=>{t=t?{...t}:{},t.code_verifier=await n.getCodeVerifierAsync();const a=[];for(const p in t){const y=encodeURIComponent(p),g=encodeURIComponent(t[p]);a.push(`${y}=${g}`)}const c=a.join("&"),u=await ls(fetch)(e,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8",...r},body:c},s);if(await Promise.all([n.setCodeVerifierAsync(null),n.setStateAsync(null)]),u.status!==200)return{success:!1,status:u.status};let d=null;u.headers.has(ko)&&(d=u.headers.get(ko));const h=await u.json();return{success:!0,data:{state:t.state,tokens:Hc(h,null,i),demonstratingProofOfPossessionNonce:d}}};async function bh(n,e,t,r=null){const i=c=>{n.tokens=c},{tokens:s,status:a}=await po(n)(i,0,e,t,r);return await Ht(n.configuration,n.configurationName)||await Vt(n.configurationName,n.configuration.storage).setTokens(n.tokens),n.tokens?s:(await n.destroyAsync(a),null)}async function mm(n,e=!1,t=null,r=null){const i=n.configuration,s=`${i.client_id}_${n.configurationName}_${i.authority}`;let a;const c=await Ht(n.configuration,n.configurationName);if((i==null?void 0:i.storage)===(window==null?void 0:window.sessionStorage)&&!c||!navigator.locks)a=await bh(n,e,t,r);else{let u="retry";for(;u==="retry";)u=await navigator.locks.request(s,{ifAvailable:!0},async d=>d?await bh(n,e,t,r):(n.publishEvent(An.eventNames.syncTokensAsync_lock_not_available,{lock:"lock not available"}),"retry"));a=u}return a?(n.timeoutId&&(n.timeoutId=Qi(n,n.tokens.expiresAt,t,r)),n.tokens):null}const Qi=(n,e,t=null,r=null)=>{const i=n.configuration.refresh_time_before_tokens_expiration_in_second;return n.timeoutId&&ai.clearTimeout(n.timeoutId),ai.setTimeout(async()=>{const s={timeLeft:ji(i,e)};n.publishEvent(An.eventNames.token_timer,s),await mm(n,!1,t,r)},1e3)},Wn={FORCE_REFRESH:"FORCE_REFRESH",SESSION_LOST:"SESSION_LOST",NOT_CONNECTED:"NOT_CONNECTED",TOKENS_VALID:"TOKENS_VALID",TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID:"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID",LOGOUT_FROM_ANOTHER_TAB:"LOGOUT_FROM_ANOTHER_TAB",REQUIRE_SYNC_TOKENS:"REQUIRE_SYNC_TOKENS"},xx=n=>async(e,t,r,i=!1)=>{const s={nonce:null};if(!r)return{tokens:null,status:"NOT_CONNECTED",nonce:s};let a=s;const c=await n.initAsync(e.authority,e.authority_configuration),u=await Ht(e,t);if(u){const{status:h,tokens:p}=await u.initAsync(c,"syncTokensAsync",e);if(h==="LOGGED_OUT")return{tokens:null,status:"LOGOUT_FROM_ANOTHER_TAB",nonce:s};if(h==="SESSIONS_LOST")return{tokens:null,status:"SESSIONS_LOST",nonce:s};if(!h||!p)return{tokens:null,status:"REQUIRE_SYNC_TOKENS",nonce:s};if(p.issuedAt!==r.issuedAt){const y=ji(e.refresh_time_before_tokens_expiration_in_second,p.expiresAt)>0?"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID":"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID",g=await u.getNonceAsync();return{tokens:p,status:y,nonce:g}}a=await u.getNonceAsync()}else{const h=Vt(t,e.storage??sessionStorage),p=await h.initAsync();let{tokens:y}=p;const{status:g}=p;if(y&&(y=Vc(y,n.tokens,e.token_renew_mode)),y){if(g==="SESSIONS_LOST")return{tokens:null,status:"SESSIONS_LOST",nonce:s};if(y.issuedAt!==r.issuedAt){const _=ji(e.refresh_time_before_tokens_expiration_in_second,y.expiresAt)>0?"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID":"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_INVALID",w=await h.getNonceAsync();return{tokens:y,status:_,nonce:w}}}else return{tokens:null,status:"LOGOUT_FROM_ANOTHER_TAB",nonce:s};a=await h.getNonceAsync()}const d=ji(e.refresh_time_before_tokens_expiration_in_second,r.expiresAt)>0?"TOKENS_VALID":"TOKENS_INVALID";return i?{tokens:r,status:"FORCE_REFRESH",nonce:a}:{tokens:r,status:d,nonce:a}},po=n=>async(e,t=0,r=!1,i=null,s=null)=>{if(!navigator.onLine&&document.hidden)return{tokens:n.tokens,status:"GIVE_UP"};let a=6;for(;!navigator.onLine&&a>0;)await zo({milliseconds:1e3}),a--,n.publishEvent(ce.refreshTokensAsync,{message:`wait because navigator is offline try ${a}`});const c=document.hidden,u=c?t:t+1;if(t>4)return c?{tokens:n.tokens,status:"GIVE_UP"}:(e(null),n.publishEvent(ce.refreshTokensAsync_error,{message:"refresh token"}),{tokens:null,status:"SESSION_LOST"});i||(i={});const d=n.configuration,h=(y,g=null,_=null)=>Kc(n.configurationName,n.configuration,n.publishEvent.bind(n))(y,g,_),p=async()=>{try{let y;const g=await Ht(d,n.configurationName);g?y=g.getLoginParams():y=Vt(n.configurationName,d.storage).getLoginParams();const _=await h({...y.extras,...i,prompt:"none",scope:s});return _?_.error?(e(null),n.publishEvent(ce.refreshTokensAsync_error,{message:"refresh token silent"}),{tokens:null,status:"SESSION_LOST"}):(e(_.tokens),n.publishEvent(An.eventNames.token_renewed,{}),{tokens:_.tokens,status:"LOGGED"}):(e(null),n.publishEvent(ce.refreshTokensAsync_error,{message:"refresh token silent not active"}),{tokens:null,status:"SESSION_LOST"})}catch(y){return console.error(y),n.publishEvent(ce.refreshTokensAsync_silent_error,{message:"exceptionSilent",exception:y.message}),await po(n)(e,u,r,i,s)}};try{const{status:y,tokens:g,nonce:_}=await xx(n)(d,n.configurationName,n.tokens,r);switch(y){case Wn.SESSION_LOST:return e(null),n.publishEvent(ce.refreshTokensAsync_error,{message:"refresh token session lost"}),{tokens:null,status:"SESSION_LOST"};case Wn.NOT_CONNECTED:return e(null),{tokens:null,status:null};case Wn.TOKENS_VALID:return e(g),{tokens:g,status:"LOGGED_IN"};case Wn.TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID:return e(g),n.publishEvent(An.eventNames.token_renewed,{reason:"TOKEN_UPDATED_BY_ANOTHER_TAB_TOKENS_VALID"}),{tokens:g,status:"LOGGED_IN"};case Wn.LOGOUT_FROM_ANOTHER_TAB:return e(null),n.publishEvent(ce.logout_from_another_tab,{status:"session syncTokensAsync"}),{tokens:null,status:"LOGGED_OUT"};case Wn.REQUIRE_SYNC_TOKENS:return d.token_automatic_renew_mode==Yi.AutomaticOnlyWhenFetchExecuted&&Wn.FORCE_REFRESH!==y?(n.publishEvent(ce.tokensInvalidAndWaitingActionsToRefresh,{}),{tokens:n.tokens,status:"GIVE_UP"}):(n.publishEvent(ce.refreshTokensAsync_begin,{tryNumber:t}),await p());default:{if(d.token_automatic_renew_mode==Yi.AutomaticOnlyWhenFetchExecuted&&Wn.FORCE_REFRESH!==y)return n.publishEvent(ce.tokensInvalidAndWaitingActionsToRefresh,{}),{tokens:n.tokens,status:"GIVE_UP"};if(n.publishEvent(ce.refreshTokensAsync_begin,{refreshToken:g.refreshToken,status:y,tryNumber:t}),!g.refreshToken)return await p();const w=d.client_id,k=d.redirect_uri,A=d.authority,P={...d.token_request_extras?d.token_request_extras:{}};for(const[L,B]of Object.entries(i))L.endsWith(":token_request")&&(P[L.replace(":token_request","")]=B);return await(async()=>{const L={client_id:w,redirect_uri:k,grant_type:"refresh_token",refresh_token:g.refreshToken},B=await n.initAsync(A,d.authority_configuration),z=document.hidden?1e4:3e4*10,$=B.tokenEndpoint,J={};d.demonstrating_proof_of_possession&&(J.DPoP=await n.generateDemonstrationOfProofOfPossessionAsync(g.accessToken,$,"POST"));const K=await Sx(n.getFetch())($,L,P,g,J,d.token_renew_mode,z);if(K.success){const{isValid:V,reason:ne}=am(K.data,_.nonce,B);if(!V)return e(null),n.publishEvent(ce.refreshTokensAsync_error,{message:`refresh token return not valid tokens, reason: ${ne}`}),{tokens:null,status:"SESSION_LOST"};if(e(K.data),K.demonstratingProofOfPossessionNonce){const ve=await Ht(d,n.configurationName);ve?await ve.setDemonstratingProofOfPossessionNonce(K.demonstratingProofOfPossessionNonce):await Vt(n.configurationName,d.storage).setDemonstratingProofOfPossessionNonce(K.demonstratingProofOfPossessionNonce)}return n.publishEvent(ce.refreshTokensAsync_end,{success:K.success}),n.publishEvent(An.eventNames.token_renewed,{reason:"REFRESH_TOKEN"}),{tokens:K.data,status:"LOGGED_IN"}}else return n.publishEvent(ce.refreshTokensAsync_silent_error,{message:"bad request",tokenResponse:K}),K.status>=400&&K.status<500?(e(null),n.publishEvent(ce.refreshTokensAsync_error,{message:`session lost: ${K.status}`}),{tokens:null,status:"SESSION_LOST"}):await po(n)(e,u,r,i,s)})()}}}catch(y){return console.error(y),n.publishEvent(ce.refreshTokensAsync_silent_error,{message:"exception",exception:y.message}),new Promise((g,_)=>{setTimeout(()=>{po(n)(e,u,r,i,s).then(g).catch(_)},1e3)})}},Kc=(n,e,t)=>(r=null,i=null,s=null)=>{if(!e.silent_redirect_uri||!e.silent_login_uri)return Promise.resolve(null);try{t(ce.silentLoginAsync_begin,{});let a="";if(i&&(r==null&&(r={}),r.state=i),s!=null&&(r==null&&(r={}),r.scope=s),r!=null)for(const[p,y]of Object.entries(r))a===""?a=`?${encodeURIComponent(p)}=${encodeURIComponent(y)}`:a+=`&${encodeURIComponent(p)}=${encodeURIComponent(y)}`;const c=e.silent_login_uri+a,u=c.indexOf("/",c.indexOf("//")+2),d=c.substring(0,u),h=document.createElement("iframe");return h.width="0px",h.height="0px",h.id=`${n}_oidc_iframe`,h.setAttribute("src",c),document.body.appendChild(h),new Promise((p,y)=>{let g=!1;const _=()=>{window.removeEventListener("message",w),h.remove(),g=!0},w=k=>{if(k.origin===d&&k.source===h.contentWindow){const A=`${n}_oidc_tokens:`,P=`${n}_oidc_error:`,L=`${n}_oidc_exception:`,B=k.data;if(B&&typeof B=="string"&&!g){if(B.startsWith(A)){const z=JSON.parse(k.data.replace(A,""));t(ce.silentLoginAsync_end,{}),p(z),_()}else if(B.startsWith(P)){const z=JSON.parse(k.data.replace(P,""));t(ce.silentLoginAsync_error,z),p({error:"oidc_"+z.error,tokens:null,sessionState:null}),_()}else if(B.startsWith(L)){const z=JSON.parse(k.data.replace(L,""));t(ce.silentLoginAsync_error,z),y(new Error(z.error)),_()}}}};try{window.addEventListener("message",w);const k=e.silent_login_timeout;setTimeout(()=>{g||(_(),t(ce.silentLoginAsync_error,{reason:"timeout"}),y(new Error("timeout")))},k)}catch(k){_(),t(ce.silentLoginAsync_error,k),y(k)}})}catch(a){throw t(ce.silentLoginAsync_error,a),a}},Ex=(n,e,t,r,i)=>(s=null,a=void 0)=>{s={...s};const c=(u,d,h)=>Kc(e,t,r.bind(i))(u,d,h);return(async()=>{i.timeoutId&&ai.clearTimeout(i.timeoutId);let u;s&&"state"in s&&(u=s.state,delete s.state);try{const d=t.extras?{...t.extras,...s}:s,h=await c({...d,prompt:"none"},u,a);if(h)return i.tokens=h.tokens,r(ce.token_acquired,{}),i.timeoutId=Qi(i,i.tokens.expiresAt,s,a),{}}catch(d){return d}})()},Ox=(n,e,t)=>(r,i,s,a=!1)=>{const c=(u,d=void 0,h=void 0)=>Kc(n.configurationName,t,n.publishEvent.bind(n))(u,d,h);return new Promise((u,d)=>{if(t.silent_login_uri&&t.silent_redirect_uri&&t.monitor_session&&r&&s&&!a){const h=()=>{n.checkSessionIFrame.stop();const p=n.tokens;if(p===null)return;const y=p.idToken,g=p.idTokenPayload;return c({prompt:"none",id_token_hint:y,scope:t.scope||"openid"}).then(_=>{if(_.error)throw new Error(_.error);const w=_.tokens.idTokenPayload;if(g.sub===w.sub){const k=_.sessionState;n.checkSessionIFrame.start(_.sessionState),g.sid===w.sid?console.debug("SessionMonitor._callback: Same sub still logged in at OP, restarting check session iframe; session_state:",k):console.debug("SessionMonitor._callback: Same sub still logged in at OP, session state has changed, restarting check session iframe; session_state:",k)}else console.debug("SessionMonitor._callback: Different subject signed into OP:",w.sub)}).catch(async _=>{console.warn("SessionMonitor._callback: Silent login failed, logging out other tabs:",_);for(const[,w]of Object.entries(e))await w.logoutOtherTabAsync(t.client_id,g.sub)})};n.checkSessionIFrame=new Y1(h,i,r),n.checkSessionIFrame.load().then(()=>{n.checkSessionIFrame.start(s),u(n.checkSessionIFrame)}).catch(p=>{d(p)})}else u(null)})},Tx=n=>!!(n.os==="iOS"&&n.osVersion.startsWith("12")||n.os==="Mac OS X"&&n.osVersion.startsWith("10_15_6")),Ax=n=>{const e=n.appVersion,t=n.userAgent,r="-";let i=r;const s=[{s:"Windows 10",r:/(Windows 10.0|Windows NT 10.0)/},{s:"Windows 8.1",r:/(Windows 8.1|Windows NT 6.3)/},{s:"Windows 8",r:/(Windows 8|Windows NT 6.2)/},{s:"Windows 7",r:/(Windows 7|Windows NT 6.1)/},{s:"Windows Vista",r:/Windows NT 6.0/},{s:"Windows Server 2003",r:/Windows NT 5.2/},{s:"Windows XP",r:/(Windows NT 5.1|Windows XP)/},{s:"Windows 2000",r:/(Windows NT 5.0|Windows 2000)/},{s:"Windows ME",r:/(Win 9x 4.90|Windows ME)/},{s:"Windows 98",r:/(Windows 98|Win98)/},{s:"Windows 95",r:/(Windows 95|Win95|Windows_95)/},{s:"Windows NT 4.0",r:/(Windows NT 4.0|WinNT4.0|WinNT|Windows NT)/},{s:"Windows CE",r:/Windows CE/},{s:"Windows 3.11",r:/Win16/},{s:"Android",r:/Android/},{s:"Open BSD",r:/OpenBSD/},{s:"Sun OS",r:/SunOS/},{s:"Chrome OS",r:/CrOS/},{s:"Linux",r:/(Linux|X11(?!.*CrOS))/},{s:"iOS",r:/(iPhone|iPad|iPod)/},{s:"Mac OS X",r:/Mac OS X/},{s:"Mac OS",r:/(Mac OS|MacPPC|MacIntel|Mac_PowerPC|Macintosh)/},{s:"QNX",r:/QNX/},{s:"UNIX",r:/UNIX/},{s:"BeOS",r:/BeOS/},{s:"OS/2",r:/OS\/2/},{s:"Search Bot",r:/(nuhk|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask Jeeves\/Teoma|ia_archiver)/}];for(const c in s){const u=s[c];if(u.r.test(t)){i=u.s;break}}let a=r;switch(/Windows/.test(i)&&(a=/Windows (.*)/.exec(i)[1],i="Windows"),i){case"Mac OS":case"Mac OS X":case"Android":a=/(?:Android|Mac OS|Mac OS X|MacPPC|MacIntel|Mac_PowerPC|Macintosh) ([._\d]+)/.exec(t)[1];break;case"iOS":{const c=/OS (\d+)_(\d+)_?(\d+)?/.exec(e);c!=null&&c.length>2&&(a=c[1]+"."+c[2]+"."+(parseInt(c[3])|0));break}}return{os:i,osVersion:a}};function Cx(){const n=navigator.userAgent;let e,t=n.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];if(/trident/i.test(t[1]))return e=/\brv[ :]+(\d+)/g.exec(n)||[],{name:"ie",version:e[1]||""};if(t[1]==="Chrome"&&(e=n.match(/\bOPR|Edge\/(\d+)/),e!=null)){let r=e[1];if(!r){const i=n.split(e[0]+"/");i.length>1&&(r=i[1])}return{name:"opera",version:r}}return t=t[2]?[t[1],t[2]]:[navigator.appName,navigator.appVersion,"-?"],(e=n.match(/version\/(\d+)/i))!=null&&t.splice(1,1,e[1]),{name:t[0].toLowerCase(),version:t[1]}}const Mx=()=>{const{name:n,version:e}=Cx();if(n==="chrome"&&parseInt(e)<=70||n==="opera"&&(!e||parseInt(e.split(".")[0])<80)||n==="ie")return!1;const t=Ax(navigator);return!Tx(t)},Nx=async n=>{let e;if(n.tokens!=null)return!1;n.publishEvent(ce.tryKeepExistingSessionAsync_begin,{});try{const t=n.configuration,r=await n.initAsync(t.authority,t.authority_configuration);if(e=await Ht(t,n.configurationName),e){const{tokens:i}=await e.initAsync(r,"tryKeepExistingSessionAsync",t);if(i){e.startKeepAliveServiceWorker(),n.tokens=i;const s=e.getLoginParams(n.configurationName);n.timeoutId=Qi(n,n.tokens.expiresAt,s.extras,s.scope);const a=await e.getSessionStateAsync();return await n.startCheckSessionAsync(r.checkSessionIframe,t.client_id,a),t.preload_user_info&&await n.userInfoAsync(),n.publishEvent(ce.tryKeepExistingSessionAsync_end,{success:!0,message:"tokens inside ServiceWorker are valid"}),!0}n.publishEvent(ce.tryKeepExistingSessionAsync_end,{success:!1,message:"no exiting session found"})}else{t.service_worker_relative_url&&n.publishEvent(ce.service_worker_not_supported_by_browser,{message:"service worker is not supported by this browser"});const i=Vt(n.configurationName,t.storage??sessionStorage),{tokens:s}=await i.initAsync();if(s){n.tokens=Vc(s,null,t.token_renew_mode);const a=i.getLoginParams();n.timeoutId=Qi(n,n.tokens.expiresAt,a.extras,a.scope);const c=await i.getSessionStateAsync();return await n.startCheckSessionAsync(r.checkSessionIframe,t.client_id,c),t.preload_user_info&&await n.userInfoAsync(),n.publishEvent(ce.tryKeepExistingSessionAsync_end,{success:!0,message:"tokens inside storage are valid"}),!0}}return n.publishEvent(ce.tryKeepExistingSessionAsync_end,{success:!1,message:e?"service worker sessions not retrieved":"session storage sessions not retrieved"}),!1}catch(t){return console.error(t),e&&await e.clearAsync(),n.publishEvent(ce.tryKeepExistingSessionAsync_error,"tokens inside ServiceWorker are invalid"),!1}},gm=n=>{const e=n.match(/^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/);if(!e)throw new Error("Invalid URL");let t=e[6],r=e[7];if(r){const i=r.split("?");i.length===2&&(r=i[0],t=i[1])}return t.startsWith("?")&&(t=t.slice(1)),e&&{href:n,protocol:e[1],host:e[2],hostname:e[3],port:e[4],path:e[5],search:t,hash:r}},$i=n=>{const e=gm(n);let{path:t}=e;t.endsWith("/")&&(t=t.slice(0,-1));let{hash:r}=e;return r==="#_=_"&&(r=""),r&&(t+=r),t},xo=n=>{const e=gm(n),{search:t}=e;return Ix(t)},Ix=n=>{const e={};let t,r,i;const s=n.split("&");for(r=0,i=s.length;r<i;r++)t=s[r].split("="),e[decodeURIComponent(t[0])]=decodeURIComponent(t[1]);return e},Px=(n,e,t,r,i)=>(s=void 0,a=null,c=!1,u=void 0)=>{const d=a;return a={...a},(async()=>{const h=s||i.getPath();if("state"in a||(a.state=fc(16)),t(ce.loginAsync_begin,{}),a)for(const p of Object.keys(a))p.endsWith(":token_request")&&delete a[p];try{const p=c?e.silent_redirect_uri:e.redirect_uri;u||(u=e.scope);const y=e.extras?{...e.extras,...a}:a;y.nonce||(y.nonce=fc(12));const g={nonce:y.nonce},_=await Ht(e,n),w=await r(e.authority,e.authority_configuration);let k;if(_)_.setLoginParams({callbackPath:h,extras:d,scope:u}),await _.initAsync(w,"loginAsync",e),await _.setNonceAsync(g),_.startKeepAliveServiceWorker(),k=_;else{const P=Vt(n,e.storage??sessionStorage);P.setLoginParams({callbackPath:h,extras:d,scope:u}),await P.setNonceAsync(g),k=P}const A={client_id:e.client_id,redirect_uri:p,scope:u,response_type:"code",...y};await wx(k,i)(w.authorizationEndpoint,A)}catch(p){throw t(ce.loginAsync_error,p),p}})()},Rx=n=>async(e=!1)=>{try{n.publishEvent(ce.loginCallbackAsync_begin,{});const t=n.configuration,r=t.client_id,i=e?t.silent_redirect_uri:t.redirect_uri,s=t.authority,a=t.token_request_timeout,c=await n.initAsync(s,t.authority_configuration),u=n.location.getCurrentHref(),d=xo(u),h=d.session_state,p=await Ht(t,n.configurationName);let y,g,_,w;if(p)await p.initAsync(c,"loginCallbackAsync",t),await p.setSessionStateAsync(h),g=await p.getNonceAsync(),_=p.getLoginParams(),w=await p.getStateAsync(),p.startKeepAliveServiceWorker(),y=p;else{const ne=Vt(n.configurationName,t.storage??sessionStorage);await ne.setSessionStateAsync(h),g=await ne.getNonceAsync(),_=ne.getLoginParams(),w=await ne.getStateAsync(),y=ne}if(d.error||d.error_description)throw new Error(`Error from OIDC server: ${d.error} - ${d.error_description}`);if(d.iss&&d.iss!==c.issuer)throw console.error(),new Error(`Issuer not valid (expected: ${c.issuer}, received: ${d.iss})`);if(d.state&&d.state!==w)throw new Error(`State not valid (expected: ${w}, received: ${d.state})`);const k={code:d.code,grant_type:"authorization_code",client_id:t.client_id,redirect_uri:i},A={};if(t.token_request_extras)for(const[ne,ve]of Object.entries(t.token_request_extras))A[ne]=ve;if(_!=null&&_.extras)for(const[ne,ve]of Object.entries(_.extras))ne.endsWith(":token_request")&&(A[ne.replace(":token_request","")]=ve);const P=c.tokenEndpoint,L={};if(t.demonstrating_proof_of_possession)if(p)L.DPoP=`DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${n.configurationName}`;else{const ne=await px(window)(t.demonstrating_proof_of_possession_configuration.generateKeyAlgorithm);await Vt(n.configurationName,t.storage).setDemonstratingProofOfPossessionJwkAsync(ne),L.DPoP=await dm(window)(t.demonstrating_proof_of_possession_configuration)(ne,"POST",P)}const B=await kx(y)(P,{...k,...A},L,n.configuration.token_renew_mode,a);if(!B.success)throw new Error("Token request failed");let z;const $=B.data.tokens,J=B.data.demonstratingProofOfPossessionNonce;if(B.data.state!==A.state)throw new Error("state is not valid");const{isValid:K,reason:V}=am($,g.nonce,c);if(!K)throw new Error(`Tokens are not OpenID valid, reason: ${V}`);if(p){if($.refreshToken&&!$.refreshToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))throw new Error("Refresh token should be hidden by service worker");if(J&&$!=null&&$.accessToken.includes("SECURED_BY_OIDC_SERVICE_WORKER"))throw new Error("Demonstration of proof of possession require Access token not hidden by service worker")}if(p)await p.initAsync(c,"syncTokensAsync",t),z=p.getLoginParams(),J&&await p.setDemonstratingProofOfPossessionNonce(J);else{const ne=Vt(n.configurationName,t.storage);z=ne.getLoginParams(),J&&await ne.setDemonstratingProofOfPossessionNonce(J)}return await n.startCheckSessionAsync(c.checkSessionIframe,r,h,e),n.publishEvent(ce.loginCallbackAsync_end,{}),{tokens:$,state:"request.state",callbackPath:z.callbackPath,scope:d.scope,extras:z.extras}}catch(t){throw console.error(t),n.publishEvent(ce.loginCallbackAsync_error,t),t}},vh={access_token:"access_token",refresh_token:"refresh_token"},El=(n,e)=>{const t={};if(n){for(const[r,i]of Object.entries(n))if(r.endsWith(e)){const s=r.replace(e,"");t[s]=i}return t}return t},Dx=n=>{const e={};if(n){for(const[t,r]of Object.entries(n))t.includes(":")||(e[t]=r);return e}return e},Lx=n=>async e=>{ai.clearTimeout(n.timeoutId),n.timeoutId=null,n.checkSessionIFrame&&n.checkSessionIFrame.stop();const t=await Ht(n.configuration,n.configurationName);t?await t.clearAsync(e):await Vt(n.configurationName,n.configuration.storage).clearAsync(e),n.tokens=null,n.userInfo=null},Bx=(n,e,t,r,i)=>async(s=void 0,a=null)=>{var c,u;const d=n.configuration,h=await n.initAsync(d.authority,d.authority_configuration);s&&typeof s!="string"&&(s=void 0,r.warn("callbackPathOrUrl path is not a string"));const p=s??i.getPath();let y=!1;s&&(y=s.includes("https://")||s.includes("http://"));const g=y?s:i.getOrigin()+p,_=n.tokens?n.tokens.idToken:"";try{const P=h.revocationEndpoint;if(P){const L=[],B=n.tokens?n.tokens.accessToken:null;if(B&&d.logout_tokens_to_invalidate.includes(vh.access_token)){const $=El(a,":revoke_access_token"),J=_h(t)(P,B,dc.access_token,d.client_id,$);L.push(J)}const z=n.tokens?n.tokens.refreshToken:null;if(z&&d.logout_tokens_to_invalidate.includes(vh.refresh_token)){const $=El(a,":revoke_refresh_token"),J=_h(t)(P,z,dc.refresh_token,d.client_id,$);L.push(J)}L.length>0&&await Promise.all(L)}}catch(P){r.warn("logoutAsync: error when revoking tokens, if the error persist, you ay configure property logout_tokens_to_invalidate from configuration to avoid this error"),r.warn(P)}const w=((u=(c=n.tokens)==null?void 0:c.idTokenPayload)==null?void 0:u.sub)??null;await n.destroyAsync("LOGGED_OUT");for(const[,P]of Object.entries(e))P!==n?await n.logoutSameTabAsync(n.configuration.client_id,w):n.publishEvent(ce.logout_from_same_tab,{});const k=El(a,":oidc");if(k&&k.no_reload==="true")return;const A=Dx(a);if(h.endSessionEndpoint){"id_token_hint"in A||(A.id_token_hint=_),!("post_logout_redirect_uri"in A)&&s!==null&&(A.post_logout_redirect_uri=g);let P="";for(const[L,B]of Object.entries(A))B!=null&&(P===""?P+="?":P+="&",P+=`${L}=${encodeURIComponent(B)}`);i.open(`${h.endSessionEndpoint}${P}`)}else i.reload()},ym=(n,e,t=!1)=>async(...r)=>{var i;const[s,a,...c]=r,u=a?{...a}:{method:"GET"};let d=new Headers;u.headers&&(d=u.headers instanceof Headers?u.headers:new Headers(u.headers));const h={getTokens:()=>e.tokens,configuration:{token_automatic_renew_mode:e.configuration.token_automatic_renew_mode,refresh_time_before_tokens_expiration_in_second:e.configuration.refresh_time_before_tokens_expiration_in_second},renewTokensAsync:e.renewTokensAsync.bind(e)},p=await om(h),y=(i=p==null?void 0:p.tokens)==null?void 0:i.accessToken;if(d.has("Accept")||d.set("Accept","application/json"),y){if(e.configuration.demonstrating_proof_of_possession&&t){const _=await e.generateDemonstrationOfProofOfPossessionAsync(y,s.toString(),u.method);d.set("Authorization",`DPoP ${y}`),d.set("DPoP",_)}else d.set("Authorization",`Bearer ${y}`);u.credentials||(u.credentials="same-origin")}const g={...u,headers:d};return await n(s,g,...c)},Fx=n=>async(e=!1,t=!1)=>{if(n.userInfo!=null&&!e)return n.userInfo;const r=n.configuration,i=(await n.initAsync(r.authority,r.authority_configuration)).userInfoEndpoint,s=await(async()=>{const a=await ym(fetch,n,t)(i);return a.status!==200?null:a.json()})();return n.userInfo=s,s},_m=()=>fetch;let hc=class{constructor(e){this.authorizationEndpoint=e.authorization_endpoint,this.tokenEndpoint=e.token_endpoint,this.revocationEndpoint=e.revocation_endpoint,this.userInfoEndpoint=e.userinfo_endpoint,this.checkSessionIframe=e.check_session_iframe,this.issuer=e.issuer,this.endSessionEndpoint=e.end_session_endpoint}};const gr={},$x=(n,e=new oi)=>(t,r="default")=>(gr[r]||(gr[r]=new An(t,r,n,e)),gr[r]),zx=async n=>{const{parsedTokens:e,callbackPath:t,extras:r,scope:i}=await n.loginCallbackAsync();return n.timeoutId=Qi(n,e.expiresAt,r,i),{callbackPath:t}},Wx=n=>Math.floor(Math.random()*n),pc=class bm{constructor(e,t="default",r,i=new oi){this.initPromise=null,this.tryKeepExistingSessionPromise=null,this.loginPromise=null,this.loginCallbackPromise=null,this.loginCallbackWithAutoTokensRenewPromise=null,this.userInfoPromise=null,this.renewTokensPromise=null,this.logoutPromise=null;let s=e.silent_login_uri;e.silent_redirect_uri&&!e.silent_login_uri&&(s=`${e.silent_redirect_uri.replace("-callback","").replace("callback","")}-login`);let a=e.refresh_time_before_tokens_expiration_in_second??120;a>60&&(a=a-Math.floor(Math.random()*40)),this.location=i??new oi;const c=e.service_worker_update_require_callback??nx(this.location);this.configuration={...e,silent_login_uri:s,token_automatic_renew_mode:e.token_automatic_renew_mode??Yi.AutomaticBeforeTokenExpiration,monitor_session:e.monitor_session??!1,refresh_time_before_tokens_expiration_in_second:a,silent_login_timeout:e.silent_login_timeout??12e3,token_renew_mode:e.token_renew_mode??cc.access_token_or_id_token_invalid,demonstrating_proof_of_possession:e.demonstrating_proof_of_possession??!1,authority_timeout_wellknowurl_in_millisecond:e.authority_timeout_wellknowurl_in_millisecond??1e4,logout_tokens_to_invalidate:e.logout_tokens_to_invalidate??["access_token","refresh_token"],service_worker_update_require_callback:c,service_worker_activate:e.service_worker_activate??Mx,demonstrating_proof_of_possession_configuration:e.demonstrating_proof_of_possession_configuration??ox,preload_user_info:e.preload_user_info??!1},this.getFetch=r??_m,this.configurationName=t,this.tokens=null,this.userInfo=null,this.events=[],this.timeoutId=null,this.loginCallbackWithAutoTokensRenewAsync.bind(this),this.initAsync.bind(this),this.loginCallbackAsync.bind(this),this.subscribeEvents.bind(this),this.removeEventSubscription.bind(this),this.publishEvent.bind(this),this.destroyAsync.bind(this),this.logoutAsync.bind(this),this.renewTokensAsync.bind(this),this.initAsync(this.configuration.authority,this.configuration.authority_configuration)}subscribeEvents(e){const t=Wx(9999999999999).toString();return this.events.push({id:t,func:e}),t}removeEventSubscription(e){const t=this.events.filter(r=>r.id!==e);this.events=t}publishEvent(e,t){this.events.forEach(r=>{r.func(e,t)})}static get(e="default"){const t=typeof process>"u";if(!Object.prototype.hasOwnProperty.call(gr,e)&&t)throw Error(`OIDC library does seem initialized.
24
+ Please checkout that you are using OIDC hook inside a <OidcProvider configurationName="${e}"></OidcProvider> component.`);return gr[e]}_silentLoginCallbackFromIFrame(){if(this.configuration.silent_redirect_uri&&this.configuration.silent_login_uri){const e=this.location,t=xo(e.getCurrentHref());window.parent.postMessage(`${this.configurationName}_oidc_tokens:${JSON.stringify({tokens:this.tokens,sessionState:t.session_state})}`,e.getOrigin())}}_silentLoginErrorCallbackFromIFrame(e=null){if(this.configuration.silent_redirect_uri&&this.configuration.silent_login_uri){const t=this.location,r=xo(t.getCurrentHref());r.error?window.parent.postMessage(`${this.configurationName}_oidc_error:${JSON.stringify({error:r.error})}`,t.getOrigin()):window.parent.postMessage(`${this.configurationName}_oidc_exception:${JSON.stringify({error:e==null?"":e.toString()})}`,t.getOrigin())}}async silentLoginCallbackAsync(){try{await this.loginCallbackAsync(!0),this._silentLoginCallbackFromIFrame()}catch(e){console.error(e),this._silentLoginErrorCallbackFromIFrame(e)}}async initAsync(e,t){if(this.initPromise!==null)return this.initPromise;const r=async()=>{if(t!=null)return new hc({authorization_endpoint:t.authorization_endpoint,end_session_endpoint:t.end_session_endpoint,revocation_endpoint:t.revocation_endpoint,token_endpoint:t.token_endpoint,userinfo_endpoint:t.userinfo_endpoint,check_session_iframe:t.check_session_iframe,issuer:t.issuer});const i=await Ht(this.configuration,this.configurationName)?window.sessionStorage:null;return await vx(this.getFetch())(e,this.configuration.authority_time_cache_wellknowurl_in_second??60*60,i,this.configuration.authority_timeout_wellknowurl_in_millisecond)};return this.initPromise=r(),this.initPromise.finally(()=>{this.initPromise=null})}async tryKeepExistingSessionAsync(){return this.tryKeepExistingSessionPromise!==null?this.tryKeepExistingSessionPromise:(this.tryKeepExistingSessionPromise=Nx(this),this.tryKeepExistingSessionPromise.finally(()=>{this.tryKeepExistingSessionPromise=null}))}async startCheckSessionAsync(e,t,r,i=!1){await Ox(this,gr,this.configuration)(e,t,r,i)}async loginAsync(e=void 0,t=null,r=!1,i=void 0,s=!1){return this.logoutPromise&&await this.logoutPromise,this.loginPromise!==null?this.loginPromise:(s?this.loginPromise=Ex(window,this.configurationName,this.configuration,this.publishEvent.bind(this),this)(t,i):this.loginPromise=Px(this.configurationName,this.configuration,this.publishEvent.bind(this),this.initAsync.bind(this),this.location)(e,t,r,i),this.loginPromise.finally(()=>{this.loginPromise=null}))}async loginCallbackAsync(e=!1){if(this.loginCallbackPromise!==null)return this.loginCallbackPromise;const t=async()=>{const r=await Rx(this)(e),i=r.tokens;return this.tokens=i,await Ht(this.configuration,this.configurationName)||Vt(this.configurationName,this.configuration.storage).setTokens(i),this.publishEvent(bm.eventNames.token_acquired,i),this.configuration.preload_user_info&&await this.userInfoAsync(),{parsedTokens:i,state:r.state,callbackPath:r.callbackPath,scope:r.scope,extras:r.extras}};return this.loginCallbackPromise=t(),this.loginCallbackPromise.finally(()=>{this.loginCallbackPromise=null})}async generateDemonstrationOfProofOfPossessionAsync(e,t,r,i={}){const s=this.configuration,a={ath:await pm(e),...i};if(await Ht(s,this.configurationName))return`DPOP_SECURED_BY_OIDC_SERVICE_WORKER_${this.configurationName}#tabId=${cm(this.configurationName)}`;const c=Vt(this.configurationName,s.storage),u=await c.getDemonstratingProofOfPossessionJwkAsync(),d=c.getDemonstratingProofOfPossessionNonce();return d&&(a.nonce=d),await dm(window)(s.demonstrating_proof_of_possession_configuration)(u,r,t,a)}loginCallbackWithAutoTokensRenewAsync(){return this.loginCallbackWithAutoTokensRenewPromise!==null?this.loginCallbackWithAutoTokensRenewPromise:(this.loginCallbackWithAutoTokensRenewPromise=zx(this),this.loginCallbackWithAutoTokensRenewPromise.finally(()=>{this.loginCallbackWithAutoTokensRenewPromise=null}))}userInfoAsync(e=!1,t=!1){return this.userInfoPromise!==null?this.userInfoPromise:(this.userInfoPromise=Fx(this)(e,t),this.userInfoPromise.finally(()=>{this.userInfoPromise=null}))}async renewTokensAsync(e=null,t=null){if(this.renewTokensPromise!==null)return this.renewTokensPromise;if(this.timeoutId)return ai.clearTimeout(this.timeoutId),this.renewTokensPromise=mm(this,!0,e,t),this.renewTokensPromise.finally(()=>{this.renewTokensPromise=null})}async destroyAsync(e){return await Lx(this)(e)}async logoutSameTabAsync(e,t){this.configuration.monitor_session&&this.configuration.client_id===e&&t&&this.tokens&&this.tokens.idTokenPayload&&this.tokens.idTokenPayload.sub===t&&(await this.destroyAsync("LOGGED_OUT"),this.publishEvent(ce.logout_from_same_tab,{mmessage:"SessionMonitor",sub:t}))}async logoutOtherTabAsync(e,t){this.configuration.monitor_session&&this.configuration.client_id===e&&t&&this.tokens&&this.tokens.idTokenPayload&&this.tokens.idTokenPayload.sub===t&&(await this.destroyAsync("LOGGED_OUT"),this.publishEvent(ce.logout_from_another_tab,{message:"SessionMonitor",sub:t}))}async logoutAsync(e=void 0,t=null){return this.logoutPromise?this.logoutPromise:(this.logoutPromise=Bx(this,gr,this.getFetch(),console,this.location)(e,t),this.logoutPromise.finally(()=>{this.logoutPromise=null}))}};pc.getOrCreate=(n,e)=>(t,r="default")=>$x(n,e)(t,r),pc.eventNames=ce;let An=pc;const mo=class vm{constructor(e){this._oidc=e}subscribeEvents(e){return this._oidc.subscribeEvents(e)}removeEventSubscription(e){this._oidc.removeEventSubscription(e)}publishEvent(e,t){this._oidc.publishEvent(e,t)}static get(e="default"){return new vm(An.get(e))}tryKeepExistingSessionAsync(){return this._oidc.tryKeepExistingSessionAsync()}loginAsync(e=void 0,t=null,r=!1,i=void 0,s=!1){return this._oidc.loginAsync(e,t,r,i,s)}logoutAsync(e=void 0,t=null){return this._oidc.logoutAsync(e,t)}silentLoginCallbackAsync(){return this._oidc.silentLoginCallbackAsync()}renewTokensAsync(e=null,t=null){return this._oidc.renewTokensAsync(e,t)}loginCallbackAsync(){return this._oidc.loginCallbackWithAutoTokensRenewAsync()}get tokens(){return this._oidc.tokens}get configuration(){return this._oidc.configuration}async generateDemonstrationOfProofOfPossessionAsync(e,t,r,i={}){return this._oidc.generateDemonstrationOfProofOfPossessionAsync(e,t,r,i)}async getValidTokenAsync(e=200,t=50){const r=this._oidc,i={getTokens:()=>r.tokens,configuration:{token_automatic_renew_mode:r.configuration.token_automatic_renew_mode,refresh_time_before_tokens_expiration_in_second:r.configuration.refresh_time_before_tokens_expiration_in_second},renewTokensAsync:r.renewTokensAsync.bind(r)};return om(i,e,t)}fetchWithTokens(e,t=!1){return ym(e,this._oidc,t)}async userInfoAsync(e=!1,t=!1){return this._oidc.userInfoAsync(e,t)}userInfo(){return this._oidc.userInfo}};mo.getOrCreate=(n,e=new oi)=>(t,r="default")=>new mo(An.getOrCreate(n,e)(t,r)),mo.eventNames=An.eventNames;let me=mo;const Sm=()=>Y.jsx("div",{className:"oidc-authenticating",children:Y.jsxs("div",{className:"oidc-authenticating__container",children:[Y.jsx("h1",{className:"oidc-authenticating__title",children:"Error authentication"}),Y.jsx("p",{className:"oidc-authenticating__content",children:"An error occurred during authentication."})]})}),Vx=()=>Y.jsx("div",{className:"oidc-authenticating",children:Y.jsxs("div",{className:"oidc-authenticating__container",children:[Y.jsx("h1",{className:"oidc-authenticating__title",children:"Authentication in progress"}),Y.jsx("p",{className:"oidc-authenticating__content",children:"You will be redirected to the login page."})]})}),Hx=()=>Math.random().toString(36).slice(2,8),Ux=(n,e)=>(t,r)=>{if(typeof n.CustomEvent=="function")return new n.CustomEvent(t,r);const i=r||{bubbles:!1,cancelable:!1,detail:void 0},s=e.createEvent("CustomEvent");return s.initCustomEvent(t,i.bubbles,i.cancelable,i.detail),s.prototype=n.Event.prototype,s},Kx=(n,e,t)=>({replaceState:(r,i)=>{const s=t(),a=i||n.history.state;n.history.replaceState({key:s,state:a},null,r),n.dispatchEvent(e("popstate"))}}),jx=()=>Kx(window,Ux(window,document),Hx),wm=()=>Y.jsx("div",{className:"oidc-callback",children:Y.jsxs("div",{className:"oidc-callback__container",children:[Y.jsx("h1",{className:"oidc-callback__title",children:"Authentication complete"}),Y.jsx("p",{className:"oidc-callback__content",children:"You will be redirected to your application."})]})}),qx=({callBackError:n,callBackSuccess:e,configurationName:t,withCustomHistory:r})=>{const[i,s]=q.useState(!1);q.useEffect(()=>{let u=!0;return(async()=>{const d=me.get;try{const{callbackPath:h}=await d(t).loginCallbackAsync();(r?r():jx()).replaceState(h||"/")}catch(h){u&&(console.warn(h),s(!0))}})(),()=>{u=!1}},[]);const a=n||Sm,c=e||wm;return i?Y.jsx(a,{configurationName:t}):Y.jsx(c,{configurationName:t})},Jx=()=>Y.jsx("span",{className:"oidc-loading",children:"Loading"}),Gx=()=>Y.jsx("div",{className:"oidc-serviceworker",children:Y.jsxs("div",{className:"oidc-serviceworker__container",children:[Y.jsx("h1",{className:"oidc-serviceworker__title",children:"Unable to authenticate on this browser"}),Y.jsx("p",{className:"oidc-serviceworker__content",children:"Your browser is not secure enough to make authentication work. Try updating your browser or use a newer browser."})]})}),Yx=()=>Y.jsx("div",{className:"oidc-session-lost",children:Y.jsxs("div",{className:"oidc-session-lost__container",children:[Y.jsx("h1",{className:"oidc-session-lost__title",children:"Session timed out"}),Y.jsx("p",{className:"oidc-session-lost__content",children:"Your session has expired. Please re-authenticate."})]})}),Qx=({configurationName:n})=>(q.useEffect(()=>{(async()=>{me.get(n).silentLoginCallbackAsync()})().catch(e=>{console.error("Error during silent login callback:",e)})},[n]),null),Xx=({configurationName:n})=>{const e=xo(window.location.href),t=me.get,r=t(n);let i=null;for(const[s,a]of Object.entries(e))s==="state"||s==="scope"||(i===null&&(i={}),i[s]=a);return q.useEffect(()=>{r.tokens||r.loginAsync(null,i,!0,e.scope)},[]),Y.jsx(Y.Fragment,{})},Zx=({callbackErrorComponent:n,callbackSuccessComponent:e,redirect_uri:t,silent_redirect_uri:r,silent_login_uri:i,children:s,configurationName:a,withCustomHistory:c=null})=>{const u=window?$i(window.location.href):"",[d,h]=q.useState(u);q.useEffect(()=>{const y=()=>h($i(window.location.href));return y(),window.addEventListener("popstate",y,!1),()=>window.removeEventListener("popstate",y,!1)},[]);const p=$i(t);if(r&&d===$i(r))return Y.jsx(Qx,{configurationName:a});if(i&&d===$i(i))return Y.jsx(Xx,{configurationName:a});switch(d){case p:return Y.jsx(qx,{callBackError:n,callBackSuccess:e,configurationName:a,withCustomHistory:c});default:return Y.jsx(Y.Fragment,{children:s})}},eE=q.memo(Zx),Sh={name:"",data:null},tE=({loadingComponent:n,children:e,configurationName:t})=>{const[r,i]=q.useState(!0),s=me.get,a=s(t);return q.useEffect(()=>{let c=!0;return a&&a.tryKeepExistingSessionAsync().then(()=>{c&&i(!1)}),()=>{c=!1}},[t]),Y.jsx(Y.Fragment,{children:r?Y.jsx(n,{configurationName:t}):Y.jsx(Y.Fragment,{children:e})})},zi=({isLoading:n,loadingComponent:e,children:t,configurationName:r})=>{const i=e;return n?Y.jsx(i,{configurationName:r,children:t}):Y.jsx(Y.Fragment,{children:t})},nE=({children:n,configuration:e,configurationName:t="default",callbackSuccessComponent:r=wm,authenticatingComponent:i=Vx,loadingComponent:s=Jx,serviceWorkerNotSupportedComponent:a=Gx,authenticatingErrorComponent:c=Sm,sessionLostComponent:u=Yx,onSessionLost:d=null,onLogoutFromAnotherTab:h=null,onLogoutFromSameTab:p=null,withCustomHistory:y=null,onEvent:g=null,getFetch:_=null,location:w=null})=>{const k=(We="default")=>me.getOrCreate(_??_m,w??new oi)(e,We),[A,P]=q.useState(!0),[L,B]=q.useState(Sh),[z,$]=q.useState("default");q.useEffect(()=>{const We=k(t).subscribeEvents((Ce,ot)=>{g&&g(t,Ce,ot)});return()=>{k(t).removeEventSubscription(We)}},[t,g]),q.useEffect(()=>{const We=k(t).subscribeEvents((Ce,ot)=>{if(Ce===me.eventNames.refreshTokensAsync_error||Ce===me.eventNames.syncTokensAsync_error){if(d!=null){d();return}B({name:Ce,data:ot})}else if(Ce===me.eventNames.logout_from_another_tab){if(h!=null){h();return}B({name:Ce,data:ot})}else Ce===me.eventNames.logout_from_same_tab?p!=null&&p():Ce===me.eventNames.loginAsync_begin||Ce===me.eventNames.loginCallbackAsync_end||Ce===me.eventNames.loginAsync_error||Ce===me.eventNames.loginCallbackAsync_error?B({name:Ce,data:ot}):Ce===me.eventNames.service_worker_not_supported_by_browser&&e.service_worker_only===!0&&B({name:Ce,data:ot})});return $(t),P(!1),()=>{k(t).removeEventSubscription(We),B(Sh)}},[e,t]);const J=u,K=i,V=s,ne=a,ve=c,De=A||z!==t,pt=k(t);switch(L.name){case me.eventNames.service_worker_not_supported_by_browser:return Y.jsx(zi,{loadingComponent:V,isLoading:De,configurationName:t,children:Y.jsx(ne,{configurationName:t})});case me.eventNames.loginAsync_begin:return Y.jsx(zi,{loadingComponent:V,isLoading:De,configurationName:t,children:Y.jsx(K,{configurationName:t})});case me.eventNames.loginAsync_error:case me.eventNames.loginCallbackAsync_error:return Y.jsx(zi,{loadingComponent:V,isLoading:De,configurationName:t,children:Y.jsx(ve,{configurationName:t})});case me.eventNames.refreshTokensAsync_error:case me.eventNames.syncTokensAsync_error:case me.eventNames.logout_from_another_tab:return Y.jsx(zi,{loadingComponent:V,isLoading:De,configurationName:t,children:Y.jsx(J,{configurationName:t})});default:return Y.jsx(zi,{loadingComponent:V,isLoading:De,configurationName:t,children:Y.jsx(eE,{redirect_uri:pt.configuration.redirect_uri,silent_redirect_uri:pt.configuration.silent_redirect_uri,silent_login_uri:pt.configuration.silent_login_uri,callbackSuccessComponent:r,callbackErrorComponent:c,authenticatingComponent:i,configurationName:t,withCustomHistory:y,location:w??new oi,children:Y.jsx(tE,{loadingComponent:V,configurationName:t,children:n})})})}},km="default",Ol=(n,e)=>{let t=!1;return n(e)&&(t=n(e).tokens!=null),t},rE=(n=km)=>{const e=me.get,[t,r]=q.useState(Ol(e,n));return q.useEffect(()=>{let i=!0;const s=e(n);r(Ol(e,n));const a=s.subscribeEvents((c,u)=>{(c===me.eventNames.logout_from_another_tab||c===me.eventNames.logout_from_same_tab||c===me.eventNames.token_acquired)&&i&&r(Ol(e,n))});return()=>{i=!1,s.removeEventSubscription(a)}},[n]),{login:(i=void 0,s=void 0,a=!1,c=void 0)=>e(n).loginAsync(i,s,!1,c,a),logout:(i=void 0,s=void 0)=>e(n).logoutAsync(i,s),renewTokens:async(i=void 0)=>{const s=await e(n).renewTokensAsync(i);return{accessToken:s.accessToken,accessTokenPayload:s.accessTokenPayload,idToken:s.idToken,idTokenPayload:s.idTokenPayload}},isAuthenticated:t}},xm={accessToken:null,accessTokenPayload:null},iE=n=>{const e=me.get,t=e(n);if(t.tokens){const r=t.tokens;return{accessToken:r.accessToken,accessTokenPayload:r.accessTokenPayload,generateDemonstrationOfProofOfPossessionAsync:t.configuration.demonstrating_proof_of_possession?(i,s)=>t.generateDemonstrationOfProofOfPossessionAsync(r.accessToken,i,s):null}}return xm};function sE(n,e){return n.configuration.demonstrating_proof_of_possession?(t,r,i={})=>n.generateDemonstrationOfProofOfPossessionAsync(e.accessToken,t,r,i):null}const oE=(n=km)=>{const e=me.get,[t,r]=q.useState(iE(n));return q.useEffect(()=>{let i=!0;const s=e(n);if(s.tokens){const c=s.tokens;r({accessToken:c.accessToken,accessTokenPayload:c.accessTokenPayload})}const a=s.subscribeEvents((c,u)=>{if((c===me.eventNames.token_renewed||c===me.eventNames.token_acquired||c===me.eventNames.logout_from_another_tab||c===me.eventNames.logout_from_same_tab||c===me.eventNames.refreshTokensAsync_error||c===me.eventNames.syncTokensAsync_error)&&i){const d=s.tokens;r(d!=null?{accessToken:d.accessToken,accessTokenPayload:d.accessTokenPayload,generateDemonstrationOfProofOfPossessionAsync:sE(s,d)}:xm)}});return()=>{i=!1,s.removeEventSubscription(a)}},[n]),t},aE=Er.graphql(`
25
25
  query players(
26
26
  $ids: [ID!]!
27
27
  $page: PageInfo!
@@ -39,6 +39,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
39
39
  value
40
40
  }
41
41
  identities {
42
+ providerId
42
43
  properties {
43
44
  property
44
45
  value
@@ -47,7 +48,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
47
48
  }
48
49
  }
49
50
  }
50
- `),Em=({playerIds:n,skip:e})=>{const[t,r]=q.useState([]),[i,s]=q.useState(!e),[a]=sm(aE),c=async u=>{var h,p;const d=[];for(;u.length>0;)d.push(...((p=(h=(await a({variables:{page:{first:100},ids:u.splice(0,100)}})).data)==null?void 0:h.players)==null?void 0:p.nodes)??[]);r(d)};return q.useEffect(()=>{!e&&n&&(s(!0),c(n).finally(()=>s(!1)))},[e,n]),{results:t,refetch:c,loading:i}},lE=di.graphql(`
51
+ `),Em=({playerIds:n,skip:e})=>{const[t,r]=q.useState([]),[i,s]=q.useState(!e),[a]=sm(aE),c=async u=>{var h,p;const d=[];for(;u.length>0;)d.push(...((p=(h=(await a({variables:{page:{first:100},ids:u.splice(0,100)}})).data)==null?void 0:h.players)==null?void 0:p.nodes)??[]);r(d)};return q.useEffect(()=>{!e&&n&&(s(!0),c(n).finally(()=>s(!1)))},[e,n]),{results:t,refetch:c,loading:i}},lE=Er.graphql(`
51
52
  query getMyAccount {
52
53
  getMyAccount {
53
54
  id
@@ -64,6 +65,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
64
65
  }
65
66
  }
66
67
  identities {
68
+ providerId
67
69
  properties {
68
70
  property
69
71
  value
@@ -71,7 +73,7 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
71
73
  }
72
74
  }
73
75
  }
74
- `),cE=()=>{const n=rE(),{data:e,loading:t,refetch:r}=$c(lE,{skip:!n.isAuthenticated,notifyOnNetworkStatusChange:!0});return{loading:t,data:e,refetch:r,authenticated:n.isAuthenticated,login:n.login,logout:n.logout}},uE=di.graphql(`
76
+ `),cE=()=>{const n=rE(),{data:e,loading:t,refetch:r}=$c(lE,{skip:!n.isAuthenticated,notifyOnNetworkStatusChange:!0});return{loading:t,data:e,refetch:r,authenticated:n.isAuthenticated,login:n.login,logout:n.logout}},uE=Er.graphql(`
75
77
  query tournamentTeam(
76
78
  $tournamentId: ID!
77
79
  $page: PageInfo!
@@ -105,9 +107,9 @@ Please checkout that you are using OIDC hook inside a <OidcProvider configuratio
105
107
  * Released under MIT license <https://lodash.com/license>
106
108
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
107
109
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
108
- */Eo.exports;(function(n,e){(function(){var t,r="4.17.21",i=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",c="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",d=500,h="__lodash_placeholder__",p=1,y=2,g=4,_=1,w=2,k=1,A=2,P=4,L=8,B=16,z=32,$=64,J=128,K=256,V=512,ne=30,ve="...",De=800,pt=16,We=1,Ce=2,ot=3,jt=1/0,dn=9007199254740991,ds=17976931348623157e292,F=NaN,te=4294967295,xe=te-1,Ve=te>>>1,tn=[["ary",J],["bind",k],["bindKey",A],["curry",L],["curryRight",B],["flip",V],["partial",z],["partialRight",$],["rearg",K]],Je="[object Arguments]",Nn="[object Array]",pi="[object AsyncFunction]",Me="[object Boolean]",Mt="[object Date]",mi="[object DOMException]",Ir="[object Error]",hs="[object Function]",_u="[object GeneratorFunction]",qt="[object Map]",gi="[object Number]",my="[object Null]",hn="[object Object]",bu="[object Promise]",gy="[object Proxy]",yi="[object RegExp]",Jt="[object Set]",_i="[object String]",ps="[object Symbol]",yy="[object Undefined]",bi="[object WeakMap]",_y="[object WeakSet]",vi="[object ArrayBuffer]",Pr="[object DataView]",ta="[object Float32Array]",na="[object Float64Array]",ra="[object Int8Array]",ia="[object Int16Array]",sa="[object Int32Array]",oa="[object Uint8Array]",aa="[object Uint8ClampedArray]",la="[object Uint16Array]",ca="[object Uint32Array]",by=/\b__p \+= '';/g,vy=/\b(__p \+=) '' \+/g,Sy=/(__e\(.*?\)|\b__t\)) \+\n'';/g,vu=/&(?:amp|lt|gt|quot|#39);/g,Su=/[&<>"']/g,wy=RegExp(vu.source),ky=RegExp(Su.source),xy=/<%-([\s\S]+?)%>/g,Ey=/<%([\s\S]+?)%>/g,wu=/<%=([\s\S]+?)%>/g,Oy=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ty=/^\w*$/,Ay=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ua=/[\\^$.*+?()[\]{}|]/g,Cy=RegExp(ua.source),fa=/^\s+/,My=/\s/,Ny=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Iy=/\{\n\/\* \[wrapped with (.+)\] \*/,Py=/,? & /,Ry=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Dy=/[()=,{}\[\]\/\s]/,Ly=/\\(\\)?/g,By=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ku=/\w*$/,Fy=/^[-+]0x[0-9a-f]+$/i,$y=/^0b[01]+$/i,zy=/^\[object .+?Constructor\]$/,Wy=/^0o[0-7]+$/i,Vy=/^(?:0|[1-9]\d*)$/,Hy=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ms=/($^)/,Uy=/['\n\r\u2028\u2029\\]/g,gs="\\ud800-\\udfff",Ky="\\u0300-\\u036f",jy="\\ufe20-\\ufe2f",qy="\\u20d0-\\u20ff",xu=Ky+jy+qy,Eu="\\u2700-\\u27bf",Ou="a-z\\xdf-\\xf6\\xf8-\\xff",Jy="\\xac\\xb1\\xd7\\xf7",Gy="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Yy="\\u2000-\\u206f",Qy=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Tu="A-Z\\xc0-\\xd6\\xd8-\\xde",Au="\\ufe0e\\ufe0f",Cu=Jy+Gy+Yy+Qy,da="['’]",Xy="["+gs+"]",Mu="["+Cu+"]",ys="["+xu+"]",Nu="\\d+",Zy="["+Eu+"]",Iu="["+Ou+"]",Pu="[^"+gs+Cu+Nu+Eu+Ou+Tu+"]",ha="\\ud83c[\\udffb-\\udfff]",e0="(?:"+ys+"|"+ha+")",Ru="[^"+gs+"]",pa="(?:\\ud83c[\\udde6-\\uddff]){2}",ma="[\\ud800-\\udbff][\\udc00-\\udfff]",Rr="["+Tu+"]",Du="\\u200d",Lu="(?:"+Iu+"|"+Pu+")",t0="(?:"+Rr+"|"+Pu+")",Bu="(?:"+da+"(?:d|ll|m|re|s|t|ve))?",Fu="(?:"+da+"(?:D|LL|M|RE|S|T|VE))?",$u=e0+"?",zu="["+Au+"]?",n0="(?:"+Du+"(?:"+[Ru,pa,ma].join("|")+")"+zu+$u+")*",r0="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",i0="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Wu=zu+$u+n0,s0="(?:"+[Zy,pa,ma].join("|")+")"+Wu,o0="(?:"+[Ru+ys+"?",ys,pa,ma,Xy].join("|")+")",a0=RegExp(da,"g"),l0=RegExp(ys,"g"),ga=RegExp(ha+"(?="+ha+")|"+o0+Wu,"g"),c0=RegExp([Rr+"?"+Iu+"+"+Bu+"(?="+[Mu,Rr,"$"].join("|")+")",t0+"+"+Fu+"(?="+[Mu,Rr+Lu,"$"].join("|")+")",Rr+"?"+Lu+"+"+Bu,Rr+"+"+Fu,i0,r0,Nu,s0].join("|"),"g"),u0=RegExp("["+Du+gs+xu+Au+"]"),f0=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,d0=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],h0=-1,Ee={};Ee[ta]=Ee[na]=Ee[ra]=Ee[ia]=Ee[sa]=Ee[oa]=Ee[aa]=Ee[la]=Ee[ca]=!0,Ee[Je]=Ee[Nn]=Ee[vi]=Ee[Me]=Ee[Pr]=Ee[Mt]=Ee[Ir]=Ee[hs]=Ee[qt]=Ee[gi]=Ee[hn]=Ee[yi]=Ee[Jt]=Ee[_i]=Ee[bi]=!1;var ke={};ke[Je]=ke[Nn]=ke[vi]=ke[Pr]=ke[Me]=ke[Mt]=ke[ta]=ke[na]=ke[ra]=ke[ia]=ke[sa]=ke[qt]=ke[gi]=ke[hn]=ke[yi]=ke[Jt]=ke[_i]=ke[ps]=ke[oa]=ke[aa]=ke[la]=ke[ca]=!0,ke[Ir]=ke[hs]=ke[bi]=!1;var p0={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},m0={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},g0={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},y0={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},_0=parseFloat,b0=parseInt,Vu=typeof Li=="object"&&Li&&Li.Object===Object&&Li,v0=typeof self=="object"&&self&&self.Object===Object&&self,Ge=Vu||v0||Function("return this")(),ya=e&&!e.nodeType&&e,ir=ya&&!0&&n&&!n.nodeType&&n,Hu=ir&&ir.exports===ya,_a=Hu&&Vu.process,Nt=function(){try{var O=ir&&ir.require&&ir.require("util").types;return O||_a&&_a.binding&&_a.binding("util")}catch{}}(),Uu=Nt&&Nt.isArrayBuffer,Ku=Nt&&Nt.isDate,ju=Nt&&Nt.isMap,qu=Nt&&Nt.isRegExp,Ju=Nt&&Nt.isSet,Gu=Nt&&Nt.isTypedArray;function wt(O,M,C){switch(C.length){case 0:return O.call(M);case 1:return O.call(M,C[0]);case 2:return O.call(M,C[0],C[1]);case 3:return O.call(M,C[0],C[1],C[2])}return O.apply(M,C)}function S0(O,M,C,U){for(var ie=-1,ge=O==null?0:O.length;++ie<ge;){var Be=O[ie];M(U,Be,C(Be),O)}return U}function It(O,M){for(var C=-1,U=O==null?0:O.length;++C<U&&M(O[C],C,O)!==!1;);return O}function w0(O,M){for(var C=O==null?0:O.length;C--&&M(O[C],C,O)!==!1;);return O}function Yu(O,M){for(var C=-1,U=O==null?0:O.length;++C<U;)if(!M(O[C],C,O))return!1;return!0}function In(O,M){for(var C=-1,U=O==null?0:O.length,ie=0,ge=[];++C<U;){var Be=O[C];M(Be,C,O)&&(ge[ie++]=Be)}return ge}function _s(O,M){var C=O==null?0:O.length;return!!C&&Dr(O,M,0)>-1}function ba(O,M,C){for(var U=-1,ie=O==null?0:O.length;++U<ie;)if(C(M,O[U]))return!0;return!1}function Te(O,M){for(var C=-1,U=O==null?0:O.length,ie=Array(U);++C<U;)ie[C]=M(O[C],C,O);return ie}function Pn(O,M){for(var C=-1,U=M.length,ie=O.length;++C<U;)O[ie+C]=M[C];return O}function va(O,M,C,U){var ie=-1,ge=O==null?0:O.length;for(U&&ge&&(C=O[++ie]);++ie<ge;)C=M(C,O[ie],ie,O);return C}function k0(O,M,C,U){var ie=O==null?0:O.length;for(U&&ie&&(C=O[--ie]);ie--;)C=M(C,O[ie],ie,O);return C}function Sa(O,M){for(var C=-1,U=O==null?0:O.length;++C<U;)if(M(O[C],C,O))return!0;return!1}var x0=wa("length");function E0(O){return O.split("")}function O0(O){return O.match(Ry)||[]}function Qu(O,M,C){var U;return C(O,function(ie,ge,Be){if(M(ie,ge,Be))return U=ge,!1}),U}function bs(O,M,C,U){for(var ie=O.length,ge=C+(U?1:-1);U?ge--:++ge<ie;)if(M(O[ge],ge,O))return ge;return-1}function Dr(O,M,C){return M===M?F0(O,M,C):bs(O,Xu,C)}function T0(O,M,C,U){for(var ie=C-1,ge=O.length;++ie<ge;)if(U(O[ie],M))return ie;return-1}function Xu(O){return O!==O}function Zu(O,M){var C=O==null?0:O.length;return C?xa(O,M)/C:F}function wa(O){return function(M){return M==null?t:M[O]}}function ka(O){return function(M){return O==null?t:O[M]}}function ef(O,M,C,U,ie){return ie(O,function(ge,Be,Se){C=U?(U=!1,ge):M(C,ge,Be,Se)}),C}function A0(O,M){var C=O.length;for(O.sort(M);C--;)O[C]=O[C].value;return O}function xa(O,M){for(var C,U=-1,ie=O.length;++U<ie;){var ge=M(O[U]);ge!==t&&(C=C===t?ge:C+ge)}return C}function Ea(O,M){for(var C=-1,U=Array(O);++C<O;)U[C]=M(C);return U}function C0(O,M){return Te(M,function(C){return[C,O[C]]})}function tf(O){return O&&O.slice(0,of(O)+1).replace(fa,"")}function kt(O){return function(M){return O(M)}}function Oa(O,M){return Te(M,function(C){return O[C]})}function Si(O,M){return O.has(M)}function nf(O,M){for(var C=-1,U=O.length;++C<U&&Dr(M,O[C],0)>-1;);return C}function rf(O,M){for(var C=O.length;C--&&Dr(M,O[C],0)>-1;);return C}function M0(O,M){for(var C=O.length,U=0;C--;)O[C]===M&&++U;return U}var N0=ka(p0),I0=ka(m0);function P0(O){return"\\"+y0[O]}function R0(O,M){return O==null?t:O[M]}function Lr(O){return u0.test(O)}function D0(O){return f0.test(O)}function L0(O){for(var M,C=[];!(M=O.next()).done;)C.push(M.value);return C}function Ta(O){var M=-1,C=Array(O.size);return O.forEach(function(U,ie){C[++M]=[ie,U]}),C}function sf(O,M){return function(C){return O(M(C))}}function Rn(O,M){for(var C=-1,U=O.length,ie=0,ge=[];++C<U;){var Be=O[C];(Be===M||Be===h)&&(O[C]=h,ge[ie++]=C)}return ge}function vs(O){var M=-1,C=Array(O.size);return O.forEach(function(U){C[++M]=U}),C}function B0(O){var M=-1,C=Array(O.size);return O.forEach(function(U){C[++M]=[U,U]}),C}function F0(O,M,C){for(var U=C-1,ie=O.length;++U<ie;)if(O[U]===M)return U;return-1}function $0(O,M,C){for(var U=C+1;U--;)if(O[U]===M)return U;return U}function Br(O){return Lr(O)?W0(O):x0(O)}function Gt(O){return Lr(O)?V0(O):E0(O)}function of(O){for(var M=O.length;M--&&My.test(O.charAt(M)););return M}var z0=ka(g0);function W0(O){for(var M=ga.lastIndex=0;ga.test(O);)++M;return M}function V0(O){return O.match(ga)||[]}function H0(O){return O.match(c0)||[]}var U0=function O(M){M=M==null?Ge:Fr.defaults(Ge.Object(),M,Fr.pick(Ge,d0));var C=M.Array,U=M.Date,ie=M.Error,ge=M.Function,Be=M.Math,Se=M.Object,Aa=M.RegExp,K0=M.String,Pt=M.TypeError,Ss=C.prototype,j0=ge.prototype,$r=Se.prototype,ws=M["__core-js_shared__"],ks=j0.toString,be=$r.hasOwnProperty,q0=0,af=function(){var o=/[^.]+$/.exec(ws&&ws.keys&&ws.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),xs=$r.toString,J0=ks.call(Se),G0=Ge._,Y0=Aa("^"+ks.call(be).replace(ua,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Es=Hu?M.Buffer:t,Dn=M.Symbol,Os=M.Uint8Array,lf=Es?Es.allocUnsafe:t,Ts=sf(Se.getPrototypeOf,Se),cf=Se.create,uf=$r.propertyIsEnumerable,As=Ss.splice,ff=Dn?Dn.isConcatSpreadable:t,wi=Dn?Dn.iterator:t,sr=Dn?Dn.toStringTag:t,Cs=function(){try{var o=ur(Se,"defineProperty");return o({},"",{}),o}catch{}}(),Q0=M.clearTimeout!==Ge.clearTimeout&&M.clearTimeout,X0=U&&U.now!==Ge.Date.now&&U.now,Z0=M.setTimeout!==Ge.setTimeout&&M.setTimeout,Ms=Be.ceil,Ns=Be.floor,Ca=Se.getOwnPropertySymbols,e_=Es?Es.isBuffer:t,df=M.isFinite,t_=Ss.join,n_=sf(Se.keys,Se),Fe=Be.max,et=Be.min,r_=U.now,i_=M.parseInt,hf=Be.random,s_=Ss.reverse,Ma=ur(M,"DataView"),ki=ur(M,"Map"),Na=ur(M,"Promise"),zr=ur(M,"Set"),xi=ur(M,"WeakMap"),Ei=ur(Se,"create"),Is=xi&&new xi,Wr={},o_=fr(Ma),a_=fr(ki),l_=fr(Na),c_=fr(zr),u_=fr(xi),Ps=Dn?Dn.prototype:t,Oi=Ps?Ps.valueOf:t,pf=Ps?Ps.toString:t;function v(o){if(Ne(o)&&!se(o)&&!(o instanceof he)){if(o instanceof Rt)return o;if(be.call(o,"__wrapped__"))return md(o)}return new Rt(o)}var Vr=function(){function o(){}return function(l){if(!Ae(l))return{};if(cf)return cf(l);o.prototype=l;var f=new o;return o.prototype=t,f}}();function Rs(){}function Rt(o,l){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!l,this.__index__=0,this.__values__=t}v.templateSettings={escape:xy,evaluate:Ey,interpolate:wu,variable:"",imports:{_:v}},v.prototype=Rs.prototype,v.prototype.constructor=v,Rt.prototype=Vr(Rs.prototype),Rt.prototype.constructor=Rt;function he(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=te,this.__views__=[]}function f_(){var o=new he(this.__wrapped__);return o.__actions__=mt(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=mt(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=mt(this.__views__),o}function d_(){if(this.__filtered__){var o=new he(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function h_(){var o=this.__wrapped__.value(),l=this.__dir__,f=se(o),m=l<0,b=f?o.length:0,S=Eb(0,b,this.__views__),x=S.start,E=S.end,T=E-x,N=m?E:x-1,I=this.__iteratees__,R=I.length,W=0,G=et(T,this.__takeCount__);if(!f||!m&&b==T&&G==T)return Ff(o,this.__actions__);var Z=[];e:for(;T--&&W<G;){N+=l;for(var le=-1,ee=o[N];++le<R;){var de=I[le],pe=de.iteratee,Ot=de.type,ct=pe(ee);if(Ot==Ce)ee=ct;else if(!ct){if(Ot==We)continue e;break e}}Z[W++]=ee}return Z}he.prototype=Vr(Rs.prototype),he.prototype.constructor=he;function or(o){var l=-1,f=o==null?0:o.length;for(this.clear();++l<f;){var m=o[l];this.set(m[0],m[1])}}function p_(){this.__data__=Ei?Ei(null):{},this.size=0}function m_(o){var l=this.has(o)&&delete this.__data__[o];return this.size-=l?1:0,l}function g_(o){var l=this.__data__;if(Ei){var f=l[o];return f===u?t:f}return be.call(l,o)?l[o]:t}function y_(o){var l=this.__data__;return Ei?l[o]!==t:be.call(l,o)}function __(o,l){var f=this.__data__;return this.size+=this.has(o)?0:1,f[o]=Ei&&l===t?u:l,this}or.prototype.clear=p_,or.prototype.delete=m_,or.prototype.get=g_,or.prototype.has=y_,or.prototype.set=__;function pn(o){var l=-1,f=o==null?0:o.length;for(this.clear();++l<f;){var m=o[l];this.set(m[0],m[1])}}function b_(){this.__data__=[],this.size=0}function v_(o){var l=this.__data__,f=Ds(l,o);if(f<0)return!1;var m=l.length-1;return f==m?l.pop():As.call(l,f,1),--this.size,!0}function S_(o){var l=this.__data__,f=Ds(l,o);return f<0?t:l[f][1]}function w_(o){return Ds(this.__data__,o)>-1}function k_(o,l){var f=this.__data__,m=Ds(f,o);return m<0?(++this.size,f.push([o,l])):f[m][1]=l,this}pn.prototype.clear=b_,pn.prototype.delete=v_,pn.prototype.get=S_,pn.prototype.has=w_,pn.prototype.set=k_;function mn(o){var l=-1,f=o==null?0:o.length;for(this.clear();++l<f;){var m=o[l];this.set(m[0],m[1])}}function x_(){this.size=0,this.__data__={hash:new or,map:new(ki||pn),string:new or}}function E_(o){var l=qs(this,o).delete(o);return this.size-=l?1:0,l}function O_(o){return qs(this,o).get(o)}function T_(o){return qs(this,o).has(o)}function A_(o,l){var f=qs(this,o),m=f.size;return f.set(o,l),this.size+=f.size==m?0:1,this}mn.prototype.clear=x_,mn.prototype.delete=E_,mn.prototype.get=O_,mn.prototype.has=T_,mn.prototype.set=A_;function ar(o){var l=-1,f=o==null?0:o.length;for(this.__data__=new mn;++l<f;)this.add(o[l])}function C_(o){return this.__data__.set(o,u),this}function M_(o){return this.__data__.has(o)}ar.prototype.add=ar.prototype.push=C_,ar.prototype.has=M_;function Yt(o){var l=this.__data__=new pn(o);this.size=l.size}function N_(){this.__data__=new pn,this.size=0}function I_(o){var l=this.__data__,f=l.delete(o);return this.size=l.size,f}function P_(o){return this.__data__.get(o)}function R_(o){return this.__data__.has(o)}function D_(o,l){var f=this.__data__;if(f instanceof pn){var m=f.__data__;if(!ki||m.length<i-1)return m.push([o,l]),this.size=++f.size,this;f=this.__data__=new mn(m)}return f.set(o,l),this.size=f.size,this}Yt.prototype.clear=N_,Yt.prototype.delete=I_,Yt.prototype.get=P_,Yt.prototype.has=R_,Yt.prototype.set=D_;function mf(o,l){var f=se(o),m=!f&&dr(o),b=!f&&!m&&zn(o),S=!f&&!m&&!b&&jr(o),x=f||m||b||S,E=x?Ea(o.length,K0):[],T=E.length;for(var N in o)(l||be.call(o,N))&&!(x&&(N=="length"||b&&(N=="offset"||N=="parent")||S&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||bn(N,T)))&&E.push(N);return E}function gf(o){var l=o.length;return l?o[Va(0,l-1)]:t}function L_(o,l){return Js(mt(o),lr(l,0,o.length))}function B_(o){return Js(mt(o))}function Ia(o,l,f){(f!==t&&!Qt(o[l],f)||f===t&&!(l in o))&&gn(o,l,f)}function Ti(o,l,f){var m=o[l];(!(be.call(o,l)&&Qt(m,f))||f===t&&!(l in o))&&gn(o,l,f)}function Ds(o,l){for(var f=o.length;f--;)if(Qt(o[f][0],l))return f;return-1}function F_(o,l,f,m){return Ln(o,function(b,S,x){l(m,b,f(b),x)}),m}function yf(o,l){return o&&rn(l,He(l),o)}function $_(o,l){return o&&rn(l,yt(l),o)}function gn(o,l,f){l=="__proto__"&&Cs?Cs(o,l,{configurable:!0,enumerable:!0,value:f,writable:!0}):o[l]=f}function Pa(o,l){for(var f=-1,m=l.length,b=C(m),S=o==null;++f<m;)b[f]=S?t:hl(o,l[f]);return b}function lr(o,l,f){return o===o&&(f!==t&&(o=o<=f?o:f),l!==t&&(o=o>=l?o:l)),o}function Dt(o,l,f,m,b,S){var x,E=l&p,T=l&y,N=l&g;if(f&&(x=b?f(o,m,b,S):f(o)),x!==t)return x;if(!Ae(o))return o;var I=se(o);if(I){if(x=Tb(o),!E)return mt(o,x)}else{var R=tt(o),W=R==hs||R==_u;if(zn(o))return Wf(o,E);if(R==hn||R==Je||W&&!b){if(x=T||W?{}:od(o),!E)return T?gb(o,$_(x,o)):mb(o,yf(x,o))}else{if(!ke[R])return b?o:{};x=Ab(o,R,E)}}S||(S=new Yt);var G=S.get(o);if(G)return G;S.set(o,x),Dd(o)?o.forEach(function(ee){x.add(Dt(ee,l,f,ee,o,S))}):Pd(o)&&o.forEach(function(ee,de){x.set(de,Dt(ee,l,f,de,o,S))});var Z=N?T?Za:Xa:T?yt:He,le=I?t:Z(o);return It(le||o,function(ee,de){le&&(de=ee,ee=o[de]),Ti(x,de,Dt(ee,l,f,de,o,S))}),x}function z_(o){var l=He(o);return function(f){return _f(f,o,l)}}function _f(o,l,f){var m=f.length;if(o==null)return!m;for(o=Se(o);m--;){var b=f[m],S=l[b],x=o[b];if(x===t&&!(b in o)||!S(x))return!1}return!0}function bf(o,l,f){if(typeof o!="function")throw new Pt(a);return Ri(function(){o.apply(t,f)},l)}function Ai(o,l,f,m){var b=-1,S=_s,x=!0,E=o.length,T=[],N=l.length;if(!E)return T;f&&(l=Te(l,kt(f))),m?(S=ba,x=!1):l.length>=i&&(S=Si,x=!1,l=new ar(l));e:for(;++b<E;){var I=o[b],R=f==null?I:f(I);if(I=m||I!==0?I:0,x&&R===R){for(var W=N;W--;)if(l[W]===R)continue e;T.push(I)}else S(l,R,m)||T.push(I)}return T}var Ln=jf(nn),vf=jf(Da,!0);function W_(o,l){var f=!0;return Ln(o,function(m,b,S){return f=!!l(m,b,S),f}),f}function Ls(o,l,f){for(var m=-1,b=o.length;++m<b;){var S=o[m],x=l(S);if(x!=null&&(E===t?x===x&&!Et(x):f(x,E)))var E=x,T=S}return T}function V_(o,l,f,m){var b=o.length;for(f=oe(f),f<0&&(f=-f>b?0:b+f),m=m===t||m>b?b:oe(m),m<0&&(m+=b),m=f>m?0:Bd(m);f<m;)o[f++]=l;return o}function Sf(o,l){var f=[];return Ln(o,function(m,b,S){l(m,b,S)&&f.push(m)}),f}function Ye(o,l,f,m,b){var S=-1,x=o.length;for(f||(f=Mb),b||(b=[]);++S<x;){var E=o[S];l>0&&f(E)?l>1?Ye(E,l-1,f,m,b):Pn(b,E):m||(b[b.length]=E)}return b}var Ra=qf(),wf=qf(!0);function nn(o,l){return o&&Ra(o,l,He)}function Da(o,l){return o&&wf(o,l,He)}function Bs(o,l){return In(l,function(f){return vn(o[f])})}function cr(o,l){l=Fn(l,o);for(var f=0,m=l.length;o!=null&&f<m;)o=o[sn(l[f++])];return f&&f==m?o:t}function kf(o,l,f){var m=l(o);return se(o)?m:Pn(m,f(o))}function at(o){return o==null?o===t?yy:my:sr&&sr in Se(o)?xb(o):Bb(o)}function La(o,l){return o>l}function H_(o,l){return o!=null&&be.call(o,l)}function U_(o,l){return o!=null&&l in Se(o)}function K_(o,l,f){return o>=et(l,f)&&o<Fe(l,f)}function Ba(o,l,f){for(var m=f?ba:_s,b=o[0].length,S=o.length,x=S,E=C(S),T=1/0,N=[];x--;){var I=o[x];x&&l&&(I=Te(I,kt(l))),T=et(I.length,T),E[x]=!f&&(l||b>=120&&I.length>=120)?new ar(x&&I):t}I=o[0];var R=-1,W=E[0];e:for(;++R<b&&N.length<T;){var G=I[R],Z=l?l(G):G;if(G=f||G!==0?G:0,!(W?Si(W,Z):m(N,Z,f))){for(x=S;--x;){var le=E[x];if(!(le?Si(le,Z):m(o[x],Z,f)))continue e}W&&W.push(Z),N.push(G)}}return N}function j_(o,l,f,m){return nn(o,function(b,S,x){l(m,f(b),S,x)}),m}function Ci(o,l,f){l=Fn(l,o),o=ud(o,l);var m=o==null?o:o[sn(Bt(l))];return m==null?t:wt(m,o,f)}function xf(o){return Ne(o)&&at(o)==Je}function q_(o){return Ne(o)&&at(o)==vi}function J_(o){return Ne(o)&&at(o)==Mt}function Mi(o,l,f,m,b){return o===l?!0:o==null||l==null||!Ne(o)&&!Ne(l)?o!==o&&l!==l:G_(o,l,f,m,Mi,b)}function G_(o,l,f,m,b,S){var x=se(o),E=se(l),T=x?Nn:tt(o),N=E?Nn:tt(l);T=T==Je?hn:T,N=N==Je?hn:N;var I=T==hn,R=N==hn,W=T==N;if(W&&zn(o)){if(!zn(l))return!1;x=!0,I=!1}if(W&&!I)return S||(S=new Yt),x||jr(o)?rd(o,l,f,m,b,S):wb(o,l,T,f,m,b,S);if(!(f&_)){var G=I&&be.call(o,"__wrapped__"),Z=R&&be.call(l,"__wrapped__");if(G||Z){var le=G?o.value():o,ee=Z?l.value():l;return S||(S=new Yt),b(le,ee,f,m,S)}}return W?(S||(S=new Yt),kb(o,l,f,m,b,S)):!1}function Y_(o){return Ne(o)&&tt(o)==qt}function Fa(o,l,f,m){var b=f.length,S=b,x=!m;if(o==null)return!S;for(o=Se(o);b--;){var E=f[b];if(x&&E[2]?E[1]!==o[E[0]]:!(E[0]in o))return!1}for(;++b<S;){E=f[b];var T=E[0],N=o[T],I=E[1];if(x&&E[2]){if(N===t&&!(T in o))return!1}else{var R=new Yt;if(m)var W=m(N,I,T,o,l,R);if(!(W===t?Mi(I,N,_|w,m,R):W))return!1}}return!0}function Ef(o){if(!Ae(o)||Ib(o))return!1;var l=vn(o)?Y0:zy;return l.test(fr(o))}function Q_(o){return Ne(o)&&at(o)==yi}function X_(o){return Ne(o)&&tt(o)==Jt}function Z_(o){return Ne(o)&&eo(o.length)&&!!Ee[at(o)]}function Of(o){return typeof o=="function"?o:o==null?_t:typeof o=="object"?se(o)?Cf(o[0],o[1]):Af(o):Jd(o)}function $a(o){if(!Pi(o))return n_(o);var l=[];for(var f in Se(o))be.call(o,f)&&f!="constructor"&&l.push(f);return l}function eb(o){if(!Ae(o))return Lb(o);var l=Pi(o),f=[];for(var m in o)m=="constructor"&&(l||!be.call(o,m))||f.push(m);return f}function za(o,l){return o<l}function Tf(o,l){var f=-1,m=gt(o)?C(o.length):[];return Ln(o,function(b,S,x){m[++f]=l(b,S,x)}),m}function Af(o){var l=tl(o);return l.length==1&&l[0][2]?ld(l[0][0],l[0][1]):function(f){return f===o||Fa(f,o,l)}}function Cf(o,l){return rl(o)&&ad(l)?ld(sn(o),l):function(f){var m=hl(f,o);return m===t&&m===l?pl(f,o):Mi(l,m,_|w)}}function Fs(o,l,f,m,b){o!==l&&Ra(l,function(S,x){if(b||(b=new Yt),Ae(S))tb(o,l,x,f,Fs,m,b);else{var E=m?m(sl(o,x),S,x+"",o,l,b):t;E===t&&(E=S),Ia(o,x,E)}},yt)}function tb(o,l,f,m,b,S,x){var E=sl(o,f),T=sl(l,f),N=x.get(T);if(N){Ia(o,f,N);return}var I=S?S(E,T,f+"",o,l,x):t,R=I===t;if(R){var W=se(T),G=!W&&zn(T),Z=!W&&!G&&jr(T);I=T,W||G||Z?se(E)?I=E:Pe(E)?I=mt(E):G?(R=!1,I=Wf(T,!0)):Z?(R=!1,I=Vf(T,!0)):I=[]:Di(T)||dr(T)?(I=E,dr(E)?I=Fd(E):(!Ae(E)||vn(E))&&(I=od(T))):R=!1}R&&(x.set(T,I),b(I,T,m,S,x),x.delete(T)),Ia(o,f,I)}function Mf(o,l){var f=o.length;if(f)return l+=l<0?f:0,bn(l,f)?o[l]:t}function Nf(o,l,f){l.length?l=Te(l,function(S){return se(S)?function(x){return cr(x,S.length===1?S[0]:S)}:S}):l=[_t];var m=-1;l=Te(l,kt(X()));var b=Tf(o,function(S,x,E){var T=Te(l,function(N){return N(S)});return{criteria:T,index:++m,value:S}});return A0(b,function(S,x){return pb(S,x,f)})}function nb(o,l){return If(o,l,function(f,m){return pl(o,m)})}function If(o,l,f){for(var m=-1,b=l.length,S={};++m<b;){var x=l[m],E=cr(o,x);f(E,x)&&Ni(S,Fn(x,o),E)}return S}function rb(o){return function(l){return cr(l,o)}}function Wa(o,l,f,m){var b=m?T0:Dr,S=-1,x=l.length,E=o;for(o===l&&(l=mt(l)),f&&(E=Te(o,kt(f)));++S<x;)for(var T=0,N=l[S],I=f?f(N):N;(T=b(E,I,T,m))>-1;)E!==o&&As.call(E,T,1),As.call(o,T,1);return o}function Pf(o,l){for(var f=o?l.length:0,m=f-1;f--;){var b=l[f];if(f==m||b!==S){var S=b;bn(b)?As.call(o,b,1):Ka(o,b)}}return o}function Va(o,l){return o+Ns(hf()*(l-o+1))}function ib(o,l,f,m){for(var b=-1,S=Fe(Ms((l-o)/(f||1)),0),x=C(S);S--;)x[m?S:++b]=o,o+=f;return x}function Ha(o,l){var f="";if(!o||l<1||l>dn)return f;do l%2&&(f+=o),l=Ns(l/2),l&&(o+=o);while(l);return f}function ue(o,l){return ol(cd(o,l,_t),o+"")}function sb(o){return gf(qr(o))}function ob(o,l){var f=qr(o);return Js(f,lr(l,0,f.length))}function Ni(o,l,f,m){if(!Ae(o))return o;l=Fn(l,o);for(var b=-1,S=l.length,x=S-1,E=o;E!=null&&++b<S;){var T=sn(l[b]),N=f;if(T==="__proto__"||T==="constructor"||T==="prototype")return o;if(b!=x){var I=E[T];N=m?m(I,T,E):t,N===t&&(N=Ae(I)?I:bn(l[b+1])?[]:{})}Ti(E,T,N),E=E[T]}return o}var Rf=Is?function(o,l){return Is.set(o,l),o}:_t,ab=Cs?function(o,l){return Cs(o,"toString",{configurable:!0,enumerable:!1,value:gl(l),writable:!0})}:_t;function lb(o){return Js(qr(o))}function Lt(o,l,f){var m=-1,b=o.length;l<0&&(l=-l>b?0:b+l),f=f>b?b:f,f<0&&(f+=b),b=l>f?0:f-l>>>0,l>>>=0;for(var S=C(b);++m<b;)S[m]=o[m+l];return S}function cb(o,l){var f;return Ln(o,function(m,b,S){return f=l(m,b,S),!f}),!!f}function $s(o,l,f){var m=0,b=o==null?m:o.length;if(typeof l=="number"&&l===l&&b<=Ve){for(;m<b;){var S=m+b>>>1,x=o[S];x!==null&&!Et(x)&&(f?x<=l:x<l)?m=S+1:b=S}return b}return Ua(o,l,_t,f)}function Ua(o,l,f,m){var b=0,S=o==null?0:o.length;if(S===0)return 0;l=f(l);for(var x=l!==l,E=l===null,T=Et(l),N=l===t;b<S;){var I=Ns((b+S)/2),R=f(o[I]),W=R!==t,G=R===null,Z=R===R,le=Et(R);if(x)var ee=m||Z;else N?ee=Z&&(m||W):E?ee=Z&&W&&(m||!G):T?ee=Z&&W&&!G&&(m||!le):G||le?ee=!1:ee=m?R<=l:R<l;ee?b=I+1:S=I}return et(S,xe)}function Df(o,l){for(var f=-1,m=o.length,b=0,S=[];++f<m;){var x=o[f],E=l?l(x):x;if(!f||!Qt(E,T)){var T=E;S[b++]=x===0?0:x}}return S}function Lf(o){return typeof o=="number"?o:Et(o)?F:+o}function xt(o){if(typeof o=="string")return o;if(se(o))return Te(o,xt)+"";if(Et(o))return pf?pf.call(o):"";var l=o+"";return l=="0"&&1/o==-1/0?"-0":l}function Bn(o,l,f){var m=-1,b=_s,S=o.length,x=!0,E=[],T=E;if(f)x=!1,b=ba;else if(S>=i){var N=l?null:vb(o);if(N)return vs(N);x=!1,b=Si,T=new ar}else T=l?[]:E;e:for(;++m<S;){var I=o[m],R=l?l(I):I;if(I=f||I!==0?I:0,x&&R===R){for(var W=T.length;W--;)if(T[W]===R)continue e;l&&T.push(R),E.push(I)}else b(T,R,f)||(T!==E&&T.push(R),E.push(I))}return E}function Ka(o,l){return l=Fn(l,o),o=ud(o,l),o==null||delete o[sn(Bt(l))]}function Bf(o,l,f,m){return Ni(o,l,f(cr(o,l)),m)}function zs(o,l,f,m){for(var b=o.length,S=m?b:-1;(m?S--:++S<b)&&l(o[S],S,o););return f?Lt(o,m?0:S,m?S+1:b):Lt(o,m?S+1:0,m?b:S)}function Ff(o,l){var f=o;return f instanceof he&&(f=f.value()),va(l,function(m,b){return b.func.apply(b.thisArg,Pn([m],b.args))},f)}function ja(o,l,f){var m=o.length;if(m<2)return m?Bn(o[0]):[];for(var b=-1,S=C(m);++b<m;)for(var x=o[b],E=-1;++E<m;)E!=b&&(S[b]=Ai(S[b]||x,o[E],l,f));return Bn(Ye(S,1),l,f)}function $f(o,l,f){for(var m=-1,b=o.length,S=l.length,x={};++m<b;){var E=m<S?l[m]:t;f(x,o[m],E)}return x}function qa(o){return Pe(o)?o:[]}function Ja(o){return typeof o=="function"?o:_t}function Fn(o,l){return se(o)?o:rl(o,l)?[o]:pd(_e(o))}var ub=ue;function $n(o,l,f){var m=o.length;return f=f===t?m:f,!l&&f>=m?o:Lt(o,l,f)}var zf=Q0||function(o){return Ge.clearTimeout(o)};function Wf(o,l){if(l)return o.slice();var f=o.length,m=lf?lf(f):new o.constructor(f);return o.copy(m),m}function Ga(o){var l=new o.constructor(o.byteLength);return new Os(l).set(new Os(o)),l}function fb(o,l){var f=l?Ga(o.buffer):o.buffer;return new o.constructor(f,o.byteOffset,o.byteLength)}function db(o){var l=new o.constructor(o.source,ku.exec(o));return l.lastIndex=o.lastIndex,l}function hb(o){return Oi?Se(Oi.call(o)):{}}function Vf(o,l){var f=l?Ga(o.buffer):o.buffer;return new o.constructor(f,o.byteOffset,o.length)}function Hf(o,l){if(o!==l){var f=o!==t,m=o===null,b=o===o,S=Et(o),x=l!==t,E=l===null,T=l===l,N=Et(l);if(!E&&!N&&!S&&o>l||S&&x&&T&&!E&&!N||m&&x&&T||!f&&T||!b)return 1;if(!m&&!S&&!N&&o<l||N&&f&&b&&!m&&!S||E&&f&&b||!x&&b||!T)return-1}return 0}function pb(o,l,f){for(var m=-1,b=o.criteria,S=l.criteria,x=b.length,E=f.length;++m<x;){var T=Hf(b[m],S[m]);if(T){if(m>=E)return T;var N=f[m];return T*(N=="desc"?-1:1)}}return o.index-l.index}function Uf(o,l,f,m){for(var b=-1,S=o.length,x=f.length,E=-1,T=l.length,N=Fe(S-x,0),I=C(T+N),R=!m;++E<T;)I[E]=l[E];for(;++b<x;)(R||b<S)&&(I[f[b]]=o[b]);for(;N--;)I[E++]=o[b++];return I}function Kf(o,l,f,m){for(var b=-1,S=o.length,x=-1,E=f.length,T=-1,N=l.length,I=Fe(S-E,0),R=C(I+N),W=!m;++b<I;)R[b]=o[b];for(var G=b;++T<N;)R[G+T]=l[T];for(;++x<E;)(W||b<S)&&(R[G+f[x]]=o[b++]);return R}function mt(o,l){var f=-1,m=o.length;for(l||(l=C(m));++f<m;)l[f]=o[f];return l}function rn(o,l,f,m){var b=!f;f||(f={});for(var S=-1,x=l.length;++S<x;){var E=l[S],T=m?m(f[E],o[E],E,f,o):t;T===t&&(T=o[E]),b?gn(f,E,T):Ti(f,E,T)}return f}function mb(o,l){return rn(o,nl(o),l)}function gb(o,l){return rn(o,id(o),l)}function Ws(o,l){return function(f,m){var b=se(f)?S0:F_,S=l?l():{};return b(f,o,X(m,2),S)}}function Hr(o){return ue(function(l,f){var m=-1,b=f.length,S=b>1?f[b-1]:t,x=b>2?f[2]:t;for(S=o.length>3&&typeof S=="function"?(b--,S):t,x&&lt(f[0],f[1],x)&&(S=b<3?t:S,b=1),l=Se(l);++m<b;){var E=f[m];E&&o(l,E,m,S)}return l})}function jf(o,l){return function(f,m){if(f==null)return f;if(!gt(f))return o(f,m);for(var b=f.length,S=l?b:-1,x=Se(f);(l?S--:++S<b)&&m(x[S],S,x)!==!1;);return f}}function qf(o){return function(l,f,m){for(var b=-1,S=Se(l),x=m(l),E=x.length;E--;){var T=x[o?E:++b];if(f(S[T],T,S)===!1)break}return l}}function yb(o,l,f){var m=l&k,b=Ii(o);function S(){var x=this&&this!==Ge&&this instanceof S?b:o;return x.apply(m?f:this,arguments)}return S}function Jf(o){return function(l){l=_e(l);var f=Lr(l)?Gt(l):t,m=f?f[0]:l.charAt(0),b=f?$n(f,1).join(""):l.slice(1);return m[o]()+b}}function Ur(o){return function(l){return va(jd(Kd(l).replace(a0,"")),o,"")}}function Ii(o){return function(){var l=arguments;switch(l.length){case 0:return new o;case 1:return new o(l[0]);case 2:return new o(l[0],l[1]);case 3:return new o(l[0],l[1],l[2]);case 4:return new o(l[0],l[1],l[2],l[3]);case 5:return new o(l[0],l[1],l[2],l[3],l[4]);case 6:return new o(l[0],l[1],l[2],l[3],l[4],l[5]);case 7:return new o(l[0],l[1],l[2],l[3],l[4],l[5],l[6])}var f=Vr(o.prototype),m=o.apply(f,l);return Ae(m)?m:f}}function _b(o,l,f){var m=Ii(o);function b(){for(var S=arguments.length,x=C(S),E=S,T=Kr(b);E--;)x[E]=arguments[E];var N=S<3&&x[0]!==T&&x[S-1]!==T?[]:Rn(x,T);if(S-=N.length,S<f)return Zf(o,l,Vs,b.placeholder,t,x,N,t,t,f-S);var I=this&&this!==Ge&&this instanceof b?m:o;return wt(I,this,x)}return b}function Gf(o){return function(l,f,m){var b=Se(l);if(!gt(l)){var S=X(f,3);l=He(l),f=function(E){return S(b[E],E,b)}}var x=o(l,f,m);return x>-1?b[S?l[x]:x]:t}}function Yf(o){return _n(function(l){var f=l.length,m=f,b=Rt.prototype.thru;for(o&&l.reverse();m--;){var S=l[m];if(typeof S!="function")throw new Pt(a);if(b&&!x&&js(S)=="wrapper")var x=new Rt([],!0)}for(m=x?m:f;++m<f;){S=l[m];var E=js(S),T=E=="wrapper"?el(S):t;T&&il(T[0])&&T[1]==(J|L|z|K)&&!T[4].length&&T[9]==1?x=x[js(T[0])].apply(x,T[3]):x=S.length==1&&il(S)?x[E]():x.thru(S)}return function(){var N=arguments,I=N[0];if(x&&N.length==1&&se(I))return x.plant(I).value();for(var R=0,W=f?l[R].apply(this,N):I;++R<f;)W=l[R].call(this,W);return W}})}function Vs(o,l,f,m,b,S,x,E,T,N){var I=l&J,R=l&k,W=l&A,G=l&(L|B),Z=l&V,le=W?t:Ii(o);function ee(){for(var de=arguments.length,pe=C(de),Ot=de;Ot--;)pe[Ot]=arguments[Ot];if(G)var ct=Kr(ee),Tt=M0(pe,ct);if(m&&(pe=Uf(pe,m,b,G)),S&&(pe=Kf(pe,S,x,G)),de-=Tt,G&&de<N){var Re=Rn(pe,ct);return Zf(o,l,Vs,ee.placeholder,f,pe,Re,E,T,N-de)}var Xt=R?f:this,wn=W?Xt[o]:o;return de=pe.length,E?pe=Fb(pe,E):Z&&de>1&&pe.reverse(),I&&T<de&&(pe.length=T),this&&this!==Ge&&this instanceof ee&&(wn=le||Ii(wn)),wn.apply(Xt,pe)}return ee}function Qf(o,l){return function(f,m){return j_(f,o,l(m),{})}}function Hs(o,l){return function(f,m){var b;if(f===t&&m===t)return l;if(f!==t&&(b=f),m!==t){if(b===t)return m;typeof f=="string"||typeof m=="string"?(f=xt(f),m=xt(m)):(f=Lf(f),m=Lf(m)),b=o(f,m)}return b}}function Ya(o){return _n(function(l){return l=Te(l,kt(X())),ue(function(f){var m=this;return o(l,function(b){return wt(b,m,f)})})})}function Us(o,l){l=l===t?" ":xt(l);var f=l.length;if(f<2)return f?Ha(l,o):l;var m=Ha(l,Ms(o/Br(l)));return Lr(l)?$n(Gt(m),0,o).join(""):m.slice(0,o)}function bb(o,l,f,m){var b=l&k,S=Ii(o);function x(){for(var E=-1,T=arguments.length,N=-1,I=m.length,R=C(I+T),W=this&&this!==Ge&&this instanceof x?S:o;++N<I;)R[N]=m[N];for(;T--;)R[N++]=arguments[++E];return wt(W,b?f:this,R)}return x}function Xf(o){return function(l,f,m){return m&&typeof m!="number"&&lt(l,f,m)&&(f=m=t),l=Sn(l),f===t?(f=l,l=0):f=Sn(f),m=m===t?l<f?1:-1:Sn(m),ib(l,f,m,o)}}function Ks(o){return function(l,f){return typeof l=="string"&&typeof f=="string"||(l=Ft(l),f=Ft(f)),o(l,f)}}function Zf(o,l,f,m,b,S,x,E,T,N){var I=l&L,R=I?x:t,W=I?t:x,G=I?S:t,Z=I?t:S;l|=I?z:$,l&=~(I?$:z),l&P||(l&=-4);var le=[o,l,b,G,R,Z,W,E,T,N],ee=f.apply(t,le);return il(o)&&fd(ee,le),ee.placeholder=m,dd(ee,o,l)}function Qa(o){var l=Be[o];return function(f,m){if(f=Ft(f),m=m==null?0:et(oe(m),292),m&&df(f)){var b=(_e(f)+"e").split("e"),S=l(b[0]+"e"+(+b[1]+m));return b=(_e(S)+"e").split("e"),+(b[0]+"e"+(+b[1]-m))}return l(f)}}var vb=zr&&1/vs(new zr([,-0]))[1]==jt?function(o){return new zr(o)}:bl;function ed(o){return function(l){var f=tt(l);return f==qt?Ta(l):f==Jt?B0(l):C0(l,o(l))}}function yn(o,l,f,m,b,S,x,E){var T=l&A;if(!T&&typeof o!="function")throw new Pt(a);var N=m?m.length:0;if(N||(l&=-97,m=b=t),x=x===t?x:Fe(oe(x),0),E=E===t?E:oe(E),N-=b?b.length:0,l&$){var I=m,R=b;m=b=t}var W=T?t:el(o),G=[o,l,f,m,b,I,R,S,x,E];if(W&&Db(G,W),o=G[0],l=G[1],f=G[2],m=G[3],b=G[4],E=G[9]=G[9]===t?T?0:o.length:Fe(G[9]-N,0),!E&&l&(L|B)&&(l&=-25),!l||l==k)var Z=yb(o,l,f);else l==L||l==B?Z=_b(o,l,E):(l==z||l==(k|z))&&!b.length?Z=bb(o,l,f,m):Z=Vs.apply(t,G);var le=W?Rf:fd;return dd(le(Z,G),o,l)}function td(o,l,f,m){return o===t||Qt(o,$r[f])&&!be.call(m,f)?l:o}function nd(o,l,f,m,b,S){return Ae(o)&&Ae(l)&&(S.set(l,o),Fs(o,l,t,nd,S),S.delete(l)),o}function Sb(o){return Di(o)?t:o}function rd(o,l,f,m,b,S){var x=f&_,E=o.length,T=l.length;if(E!=T&&!(x&&T>E))return!1;var N=S.get(o),I=S.get(l);if(N&&I)return N==l&&I==o;var R=-1,W=!0,G=f&w?new ar:t;for(S.set(o,l),S.set(l,o);++R<E;){var Z=o[R],le=l[R];if(m)var ee=x?m(le,Z,R,l,o,S):m(Z,le,R,o,l,S);if(ee!==t){if(ee)continue;W=!1;break}if(G){if(!Sa(l,function(de,pe){if(!Si(G,pe)&&(Z===de||b(Z,de,f,m,S)))return G.push(pe)})){W=!1;break}}else if(!(Z===le||b(Z,le,f,m,S))){W=!1;break}}return S.delete(o),S.delete(l),W}function wb(o,l,f,m,b,S,x){switch(f){case Pr:if(o.byteLength!=l.byteLength||o.byteOffset!=l.byteOffset)return!1;o=o.buffer,l=l.buffer;case vi:return!(o.byteLength!=l.byteLength||!S(new Os(o),new Os(l)));case Me:case Mt:case gi:return Qt(+o,+l);case Ir:return o.name==l.name&&o.message==l.message;case yi:case _i:return o==l+"";case qt:var E=Ta;case Jt:var T=m&_;if(E||(E=vs),o.size!=l.size&&!T)return!1;var N=x.get(o);if(N)return N==l;m|=w,x.set(o,l);var I=rd(E(o),E(l),m,b,S,x);return x.delete(o),I;case ps:if(Oi)return Oi.call(o)==Oi.call(l)}return!1}function kb(o,l,f,m,b,S){var x=f&_,E=Xa(o),T=E.length,N=Xa(l),I=N.length;if(T!=I&&!x)return!1;for(var R=T;R--;){var W=E[R];if(!(x?W in l:be.call(l,W)))return!1}var G=S.get(o),Z=S.get(l);if(G&&Z)return G==l&&Z==o;var le=!0;S.set(o,l),S.set(l,o);for(var ee=x;++R<T;){W=E[R];var de=o[W],pe=l[W];if(m)var Ot=x?m(pe,de,W,l,o,S):m(de,pe,W,o,l,S);if(!(Ot===t?de===pe||b(de,pe,f,m,S):Ot)){le=!1;break}ee||(ee=W=="constructor")}if(le&&!ee){var ct=o.constructor,Tt=l.constructor;ct!=Tt&&"constructor"in o&&"constructor"in l&&!(typeof ct=="function"&&ct instanceof ct&&typeof Tt=="function"&&Tt instanceof Tt)&&(le=!1)}return S.delete(o),S.delete(l),le}function _n(o){return ol(cd(o,t,_d),o+"")}function Xa(o){return kf(o,He,nl)}function Za(o){return kf(o,yt,id)}var el=Is?function(o){return Is.get(o)}:bl;function js(o){for(var l=o.name+"",f=Wr[l],m=be.call(Wr,l)?f.length:0;m--;){var b=f[m],S=b.func;if(S==null||S==o)return b.name}return l}function Kr(o){var l=be.call(v,"placeholder")?v:o;return l.placeholder}function X(){var o=v.iteratee||yl;return o=o===yl?Of:o,arguments.length?o(arguments[0],arguments[1]):o}function qs(o,l){var f=o.__data__;return Nb(l)?f[typeof l=="string"?"string":"hash"]:f.map}function tl(o){for(var l=He(o),f=l.length;f--;){var m=l[f],b=o[m];l[f]=[m,b,ad(b)]}return l}function ur(o,l){var f=R0(o,l);return Ef(f)?f:t}function xb(o){var l=be.call(o,sr),f=o[sr];try{o[sr]=t;var m=!0}catch{}var b=xs.call(o);return m&&(l?o[sr]=f:delete o[sr]),b}var nl=Ca?function(o){return o==null?[]:(o=Se(o),In(Ca(o),function(l){return uf.call(o,l)}))}:vl,id=Ca?function(o){for(var l=[];o;)Pn(l,nl(o)),o=Ts(o);return l}:vl,tt=at;(Ma&&tt(new Ma(new ArrayBuffer(1)))!=Pr||ki&&tt(new ki)!=qt||Na&&tt(Na.resolve())!=bu||zr&&tt(new zr)!=Jt||xi&&tt(new xi)!=bi)&&(tt=function(o){var l=at(o),f=l==hn?o.constructor:t,m=f?fr(f):"";if(m)switch(m){case o_:return Pr;case a_:return qt;case l_:return bu;case c_:return Jt;case u_:return bi}return l});function Eb(o,l,f){for(var m=-1,b=f.length;++m<b;){var S=f[m],x=S.size;switch(S.type){case"drop":o+=x;break;case"dropRight":l-=x;break;case"take":l=et(l,o+x);break;case"takeRight":o=Fe(o,l-x);break}}return{start:o,end:l}}function Ob(o){var l=o.match(Iy);return l?l[1].split(Py):[]}function sd(o,l,f){l=Fn(l,o);for(var m=-1,b=l.length,S=!1;++m<b;){var x=sn(l[m]);if(!(S=o!=null&&f(o,x)))break;o=o[x]}return S||++m!=b?S:(b=o==null?0:o.length,!!b&&eo(b)&&bn(x,b)&&(se(o)||dr(o)))}function Tb(o){var l=o.length,f=new o.constructor(l);return l&&typeof o[0]=="string"&&be.call(o,"index")&&(f.index=o.index,f.input=o.input),f}function od(o){return typeof o.constructor=="function"&&!Pi(o)?Vr(Ts(o)):{}}function Ab(o,l,f){var m=o.constructor;switch(l){case vi:return Ga(o);case Me:case Mt:return new m(+o);case Pr:return fb(o,f);case ta:case na:case ra:case ia:case sa:case oa:case aa:case la:case ca:return Vf(o,f);case qt:return new m;case gi:case _i:return new m(o);case yi:return db(o);case Jt:return new m;case ps:return hb(o)}}function Cb(o,l){var f=l.length;if(!f)return o;var m=f-1;return l[m]=(f>1?"& ":"")+l[m],l=l.join(f>2?", ":" "),o.replace(Ny,`{
110
+ */Eo.exports;(function(n,e){(function(){var t,r="4.17.21",i=200,s="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",a="Expected a function",c="Invalid `variable` option passed into `_.template`",u="__lodash_hash_undefined__",d=500,h="__lodash_placeholder__",p=1,y=2,g=4,_=1,w=2,k=1,A=2,P=4,L=8,B=16,z=32,$=64,J=128,K=256,V=512,ne=30,ve="...",De=800,pt=16,We=1,Ce=2,ot=3,jt=1/0,dn=9007199254740991,ds=17976931348623157e292,F=NaN,te=4294967295,xe=te-1,Ve=te>>>1,tn=[["ary",J],["bind",k],["bindKey",A],["curry",L],["curryRight",B],["flip",V],["partial",z],["partialRight",$],["rearg",K]],Je="[object Arguments]",Nn="[object Array]",pi="[object AsyncFunction]",Me="[object Boolean]",Mt="[object Date]",mi="[object DOMException]",Pr="[object Error]",hs="[object Function]",_u="[object GeneratorFunction]",qt="[object Map]",gi="[object Number]",my="[object Null]",hn="[object Object]",bu="[object Promise]",gy="[object Proxy]",yi="[object RegExp]",Jt="[object Set]",_i="[object String]",ps="[object Symbol]",yy="[object Undefined]",bi="[object WeakMap]",_y="[object WeakSet]",vi="[object ArrayBuffer]",Rr="[object DataView]",ta="[object Float32Array]",na="[object Float64Array]",ra="[object Int8Array]",ia="[object Int16Array]",sa="[object Int32Array]",oa="[object Uint8Array]",aa="[object Uint8ClampedArray]",la="[object Uint16Array]",ca="[object Uint32Array]",by=/\b__p \+= '';/g,vy=/\b(__p \+=) '' \+/g,Sy=/(__e\(.*?\)|\b__t\)) \+\n'';/g,vu=/&(?:amp|lt|gt|quot|#39);/g,Su=/[&<>"']/g,wy=RegExp(vu.source),ky=RegExp(Su.source),xy=/<%-([\s\S]+?)%>/g,Ey=/<%([\s\S]+?)%>/g,wu=/<%=([\s\S]+?)%>/g,Oy=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ty=/^\w*$/,Ay=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ua=/[\\^$.*+?()[\]{}|]/g,Cy=RegExp(ua.source),fa=/^\s+/,My=/\s/,Ny=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Iy=/\{\n\/\* \[wrapped with (.+)\] \*/,Py=/,? & /,Ry=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Dy=/[()=,{}\[\]\/\s]/,Ly=/\\(\\)?/g,By=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ku=/\w*$/,Fy=/^[-+]0x[0-9a-f]+$/i,$y=/^0b[01]+$/i,zy=/^\[object .+?Constructor\]$/,Wy=/^0o[0-7]+$/i,Vy=/^(?:0|[1-9]\d*)$/,Hy=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ms=/($^)/,Uy=/['\n\r\u2028\u2029\\]/g,gs="\\ud800-\\udfff",Ky="\\u0300-\\u036f",jy="\\ufe20-\\ufe2f",qy="\\u20d0-\\u20ff",xu=Ky+jy+qy,Eu="\\u2700-\\u27bf",Ou="a-z\\xdf-\\xf6\\xf8-\\xff",Jy="\\xac\\xb1\\xd7\\xf7",Gy="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Yy="\\u2000-\\u206f",Qy=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Tu="A-Z\\xc0-\\xd6\\xd8-\\xde",Au="\\ufe0e\\ufe0f",Cu=Jy+Gy+Yy+Qy,da="['’]",Xy="["+gs+"]",Mu="["+Cu+"]",ys="["+xu+"]",Nu="\\d+",Zy="["+Eu+"]",Iu="["+Ou+"]",Pu="[^"+gs+Cu+Nu+Eu+Ou+Tu+"]",ha="\\ud83c[\\udffb-\\udfff]",e0="(?:"+ys+"|"+ha+")",Ru="[^"+gs+"]",pa="(?:\\ud83c[\\udde6-\\uddff]){2}",ma="[\\ud800-\\udbff][\\udc00-\\udfff]",Dr="["+Tu+"]",Du="\\u200d",Lu="(?:"+Iu+"|"+Pu+")",t0="(?:"+Dr+"|"+Pu+")",Bu="(?:"+da+"(?:d|ll|m|re|s|t|ve))?",Fu="(?:"+da+"(?:D|LL|M|RE|S|T|VE))?",$u=e0+"?",zu="["+Au+"]?",n0="(?:"+Du+"(?:"+[Ru,pa,ma].join("|")+")"+zu+$u+")*",r0="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",i0="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Wu=zu+$u+n0,s0="(?:"+[Zy,pa,ma].join("|")+")"+Wu,o0="(?:"+[Ru+ys+"?",ys,pa,ma,Xy].join("|")+")",a0=RegExp(da,"g"),l0=RegExp(ys,"g"),ga=RegExp(ha+"(?="+ha+")|"+o0+Wu,"g"),c0=RegExp([Dr+"?"+Iu+"+"+Bu+"(?="+[Mu,Dr,"$"].join("|")+")",t0+"+"+Fu+"(?="+[Mu,Dr+Lu,"$"].join("|")+")",Dr+"?"+Lu+"+"+Bu,Dr+"+"+Fu,i0,r0,Nu,s0].join("|"),"g"),u0=RegExp("["+Du+gs+xu+Au+"]"),f0=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,d0=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],h0=-1,Ee={};Ee[ta]=Ee[na]=Ee[ra]=Ee[ia]=Ee[sa]=Ee[oa]=Ee[aa]=Ee[la]=Ee[ca]=!0,Ee[Je]=Ee[Nn]=Ee[vi]=Ee[Me]=Ee[Rr]=Ee[Mt]=Ee[Pr]=Ee[hs]=Ee[qt]=Ee[gi]=Ee[hn]=Ee[yi]=Ee[Jt]=Ee[_i]=Ee[bi]=!1;var ke={};ke[Je]=ke[Nn]=ke[vi]=ke[Rr]=ke[Me]=ke[Mt]=ke[ta]=ke[na]=ke[ra]=ke[ia]=ke[sa]=ke[qt]=ke[gi]=ke[hn]=ke[yi]=ke[Jt]=ke[_i]=ke[ps]=ke[oa]=ke[aa]=ke[la]=ke[ca]=!0,ke[Pr]=ke[hs]=ke[bi]=!1;var p0={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},m0={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},g0={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},y0={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},_0=parseFloat,b0=parseInt,Vu=typeof Li=="object"&&Li&&Li.Object===Object&&Li,v0=typeof self=="object"&&self&&self.Object===Object&&self,Ge=Vu||v0||Function("return this")(),ya=e&&!e.nodeType&&e,ir=ya&&!0&&n&&!n.nodeType&&n,Hu=ir&&ir.exports===ya,_a=Hu&&Vu.process,Nt=function(){try{var O=ir&&ir.require&&ir.require("util").types;return O||_a&&_a.binding&&_a.binding("util")}catch{}}(),Uu=Nt&&Nt.isArrayBuffer,Ku=Nt&&Nt.isDate,ju=Nt&&Nt.isMap,qu=Nt&&Nt.isRegExp,Ju=Nt&&Nt.isSet,Gu=Nt&&Nt.isTypedArray;function wt(O,M,C){switch(C.length){case 0:return O.call(M);case 1:return O.call(M,C[0]);case 2:return O.call(M,C[0],C[1]);case 3:return O.call(M,C[0],C[1],C[2])}return O.apply(M,C)}function S0(O,M,C,U){for(var ie=-1,ge=O==null?0:O.length;++ie<ge;){var Be=O[ie];M(U,Be,C(Be),O)}return U}function It(O,M){for(var C=-1,U=O==null?0:O.length;++C<U&&M(O[C],C,O)!==!1;);return O}function w0(O,M){for(var C=O==null?0:O.length;C--&&M(O[C],C,O)!==!1;);return O}function Yu(O,M){for(var C=-1,U=O==null?0:O.length;++C<U;)if(!M(O[C],C,O))return!1;return!0}function In(O,M){for(var C=-1,U=O==null?0:O.length,ie=0,ge=[];++C<U;){var Be=O[C];M(Be,C,O)&&(ge[ie++]=Be)}return ge}function _s(O,M){var C=O==null?0:O.length;return!!C&&Lr(O,M,0)>-1}function ba(O,M,C){for(var U=-1,ie=O==null?0:O.length;++U<ie;)if(C(M,O[U]))return!0;return!1}function Te(O,M){for(var C=-1,U=O==null?0:O.length,ie=Array(U);++C<U;)ie[C]=M(O[C],C,O);return ie}function Pn(O,M){for(var C=-1,U=M.length,ie=O.length;++C<U;)O[ie+C]=M[C];return O}function va(O,M,C,U){var ie=-1,ge=O==null?0:O.length;for(U&&ge&&(C=O[++ie]);++ie<ge;)C=M(C,O[ie],ie,O);return C}function k0(O,M,C,U){var ie=O==null?0:O.length;for(U&&ie&&(C=O[--ie]);ie--;)C=M(C,O[ie],ie,O);return C}function Sa(O,M){for(var C=-1,U=O==null?0:O.length;++C<U;)if(M(O[C],C,O))return!0;return!1}var x0=wa("length");function E0(O){return O.split("")}function O0(O){return O.match(Ry)||[]}function Qu(O,M,C){var U;return C(O,function(ie,ge,Be){if(M(ie,ge,Be))return U=ge,!1}),U}function bs(O,M,C,U){for(var ie=O.length,ge=C+(U?1:-1);U?ge--:++ge<ie;)if(M(O[ge],ge,O))return ge;return-1}function Lr(O,M,C){return M===M?F0(O,M,C):bs(O,Xu,C)}function T0(O,M,C,U){for(var ie=C-1,ge=O.length;++ie<ge;)if(U(O[ie],M))return ie;return-1}function Xu(O){return O!==O}function Zu(O,M){var C=O==null?0:O.length;return C?xa(O,M)/C:F}function wa(O){return function(M){return M==null?t:M[O]}}function ka(O){return function(M){return O==null?t:O[M]}}function ef(O,M,C,U,ie){return ie(O,function(ge,Be,Se){C=U?(U=!1,ge):M(C,ge,Be,Se)}),C}function A0(O,M){var C=O.length;for(O.sort(M);C--;)O[C]=O[C].value;return O}function xa(O,M){for(var C,U=-1,ie=O.length;++U<ie;){var ge=M(O[U]);ge!==t&&(C=C===t?ge:C+ge)}return C}function Ea(O,M){for(var C=-1,U=Array(O);++C<O;)U[C]=M(C);return U}function C0(O,M){return Te(M,function(C){return[C,O[C]]})}function tf(O){return O&&O.slice(0,of(O)+1).replace(fa,"")}function kt(O){return function(M){return O(M)}}function Oa(O,M){return Te(M,function(C){return O[C]})}function Si(O,M){return O.has(M)}function nf(O,M){for(var C=-1,U=O.length;++C<U&&Lr(M,O[C],0)>-1;);return C}function rf(O,M){for(var C=O.length;C--&&Lr(M,O[C],0)>-1;);return C}function M0(O,M){for(var C=O.length,U=0;C--;)O[C]===M&&++U;return U}var N0=ka(p0),I0=ka(m0);function P0(O){return"\\"+y0[O]}function R0(O,M){return O==null?t:O[M]}function Br(O){return u0.test(O)}function D0(O){return f0.test(O)}function L0(O){for(var M,C=[];!(M=O.next()).done;)C.push(M.value);return C}function Ta(O){var M=-1,C=Array(O.size);return O.forEach(function(U,ie){C[++M]=[ie,U]}),C}function sf(O,M){return function(C){return O(M(C))}}function Rn(O,M){for(var C=-1,U=O.length,ie=0,ge=[];++C<U;){var Be=O[C];(Be===M||Be===h)&&(O[C]=h,ge[ie++]=C)}return ge}function vs(O){var M=-1,C=Array(O.size);return O.forEach(function(U){C[++M]=U}),C}function B0(O){var M=-1,C=Array(O.size);return O.forEach(function(U){C[++M]=[U,U]}),C}function F0(O,M,C){for(var U=C-1,ie=O.length;++U<ie;)if(O[U]===M)return U;return-1}function $0(O,M,C){for(var U=C+1;U--;)if(O[U]===M)return U;return U}function Fr(O){return Br(O)?W0(O):x0(O)}function Gt(O){return Br(O)?V0(O):E0(O)}function of(O){for(var M=O.length;M--&&My.test(O.charAt(M)););return M}var z0=ka(g0);function W0(O){for(var M=ga.lastIndex=0;ga.test(O);)++M;return M}function V0(O){return O.match(ga)||[]}function H0(O){return O.match(c0)||[]}var U0=function O(M){M=M==null?Ge:$r.defaults(Ge.Object(),M,$r.pick(Ge,d0));var C=M.Array,U=M.Date,ie=M.Error,ge=M.Function,Be=M.Math,Se=M.Object,Aa=M.RegExp,K0=M.String,Pt=M.TypeError,Ss=C.prototype,j0=ge.prototype,zr=Se.prototype,ws=M["__core-js_shared__"],ks=j0.toString,be=zr.hasOwnProperty,q0=0,af=function(){var o=/[^.]+$/.exec(ws&&ws.keys&&ws.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}(),xs=zr.toString,J0=ks.call(Se),G0=Ge._,Y0=Aa("^"+ks.call(be).replace(ua,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Es=Hu?M.Buffer:t,Dn=M.Symbol,Os=M.Uint8Array,lf=Es?Es.allocUnsafe:t,Ts=sf(Se.getPrototypeOf,Se),cf=Se.create,uf=zr.propertyIsEnumerable,As=Ss.splice,ff=Dn?Dn.isConcatSpreadable:t,wi=Dn?Dn.iterator:t,sr=Dn?Dn.toStringTag:t,Cs=function(){try{var o=ur(Se,"defineProperty");return o({},"",{}),o}catch{}}(),Q0=M.clearTimeout!==Ge.clearTimeout&&M.clearTimeout,X0=U&&U.now!==Ge.Date.now&&U.now,Z0=M.setTimeout!==Ge.setTimeout&&M.setTimeout,Ms=Be.ceil,Ns=Be.floor,Ca=Se.getOwnPropertySymbols,e_=Es?Es.isBuffer:t,df=M.isFinite,t_=Ss.join,n_=sf(Se.keys,Se),Fe=Be.max,et=Be.min,r_=U.now,i_=M.parseInt,hf=Be.random,s_=Ss.reverse,Ma=ur(M,"DataView"),ki=ur(M,"Map"),Na=ur(M,"Promise"),Wr=ur(M,"Set"),xi=ur(M,"WeakMap"),Ei=ur(Se,"create"),Is=xi&&new xi,Vr={},o_=fr(Ma),a_=fr(ki),l_=fr(Na),c_=fr(Wr),u_=fr(xi),Ps=Dn?Dn.prototype:t,Oi=Ps?Ps.valueOf:t,pf=Ps?Ps.toString:t;function v(o){if(Ne(o)&&!se(o)&&!(o instanceof he)){if(o instanceof Rt)return o;if(be.call(o,"__wrapped__"))return md(o)}return new Rt(o)}var Hr=function(){function o(){}return function(l){if(!Ae(l))return{};if(cf)return cf(l);o.prototype=l;var f=new o;return o.prototype=t,f}}();function Rs(){}function Rt(o,l){this.__wrapped__=o,this.__actions__=[],this.__chain__=!!l,this.__index__=0,this.__values__=t}v.templateSettings={escape:xy,evaluate:Ey,interpolate:wu,variable:"",imports:{_:v}},v.prototype=Rs.prototype,v.prototype.constructor=v,Rt.prototype=Hr(Rs.prototype),Rt.prototype.constructor=Rt;function he(o){this.__wrapped__=o,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=te,this.__views__=[]}function f_(){var o=new he(this.__wrapped__);return o.__actions__=mt(this.__actions__),o.__dir__=this.__dir__,o.__filtered__=this.__filtered__,o.__iteratees__=mt(this.__iteratees__),o.__takeCount__=this.__takeCount__,o.__views__=mt(this.__views__),o}function d_(){if(this.__filtered__){var o=new he(this);o.__dir__=-1,o.__filtered__=!0}else o=this.clone(),o.__dir__*=-1;return o}function h_(){var o=this.__wrapped__.value(),l=this.__dir__,f=se(o),m=l<0,b=f?o.length:0,S=Eb(0,b,this.__views__),x=S.start,E=S.end,T=E-x,N=m?E:x-1,I=this.__iteratees__,R=I.length,W=0,G=et(T,this.__takeCount__);if(!f||!m&&b==T&&G==T)return Ff(o,this.__actions__);var Z=[];e:for(;T--&&W<G;){N+=l;for(var le=-1,ee=o[N];++le<R;){var de=I[le],pe=de.iteratee,Ot=de.type,ct=pe(ee);if(Ot==Ce)ee=ct;else if(!ct){if(Ot==We)continue e;break e}}Z[W++]=ee}return Z}he.prototype=Hr(Rs.prototype),he.prototype.constructor=he;function or(o){var l=-1,f=o==null?0:o.length;for(this.clear();++l<f;){var m=o[l];this.set(m[0],m[1])}}function p_(){this.__data__=Ei?Ei(null):{},this.size=0}function m_(o){var l=this.has(o)&&delete this.__data__[o];return this.size-=l?1:0,l}function g_(o){var l=this.__data__;if(Ei){var f=l[o];return f===u?t:f}return be.call(l,o)?l[o]:t}function y_(o){var l=this.__data__;return Ei?l[o]!==t:be.call(l,o)}function __(o,l){var f=this.__data__;return this.size+=this.has(o)?0:1,f[o]=Ei&&l===t?u:l,this}or.prototype.clear=p_,or.prototype.delete=m_,or.prototype.get=g_,or.prototype.has=y_,or.prototype.set=__;function pn(o){var l=-1,f=o==null?0:o.length;for(this.clear();++l<f;){var m=o[l];this.set(m[0],m[1])}}function b_(){this.__data__=[],this.size=0}function v_(o){var l=this.__data__,f=Ds(l,o);if(f<0)return!1;var m=l.length-1;return f==m?l.pop():As.call(l,f,1),--this.size,!0}function S_(o){var l=this.__data__,f=Ds(l,o);return f<0?t:l[f][1]}function w_(o){return Ds(this.__data__,o)>-1}function k_(o,l){var f=this.__data__,m=Ds(f,o);return m<0?(++this.size,f.push([o,l])):f[m][1]=l,this}pn.prototype.clear=b_,pn.prototype.delete=v_,pn.prototype.get=S_,pn.prototype.has=w_,pn.prototype.set=k_;function mn(o){var l=-1,f=o==null?0:o.length;for(this.clear();++l<f;){var m=o[l];this.set(m[0],m[1])}}function x_(){this.size=0,this.__data__={hash:new or,map:new(ki||pn),string:new or}}function E_(o){var l=qs(this,o).delete(o);return this.size-=l?1:0,l}function O_(o){return qs(this,o).get(o)}function T_(o){return qs(this,o).has(o)}function A_(o,l){var f=qs(this,o),m=f.size;return f.set(o,l),this.size+=f.size==m?0:1,this}mn.prototype.clear=x_,mn.prototype.delete=E_,mn.prototype.get=O_,mn.prototype.has=T_,mn.prototype.set=A_;function ar(o){var l=-1,f=o==null?0:o.length;for(this.__data__=new mn;++l<f;)this.add(o[l])}function C_(o){return this.__data__.set(o,u),this}function M_(o){return this.__data__.has(o)}ar.prototype.add=ar.prototype.push=C_,ar.prototype.has=M_;function Yt(o){var l=this.__data__=new pn(o);this.size=l.size}function N_(){this.__data__=new pn,this.size=0}function I_(o){var l=this.__data__,f=l.delete(o);return this.size=l.size,f}function P_(o){return this.__data__.get(o)}function R_(o){return this.__data__.has(o)}function D_(o,l){var f=this.__data__;if(f instanceof pn){var m=f.__data__;if(!ki||m.length<i-1)return m.push([o,l]),this.size=++f.size,this;f=this.__data__=new mn(m)}return f.set(o,l),this.size=f.size,this}Yt.prototype.clear=N_,Yt.prototype.delete=I_,Yt.prototype.get=P_,Yt.prototype.has=R_,Yt.prototype.set=D_;function mf(o,l){var f=se(o),m=!f&&dr(o),b=!f&&!m&&zn(o),S=!f&&!m&&!b&&qr(o),x=f||m||b||S,E=x?Ea(o.length,K0):[],T=E.length;for(var N in o)(l||be.call(o,N))&&!(x&&(N=="length"||b&&(N=="offset"||N=="parent")||S&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||bn(N,T)))&&E.push(N);return E}function gf(o){var l=o.length;return l?o[Va(0,l-1)]:t}function L_(o,l){return Js(mt(o),lr(l,0,o.length))}function B_(o){return Js(mt(o))}function Ia(o,l,f){(f!==t&&!Qt(o[l],f)||f===t&&!(l in o))&&gn(o,l,f)}function Ti(o,l,f){var m=o[l];(!(be.call(o,l)&&Qt(m,f))||f===t&&!(l in o))&&gn(o,l,f)}function Ds(o,l){for(var f=o.length;f--;)if(Qt(o[f][0],l))return f;return-1}function F_(o,l,f,m){return Ln(o,function(b,S,x){l(m,b,f(b),x)}),m}function yf(o,l){return o&&rn(l,He(l),o)}function $_(o,l){return o&&rn(l,yt(l),o)}function gn(o,l,f){l=="__proto__"&&Cs?Cs(o,l,{configurable:!0,enumerable:!0,value:f,writable:!0}):o[l]=f}function Pa(o,l){for(var f=-1,m=l.length,b=C(m),S=o==null;++f<m;)b[f]=S?t:hl(o,l[f]);return b}function lr(o,l,f){return o===o&&(f!==t&&(o=o<=f?o:f),l!==t&&(o=o>=l?o:l)),o}function Dt(o,l,f,m,b,S){var x,E=l&p,T=l&y,N=l&g;if(f&&(x=b?f(o,m,b,S):f(o)),x!==t)return x;if(!Ae(o))return o;var I=se(o);if(I){if(x=Tb(o),!E)return mt(o,x)}else{var R=tt(o),W=R==hs||R==_u;if(zn(o))return Wf(o,E);if(R==hn||R==Je||W&&!b){if(x=T||W?{}:od(o),!E)return T?gb(o,$_(x,o)):mb(o,yf(x,o))}else{if(!ke[R])return b?o:{};x=Ab(o,R,E)}}S||(S=new Yt);var G=S.get(o);if(G)return G;S.set(o,x),Dd(o)?o.forEach(function(ee){x.add(Dt(ee,l,f,ee,o,S))}):Pd(o)&&o.forEach(function(ee,de){x.set(de,Dt(ee,l,f,de,o,S))});var Z=N?T?Za:Xa:T?yt:He,le=I?t:Z(o);return It(le||o,function(ee,de){le&&(de=ee,ee=o[de]),Ti(x,de,Dt(ee,l,f,de,o,S))}),x}function z_(o){var l=He(o);return function(f){return _f(f,o,l)}}function _f(o,l,f){var m=f.length;if(o==null)return!m;for(o=Se(o);m--;){var b=f[m],S=l[b],x=o[b];if(x===t&&!(b in o)||!S(x))return!1}return!0}function bf(o,l,f){if(typeof o!="function")throw new Pt(a);return Ri(function(){o.apply(t,f)},l)}function Ai(o,l,f,m){var b=-1,S=_s,x=!0,E=o.length,T=[],N=l.length;if(!E)return T;f&&(l=Te(l,kt(f))),m?(S=ba,x=!1):l.length>=i&&(S=Si,x=!1,l=new ar(l));e:for(;++b<E;){var I=o[b],R=f==null?I:f(I);if(I=m||I!==0?I:0,x&&R===R){for(var W=N;W--;)if(l[W]===R)continue e;T.push(I)}else S(l,R,m)||T.push(I)}return T}var Ln=jf(nn),vf=jf(Da,!0);function W_(o,l){var f=!0;return Ln(o,function(m,b,S){return f=!!l(m,b,S),f}),f}function Ls(o,l,f){for(var m=-1,b=o.length;++m<b;){var S=o[m],x=l(S);if(x!=null&&(E===t?x===x&&!Et(x):f(x,E)))var E=x,T=S}return T}function V_(o,l,f,m){var b=o.length;for(f=oe(f),f<0&&(f=-f>b?0:b+f),m=m===t||m>b?b:oe(m),m<0&&(m+=b),m=f>m?0:Bd(m);f<m;)o[f++]=l;return o}function Sf(o,l){var f=[];return Ln(o,function(m,b,S){l(m,b,S)&&f.push(m)}),f}function Ye(o,l,f,m,b){var S=-1,x=o.length;for(f||(f=Mb),b||(b=[]);++S<x;){var E=o[S];l>0&&f(E)?l>1?Ye(E,l-1,f,m,b):Pn(b,E):m||(b[b.length]=E)}return b}var Ra=qf(),wf=qf(!0);function nn(o,l){return o&&Ra(o,l,He)}function Da(o,l){return o&&wf(o,l,He)}function Bs(o,l){return In(l,function(f){return vn(o[f])})}function cr(o,l){l=Fn(l,o);for(var f=0,m=l.length;o!=null&&f<m;)o=o[sn(l[f++])];return f&&f==m?o:t}function kf(o,l,f){var m=l(o);return se(o)?m:Pn(m,f(o))}function at(o){return o==null?o===t?yy:my:sr&&sr in Se(o)?xb(o):Bb(o)}function La(o,l){return o>l}function H_(o,l){return o!=null&&be.call(o,l)}function U_(o,l){return o!=null&&l in Se(o)}function K_(o,l,f){return o>=et(l,f)&&o<Fe(l,f)}function Ba(o,l,f){for(var m=f?ba:_s,b=o[0].length,S=o.length,x=S,E=C(S),T=1/0,N=[];x--;){var I=o[x];x&&l&&(I=Te(I,kt(l))),T=et(I.length,T),E[x]=!f&&(l||b>=120&&I.length>=120)?new ar(x&&I):t}I=o[0];var R=-1,W=E[0];e:for(;++R<b&&N.length<T;){var G=I[R],Z=l?l(G):G;if(G=f||G!==0?G:0,!(W?Si(W,Z):m(N,Z,f))){for(x=S;--x;){var le=E[x];if(!(le?Si(le,Z):m(o[x],Z,f)))continue e}W&&W.push(Z),N.push(G)}}return N}function j_(o,l,f,m){return nn(o,function(b,S,x){l(m,f(b),S,x)}),m}function Ci(o,l,f){l=Fn(l,o),o=ud(o,l);var m=o==null?o:o[sn(Bt(l))];return m==null?t:wt(m,o,f)}function xf(o){return Ne(o)&&at(o)==Je}function q_(o){return Ne(o)&&at(o)==vi}function J_(o){return Ne(o)&&at(o)==Mt}function Mi(o,l,f,m,b){return o===l?!0:o==null||l==null||!Ne(o)&&!Ne(l)?o!==o&&l!==l:G_(o,l,f,m,Mi,b)}function G_(o,l,f,m,b,S){var x=se(o),E=se(l),T=x?Nn:tt(o),N=E?Nn:tt(l);T=T==Je?hn:T,N=N==Je?hn:N;var I=T==hn,R=N==hn,W=T==N;if(W&&zn(o)){if(!zn(l))return!1;x=!0,I=!1}if(W&&!I)return S||(S=new Yt),x||qr(o)?rd(o,l,f,m,b,S):wb(o,l,T,f,m,b,S);if(!(f&_)){var G=I&&be.call(o,"__wrapped__"),Z=R&&be.call(l,"__wrapped__");if(G||Z){var le=G?o.value():o,ee=Z?l.value():l;return S||(S=new Yt),b(le,ee,f,m,S)}}return W?(S||(S=new Yt),kb(o,l,f,m,b,S)):!1}function Y_(o){return Ne(o)&&tt(o)==qt}function Fa(o,l,f,m){var b=f.length,S=b,x=!m;if(o==null)return!S;for(o=Se(o);b--;){var E=f[b];if(x&&E[2]?E[1]!==o[E[0]]:!(E[0]in o))return!1}for(;++b<S;){E=f[b];var T=E[0],N=o[T],I=E[1];if(x&&E[2]){if(N===t&&!(T in o))return!1}else{var R=new Yt;if(m)var W=m(N,I,T,o,l,R);if(!(W===t?Mi(I,N,_|w,m,R):W))return!1}}return!0}function Ef(o){if(!Ae(o)||Ib(o))return!1;var l=vn(o)?Y0:zy;return l.test(fr(o))}function Q_(o){return Ne(o)&&at(o)==yi}function X_(o){return Ne(o)&&tt(o)==Jt}function Z_(o){return Ne(o)&&eo(o.length)&&!!Ee[at(o)]}function Of(o){return typeof o=="function"?o:o==null?_t:typeof o=="object"?se(o)?Cf(o[0],o[1]):Af(o):Jd(o)}function $a(o){if(!Pi(o))return n_(o);var l=[];for(var f in Se(o))be.call(o,f)&&f!="constructor"&&l.push(f);return l}function eb(o){if(!Ae(o))return Lb(o);var l=Pi(o),f=[];for(var m in o)m=="constructor"&&(l||!be.call(o,m))||f.push(m);return f}function za(o,l){return o<l}function Tf(o,l){var f=-1,m=gt(o)?C(o.length):[];return Ln(o,function(b,S,x){m[++f]=l(b,S,x)}),m}function Af(o){var l=tl(o);return l.length==1&&l[0][2]?ld(l[0][0],l[0][1]):function(f){return f===o||Fa(f,o,l)}}function Cf(o,l){return rl(o)&&ad(l)?ld(sn(o),l):function(f){var m=hl(f,o);return m===t&&m===l?pl(f,o):Mi(l,m,_|w)}}function Fs(o,l,f,m,b){o!==l&&Ra(l,function(S,x){if(b||(b=new Yt),Ae(S))tb(o,l,x,f,Fs,m,b);else{var E=m?m(sl(o,x),S,x+"",o,l,b):t;E===t&&(E=S),Ia(o,x,E)}},yt)}function tb(o,l,f,m,b,S,x){var E=sl(o,f),T=sl(l,f),N=x.get(T);if(N){Ia(o,f,N);return}var I=S?S(E,T,f+"",o,l,x):t,R=I===t;if(R){var W=se(T),G=!W&&zn(T),Z=!W&&!G&&qr(T);I=T,W||G||Z?se(E)?I=E:Pe(E)?I=mt(E):G?(R=!1,I=Wf(T,!0)):Z?(R=!1,I=Vf(T,!0)):I=[]:Di(T)||dr(T)?(I=E,dr(E)?I=Fd(E):(!Ae(E)||vn(E))&&(I=od(T))):R=!1}R&&(x.set(T,I),b(I,T,m,S,x),x.delete(T)),Ia(o,f,I)}function Mf(o,l){var f=o.length;if(f)return l+=l<0?f:0,bn(l,f)?o[l]:t}function Nf(o,l,f){l.length?l=Te(l,function(S){return se(S)?function(x){return cr(x,S.length===1?S[0]:S)}:S}):l=[_t];var m=-1;l=Te(l,kt(X()));var b=Tf(o,function(S,x,E){var T=Te(l,function(N){return N(S)});return{criteria:T,index:++m,value:S}});return A0(b,function(S,x){return pb(S,x,f)})}function nb(o,l){return If(o,l,function(f,m){return pl(o,m)})}function If(o,l,f){for(var m=-1,b=l.length,S={};++m<b;){var x=l[m],E=cr(o,x);f(E,x)&&Ni(S,Fn(x,o),E)}return S}function rb(o){return function(l){return cr(l,o)}}function Wa(o,l,f,m){var b=m?T0:Lr,S=-1,x=l.length,E=o;for(o===l&&(l=mt(l)),f&&(E=Te(o,kt(f)));++S<x;)for(var T=0,N=l[S],I=f?f(N):N;(T=b(E,I,T,m))>-1;)E!==o&&As.call(E,T,1),As.call(o,T,1);return o}function Pf(o,l){for(var f=o?l.length:0,m=f-1;f--;){var b=l[f];if(f==m||b!==S){var S=b;bn(b)?As.call(o,b,1):Ka(o,b)}}return o}function Va(o,l){return o+Ns(hf()*(l-o+1))}function ib(o,l,f,m){for(var b=-1,S=Fe(Ms((l-o)/(f||1)),0),x=C(S);S--;)x[m?S:++b]=o,o+=f;return x}function Ha(o,l){var f="";if(!o||l<1||l>dn)return f;do l%2&&(f+=o),l=Ns(l/2),l&&(o+=o);while(l);return f}function ue(o,l){return ol(cd(o,l,_t),o+"")}function sb(o){return gf(Jr(o))}function ob(o,l){var f=Jr(o);return Js(f,lr(l,0,f.length))}function Ni(o,l,f,m){if(!Ae(o))return o;l=Fn(l,o);for(var b=-1,S=l.length,x=S-1,E=o;E!=null&&++b<S;){var T=sn(l[b]),N=f;if(T==="__proto__"||T==="constructor"||T==="prototype")return o;if(b!=x){var I=E[T];N=m?m(I,T,E):t,N===t&&(N=Ae(I)?I:bn(l[b+1])?[]:{})}Ti(E,T,N),E=E[T]}return o}var Rf=Is?function(o,l){return Is.set(o,l),o}:_t,ab=Cs?function(o,l){return Cs(o,"toString",{configurable:!0,enumerable:!1,value:gl(l),writable:!0})}:_t;function lb(o){return Js(Jr(o))}function Lt(o,l,f){var m=-1,b=o.length;l<0&&(l=-l>b?0:b+l),f=f>b?b:f,f<0&&(f+=b),b=l>f?0:f-l>>>0,l>>>=0;for(var S=C(b);++m<b;)S[m]=o[m+l];return S}function cb(o,l){var f;return Ln(o,function(m,b,S){return f=l(m,b,S),!f}),!!f}function $s(o,l,f){var m=0,b=o==null?m:o.length;if(typeof l=="number"&&l===l&&b<=Ve){for(;m<b;){var S=m+b>>>1,x=o[S];x!==null&&!Et(x)&&(f?x<=l:x<l)?m=S+1:b=S}return b}return Ua(o,l,_t,f)}function Ua(o,l,f,m){var b=0,S=o==null?0:o.length;if(S===0)return 0;l=f(l);for(var x=l!==l,E=l===null,T=Et(l),N=l===t;b<S;){var I=Ns((b+S)/2),R=f(o[I]),W=R!==t,G=R===null,Z=R===R,le=Et(R);if(x)var ee=m||Z;else N?ee=Z&&(m||W):E?ee=Z&&W&&(m||!G):T?ee=Z&&W&&!G&&(m||!le):G||le?ee=!1:ee=m?R<=l:R<l;ee?b=I+1:S=I}return et(S,xe)}function Df(o,l){for(var f=-1,m=o.length,b=0,S=[];++f<m;){var x=o[f],E=l?l(x):x;if(!f||!Qt(E,T)){var T=E;S[b++]=x===0?0:x}}return S}function Lf(o){return typeof o=="number"?o:Et(o)?F:+o}function xt(o){if(typeof o=="string")return o;if(se(o))return Te(o,xt)+"";if(Et(o))return pf?pf.call(o):"";var l=o+"";return l=="0"&&1/o==-1/0?"-0":l}function Bn(o,l,f){var m=-1,b=_s,S=o.length,x=!0,E=[],T=E;if(f)x=!1,b=ba;else if(S>=i){var N=l?null:vb(o);if(N)return vs(N);x=!1,b=Si,T=new ar}else T=l?[]:E;e:for(;++m<S;){var I=o[m],R=l?l(I):I;if(I=f||I!==0?I:0,x&&R===R){for(var W=T.length;W--;)if(T[W]===R)continue e;l&&T.push(R),E.push(I)}else b(T,R,f)||(T!==E&&T.push(R),E.push(I))}return E}function Ka(o,l){return l=Fn(l,o),o=ud(o,l),o==null||delete o[sn(Bt(l))]}function Bf(o,l,f,m){return Ni(o,l,f(cr(o,l)),m)}function zs(o,l,f,m){for(var b=o.length,S=m?b:-1;(m?S--:++S<b)&&l(o[S],S,o););return f?Lt(o,m?0:S,m?S+1:b):Lt(o,m?S+1:0,m?b:S)}function Ff(o,l){var f=o;return f instanceof he&&(f=f.value()),va(l,function(m,b){return b.func.apply(b.thisArg,Pn([m],b.args))},f)}function ja(o,l,f){var m=o.length;if(m<2)return m?Bn(o[0]):[];for(var b=-1,S=C(m);++b<m;)for(var x=o[b],E=-1;++E<m;)E!=b&&(S[b]=Ai(S[b]||x,o[E],l,f));return Bn(Ye(S,1),l,f)}function $f(o,l,f){for(var m=-1,b=o.length,S=l.length,x={};++m<b;){var E=m<S?l[m]:t;f(x,o[m],E)}return x}function qa(o){return Pe(o)?o:[]}function Ja(o){return typeof o=="function"?o:_t}function Fn(o,l){return se(o)?o:rl(o,l)?[o]:pd(_e(o))}var ub=ue;function $n(o,l,f){var m=o.length;return f=f===t?m:f,!l&&f>=m?o:Lt(o,l,f)}var zf=Q0||function(o){return Ge.clearTimeout(o)};function Wf(o,l){if(l)return o.slice();var f=o.length,m=lf?lf(f):new o.constructor(f);return o.copy(m),m}function Ga(o){var l=new o.constructor(o.byteLength);return new Os(l).set(new Os(o)),l}function fb(o,l){var f=l?Ga(o.buffer):o.buffer;return new o.constructor(f,o.byteOffset,o.byteLength)}function db(o){var l=new o.constructor(o.source,ku.exec(o));return l.lastIndex=o.lastIndex,l}function hb(o){return Oi?Se(Oi.call(o)):{}}function Vf(o,l){var f=l?Ga(o.buffer):o.buffer;return new o.constructor(f,o.byteOffset,o.length)}function Hf(o,l){if(o!==l){var f=o!==t,m=o===null,b=o===o,S=Et(o),x=l!==t,E=l===null,T=l===l,N=Et(l);if(!E&&!N&&!S&&o>l||S&&x&&T&&!E&&!N||m&&x&&T||!f&&T||!b)return 1;if(!m&&!S&&!N&&o<l||N&&f&&b&&!m&&!S||E&&f&&b||!x&&b||!T)return-1}return 0}function pb(o,l,f){for(var m=-1,b=o.criteria,S=l.criteria,x=b.length,E=f.length;++m<x;){var T=Hf(b[m],S[m]);if(T){if(m>=E)return T;var N=f[m];return T*(N=="desc"?-1:1)}}return o.index-l.index}function Uf(o,l,f,m){for(var b=-1,S=o.length,x=f.length,E=-1,T=l.length,N=Fe(S-x,0),I=C(T+N),R=!m;++E<T;)I[E]=l[E];for(;++b<x;)(R||b<S)&&(I[f[b]]=o[b]);for(;N--;)I[E++]=o[b++];return I}function Kf(o,l,f,m){for(var b=-1,S=o.length,x=-1,E=f.length,T=-1,N=l.length,I=Fe(S-E,0),R=C(I+N),W=!m;++b<I;)R[b]=o[b];for(var G=b;++T<N;)R[G+T]=l[T];for(;++x<E;)(W||b<S)&&(R[G+f[x]]=o[b++]);return R}function mt(o,l){var f=-1,m=o.length;for(l||(l=C(m));++f<m;)l[f]=o[f];return l}function rn(o,l,f,m){var b=!f;f||(f={});for(var S=-1,x=l.length;++S<x;){var E=l[S],T=m?m(f[E],o[E],E,f,o):t;T===t&&(T=o[E]),b?gn(f,E,T):Ti(f,E,T)}return f}function mb(o,l){return rn(o,nl(o),l)}function gb(o,l){return rn(o,id(o),l)}function Ws(o,l){return function(f,m){var b=se(f)?S0:F_,S=l?l():{};return b(f,o,X(m,2),S)}}function Ur(o){return ue(function(l,f){var m=-1,b=f.length,S=b>1?f[b-1]:t,x=b>2?f[2]:t;for(S=o.length>3&&typeof S=="function"?(b--,S):t,x&&lt(f[0],f[1],x)&&(S=b<3?t:S,b=1),l=Se(l);++m<b;){var E=f[m];E&&o(l,E,m,S)}return l})}function jf(o,l){return function(f,m){if(f==null)return f;if(!gt(f))return o(f,m);for(var b=f.length,S=l?b:-1,x=Se(f);(l?S--:++S<b)&&m(x[S],S,x)!==!1;);return f}}function qf(o){return function(l,f,m){for(var b=-1,S=Se(l),x=m(l),E=x.length;E--;){var T=x[o?E:++b];if(f(S[T],T,S)===!1)break}return l}}function yb(o,l,f){var m=l&k,b=Ii(o);function S(){var x=this&&this!==Ge&&this instanceof S?b:o;return x.apply(m?f:this,arguments)}return S}function Jf(o){return function(l){l=_e(l);var f=Br(l)?Gt(l):t,m=f?f[0]:l.charAt(0),b=f?$n(f,1).join(""):l.slice(1);return m[o]()+b}}function Kr(o){return function(l){return va(jd(Kd(l).replace(a0,"")),o,"")}}function Ii(o){return function(){var l=arguments;switch(l.length){case 0:return new o;case 1:return new o(l[0]);case 2:return new o(l[0],l[1]);case 3:return new o(l[0],l[1],l[2]);case 4:return new o(l[0],l[1],l[2],l[3]);case 5:return new o(l[0],l[1],l[2],l[3],l[4]);case 6:return new o(l[0],l[1],l[2],l[3],l[4],l[5]);case 7:return new o(l[0],l[1],l[2],l[3],l[4],l[5],l[6])}var f=Hr(o.prototype),m=o.apply(f,l);return Ae(m)?m:f}}function _b(o,l,f){var m=Ii(o);function b(){for(var S=arguments.length,x=C(S),E=S,T=jr(b);E--;)x[E]=arguments[E];var N=S<3&&x[0]!==T&&x[S-1]!==T?[]:Rn(x,T);if(S-=N.length,S<f)return Zf(o,l,Vs,b.placeholder,t,x,N,t,t,f-S);var I=this&&this!==Ge&&this instanceof b?m:o;return wt(I,this,x)}return b}function Gf(o){return function(l,f,m){var b=Se(l);if(!gt(l)){var S=X(f,3);l=He(l),f=function(E){return S(b[E],E,b)}}var x=o(l,f,m);return x>-1?b[S?l[x]:x]:t}}function Yf(o){return _n(function(l){var f=l.length,m=f,b=Rt.prototype.thru;for(o&&l.reverse();m--;){var S=l[m];if(typeof S!="function")throw new Pt(a);if(b&&!x&&js(S)=="wrapper")var x=new Rt([],!0)}for(m=x?m:f;++m<f;){S=l[m];var E=js(S),T=E=="wrapper"?el(S):t;T&&il(T[0])&&T[1]==(J|L|z|K)&&!T[4].length&&T[9]==1?x=x[js(T[0])].apply(x,T[3]):x=S.length==1&&il(S)?x[E]():x.thru(S)}return function(){var N=arguments,I=N[0];if(x&&N.length==1&&se(I))return x.plant(I).value();for(var R=0,W=f?l[R].apply(this,N):I;++R<f;)W=l[R].call(this,W);return W}})}function Vs(o,l,f,m,b,S,x,E,T,N){var I=l&J,R=l&k,W=l&A,G=l&(L|B),Z=l&V,le=W?t:Ii(o);function ee(){for(var de=arguments.length,pe=C(de),Ot=de;Ot--;)pe[Ot]=arguments[Ot];if(G)var ct=jr(ee),Tt=M0(pe,ct);if(m&&(pe=Uf(pe,m,b,G)),S&&(pe=Kf(pe,S,x,G)),de-=Tt,G&&de<N){var Re=Rn(pe,ct);return Zf(o,l,Vs,ee.placeholder,f,pe,Re,E,T,N-de)}var Xt=R?f:this,wn=W?Xt[o]:o;return de=pe.length,E?pe=Fb(pe,E):Z&&de>1&&pe.reverse(),I&&T<de&&(pe.length=T),this&&this!==Ge&&this instanceof ee&&(wn=le||Ii(wn)),wn.apply(Xt,pe)}return ee}function Qf(o,l){return function(f,m){return j_(f,o,l(m),{})}}function Hs(o,l){return function(f,m){var b;if(f===t&&m===t)return l;if(f!==t&&(b=f),m!==t){if(b===t)return m;typeof f=="string"||typeof m=="string"?(f=xt(f),m=xt(m)):(f=Lf(f),m=Lf(m)),b=o(f,m)}return b}}function Ya(o){return _n(function(l){return l=Te(l,kt(X())),ue(function(f){var m=this;return o(l,function(b){return wt(b,m,f)})})})}function Us(o,l){l=l===t?" ":xt(l);var f=l.length;if(f<2)return f?Ha(l,o):l;var m=Ha(l,Ms(o/Fr(l)));return Br(l)?$n(Gt(m),0,o).join(""):m.slice(0,o)}function bb(o,l,f,m){var b=l&k,S=Ii(o);function x(){for(var E=-1,T=arguments.length,N=-1,I=m.length,R=C(I+T),W=this&&this!==Ge&&this instanceof x?S:o;++N<I;)R[N]=m[N];for(;T--;)R[N++]=arguments[++E];return wt(W,b?f:this,R)}return x}function Xf(o){return function(l,f,m){return m&&typeof m!="number"&&lt(l,f,m)&&(f=m=t),l=Sn(l),f===t?(f=l,l=0):f=Sn(f),m=m===t?l<f?1:-1:Sn(m),ib(l,f,m,o)}}function Ks(o){return function(l,f){return typeof l=="string"&&typeof f=="string"||(l=Ft(l),f=Ft(f)),o(l,f)}}function Zf(o,l,f,m,b,S,x,E,T,N){var I=l&L,R=I?x:t,W=I?t:x,G=I?S:t,Z=I?t:S;l|=I?z:$,l&=~(I?$:z),l&P||(l&=-4);var le=[o,l,b,G,R,Z,W,E,T,N],ee=f.apply(t,le);return il(o)&&fd(ee,le),ee.placeholder=m,dd(ee,o,l)}function Qa(o){var l=Be[o];return function(f,m){if(f=Ft(f),m=m==null?0:et(oe(m),292),m&&df(f)){var b=(_e(f)+"e").split("e"),S=l(b[0]+"e"+(+b[1]+m));return b=(_e(S)+"e").split("e"),+(b[0]+"e"+(+b[1]-m))}return l(f)}}var vb=Wr&&1/vs(new Wr([,-0]))[1]==jt?function(o){return new Wr(o)}:bl;function ed(o){return function(l){var f=tt(l);return f==qt?Ta(l):f==Jt?B0(l):C0(l,o(l))}}function yn(o,l,f,m,b,S,x,E){var T=l&A;if(!T&&typeof o!="function")throw new Pt(a);var N=m?m.length:0;if(N||(l&=-97,m=b=t),x=x===t?x:Fe(oe(x),0),E=E===t?E:oe(E),N-=b?b.length:0,l&$){var I=m,R=b;m=b=t}var W=T?t:el(o),G=[o,l,f,m,b,I,R,S,x,E];if(W&&Db(G,W),o=G[0],l=G[1],f=G[2],m=G[3],b=G[4],E=G[9]=G[9]===t?T?0:o.length:Fe(G[9]-N,0),!E&&l&(L|B)&&(l&=-25),!l||l==k)var Z=yb(o,l,f);else l==L||l==B?Z=_b(o,l,E):(l==z||l==(k|z))&&!b.length?Z=bb(o,l,f,m):Z=Vs.apply(t,G);var le=W?Rf:fd;return dd(le(Z,G),o,l)}function td(o,l,f,m){return o===t||Qt(o,zr[f])&&!be.call(m,f)?l:o}function nd(o,l,f,m,b,S){return Ae(o)&&Ae(l)&&(S.set(l,o),Fs(o,l,t,nd,S),S.delete(l)),o}function Sb(o){return Di(o)?t:o}function rd(o,l,f,m,b,S){var x=f&_,E=o.length,T=l.length;if(E!=T&&!(x&&T>E))return!1;var N=S.get(o),I=S.get(l);if(N&&I)return N==l&&I==o;var R=-1,W=!0,G=f&w?new ar:t;for(S.set(o,l),S.set(l,o);++R<E;){var Z=o[R],le=l[R];if(m)var ee=x?m(le,Z,R,l,o,S):m(Z,le,R,o,l,S);if(ee!==t){if(ee)continue;W=!1;break}if(G){if(!Sa(l,function(de,pe){if(!Si(G,pe)&&(Z===de||b(Z,de,f,m,S)))return G.push(pe)})){W=!1;break}}else if(!(Z===le||b(Z,le,f,m,S))){W=!1;break}}return S.delete(o),S.delete(l),W}function wb(o,l,f,m,b,S,x){switch(f){case Rr:if(o.byteLength!=l.byteLength||o.byteOffset!=l.byteOffset)return!1;o=o.buffer,l=l.buffer;case vi:return!(o.byteLength!=l.byteLength||!S(new Os(o),new Os(l)));case Me:case Mt:case gi:return Qt(+o,+l);case Pr:return o.name==l.name&&o.message==l.message;case yi:case _i:return o==l+"";case qt:var E=Ta;case Jt:var T=m&_;if(E||(E=vs),o.size!=l.size&&!T)return!1;var N=x.get(o);if(N)return N==l;m|=w,x.set(o,l);var I=rd(E(o),E(l),m,b,S,x);return x.delete(o),I;case ps:if(Oi)return Oi.call(o)==Oi.call(l)}return!1}function kb(o,l,f,m,b,S){var x=f&_,E=Xa(o),T=E.length,N=Xa(l),I=N.length;if(T!=I&&!x)return!1;for(var R=T;R--;){var W=E[R];if(!(x?W in l:be.call(l,W)))return!1}var G=S.get(o),Z=S.get(l);if(G&&Z)return G==l&&Z==o;var le=!0;S.set(o,l),S.set(l,o);for(var ee=x;++R<T;){W=E[R];var de=o[W],pe=l[W];if(m)var Ot=x?m(pe,de,W,l,o,S):m(de,pe,W,o,l,S);if(!(Ot===t?de===pe||b(de,pe,f,m,S):Ot)){le=!1;break}ee||(ee=W=="constructor")}if(le&&!ee){var ct=o.constructor,Tt=l.constructor;ct!=Tt&&"constructor"in o&&"constructor"in l&&!(typeof ct=="function"&&ct instanceof ct&&typeof Tt=="function"&&Tt instanceof Tt)&&(le=!1)}return S.delete(o),S.delete(l),le}function _n(o){return ol(cd(o,t,_d),o+"")}function Xa(o){return kf(o,He,nl)}function Za(o){return kf(o,yt,id)}var el=Is?function(o){return Is.get(o)}:bl;function js(o){for(var l=o.name+"",f=Vr[l],m=be.call(Vr,l)?f.length:0;m--;){var b=f[m],S=b.func;if(S==null||S==o)return b.name}return l}function jr(o){var l=be.call(v,"placeholder")?v:o;return l.placeholder}function X(){var o=v.iteratee||yl;return o=o===yl?Of:o,arguments.length?o(arguments[0],arguments[1]):o}function qs(o,l){var f=o.__data__;return Nb(l)?f[typeof l=="string"?"string":"hash"]:f.map}function tl(o){for(var l=He(o),f=l.length;f--;){var m=l[f],b=o[m];l[f]=[m,b,ad(b)]}return l}function ur(o,l){var f=R0(o,l);return Ef(f)?f:t}function xb(o){var l=be.call(o,sr),f=o[sr];try{o[sr]=t;var m=!0}catch{}var b=xs.call(o);return m&&(l?o[sr]=f:delete o[sr]),b}var nl=Ca?function(o){return o==null?[]:(o=Se(o),In(Ca(o),function(l){return uf.call(o,l)}))}:vl,id=Ca?function(o){for(var l=[];o;)Pn(l,nl(o)),o=Ts(o);return l}:vl,tt=at;(Ma&&tt(new Ma(new ArrayBuffer(1)))!=Rr||ki&&tt(new ki)!=qt||Na&&tt(Na.resolve())!=bu||Wr&&tt(new Wr)!=Jt||xi&&tt(new xi)!=bi)&&(tt=function(o){var l=at(o),f=l==hn?o.constructor:t,m=f?fr(f):"";if(m)switch(m){case o_:return Rr;case a_:return qt;case l_:return bu;case c_:return Jt;case u_:return bi}return l});function Eb(o,l,f){for(var m=-1,b=f.length;++m<b;){var S=f[m],x=S.size;switch(S.type){case"drop":o+=x;break;case"dropRight":l-=x;break;case"take":l=et(l,o+x);break;case"takeRight":o=Fe(o,l-x);break}}return{start:o,end:l}}function Ob(o){var l=o.match(Iy);return l?l[1].split(Py):[]}function sd(o,l,f){l=Fn(l,o);for(var m=-1,b=l.length,S=!1;++m<b;){var x=sn(l[m]);if(!(S=o!=null&&f(o,x)))break;o=o[x]}return S||++m!=b?S:(b=o==null?0:o.length,!!b&&eo(b)&&bn(x,b)&&(se(o)||dr(o)))}function Tb(o){var l=o.length,f=new o.constructor(l);return l&&typeof o[0]=="string"&&be.call(o,"index")&&(f.index=o.index,f.input=o.input),f}function od(o){return typeof o.constructor=="function"&&!Pi(o)?Hr(Ts(o)):{}}function Ab(o,l,f){var m=o.constructor;switch(l){case vi:return Ga(o);case Me:case Mt:return new m(+o);case Rr:return fb(o,f);case ta:case na:case ra:case ia:case sa:case oa:case aa:case la:case ca:return Vf(o,f);case qt:return new m;case gi:case _i:return new m(o);case yi:return db(o);case Jt:return new m;case ps:return hb(o)}}function Cb(o,l){var f=l.length;if(!f)return o;var m=f-1;return l[m]=(f>1?"& ":"")+l[m],l=l.join(f>2?", ":" "),o.replace(Ny,`{
109
111
  /* [wrapped with `+l+`] */
110
- `)}function Mb(o){return se(o)||dr(o)||!!(ff&&o&&o[ff])}function bn(o,l){var f=typeof o;return l=l??dn,!!l&&(f=="number"||f!="symbol"&&Vy.test(o))&&o>-1&&o%1==0&&o<l}function lt(o,l,f){if(!Ae(f))return!1;var m=typeof l;return(m=="number"?gt(f)&&bn(l,f.length):m=="string"&&l in f)?Qt(f[l],o):!1}function rl(o,l){if(se(o))return!1;var f=typeof o;return f=="number"||f=="symbol"||f=="boolean"||o==null||Et(o)?!0:Ty.test(o)||!Oy.test(o)||l!=null&&o in Se(l)}function Nb(o){var l=typeof o;return l=="string"||l=="number"||l=="symbol"||l=="boolean"?o!=="__proto__":o===null}function il(o){var l=js(o),f=v[l];if(typeof f!="function"||!(l in he.prototype))return!1;if(o===f)return!0;var m=el(f);return!!m&&o===m[0]}function Ib(o){return!!af&&af in o}var Pb=ws?vn:Sl;function Pi(o){var l=o&&o.constructor,f=typeof l=="function"&&l.prototype||$r;return o===f}function ad(o){return o===o&&!Ae(o)}function ld(o,l){return function(f){return f==null?!1:f[o]===l&&(l!==t||o in Se(f))}}function Rb(o){var l=Xs(o,function(m){return f.size===d&&f.clear(),m}),f=l.cache;return l}function Db(o,l){var f=o[1],m=l[1],b=f|m,S=b<(k|A|J),x=m==J&&f==L||m==J&&f==K&&o[7].length<=l[8]||m==(J|K)&&l[7].length<=l[8]&&f==L;if(!(S||x))return o;m&k&&(o[2]=l[2],b|=f&k?0:P);var E=l[3];if(E){var T=o[3];o[3]=T?Uf(T,E,l[4]):E,o[4]=T?Rn(o[3],h):l[4]}return E=l[5],E&&(T=o[5],o[5]=T?Kf(T,E,l[6]):E,o[6]=T?Rn(o[5],h):l[6]),E=l[7],E&&(o[7]=E),m&J&&(o[8]=o[8]==null?l[8]:et(o[8],l[8])),o[9]==null&&(o[9]=l[9]),o[0]=l[0],o[1]=b,o}function Lb(o){var l=[];if(o!=null)for(var f in Se(o))l.push(f);return l}function Bb(o){return xs.call(o)}function cd(o,l,f){return l=Fe(l===t?o.length-1:l,0),function(){for(var m=arguments,b=-1,S=Fe(m.length-l,0),x=C(S);++b<S;)x[b]=m[l+b];b=-1;for(var E=C(l+1);++b<l;)E[b]=m[b];return E[l]=f(x),wt(o,this,E)}}function ud(o,l){return l.length<2?o:cr(o,Lt(l,0,-1))}function Fb(o,l){for(var f=o.length,m=et(l.length,f),b=mt(o);m--;){var S=l[m];o[m]=bn(S,f)?b[S]:t}return o}function sl(o,l){if(!(l==="constructor"&&typeof o[l]=="function")&&l!="__proto__")return o[l]}var fd=hd(Rf),Ri=Z0||function(o,l){return Ge.setTimeout(o,l)},ol=hd(ab);function dd(o,l,f){var m=l+"";return ol(o,Cb(m,$b(Ob(m),f)))}function hd(o){var l=0,f=0;return function(){var m=r_(),b=pt-(m-f);if(f=m,b>0){if(++l>=De)return arguments[0]}else l=0;return o.apply(t,arguments)}}function Js(o,l){var f=-1,m=o.length,b=m-1;for(l=l===t?m:l;++f<l;){var S=Va(f,b),x=o[S];o[S]=o[f],o[f]=x}return o.length=l,o}var pd=Rb(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(Ay,function(f,m,b,S){l.push(b?S.replace(Ly,"$1"):m||f)}),l});function sn(o){if(typeof o=="string"||Et(o))return o;var l=o+"";return l=="0"&&1/o==-1/0?"-0":l}function fr(o){if(o!=null){try{return ks.call(o)}catch{}try{return o+""}catch{}}return""}function $b(o,l){return It(tn,function(f){var m="_."+f[0];l&f[1]&&!_s(o,m)&&o.push(m)}),o.sort()}function md(o){if(o instanceof he)return o.clone();var l=new Rt(o.__wrapped__,o.__chain__);return l.__actions__=mt(o.__actions__),l.__index__=o.__index__,l.__values__=o.__values__,l}function zb(o,l,f){(f?lt(o,l,f):l===t)?l=1:l=Fe(oe(l),0);var m=o==null?0:o.length;if(!m||l<1)return[];for(var b=0,S=0,x=C(Ms(m/l));b<m;)x[S++]=Lt(o,b,b+=l);return x}function Wb(o){for(var l=-1,f=o==null?0:o.length,m=0,b=[];++l<f;){var S=o[l];S&&(b[m++]=S)}return b}function Vb(){var o=arguments.length;if(!o)return[];for(var l=C(o-1),f=arguments[0],m=o;m--;)l[m-1]=arguments[m];return Pn(se(f)?mt(f):[f],Ye(l,1))}var Hb=ue(function(o,l){return Pe(o)?Ai(o,Ye(l,1,Pe,!0)):[]}),Ub=ue(function(o,l){var f=Bt(l);return Pe(f)&&(f=t),Pe(o)?Ai(o,Ye(l,1,Pe,!0),X(f,2)):[]}),Kb=ue(function(o,l){var f=Bt(l);return Pe(f)&&(f=t),Pe(o)?Ai(o,Ye(l,1,Pe,!0),t,f):[]});function jb(o,l,f){var m=o==null?0:o.length;return m?(l=f||l===t?1:oe(l),Lt(o,l<0?0:l,m)):[]}function qb(o,l,f){var m=o==null?0:o.length;return m?(l=f||l===t?1:oe(l),l=m-l,Lt(o,0,l<0?0:l)):[]}function Jb(o,l){return o&&o.length?zs(o,X(l,3),!0,!0):[]}function Gb(o,l){return o&&o.length?zs(o,X(l,3),!0):[]}function Yb(o,l,f,m){var b=o==null?0:o.length;return b?(f&&typeof f!="number"&&lt(o,l,f)&&(f=0,m=b),V_(o,l,f,m)):[]}function gd(o,l,f){var m=o==null?0:o.length;if(!m)return-1;var b=f==null?0:oe(f);return b<0&&(b=Fe(m+b,0)),bs(o,X(l,3),b)}function yd(o,l,f){var m=o==null?0:o.length;if(!m)return-1;var b=m-1;return f!==t&&(b=oe(f),b=f<0?Fe(m+b,0):et(b,m-1)),bs(o,X(l,3),b,!0)}function _d(o){var l=o==null?0:o.length;return l?Ye(o,1):[]}function Qb(o){var l=o==null?0:o.length;return l?Ye(o,jt):[]}function Xb(o,l){var f=o==null?0:o.length;return f?(l=l===t?1:oe(l),Ye(o,l)):[]}function Zb(o){for(var l=-1,f=o==null?0:o.length,m={};++l<f;){var b=o[l];m[b[0]]=b[1]}return m}function bd(o){return o&&o.length?o[0]:t}function ev(o,l,f){var m=o==null?0:o.length;if(!m)return-1;var b=f==null?0:oe(f);return b<0&&(b=Fe(m+b,0)),Dr(o,l,b)}function tv(o){var l=o==null?0:o.length;return l?Lt(o,0,-1):[]}var nv=ue(function(o){var l=Te(o,qa);return l.length&&l[0]===o[0]?Ba(l):[]}),rv=ue(function(o){var l=Bt(o),f=Te(o,qa);return l===Bt(f)?l=t:f.pop(),f.length&&f[0]===o[0]?Ba(f,X(l,2)):[]}),iv=ue(function(o){var l=Bt(o),f=Te(o,qa);return l=typeof l=="function"?l:t,l&&f.pop(),f.length&&f[0]===o[0]?Ba(f,t,l):[]});function sv(o,l){return o==null?"":t_.call(o,l)}function Bt(o){var l=o==null?0:o.length;return l?o[l-1]:t}function ov(o,l,f){var m=o==null?0:o.length;if(!m)return-1;var b=m;return f!==t&&(b=oe(f),b=b<0?Fe(m+b,0):et(b,m-1)),l===l?$0(o,l,b):bs(o,Xu,b,!0)}function av(o,l){return o&&o.length?Mf(o,oe(l)):t}var lv=ue(vd);function vd(o,l){return o&&o.length&&l&&l.length?Wa(o,l):o}function cv(o,l,f){return o&&o.length&&l&&l.length?Wa(o,l,X(f,2)):o}function uv(o,l,f){return o&&o.length&&l&&l.length?Wa(o,l,t,f):o}var fv=_n(function(o,l){var f=o==null?0:o.length,m=Pa(o,l);return Pf(o,Te(l,function(b){return bn(b,f)?+b:b}).sort(Hf)),m});function dv(o,l){var f=[];if(!(o&&o.length))return f;var m=-1,b=[],S=o.length;for(l=X(l,3);++m<S;){var x=o[m];l(x,m,o)&&(f.push(x),b.push(m))}return Pf(o,b),f}function al(o){return o==null?o:s_.call(o)}function hv(o,l,f){var m=o==null?0:o.length;return m?(f&&typeof f!="number"&&lt(o,l,f)?(l=0,f=m):(l=l==null?0:oe(l),f=f===t?m:oe(f)),Lt(o,l,f)):[]}function pv(o,l){return $s(o,l)}function mv(o,l,f){return Ua(o,l,X(f,2))}function gv(o,l){var f=o==null?0:o.length;if(f){var m=$s(o,l);if(m<f&&Qt(o[m],l))return m}return-1}function yv(o,l){return $s(o,l,!0)}function _v(o,l,f){return Ua(o,l,X(f,2),!0)}function bv(o,l){var f=o==null?0:o.length;if(f){var m=$s(o,l,!0)-1;if(Qt(o[m],l))return m}return-1}function vv(o){return o&&o.length?Df(o):[]}function Sv(o,l){return o&&o.length?Df(o,X(l,2)):[]}function wv(o){var l=o==null?0:o.length;return l?Lt(o,1,l):[]}function kv(o,l,f){return o&&o.length?(l=f||l===t?1:oe(l),Lt(o,0,l<0?0:l)):[]}function xv(o,l,f){var m=o==null?0:o.length;return m?(l=f||l===t?1:oe(l),l=m-l,Lt(o,l<0?0:l,m)):[]}function Ev(o,l){return o&&o.length?zs(o,X(l,3),!1,!0):[]}function Ov(o,l){return o&&o.length?zs(o,X(l,3)):[]}var Tv=ue(function(o){return Bn(Ye(o,1,Pe,!0))}),Av=ue(function(o){var l=Bt(o);return Pe(l)&&(l=t),Bn(Ye(o,1,Pe,!0),X(l,2))}),Cv=ue(function(o){var l=Bt(o);return l=typeof l=="function"?l:t,Bn(Ye(o,1,Pe,!0),t,l)});function Mv(o){return o&&o.length?Bn(o):[]}function Nv(o,l){return o&&o.length?Bn(o,X(l,2)):[]}function Iv(o,l){return l=typeof l=="function"?l:t,o&&o.length?Bn(o,t,l):[]}function ll(o){if(!(o&&o.length))return[];var l=0;return o=In(o,function(f){if(Pe(f))return l=Fe(f.length,l),!0}),Ea(l,function(f){return Te(o,wa(f))})}function Sd(o,l){if(!(o&&o.length))return[];var f=ll(o);return l==null?f:Te(f,function(m){return wt(l,t,m)})}var Pv=ue(function(o,l){return Pe(o)?Ai(o,l):[]}),Rv=ue(function(o){return ja(In(o,Pe))}),Dv=ue(function(o){var l=Bt(o);return Pe(l)&&(l=t),ja(In(o,Pe),X(l,2))}),Lv=ue(function(o){var l=Bt(o);return l=typeof l=="function"?l:t,ja(In(o,Pe),t,l)}),Bv=ue(ll);function Fv(o,l){return $f(o||[],l||[],Ti)}function $v(o,l){return $f(o||[],l||[],Ni)}var zv=ue(function(o){var l=o.length,f=l>1?o[l-1]:t;return f=typeof f=="function"?(o.pop(),f):t,Sd(o,f)});function wd(o){var l=v(o);return l.__chain__=!0,l}function Wv(o,l){return l(o),o}function Gs(o,l){return l(o)}var Vv=_n(function(o){var l=o.length,f=l?o[0]:0,m=this.__wrapped__,b=function(S){return Pa(S,o)};return l>1||this.__actions__.length||!(m instanceof he)||!bn(f)?this.thru(b):(m=m.slice(f,+f+(l?1:0)),m.__actions__.push({func:Gs,args:[b],thisArg:t}),new Rt(m,this.__chain__).thru(function(S){return l&&!S.length&&S.push(t),S}))});function Hv(){return wd(this)}function Uv(){return new Rt(this.value(),this.__chain__)}function Kv(){this.__values__===t&&(this.__values__=Ld(this.value()));var o=this.__index__>=this.__values__.length,l=o?t:this.__values__[this.__index__++];return{done:o,value:l}}function jv(){return this}function qv(o){for(var l,f=this;f instanceof Rs;){var m=md(f);m.__index__=0,m.__values__=t,l?b.__wrapped__=m:l=m;var b=m;f=f.__wrapped__}return b.__wrapped__=o,l}function Jv(){var o=this.__wrapped__;if(o instanceof he){var l=o;return this.__actions__.length&&(l=new he(this)),l=l.reverse(),l.__actions__.push({func:Gs,args:[al],thisArg:t}),new Rt(l,this.__chain__)}return this.thru(al)}function Gv(){return Ff(this.__wrapped__,this.__actions__)}var Yv=Ws(function(o,l,f){be.call(o,f)?++o[f]:gn(o,f,1)});function Qv(o,l,f){var m=se(o)?Yu:W_;return f&&lt(o,l,f)&&(l=t),m(o,X(l,3))}function Xv(o,l){var f=se(o)?In:Sf;return f(o,X(l,3))}var Zv=Gf(gd),eS=Gf(yd);function tS(o,l){return Ye(Ys(o,l),1)}function nS(o,l){return Ye(Ys(o,l),jt)}function rS(o,l,f){return f=f===t?1:oe(f),Ye(Ys(o,l),f)}function kd(o,l){var f=se(o)?It:Ln;return f(o,X(l,3))}function xd(o,l){var f=se(o)?w0:vf;return f(o,X(l,3))}var iS=Ws(function(o,l,f){be.call(o,f)?o[f].push(l):gn(o,f,[l])});function sS(o,l,f,m){o=gt(o)?o:qr(o),f=f&&!m?oe(f):0;var b=o.length;return f<0&&(f=Fe(b+f,0)),to(o)?f<=b&&o.indexOf(l,f)>-1:!!b&&Dr(o,l,f)>-1}var oS=ue(function(o,l,f){var m=-1,b=typeof l=="function",S=gt(o)?C(o.length):[];return Ln(o,function(x){S[++m]=b?wt(l,x,f):Ci(x,l,f)}),S}),aS=Ws(function(o,l,f){gn(o,f,l)});function Ys(o,l){var f=se(o)?Te:Tf;return f(o,X(l,3))}function lS(o,l,f,m){return o==null?[]:(se(l)||(l=l==null?[]:[l]),f=m?t:f,se(f)||(f=f==null?[]:[f]),Nf(o,l,f))}var cS=Ws(function(o,l,f){o[f?0:1].push(l)},function(){return[[],[]]});function uS(o,l,f){var m=se(o)?va:ef,b=arguments.length<3;return m(o,X(l,4),f,b,Ln)}function fS(o,l,f){var m=se(o)?k0:ef,b=arguments.length<3;return m(o,X(l,4),f,b,vf)}function dS(o,l){var f=se(o)?In:Sf;return f(o,Zs(X(l,3)))}function hS(o){var l=se(o)?gf:sb;return l(o)}function pS(o,l,f){(f?lt(o,l,f):l===t)?l=1:l=oe(l);var m=se(o)?L_:ob;return m(o,l)}function mS(o){var l=se(o)?B_:lb;return l(o)}function gS(o){if(o==null)return 0;if(gt(o))return to(o)?Br(o):o.length;var l=tt(o);return l==qt||l==Jt?o.size:$a(o).length}function yS(o,l,f){var m=se(o)?Sa:cb;return f&&lt(o,l,f)&&(l=t),m(o,X(l,3))}var _S=ue(function(o,l){if(o==null)return[];var f=l.length;return f>1&&lt(o,l[0],l[1])?l=[]:f>2&&lt(l[0],l[1],l[2])&&(l=[l[0]]),Nf(o,Ye(l,1),[])}),Qs=X0||function(){return Ge.Date.now()};function bS(o,l){if(typeof l!="function")throw new Pt(a);return o=oe(o),function(){if(--o<1)return l.apply(this,arguments)}}function Ed(o,l,f){return l=f?t:l,l=o&&l==null?o.length:l,yn(o,J,t,t,t,t,l)}function Od(o,l){var f;if(typeof l!="function")throw new Pt(a);return o=oe(o),function(){return--o>0&&(f=l.apply(this,arguments)),o<=1&&(l=t),f}}var cl=ue(function(o,l,f){var m=k;if(f.length){var b=Rn(f,Kr(cl));m|=z}return yn(o,m,l,f,b)}),Td=ue(function(o,l,f){var m=k|A;if(f.length){var b=Rn(f,Kr(Td));m|=z}return yn(l,m,o,f,b)});function Ad(o,l,f){l=f?t:l;var m=yn(o,L,t,t,t,t,t,l);return m.placeholder=Ad.placeholder,m}function Cd(o,l,f){l=f?t:l;var m=yn(o,B,t,t,t,t,t,l);return m.placeholder=Cd.placeholder,m}function Md(o,l,f){var m,b,S,x,E,T,N=0,I=!1,R=!1,W=!0;if(typeof o!="function")throw new Pt(a);l=Ft(l)||0,Ae(f)&&(I=!!f.leading,R="maxWait"in f,S=R?Fe(Ft(f.maxWait)||0,l):S,W="trailing"in f?!!f.trailing:W);function G(Re){var Xt=m,wn=b;return m=b=t,N=Re,x=o.apply(wn,Xt),x}function Z(Re){return N=Re,E=Ri(de,l),I?G(Re):x}function le(Re){var Xt=Re-T,wn=Re-N,Gd=l-Xt;return R?et(Gd,S-wn):Gd}function ee(Re){var Xt=Re-T,wn=Re-N;return T===t||Xt>=l||Xt<0||R&&wn>=S}function de(){var Re=Qs();if(ee(Re))return pe(Re);E=Ri(de,le(Re))}function pe(Re){return E=t,W&&m?G(Re):(m=b=t,x)}function Ot(){E!==t&&zf(E),N=0,m=T=b=E=t}function ct(){return E===t?x:pe(Qs())}function Tt(){var Re=Qs(),Xt=ee(Re);if(m=arguments,b=this,T=Re,Xt){if(E===t)return Z(T);if(R)return zf(E),E=Ri(de,l),G(T)}return E===t&&(E=Ri(de,l)),x}return Tt.cancel=Ot,Tt.flush=ct,Tt}var vS=ue(function(o,l){return bf(o,1,l)}),SS=ue(function(o,l,f){return bf(o,Ft(l)||0,f)});function wS(o){return yn(o,V)}function Xs(o,l){if(typeof o!="function"||l!=null&&typeof l!="function")throw new Pt(a);var f=function(){var m=arguments,b=l?l.apply(this,m):m[0],S=f.cache;if(S.has(b))return S.get(b);var x=o.apply(this,m);return f.cache=S.set(b,x)||S,x};return f.cache=new(Xs.Cache||mn),f}Xs.Cache=mn;function Zs(o){if(typeof o!="function")throw new Pt(a);return function(){var l=arguments;switch(l.length){case 0:return!o.call(this);case 1:return!o.call(this,l[0]);case 2:return!o.call(this,l[0],l[1]);case 3:return!o.call(this,l[0],l[1],l[2])}return!o.apply(this,l)}}function kS(o){return Od(2,o)}var xS=ub(function(o,l){l=l.length==1&&se(l[0])?Te(l[0],kt(X())):Te(Ye(l,1),kt(X()));var f=l.length;return ue(function(m){for(var b=-1,S=et(m.length,f);++b<S;)m[b]=l[b].call(this,m[b]);return wt(o,this,m)})}),ul=ue(function(o,l){var f=Rn(l,Kr(ul));return yn(o,z,t,l,f)}),Nd=ue(function(o,l){var f=Rn(l,Kr(Nd));return yn(o,$,t,l,f)}),ES=_n(function(o,l){return yn(o,K,t,t,t,l)});function OS(o,l){if(typeof o!="function")throw new Pt(a);return l=l===t?l:oe(l),ue(o,l)}function TS(o,l){if(typeof o!="function")throw new Pt(a);return l=l==null?0:Fe(oe(l),0),ue(function(f){var m=f[l],b=$n(f,0,l);return m&&Pn(b,m),wt(o,this,b)})}function AS(o,l,f){var m=!0,b=!0;if(typeof o!="function")throw new Pt(a);return Ae(f)&&(m="leading"in f?!!f.leading:m,b="trailing"in f?!!f.trailing:b),Md(o,l,{leading:m,maxWait:l,trailing:b})}function CS(o){return Ed(o,1)}function MS(o,l){return ul(Ja(l),o)}function NS(){if(!arguments.length)return[];var o=arguments[0];return se(o)?o:[o]}function IS(o){return Dt(o,g)}function PS(o,l){return l=typeof l=="function"?l:t,Dt(o,g,l)}function RS(o){return Dt(o,p|g)}function DS(o,l){return l=typeof l=="function"?l:t,Dt(o,p|g,l)}function LS(o,l){return l==null||_f(o,l,He(l))}function Qt(o,l){return o===l||o!==o&&l!==l}var BS=Ks(La),FS=Ks(function(o,l){return o>=l}),dr=xf(function(){return arguments}())?xf:function(o){return Ne(o)&&be.call(o,"callee")&&!uf.call(o,"callee")},se=C.isArray,$S=Uu?kt(Uu):q_;function gt(o){return o!=null&&eo(o.length)&&!vn(o)}function Pe(o){return Ne(o)&&gt(o)}function zS(o){return o===!0||o===!1||Ne(o)&&at(o)==Me}var zn=e_||Sl,WS=Ku?kt(Ku):J_;function VS(o){return Ne(o)&&o.nodeType===1&&!Di(o)}function HS(o){if(o==null)return!0;if(gt(o)&&(se(o)||typeof o=="string"||typeof o.splice=="function"||zn(o)||jr(o)||dr(o)))return!o.length;var l=tt(o);if(l==qt||l==Jt)return!o.size;if(Pi(o))return!$a(o).length;for(var f in o)if(be.call(o,f))return!1;return!0}function US(o,l){return Mi(o,l)}function KS(o,l,f){f=typeof f=="function"?f:t;var m=f?f(o,l):t;return m===t?Mi(o,l,t,f):!!m}function fl(o){if(!Ne(o))return!1;var l=at(o);return l==Ir||l==mi||typeof o.message=="string"&&typeof o.name=="string"&&!Di(o)}function jS(o){return typeof o=="number"&&df(o)}function vn(o){if(!Ae(o))return!1;var l=at(o);return l==hs||l==_u||l==pi||l==gy}function Id(o){return typeof o=="number"&&o==oe(o)}function eo(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=dn}function Ae(o){var l=typeof o;return o!=null&&(l=="object"||l=="function")}function Ne(o){return o!=null&&typeof o=="object"}var Pd=ju?kt(ju):Y_;function qS(o,l){return o===l||Fa(o,l,tl(l))}function JS(o,l,f){return f=typeof f=="function"?f:t,Fa(o,l,tl(l),f)}function GS(o){return Rd(o)&&o!=+o}function YS(o){if(Pb(o))throw new ie(s);return Ef(o)}function QS(o){return o===null}function XS(o){return o==null}function Rd(o){return typeof o=="number"||Ne(o)&&at(o)==gi}function Di(o){if(!Ne(o)||at(o)!=hn)return!1;var l=Ts(o);if(l===null)return!0;var f=be.call(l,"constructor")&&l.constructor;return typeof f=="function"&&f instanceof f&&ks.call(f)==J0}var dl=qu?kt(qu):Q_;function ZS(o){return Id(o)&&o>=-9007199254740991&&o<=dn}var Dd=Ju?kt(Ju):X_;function to(o){return typeof o=="string"||!se(o)&&Ne(o)&&at(o)==_i}function Et(o){return typeof o=="symbol"||Ne(o)&&at(o)==ps}var jr=Gu?kt(Gu):Z_;function ew(o){return o===t}function tw(o){return Ne(o)&&tt(o)==bi}function nw(o){return Ne(o)&&at(o)==_y}var rw=Ks(za),iw=Ks(function(o,l){return o<=l});function Ld(o){if(!o)return[];if(gt(o))return to(o)?Gt(o):mt(o);if(wi&&o[wi])return L0(o[wi]());var l=tt(o),f=l==qt?Ta:l==Jt?vs:qr;return f(o)}function Sn(o){if(!o)return o===0?o:0;if(o=Ft(o),o===jt||o===-1/0){var l=o<0?-1:1;return l*ds}return o===o?o:0}function oe(o){var l=Sn(o),f=l%1;return l===l?f?l-f:l:0}function Bd(o){return o?lr(oe(o),0,te):0}function Ft(o){if(typeof o=="number")return o;if(Et(o))return F;if(Ae(o)){var l=typeof o.valueOf=="function"?o.valueOf():o;o=Ae(l)?l+"":l}if(typeof o!="string")return o===0?o:+o;o=tf(o);var f=$y.test(o);return f||Wy.test(o)?b0(o.slice(2),f?2:8):Fy.test(o)?F:+o}function Fd(o){return rn(o,yt(o))}function sw(o){return o?lr(oe(o),-9007199254740991,dn):o===0?o:0}function _e(o){return o==null?"":xt(o)}var ow=Hr(function(o,l){if(Pi(l)||gt(l)){rn(l,He(l),o);return}for(var f in l)be.call(l,f)&&Ti(o,f,l[f])}),$d=Hr(function(o,l){rn(l,yt(l),o)}),no=Hr(function(o,l,f,m){rn(l,yt(l),o,m)}),aw=Hr(function(o,l,f,m){rn(l,He(l),o,m)}),lw=_n(Pa);function cw(o,l){var f=Vr(o);return l==null?f:yf(f,l)}var uw=ue(function(o,l){o=Se(o);var f=-1,m=l.length,b=m>2?l[2]:t;for(b&&lt(l[0],l[1],b)&&(m=1);++f<m;)for(var S=l[f],x=yt(S),E=-1,T=x.length;++E<T;){var N=x[E],I=o[N];(I===t||Qt(I,$r[N])&&!be.call(o,N))&&(o[N]=S[N])}return o}),fw=ue(function(o){return o.push(t,nd),wt(zd,t,o)});function dw(o,l){return Qu(o,X(l,3),nn)}function hw(o,l){return Qu(o,X(l,3),Da)}function pw(o,l){return o==null?o:Ra(o,X(l,3),yt)}function mw(o,l){return o==null?o:wf(o,X(l,3),yt)}function gw(o,l){return o&&nn(o,X(l,3))}function yw(o,l){return o&&Da(o,X(l,3))}function _w(o){return o==null?[]:Bs(o,He(o))}function bw(o){return o==null?[]:Bs(o,yt(o))}function hl(o,l,f){var m=o==null?t:cr(o,l);return m===t?f:m}function vw(o,l){return o!=null&&sd(o,l,H_)}function pl(o,l){return o!=null&&sd(o,l,U_)}var Sw=Qf(function(o,l,f){l!=null&&typeof l.toString!="function"&&(l=xs.call(l)),o[l]=f},gl(_t)),ww=Qf(function(o,l,f){l!=null&&typeof l.toString!="function"&&(l=xs.call(l)),be.call(o,l)?o[l].push(f):o[l]=[f]},X),kw=ue(Ci);function He(o){return gt(o)?mf(o):$a(o)}function yt(o){return gt(o)?mf(o,!0):eb(o)}function xw(o,l){var f={};return l=X(l,3),nn(o,function(m,b,S){gn(f,l(m,b,S),m)}),f}function Ew(o,l){var f={};return l=X(l,3),nn(o,function(m,b,S){gn(f,b,l(m,b,S))}),f}var Ow=Hr(function(o,l,f){Fs(o,l,f)}),zd=Hr(function(o,l,f,m){Fs(o,l,f,m)}),Tw=_n(function(o,l){var f={};if(o==null)return f;var m=!1;l=Te(l,function(S){return S=Fn(S,o),m||(m=S.length>1),S}),rn(o,Za(o),f),m&&(f=Dt(f,p|y|g,Sb));for(var b=l.length;b--;)Ka(f,l[b]);return f});function Aw(o,l){return Wd(o,Zs(X(l)))}var Cw=_n(function(o,l){return o==null?{}:nb(o,l)});function Wd(o,l){if(o==null)return{};var f=Te(Za(o),function(m){return[m]});return l=X(l),If(o,f,function(m,b){return l(m,b[0])})}function Mw(o,l,f){l=Fn(l,o);var m=-1,b=l.length;for(b||(b=1,o=t);++m<b;){var S=o==null?t:o[sn(l[m])];S===t&&(m=b,S=f),o=vn(S)?S.call(o):S}return o}function Nw(o,l,f){return o==null?o:Ni(o,l,f)}function Iw(o,l,f,m){return m=typeof m=="function"?m:t,o==null?o:Ni(o,l,f,m)}var Vd=ed(He),Hd=ed(yt);function Pw(o,l,f){var m=se(o),b=m||zn(o)||jr(o);if(l=X(l,4),f==null){var S=o&&o.constructor;b?f=m?new S:[]:Ae(o)?f=vn(S)?Vr(Ts(o)):{}:f={}}return(b?It:nn)(o,function(x,E,T){return l(f,x,E,T)}),f}function Rw(o,l){return o==null?!0:Ka(o,l)}function Dw(o,l,f){return o==null?o:Bf(o,l,Ja(f))}function Lw(o,l,f,m){return m=typeof m=="function"?m:t,o==null?o:Bf(o,l,Ja(f),m)}function qr(o){return o==null?[]:Oa(o,He(o))}function Bw(o){return o==null?[]:Oa(o,yt(o))}function Fw(o,l,f){return f===t&&(f=l,l=t),f!==t&&(f=Ft(f),f=f===f?f:0),l!==t&&(l=Ft(l),l=l===l?l:0),lr(Ft(o),l,f)}function $w(o,l,f){return l=Sn(l),f===t?(f=l,l=0):f=Sn(f),o=Ft(o),K_(o,l,f)}function zw(o,l,f){if(f&&typeof f!="boolean"&&lt(o,l,f)&&(l=f=t),f===t&&(typeof l=="boolean"?(f=l,l=t):typeof o=="boolean"&&(f=o,o=t)),o===t&&l===t?(o=0,l=1):(o=Sn(o),l===t?(l=o,o=0):l=Sn(l)),o>l){var m=o;o=l,l=m}if(f||o%1||l%1){var b=hf();return et(o+b*(l-o+_0("1e-"+((b+"").length-1))),l)}return Va(o,l)}var Ww=Ur(function(o,l,f){return l=l.toLowerCase(),o+(f?Ud(l):l)});function Ud(o){return ml(_e(o).toLowerCase())}function Kd(o){return o=_e(o),o&&o.replace(Hy,N0).replace(l0,"")}function Vw(o,l,f){o=_e(o),l=xt(l);var m=o.length;f=f===t?m:lr(oe(f),0,m);var b=f;return f-=l.length,f>=0&&o.slice(f,b)==l}function Hw(o){return o=_e(o),o&&ky.test(o)?o.replace(Su,I0):o}function Uw(o){return o=_e(o),o&&Cy.test(o)?o.replace(ua,"\\$&"):o}var Kw=Ur(function(o,l,f){return o+(f?"-":"")+l.toLowerCase()}),jw=Ur(function(o,l,f){return o+(f?" ":"")+l.toLowerCase()}),qw=Jf("toLowerCase");function Jw(o,l,f){o=_e(o),l=oe(l);var m=l?Br(o):0;if(!l||m>=l)return o;var b=(l-m)/2;return Us(Ns(b),f)+o+Us(Ms(b),f)}function Gw(o,l,f){o=_e(o),l=oe(l);var m=l?Br(o):0;return l&&m<l?o+Us(l-m,f):o}function Yw(o,l,f){o=_e(o),l=oe(l);var m=l?Br(o):0;return l&&m<l?Us(l-m,f)+o:o}function Qw(o,l,f){return f||l==null?l=0:l&&(l=+l),i_(_e(o).replace(fa,""),l||0)}function Xw(o,l,f){return(f?lt(o,l,f):l===t)?l=1:l=oe(l),Ha(_e(o),l)}function Zw(){var o=arguments,l=_e(o[0]);return o.length<3?l:l.replace(o[1],o[2])}var ek=Ur(function(o,l,f){return o+(f?"_":"")+l.toLowerCase()});function tk(o,l,f){return f&&typeof f!="number"&&lt(o,l,f)&&(l=f=t),f=f===t?te:f>>>0,f?(o=_e(o),o&&(typeof l=="string"||l!=null&&!dl(l))&&(l=xt(l),!l&&Lr(o))?$n(Gt(o),0,f):o.split(l,f)):[]}var nk=Ur(function(o,l,f){return o+(f?" ":"")+ml(l)});function rk(o,l,f){return o=_e(o),f=f==null?0:lr(oe(f),0,o.length),l=xt(l),o.slice(f,f+l.length)==l}function ik(o,l,f){var m=v.templateSettings;f&&lt(o,l,f)&&(l=t),o=_e(o),l=no({},l,m,td);var b=no({},l.imports,m.imports,td),S=He(b),x=Oa(b,S),E,T,N=0,I=l.interpolate||ms,R="__p += '",W=Aa((l.escape||ms).source+"|"+I.source+"|"+(I===wu?By:ms).source+"|"+(l.evaluate||ms).source+"|$","g"),G="//# sourceURL="+(be.call(l,"sourceURL")?(l.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++h0+"]")+`
112
+ `)}function Mb(o){return se(o)||dr(o)||!!(ff&&o&&o[ff])}function bn(o,l){var f=typeof o;return l=l??dn,!!l&&(f=="number"||f!="symbol"&&Vy.test(o))&&o>-1&&o%1==0&&o<l}function lt(o,l,f){if(!Ae(f))return!1;var m=typeof l;return(m=="number"?gt(f)&&bn(l,f.length):m=="string"&&l in f)?Qt(f[l],o):!1}function rl(o,l){if(se(o))return!1;var f=typeof o;return f=="number"||f=="symbol"||f=="boolean"||o==null||Et(o)?!0:Ty.test(o)||!Oy.test(o)||l!=null&&o in Se(l)}function Nb(o){var l=typeof o;return l=="string"||l=="number"||l=="symbol"||l=="boolean"?o!=="__proto__":o===null}function il(o){var l=js(o),f=v[l];if(typeof f!="function"||!(l in he.prototype))return!1;if(o===f)return!0;var m=el(f);return!!m&&o===m[0]}function Ib(o){return!!af&&af in o}var Pb=ws?vn:Sl;function Pi(o){var l=o&&o.constructor,f=typeof l=="function"&&l.prototype||zr;return o===f}function ad(o){return o===o&&!Ae(o)}function ld(o,l){return function(f){return f==null?!1:f[o]===l&&(l!==t||o in Se(f))}}function Rb(o){var l=Xs(o,function(m){return f.size===d&&f.clear(),m}),f=l.cache;return l}function Db(o,l){var f=o[1],m=l[1],b=f|m,S=b<(k|A|J),x=m==J&&f==L||m==J&&f==K&&o[7].length<=l[8]||m==(J|K)&&l[7].length<=l[8]&&f==L;if(!(S||x))return o;m&k&&(o[2]=l[2],b|=f&k?0:P);var E=l[3];if(E){var T=o[3];o[3]=T?Uf(T,E,l[4]):E,o[4]=T?Rn(o[3],h):l[4]}return E=l[5],E&&(T=o[5],o[5]=T?Kf(T,E,l[6]):E,o[6]=T?Rn(o[5],h):l[6]),E=l[7],E&&(o[7]=E),m&J&&(o[8]=o[8]==null?l[8]:et(o[8],l[8])),o[9]==null&&(o[9]=l[9]),o[0]=l[0],o[1]=b,o}function Lb(o){var l=[];if(o!=null)for(var f in Se(o))l.push(f);return l}function Bb(o){return xs.call(o)}function cd(o,l,f){return l=Fe(l===t?o.length-1:l,0),function(){for(var m=arguments,b=-1,S=Fe(m.length-l,0),x=C(S);++b<S;)x[b]=m[l+b];b=-1;for(var E=C(l+1);++b<l;)E[b]=m[b];return E[l]=f(x),wt(o,this,E)}}function ud(o,l){return l.length<2?o:cr(o,Lt(l,0,-1))}function Fb(o,l){for(var f=o.length,m=et(l.length,f),b=mt(o);m--;){var S=l[m];o[m]=bn(S,f)?b[S]:t}return o}function sl(o,l){if(!(l==="constructor"&&typeof o[l]=="function")&&l!="__proto__")return o[l]}var fd=hd(Rf),Ri=Z0||function(o,l){return Ge.setTimeout(o,l)},ol=hd(ab);function dd(o,l,f){var m=l+"";return ol(o,Cb(m,$b(Ob(m),f)))}function hd(o){var l=0,f=0;return function(){var m=r_(),b=pt-(m-f);if(f=m,b>0){if(++l>=De)return arguments[0]}else l=0;return o.apply(t,arguments)}}function Js(o,l){var f=-1,m=o.length,b=m-1;for(l=l===t?m:l;++f<l;){var S=Va(f,b),x=o[S];o[S]=o[f],o[f]=x}return o.length=l,o}var pd=Rb(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(Ay,function(f,m,b,S){l.push(b?S.replace(Ly,"$1"):m||f)}),l});function sn(o){if(typeof o=="string"||Et(o))return o;var l=o+"";return l=="0"&&1/o==-1/0?"-0":l}function fr(o){if(o!=null){try{return ks.call(o)}catch{}try{return o+""}catch{}}return""}function $b(o,l){return It(tn,function(f){var m="_."+f[0];l&f[1]&&!_s(o,m)&&o.push(m)}),o.sort()}function md(o){if(o instanceof he)return o.clone();var l=new Rt(o.__wrapped__,o.__chain__);return l.__actions__=mt(o.__actions__),l.__index__=o.__index__,l.__values__=o.__values__,l}function zb(o,l,f){(f?lt(o,l,f):l===t)?l=1:l=Fe(oe(l),0);var m=o==null?0:o.length;if(!m||l<1)return[];for(var b=0,S=0,x=C(Ms(m/l));b<m;)x[S++]=Lt(o,b,b+=l);return x}function Wb(o){for(var l=-1,f=o==null?0:o.length,m=0,b=[];++l<f;){var S=o[l];S&&(b[m++]=S)}return b}function Vb(){var o=arguments.length;if(!o)return[];for(var l=C(o-1),f=arguments[0],m=o;m--;)l[m-1]=arguments[m];return Pn(se(f)?mt(f):[f],Ye(l,1))}var Hb=ue(function(o,l){return Pe(o)?Ai(o,Ye(l,1,Pe,!0)):[]}),Ub=ue(function(o,l){var f=Bt(l);return Pe(f)&&(f=t),Pe(o)?Ai(o,Ye(l,1,Pe,!0),X(f,2)):[]}),Kb=ue(function(o,l){var f=Bt(l);return Pe(f)&&(f=t),Pe(o)?Ai(o,Ye(l,1,Pe,!0),t,f):[]});function jb(o,l,f){var m=o==null?0:o.length;return m?(l=f||l===t?1:oe(l),Lt(o,l<0?0:l,m)):[]}function qb(o,l,f){var m=o==null?0:o.length;return m?(l=f||l===t?1:oe(l),l=m-l,Lt(o,0,l<0?0:l)):[]}function Jb(o,l){return o&&o.length?zs(o,X(l,3),!0,!0):[]}function Gb(o,l){return o&&o.length?zs(o,X(l,3),!0):[]}function Yb(o,l,f,m){var b=o==null?0:o.length;return b?(f&&typeof f!="number"&&lt(o,l,f)&&(f=0,m=b),V_(o,l,f,m)):[]}function gd(o,l,f){var m=o==null?0:o.length;if(!m)return-1;var b=f==null?0:oe(f);return b<0&&(b=Fe(m+b,0)),bs(o,X(l,3),b)}function yd(o,l,f){var m=o==null?0:o.length;if(!m)return-1;var b=m-1;return f!==t&&(b=oe(f),b=f<0?Fe(m+b,0):et(b,m-1)),bs(o,X(l,3),b,!0)}function _d(o){var l=o==null?0:o.length;return l?Ye(o,1):[]}function Qb(o){var l=o==null?0:o.length;return l?Ye(o,jt):[]}function Xb(o,l){var f=o==null?0:o.length;return f?(l=l===t?1:oe(l),Ye(o,l)):[]}function Zb(o){for(var l=-1,f=o==null?0:o.length,m={};++l<f;){var b=o[l];m[b[0]]=b[1]}return m}function bd(o){return o&&o.length?o[0]:t}function ev(o,l,f){var m=o==null?0:o.length;if(!m)return-1;var b=f==null?0:oe(f);return b<0&&(b=Fe(m+b,0)),Lr(o,l,b)}function tv(o){var l=o==null?0:o.length;return l?Lt(o,0,-1):[]}var nv=ue(function(o){var l=Te(o,qa);return l.length&&l[0]===o[0]?Ba(l):[]}),rv=ue(function(o){var l=Bt(o),f=Te(o,qa);return l===Bt(f)?l=t:f.pop(),f.length&&f[0]===o[0]?Ba(f,X(l,2)):[]}),iv=ue(function(o){var l=Bt(o),f=Te(o,qa);return l=typeof l=="function"?l:t,l&&f.pop(),f.length&&f[0]===o[0]?Ba(f,t,l):[]});function sv(o,l){return o==null?"":t_.call(o,l)}function Bt(o){var l=o==null?0:o.length;return l?o[l-1]:t}function ov(o,l,f){var m=o==null?0:o.length;if(!m)return-1;var b=m;return f!==t&&(b=oe(f),b=b<0?Fe(m+b,0):et(b,m-1)),l===l?$0(o,l,b):bs(o,Xu,b,!0)}function av(o,l){return o&&o.length?Mf(o,oe(l)):t}var lv=ue(vd);function vd(o,l){return o&&o.length&&l&&l.length?Wa(o,l):o}function cv(o,l,f){return o&&o.length&&l&&l.length?Wa(o,l,X(f,2)):o}function uv(o,l,f){return o&&o.length&&l&&l.length?Wa(o,l,t,f):o}var fv=_n(function(o,l){var f=o==null?0:o.length,m=Pa(o,l);return Pf(o,Te(l,function(b){return bn(b,f)?+b:b}).sort(Hf)),m});function dv(o,l){var f=[];if(!(o&&o.length))return f;var m=-1,b=[],S=o.length;for(l=X(l,3);++m<S;){var x=o[m];l(x,m,o)&&(f.push(x),b.push(m))}return Pf(o,b),f}function al(o){return o==null?o:s_.call(o)}function hv(o,l,f){var m=o==null?0:o.length;return m?(f&&typeof f!="number"&&lt(o,l,f)?(l=0,f=m):(l=l==null?0:oe(l),f=f===t?m:oe(f)),Lt(o,l,f)):[]}function pv(o,l){return $s(o,l)}function mv(o,l,f){return Ua(o,l,X(f,2))}function gv(o,l){var f=o==null?0:o.length;if(f){var m=$s(o,l);if(m<f&&Qt(o[m],l))return m}return-1}function yv(o,l){return $s(o,l,!0)}function _v(o,l,f){return Ua(o,l,X(f,2),!0)}function bv(o,l){var f=o==null?0:o.length;if(f){var m=$s(o,l,!0)-1;if(Qt(o[m],l))return m}return-1}function vv(o){return o&&o.length?Df(o):[]}function Sv(o,l){return o&&o.length?Df(o,X(l,2)):[]}function wv(o){var l=o==null?0:o.length;return l?Lt(o,1,l):[]}function kv(o,l,f){return o&&o.length?(l=f||l===t?1:oe(l),Lt(o,0,l<0?0:l)):[]}function xv(o,l,f){var m=o==null?0:o.length;return m?(l=f||l===t?1:oe(l),l=m-l,Lt(o,l<0?0:l,m)):[]}function Ev(o,l){return o&&o.length?zs(o,X(l,3),!1,!0):[]}function Ov(o,l){return o&&o.length?zs(o,X(l,3)):[]}var Tv=ue(function(o){return Bn(Ye(o,1,Pe,!0))}),Av=ue(function(o){var l=Bt(o);return Pe(l)&&(l=t),Bn(Ye(o,1,Pe,!0),X(l,2))}),Cv=ue(function(o){var l=Bt(o);return l=typeof l=="function"?l:t,Bn(Ye(o,1,Pe,!0),t,l)});function Mv(o){return o&&o.length?Bn(o):[]}function Nv(o,l){return o&&o.length?Bn(o,X(l,2)):[]}function Iv(o,l){return l=typeof l=="function"?l:t,o&&o.length?Bn(o,t,l):[]}function ll(o){if(!(o&&o.length))return[];var l=0;return o=In(o,function(f){if(Pe(f))return l=Fe(f.length,l),!0}),Ea(l,function(f){return Te(o,wa(f))})}function Sd(o,l){if(!(o&&o.length))return[];var f=ll(o);return l==null?f:Te(f,function(m){return wt(l,t,m)})}var Pv=ue(function(o,l){return Pe(o)?Ai(o,l):[]}),Rv=ue(function(o){return ja(In(o,Pe))}),Dv=ue(function(o){var l=Bt(o);return Pe(l)&&(l=t),ja(In(o,Pe),X(l,2))}),Lv=ue(function(o){var l=Bt(o);return l=typeof l=="function"?l:t,ja(In(o,Pe),t,l)}),Bv=ue(ll);function Fv(o,l){return $f(o||[],l||[],Ti)}function $v(o,l){return $f(o||[],l||[],Ni)}var zv=ue(function(o){var l=o.length,f=l>1?o[l-1]:t;return f=typeof f=="function"?(o.pop(),f):t,Sd(o,f)});function wd(o){var l=v(o);return l.__chain__=!0,l}function Wv(o,l){return l(o),o}function Gs(o,l){return l(o)}var Vv=_n(function(o){var l=o.length,f=l?o[0]:0,m=this.__wrapped__,b=function(S){return Pa(S,o)};return l>1||this.__actions__.length||!(m instanceof he)||!bn(f)?this.thru(b):(m=m.slice(f,+f+(l?1:0)),m.__actions__.push({func:Gs,args:[b],thisArg:t}),new Rt(m,this.__chain__).thru(function(S){return l&&!S.length&&S.push(t),S}))});function Hv(){return wd(this)}function Uv(){return new Rt(this.value(),this.__chain__)}function Kv(){this.__values__===t&&(this.__values__=Ld(this.value()));var o=this.__index__>=this.__values__.length,l=o?t:this.__values__[this.__index__++];return{done:o,value:l}}function jv(){return this}function qv(o){for(var l,f=this;f instanceof Rs;){var m=md(f);m.__index__=0,m.__values__=t,l?b.__wrapped__=m:l=m;var b=m;f=f.__wrapped__}return b.__wrapped__=o,l}function Jv(){var o=this.__wrapped__;if(o instanceof he){var l=o;return this.__actions__.length&&(l=new he(this)),l=l.reverse(),l.__actions__.push({func:Gs,args:[al],thisArg:t}),new Rt(l,this.__chain__)}return this.thru(al)}function Gv(){return Ff(this.__wrapped__,this.__actions__)}var Yv=Ws(function(o,l,f){be.call(o,f)?++o[f]:gn(o,f,1)});function Qv(o,l,f){var m=se(o)?Yu:W_;return f&&lt(o,l,f)&&(l=t),m(o,X(l,3))}function Xv(o,l){var f=se(o)?In:Sf;return f(o,X(l,3))}var Zv=Gf(gd),eS=Gf(yd);function tS(o,l){return Ye(Ys(o,l),1)}function nS(o,l){return Ye(Ys(o,l),jt)}function rS(o,l,f){return f=f===t?1:oe(f),Ye(Ys(o,l),f)}function kd(o,l){var f=se(o)?It:Ln;return f(o,X(l,3))}function xd(o,l){var f=se(o)?w0:vf;return f(o,X(l,3))}var iS=Ws(function(o,l,f){be.call(o,f)?o[f].push(l):gn(o,f,[l])});function sS(o,l,f,m){o=gt(o)?o:Jr(o),f=f&&!m?oe(f):0;var b=o.length;return f<0&&(f=Fe(b+f,0)),to(o)?f<=b&&o.indexOf(l,f)>-1:!!b&&Lr(o,l,f)>-1}var oS=ue(function(o,l,f){var m=-1,b=typeof l=="function",S=gt(o)?C(o.length):[];return Ln(o,function(x){S[++m]=b?wt(l,x,f):Ci(x,l,f)}),S}),aS=Ws(function(o,l,f){gn(o,f,l)});function Ys(o,l){var f=se(o)?Te:Tf;return f(o,X(l,3))}function lS(o,l,f,m){return o==null?[]:(se(l)||(l=l==null?[]:[l]),f=m?t:f,se(f)||(f=f==null?[]:[f]),Nf(o,l,f))}var cS=Ws(function(o,l,f){o[f?0:1].push(l)},function(){return[[],[]]});function uS(o,l,f){var m=se(o)?va:ef,b=arguments.length<3;return m(o,X(l,4),f,b,Ln)}function fS(o,l,f){var m=se(o)?k0:ef,b=arguments.length<3;return m(o,X(l,4),f,b,vf)}function dS(o,l){var f=se(o)?In:Sf;return f(o,Zs(X(l,3)))}function hS(o){var l=se(o)?gf:sb;return l(o)}function pS(o,l,f){(f?lt(o,l,f):l===t)?l=1:l=oe(l);var m=se(o)?L_:ob;return m(o,l)}function mS(o){var l=se(o)?B_:lb;return l(o)}function gS(o){if(o==null)return 0;if(gt(o))return to(o)?Fr(o):o.length;var l=tt(o);return l==qt||l==Jt?o.size:$a(o).length}function yS(o,l,f){var m=se(o)?Sa:cb;return f&&lt(o,l,f)&&(l=t),m(o,X(l,3))}var _S=ue(function(o,l){if(o==null)return[];var f=l.length;return f>1&&lt(o,l[0],l[1])?l=[]:f>2&&lt(l[0],l[1],l[2])&&(l=[l[0]]),Nf(o,Ye(l,1),[])}),Qs=X0||function(){return Ge.Date.now()};function bS(o,l){if(typeof l!="function")throw new Pt(a);return o=oe(o),function(){if(--o<1)return l.apply(this,arguments)}}function Ed(o,l,f){return l=f?t:l,l=o&&l==null?o.length:l,yn(o,J,t,t,t,t,l)}function Od(o,l){var f;if(typeof l!="function")throw new Pt(a);return o=oe(o),function(){return--o>0&&(f=l.apply(this,arguments)),o<=1&&(l=t),f}}var cl=ue(function(o,l,f){var m=k;if(f.length){var b=Rn(f,jr(cl));m|=z}return yn(o,m,l,f,b)}),Td=ue(function(o,l,f){var m=k|A;if(f.length){var b=Rn(f,jr(Td));m|=z}return yn(l,m,o,f,b)});function Ad(o,l,f){l=f?t:l;var m=yn(o,L,t,t,t,t,t,l);return m.placeholder=Ad.placeholder,m}function Cd(o,l,f){l=f?t:l;var m=yn(o,B,t,t,t,t,t,l);return m.placeholder=Cd.placeholder,m}function Md(o,l,f){var m,b,S,x,E,T,N=0,I=!1,R=!1,W=!0;if(typeof o!="function")throw new Pt(a);l=Ft(l)||0,Ae(f)&&(I=!!f.leading,R="maxWait"in f,S=R?Fe(Ft(f.maxWait)||0,l):S,W="trailing"in f?!!f.trailing:W);function G(Re){var Xt=m,wn=b;return m=b=t,N=Re,x=o.apply(wn,Xt),x}function Z(Re){return N=Re,E=Ri(de,l),I?G(Re):x}function le(Re){var Xt=Re-T,wn=Re-N,Gd=l-Xt;return R?et(Gd,S-wn):Gd}function ee(Re){var Xt=Re-T,wn=Re-N;return T===t||Xt>=l||Xt<0||R&&wn>=S}function de(){var Re=Qs();if(ee(Re))return pe(Re);E=Ri(de,le(Re))}function pe(Re){return E=t,W&&m?G(Re):(m=b=t,x)}function Ot(){E!==t&&zf(E),N=0,m=T=b=E=t}function ct(){return E===t?x:pe(Qs())}function Tt(){var Re=Qs(),Xt=ee(Re);if(m=arguments,b=this,T=Re,Xt){if(E===t)return Z(T);if(R)return zf(E),E=Ri(de,l),G(T)}return E===t&&(E=Ri(de,l)),x}return Tt.cancel=Ot,Tt.flush=ct,Tt}var vS=ue(function(o,l){return bf(o,1,l)}),SS=ue(function(o,l,f){return bf(o,Ft(l)||0,f)});function wS(o){return yn(o,V)}function Xs(o,l){if(typeof o!="function"||l!=null&&typeof l!="function")throw new Pt(a);var f=function(){var m=arguments,b=l?l.apply(this,m):m[0],S=f.cache;if(S.has(b))return S.get(b);var x=o.apply(this,m);return f.cache=S.set(b,x)||S,x};return f.cache=new(Xs.Cache||mn),f}Xs.Cache=mn;function Zs(o){if(typeof o!="function")throw new Pt(a);return function(){var l=arguments;switch(l.length){case 0:return!o.call(this);case 1:return!o.call(this,l[0]);case 2:return!o.call(this,l[0],l[1]);case 3:return!o.call(this,l[0],l[1],l[2])}return!o.apply(this,l)}}function kS(o){return Od(2,o)}var xS=ub(function(o,l){l=l.length==1&&se(l[0])?Te(l[0],kt(X())):Te(Ye(l,1),kt(X()));var f=l.length;return ue(function(m){for(var b=-1,S=et(m.length,f);++b<S;)m[b]=l[b].call(this,m[b]);return wt(o,this,m)})}),ul=ue(function(o,l){var f=Rn(l,jr(ul));return yn(o,z,t,l,f)}),Nd=ue(function(o,l){var f=Rn(l,jr(Nd));return yn(o,$,t,l,f)}),ES=_n(function(o,l){return yn(o,K,t,t,t,l)});function OS(o,l){if(typeof o!="function")throw new Pt(a);return l=l===t?l:oe(l),ue(o,l)}function TS(o,l){if(typeof o!="function")throw new Pt(a);return l=l==null?0:Fe(oe(l),0),ue(function(f){var m=f[l],b=$n(f,0,l);return m&&Pn(b,m),wt(o,this,b)})}function AS(o,l,f){var m=!0,b=!0;if(typeof o!="function")throw new Pt(a);return Ae(f)&&(m="leading"in f?!!f.leading:m,b="trailing"in f?!!f.trailing:b),Md(o,l,{leading:m,maxWait:l,trailing:b})}function CS(o){return Ed(o,1)}function MS(o,l){return ul(Ja(l),o)}function NS(){if(!arguments.length)return[];var o=arguments[0];return se(o)?o:[o]}function IS(o){return Dt(o,g)}function PS(o,l){return l=typeof l=="function"?l:t,Dt(o,g,l)}function RS(o){return Dt(o,p|g)}function DS(o,l){return l=typeof l=="function"?l:t,Dt(o,p|g,l)}function LS(o,l){return l==null||_f(o,l,He(l))}function Qt(o,l){return o===l||o!==o&&l!==l}var BS=Ks(La),FS=Ks(function(o,l){return o>=l}),dr=xf(function(){return arguments}())?xf:function(o){return Ne(o)&&be.call(o,"callee")&&!uf.call(o,"callee")},se=C.isArray,$S=Uu?kt(Uu):q_;function gt(o){return o!=null&&eo(o.length)&&!vn(o)}function Pe(o){return Ne(o)&&gt(o)}function zS(o){return o===!0||o===!1||Ne(o)&&at(o)==Me}var zn=e_||Sl,WS=Ku?kt(Ku):J_;function VS(o){return Ne(o)&&o.nodeType===1&&!Di(o)}function HS(o){if(o==null)return!0;if(gt(o)&&(se(o)||typeof o=="string"||typeof o.splice=="function"||zn(o)||qr(o)||dr(o)))return!o.length;var l=tt(o);if(l==qt||l==Jt)return!o.size;if(Pi(o))return!$a(o).length;for(var f in o)if(be.call(o,f))return!1;return!0}function US(o,l){return Mi(o,l)}function KS(o,l,f){f=typeof f=="function"?f:t;var m=f?f(o,l):t;return m===t?Mi(o,l,t,f):!!m}function fl(o){if(!Ne(o))return!1;var l=at(o);return l==Pr||l==mi||typeof o.message=="string"&&typeof o.name=="string"&&!Di(o)}function jS(o){return typeof o=="number"&&df(o)}function vn(o){if(!Ae(o))return!1;var l=at(o);return l==hs||l==_u||l==pi||l==gy}function Id(o){return typeof o=="number"&&o==oe(o)}function eo(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=dn}function Ae(o){var l=typeof o;return o!=null&&(l=="object"||l=="function")}function Ne(o){return o!=null&&typeof o=="object"}var Pd=ju?kt(ju):Y_;function qS(o,l){return o===l||Fa(o,l,tl(l))}function JS(o,l,f){return f=typeof f=="function"?f:t,Fa(o,l,tl(l),f)}function GS(o){return Rd(o)&&o!=+o}function YS(o){if(Pb(o))throw new ie(s);return Ef(o)}function QS(o){return o===null}function XS(o){return o==null}function Rd(o){return typeof o=="number"||Ne(o)&&at(o)==gi}function Di(o){if(!Ne(o)||at(o)!=hn)return!1;var l=Ts(o);if(l===null)return!0;var f=be.call(l,"constructor")&&l.constructor;return typeof f=="function"&&f instanceof f&&ks.call(f)==J0}var dl=qu?kt(qu):Q_;function ZS(o){return Id(o)&&o>=-9007199254740991&&o<=dn}var Dd=Ju?kt(Ju):X_;function to(o){return typeof o=="string"||!se(o)&&Ne(o)&&at(o)==_i}function Et(o){return typeof o=="symbol"||Ne(o)&&at(o)==ps}var qr=Gu?kt(Gu):Z_;function ew(o){return o===t}function tw(o){return Ne(o)&&tt(o)==bi}function nw(o){return Ne(o)&&at(o)==_y}var rw=Ks(za),iw=Ks(function(o,l){return o<=l});function Ld(o){if(!o)return[];if(gt(o))return to(o)?Gt(o):mt(o);if(wi&&o[wi])return L0(o[wi]());var l=tt(o),f=l==qt?Ta:l==Jt?vs:Jr;return f(o)}function Sn(o){if(!o)return o===0?o:0;if(o=Ft(o),o===jt||o===-1/0){var l=o<0?-1:1;return l*ds}return o===o?o:0}function oe(o){var l=Sn(o),f=l%1;return l===l?f?l-f:l:0}function Bd(o){return o?lr(oe(o),0,te):0}function Ft(o){if(typeof o=="number")return o;if(Et(o))return F;if(Ae(o)){var l=typeof o.valueOf=="function"?o.valueOf():o;o=Ae(l)?l+"":l}if(typeof o!="string")return o===0?o:+o;o=tf(o);var f=$y.test(o);return f||Wy.test(o)?b0(o.slice(2),f?2:8):Fy.test(o)?F:+o}function Fd(o){return rn(o,yt(o))}function sw(o){return o?lr(oe(o),-9007199254740991,dn):o===0?o:0}function _e(o){return o==null?"":xt(o)}var ow=Ur(function(o,l){if(Pi(l)||gt(l)){rn(l,He(l),o);return}for(var f in l)be.call(l,f)&&Ti(o,f,l[f])}),$d=Ur(function(o,l){rn(l,yt(l),o)}),no=Ur(function(o,l,f,m){rn(l,yt(l),o,m)}),aw=Ur(function(o,l,f,m){rn(l,He(l),o,m)}),lw=_n(Pa);function cw(o,l){var f=Hr(o);return l==null?f:yf(f,l)}var uw=ue(function(o,l){o=Se(o);var f=-1,m=l.length,b=m>2?l[2]:t;for(b&&lt(l[0],l[1],b)&&(m=1);++f<m;)for(var S=l[f],x=yt(S),E=-1,T=x.length;++E<T;){var N=x[E],I=o[N];(I===t||Qt(I,zr[N])&&!be.call(o,N))&&(o[N]=S[N])}return o}),fw=ue(function(o){return o.push(t,nd),wt(zd,t,o)});function dw(o,l){return Qu(o,X(l,3),nn)}function hw(o,l){return Qu(o,X(l,3),Da)}function pw(o,l){return o==null?o:Ra(o,X(l,3),yt)}function mw(o,l){return o==null?o:wf(o,X(l,3),yt)}function gw(o,l){return o&&nn(o,X(l,3))}function yw(o,l){return o&&Da(o,X(l,3))}function _w(o){return o==null?[]:Bs(o,He(o))}function bw(o){return o==null?[]:Bs(o,yt(o))}function hl(o,l,f){var m=o==null?t:cr(o,l);return m===t?f:m}function vw(o,l){return o!=null&&sd(o,l,H_)}function pl(o,l){return o!=null&&sd(o,l,U_)}var Sw=Qf(function(o,l,f){l!=null&&typeof l.toString!="function"&&(l=xs.call(l)),o[l]=f},gl(_t)),ww=Qf(function(o,l,f){l!=null&&typeof l.toString!="function"&&(l=xs.call(l)),be.call(o,l)?o[l].push(f):o[l]=[f]},X),kw=ue(Ci);function He(o){return gt(o)?mf(o):$a(o)}function yt(o){return gt(o)?mf(o,!0):eb(o)}function xw(o,l){var f={};return l=X(l,3),nn(o,function(m,b,S){gn(f,l(m,b,S),m)}),f}function Ew(o,l){var f={};return l=X(l,3),nn(o,function(m,b,S){gn(f,b,l(m,b,S))}),f}var Ow=Ur(function(o,l,f){Fs(o,l,f)}),zd=Ur(function(o,l,f,m){Fs(o,l,f,m)}),Tw=_n(function(o,l){var f={};if(o==null)return f;var m=!1;l=Te(l,function(S){return S=Fn(S,o),m||(m=S.length>1),S}),rn(o,Za(o),f),m&&(f=Dt(f,p|y|g,Sb));for(var b=l.length;b--;)Ka(f,l[b]);return f});function Aw(o,l){return Wd(o,Zs(X(l)))}var Cw=_n(function(o,l){return o==null?{}:nb(o,l)});function Wd(o,l){if(o==null)return{};var f=Te(Za(o),function(m){return[m]});return l=X(l),If(o,f,function(m,b){return l(m,b[0])})}function Mw(o,l,f){l=Fn(l,o);var m=-1,b=l.length;for(b||(b=1,o=t);++m<b;){var S=o==null?t:o[sn(l[m])];S===t&&(m=b,S=f),o=vn(S)?S.call(o):S}return o}function Nw(o,l,f){return o==null?o:Ni(o,l,f)}function Iw(o,l,f,m){return m=typeof m=="function"?m:t,o==null?o:Ni(o,l,f,m)}var Vd=ed(He),Hd=ed(yt);function Pw(o,l,f){var m=se(o),b=m||zn(o)||qr(o);if(l=X(l,4),f==null){var S=o&&o.constructor;b?f=m?new S:[]:Ae(o)?f=vn(S)?Hr(Ts(o)):{}:f={}}return(b?It:nn)(o,function(x,E,T){return l(f,x,E,T)}),f}function Rw(o,l){return o==null?!0:Ka(o,l)}function Dw(o,l,f){return o==null?o:Bf(o,l,Ja(f))}function Lw(o,l,f,m){return m=typeof m=="function"?m:t,o==null?o:Bf(o,l,Ja(f),m)}function Jr(o){return o==null?[]:Oa(o,He(o))}function Bw(o){return o==null?[]:Oa(o,yt(o))}function Fw(o,l,f){return f===t&&(f=l,l=t),f!==t&&(f=Ft(f),f=f===f?f:0),l!==t&&(l=Ft(l),l=l===l?l:0),lr(Ft(o),l,f)}function $w(o,l,f){return l=Sn(l),f===t?(f=l,l=0):f=Sn(f),o=Ft(o),K_(o,l,f)}function zw(o,l,f){if(f&&typeof f!="boolean"&&lt(o,l,f)&&(l=f=t),f===t&&(typeof l=="boolean"?(f=l,l=t):typeof o=="boolean"&&(f=o,o=t)),o===t&&l===t?(o=0,l=1):(o=Sn(o),l===t?(l=o,o=0):l=Sn(l)),o>l){var m=o;o=l,l=m}if(f||o%1||l%1){var b=hf();return et(o+b*(l-o+_0("1e-"+((b+"").length-1))),l)}return Va(o,l)}var Ww=Kr(function(o,l,f){return l=l.toLowerCase(),o+(f?Ud(l):l)});function Ud(o){return ml(_e(o).toLowerCase())}function Kd(o){return o=_e(o),o&&o.replace(Hy,N0).replace(l0,"")}function Vw(o,l,f){o=_e(o),l=xt(l);var m=o.length;f=f===t?m:lr(oe(f),0,m);var b=f;return f-=l.length,f>=0&&o.slice(f,b)==l}function Hw(o){return o=_e(o),o&&ky.test(o)?o.replace(Su,I0):o}function Uw(o){return o=_e(o),o&&Cy.test(o)?o.replace(ua,"\\$&"):o}var Kw=Kr(function(o,l,f){return o+(f?"-":"")+l.toLowerCase()}),jw=Kr(function(o,l,f){return o+(f?" ":"")+l.toLowerCase()}),qw=Jf("toLowerCase");function Jw(o,l,f){o=_e(o),l=oe(l);var m=l?Fr(o):0;if(!l||m>=l)return o;var b=(l-m)/2;return Us(Ns(b),f)+o+Us(Ms(b),f)}function Gw(o,l,f){o=_e(o),l=oe(l);var m=l?Fr(o):0;return l&&m<l?o+Us(l-m,f):o}function Yw(o,l,f){o=_e(o),l=oe(l);var m=l?Fr(o):0;return l&&m<l?Us(l-m,f)+o:o}function Qw(o,l,f){return f||l==null?l=0:l&&(l=+l),i_(_e(o).replace(fa,""),l||0)}function Xw(o,l,f){return(f?lt(o,l,f):l===t)?l=1:l=oe(l),Ha(_e(o),l)}function Zw(){var o=arguments,l=_e(o[0]);return o.length<3?l:l.replace(o[1],o[2])}var ek=Kr(function(o,l,f){return o+(f?"_":"")+l.toLowerCase()});function tk(o,l,f){return f&&typeof f!="number"&&lt(o,l,f)&&(l=f=t),f=f===t?te:f>>>0,f?(o=_e(o),o&&(typeof l=="string"||l!=null&&!dl(l))&&(l=xt(l),!l&&Br(o))?$n(Gt(o),0,f):o.split(l,f)):[]}var nk=Kr(function(o,l,f){return o+(f?" ":"")+ml(l)});function rk(o,l,f){return o=_e(o),f=f==null?0:lr(oe(f),0,o.length),l=xt(l),o.slice(f,f+l.length)==l}function ik(o,l,f){var m=v.templateSettings;f&&lt(o,l,f)&&(l=t),o=_e(o),l=no({},l,m,td);var b=no({},l.imports,m.imports,td),S=He(b),x=Oa(b,S),E,T,N=0,I=l.interpolate||ms,R="__p += '",W=Aa((l.escape||ms).source+"|"+I.source+"|"+(I===wu?By:ms).source+"|"+(l.evaluate||ms).source+"|$","g"),G="//# sourceURL="+(be.call(l,"sourceURL")?(l.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++h0+"]")+`
111
113
  `;o.replace(W,function(ee,de,pe,Ot,ct,Tt){return pe||(pe=Ot),R+=o.slice(N,Tt).replace(Uy,P0),de&&(E=!0,R+=`' +
112
114
  __e(`+de+`) +
113
115
  '`),ct&&(T=!0,R+=`';
@@ -124,7 +126,7 @@ __p += '`),pe&&(R+=`' +
124
126
  function print() { __p += __j.call(arguments, '') }
125
127
  `:`;
126
128
  `)+R+`return __p
127
- }`;var le=qd(function(){return ge(S,G+"return "+R).apply(t,x)});if(le.source=R,fl(le))throw le;return le}function sk(o){return _e(o).toLowerCase()}function ok(o){return _e(o).toUpperCase()}function ak(o,l,f){if(o=_e(o),o&&(f||l===t))return tf(o);if(!o||!(l=xt(l)))return o;var m=Gt(o),b=Gt(l),S=nf(m,b),x=rf(m,b)+1;return $n(m,S,x).join("")}function lk(o,l,f){if(o=_e(o),o&&(f||l===t))return o.slice(0,of(o)+1);if(!o||!(l=xt(l)))return o;var m=Gt(o),b=rf(m,Gt(l))+1;return $n(m,0,b).join("")}function ck(o,l,f){if(o=_e(o),o&&(f||l===t))return o.replace(fa,"");if(!o||!(l=xt(l)))return o;var m=Gt(o),b=nf(m,Gt(l));return $n(m,b).join("")}function uk(o,l){var f=ne,m=ve;if(Ae(l)){var b="separator"in l?l.separator:b;f="length"in l?oe(l.length):f,m="omission"in l?xt(l.omission):m}o=_e(o);var S=o.length;if(Lr(o)){var x=Gt(o);S=x.length}if(f>=S)return o;var E=f-Br(m);if(E<1)return m;var T=x?$n(x,0,E).join(""):o.slice(0,E);if(b===t)return T+m;if(x&&(E+=T.length-E),dl(b)){if(o.slice(E).search(b)){var N,I=T;for(b.global||(b=Aa(b.source,_e(ku.exec(b))+"g")),b.lastIndex=0;N=b.exec(I);)var R=N.index;T=T.slice(0,R===t?E:R)}}else if(o.indexOf(xt(b),E)!=E){var W=T.lastIndexOf(b);W>-1&&(T=T.slice(0,W))}return T+m}function fk(o){return o=_e(o),o&&wy.test(o)?o.replace(vu,z0):o}var dk=Ur(function(o,l,f){return o+(f?" ":"")+l.toUpperCase()}),ml=Jf("toUpperCase");function jd(o,l,f){return o=_e(o),l=f?t:l,l===t?D0(o)?H0(o):O0(o):o.match(l)||[]}var qd=ue(function(o,l){try{return wt(o,t,l)}catch(f){return fl(f)?f:new ie(f)}}),hk=_n(function(o,l){return It(l,function(f){f=sn(f),gn(o,f,cl(o[f],o))}),o});function pk(o){var l=o==null?0:o.length,f=X();return o=l?Te(o,function(m){if(typeof m[1]!="function")throw new Pt(a);return[f(m[0]),m[1]]}):[],ue(function(m){for(var b=-1;++b<l;){var S=o[b];if(wt(S[0],this,m))return wt(S[1],this,m)}})}function mk(o){return z_(Dt(o,p))}function gl(o){return function(){return o}}function gk(o,l){return o==null||o!==o?l:o}var yk=Yf(),_k=Yf(!0);function _t(o){return o}function yl(o){return Of(typeof o=="function"?o:Dt(o,p))}function bk(o){return Af(Dt(o,p))}function vk(o,l){return Cf(o,Dt(l,p))}var Sk=ue(function(o,l){return function(f){return Ci(f,o,l)}}),wk=ue(function(o,l){return function(f){return Ci(o,f,l)}});function _l(o,l,f){var m=He(l),b=Bs(l,m);f==null&&!(Ae(l)&&(b.length||!m.length))&&(f=l,l=o,o=this,b=Bs(l,He(l)));var S=!(Ae(f)&&"chain"in f)||!!f.chain,x=vn(o);return It(b,function(E){var T=l[E];o[E]=T,x&&(o.prototype[E]=function(){var N=this.__chain__;if(S||N){var I=o(this.__wrapped__),R=I.__actions__=mt(this.__actions__);return R.push({func:T,args:arguments,thisArg:o}),I.__chain__=N,I}return T.apply(o,Pn([this.value()],arguments))})}),o}function kk(){return Ge._===this&&(Ge._=G0),this}function bl(){}function xk(o){return o=oe(o),ue(function(l){return Mf(l,o)})}var Ek=Ya(Te),Ok=Ya(Yu),Tk=Ya(Sa);function Jd(o){return rl(o)?wa(sn(o)):rb(o)}function Ak(o){return function(l){return o==null?t:cr(o,l)}}var Ck=Xf(),Mk=Xf(!0);function vl(){return[]}function Sl(){return!1}function Nk(){return{}}function Ik(){return""}function Pk(){return!0}function Rk(o,l){if(o=oe(o),o<1||o>dn)return[];var f=te,m=et(o,te);l=X(l),o-=te;for(var b=Ea(m,l);++f<o;)l(f);return b}function Dk(o){return se(o)?Te(o,sn):Et(o)?[o]:mt(pd(_e(o)))}function Lk(o){var l=++q0;return _e(o)+l}var Bk=Hs(function(o,l){return o+l},0),Fk=Qa("ceil"),$k=Hs(function(o,l){return o/l},1),zk=Qa("floor");function Wk(o){return o&&o.length?Ls(o,_t,La):t}function Vk(o,l){return o&&o.length?Ls(o,X(l,2),La):t}function Hk(o){return Zu(o,_t)}function Uk(o,l){return Zu(o,X(l,2))}function Kk(o){return o&&o.length?Ls(o,_t,za):t}function jk(o,l){return o&&o.length?Ls(o,X(l,2),za):t}var qk=Hs(function(o,l){return o*l},1),Jk=Qa("round"),Gk=Hs(function(o,l){return o-l},0);function Yk(o){return o&&o.length?xa(o,_t):0}function Qk(o,l){return o&&o.length?xa(o,X(l,2)):0}return v.after=bS,v.ary=Ed,v.assign=ow,v.assignIn=$d,v.assignInWith=no,v.assignWith=aw,v.at=lw,v.before=Od,v.bind=cl,v.bindAll=hk,v.bindKey=Td,v.castArray=NS,v.chain=wd,v.chunk=zb,v.compact=Wb,v.concat=Vb,v.cond=pk,v.conforms=mk,v.constant=gl,v.countBy=Yv,v.create=cw,v.curry=Ad,v.curryRight=Cd,v.debounce=Md,v.defaults=uw,v.defaultsDeep=fw,v.defer=vS,v.delay=SS,v.difference=Hb,v.differenceBy=Ub,v.differenceWith=Kb,v.drop=jb,v.dropRight=qb,v.dropRightWhile=Jb,v.dropWhile=Gb,v.fill=Yb,v.filter=Xv,v.flatMap=tS,v.flatMapDeep=nS,v.flatMapDepth=rS,v.flatten=_d,v.flattenDeep=Qb,v.flattenDepth=Xb,v.flip=wS,v.flow=yk,v.flowRight=_k,v.fromPairs=Zb,v.functions=_w,v.functionsIn=bw,v.groupBy=iS,v.initial=tv,v.intersection=nv,v.intersectionBy=rv,v.intersectionWith=iv,v.invert=Sw,v.invertBy=ww,v.invokeMap=oS,v.iteratee=yl,v.keyBy=aS,v.keys=He,v.keysIn=yt,v.map=Ys,v.mapKeys=xw,v.mapValues=Ew,v.matches=bk,v.matchesProperty=vk,v.memoize=Xs,v.merge=Ow,v.mergeWith=zd,v.method=Sk,v.methodOf=wk,v.mixin=_l,v.negate=Zs,v.nthArg=xk,v.omit=Tw,v.omitBy=Aw,v.once=kS,v.orderBy=lS,v.over=Ek,v.overArgs=xS,v.overEvery=Ok,v.overSome=Tk,v.partial=ul,v.partialRight=Nd,v.partition=cS,v.pick=Cw,v.pickBy=Wd,v.property=Jd,v.propertyOf=Ak,v.pull=lv,v.pullAll=vd,v.pullAllBy=cv,v.pullAllWith=uv,v.pullAt=fv,v.range=Ck,v.rangeRight=Mk,v.rearg=ES,v.reject=dS,v.remove=dv,v.rest=OS,v.reverse=al,v.sampleSize=pS,v.set=Nw,v.setWith=Iw,v.shuffle=mS,v.slice=hv,v.sortBy=_S,v.sortedUniq=vv,v.sortedUniqBy=Sv,v.split=tk,v.spread=TS,v.tail=wv,v.take=kv,v.takeRight=xv,v.takeRightWhile=Ev,v.takeWhile=Ov,v.tap=Wv,v.throttle=AS,v.thru=Gs,v.toArray=Ld,v.toPairs=Vd,v.toPairsIn=Hd,v.toPath=Dk,v.toPlainObject=Fd,v.transform=Pw,v.unary=CS,v.union=Tv,v.unionBy=Av,v.unionWith=Cv,v.uniq=Mv,v.uniqBy=Nv,v.uniqWith=Iv,v.unset=Rw,v.unzip=ll,v.unzipWith=Sd,v.update=Dw,v.updateWith=Lw,v.values=qr,v.valuesIn=Bw,v.without=Pv,v.words=jd,v.wrap=MS,v.xor=Rv,v.xorBy=Dv,v.xorWith=Lv,v.zip=Bv,v.zipObject=Fv,v.zipObjectDeep=$v,v.zipWith=zv,v.entries=Vd,v.entriesIn=Hd,v.extend=$d,v.extendWith=no,_l(v,v),v.add=Bk,v.attempt=qd,v.camelCase=Ww,v.capitalize=Ud,v.ceil=Fk,v.clamp=Fw,v.clone=IS,v.cloneDeep=RS,v.cloneDeepWith=DS,v.cloneWith=PS,v.conformsTo=LS,v.deburr=Kd,v.defaultTo=gk,v.divide=$k,v.endsWith=Vw,v.eq=Qt,v.escape=Hw,v.escapeRegExp=Uw,v.every=Qv,v.find=Zv,v.findIndex=gd,v.findKey=dw,v.findLast=eS,v.findLastIndex=yd,v.findLastKey=hw,v.floor=zk,v.forEach=kd,v.forEachRight=xd,v.forIn=pw,v.forInRight=mw,v.forOwn=gw,v.forOwnRight=yw,v.get=hl,v.gt=BS,v.gte=FS,v.has=vw,v.hasIn=pl,v.head=bd,v.identity=_t,v.includes=sS,v.indexOf=ev,v.inRange=$w,v.invoke=kw,v.isArguments=dr,v.isArray=se,v.isArrayBuffer=$S,v.isArrayLike=gt,v.isArrayLikeObject=Pe,v.isBoolean=zS,v.isBuffer=zn,v.isDate=WS,v.isElement=VS,v.isEmpty=HS,v.isEqual=US,v.isEqualWith=KS,v.isError=fl,v.isFinite=jS,v.isFunction=vn,v.isInteger=Id,v.isLength=eo,v.isMap=Pd,v.isMatch=qS,v.isMatchWith=JS,v.isNaN=GS,v.isNative=YS,v.isNil=XS,v.isNull=QS,v.isNumber=Rd,v.isObject=Ae,v.isObjectLike=Ne,v.isPlainObject=Di,v.isRegExp=dl,v.isSafeInteger=ZS,v.isSet=Dd,v.isString=to,v.isSymbol=Et,v.isTypedArray=jr,v.isUndefined=ew,v.isWeakMap=tw,v.isWeakSet=nw,v.join=sv,v.kebabCase=Kw,v.last=Bt,v.lastIndexOf=ov,v.lowerCase=jw,v.lowerFirst=qw,v.lt=rw,v.lte=iw,v.max=Wk,v.maxBy=Vk,v.mean=Hk,v.meanBy=Uk,v.min=Kk,v.minBy=jk,v.stubArray=vl,v.stubFalse=Sl,v.stubObject=Nk,v.stubString=Ik,v.stubTrue=Pk,v.multiply=qk,v.nth=av,v.noConflict=kk,v.noop=bl,v.now=Qs,v.pad=Jw,v.padEnd=Gw,v.padStart=Yw,v.parseInt=Qw,v.random=zw,v.reduce=uS,v.reduceRight=fS,v.repeat=Xw,v.replace=Zw,v.result=Mw,v.round=Jk,v.runInContext=O,v.sample=hS,v.size=gS,v.snakeCase=ek,v.some=yS,v.sortedIndex=pv,v.sortedIndexBy=mv,v.sortedIndexOf=gv,v.sortedLastIndex=yv,v.sortedLastIndexBy=_v,v.sortedLastIndexOf=bv,v.startCase=nk,v.startsWith=rk,v.subtract=Gk,v.sum=Yk,v.sumBy=Qk,v.template=ik,v.times=Rk,v.toFinite=Sn,v.toInteger=oe,v.toLength=Bd,v.toLower=sk,v.toNumber=Ft,v.toSafeInteger=sw,v.toString=_e,v.toUpper=ok,v.trim=ak,v.trimEnd=lk,v.trimStart=ck,v.truncate=uk,v.unescape=fk,v.uniqueId=Lk,v.upperCase=dk,v.upperFirst=ml,v.each=kd,v.eachRight=xd,v.first=bd,_l(v,function(){var o={};return nn(v,function(l,f){be.call(v.prototype,f)||(o[f]=l)}),o}(),{chain:!1}),v.VERSION=r,It(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){v[o].placeholder=v}),It(["drop","take"],function(o,l){he.prototype[o]=function(f){f=f===t?1:Fe(oe(f),0);var m=this.__filtered__&&!l?new he(this):this.clone();return m.__filtered__?m.__takeCount__=et(f,m.__takeCount__):m.__views__.push({size:et(f,te),type:o+(m.__dir__<0?"Right":"")}),m},he.prototype[o+"Right"]=function(f){return this.reverse()[o](f).reverse()}}),It(["filter","map","takeWhile"],function(o,l){var f=l+1,m=f==We||f==ot;he.prototype[o]=function(b){var S=this.clone();return S.__iteratees__.push({iteratee:X(b,3),type:f}),S.__filtered__=S.__filtered__||m,S}}),It(["head","last"],function(o,l){var f="take"+(l?"Right":"");he.prototype[o]=function(){return this[f](1).value()[0]}}),It(["initial","tail"],function(o,l){var f="drop"+(l?"":"Right");he.prototype[o]=function(){return this.__filtered__?new he(this):this[f](1)}}),he.prototype.compact=function(){return this.filter(_t)},he.prototype.find=function(o){return this.filter(o).head()},he.prototype.findLast=function(o){return this.reverse().find(o)},he.prototype.invokeMap=ue(function(o,l){return typeof o=="function"?new he(this):this.map(function(f){return Ci(f,o,l)})}),he.prototype.reject=function(o){return this.filter(Zs(X(o)))},he.prototype.slice=function(o,l){o=oe(o);var f=this;return f.__filtered__&&(o>0||l<0)?new he(f):(o<0?f=f.takeRight(-o):o&&(f=f.drop(o)),l!==t&&(l=oe(l),f=l<0?f.dropRight(-l):f.take(l-o)),f)},he.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},he.prototype.toArray=function(){return this.take(te)},nn(he.prototype,function(o,l){var f=/^(?:filter|find|map|reject)|While$/.test(l),m=/^(?:head|last)$/.test(l),b=v[m?"take"+(l=="last"?"Right":""):l],S=m||/^find/.test(l);b&&(v.prototype[l]=function(){var x=this.__wrapped__,E=m?[1]:arguments,T=x instanceof he,N=E[0],I=T||se(x),R=function(de){var pe=b.apply(v,Pn([de],E));return m&&W?pe[0]:pe};I&&f&&typeof N=="function"&&N.length!=1&&(T=I=!1);var W=this.__chain__,G=!!this.__actions__.length,Z=S&&!W,le=T&&!G;if(!S&&I){x=le?x:new he(this);var ee=o.apply(x,E);return ee.__actions__.push({func:Gs,args:[R],thisArg:t}),new Rt(ee,W)}return Z&&le?o.apply(this,E):(ee=this.thru(R),Z?m?ee.value()[0]:ee.value():ee)})}),It(["pop","push","shift","sort","splice","unshift"],function(o){var l=Ss[o],f=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",m=/^(?:pop|shift)$/.test(o);v.prototype[o]=function(){var b=arguments;if(m&&!this.__chain__){var S=this.value();return l.apply(se(S)?S:[],b)}return this[f](function(x){return l.apply(se(x)?x:[],b)})}}),nn(he.prototype,function(o,l){var f=v[l];if(f){var m=f.name+"";be.call(Wr,m)||(Wr[m]=[]),Wr[m].push({name:l,func:f})}}),Wr[Vs(t,A).name]=[{name:"wrapper",func:t}],he.prototype.clone=f_,he.prototype.reverse=d_,he.prototype.value=h_,v.prototype.at=Vv,v.prototype.chain=Hv,v.prototype.commit=Uv,v.prototype.next=Kv,v.prototype.plant=qv,v.prototype.reverse=Jv,v.prototype.toJSON=v.prototype.valueOf=v.prototype.value=Gv,v.prototype.first=v.prototype.head,wi&&(v.prototype[wi]=jv),v},Fr=U0();ir?((ir.exports=Fr)._=Fr,ya._=Fr):Ge._=Fr}).call(Li)})(Eo,Eo.exports);var fE=Eo.exports;const dE=di.graphql(`
129
+ }`;var le=qd(function(){return ge(S,G+"return "+R).apply(t,x)});if(le.source=R,fl(le))throw le;return le}function sk(o){return _e(o).toLowerCase()}function ok(o){return _e(o).toUpperCase()}function ak(o,l,f){if(o=_e(o),o&&(f||l===t))return tf(o);if(!o||!(l=xt(l)))return o;var m=Gt(o),b=Gt(l),S=nf(m,b),x=rf(m,b)+1;return $n(m,S,x).join("")}function lk(o,l,f){if(o=_e(o),o&&(f||l===t))return o.slice(0,of(o)+1);if(!o||!(l=xt(l)))return o;var m=Gt(o),b=rf(m,Gt(l))+1;return $n(m,0,b).join("")}function ck(o,l,f){if(o=_e(o),o&&(f||l===t))return o.replace(fa,"");if(!o||!(l=xt(l)))return o;var m=Gt(o),b=nf(m,Gt(l));return $n(m,b).join("")}function uk(o,l){var f=ne,m=ve;if(Ae(l)){var b="separator"in l?l.separator:b;f="length"in l?oe(l.length):f,m="omission"in l?xt(l.omission):m}o=_e(o);var S=o.length;if(Br(o)){var x=Gt(o);S=x.length}if(f>=S)return o;var E=f-Fr(m);if(E<1)return m;var T=x?$n(x,0,E).join(""):o.slice(0,E);if(b===t)return T+m;if(x&&(E+=T.length-E),dl(b)){if(o.slice(E).search(b)){var N,I=T;for(b.global||(b=Aa(b.source,_e(ku.exec(b))+"g")),b.lastIndex=0;N=b.exec(I);)var R=N.index;T=T.slice(0,R===t?E:R)}}else if(o.indexOf(xt(b),E)!=E){var W=T.lastIndexOf(b);W>-1&&(T=T.slice(0,W))}return T+m}function fk(o){return o=_e(o),o&&wy.test(o)?o.replace(vu,z0):o}var dk=Kr(function(o,l,f){return o+(f?" ":"")+l.toUpperCase()}),ml=Jf("toUpperCase");function jd(o,l,f){return o=_e(o),l=f?t:l,l===t?D0(o)?H0(o):O0(o):o.match(l)||[]}var qd=ue(function(o,l){try{return wt(o,t,l)}catch(f){return fl(f)?f:new ie(f)}}),hk=_n(function(o,l){return It(l,function(f){f=sn(f),gn(o,f,cl(o[f],o))}),o});function pk(o){var l=o==null?0:o.length,f=X();return o=l?Te(o,function(m){if(typeof m[1]!="function")throw new Pt(a);return[f(m[0]),m[1]]}):[],ue(function(m){for(var b=-1;++b<l;){var S=o[b];if(wt(S[0],this,m))return wt(S[1],this,m)}})}function mk(o){return z_(Dt(o,p))}function gl(o){return function(){return o}}function gk(o,l){return o==null||o!==o?l:o}var yk=Yf(),_k=Yf(!0);function _t(o){return o}function yl(o){return Of(typeof o=="function"?o:Dt(o,p))}function bk(o){return Af(Dt(o,p))}function vk(o,l){return Cf(o,Dt(l,p))}var Sk=ue(function(o,l){return function(f){return Ci(f,o,l)}}),wk=ue(function(o,l){return function(f){return Ci(o,f,l)}});function _l(o,l,f){var m=He(l),b=Bs(l,m);f==null&&!(Ae(l)&&(b.length||!m.length))&&(f=l,l=o,o=this,b=Bs(l,He(l)));var S=!(Ae(f)&&"chain"in f)||!!f.chain,x=vn(o);return It(b,function(E){var T=l[E];o[E]=T,x&&(o.prototype[E]=function(){var N=this.__chain__;if(S||N){var I=o(this.__wrapped__),R=I.__actions__=mt(this.__actions__);return R.push({func:T,args:arguments,thisArg:o}),I.__chain__=N,I}return T.apply(o,Pn([this.value()],arguments))})}),o}function kk(){return Ge._===this&&(Ge._=G0),this}function bl(){}function xk(o){return o=oe(o),ue(function(l){return Mf(l,o)})}var Ek=Ya(Te),Ok=Ya(Yu),Tk=Ya(Sa);function Jd(o){return rl(o)?wa(sn(o)):rb(o)}function Ak(o){return function(l){return o==null?t:cr(o,l)}}var Ck=Xf(),Mk=Xf(!0);function vl(){return[]}function Sl(){return!1}function Nk(){return{}}function Ik(){return""}function Pk(){return!0}function Rk(o,l){if(o=oe(o),o<1||o>dn)return[];var f=te,m=et(o,te);l=X(l),o-=te;for(var b=Ea(m,l);++f<o;)l(f);return b}function Dk(o){return se(o)?Te(o,sn):Et(o)?[o]:mt(pd(_e(o)))}function Lk(o){var l=++q0;return _e(o)+l}var Bk=Hs(function(o,l){return o+l},0),Fk=Qa("ceil"),$k=Hs(function(o,l){return o/l},1),zk=Qa("floor");function Wk(o){return o&&o.length?Ls(o,_t,La):t}function Vk(o,l){return o&&o.length?Ls(o,X(l,2),La):t}function Hk(o){return Zu(o,_t)}function Uk(o,l){return Zu(o,X(l,2))}function Kk(o){return o&&o.length?Ls(o,_t,za):t}function jk(o,l){return o&&o.length?Ls(o,X(l,2),za):t}var qk=Hs(function(o,l){return o*l},1),Jk=Qa("round"),Gk=Hs(function(o,l){return o-l},0);function Yk(o){return o&&o.length?xa(o,_t):0}function Qk(o,l){return o&&o.length?xa(o,X(l,2)):0}return v.after=bS,v.ary=Ed,v.assign=ow,v.assignIn=$d,v.assignInWith=no,v.assignWith=aw,v.at=lw,v.before=Od,v.bind=cl,v.bindAll=hk,v.bindKey=Td,v.castArray=NS,v.chain=wd,v.chunk=zb,v.compact=Wb,v.concat=Vb,v.cond=pk,v.conforms=mk,v.constant=gl,v.countBy=Yv,v.create=cw,v.curry=Ad,v.curryRight=Cd,v.debounce=Md,v.defaults=uw,v.defaultsDeep=fw,v.defer=vS,v.delay=SS,v.difference=Hb,v.differenceBy=Ub,v.differenceWith=Kb,v.drop=jb,v.dropRight=qb,v.dropRightWhile=Jb,v.dropWhile=Gb,v.fill=Yb,v.filter=Xv,v.flatMap=tS,v.flatMapDeep=nS,v.flatMapDepth=rS,v.flatten=_d,v.flattenDeep=Qb,v.flattenDepth=Xb,v.flip=wS,v.flow=yk,v.flowRight=_k,v.fromPairs=Zb,v.functions=_w,v.functionsIn=bw,v.groupBy=iS,v.initial=tv,v.intersection=nv,v.intersectionBy=rv,v.intersectionWith=iv,v.invert=Sw,v.invertBy=ww,v.invokeMap=oS,v.iteratee=yl,v.keyBy=aS,v.keys=He,v.keysIn=yt,v.map=Ys,v.mapKeys=xw,v.mapValues=Ew,v.matches=bk,v.matchesProperty=vk,v.memoize=Xs,v.merge=Ow,v.mergeWith=zd,v.method=Sk,v.methodOf=wk,v.mixin=_l,v.negate=Zs,v.nthArg=xk,v.omit=Tw,v.omitBy=Aw,v.once=kS,v.orderBy=lS,v.over=Ek,v.overArgs=xS,v.overEvery=Ok,v.overSome=Tk,v.partial=ul,v.partialRight=Nd,v.partition=cS,v.pick=Cw,v.pickBy=Wd,v.property=Jd,v.propertyOf=Ak,v.pull=lv,v.pullAll=vd,v.pullAllBy=cv,v.pullAllWith=uv,v.pullAt=fv,v.range=Ck,v.rangeRight=Mk,v.rearg=ES,v.reject=dS,v.remove=dv,v.rest=OS,v.reverse=al,v.sampleSize=pS,v.set=Nw,v.setWith=Iw,v.shuffle=mS,v.slice=hv,v.sortBy=_S,v.sortedUniq=vv,v.sortedUniqBy=Sv,v.split=tk,v.spread=TS,v.tail=wv,v.take=kv,v.takeRight=xv,v.takeRightWhile=Ev,v.takeWhile=Ov,v.tap=Wv,v.throttle=AS,v.thru=Gs,v.toArray=Ld,v.toPairs=Vd,v.toPairsIn=Hd,v.toPath=Dk,v.toPlainObject=Fd,v.transform=Pw,v.unary=CS,v.union=Tv,v.unionBy=Av,v.unionWith=Cv,v.uniq=Mv,v.uniqBy=Nv,v.uniqWith=Iv,v.unset=Rw,v.unzip=ll,v.unzipWith=Sd,v.update=Dw,v.updateWith=Lw,v.values=Jr,v.valuesIn=Bw,v.without=Pv,v.words=jd,v.wrap=MS,v.xor=Rv,v.xorBy=Dv,v.xorWith=Lv,v.zip=Bv,v.zipObject=Fv,v.zipObjectDeep=$v,v.zipWith=zv,v.entries=Vd,v.entriesIn=Hd,v.extend=$d,v.extendWith=no,_l(v,v),v.add=Bk,v.attempt=qd,v.camelCase=Ww,v.capitalize=Ud,v.ceil=Fk,v.clamp=Fw,v.clone=IS,v.cloneDeep=RS,v.cloneDeepWith=DS,v.cloneWith=PS,v.conformsTo=LS,v.deburr=Kd,v.defaultTo=gk,v.divide=$k,v.endsWith=Vw,v.eq=Qt,v.escape=Hw,v.escapeRegExp=Uw,v.every=Qv,v.find=Zv,v.findIndex=gd,v.findKey=dw,v.findLast=eS,v.findLastIndex=yd,v.findLastKey=hw,v.floor=zk,v.forEach=kd,v.forEachRight=xd,v.forIn=pw,v.forInRight=mw,v.forOwn=gw,v.forOwnRight=yw,v.get=hl,v.gt=BS,v.gte=FS,v.has=vw,v.hasIn=pl,v.head=bd,v.identity=_t,v.includes=sS,v.indexOf=ev,v.inRange=$w,v.invoke=kw,v.isArguments=dr,v.isArray=se,v.isArrayBuffer=$S,v.isArrayLike=gt,v.isArrayLikeObject=Pe,v.isBoolean=zS,v.isBuffer=zn,v.isDate=WS,v.isElement=VS,v.isEmpty=HS,v.isEqual=US,v.isEqualWith=KS,v.isError=fl,v.isFinite=jS,v.isFunction=vn,v.isInteger=Id,v.isLength=eo,v.isMap=Pd,v.isMatch=qS,v.isMatchWith=JS,v.isNaN=GS,v.isNative=YS,v.isNil=XS,v.isNull=QS,v.isNumber=Rd,v.isObject=Ae,v.isObjectLike=Ne,v.isPlainObject=Di,v.isRegExp=dl,v.isSafeInteger=ZS,v.isSet=Dd,v.isString=to,v.isSymbol=Et,v.isTypedArray=qr,v.isUndefined=ew,v.isWeakMap=tw,v.isWeakSet=nw,v.join=sv,v.kebabCase=Kw,v.last=Bt,v.lastIndexOf=ov,v.lowerCase=jw,v.lowerFirst=qw,v.lt=rw,v.lte=iw,v.max=Wk,v.maxBy=Vk,v.mean=Hk,v.meanBy=Uk,v.min=Kk,v.minBy=jk,v.stubArray=vl,v.stubFalse=Sl,v.stubObject=Nk,v.stubString=Ik,v.stubTrue=Pk,v.multiply=qk,v.nth=av,v.noConflict=kk,v.noop=bl,v.now=Qs,v.pad=Jw,v.padEnd=Gw,v.padStart=Yw,v.parseInt=Qw,v.random=zw,v.reduce=uS,v.reduceRight=fS,v.repeat=Xw,v.replace=Zw,v.result=Mw,v.round=Jk,v.runInContext=O,v.sample=hS,v.size=gS,v.snakeCase=ek,v.some=yS,v.sortedIndex=pv,v.sortedIndexBy=mv,v.sortedIndexOf=gv,v.sortedLastIndex=yv,v.sortedLastIndexBy=_v,v.sortedLastIndexOf=bv,v.startCase=nk,v.startsWith=rk,v.subtract=Gk,v.sum=Yk,v.sumBy=Qk,v.template=ik,v.times=Rk,v.toFinite=Sn,v.toInteger=oe,v.toLength=Bd,v.toLower=sk,v.toNumber=Ft,v.toSafeInteger=sw,v.toString=_e,v.toUpper=ok,v.trim=ak,v.trimEnd=lk,v.trimStart=ck,v.truncate=uk,v.unescape=fk,v.uniqueId=Lk,v.upperCase=dk,v.upperFirst=ml,v.each=kd,v.eachRight=xd,v.first=bd,_l(v,function(){var o={};return nn(v,function(l,f){be.call(v.prototype,f)||(o[f]=l)}),o}(),{chain:!1}),v.VERSION=r,It(["bind","bindKey","curry","curryRight","partial","partialRight"],function(o){v[o].placeholder=v}),It(["drop","take"],function(o,l){he.prototype[o]=function(f){f=f===t?1:Fe(oe(f),0);var m=this.__filtered__&&!l?new he(this):this.clone();return m.__filtered__?m.__takeCount__=et(f,m.__takeCount__):m.__views__.push({size:et(f,te),type:o+(m.__dir__<0?"Right":"")}),m},he.prototype[o+"Right"]=function(f){return this.reverse()[o](f).reverse()}}),It(["filter","map","takeWhile"],function(o,l){var f=l+1,m=f==We||f==ot;he.prototype[o]=function(b){var S=this.clone();return S.__iteratees__.push({iteratee:X(b,3),type:f}),S.__filtered__=S.__filtered__||m,S}}),It(["head","last"],function(o,l){var f="take"+(l?"Right":"");he.prototype[o]=function(){return this[f](1).value()[0]}}),It(["initial","tail"],function(o,l){var f="drop"+(l?"":"Right");he.prototype[o]=function(){return this.__filtered__?new he(this):this[f](1)}}),he.prototype.compact=function(){return this.filter(_t)},he.prototype.find=function(o){return this.filter(o).head()},he.prototype.findLast=function(o){return this.reverse().find(o)},he.prototype.invokeMap=ue(function(o,l){return typeof o=="function"?new he(this):this.map(function(f){return Ci(f,o,l)})}),he.prototype.reject=function(o){return this.filter(Zs(X(o)))},he.prototype.slice=function(o,l){o=oe(o);var f=this;return f.__filtered__&&(o>0||l<0)?new he(f):(o<0?f=f.takeRight(-o):o&&(f=f.drop(o)),l!==t&&(l=oe(l),f=l<0?f.dropRight(-l):f.take(l-o)),f)},he.prototype.takeRightWhile=function(o){return this.reverse().takeWhile(o).reverse()},he.prototype.toArray=function(){return this.take(te)},nn(he.prototype,function(o,l){var f=/^(?:filter|find|map|reject)|While$/.test(l),m=/^(?:head|last)$/.test(l),b=v[m?"take"+(l=="last"?"Right":""):l],S=m||/^find/.test(l);b&&(v.prototype[l]=function(){var x=this.__wrapped__,E=m?[1]:arguments,T=x instanceof he,N=E[0],I=T||se(x),R=function(de){var pe=b.apply(v,Pn([de],E));return m&&W?pe[0]:pe};I&&f&&typeof N=="function"&&N.length!=1&&(T=I=!1);var W=this.__chain__,G=!!this.__actions__.length,Z=S&&!W,le=T&&!G;if(!S&&I){x=le?x:new he(this);var ee=o.apply(x,E);return ee.__actions__.push({func:Gs,args:[R],thisArg:t}),new Rt(ee,W)}return Z&&le?o.apply(this,E):(ee=this.thru(R),Z?m?ee.value()[0]:ee.value():ee)})}),It(["pop","push","shift","sort","splice","unshift"],function(o){var l=Ss[o],f=/^(?:push|sort|unshift)$/.test(o)?"tap":"thru",m=/^(?:pop|shift)$/.test(o);v.prototype[o]=function(){var b=arguments;if(m&&!this.__chain__){var S=this.value();return l.apply(se(S)?S:[],b)}return this[f](function(x){return l.apply(se(x)?x:[],b)})}}),nn(he.prototype,function(o,l){var f=v[l];if(f){var m=f.name+"";be.call(Vr,m)||(Vr[m]=[]),Vr[m].push({name:l,func:f})}}),Vr[Vs(t,A).name]=[{name:"wrapper",func:t}],he.prototype.clone=f_,he.prototype.reverse=d_,he.prototype.value=h_,v.prototype.at=Vv,v.prototype.chain=Hv,v.prototype.commit=Uv,v.prototype.next=Kv,v.prototype.plant=qv,v.prototype.reverse=Jv,v.prototype.toJSON=v.prototype.valueOf=v.prototype.value=Gv,v.prototype.first=v.prototype.head,wi&&(v.prototype[wi]=jv),v},$r=U0();ir?((ir.exports=$r)._=$r,ya._=$r):Ge._=$r}).call(Li)})(Eo,Eo.exports);var fE=Eo.exports;const dE=Er.graphql(`
128
130
  query tournamentStepGeneratedShape($stepId: ID!) {
129
131
  tournamentStepGeneratedShape(stepId: $stepId) {
130
132
  id
@@ -145,7 +147,7 @@ function print() { __p += __j.call(arguments, '') }
145
147
  }
146
148
  }
147
149
  }
148
- `),hE=di.graphql(`
150
+ `),hE=Er.graphql(`
149
151
  query tournamentStepGroupRoundGameMatchScoresGetForStep($stepId: ID!, $page: PageInfo!) {
150
152
  tournamentStepGroupRoundGameMatchScoresGetForStep(
151
153
  stepId: $stepId
@@ -163,17 +165,17 @@ function print() { __p += __j.call(arguments, '') }
163
165
  }
164
166
  }
165
167
  }
166
- `),pE=({tournamentId:n,stepId:e,skip:t})=>{const{loading:r,data:i}=$c(dE,{variables:{stepId:e},skip:t}),{loading:s,results:a}=Wc(hE,{skip:t,variables:{stepId:e}}),{loading:c,results:u}=Om({tournamentId:n,skip:t,status:"CONFIRMED"});return{loading:r||s||c,groups:i==null?void 0:i.tournamentStepGeneratedShape.map(d=>{const h=fE.cloneDeep(d),p=u.reduce((g,_)=>(g[_.id]=_,g),{}),y={};for(const g of a){const _=p[g.teamId];if(!_){console.warn(`No team for score ${g.teamId}, match ${g.matchId}`);continue}const w=y[g.matchId]??[];y[g.matchId]=w.concat({..._,score:g.score})}for(const g of h.rounds)for(const _ of g.games)for(const w of _.matches)w.teamScores=y[w.id]??[];return h})}};function Qe(n){this.content=n}Qe.prototype={constructor:Qe,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new Qe(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Qe(t)},addToStart:function(n,e){return new Qe([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Qe(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new Qe(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Qe.from(n),n.size?new Qe(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Qe.from(n),n.size?new Qe(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Qe.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};Qe.from=function(n){if(n instanceof Qe)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Qe(e)};function Tm(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let a=0;i.text[a]==s.text[a];a++)t++;return t}if(i.content.size||s.content.size){let a=Tm(i.content,s.content,t+1);if(a!=null)return a}t+=i.nodeSize}}function Am(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let a=n.child(--i),c=e.child(--s),u=a.nodeSize;if(a==c){t-=u,r-=u;continue}if(!a.sameMarkup(c))return{a:t,b:r};if(a.isText&&a.text!=c.text){let d=0,h=Math.min(a.text.length,c.text.length);for(;d<h&&a.text[a.text.length-d-1]==c.text[c.text.length-d-1];)d++,t--,r--;return{a:t,b:r}}if(a.content.size||c.content.size){let d=Am(a.content,c.content,t-1,r-1);if(d)return d}t-=u,r-=u}}class D{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let a=0,c=0;c<t;a++){let u=this.content[a],d=c+u.nodeSize;if(d>e&&r(u,i+c,s||null,a)!==!1&&u.content.size){let h=c+1;u.nodesBetween(Math.max(0,e-h),Math.min(u.content.size,t-h),r,i+h)}c=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",a=!0;return this.nodesBetween(e,t,(c,u)=>{let d=c.isText?c.text.slice(Math.max(e,u)-u,t-u):c.isLeaf?i?typeof i=="function"?i(c):i:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&d||c.isTextblock)&&r&&(a?a=!1:s+=r),s+=d},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new D(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,a=0;a<t;s++){let c=this.content[s],u=a+c.nodeSize;u>e&&((a<e||u>t)&&(c.isText?c=c.cut(Math.max(0,e-a),Math.min(c.text.length,t-a)):c=c.cut(Math.max(0,e-a-1),Math.min(c.content.size,t-a-1))),r.push(c),i+=c.nodeSize),a=u}return new D(r,i)}cutByIndex(e,t){return e==t?D.empty:e==0&&t==this.content.length?this:new D(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new D(i,s)}addToStart(e){return new D([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new D(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return Tm(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Am(this,e,t,r)}findIndex(e,t=-1){if(e==0)return so(0,e);if(e==this.size)return so(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let s=this.child(r),a=i+s.nodeSize;if(a>=e)return a==e||t>0?so(r+1,a):so(r,i);i=a}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return D.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new D(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return D.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new D(t||e,r)}static from(e){if(!e)return D.empty;if(e instanceof D)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new D([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}D.empty=new D([],0);const Tl={index:0,offset:0};function so(n,e){return Tl.index=n,Tl.offset=e,Tl}function Oo(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Oo(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Oo(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let we=class mc{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Oo(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return mc.none;if(e instanceof mc)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};we.none=[];class To extends Error{}class H{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Mm(this.content,e+this.openStart,t);return r&&new H(r,this.openStart,this.openEnd)}removeBetween(e,t){return new H(Cm(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return H.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new H(D.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new H(e,r,i)}}H.empty=new H(D.empty,0,0);function Cm(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:a,offset:c}=n.findIndex(t);if(i==e||s.isText){if(c!=t&&!n.child(a).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=a)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(Cm(s.content,e-i-1,t-i-1)))}function Mm(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),a=n.maybeChild(i);if(s==e||a.isText)return n.cut(0,e).append(t).append(n.cut(e));let c=Mm(a.content,e-s-1,t);return c&&n.replaceChild(i,a.copy(c))}function mE(n,e,t){if(t.openStart>n.depth)throw new To("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new To("Inconsistent open depths");return Nm(n,e,t,0)}function Nm(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let a=Nm(n,e,t,r+1);return s.copy(s.content.replaceChild(i,a))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let a=n.parent,c=a.content;return Sr(a,c.cut(0,n.parentOffset).append(t.content).append(c.cut(e.parentOffset)))}else{let{start:a,end:c}=gE(t,n);return Sr(s,Pm(n,a,c,e,r))}else return Sr(s,Ao(n,e,r))}function Im(n,e){if(!e.type.compatibleContent(n.type))throw new To("Cannot join "+e.type.name+" onto "+n.type.name)}function gc(n,e,t){let r=n.node(t);return Im(r,e.node(t)),r}function vr(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function qi(n,e,t,r){let i=(e||n).node(t),s=0,a=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(vr(n.nodeAfter,r),s++));for(let c=s;c<a;c++)vr(i.child(c),r);e&&e.depth==t&&e.textOffset&&vr(e.nodeBefore,r)}function Sr(n,e){return n.type.checkContent(e),n.copy(e)}function Pm(n,e,t,r,i){let s=n.depth>i&&gc(n,e,i+1),a=r.depth>i&&gc(t,r,i+1),c=[];return qi(null,n,i,c),s&&a&&e.index(i)==t.index(i)?(Im(s,a),vr(Sr(s,Pm(n,e,t,r,i+1)),c)):(s&&vr(Sr(s,Ao(n,e,i+1)),c),qi(e,t,i,c),a&&vr(Sr(a,Ao(t,r,i+1)),c)),qi(r,null,i,c),new D(c)}function Ao(n,e,t){let r=[];if(qi(null,n,t,r),n.depth>t){let i=gc(n,e,t+1);vr(Sr(i,Ao(n,e,t+1)),r)}return qi(e,null,t,r),new D(r)}function gE(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(D.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Xi{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return we.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let c=r;r=i,i=c}let s=r.marks;for(var a=0;a<s.length;a++)s[a].type.spec.inclusive===!1&&(!i||!s[a].isInSet(i.marks))&&(s=s[a--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Co(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let a=e;;){let{index:c,offset:u}=a.content.findIndex(s),d=s-u;if(r.push(a,c,i+u),!d||(a=a.child(c),a.isText))break;s=d-1,i+=u+1}return new Xi(t,r,s)}static resolveCached(e,t){let r=wh.get(e);if(r)for(let s=0;s<r.elts.length;s++){let a=r.elts[s];if(a.pos==t)return a}else wh.set(e,r=new yE);let i=r.elts[r.i]=Xi.resolve(e,t);return r.i=(r.i+1)%_E,i}}class yE{constructor(){this.elts=[],this.i=0}}const _E=12,wh=new WeakMap;class Co{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const bE=Object.create(null);let Gn=class yc{constructor(e,t,r,i=we.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||D.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Oo(this.attrs,t||e.defaultAttrs||bE)&&we.sameSet(this.marks,r||we.none)}copy(e=null){return e==this.content?this:new yc(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new yc(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return H.empty;let i=this.resolve(e),s=this.resolve(t),a=r?0:i.sharedDepth(t),c=i.start(a),d=i.node(a).content.cut(i.pos-c,s.pos-c);return new H(d,i.depth-a,s.depth-a)}replace(e,t,r){return mE(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return Xi.resolveCached(this,e)}resolveNoCache(e){return Xi.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}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()+")"),Rm(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=D.empty,i=0,s=r.childCount){let a=this.contentMatchAt(e).matchFragment(r,i,s),c=a&&a.matchFragment(this.content,t);if(!c||!c.validEnd)return!1;for(let u=i;u<s;u++)if(!this.type.allowsMarks(r.child(u).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),a=s&&s.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=we.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!we.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=D.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};Gn.prototype.text=void 0;class Mo extends Gn{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Rm(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Mo(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Mo(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Rm(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Or{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new vE(e,t);if(r.next==null)return Or.empty;let i=Dm(r);r.next&&r.err("Unexpected trailing text");let s=TE(OE(i));return AE(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let s=t;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function s(a,c){let u=a.matchFragment(e,r);if(u&&(!t||u.validEnd))return D.from(c.map(d=>d.createAndFill()));for(let d=0;d<a.next.length;d++){let{type:h,next:p}=a.next[d];if(!(h.isText||h.hasRequiredAttrs())&&i.indexOf(p)==-1){i.push(p);let y=s(p,c.concat(h));if(y)return y}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let a=[];for(let c=i;c.type;c=c.via)a.push(c.type);return a.reverse()}for(let a=0;a<s.next.length;a++){let{type:c,next:u}=s.next[a];!c.isLeaf&&!c.hasRequiredAttrs()&&!(c.name in t)&&(!i.type||u.validEnd)&&(r.push({match:c.contentMatch,type:c,via:i}),t[c.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let a=0;a<r.next.length;a++)s+=(a?", ":"")+r.next[a].type.name+"->"+e.indexOf(r.next[a].next);return s}).join(`
167
- `)}}Or.empty=new Or(!0);class vE{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Dm(n){let e=[];do e.push(SE(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function SE(n){let e=[];do e.push(wE(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function wE(n){let e=EE(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=kE(n,e);else break;return e}function kh(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function kE(n,e){let t=kh(n),r=t;return n.eat(",")&&(n.next!="}"?r=kh(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function xE(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let a=t[s];a.isInGroup(e)&&i.push(a)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function EE(n){if(n.eat("(")){let e=Dm(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=xE(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function OE(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(a,c,u){let d={term:u,to:c};return e[a].push(d),d}function i(a,c){a.forEach(u=>u.to=c)}function s(a,c){if(a.type=="choice")return a.exprs.reduce((u,d)=>u.concat(s(d,c)),[]);if(a.type=="seq")for(let u=0;;u++){let d=s(a.exprs[u],c);if(u==a.exprs.length-1)return d;i(d,c=t())}else if(a.type=="star"){let u=t();return r(c,u),i(s(a.expr,u),u),[r(u)]}else if(a.type=="plus"){let u=t();return i(s(a.expr,c),u),i(s(a.expr,u),u),[r(u)]}else{if(a.type=="opt")return[r(c)].concat(s(a.expr,c));if(a.type=="range"){let u=c;for(let d=0;d<a.min;d++){let h=t();i(s(a.expr,u),h),u=h}if(a.max==-1)i(s(a.expr,u),u);else for(let d=a.min;d<a.max;d++){let h=t();r(u,h),i(s(a.expr,u),h),u=h}return[r(u)]}else{if(a.type=="name")return[r(c,void 0,a.value)];throw new Error("Unknown expr type")}}}}function Lm(n,e){return e-n}function xh(n,e){let t=[];return r(e),t.sort(Lm);function r(i){let s=n[i];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(i);for(let a=0;a<s.length;a++){let{term:c,to:u}=s[a];!c&&t.indexOf(u)==-1&&r(u)}}}function TE(n){let e=Object.create(null);return t(xh(n,0));function t(r){let i=[];r.forEach(a=>{n[a].forEach(({term:c,to:u})=>{if(!c)return;let d;for(let h=0;h<i.length;h++)i[h][0]==c&&(d=i[h][1]);xh(n,u).forEach(h=>{d||i.push([c,d=[]]),d.indexOf(h)==-1&&d.push(h)})})});let s=e[r.join(",")]=new Or(r.indexOf(n.length-1)>-1);for(let a=0;a<i.length;a++){let c=i[a][1].sort(Lm);s.next.push({type:i[a][0],next:e[c.join(",")]||t(c)})}return s}}function AE(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],s=!i.validEnd,a=[];for(let c=0;c<i.next.length;c++){let{type:u,next:d}=i.next[c];a.push(u.name),s&&!(u.isText||u.hasRequiredAttrs())&&(s=!1),r.indexOf(d)==-1&&r.push(d)}s&&e.err("Only non-generatable nodes ("+a.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Bm(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Fm(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function $m(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in n){let s=n[i];s.validate&&s.validate(e[i])}}function zm(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new ME(n,r,e[r]);return t}let Eh=class Wm{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=zm(e,r.attrs),this.defaultAttrs=Bm(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==Or.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:Fm(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Gn(this,this.computeAttrs(e),D.from(t),we.setFrom(r))}createChecked(e=null,t,r){return t=D.from(t),this.checkContent(t),new Gn(this,this.computeAttrs(e),t,we.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=D.from(t),t.size){let a=this.contentMatch.fillBefore(t);if(!a)return null;t=a.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(D.empty,!0);return s?new Gn(this,e,t.append(s),we.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){$m(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:we.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,a)=>r[s]=new Wm(s,t,a));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function CE(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class ME{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?CE(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Wo{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=zm(e,i.attrs),this.excluded=null;let s=Bm(this.attrs);this.instance=s?new we(this,s):null}create(e=null){return!e&&this.instance?this.instance:new we(this,Fm(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,a)=>r[s]=new Wo(s,i++,t,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){$m(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Vm{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=Qe.from(e.nodes),t.marks=Qe.from(e.marks||{}),this.nodes=Eh.compile(this.spec.nodes,this),this.marks=Wo.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],a=s.spec.content||"",c=s.spec.marks;if(s.contentMatch=r[a]||(r[a]=Or.parse(a,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=c=="_"?null:c?Oh(this,c.split(" ")):c==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],a=s.spec.excludes;s.excluded=a==null?[s]:a==""?[]:Oh(this,a.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Eh){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new Mo(r,r.defaultAttrs,e,we.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Gn.fromJSON(this,e)}markFromJSON(e){return we.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Oh(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],s=n.marks[i],a=s;if(s)t.push(s);else for(let c in n.marks){let u=n.marks[c];(i=="_"||u.spec.group&&u.spec.group.split(" ").indexOf(i)>-1)&&t.push(a=u)}if(!a)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function NE(n){return n.tag!=null}function IE(n){return n.style!=null}class Yn{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(NE(i))this.tags.push(i);else if(IE(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new Ah(this,t,!1);return r.addAll(e,we.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Ah(this,t,!0);return r.addAll(e,we.none,t.from,t.to),H.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(DE(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let a=s.getAttrs(e);if(a===!1)continue;s.attrs=a||void 0}return s}}}matchStyle(e,t,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let a=this.styles[s],c=a.style;if(!(c.indexOf(e)!=0||a.context&&!r.matchesContext(a.context)||c.length>e.length&&(c.charCodeAt(e.length)!=61||c.slice(e.length+1)!=t))){if(a.getAttrs){let u=a.getAttrs(t);if(u===!1)continue;a.attrs=u||void 0}return a}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,a=0;for(;a<t.length;a++){let c=t[a];if((c.priority==null?50:c.priority)<s)break}t.splice(a,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(a=>{r(a=Ch(a)),a.mark||a.ignore||a.clearMark||(a.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(a=>{r(a=Ch(a)),a.node||a.ignore||a.mark||(a.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Yn(e,Yn.schemaRules(e)))}}const Hm={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},PE={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Um={ol:!0,ul:!0},Zi=1,_c=2,go=4;function Th(n,e,t){return e!=null?(e?Zi:0)|(e==="full"?_c:0):n&&n.whitespace=="pre"?Zi|_c:t&-5}class oo{constructor(e,t,r,i,s,a){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=a,this.content=[],this.activeMarks=we.none,this.match=s||(a&go?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(D.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Zi)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=D.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(D.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Hm.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ah{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,a=Th(null,t.preserveWhitespace,0)|(r?go:0);i?s=new oo(i.type,i.attrs,we.none,!0,t.topMatch||i.type.contentMatch,a):r?s=new oo(null,null,we.none,!0,null,a):s=new oo(e.schema.topNodeType,null,we.none,!0,null,a),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,s=i.options&_c?"full":this.localPreserveWS||(i.options&Zi)>0;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)s!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
168
+ `),pE=({tournamentId:n,stepId:e,skip:t})=>{const{loading:r,data:i}=$c(dE,{variables:{stepId:e},skip:t}),{loading:s,results:a}=Wc(hE,{skip:t,variables:{stepId:e}}),{loading:c,results:u}=Om({tournamentId:n,skip:t,status:"CONFIRMED"});return{loading:r||s||c,groups:i==null?void 0:i.tournamentStepGeneratedShape.map(d=>{const h=fE.cloneDeep(d),p=u.reduce((g,_)=>(g[_.id]=_,g),{}),y={};for(const g of a){const _=p[g.teamId];if(!_){console.warn(`No team for score ${g.teamId}, match ${g.matchId}`);continue}const w=y[g.matchId]??[];y[g.matchId]=w.concat({..._,score:g.score})}for(const g of h.rounds)for(const _ of g.games)for(const w of _.matches)w.teamScores=y[w.id]??[];return h})}};function Qe(n){this.content=n}Qe.prototype={constructor:Qe,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new Qe(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Qe(t)},addToStart:function(n,e){return new Qe([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Qe(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new Qe(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Qe.from(n),n.size?new Qe(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Qe.from(n),n.size?new Qe(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Qe.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};Qe.from=function(n){if(n instanceof Qe)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Qe(e)};function Tm(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let a=0;i.text[a]==s.text[a];a++)t++;return t}if(i.content.size||s.content.size){let a=Tm(i.content,s.content,t+1);if(a!=null)return a}t+=i.nodeSize}}function Am(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let a=n.child(--i),c=e.child(--s),u=a.nodeSize;if(a==c){t-=u,r-=u;continue}if(!a.sameMarkup(c))return{a:t,b:r};if(a.isText&&a.text!=c.text){let d=0,h=Math.min(a.text.length,c.text.length);for(;d<h&&a.text[a.text.length-d-1]==c.text[c.text.length-d-1];)d++,t--,r--;return{a:t,b:r}}if(a.content.size||c.content.size){let d=Am(a.content,c.content,t-1,r-1);if(d)return d}t-=u,r-=u}}class D{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let a=0,c=0;c<t;a++){let u=this.content[a],d=c+u.nodeSize;if(d>e&&r(u,i+c,s||null,a)!==!1&&u.content.size){let h=c+1;u.nodesBetween(Math.max(0,e-h),Math.min(u.content.size,t-h),r,i+h)}c=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",a=!0;return this.nodesBetween(e,t,(c,u)=>{let d=c.isText?c.text.slice(Math.max(e,u)-u,t-u):c.isLeaf?i?typeof i=="function"?i(c):i:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&d||c.isTextblock)&&r&&(a?a=!1:s+=r),s+=d},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new D(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,a=0;a<t;s++){let c=this.content[s],u=a+c.nodeSize;u>e&&((a<e||u>t)&&(c.isText?c=c.cut(Math.max(0,e-a),Math.min(c.text.length,t-a)):c=c.cut(Math.max(0,e-a-1),Math.min(c.content.size,t-a-1))),r.push(c),i+=c.nodeSize),a=u}return new D(r,i)}cutByIndex(e,t){return e==t?D.empty:e==0&&t==this.content.length?this:new D(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,new D(i,s)}addToStart(e){return new D([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new D(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return Tm(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Am(this,e,t,r)}findIndex(e,t=-1){if(e==0)return so(0,e);if(e==this.size)return so(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let s=this.child(r),a=i+s.nodeSize;if(a>=e)return a==e||t>0?so(r+1,a):so(r,i);i=a}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return D.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new D(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return D.empty;let t,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new D(t||e,r)}static from(e){if(!e)return D.empty;if(e instanceof D)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new D([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}D.empty=new D([],0);const Tl={index:0,offset:0};function so(n,e){return Tl.index=n,Tl.offset=e,Tl}function Oo(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Oo(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Oo(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let we=class mc{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Oo(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=r.create(t.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return mc.none;if(e instanceof mc)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};we.none=[];class To extends Error{}class H{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Mm(this.content,e+this.openStart,t);return r&&new H(r,this.openStart,this.openEnd)}removeBetween(e,t){return new H(Cm(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return H.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new H(D.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new H(e,r,i)}}H.empty=new H(D.empty,0,0);function Cm(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:a,offset:c}=n.findIndex(t);if(i==e||s.isText){if(c!=t&&!n.child(a).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=a)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(Cm(s.content,e-i-1,t-i-1)))}function Mm(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),a=n.maybeChild(i);if(s==e||a.isText)return n.cut(0,e).append(t).append(n.cut(e));let c=Mm(a.content,e-s-1,t);return c&&n.replaceChild(i,a.copy(c))}function mE(n,e,t){if(t.openStart>n.depth)throw new To("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new To("Inconsistent open depths");return Nm(n,e,t,0)}function Nm(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let a=Nm(n,e,t,r+1);return s.copy(s.content.replaceChild(i,a))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let a=n.parent,c=a.content;return Sr(a,c.cut(0,n.parentOffset).append(t.content).append(c.cut(e.parentOffset)))}else{let{start:a,end:c}=gE(t,n);return Sr(s,Pm(n,a,c,e,r))}else return Sr(s,Ao(n,e,r))}function Im(n,e){if(!e.type.compatibleContent(n.type))throw new To("Cannot join "+e.type.name+" onto "+n.type.name)}function gc(n,e,t){let r=n.node(t);return Im(r,e.node(t)),r}function vr(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function qi(n,e,t,r){let i=(e||n).node(t),s=0,a=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(vr(n.nodeAfter,r),s++));for(let c=s;c<a;c++)vr(i.child(c),r);e&&e.depth==t&&e.textOffset&&vr(e.nodeBefore,r)}function Sr(n,e){return n.type.checkContent(e),n.copy(e)}function Pm(n,e,t,r,i){let s=n.depth>i&&gc(n,e,i+1),a=r.depth>i&&gc(t,r,i+1),c=[];return qi(null,n,i,c),s&&a&&e.index(i)==t.index(i)?(Im(s,a),vr(Sr(s,Pm(n,e,t,r,i+1)),c)):(s&&vr(Sr(s,Ao(n,e,i+1)),c),qi(e,t,i,c),a&&vr(Sr(a,Ao(t,r,i+1)),c)),qi(r,null,i,c),new D(c)}function Ao(n,e,t){let r=[];if(qi(null,n,t,r),n.depth>t){let i=gc(n,e,t+1);vr(Sr(i,Ao(n,e,t+1)),r)}return qi(e,null,t,r),new D(r)}function gE(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(D.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Xi{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return we.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);if(!r){let c=r;r=i,i=c}let s=r.marks;for(var a=0;a<s.length;a++)s[a].type.spec.inclusive===!1&&(!i||!s[a].isInSet(i.marks))&&(s=s[a--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Co(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;for(let a=e;;){let{index:c,offset:u}=a.content.findIndex(s),d=s-u;if(r.push(a,c,i+u),!d||(a=a.child(c),a.isText))break;s=d-1,i+=u+1}return new Xi(t,r,s)}static resolveCached(e,t){let r=wh.get(e);if(r)for(let s=0;s<r.elts.length;s++){let a=r.elts[s];if(a.pos==t)return a}else wh.set(e,r=new yE);let i=r.elts[r.i]=Xi.resolve(e,t);return r.i=(r.i+1)%_E,i}}class yE{constructor(){this.elts=[],this.i=0}}const _E=12,wh=new WeakMap;class Co{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const bE=Object.create(null);let Gn=class yc{constructor(e,t,r,i=we.none){this.type=e,this.attrs=t,this.marks=i,this.content=r||D.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,i=0){this.content.nodesBetween(e,t,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,i){return this.content.textBetween(e,t,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Oo(this.attrs,t||e.defaultAttrs||bE)&&we.sameSet(this.marks,r||we.none)}copy(e=null){return e==this.content?this:new yc(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new yc(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return H.empty;let i=this.resolve(e),s=this.resolve(t),a=r?0:i.sharedDepth(t),c=i.start(a),d=i.node(a).content.cut(i.pos-c,s.pos-c);return new H(d,i.depth-a,s.depth-a)}replace(e,t,r){return mE(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return Xi.resolveCached(this,e)}resolveNoCache(e){return Xi.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}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()+")"),Rm(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=D.empty,i=0,s=r.childCount){let a=this.contentMatchAt(e).matchFragment(r,i,s),c=a&&a.matchFragment(this.content,t);if(!c||!c.validEnd)return!1;for(let u=i;u<s;u++)if(!this.type.allowsMarks(r.child(u).marks))return!1;return!0}canReplaceWith(e,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),a=s&&s.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=we.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!we.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=D.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};Gn.prototype.text=void 0;class Mo extends Gn{constructor(e,t,r,i){if(super(e,t,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Rm(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Mo(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Mo(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Rm(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Tr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new vE(e,t);if(r.next==null)return Tr.empty;let i=Dm(r);r.next&&r.err("Unexpected trailing text");let s=TE(OE(i));return AE(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let s=t;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function s(a,c){let u=a.matchFragment(e,r);if(u&&(!t||u.validEnd))return D.from(c.map(d=>d.createAndFill()));for(let d=0;d<a.next.length;d++){let{type:h,next:p}=a.next[d];if(!(h.isText||h.hasRequiredAttrs())&&i.indexOf(p)==-1){i.push(p);let y=s(p,c.concat(h));if(y)return y}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let a=[];for(let c=i;c.type;c=c.via)a.push(c.type);return a.reverse()}for(let a=0;a<s.next.length;a++){let{type:c,next:u}=s.next[a];!c.isLeaf&&!c.hasRequiredAttrs()&&!(c.name in t)&&(!i.type||u.validEnd)&&(r.push({match:c.contentMatch,type:c,via:i}),t[c.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let a=0;a<r.next.length;a++)s+=(a?", ":"")+r.next[a].type.name+"->"+e.indexOf(r.next[a].next);return s}).join(`
169
+ `)}}Tr.empty=new Tr(!0);class vE{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Dm(n){let e=[];do e.push(SE(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function SE(n){let e=[];do e.push(wE(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function wE(n){let e=EE(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=kE(n,e);else break;return e}function kh(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function kE(n,e){let t=kh(n),r=t;return n.eat(",")&&(n.next!="}"?r=kh(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function xE(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let a=t[s];a.isInGroup(e)&&i.push(a)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function EE(n){if(n.eat("(")){let e=Dm(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=xE(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function OE(n){let e=[[]];return i(s(n,0),t()),e;function t(){return e.push([])-1}function r(a,c,u){let d={term:u,to:c};return e[a].push(d),d}function i(a,c){a.forEach(u=>u.to=c)}function s(a,c){if(a.type=="choice")return a.exprs.reduce((u,d)=>u.concat(s(d,c)),[]);if(a.type=="seq")for(let u=0;;u++){let d=s(a.exprs[u],c);if(u==a.exprs.length-1)return d;i(d,c=t())}else if(a.type=="star"){let u=t();return r(c,u),i(s(a.expr,u),u),[r(u)]}else if(a.type=="plus"){let u=t();return i(s(a.expr,c),u),i(s(a.expr,u),u),[r(u)]}else{if(a.type=="opt")return[r(c)].concat(s(a.expr,c));if(a.type=="range"){let u=c;for(let d=0;d<a.min;d++){let h=t();i(s(a.expr,u),h),u=h}if(a.max==-1)i(s(a.expr,u),u);else for(let d=a.min;d<a.max;d++){let h=t();r(u,h),i(s(a.expr,u),h),u=h}return[r(u)]}else{if(a.type=="name")return[r(c,void 0,a.value)];throw new Error("Unknown expr type")}}}}function Lm(n,e){return e-n}function xh(n,e){let t=[];return r(e),t.sort(Lm);function r(i){let s=n[i];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(i);for(let a=0;a<s.length;a++){let{term:c,to:u}=s[a];!c&&t.indexOf(u)==-1&&r(u)}}}function TE(n){let e=Object.create(null);return t(xh(n,0));function t(r){let i=[];r.forEach(a=>{n[a].forEach(({term:c,to:u})=>{if(!c)return;let d;for(let h=0;h<i.length;h++)i[h][0]==c&&(d=i[h][1]);xh(n,u).forEach(h=>{d||i.push([c,d=[]]),d.indexOf(h)==-1&&d.push(h)})})});let s=e[r.join(",")]=new Tr(r.indexOf(n.length-1)>-1);for(let a=0;a<i.length;a++){let c=i[a][1].sort(Lm);s.next.push({type:i[a][0],next:e[c.join(",")]||t(c)})}return s}}function AE(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],s=!i.validEnd,a=[];for(let c=0;c<i.next.length;c++){let{type:u,next:d}=i.next[c];a.push(u.name),s&&!(u.isText||u.hasRequiredAttrs())&&(s=!1),r.indexOf(d)==-1&&r.push(d)}s&&e.err("Only non-generatable nodes ("+a.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Bm(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Fm(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function $m(n,e,t,r){for(let i in e)if(!(i in n))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in n){let s=n[i];s.validate&&s.validate(e[i])}}function zm(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new ME(n,r,e[r]);return t}let Eh=class Wm{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=zm(e,r.attrs),this.defaultAttrs=Bm(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==Tr.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:Fm(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Gn(this,this.computeAttrs(e),D.from(t),we.setFrom(r))}createChecked(e=null,t,r){return t=D.from(t),this.checkContent(t),new Gn(this,this.computeAttrs(e),t,we.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=D.from(t),t.size){let a=this.contentMatch.fillBefore(t);if(!a)return null;t=a.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(D.empty,!0);return s?new Gn(this,e,t.append(s),we.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){$m(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:we.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,a)=>r[s]=new Wm(s,t,a));let i=t.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function CE(n,e,t){let r=t.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class ME{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?CE(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Wo{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=zm(e,i.attrs),this.excluded=null;let s=Bm(this.attrs);this.instance=s?new we(this,s):null}create(e=null){return!e&&this.instance?this.instance:new we(this,Fm(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,a)=>r[s]=new Wo(s,i++,t,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){$m(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Vm{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=Qe.from(e.nodes),t.marks=Qe.from(e.marks||{}),this.nodes=Eh.compile(this.spec.nodes,this),this.marks=Wo.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],a=s.spec.content||"",c=s.spec.marks;if(s.contentMatch=r[a]||(r[a]=Tr.parse(a,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=c=="_"?null:c?Oh(this,c.split(" ")):c==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],a=s.spec.excludes;s.excluded=a==null?[s]:a==""?[]:Oh(this,a.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Eh){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new Mo(r,r.defaultAttrs,e,we.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Gn.fromJSON(this,e)}markFromJSON(e){return we.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Oh(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],s=n.marks[i],a=s;if(s)t.push(s);else for(let c in n.marks){let u=n.marks[c];(i=="_"||u.spec.group&&u.spec.group.split(" ").indexOf(i)>-1)&&t.push(a=u)}if(!a)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function NE(n){return n.tag!=null}function IE(n){return n.style!=null}class Yn{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(i=>{if(NE(i))this.tags.push(i);else if(IE(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new Ah(this,t,!1);return r.addAll(e,we.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Ah(this,t,!0);return r.addAll(e,we.none,t.from,t.to),H.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(DE(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let a=s.getAttrs(e);if(a===!1)continue;s.attrs=a||void 0}return s}}}matchStyle(e,t,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let a=this.styles[s],c=a.style;if(!(c.indexOf(e)!=0||a.context&&!r.matchesContext(a.context)||c.length>e.length&&(c.charCodeAt(e.length)!=61||c.slice(e.length+1)!=t))){if(a.getAttrs){let u=a.getAttrs(t);if(u===!1)continue;a.attrs=u||void 0}return a}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,a=0;for(;a<t.length;a++){let c=t[a];if((c.priority==null?50:c.priority)<s)break}t.splice(a,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(a=>{r(a=Ch(a)),a.mark||a.ignore||a.clearMark||(a.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(a=>{r(a=Ch(a)),a.node||a.ignore||a.mark||(a.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Yn(e,Yn.schemaRules(e)))}}const Hm={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},PE={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Um={ol:!0,ul:!0},Zi=1,_c=2,go=4;function Th(n,e,t){return e!=null?(e?Zi:0)|(e==="full"?_c:0):n&&n.whitespace=="pre"?Zi|_c:t&-5}class oo{constructor(e,t,r,i,s,a){this.type=e,this.attrs=t,this.marks=r,this.solid=i,this.options=a,this.content=[],this.activeMarks=we.none,this.match=s||(a&go?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(D.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Zi)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=D.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(D.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Hm.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Ah{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,a=Th(null,t.preserveWhitespace,0)|(r?go:0);i?s=new oo(i.type,i.attrs,we.none,!0,t.topMatch||i.type.contentMatch,a):r?s=new oo(null,null,we.none,!0,null,a):s=new oo(e.schema.topNodeType,null,we.none,!0,null,a),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,i=this.top,s=i.options&_c?"full":this.localPreserveWS||(i.options&Zi)>0;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)s!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
168
170
  `);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let a=i.content[i.content.length-1],c=e.previousSibling;(!a||c&&c.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),c;Um.hasOwnProperty(a)&&this.parser.normalizeLists&&RE(e);let u=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(c=this.parser.matchTag(e,this,r));e:if(u?u.ignore:PE.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!u||u.skip||u.closeParent){u&&u.closeParent?this.open=Math.max(0,this.open-1):u&&u.skip.nodeType&&(e=u.skip);let d,h=this.needsBlock;if(Hm.hasOwnProperty(a))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),d=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let p=u&&u.skip?t:this.readStyles(e,t);p&&this.addAll(e,p),d&&this.sync(s),this.needsBlock=h}else{let d=this.readStyles(e,t);d&&this.addElementByRule(e,u,d,u.consuming===!1?c:void 0)}this.localPreserveWS=i}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
169
- `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],a=r.getPropertyValue(s);if(a)for(let c=void 0;;){let u=this.parser.matchStyle(s,a,this,c);if(!u)break;if(u.ignore)return null;if(u.clearMark?t=t.filter(d=>!u.clearMark(d)):t=t.concat(this.parser.schema.marks[u.mark].create(u.attrs)),u.consuming===!1)c=u;else break}}return t}addElementByRule(e,t,r,i){let s,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),r)||this.leafFallback(e,r);else{let u=this.enter(a,t.attrs||null,r,t.preserveWhitespace);u&&(s=!0,r=u)}else{let u=this.parser.schema.marks[t.mark];r=r.concat(u.create(t.attrs))}let c=this.top;if(a&&a.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u,r));else{let u=e;typeof t.contentElement=="string"?u=e.querySelector(t.contentElement):typeof t.contentElement=="function"?u=t.contentElement(e):t.contentElement&&(u=t.contentElement),this.findAround(e,u,!0),this.addAll(u,r),this.findAround(e,u,!1)}s&&this.sync(c)&&this.open--}addAll(e,t,r,i){let s=r||0;for(let a=r?e.childNodes[r]:e.firstChild,c=i==null?null:e.childNodes[i];a!=c;a=a.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(a,t);this.findAtPoint(e,s)}findPlace(e,t){let r,i;for(let s=this.open;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!r||r.length>c.length)&&(r=c,i=a,!c.length)||a.solid)break}if(!r)return null;this.sync(i);for(let s=0;s<r.length;s++)t=this.enterInner(r[s],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let r=this.findPlace(e,t);if(r){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=we.none;for(let a of r.concat(e.marks))(i.type?i.type.allowsMarkType(a.type):Mh(a.type,e.type))&&(s=a.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,t,r,i){let s=this.findPlace(e.create(t),r);return s&&(s=this.enterInner(e,t,r,!0,i)),s}enterInner(e,t,r,i=!1,s){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let c=Th(e,s,a.options);a.options&go&&a.content.length==0&&(c|=go);let u=we.none;return r=r.filter(d=>(a.type?a.type.allowsMarkType(d.type):Mh(d.type,e))?(u=d.addToSet(u),!1):!0),this.nodes.push(new oo(e,t,u,i,null,c)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Zi)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),a=(c,u)=>{for(;c>=0;c--){let d=t[c];if(d==""){if(c==t.length-1||c==0)continue;for(;u>=s;u--)if(a(c-1,u))return!0;return!1}else{let h=u>0||u==0&&i?this.nodes[u].type:r&&u>=s?r.node(u-s).type:null;if(!h||h.name!=d&&!h.isInGroup(d))return!1;u--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function RE(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Um.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function DE(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Ch(n){let e={};for(let t in n)e[t]=n[t];return e}function Mh(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],a=c=>{s.push(c);for(let u=0;u<c.edgeCount;u++){let{type:d,next:h}=c.edge(u);if(d==e||s.indexOf(h)<0&&a(h))return!0}};if(a(i.contentMatch))return!0}}class Nr{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Al(t).createDocumentFragment());let i=r,s=[];return e.forEach(a=>{if(s.length||a.marks.length){let c=0,u=0;for(;c<s.length&&u<a.marks.length;){let d=a.marks[u];if(!this.marks[d.type.name]){u++;continue}if(!d.eq(s[c][0])||d.type.spec.spanning===!1)break;c++,u++}for(;c<s.length;)i=s.pop()[1];for(;u<a.marks.length;){let d=a.marks[u++],h=this.serializeMark(d,a.isInline,t);h&&(s.push([d,i]),i.appendChild(h.dom),i=h.contentDOM||h.dom)}}i.appendChild(this.serializeNodeInner(a,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=yo(Al(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&yo(Al(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return yo(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Nr(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Nh(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Nh(e.marks)}}function Nh(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Al(n){return n.document||window.document}const Ih=new WeakMap;function LE(n){let e=Ih.get(n);return e===void 0&&Ih.set(n,e=BE(n)),e}function BE(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function yo(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=LE(r))&&s.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 a=i.indexOf(" ");a>0&&(t=i.slice(0,a),i=i.slice(a+1));let c,u=t?n.createElementNS(t,i):n.createElement(i),d=e[1],h=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){h=2;for(let p in d)if(d[p]!=null){let y=p.indexOf(" ");y>0?u.setAttributeNS(p.slice(0,y),p.slice(y+1),d[p]):u.setAttribute(p,d[p])}}for(let p=h;p<e.length;p++){let y=e[p];if(y===0){if(p<e.length-1||p>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:g,contentDOM:_}=yo(n,y,t,r);if(u.appendChild(g),_){if(c)throw new RangeError("Multiple content holes");c=_}}}return{dom:u,contentDOM:c}}const Km=65535,jm=Math.pow(2,16);function FE(n,e){return n+e*jm}function Ph(n){return n&Km}function $E(n){return(n-(n&Km))/jm}const qm=1,Jm=2,_o=4,Gm=8;class bc{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Gm)>0}get deletedBefore(){return(this.delInfo&(qm|_o))>0}get deletedAfter(){return(this.delInfo&(Jm|_o))>0}get deletedAcross(){return(this.delInfo&_o)>0}}class At{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&At.empty)return At.empty}recover(e){let t=0,r=Ph(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+$E(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,a=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?i:0);if(u>e)break;let d=this.ranges[c+s],h=this.ranges[c+a],p=u+d;if(e<=p){let y=d?e==u?-1:e==p?1:t:t,g=u+i+(y<0?0:h);if(r)return g;let _=e==(t<0?u:p)?null:FE(c/3,e-u),w=e==u?Jm:e==p?qm:_o;return(t<0?e!=u:e!=p)&&(w|=Gm),new bc(g,w,_)}i+=h-d}return r?e+i:new bc(e+i,0,null)}touches(e,t){let r=0,i=Ph(t),s=this.inverted?2:1,a=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?r:0);if(u>e)break;let d=this.ranges[c+s],h=u+d;if(e<=h&&c==i*3)return!0;r+=this.ranges[c+a]-d}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let a=this.ranges[i],c=a-(this.inverted?s:0),u=a+(this.inverted?0:s),d=this.ranges[i+t],h=this.ranges[i+r];e(c,c+d,u,u+h),s+=h-d}}invert(){return new At(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?At.empty:new At(e<0?[0,-e,0]:[0,0,e])}}At.empty=new At([]);class es{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new es(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new es;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let a=this._maps[s],c=a.mapResult(e,t);if(c.recover!=null){let u=this.getMirror(s);if(u!=null&&u>s&&u<this.to){s=u,e=this._maps[u].recover(c.recover);continue}}i|=c.delInfo,e=c.pos}return r?e:new bc(e,i,null)}}const Cl=Object.create(null);class st{getMap(){return At.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Cl[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Cl)throw new RangeError("Duplicate use of step JSON ID "+e);return Cl[e]=t,t.prototype.jsonID=e,t}}class Le{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new Le(e,null)}static fail(e){return new Le(null,e)}static fromReplace(e,t,r,i){try{return Le.ok(e.replace(t,r,i))}catch(s){if(s instanceof To)return Le.fail(s.message);throw s}}}function jc(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(jc(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return D.fromArray(r)}class jn extends st{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new H(jc(t.content,(a,c)=>!a.isAtom||!c.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),i),t.openStart,t.openEnd);return Le.fromReplace(e,this.from,this.to,s)}invert(){return new ln(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new jn(t.pos,r.pos,this.mark)}merge(e){return e instanceof jn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new jn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new jn(t.from,t.to,e.markFromJSON(t.mark))}}st.jsonID("addMark",jn);class ln extends st{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new H(jc(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Le.fromReplace(e,this.from,this.to,r)}invert(){return new jn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new ln(t.pos,r.pos,this.mark)}merge(e){return e instanceof ln&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ln(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ln(t.from,t.to,e.markFromJSON(t.mark))}}st.jsonID("removeMark",ln);class qn extends st{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Le.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Le.fromReplace(e,this.pos,this.pos+1,new H(D.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new qn(this.pos,t.marks[i]);return new qn(this.pos,this.mark)}}return new ai(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new qn(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new qn(t.pos,e.markFromJSON(t.mark))}}st.jsonID("addNodeMark",qn);class ai extends st{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Le.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Le.fromReplace(e,this.pos,this.pos+1,new H(D.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new qn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ai(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new ai(t.pos,e.markFromJSON(t.mark))}}st.jsonID("removeNodeMark",ai);class Ue extends st{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&vc(e,this.from,this.to)?Le.fail("Structure replace would overwrite content"):Le.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new At([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ue(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new Ue(t.pos,Math.max(t.pos,r.pos),this.slice)}merge(e){if(!(e instanceof Ue)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?H.empty:new H(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ue(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?H.empty:new H(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ue(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ue(t.from,t.to,H.fromJSON(e,t.slice),!!t.structure)}}st.jsonID("replace",Ue);class Ke extends st{constructor(e,t,r,i,s,a,c=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=a,this.structure=c}apply(e){if(this.structure&&(vc(e,this.from,this.gapFrom)||vc(e,this.gapTo,this.to)))return Le.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Le.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?Le.fromReplace(e,this.from,this.to,r):Le.fail("Content does not fit in gap")}getMap(){return new At([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Ke(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new Ke(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ke(t.from,t.to,t.gapFrom,t.gapTo,H.fromJSON(e,t.slice),t.insert,!!t.structure)}}st.jsonID("replaceAround",Ke);function vc(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let a=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,i--}}return!1}function zE(n,e,t,r){let i=[],s=[],a,c;n.doc.nodesBetween(e,t,(u,d,h)=>{if(!u.isInline)return;let p=u.marks;if(!r.isInSet(p)&&h.type.allowsMarkType(r.type)){let y=Math.max(d,e),g=Math.min(d+u.nodeSize,t),_=r.addToSet(p);for(let w=0;w<p.length;w++)p[w].isInSet(_)||(a&&a.to==y&&a.mark.eq(p[w])?a.to=g:i.push(a=new ln(y,g,p[w])));c&&c.to==y?c.to=g:s.push(c=new jn(y,g,r))}}),i.forEach(u=>n.step(u)),s.forEach(u=>n.step(u))}function WE(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(a,c)=>{if(!a.isInline)return;s++;let u=null;if(r instanceof Wo){let d=a.marks,h;for(;h=r.isInSet(d);)(u||(u=[])).push(h),d=h.removeFromSet(d)}else r?r.isInSet(a.marks)&&(u=[r]):u=a.marks;if(u&&u.length){let d=Math.min(c+a.nodeSize,t);for(let h=0;h<u.length;h++){let p=u[h],y;for(let g=0;g<i.length;g++){let _=i[g];_.step==s-1&&p.eq(i[g].style)&&(y=_)}y?(y.to=d,y.step=s):i.push({style:p,from:Math.max(c,e),to:d,step:s})}}}),i.forEach(a=>n.step(new ln(a.from,a.to,a.style)))}function qc(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),a=[],c=e+1;for(let u=0;u<s.childCount;u++){let d=s.child(u),h=c+d.nodeSize,p=r.matchType(d.type);if(!p)a.push(new Ue(c,h,H.empty));else{r=p;for(let y=0;y<d.marks.length;y++)t.allowsMarkType(d.marks[y].type)||n.step(new ln(c,h,d.marks[y]));if(i&&d.isText&&t.whitespace!="pre"){let y,g=/\r?\n|\r/g,_;for(;y=g.exec(d.text);)_||(_=new H(D.from(t.schema.text(" ",t.allowedMarks(d.marks))),0,0)),a.push(new Ue(c+y.index,c+y.index+y[0].length,_))}}c=h}if(!r.validEnd){let u=r.fillBefore(D.empty,!0);n.replace(c,c,new H(u,0,0))}for(let u=a.length-1;u>=0;u--)n.step(a[u])}function VE(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function hi(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),s=n.$from.index(r),a=n.$to.indexAfter(r);if(r<n.depth&&i.canReplace(s,a,t))return r;if(r==0||i.type.spec.isolating||!VE(i,s,a))break}return null}function HE(n,e,t){let{$from:r,$to:i,depth:s}=e,a=r.before(s+1),c=i.after(s+1),u=a,d=c,h=D.empty,p=0;for(let _=s,w=!1;_>t;_--)w||r.index(_)>0?(w=!0,h=D.from(r.node(_).copy(h)),p++):u--;let y=D.empty,g=0;for(let _=s,w=!1;_>t;_--)w||i.after(_+1)<i.end(_)?(w=!0,y=D.from(i.node(_).copy(y)),g++):d++;n.step(new Ke(u,d,a,c,new H(h.append(y),p,g),h.size-p,!0))}function Jc(n,e,t=null,r=n){let i=UE(n,e),s=i&&KE(r,e);return s?i.map(Rh).concat({type:e,attrs:t}).concat(s.map(Rh)):null}function Rh(n){return{type:n,attrs:null}}function UE(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let a=s.length?s[0]:e;return t.canReplaceWith(r,i,a)?s:null}function KE(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.child(r),a=e.contentMatch.findWrapping(s.type);if(!a)return null;let u=(a.length?a[a.length-1]:e).contentMatch;for(let d=r;u&&d<i;d++)u=u.matchType(t.child(d).type);return!u||!u.validEnd?null:a}function jE(n,e,t){let r=D.empty;for(let a=t.length-1;a>=0;a--){if(r.size){let c=t[a].type.contentMatch.matchFragment(r);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=D.from(t[a].type.create(t[a].attrs,r))}let i=e.start,s=e.end;n.step(new Ke(i,s,i,s,new H(r,0,0),t.length,!0))}function qE(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(a,c)=>{let u=typeof i=="function"?i(a):i;if(a.isTextblock&&!a.hasMarkup(r,u)&&JE(n.doc,n.mapping.slice(s).map(c),r)){let d=null;if(r.schema.linebreakReplacement){let g=r.whitespace=="pre",_=!!r.contentMatch.matchType(r.schema.linebreakReplacement);g&&!_?d=!1:!g&&_&&(d=!0)}d===!1&&Qm(n,a,c,s),qc(n,n.mapping.slice(s).map(c,1),r,void 0,d===null);let h=n.mapping.slice(s),p=h.map(c,1),y=h.map(c+a.nodeSize,1);return n.step(new Ke(p,y,p+1,y-1,new H(D.from(r.create(u,null,a.marks)),0,0),1,!0)),d===!0&&Ym(n,a,c,s),!1}})}function Ym(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let a,c=/\r?\n|\r/g;for(;a=c.exec(i.text);){let u=n.mapping.slice(r).map(t+1+s+a.index);n.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function Qm(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let a=n.mapping.slice(r).map(t+1+s);n.replaceWith(a,a+1,e.type.schema.text(`
170
- `))}})}function JE(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function GE(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let a=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,a);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Ke(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new H(D.from(a),0,0),1,!0))}function Cn(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,a=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!a.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let d=i.depth-1,h=t-2;d>s;d--,h--){let p=i.node(d),y=i.index(d);if(p.type.spec.isolating)return!1;let g=p.content.cutByIndex(y,p.childCount),_=r&&r[h+1];_&&(g=g.replaceChild(0,_.type.create(_.attrs)));let w=r&&r[h]||p;if(!p.canReplace(y+1,p.childCount)||!w.type.validContent(g))return!1}let c=i.indexAfter(s),u=r&&r[0];return i.node(s).canReplaceWith(c,c,u?u.type:i.node(s+1).type)}function YE(n,e,t=1,r){let i=n.doc.resolve(e),s=D.empty,a=D.empty;for(let c=i.depth,u=i.depth-t,d=t-1;c>u;c--,d--){s=D.from(i.node(c).copy(s));let h=r&&r[d];a=D.from(h?h.type.create(h.attrs,a):i.node(c).copy(a))}n.step(new Ue(e,e,new H(s.append(a),t,t),!0))}function tr(n,e){let t=n.resolve(e),r=t.index();return Xm(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function QE(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),a=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(a),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function Xm(n,e){return!!(n&&e&&!n.isLeaf&&QE(n,e))}function Vo(n,e,t=-1){let r=n.resolve(e);for(let i=r.depth;;i--){let s,a,c=r.index(i);if(i==r.depth?(s=r.nodeBefore,a=r.nodeAfter):t>0?(s=r.node(i+1),c++,a=r.node(i).maybeChild(c)):(s=r.node(i).maybeChild(c-1),a=r.node(i+1)),s&&!s.isTextblock&&Xm(s,a)&&r.node(i).canReplace(c,c+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function XE(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(e-t),a=s.node().type;if(i&&a.inlineContent){let h=a.whitespace=="pre",p=!!a.contentMatch.matchType(i);h&&!p?r=!1:!h&&p&&(r=!0)}let c=n.steps.length;if(r===!1){let h=n.doc.resolve(e+t);Qm(n,h.node(),h.before(),c)}a.inlineContent&&qc(n,e+t-1,a,s.node().contentMatchAt(s.index()),r==null);let u=n.mapping.slice(c),d=u.map(e-t);if(n.step(new Ue(d,u.map(e+t,-1),H.empty,!0)),r===!0){let h=n.doc.resolve(d);Ym(n,h.node(),h.before(),n.steps.length)}return n}function ZE(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function Zm(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let a=r.depth;a>=0;a--){let c=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,u=r.index(a)+(c>0?1:0),d=r.node(a),h=!1;if(s==1)h=d.canReplace(u,u,i);else{let p=d.contentMatchAt(u).findWrapping(i.firstChild.type);h=p&&d.canReplaceWith(u,u,p[0])}if(h)return c==0?r.pos:c<0?r.before(a+1):r.after(a+1)}return null}function Ho(n,e,t=e,r=H.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return eg(i,s,r)?new Ue(e,t,r):new eO(i,s,r).fit()}function eg(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class eO{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=D.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=D.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,a=r.depth,c=i.depth;for(;a&&c&&s.childCount==1;)s=s.firstChild.content,a--,c--;let u=new H(s,a,c);return e>-1?new Ke(r.pos,e,this.$to.pos,this.$to.end(),u,t):u.size||r.pos!=this.$to.pos?new Ue(r.pos,i.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Ml(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let a=i.firstChild;for(let c=this.depth;c>=0;c--){let{type:u,match:d}=this.frontier[c],h,p=null;if(t==1&&(a?d.matchType(a.type)||(p=d.fillBefore(D.from(a),!1)):s&&u.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:c,parent:s,inject:p};if(t==2&&a&&(h=d.findWrapping(a.type)))return{sliceDepth:r,frontierDepth:c,parent:s,wrap:h};if(s&&d.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Ml(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new H(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Ml(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new H(Hi(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new H(Hi(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let w=0;w<s.length;w++)this.openFrontierNode(s[w]);let a=this.unplaced,c=r?r.content:a.content,u=a.openStart-e,d=0,h=[],{match:p,type:y}=this.frontier[t];if(i){for(let w=0;w<i.childCount;w++)h.push(i.child(w));p=p.matchFragment(i)}let g=c.size+e-(a.content.size-a.openEnd);for(;d<c.childCount;){let w=c.child(d),k=p.matchType(w.type);if(!k)break;d++,(d>1||u==0||w.content.size)&&(p=k,h.push(tg(w.mark(y.allowedMarks(w.marks)),d==1?u:0,d==c.childCount?g:-1)))}let _=d==c.childCount;_||(g=-1),this.placed=Ui(this.placed,t,D.from(h)),this.frontier[t].match=p,_&&g<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,k=c;w<g;w++){let A=k.lastChild;this.frontier.push({type:A.type,match:A.contentMatchAt(A.childCount)}),k=A.content}this.unplaced=_?e==0?H.empty:new H(Hi(a.content,e-1,1),e-1,g<0?a.openEnd:e-1):new H(Hi(a.content,e,d),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Nl(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=Nl(e,t,i,r,s);if(a){for(let c=t-1;c>=0;c--){let{match:u,type:d}=this.frontier[c],h=Nl(e,c,d,u,!0);if(!h||h.childCount)continue e}return{depth:t,fit:a,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Ui(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Ui(this.placed,this.depth,D.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(D.empty,!0);t.childCount&&(this.placed=Ui(this.placed,this.frontier.length,t))}}function Hi(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Hi(n.firstChild.content,e-1,t)))}function Ui(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Ui(n.lastChild.content,e-1,t)))}function Ml(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function tg(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,tg(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(D.empty,!0)))),n.copy(r)}function Nl(n,e,t,r,i){let s=n.node(e),a=i?n.indexAfter(e):n.index(e);if(a==s.childCount&&!t.compatibleContent(s.type))return null;let c=r.fillBefore(s.content,!0,a);return c&&!tO(t,s.content,a)?c:null}function tO(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function nO(n){return n.spec.defining||n.spec.definingForContent}function rO(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(eg(i,s,r))return n.step(new Ue(e,t,r));let a=rg(i,n.doc.resolve(t));a[a.length-1]==0&&a.pop();let c=-(i.depth+1);a.unshift(c);for(let y=i.depth,g=i.pos-1;y>0;y--,g--){let _=i.node(y).type.spec;if(_.defining||_.definingAsContext||_.isolating)break;a.indexOf(y)>-1?c=y:i.before(y)==g&&a.splice(1,0,-y)}let u=a.indexOf(c),d=[],h=r.openStart;for(let y=r.content,g=0;;g++){let _=y.firstChild;if(d.push(_),g==r.openStart)break;y=_.content}for(let y=h-1;y>=0;y--){let g=d[y],_=nO(g.type);if(_&&!g.sameMarkup(i.node(Math.abs(c)-1)))h=y;else if(_||!g.type.isTextblock)break}for(let y=r.openStart;y>=0;y--){let g=(y+h+1)%(r.openStart+1),_=d[g];if(_)for(let w=0;w<a.length;w++){let k=a[(w+u)%a.length],A=!0;k<0&&(A=!1,k=-k);let P=i.node(k-1),L=i.index(k-1);if(P.canReplaceWith(L,L,_.type,_.marks))return n.replace(i.before(k),A?s.after(k):t,new H(ng(r.content,0,r.openStart,g),g,r.openEnd))}}let p=n.steps.length;for(let y=a.length-1;y>=0&&(n.replace(e,t,r),!(n.steps.length>p));y--){let g=a[y];g<0||(e=i.before(g),t=s.after(g))}}function ng(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(ng(s.content,e+1,t,r,s)))}if(e>r){let s=i.contentMatchAt(0),a=s.fillBefore(n).append(n);n=a.append(s.matchFragment(a).fillBefore(D.empty,!0))}return n}function iO(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=ZE(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new H(D.from(r),0,0))}function sO(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),s=rg(r,i);for(let a=0;a<s.length;a++){let c=s[a],u=a==s.length-1;if(u&&c==0||r.node(c).type.contentMatch.validEnd)return n.delete(r.start(c),i.end(c));if(c>0&&(u||r.node(c-1).canReplace(r.index(c-1),i.indexAfter(c-1))))return n.delete(r.before(c),i.after(c))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(e-r.start(a)==r.depth-a&&t>r.end(a)&&i.end(a)-t!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return n.delete(r.before(a),t);n.delete(e,t)}function rg(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(s<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class ri extends st{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return Le.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return Le.fromReplace(e,this.pos,this.pos+1,new H(D.from(i),0,t.isLeaf?0:1))}getMap(){return At.empty}invert(e){return new ri(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ri(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ri(t.pos,t.attr,t.value)}}st.jsonID("attr",ri);class ts extends st{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return Le.ok(r)}getMap(){return At.empty}invert(e){return new ts(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new ts(t.attr,t.value)}}st.jsonID("docAttr",ts);let li=class extends Error{};li=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};li.prototype=Object.create(Error.prototype);li.prototype.constructor=li;li.prototype.name="TransformError";class oO{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new es}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new li(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=H.empty){let i=Ho(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new H(D.from(r),0,0))}delete(e,t){return this.replace(e,t,H.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return rO(this,e,t,r),this}replaceRangeWith(e,t,r){return iO(this,e,t,r),this}deleteRange(e,t){return sO(this,e,t),this}lift(e,t){return HE(this,e,t),this}join(e,t=1){return XE(this,e,t),this}wrap(e,t){return jE(this,e,t),this}setBlockType(e,t=e,r,i=null){return qE(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return GE(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new ri(e,t,r)),this}setDocAttribute(e,t){return this.step(new ts(e,t)),this}addNodeMark(e,t){return this.step(new qn(e,t)),this}removeNodeMark(e,t){if(!(t instanceof we)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new ai(e,t)),this}split(e,t=1,r){return YE(this,e,t,r),this}addMark(e,t,r){return zE(this,e,t,r),this}removeMark(e,t,r){return WE(this,e,t,r),this}clearIncompatible(e,t,r){return qc(this,e,t,r),this}}const Il=Object.create(null);class ae{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new aO(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=H.empty){let r=t.content.lastChild,i=null;for(let c=0;c<t.openEnd;c++)i=r,r=r.lastChild;let s=e.steps.length,a=this.ranges;for(let c=0;c<a.length;c++){let{$from:u,$to:d}=a[c],h=e.mapping.slice(s);e.replaceRange(h.map(u.pos),h.map(d.pos),c?H.empty:t),c==0&&Bh(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:a,$to:c}=i[s],u=e.mapping.slice(r),d=u.map(a.pos),h=u.map(c.pos);s?e.deleteRange(d,h):(e.replaceRangeWith(d,h,t),Bh(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new re(e):Xr(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let a=t<0?Xr(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):Xr(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(a)return a}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Ct(e.node(0))}static atStart(e){return Xr(e,e,0,0,1)||new Ct(e)}static atEnd(e){return Xr(e,e,e.content.size,e.childCount,-1)||new Ct(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Il[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Il)throw new RangeError("Duplicate use of selection JSON ID "+e);return Il[e]=t,t.prototype.jsonID=e,t}getBookmark(){return re.between(this.$anchor,this.$head).getBookmark()}}ae.prototype.visible=!0;class aO{constructor(e,t){this.$from=e,this.$to=t}}let Dh=!1;function Lh(n){!Dh&&!n.parent.inlineContent&&(Dh=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class re extends ae{constructor(e,t=e){Lh(e),Lh(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return ae.near(r);let i=e.resolve(t.map(this.anchor));return new re(i.parent.inlineContent?i:r,r)}replace(e,t=H.empty){if(super.replace(e,t),t==H.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof re&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Uo(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new re(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=ae.findFrom(t,r,!0)||ae.findFrom(t,-r,!0);if(s)t=s.$head;else return ae.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(ae.findFrom(e,-r,!0)||ae.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new re(e,t)}}ae.jsonID("text",re);class Uo{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Uo(e.map(this.anchor),e.map(this.head))}resolve(e){return re.between(e.resolve(this.anchor),e.resolve(this.head))}}class Q extends ae{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return r?ae.near(s):new Q(s)}content(){return new H(D.from(this.node),0,0)}eq(e){return e instanceof Q&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Gc(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Q(e.resolve(t.anchor))}static create(e,t){return new Q(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Q.prototype.visible=!1;ae.jsonID("node",Q);class Gc{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Uo(r,r):new Gc(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&Q.isSelectable(r)?new Q(t):ae.near(t)}}class Ct extends ae{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=H.empty){if(t==H.empty){e.delete(0,e.doc.content.size);let r=ae.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ct(e)}map(e){return new Ct(e)}eq(e){return e instanceof Ct}getBookmark(){return lO}}ae.jsonID("all",Ct);const lO={map(){return this},resolve(n){return new Ct(n)}};function Xr(n,e,t,r,i,s=!1){if(e.inlineContent)return re.create(n,t);for(let a=r-(i>0?0:1);i>0?a<e.childCount:a>=0;a+=i){let c=e.child(a);if(c.isAtom){if(!s&&Q.isSelectable(c))return Q.create(n,t-(i<0?c.nodeSize:0))}else{let u=Xr(n,c,t+i,i<0?c.childCount:0,i,s);if(u)return u}t+=c.nodeSize*i}return null}function Bh(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof Ue||i instanceof Ke))return;let s=n.mapping.maps[r],a;s.forEach((c,u,d,h)=>{a==null&&(a=h)}),n.setSelection(ae.near(n.doc.resolve(a),t))}const Fh=1,$h=2,zh=4;class cO extends oO{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|Fh)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&Fh)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=$h,this}ensureMarks(e){return we.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&$h)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||we.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let a=this.doc.resolve(t);s=r==t?a.marks():a.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,s)),this.selection.empty||this.setSelection(ae.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=zh,this}get scrolledIntoView(){return(this.updated&zh)>0}}function Wh(n,e){return!e||!n?n:n.bind(e)}class Ki{constructor(e,t,r){this.name=e,this.init=Wh(t.init,r),this.apply=Wh(t.apply,r)}}const uO=[new Ki("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Ki("selection",{init(n,e){return n.selection||ae.atStart(e.doc)},apply(n){return n.selection}}),new Ki("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Ki("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Pl{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=uO.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Ki(r.key,r.spec.state,r))})}}class ei{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let a=0;a<this.config.plugins.length;a++){let c=this.config.plugins[a];if(c.spec.appendTransaction){let u=i?i[a].n:0,d=i?i[a].state:this,h=u<t.length&&c.spec.appendTransaction.call(c,u?t.slice(u):t,d,r);if(h&&r.filterTransaction(h,a)){if(h.setMeta("appendedTransaction",e),!i){i=[];for(let p=0;p<this.config.plugins.length;p++)i.push(p<a?{state:r,n:t.length}:{state:this,n:0})}t.push(h),r=r.applyInner(h),s=!0}i&&(i[a]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new ei(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new cO(this)}static create(e){let t=new Pl(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new ei(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new Pl(this.schema,e.plugins),r=t.fields,i=new ei(t);for(let s=0;s<r.length;s++){let a=r[s].name;i[a]=this.hasOwnProperty(a)?this[a]:r[s].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Pl(e.schema,e.plugins),s=new ei(i);return i.fields.forEach(a=>{if(a.name=="doc")s.doc=Gn.fromJSON(e.schema,t.doc);else if(a.name=="selection")s.selection=ae.fromJSON(s.doc,t.selection);else if(a.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let c in r){let u=r[c],d=u.spec.state;if(u.key==a.name&&d&&d.fromJSON&&Object.prototype.hasOwnProperty.call(t,c)){s[a.name]=d.fromJSON.call(u,e,t[c],s);return}}s[a.name]=a.init(e,s)}}),s}}function ig(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=ig(i,e,{})),t[r]=i}return t}class St{constructor(e){this.spec=e,this.props={},e.props&&ig(e.props,this,this.props),this.key=e.key?e.key.key:sg("plugin")}getState(e){return e[this.key]}}const Rl=Object.create(null);function sg(n){return n in Rl?n+"$"+ ++Rl[n]:(Rl[n]=0,n+"$")}class fn{constructor(e="key"){this.key=sg(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Xe=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},ci=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Sc=null;const xn=function(n,e,t){let r=Sc||(Sc=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},fO=function(){Sc=null},Tr=function(n,e,t,r){return t&&(Vh(n,e,t,r,-1)||Vh(n,e,t,r,1))},dO=/^(img|br|input|textarea|hr)$/i;function Vh(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:zt(n))){let s=n.parentNode;if(!s||s.nodeType!=1||cs(n)||dO.test(n.nodeName)||n.contentEditable=="false")return!1;e=Xe(n)+(i<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?zt(n):0}else return!1}}function zt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function hO(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=zt(n)}else if(n.parentNode&&!cs(n))e=Xe(n),n=n.parentNode;else return null}}function pO(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!cs(n))e=Xe(n)+1,n=n.parentNode;else return null}}function mO(n,e,t){for(let r=e==0,i=e==zt(n);r||i;){if(n==t)return!0;let s=Xe(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,i=i&&s==zt(n)}}function cs(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Ko=function(n){return n.focusNode&&Tr(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function pr(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function gO(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function yO(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(zt(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(zt(r.startContainer),r.startOffset)}}}const cn=typeof navigator<"u"?navigator:null,Hh=typeof document<"u"?document:null,nr=cn&&cn.userAgent||"",wc=/Edge\/(\d+)/.exec(nr),og=/MSIE \d/.exec(nr),kc=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nr),bt=!!(og||kc||wc),Qn=og?document.documentMode:kc?+kc[1]:wc?+wc[1]:0,en=!bt&&/gecko\/(\d+)/i.test(nr);en&&+(/Firefox\/(\d+)/.exec(nr)||[0,0])[1];const xc=!bt&&/Chrome\/(\d+)/.exec(nr),rt=!!xc,ag=xc?+xc[1]:0,ft=!bt&&!!cn&&/Apple Computer/.test(cn.vendor),ui=ft&&(/Mobile\/\w+/.test(nr)||!!cn&&cn.maxTouchPoints>2),$t=ui||(cn?/Mac/.test(cn.platform):!1),_O=cn?/Win/.test(cn.platform):!1,On=/Android \d/.test(nr),us=!!Hh&&"webkitFontSmoothing"in Hh.documentElement.style,bO=us?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function vO(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function kn(n,e){return typeof n=="number"?n:n[e]}function SO(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Uh(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let a=t||n.dom;a;){if(a.nodeType!=1){a=ci(a);continue}let c=a,u=c==s.body,d=u?vO(s):SO(c),h=0,p=0;if(e.top<d.top+kn(r,"top")?p=-(d.top-e.top+kn(i,"top")):e.bottom>d.bottom-kn(r,"bottom")&&(p=e.bottom-e.top>d.bottom-d.top?e.top+kn(i,"top")-d.top:e.bottom-d.bottom+kn(i,"bottom")),e.left<d.left+kn(r,"left")?h=-(d.left-e.left+kn(i,"left")):e.right>d.right-kn(r,"right")&&(h=e.right-d.right+kn(i,"right")),h||p)if(u)s.defaultView.scrollBy(h,p);else{let g=c.scrollLeft,_=c.scrollTop;p&&(c.scrollTop+=p),h&&(c.scrollLeft+=h);let w=c.scrollLeft-g,k=c.scrollTop-_;e={left:e.left-w,top:e.top-k,right:e.right-w,bottom:e.bottom-k}}let y=u?"fixed":getComputedStyle(a).position;if(/^(fixed|sticky)$/.test(y))break;a=y=="absolute"?a.offsetParent:ci(a)}}function wO(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,a=t+1;a<Math.min(innerHeight,e.bottom);a+=5){let c=n.root.elementFromPoint(s,a);if(!c||c==n.dom||!n.dom.contains(c))continue;let u=c.getBoundingClientRect();if(u.top>=t-20){r=c,i=u.top;break}}return{refDOM:r,refTop:i,stack:lg(n.dom)}}function lg(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=ci(r));return e}function kO({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;cg(t,r==0?0:r-e)}function cg(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:s}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let Gr=null;function xO(n){if(n.setActive)return n.setActive();if(Gr)return n.focus(Gr);let e=lg(n);n.focus(Gr==null?{get preventScroll(){return Gr={preventScroll:!0},!0}}:void 0),Gr||(Gr=!1,cg(e,0))}function ug(n,e){let t,r=2e8,i,s=0,a=e.top,c=e.top,u,d;for(let h=n.firstChild,p=0;h;h=h.nextSibling,p++){let y;if(h.nodeType==1)y=h.getClientRects();else if(h.nodeType==3)y=xn(h).getClientRects();else continue;for(let g=0;g<y.length;g++){let _=y[g];if(_.top<=a&&_.bottom>=c){a=Math.max(_.bottom,a),c=Math.min(_.top,c);let w=_.left>e.left?_.left-e.left:_.right<e.left?e.left-_.right:0;if(w<r){t=h,r=w,i=w&&t.nodeType==3?{left:_.right<e.left?_.right:_.left,top:e.top}:e,h.nodeType==1&&w&&(s=p+(e.left>=(_.left+_.right)/2?1:0));continue}}else _.top>e.top&&!u&&_.left<=e.left&&_.right>=e.left&&(u=h,d={left:Math.max(_.left,Math.min(_.right,e.left)),top:_.top});!t&&(e.left>=_.right&&e.top>=_.top||e.left>=_.left&&e.top>=_.bottom)&&(s=p+1)}}return!t&&u&&(t=u,i=d,r=0),t&&t.nodeType==3?EO(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:ug(t,i)}function EO(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let s=Vn(r,1);if(s.top!=s.bottom&&Yc(e,s))return{node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function Yc(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function OO(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function TO(n,e,t){let{node:r,offset:i}=ug(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let a=r.getBoundingClientRect();s=a.left!=a.right&&t.left>(a.left+a.right)/2?1:-1}return n.docView.posFromDOM(r,i,s)}function AO(n,e,t,r){let i=-1;for(let s=e,a=!1;s!=n.dom;){let c=n.docView.nearestDesc(s,!0),u;if(!c)return null;if(c.dom.nodeType==1&&(c.node.isBlock&&c.parent||!c.contentDOM)&&((u=c.dom.getBoundingClientRect()).width||u.height)&&(c.node.isBlock&&c.parent&&(!a&&u.left>r.left||u.top>r.top?i=c.posBefore:(!a&&u.right<r.left||u.bottom<r.top)&&(i=c.posAfter),a=!0),!c.contentDOM&&i<0&&!c.node.isText))return(c.node.isBlock?r.top<(u.top+u.bottom)/2:r.left<(u.left+u.right)/2)?c.posBefore:c.posAfter;s=c.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function fg(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let a=n.childNodes[s];if(a.nodeType==1){let c=a.getClientRects();for(let u=0;u<c.length;u++){let d=c[u];if(Yc(e,d))return fg(a,e,d)}}if((s=(s+1)%r)==i)break}return n}function CO(n,e){let t=n.dom.ownerDocument,r,i=0,s=yO(t,e.left,e.top);s&&({node:r,offset:i}=s);let a=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),c;if(!a||!n.dom.contains(a.nodeType!=1?a.parentNode:a)){let d=n.dom.getBoundingClientRect();if(!Yc(e,d)||(a=fg(n.dom,e,d),!a))return null}if(ft)for(let d=a;r&&d;d=ci(d))d.draggable&&(r=void 0);if(a=OO(a,e),r){if(en&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let h=r.childNodes[i],p;h.nodeName=="IMG"&&(p=h.getBoundingClientRect()).right<=e.left&&p.bottom>e.top&&i++}let d;us&&i&&r.nodeType==1&&(d=r.childNodes[i-1]).nodeType==1&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?c=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(c=AO(n,r,i,e))}c==null&&(c=TO(n,a,e));let u=n.docView.nearestDesc(a,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function Kh(n){return n.top<n.bottom||n.left<n.right}function Vn(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Kh(r))return r}return Array.prototype.find.call(t,Kh)||n.getBoundingClientRect()}const MO=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function dg(n,e,t){let{node:r,offset:i,atom:s}=n.docView.domFromPos(e,t<0?-1:1),a=us||en;if(r.nodeType==3)if(a&&(MO.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let u=Vn(xn(r,i,i),t);if(en&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let d=Vn(xn(r,i-1,i-1),-1);if(d.top==u.top){let h=Vn(xn(r,i,i+1),-1);if(h.top!=u.top)return Wi(h,h.left<d.left)}}return u}else{let u=i,d=i,h=t<0?1:-1;return t<0&&!i?(d++,h=-1):t>=0&&i==r.nodeValue.length?(u--,h=1):t<0?u--:d++,Wi(Vn(xn(r,u,d),h),h<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==zt(r))){let u=r.childNodes[i-1];if(u.nodeType==1)return Dl(u.getBoundingClientRect(),!1)}if(s==null&&i<zt(r)){let u=r.childNodes[i];if(u.nodeType==1)return Dl(u.getBoundingClientRect(),!0)}return Dl(r.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==zt(r))){let u=r.childNodes[i-1],d=u.nodeType==3?xn(u,zt(u)-(a?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(d)return Wi(Vn(d,1),!1)}if(s==null&&i<zt(r)){let u=r.childNodes[i];for(;u.pmViewDesc&&u.pmViewDesc.ignoreForCoords;)u=u.nextSibling;let d=u?u.nodeType==3?xn(u,0,a?0:1):u.nodeType==1?u:null:null;if(d)return Wi(Vn(d,-1),!0)}return Wi(Vn(r.nodeType==3?xn(r):r,-t),t>=0)}function Wi(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Dl(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function hg(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function NO(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return hg(n,e,()=>{let{node:s}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let c=n.docView.nearestDesc(s,!0);if(!c)break;if(c.node.isBlock){s=c.contentDOM||c.dom;break}s=c.dom.parentNode}let a=dg(n,i.pos,1);for(let c=s.firstChild;c;c=c.nextSibling){let u;if(c.nodeType==1)u=c.getClientRects();else if(c.nodeType==3)u=xn(c,0,c.nodeValue.length).getClientRects();else continue;for(let d=0;d<u.length;d++){let h=u[d];if(h.bottom>h.top+1&&(t=="up"?a.top-h.top>(h.bottom-a.top)*2:h.bottom-a.bottom>(a.bottom-h.top)*2))return!1}}return!0})}const IO=/[\u0590-\u08ac]/;function PO(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,a=i==r.parent.content.size,c=n.domSelection();return c?!IO.test(r.parent.textContent)||!c.modify?t=="left"||t=="backward"?s:a:hg(n,e,()=>{let{focusNode:u,focusOffset:d,anchorNode:h,anchorOffset:p}=n.domSelectionRange(),y=c.caretBidiLevel;c.modify("move",t,"character");let g=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:_,focusOffset:w}=n.domSelectionRange(),k=_&&!g.contains(_.nodeType==1?_:_.parentNode)||u==_&&d==w;try{c.collapse(h,p),u&&(u!=h||d!=p)&&c.extend&&c.extend(u,d)}catch{}return y!=null&&(c.caretBidiLevel=y),k}):r.pos==r.start()||r.pos==r.end()}let jh=null,qh=null,Jh=!1;function RO(n,e,t){return jh==e&&qh==t?Jh:(jh=e,qh=t,Jh=t=="up"||t=="down"?NO(n,e,t):PO(n,e,t))}const Ut=0,Gh=1,yr=2,un=3;class fs{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Ut,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let i=this.children[t];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,a;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((a=s.pmViewDesc)&&a.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(a)+a.size:this.posAtStart}else{let s,a;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((a=s.pmViewDesc)&&a.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(a):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>Xe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),a;if(s&&(!t||s.node))if(r&&(a=s.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let a=0;a<i.children.length;a++){let c=i.children[a];if(c.size){i=c;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let a=this.children[r],c=s+a.size;if(c>e||a instanceof mg){i=e-s;break}s=c}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof pg&&s.side>=0;r--);if(t<=0){let s,a=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,a=!1);return s&&t&&a&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Xe(s.dom)+1:0}}else{let s,a=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,a=!1);return s&&a&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Xe(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let a=r,c=0;;c++){let u=this.children[c],d=a+u.size;if(i==-1&&e<=d){let h=a+u.border;if(e>=h&&t<=d-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,t,h);e=a;for(let p=c;p>0;p--){let y=this.children[p-1];if(y.size&&y.dom.parentNode==this.contentDOM&&!y.emptyChildAt(1)){i=Xe(y.dom)+1;break}e-=y.size}i==-1&&(i=0)}if(i>-1&&(d>t||c==this.children.length-1)){t=d;for(let h=c+1;h<this.children.length;h++){let p=this.children[h];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(-1)){s=Xe(p.dom);break}t+=p.size}s==-1&&(s=this.contentDOM.childNodes.length);break}a=d}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,i=!1){let s=Math.min(e,t),a=Math.max(e,t);for(let g=0,_=0;g<this.children.length;g++){let w=this.children[g],k=_+w.size;if(s>_&&a<k)return w.setSelection(e-_-w.border,t-_-w.border,r,i);_=k}let c=this.domFromPos(e,e?-1:1),u=t==e?c:this.domFromPos(t,t?-1:1),d=r.root.getSelection(),h=r.domSelectionRange(),p=!1;if((en||ft)&&e==t){let{node:g,offset:_}=c;if(g.nodeType==3){if(p=!!(_&&g.nodeValue[_-1]==`
171
- `),p&&_==g.nodeValue.length)for(let w=g,k;w;w=w.parentNode){if(k=w.nextSibling){k.nodeName=="BR"&&(c=u={node:k.parentNode,offset:Xe(k)+1});break}let A=w.pmViewDesc;if(A&&A.node&&A.node.isBlock)break}}else{let w=g.childNodes[_-1];p=w&&(w.nodeName=="BR"||w.contentEditable=="false")}}if(en&&h.focusNode&&h.focusNode!=u.node&&h.focusNode.nodeType==1){let g=h.focusNode.childNodes[h.focusOffset];g&&g.contentEditable=="false"&&(i=!0)}if(!(i||p&&ft)&&Tr(c.node,c.offset,h.anchorNode,h.anchorOffset)&&Tr(u.node,u.offset,h.focusNode,h.focusOffset))return;let y=!1;if((d.extend||e==t)&&!p){d.collapse(c.node,c.offset);try{e!=t&&d.extend(u.node,u.offset),y=!0}catch{}}if(!y){if(e>t){let _=c;c=u,u=_}let g=document.createRange();g.setEnd(u.node,u.offset),g.setStart(c.node,c.offset),d.removeAllRanges(),d.addRange(g)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],a=r+s.size;if(r==a?e<=a&&t>=r:e<a&&t>r){let c=r+s.border,u=a-s.border;if(e>=c&&t<=u){this.dirty=e==r||t==a?yr:Gh,e==c&&t==u&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=un:s.markDirty(e-c,t-c);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?yr:un}r=a}this.dirty=yr}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?yr:Gh;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class pg extends fs{constructor(e,t,r,i){let s,a=t.type.toDOM;if(typeof a=="function"&&(a=a(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(a.nodeType!=1){let c=document.createElement("span");c.appendChild(a),a=c}a.contentEditable="false",a.classList.add("ProseMirror-widget")}super(e,[],a,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Ut&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class DO extends fs{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Ar extends fs{constructor(e,t,r,i,s){super(e,[],r,i),this.mark=t,this.spec=s}static create(e,t,r,i){let s=i.nodeViews[t.type.name],a=s&&s(t,i,r);return(!a||!a.dom)&&(a=Nr.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Ar(e,t,a.dom,a.contentDOM||a.dom,a)}parseRule(){return this.dirty&un||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=un&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ut){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ut}}slice(e,t,r){let i=Ar.create(this.parent,this.mark,!0,r),s=this.children,a=this.size;t<a&&(s=Oc(s,t,a,r)),e>0&&(s=Oc(s,0,e,r));for(let c=0;c<s.length;c++)s[c].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Xn extends fs{constructor(e,t,r,i,s,a,c,u,d){super(e,[],s,a),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=c}static create(e,t,r,i,s,a){let c=s.nodeViews[t.type.name],u,d=c&&c(t,s,()=>{if(!u)return a;if(u.parent)return u.parent.posBeforeChild(u)},r,i),h=d&&d.dom,p=d&&d.contentDOM;if(t.isText){if(!h)h=document.createTextNode(t.text);else if(h.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else h||({dom:h,contentDOM:p}=Nr.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!p&&!t.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),t.type.spec.draggable&&(h.draggable=!0));let y=h;return h=_g(h,r,t),d?u=new LO(e,t,r,i,h,p||null,y,d,s,a+1):t.isText?new jo(e,t,r,i,h,y,s):new Xn(e,t,r,i,h,p||null,y,s,a+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>D.empty)}return e}matchesNode(e,t,r){return this.dirty==Ut&&e.eq(this.node)&&No(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,a=s&&s.pos>-1?s:null,c=s&&s.pos<0,u=new FO(this,a&&a.node,e);WO(this.node,this.innerDeco,(d,h,p)=>{d.spec.marks?u.syncToMarks(d.spec.marks,r,e):d.type.side>=0&&!p&&u.syncToMarks(h==this.node.childCount?we.none:this.node.child(h).marks,r,e),u.placeWidget(d,e,i)},(d,h,p,y)=>{u.syncToMarks(d.marks,r,e);let g;u.findNodeMatch(d,h,p,y)||c&&e.state.selection.from>i&&e.state.selection.to<i+d.nodeSize&&(g=u.findIndexWithChild(s.node))>-1&&u.updateNodeAt(d,h,p,g,e)||u.updateNextNode(d,h,p,e,y,i)||u.addNode(d,h,p,e,i),i+=d.nodeSize}),u.syncToMarks([],r,e),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==yr)&&(a&&this.protectLocalComposition(e,a),gg(this.contentDOM,this.children,e),ui&&VO(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof re)||r<t||i>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let a=s.nodeValue,c=HO(this.node.content,a,r-t,i-t);return c<0?null:{node:s,pos:c,text:a}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let a=new DO(this,s,t,i);e.input.compositionNodes.push(a),this.children=Oc(this.children,r,r+i.length,e,a)}update(e,t,r,i){return this.dirty==un||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Ut}updateOuterDeco(e){if(No(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=yg(this.dom,this.nodeDOM,Ec(this.outerDeco,this.node,t),Ec(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Yh(n,e,t,r,i){_g(r,e,n);let s=new Xn(void 0,n,e,t,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class jo extends Xn{constructor(e,t,r,i,s,a,c){super(e,t,r,i,s,null,a,c,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==un||this.dirty!=Ut&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ut||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Ut,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new jo(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=un)}get domAtom(){return!1}isText(e){return this.node.text==e}}class mg extends fs{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ut&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class LO extends Xn{constructor(e,t,r,i,s,a,c,u,d,h){super(e,t,r,i,s,a,c,d,h),this.spec=u}update(e,t,r,i){if(this.dirty==un)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}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 gg(n,e,t){let r=n.firstChild,i=!1;for(let s=0;s<e.length;s++){let a=e[s],c=a.dom;if(c.parentNode==n){for(;c!=r;)r=Qh(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(c,r);if(a instanceof Ar){let u=r?r.previousSibling:n.lastChild;gg(a.contentDOM,a.children,t),r=u?u.nextSibling:n.firstChild}}for(;r;)r=Qh(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const Ji=function(n){n&&(this.nodeName=n)};Ji.prototype=Object.create(null);const _r=[new Ji];function Ec(n,e,t){if(n.length==0)return _r;let r=t?_r[0]:new Ji,i=[r];for(let s=0;s<n.length;s++){let a=n[s].type.attrs;if(a){a.nodeName&&i.push(r=new Ji(a.nodeName));for(let c in a){let u=a[c];u!=null&&(t&&i.length==1&&i.push(r=new Ji(e.isInline?"span":"div")),c=="class"?r.class=(r.class?r.class+" ":"")+u:c=="style"?r.style=(r.style?r.style+";":"")+u:c!="nodeName"&&(r[c]=u))}}}return i}function yg(n,e,t,r){if(t==_r&&r==_r)return e;let i=e;for(let s=0;s<r.length;s++){let a=r[s],c=t[s];if(s){let u;c&&c.nodeName==a.nodeName&&i!=n&&(u=i.parentNode)&&u.nodeName.toLowerCase()==a.nodeName||(u=document.createElement(a.nodeName),u.pmIsDeco=!0,u.appendChild(i),c=_r[0]),i=u}BO(i,c||_r[0],a)}return i}function BO(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&n.classList.add(i[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function _g(n,e,t){return yg(n,n,_r,Ec(e,t,n.nodeType!=1))}function No(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Qh(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class FO{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=$O(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let i=0,s=this.stack.length>>1,a=Math.min(s,e.length);for(;i<a&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=Ut,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let c=-1;for(let u=this.index;u<Math.min(this.index+3,this.top.children.length);u++){let d=this.top.children[u];if(d.matchesMark(e[s])&&!this.isLocked(d.dom)){c=u;break}}if(c>-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let u=Ar.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,i){let s=-1,a;if(i>=this.preMatch.index&&(a=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,r))s=this.top.children.indexOf(a,this.index);else for(let c=this.index,u=Math.min(this.top.children.length,c+5);c<u;c++){let d=this.top.children[c];if(d.matchesNode(e,t,r)&&!this.preMatch.matched.has(d)){s=c;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,i,s){let a=this.top.children[i];return a.dirty==un&&a.dom==a.contentDOM&&(a.dirty=yr),a.update(e,t,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=t}}updateNextNode(e,t,r,i,s,a){for(let c=this.index;c<this.top.children.length;c++){let u=this.top.children[c];if(u instanceof Xn){let d=this.preMatch.matched.get(u);if(d!=null&&d!=s)return!1;let h=u.dom,p,y=this.isLocked(h)&&!(e.isText&&u.node&&u.node.isText&&u.nodeDOM.nodeValue==e.text&&u.dirty!=un&&No(t,u.outerDeco));if(!y&&u.update(e,t,r,i))return this.destroyBetween(this.index,c),u.dom!=h&&(this.changed=!0),this.index++,!0;if(!y&&(p=this.recreateWrapper(u,e,t,r,i,a)))return this.destroyBetween(this.index,c),this.top.children[this.index]=p,p.contentDOM&&(p.dirty=yr,p.updateChildren(i,a+1),p.dirty=Ut),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,i,s,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!No(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let c=Xn.create(this.top,t,r,i,s,a);if(c.contentDOM){c.children=e.children,e.children=[];for(let u of c.children)u.parent=c}return e.destroy(),c}addNode(e,t,r,i,s){let a=Xn.create(this.top,e,t,r,i,s);a.contentDOM&&a.updateChildren(i,s+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,t,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new pg(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Ar;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof jo)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ft||rt)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new mg(this.top,[],r,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function $O(n,e){let t=e,r=t.children.length,i=n.childCount,s=new Map,a=[];e:for(;i>0;){let c;for(;;)if(r){let d=t.children[r-1];if(d instanceof Ar)t=d,r=d.children.length;else{c=d,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let u=c.node;if(u){if(u!=n.child(i-1))break;--i,s.set(c,i),a.push(c)}}return{index:i,matched:s,matches:a.reverse()}}function zO(n,e){return n.type.side-e.type.side}function WO(n,e,t,r){let i=e.locals(n),s=0;if(i.length==0){for(let d=0;d<n.childCount;d++){let h=n.child(d);r(h,i,e.forChild(s,h),d),s+=h.nodeSize}return}let a=0,c=[],u=null;for(let d=0;;){let h,p;for(;a<i.length&&i[a].to==s;){let k=i[a++];k.widget&&(h?(p||(p=[h])).push(k):h=k)}if(h)if(p){p.sort(zO);for(let k=0;k<p.length;k++)t(p[k],d,!!u)}else t(h,d,!!u);let y,g;if(u)g=-1,y=u,u=null;else if(d<n.childCount)g=d,y=n.child(d++);else break;for(let k=0;k<c.length;k++)c[k].to<=s&&c.splice(k--,1);for(;a<i.length&&i[a].from<=s&&i[a].to>s;)c.push(i[a++]);let _=s+y.nodeSize;if(y.isText){let k=_;a<i.length&&i[a].from<k&&(k=i[a].from);for(let A=0;A<c.length;A++)c[A].to<k&&(k=c[A].to);k<_&&(u=y.cut(k-s),y=y.cut(0,k-s),_=k,g=-1)}else for(;a<i.length&&i[a].to<_;)a++;let w=y.isInline&&!y.isLeaf?c.filter(k=>!k.inline):c.slice();r(y,w,e.forChild(s,y),g),s=_}}function VO(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function HO(n,e,t,r){for(let i=0,s=0;i<n.childCount&&s<=r;){let a=n.child(i++),c=s;if(s+=a.nodeSize,!a.isText)continue;let u=a.text;for(;i<n.childCount;){let d=n.child(i++);if(s+=d.nodeSize,!d.isText)break;u+=d.text}if(s>=t){if(s>=r&&u.slice(r-e.length-c,r-c)==e)return r-e.length;let d=c<r?u.lastIndexOf(e,r-c-1):-1;if(d>=0&&d+e.length+c>=t)return c+d;if(t==r&&u.length>=r+e.length-c&&u.slice(r-c,r-c+e.length)==e)return r}}return-1}function Oc(n,e,t,r,i){let s=[];for(let a=0,c=0;a<n.length;a++){let u=n[a],d=c,h=c+=u.size;d>=t||h<=e?s.push(u):(d<e&&s.push(u.slice(0,e-d,r)),i&&(s.push(i),i=void 0),h>t&&s.push(u.slice(t-d,u.size,r)))}return s}function Qc(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,a=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(a<0)return null;let c=r.resolve(a),u,d;if(Ko(t)){for(u=a;i&&!i.node;)i=i.parent;let p=i.node;if(i&&p.isAtom&&Q.isSelectable(p)&&i.parent&&!(p.isInline&&mO(t.focusNode,t.focusOffset,i.dom))){let y=i.posBefore;d=new Q(a==y?c:r.resolve(y))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let p=a,y=a;for(let g=0;g<t.rangeCount;g++){let _=t.getRangeAt(g);p=Math.min(p,n.docView.posFromDOM(_.startContainer,_.startOffset,1)),y=Math.max(y,n.docView.posFromDOM(_.endContainer,_.endOffset,-1))}if(p<0)return null;[u,a]=y==n.state.selection.anchor?[y,p]:[p,y],c=r.resolve(a)}else u=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(u<0)return null}let h=r.resolve(u);if(!d){let p=e=="pointer"||n.state.selection.head<c.pos&&!s?1:-1;d=Xc(n,h,c,p)}return d}function bg(n){return n.editable?n.hasFocus():Sg(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Mn(n,e=!1){let t=n.state.selection;if(vg(n,t),!!bg(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&rt){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Tr(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)KO(n);else{let{anchor:r,head:i}=t,s,a;Xh&&!(t instanceof re)&&(t.$from.parent.inlineContent||(s=Zh(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(a=Zh(n,t.to))),n.docView.setSelection(r,i,n,e),Xh&&(s&&ep(s),a&&ep(a)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&UO(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Xh=ft||rt&&ag<63;function Zh(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(ft&&i&&i.contentEditable=="false")return Ll(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Ll(i);if(s)return Ll(s)}}function Ll(n){return n.contentEditable="true",ft&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function ep(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function UO(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!bg(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function KO(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,i=r.nodeName=="IMG";i?t.setStart(r.parentNode,Xe(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&bt&&Qn<=11&&(r.disabled=!0,r.disabled=!1)}function vg(n,e){if(e instanceof Q){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(tp(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else tp(n)}function tp(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Xc(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||re.between(e,t,r)}function np(n){return n.editable&&!n.hasFocus()?!1:Sg(n)}function Sg(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function jO(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Tr(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Tc(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&ae.findFrom(s,e)}function Hn(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function rp(n,e,t){let r=n.state.selection;if(r instanceof re)if(t.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let a=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Hn(n,new re(r.$anchor,a))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Tc(n.state,e);return i&&i instanceof Q?Hn(n,i):!1}else if(!($t&&t.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,a;if(!s||s.isText)return!1;let c=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(a=n.docView.descAt(c))&&!a.contentDOM?Q.isSelectable(s)?Hn(n,new Q(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):us?Hn(n,new re(n.state.doc.resolve(e<0?c:c+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Q&&r.node.isInline)return Hn(n,new re(e>0?r.$to:r.$from));{let i=Tc(n.state,e);return i?Hn(n,i):!1}}}function Io(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Gi(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Yr(n,e){return e<0?qO(n):JO(n)}function qO(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,a=!1;for(en&&t.nodeType==1&&r<Io(t)&&Gi(t.childNodes[r],-1)&&(a=!0);;)if(r>0){if(t.nodeType!=1)break;{let c=t.childNodes[r-1];if(Gi(c,-1))i=t,s=--r;else if(c.nodeType==3)t=c,r=t.nodeValue.length;else break}}else{if(wg(t))break;{let c=t.previousSibling;for(;c&&Gi(c,-1);)i=t.parentNode,s=Xe(c),c=c.previousSibling;if(c)t=c,r=Io(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}a?Ac(n,t,r):i&&Ac(n,i,s)}function JO(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=Io(t),s,a;for(;;)if(r<i){if(t.nodeType!=1)break;let c=t.childNodes[r];if(Gi(c,1))s=t,a=++r;else break}else{if(wg(t))break;{let c=t.nextSibling;for(;c&&Gi(c,1);)s=c.parentNode,a=Xe(c)+1,c=c.nextSibling;if(c)t=c,r=0,i=Io(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&Ac(n,s,a)}function wg(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function GO(n,e){for(;n&&e==n.childNodes.length&&!cs(n);)e=Xe(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function YO(n,e){for(;n&&!e&&!cs(n);)e=Xe(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Ac(n,e,t){if(e.nodeType!=3){let s,a;(a=GO(e,t))?(e=a,t=0):(s=YO(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Ko(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&Mn(n)},50)}function ip(n,e){let t=n.state.doc.resolve(e);if(!(rt||_O)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),a=(s.top+s.bottom)/2;if(a>i.top&&a<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),a=(s.top+s.bottom)/2;if(a>i.top&&a<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function sp(n,e,t){let r=n.state.selection;if(r instanceof re&&!r.empty||t.indexOf("s")>-1||$t&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let a=Tc(n.state,e);if(a&&a instanceof Q)return Hn(n,a)}if(!i.parent.inlineContent){let a=e<0?i:s,c=r instanceof Ct?ae.near(a,e):ae.findFrom(a,e);return c?Hn(n,c):!1}return!1}function op(n,e){if(!(n.state.selection instanceof re))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let a=n.state.tr;return e<0?a.delete(t.pos-s.nodeSize,t.pos):a.delete(t.pos,t.pos+s.nodeSize),n.dispatch(a),!0}return!1}function ap(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function QO(n){if(!ft||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;ap(n,r,"true"),setTimeout(()=>ap(n,r,"false"),20)}return!1}function XO(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function ZO(n,e){let t=e.keyCode,r=XO(e);if(t==8||$t&&t==72&&r=="c")return op(n,-1)||Yr(n,-1);if(t==46&&!e.shiftKey||$t&&t==68&&r=="c")return op(n,1)||Yr(n,1);if(t==13||t==27)return!0;if(t==37||$t&&t==66&&r=="c"){let i=t==37?ip(n,n.state.selection.from)=="ltr"?-1:1:-1;return rp(n,i,r)||Yr(n,i)}else if(t==39||$t&&t==70&&r=="c"){let i=t==39?ip(n,n.state.selection.from)=="ltr"?1:-1:1;return rp(n,i,r)||Yr(n,i)}else{if(t==38||$t&&t==80&&r=="c")return sp(n,-1,r)||Yr(n,-1);if(t==40||$t&&t==78&&r=="c")return QO(n)||sp(n,1,r)||Yr(n,1);if(r==($t?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Zc(n,e){n.someProp("transformCopied",g=>{e=g(e,n)});let t=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let g=r.firstChild;t.push(g.type.name,g.attrs!=g.type.defaultAttrs?g.attrs:null),r=g.content}let a=n.someProp("clipboardSerializer")||Nr.fromSchema(n.state.schema),c=Ag(),u=c.createElement("div");u.appendChild(a.serializeFragment(r,{document:c}));let d=u.firstChild,h,p=0;for(;d&&d.nodeType==1&&(h=Tg[d.nodeName.toLowerCase()]);){for(let g=h.length-1;g>=0;g--){let _=c.createElement(h[g]);for(;u.firstChild;)_.appendChild(u.firstChild);u.appendChild(_),p++}d=u.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${i} ${s}${p?` -${p}`:""} ${JSON.stringify(t)}`);let y=n.someProp("clipboardTextSerializer",g=>g(e,n))||e.content.textBetween(0,e.content.size,`
171
+ `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],a=r.getPropertyValue(s);if(a)for(let c=void 0;;){let u=this.parser.matchStyle(s,a,this,c);if(!u)break;if(u.ignore)return null;if(u.clearMark?t=t.filter(d=>!u.clearMark(d)):t=t.concat(this.parser.schema.marks[u.mark].create(u.attrs)),u.consuming===!1)c=u;else break}}return t}addElementByRule(e,t,r,i){let s,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),r)||this.leafFallback(e,r);else{let u=this.enter(a,t.attrs||null,r,t.preserveWhitespace);u&&(s=!0,r=u)}else{let u=this.parser.schema.marks[t.mark];r=r.concat(u.create(t.attrs))}let c=this.top;if(a&&a.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u,r));else{let u=e;typeof t.contentElement=="string"?u=e.querySelector(t.contentElement):typeof t.contentElement=="function"?u=t.contentElement(e):t.contentElement&&(u=t.contentElement),this.findAround(e,u,!0),this.addAll(u,r),this.findAround(e,u,!1)}s&&this.sync(c)&&this.open--}addAll(e,t,r,i){let s=r||0;for(let a=r?e.childNodes[r]:e.firstChild,c=i==null?null:e.childNodes[i];a!=c;a=a.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(a,t);this.findAtPoint(e,s)}findPlace(e,t){let r,i;for(let s=this.open;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!r||r.length>c.length)&&(r=c,i=a,!c.length)||a.solid)break}if(!r)return null;this.sync(i);for(let s=0;s<r.length;s++)t=this.enterInner(r[s],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let r=this.findPlace(e,t);if(r){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=we.none;for(let a of r.concat(e.marks))(i.type?i.type.allowsMarkType(a.type):Mh(a.type,e.type))&&(s=a.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,t,r,i){let s=this.findPlace(e.create(t),r);return s&&(s=this.enterInner(e,t,r,!0,i)),s}enterInner(e,t,r,i=!1,s){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let c=Th(e,s,a.options);a.options&go&&a.content.length==0&&(c|=go);let u=we.none;return r=r.filter(d=>(a.type?a.type.allowsMarkType(d.type):Mh(d.type,e))?(u=d.addToSet(u),!1):!0),this.nodes.push(new oo(e,t,u,i,null,c)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Zi)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),a=(c,u)=>{for(;c>=0;c--){let d=t[c];if(d==""){if(c==t.length-1||c==0)continue;for(;u>=s;u--)if(a(c-1,u))return!0;return!1}else{let h=u>0||u==0&&i?this.nodes[u].type:r&&u>=s?r.node(u-s).type:null;if(!h||h.name!=d&&!h.isInGroup(d))return!1;u--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function RE(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Um.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function DE(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Ch(n){let e={};for(let t in n)e[t]=n[t];return e}function Mh(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))continue;let s=[],a=c=>{s.push(c);for(let u=0;u<c.edgeCount;u++){let{type:d,next:h}=c.edge(u);if(d==e||s.indexOf(h)<0&&a(h))return!0}};if(a(i.contentMatch))return!0}}class Ir{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Al(t).createDocumentFragment());let i=r,s=[];return e.forEach(a=>{if(s.length||a.marks.length){let c=0,u=0;for(;c<s.length&&u<a.marks.length;){let d=a.marks[u];if(!this.marks[d.type.name]){u++;continue}if(!d.eq(s[c][0])||d.type.spec.spanning===!1)break;c++,u++}for(;c<s.length;)i=s.pop()[1];for(;u<a.marks.length;){let d=a.marks[u++],h=this.serializeMark(d,a.isInline,t);h&&(s.push([d,i]),i.appendChild(h.dom),i=h.contentDOM||h.dom)}}i.appendChild(this.serializeNodeInner(a,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=yo(Al(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&yo(Al(r),i(e,t),null,e.attrs)}static renderSpec(e,t,r=null,i){return yo(e,t,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ir(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Nh(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Nh(e.marks)}}function Nh(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Al(n){return n.document||window.document}const Ih=new WeakMap;function LE(n){let e=Ih.get(n);return e===void 0&&Ih.set(n,e=BE(n)),e}function BE(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)t(r[i]);else for(let i in r)t(r[i])}return t(n),e}function yo(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=LE(r))&&s.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 a=i.indexOf(" ");a>0&&(t=i.slice(0,a),i=i.slice(a+1));let c,u=t?n.createElementNS(t,i):n.createElement(i),d=e[1],h=1;if(d&&typeof d=="object"&&d.nodeType==null&&!Array.isArray(d)){h=2;for(let p in d)if(d[p]!=null){let y=p.indexOf(" ");y>0?u.setAttributeNS(p.slice(0,y),p.slice(y+1),d[p]):u.setAttribute(p,d[p])}}for(let p=h;p<e.length;p++){let y=e[p];if(y===0){if(p<e.length-1||p>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:g,contentDOM:_}=yo(n,y,t,r);if(u.appendChild(g),_){if(c)throw new RangeError("Multiple content holes");c=_}}}return{dom:u,contentDOM:c}}const Km=65535,jm=Math.pow(2,16);function FE(n,e){return n+e*jm}function Ph(n){return n&Km}function $E(n){return(n-(n&Km))/jm}const qm=1,Jm=2,_o=4,Gm=8;class bc{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Gm)>0}get deletedBefore(){return(this.delInfo&(qm|_o))>0}get deletedAfter(){return(this.delInfo&(Jm|_o))>0}get deletedAcross(){return(this.delInfo&_o)>0}}class At{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&At.empty)return At.empty}recover(e){let t=0,r=Ph(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+$E(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let i=0,s=this.inverted?2:1,a=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?i:0);if(u>e)break;let d=this.ranges[c+s],h=this.ranges[c+a],p=u+d;if(e<=p){let y=d?e==u?-1:e==p?1:t:t,g=u+i+(y<0?0:h);if(r)return g;let _=e==(t<0?u:p)?null:FE(c/3,e-u),w=e==u?Jm:e==p?qm:_o;return(t<0?e!=u:e!=p)&&(w|=Gm),new bc(g,w,_)}i+=h-d}return r?e+i:new bc(e+i,0,null)}touches(e,t){let r=0,i=Ph(t),s=this.inverted?2:1,a=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?r:0);if(u>e)break;let d=this.ranges[c+s],h=u+d;if(e<=h&&c==i*3)return!0;r+=this.ranges[c+a]-d}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let a=this.ranges[i],c=a-(this.inverted?s:0),u=a+(this.inverted?0:s),d=this.ranges[i+t],h=this.ranges[i+r];e(c,c+d,u,u+h),s+=h-d}}invert(){return new At(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?At.empty:new At(e<0?[0,-e,0]:[0,0,e])}}At.empty=new At([]);class es{constructor(e,t,r=0,i=e?e.length:0){this.mirror=t,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new es(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new es;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let a=this._maps[s],c=a.mapResult(e,t);if(c.recover!=null){let u=this.getMirror(s);if(u!=null&&u>s&&u<this.to){s=u,e=this._maps[u].recover(c.recover);continue}}i|=c.delInfo,e=c.pos}return r?e:new bc(e,i,null)}}const Cl=Object.create(null);class st{getMap(){return At.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Cl[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Cl)throw new RangeError("Duplicate use of step JSON ID "+e);return Cl[e]=t,t.prototype.jsonID=e,t}}class Le{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new Le(e,null)}static fail(e){return new Le(null,e)}static fromReplace(e,t,r,i){try{return Le.ok(e.replace(t,r,i))}catch(s){if(s instanceof To)return Le.fail(s.message);throw s}}}function jc(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(jc(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return D.fromArray(r)}class jn extends st{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new H(jc(t.content,(a,c)=>!a.isAtom||!c.type.allowsMarkType(this.mark.type)?a:a.mark(this.mark.addToSet(a.marks)),i),t.openStart,t.openEnd);return Le.fromReplace(e,this.from,this.to,s)}invert(){return new ln(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new jn(t.pos,r.pos,this.mark)}merge(e){return e instanceof jn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new jn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new jn(t.from,t.to,e.markFromJSON(t.mark))}}st.jsonID("addMark",jn);class ln extends st{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new H(jc(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return Le.fromReplace(e,this.from,this.to,r)}invert(){return new jn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new ln(t.pos,r.pos,this.mark)}merge(e){return e instanceof ln&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ln(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ln(t.from,t.to,e.markFromJSON(t.mark))}}st.jsonID("removeMark",ln);class qn extends st{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Le.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Le.fromReplace(e,this.pos,this.pos+1,new H(D.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new qn(this.pos,t.marks[i]);return new qn(this.pos,this.mark)}}return new li(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new qn(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new qn(t.pos,e.markFromJSON(t.mark))}}st.jsonID("addNodeMark",qn);class li extends st{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Le.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Le.fromReplace(e,this.pos,this.pos+1,new H(D.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new qn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new li(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new li(t.pos,e.markFromJSON(t.mark))}}st.jsonID("removeNodeMark",li);class Ue extends st{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&vc(e,this.from,this.to)?Le.fail("Structure replace would overwrite content"):Le.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new At([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ue(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new Ue(t.pos,Math.max(t.pos,r.pos),this.slice)}merge(e){if(!(e instanceof Ue)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?H.empty:new H(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ue(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?H.empty:new H(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ue(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ue(t.from,t.to,H.fromJSON(e,t.slice),!!t.structure)}}st.jsonID("replace",Ue);class Ke extends st{constructor(e,t,r,i,s,a,c=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=a,this.structure=c}apply(e){if(this.structure&&(vc(e,this.from,this.gapFrom)||vc(e,this.gapTo,this.to)))return Le.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Le.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?Le.fromReplace(e,this.from,this.to,r):Le.fail("Content does not fit in gap")}getMap(){return new At([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Ke(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new Ke(t.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ke(t.from,t.to,t.gapFrom,t.gapTo,H.fromJSON(e,t.slice),t.insert,!!t.structure)}}st.jsonID("replaceAround",Ke);function vc(n,e,t){let r=n.resolve(e),i=t-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let a=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!a||a.isLeaf)return!0;a=a.firstChild,i--}}return!1}function zE(n,e,t,r){let i=[],s=[],a,c;n.doc.nodesBetween(e,t,(u,d,h)=>{if(!u.isInline)return;let p=u.marks;if(!r.isInSet(p)&&h.type.allowsMarkType(r.type)){let y=Math.max(d,e),g=Math.min(d+u.nodeSize,t),_=r.addToSet(p);for(let w=0;w<p.length;w++)p[w].isInSet(_)||(a&&a.to==y&&a.mark.eq(p[w])?a.to=g:i.push(a=new ln(y,g,p[w])));c&&c.to==y?c.to=g:s.push(c=new jn(y,g,r))}}),i.forEach(u=>n.step(u)),s.forEach(u=>n.step(u))}function WE(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(a,c)=>{if(!a.isInline)return;s++;let u=null;if(r instanceof Wo){let d=a.marks,h;for(;h=r.isInSet(d);)(u||(u=[])).push(h),d=h.removeFromSet(d)}else r?r.isInSet(a.marks)&&(u=[r]):u=a.marks;if(u&&u.length){let d=Math.min(c+a.nodeSize,t);for(let h=0;h<u.length;h++){let p=u[h],y;for(let g=0;g<i.length;g++){let _=i[g];_.step==s-1&&p.eq(i[g].style)&&(y=_)}y?(y.to=d,y.step=s):i.push({style:p,from:Math.max(c,e),to:d,step:s})}}}),i.forEach(a=>n.step(new ln(a.from,a.to,a.style)))}function qc(n,e,t,r=t.contentMatch,i=!0){let s=n.doc.nodeAt(e),a=[],c=e+1;for(let u=0;u<s.childCount;u++){let d=s.child(u),h=c+d.nodeSize,p=r.matchType(d.type);if(!p)a.push(new Ue(c,h,H.empty));else{r=p;for(let y=0;y<d.marks.length;y++)t.allowsMarkType(d.marks[y].type)||n.step(new ln(c,h,d.marks[y]));if(i&&d.isText&&t.whitespace!="pre"){let y,g=/\r?\n|\r/g,_;for(;y=g.exec(d.text);)_||(_=new H(D.from(t.schema.text(" ",t.allowedMarks(d.marks))),0,0)),a.push(new Ue(c+y.index,c+y.index+y[0].length,_))}}c=h}if(!r.validEnd){let u=r.fillBefore(D.empty,!0);n.replace(c,c,new H(u,0,0))}for(let u=a.length-1;u>=0;u--)n.step(a[u])}function VE(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function hi(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),s=n.$from.index(r),a=n.$to.indexAfter(r);if(r<n.depth&&i.canReplace(s,a,t))return r;if(r==0||i.type.spec.isolating||!VE(i,s,a))break}return null}function HE(n,e,t){let{$from:r,$to:i,depth:s}=e,a=r.before(s+1),c=i.after(s+1),u=a,d=c,h=D.empty,p=0;for(let _=s,w=!1;_>t;_--)w||r.index(_)>0?(w=!0,h=D.from(r.node(_).copy(h)),p++):u--;let y=D.empty,g=0;for(let _=s,w=!1;_>t;_--)w||i.after(_+1)<i.end(_)?(w=!0,y=D.from(i.node(_).copy(y)),g++):d++;n.step(new Ke(u,d,a,c,new H(h.append(y),p,g),h.size-p,!0))}function Jc(n,e,t=null,r=n){let i=UE(n,e),s=i&&KE(r,e);return s?i.map(Rh).concat({type:e,attrs:t}).concat(s.map(Rh)):null}function Rh(n){return{type:n,attrs:null}}function UE(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let a=s.length?s[0]:e;return t.canReplaceWith(r,i,a)?s:null}function KE(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.child(r),a=e.contentMatch.findWrapping(s.type);if(!a)return null;let u=(a.length?a[a.length-1]:e).contentMatch;for(let d=r;u&&d<i;d++)u=u.matchType(t.child(d).type);return!u||!u.validEnd?null:a}function jE(n,e,t){let r=D.empty;for(let a=t.length-1;a>=0;a--){if(r.size){let c=t[a].type.contentMatch.matchFragment(r);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=D.from(t[a].type.create(t[a].attrs,r))}let i=e.start,s=e.end;n.step(new Ke(i,s,i,s,new H(r,0,0),t.length,!0))}function qE(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(a,c)=>{let u=typeof i=="function"?i(a):i;if(a.isTextblock&&!a.hasMarkup(r,u)&&JE(n.doc,n.mapping.slice(s).map(c),r)){let d=null;if(r.schema.linebreakReplacement){let g=r.whitespace=="pre",_=!!r.contentMatch.matchType(r.schema.linebreakReplacement);g&&!_?d=!1:!g&&_&&(d=!0)}d===!1&&Qm(n,a,c,s),qc(n,n.mapping.slice(s).map(c,1),r,void 0,d===null);let h=n.mapping.slice(s),p=h.map(c,1),y=h.map(c+a.nodeSize,1);return n.step(new Ke(p,y,p+1,y-1,new H(D.from(r.create(u,null,a.marks)),0,0),1,!0)),d===!0&&Ym(n,a,c,s),!1}})}function Ym(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let a,c=/\r?\n|\r/g;for(;a=c.exec(i.text);){let u=n.mapping.slice(r).map(t+1+s+a.index);n.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function Qm(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let a=n.mapping.slice(r).map(t+1+s);n.replaceWith(a,a+1,e.type.schema.text(`
172
+ `))}})}function JE(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function GE(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let a=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,a);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Ke(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new H(D.from(a),0,0),1,!0))}function Cn(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,a=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!a.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let d=i.depth-1,h=t-2;d>s;d--,h--){let p=i.node(d),y=i.index(d);if(p.type.spec.isolating)return!1;let g=p.content.cutByIndex(y,p.childCount),_=r&&r[h+1];_&&(g=g.replaceChild(0,_.type.create(_.attrs)));let w=r&&r[h]||p;if(!p.canReplace(y+1,p.childCount)||!w.type.validContent(g))return!1}let c=i.indexAfter(s),u=r&&r[0];return i.node(s).canReplaceWith(c,c,u?u.type:i.node(s+1).type)}function YE(n,e,t=1,r){let i=n.doc.resolve(e),s=D.empty,a=D.empty;for(let c=i.depth,u=i.depth-t,d=t-1;c>u;c--,d--){s=D.from(i.node(c).copy(s));let h=r&&r[d];a=D.from(h?h.type.create(h.attrs,a):i.node(c).copy(a))}n.step(new Ue(e,e,new H(s.append(a),t,t),!0))}function tr(n,e){let t=n.resolve(e),r=t.index();return Xm(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function QE(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),a=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(a),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function Xm(n,e){return!!(n&&e&&!n.isLeaf&&QE(n,e))}function Vo(n,e,t=-1){let r=n.resolve(e);for(let i=r.depth;;i--){let s,a,c=r.index(i);if(i==r.depth?(s=r.nodeBefore,a=r.nodeAfter):t>0?(s=r.node(i+1),c++,a=r.node(i).maybeChild(c)):(s=r.node(i).maybeChild(c-1),a=r.node(i+1)),s&&!s.isTextblock&&Xm(s,a)&&r.node(i).canReplace(c,c+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function XE(n,e,t){let r=null,{linebreakReplacement:i}=n.doc.type.schema,s=n.doc.resolve(e-t),a=s.node().type;if(i&&a.inlineContent){let h=a.whitespace=="pre",p=!!a.contentMatch.matchType(i);h&&!p?r=!1:!h&&p&&(r=!0)}let c=n.steps.length;if(r===!1){let h=n.doc.resolve(e+t);Qm(n,h.node(),h.before(),c)}a.inlineContent&&qc(n,e+t-1,a,s.node().contentMatchAt(s.index()),r==null);let u=n.mapping.slice(c),d=u.map(e-t);if(n.step(new Ue(d,u.map(e+t,-1),H.empty,!0)),r===!0){let h=n.doc.resolve(d);Ym(n,h.node(),h.before(),n.steps.length)}return n}function ZE(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,t))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function Zm(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let a=r.depth;a>=0;a--){let c=a==r.depth?0:r.pos<=(r.start(a+1)+r.end(a+1))/2?-1:1,u=r.index(a)+(c>0?1:0),d=r.node(a),h=!1;if(s==1)h=d.canReplace(u,u,i);else{let p=d.contentMatchAt(u).findWrapping(i.firstChild.type);h=p&&d.canReplaceWith(u,u,p[0])}if(h)return c==0?r.pos:c<0?r.before(a+1):r.after(a+1)}return null}function Ho(n,e,t=e,r=H.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return eg(i,s,r)?new Ue(e,t,r):new eO(i,s,r).fit()}function eg(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class eO{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=D.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=D.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let d=this.findFittable();d?this.placeNodes(d):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,a=r.depth,c=i.depth;for(;a&&c&&s.childCount==1;)s=s.firstChild.content,a--,c--;let u=new H(s,a,c);return e>-1?new Ke(r.pos,e,this.$to.pos,this.$to.end(),u,t):u.size||r.pos!=this.$to.pos?new Ue(r.pos,i.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Ml(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let a=i.firstChild;for(let c=this.depth;c>=0;c--){let{type:u,match:d}=this.frontier[c],h,p=null;if(t==1&&(a?d.matchType(a.type)||(p=d.fillBefore(D.from(a),!1)):s&&u.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:c,parent:s,inject:p};if(t==2&&a&&(h=d.findWrapping(a.type)))return{sliceDepth:r,frontierDepth:c,parent:s,wrap:h};if(s&&d.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Ml(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new H(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Ml(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new H(Hi(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new H(Hi(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let w=0;w<s.length;w++)this.openFrontierNode(s[w]);let a=this.unplaced,c=r?r.content:a.content,u=a.openStart-e,d=0,h=[],{match:p,type:y}=this.frontier[t];if(i){for(let w=0;w<i.childCount;w++)h.push(i.child(w));p=p.matchFragment(i)}let g=c.size+e-(a.content.size-a.openEnd);for(;d<c.childCount;){let w=c.child(d),k=p.matchType(w.type);if(!k)break;d++,(d>1||u==0||w.content.size)&&(p=k,h.push(tg(w.mark(y.allowedMarks(w.marks)),d==1?u:0,d==c.childCount?g:-1)))}let _=d==c.childCount;_||(g=-1),this.placed=Ui(this.placed,t,D.from(h)),this.frontier[t].match=p,_&&g<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,k=c;w<g;w++){let A=k.lastChild;this.frontier.push({type:A.type,match:A.contentMatchAt(A.childCount)}),k=A.content}this.unplaced=_?e==0?H.empty:new H(Hi(a.content,e-1,1),e-1,g<0?a.openEnd:e-1):new H(Hi(a.content,e,d),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Nl(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=Nl(e,t,i,r,s);if(a){for(let c=t-1;c>=0;c--){let{match:u,type:d}=this.frontier[c],h=Nl(e,c,d,u,!0);if(!h||h.childCount)continue e}return{depth:t,fit:a,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Ui(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Ui(this.placed,this.depth,D.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(D.empty,!0);t.childCount&&(this.placed=Ui(this.placed,this.frontier.length,t))}}function Hi(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Hi(n.firstChild.content,e-1,t)))}function Ui(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Ui(n.lastChild.content,e-1,t)))}function Ml(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function tg(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,tg(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(D.empty,!0)))),n.copy(r)}function Nl(n,e,t,r,i){let s=n.node(e),a=i?n.indexAfter(e):n.index(e);if(a==s.childCount&&!t.compatibleContent(s.type))return null;let c=r.fillBefore(s.content,!0,a);return c&&!tO(t,s.content,a)?c:null}function tO(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function nO(n){return n.spec.defining||n.spec.definingForContent}function rO(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(eg(i,s,r))return n.step(new Ue(e,t,r));let a=rg(i,n.doc.resolve(t));a[a.length-1]==0&&a.pop();let c=-(i.depth+1);a.unshift(c);for(let y=i.depth,g=i.pos-1;y>0;y--,g--){let _=i.node(y).type.spec;if(_.defining||_.definingAsContext||_.isolating)break;a.indexOf(y)>-1?c=y:i.before(y)==g&&a.splice(1,0,-y)}let u=a.indexOf(c),d=[],h=r.openStart;for(let y=r.content,g=0;;g++){let _=y.firstChild;if(d.push(_),g==r.openStart)break;y=_.content}for(let y=h-1;y>=0;y--){let g=d[y],_=nO(g.type);if(_&&!g.sameMarkup(i.node(Math.abs(c)-1)))h=y;else if(_||!g.type.isTextblock)break}for(let y=r.openStart;y>=0;y--){let g=(y+h+1)%(r.openStart+1),_=d[g];if(_)for(let w=0;w<a.length;w++){let k=a[(w+u)%a.length],A=!0;k<0&&(A=!1,k=-k);let P=i.node(k-1),L=i.index(k-1);if(P.canReplaceWith(L,L,_.type,_.marks))return n.replace(i.before(k),A?s.after(k):t,new H(ng(r.content,0,r.openStart,g),g,r.openEnd))}}let p=n.steps.length;for(let y=a.length-1;y>=0&&(n.replace(e,t,r),!(n.steps.length>p));y--){let g=a[y];g<0||(e=i.before(g),t=s.after(g))}}function ng(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(ng(s.content,e+1,t,r,s)))}if(e>r){let s=i.contentMatchAt(0),a=s.fillBefore(n).append(n);n=a.append(s.matchFragment(a).fillBefore(D.empty,!0))}return n}function iO(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=ZE(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new H(D.from(r),0,0))}function sO(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),s=rg(r,i);for(let a=0;a<s.length;a++){let c=s[a],u=a==s.length-1;if(u&&c==0||r.node(c).type.contentMatch.validEnd)return n.delete(r.start(c),i.end(c));if(c>0&&(u||r.node(c-1).canReplace(r.index(c-1),i.indexAfter(c-1))))return n.delete(r.before(c),i.after(c))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(e-r.start(a)==r.depth-a&&t>r.end(a)&&i.end(a)-t!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return n.delete(r.before(a),t);n.delete(e,t)}function rg(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(s<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class ii extends st{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return Le.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return Le.fromReplace(e,this.pos,this.pos+1,new H(D.from(i),0,t.isLeaf?0:1))}getMap(){return At.empty}invert(e){return new ii(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ii(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ii(t.pos,t.attr,t.value)}}st.jsonID("attr",ii);class ts extends st{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return Le.ok(r)}getMap(){return At.empty}invert(e){return new ts(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new ts(t.attr,t.value)}}st.jsonID("docAttr",ts);let ci=class extends Error{};ci=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};ci.prototype=Object.create(Error.prototype);ci.prototype.constructor=ci;ci.prototype.name="TransformError";class oO{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new es}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new ci(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=H.empty){let i=Ho(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new H(D.from(r),0,0))}delete(e,t){return this.replace(e,t,H.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return rO(this,e,t,r),this}replaceRangeWith(e,t,r){return iO(this,e,t,r),this}deleteRange(e,t){return sO(this,e,t),this}lift(e,t){return HE(this,e,t),this}join(e,t=1){return XE(this,e,t),this}wrap(e,t){return jE(this,e,t),this}setBlockType(e,t=e,r,i=null){return qE(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return GE(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new ii(e,t,r)),this}setDocAttribute(e,t){return this.step(new ts(e,t)),this}addNodeMark(e,t){return this.step(new qn(e,t)),this}removeNodeMark(e,t){if(!(t instanceof we)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new li(e,t)),this}split(e,t=1,r){return YE(this,e,t,r),this}addMark(e,t,r){return zE(this,e,t,r),this}removeMark(e,t,r){return WE(this,e,t,r),this}clearIncompatible(e,t,r){return qc(this,e,t,r),this}}const Il=Object.create(null);class ae{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new aO(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=H.empty){let r=t.content.lastChild,i=null;for(let c=0;c<t.openEnd;c++)i=r,r=r.lastChild;let s=e.steps.length,a=this.ranges;for(let c=0;c<a.length;c++){let{$from:u,$to:d}=a[c],h=e.mapping.slice(s);e.replaceRange(h.map(u.pos),h.map(d.pos),c?H.empty:t),c==0&&Bh(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:a,$to:c}=i[s],u=e.mapping.slice(r),d=u.map(a.pos),h=u.map(c.pos);s?e.deleteRange(d,h):(e.replaceRangeWith(d,h,t),Bh(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new re(e):Zr(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let a=t<0?Zr(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):Zr(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(a)return a}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Ct(e.node(0))}static atStart(e){return Zr(e,e,0,0,1)||new Ct(e)}static atEnd(e){return Zr(e,e,e.content.size,e.childCount,-1)||new Ct(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Il[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Il)throw new RangeError("Duplicate use of selection JSON ID "+e);return Il[e]=t,t.prototype.jsonID=e,t}getBookmark(){return re.between(this.$anchor,this.$head).getBookmark()}}ae.prototype.visible=!0;class aO{constructor(e,t){this.$from=e,this.$to=t}}let Dh=!1;function Lh(n){!Dh&&!n.parent.inlineContent&&(Dh=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class re extends ae{constructor(e,t=e){Lh(e),Lh(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return ae.near(r);let i=e.resolve(t.map(this.anchor));return new re(i.parent.inlineContent?i:r,r)}replace(e,t=H.empty){if(super.replace(e,t),t==H.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof re&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Uo(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new re(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=ae.findFrom(t,r,!0)||ae.findFrom(t,-r,!0);if(s)t=s.$head;else return ae.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(ae.findFrom(e,-r,!0)||ae.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new re(e,t)}}ae.jsonID("text",re);class Uo{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Uo(e.map(this.anchor),e.map(this.head))}resolve(e){return re.between(e.resolve(this.anchor),e.resolve(this.head))}}class Q extends ae{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return r?ae.near(s):new Q(s)}content(){return new H(D.from(this.node),0,0)}eq(e){return e instanceof Q&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Gc(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Q(e.resolve(t.anchor))}static create(e,t){return new Q(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Q.prototype.visible=!1;ae.jsonID("node",Q);class Gc{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Uo(r,r):new Gc(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&Q.isSelectable(r)?new Q(t):ae.near(t)}}class Ct extends ae{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=H.empty){if(t==H.empty){e.delete(0,e.doc.content.size);let r=ae.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Ct(e)}map(e){return new Ct(e)}eq(e){return e instanceof Ct}getBookmark(){return lO}}ae.jsonID("all",Ct);const lO={map(){return this},resolve(n){return new Ct(n)}};function Zr(n,e,t,r,i,s=!1){if(e.inlineContent)return re.create(n,t);for(let a=r-(i>0?0:1);i>0?a<e.childCount:a>=0;a+=i){let c=e.child(a);if(c.isAtom){if(!s&&Q.isSelectable(c))return Q.create(n,t-(i<0?c.nodeSize:0))}else{let u=Zr(n,c,t+i,i<0?c.childCount:0,i,s);if(u)return u}t+=c.nodeSize*i}return null}function Bh(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof Ue||i instanceof Ke))return;let s=n.mapping.maps[r],a;s.forEach((c,u,d,h)=>{a==null&&(a=h)}),n.setSelection(ae.near(n.doc.resolve(a),t))}const Fh=1,$h=2,zh=4;class cO extends oO{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|Fh)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&Fh)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=$h,this}ensureMarks(e){return we.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&$h)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||we.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let a=this.doc.resolve(t);s=r==t?a.marks():a.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,s)),this.selection.empty||this.setSelection(ae.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=zh,this}get scrolledIntoView(){return(this.updated&zh)>0}}function Wh(n,e){return!e||!n?n:n.bind(e)}class Ki{constructor(e,t,r){this.name=e,this.init=Wh(t.init,r),this.apply=Wh(t.apply,r)}}const uO=[new Ki("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Ki("selection",{init(n,e){return n.selection||ae.atStart(e.doc)},apply(n){return n.selection}}),new Ki("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Ki("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Pl{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=uO.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Ki(r.key,r.spec.state,r))})}}class ti{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let a=0;a<this.config.plugins.length;a++){let c=this.config.plugins[a];if(c.spec.appendTransaction){let u=i?i[a].n:0,d=i?i[a].state:this,h=u<t.length&&c.spec.appendTransaction.call(c,u?t.slice(u):t,d,r);if(h&&r.filterTransaction(h,a)){if(h.setMeta("appendedTransaction",e),!i){i=[];for(let p=0;p<this.config.plugins.length;p++)i.push(p<a?{state:r,n:t.length}:{state:this,n:0})}t.push(h),r=r.applyInner(h),s=!0}i&&(i[a]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new ti(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new cO(this)}static create(e){let t=new Pl(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new ti(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new Pl(this.schema,e.plugins),r=t.fields,i=new ti(t);for(let s=0;s<r.length;s++){let a=r[s].name;i[a]=this.hasOwnProperty(a)?this[a]:r[s].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Pl(e.schema,e.plugins),s=new ti(i);return i.fields.forEach(a=>{if(a.name=="doc")s.doc=Gn.fromJSON(e.schema,t.doc);else if(a.name=="selection")s.selection=ae.fromJSON(s.doc,t.selection);else if(a.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let c in r){let u=r[c],d=u.spec.state;if(u.key==a.name&&d&&d.fromJSON&&Object.prototype.hasOwnProperty.call(t,c)){s[a.name]=d.fromJSON.call(u,e,t[c],s);return}}s[a.name]=a.init(e,s)}}),s}}function ig(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=ig(i,e,{})),t[r]=i}return t}class St{constructor(e){this.spec=e,this.props={},e.props&&ig(e.props,this,this.props),this.key=e.key?e.key.key:sg("plugin")}getState(e){return e[this.key]}}const Rl=Object.create(null);function sg(n){return n in Rl?n+"$"+ ++Rl[n]:(Rl[n]=0,n+"$")}class fn{constructor(e="key"){this.key=sg(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Xe=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},ui=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Sc=null;const xn=function(n,e,t){let r=Sc||(Sc=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},fO=function(){Sc=null},Ar=function(n,e,t,r){return t&&(Vh(n,e,t,r,-1)||Vh(n,e,t,r,1))},dO=/^(img|br|input|textarea|hr)$/i;function Vh(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:zt(n))){let s=n.parentNode;if(!s||s.nodeType!=1||cs(n)||dO.test(n.nodeName)||n.contentEditable=="false")return!1;e=Xe(n)+(i<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?zt(n):0}else return!1}}function zt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function hO(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=zt(n)}else if(n.parentNode&&!cs(n))e=Xe(n),n=n.parentNode;else return null}}function pO(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!cs(n))e=Xe(n)+1,n=n.parentNode;else return null}}function mO(n,e,t){for(let r=e==0,i=e==zt(n);r||i;){if(n==t)return!0;let s=Xe(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,i=i&&s==zt(n)}}function cs(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Ko=function(n){return n.focusNode&&Ar(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function pr(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function gO(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function yO(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(zt(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(zt(r.startContainer),r.startOffset)}}}const cn=typeof navigator<"u"?navigator:null,Hh=typeof document<"u"?document:null,nr=cn&&cn.userAgent||"",wc=/Edge\/(\d+)/.exec(nr),og=/MSIE \d/.exec(nr),kc=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nr),bt=!!(og||kc||wc),Qn=og?document.documentMode:kc?+kc[1]:wc?+wc[1]:0,en=!bt&&/gecko\/(\d+)/i.test(nr);en&&+(/Firefox\/(\d+)/.exec(nr)||[0,0])[1];const xc=!bt&&/Chrome\/(\d+)/.exec(nr),rt=!!xc,ag=xc?+xc[1]:0,ft=!bt&&!!cn&&/Apple Computer/.test(cn.vendor),fi=ft&&(/Mobile\/\w+/.test(nr)||!!cn&&cn.maxTouchPoints>2),$t=fi||(cn?/Mac/.test(cn.platform):!1),_O=cn?/Win/.test(cn.platform):!1,On=/Android \d/.test(nr),us=!!Hh&&"webkitFontSmoothing"in Hh.documentElement.style,bO=us?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function vO(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function kn(n,e){return typeof n=="number"?n:n[e]}function SO(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Uh(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let a=t||n.dom;a;){if(a.nodeType!=1){a=ui(a);continue}let c=a,u=c==s.body,d=u?vO(s):SO(c),h=0,p=0;if(e.top<d.top+kn(r,"top")?p=-(d.top-e.top+kn(i,"top")):e.bottom>d.bottom-kn(r,"bottom")&&(p=e.bottom-e.top>d.bottom-d.top?e.top+kn(i,"top")-d.top:e.bottom-d.bottom+kn(i,"bottom")),e.left<d.left+kn(r,"left")?h=-(d.left-e.left+kn(i,"left")):e.right>d.right-kn(r,"right")&&(h=e.right-d.right+kn(i,"right")),h||p)if(u)s.defaultView.scrollBy(h,p);else{let g=c.scrollLeft,_=c.scrollTop;p&&(c.scrollTop+=p),h&&(c.scrollLeft+=h);let w=c.scrollLeft-g,k=c.scrollTop-_;e={left:e.left-w,top:e.top-k,right:e.right-w,bottom:e.bottom-k}}let y=u?"fixed":getComputedStyle(a).position;if(/^(fixed|sticky)$/.test(y))break;a=y=="absolute"?a.offsetParent:ui(a)}}function wO(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,a=t+1;a<Math.min(innerHeight,e.bottom);a+=5){let c=n.root.elementFromPoint(s,a);if(!c||c==n.dom||!n.dom.contains(c))continue;let u=c.getBoundingClientRect();if(u.top>=t-20){r=c,i=u.top;break}}return{refDOM:r,refTop:i,stack:lg(n.dom)}}function lg(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=ui(r));return e}function kO({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;cg(t,r==0?0:r-e)}function cg(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:s}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let Yr=null;function xO(n){if(n.setActive)return n.setActive();if(Yr)return n.focus(Yr);let e=lg(n);n.focus(Yr==null?{get preventScroll(){return Yr={preventScroll:!0},!0}}:void 0),Yr||(Yr=!1,cg(e,0))}function ug(n,e){let t,r=2e8,i,s=0,a=e.top,c=e.top,u,d;for(let h=n.firstChild,p=0;h;h=h.nextSibling,p++){let y;if(h.nodeType==1)y=h.getClientRects();else if(h.nodeType==3)y=xn(h).getClientRects();else continue;for(let g=0;g<y.length;g++){let _=y[g];if(_.top<=a&&_.bottom>=c){a=Math.max(_.bottom,a),c=Math.min(_.top,c);let w=_.left>e.left?_.left-e.left:_.right<e.left?e.left-_.right:0;if(w<r){t=h,r=w,i=w&&t.nodeType==3?{left:_.right<e.left?_.right:_.left,top:e.top}:e,h.nodeType==1&&w&&(s=p+(e.left>=(_.left+_.right)/2?1:0));continue}}else _.top>e.top&&!u&&_.left<=e.left&&_.right>=e.left&&(u=h,d={left:Math.max(_.left,Math.min(_.right,e.left)),top:_.top});!t&&(e.left>=_.right&&e.top>=_.top||e.left>=_.left&&e.top>=_.bottom)&&(s=p+1)}}return!t&&u&&(t=u,i=d,r=0),t&&t.nodeType==3?EO(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:ug(t,i)}function EO(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let s=Vn(r,1);if(s.top!=s.bottom&&Yc(e,s))return{node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function Yc(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function OO(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function TO(n,e,t){let{node:r,offset:i}=ug(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let a=r.getBoundingClientRect();s=a.left!=a.right&&t.left>(a.left+a.right)/2?1:-1}return n.docView.posFromDOM(r,i,s)}function AO(n,e,t,r){let i=-1;for(let s=e,a=!1;s!=n.dom;){let c=n.docView.nearestDesc(s,!0),u;if(!c)return null;if(c.dom.nodeType==1&&(c.node.isBlock&&c.parent||!c.contentDOM)&&((u=c.dom.getBoundingClientRect()).width||u.height)&&(c.node.isBlock&&c.parent&&(!a&&u.left>r.left||u.top>r.top?i=c.posBefore:(!a&&u.right<r.left||u.bottom<r.top)&&(i=c.posAfter),a=!0),!c.contentDOM&&i<0&&!c.node.isText))return(c.node.isBlock?r.top<(u.top+u.bottom)/2:r.left<(u.left+u.right)/2)?c.posBefore:c.posAfter;s=c.dom.parentNode}return i>-1?i:n.docView.posFromDOM(e,t,-1)}function fg(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let a=n.childNodes[s];if(a.nodeType==1){let c=a.getClientRects();for(let u=0;u<c.length;u++){let d=c[u];if(Yc(e,d))return fg(a,e,d)}}if((s=(s+1)%r)==i)break}return n}function CO(n,e){let t=n.dom.ownerDocument,r,i=0,s=yO(t,e.left,e.top);s&&({node:r,offset:i}=s);let a=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),c;if(!a||!n.dom.contains(a.nodeType!=1?a.parentNode:a)){let d=n.dom.getBoundingClientRect();if(!Yc(e,d)||(a=fg(n.dom,e,d),!a))return null}if(ft)for(let d=a;r&&d;d=ui(d))d.draggable&&(r=void 0);if(a=OO(a,e),r){if(en&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let h=r.childNodes[i],p;h.nodeName=="IMG"&&(p=h.getBoundingClientRect()).right<=e.left&&p.bottom>e.top&&i++}let d;us&&i&&r.nodeType==1&&(d=r.childNodes[i-1]).nodeType==1&&d.contentEditable=="false"&&d.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?c=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(c=AO(n,r,i,e))}c==null&&(c=TO(n,a,e));let u=n.docView.nearestDesc(a,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function Kh(n){return n.top<n.bottom||n.left<n.right}function Vn(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Kh(r))return r}return Array.prototype.find.call(t,Kh)||n.getBoundingClientRect()}const MO=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function dg(n,e,t){let{node:r,offset:i,atom:s}=n.docView.domFromPos(e,t<0?-1:1),a=us||en;if(r.nodeType==3)if(a&&(MO.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let u=Vn(xn(r,i,i),t);if(en&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let d=Vn(xn(r,i-1,i-1),-1);if(d.top==u.top){let h=Vn(xn(r,i,i+1),-1);if(h.top!=u.top)return Wi(h,h.left<d.left)}}return u}else{let u=i,d=i,h=t<0?1:-1;return t<0&&!i?(d++,h=-1):t>=0&&i==r.nodeValue.length?(u--,h=1):t<0?u--:d++,Wi(Vn(xn(r,u,d),h),h<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==zt(r))){let u=r.childNodes[i-1];if(u.nodeType==1)return Dl(u.getBoundingClientRect(),!1)}if(s==null&&i<zt(r)){let u=r.childNodes[i];if(u.nodeType==1)return Dl(u.getBoundingClientRect(),!0)}return Dl(r.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==zt(r))){let u=r.childNodes[i-1],d=u.nodeType==3?xn(u,zt(u)-(a?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(d)return Wi(Vn(d,1),!1)}if(s==null&&i<zt(r)){let u=r.childNodes[i];for(;u.pmViewDesc&&u.pmViewDesc.ignoreForCoords;)u=u.nextSibling;let d=u?u.nodeType==3?xn(u,0,a?0:1):u.nodeType==1?u:null:null;if(d)return Wi(Vn(d,-1),!0)}return Wi(Vn(r.nodeType==3?xn(r):r,-t),t>=0)}function Wi(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Dl(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function hg(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function NO(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return hg(n,e,()=>{let{node:s}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let c=n.docView.nearestDesc(s,!0);if(!c)break;if(c.node.isBlock){s=c.contentDOM||c.dom;break}s=c.dom.parentNode}let a=dg(n,i.pos,1);for(let c=s.firstChild;c;c=c.nextSibling){let u;if(c.nodeType==1)u=c.getClientRects();else if(c.nodeType==3)u=xn(c,0,c.nodeValue.length).getClientRects();else continue;for(let d=0;d<u.length;d++){let h=u[d];if(h.bottom>h.top+1&&(t=="up"?a.top-h.top>(h.bottom-a.top)*2:h.bottom-a.bottom>(a.bottom-h.top)*2))return!1}}return!0})}const IO=/[\u0590-\u08ac]/;function PO(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,a=i==r.parent.content.size,c=n.domSelection();return c?!IO.test(r.parent.textContent)||!c.modify?t=="left"||t=="backward"?s:a:hg(n,e,()=>{let{focusNode:u,focusOffset:d,anchorNode:h,anchorOffset:p}=n.domSelectionRange(),y=c.caretBidiLevel;c.modify("move",t,"character");let g=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:_,focusOffset:w}=n.domSelectionRange(),k=_&&!g.contains(_.nodeType==1?_:_.parentNode)||u==_&&d==w;try{c.collapse(h,p),u&&(u!=h||d!=p)&&c.extend&&c.extend(u,d)}catch{}return y!=null&&(c.caretBidiLevel=y),k}):r.pos==r.start()||r.pos==r.end()}let jh=null,qh=null,Jh=!1;function RO(n,e,t){return jh==e&&qh==t?Jh:(jh=e,qh=t,Jh=t=="up"||t=="down"?NO(n,e,t):PO(n,e,t))}const Ut=0,Gh=1,yr=2,un=3;class fs{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=Ut,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let i=this.children[t];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,a;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((a=s.pmViewDesc)&&a.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(a)+a.size:this.posAtStart}else{let s,a;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((a=s.pmViewDesc)&&a.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(a):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>Xe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),a;if(s&&(!t||s.node))if(r&&(a=s.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let a=0;a<i.children.length;a++){let c=i.children[a];if(c.size){i=c;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let a=this.children[r],c=s+a.size;if(c>e||a instanceof mg){i=e-s;break}s=c}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof pg&&s.side>=0;r--);if(t<=0){let s,a=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,a=!1);return s&&t&&a&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Xe(s.dom)+1:0}}else{let s,a=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,a=!1);return s&&a&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Xe(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let a=r,c=0;;c++){let u=this.children[c],d=a+u.size;if(i==-1&&e<=d){let h=a+u.border;if(e>=h&&t<=d-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,t,h);e=a;for(let p=c;p>0;p--){let y=this.children[p-1];if(y.size&&y.dom.parentNode==this.contentDOM&&!y.emptyChildAt(1)){i=Xe(y.dom)+1;break}e-=y.size}i==-1&&(i=0)}if(i>-1&&(d>t||c==this.children.length-1)){t=d;for(let h=c+1;h<this.children.length;h++){let p=this.children[h];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(-1)){s=Xe(p.dom);break}t+=p.size}s==-1&&(s=this.contentDOM.childNodes.length);break}a=d}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,i=!1){let s=Math.min(e,t),a=Math.max(e,t);for(let g=0,_=0;g<this.children.length;g++){let w=this.children[g],k=_+w.size;if(s>_&&a<k)return w.setSelection(e-_-w.border,t-_-w.border,r,i);_=k}let c=this.domFromPos(e,e?-1:1),u=t==e?c:this.domFromPos(t,t?-1:1),d=r.root.getSelection(),h=r.domSelectionRange(),p=!1;if((en||ft)&&e==t){let{node:g,offset:_}=c;if(g.nodeType==3){if(p=!!(_&&g.nodeValue[_-1]==`
173
+ `),p&&_==g.nodeValue.length)for(let w=g,k;w;w=w.parentNode){if(k=w.nextSibling){k.nodeName=="BR"&&(c=u={node:k.parentNode,offset:Xe(k)+1});break}let A=w.pmViewDesc;if(A&&A.node&&A.node.isBlock)break}}else{let w=g.childNodes[_-1];p=w&&(w.nodeName=="BR"||w.contentEditable=="false")}}if(en&&h.focusNode&&h.focusNode!=u.node&&h.focusNode.nodeType==1){let g=h.focusNode.childNodes[h.focusOffset];g&&g.contentEditable=="false"&&(i=!0)}if(!(i||p&&ft)&&Ar(c.node,c.offset,h.anchorNode,h.anchorOffset)&&Ar(u.node,u.offset,h.focusNode,h.focusOffset))return;let y=!1;if((d.extend||e==t)&&!p){d.collapse(c.node,c.offset);try{e!=t&&d.extend(u.node,u.offset),y=!0}catch{}}if(!y){if(e>t){let _=c;c=u,u=_}let g=document.createRange();g.setEnd(u.node,u.offset),g.setStart(c.node,c.offset),d.removeAllRanges(),d.addRange(g)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,i=0;i<this.children.length;i++){let s=this.children[i],a=r+s.size;if(r==a?e<=a&&t>=r:e<a&&t>r){let c=r+s.border,u=a-s.border;if(e>=c&&t<=u){this.dirty=e==r||t==a?yr:Gh,e==c&&t==u&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=un:s.markDirty(e-c,t-c);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?yr:un}r=a}this.dirty=yr}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?yr:Gh;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class pg extends fs{constructor(e,t,r,i){let s,a=t.type.toDOM;if(typeof a=="function"&&(a=a(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(a.nodeType!=1){let c=document.createElement("span");c.appendChild(a),a=c}a.contentEditable="false",a.classList.add("ProseMirror-widget")}super(e,[],a,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Ut&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class DO extends fs{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Cr extends fs{constructor(e,t,r,i,s){super(e,[],r,i),this.mark=t,this.spec=s}static create(e,t,r,i){let s=i.nodeViews[t.type.name],a=s&&s(t,i,r);return(!a||!a.dom)&&(a=Ir.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new Cr(e,t,a.dom,a.contentDOM||a.dom,a)}parseRule(){return this.dirty&un||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=un&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ut){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ut}}slice(e,t,r){let i=Cr.create(this.parent,this.mark,!0,r),s=this.children,a=this.size;t<a&&(s=Oc(s,t,a,r)),e>0&&(s=Oc(s,0,e,r));for(let c=0;c<s.length;c++)s[c].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Xn extends fs{constructor(e,t,r,i,s,a,c,u,d){super(e,[],s,a),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=c}static create(e,t,r,i,s,a){let c=s.nodeViews[t.type.name],u,d=c&&c(t,s,()=>{if(!u)return a;if(u.parent)return u.parent.posBeforeChild(u)},r,i),h=d&&d.dom,p=d&&d.contentDOM;if(t.isText){if(!h)h=document.createTextNode(t.text);else if(h.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else h||({dom:h,contentDOM:p}=Ir.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!p&&!t.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),t.type.spec.draggable&&(h.draggable=!0));let y=h;return h=_g(h,r,t),d?u=new LO(e,t,r,i,h,p||null,y,d,s,a+1):t.isText?new jo(e,t,r,i,h,y,s):new Xn(e,t,r,i,h,p||null,y,s,a+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>D.empty)}return e}matchesNode(e,t,r){return this.dirty==Ut&&e.eq(this.node)&&No(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,a=s&&s.pos>-1?s:null,c=s&&s.pos<0,u=new FO(this,a&&a.node,e);WO(this.node,this.innerDeco,(d,h,p)=>{d.spec.marks?u.syncToMarks(d.spec.marks,r,e):d.type.side>=0&&!p&&u.syncToMarks(h==this.node.childCount?we.none:this.node.child(h).marks,r,e),u.placeWidget(d,e,i)},(d,h,p,y)=>{u.syncToMarks(d.marks,r,e);let g;u.findNodeMatch(d,h,p,y)||c&&e.state.selection.from>i&&e.state.selection.to<i+d.nodeSize&&(g=u.findIndexWithChild(s.node))>-1&&u.updateNodeAt(d,h,p,g,e)||u.updateNextNode(d,h,p,e,y,i)||u.addNode(d,h,p,e,i),i+=d.nodeSize}),u.syncToMarks([],r,e),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==yr)&&(a&&this.protectLocalComposition(e,a),gg(this.contentDOM,this.children,e),fi&&VO(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof re)||r<t||i>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let a=s.nodeValue,c=HO(this.node.content,a,r-t,i-t);return c<0?null:{node:s,pos:c,text:a}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let a=new DO(this,s,t,i);e.input.compositionNodes.push(a),this.children=Oc(this.children,r,r+i.length,e,a)}update(e,t,r,i){return this.dirty==un||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Ut}updateOuterDeco(e){if(No(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=yg(this.dom,this.nodeDOM,Ec(this.outerDeco,this.node,t),Ec(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Yh(n,e,t,r,i){_g(r,e,n);let s=new Xn(void 0,n,e,t,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class jo extends Xn{constructor(e,t,r,i,s,a,c){super(e,t,r,i,s,null,a,c,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,i){return this.dirty==un||this.dirty!=Ut&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ut||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Ut,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new jo(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=un)}get domAtom(){return!1}isText(e){return this.node.text==e}}class mg extends fs{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ut&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class LO extends Xn{constructor(e,t,r,i,s,a,c,u,d,h){super(e,t,r,i,s,a,c,d,h),this.spec=u}update(e,t,r,i){if(this.dirty==un)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,i)}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 gg(n,e,t){let r=n.firstChild,i=!1;for(let s=0;s<e.length;s++){let a=e[s],c=a.dom;if(c.parentNode==n){for(;c!=r;)r=Qh(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(c,r);if(a instanceof Cr){let u=r?r.previousSibling:n.lastChild;gg(a.contentDOM,a.children,t),r=u?u.nextSibling:n.firstChild}}for(;r;)r=Qh(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const Ji=function(n){n&&(this.nodeName=n)};Ji.prototype=Object.create(null);const _r=[new Ji];function Ec(n,e,t){if(n.length==0)return _r;let r=t?_r[0]:new Ji,i=[r];for(let s=0;s<n.length;s++){let a=n[s].type.attrs;if(a){a.nodeName&&i.push(r=new Ji(a.nodeName));for(let c in a){let u=a[c];u!=null&&(t&&i.length==1&&i.push(r=new Ji(e.isInline?"span":"div")),c=="class"?r.class=(r.class?r.class+" ":"")+u:c=="style"?r.style=(r.style?r.style+";":"")+u:c!="nodeName"&&(r[c]=u))}}}return i}function yg(n,e,t,r){if(t==_r&&r==_r)return e;let i=e;for(let s=0;s<r.length;s++){let a=r[s],c=t[s];if(s){let u;c&&c.nodeName==a.nodeName&&i!=n&&(u=i.parentNode)&&u.nodeName.toLowerCase()==a.nodeName||(u=document.createElement(a.nodeName),u.pmIsDeco=!0,u.appendChild(i),c=_r[0]),i=u}BO(i,c||_r[0],a)}return i}function BO(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&n.classList.add(i[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function _g(n,e,t){return yg(n,n,_r,Ec(e,t,n.nodeType!=1))}function No(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Qh(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class FO{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=$O(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let i=0,s=this.stack.length>>1,a=Math.min(s,e.length);for(;i<a&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=Ut,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let c=-1;for(let u=this.index;u<Math.min(this.index+3,this.top.children.length);u++){let d=this.top.children[u];if(d.matchesMark(e[s])&&!this.isLocked(d.dom)){c=u;break}}if(c>-1)c>this.index&&(this.changed=!0,this.destroyBetween(this.index,c)),this.top=this.top.children[this.index];else{let u=Cr.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,i){let s=-1,a;if(i>=this.preMatch.index&&(a=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,r))s=this.top.children.indexOf(a,this.index);else for(let c=this.index,u=Math.min(this.top.children.length,c+5);c<u;c++){let d=this.top.children[c];if(d.matchesNode(e,t,r)&&!this.preMatch.matched.has(d)){s=c;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,i,s){let a=this.top.children[i];return a.dirty==un&&a.dom==a.contentDOM&&(a.dirty=yr),a.update(e,t,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=t}}updateNextNode(e,t,r,i,s,a){for(let c=this.index;c<this.top.children.length;c++){let u=this.top.children[c];if(u instanceof Xn){let d=this.preMatch.matched.get(u);if(d!=null&&d!=s)return!1;let h=u.dom,p,y=this.isLocked(h)&&!(e.isText&&u.node&&u.node.isText&&u.nodeDOM.nodeValue==e.text&&u.dirty!=un&&No(t,u.outerDeco));if(!y&&u.update(e,t,r,i))return this.destroyBetween(this.index,c),u.dom!=h&&(this.changed=!0),this.index++,!0;if(!y&&(p=this.recreateWrapper(u,e,t,r,i,a)))return this.destroyBetween(this.index,c),this.top.children[this.index]=p,p.contentDOM&&(p.dirty=yr,p.updateChildren(i,a+1),p.dirty=Ut),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,i,s,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!No(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let c=Xn.create(this.top,t,r,i,s,a);if(c.contentDOM){c.children=e.children,e.children=[];for(let u of c.children)u.parent=c}return e.destroy(),c}addNode(e,t,r,i,s){let a=Xn.create(this.top,e,t,r,i,s);a.contentDOM&&a.updateChildren(i,s+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,t,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new pg(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Cr;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof jo)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ft||rt)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new mg(this.top,[],r,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function $O(n,e){let t=e,r=t.children.length,i=n.childCount,s=new Map,a=[];e:for(;i>0;){let c;for(;;)if(r){let d=t.children[r-1];if(d instanceof Cr)t=d,r=d.children.length;else{c=d,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let u=c.node;if(u){if(u!=n.child(i-1))break;--i,s.set(c,i),a.push(c)}}return{index:i,matched:s,matches:a.reverse()}}function zO(n,e){return n.type.side-e.type.side}function WO(n,e,t,r){let i=e.locals(n),s=0;if(i.length==0){for(let d=0;d<n.childCount;d++){let h=n.child(d);r(h,i,e.forChild(s,h),d),s+=h.nodeSize}return}let a=0,c=[],u=null;for(let d=0;;){let h,p;for(;a<i.length&&i[a].to==s;){let k=i[a++];k.widget&&(h?(p||(p=[h])).push(k):h=k)}if(h)if(p){p.sort(zO);for(let k=0;k<p.length;k++)t(p[k],d,!!u)}else t(h,d,!!u);let y,g;if(u)g=-1,y=u,u=null;else if(d<n.childCount)g=d,y=n.child(d++);else break;for(let k=0;k<c.length;k++)c[k].to<=s&&c.splice(k--,1);for(;a<i.length&&i[a].from<=s&&i[a].to>s;)c.push(i[a++]);let _=s+y.nodeSize;if(y.isText){let k=_;a<i.length&&i[a].from<k&&(k=i[a].from);for(let A=0;A<c.length;A++)c[A].to<k&&(k=c[A].to);k<_&&(u=y.cut(k-s),y=y.cut(0,k-s),_=k,g=-1)}else for(;a<i.length&&i[a].to<_;)a++;let w=y.isInline&&!y.isLeaf?c.filter(k=>!k.inline):c.slice();r(y,w,e.forChild(s,y),g),s=_}}function VO(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function HO(n,e,t,r){for(let i=0,s=0;i<n.childCount&&s<=r;){let a=n.child(i++),c=s;if(s+=a.nodeSize,!a.isText)continue;let u=a.text;for(;i<n.childCount;){let d=n.child(i++);if(s+=d.nodeSize,!d.isText)break;u+=d.text}if(s>=t){if(s>=r&&u.slice(r-e.length-c,r-c)==e)return r-e.length;let d=c<r?u.lastIndexOf(e,r-c-1):-1;if(d>=0&&d+e.length+c>=t)return c+d;if(t==r&&u.length>=r+e.length-c&&u.slice(r-c,r-c+e.length)==e)return r}}return-1}function Oc(n,e,t,r,i){let s=[];for(let a=0,c=0;a<n.length;a++){let u=n[a],d=c,h=c+=u.size;d>=t||h<=e?s.push(u):(d<e&&s.push(u.slice(0,e-d,r)),i&&(s.push(i),i=void 0),h>t&&s.push(u.slice(t-d,u.size,r)))}return s}function Qc(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,a=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(a<0)return null;let c=r.resolve(a),u,d;if(Ko(t)){for(u=a;i&&!i.node;)i=i.parent;let p=i.node;if(i&&p.isAtom&&Q.isSelectable(p)&&i.parent&&!(p.isInline&&mO(t.focusNode,t.focusOffset,i.dom))){let y=i.posBefore;d=new Q(a==y?c:r.resolve(y))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let p=a,y=a;for(let g=0;g<t.rangeCount;g++){let _=t.getRangeAt(g);p=Math.min(p,n.docView.posFromDOM(_.startContainer,_.startOffset,1)),y=Math.max(y,n.docView.posFromDOM(_.endContainer,_.endOffset,-1))}if(p<0)return null;[u,a]=y==n.state.selection.anchor?[y,p]:[p,y],c=r.resolve(a)}else u=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(u<0)return null}let h=r.resolve(u);if(!d){let p=e=="pointer"||n.state.selection.head<c.pos&&!s?1:-1;d=Xc(n,h,c,p)}return d}function bg(n){return n.editable?n.hasFocus():Sg(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Mn(n,e=!1){let t=n.state.selection;if(vg(n,t),!!bg(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&rt){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Ar(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)KO(n);else{let{anchor:r,head:i}=t,s,a;Xh&&!(t instanceof re)&&(t.$from.parent.inlineContent||(s=Zh(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(a=Zh(n,t.to))),n.docView.setSelection(r,i,n,e),Xh&&(s&&ep(s),a&&ep(a)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&UO(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Xh=ft||rt&&ag<63;function Zh(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(ft&&i&&i.contentEditable=="false")return Ll(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Ll(i);if(s)return Ll(s)}}function Ll(n){return n.contentEditable="true",ft&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function ep(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function UO(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!bg(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function KO(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,i=r.nodeName=="IMG";i?t.setStart(r.parentNode,Xe(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&bt&&Qn<=11&&(r.disabled=!0,r.disabled=!1)}function vg(n,e){if(e instanceof Q){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(tp(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else tp(n)}function tp(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Xc(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||re.between(e,t,r)}function np(n){return n.editable&&!n.hasFocus()?!1:Sg(n)}function Sg(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function jO(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Ar(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Tc(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&ae.findFrom(s,e)}function Hn(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function rp(n,e,t){let r=n.state.selection;if(r instanceof re)if(t.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let a=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Hn(n,new re(r.$anchor,a))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=Tc(n.state,e);return i&&i instanceof Q?Hn(n,i):!1}else if(!($t&&t.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,a;if(!s||s.isText)return!1;let c=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(a=n.docView.descAt(c))&&!a.contentDOM?Q.isSelectable(s)?Hn(n,new Q(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):us?Hn(n,new re(n.state.doc.resolve(e<0?c:c+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Q&&r.node.isInline)return Hn(n,new re(e>0?r.$to:r.$from));{let i=Tc(n.state,e);return i?Hn(n,i):!1}}}function Io(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Gi(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Qr(n,e){return e<0?qO(n):JO(n)}function qO(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,a=!1;for(en&&t.nodeType==1&&r<Io(t)&&Gi(t.childNodes[r],-1)&&(a=!0);;)if(r>0){if(t.nodeType!=1)break;{let c=t.childNodes[r-1];if(Gi(c,-1))i=t,s=--r;else if(c.nodeType==3)t=c,r=t.nodeValue.length;else break}}else{if(wg(t))break;{let c=t.previousSibling;for(;c&&Gi(c,-1);)i=t.parentNode,s=Xe(c),c=c.previousSibling;if(c)t=c,r=Io(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}a?Ac(n,t,r):i&&Ac(n,i,s)}function JO(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=Io(t),s,a;for(;;)if(r<i){if(t.nodeType!=1)break;let c=t.childNodes[r];if(Gi(c,1))s=t,a=++r;else break}else{if(wg(t))break;{let c=t.nextSibling;for(;c&&Gi(c,1);)s=c.parentNode,a=Xe(c)+1,c=c.nextSibling;if(c)t=c,r=0,i=Io(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&Ac(n,s,a)}function wg(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function GO(n,e){for(;n&&e==n.childNodes.length&&!cs(n);)e=Xe(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function YO(n,e){for(;n&&!e&&!cs(n);)e=Xe(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Ac(n,e,t){if(e.nodeType!=3){let s,a;(a=GO(e,t))?(e=a,t=0):(s=YO(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Ko(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&Mn(n)},50)}function ip(n,e){let t=n.state.doc.resolve(e);if(!(rt||_O)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),a=(s.top+s.bottom)/2;if(a>i.top&&a<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),a=(s.top+s.bottom)/2;if(a>i.top&&a<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function sp(n,e,t){let r=n.state.selection;if(r instanceof re&&!r.empty||t.indexOf("s")>-1||$t&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let a=Tc(n.state,e);if(a&&a instanceof Q)return Hn(n,a)}if(!i.parent.inlineContent){let a=e<0?i:s,c=r instanceof Ct?ae.near(a,e):ae.findFrom(a,e);return c?Hn(n,c):!1}return!1}function op(n,e){if(!(n.state.selection instanceof re))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let a=n.state.tr;return e<0?a.delete(t.pos-s.nodeSize,t.pos):a.delete(t.pos,t.pos+s.nodeSize),n.dispatch(a),!0}return!1}function ap(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function QO(n){if(!ft||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;ap(n,r,"true"),setTimeout(()=>ap(n,r,"false"),20)}return!1}function XO(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function ZO(n,e){let t=e.keyCode,r=XO(e);if(t==8||$t&&t==72&&r=="c")return op(n,-1)||Qr(n,-1);if(t==46&&!e.shiftKey||$t&&t==68&&r=="c")return op(n,1)||Qr(n,1);if(t==13||t==27)return!0;if(t==37||$t&&t==66&&r=="c"){let i=t==37?ip(n,n.state.selection.from)=="ltr"?-1:1:-1;return rp(n,i,r)||Qr(n,i)}else if(t==39||$t&&t==70&&r=="c"){let i=t==39?ip(n,n.state.selection.from)=="ltr"?1:-1:1;return rp(n,i,r)||Qr(n,i)}else{if(t==38||$t&&t==80&&r=="c")return sp(n,-1,r)||Qr(n,-1);if(t==40||$t&&t==78&&r=="c")return QO(n)||sp(n,1,r)||Qr(n,1);if(r==($t?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Zc(n,e){n.someProp("transformCopied",g=>{e=g(e,n)});let t=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let g=r.firstChild;t.push(g.type.name,g.attrs!=g.type.defaultAttrs?g.attrs:null),r=g.content}let a=n.someProp("clipboardSerializer")||Ir.fromSchema(n.state.schema),c=Ag(),u=c.createElement("div");u.appendChild(a.serializeFragment(r,{document:c}));let d=u.firstChild,h,p=0;for(;d&&d.nodeType==1&&(h=Tg[d.nodeName.toLowerCase()]);){for(let g=h.length-1;g>=0;g--){let _=c.createElement(h[g]);for(;u.firstChild;)_.appendChild(u.firstChild);u.appendChild(_),p++}d=u.firstChild}d&&d.nodeType==1&&d.setAttribute("data-pm-slice",`${i} ${s}${p?` -${p}`:""} ${JSON.stringify(t)}`);let y=n.someProp("clipboardTextSerializer",g=>g(e,n))||e.content.textBetween(0,e.content.size,`
172
174
 
173
175
  `);return{dom:u,text:y,slice:e}}function kg(n,e,t,r,i){let s=i.parent.type.spec.code,a,c;if(!t&&!e)return null;let u=e&&(r||s||!t);if(u){if(n.someProp("transformPastedText",y=>{e=y(e,s||r,n)}),s)return e?new H(D.from(n.state.schema.text(e.replace(/\r\n?/g,`
174
- `))),0,0):H.empty;let p=n.someProp("clipboardTextParser",y=>y(e,i,r,n));if(p)c=p;else{let y=i.marks(),{schema:g}=n.state,_=Nr.fromSchema(g);a=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(w=>{let k=a.appendChild(document.createElement("p"));w&&k.appendChild(_.serializeNode(g.text(w,y)))})}}else n.someProp("transformPastedHTML",p=>{t=p(t,n)}),a=rT(t),us&&iT(a);let d=a&&a.querySelector("[data-pm-slice]"),h=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let p=+h[3];p>0;p--){let y=a.firstChild;for(;y&&y.nodeType!=1;)y=y.nextSibling;if(!y)break;a=y}if(c||(c=(n.someProp("clipboardParser")||n.someProp("domParser")||Yn.fromSchema(n.state.schema)).parseSlice(a,{preserveWhitespace:!!(u||h),context:i,ruleFromNode(y){return y.nodeName=="BR"&&!y.nextSibling&&y.parentNode&&!eT.test(y.parentNode.nodeName)?{ignore:!0}:null}})),h)c=sT(lp(c,+h[1],+h[2]),h[4]);else if(c=H.maxOpen(tT(c.content,i),!0),c.openStart||c.openEnd){let p=0,y=0;for(let g=c.content.firstChild;p<c.openStart&&!g.type.spec.isolating;p++,g=g.firstChild);for(let g=c.content.lastChild;y<c.openEnd&&!g.type.spec.isolating;y++,g=g.lastChild);c=lp(c,p,y)}return n.someProp("transformPasted",p=>{c=p(c,n)}),c}const eT=/^(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 tT(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,a=[];if(n.forEach(c=>{if(!a)return;let u=i.findWrapping(c.type),d;if(!u)return a=null;if(d=a.length&&s.length&&Eg(u,s,c,a[a.length-1],0))a[a.length-1]=d;else{a.length&&(a[a.length-1]=Og(a[a.length-1],s.length));let h=xg(c,u);a.push(h),i=i.matchType(h.type),s=u}}),a)return D.from(a)}return n}function xg(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,D.from(n));return n}function Eg(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=Eg(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(D.from(xg(t,n,i+1))))}}function Og(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Og(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(D.empty,!0);return n.copy(t.append(r))}function Cc(n,e,t,r,i,s){let a=e<0?n.firstChild:n.lastChild,c=a.content;return n.childCount>1&&(s=0),i<r-1&&(c=Cc(c,e,t,r,i+1,s)),i>=t&&(c=e<0?a.contentMatchAt(0).fillBefore(c,s<=i).append(c):c.append(a.contentMatchAt(a.childCount).fillBefore(D.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,a.copy(c))}function lp(n,e,t){return e<n.openStart&&(n=new H(Cc(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new H(Cc(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Tg={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let cp=null;function Ag(){return cp||(cp=document.implementation.createHTMLDocument("title"))}let Bl=null;function nT(n){let e=window.trustedTypes;return e?(Bl||(Bl=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Bl.createHTML(n)):n}function rT(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Ag().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Tg[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=nT(n),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function iT(n){let e=n.querySelectorAll(rt?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function sT(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:a}=n;for(let c=r.length-2;c>=0;c-=2){let u=t.nodes[r[c]];if(!u||u.hasRequiredAttrs())break;i=D.from(u.create(r[c+1],i)),s++,a++}return new H(i,s,a)}const dt={},ht={},oT={touchstart:!0,touchmove:!0};class aT{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function lT(n){for(let e in dt){let t=dt[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{uT(n,r)&&!eu(n,r)&&(n.editable||!(r.type in ht))&&t(n,r)},oT[e]?{passive:!0}:void 0)}ft&&n.dom.addEventListener("input",()=>null),Mc(n)}function Jn(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function cT(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Mc(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>eu(n,r))})}function eu(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function uT(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function fT(n,e){!eu(n,e)&&dt[e.type]&&(n.editable||!(e.type in ht))&&dt[e.type](n,e)}ht.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Mg(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(On&&rt&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),ui&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,pr(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||ZO(n,t)?t.preventDefault():Jn(n,"key")};ht.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};ht.keypress=(n,e)=>{let t=e;if(Mg(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||$t&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof re)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,i))&&n.dispatch(n.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function qo(n){return{left:n.clientX,top:n.clientY}}function dT(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function tu(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let a=s.depth+1;a>0;a--)if(n.someProp(e,c=>a>s.depth?c(n,t,s.nodeAfter,s.before(a),i,!0):c(n,t,s.node(a),s.before(a),i,!1)))return!0;return!1}function ii(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function hT(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&Q.isSelectable(r)?(ii(n,new Q(t)),!0):!1}function pT(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof Q&&(r=t.node);let s=n.state.doc.resolve(e);for(let a=s.depth+1;a>0;a--){let c=a>s.depth?s.nodeAfter:s.node(a);if(Q.isSelectable(c)){r&&t.$from.depth>0&&a>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(a);break}}return i!=null?(ii(n,Q.create(n.state.doc,i)),!0):!1}function mT(n,e,t,r,i){return tu(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?pT(n,t):hT(n,t))}function gT(n,e,t,r){return tu(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function yT(n,e,t,r){return tu(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||_T(n,t,r)}function _T(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(ii(n,re.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let a=s>i.depth?i.nodeAfter:i.node(s),c=i.before(s);if(a.inlineContent)ii(n,re.create(r,c+1,c+1+a.content.size));else if(Q.isSelectable(a))ii(n,Q.create(r,c));else continue;return!0}}function nu(n){return Po(n)}const Cg=$t?"metaKey":"ctrlKey";dt.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=nu(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&dT(t,n.input.lastClick)&&!t[Cg]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s};let a=n.posAtCoords(qo(t));a&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new bT(n,a,t,!!r)):(s=="doubleClick"?gT:yT)(n,a.pos,a.inside,t)?t.preventDefault():Jn(n,"pointer"))};class bT{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Cg],this.allowDefault=r.shiftKey;let s,a;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),a=t.inside;else{let h=e.state.doc.resolve(t.pos);s=h.parent,a=h.depth?h.before():0}const c=i?null:r.target,u=c?e.docView.nearestDesc(c,!0):null;this.target=u&&u.dom.nodeType==1?u.dom:null;let{selection:d}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||d instanceof Q&&d.from<=a&&d.to>a)&&(this.mightDrag={node:s,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&en&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Jn(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Mn(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(qo(e))),this.updateAllowDefault(e),this.allowDefault||!t?Jn(this.view,"pointer"):mT(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ft&&this.mightDrag&&!this.mightDrag.node.isAtom||rt&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(ii(this.view,ae.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Jn(this.view,"pointer")}move(e){this.updateAllowDefault(e),Jn(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}dt.touchstart=n=>{n.input.lastTouch=Date.now(),nu(n),Jn(n,"pointer")};dt.touchmove=n=>{n.input.lastTouch=Date.now(),Jn(n,"pointer")};dt.contextmenu=n=>nu(n);function Mg(n,e){return n.composing?!0:ft&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const vT=On?5e3:-1;ht.compositionstart=ht.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof re&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Po(n,!0),n.markCursor=null;else if(Po(n,!e.selection.empty),en&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let a=s<0?i.lastChild:i.childNodes[s-1];if(!a)break;if(a.nodeType==3){let c=n.domSelection();c&&c.collapse(a,a.nodeValue.length);break}else i=a,s=-1}}n.input.composing=!0}Ng(n,vT)};ht.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Ng(n,20))};function Ng(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Po(n),e))}function Ig(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=wT());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function ST(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=hO(e.focusNode,e.focusOffset),r=pO(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let a=t.pmViewDesc;if(!(!a||!a.isText(t.nodeValue)))return r}}return t||r}function wT(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Po(n,e=!1){if(!(On&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ig(n),e||n.docView&&n.docView.dirty){let t=Qc(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function kT(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const ns=bt&&Qn<15||ui&&bO<604;dt.copy=ht.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=ns?null:t.clipboardData,a=r.content(),{dom:c,text:u}=Zc(n,a);s?(t.preventDefault(),s.clearData(),s.setData("text/html",c.innerHTML),s.setData("text/plain",u)):kT(n,c),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function xT(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function ET(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?rs(n,r.value,null,i,e):rs(n,r.textContent,r.innerHTML,i,e)},50)}function rs(n,e,t,r,i){let s=kg(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",u=>u(n,i,s||H.empty)))return!0;if(!s)return!1;let a=xT(s),c=a?n.state.tr.replaceSelectionWith(a,r):n.state.tr.replaceSelection(s);return n.dispatch(c.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Pg(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ht.paste=(n,e)=>{let t=e;if(n.composing&&!On)return;let r=ns?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&rs(n,Pg(r),r.getData("text/html"),i,t)?t.preventDefault():ET(n,t)};class Rg{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Dg=$t?"altKey":"ctrlKey";dt.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(qo(t)),a;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof Q?i.to-1:i.to))){if(r&&r.mightDrag)a=Q.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let p=n.docView.nearestDesc(t.target,!0);p&&p.node.type.spec.draggable&&p!=n.docView&&(a=Q.create(n.state.doc,p.posBefore))}}let c=(a||n.state.selection).content(),{dom:u,text:d,slice:h}=Zc(n,c);(!t.dataTransfer.files.length||!rt||ag>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(ns?"Text":"text/html",u.innerHTML),t.dataTransfer.effectAllowed="copyMove",ns||t.dataTransfer.setData("text/plain",d),n.dragging=new Rg(h,!t[Dg],a)};dt.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};ht.dragover=ht.dragenter=(n,e)=>e.preventDefault();ht.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(qo(t));if(!i)return;let s=n.state.doc.resolve(i.pos),a=r&&r.slice;a?n.someProp("transformPasted",_=>{a=_(a,n)}):a=kg(n,Pg(t.dataTransfer),ns?null:t.dataTransfer.getData("text/html"),!1,s);let c=!!(r&&!t[Dg]);if(n.someProp("handleDrop",_=>_(n,t,a||H.empty,c))){t.preventDefault();return}if(!a)return;t.preventDefault();let u=a?Zm(n.state.doc,s.pos,a):s.pos;u==null&&(u=s.pos);let d=n.state.tr;if(c){let{node:_}=r;_?_.replace(d):d.deleteSelection()}let h=d.mapping.map(u),p=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,y=d.doc;if(p?d.replaceRangeWith(h,h,a.content.firstChild):d.replaceRange(h,h,a),d.doc.eq(y))return;let g=d.doc.resolve(h);if(p&&Q.isSelectable(a.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(a.content.firstChild))d.setSelection(new Q(g));else{let _=d.mapping.map(u);d.mapping.maps[d.mapping.maps.length-1].forEach((w,k,A,P)=>_=P),d.setSelection(Xc(n,g,d.doc.resolve(_)))}n.focus(),n.dispatch(d.setMeta("uiEvent","drop"))};dt.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Mn(n)},20))};dt.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};dt.beforeinput=(n,e)=>{if(rt&&On&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,pr(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in ht)dt[n]=ht[n];function is(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Ro{constructor(e,t){this.toDOM=e,this.spec=t||wr,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:a}=e.mapResult(t.from+i,this.side<0?-1:1);return a?null:new Wt(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Ro&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&is(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Zn{constructor(e,t){this.attrs=e,this.spec=t||wr}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,a=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=a?null:new Wt(s,a,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Zn&&is(this.attrs,e.attrs)&&is(this.spec,e.spec)}static is(e){return e.type instanceof Zn}destroy(){}}class ru{constructor(e,t){this.attrs=e,this.spec=t||wr}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let a=e.mapResult(t.to+i,-1);return a.deleted||a.pos<=s.pos?null:new Wt(s.pos-r,a.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof ru&&is(this.attrs,e.attrs)&&is(this.spec,e.spec)}destroy(){}}class Wt{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new Wt(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new Wt(e,e,new Ro(t,r))}static inline(e,t,r,i){return new Wt(e,t,new Zn(r,i))}static node(e,t,r,i){return new Wt(e,t,new ru(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Zn}get widget(){return this.type instanceof Ro}}const Zr=[],wr={};class $e{constructor(e,t){this.local=e.length?e:Zr,this.children=t.length?t:Zr}static create(e,t){return t.length?Do(t,e,0,wr):nt}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let a=0;a<this.local.length;a++){let c=this.local[a];c.from<=t&&c.to>=e&&(!s||s(c.spec))&&r.push(c.copy(c.from+i,c.to+i))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let c=this.children[a]+1;this.children[a+2].findInner(e-c,t-c,r,i+c,s)}}map(e,t,r){return this==nt||e.maps.length==0?this:this.mapInner(e,t,0,0,r||wr)}mapInner(e,t,r,i,s){let a;for(let c=0;c<this.local.length;c++){let u=this.local[c].map(e,r,i);u&&u.type.valid(t,u)?(a||(a=[])).push(u):s.onRemove&&s.onRemove(this.local[c].spec)}return this.children.length?OT(this.children,a||[],e,t,r,i,s):a?new $e(a.sort(kr),Zr):nt}add(e,t){return t.length?this==nt?$e.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((c,u)=>{let d=u+r,h;if(h=Bg(t,c,d)){for(i||(i=this.children.slice());s<i.length&&i[s]<u;)s+=3;i[s]==u?i[s+2]=i[s+2].addInner(c,h,d+1):i.splice(s,0,u,u+c.nodeSize,Do(h,c,d+1,wr)),s+=3}});let a=Lg(s?Fg(t):t,-r);for(let c=0;c<a.length;c++)a[c].type.valid(e,a[c])||a.splice(c--,1);return new $e(a.length?this.local.concat(a).sort(kr):this.local,i||this.children)}remove(e){return e.length==0||this==nt?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let a,c=r[s]+t,u=r[s+1]+t;for(let h=0,p;h<e.length;h++)(p=e[h])&&p.from>c&&p.to<u&&(e[h]=null,(a||(a=[])).push(p));if(!a)continue;r==this.children&&(r=this.children.slice());let d=r[s+2].removeInner(a,c+1);d!=nt?r[s+2]=d:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,a;s<e.length;s++)if(a=e[s])for(let c=0;c<i.length;c++)i[c].eq(a,t)&&(i==this.local&&(i=this.local.slice()),i.splice(c--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new $e(i,r):nt}forChild(e,t){if(this==nt)return this;if(t.isLeaf)return $e.empty;let r,i;for(let c=0;c<this.children.length;c+=3)if(this.children[c]>=e){this.children[c]==e&&(r=this.children[c+2]);break}let s=e+1,a=s+t.content.size;for(let c=0;c<this.local.length;c++){let u=this.local[c];if(u.from<a&&u.to>s&&u.type instanceof Zn){let d=Math.max(s,u.from)-s,h=Math.min(a,u.to)-s;d<h&&(i||(i=[])).push(u.copy(d,h))}}if(i){let c=new $e(i.sort(kr),Zr);return r?new Kn([c,r]):c}return r||nt}eq(e){if(this==e)return!0;if(!(e instanceof $e)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return iu(this.localsInner(e))}localsInner(e){if(this==nt)return Zr;if(e.inlineContent||!this.local.some(Zn.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Zn||t.push(this.local[r]);return t}forEachSet(e){e(this)}}$e.empty=new $e([],[]);$e.removeOverlap=iu;const nt=$e.empty;class Kn{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,wr));return Kn.from(r)}forChild(e,t){if(t.isLeaf)return $e.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=nt&&(s instanceof Kn?r=r.concat(s.members):r.push(s))}return Kn.from(r)}eq(e){if(!(e instanceof Kn)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let a=0;a<s.length;a++)t.push(s[a])}}return t?iu(r?t:t.sort(kr)):Zr}static from(e){switch(e.length){case 0:return nt;case 1:return e[0];default:return new Kn(e.every(t=>t instanceof $e)?e:e.reduce((t,r)=>t.concat(r instanceof $e?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function OT(n,e,t,r,i,s,a){let c=n.slice();for(let d=0,h=s;d<t.maps.length;d++){let p=0;t.maps[d].forEach((y,g,_,w)=>{let k=w-_-(g-y);for(let A=0;A<c.length;A+=3){let P=c[A+1];if(P<0||y>P+h-p)continue;let L=c[A]+h-p;g>=L?c[A+1]=y<=L?-2:-1:y>=h&&k&&(c[A]+=k,c[A+1]+=k)}p+=k}),h=t.maps[d].map(h,-1)}let u=!1;for(let d=0;d<c.length;d+=3)if(c[d+1]<0){if(c[d+1]==-2){u=!0,c[d+1]=-1;continue}let h=t.map(n[d]+s),p=h-i;if(p<0||p>=r.content.size){u=!0;continue}let y=t.map(n[d+1]+s,-1),g=y-i,{index:_,offset:w}=r.content.findIndex(p),k=r.maybeChild(_);if(k&&w==p&&w+k.nodeSize==g){let A=c[d+2].mapInner(t,k,h+1,n[d]+s+1,a);A!=nt?(c[d]=p,c[d+1]=g,c[d+2]=A):(c[d+1]=-2,u=!0)}else u=!0}if(u){let d=TT(c,n,e,t,i,s,a),h=Do(d,r,0,a);e=h.local;for(let p=0;p<c.length;p+=3)c[p+1]<0&&(c.splice(p,3),p-=3);for(let p=0,y=0;p<h.children.length;p+=3){let g=h.children[p];for(;y<c.length&&c[y]<g;)y+=3;c.splice(y,0,h.children[p],h.children[p+1],h.children[p+2])}}return new $e(e.sort(kr),c)}function Lg(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new Wt(i.from+e,i.to+e,i.type))}return t}function TT(n,e,t,r,i,s,a){function c(u,d){for(let h=0;h<u.local.length;h++){let p=u.local[h].map(r,i,d);p?t.push(p):a.onRemove&&a.onRemove(u.local[h].spec)}for(let h=0;h<u.children.length;h+=3)c(u.children[h+2],u.children[h]+d+1)}for(let u=0;u<n.length;u+=3)n[u+1]==-1&&c(n[u+2],e[u]+s+1);return t}function Bg(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,a;s<n.length;s++)(a=n[s])&&a.from>t&&a.to<r&&((i||(i=[])).push(a),n[s]=null);return i}function Fg(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Do(n,e,t,r){let i=[],s=!1;e.forEach((c,u)=>{let d=Bg(n,c,u+t);if(d){s=!0;let h=Do(d,c,t+u+1,r);h!=nt&&i.push(u,u+c.nodeSize,h)}});let a=Lg(s?Fg(n):n,-t).sort(kr);for(let c=0;c<a.length;c++)a[c].type.valid(e,a[c])||(r.onRemove&&r.onRemove(a[c].spec),a.splice(c--,1));return a.length||i.length?new $e(a,i):nt}function kr(n,e){return n.from-e.from||n.to-e.to}function iu(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),up(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),up(e,i,r.copy(s.from,r.to)));break}}}return e}function up(n,e,t){for(;e<n.length&&kr(t,n[e])>0;)e++;n.splice(e,0,t)}function Fl(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=nt&&e.push(r)}),n.cursorWrapper&&e.push($e.create(n.state.doc,[n.cursorWrapper.deco])),Kn.from(e)}const AT={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},CT=bt&&Qn<=11;class MT{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class NT{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new MT,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);bt&&Qn<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),CT&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,AT)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(np(this.view)){if(this.suppressingSelectionUpdates)return Mn(this.view);if(bt&&Qn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Tr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let s=e.focusNode;s;s=ci(s))t.add(s);for(let s=e.anchorNode;s;s=ci(s))if(t.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&np(e)&&!this.ignoreSelectionChange(r),s=-1,a=-1,c=!1,u=[];if(e.editable)for(let h=0;h<t.length;h++){let p=this.registerMutation(t[h],u);p&&(s=s<0?p.from:Math.min(p.from,s),a=a<0?p.to:Math.max(p.to,a),p.typeOver&&(c=!0))}if(en&&u.length){let h=u.filter(p=>p.nodeName=="BR");if(h.length==2){let[p,y]=h;p.parentNode&&p.parentNode.parentNode==y.parentNode?y.remove():p.remove()}else{let{focusNode:p}=this.currentSelection;for(let y of h){let g=y.parentNode;g&&g.nodeName=="LI"&&(!p||RT(e,p)!=g)&&y.remove()}}}let d=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ko(r)&&(d=Qc(e))&&d.eq(ae.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Mn(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,a),IT(e)),this.handleDOMChange(s,a,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Mn(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let h=0;h<e.addedNodes.length;h++){let p=e.addedNodes[h];t.push(p),p.nodeType==3&&(this.lastChangedTextNode=p)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(bt&&Qn<=11&&e.addedNodes.length)for(let h=0;h<e.addedNodes.length;h++){let{previousSibling:p,nextSibling:y}=e.addedNodes[h];(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(i=p),(!y||Array.prototype.indexOf.call(e.addedNodes,y)<0)&&(s=y)}let a=i&&i.parentNode==e.target?Xe(i)+1:0,c=r.localPosFromDOM(e.target,a,-1),u=s&&s.parentNode==e.target?Xe(s):e.target.childNodes.length,d=r.localPosFromDOM(e.target,u,1);return{from:c,to:d}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let fp=new WeakMap,dp=!1;function IT(n){if(!fp.has(n)&&(fp.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=en,dp)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."),dp=!0}}function hp(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,a=n.domAtPos(n.state.selection.anchor);return Tr(a.node,a.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function PT(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return hp(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?hp(n,t):null}function RT(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function DT(n,e,t){let{node:r,fromOffset:i,toOffset:s,from:a,to:c}=n.docView.parseRange(e,t),u=n.domSelectionRange(),d,h=u.anchorNode;if(h&&n.dom.contains(h.nodeType==1?h:h.parentNode)&&(d=[{node:h,offset:u.anchorOffset}],Ko(u)||d.push({node:u.focusNode,offset:u.focusOffset})),rt&&n.input.lastKeyCode===8)for(let k=s;k>i;k--){let A=r.childNodes[k-1],P=A.pmViewDesc;if(A.nodeName=="BR"&&!P){s=k;break}if(!P||P.size)break}let p=n.state.doc,y=n.someProp("domParser")||Yn.fromSchema(n.state.schema),g=p.resolve(a),_=null,w=y.parse(r,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:i,to:s,preserveWhitespace:g.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:LT,context:g});if(d&&d[0].pos!=null){let k=d[0].pos,A=d[1]&&d[1].pos;A==null&&(A=k),_={anchor:k+a,head:A+a}}return{doc:w,sel:_,from:a,to:c}}function LT(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(ft&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||ft&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const BT=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function FT(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let V=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,ne=Qc(n,V);if(ne&&!n.state.selection.eq(ne)){if(rt&&On&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",De=>De(n,pr(13,"Enter"))))return;let ve=n.state.tr.setSelection(ne);V=="pointer"?ve.setMeta("pointer",!0):V=="key"&&ve.scrollIntoView(),s&&ve.setMeta("composition",s),n.dispatch(ve)}return}let a=n.state.doc.resolve(e),c=a.sharedDepth(t);e=a.before(c+1),t=n.state.doc.resolve(t).after(c+1);let u=n.state.selection,d=DT(n,e,t),h=n.state.doc,p=h.slice(d.from,d.to),y,g;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(y=n.state.selection.to,g="end"):(y=n.state.selection.from,g="start"),n.input.lastKeyCode=null;let _=WT(p.content,d.doc.content,d.from,y,g);if(_&&n.input.domChangeCount++,(ui&&n.input.lastIOSEnter>Date.now()-225||On)&&i.some(V=>V.nodeType==1&&!BT.test(V.nodeName))&&(!_||_.endA>=_.endB)&&n.someProp("handleKeyDown",V=>V(n,pr(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!_)if(r&&u instanceof re&&!u.empty&&u.$head.sameParent(u.$anchor)&&!n.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))_={start:u.from,endA:u.to,endB:u.to};else{if(d.sel){let V=pp(n,n.state.doc,d.sel);if(V&&!V.eq(n.state.selection)){let ne=n.state.tr.setSelection(V);s&&ne.setMeta("composition",s),n.dispatch(ne)}}return}n.state.selection.from<n.state.selection.to&&_.start==_.endB&&n.state.selection instanceof re&&(_.start>n.state.selection.from&&_.start<=n.state.selection.from+2&&n.state.selection.from>=d.from?_.start=n.state.selection.from:_.endA<n.state.selection.to&&_.endA>=n.state.selection.to-2&&n.state.selection.to<=d.to&&(_.endB+=n.state.selection.to-_.endA,_.endA=n.state.selection.to)),bt&&Qn<=11&&_.endB==_.start+1&&_.endA==_.start&&_.start>d.from&&d.doc.textBetween(_.start-d.from-1,_.start-d.from+1)=="  "&&(_.start--,_.endA--,_.endB--);let w=d.doc.resolveNoCache(_.start-d.from),k=d.doc.resolveNoCache(_.endB-d.from),A=h.resolve(_.start),P=w.sameParent(k)&&w.parent.inlineContent&&A.end()>=_.endA,L;if((ui&&n.input.lastIOSEnter>Date.now()-225&&(!P||i.some(V=>V.nodeName=="DIV"||V.nodeName=="P"))||!P&&w.pos<d.doc.content.size&&!w.sameParent(k)&&(L=ae.findFrom(d.doc.resolve(w.pos+1),1,!0))&&L.head==k.pos)&&n.someProp("handleKeyDown",V=>V(n,pr(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>_.start&&zT(h,_.start,_.endA,w,k)&&n.someProp("handleKeyDown",V=>V(n,pr(8,"Backspace")))){On&&rt&&n.domObserver.suppressSelectionUpdates();return}rt&&_.endB==_.start&&(n.input.lastChromeDelete=Date.now()),On&&!P&&w.start()!=k.start()&&k.parentOffset==0&&w.depth==k.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==_.endA&&(_.endB-=2,k=d.doc.resolveNoCache(_.endB-d.from),setTimeout(()=>{n.someProp("handleKeyDown",function(V){return V(n,pr(13,"Enter"))})},20));let B=_.start,z=_.endA,$,J,K;if(P){if(w.pos==k.pos)bt&&Qn<=11&&w.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Mn(n),20)),$=n.state.tr.delete(B,z),J=h.resolve(_.start).marksAcross(h.resolve(_.endA));else if(_.endA==_.endB&&(K=$T(w.parent.content.cut(w.parentOffset,k.parentOffset),A.parent.content.cut(A.parentOffset,_.endA-A.start()))))$=n.state.tr,K.type=="add"?$.addMark(B,z,K.mark):$.removeMark(B,z,K.mark);else if(w.parent.child(w.index()).isText&&w.index()==k.index()-(k.textOffset?0:1)){let V=w.parent.textBetween(w.parentOffset,k.parentOffset);if(n.someProp("handleTextInput",ne=>ne(n,B,z,V)))return;$=n.state.tr.insertText(V,B,z)}}if($||($=n.state.tr.replace(B,z,d.doc.slice(_.start-d.from,_.endB-d.from))),d.sel){let V=pp(n,$.doc,d.sel);V&&!(rt&&n.composing&&V.empty&&(_.start!=_.endB||n.input.lastChromeDelete<Date.now()-100)&&(V.head==B||V.head==$.mapping.map(z)-1)||bt&&V.empty&&V.head==B)&&$.setSelection(V)}J&&$.ensureMarks(J),s&&$.setMeta("composition",s),n.dispatch($.scrollIntoView())}function pp(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Xc(n,e.resolve(t.anchor),e.resolve(t.head))}function $T(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,a,c,u;for(let h=0;h<r.length;h++)i=r[h].removeFromSet(i);for(let h=0;h<t.length;h++)s=t[h].removeFromSet(s);if(i.length==1&&s.length==0)c=i[0],a="add",u=h=>h.mark(c.addToSet(h.marks));else if(i.length==0&&s.length==1)c=s[0],a="remove",u=h=>h.mark(c.removeFromSet(h.marks));else return null;let d=[];for(let h=0;h<e.childCount;h++)d.push(u(e.child(h)));if(D.from(d).eq(n))return{mark:c,type:a}}function zT(n,e,t,r,i){if(t-e<=i.pos-r.pos||$l(r,!0,!1)<i.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let c=s.nodeAfter;return c!=null&&t==e+c.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let a=n.resolve($l(s,!0,!0));return!a.parent.isTextblock||a.pos>t||$l(a,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(a.parent.content)}function $l(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function WT(n,e,t,r,i){let s=n.findDiffStart(e,t);if(s==null)return null;let{a,b:c}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let u=Math.max(0,s-Math.min(a,c));r-=a+u-s}if(a<s&&n.size<e.size){let u=r<=s&&r>=a?s-r:0;s-=u,s&&s<e.size&&mp(e.textBetween(s-1,s+1))&&(s+=u?1:-1),c=s+(c-a),a=s}else if(c<s){let u=r<=s&&r>=c?s-r:0;s-=u,s&&s<n.size&&mp(n.textBetween(s-1,s+1))&&(s+=u?1:-1),a=s+(a-c),c=s}return{start:s,endA:a,endB:c}}function mp(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class VT{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new aT,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(vp),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=_p(this),yp(this),this.nodeViews=bp(this),this.docView=Yh(this.state.doc,gp(this),Fl(this),this.dom,this),this.domObserver=new NT(this,(r,i,s,a)=>FT(this,r,i,s,a)),this.domObserver.start(),lT(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Mc(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(vp),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,s=!1,a=!1;e.storedMarks&&this.composing&&(Ig(this),a=!0),this.state=e;let c=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(c||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let g=bp(this);UT(g,this.nodeViews)&&(this.nodeViews=g,s=!0)}(c||t.handleDOMEvents!=this._props.handleDOMEvents)&&Mc(this),this.editable=_p(this),yp(this);let u=Fl(this),d=gp(this),h=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",p=s||!this.docView.matchesNode(e.doc,d,u);(p||!e.selection.eq(i.selection))&&(a=!0);let y=h=="preserve"&&a&&this.dom.style.overflowAnchor==null&&wO(this);if(a){this.domObserver.stop();let g=p&&(bt||rt)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&HT(i.selection,e.selection);if(p){let _=rt?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ST(this)),(s||!this.docView.update(e.doc,d,u,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=Yh(e.doc,d,u,this.dom,this)),_&&!this.trackWrites&&(g=!0)}g||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&jO(this))?Mn(this,g):(vg(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),h=="reset"?this.dom.scrollTop=0:h=="to selection"?this.scrollToSelection():y&&kO(y)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof Q){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Uh(this,t.getBoundingClientRect(),e)}else Uh(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new Rg(e.slice,e.move,i<0?void 0:Q.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let a=0;a<this.directPlugins.length;a++){let c=this.directPlugins[a].props[e];if(c!=null&&(i=t?t(c):c))return i}let s=this.state.plugins;if(s)for(let a=0;a<s.length;a++){let c=s[a].props[e];if(c!=null&&(i=t?t(c):c))return i}}hasFocus(){if(bt){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&xO(this.dom),Mn(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return CO(this,e)}coordsAtPos(e,t=1){return dg(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return RO(this,t||this.state,e)}pasteHTML(e,t){return rs(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return rs(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Zc(this,e)}destroy(){this.docView&&(cT(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Fl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,fO())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return fT(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?ft&&this.root.nodeType===11&&gO(this.dom.ownerDocument)==this.dom&&PT(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function gp(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Wt.node(0,n.state.doc.content.size,e)]}function yp(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Wt.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function _p(n){return!n.someProp("editable",e=>e(n.state)===!1)}function HT(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function bp(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function UT(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function vp(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var er={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:"'"},Lo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},KT=typeof navigator<"u"&&/Mac/.test(navigator.platform),jT=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ze=0;Ze<10;Ze++)er[48+Ze]=er[96+Ze]=String(Ze);for(var Ze=1;Ze<=24;Ze++)er[Ze+111]="F"+Ze;for(var Ze=65;Ze<=90;Ze++)er[Ze]=String.fromCharCode(Ze+32),Lo[Ze]=String.fromCharCode(Ze);for(var zl in er)Lo.hasOwnProperty(zl)||(Lo[zl]=er[zl]);function qT(n){var e=KT&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||jT&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Lo:er)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const JT=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function GT(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,s,a;for(let c=0;c<e.length-1;c++){let u=e[c];if(/^(cmd|meta|m)$/i.test(u))a=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))s=!0;else if(/^mod$/i.test(u))JT?a=!0:i=!0;else throw new Error("Unrecognized modifier name: "+u)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),a&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function YT(n){let e=Object.create(null);for(let t in n)e[GT(t)]=n[t];return e}function Wl(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function QT(n){return new St({props:{handleKeyDown:$g(n)}})}function $g(n){let e=YT(n);return function(t,r){let i=qT(r),s,a=e[Wl(i,r)];if(a&&a(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let c=e[Wl(i,r,!1)];if(c&&c(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||i.charCodeAt(0)>127)&&(s=er[r.keyCode])&&s!=i){let c=e[Wl(s,r)];if(c&&c(t.state,t.dispatch,t))return!0}}return!1}}const su=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function zg(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Wg=(n,e,t)=>{let r=zg(n,t);if(!r)return!1;let i=ou(r);if(!i){let a=r.blockRange(),c=a&&hi(a);return c==null?!1:(e&&e(n.tr.lift(a,c).scrollIntoView()),!0)}let s=i.nodeBefore;if(Yg(n,i,e,-1))return!0;if(r.parent.content.size==0&&(fi(s,"end")||Q.isSelectable(s)))for(let a=r.depth;;a--){let c=Ho(n.doc,r.before(a),r.after(a),H.empty);if(c&&c.slice.size<c.to-c.from){if(e){let u=n.tr.step(c);u.setSelection(fi(s,"end")?ae.findFrom(u.doc.resolve(u.mapping.map(i.pos,-1)),-1):Q.create(u.doc,i.pos-s.nodeSize)),e(u.scrollIntoView())}return!0}if(a==1||r.node(a-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},XT=(n,e,t)=>{let r=zg(n,t);if(!r)return!1;let i=ou(r);return i?Vg(n,i,e):!1},ZT=(n,e,t)=>{let r=Ug(n,t);if(!r)return!1;let i=au(r);return i?Vg(n,i,e):!1};function Vg(n,e,t){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let h=i.lastChild;if(!h)return!1;i=h}let a=e.nodeAfter,c=a,u=e.pos+1;for(;!c.isTextblock;u++){if(c.type.spec.isolating)return!1;let h=c.firstChild;if(!h)return!1;c=h}let d=Ho(n.doc,s,u,H.empty);if(!d||d.from!=s||d instanceof Ue&&d.slice.size>=u-s)return!1;if(t){let h=n.tr.step(d);h.setSelection(re.create(h.doc,s)),t(h.scrollIntoView())}return!0}function fi(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Hg=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=ou(r)}let a=s&&s.nodeBefore;return!a||!Q.isSelectable(a)?!1:(e&&e(n.tr.setSelection(Q.create(n.doc,s.pos-a.nodeSize)).scrollIntoView()),!0)};function ou(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Ug(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Kg=(n,e,t)=>{let r=Ug(n,t);if(!r)return!1;let i=au(r);if(!i)return!1;let s=i.nodeAfter;if(Yg(n,i,e,1))return!0;if(r.parent.content.size==0&&(fi(s,"start")||Q.isSelectable(s))){let a=Ho(n.doc,r.before(),r.after(),H.empty);if(a&&a.slice.size<a.to-a.from){if(e){let c=n.tr.step(a);c.setSelection(fi(s,"start")?ae.findFrom(c.doc.resolve(c.mapping.map(i.pos)),1):Q.create(c.doc,c.mapping.map(i.pos))),e(c.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},jg=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=au(r)}let a=s&&s.nodeAfter;return!a||!Q.isSelectable(a)?!1:(e&&e(n.tr.setSelection(Q.create(n.doc,s.pos)).scrollIntoView()),!0)};function au(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const eA=(n,e)=>{let t=n.selection,r=t instanceof Q,i;if(r){if(t.node.isTextblock||!tr(n.doc,t.from))return!1;i=t.from}else if(i=Vo(n.doc,t.from,-1),i==null)return!1;if(e){let s=n.tr.join(i);r&&s.setSelection(Q.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},tA=(n,e)=>{let t=n.selection,r;if(t instanceof Q){if(t.node.isTextblock||!tr(n.doc,t.to))return!1;r=t.to}else if(r=Vo(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},nA=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&hi(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},qg=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
175
- `).scrollIntoView()),!0)};function lu(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const rA=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),a=lu(i.contentMatchAt(s));if(!a||!i.canReplaceWith(s,s,a))return!1;if(e){let c=t.after(),u=n.tr.replaceWith(c,c,a.createAndFill());u.setSelection(ae.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},Jg=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Ct||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=lu(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let a=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,c=n.tr.insert(a,s.createAndFill());c.setSelection(re.create(c.doc,a+1)),e(c.scrollIntoView())}return!0},Gg=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Cn(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&hi(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function iA(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Q&&e.selection.node.isBlock)return!r.parentOffset||!Cn(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],a,c,u=!1,d=!1;for(let g=r.depth;;g--)if(r.node(g).isBlock){u=r.end(g)==r.pos+(r.depth-g),d=r.start(g)==r.pos-(r.depth-g),c=lu(r.node(g-1).contentMatchAt(r.indexAfter(g-1))),s.unshift(u&&c?{type:c}:null),a=g;break}else{if(g==1)return!1;s.unshift(null)}let h=e.tr;(e.selection instanceof re||e.selection instanceof Ct)&&h.deleteSelection();let p=h.mapping.map(r.pos),y=Cn(h.doc,p,s.length,s);if(y||(s[0]=c?{type:c}:null,y=Cn(h.doc,p,s.length,s)),h.split(p,s.length,s),!u&&d&&r.node(a).type!=c){let g=h.mapping.map(r.before(a)),_=h.doc.resolve(g);c&&r.node(a-1).canReplaceWith(_.index(),_.index()+1,c)&&h.setNodeMarkup(h.mapping.map(r.before(a)),c)}return t&&t(h.scrollIntoView()),!0}}const sA=iA(),oA=(n,e)=>{let{$from:t,to:r}=n.selection,i,s=t.sharedDepth(r);return s==0?!1:(i=t.before(s),e&&e(n.tr.setSelection(Q.create(n.doc,i))),!0)};function aA(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||tr(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Yg(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,a,c,u=i.type.spec.isolating||s.type.spec.isolating;if(!u&&aA(n,e,t))return!0;let d=!u&&e.parent.canReplace(e.index(),e.index()+1);if(d&&(a=(c=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&c.matchType(a[0]||s.type).validEnd){if(t){let g=e.pos+s.nodeSize,_=D.empty;for(let A=a.length-1;A>=0;A--)_=D.from(a[A].create(null,_));_=D.from(i.copy(_));let w=n.tr.step(new Ke(e.pos-1,g,e.pos,g,new H(_,1,0),a.length,!0)),k=w.doc.resolve(g+2*a.length);k.nodeAfter&&k.nodeAfter.type==i.type&&tr(w.doc,k.pos)&&w.join(k.pos),t(w.scrollIntoView())}return!0}let h=s.type.spec.isolating||r>0&&u?null:ae.findFrom(e,1),p=h&&h.$from.blockRange(h.$to),y=p&&hi(p);if(y!=null&&y>=e.depth)return t&&t(n.tr.lift(p,y).scrollIntoView()),!0;if(d&&fi(s,"start",!0)&&fi(i,"end")){let g=i,_=[];for(;_.push(g),!g.isTextblock;)g=g.lastChild;let w=s,k=1;for(;!w.isTextblock;w=w.firstChild)k++;if(g.canReplace(g.childCount,g.childCount,w.content)){if(t){let A=D.empty;for(let L=_.length-1;L>=0;L--)A=D.from(_[L].copy(A));let P=n.tr.step(new Ke(e.pos-_.length,e.pos+s.nodeSize,e.pos+k,e.pos+s.nodeSize-k,new H(A,_.length,0),0,!0));t(P.scrollIntoView())}return!0}}return!1}function Qg(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(re.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const lA=Qg(-1),cA=Qg(1);function uA(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,a=i.blockRange(s),c=a&&Jc(a,n,e);return c?(r&&r(t.tr.wrap(a,c).scrollIntoView()),!0):!1}}function Sp(n,e=null){return function(t,r){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:a},$to:{pos:c}}=t.selection.ranges[s];t.doc.nodesBetween(a,c,(u,d)=>{if(i)return!1;if(!(!u.isTextblock||u.hasMarkup(n,e)))if(u.type==n)i=!0;else{let h=t.doc.resolve(d),p=h.index();i=h.parent.canReplaceWith(p,p+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let a=0;a<t.selection.ranges.length;a++){let{$from:{pos:c},$to:{pos:u}}=t.selection.ranges[a];s.setBlockType(c,u,n,e)}r(s.scrollIntoView())}return!0}}function cu(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}cu(su,Wg,Hg);cu(su,Kg,jg);cu(qg,Jg,Gg,sA);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function fA(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,a=i.blockRange(s);if(!a)return!1;let c=r?t.tr:null;return dA(c,a,n,e)?(r&&r(c.scrollIntoView()),!0):!1}}function dA(n,e,t,r=null){let i=!1,s=e,a=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let u=a.resolve(e.start-2);s=new Co(u,u,e.depth),e.endIndex<e.parent.childCount&&(e=new Co(e.$from,a.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let c=Jc(s,t,r,e);return c?(n&&hA(n,e,c,i,t),!0):!1}function hA(n,e,t,r,i){let s=D.empty;for(let h=t.length-1;h>=0;h--)s=D.from(t[h].type.create(t[h].attrs,s));n.step(new Ke(e.start-(r?2:0),e.end,e.start,e.end,new H(s,0,0),t.length,!0));let a=0;for(let h=0;h<t.length;h++)t[h].type==i&&(a=h+1);let c=t.length-a,u=e.start+t.length-(r?2:0),d=e.parent;for(let h=e.startIndex,p=e.endIndex,y=!0;h<p;h++,y=!1)!y&&Cn(n.doc,u,c)&&(n.split(u,c),u+=2*c),u+=d.child(h).nodeSize;return n}function pA(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,a=>a.childCount>0&&a.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?mA(e,t,n,s):gA(e,t,s):!0:!1}}function mA(n,e,t,r){let i=n.tr,s=r.end,a=r.$to.end(r.depth);s<a&&(i.step(new Ke(s-1,a,s,a,new H(D.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new Co(i.doc.resolve(r.$from.pos),i.doc.resolve(a),r.depth));const c=hi(r);if(c==null)return!1;i.lift(r,c);let u=i.doc.resolve(i.mapping.map(s,-1)-1);return tr(i.doc,u.pos)&&u.nodeBefore.type==u.nodeAfter.type&&i.join(u.pos),e(i.scrollIntoView()),!0}function gA(n,e,t){let r=n.tr,i=t.parent;for(let g=t.end,_=t.endIndex-1,w=t.startIndex;_>w;_--)g-=i.child(_).nodeSize,r.delete(g-1,g+1);let s=r.doc.resolve(t.start),a=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let c=t.startIndex==0,u=t.endIndex==i.childCount,d=s.node(-1),h=s.index(-1);if(!d.canReplace(h+(c?0:1),h+1,a.content.append(u?D.empty:D.from(i))))return!1;let p=s.pos,y=p+a.nodeSize;return r.step(new Ke(p-(c?1:0),y+(u?1:0),p+1,y-1,new H((c?D.empty:D.from(i.copy(D.empty))).append(u?D.empty:D.from(i.copy(D.empty))),c?0:1,u?0:1),c?0:1)),e(r.scrollIntoView()),!0}function yA(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,d=>d.childCount>0&&d.firstChild.type==n);if(!s)return!1;let a=s.startIndex;if(a==0)return!1;let c=s.parent,u=c.child(a-1);if(u.type!=n)return!1;if(t){let d=u.lastChild&&u.lastChild.type==c.type,h=D.from(d?n.create():null),p=new H(D.from(n.create(null,D.from(c.type.create(null,h)))),d?3:1,0),y=s.start,g=s.end;t(e.tr.step(new Ke(y-(d?3:1),g,y,g,p,1,!0)).scrollIntoView())}return!0}}function Jo(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=t.selection,i=t.doc,s=t.storedMarks,t}}}class Go{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:r}=this,{view:i}=t,{tr:s}=r,a=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([c,u])=>[c,(...h)=>{const p=u(...h)(a);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(s),p}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:i,state:s}=this,{view:a}=i,c=[],u=!!e,d=e||s.tr,h=()=>(!u&&t&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(d),c.every(y=>y===!0)),p={...Object.fromEntries(Object.entries(r).map(([y,g])=>[y,(...w)=>{const k=this.buildProps(d,t),A=g(...w)(k);return c.push(A),p}])),run:h};return p}createCan(e){const{rawCommands:t,state:r}=this,i=!1,s=e||r.tr,a=this.buildProps(s,i);return{...Object.fromEntries(Object.entries(t).map(([u,d])=>[u,(...h)=>d(...h)({...a,dispatch:void 0})])),chain:()=>this.createChain(s,i)}}buildProps(e,t=!0){const{rawCommands:r,editor:i,state:s}=this,{view:a}=i,c={tr:e,editor:i,view:a,state:Jo({state:s,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([u,d])=>[u,(...h)=>d(...h)(c)]))}};return c}}class _A{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(i=>i!==t):delete this.callbacks[e]),this}once(e,t){const r=(...i)=>{this.off(e,r),t.apply(this,i)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}}function j(n,e,t){return n.config[e]===void 0&&n.parent?j(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?j(n.parent,e,t):null}):n.config[e]}function Yo(n){const e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Xg(n){const e=[],{nodeExtensions:t,markExtensions:r}=Yo(n),i=[...t,...r],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(a=>{const c={name:a.name,options:a.options,storage:a.storage,extensions:i},u=j(a,"addGlobalAttributes",c);if(!u)return;u().forEach(h=>{h.types.forEach(p=>{Object.entries(h.attributes).forEach(([y,g])=>{e.push({type:p,name:y,attribute:{...s,...g}})})})})}),i.forEach(a=>{const c={name:a.name,options:a.options,storage:a.storage},u=j(a,"addAttributes",c);if(!u)return;const d=u();Object.entries(d).forEach(([h,p])=>{const y={...s,...p};typeof(y==null?void 0:y.default)=="function"&&(y.default=y.default()),y!=null&&y.isRequired&&(y==null?void 0:y.default)===void 0&&delete y.default,e.push({type:a.name,name:h,attribute:y})})}),e}function qe(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function ze(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const c=s?String(s).split(" "):[],u=r[i]?r[i].split(" "):[],d=c.filter(h=>!u.includes(h));r[i]=[...u,...d].join(" ")}else if(i==="style"){const c=s?s.split(";").map(h=>h.trim()).filter(Boolean):[],u=r[i]?r[i].split(";").map(h=>h.trim()).filter(Boolean):[],d=new Map;u.forEach(h=>{const[p,y]=h.split(":").map(g=>g.trim());d.set(p,y)}),c.forEach(h=>{const[p,y]=h.split(":").map(g=>g.trim());d.set(p,y)}),r[i]=Array.from(d.entries()).map(([h,p])=>`${h}: ${p}`).join("; ")}else r[i]=s}),r},{})}function Nc(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>ze(t,r),{})}function Zg(n){return typeof n=="function"}function fe(n,e=void 0,...t){return Zg(n)?e?n.bind(e)(...t):n(...t):n}function bA(n={}){return Object.keys(n).length===0&&n.constructor===Object}function vA(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function wp(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const i=e.reduce((s,a)=>{const c=a.attribute.parseHTML?a.attribute.parseHTML(t):vA(t.getAttribute(a.name));return c==null?s:{...s,[a.name]:c}},{});return{...r,...i}}}}function kp(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&bA(t)?!1:t!=null))}function SA(n,e){var t;const r=Xg(n),{nodeExtensions:i,markExtensions:s}=Yo(n),a=(t=i.find(d=>j(d,"topNode")))===null||t===void 0?void 0:t.name,c=Object.fromEntries(i.map(d=>{const h=r.filter(A=>A.type===d.name),p={name:d.name,options:d.options,storage:d.storage,editor:e},y=n.reduce((A,P)=>{const L=j(P,"extendNodeSchema",p);return{...A,...L?L(d):{}}},{}),g=kp({...y,content:fe(j(d,"content",p)),marks:fe(j(d,"marks",p)),group:fe(j(d,"group",p)),inline:fe(j(d,"inline",p)),atom:fe(j(d,"atom",p)),selectable:fe(j(d,"selectable",p)),draggable:fe(j(d,"draggable",p)),code:fe(j(d,"code",p)),whitespace:fe(j(d,"whitespace",p)),linebreakReplacement:fe(j(d,"linebreakReplacement",p)),defining:fe(j(d,"defining",p)),isolating:fe(j(d,"isolating",p)),attrs:Object.fromEntries(h.map(A=>{var P;return[A.name,{default:(P=A==null?void 0:A.attribute)===null||P===void 0?void 0:P.default}]}))}),_=fe(j(d,"parseHTML",p));_&&(g.parseDOM=_.map(A=>wp(A,h)));const w=j(d,"renderHTML",p);w&&(g.toDOM=A=>w({node:A,HTMLAttributes:Nc(A,h)}));const k=j(d,"renderText",p);return k&&(g.toText=k),[d.name,g]})),u=Object.fromEntries(s.map(d=>{const h=r.filter(k=>k.type===d.name),p={name:d.name,options:d.options,storage:d.storage,editor:e},y=n.reduce((k,A)=>{const P=j(A,"extendMarkSchema",p);return{...k,...P?P(d):{}}},{}),g=kp({...y,inclusive:fe(j(d,"inclusive",p)),excludes:fe(j(d,"excludes",p)),group:fe(j(d,"group",p)),spanning:fe(j(d,"spanning",p)),code:fe(j(d,"code",p)),attrs:Object.fromEntries(h.map(k=>{var A;return[k.name,{default:(A=k==null?void 0:k.attribute)===null||A===void 0?void 0:A.default}]}))}),_=fe(j(d,"parseHTML",p));_&&(g.parseDOM=_.map(k=>wp(k,h)));const w=j(d,"renderHTML",p);return w&&(g.toDOM=k=>w({mark:k,HTMLAttributes:Nc(k,h)})),[d.name,g]}));return new Vm({topNode:a,nodes:c,marks:u})}function Vl(n,e){return e.nodes[n]||e.marks[n]||null}function xp(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function uu(n,e){const t=Nr.fromSchema(e).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}const wA=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(i,s,a,c)=>{var u,d;const h=((d=(u=i.type.spec).toText)===null||d===void 0?void 0:d.call(u,{node:i,pos:s,parent:a,index:c}))||i.textContent||"%leaf%";t+=i.isAtom&&!i.isText?h:h.slice(0,Math.max(0,r-s))}),t};function fu(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class Qo{constructor(e){this.find=e.find,this.handler=e.handler}}const kA=(n,e)=>{if(fu(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function ao(n){var e;const{editor:t,from:r,to:i,text:s,rules:a,plugin:c}=n,{view:u}=t;if(u.composing)return!1;const d=u.state.doc.resolve(r);if(d.parent.type.spec.code||!((e=d.nodeBefore||d.nodeAfter)===null||e===void 0)&&e.marks.find(y=>y.type.spec.code))return!1;let h=!1;const p=wA(d)+s;return a.forEach(y=>{if(h)return;const g=kA(p,y.find);if(!g)return;const _=u.state.tr,w=Jo({state:u.state,transaction:_}),k={from:r-(g[0].length-s.length),to:i},{commands:A,chain:P,can:L}=new Go({editor:t,state:w});y.handler({state:w,range:k,match:g,commands:A,chain:P,can:L})===null||!_.steps.length||(_.setMeta(c,{transform:_,from:r,to:i,text:s}),u.dispatch(_),h=!0)}),h}function xA(n){const{editor:e,rules:t}=n,r=new St({state:{init(){return null},apply(i,s,a){const c=i.getMeta(r);if(c)return c;const u=i.getMeta("applyInputRules");return!!u&&setTimeout(()=>{let{text:h}=u;typeof h=="string"?h=h:h=uu(D.from(h),a.schema);const{from:p}=u,y=p+h.length;ao({editor:e,from:p,to:y,text:h,rules:t,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,a,c){return ao({editor:e,from:s,to:a,text:c,rules:t,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&ao({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:a}=i.state.selection;return a?ao({editor:e,from:a.pos,to:a.pos,text:`
176
- `,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function EA(n){return Object.prototype.toString.call(n).slice(8,-1)}function lo(n){return EA(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Xo(n,e){const t={...n};return lo(n)&&lo(e)&&Object.keys(e).forEach(r=>{lo(e[r])&&lo(n[r])?t[r]=Xo(n[r],e[r]):t[r]=e[r]}),t}class Kt{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=fe(j(this,"addOptions",{name:this.name}))),this.storage=fe(j(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Kt(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Xo(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new Kt(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=fe(j(t,"addOptions",{name:t.name})),t.storage=fe(j(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const a=i.marks();if(!!!a.find(d=>(d==null?void 0:d.type.name)===t.name))return!1;const u=a.find(d=>(d==null?void 0:d.type.name)===t.name);return u&&r.removeStoredMark(u),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}}function OA(n){return typeof n=="number"}class TA{constructor(e){this.find=e.find,this.handler=e.handler}}const AA=(n,e,t)=>{if(fu(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=n,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function CA(n){const{editor:e,state:t,from:r,to:i,rule:s,pasteEvent:a,dropEvent:c}=n,{commands:u,chain:d,can:h}=new Go({editor:e,state:t}),p=[];return t.doc.nodesBetween(r,i,(g,_)=>{if(!g.isTextblock||g.type.spec.code)return;const w=Math.max(r,_),k=Math.min(i,_+g.content.size),A=g.textBetween(w-_,k-_,void 0,"");AA(A,s.find,a).forEach(L=>{if(L.index===void 0)return;const B=w+L.index+1,z=B+L[0].length,$={from:t.tr.mapping.map(B),to:t.tr.mapping.map(z)},J=s.handler({state:t,range:$,match:L,commands:u,chain:d,can:h,pasteEvent:a,dropEvent:c});p.push(J)})}),p.every(g=>g!==null)}let co=null;const MA=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function NA(n){const{editor:e,rules:t}=n;let r=null,i=!1,s=!1,a=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,c;try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}const u=({state:h,from:p,to:y,rule:g,pasteEvt:_})=>{const w=h.tr,k=Jo({state:h,transaction:w});if(!(!CA({editor:e,state:k,from:Math.max(p-1,0),to:y.b-1,rule:g,pasteEvent:_,dropEvent:c})||!w.steps.length)){try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}return a=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,w}};return t.map(h=>new St({view(p){const y=_=>{var w;r=!((w=p.dom.parentElement)===null||w===void 0)&&w.contains(_.target)?p.dom.parentElement:null,r&&(co=e)},g=()=>{co&&(co=null)};return window.addEventListener("dragstart",y),window.addEventListener("dragend",g),{destroy(){window.removeEventListener("dragstart",y),window.removeEventListener("dragend",g)}}},props:{handleDOMEvents:{drop:(p,y)=>{if(s=r===p.dom.parentElement,c=y,!s){const g=co;g&&setTimeout(()=>{const _=g.state.selection;_&&g.commands.deleteRange({from:_.from,to:_.to})},10)}return!1},paste:(p,y)=>{var g;const _=(g=y.clipboardData)===null||g===void 0?void 0:g.getData("text/html");return a=y,i=!!(_!=null&&_.includes("data-pm-slice")),!1}}},appendTransaction:(p,y,g)=>{const _=p[0],w=_.getMeta("uiEvent")==="paste"&&!i,k=_.getMeta("uiEvent")==="drop"&&!s,A=_.getMeta("applyPasteRules"),P=!!A;if(!w&&!k&&!P)return;if(P){let{text:z}=A;typeof z=="string"?z=z:z=uu(D.from(z),g.schema);const{from:$}=A,J=$+z.length,K=MA(z);return u({rule:h,state:g,from:$,to:{b:J},pasteEvt:K})}const L=y.doc.content.findDiffStart(g.doc.content),B=y.doc.content.findDiffEnd(g.doc.content);if(!(!OA(L)||!B||L===B.b))return u({rule:h,state:g,from:L,to:B,pasteEvt:a})}}))}function IA(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}class ti{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=ti.resolve(e),this.schema=SA(this.extensions,t),this.setupExtensions()}static resolve(e){const t=ti.sort(ti.flatten(e)),r=IA(t.map(i=>i.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const r={name:t.name,options:t.options,storage:t.storage},i=j(t,"addExtensions",r);return i?[t,...this.flatten(i())]:t}).flat(10)}static sort(e){return e.sort((r,i)=>{const s=j(r,"priority")||100,a=j(i,"priority")||100;return s>a?-1:s<a?1:0})}get commands(){return this.extensions.reduce((e,t)=>{const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Vl(t.name,this.schema)},i=j(t,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,t=ti.sort([...this.extensions].reverse()),r=[],i=[],s=t.map(a=>{const c={name:a.name,options:a.options,storage:a.storage,editor:e,type:Vl(a.name,this.schema)},u=[],d=j(a,"addKeyboardShortcuts",c);let h={};if(a.type==="mark"&&j(a,"exitable",c)&&(h.ArrowRight=()=>Kt.handleExit({editor:e,mark:a})),d){const w=Object.fromEntries(Object.entries(d()).map(([k,A])=>[k,()=>A({editor:e})]));h={...h,...w}}const p=QT(h);u.push(p);const y=j(a,"addInputRules",c);xp(a,e.options.enableInputRules)&&y&&r.push(...y());const g=j(a,"addPasteRules",c);xp(a,e.options.enablePasteRules)&&g&&i.push(...g());const _=j(a,"addProseMirrorPlugins",c);if(_){const w=_();u.push(...w)}return u}).flat();return[xA({editor:e,rules:r}),...NA({editor:e,rules:i}),...s]}get attributes(){return Xg(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=Yo(this.extensions);return Object.fromEntries(t.filter(r=>!!j(r,"addNodeView")).map(r=>{const i=this.attributes.filter(u=>u.type===r.name),s={name:r.name,options:r.options,storage:r.storage,editor:e,type:qe(r.name,this.schema)},a=j(r,"addNodeView",s);if(!a)return[];const c=(u,d,h,p,y)=>{const g=Nc(u,i);return a()({node:u,view:d,getPos:h,decorations:p,innerDecorations:y,editor:e,extension:r,HTMLAttributes:g})};return[r.name,c]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Vl(e.name,this.schema)};e.type==="mark"&&(!((t=fe(j(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);const i=j(e,"onBeforeCreate",r),s=j(e,"onCreate",r),a=j(e,"onUpdate",r),c=j(e,"onSelectionUpdate",r),u=j(e,"onTransaction",r),d=j(e,"onFocus",r),h=j(e,"onBlur",r),p=j(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),a&&this.editor.on("update",a),c&&this.editor.on("selectionUpdate",c),u&&this.editor.on("transaction",u),d&&this.editor.on("focus",d),h&&this.editor.on("blur",h),p&&this.editor.on("destroy",p)})}}class it{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=fe(j(this,"addOptions",{name:this.name}))),this.storage=fe(j(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new it(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Xo(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new it({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=fe(j(t,"addOptions",{name:t.name})),t.storage=fe(j(t,"addStorage",{name:t.name,options:t.options})),t}}function ey(n,e,t){const{from:r,to:i}=e,{blockSeparator:s=`
176
+ `))),0,0):H.empty;let p=n.someProp("clipboardTextParser",y=>y(e,i,r,n));if(p)c=p;else{let y=i.marks(),{schema:g}=n.state,_=Ir.fromSchema(g);a=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(w=>{let k=a.appendChild(document.createElement("p"));w&&k.appendChild(_.serializeNode(g.text(w,y)))})}}else n.someProp("transformPastedHTML",p=>{t=p(t,n)}),a=rT(t),us&&iT(a);let d=a&&a.querySelector("[data-pm-slice]"),h=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let p=+h[3];p>0;p--){let y=a.firstChild;for(;y&&y.nodeType!=1;)y=y.nextSibling;if(!y)break;a=y}if(c||(c=(n.someProp("clipboardParser")||n.someProp("domParser")||Yn.fromSchema(n.state.schema)).parseSlice(a,{preserveWhitespace:!!(u||h),context:i,ruleFromNode(y){return y.nodeName=="BR"&&!y.nextSibling&&y.parentNode&&!eT.test(y.parentNode.nodeName)?{ignore:!0}:null}})),h)c=sT(lp(c,+h[1],+h[2]),h[4]);else if(c=H.maxOpen(tT(c.content,i),!0),c.openStart||c.openEnd){let p=0,y=0;for(let g=c.content.firstChild;p<c.openStart&&!g.type.spec.isolating;p++,g=g.firstChild);for(let g=c.content.lastChild;y<c.openEnd&&!g.type.spec.isolating;y++,g=g.lastChild);c=lp(c,p,y)}return n.someProp("transformPasted",p=>{c=p(c,n)}),c}const eT=/^(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 tT(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,a=[];if(n.forEach(c=>{if(!a)return;let u=i.findWrapping(c.type),d;if(!u)return a=null;if(d=a.length&&s.length&&Eg(u,s,c,a[a.length-1],0))a[a.length-1]=d;else{a.length&&(a[a.length-1]=Og(a[a.length-1],s.length));let h=xg(c,u);a.push(h),i=i.matchType(h.type),s=u}}),a)return D.from(a)}return n}function xg(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,D.from(n));return n}function Eg(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=Eg(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(D.from(xg(t,n,i+1))))}}function Og(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Og(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(D.empty,!0);return n.copy(t.append(r))}function Cc(n,e,t,r,i,s){let a=e<0?n.firstChild:n.lastChild,c=a.content;return n.childCount>1&&(s=0),i<r-1&&(c=Cc(c,e,t,r,i+1,s)),i>=t&&(c=e<0?a.contentMatchAt(0).fillBefore(c,s<=i).append(c):c.append(a.contentMatchAt(a.childCount).fillBefore(D.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,a.copy(c))}function lp(n,e,t){return e<n.openStart&&(n=new H(Cc(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new H(Cc(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Tg={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let cp=null;function Ag(){return cp||(cp=document.implementation.createHTMLDocument("title"))}let Bl=null;function nT(n){let e=window.trustedTypes;return e?(Bl||(Bl=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Bl.createHTML(n)):n}function rT(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Ag().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&Tg[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=nT(n),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function iT(n){let e=n.querySelectorAll(rt?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function sT(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:a}=n;for(let c=r.length-2;c>=0;c-=2){let u=t.nodes[r[c]];if(!u||u.hasRequiredAttrs())break;i=D.from(u.create(r[c+1],i)),s++,a++}return new H(i,s,a)}const dt={},ht={},oT={touchstart:!0,touchmove:!0};class aT{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function lT(n){for(let e in dt){let t=dt[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{uT(n,r)&&!eu(n,r)&&(n.editable||!(r.type in ht))&&t(n,r)},oT[e]?{passive:!0}:void 0)}ft&&n.dom.addEventListener("input",()=>null),Mc(n)}function Jn(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function cT(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Mc(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>eu(n,r))})}function eu(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function uT(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function fT(n,e){!eu(n,e)&&dt[e.type]&&(n.editable||!(e.type in ht))&&dt[e.type](n,e)}ht.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Mg(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(On&&rt&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),fi&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,pr(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||ZO(n,t)?t.preventDefault():Jn(n,"key")};ht.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};ht.keypress=(n,e)=>{let t=e;if(Mg(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||$t&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof re)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,i))&&n.dispatch(n.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function qo(n){return{left:n.clientX,top:n.clientY}}function dT(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function tu(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let a=s.depth+1;a>0;a--)if(n.someProp(e,c=>a>s.depth?c(n,t,s.nodeAfter,s.before(a),i,!0):c(n,t,s.node(a),s.before(a),i,!1)))return!0;return!1}function si(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function hT(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&Q.isSelectable(r)?(si(n,new Q(t)),!0):!1}function pT(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof Q&&(r=t.node);let s=n.state.doc.resolve(e);for(let a=s.depth+1;a>0;a--){let c=a>s.depth?s.nodeAfter:s.node(a);if(Q.isSelectable(c)){r&&t.$from.depth>0&&a>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(a);break}}return i!=null?(si(n,Q.create(n.state.doc,i)),!0):!1}function mT(n,e,t,r,i){return tu(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?pT(n,t):hT(n,t))}function gT(n,e,t,r){return tu(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function yT(n,e,t,r){return tu(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||_T(n,t,r)}function _T(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(si(n,re.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let a=s>i.depth?i.nodeAfter:i.node(s),c=i.before(s);if(a.inlineContent)si(n,re.create(r,c+1,c+1+a.content.size));else if(Q.isSelectable(a))si(n,Q.create(r,c));else continue;return!0}}function nu(n){return Po(n)}const Cg=$t?"metaKey":"ctrlKey";dt.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=nu(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&dT(t,n.input.lastClick)&&!t[Cg]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s};let a=n.posAtCoords(qo(t));a&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new bT(n,a,t,!!r)):(s=="doubleClick"?gT:yT)(n,a.pos,a.inside,t)?t.preventDefault():Jn(n,"pointer"))};class bT{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Cg],this.allowDefault=r.shiftKey;let s,a;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),a=t.inside;else{let h=e.state.doc.resolve(t.pos);s=h.parent,a=h.depth?h.before():0}const c=i?null:r.target,u=c?e.docView.nearestDesc(c,!0):null;this.target=u&&u.dom.nodeType==1?u.dom:null;let{selection:d}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||d instanceof Q&&d.from<=a&&d.to>a)&&(this.mightDrag={node:s,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&en&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Jn(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Mn(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(qo(e))),this.updateAllowDefault(e),this.allowDefault||!t?Jn(this.view,"pointer"):mT(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ft&&this.mightDrag&&!this.mightDrag.node.isAtom||rt&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(si(this.view,ae.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Jn(this.view,"pointer")}move(e){this.updateAllowDefault(e),Jn(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}dt.touchstart=n=>{n.input.lastTouch=Date.now(),nu(n),Jn(n,"pointer")};dt.touchmove=n=>{n.input.lastTouch=Date.now(),Jn(n,"pointer")};dt.contextmenu=n=>nu(n);function Mg(n,e){return n.composing?!0:ft&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const vT=On?5e3:-1;ht.compositionstart=ht.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof re&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Po(n,!0),n.markCursor=null;else if(Po(n,!e.selection.empty),en&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let a=s<0?i.lastChild:i.childNodes[s-1];if(!a)break;if(a.nodeType==3){let c=n.domSelection();c&&c.collapse(a,a.nodeValue.length);break}else i=a,s=-1}}n.input.composing=!0}Ng(n,vT)};ht.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Ng(n,20))};function Ng(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Po(n),e))}function Ig(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=wT());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function ST(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=hO(e.focusNode,e.focusOffset),r=pO(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let a=t.pmViewDesc;if(!(!a||!a.isText(t.nodeValue)))return r}}return t||r}function wT(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Po(n,e=!1){if(!(On&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ig(n),e||n.docView&&n.docView.dirty){let t=Qc(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function kT(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const ns=bt&&Qn<15||fi&&bO<604;dt.copy=ht.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=ns?null:t.clipboardData,a=r.content(),{dom:c,text:u}=Zc(n,a);s?(t.preventDefault(),s.clearData(),s.setData("text/html",c.innerHTML),s.setData("text/plain",u)):kT(n,c),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function xT(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function ET(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?rs(n,r.value,null,i,e):rs(n,r.textContent,r.innerHTML,i,e)},50)}function rs(n,e,t,r,i){let s=kg(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",u=>u(n,i,s||H.empty)))return!0;if(!s)return!1;let a=xT(s),c=a?n.state.tr.replaceSelectionWith(a,r):n.state.tr.replaceSelection(s);return n.dispatch(c.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Pg(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ht.paste=(n,e)=>{let t=e;if(n.composing&&!On)return;let r=ns?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&rs(n,Pg(r),r.getData("text/html"),i,t)?t.preventDefault():ET(n,t)};class Rg{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Dg=$t?"altKey":"ctrlKey";dt.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(qo(t)),a;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof Q?i.to-1:i.to))){if(r&&r.mightDrag)a=Q.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let p=n.docView.nearestDesc(t.target,!0);p&&p.node.type.spec.draggable&&p!=n.docView&&(a=Q.create(n.state.doc,p.posBefore))}}let c=(a||n.state.selection).content(),{dom:u,text:d,slice:h}=Zc(n,c);(!t.dataTransfer.files.length||!rt||ag>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(ns?"Text":"text/html",u.innerHTML),t.dataTransfer.effectAllowed="copyMove",ns||t.dataTransfer.setData("text/plain",d),n.dragging=new Rg(h,!t[Dg],a)};dt.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};ht.dragover=ht.dragenter=(n,e)=>e.preventDefault();ht.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(qo(t));if(!i)return;let s=n.state.doc.resolve(i.pos),a=r&&r.slice;a?n.someProp("transformPasted",_=>{a=_(a,n)}):a=kg(n,Pg(t.dataTransfer),ns?null:t.dataTransfer.getData("text/html"),!1,s);let c=!!(r&&!t[Dg]);if(n.someProp("handleDrop",_=>_(n,t,a||H.empty,c))){t.preventDefault();return}if(!a)return;t.preventDefault();let u=a?Zm(n.state.doc,s.pos,a):s.pos;u==null&&(u=s.pos);let d=n.state.tr;if(c){let{node:_}=r;_?_.replace(d):d.deleteSelection()}let h=d.mapping.map(u),p=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,y=d.doc;if(p?d.replaceRangeWith(h,h,a.content.firstChild):d.replaceRange(h,h,a),d.doc.eq(y))return;let g=d.doc.resolve(h);if(p&&Q.isSelectable(a.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(a.content.firstChild))d.setSelection(new Q(g));else{let _=d.mapping.map(u);d.mapping.maps[d.mapping.maps.length-1].forEach((w,k,A,P)=>_=P),d.setSelection(Xc(n,g,d.doc.resolve(_)))}n.focus(),n.dispatch(d.setMeta("uiEvent","drop"))};dt.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Mn(n)},20))};dt.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};dt.beforeinput=(n,e)=>{if(rt&&On&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,pr(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in ht)dt[n]=ht[n];function is(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Ro{constructor(e,t){this.toDOM=e,this.spec=t||wr,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:a}=e.mapResult(t.from+i,this.side<0?-1:1);return a?null:new Wt(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Ro&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&is(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Zn{constructor(e,t){this.attrs=e,this.spec=t||wr}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,a=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=a?null:new Wt(s,a,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Zn&&is(this.attrs,e.attrs)&&is(this.spec,e.spec)}static is(e){return e.type instanceof Zn}destroy(){}}class ru{constructor(e,t){this.attrs=e,this.spec=t||wr}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let a=e.mapResult(t.to+i,-1);return a.deleted||a.pos<=s.pos?null:new Wt(s.pos-r,a.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof ru&&is(this.attrs,e.attrs)&&is(this.spec,e.spec)}destroy(){}}class Wt{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new Wt(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new Wt(e,e,new Ro(t,r))}static inline(e,t,r,i){return new Wt(e,t,new Zn(r,i))}static node(e,t,r,i){return new Wt(e,t,new ru(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Zn}get widget(){return this.type instanceof Ro}}const ei=[],wr={};class $e{constructor(e,t){this.local=e.length?e:ei,this.children=t.length?t:ei}static create(e,t){return t.length?Do(t,e,0,wr):nt}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let a=0;a<this.local.length;a++){let c=this.local[a];c.from<=t&&c.to>=e&&(!s||s(c.spec))&&r.push(c.copy(c.from+i,c.to+i))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let c=this.children[a]+1;this.children[a+2].findInner(e-c,t-c,r,i+c,s)}}map(e,t,r){return this==nt||e.maps.length==0?this:this.mapInner(e,t,0,0,r||wr)}mapInner(e,t,r,i,s){let a;for(let c=0;c<this.local.length;c++){let u=this.local[c].map(e,r,i);u&&u.type.valid(t,u)?(a||(a=[])).push(u):s.onRemove&&s.onRemove(this.local[c].spec)}return this.children.length?OT(this.children,a||[],e,t,r,i,s):a?new $e(a.sort(kr),ei):nt}add(e,t){return t.length?this==nt?$e.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((c,u)=>{let d=u+r,h;if(h=Bg(t,c,d)){for(i||(i=this.children.slice());s<i.length&&i[s]<u;)s+=3;i[s]==u?i[s+2]=i[s+2].addInner(c,h,d+1):i.splice(s,0,u,u+c.nodeSize,Do(h,c,d+1,wr)),s+=3}});let a=Lg(s?Fg(t):t,-r);for(let c=0;c<a.length;c++)a[c].type.valid(e,a[c])||a.splice(c--,1);return new $e(a.length?this.local.concat(a).sort(kr):this.local,i||this.children)}remove(e){return e.length==0||this==nt?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let a,c=r[s]+t,u=r[s+1]+t;for(let h=0,p;h<e.length;h++)(p=e[h])&&p.from>c&&p.to<u&&(e[h]=null,(a||(a=[])).push(p));if(!a)continue;r==this.children&&(r=this.children.slice());let d=r[s+2].removeInner(a,c+1);d!=nt?r[s+2]=d:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,a;s<e.length;s++)if(a=e[s])for(let c=0;c<i.length;c++)i[c].eq(a,t)&&(i==this.local&&(i=this.local.slice()),i.splice(c--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new $e(i,r):nt}forChild(e,t){if(this==nt)return this;if(t.isLeaf)return $e.empty;let r,i;for(let c=0;c<this.children.length;c+=3)if(this.children[c]>=e){this.children[c]==e&&(r=this.children[c+2]);break}let s=e+1,a=s+t.content.size;for(let c=0;c<this.local.length;c++){let u=this.local[c];if(u.from<a&&u.to>s&&u.type instanceof Zn){let d=Math.max(s,u.from)-s,h=Math.min(a,u.to)-s;d<h&&(i||(i=[])).push(u.copy(d,h))}}if(i){let c=new $e(i.sort(kr),ei);return r?new Kn([c,r]):c}return r||nt}eq(e){if(this==e)return!0;if(!(e instanceof $e)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return iu(this.localsInner(e))}localsInner(e){if(this==nt)return ei;if(e.inlineContent||!this.local.some(Zn.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Zn||t.push(this.local[r]);return t}forEachSet(e){e(this)}}$e.empty=new $e([],[]);$e.removeOverlap=iu;const nt=$e.empty;class Kn{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,wr));return Kn.from(r)}forChild(e,t){if(t.isLeaf)return $e.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=nt&&(s instanceof Kn?r=r.concat(s.members):r.push(s))}return Kn.from(r)}eq(e){if(!(e instanceof Kn)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let a=0;a<s.length;a++)t.push(s[a])}}return t?iu(r?t:t.sort(kr)):ei}static from(e){switch(e.length){case 0:return nt;case 1:return e[0];default:return new Kn(e.every(t=>t instanceof $e)?e:e.reduce((t,r)=>t.concat(r instanceof $e?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function OT(n,e,t,r,i,s,a){let c=n.slice();for(let d=0,h=s;d<t.maps.length;d++){let p=0;t.maps[d].forEach((y,g,_,w)=>{let k=w-_-(g-y);for(let A=0;A<c.length;A+=3){let P=c[A+1];if(P<0||y>P+h-p)continue;let L=c[A]+h-p;g>=L?c[A+1]=y<=L?-2:-1:y>=h&&k&&(c[A]+=k,c[A+1]+=k)}p+=k}),h=t.maps[d].map(h,-1)}let u=!1;for(let d=0;d<c.length;d+=3)if(c[d+1]<0){if(c[d+1]==-2){u=!0,c[d+1]=-1;continue}let h=t.map(n[d]+s),p=h-i;if(p<0||p>=r.content.size){u=!0;continue}let y=t.map(n[d+1]+s,-1),g=y-i,{index:_,offset:w}=r.content.findIndex(p),k=r.maybeChild(_);if(k&&w==p&&w+k.nodeSize==g){let A=c[d+2].mapInner(t,k,h+1,n[d]+s+1,a);A!=nt?(c[d]=p,c[d+1]=g,c[d+2]=A):(c[d+1]=-2,u=!0)}else u=!0}if(u){let d=TT(c,n,e,t,i,s,a),h=Do(d,r,0,a);e=h.local;for(let p=0;p<c.length;p+=3)c[p+1]<0&&(c.splice(p,3),p-=3);for(let p=0,y=0;p<h.children.length;p+=3){let g=h.children[p];for(;y<c.length&&c[y]<g;)y+=3;c.splice(y,0,h.children[p],h.children[p+1],h.children[p+2])}}return new $e(e.sort(kr),c)}function Lg(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new Wt(i.from+e,i.to+e,i.type))}return t}function TT(n,e,t,r,i,s,a){function c(u,d){for(let h=0;h<u.local.length;h++){let p=u.local[h].map(r,i,d);p?t.push(p):a.onRemove&&a.onRemove(u.local[h].spec)}for(let h=0;h<u.children.length;h+=3)c(u.children[h+2],u.children[h]+d+1)}for(let u=0;u<n.length;u+=3)n[u+1]==-1&&c(n[u+2],e[u]+s+1);return t}function Bg(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,a;s<n.length;s++)(a=n[s])&&a.from>t&&a.to<r&&((i||(i=[])).push(a),n[s]=null);return i}function Fg(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Do(n,e,t,r){let i=[],s=!1;e.forEach((c,u)=>{let d=Bg(n,c,u+t);if(d){s=!0;let h=Do(d,c,t+u+1,r);h!=nt&&i.push(u,u+c.nodeSize,h)}});let a=Lg(s?Fg(n):n,-t).sort(kr);for(let c=0;c<a.length;c++)a[c].type.valid(e,a[c])||(r.onRemove&&r.onRemove(a[c].spec),a.splice(c--,1));return a.length||i.length?new $e(a,i):nt}function kr(n,e){return n.from-e.from||n.to-e.to}function iu(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),up(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),up(e,i,r.copy(s.from,r.to)));break}}}return e}function up(n,e,t){for(;e<n.length&&kr(t,n[e])>0;)e++;n.splice(e,0,t)}function Fl(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=nt&&e.push(r)}),n.cursorWrapper&&e.push($e.create(n.state.doc,[n.cursorWrapper.deco])),Kn.from(e)}const AT={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},CT=bt&&Qn<=11;class MT{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class NT{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new MT,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);bt&&Qn<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),CT&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,AT)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(np(this.view)){if(this.suppressingSelectionUpdates)return Mn(this.view);if(bt&&Qn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ar(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let s=e.focusNode;s;s=ui(s))t.add(s);for(let s=e.anchorNode;s;s=ui(s))if(t.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&np(e)&&!this.ignoreSelectionChange(r),s=-1,a=-1,c=!1,u=[];if(e.editable)for(let h=0;h<t.length;h++){let p=this.registerMutation(t[h],u);p&&(s=s<0?p.from:Math.min(p.from,s),a=a<0?p.to:Math.max(p.to,a),p.typeOver&&(c=!0))}if(en&&u.length){let h=u.filter(p=>p.nodeName=="BR");if(h.length==2){let[p,y]=h;p.parentNode&&p.parentNode.parentNode==y.parentNode?y.remove():p.remove()}else{let{focusNode:p}=this.currentSelection;for(let y of h){let g=y.parentNode;g&&g.nodeName=="LI"&&(!p||RT(e,p)!=g)&&y.remove()}}}let d=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ko(r)&&(d=Qc(e))&&d.eq(ae.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Mn(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,a),IT(e)),this.handleDOMChange(s,a,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Mn(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let h=0;h<e.addedNodes.length;h++){let p=e.addedNodes[h];t.push(p),p.nodeType==3&&(this.lastChangedTextNode=p)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(bt&&Qn<=11&&e.addedNodes.length)for(let h=0;h<e.addedNodes.length;h++){let{previousSibling:p,nextSibling:y}=e.addedNodes[h];(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(i=p),(!y||Array.prototype.indexOf.call(e.addedNodes,y)<0)&&(s=y)}let a=i&&i.parentNode==e.target?Xe(i)+1:0,c=r.localPosFromDOM(e.target,a,-1),u=s&&s.parentNode==e.target?Xe(s):e.target.childNodes.length,d=r.localPosFromDOM(e.target,u,1);return{from:c,to:d}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let fp=new WeakMap,dp=!1;function IT(n){if(!fp.has(n)&&(fp.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=en,dp)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."),dp=!0}}function hp(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,a=n.domAtPos(n.state.selection.anchor);return Ar(a.node,a.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function PT(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return hp(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?hp(n,t):null}function RT(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function DT(n,e,t){let{node:r,fromOffset:i,toOffset:s,from:a,to:c}=n.docView.parseRange(e,t),u=n.domSelectionRange(),d,h=u.anchorNode;if(h&&n.dom.contains(h.nodeType==1?h:h.parentNode)&&(d=[{node:h,offset:u.anchorOffset}],Ko(u)||d.push({node:u.focusNode,offset:u.focusOffset})),rt&&n.input.lastKeyCode===8)for(let k=s;k>i;k--){let A=r.childNodes[k-1],P=A.pmViewDesc;if(A.nodeName=="BR"&&!P){s=k;break}if(!P||P.size)break}let p=n.state.doc,y=n.someProp("domParser")||Yn.fromSchema(n.state.schema),g=p.resolve(a),_=null,w=y.parse(r,{topNode:g.parent,topMatch:g.parent.contentMatchAt(g.index()),topOpen:!0,from:i,to:s,preserveWhitespace:g.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:LT,context:g});if(d&&d[0].pos!=null){let k=d[0].pos,A=d[1]&&d[1].pos;A==null&&(A=k),_={anchor:k+a,head:A+a}}return{doc:w,sel:_,from:a,to:c}}function LT(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(ft&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||ft&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const BT=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function FT(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let V=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,ne=Qc(n,V);if(ne&&!n.state.selection.eq(ne)){if(rt&&On&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",De=>De(n,pr(13,"Enter"))))return;let ve=n.state.tr.setSelection(ne);V=="pointer"?ve.setMeta("pointer",!0):V=="key"&&ve.scrollIntoView(),s&&ve.setMeta("composition",s),n.dispatch(ve)}return}let a=n.state.doc.resolve(e),c=a.sharedDepth(t);e=a.before(c+1),t=n.state.doc.resolve(t).after(c+1);let u=n.state.selection,d=DT(n,e,t),h=n.state.doc,p=h.slice(d.from,d.to),y,g;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(y=n.state.selection.to,g="end"):(y=n.state.selection.from,g="start"),n.input.lastKeyCode=null;let _=WT(p.content,d.doc.content,d.from,y,g);if(_&&n.input.domChangeCount++,(fi&&n.input.lastIOSEnter>Date.now()-225||On)&&i.some(V=>V.nodeType==1&&!BT.test(V.nodeName))&&(!_||_.endA>=_.endB)&&n.someProp("handleKeyDown",V=>V(n,pr(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!_)if(r&&u instanceof re&&!u.empty&&u.$head.sameParent(u.$anchor)&&!n.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))_={start:u.from,endA:u.to,endB:u.to};else{if(d.sel){let V=pp(n,n.state.doc,d.sel);if(V&&!V.eq(n.state.selection)){let ne=n.state.tr.setSelection(V);s&&ne.setMeta("composition",s),n.dispatch(ne)}}return}n.state.selection.from<n.state.selection.to&&_.start==_.endB&&n.state.selection instanceof re&&(_.start>n.state.selection.from&&_.start<=n.state.selection.from+2&&n.state.selection.from>=d.from?_.start=n.state.selection.from:_.endA<n.state.selection.to&&_.endA>=n.state.selection.to-2&&n.state.selection.to<=d.to&&(_.endB+=n.state.selection.to-_.endA,_.endA=n.state.selection.to)),bt&&Qn<=11&&_.endB==_.start+1&&_.endA==_.start&&_.start>d.from&&d.doc.textBetween(_.start-d.from-1,_.start-d.from+1)=="  "&&(_.start--,_.endA--,_.endB--);let w=d.doc.resolveNoCache(_.start-d.from),k=d.doc.resolveNoCache(_.endB-d.from),A=h.resolve(_.start),P=w.sameParent(k)&&w.parent.inlineContent&&A.end()>=_.endA,L;if((fi&&n.input.lastIOSEnter>Date.now()-225&&(!P||i.some(V=>V.nodeName=="DIV"||V.nodeName=="P"))||!P&&w.pos<d.doc.content.size&&!w.sameParent(k)&&(L=ae.findFrom(d.doc.resolve(w.pos+1),1,!0))&&L.head==k.pos)&&n.someProp("handleKeyDown",V=>V(n,pr(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>_.start&&zT(h,_.start,_.endA,w,k)&&n.someProp("handleKeyDown",V=>V(n,pr(8,"Backspace")))){On&&rt&&n.domObserver.suppressSelectionUpdates();return}rt&&_.endB==_.start&&(n.input.lastChromeDelete=Date.now()),On&&!P&&w.start()!=k.start()&&k.parentOffset==0&&w.depth==k.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==_.endA&&(_.endB-=2,k=d.doc.resolveNoCache(_.endB-d.from),setTimeout(()=>{n.someProp("handleKeyDown",function(V){return V(n,pr(13,"Enter"))})},20));let B=_.start,z=_.endA,$,J,K;if(P){if(w.pos==k.pos)bt&&Qn<=11&&w.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Mn(n),20)),$=n.state.tr.delete(B,z),J=h.resolve(_.start).marksAcross(h.resolve(_.endA));else if(_.endA==_.endB&&(K=$T(w.parent.content.cut(w.parentOffset,k.parentOffset),A.parent.content.cut(A.parentOffset,_.endA-A.start()))))$=n.state.tr,K.type=="add"?$.addMark(B,z,K.mark):$.removeMark(B,z,K.mark);else if(w.parent.child(w.index()).isText&&w.index()==k.index()-(k.textOffset?0:1)){let V=w.parent.textBetween(w.parentOffset,k.parentOffset);if(n.someProp("handleTextInput",ne=>ne(n,B,z,V)))return;$=n.state.tr.insertText(V,B,z)}}if($||($=n.state.tr.replace(B,z,d.doc.slice(_.start-d.from,_.endB-d.from))),d.sel){let V=pp(n,$.doc,d.sel);V&&!(rt&&n.composing&&V.empty&&(_.start!=_.endB||n.input.lastChromeDelete<Date.now()-100)&&(V.head==B||V.head==$.mapping.map(z)-1)||bt&&V.empty&&V.head==B)&&$.setSelection(V)}J&&$.ensureMarks(J),s&&$.setMeta("composition",s),n.dispatch($.scrollIntoView())}function pp(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Xc(n,e.resolve(t.anchor),e.resolve(t.head))}function $T(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,a,c,u;for(let h=0;h<r.length;h++)i=r[h].removeFromSet(i);for(let h=0;h<t.length;h++)s=t[h].removeFromSet(s);if(i.length==1&&s.length==0)c=i[0],a="add",u=h=>h.mark(c.addToSet(h.marks));else if(i.length==0&&s.length==1)c=s[0],a="remove",u=h=>h.mark(c.removeFromSet(h.marks));else return null;let d=[];for(let h=0;h<e.childCount;h++)d.push(u(e.child(h)));if(D.from(d).eq(n))return{mark:c,type:a}}function zT(n,e,t,r,i){if(t-e<=i.pos-r.pos||$l(r,!0,!1)<i.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let c=s.nodeAfter;return c!=null&&t==e+c.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let a=n.resolve($l(s,!0,!0));return!a.parent.isTextblock||a.pos>t||$l(a,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(a.parent.content)}function $l(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function WT(n,e,t,r,i){let s=n.findDiffStart(e,t);if(s==null)return null;let{a,b:c}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let u=Math.max(0,s-Math.min(a,c));r-=a+u-s}if(a<s&&n.size<e.size){let u=r<=s&&r>=a?s-r:0;s-=u,s&&s<e.size&&mp(e.textBetween(s-1,s+1))&&(s+=u?1:-1),c=s+(c-a),a=s}else if(c<s){let u=r<=s&&r>=c?s-r:0;s-=u,s&&s<n.size&&mp(n.textBetween(s-1,s+1))&&(s+=u?1:-1),a=s+(a-c),c=s}return{start:s,endA:a,endB:c}}function mp(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class VT{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new aT,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(vp),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=_p(this),yp(this),this.nodeViews=bp(this),this.docView=Yh(this.state.doc,gp(this),Fl(this),this.dom,this),this.domObserver=new NT(this,(r,i,s,a)=>FT(this,r,i,s,a)),this.domObserver.start(),lT(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Mc(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(vp),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,s=!1,a=!1;e.storedMarks&&this.composing&&(Ig(this),a=!0),this.state=e;let c=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(c||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let g=bp(this);UT(g,this.nodeViews)&&(this.nodeViews=g,s=!0)}(c||t.handleDOMEvents!=this._props.handleDOMEvents)&&Mc(this),this.editable=_p(this),yp(this);let u=Fl(this),d=gp(this),h=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",p=s||!this.docView.matchesNode(e.doc,d,u);(p||!e.selection.eq(i.selection))&&(a=!0);let y=h=="preserve"&&a&&this.dom.style.overflowAnchor==null&&wO(this);if(a){this.domObserver.stop();let g=p&&(bt||rt)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&HT(i.selection,e.selection);if(p){let _=rt?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ST(this)),(s||!this.docView.update(e.doc,d,u,this))&&(this.docView.updateOuterDeco(d),this.docView.destroy(),this.docView=Yh(e.doc,d,u,this.dom,this)),_&&!this.trackWrites&&(g=!0)}g||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&jO(this))?Mn(this,g):(vg(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),h=="reset"?this.dom.scrollTop=0:h=="to selection"?this.scrollToSelection():y&&kO(y)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof Q){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Uh(this,t.getBoundingClientRect(),e)}else Uh(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new Rg(e.slice,e.move,i<0?void 0:Q.create(this.state.doc,i))}someProp(e,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let a=0;a<this.directPlugins.length;a++){let c=this.directPlugins[a].props[e];if(c!=null&&(i=t?t(c):c))return i}let s=this.state.plugins;if(s)for(let a=0;a<s.length;a++){let c=s[a].props[e];if(c!=null&&(i=t?t(c):c))return i}}hasFocus(){if(bt){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&xO(this.dom),Mn(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return CO(this,e)}coordsAtPos(e,t=1){return dg(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return RO(this,t||this.state,e)}pasteHTML(e,t){return rs(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return rs(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Zc(this,e)}destroy(){this.docView&&(cT(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Fl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,fO())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return fT(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?ft&&this.root.nodeType===11&&gO(this.dom.ownerDocument)==this.dom&&PT(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function gp(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Wt.node(0,n.state.doc.content.size,e)]}function yp(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Wt.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function _p(n){return!n.someProp("editable",e=>e(n.state)===!1)}function HT(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function bp(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function UT(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function vp(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var er={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:"'"},Lo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},KT=typeof navigator<"u"&&/Mac/.test(navigator.platform),jT=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ze=0;Ze<10;Ze++)er[48+Ze]=er[96+Ze]=String(Ze);for(var Ze=1;Ze<=24;Ze++)er[Ze+111]="F"+Ze;for(var Ze=65;Ze<=90;Ze++)er[Ze]=String.fromCharCode(Ze+32),Lo[Ze]=String.fromCharCode(Ze);for(var zl in er)Lo.hasOwnProperty(zl)||(Lo[zl]=er[zl]);function qT(n){var e=KT&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||jT&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Lo:er)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const JT=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function GT(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,i,s,a;for(let c=0;c<e.length-1;c++){let u=e[c];if(/^(cmd|meta|m)$/i.test(u))a=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))s=!0;else if(/^mod$/i.test(u))JT?a=!0:i=!0;else throw new Error("Unrecognized modifier name: "+u)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),a&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function YT(n){let e=Object.create(null);for(let t in n)e[GT(t)]=n[t];return e}function Wl(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function QT(n){return new St({props:{handleKeyDown:$g(n)}})}function $g(n){let e=YT(n);return function(t,r){let i=qT(r),s,a=e[Wl(i,r)];if(a&&a(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let c=e[Wl(i,r,!1)];if(c&&c(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||i.charCodeAt(0)>127)&&(s=er[r.keyCode])&&s!=i){let c=e[Wl(s,r)];if(c&&c(t.state,t.dispatch,t))return!0}}return!1}}const su=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function zg(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Wg=(n,e,t)=>{let r=zg(n,t);if(!r)return!1;let i=ou(r);if(!i){let a=r.blockRange(),c=a&&hi(a);return c==null?!1:(e&&e(n.tr.lift(a,c).scrollIntoView()),!0)}let s=i.nodeBefore;if(Yg(n,i,e,-1))return!0;if(r.parent.content.size==0&&(di(s,"end")||Q.isSelectable(s)))for(let a=r.depth;;a--){let c=Ho(n.doc,r.before(a),r.after(a),H.empty);if(c&&c.slice.size<c.to-c.from){if(e){let u=n.tr.step(c);u.setSelection(di(s,"end")?ae.findFrom(u.doc.resolve(u.mapping.map(i.pos,-1)),-1):Q.create(u.doc,i.pos-s.nodeSize)),e(u.scrollIntoView())}return!0}if(a==1||r.node(a-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},XT=(n,e,t)=>{let r=zg(n,t);if(!r)return!1;let i=ou(r);return i?Vg(n,i,e):!1},ZT=(n,e,t)=>{let r=Ug(n,t);if(!r)return!1;let i=au(r);return i?Vg(n,i,e):!1};function Vg(n,e,t){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let h=i.lastChild;if(!h)return!1;i=h}let a=e.nodeAfter,c=a,u=e.pos+1;for(;!c.isTextblock;u++){if(c.type.spec.isolating)return!1;let h=c.firstChild;if(!h)return!1;c=h}let d=Ho(n.doc,s,u,H.empty);if(!d||d.from!=s||d instanceof Ue&&d.slice.size>=u-s)return!1;if(t){let h=n.tr.step(d);h.setSelection(re.create(h.doc,s)),t(h.scrollIntoView())}return!0}function di(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Hg=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=ou(r)}let a=s&&s.nodeBefore;return!a||!Q.isSelectable(a)?!1:(e&&e(n.tr.setSelection(Q.create(n.doc,s.pos-a.nodeSize)).scrollIntoView()),!0)};function ou(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Ug(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Kg=(n,e,t)=>{let r=Ug(n,t);if(!r)return!1;let i=au(r);if(!i)return!1;let s=i.nodeAfter;if(Yg(n,i,e,1))return!0;if(r.parent.content.size==0&&(di(s,"start")||Q.isSelectable(s))){let a=Ho(n.doc,r.before(),r.after(),H.empty);if(a&&a.slice.size<a.to-a.from){if(e){let c=n.tr.step(a);c.setSelection(di(s,"start")?ae.findFrom(c.doc.resolve(c.mapping.map(i.pos)),1):Q.create(c.doc,c.mapping.map(i.pos))),e(c.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(n.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},jg=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=au(r)}let a=s&&s.nodeAfter;return!a||!Q.isSelectable(a)?!1:(e&&e(n.tr.setSelection(Q.create(n.doc,s.pos)).scrollIntoView()),!0)};function au(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const eA=(n,e)=>{let t=n.selection,r=t instanceof Q,i;if(r){if(t.node.isTextblock||!tr(n.doc,t.from))return!1;i=t.from}else if(i=Vo(n.doc,t.from,-1),i==null)return!1;if(e){let s=n.tr.join(i);r&&s.setSelection(Q.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},tA=(n,e)=>{let t=n.selection,r;if(t instanceof Q){if(t.node.isTextblock||!tr(n.doc,t.to))return!1;r=t.to}else if(r=Vo(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},nA=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&hi(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},qg=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
177
+ `).scrollIntoView()),!0)};function lu(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const rA=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),a=lu(i.contentMatchAt(s));if(!a||!i.canReplaceWith(s,s,a))return!1;if(e){let c=t.after(),u=n.tr.replaceWith(c,c,a.createAndFill());u.setSelection(ae.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},Jg=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof Ct||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=lu(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let a=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,c=n.tr.insert(a,s.createAndFill());c.setSelection(re.create(c.doc,a+1)),e(c.scrollIntoView())}return!0},Gg=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Cn(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&hi(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)};function iA(n){return(e,t)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Q&&e.selection.node.isBlock)return!r.parentOffset||!Cn(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],a,c,u=!1,d=!1;for(let g=r.depth;;g--)if(r.node(g).isBlock){u=r.end(g)==r.pos+(r.depth-g),d=r.start(g)==r.pos-(r.depth-g),c=lu(r.node(g-1).contentMatchAt(r.indexAfter(g-1))),s.unshift(u&&c?{type:c}:null),a=g;break}else{if(g==1)return!1;s.unshift(null)}let h=e.tr;(e.selection instanceof re||e.selection instanceof Ct)&&h.deleteSelection();let p=h.mapping.map(r.pos),y=Cn(h.doc,p,s.length,s);if(y||(s[0]=c?{type:c}:null,y=Cn(h.doc,p,s.length,s)),h.split(p,s.length,s),!u&&d&&r.node(a).type!=c){let g=h.mapping.map(r.before(a)),_=h.doc.resolve(g);c&&r.node(a-1).canReplaceWith(_.index(),_.index()+1,c)&&h.setNodeMarkup(h.mapping.map(r.before(a)),c)}return t&&t(h.scrollIntoView()),!0}}const sA=iA(),oA=(n,e)=>{let{$from:t,to:r}=n.selection,i,s=t.sharedDepth(r);return s==0?!1:(i=t.before(s),e&&e(n.tr.setSelection(Q.create(n.doc,i))),!0)};function aA(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||tr(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Yg(n,e,t,r){let i=e.nodeBefore,s=e.nodeAfter,a,c,u=i.type.spec.isolating||s.type.spec.isolating;if(!u&&aA(n,e,t))return!0;let d=!u&&e.parent.canReplace(e.index(),e.index()+1);if(d&&(a=(c=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&c.matchType(a[0]||s.type).validEnd){if(t){let g=e.pos+s.nodeSize,_=D.empty;for(let A=a.length-1;A>=0;A--)_=D.from(a[A].create(null,_));_=D.from(i.copy(_));let w=n.tr.step(new Ke(e.pos-1,g,e.pos,g,new H(_,1,0),a.length,!0)),k=w.doc.resolve(g+2*a.length);k.nodeAfter&&k.nodeAfter.type==i.type&&tr(w.doc,k.pos)&&w.join(k.pos),t(w.scrollIntoView())}return!0}let h=s.type.spec.isolating||r>0&&u?null:ae.findFrom(e,1),p=h&&h.$from.blockRange(h.$to),y=p&&hi(p);if(y!=null&&y>=e.depth)return t&&t(n.tr.lift(p,y).scrollIntoView()),!0;if(d&&di(s,"start",!0)&&di(i,"end")){let g=i,_=[];for(;_.push(g),!g.isTextblock;)g=g.lastChild;let w=s,k=1;for(;!w.isTextblock;w=w.firstChild)k++;if(g.canReplace(g.childCount,g.childCount,w.content)){if(t){let A=D.empty;for(let L=_.length-1;L>=0;L--)A=D.from(_[L].copy(A));let P=n.tr.step(new Ke(e.pos-_.length,e.pos+s.nodeSize,e.pos+k,e.pos+s.nodeSize-k,new H(A,_.length,0),0,!0));t(P.scrollIntoView())}return!0}}return!1}function Qg(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(re.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const lA=Qg(-1),cA=Qg(1);function uA(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,a=i.blockRange(s),c=a&&Jc(a,n,e);return c?(r&&r(t.tr.wrap(a,c).scrollIntoView()),!0):!1}}function Sp(n,e=null){return function(t,r){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:a},$to:{pos:c}}=t.selection.ranges[s];t.doc.nodesBetween(a,c,(u,d)=>{if(i)return!1;if(!(!u.isTextblock||u.hasMarkup(n,e)))if(u.type==n)i=!0;else{let h=t.doc.resolve(d),p=h.index();i=h.parent.canReplaceWith(p,p+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let a=0;a<t.selection.ranges.length;a++){let{$from:{pos:c},$to:{pos:u}}=t.selection.ranges[a];s.setBlockType(c,u,n,e)}r(s.scrollIntoView())}return!0}}function cu(...n){return function(e,t,r){for(let i=0;i<n.length;i++)if(n[i](e,t,r))return!0;return!1}}cu(su,Wg,Hg);cu(su,Kg,jg);cu(qg,Jg,Gg,sA);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function fA(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,a=i.blockRange(s);if(!a)return!1;let c=r?t.tr:null;return dA(c,a,n,e)?(r&&r(c.scrollIntoView()),!0):!1}}function dA(n,e,t,r=null){let i=!1,s=e,a=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let u=a.resolve(e.start-2);s=new Co(u,u,e.depth),e.endIndex<e.parent.childCount&&(e=new Co(e.$from,a.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let c=Jc(s,t,r,e);return c?(n&&hA(n,e,c,i,t),!0):!1}function hA(n,e,t,r,i){let s=D.empty;for(let h=t.length-1;h>=0;h--)s=D.from(t[h].type.create(t[h].attrs,s));n.step(new Ke(e.start-(r?2:0),e.end,e.start,e.end,new H(s,0,0),t.length,!0));let a=0;for(let h=0;h<t.length;h++)t[h].type==i&&(a=h+1);let c=t.length-a,u=e.start+t.length-(r?2:0),d=e.parent;for(let h=e.startIndex,p=e.endIndex,y=!0;h<p;h++,y=!1)!y&&Cn(n.doc,u,c)&&(n.split(u,c),u+=2*c),u+=d.child(h).nodeSize;return n}function pA(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,a=>a.childCount>0&&a.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?mA(e,t,n,s):gA(e,t,s):!0:!1}}function mA(n,e,t,r){let i=n.tr,s=r.end,a=r.$to.end(r.depth);s<a&&(i.step(new Ke(s-1,a,s,a,new H(D.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new Co(i.doc.resolve(r.$from.pos),i.doc.resolve(a),r.depth));const c=hi(r);if(c==null)return!1;i.lift(r,c);let u=i.doc.resolve(i.mapping.map(s,-1)-1);return tr(i.doc,u.pos)&&u.nodeBefore.type==u.nodeAfter.type&&i.join(u.pos),e(i.scrollIntoView()),!0}function gA(n,e,t){let r=n.tr,i=t.parent;for(let g=t.end,_=t.endIndex-1,w=t.startIndex;_>w;_--)g-=i.child(_).nodeSize,r.delete(g-1,g+1);let s=r.doc.resolve(t.start),a=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let c=t.startIndex==0,u=t.endIndex==i.childCount,d=s.node(-1),h=s.index(-1);if(!d.canReplace(h+(c?0:1),h+1,a.content.append(u?D.empty:D.from(i))))return!1;let p=s.pos,y=p+a.nodeSize;return r.step(new Ke(p-(c?1:0),y+(u?1:0),p+1,y-1,new H((c?D.empty:D.from(i.copy(D.empty))).append(u?D.empty:D.from(i.copy(D.empty))),c?0:1,u?0:1),c?0:1)),e(r.scrollIntoView()),!0}function yA(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,d=>d.childCount>0&&d.firstChild.type==n);if(!s)return!1;let a=s.startIndex;if(a==0)return!1;let c=s.parent,u=c.child(a-1);if(u.type!=n)return!1;if(t){let d=u.lastChild&&u.lastChild.type==c.type,h=D.from(d?n.create():null),p=new H(D.from(n.create(null,D.from(c.type.create(null,h)))),d?3:1,0),y=s.start,g=s.end;t(e.tr.step(new Ke(y-(d?3:1),g,y,g,p,1,!0)).scrollIntoView())}return!0}}function Jo(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:i}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=t.selection,i=t.doc,s=t.storedMarks,t}}}class Go{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:r}=this,{view:i}=t,{tr:s}=r,a=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([c,u])=>[c,(...h)=>{const p=u(...h)(a);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(s),p}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:i,state:s}=this,{view:a}=i,c=[],u=!!e,d=e||s.tr,h=()=>(!u&&t&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(d),c.every(y=>y===!0)),p={...Object.fromEntries(Object.entries(r).map(([y,g])=>[y,(...w)=>{const k=this.buildProps(d,t),A=g(...w)(k);return c.push(A),p}])),run:h};return p}createCan(e){const{rawCommands:t,state:r}=this,i=!1,s=e||r.tr,a=this.buildProps(s,i);return{...Object.fromEntries(Object.entries(t).map(([u,d])=>[u,(...h)=>d(...h)({...a,dispatch:void 0})])),chain:()=>this.createChain(s,i)}}buildProps(e,t=!0){const{rawCommands:r,editor:i,state:s}=this,{view:a}=i,c={tr:e,editor:i,view:a,state:Jo({state:s,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([u,d])=>[u,(...h)=>d(...h)(c)]))}};return c}}class _A{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(i=>i!==t):delete this.callbacks[e]),this}once(e,t){const r=(...i)=>{this.off(e,r),t.apply(this,i)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}}function j(n,e,t){return n.config[e]===void 0&&n.parent?j(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?j(n.parent,e,t):null}):n.config[e]}function Yo(n){const e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Xg(n){const e=[],{nodeExtensions:t,markExtensions:r}=Yo(n),i=[...t,...r],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(a=>{const c={name:a.name,options:a.options,storage:a.storage,extensions:i},u=j(a,"addGlobalAttributes",c);if(!u)return;u().forEach(h=>{h.types.forEach(p=>{Object.entries(h.attributes).forEach(([y,g])=>{e.push({type:p,name:y,attribute:{...s,...g}})})})})}),i.forEach(a=>{const c={name:a.name,options:a.options,storage:a.storage},u=j(a,"addAttributes",c);if(!u)return;const d=u();Object.entries(d).forEach(([h,p])=>{const y={...s,...p};typeof(y==null?void 0:y.default)=="function"&&(y.default=y.default()),y!=null&&y.isRequired&&(y==null?void 0:y.default)===void 0&&delete y.default,e.push({type:a.name,name:h,attribute:y})})}),e}function qe(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function ze(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const c=s?String(s).split(" "):[],u=r[i]?r[i].split(" "):[],d=c.filter(h=>!u.includes(h));r[i]=[...u,...d].join(" ")}else if(i==="style"){const c=s?s.split(";").map(h=>h.trim()).filter(Boolean):[],u=r[i]?r[i].split(";").map(h=>h.trim()).filter(Boolean):[],d=new Map;u.forEach(h=>{const[p,y]=h.split(":").map(g=>g.trim());d.set(p,y)}),c.forEach(h=>{const[p,y]=h.split(":").map(g=>g.trim());d.set(p,y)}),r[i]=Array.from(d.entries()).map(([h,p])=>`${h}: ${p}`).join("; ")}else r[i]=s}),r},{})}function Nc(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>ze(t,r),{})}function Zg(n){return typeof n=="function"}function fe(n,e=void 0,...t){return Zg(n)?e?n.bind(e)(...t):n(...t):n}function bA(n={}){return Object.keys(n).length===0&&n.constructor===Object}function vA(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function wp(n,e){return"style"in n?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const i=e.reduce((s,a)=>{const c=a.attribute.parseHTML?a.attribute.parseHTML(t):vA(t.getAttribute(a.name));return c==null?s:{...s,[a.name]:c}},{});return{...r,...i}}}}function kp(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&bA(t)?!1:t!=null))}function SA(n,e){var t;const r=Xg(n),{nodeExtensions:i,markExtensions:s}=Yo(n),a=(t=i.find(d=>j(d,"topNode")))===null||t===void 0?void 0:t.name,c=Object.fromEntries(i.map(d=>{const h=r.filter(A=>A.type===d.name),p={name:d.name,options:d.options,storage:d.storage,editor:e},y=n.reduce((A,P)=>{const L=j(P,"extendNodeSchema",p);return{...A,...L?L(d):{}}},{}),g=kp({...y,content:fe(j(d,"content",p)),marks:fe(j(d,"marks",p)),group:fe(j(d,"group",p)),inline:fe(j(d,"inline",p)),atom:fe(j(d,"atom",p)),selectable:fe(j(d,"selectable",p)),draggable:fe(j(d,"draggable",p)),code:fe(j(d,"code",p)),whitespace:fe(j(d,"whitespace",p)),linebreakReplacement:fe(j(d,"linebreakReplacement",p)),defining:fe(j(d,"defining",p)),isolating:fe(j(d,"isolating",p)),attrs:Object.fromEntries(h.map(A=>{var P;return[A.name,{default:(P=A==null?void 0:A.attribute)===null||P===void 0?void 0:P.default}]}))}),_=fe(j(d,"parseHTML",p));_&&(g.parseDOM=_.map(A=>wp(A,h)));const w=j(d,"renderHTML",p);w&&(g.toDOM=A=>w({node:A,HTMLAttributes:Nc(A,h)}));const k=j(d,"renderText",p);return k&&(g.toText=k),[d.name,g]})),u=Object.fromEntries(s.map(d=>{const h=r.filter(k=>k.type===d.name),p={name:d.name,options:d.options,storage:d.storage,editor:e},y=n.reduce((k,A)=>{const P=j(A,"extendMarkSchema",p);return{...k,...P?P(d):{}}},{}),g=kp({...y,inclusive:fe(j(d,"inclusive",p)),excludes:fe(j(d,"excludes",p)),group:fe(j(d,"group",p)),spanning:fe(j(d,"spanning",p)),code:fe(j(d,"code",p)),attrs:Object.fromEntries(h.map(k=>{var A;return[k.name,{default:(A=k==null?void 0:k.attribute)===null||A===void 0?void 0:A.default}]}))}),_=fe(j(d,"parseHTML",p));_&&(g.parseDOM=_.map(k=>wp(k,h)));const w=j(d,"renderHTML",p);return w&&(g.toDOM=k=>w({mark:k,HTMLAttributes:Nc(k,h)})),[d.name,g]}));return new Vm({topNode:a,nodes:c,marks:u})}function Vl(n,e){return e.nodes[n]||e.marks[n]||null}function xp(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function uu(n,e){const t=Ir.fromSchema(e).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}const wA=(n,e=500)=>{let t="";const r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(i,s,a,c)=>{var u,d;const h=((d=(u=i.type.spec).toText)===null||d===void 0?void 0:d.call(u,{node:i,pos:s,parent:a,index:c}))||i.textContent||"%leaf%";t+=i.isAtom&&!i.isText?h:h.slice(0,Math.max(0,r-s))}),t};function fu(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class Qo{constructor(e){this.find=e.find,this.handler=e.handler}}const kA=(n,e)=>{if(fu(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function ao(n){var e;const{editor:t,from:r,to:i,text:s,rules:a,plugin:c}=n,{view:u}=t;if(u.composing)return!1;const d=u.state.doc.resolve(r);if(d.parent.type.spec.code||!((e=d.nodeBefore||d.nodeAfter)===null||e===void 0)&&e.marks.find(y=>y.type.spec.code))return!1;let h=!1;const p=wA(d)+s;return a.forEach(y=>{if(h)return;const g=kA(p,y.find);if(!g)return;const _=u.state.tr,w=Jo({state:u.state,transaction:_}),k={from:r-(g[0].length-s.length),to:i},{commands:A,chain:P,can:L}=new Go({editor:t,state:w});y.handler({state:w,range:k,match:g,commands:A,chain:P,can:L})===null||!_.steps.length||(_.setMeta(c,{transform:_,from:r,to:i,text:s}),u.dispatch(_),h=!0)}),h}function xA(n){const{editor:e,rules:t}=n,r=new St({state:{init(){return null},apply(i,s,a){const c=i.getMeta(r);if(c)return c;const u=i.getMeta("applyInputRules");return!!u&&setTimeout(()=>{let{text:h}=u;typeof h=="string"?h=h:h=uu(D.from(h),a.schema);const{from:p}=u,y=p+h.length;ao({editor:e,from:p,to:y,text:h,rules:t,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,a,c){return ao({editor:e,from:s,to:a,text:c,rules:t,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&ao({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:a}=i.state.selection;return a?ao({editor:e,from:a.pos,to:a.pos,text:`
178
+ `,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function EA(n){return Object.prototype.toString.call(n).slice(8,-1)}function lo(n){return EA(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Xo(n,e){const t={...n};return lo(n)&&lo(e)&&Object.keys(e).forEach(r=>{lo(e[r])&&lo(n[r])?t[r]=Xo(n[r],e[r]):t[r]=e[r]}),t}class Kt{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=fe(j(this,"addOptions",{name:this.name}))),this.storage=fe(j(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Kt(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Xo(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new Kt(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=fe(j(t,"addOptions",{name:t.name})),t.storage=fe(j(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const a=i.marks();if(!!!a.find(d=>(d==null?void 0:d.type.name)===t.name))return!1;const u=a.find(d=>(d==null?void 0:d.type.name)===t.name);return u&&r.removeStoredMark(u),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}}function OA(n){return typeof n=="number"}class TA{constructor(e){this.find=e.find,this.handler=e.handler}}const AA=(n,e,t)=>{if(fu(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=n,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function CA(n){const{editor:e,state:t,from:r,to:i,rule:s,pasteEvent:a,dropEvent:c}=n,{commands:u,chain:d,can:h}=new Go({editor:e,state:t}),p=[];return t.doc.nodesBetween(r,i,(g,_)=>{if(!g.isTextblock||g.type.spec.code)return;const w=Math.max(r,_),k=Math.min(i,_+g.content.size),A=g.textBetween(w-_,k-_,void 0,"");AA(A,s.find,a).forEach(L=>{if(L.index===void 0)return;const B=w+L.index+1,z=B+L[0].length,$={from:t.tr.mapping.map(B),to:t.tr.mapping.map(z)},J=s.handler({state:t,range:$,match:L,commands:u,chain:d,can:h,pasteEvent:a,dropEvent:c});p.push(J)})}),p.every(g=>g!==null)}let co=null;const MA=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function NA(n){const{editor:e,rules:t}=n;let r=null,i=!1,s=!1,a=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,c;try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}const u=({state:h,from:p,to:y,rule:g,pasteEvt:_})=>{const w=h.tr,k=Jo({state:h,transaction:w});if(!(!CA({editor:e,state:k,from:Math.max(p-1,0),to:y.b-1,rule:g,pasteEvent:_,dropEvent:c})||!w.steps.length)){try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}return a=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,w}};return t.map(h=>new St({view(p){const y=_=>{var w;r=!((w=p.dom.parentElement)===null||w===void 0)&&w.contains(_.target)?p.dom.parentElement:null,r&&(co=e)},g=()=>{co&&(co=null)};return window.addEventListener("dragstart",y),window.addEventListener("dragend",g),{destroy(){window.removeEventListener("dragstart",y),window.removeEventListener("dragend",g)}}},props:{handleDOMEvents:{drop:(p,y)=>{if(s=r===p.dom.parentElement,c=y,!s){const g=co;g&&setTimeout(()=>{const _=g.state.selection;_&&g.commands.deleteRange({from:_.from,to:_.to})},10)}return!1},paste:(p,y)=>{var g;const _=(g=y.clipboardData)===null||g===void 0?void 0:g.getData("text/html");return a=y,i=!!(_!=null&&_.includes("data-pm-slice")),!1}}},appendTransaction:(p,y,g)=>{const _=p[0],w=_.getMeta("uiEvent")==="paste"&&!i,k=_.getMeta("uiEvent")==="drop"&&!s,A=_.getMeta("applyPasteRules"),P=!!A;if(!w&&!k&&!P)return;if(P){let{text:z}=A;typeof z=="string"?z=z:z=uu(D.from(z),g.schema);const{from:$}=A,J=$+z.length,K=MA(z);return u({rule:h,state:g,from:$,to:{b:J},pasteEvt:K})}const L=y.doc.content.findDiffStart(g.doc.content),B=y.doc.content.findDiffEnd(g.doc.content);if(!(!OA(L)||!B||L===B.b))return u({rule:h,state:g,from:L,to:B,pasteEvt:a})}}))}function IA(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}class ni{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=ni.resolve(e),this.schema=SA(this.extensions,t),this.setupExtensions()}static resolve(e){const t=ni.sort(ni.flatten(e)),r=IA(t.map(i=>i.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{const r={name:t.name,options:t.options,storage:t.storage},i=j(t,"addExtensions",r);return i?[t,...this.flatten(i())]:t}).flat(10)}static sort(e){return e.sort((r,i)=>{const s=j(r,"priority")||100,a=j(i,"priority")||100;return s>a?-1:s<a?1:0})}get commands(){return this.extensions.reduce((e,t)=>{const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Vl(t.name,this.schema)},i=j(t,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,t=ni.sort([...this.extensions].reverse()),r=[],i=[],s=t.map(a=>{const c={name:a.name,options:a.options,storage:a.storage,editor:e,type:Vl(a.name,this.schema)},u=[],d=j(a,"addKeyboardShortcuts",c);let h={};if(a.type==="mark"&&j(a,"exitable",c)&&(h.ArrowRight=()=>Kt.handleExit({editor:e,mark:a})),d){const w=Object.fromEntries(Object.entries(d()).map(([k,A])=>[k,()=>A({editor:e})]));h={...h,...w}}const p=QT(h);u.push(p);const y=j(a,"addInputRules",c);xp(a,e.options.enableInputRules)&&y&&r.push(...y());const g=j(a,"addPasteRules",c);xp(a,e.options.enablePasteRules)&&g&&i.push(...g());const _=j(a,"addProseMirrorPlugins",c);if(_){const w=_();u.push(...w)}return u}).flat();return[xA({editor:e,rules:r}),...NA({editor:e,rules:i}),...s]}get attributes(){return Xg(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=Yo(this.extensions);return Object.fromEntries(t.filter(r=>!!j(r,"addNodeView")).map(r=>{const i=this.attributes.filter(u=>u.type===r.name),s={name:r.name,options:r.options,storage:r.storage,editor:e,type:qe(r.name,this.schema)},a=j(r,"addNodeView",s);if(!a)return[];const c=(u,d,h,p,y)=>{const g=Nc(u,i);return a()({node:u,view:d,getPos:h,decorations:p,innerDecorations:y,editor:e,extension:r,HTMLAttributes:g})};return[r.name,c]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Vl(e.name,this.schema)};e.type==="mark"&&(!((t=fe(j(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);const i=j(e,"onBeforeCreate",r),s=j(e,"onCreate",r),a=j(e,"onUpdate",r),c=j(e,"onSelectionUpdate",r),u=j(e,"onTransaction",r),d=j(e,"onFocus",r),h=j(e,"onBlur",r),p=j(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),a&&this.editor.on("update",a),c&&this.editor.on("selectionUpdate",c),u&&this.editor.on("transaction",u),d&&this.editor.on("focus",d),h&&this.editor.on("blur",h),p&&this.editor.on("destroy",p)})}}class it{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=fe(j(this,"addOptions",{name:this.name}))),this.storage=fe(j(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new it(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Xo(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new it({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=fe(j(t,"addOptions",{name:t.name})),t.storage=fe(j(t,"addStorage",{name:t.name,options:t.options})),t}}function ey(n,e,t){const{from:r,to:i}=e,{blockSeparator:s=`
177
179
 
178
180
  `,textSerializers:a={}}=t||{};let c="";return n.nodesBetween(r,i,(u,d,h,p)=>{var y;u.isBlock&&d>r&&(c+=s);const g=a==null?void 0:a[u.type.name];if(g)return h&&(c+=g({node:u,pos:d,parent:h,index:p,range:e})),!1;u.isText&&(c+=(y=u==null?void 0:u.text)===null||y===void 0?void 0:y.slice(Math.max(r,d)-d,i-d))}),c}function ty(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const PA=it.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new St({key:new fn("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:i}=e,{ranges:s}=i,a=Math.min(...s.map(h=>h.$from.pos)),c=Math.max(...s.map(h=>h.$to.pos)),u=ty(t);return ey(r,{from:a,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),RA=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),DA=(n=!1)=>({commands:e})=>e.setContent("",n),LA=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:s,$to:a})=>{n.doc.nodesBetween(s.pos,a.pos,(c,u)=>{if(c.type.isText)return;const{doc:d,mapping:h}=e,p=d.resolve(h.map(u)),y=d.resolve(h.map(u+c.nodeSize)),g=p.blockRange(y);if(!g)return;const _=hi(g);if(c.type.isTextblock){const{defaultType:w}=p.parent.contentMatchAt(p.index());e.setNodeMarkup(g.start,w)}(_||_===0)&&e.lift(g,_)})}),!0},BA=n=>e=>n(e),FA=()=>({state:n,dispatch:e})=>Jg(n,e),$A=(n,e)=>({editor:t,tr:r})=>{const{state:i}=t,s=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const a=r.mapping.map(e);return r.insert(a,s.content),r.setSelection(new re(r.doc.resolve(a-1))),!0},zA=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const i=n.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const c=i.before(s),u=i.after(s);n.delete(c,u).scrollIntoView()}return!0}return!1},WA=n=>({tr:e,state:t,dispatch:r})=>{const i=qe(n,t.schema),s=e.selection.$anchor;for(let a=s.depth;a>0;a-=1)if(s.node(a).type===i){if(r){const u=s.before(a),d=s.after(a);e.delete(u,d).scrollIntoView()}return!0}return!1},VA=n=>({tr:e,dispatch:t})=>{const{from:r,to:i}=n;return t&&e.delete(r,i),!0},HA=()=>({state:n,dispatch:e})=>su(n,e),UA=()=>({commands:n})=>n.keyboardShortcut("Enter"),KA=()=>({state:n,dispatch:e})=>rA(n,e);function Bo(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:fu(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function ny(n,e,t={}){return n.find(r=>r.type===e&&Bo(Object.fromEntries(Object.keys(t).map(i=>[i,r.attrs[i]])),t))}function Ep(n,e,t={}){return!!ny(n,e,t)}function du(n,e,t){var r;if(!n||!e)return;let i=n.parent.childAfter(n.parentOffset);if((!i.node||!i.node.marks.some(h=>h.type===e))&&(i=n.parent.childBefore(n.parentOffset)),!i.node||!i.node.marks.some(h=>h.type===e)||(t=t||((r=i.node.marks[0])===null||r===void 0?void 0:r.attrs),!ny([...i.node.marks],e,t)))return;let a=i.index,c=n.start()+i.offset,u=a+1,d=c+i.node.nodeSize;for(;a>0&&Ep([...n.parent.child(a-1).marks],e,t);)a-=1,c-=n.parent.child(a).nodeSize;for(;u<n.parent.childCount&&Ep([...n.parent.child(u).marks],e,t);)d+=n.parent.child(u).nodeSize,u+=1;return{from:c,to:d}}function rr(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}const jA=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const s=rr(n,r.schema),{doc:a,selection:c}=t,{$from:u,from:d,to:h}=c;if(i){const p=du(u,s,e);if(p&&p.from<=d&&p.to>=h){const y=re.create(a,p.from,p.to);t.setSelection(y)}}return!0},qA=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function ry(n){return n instanceof re}function br(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function iy(n,e=null){if(!e)return null;const t=ae.atStart(n),r=ae.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const i=t.from,s=r.to;return e==="all"?re.create(n,br(0,i,s),br(n.content.size,i,s)):re.create(n,br(e,i,s),br(e,i,s))}function JA(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function hu(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const GA=(n=null,e={})=>({editor:t,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const a=()=>{(hu()||JA())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(s&&n===null&&!ry(t.state.selection))return a(),!0;const c=iy(i.doc,n)||t.state.selection,u=t.state.selection.eq(c);return s&&(u||i.setSelection(c),u&&i.storedMarks&&i.setStoredMarks(i.storedMarks),a()),!0},YA=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),QA=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),sy=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&sy(r)}return n};function uo(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return sy(t)}function Fo(n,e,t){if(n instanceof Gn||n instanceof D)return n;t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,i=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return D.fromArray(n.map(c=>e.nodeFromJSON(c)));const a=e.nodeFromJSON(n);return t.errorOnInvalidContent&&a.check(),a}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),Fo("",e,t)}if(i){if(t.errorOnInvalidContent){let a=!1,c="";const u=new Vm({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:d=>(a=!0,c=typeof d=="string"?d:d.outerHTML,null)}]}})});if(t.slice?Yn.fromSchema(u).parseSlice(uo(n),t.parseOptions):Yn.fromSchema(u).parse(uo(n),t.parseOptions),t.errorOnInvalidContent&&a)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const s=Yn.fromSchema(e);return t.slice?s.parseSlice(uo(n),t.parseOptions).content:s.parse(uo(n),t.parseOptions)}return Fo("",e,t)}function XA(n,e,t){const r=n.steps.length-1;if(r<e)return;const i=n.steps[r];if(!(i instanceof Ue||i instanceof Ke))return;const s=n.mapping.maps[r];let a=0;s.forEach((c,u,d,h)=>{a===0&&(a=h)}),n.setSelection(ae.near(n.doc.resolve(a),t))}const ZA=n=>!("type"in n),eC=(n,e,t)=>({tr:r,dispatch:i,editor:s})=>{var a;if(i){t={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let c;try{c=Fo(e,s.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions},errorOnInvalidContent:(a=t.errorOnInvalidContent)!==null&&a!==void 0?a:s.options.enableContentCheck})}catch(_){return s.emit("contentError",{editor:s,error:_,disableCollaboration:()=>{s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}}),!1}let{from:u,to:d}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},h=!0,p=!0;if((ZA(c)?c:[c]).forEach(_=>{_.check(),h=h?_.isText&&_.marks.length===0:!1,p=p?_.isBlock:!1}),u===d&&p){const{parent:_}=r.doc.resolve(u);_.isTextblock&&!_.type.spec.code&&!_.childCount&&(u-=1,d+=1)}let g;if(h){if(Array.isArray(e))g=e.map(_=>_.text||"").join("");else if(e instanceof D){let _="";e.forEach(w=>{w.text&&(_+=w.text)}),g=_}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,u,d)}else g=c,r.replaceWith(u,d,g);t.updateSelection&&XA(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:g}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:g})}return!0},tC=()=>({state:n,dispatch:e})=>eA(n,e),nC=()=>({state:n,dispatch:e})=>tA(n,e),rC=()=>({state:n,dispatch:e})=>Wg(n,e),iC=()=>({state:n,dispatch:e})=>Kg(n,e),sC=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Vo(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},oC=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Vo(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},aC=()=>({state:n,dispatch:e})=>XT(n,e),lC=()=>({state:n,dispatch:e})=>ZT(n,e);function oy(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function cC(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,i,s,a;for(let c=0;c<e.length-1;c+=1){const u=e[c];if(/^(cmd|meta|m)$/i.test(u))a=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))s=!0;else if(/^mod$/i.test(u))hu()||oy()?a=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return r&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),a&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}const uC=n=>({editor:e,view:t,tr:r,dispatch:i})=>{const s=cC(n).split(/-(?!$)/),a=s.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),c=new KeyboardEvent("keydown",{key:a==="Space"?" ":a,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),u=e.captureTransaction(()=>{t.someProp("handleKeyDown",d=>d(t,c))});return u==null||u.steps.forEach(d=>{const h=d.map(r.mapping);h&&i&&r.maybeStep(h)}),!0};function ss(n,e,t={}){const{from:r,to:i,empty:s}=n.selection,a=e?qe(e,n.schema):null,c=[];n.doc.nodesBetween(r,i,(p,y)=>{if(p.isText)return;const g=Math.max(r,y),_=Math.min(i,y+p.nodeSize);c.push({node:p,from:g,to:_})});const u=i-r,d=c.filter(p=>a?a.name===p.node.type.name:!0).filter(p=>Bo(p.node.attrs,t,{strict:!1}));return s?!!d.length:d.reduce((p,y)=>p+y.to-y.from,0)>=u}const fC=(n,e={})=>({state:t,dispatch:r})=>{const i=qe(n,t.schema);return ss(t,i,e)?nA(t,r):!1},dC=()=>({state:n,dispatch:e})=>Gg(n,e),hC=n=>({state:e,dispatch:t})=>{const r=qe(n,e.schema);return pA(r)(e,t)},pC=()=>({state:n,dispatch:e})=>qg(n,e);function Zo(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Op(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}const mC=(n,e)=>({tr:t,state:r,dispatch:i})=>{let s=null,a=null;const c=Zo(typeof n=="string"?n:n.name,r.schema);return c?(c==="node"&&(s=qe(n,r.schema)),c==="mark"&&(a=rr(n,r.schema)),i&&t.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,h)=>{s&&s===d.type&&t.setNodeMarkup(h,void 0,Op(d.attrs,e)),a&&d.marks.length&&d.marks.forEach(p=>{a===p.type&&t.addMark(h,h+d.nodeSize,a.create(Op(p.attrs,e)))})})}),!0):!1},gC=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),yC=()=>({tr:n,dispatch:e})=>{if(e){const t=new Ct(n.doc);n.setSelection(t)}return!0},_C=()=>({state:n,dispatch:e})=>Hg(n,e),bC=()=>({state:n,dispatch:e})=>jg(n,e),vC=()=>({state:n,dispatch:e})=>oA(n,e),SC=()=>({state:n,dispatch:e})=>cA(n,e),wC=()=>({state:n,dispatch:e})=>lA(n,e);function Ic(n,e,t={},r={}){return Fo(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}const kC=(n,e=!1,t={},r={})=>({editor:i,tr:s,dispatch:a,commands:c})=>{var u,d;const{doc:h}=s;if(t.preserveWhitespace!=="full"){const p=Ic(n,i.schema,t,{errorOnInvalidContent:(u=r.errorOnInvalidContent)!==null&&u!==void 0?u:i.options.enableContentCheck});return a&&s.replaceWith(0,h.content.size,p).setMeta("preventUpdate",!e),!0}return a&&s.setMeta("preventUpdate",!e),c.insertContentAt({from:0,to:h.content.size},n,{parseOptions:t,errorOnInvalidContent:(d=r.errorOnInvalidContent)!==null&&d!==void 0?d:i.options.enableContentCheck})};function ay(n,e){const t=rr(e,n.schema),{from:r,to:i,empty:s}=n.selection,a=[];s?(n.storedMarks&&a.push(...n.storedMarks),a.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,u=>{a.push(...u.marks)});const c=a.find(u=>u.type.name===t.name);return c?{...c.attrs}:{}}function xC(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function EC(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function pu(n){return e=>EC(e.$from,n)}function OC(n,e){const t={from:0,to:n.content.size};return ey(n,t,e)}function TC(n,e){const t=qe(e,n.schema),{from:r,to:i}=n.selection,s=[];n.doc.nodesBetween(r,i,c=>{s.push(c)});const a=s.reverse().find(c=>c.type.name===t.name);return a?{...a.attrs}:{}}function AC(n,e){const t=Zo(typeof e=="string"?e:e.name,n.schema);return t==="node"?TC(n,e):t==="mark"?ay(n,e):{}}function ly(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(i=>{const s=t.resolve(n),a=du(s,i.type);a&&r.push({mark:i,...a})}):t.nodesBetween(n,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(a=>({from:s,to:s+i.nodeSize,mark:a})))}),r}function bo(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const i=n.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}function Pc(n,e,t={}){const{empty:r,ranges:i}=n.selection,s=e?rr(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(p=>s?s.name===p.type.name:!0).find(p=>Bo(p.attrs,t,{strict:!1}));let a=0;const c=[];if(i.forEach(({$from:p,$to:y})=>{const g=p.pos,_=y.pos;n.doc.nodesBetween(g,_,(w,k)=>{if(!w.isText&&!w.marks.length)return;const A=Math.max(g,k),P=Math.min(_,k+w.nodeSize),L=P-A;a+=L,c.push(...w.marks.map(B=>({mark:B,from:A,to:P})))})}),a===0)return!1;const u=c.filter(p=>s?s.name===p.mark.type.name:!0).filter(p=>Bo(p.mark.attrs,t,{strict:!1})).reduce((p,y)=>p+y.to-y.from,0),d=c.filter(p=>s?p.mark.type!==s&&p.mark.type.excludes(s):!0).reduce((p,y)=>p+y.to-y.from,0);return(u>0?u+d:u)>=a}function CC(n,e,t={}){if(!e)return ss(n,null,t)||Pc(n,null,t);const r=Zo(e,n.schema);return r==="node"?ss(n,e,t):r==="mark"?Pc(n,e,t):!1}function Tp(n,e){const{nodeExtensions:t}=Yo(e),r=t.find(a=>a.name===n);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=fe(j(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function mu(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let i=!0;return n.content.forEach(s=>{i!==!1&&(mu(s,{ignoreWhitespace:t,checkChildren:e})||(i=!1))}),i}return!1}function MC(n){return n instanceof Q}function NC(n,e,t){var r;const{selection:i}=e;let s=null;if(ry(i)&&(s=i.$cursor),s){const c=(r=n.storedMarks)!==null&&r!==void 0?r:s.marks();return!!t.isInSet(c)||!c.some(u=>u.type.excludes(t))}const{ranges:a}=i;return a.some(({$from:c,$to:u})=>{let d=c.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(c.pos,u.pos,(h,p,y)=>{if(d)return!1;if(h.isInline){const g=!y||y.type.allowsMarkType(t),_=!!t.isInSet(h.marks)||!h.marks.some(w=>w.type.excludes(t));d=g&&_}return!d}),d})}const IC=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const{selection:s}=t,{empty:a,ranges:c}=s,u=rr(n,r.schema);if(i)if(a){const d=ay(r,u);t.addStoredMark(u.create({...d,...e}))}else c.forEach(d=>{const h=d.$from.pos,p=d.$to.pos;r.doc.nodesBetween(h,p,(y,g)=>{const _=Math.max(g,h),w=Math.min(g+y.nodeSize,p);y.marks.find(A=>A.type===u)?y.marks.forEach(A=>{u===A.type&&t.addMark(_,w,u.create({...A.attrs,...e}))}):t.addMark(_,w,u.create(e))})});return NC(r,t,u)},PC=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),RC=(n,e={})=>({state:t,dispatch:r,chain:i})=>{const s=qe(n,t.schema);let a;return t.selection.$anchor.sameParent(t.selection.$head)&&(a=t.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:c})=>Sp(s,{...a,...e})(t)?!0:c.clearNodes()).command(({state:c})=>Sp(s,{...a,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},DC=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,i=br(n,0,r.content.size),s=Q.create(r,i);e.setSelection(s)}return!0},LC=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:i,to:s}=typeof n=="number"?{from:n,to:n}:n,a=re.atStart(r).from,c=re.atEnd(r).to,u=br(i,a,c),d=br(s,a,c),h=re.create(r,u,d);e.setSelection(h)}return!0},BC=n=>({state:e,dispatch:t})=>{const r=qe(n,e.schema);return yA(r)(e,t)};function Ap(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(i=>e==null?void 0:e.includes(i.type.name));n.tr.ensureMarks(r)}}const FC=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{const{selection:s,doc:a}=e,{$from:c,$to:u}=s,d=i.extensionManager.attributes,h=bo(d,c.node().type.name,c.node().attrs);if(s instanceof Q&&s.node.isBlock)return!c.parentOffset||!Cn(a,c.pos)?!1:(r&&(n&&Ap(t,i.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;const p=u.parentOffset===u.parent.content.size,y=c.depth===0?void 0:xC(c.node(-1).contentMatchAt(c.indexAfter(-1)));let g=p&&y?[{type:y,attrs:h}]:void 0,_=Cn(e.doc,e.mapping.map(c.pos),1,g);if(!g&&!_&&Cn(e.doc,e.mapping.map(c.pos),1,y?[{type:y}]:void 0)&&(_=!0,g=y?[{type:y,attrs:h}]:void 0),r){if(_&&(s instanceof re&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,g),y&&!p&&!c.parentOffset&&c.parent.type!==y)){const w=e.mapping.map(c.before()),k=e.doc.resolve(w);c.node(-1).canReplaceWith(k.index(),k.index()+1,y)&&e.setNodeMarkup(e.mapping.map(c.before()),y)}n&&Ap(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return _},$C=(n,e={})=>({tr:t,state:r,dispatch:i,editor:s})=>{var a;const c=qe(n,r.schema),{$from:u,$to:d}=r.selection,h=r.selection.node;if(h&&h.isBlock||u.depth<2||!u.sameParent(d))return!1;const p=u.node(-1);if(p.type!==c)return!1;const y=s.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==c||u.index(-2)!==u.node(-2).childCount-1)return!1;if(i){let A=D.empty;const P=u.index(-1)?1:u.index(-2)?2:3;for(let K=u.depth-P;K>=u.depth-3;K-=1)A=D.from(u.node(K).copy(A));const L=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3,B={...bo(y,u.node().type.name,u.node().attrs),...e},z=((a=c.contentMatch.defaultType)===null||a===void 0?void 0:a.createAndFill(B))||void 0;A=A.append(D.from(c.createAndFill(null,z)||void 0));const $=u.before(u.depth-(P-1));t.replace($,u.after(-L),new H(A,4-P,0));let J=-1;t.doc.nodesBetween($,t.doc.content.size,(K,V)=>{if(J>-1)return!1;K.isTextblock&&K.content.size===0&&(J=V+1)}),J>-1&&t.setSelection(re.near(t.doc.resolve(J))),t.scrollIntoView()}return!0}const g=d.pos===u.end()?p.contentMatchAt(0).defaultType:null,_={...bo(y,p.type.name,p.attrs),...e},w={...bo(y,u.node().type.name,u.node().attrs),...e};t.delete(u.pos,d.pos);const k=g?[{type:c,attrs:_},{type:g,attrs:w}]:[{type:c,attrs:_}];if(!Cn(t.doc,u.pos,2))return!1;if(i){const{selection:A,storedMarks:P}=r,{splittableMarks:L}=s.extensionManager,B=P||A.$to.parentOffset&&A.$from.marks();if(t.split(u.pos,2,k).scrollIntoView(),!B||!i)return!0;const z=B.filter($=>L.includes($.type.name));t.ensureMarks(z)}return!0},Hl=(n,e)=>{const t=pu(a=>a.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&tr(n.doc,t.pos)&&n.join(t.pos),!0},Ul=(n,e)=>{const t=pu(a=>a.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&tr(n.doc,r)&&n.join(r),!0},zC=(n,e,t,r={})=>({editor:i,tr:s,state:a,dispatch:c,chain:u,commands:d,can:h})=>{const{extensions:p,splittableMarks:y}=i.extensionManager,g=qe(n,a.schema),_=qe(e,a.schema),{selection:w,storedMarks:k}=a,{$from:A,$to:P}=w,L=A.blockRange(P),B=k||w.$to.parentOffset&&w.$from.marks();if(!L)return!1;const z=pu($=>Tp($.type.name,p))(w);if(L.depth>=1&&z&&L.depth-z.depth<=1){if(z.node.type===g)return d.liftListItem(_);if(Tp(z.node.type.name,p)&&g.validContent(z.node.content)&&c)return u().command(()=>(s.setNodeMarkup(z.pos,g),!0)).command(()=>Hl(s,g)).command(()=>Ul(s,g)).run()}return!t||!B||!c?u().command(()=>h().wrapInList(g,r)?!0:d.clearNodes()).wrapInList(g,r).command(()=>Hl(s,g)).command(()=>Ul(s,g)).run():u().command(()=>{const $=h().wrapInList(g,r),J=B.filter(K=>y.includes(K.type.name));return s.ensureMarks(J),$?!0:d.clearNodes()}).wrapInList(g,r).command(()=>Hl(s,g)).command(()=>Ul(s,g)).run()},WC=(n,e={},t={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,a=rr(n,r.schema);return Pc(r,a,e)?i.unsetMark(a,{extendEmptyMarkRange:s}):i.setMark(a,e)},VC=(n,e,t={})=>({state:r,commands:i})=>{const s=qe(n,r.schema),a=qe(e,r.schema),c=ss(r,s,t);let u;return r.selection.$anchor.sameParent(r.selection.$head)&&(u=r.selection.$anchor.parent.attrs),c?i.setNode(a,u):i.setNode(s,{...u,...t})},HC=(n,e={})=>({state:t,commands:r})=>{const i=qe(n,t.schema);return ss(t,i,e)?r.lift(i):r.wrapIn(i,e)},UC=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const i=t[r];let s;if(i.spec.isInputRules&&(s=i.getState(n))){if(e){const a=n.tr,c=s.transform;for(let u=c.steps.length-1;u>=0;u-=1)a.step(c.steps[u].invert(c.docs[u]));if(s.text){const u=a.doc.resolve(s.from).marks();a.replaceWith(s.from,s.to,n.schema.text(s.text,u))}else a.delete(s.from,s.to)}return!0}}return!1},KC=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:i}=t;return r||e&&i.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},jC=(n,e={})=>({tr:t,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:a=!1}=e,{selection:c}=t,u=rr(n,r.schema),{$from:d,empty:h,ranges:p}=c;if(!i)return!0;if(h&&a){let{from:y,to:g}=c;const _=(s=d.marks().find(k=>k.type===u))===null||s===void 0?void 0:s.attrs,w=du(d,u,_);w&&(y=w.from,g=w.to),t.removeMark(y,g,u)}else p.forEach(y=>{t.removeMark(y.$from.pos,y.$to.pos,u)});return t.removeStoredMark(u),!0},qC=(n,e={})=>({tr:t,state:r,dispatch:i})=>{let s=null,a=null;const c=Zo(typeof n=="string"?n:n.name,r.schema);return c?(c==="node"&&(s=qe(n,r.schema)),c==="mark"&&(a=rr(n,r.schema)),i&&t.selection.ranges.forEach(u=>{const d=u.$from.pos,h=u.$to.pos;let p,y,g,_;t.selection.empty?r.doc.nodesBetween(d,h,(w,k)=>{s&&s===w.type&&(g=Math.max(k,d),_=Math.min(k+w.nodeSize,h),p=k,y=w)}):r.doc.nodesBetween(d,h,(w,k)=>{k<d&&s&&s===w.type&&(g=Math.max(k,d),_=Math.min(k+w.nodeSize,h),p=k,y=w),k>=d&&k<=h&&(s&&s===w.type&&t.setNodeMarkup(k,void 0,{...w.attrs,...e}),a&&w.marks.length&&w.marks.forEach(A=>{if(a===A.type){const P=Math.max(k,d),L=Math.min(k+w.nodeSize,h);t.addMark(P,L,a.create({...A.attrs,...e}))}}))}),y&&(p!==void 0&&t.setNodeMarkup(p,void 0,{...y.attrs,...e}),a&&y.marks.length&&y.marks.forEach(w=>{a===w.type&&t.addMark(g,_,a.create({...w.attrs,...e}))}))}),!0):!1},JC=(n,e={})=>({state:t,dispatch:r})=>{const i=qe(n,t.schema);return uA(i,e)(t,r)},GC=(n,e={})=>({state:t,dispatch:r})=>{const i=qe(n,t.schema);return fA(i,e)(t,r)};var YC=Object.freeze({__proto__:null,blur:RA,clearContent:DA,clearNodes:LA,command:BA,createParagraphNear:FA,cut:$A,deleteCurrentNode:zA,deleteNode:WA,deleteRange:VA,deleteSelection:HA,enter:UA,exitCode:KA,extendMarkRange:jA,first:qA,focus:GA,forEach:YA,insertContent:QA,insertContentAt:eC,joinBackward:rC,joinDown:nC,joinForward:iC,joinItemBackward:sC,joinItemForward:oC,joinTextblockBackward:aC,joinTextblockForward:lC,joinUp:tC,keyboardShortcut:uC,lift:fC,liftEmptyBlock:dC,liftListItem:hC,newlineInCode:pC,resetAttributes:mC,scrollIntoView:gC,selectAll:yC,selectNodeBackward:_C,selectNodeForward:bC,selectParentNode:vC,selectTextblockEnd:SC,selectTextblockStart:wC,setContent:kC,setMark:IC,setMeta:PC,setNode:RC,setNodeSelection:DC,setTextSelection:LC,sinkListItem:BC,splitBlock:FC,splitListItem:$C,toggleList:zC,toggleMark:WC,toggleNode:VC,toggleWrap:HC,undoInputRule:UC,unsetAllMarks:KC,unsetMark:jC,updateAttributes:qC,wrapIn:JC,wrapInList:GC});const QC=it.create({name:"commands",addCommands(){return{...YC}}}),XC=it.create({name:"drop",addProseMirrorPlugins(){return[new St({key:new fn("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),ZC=it.create({name:"editable",addProseMirrorPlugins(){return[new St({key:new fn("editable"),props:{editable:()=>this.editor.options.editable}})]}}),eM=new fn("focusEvents"),tM=it.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new St({key:eM,props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),nM=it.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:a})=>[()=>a.undoInputRule(),()=>a.command(({tr:c})=>{const{selection:u,doc:d}=c,{empty:h,$anchor:p}=u,{pos:y,parent:g}=p,_=p.parent.isTextblock&&y>0?c.doc.resolve(y-1):p,w=_.parent.type.spec.isolating,k=p.pos-p.parentOffset,A=w&&_.parent.childCount===1?k===p.pos:ae.atStart(d).from===y;return!h||!g.type.isTextblock||g.textContent.length||!A||A&&p.parent.type.name==="paragraph"?!1:a.clearNodes()}),()=>a.deleteSelection(),()=>a.joinBackward(),()=>a.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:a})=>[()=>a.deleteSelection(),()=>a.deleteCurrentNode(),()=>a.joinForward(),()=>a.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:a})=>[()=>a.newlineInCode(),()=>a.createParagraphNear(),()=>a.liftEmptyBlock(),()=>a.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return hu()||oy()?s:i},addProseMirrorPlugins(){return[new St({key:new fn("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(w=>w.getMeta("composition")))return;const r=n.some(w=>w.docChanged)&&!e.doc.eq(t.doc),i=n.some(w=>w.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:a,to:c}=e.selection,u=ae.atStart(e.doc).from,d=ae.atEnd(e.doc).to;if(s||!(a===u&&c===d)||!mu(t.doc))return;const y=t.tr,g=Jo({state:t,transaction:y}),{commands:_}=new Go({editor:this.editor,state:g});if(_.clearNodes(),!!y.steps.length)return y}})]}}),rM=it.create({name:"paste",addProseMirrorPlugins(){return[new St({key:new fn("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),iM=it.create({name:"tabindex",addProseMirrorPlugins(){return[new St({key:new fn("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class mr{get name(){return this.node.type.name}constructor(e,t,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new mr(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new mr(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 mr(e,this.editor)}get children(){const e=[];return this.node.content.forEach((t,r)=>{const i=t.isBlock&&!t.isTextblock,s=t.isAtom&&!t.isText,a=this.pos+r+(s?0:1),c=this.resolvedPos.doc.resolve(a);if(!i&&c.depth<=this.depth)return;const u=new mr(c,this.editor,i,i?t:null);i&&(u.actualDepth=this.depth+1),e.push(new mr(c,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(t).length>0){const s=i.node.attrs,a=Object.keys(t);for(let c=0;c<a.length;c+=1){const u=a[c];if(s[u]!==t[u])break}}else r=i;i=i.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(t);return this.children.forEach(a=>{r&&i.length>0||(a.node.type.name===e&&s.every(u=>t[u]===a.node.attrs[u])&&i.push(a),!(r&&i.length>0)&&(i=i.concat(a.querySelectorAll(e,t,r))))}),i}setAttribute(e){const{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}const sM=`.ProseMirror {
179
181
  position: relative;
@@ -249,9 +251,9 @@ img.ProseMirror-separator {
249
251
 
250
252
  .tippy-box[data-animation=fade][data-state=hidden] {
251
253
  opacity: 0
252
- }`;function oM(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(i),i}class aM extends _A{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:r,moved:i})=>this.options.onDrop(t,r,i)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=oM(sM,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const r=Zg(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let r=t;if([].concat(e).forEach(s=>{const a=typeof s=="string"?`${s}$`:s.key;r=t.filter(c=>!c.key.startsWith(a))}),t.length===r.length)return;const i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}createExtensionManager(){var e,t;const i=[...this.options.enableCoreExtensions?[ZC,PA.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),QC,tM,nM,iM,XC,rM].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new ti(i,this)}createCommandManager(){this.commandManager=new Go({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=Ic(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(a){if(!(a instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(a.message))throw a;this.emit("contentError",{editor:this,error:a,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(c=>c.name!=="collaboration"),this.createExtensionManager()}}),t=Ic(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=iy(t,this.options.autofocus);this.view=new VT(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:ei.create({doc:t,selection:r||void 0})});const i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.createNodeViews(),this.prependClass();const s=this.view.dom;s.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(a=>{var c;return(c=this.capturedTransaction)===null||c===void 0?void 0:c.step(a)});return}const t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const i=e.getMeta("focus"),s=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),s&&this.emit("blur",{editor:this,event:s.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return AC(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,i=typeof e=="string"?t:e;return CC(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return uu(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=`
254
+ }`;function oM(n,e,t){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(i),i}class aM extends _A{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:r,moved:i})=>this.options.onDrop(t,r,i)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=oM(sM,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){const r=Zg(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}unregisterPlugin(e){if(this.isDestroyed)return;const t=this.state.plugins;let r=t;if([].concat(e).forEach(s=>{const a=typeof s=="string"?`${s}$`:s.key;r=t.filter(c=>!c.key.startsWith(a))}),t.length===r.length)return;const i=this.state.reconfigure({plugins:r});return this.view.updateState(i),i}createExtensionManager(){var e,t;const i=[...this.options.enableCoreExtensions?[ZC,PA.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),QC,tM,nM,iM,XC,rM].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new ni(i,this)}createCommandManager(){this.commandManager=new Go({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=Ic(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(a){if(!(a instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(a.message))throw a;this.emit("contentError",{editor:this,error:a,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(c=>c.name!=="collaboration"),this.createExtensionManager()}}),t=Ic(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const r=iy(t,this.options.autofocus);this.view=new VT(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:ti.create({doc:t,selection:r||void 0})});const i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.createNodeViews(),this.prependClass();const s=this.view.dom;s.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(a=>{var c;return(c=this.capturedTransaction)===null||c===void 0?void 0:c.step(a)});return}const t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const i=e.getMeta("focus"),s=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),s&&this.emit("blur",{editor:this,event:s.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return AC(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,i=typeof e=="string"?t:e;return CC(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return uu(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=`
253
255
 
254
- `,textSerializers:r={}}=e||{};return OC(this.state.doc,{blockSeparator:t,textSerializers:{...ty(this.schema),...r}})}get isEmpty(){return mu(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new mr(t,this)}get $doc(){return this.$pos(0)}}function Cr(n){return new Qo({find:n.find,handler:({state:e,range:t,match:r})=>{const i=fe(n.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,a=r[r.length-1],c=r[0];if(a){const u=c.search(/\S/),d=t.from+c.indexOf(a),h=d+a.length;if(ly(t.from,t.to,e.doc).filter(g=>g.mark.type.excluded.find(w=>w===n.type&&w!==g.mark.type)).filter(g=>g.to>d).length)return null;h<t.to&&s.delete(h,t.to),d>t.from&&s.delete(t.from+u,d);const y=t.from+u+a.length;s.addMark(t.from+u,y,n.type.create(i||{})),s.removeStoredMark(n.type)}}})}function lM(n){return new Qo({find:n.find,handler:({state:e,range:t,match:r})=>{const i=fe(n.getAttributes,void 0,r)||{},{tr:s}=e,a=t.from;let c=t.to;const u=n.type.create(i);if(r[1]){const d=r[0].lastIndexOf(r[1]);let h=a+d;h>c?h=c:c=h+r[1].length;const p=r[0][r[0].length-1];s.insertText(p,a+r[0].length-1),s.replaceWith(h,c,u)}else if(r[0]){const d=n.type.isInline?a:a-1;s.insert(d,n.type.create(i)).delete(s.mapping.map(a),s.mapping.map(c))}s.scrollIntoView()}})}function Rc(n){return new Qo({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),s=fe(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)}})}function as(n){return new Qo({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const s=fe(n.getAttributes,void 0,r)||{},a=e.tr.delete(t.from,t.to),u=a.doc.resolve(t.from).blockRange(),d=u&&Jc(u,n.type,s);if(!d)return null;if(a.wrap(u,d),n.keepMarks&&n.editor){const{selection:p,storedMarks:y}=e,{splittableMarks:g}=n.editor.extensionManager,_=y||p.$to.parentOffset&&p.$from.marks();if(_){const w=_.filter(k=>g.includes(k.type.name));a.ensureMarks(w)}}if(n.keepAttributes){const p=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(p,s).run()}const h=a.doc.resolve(t.from-1).nodeBefore;h&&h.type===n.type&&tr(a.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,h))&&a.join(t.from-1)}})}class vt{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=fe(j(this,"addOptions",{name:this.name}))),this.storage=fe(j(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new vt(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Xo(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new vt(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=fe(j(t,"addOptions",{name:t.name})),t.storage=fe(j(t,"addStorage",{name:t.name,options:t.options})),t}}function Mr(n){return new TA({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const s=fe(n.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:a}=e,c=r[r.length-1],u=r[0];let d=t.to;if(c){const h=u.search(/\S/),p=t.from+u.indexOf(c),y=p+c.length;if(ly(t.from,t.to,e.doc).filter(_=>_.mark.type.excluded.find(k=>k===n.type&&k!==_.mark.type)).filter(_=>_.to>p).length)return null;y<t.to&&a.delete(y,t.to),p>t.from&&a.delete(t.from+h,p),d=t.from+h+c.length,a.addMark(t.from+h,d,n.type.create(s||{})),a.removeStoredMark(n.type)}}})}const cM=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,uM=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,fM=Kt.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Cr({find:cM,type:this.type})]},addPasteRules(){return[Mr({find:uM,type:this.type})]}}),dM=Kt.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(n){return n!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sub",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setSubscript:()=>({commands:n})=>n.setMark(this.name),toggleSubscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSubscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),hM=Kt.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(n){return n!=="super"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sup",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setSuperscript:()=>({commands:n})=>n.setMark(this.name),toggleSuperscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSuperscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),pM=it.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>{const e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).every(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).every(e=>e)}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),mM=Kt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function gM(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Dc={exports:{}},Kl={};/**
256
+ `,textSerializers:r={}}=e||{};return OC(this.state.doc,{blockSeparator:t,textSerializers:{...ty(this.schema),...r}})}get isEmpty(){return mu(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new mr(t,this)}get $doc(){return this.$pos(0)}}function Mr(n){return new Qo({find:n.find,handler:({state:e,range:t,match:r})=>{const i=fe(n.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,a=r[r.length-1],c=r[0];if(a){const u=c.search(/\S/),d=t.from+c.indexOf(a),h=d+a.length;if(ly(t.from,t.to,e.doc).filter(g=>g.mark.type.excluded.find(w=>w===n.type&&w!==g.mark.type)).filter(g=>g.to>d).length)return null;h<t.to&&s.delete(h,t.to),d>t.from&&s.delete(t.from+u,d);const y=t.from+u+a.length;s.addMark(t.from+u,y,n.type.create(i||{})),s.removeStoredMark(n.type)}}})}function lM(n){return new Qo({find:n.find,handler:({state:e,range:t,match:r})=>{const i=fe(n.getAttributes,void 0,r)||{},{tr:s}=e,a=t.from;let c=t.to;const u=n.type.create(i);if(r[1]){const d=r[0].lastIndexOf(r[1]);let h=a+d;h>c?h=c:c=h+r[1].length;const p=r[0][r[0].length-1];s.insertText(p,a+r[0].length-1),s.replaceWith(h,c,u)}else if(r[0]){const d=n.type.isInline?a:a-1;s.insert(d,n.type.create(i)).delete(s.mapping.map(a),s.mapping.map(c))}s.scrollIntoView()}})}function Rc(n){return new Qo({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),s=fe(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)}})}function as(n){return new Qo({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const s=fe(n.getAttributes,void 0,r)||{},a=e.tr.delete(t.from,t.to),u=a.doc.resolve(t.from).blockRange(),d=u&&Jc(u,n.type,s);if(!d)return null;if(a.wrap(u,d),n.keepMarks&&n.editor){const{selection:p,storedMarks:y}=e,{splittableMarks:g}=n.editor.extensionManager,_=y||p.$to.parentOffset&&p.$from.marks();if(_){const w=_.filter(k=>g.includes(k.type.name));a.ensureMarks(w)}}if(n.keepAttributes){const p=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(p,s).run()}const h=a.doc.resolve(t.from-1).nodeBefore;h&&h.type===n.type&&tr(a.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,h))&&a.join(t.from-1)}})}class vt{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=fe(j(this,"addOptions",{name:this.name}))),this.storage=fe(j(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new vt(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>Xo(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new vt(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=fe(j(t,"addOptions",{name:t.name})),t.storage=fe(j(t,"addStorage",{name:t.name,options:t.options})),t}}function Nr(n){return new TA({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const s=fe(n.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:a}=e,c=r[r.length-1],u=r[0];let d=t.to;if(c){const h=u.search(/\S/),p=t.from+u.indexOf(c),y=p+c.length;if(ly(t.from,t.to,e.doc).filter(_=>_.mark.type.excluded.find(k=>k===n.type&&k!==_.mark.type)).filter(_=>_.to>p).length)return null;y<t.to&&a.delete(y,t.to),p>t.from&&a.delete(t.from+h,p),d=t.from+h+c.length,a.addMark(t.from+h,d,n.type.create(s||{})),a.removeStoredMark(n.type)}}})}const cM=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,uM=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,fM=Kt.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Mr({find:cM,type:this.type})]},addPasteRules(){return[Nr({find:uM,type:this.type})]}}),dM=Kt.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(n){return n!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sub",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setSubscript:()=>({commands:n})=>n.setMark(this.name),toggleSubscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSubscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),hM=Kt.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(n){return n!=="super"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sup",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setSuperscript:()=>({commands:n})=>n.setMark(this.name),toggleSuperscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSuperscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),pM=it.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>{const e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).every(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).every(e=>e)}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),mM=Kt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function gM(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Dc={exports:{}},Kl={};/**
255
257
  * @license React
256
258
  * use-sync-external-store-shim.production.min.js
257
259
  *
@@ -283,8 +285,8 @@ img.ProseMirror-separator {
283
285
  *
284
286
  * This source code is licensed under the MIT license found in the
285
287
  * LICENSE file in the root directory of this source tree.
286
- */var Ip;function AM(){return Ip||(Ip=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var n=q,e=ea;function t(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var r=typeof Object.is=="function"?Object.is:t,i=e.useSyncExternalStore,s=n.useRef,a=n.useEffect,c=n.useMemo,u=n.useDebugValue;function d(h,p,y,g,_){var w=s(null),k;w.current===null?(k={hasValue:!1,value:null},w.current=k):k=w.current;var A=c(function(){var z=!1,$,J,K=function(De){if(!z){z=!0,$=De;var pt=g(De);if(_!==void 0&&k.hasValue){var We=k.value;if(_(We,pt))return J=We,We}return J=pt,pt}var Ce=$,ot=J;if(r(Ce,De))return ot;var jt=g(De);return _!==void 0&&_(ot,jt)?ot:($=De,J=jt,jt)},V=y===void 0?null:y,ne=function(){return K(p())},ve=V===null?void 0:function(){return K(V())};return[ne,ve]},[p,y,g,_]),P=A[0],L=A[1],B=i(h,P,L);return a(function(){k.hasValue=!0,k.value=B},[B]),u(B),B}Jl.useSyncExternalStoreWithSelector=d,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Jl}process.env.NODE_ENV==="production"?Lc.exports=TM():Lc.exports=AM();var CM=Lc.exports;const MM=typeof window<"u"?q.useLayoutEffect:q.useEffect;class NM{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,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(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach(i=>i())},r=this.editor;return r.on("transaction",t),()=>{r.off("transaction",t)}}}}function IM(n){var e;const[t]=q.useState(()=>new NM(n.editor)),r=CM.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!==null&&e!==void 0?e:OM);return MM(()=>t.watch(n.editor),[n.editor,t]),q.useDebugValue(r),r}const Pp=process.env.NODE_ENV!=="production",Bc=typeof window>"u",PM=Bc||!!(typeof window<"u"&&window.next);class gu{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(t=>t())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0)return Bc||PM?(Pp&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&Bc&&Pp)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onBeforeCreate)===null||s===void 0?void 0:s.call(i,...r)},onBlur:(...r)=>{var i,s;return(s=(i=this.options.current).onBlur)===null||s===void 0?void 0:s.call(i,...r)},onCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onCreate)===null||s===void 0?void 0:s.call(i,...r)},onDestroy:(...r)=>{var i,s;return(s=(i=this.options.current).onDestroy)===null||s===void 0?void 0:s.call(i,...r)},onFocus:(...r)=>{var i,s;return(s=(i=this.options.current).onFocus)===null||s===void 0?void 0:s.call(i,...r)},onSelectionUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onSelectionUpdate)===null||s===void 0?void 0:s.call(i,...r)},onTransaction:(...r)=>{var i,s;return(s=(i=this.options.current).onTransaction)===null||s===void 0?void 0:s.call(i,...r)},onUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onUpdate)===null||s===void 0?void 0:s.call(i,...r)},onContentError:(...r)=>{var i,s;return(s=(i=this.options.current).onContentError)===null||s===void 0?void 0:s.call(i,...r)},onDrop:(...r)=>{var i,s;return(s=(i=this.options.current).onDrop)===null||s===void 0?void 0:s.call(i,...r)},onPaste:(...r)=>{var i,s;return(s=(i=this.options.current).onPaste)===null||s===void 0?void 0:s.call(i,...r)}};return new aM(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((i,s)=>{var a;return i===((a=t.extensions)===null||a===void 0?void 0:a[s])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?gu.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,i)=>r===e[i]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function RM(n={},e=[]){const t=q.useRef(n);t.current=n;const[r]=q.useState(()=>new gu(t)),i=ea.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return q.useDebugValue(i),q.useEffect(r.onRender(e)),IM({editor:i,selector:({transactionNumber:s})=>n.shouldRerenderOnTransaction===!1?null:n.immediatelyRender&&s===0?0:s+1}),i}const cy=q.createContext({editor:null}),DM=cy.Consumer;function LM({children:n,slotAfter:e,slotBefore:t,editorContainerProps:r={},...i}){const s=RM(i);return s?q.createElement(cy.Provider,{value:{editor:s}},t,q.createElement(DM,null,({editor:a})=>q.createElement(xM,{editor:a,...r})),n,e):null}const BM=q.createContext({onDragStart:void 0}),FM=()=>q.useContext(BM);q.forwardRef((n,e)=>{const{onDragStart:t}=FM(),r=n.as||"div";return q.createElement(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});const $M=/^\s*>\s$/,zM=vt.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[as({find:$M,type:this.type})]}}),WM=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,VM=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,HM=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,UM=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,KM=Kt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Cr({find:WM,type:this.type}),Cr({find:HM,type:this.type})]},addPasteRules(){return[Mr({find:VM,type:this.type}),Mr({find:UM,type:this.type})]}}),jM="listItem",Rp="textStyle",Dp=/^\s*([-+*])\s$/,qM=vt.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(jM,this.editor.getAttributes(Rp)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=as({find:Dp,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=as({find:Dp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Rp),editor:this.editor})),[n]}}),JM=/(^|[^`])`([^`]+)`(?!`)/,GM=/(^|[^`])`([^`]+)`(?!`)/g,YM=Kt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Cr({find:JM,type:this.type})]},addPasteRules(){return[Mr({find:GM,type:this.type})]}}),QM=/^```([a-z]+)?[\s\n]$/,XM=/^~~~([a-z]+)?[\s\n]$/,ZM=vt.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,s=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(a=>a.startsWith(t)).map(a=>a.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",ze(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,a=r.parent.textContent.endsWith(`
288
+ */var Ip;function AM(){return Ip||(Ip=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var n=q,e=ea;function t(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var r=typeof Object.is=="function"?Object.is:t,i=e.useSyncExternalStore,s=n.useRef,a=n.useEffect,c=n.useMemo,u=n.useDebugValue;function d(h,p,y,g,_){var w=s(null),k;w.current===null?(k={hasValue:!1,value:null},w.current=k):k=w.current;var A=c(function(){var z=!1,$,J,K=function(De){if(!z){z=!0,$=De;var pt=g(De);if(_!==void 0&&k.hasValue){var We=k.value;if(_(We,pt))return J=We,We}return J=pt,pt}var Ce=$,ot=J;if(r(Ce,De))return ot;var jt=g(De);return _!==void 0&&_(ot,jt)?ot:($=De,J=jt,jt)},V=y===void 0?null:y,ne=function(){return K(p())},ve=V===null?void 0:function(){return K(V())};return[ne,ve]},[p,y,g,_]),P=A[0],L=A[1],B=i(h,P,L);return a(function(){k.hasValue=!0,k.value=B},[B]),u(B),B}Jl.useSyncExternalStoreWithSelector=d,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),Jl}process.env.NODE_ENV==="production"?Lc.exports=TM():Lc.exports=AM();var CM=Lc.exports;const MM=typeof window<"u"?q.useLayoutEffect:q.useEffect;class NM{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,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(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach(i=>i())},r=this.editor;return r.on("transaction",t),()=>{r.off("transaction",t)}}}}function IM(n){var e;const[t]=q.useState(()=>new NM(n.editor)),r=CM.useSyncExternalStoreWithSelector(t.subscribe,t.getSnapshot,t.getServerSnapshot,n.selector,(e=n.equalityFn)!==null&&e!==void 0?e:OM);return MM(()=>t.watch(n.editor),[n.editor,t]),q.useDebugValue(r),r}const Pp=process.env.NODE_ENV!=="production",Bc=typeof window>"u",PM=Bc||!!(typeof window<"u"&&window.next);class gu{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(t=>t())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0)return Bc||PM?(Pp&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&Bc&&Pp)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onBeforeCreate)===null||s===void 0?void 0:s.call(i,...r)},onBlur:(...r)=>{var i,s;return(s=(i=this.options.current).onBlur)===null||s===void 0?void 0:s.call(i,...r)},onCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onCreate)===null||s===void 0?void 0:s.call(i,...r)},onDestroy:(...r)=>{var i,s;return(s=(i=this.options.current).onDestroy)===null||s===void 0?void 0:s.call(i,...r)},onFocus:(...r)=>{var i,s;return(s=(i=this.options.current).onFocus)===null||s===void 0?void 0:s.call(i,...r)},onSelectionUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onSelectionUpdate)===null||s===void 0?void 0:s.call(i,...r)},onTransaction:(...r)=>{var i,s;return(s=(i=this.options.current).onTransaction)===null||s===void 0?void 0:s.call(i,...r)},onUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onUpdate)===null||s===void 0?void 0:s.call(i,...r)},onContentError:(...r)=>{var i,s;return(s=(i=this.options.current).onContentError)===null||s===void 0?void 0:s.call(i,...r)},onDrop:(...r)=>{var i,s;return(s=(i=this.options.current).onDrop)===null||s===void 0?void 0:s.call(i,...r)},onPaste:(...r)=>{var i,s;return(s=(i=this.options.current).onPaste)===null||s===void 0?void 0:s.call(i,...r)}};return new aM(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&t.extensions?e.extensions.length!==t.extensions.length?!1:e.extensions.every((i,s)=>{var a;return i===((a=t.extensions)===null||a===void 0?void 0:a[s])}):e[r]===t[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?gu.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,i)=>r===e[i]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function RM(n={},e=[]){const t=q.useRef(n);t.current=n;const[r]=q.useState(()=>new gu(t)),i=ea.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return q.useDebugValue(i),q.useEffect(r.onRender(e)),IM({editor:i,selector:({transactionNumber:s})=>n.shouldRerenderOnTransaction===!1?null:n.immediatelyRender&&s===0?0:s+1}),i}const cy=q.createContext({editor:null}),DM=cy.Consumer;function LM({children:n,slotAfter:e,slotBefore:t,editorContainerProps:r={},...i}){const s=RM(i);return s?q.createElement(cy.Provider,{value:{editor:s}},t,q.createElement(DM,null,({editor:a})=>q.createElement(xM,{editor:a,...r})),n,e):null}const BM=q.createContext({onDragStart:void 0}),FM=()=>q.useContext(BM);q.forwardRef((n,e)=>{const{onDragStart:t}=FM(),r=n.as||"div";return q.createElement(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});const $M=/^\s*>\s$/,zM=vt.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[as({find:$M,type:this.type})]}}),WM=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,VM=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,HM=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,UM=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,KM=Kt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Mr({find:WM,type:this.type}),Mr({find:HM,type:this.type})]},addPasteRules(){return[Nr({find:VM,type:this.type}),Nr({find:UM,type:this.type})]}}),jM="listItem",Rp="textStyle",Dp=/^\s*([-+*])\s$/,qM=vt.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(jM,this.editor.getAttributes(Rp)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=as({find:Dp,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=as({find:Dp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Rp),editor:this.editor})),[n]}}),JM=/(^|[^`])`([^`]+)`(?!`)/,GM=/(^|[^`])`([^`]+)`(?!`)/g,YM=Kt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Mr({find:JM,type:this.type})]},addPasteRules(){return[Nr({find:GM,type:this.type})]}}),QM=/^```([a-z]+)?[\s\n]$/,XM=/^~~~([a-z]+)?[\s\n]$/,ZM=vt.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,s=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(a=>a.startsWith(t)).map(a=>a.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",ze(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,a=r.parent.textContent.endsWith(`
287
289
 
288
290
  `);return!s||!a?!1:n.chain().command(({tr:c})=>(c.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:i,empty:s}=t;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const c=i.after();return c===void 0?!1:r.nodeAt(c)?n.commands.command(({tr:d})=>(d.setSelection(ae.near(r.resolve(c))),!0)):n.commands.exitCode()}}},addInputRules(){return[Rc({find:QM,type:this.type,getAttributes:n=>({language:n[1]})}),Rc({find:XM,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new St({key:new fn("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i==null?void 0:i.mode;if(!t||!s)return!1;const{tr:a,schema:c}=n.state,u=c.text(t.replace(/\r\n?/g,`
289
291
  `));return a.replaceSelectionWith(this.type.create({language:s},u)),a.selection.$from.parent.type!==this.type&&a.setSelection(re.near(a.doc.resolve(Math.max(0,a.selection.from-2)))),a.setMeta("paste",!0),n.dispatch(a),!0}}})]}}),eN=vt.create({name:"doc",topNode:!0,content:"block+"});function tN(n={}){return new St({view(e){return new nN(e,n)}})}class nN{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=a=>{this[i](a)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r;if(t){let c=e.nodeBefore,u=e.nodeAfter;if(c||u){let d=this.editorView.nodeDOM(this.cursorPos-(c?c.nodeSize:0));if(d){let h=d.getBoundingClientRect(),p=c?h.bottom:h.top;c&&u&&(p=(p+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:h.left,right:h.right,top:p-this.width/2,bottom:p+this.width/2}}}}if(!r){let c=this.editorView.coordsAtPos(this.cursorPos);r={left:c.left-this.width/2,right:c.left+this.width/2,top:c.top,bottom:c.bottom}}let i=this.editorView.dom.offsetParent;this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let s,a;if(!i||i==document.body&&getComputedStyle(i).position=="static")s=-pageXOffset,a=-pageYOffset;else{let c=i.getBoundingClientRect();s=c.left-i.scrollLeft,a=c.top-i.scrollTop}this.element.style.left=r.left-s+"px",this.element.style.top=r.top-a+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!s){let a=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let c=Zm(this.editorView.state.doc,a,this.editorView.dragging.slice);c!=null&&(a=c)}this.setCursor(a),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}}const rN=it.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[tN(this.options)]}});class Ie extends ae{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return Ie.valid(r)?new Ie(r):ae.near(r)}content(){return H.empty}eq(e){return e instanceof Ie&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Ie(e.resolve(t.pos))}getBookmark(){return new yu(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!iN(e)||!sN(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&Ie.valid(e))return e;let i=e.pos,s=null;for(let a=e.depth;;a--){let c=e.node(a);if(t>0?e.indexAfter(a)<c.childCount:e.index(a)>0){s=c.child(t>0?e.indexAfter(a):e.index(a)-1);break}else if(a==0)return null;i+=t;let u=e.doc.resolve(i);if(Ie.valid(u))return u}for(;;){let a=t>0?s.firstChild:s.lastChild;if(!a){if(s.isAtom&&!s.isText&&!Q.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),r=!1;continue e}break}s=a,i+=t;let c=e.doc.resolve(i);if(Ie.valid(c))return c}return null}}}Ie.prototype.visible=!1;Ie.findFrom=Ie.findGapCursorFrom;ae.jsonID("gapcursor",Ie);class yu{constructor(e){this.pos=e}map(e){return new yu(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Ie.valid(t)?new Ie(t):ae.near(t)}}function iN(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function sN(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function oN(){return new St({props:{decorations:uN,createSelectionBetween(n,e,t){return e.pos==t.pos&&Ie.valid(t)?new Ie(t):null},handleClick:lN,handleKeyDown:aN,handleDOMEvents:{beforeinput:cN}}})}const aN=$g({ArrowLeft:fo("horiz",-1),ArrowRight:fo("horiz",1),ArrowUp:fo("vert",-1),ArrowDown:fo("vert",1)});function fo(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let a=r.selection,c=e>0?a.$to:a.$from,u=a.empty;if(a instanceof re){if(!s.endOfTextblock(t)||c.depth==0)return!1;u=!1,c=r.doc.resolve(e>0?c.after():c.before())}let d=Ie.findGapCursorFrom(c,e,u);return d?(i&&i(r.tr.setSelection(new Ie(d))),!0):!1}}function lN(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Ie.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&Q.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Ie(r))),!0)}function cN(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Ie))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=D.empty;for(let a=r.length-1;a>=0;a--)i=D.from(r[a].createAndFill(null,i));let s=n.state.tr.replace(t.pos,t.pos,new H(i,0,0));return s.setSelection(re.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function uN(n){if(!(n.selection instanceof Ie))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",$e.create(n.doc,[Wt.widget(n.selection.head,e,{key:"gapcursor"})])}const fN=it.create({name:"gapCursor",addProseMirrorPlugins(){return[oN()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=fe(j(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),dN=vt.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",ze(this.options.HTMLAttributes,n)]},renderText(){return`
290
- `},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:i,storedMarks:s}=t;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:a}=this.options,{splittableMarks:c}=r.extensionManager,u=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:d,dispatch:h})=>{if(h&&u&&a){const p=u.filter(y=>c.includes(y.type.name));d.ensureMarks(p)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),hN=vt.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,ze(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Rc({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var $o=200,je=function(){};je.prototype.append=function(e){return e.length?(e=je.from(e),!this.length&&e||e.length<$o&&this.leafAppend(e)||this.length<$o&&e.leafPrepend(this)||this.appendInner(e)):this};je.prototype.prepend=function(e){return e.length?je.from(e).append(this):this};je.prototype.appendInner=function(e){return new pN(this,e)};je.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?je.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};je.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};je.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};je.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,a){return i.push(e(s,a))},t,r),i};je.from=function(e){return e instanceof je?e:e&&e.length?new uy(e):je.empty};var uy=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,a,c){for(var u=s;u<a;u++)if(i(this.values[u],c+u)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,a,c){for(var u=s-1;u>=a;u--)if(i(this.values[u],c+u)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=$o)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=$o)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(je);je.empty=new uy([]);var pN=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,s,a){var c=this.left.length;if(i<c&&this.left.forEachInner(r,i,Math.min(s,c),a)===!1||s>c&&this.right.forEachInner(r,Math.max(i-c,0),Math.min(this.length,s)-c,a+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,a){var c=this.left.length;if(i>c&&this.right.forEachInvertedInner(r,i-c,Math.max(s,c)-c,a+c)===!1||s<c&&this.left.forEachInvertedInner(r,Math.min(i,c),s,a)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(je);const mN=500;class Zt{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;t&&(i=this.remapping(r,this.items.length),s=i.maps.length);let a=e.tr,c,u,d=[],h=[];return this.items.forEach((p,y)=>{if(!p.step){i||(i=this.remapping(r,y+1),s=i.maps.length),s--,h.push(p);return}if(i){h.push(new on(p.map));let g=p.step.map(i.slice(s)),_;g&&a.maybeStep(g).doc&&(_=a.mapping.maps[a.mapping.maps.length-1],d.push(new on(_,void 0,void 0,d.length+h.length))),s--,_&&i.appendMap(_,s)}else a.maybeStep(p.step);if(p.selection)return c=i?p.selection.map(i.slice(s)):p.selection,u=new Zt(this.items.slice(0,r).append(h.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:u,transform:a,selection:c}}addTransform(e,t,r,i){let s=[],a=this.eventCount,c=this.items,u=!i&&c.length?c.get(c.length-1):null;for(let h=0;h<e.steps.length;h++){let p=e.steps[h].invert(e.docs[h]),y=new on(e.mapping.maps[h],p,t),g;(g=u&&u.merge(y))&&(y=g,h?s.pop():c=c.slice(0,c.length-1)),s.push(y),t&&(a++,t=void 0),i||(u=y)}let d=a-r.depth;return d>yN&&(c=gN(c,d),a-=d),new Zt(c.append(s),a)}remapping(e,t){let r=new es;return this.items.forEach((i,s)=>{let a=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,a)},e,t),r}addMaps(e){return this.eventCount==0?this:new Zt(this.items.append(e.map(t=>new on(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),s=e.mapping,a=e.steps.length,c=this.eventCount;this.items.forEach(y=>{y.selection&&c--},i);let u=t;this.items.forEach(y=>{let g=s.getMirror(--u);if(g==null)return;a=Math.min(a,g);let _=s.maps[g];if(y.step){let w=e.steps[g].invert(e.docs[g]),k=y.selection&&y.selection.map(s.slice(u+1,g));k&&c++,r.push(new on(_,w,k))}else r.push(new on(_))},i);let d=[];for(let y=t;y<a;y++)d.push(new on(s.maps[y]));let h=this.items.slice(0,i).append(d).append(r),p=new Zt(h,c);return p.emptyItemCount()>mN&&(p=p.compress(this.items.length-r.length)),p}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],s=0;return this.items.forEach((a,c)=>{if(c>=e)i.push(a),a.selection&&s++;else if(a.step){let u=a.step.map(t.slice(r)),d=u&&u.getMap();if(r--,d&&t.appendMap(d,r),u){let h=a.selection&&a.selection.map(t.slice(r));h&&s++;let p=new on(d.invert(),u,h),y,g=i.length-1;(y=i.length&&i[g].merge(p))?i[g]=y:i.push(p)}}else a.map&&r--},this.items.length,0),new Zt(je.from(i.reverse()),s)}}Zt.empty=new Zt(je.empty,0);function gN(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}class on{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new on(t.getMap().invert(),t,this.selection)}}}class Un{constructor(e,t,r,i,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const yN=20;function _N(n,e,t,r){let i=t.getMeta(xr),s;if(i)return i.historyState;t.getMeta(SN)&&(n=new Un(n.done,n.undone,null,0,-1));let a=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(a&&a.getMeta(xr))return a.getMeta(xr).redo?new Un(n.done.addTransform(t,void 0,r,vo(e)),n.undone,Lp(t.mapping.maps),n.prevTime,n.prevComposition):new Un(n.done,n.undone.addTransform(t,void 0,r,vo(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let c=t.getMeta("composition"),u=n.prevTime==0||!a&&n.prevComposition!=c&&(n.prevTime<(t.time||0)-r.newGroupDelay||!bN(t,n.prevRanges)),d=a?Gl(n.prevRanges,t.mapping):Lp(t.mapping.maps);return new Un(n.done.addTransform(t,u?e.selection.getBookmark():void 0,r,vo(e)),Zt.empty,d,t.time,c??n.prevComposition)}else return(s=t.getMeta("rebased"))?new Un(n.done.rebased(t,s),n.undone.rebased(t,s),Gl(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Un(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Gl(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function bN(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function Lp(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,s,a)=>e.push(s,a));return e}function Gl(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),s=e.map(n[r+1],-1);i<=s&&t.push(i,s)}return t}function vN(n,e,t){let r=vo(e),i=xr.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let a=s.selection.resolve(s.transform.doc),c=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),u=new Un(t?c:s.remaining,t?s.remaining:c,null,0,-1);return s.transform.setSelection(a).setMeta(xr,{redo:t,historyState:u})}let Yl=!1,Bp=null;function vo(n){let e=n.plugins;if(Bp!=e){Yl=!1,Bp=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Yl=!0;break}}return Yl}const xr=new fn("history"),SN=new fn("closeHistory");function wN(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new St({key:xr,state:{init(){return new Un(Zt.empty,Zt.empty,null,0,-1)},apply(e,t,r){return _N(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?dy:r=="historyRedo"?hy:null;return i?(t.preventDefault(),i(e.state,e.dispatch)):!1}}}})}function fy(n,e){return(t,r)=>{let i=xr.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let s=vN(i,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}const dy=fy(!1,!0),hy=fy(!0,!0),kN=it.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>dy(n,e),redo:()=>({state:n,dispatch:e})=>hy(n,e)}},addProseMirrorPlugins(){return[wN(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),xN=vt.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",ze(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{const{selection:t}=e,{$from:r,$to:i}=t,s=n();return r.parentOffset===0?s.insertContentAt({from:Math.max(r.pos-1,0),to:i.pos},{type:this.name}):MC(t)?s.insertContentAt(i.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({tr:a,dispatch:c})=>{var u;if(c){const{$to:d}=a.selection,h=d.end();if(d.nodeAfter)d.nodeAfter.isTextblock?a.setSelection(re.create(a.doc,d.pos+1)):d.nodeAfter.isBlock?a.setSelection(Q.create(a.doc,d.pos)):a.setSelection(re.create(a.doc,d.pos));else{const p=(u=d.parent.type.contentMatch.defaultType)===null||u===void 0?void 0:u.create();p&&(a.insert(h,p),a.setSelection(re.create(a.doc,h+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[lM({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),EN=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,ON=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,TN=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,AN=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,CN=Kt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Cr({find:EN,type:this.type}),Cr({find:TN,type:this.type})]},addPasteRules(){return[Mr({find:ON,type:this.type}),Mr({find:AN,type:this.type})]}}),MN=vt.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",ze(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),NN="listItem",Fp="textStyle",$p=/^(\d+)\.\s$/,IN=vt.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",ze(this.options.HTMLAttributes,t),0]:["ol",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(NN,this.editor.getAttributes(Fp)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=as({find:$p,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=as({find:$p,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Fp)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),PN=vt.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),RN=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,DN=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,LN=Kt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Cr({find:RN,type:this.type})]},addPasteRules(){return[Mr({find:DN,type:this.type})]}}),BN=vt.create({name:"text",group:"inline"}),FN=it.create({name:"starterKit",addExtensions(){const n=[];return this.options.bold!==!1&&n.push(KM.configure(this.options.bold)),this.options.blockquote!==!1&&n.push(zM.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(qM.configure(this.options.bulletList)),this.options.code!==!1&&n.push(YM.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(ZM.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(eN.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(rN.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(fN.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(dN.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(hN.configure(this.options.heading)),this.options.history!==!1&&n.push(kN.configure(this.options.history)),this.options.horizontalRule!==!1&&n.push(xN.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push(CN.configure(this.options.italic)),this.options.listItem!==!1&&n.push(MN.configure(this.options.listItem)),this.options.orderedList!==!1&&n.push(IN.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(PN.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(LN.configure(this.options.strike)),this.options.text!==!1&&n.push(BN.configure(this.options.text)),n}}),$N=({content:n,style:e})=>Y.jsx("div",{style:e,children:Y.jsx(LM,{editable:!1,extensions:[FN,mM,hM,dM,fM,pM.configure({types:["heading","paragraph"]})],content:n})}),py=q.createContext({}),zN=()=>{const n=q.useContext(py);if(!n)throw new Error("useWellPlayed must be used within a WellPlayedProvider");return n},WN=({children:n,clientConfig:e,organizationId:t,apiBaseUrl:r})=>{const i=oE(),s=q.useMemo(()=>di.createWellPlayedClient({token:(i==null?void 0:i.accessToken)??void 0,organizationId:t,...e,apiBaseUrl:r}),[i==null?void 0:i.accessToken,t,e,r]);return Y.jsx(T1,{client:s,children:Y.jsx(py.Provider,{value:{organizationId:t,apiClient:s},children:n})})},VN=({children:n,oidcConfig:e,wpAppConfig:t,...r})=>Y.jsx(nE,{...e,configuration:{...t,...e==null?void 0:e.configuration,authority:`https://oauth.warrior.${r.apiBaseUrl??"well-played.gg"}`},children:Y.jsx(WN,{...r,children:n})});exports.RichTextEditorContent=$N;exports.WellPlayedProvider=VN;exports.useConnectedPlayer=cE;exports.usePaginatedLoadAll=Wc;exports.usePaginatedQuery=q1;exports.usePlayers=Em;exports.useTournamentStep=pE;exports.useTournamentTeams=Om;exports.useWellPlayed=zN;
292
+ `},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:i,storedMarks:s}=t;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:a}=this.options,{splittableMarks:c}=r.extensionManager,u=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:d,dispatch:h})=>{if(h&&u&&a){const p=u.filter(y=>c.includes(y.type.name));d.ensureMarks(p)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),hN=vt.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,ze(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Rc({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var $o=200,je=function(){};je.prototype.append=function(e){return e.length?(e=je.from(e),!this.length&&e||e.length<$o&&this.leafAppend(e)||this.length<$o&&e.leafPrepend(this)||this.appendInner(e)):this};je.prototype.prepend=function(e){return e.length?je.from(e).append(this):this};je.prototype.appendInner=function(e){return new pN(this,e)};je.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?je.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};je.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};je.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};je.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,a){return i.push(e(s,a))},t,r),i};je.from=function(e){return e instanceof je?e:e&&e.length?new uy(e):je.empty};var uy=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,a,c){for(var u=s;u<a;u++)if(i(this.values[u],c+u)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,a,c){for(var u=s-1;u>=a;u--)if(i(this.values[u],c+u)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=$o)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=$o)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(je);je.empty=new uy([]);var pN=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,s,a){var c=this.left.length;if(i<c&&this.left.forEachInner(r,i,Math.min(s,c),a)===!1||s>c&&this.right.forEachInner(r,Math.max(i-c,0),Math.min(this.length,s)-c,a+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,a){var c=this.left.length;if(i>c&&this.right.forEachInvertedInner(r,i-c,Math.max(s,c)-c,a+c)===!1||s<c&&this.left.forEachInvertedInner(r,Math.min(i,c),s,a)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(je);const mN=500;class Zt{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;t&&(i=this.remapping(r,this.items.length),s=i.maps.length);let a=e.tr,c,u,d=[],h=[];return this.items.forEach((p,y)=>{if(!p.step){i||(i=this.remapping(r,y+1),s=i.maps.length),s--,h.push(p);return}if(i){h.push(new on(p.map));let g=p.step.map(i.slice(s)),_;g&&a.maybeStep(g).doc&&(_=a.mapping.maps[a.mapping.maps.length-1],d.push(new on(_,void 0,void 0,d.length+h.length))),s--,_&&i.appendMap(_,s)}else a.maybeStep(p.step);if(p.selection)return c=i?p.selection.map(i.slice(s)):p.selection,u=new Zt(this.items.slice(0,r).append(h.reverse().concat(d)),this.eventCount-1),!1},this.items.length,0),{remaining:u,transform:a,selection:c}}addTransform(e,t,r,i){let s=[],a=this.eventCount,c=this.items,u=!i&&c.length?c.get(c.length-1):null;for(let h=0;h<e.steps.length;h++){let p=e.steps[h].invert(e.docs[h]),y=new on(e.mapping.maps[h],p,t),g;(g=u&&u.merge(y))&&(y=g,h?s.pop():c=c.slice(0,c.length-1)),s.push(y),t&&(a++,t=void 0),i||(u=y)}let d=a-r.depth;return d>yN&&(c=gN(c,d),a-=d),new Zt(c.append(s),a)}remapping(e,t){let r=new es;return this.items.forEach((i,s)=>{let a=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,a)},e,t),r}addMaps(e){return this.eventCount==0?this:new Zt(this.items.append(e.map(t=>new on(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),s=e.mapping,a=e.steps.length,c=this.eventCount;this.items.forEach(y=>{y.selection&&c--},i);let u=t;this.items.forEach(y=>{let g=s.getMirror(--u);if(g==null)return;a=Math.min(a,g);let _=s.maps[g];if(y.step){let w=e.steps[g].invert(e.docs[g]),k=y.selection&&y.selection.map(s.slice(u+1,g));k&&c++,r.push(new on(_,w,k))}else r.push(new on(_))},i);let d=[];for(let y=t;y<a;y++)d.push(new on(s.maps[y]));let h=this.items.slice(0,i).append(d).append(r),p=new Zt(h,c);return p.emptyItemCount()>mN&&(p=p.compress(this.items.length-r.length)),p}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,i=[],s=0;return this.items.forEach((a,c)=>{if(c>=e)i.push(a),a.selection&&s++;else if(a.step){let u=a.step.map(t.slice(r)),d=u&&u.getMap();if(r--,d&&t.appendMap(d,r),u){let h=a.selection&&a.selection.map(t.slice(r));h&&s++;let p=new on(d.invert(),u,h),y,g=i.length-1;(y=i.length&&i[g].merge(p))?i[g]=y:i.push(p)}}else a.map&&r--},this.items.length,0),new Zt(je.from(i.reverse()),s)}}Zt.empty=new Zt(je.empty,0);function gN(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}class on{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new on(t.getMap().invert(),t,this.selection)}}}class Un{constructor(e,t,r,i,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const yN=20;function _N(n,e,t,r){let i=t.getMeta(xr),s;if(i)return i.historyState;t.getMeta(SN)&&(n=new Un(n.done,n.undone,null,0,-1));let a=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(a&&a.getMeta(xr))return a.getMeta(xr).redo?new Un(n.done.addTransform(t,void 0,r,vo(e)),n.undone,Lp(t.mapping.maps),n.prevTime,n.prevComposition):new Un(n.done,n.undone.addTransform(t,void 0,r,vo(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(a&&a.getMeta("addToHistory")===!1)){let c=t.getMeta("composition"),u=n.prevTime==0||!a&&n.prevComposition!=c&&(n.prevTime<(t.time||0)-r.newGroupDelay||!bN(t,n.prevRanges)),d=a?Gl(n.prevRanges,t.mapping):Lp(t.mapping.maps);return new Un(n.done.addTransform(t,u?e.selection.getBookmark():void 0,r,vo(e)),Zt.empty,d,t.time,c??n.prevComposition)}else return(s=t.getMeta("rebased"))?new Un(n.done.rebased(t,s),n.undone.rebased(t,s),Gl(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Un(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Gl(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function bN(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function Lp(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,i,s,a)=>e.push(s,a));return e}function Gl(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),s=e.map(n[r+1],-1);i<=s&&t.push(i,s)}return t}function vN(n,e,t){let r=vo(e),i=xr.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let a=s.selection.resolve(s.transform.doc),c=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),u=new Un(t?c:s.remaining,t?s.remaining:c,null,0,-1);return s.transform.setSelection(a).setMeta(xr,{redo:t,historyState:u})}let Yl=!1,Bp=null;function vo(n){let e=n.plugins;if(Bp!=e){Yl=!1,Bp=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Yl=!0;break}}return Yl}const xr=new fn("history"),SN=new fn("closeHistory");function wN(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new St({key:xr,state:{init(){return new Un(Zt.empty,Zt.empty,null,0,-1)},apply(e,t,r){return _N(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?dy:r=="historyRedo"?hy:null;return i?(t.preventDefault(),i(e.state,e.dispatch)):!1}}}})}function fy(n,e){return(t,r)=>{let i=xr.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let s=vN(i,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}const dy=fy(!1,!0),hy=fy(!0,!0),kN=it.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>dy(n,e),redo:()=>({state:n,dispatch:e})=>hy(n,e)}},addProseMirrorPlugins(){return[wN(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),xN=vt.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",ze(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{const{selection:t}=e,{$from:r,$to:i}=t,s=n();return r.parentOffset===0?s.insertContentAt({from:Math.max(r.pos-1,0),to:i.pos},{type:this.name}):MC(t)?s.insertContentAt(i.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({tr:a,dispatch:c})=>{var u;if(c){const{$to:d}=a.selection,h=d.end();if(d.nodeAfter)d.nodeAfter.isTextblock?a.setSelection(re.create(a.doc,d.pos+1)):d.nodeAfter.isBlock?a.setSelection(Q.create(a.doc,d.pos)):a.setSelection(re.create(a.doc,d.pos));else{const p=(u=d.parent.type.contentMatch.defaultType)===null||u===void 0?void 0:u.create();p&&(a.insert(h,p),a.setSelection(re.create(a.doc,h+1)))}a.scrollIntoView()}return!0}).run()}}},addInputRules(){return[lM({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),EN=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,ON=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,TN=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,AN=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,CN=Kt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Mr({find:EN,type:this.type}),Mr({find:TN,type:this.type})]},addPasteRules(){return[Nr({find:ON,type:this.type}),Nr({find:AN,type:this.type})]}}),MN=vt.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",ze(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),NN="listItem",Fp="textStyle",$p=/^(\d+)\.\s$/,IN=vt.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:null,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",ze(this.options.HTMLAttributes,t),0]:["ol",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(NN,this.editor.getAttributes(Fp)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=as({find:$p,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=as({find:$p,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Fp)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),PN=vt.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),RN=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,DN=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,LN=Kt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",ze(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Mr({find:RN,type:this.type})]},addPasteRules(){return[Nr({find:DN,type:this.type})]}}),BN=vt.create({name:"text",group:"inline"}),FN=it.create({name:"starterKit",addExtensions(){const n=[];return this.options.bold!==!1&&n.push(KM.configure(this.options.bold)),this.options.blockquote!==!1&&n.push(zM.configure(this.options.blockquote)),this.options.bulletList!==!1&&n.push(qM.configure(this.options.bulletList)),this.options.code!==!1&&n.push(YM.configure(this.options.code)),this.options.codeBlock!==!1&&n.push(ZM.configure(this.options.codeBlock)),this.options.document!==!1&&n.push(eN.configure(this.options.document)),this.options.dropcursor!==!1&&n.push(rN.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&n.push(fN.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&n.push(dN.configure(this.options.hardBreak)),this.options.heading!==!1&&n.push(hN.configure(this.options.heading)),this.options.history!==!1&&n.push(kN.configure(this.options.history)),this.options.horizontalRule!==!1&&n.push(xN.configure(this.options.horizontalRule)),this.options.italic!==!1&&n.push(CN.configure(this.options.italic)),this.options.listItem!==!1&&n.push(MN.configure(this.options.listItem)),this.options.orderedList!==!1&&n.push(IN.configure(this.options.orderedList)),this.options.paragraph!==!1&&n.push(PN.configure(this.options.paragraph)),this.options.strike!==!1&&n.push(LN.configure(this.options.strike)),this.options.text!==!1&&n.push(BN.configure(this.options.text)),n}}),$N=({content:n,style:e})=>Y.jsx("div",{style:e,children:Y.jsx(LM,{editable:!1,extensions:[FN,mM,hM,dM,fM,pM.configure({types:["heading","paragraph"]})],content:n})}),py=q.createContext({}),zN=()=>{const n=q.useContext(py);if(!n)throw new Error("useWellPlayed must be used within a WellPlayedProvider");return n},WN=({children:n,clientConfig:e,organizationId:t,apiBaseUrl:r,typedClientConfig:i})=>{const s=oE(),a=q.useMemo(()=>Er.createWellPlayedClient({token:(s==null?void 0:s.accessToken)??void 0,organizationId:t,...e,apiBaseUrl:r}),[s==null?void 0:s.accessToken,t,e,r]);return Y.jsx(T1,{client:a,children:Y.jsx(py.Provider,{value:{organizationId:t,apiClient:a,typedClient:Er.createTypedClient({apiBaseUrl:r,organizationId:t,token:(s==null?void 0:s.accessToken)??void 0,...i})},children:n})})},VN=({children:n,oidcConfig:e,wpAppConfig:t,...r})=>Y.jsx(nE,{...e,configuration:{...t,...e==null?void 0:e.configuration,authority:`https://oauth.warrior.${r.apiBaseUrl??"well-played.gg"}`},children:Y.jsx(WN,{...r,children:n})});exports.RichTextEditorContent=$N;exports.WellPlayedProvider=VN;exports.useConnectedPlayer=cE;exports.usePaginatedLoadAll=Wc;exports.usePaginatedQuery=q1;exports.usePlayers=Em;exports.useTournamentStep=pE;exports.useTournamentTeams=Om;exports.useWellPlayed=zN;