@select-org/select-post-builder 1.4.1 → 1.4.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,247 +0,0 @@
1
- "use strict";const j=require("react"),PS=require("react-dom"),y=require("react/jsx-runtime");function LS(t){if(t&&t.__esModule)return t;const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const w=LS(j),vi=LS(PS);function jS(t,e){return function(){return t.apply(e,arguments)}}const{toString:eP}=Object.prototype,{getPrototypeOf:yy}=Object,{iterator:If,toStringTag:$S}=Symbol,Df=(t=>e=>{const n=eP.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Dr=t=>(t=t.toLowerCase(),e=>Df(e)===t),Pf=t=>e=>typeof e===t,{isArray:Ca}=Array,na=Pf("undefined");function yc(t){return t!==null&&!na(t)&&t.constructor!==null&&!na(t.constructor)&&In(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const FS=Dr("ArrayBuffer");function tP(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&FS(t.buffer),e}const nP=Pf("string"),In=Pf("function"),US=Pf("number"),bc=t=>t!==null&&typeof t=="object",rP=t=>t===!0||t===!1,Ou=t=>{if(Df(t)!=="object")return!1;const e=yy(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!($S in t)&&!(If in t)},oP=t=>{if(!bc(t)||yc(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},sP=Dr("Date"),iP=Dr("File"),aP=t=>!!(t&&typeof t.uri<"u"),lP=t=>t&&typeof t.getParts<"u",cP=Dr("Blob"),uP=Dr("FileList"),dP=t=>bc(t)&&In(t.pipe);function fP(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const f0=fP(),h0=typeof f0.FormData<"u"?f0.FormData:void 0,hP=t=>{let e;return t&&(h0&&t instanceof h0||In(t.append)&&((e=Df(t))==="formdata"||e==="object"&&In(t.toString)&&t.toString()==="[object FormData]"))},pP=Dr("URLSearchParams"),[mP,gP,yP,bP]=["ReadableStream","Request","Response","Headers"].map(Dr),vP=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function vc(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let r,o;if(typeof t!="object"&&(t=[t]),Ca(t))for(r=0,o=t.length;r<o;r++)e.call(null,t[r],r,t);else{if(yc(t))return;const s=n?Object.getOwnPropertyNames(t):Object.keys(t),i=s.length;let a;for(r=0;r<i;r++)a=s[r],e.call(null,t[a],a,t)}}function BS(t,e){if(yc(t))return null;e=e.toLowerCase();const n=Object.keys(t);let r=n.length,o;for(;r-- >0;)if(o=n[r],e===o.toLowerCase())return o;return null}const Us=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,zS=t=>!na(t)&&t!==Us;function Mm(){const{caseless:t,skipUndefined:e}=zS(this)&&this||{},n={},r=(o,s)=>{if(s==="__proto__"||s==="constructor"||s==="prototype")return;const i=t&&BS(n,s)||s;Ou(n[i])&&Ou(o)?n[i]=Mm(n[i],o):Ou(o)?n[i]=Mm({},o):Ca(o)?n[i]=o.slice():(!e||!na(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&vc(arguments[o],r);return n}const wP=(t,e,n,{allOwnKeys:r}={})=>(vc(e,(o,s)=>{n&&In(o)?Object.defineProperty(t,s,{value:jS(o,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,s,{value:o,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),xP=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),EP=(t,e,n,r)=>{t.prototype=Object.create(e.prototype,r),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},SP=(t,e,n,r)=>{let o,s,i;const a={};if(e=e||{},t==null)return e;do{for(o=Object.getOwnPropertyNames(t),s=o.length;s-- >0;)i=o[s],(!r||r(i,t,e))&&!a[i]&&(e[i]=t[i],a[i]=!0);t=n!==!1&&yy(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},kP=(t,e,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;const r=t.indexOf(e,n);return r!==-1&&r===n},TP=t=>{if(!t)return null;if(Ca(t))return t;let e=t.length;if(!US(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},CP=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&yy(Uint8Array)),AP=(t,e)=>{const r=(t&&t[If]).call(t);let o;for(;(o=r.next())&&!o.done;){const s=o.value;e.call(t,s[0],s[1])}},_P=(t,e)=>{let n;const r=[];for(;(n=t.exec(e))!==null;)r.push(n);return r},MP=Dr("HTMLFormElement"),OP=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),p0=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),RP=Dr("RegExp"),HS=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),r={};vc(n,(o,s)=>{let i;(i=e(o,s,t))!==!1&&(r[s]=i||o)}),Object.defineProperties(t,r)},NP=t=>{HS(t,(e,n)=>{if(In(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=t[n];if(In(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},IP=(t,e)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return Ca(t)?r(t):r(String(t).split(e)),n},DP=()=>{},PP=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function LP(t){return!!(t&&In(t.append)&&t[$S]==="FormData"&&t[If])}const jP=t=>{const e=new Array(10),n=(r,o)=>{if(bc(r)){if(e.indexOf(r)>=0)return;if(yc(r))return r;if(!("toJSON"in r)){e[o]=r;const s=Ca(r)?[]:{};return vc(r,(i,a)=>{const l=n(i,o+1);!na(l)&&(s[a]=l)}),e[o]=void 0,s}}return r};return n(t,0)},$P=Dr("AsyncFunction"),FP=t=>t&&(bc(t)||In(t))&&In(t.then)&&In(t.catch),VS=((t,e)=>t?setImmediate:e?((n,r)=>(Us.addEventListener("message",({source:o,data:s})=>{o===Us&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Us.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",In(Us.postMessage)),UP=typeof queueMicrotask<"u"?queueMicrotask.bind(Us):typeof process<"u"&&process.nextTick||VS,BP=t=>t!=null&&In(t[If]),G={isArray:Ca,isArrayBuffer:FS,isBuffer:yc,isFormData:hP,isArrayBufferView:tP,isString:nP,isNumber:US,isBoolean:rP,isObject:bc,isPlainObject:Ou,isEmptyObject:oP,isReadableStream:mP,isRequest:gP,isResponse:yP,isHeaders:bP,isUndefined:na,isDate:sP,isFile:iP,isReactNativeBlob:aP,isReactNative:lP,isBlob:cP,isRegExp:RP,isFunction:In,isStream:dP,isURLSearchParams:pP,isTypedArray:CP,isFileList:uP,forEach:vc,merge:Mm,extend:wP,trim:vP,stripBOM:xP,inherits:EP,toFlatObject:SP,kindOf:Df,kindOfTest:Dr,endsWith:kP,toArray:TP,forEachEntry:AP,matchAll:_P,isHTMLForm:MP,hasOwnProperty:p0,hasOwnProp:p0,reduceDescriptors:HS,freezeMethods:NP,toObjectSet:IP,toCamelCase:OP,noop:DP,toFiniteNumber:PP,findKey:BS,global:Us,isContextDefined:zS,isSpecCompliantForm:LP,toJSONObject:jP,isAsyncFn:$P,isThenable:FP,setImmediate:VS,asap:UP,isIterable:BP};let Te=class WS extends Error{static from(e,n,r,o,s,i){const a=new WS(e.message,n||e.code,r,o,s);return a.cause=e,a.name=e.name,e.status!=null&&a.status==null&&(a.status=e.status),i&&Object.assign(a,i),a}constructor(e,n,r,o,s){super(e),Object.defineProperty(this,"message",{value:e,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),o&&(this.request=o),s&&(this.response=s,this.status=s.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:G.toJSONObject(this.config),code:this.code,status:this.status}}};Te.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";Te.ERR_BAD_OPTION="ERR_BAD_OPTION";Te.ECONNABORTED="ECONNABORTED";Te.ETIMEDOUT="ETIMEDOUT";Te.ERR_NETWORK="ERR_NETWORK";Te.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";Te.ERR_DEPRECATED="ERR_DEPRECATED";Te.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";Te.ERR_BAD_REQUEST="ERR_BAD_REQUEST";Te.ERR_CANCELED="ERR_CANCELED";Te.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";Te.ERR_INVALID_URL="ERR_INVALID_URL";const zP=null;function Om(t){return G.isPlainObject(t)||G.isArray(t)}function KS(t){return G.endsWith(t,"[]")?t.slice(0,-2):t}function Zh(t,e,n){return t?t.concat(e).map(function(o,s){return o=KS(o),!n&&s?"["+o+"]":o}).join(n?".":""):e}function HP(t){return G.isArray(t)&&!t.some(Om)}const VP=G.toFlatObject(G,{},null,function(e){return/^is[A-Z]/.test(e)});function Lf(t,e,n){if(!G.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,n=G.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,g){return!G.isUndefined(g[m])});const r=n.metaTokens,o=n.visitor||u,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&G.isSpecCompliantForm(e);if(!G.isFunction(o))throw new TypeError("visitor must be a function");function c(p){if(p===null)return"";if(G.isDate(p))return p.toISOString();if(G.isBoolean(p))return p.toString();if(!l&&G.isBlob(p))throw new Te("Blob is not supported. Use a Buffer instead.");return G.isArrayBuffer(p)||G.isTypedArray(p)?l&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function u(p,m,g){let b=p;if(G.isReactNative(e)&&G.isReactNativeBlob(p))return e.append(Zh(g,m,s),c(p)),!1;if(p&&!g&&typeof p=="object"){if(G.endsWith(m,"{}"))m=r?m:m.slice(0,-2),p=JSON.stringify(p);else if(G.isArray(p)&&HP(p)||(G.isFileList(p)||G.endsWith(m,"[]"))&&(b=G.toArray(p)))return m=KS(m),b.forEach(function(k,v){!(G.isUndefined(k)||k===null)&&e.append(i===!0?Zh([m],v,s):i===null?m:m+"[]",c(k))}),!1}return Om(p)?!0:(e.append(Zh(g,m,s),c(p)),!1)}const d=[],f=Object.assign(VP,{defaultVisitor:u,convertValue:c,isVisitable:Om});function h(p,m){if(!G.isUndefined(p)){if(d.indexOf(p)!==-1)throw Error("Circular reference detected in "+m.join("."));d.push(p),G.forEach(p,function(b,S){(!(G.isUndefined(b)||b===null)&&o.call(e,b,G.isString(S)?S.trim():S,m,f))===!0&&h(b,m?m.concat(S):[S])}),d.pop()}}if(!G.isObject(t))throw new TypeError("data must be an object");return h(t),e}function m0(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function by(t,e){this._pairs=[],t&&Lf(t,this,e)}const GS=by.prototype;GS.append=function(e,n){this._pairs.push([e,n])};GS.toString=function(e){const n=e?function(r){return e.call(this,r,m0)}:m0;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function WP(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function qS(t,e,n){if(!e)return t;const r=n&&n.encode||WP,o=G.isFunction(n)?{serialize:n}:n,s=o&&o.serialize;let i;if(s?i=s(e,o):i=G.isURLSearchParams(e)?e.toString():new by(e,o).toString(r),i){const a=t.indexOf("#");a!==-1&&(t=t.slice(0,a)),t+=(t.indexOf("?")===-1?"?":"&")+i}return t}class g0{constructor(){this.handlers=[]}use(e,n,r){return this.handlers.push({fulfilled:e,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){G.forEach(this.handlers,function(r){r!==null&&e(r)})}}const vy={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},KP=typeof URLSearchParams<"u"?URLSearchParams:by,GP=typeof FormData<"u"?FormData:null,qP=typeof Blob<"u"?Blob:null,YP={isBrowser:!0,classes:{URLSearchParams:KP,FormData:GP,Blob:qP},protocols:["http","https","file","blob","url","data"]},wy=typeof window<"u"&&typeof document<"u",Rm=typeof navigator=="object"&&navigator||void 0,JP=wy&&(!Rm||["ReactNative","NativeScript","NS"].indexOf(Rm.product)<0),XP=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",QP=wy&&window.location.href||"http://localhost",ZP=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:wy,hasStandardBrowserEnv:JP,hasStandardBrowserWebWorkerEnv:XP,navigator:Rm,origin:QP},Symbol.toStringTag,{value:"Module"})),an={...ZP,...YP};function eL(t,e){return Lf(t,new an.classes.URLSearchParams,{visitor:function(n,r,o,s){return an.isNode&&G.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...e})}function tL(t){return G.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function nL(t){const e={},n=Object.keys(t);let r;const o=n.length;let s;for(r=0;r<o;r++)s=n[r],e[s]=t[s];return e}function YS(t){function e(n,r,o,s){let i=n[s++];if(i==="__proto__")return!0;const a=Number.isFinite(+i),l=s>=n.length;return i=!i&&G.isArray(o)?o.length:i,l?(G.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!G.isObject(o[i]))&&(o[i]=[]),e(n,r,o[i],s)&&G.isArray(o[i])&&(o[i]=nL(o[i])),!a)}if(G.isFormData(t)&&G.isFunction(t.entries)){const n={};return G.forEachEntry(t,(r,o)=>{e(tL(r),o,n,0)}),n}return null}function rL(t,e,n){if(G.isString(t))try{return(e||JSON.parse)(t),G.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}const wc={transitional:vy,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=G.isObject(e);if(s&&G.isHTMLForm(e)&&(e=new FormData(e)),G.isFormData(e))return o?JSON.stringify(YS(e)):e;if(G.isArrayBuffer(e)||G.isBuffer(e)||G.isStream(e)||G.isFile(e)||G.isBlob(e)||G.isReadableStream(e))return e;if(G.isArrayBufferView(e))return e.buffer;if(G.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return eL(e,this.formSerializer).toString();if((a=G.isFileList(e))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Lf(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),rL(e)):e}],transformResponse:[function(e){const n=this.transitional||wc.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(G.isResponse(e)||G.isReadableStream(e))return e;if(e&&G.isString(e)&&(r&&!this.responseType||o)){const i=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(e,this.parseReviver)}catch(a){if(i)throw a.name==="SyntaxError"?Te.from(a,Te.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:an.classes.FormData,Blob:an.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};G.forEach(["delete","get","head","post","put","patch"],t=>{wc.headers[t]={}});const oL=G.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),sL=t=>{const e={};let n,r,o;return t&&t.split(`
2
- `).forEach(function(i){o=i.indexOf(":"),n=i.substring(0,o).trim().toLowerCase(),r=i.substring(o+1).trim(),!(!n||e[n]&&oL[n])&&(n==="set-cookie"?e[n]?e[n].push(r):e[n]=[r]:e[n]=e[n]?e[n]+", "+r:r)}),e},y0=Symbol("internals");function Ba(t){return t&&String(t).trim().toLowerCase()}function Ru(t){return t===!1||t==null?t:G.isArray(t)?t.map(Ru):String(t)}function iL(t){const e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(t);)e[r[1]]=r[2];return e}const aL=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function ep(t,e,n,r,o){if(G.isFunction(r))return r.call(this,e,n);if(o&&(e=n),!!G.isString(e)){if(G.isString(r))return e.indexOf(r)!==-1;if(G.isRegExp(r))return r.test(e)}}function lL(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,r)=>n.toUpperCase()+r)}function cL(t,e){const n=G.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+n,{value:function(o,s,i){return this[r].call(this,e,o,s,i)},configurable:!0})})}let Dn=class{constructor(e){e&&this.set(e)}set(e,n,r){const o=this;function s(a,l,c){const u=Ba(l);if(!u)throw new Error("header name must be a non-empty string");const d=G.findKey(o,u);(!d||o[d]===void 0||c===!0||c===void 0&&o[d]!==!1)&&(o[d||l]=Ru(a))}const i=(a,l)=>G.forEach(a,(c,u)=>s(c,u,l));if(G.isPlainObject(e)||e instanceof this.constructor)i(e,n);else if(G.isString(e)&&(e=e.trim())&&!aL(e))i(sL(e),n);else if(G.isObject(e)&&G.isIterable(e)){let a={},l,c;for(const u of e){if(!G.isArray(u))throw TypeError("Object iterator must return a key-value pair");a[c=u[0]]=(l=a[c])?G.isArray(l)?[...l,u[1]]:[l,u[1]]:u[1]}i(a,n)}else e!=null&&s(n,e,r);return this}get(e,n){if(e=Ba(e),e){const r=G.findKey(this,e);if(r){const o=this[r];if(!n)return o;if(n===!0)return iL(o);if(G.isFunction(n))return n.call(this,o,r);if(G.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=Ba(e),e){const r=G.findKey(this,e);return!!(r&&this[r]!==void 0&&(!n||ep(this,this[r],r,n)))}return!1}delete(e,n){const r=this;let o=!1;function s(i){if(i=Ba(i),i){const a=G.findKey(r,i);a&&(!n||ep(r,r[a],a,n))&&(delete r[a],o=!0)}}return G.isArray(e)?e.forEach(s):s(e),o}clear(e){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const s=n[r];(!e||ep(this,this[s],s,e,!0))&&(delete this[s],o=!0)}return o}normalize(e){const n=this,r={};return G.forEach(this,(o,s)=>{const i=G.findKey(r,s);if(i){n[i]=Ru(o),delete n[s];return}const a=e?lL(s):String(s).trim();a!==s&&delete n[s],n[a]=Ru(o),r[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const n=Object.create(null);return G.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=e&&G.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,n])=>e+": "+n).join(`
3
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...n){const r=new this(e);return n.forEach(o=>r.set(o)),r}static accessor(e){const r=(this[y0]=this[y0]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=Ba(i);r[a]||(cL(o,i),r[a]=!0)}return G.isArray(e)?e.forEach(s):s(e),this}};Dn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);G.reduceDescriptors(Dn.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[n]=r}}});G.freezeMethods(Dn);function tp(t,e){const n=this||wc,r=e||n,o=Dn.from(r.headers);let s=r.data;return G.forEach(t,function(a){s=a.call(n,s,o.normalize(),e?e.status:void 0)}),o.normalize(),s}function JS(t){return!!(t&&t.__CANCEL__)}let xc=class extends Te{constructor(e,n,r){super(e??"canceled",Te.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}};function XS(t,e,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):e(new Te("Request failed with status code "+n.status,[Te.ERR_BAD_REQUEST,Te.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function uL(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function dL(t,e){t=t||10;const n=new Array(t),r=new Array(t);let o=0,s=0,i;return e=e!==void 0?e:1e3,function(l){const c=Date.now(),u=r[s];i||(i=c),n[o]=l,r[o]=c;let d=s,f=0;for(;d!==o;)f+=n[d++],d=d%t;if(o=(o+1)%t,o===s&&(s=(s+1)%t),c-i<e)return;const h=u&&c-u;return h?Math.round(f*1e3/h):void 0}}function fL(t,e){let n=0,r=1e3/e,o,s;const i=(c,u=Date.now())=>{n=u,o=null,s&&(clearTimeout(s),s=null),t(...c)};return[(...c)=>{const u=Date.now(),d=u-n;d>=r?i(c,u):(o=c,s||(s=setTimeout(()=>{s=null,i(o)},r-d)))},()=>o&&i(o)]}const nd=(t,e,n=3)=>{let r=0;const o=dL(50,250);return fL(s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,l=i-r,c=o(l),u=i<=a;r=i;const d={loaded:i,total:a,progress:a?i/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&u?(a-i)/c:void 0,event:s,lengthComputable:a!=null,[e?"download":"upload"]:!0};t(d)},n)},b0=(t,e)=>{const n=t!=null;return[r=>e[0]({lengthComputable:n,total:t,loaded:r}),e[1]]},v0=t=>(...e)=>G.asap(()=>t(...e)),hL=an.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,an.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(an.origin),an.navigator&&/(msie|trident)/i.test(an.navigator.userAgent)):()=>!0,pL=an.hasStandardBrowserEnv?{write(t,e,n,r,o,s,i){if(typeof document>"u")return;const a=[`${t}=${encodeURIComponent(e)}`];G.isNumber(n)&&a.push(`expires=${new Date(n).toUTCString()}`),G.isString(r)&&a.push(`path=${r}`),G.isString(o)&&a.push(`domain=${o}`),s===!0&&a.push("secure"),G.isString(i)&&a.push(`SameSite=${i}`),document.cookie=a.join("; ")},read(t){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function mL(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function gL(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function QS(t,e,n){let r=!mL(e);return t&&(r||n==!1)?gL(t,e):e}const w0=t=>t instanceof Dn?{...t}:t;function ni(t,e){e=e||{};const n={};function r(c,u,d,f){return G.isPlainObject(c)&&G.isPlainObject(u)?G.merge.call({caseless:f},c,u):G.isPlainObject(u)?G.merge({},u):G.isArray(u)?u.slice():u}function o(c,u,d,f){if(G.isUndefined(u)){if(!G.isUndefined(c))return r(void 0,c,d,f)}else return r(c,u,d,f)}function s(c,u){if(!G.isUndefined(u))return r(void 0,u)}function i(c,u){if(G.isUndefined(u)){if(!G.isUndefined(c))return r(void 0,c)}else return r(void 0,u)}function a(c,u,d){if(d in e)return r(c,u);if(d in t)return r(void 0,c)}const l={url:s,method:s,data:s,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:a,headers:(c,u,d)=>o(w0(c),w0(u),d,!0)};return G.forEach(Object.keys({...t,...e}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const d=G.hasOwnProp(l,u)?l[u]:o,f=d(t[u],e[u],u);G.isUndefined(f)&&d!==a||(n[u]=f)}),n}const ZS=t=>{const e=ni({},t);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=e;if(e.headers=i=Dn.from(i),e.url=qS(QS(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),G.isFormData(n)){if(an.hasStandardBrowserEnv||an.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(G.isFunction(n.getHeaders)){const l=n.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([u,d])=>{c.includes(u.toLowerCase())&&i.set(u,d)})}}if(an.hasStandardBrowserEnv&&(r&&G.isFunction(r)&&(r=r(e)),r||r!==!1&&hL(e.url))){const l=o&&s&&pL.read(s);l&&i.set(o,l)}return e},yL=typeof XMLHttpRequest<"u",bL=yL&&function(t){return new Promise(function(n,r){const o=ZS(t);let s=o.data;const i=Dn.from(o.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=o,u,d,f,h,p;function m(){h&&h(),p&&p(),o.cancelToken&&o.cancelToken.unsubscribe(u),o.signal&&o.signal.removeEventListener("abort",u)}let g=new XMLHttpRequest;g.open(o.method.toUpperCase(),o.url,!0),g.timeout=o.timeout;function b(){if(!g)return;const k=Dn.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),_={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:k,config:t,request:g};XS(function(A){n(A),m()},function(A){r(A),m()},_),g=null}"onloadend"in g?g.onloadend=b:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(b)},g.onabort=function(){g&&(r(new Te("Request aborted",Te.ECONNABORTED,t,g)),g=null)},g.onerror=function(v){const _=v&&v.message?v.message:"Network Error",x=new Te(_,Te.ERR_NETWORK,t,g);x.event=v||null,r(x),g=null},g.ontimeout=function(){let v=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const _=o.transitional||vy;o.timeoutErrorMessage&&(v=o.timeoutErrorMessage),r(new Te(v,_.clarifyTimeoutError?Te.ETIMEDOUT:Te.ECONNABORTED,t,g)),g=null},s===void 0&&i.setContentType(null),"setRequestHeader"in g&&G.forEach(i.toJSON(),function(v,_){g.setRequestHeader(_,v)}),G.isUndefined(o.withCredentials)||(g.withCredentials=!!o.withCredentials),a&&a!=="json"&&(g.responseType=o.responseType),c&&([f,p]=nd(c,!0),g.addEventListener("progress",f)),l&&g.upload&&([d,h]=nd(l),g.upload.addEventListener("progress",d),g.upload.addEventListener("loadend",h)),(o.cancelToken||o.signal)&&(u=k=>{g&&(r(!k||k.type?new xc(null,t,g):k),g.abort(),g=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const S=uL(o.url);if(S&&an.protocols.indexOf(S)===-1){r(new Te("Unsupported protocol "+S+":",Te.ERR_BAD_REQUEST,t));return}g.send(s||null)})},vL=(t,e)=>{const{length:n}=t=t?t.filter(Boolean):[];if(e||n){let r=new AbortController,o;const s=function(c){if(!o){o=!0,a();const u=c instanceof Error?c:this.reason;r.abort(u instanceof Te?u:new xc(u instanceof Error?u.message:u))}};let i=e&&setTimeout(()=>{i=null,s(new Te(`timeout of ${e}ms exceeded`,Te.ETIMEDOUT))},e);const a=()=>{t&&(i&&clearTimeout(i),i=null,t.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),t=null)};t.forEach(c=>c.addEventListener("abort",s));const{signal:l}=r;return l.unsubscribe=()=>G.asap(a),l}},wL=function*(t,e){let n=t.byteLength;if(n<e){yield t;return}let r=0,o;for(;r<n;)o=r+e,yield t.slice(r,o),r=o},xL=async function*(t,e){for await(const n of EL(t))yield*wL(n,e)},EL=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:n,value:r}=await e.read();if(n)break;yield r}}finally{await e.cancel()}},x0=(t,e,n,r)=>{const o=xL(t,e);let s=0,i,a=l=>{i||(i=!0,r&&r(l))};return new ReadableStream({async pull(l){try{const{done:c,value:u}=await o.next();if(c){a(),l.close();return}let d=u.byteLength;if(n){let f=s+=d;n(f)}l.enqueue(new Uint8Array(u))}catch(c){throw a(c),c}},cancel(l){return a(l),o.return()}},{highWaterMark:2})},E0=64*1024,{isFunction:Yc}=G,SL=(({Request:t,Response:e})=>({Request:t,Response:e}))(G.global),{ReadableStream:S0,TextEncoder:k0}=G.global,T0=(t,...e)=>{try{return!!t(...e)}catch{return!1}},kL=t=>{t=G.merge.call({skipUndefined:!0},SL,t);const{fetch:e,Request:n,Response:r}=t,o=e?Yc(e):typeof fetch=="function",s=Yc(n),i=Yc(r);if(!o)return!1;const a=o&&Yc(S0),l=o&&(typeof k0=="function"?(p=>m=>p.encode(m))(new k0):async p=>new Uint8Array(await new n(p).arrayBuffer())),c=s&&a&&T0(()=>{let p=!1;const m=new n(an.origin,{body:new S0,method:"POST",get duplex(){return p=!0,"half"}}).headers.has("Content-Type");return p&&!m}),u=i&&a&&T0(()=>G.isReadableStream(new r("").body)),d={stream:u&&(p=>p.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(p=>{!d[p]&&(d[p]=(m,g)=>{let b=m&&m[p];if(b)return b.call(m);throw new Te(`Response type '${p}' is not supported`,Te.ERR_NOT_SUPPORT,g)})});const f=async p=>{if(p==null)return 0;if(G.isBlob(p))return p.size;if(G.isSpecCompliantForm(p))return(await new n(an.origin,{method:"POST",body:p}).arrayBuffer()).byteLength;if(G.isArrayBufferView(p)||G.isArrayBuffer(p))return p.byteLength;if(G.isURLSearchParams(p)&&(p=p+""),G.isString(p))return(await l(p)).byteLength},h=async(p,m)=>{const g=G.toFiniteNumber(p.getContentLength());return g??f(m)};return async p=>{let{url:m,method:g,data:b,signal:S,cancelToken:k,timeout:v,onDownloadProgress:_,onUploadProgress:x,responseType:A,headers:E,withCredentials:T="same-origin",fetchOptions:N}=ZS(p),I=e||fetch;A=A?(A+"").toLowerCase():"text";let R=vL([S,k&&k.toAbortSignal()],v),D=null;const O=R&&R.unsubscribe&&(()=>{R.unsubscribe()});let P;try{if(x&&c&&g!=="get"&&g!=="head"&&(P=await h(E,b))!==0){let V=new n(m,{method:"POST",body:b,duplex:"half"}),W;if(G.isFormData(b)&&(W=V.headers.get("content-type"))&&E.setContentType(W),V.body){const[H,B]=b0(P,nd(v0(x)));b=x0(V.body,E0,H,B)}}G.isString(T)||(T=T?"include":"omit");const C=s&&"credentials"in n.prototype,M={...N,signal:R,method:g.toUpperCase(),headers:E.normalize().toJSON(),body:b,duplex:"half",credentials:C?T:void 0};D=s&&new n(m,M);let U=await(s?I(D,N):I(m,M));const L=u&&(A==="stream"||A==="response");if(u&&(_||L&&O)){const V={};["status","statusText","headers"].forEach($=>{V[$]=U[$]});const W=G.toFiniteNumber(U.headers.get("content-length")),[H,B]=_&&b0(W,nd(v0(_),!0))||[];U=new r(x0(U.body,E0,H,()=>{B&&B(),O&&O()}),V)}A=A||"text";let F=await d[G.findKey(d,A)||"text"](U,p);return!L&&O&&O(),await new Promise((V,W)=>{XS(V,W,{data:F,headers:Dn.from(U.headers),status:U.status,statusText:U.statusText,config:p,request:D})})}catch(C){throw O&&O(),C&&C.name==="TypeError"&&/Load failed|fetch/i.test(C.message)?Object.assign(new Te("Network Error",Te.ERR_NETWORK,p,D,C&&C.response),{cause:C.cause||C}):Te.from(C,C&&C.code,p,D,C&&C.response)}}},TL=new Map,ek=t=>{let e=t&&t.env||{};const{fetch:n,Request:r,Response:o}=e,s=[r,o,n];let i=s.length,a=i,l,c,u=TL;for(;a--;)l=s[a],c=u.get(l),c===void 0&&u.set(l,c=a?new Map:kL(e)),u=c;return c};ek();const xy={http:zP,xhr:bL,fetch:{get:ek}};G.forEach(xy,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const C0=t=>`- ${t}`,CL=t=>G.isFunction(t)||t===null||t===!1;function AL(t,e){t=G.isArray(t)?t:[t];const{length:n}=t;let r,o;const s={};for(let i=0;i<n;i++){r=t[i];let a;if(o=r,!CL(r)&&(o=xy[(a=String(r)).toLowerCase()],o===void 0))throw new Te(`Unknown adapter '${a}'`);if(o&&(G.isFunction(o)||(o=o.get(e))))break;s[a||"#"+i]=o}if(!o){const i=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=n?i.length>1?`since :
4
- `+i.map(C0).join(`
5
- `):" "+C0(i[0]):"as no adapter specified";throw new Te("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o}const tk={getAdapter:AL,adapters:xy};function np(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new xc(null,t)}function A0(t){return np(t),t.headers=Dn.from(t.headers),t.data=tp.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),tk.getAdapter(t.adapter||wc.adapter,t)(t).then(function(r){return np(t),r.data=tp.call(t,t.transformResponse,r),r.headers=Dn.from(r.headers),r},function(r){return JS(r)||(np(t),r&&r.response&&(r.response.data=tp.call(t,t.transformResponse,r.response),r.response.headers=Dn.from(r.response.headers))),Promise.reject(r)})}const nk="1.13.6",jf={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{jf[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}});const _0={};jf.transitional=function(e,n,r){function o(s,i){return"[Axios v"+nk+"] Transitional option '"+s+"'"+i+(r?". "+r:"")}return(s,i,a)=>{if(e===!1)throw new Te(o(i," has been removed"+(n?" in "+n:"")),Te.ERR_DEPRECATED);return n&&!_0[i]&&(_0[i]=!0),e?e(s,i,a):!0}};jf.spelling=function(e){return(n,r)=>!0};function _L(t,e,n){if(typeof t!="object")throw new Te("options must be an object",Te.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let o=r.length;for(;o-- >0;){const s=r[o],i=e[s];if(i){const a=t[s],l=a===void 0||i(a,s,t);if(l!==!0)throw new Te("option "+s+" must be "+l,Te.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Te("Unknown option "+s,Te.ERR_BAD_OPTION)}}const Nu={assertOptions:_L,validators:jf},Xn=Nu.validators;let Ks=class{constructor(e){this.defaults=e||{},this.interceptors={request:new g0,response:new g0}}async request(e,n){try{return await this._request(e,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const s=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?s&&!String(r.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(r.stack+=`
6
- `+s):r.stack=s}catch{}}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=ni(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&Nu.assertOptions(r,{silentJSONParsing:Xn.transitional(Xn.boolean),forcedJSONParsing:Xn.transitional(Xn.boolean),clarifyTimeoutError:Xn.transitional(Xn.boolean),legacyInterceptorReqResOrdering:Xn.transitional(Xn.boolean)},!1),o!=null&&(G.isFunction(o)?n.paramsSerializer={serialize:o}:Nu.assertOptions(o,{encode:Xn.function,serialize:Xn.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Nu.assertOptions(n,{baseUrl:Xn.spelling("baseURL"),withXsrfToken:Xn.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&G.merge(s.common,s[n.method]);s&&G.forEach(["delete","get","head","post","put","patch","common"],p=>{delete s[p]}),n.headers=Dn.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(m){if(typeof m.runWhen=="function"&&m.runWhen(n)===!1)return;l=l&&m.synchronous;const g=n.transitional||vy;g&&g.legacyInterceptorReqResOrdering?a.unshift(m.fulfilled,m.rejected):a.push(m.fulfilled,m.rejected)});const c=[];this.interceptors.response.forEach(function(m){c.push(m.fulfilled,m.rejected)});let u,d=0,f;if(!l){const p=[A0.bind(this),void 0];for(p.unshift(...a),p.push(...c),f=p.length,u=Promise.resolve(n);d<f;)u=u.then(p[d++],p[d++]);return u}f=a.length;let h=n;for(;d<f;){const p=a[d++],m=a[d++];try{h=p(h)}catch(g){m.call(this,g);break}}try{u=A0.call(this,h)}catch(p){return Promise.reject(p)}for(d=0,f=c.length;d<f;)u=u.then(c[d++],c[d++]);return u}getUri(e){e=ni(this.defaults,e);const n=QS(e.baseURL,e.url,e.allowAbsoluteUrls);return qS(n,e.params,e.paramsSerializer)}};G.forEach(["delete","get","head","options"],function(e){Ks.prototype[e]=function(n,r){return this.request(ni(r||{},{method:e,url:n,data:(r||{}).data}))}});G.forEach(["post","put","patch"],function(e){function n(r){return function(s,i,a){return this.request(ni(a||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}Ks.prototype[e]=n(),Ks.prototype[e+"Form"]=n(!0)});let ML=class rk{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(s){n=s});const r=this;this.promise.then(o=>{if(!r._listeners)return;let s=r._listeners.length;for(;s-- >0;)r._listeners[s](o);r._listeners=null}),this.promise.then=o=>{let s;const i=new Promise(a=>{r.subscribe(a),s=a}).then(o);return i.cancel=function(){r.unsubscribe(s)},i},e(function(s,i,a){r.reason||(r.reason=new xc(s,i,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=r=>{e.abort(r)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new rk(function(o){e=o}),cancel:e}}};function OL(t){return function(n){return t.apply(null,n)}}function RL(t){return G.isObject(t)&&t.isAxiosError===!0}const Nm={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Nm).forEach(([t,e])=>{Nm[e]=t});function ok(t){const e=new Ks(t),n=jS(Ks.prototype.request,e);return G.extend(n,Ks.prototype,e,{allOwnKeys:!0}),G.extend(n,e,null,{allOwnKeys:!0}),n.create=function(o){return ok(ni(t,o))},n}const Et=ok(wc);Et.Axios=Ks;Et.CanceledError=xc;Et.CancelToken=ML;Et.isCancel=JS;Et.VERSION=nk;Et.toFormData=Lf;Et.AxiosError=Te;Et.Cancel=Et.CanceledError;Et.all=function(e){return Promise.all(e)};Et.spread=OL;Et.isAxiosError=RL;Et.mergeConfig=ni;Et.AxiosHeaders=Dn;Et.formToJSON=t=>YS(G.isHTMLForm(t)?new FormData(t):t);Et.getAdapter=tk.getAdapter;Et.HttpStatusCode=Nm;Et.default=Et;const{Axios:Ele,AxiosError:M0,CanceledError:Sle,isCancel:kle,CancelToken:Tle,VERSION:Cle,all:Ale,Cancel:_le,isAxiosError:Mle,spread:Ole,toFormData:Rle,AxiosHeaders:Nle,HttpStatusCode:Ile,formToJSON:Dle,getAdapter:Ple,mergeConfig:Lle}=Et;var sk=(t=>(t[t.GROUP=0]="GROUP",t[t.USER=1]="USER",t))(sk||{}),hl=(t=>(t.Post="post",t.Comment="comment",t))(hl||{}),ik=(t=>(t[t.POST=0]="POST",t[t.FEATURED_POST=1]="FEATURED_POST",t))(ik||{}),Iu=(t=>(t.User="mention",t.Group="hashtag",t))(Iu||{}),cs=(t=>(t.NEW_POST_IMAGE="new:post:image",t.NEW_POST_MEDIA="new:post:media",t.NEW_POST_POLL="new:post:poll",t.NEW_POST_LINK="new:post:link",t.NEW_POST_MESSAGE="new:post:text",t.NEW_COMMENT="new:comment",t.NEW_COMMENT_GUGGY="new:comment:gif",t.NEW_COMMENT_VOICE="new:comment:voice",t.NEW_COMMENT_IMAGE="new:comment:image",t.NEW_COMMENT_MEDIA="new:comment:media",t))(cs||{}),ue=(t=>(t.Image="image",t.Video="video",t.Audio="audio",t))(ue||{}),Vn=(t=>(t.MEDIA_ITEM="mediaItem",t.IMAGE_ITEM="imageItem",t.LINK_ITEM="linkItem",t))(Vn||{}),Yr=(t=>(t.Gif="GifSearch",t.Image="ImageSearch",t))(Yr||{}),Mo=(t=>(t.Feed="Feed",t.Modal="Modal",t.Comment="Comment",t.Inbox="Inbox",t.Global="Global",t))(Mo||{}),Pe=(t=>(t.Media="Post",t.Blog="Blog",t.Poll="Poll",t))(Pe||{}),_t=(t=>(t.LEFT="left",t.CENTER="center",t.RIGHT="right",t))(_t||{}),Ec=(t=>(t.Compact="compact",t.Extended="extended",t))(Ec||{}),So=(t=>(t.POLL_TEXT_ITEM="pollTextItem",t.POLL_IMAGE_ITEM="pollImageItem",t.POLL_MEDIA_ITEM="pollMediaItem",t))(So||{});const NL=300,Ey={[ue.Image]:"img",[ue.Video]:"video",[ue.Audio]:"audio"},O0={[ue.Image]:"image/jpg, image/jpeg, image/png, image/webp, image/gif, image/avif",[ue.Video]:"video/mp4, video/quicktime, video/webm, video/ogg",[ue.Audio]:"audio/mpeg, audio/midi, audio/webm, audio/ogg, audio/wav"},Du={[ue.Image]:"image",[ue.Video]:"video",[ue.Audio]:"audio"},ke={http:{CLIENT_ERROR:"http_client_error",UNAUTHORIZED:"invalid_jwt_token",SERVER_ERROR:"http_server_error",TIMEOUT_ERROR:"http_timeout_error",CONNECTION_ERROR:"http_connection_error",NETWORK_ERROR:"http_network_error",CANCEL_ERROR:"http_cancel_error",UNKNOWN_ERROR:"http_unknown_error",NOT_FOUND:"general_no_result",INVALID_CREDENTIALS:"login_page_error_message_phone_and_pwd_not_match",PHONE_ALREADY_USE:"sign_up_login_toast_phone_number_already_registered_and_logged_in",USERNAME_ALREADY_USE:"sign_up_create_select_id_page_error_id_existed",EMAIL_ALREADY_USE:"sign_up_create_email_page_error_email_existed",RELATIONSHIP_NOT_PENDING:"relationship_not_pending",INVALID_SMS_TOKEN:"sign_up_enter_verification_code_page_error_invalid_code",MISSING_FIELD:"missing_field",ACCOUNT_WAS_NOT_REGISTERED:"login_page_phone_not_registered_alert_title",ENTITY_TOO_LARGE:"image_upload_file_size_too_big"}},IL=20,R0={images:"scrollableDiv-images",gifs:"scrollableDiv-gifs"},DL=300*1e3,Er=10,pl=50*1024*1024,dr=["#0091d5","#fcc600","#ce50a0","#139e6b"],Gs={MIN:1,MAX:4,MAX_TEXT_LENGTH:40},N0={[So.POLL_TEXT_ITEM]:"text",[So.POLL_IMAGE_ITEM]:"image",[So.POLL_MEDIA_ITEM]:"video"};class ml extends Error{httpCode=0;static className="HTTPError";constructor(e,n){super(e),this.name=ml.className,this.message=e,this.httpCode=n}}function yr(t,e,n){const r=e(t);return r===t?n:r}function rd(t){return t&&t.status?t.status:t&&t.response&&t.response.status?t.response.status:-1}const br={[ke.http.CLIENT_ERROR]:"Oops. Something went wrong. Please try again.",[ke.http.UNAUTHORIZED]:"Session expired. Please log in again.",[ke.http.SERVER_ERROR]:"The server is not responding. Please try again later.",[ke.http.TIMEOUT_ERROR]:"The network connection is slow. Please check and try again.",[ke.http.CONNECTION_ERROR]:"Oops. Please ensure your internet connection is stable.",[ke.http.NETWORK_ERROR]:"Oops. Please check your internet connection.",[ke.http.CANCEL_ERROR]:"Request has been canceled.",[ke.http.UNKNOWN_ERROR]:"Oops. Something went wrong. Please try again.",[ke.http.NOT_FOUND]:"No results",[ke.http.INVALID_CREDENTIALS]:"The phone number and password doesn't match. For the security of your account, please consider updating the password.",[ke.http.PHONE_ALREADY_USE]:"The account linked to this number already exist.",[ke.http.USERNAME_ALREADY_USE]:"Sorry, this ID is already taken.",[ke.http.EMAIL_ALREADY_USE]:"This email is already used",[ke.http.RELATIONSHIP_NOT_PENDING]:"Invalid contact request",[ke.http.INVALID_SMS_TOKEN]:"The verification code is incorrect.",[ke.http.MISSING_FIELD]:"Seems like one of the required fields is missing!",[ke.http.ACCOUNT_WAS_NOT_REGISTERED]:"No user found connected to this phone number. Currently, you can only create a SELECT account using an invitation.",[ke.http.ENTITY_TOO_LARGE]:"Image file size is too big. Please upload a smaller image"};function PL(t,e){if(!t.response)return yr(ke.http.NETWORK_ERROR,e,br[ke.http.NETWORK_ERROR]);const n=rd(t.response),r=t.response.data,o=r?.message||r?.error||r?.detail;if(o&&typeof o=="string")return o;const s=r?.code||r?.error_code;if(s){const a={PHONE_ALREADY_REGISTERED:ke.http.PHONE_ALREADY_USE,USERNAME_EXISTS:ke.http.USERNAME_ALREADY_USE,EMAIL_EXISTS:ke.http.EMAIL_ALREADY_USE,RELATIONSHIP_NOT_PENDING:ke.http.RELATIONSHIP_NOT_PENDING,INVALID_SMS_TOKEN:ke.http.INVALID_SMS_TOKEN,MISSING_FIELD:ke.http.MISSING_FIELD,ACCOUNT_NOT_FOUND:ke.http.ACCOUNT_WAS_NOT_REGISTERED,INVALID_CREDENTIALS:ke.http.INVALID_CREDENTIALS}[s];if(a)return yr(a,e,br[a]||"An error occurred")}switch(n){case 400:return yr(ke.http.CLIENT_ERROR,e,br[ke.http.CLIENT_ERROR]);case 401:return yr(ke.http.UNAUTHORIZED,e,br[ke.http.UNAUTHORIZED]);case 403:return"You do not have permission to perform this action.";case 404:return yr(ke.http.NOT_FOUND,e,br[ke.http.NOT_FOUND]);case 413:return yr(ke.http.ENTITY_TOO_LARGE,e,br[ke.http.ENTITY_TOO_LARGE]);case 422:return yr(ke.http.MISSING_FIELD,e,br[ke.http.MISSING_FIELD]);case 429:return"Too many requests. Please try again later.";case 500:case 502:case 503:case 504:return yr(ke.http.SERVER_ERROR,e,br[ke.http.SERVER_ERROR]);default:return yr(ke.http.UNKNOWN_ERROR,e,br[ke.http.UNKNOWN_ERROR])}}function Ll(t,e,n,r){if(t&&t instanceof M0&&!t.isAxiosError)return t;if(!t){const o=yr(ke.http.UNKNOWN_ERROR,e,br[ke.http.UNKNOWN_ERROR]);return r?.(o),new ml(o,0)}if(t instanceof M0){const{response:o}=t;if(!o||!o.status){const a=yr(ke.http.NETWORK_ERROR,e,br[ke.http.NETWORK_ERROR]);return r?.(a),new ml(a,0)}const{status:s}=o;if(s&&s<300)return null;const i=PL(t,e);return r?.(i),s===401&&n(ke.http.UNAUTHORIZED),new ml(i,s)}}function Sy(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var rp,I0;function LL(){if(I0)return rp;I0=1;const t=new Set(["ENOTFOUND","ENETUNREACH","UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_CRL","UNABLE_TO_DECRYPT_CERT_SIGNATURE","UNABLE_TO_DECRYPT_CRL_SIGNATURE","UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY","CERT_SIGNATURE_FAILURE","CRL_SIGNATURE_FAILURE","CERT_NOT_YET_VALID","CERT_HAS_EXPIRED","CRL_NOT_YET_VALID","CRL_HAS_EXPIRED","ERROR_IN_CERT_NOT_BEFORE_FIELD","ERROR_IN_CERT_NOT_AFTER_FIELD","ERROR_IN_CRL_LAST_UPDATE_FIELD","ERROR_IN_CRL_NEXT_UPDATE_FIELD","OUT_OF_MEM","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","CERT_CHAIN_TOO_LONG","CERT_REVOKED","INVALID_CA","PATH_LENGTH_EXCEEDED","INVALID_PURPOSE","CERT_UNTRUSTED","CERT_REJECTED","HOSTNAME_MISMATCH"]);return rp=e=>!t.has(e&&e.code),rp}var jL=LL();const $L=Sy(jL),ky="axios-retry";function ak(t){const e=["ERR_CANCELED","ECONNABORTED"];return t.response||!t.code||e.includes(t.code)?!1:$L(t)}const lk=["get","head","options"],FL=lk.concat(["put","delete"]);function Ty(t){return t.code!=="ECONNABORTED"&&(!t.response||t.response.status===429||t.response.status>=500&&t.response.status<=599)}function UL(t){return t.config?.method?Ty(t)&&lk.indexOf(t.config.method)!==-1:!1}function ck(t){return t.config?.method?Ty(t)&&FL.indexOf(t.config.method)!==-1:!1}function uk(t){return ak(t)||ck(t)}function Cy(t=void 0){const e=t?.response?.headers["retry-after"];if(!e)return 0;let n=(Number(e)||0)*1e3;return n===0&&(n=(new Date(e).valueOf()||0)-Date.now()),Math.max(0,n)}function BL(t=0,e=void 0){return Math.max(0,Cy(e))}function zL(t=0,e=void 0,n=100){const r=2**t*n,o=Math.max(r,Cy(e)),s=o*.2*Math.random();return o+s}function HL(t=100){return(e=0,n=void 0)=>{const r=e*t;return Math.max(r,Cy(n))}}const VL={retries:3,retryCondition:uk,retryDelay:BL,shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function WL(t,e){return{...VL,...e,...t[ky]}}function D0(t,e,n=!1){const r=WL(t,e||{});return r.retryCount=r.retryCount||0,(!r.lastRequestTime||n)&&(r.lastRequestTime=Date.now()),t[ky]=r,r}function KL(t,e){t.defaults.agent===e.agent&&delete e.agent,t.defaults.httpAgent===e.httpAgent&&delete e.httpAgent,t.defaults.httpsAgent===e.httpsAgent&&delete e.httpsAgent}async function GL(t,e){const{retries:n,retryCondition:r}=t,o=(t.retryCount||0)<n&&r(e);if(typeof o=="object")try{return await o!==!1}catch{return!1}return o}async function qL(t,e,n,r){e.retryCount+=1;const{retryDelay:o,shouldResetTimeout:s,onRetry:i}=e,a=o(e.retryCount,n);if(KL(t,r),!s&&r.timeout&&e.lastRequestTime){const l=Date.now()-e.lastRequestTime,c=r.timeout-l-a;if(c<=0)return Promise.reject(n);r.timeout=c}return r.transformRequest=[l=>l],await i(e.retryCount,n,r),r.signal?.aborted?Promise.resolve(t(r)):new Promise(l=>{const c=()=>{clearTimeout(u),l(t(r))},u=setTimeout(()=>{l(t(r)),r.signal?.removeEventListener&&r.signal.removeEventListener("abort",c)},a);r.signal?.addEventListener&&r.signal.addEventListener("abort",c,{once:!0})})}async function YL(t,e){t.retryCount>=t.retries&&await t.onMaxRetryTimesExceeded(e,t.retryCount)}const Oo=(t,e)=>{const n=t.interceptors.request.use(o=>(D0(o,e,!0),o[ky]?.validateResponse&&(o.validateStatus=()=>!1),o)),r=t.interceptors.response.use(null,async o=>{const{config:s}=o;if(!s)return Promise.reject(o);const i=D0(s,e);return o.response&&i.validateResponse?.(o.response)?o.response:await GL(i,o)?qL(t,i,o,s):(await YL(i,o),Promise.reject(o))});return{requestInterceptorId:n,responseInterceptorId:r}};Oo.isNetworkError=ak;Oo.isSafeRequestError=UL;Oo.isIdempotentRequestError=ck;Oo.isNetworkOrIdempotentRequestError=uk;Oo.exponentialDelay=zL;Oo.linearDelay=HL;Oo.isRetryableError=Ty;function JL(t){if(typeof document>"u")return;let e=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e.appendChild(n),n.styleSheet?n.styleSheet.cssText=t:n.appendChild(document.createTextNode(t))}const XL=t=>{switch(t){case"success":return e2;case"info":return n2;case"warning":return t2;case"error":return r2;default:return null}},QL=Array(12).fill(0),ZL=({visible:t,className:e})=>w.default.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},w.default.createElement("div",{className:"sonner-spinner"},QL.map((n,r)=>w.default.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),e2=w.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.default.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),t2=w.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},w.default.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),n2=w.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.default.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),r2=w.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},w.default.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),o2=w.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},w.default.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),w.default.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),s2=()=>{const[t,e]=w.default.useState(document.hidden);return w.default.useEffect(()=>{const n=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),t};let Im=1;class i2{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{const n=this.subscribers.indexOf(e);this.subscribers.splice(n,1)}),this.publish=e=>{this.subscribers.forEach(n=>n(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var n;const{message:r,...o}=e,s=typeof e?.id=="number"||((n=e.id)==null?void 0:n.length)>0?e.id:Im++,i=this.toasts.find(l=>l.id===s),a=e.dismissible===void 0?!0:e.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),i?this.toasts=this.toasts.map(l=>l.id===s?(this.publish({...l,...e,id:s,title:r}),{...l,...e,id:s,dismissible:a,title:r}):l):this.addToast({title:r,...o,dismissible:a,id:s}),s},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:e,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),e),this.message=(e,n)=>this.create({...n,message:e}),this.error=(e,n)=>this.create({...n,message:e,type:"error"}),this.success=(e,n)=>this.create({...n,type:"success",message:e}),this.info=(e,n)=>this.create({...n,type:"info",message:e}),this.warning=(e,n)=>this.create({...n,type:"warning",message:e}),this.loading=(e,n)=>this.create({...n,type:"loading",message:e}),this.promise=(e,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:e,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const o=Promise.resolve(e instanceof Function?e():e);let s=r!==void 0,i;const a=o.then(async c=>{if(i=["resolve",c],w.default.isValidElement(c))s=!1,this.create({id:r,type:"default",message:c});else if(l2(c)&&!c.ok){s=!1;const d=typeof n.error=="function"?await n.error(`HTTP error! status: ${c.status}`):n.error,f=typeof n.description=="function"?await n.description(`HTTP error! status: ${c.status}`):n.description,p=typeof d=="object"&&!w.default.isValidElement(d)?d:{message:d};this.create({id:r,type:"error",description:f,...p})}else if(c instanceof Error){s=!1;const d=typeof n.error=="function"?await n.error(c):n.error,f=typeof n.description=="function"?await n.description(c):n.description,p=typeof d=="object"&&!w.default.isValidElement(d)?d:{message:d};this.create({id:r,type:"error",description:f,...p})}else if(n.success!==void 0){s=!1;const d=typeof n.success=="function"?await n.success(c):n.success,f=typeof n.description=="function"?await n.description(c):n.description,p=typeof d=="object"&&!w.default.isValidElement(d)?d:{message:d};this.create({id:r,type:"success",description:f,...p})}}).catch(async c=>{if(i=["reject",c],n.error!==void 0){s=!1;const u=typeof n.error=="function"?await n.error(c):n.error,d=typeof n.description=="function"?await n.description(c):n.description,h=typeof u=="object"&&!w.default.isValidElement(u)?u:{message:u};this.create({id:r,type:"error",description:d,...h})}}).finally(()=>{s&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),l=()=>new Promise((c,u)=>a.then(()=>i[0]==="reject"?u(i[1]):c(i[1])).catch(u));return typeof r!="string"&&typeof r!="number"?{unwrap:l}:Object.assign(r,{unwrap:l})},this.custom=(e,n)=>{const r=n?.id||Im++;return this.create({jsx:e(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const Mn=new i2,a2=(t,e)=>{const n=e?.id||Im++;return Mn.addToast({title:t,...e,id:n}),n},l2=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",c2=a2,u2=()=>Mn.toasts,d2=()=>Mn.getActiveToasts(),Zt=Object.assign(c2,{success:Mn.success,info:Mn.info,warning:Mn.warning,error:Mn.error,custom:Mn.custom,message:Mn.message,promise:Mn.promise,dismiss:Mn.dismiss,loading:Mn.loading},{getHistory:u2,getToasts:d2});JL("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function Jc(t){return t.label!==void 0}const f2=3,h2="24px",p2="16px",P0=4e3,m2=356,g2=14,y2=45,b2=200;function Fr(...t){return t.filter(Boolean).join(" ")}function v2(t){const[e,n]=t.split("-"),r=[];return e&&r.push(e),n&&r.push(n),r}const w2=t=>{var e,n,r,o,s,i,a,l,c;const{invert:u,toast:d,unstyled:f,interacting:h,setHeights:p,visibleToasts:m,heights:g,index:b,toasts:S,expanded:k,removeToast:v,defaultRichColors:_,closeButton:x,style:A,cancelButtonStyle:E,actionButtonStyle:T,className:N="",descriptionClassName:I="",duration:R,position:D,gap:O,expandByDefault:P,classNames:C,icons:M,closeButtonAriaLabel:U="Close toast"}=t,[L,F]=w.default.useState(null),[V,W]=w.default.useState(null),[H,B]=w.default.useState(!1),[$,K]=w.default.useState(!1),[Y,J]=w.default.useState(!1),[Q,ne]=w.default.useState(!1),[se,te]=w.default.useState(!1),[ge,he]=w.default.useState(0),[xe,Ee]=w.default.useState(0),Se=w.default.useRef(d.duration||R||P0),_e=w.default.useRef(null),Me=w.default.useRef(null),Ke=b===0,Ge=b+1<=m,Be=d.type,je=d.dismissible!==!1,$e=d.className||"",pe=d.descriptionClassName||"",Ne=w.default.useMemo(()=>g.findIndex(ve=>ve.toastId===d.id)||0,[g,d.id]),Ie=w.default.useMemo(()=>{var ve;return(ve=d.closeButton)!=null?ve:x},[d.closeButton,x]),Ve=w.default.useMemo(()=>d.duration||R||P0,[d.duration,R]),vt=w.default.useRef(0),tt=w.default.useRef(0),et=w.default.useRef(0),qe=w.default.useRef(null),[jt,q]=D.split("-"),re=w.default.useMemo(()=>g.reduce((ve,nt,Ce)=>Ce>=Ne?ve:ve+nt.height,0),[g,Ne]),de=s2(),We=d.invert||u,Ae=Be==="loading";tt.current=w.default.useMemo(()=>Ne*O+re,[Ne,re]),w.default.useEffect(()=>{Se.current=Ve},[Ve]),w.default.useEffect(()=>{B(!0)},[]),w.default.useEffect(()=>{const ve=Me.current;if(ve){const nt=ve.getBoundingClientRect().height;return Ee(nt),p(Ce=>[{toastId:d.id,height:nt,position:d.position},...Ce]),()=>p(Ce=>Ce.filter(rt=>rt.toastId!==d.id))}},[p,d.id]),w.default.useLayoutEffect(()=>{if(!H)return;const ve=Me.current,nt=ve.style.height;ve.style.height="auto";const Ce=ve.getBoundingClientRect().height;ve.style.height=nt,Ee(Ce),p(rt=>rt.find(mt=>mt.toastId===d.id)?rt.map(mt=>mt.toastId===d.id?{...mt,height:Ce}:mt):[{toastId:d.id,height:Ce,position:d.position},...rt])},[H,d.title,d.description,p,d.id,d.jsx,d.action,d.cancel]);const ot=w.default.useCallback(()=>{K(!0),he(tt.current),p(ve=>ve.filter(nt=>nt.toastId!==d.id)),setTimeout(()=>{v(d)},b2)},[d,v,p,tt]);w.default.useEffect(()=>{if(d.promise&&Be==="loading"||d.duration===1/0||d.type==="loading")return;let ve;return k||h||de?(()=>{if(et.current<vt.current){const rt=new Date().getTime()-vt.current;Se.current=Se.current-rt}et.current=new Date().getTime()})():Se.current!==1/0&&(vt.current=new Date().getTime(),ve=setTimeout(()=>{d.onAutoClose==null||d.onAutoClose.call(d,d),ot()},Se.current)),()=>clearTimeout(ve)},[k,h,d,Be,de,ot]),w.default.useEffect(()=>{d.delete&&(ot(),d.onDismiss==null||d.onDismiss.call(d,d))},[ot,d.delete]);function ht(){var ve;if(M?.loading){var nt;return w.default.createElement("div",{className:Fr(C?.loader,d==null||(nt=d.classNames)==null?void 0:nt.loader,"sonner-loader"),"data-visible":Be==="loading"},M.loading)}return w.default.createElement(ZL,{className:Fr(C?.loader,d==null||(ve=d.classNames)==null?void 0:ve.loader),visible:Be==="loading"})}const hn=d.icon||M?.[Be]||XL(Be);var nn,pt;return w.default.createElement("li",{tabIndex:0,ref:Me,className:Fr(N,$e,C?.toast,d==null||(e=d.classNames)==null?void 0:e.toast,C?.default,C?.[Be],d==null||(n=d.classNames)==null?void 0:n[Be]),"data-sonner-toast":"","data-rich-colors":(nn=d.richColors)!=null?nn:_,"data-styled":!(d.jsx||d.unstyled||f),"data-mounted":H,"data-promise":!!d.promise,"data-swiped":se,"data-removed":$,"data-visible":Ge,"data-y-position":jt,"data-x-position":q,"data-index":b,"data-front":Ke,"data-swiping":Y,"data-dismissible":je,"data-type":Be,"data-invert":We,"data-swipe-out":Q,"data-swipe-direction":V,"data-expanded":!!(k||P&&H),"data-testid":d.testId,style:{"--index":b,"--toasts-before":b,"--z-index":S.length-b,"--offset":`${$?ge:tt.current}px`,"--initial-height":P?"auto":`${xe}px`,...A,...d.style},onDragEnd:()=>{J(!1),F(null),qe.current=null},onPointerDown:ve=>{ve.button!==2&&(Ae||!je||(_e.current=new Date,he(tt.current),ve.target.setPointerCapture(ve.pointerId),ve.target.tagName!=="BUTTON"&&(J(!0),qe.current={x:ve.clientX,y:ve.clientY})))},onPointerUp:()=>{var ve,nt,Ce;if(Q||!je)return;qe.current=null;const rt=Number(((ve=Me.current)==null?void 0:ve.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),$t=Number(((nt=Me.current)==null?void 0:nt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),mt=new Date().getTime()-((Ce=_e.current)==null?void 0:Ce.getTime()),rn=L==="x"?rt:$t,Is=Math.abs(rn)/mt;if(Math.abs(rn)>=y2||Is>.11){he(tt.current),d.onDismiss==null||d.onDismiss.call(d,d),W(L==="x"?rt>0?"right":"left":$t>0?"down":"up"),ot(),ne(!0);return}else{var An,Un;(An=Me.current)==null||An.style.setProperty("--swipe-amount-x","0px"),(Un=Me.current)==null||Un.style.setProperty("--swipe-amount-y","0px")}te(!1),J(!1),F(null)},onPointerMove:ve=>{var nt,Ce,rt;if(!qe.current||!je||((nt=window.getSelection())==null?void 0:nt.toString().length)>0)return;const mt=ve.clientY-qe.current.y,rn=ve.clientX-qe.current.x;var Is;const An=(Is=t.swipeDirections)!=null?Is:v2(D);!L&&(Math.abs(rn)>1||Math.abs(mt)>1)&&F(Math.abs(rn)>Math.abs(mt)?"x":"y");let Un={x:0,y:0};const Bn=pn=>1/(1.5+Math.abs(pn)/20);if(L==="y"){if(An.includes("top")||An.includes("bottom"))if(An.includes("top")&&mt<0||An.includes("bottom")&&mt>0)Un.y=mt;else{const pn=mt*Bn(mt);Un.y=Math.abs(pn)<Math.abs(mt)?pn:mt}}else if(L==="x"&&(An.includes("left")||An.includes("right")))if(An.includes("left")&&rn<0||An.includes("right")&&rn>0)Un.x=rn;else{const pn=rn*Bn(rn);Un.x=Math.abs(pn)<Math.abs(rn)?pn:rn}(Math.abs(Un.x)>0||Math.abs(Un.y)>0)&&te(!0),(Ce=Me.current)==null||Ce.style.setProperty("--swipe-amount-x",`${Un.x}px`),(rt=Me.current)==null||rt.style.setProperty("--swipe-amount-y",`${Un.y}px`)}},Ie&&!d.jsx&&Be!=="loading"?w.default.createElement("button",{"aria-label":U,"data-disabled":Ae,"data-close-button":!0,onClick:Ae||!je?()=>{}:()=>{ot(),d.onDismiss==null||d.onDismiss.call(d,d)},className:Fr(C?.closeButton,d==null||(r=d.classNames)==null?void 0:r.closeButton)},(pt=M?.close)!=null?pt:o2):null,(Be||d.icon||d.promise)&&d.icon!==null&&(M?.[Be]!==null||d.icon)?w.default.createElement("div",{"data-icon":"",className:Fr(C?.icon,d==null||(o=d.classNames)==null?void 0:o.icon)},d.promise||d.type==="loading"&&!d.icon?d.icon||ht():null,d.type!=="loading"?hn:null):null,w.default.createElement("div",{"data-content":"",className:Fr(C?.content,d==null||(s=d.classNames)==null?void 0:s.content)},w.default.createElement("div",{"data-title":"",className:Fr(C?.title,d==null||(i=d.classNames)==null?void 0:i.title)},d.jsx?d.jsx:typeof d.title=="function"?d.title():d.title),d.description?w.default.createElement("div",{"data-description":"",className:Fr(I,pe,C?.description,d==null||(a=d.classNames)==null?void 0:a.description)},typeof d.description=="function"?d.description():d.description):null),w.default.isValidElement(d.cancel)?d.cancel:d.cancel&&Jc(d.cancel)?w.default.createElement("button",{"data-button":!0,"data-cancel":!0,style:d.cancelButtonStyle||E,onClick:ve=>{Jc(d.cancel)&&je&&(d.cancel.onClick==null||d.cancel.onClick.call(d.cancel,ve),ot())},className:Fr(C?.cancelButton,d==null||(l=d.classNames)==null?void 0:l.cancelButton)},d.cancel.label):null,w.default.isValidElement(d.action)?d.action:d.action&&Jc(d.action)?w.default.createElement("button",{"data-button":!0,"data-action":!0,style:d.actionButtonStyle||T,onClick:ve=>{Jc(d.action)&&(d.action.onClick==null||d.action.onClick.call(d.action,ve),!ve.defaultPrevented&&ot())},className:Fr(C?.actionButton,d==null||(c=d.classNames)==null?void 0:c.actionButton)},d.action.label):null)};function L0(){if(typeof window>"u"||typeof document>"u")return"ltr";const t=document.documentElement.getAttribute("dir");return t==="auto"||!t?window.getComputedStyle(document.documentElement).direction:t}function x2(t,e){const n={};return[t,e].forEach((r,o)=>{const s=o===1,i=s?"--mobile-offset":"--offset",a=s?p2:h2;function l(c){["top","right","bottom","left"].forEach(u=>{n[`${i}-${u}`]=typeof c=="number"?`${c}px`:c})}typeof r=="number"||typeof r=="string"?l(r):typeof r=="object"?["top","right","bottom","left"].forEach(c=>{r[c]===void 0?n[`${i}-${c}`]=a:n[`${i}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(a)}),n}const E2=w.default.forwardRef(function(e,n){const{id:r,invert:o,position:s="bottom-right",hotkey:i=["altKey","KeyT"],expand:a,closeButton:l,className:c,offset:u,mobileOffset:d,theme:f="light",richColors:h,duration:p,style:m,visibleToasts:g=f2,toastOptions:b,dir:S=L0(),gap:k=g2,icons:v,containerAriaLabel:_="Notifications"}=e,[x,A]=w.default.useState([]),E=w.default.useMemo(()=>r?x.filter(H=>H.toasterId===r):x.filter(H=>!H.toasterId),[x,r]),T=w.default.useMemo(()=>Array.from(new Set([s].concat(E.filter(H=>H.position).map(H=>H.position)))),[E,s]),[N,I]=w.default.useState([]),[R,D]=w.default.useState(!1),[O,P]=w.default.useState(!1),[C,M]=w.default.useState(f!=="system"?f:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),U=w.default.useRef(null),L=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),F=w.default.useRef(null),V=w.default.useRef(!1),W=w.default.useCallback(H=>{A(B=>{var $;return($=B.find(K=>K.id===H.id))!=null&&$.delete||Mn.dismiss(H.id),B.filter(({id:K})=>K!==H.id)})},[]);return w.default.useEffect(()=>Mn.subscribe(H=>{if(H.dismiss){requestAnimationFrame(()=>{A(B=>B.map($=>$.id===H.id?{...$,delete:!0}:$))});return}setTimeout(()=>{vi.default.flushSync(()=>{A(B=>{const $=B.findIndex(K=>K.id===H.id);return $!==-1?[...B.slice(0,$),{...B[$],...H},...B.slice($+1)]:[H,...B]})})})}),[x]),w.default.useEffect(()=>{if(f!=="system"){M(f);return}if(f==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?M("dark"):M("light")),typeof window>"u")return;const H=window.matchMedia("(prefers-color-scheme: dark)");try{H.addEventListener("change",({matches:B})=>{M(B?"dark":"light")})}catch{H.addListener(({matches:$})=>{try{M($?"dark":"light")}catch{}})}},[f]),w.default.useEffect(()=>{x.length<=1&&D(!1)},[x]),w.default.useEffect(()=>{const H=B=>{var $;if(i.every(J=>B[J]||B.code===J)){var Y;D(!0),(Y=U.current)==null||Y.focus()}B.code==="Escape"&&(document.activeElement===U.current||($=U.current)!=null&&$.contains(document.activeElement))&&D(!1)};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[i]),w.default.useEffect(()=>{if(U.current)return()=>{F.current&&(F.current.focus({preventScroll:!0}),F.current=null,V.current=!1)}},[U.current]),w.default.createElement("section",{ref:n,"aria-label":`${_} ${L}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},T.map((H,B)=>{var $;const[K,Y]=H.split("-");return E.length?w.default.createElement("ol",{key:H,dir:S==="auto"?L0():S,tabIndex:-1,ref:U,className:c,"data-sonner-toaster":!0,"data-sonner-theme":C,"data-y-position":K,"data-x-position":Y,style:{"--front-toast-height":`${(($=N[0])==null?void 0:$.height)||0}px`,"--width":`${m2}px`,"--gap":`${k}px`,...m,...x2(u,d)},onBlur:J=>{V.current&&!J.currentTarget.contains(J.relatedTarget)&&(V.current=!1,F.current&&(F.current.focus({preventScroll:!0}),F.current=null))},onFocus:J=>{J.target instanceof HTMLElement&&J.target.dataset.dismissible==="false"||V.current||(V.current=!0,F.current=J.relatedTarget)},onMouseEnter:()=>D(!0),onMouseMove:()=>D(!0),onMouseLeave:()=>{O||D(!1)},onDragEnd:()=>D(!1),onPointerDown:J=>{J.target instanceof HTMLElement&&J.target.dataset.dismissible==="false"||P(!0)},onPointerUp:()=>P(!1)},E.filter(J=>!J.position&&B===0||J.position===H).map((J,Q)=>{var ne,se;return w.default.createElement(w2,{key:J.id,icons:v,index:Q,toast:J,defaultRichColors:h,duration:(ne=b?.duration)!=null?ne:p,className:b?.className,descriptionClassName:b?.descriptionClassName,invert:o,visibleToasts:g,closeButton:(se=b?.closeButton)!=null?se:l,interacting:O,position:H,style:b?.style,unstyled:b?.unstyled,classNames:b?.classNames,cancelButtonStyle:b?.cancelButtonStyle,actionButtonStyle:b?.actionButtonStyle,closeButtonAriaLabel:b?.closeButtonAriaLabel,removeToast:W,toasts:E.filter(te=>te.position==J.position),heights:N.filter(te=>te.position==J.position),setHeights:I,expandByDefault:a,gap:k,expanded:R,swipeDirections:e.swipeDirections})})):null}))}),S2=18e4,k2="http://localhost:3000/api",T2=["Oops. Something went wrong. Please try again."],dk=()=>"en-US";function od(t){const{token:e,baseURL:n=k2,timeout:r=S2}=t,o=Et.create({baseURL:n,timeout:r,headers:{"accept-encoding":"gzip","Content-Type":t.isFileStore?"multipart/form-data":"application/json",...t.isFileStore?{}:{"content-language":dk()}},...t.isFileStore?{}:{withCredentials:!0},validateStatus:s=>s<300});return Oo(o,{retries:3,retryDelay:(s,i)=>Oo.exponentialDelay(s,i),retryCondition:s=>{if(Et.isCancel(s))return!1;const i=rd(s);return!i||i>500||!s||!s.response}}),o.interceptors.request.use(s=>(e&&s.headers&&(t.isFileStore?s.headers.token=e:s.headers.Authorization=`Bearer ${e}`),s),s=>Promise.reject(s)),o.interceptors.response.use(s=>s,s=>{const i=s.config?.suppressErrorToast??!1;return Et.isCancel(s)||Ll(s,t.t,()=>{},a=>!T2.includes(a)&&!i&&Zt.error(a,{id:a})),Promise.reject(s)}),o}const j0=new Map,Xc=new Map,sd=(t,e)=>async()=>{const n=Date.now(),r=j0.get(t);if(r&&n-r.timestamp<DL)return r.data;const o=Xc.get(t);if(o)return o.promise;const s=e().then(i=>(j0.set(t,{data:i,timestamp:n}),Xc.delete(t),i)).catch(i=>{throw Xc.delete(t),i});return Xc.set(t,{promise:s,timestamp:n}),s};class C2{isAuthorize;baseUrl;url;language;onError;api;apiV2;token;toI18N;constructor(e,n,r,o){this.isAuthorize=!1,this.baseUrl=e,this.url=`${e}v1/`,this.language=o??dk(),this.onError=()=>{},this.toI18N=r,this.token=n,this.initApi()}setToken(e){this.isAuthorize=!!e,this.token=e}addErrorListener(e){this.onError=e}throwHTTPError(e){return Ll(e,this.toI18N,this.onError)}initApi(){this.api=od({baseURL:this.url,t:this.toI18N,token:this.token,isFileStore:!1}),this.apiV2=od({baseURL:`${this.baseUrl}v2/`,t:this.toI18N,token:this.token,isFileStore:!1})}getErrorMessage(e){return e&&e.response&&e.response.data&&e.response.data.error?e.response.data.error:e&&e.response&&e.response.data&&e.response.data.message?e.response.data.message:null}fetchConversationList(e,n){return sd("conversation-list",()=>this.apiV2.get("conversation/list",{params:{from_time:n,amount:e}}).then(s=>s?.data?.filter(i=>i?.conversation_detail?.type===sk.GROUP)).catch(s=>{throw this.throwHTTPError(s)}))()}searchWebImage(e,n,r){return this.api.get("search/images",{params:{q:e,l:n,o:r}}).then(o=>o.data).catch(o=>{throw this.throwHTTPError(o)})}searchWebGif(e,n,r,o=!1){return this.api.get("search/gifs",{params:{q:e,l:n,o:r,in_china:o}}).then(s=>s.data).catch(s=>{throw this.throwHTTPError(s)})}fetchTrendyWebGif(e,n,r=!1){return this.api.get("search/gifs/trending",{params:{l:e,o:n,in_china:r}}).then(o=>o.data).catch(o=>{throw this.throwHTTPError(o)})}fetchTrendyWebImage(e,n){return this.api.get("search/images/trending",{params:{l:e,o:n}}).then(r=>r.data).catch(r=>{throw this.throwHTTPError(r)})}resolveUrl(e){return sd(e,()=>this.api.post("https://phoenix.selectdc1.com/v1/url/resolve",{url:e}).then(o=>o.data).catch(o=>{throw this.throwHTTPError(o)}))()}}const qt=[];for(let t=0;t<256;++t)qt.push((t+256).toString(16).slice(1));function A2(t,e=0){return(qt[t[e+0]]+qt[t[e+1]]+qt[t[e+2]]+qt[t[e+3]]+"-"+qt[t[e+4]]+qt[t[e+5]]+"-"+qt[t[e+6]]+qt[t[e+7]]+"-"+qt[t[e+8]]+qt[t[e+9]]+"-"+qt[t[e+10]]+qt[t[e+11]]+qt[t[e+12]]+qt[t[e+13]]+qt[t[e+14]]+qt[t[e+15]]).toLowerCase()}let op;const _2=new Uint8Array(16);function M2(){if(!op){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");op=crypto.getRandomValues.bind(crypto)}return op(_2)}const O2=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),$0={randomUUID:O2};function R2(t,e,n){t=t||{};const r=t.random??t.rng?.()??M2();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,A2(r)}function Dt(t,e,n){return $0.randomUUID&&!t?$0.randomUUID():R2(t)}const sp="mp4";class N2{url;isAuthorize;api;token;toI18N;constructor(e,n,r){this.token=n,this.isAuthorize=!1,this.url=e,this.toI18N=r,this.initApi()}throwHTTPError(e){return Ll(e,this.toI18N,()=>{})}setToken(e){this.isAuthorize=!0,this.token=e}initApi(){this.isAuthorize=!1,this.api=od({baseURL:this.url,t:this.toI18N,token:this.token,isFileStore:!0})}async uploadUrl(e){const n=I2(e),r={compress:!n,crop_square:!1,gif_format:sp,source_url:e};try{return(await this.api.post("/api/v1/upload/url",r,{headers:{"Content-Type":"application/json"},suppressErrorToast:n}))?.data?.data??{}}catch(o){if(n){let s;try{const i=await fetch(e);if(i.ok){const a=await i.blob();s=new File([a],`${Dt()}.gif`,{type:"image/gif"})}}catch{}if(s)return await this.uploadChunked(s);throw Ll(o,this.toI18N,()=>{},i=>Zt.error(i,{id:i}))}throw this.throwHTTPError(o)}}uploadImage(e,n){const r=new FormData;return r.set("file",e),r.set("compress",e.type==="image/gif"?"false":"true"),r.set("gif_format",sp),r.set("target_name",Dt()),this.api.post("/api/v1/upload/file",r,{onUploadProgress:n?o=>n(Math.round(o.loaded/(o.total??o.loaded)*100)):void 0}).then(o=>o.data?.data??{}).catch(o=>{throw this.throwHTTPError(o)})}uploadVoice(e){const n=new FormData;return n.set("file",e),n.set("compress","false"),n.set("target_name",Dt()),this.api.post("/api/v1/upload/file",n).then(r=>r.data?.data??{}).catch(r=>{throw this.throwHTTPError(r)})}getFileNameAndExt(e){return e.split("/").pop()}async pollUploadStatus(e,n=60,r){let o=500;for(let s=0;s<n;s++){if(r?.aborted)throw new DOMException("Aborted","AbortError");const a=(await this.api.get(`/api/v2/upload/status/${e}`,{headers:{"Content-Type":"application/json"},signal:r})).data?.data;if(!a?.status)throw new Error("Unexpected response from upload status endpoint");if(a.status==="succeeded"&&a.result)return a.result;if(a.status==="failed")throw new Error(a.error||"Upload processing failed");await new Promise(l=>setTimeout(l,o)),o=Math.min(o*1.5,1e4)}throw new Error("Upload processing timed out")}async uploadChunked(e,n,r){if(e.size===0)throw new Error("Cannot upload an empty file");const o=await this.api.post("/api/v2/upload/init",{content_type:e.type,total_bytes:e.size,filename:e.name},{headers:{"Content-Type":"application/json"},signal:r}),{media_id:s,chunk_size:i}=o.data.data;let a=0,l=1;for(;a<e.size;){if(r?.aborted)throw new DOMException("Aborted","AbortError");const u=Math.min(a+i,e.size),d=e.slice(a,u),f=new FormData;f.append("media_id",s),f.append("chunk_index",String(l)),f.append("chunk",d,e.name),await this.api.post("/api/v2/upload/append",f,{signal:r}),a=u,l++,n?.(Math.round(a/e.size*70))}await this.api.post("/api/v2/upload/finalize",{media_id:s,compress:e.type!=="image/gif",crop_square:!1,gif_format:sp},{headers:{"Content-Type":"application/json"},signal:r});const c=D2(n,70,99);try{const u=await this.pollUploadStatus(s,60,r);return c&&clearInterval(c),n?.(100),u}catch(u){throw c&&clearInterval(c),u}}async uploadVoiceV2(e,n){const r=new FormData;r.set("file",e);const s=(await this.api.post("/api/v2/upload/simple",r,{signal:n})).data?.data;if(!s?.media_id)throw new Error("Voice upload failed: no media_id");return this.pollUploadStatus(s.media_id,60,n)}}function I2(t){try{return/\.gif$/i.test(new URL(t).pathname)}catch{return!1}}function D2(t,e,n){if(!t)return null;let r=e;const o=setInterval(()=>{r=Math.min(r+5,n),t(r),r>=n&&clearInterval(o)},300);return o}class P2{url;isAuthorize;api;token;toI18N;constructor(e,n,r){this.token=n,this.isAuthorize=!1,this.url=e,this.toI18N=r,this.initApi()}throwHTTPError(e){return Ll(e,this.toI18N,()=>{})}setToken(e){this.isAuthorize=!0,this.token=e}initApi(){this.api=od({baseURL:this.url,t:this.toI18N,token:this.token,isFileStore:!1})}getRecommendationPost(e,n,r=0,o=10,s=[],i=[],a="",l=["user_details","post_counter"]){const c=`post-recommendation:${e}${n?`:${n}`:""}`;return sd(c,()=>this.api.post("v2/recommendation/post",{group_id:e,post_id:n,included_user_ids:i,excluded_user_ids:s,keyword:a,offset:r,amount:o,scope:l}).then(d=>d.data).catch(d=>{throw[400,404].indexOf(rd(d))>-1?new Error(this.toI18N(ke.http.NOT_FOUND)):this.throwHTTPError(d)}))()}getRecommendationGroup(e,n=0,r=10,o=[],s=[],i="",a=["user_details"]){const l=`group-recommendation:${e}`;return sd(l,()=>this.api.post("v2/recommendation/group",{group_id:e,included_user_ids:s,excluded_user_ids:o,keyword:i,offset:n,amount:r,scope:a}).then(u=>u.data).catch(u=>{throw[400,404].indexOf(rd(u))>-1?new Error(this.toI18N(ke.http.NOT_FOUND)):this.throwHTTPError(u)}))()}}const fk=j.createContext(null),kn=()=>{const t=j.useContext(fk);if(!t)throw new Error("usePostBuilder must be used within PostBuilderProvider");return t},wi=()=>{const{api:t}=kn();return t};function ae(t,e,{checkForDefaultPrevented:n=!0}={}){return function(o){if(t?.(o),n===!1||!o.defaultPrevented)return e?.(o)}}function L2(t,e){const n=w.createContext(e),r=s=>{const{children:i,...a}=s,l=w.useMemo(()=>a,Object.values(a));return y.jsx(n.Provider,{value:l,children:i})};r.displayName=t+"Provider";function o(s){const i=w.useContext(n);if(i)return i;if(e!==void 0)return e;throw new Error(`\`${s}\` must be used within \`${t}\``)}return[r,o]}function Pr(t,e=[]){let n=[];function r(s,i){const a=w.createContext(i),l=n.length;n=[...n,i];const c=d=>{const{scope:f,children:h,...p}=d,m=f?.[t]?.[l]||a,g=w.useMemo(()=>p,Object.values(p));return y.jsx(m.Provider,{value:g,children:h})};c.displayName=s+"Provider";function u(d,f){const h=f?.[t]?.[l]||a,p=w.useContext(h);if(p)return p;if(i!==void 0)return i;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[c,u]}const o=()=>{const s=n.map(i=>w.createContext(i));return function(a){const l=a?.[t]||s;return w.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return o.scopeName=t,[r,j2(o,...e)]}function j2(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const d=l(s)[`__scope${c}`];return{...a,...d}},{});return w.useMemo(()=>({[`__scope${e.scopeName}`]:i}),[i])}};return n.scopeName=e.scopeName,n}function F0(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function ao(...t){return e=>{let n=!1;const r=t.map(o=>{const s=F0(o,e);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let o=0;o<r.length;o++){const s=r[o];typeof s=="function"?s():F0(t[o],null)}}}}function Ze(...t){return w.useCallback(ao(...t),t)}function U0(t){const e=$2(t),n=w.forwardRef((r,o)=>{const{children:s,...i}=r,a=w.Children.toArray(s),l=a.find(U2);if(l){const c=l.props.children,u=a.map(d=>d===l?w.Children.count(c)>1?w.Children.only(null):w.isValidElement(c)?c.props.children:null:d);return y.jsx(e,{...i,ref:o,children:w.isValidElement(c)?w.cloneElement(c,void 0,u):null})}return y.jsx(e,{...i,ref:o,children:s})});return n.displayName=`${t}.Slot`,n}function $2(t){const e=w.forwardRef((n,r)=>{const{children:o,...s}=n;if(w.isValidElement(o)){const i=z2(o),a=B2(s,o.props);return o.type!==w.Fragment&&(a.ref=r?ao(r,i):i),w.cloneElement(o,a)}return w.Children.count(o)>1?w.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var F2=Symbol("radix.slottable");function U2(t){return w.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===F2}function B2(t,e){const n={...e};for(const r in e){const o=t[r],s=e[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{const l=s(...a);return o(...a),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...t,...n}}function z2(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function Ay(t){const e=t+"CollectionProvider",[n,r]=Pr(e),[o,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),i=m=>{const{scope:g,children:b}=m,S=w.default.useRef(null),k=w.default.useRef(new Map).current;return y.jsx(o,{scope:g,itemMap:k,collectionRef:S,children:b})};i.displayName=e;const a=t+"CollectionSlot",l=U0(a),c=w.default.forwardRef((m,g)=>{const{scope:b,children:S}=m,k=s(a,b),v=Ze(g,k.collectionRef);return y.jsx(l,{ref:v,children:S})});c.displayName=a;const u=t+"CollectionItemSlot",d="data-radix-collection-item",f=U0(u),h=w.default.forwardRef((m,g)=>{const{scope:b,children:S,...k}=m,v=w.default.useRef(null),_=Ze(g,v),x=s(u,b);return w.default.useEffect(()=>(x.itemMap.set(v,{ref:v,...k}),()=>{x.itemMap.delete(v)})),y.jsx(f,{[d]:"",ref:_,children:S})});h.displayName=u;function p(m){const g=s(t+"CollectionConsumer",m);return w.default.useCallback(()=>{const S=g.collectionRef.current;if(!S)return[];const k=Array.from(S.querySelectorAll(`[${d}]`));return Array.from(g.itemMap.values()).sort((x,A)=>k.indexOf(x.ref.current)-k.indexOf(A.ref.current))},[g.collectionRef,g.itemMap])}return[{Provider:i,Slot:c,ItemSlot:h},p,r]}var Pt=globalThis?.document?w.useLayoutEffect:()=>{},H2=w[" useId ".trim().toString()]||(()=>{}),V2=0;function sr(t){const[e,n]=w.useState(H2());return Pt(()=>{n(r=>r??String(V2++))},[t]),e?`radix-${e}`:""}function W2(t){const e=K2(t),n=w.forwardRef((r,o)=>{const{children:s,...i}=r,a=w.Children.toArray(s),l=a.find(q2);if(l){const c=l.props.children,u=a.map(d=>d===l?w.Children.count(c)>1?w.Children.only(null):w.isValidElement(c)?c.props.children:null:d);return y.jsx(e,{...i,ref:o,children:w.isValidElement(c)?w.cloneElement(c,void 0,u):null})}return y.jsx(e,{...i,ref:o,children:s})});return n.displayName=`${t}.Slot`,n}function K2(t){const e=w.forwardRef((n,r)=>{const{children:o,...s}=n;if(w.isValidElement(o)){const i=J2(o),a=Y2(s,o.props);return o.type!==w.Fragment&&(a.ref=r?ao(r,i):i),w.cloneElement(o,a)}return w.Children.count(o)>1?w.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var G2=Symbol("radix.slottable");function q2(t){return w.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===G2}function Y2(t,e){const n={...e};for(const r in e){const o=t[r],s=e[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{const l=s(...a);return o(...a),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...t,...n}}function J2(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var X2=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Oe=X2.reduce((t,e)=>{const n=W2(`Primitive.${e}`),r=w.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function hk(t,e){t&&vi.flushSync(()=>t.dispatchEvent(e))}function Ar(t){const e=w.useRef(t);return w.useEffect(()=>{e.current=t}),w.useMemo(()=>(...n)=>e.current?.(...n),[])}var Q2=w[" useInsertionEffect ".trim().toString()]||Pt;function Ro({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[o,s,i]=Z2({defaultProp:e,onChange:n}),a=t!==void 0,l=a?t:o;{const u=w.useRef(t!==void 0);w.useEffect(()=>{const d=u.current;if(d!==a){const f=d?"controlled":"uncontrolled",h=a?"controlled":"uncontrolled"}u.current=a},[a,r])}const c=w.useCallback(u=>{if(a){const d=ej(u)?u(t):u;d!==t&&i.current?.(d)}else s(u)},[a,t,s,i]);return[l,c]}function Z2({defaultProp:t,onChange:e}){const[n,r]=w.useState(t),o=w.useRef(n),s=w.useRef(e);return Q2(()=>{s.current=e},[e]),w.useEffect(()=>{o.current!==n&&(s.current?.(n),o.current=n)},[n,o]),[n,r,s]}function ej(t){return typeof t=="function"}var tj=w.createContext(void 0);function $f(t){const e=w.useContext(tj);return t||e||"ltr"}var ip="rovingFocusGroup.onEntryFocus",nj={bubbles:!1,cancelable:!0},Sc="RovingFocusGroup",[Dm,pk,rj]=Ay(Sc),[oj,Ff]=Pr(Sc,[rj]),[sj,ij]=oj(Sc),mk=w.forwardRef((t,e)=>y.jsx(Dm.Provider,{scope:t.__scopeRovingFocusGroup,children:y.jsx(Dm.Slot,{scope:t.__scopeRovingFocusGroup,children:y.jsx(aj,{...t,ref:e})})}));mk.displayName=Sc;var aj=w.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:i,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...d}=t,f=w.useRef(null),h=Ze(e,f),p=$f(s),[m,g]=Ro({prop:i,defaultProp:a??null,onChange:l,caller:Sc}),[b,S]=w.useState(!1),k=Ar(c),v=pk(n),_=w.useRef(!1),[x,A]=w.useState(0);return w.useEffect(()=>{const E=f.current;if(E)return E.addEventListener(ip,k),()=>E.removeEventListener(ip,k)},[k]),y.jsx(sj,{scope:n,orientation:r,dir:p,loop:o,currentTabStopId:m,onItemFocus:w.useCallback(E=>g(E),[g]),onItemShiftTab:w.useCallback(()=>S(!0),[]),onFocusableItemAdd:w.useCallback(()=>A(E=>E+1),[]),onFocusableItemRemove:w.useCallback(()=>A(E=>E-1),[]),children:y.jsx(Oe.div,{tabIndex:b||x===0?-1:0,"data-orientation":r,...d,ref:h,style:{outline:"none",...t.style},onMouseDown:ae(t.onMouseDown,()=>{_.current=!0}),onFocus:ae(t.onFocus,E=>{const T=!_.current;if(E.target===E.currentTarget&&T&&!b){const N=new CustomEvent(ip,nj);if(E.currentTarget.dispatchEvent(N),!N.defaultPrevented){const I=v().filter(C=>C.focusable),R=I.find(C=>C.active),D=I.find(C=>C.id===m),P=[R,D,...I].filter(Boolean).map(C=>C.ref.current);bk(P,u)}}_.current=!1}),onBlur:ae(t.onBlur,()=>S(!1))})})}),gk="RovingFocusGroupItem",yk=w.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=t,l=sr(),c=s||l,u=ij(gk,n),d=u.currentTabStopId===c,f=pk(n),{onFocusableItemAdd:h,onFocusableItemRemove:p,currentTabStopId:m}=u;return w.useEffect(()=>{if(r)return h(),()=>p()},[r,h,p]),y.jsx(Dm.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:y.jsx(Oe.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...a,ref:e,onMouseDown:ae(t.onMouseDown,g=>{r?u.onItemFocus(c):g.preventDefault()}),onFocus:ae(t.onFocus,()=>u.onItemFocus(c)),onKeyDown:ae(t.onKeyDown,g=>{if(g.key==="Tab"&&g.shiftKey){u.onItemShiftTab();return}if(g.target!==g.currentTarget)return;const b=uj(g,u.orientation,u.dir);if(b!==void 0){if(g.metaKey||g.ctrlKey||g.altKey||g.shiftKey)return;g.preventDefault();let k=f().filter(v=>v.focusable).map(v=>v.ref.current);if(b==="last")k.reverse();else if(b==="prev"||b==="next"){b==="prev"&&k.reverse();const v=k.indexOf(g.currentTarget);k=u.loop?dj(k,v+1):k.slice(v+1)}setTimeout(()=>bk(k))}}),children:typeof i=="function"?i({isCurrentTabStop:d,hasTabStop:m!=null}):i})})});yk.displayName=gk;var lj={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function cj(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function uj(t,e,n){const r=cj(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return lj[r]}function bk(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function dj(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var vk=mk,wk=yk;function fj(t,e){return w.useReducer((n,r)=>e[n][r]??n,t)}var Jn=t=>{const{present:e,children:n}=t,r=hj(e),o=typeof n=="function"?n({present:r.isPresent}):w.Children.only(n),s=Ze(r.ref,pj(o));return typeof n=="function"||r.isPresent?w.cloneElement(o,{ref:s}):null};Jn.displayName="Presence";function hj(t){const[e,n]=w.useState(),r=w.useRef(null),o=w.useRef(t),s=w.useRef("none"),i=t?"mounted":"unmounted",[a,l]=fj(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return w.useEffect(()=>{const c=Qc(r.current);s.current=a==="mounted"?c:"none"},[a]),Pt(()=>{const c=r.current,u=o.current;if(u!==t){const f=s.current,h=Qc(c);t?l("MOUNT"):h==="none"||c?.display==="none"?l("UNMOUNT"):l(u&&f!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=t}},[t,l]),Pt(()=>{if(e){let c;const u=e.ownerDocument.defaultView??window,d=h=>{const m=Qc(r.current).includes(CSS.escape(h.animationName));if(h.target===e&&m&&(l("ANIMATION_END"),!o.current)){const g=e.style.animationFillMode;e.style.animationFillMode="forwards",c=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=g)})}},f=h=>{h.target===e&&(s.current=Qc(r.current))};return e.addEventListener("animationstart",f),e.addEventListener("animationcancel",d),e.addEventListener("animationend",d),()=>{u.clearTimeout(c),e.removeEventListener("animationstart",f),e.removeEventListener("animationcancel",d),e.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:w.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function Qc(t){return t?.animationName||"none"}function pj(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Uf="Tabs",[mj]=Pr(Uf,[Ff]),xk=Ff(),[gj,_y]=mj(Uf),Ek=w.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:s,orientation:i="horizontal",dir:a,activationMode:l="automatic",...c}=t,u=$f(a),[d,f]=Ro({prop:r,onChange:o,defaultProp:s??"",caller:Uf});return y.jsx(gj,{scope:n,baseId:sr(),value:d,onValueChange:f,orientation:i,dir:u,activationMode:l,children:y.jsx(Oe.div,{dir:u,"data-orientation":i,...c,ref:e})})});Ek.displayName=Uf;var Sk="TabsList",kk=w.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...o}=t,s=_y(Sk,n),i=xk(n);return y.jsx(vk,{asChild:!0,...i,orientation:s.orientation,dir:s.dir,loop:r,children:y.jsx(Oe.div,{role:"tablist","aria-orientation":s.orientation,...o,ref:e})})});kk.displayName=Sk;var Tk="TabsTrigger",Ck=w.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...s}=t,i=_y(Tk,n),a=xk(n),l=Mk(i.baseId,r),c=Ok(i.baseId,r),u=r===i.value;return y.jsx(wk,{asChild:!0,...a,focusable:!o,active:u,children:y.jsx(Oe.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":c,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l,...s,ref:e,onMouseDown:ae(t.onMouseDown,d=>{!o&&d.button===0&&d.ctrlKey===!1?i.onValueChange(r):d.preventDefault()}),onKeyDown:ae(t.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&i.onValueChange(r)}),onFocus:ae(t.onFocus,()=>{const d=i.activationMode!=="manual";!u&&!o&&d&&i.onValueChange(r)})})})});Ck.displayName=Tk;var Ak="TabsContent",_k=w.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:o,children:s,...i}=t,a=_y(Ak,n),l=Mk(a.baseId,r),c=Ok(a.baseId,r),u=r===a.value,d=w.useRef(u);return w.useEffect(()=>{const f=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(f)},[]),y.jsx(Jn,{present:o||u,children:({present:f})=>y.jsx(Oe.div,{"data-state":u?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":l,hidden:!f,id:c,tabIndex:0,...i,ref:e,style:{...t.style,animationDuration:d.current?"0s":void 0},children:f&&s})})});_k.displayName=Ak;function Mk(t,e){return`${t}-trigger-${e}`}function Ok(t,e){return`${t}-content-${e}`}var yj=Ek,bj=kk,vj=Ck,wj=_k;function Jt(t){this.content=t}Jt.prototype={constructor:Jt,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,o=r.find(t),s=r.content.slice();return o==-1?s.push(n||t,e):(s[o+1]=e,n&&(s[o]=n)),new Jt(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Jt(n)},addToStart:function(t,e){return new Jt([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Jt(n)},addBefore:function(t,e,n){var r=this.remove(e),o=r.content.slice(),s=r.find(t);return o.splice(s==-1?o.length:s,0,e,n),new Jt(o)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Jt.from(t),t.size?new Jt(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Jt.from(t),t.size?new Jt(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Jt.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Jt.from=function(t){if(t instanceof Jt)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Jt(e)};function Rk(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let o=t.child(r),s=e.child(r);if(o==s){n+=o.nodeSize;continue}if(!o.sameMarkup(s))return n;if(o.isText&&o.text!=s.text){for(let i=0;o.text[i]==s.text[i];i++)n++;return n}if(o.content.size||s.content.size){let i=Rk(o.content,s.content,n+1);if(i!=null)return i}n+=o.nodeSize}}function Nk(t,e,n,r){for(let o=t.childCount,s=e.childCount;;){if(o==0||s==0)return o==s?null:{a:n,b:r};let i=t.child(--o),a=e.child(--s),l=i.nodeSize;if(i==a){n-=l,r-=l;continue}if(!i.sameMarkup(a))return{a:n,b:r};if(i.isText&&i.text!=a.text){let c=0,u=Math.min(i.text.length,a.text.length);for(;c<u&&i.text[i.text.length-c-1]==a.text[a.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(i.content.size||a.content.size){let c=Nk(i.content,a.content,n-1,r-1);if(c)return c}n-=l,r-=l}}class X{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,o=0,s){for(let i=0,a=0;a<n;i++){let l=this.content[i],c=a+l.nodeSize;if(c>e&&r(l,o+a,s||null,i)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,e-u),Math.min(l.content.size,n-u),r,o+u)}a=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,o){let s="",i=!0;return this.nodesBetween(e,n,(a,l)=>{let c=a.isText?a.text.slice(Math.max(e,l)-l,n-l):a.isLeaf?o?typeof o=="function"?o(a):o:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&c||a.isTextblock)&&r&&(i?i=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,o=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)o.push(e.content[s]);return new X(o,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],o=0;if(n>e)for(let s=0,i=0;i<n;s++){let a=this.content[s],l=i+a.nodeSize;l>e&&((i<e||l>n)&&(a.isText?a=a.cut(Math.max(0,e-i),Math.min(a.text.length,n-i)):a=a.cut(Math.max(0,e-i-1),Math.min(a.content.size,n-i-1))),r.push(a),o+=a.nodeSize),i=l}return new X(r,o)}cutByIndex(e,n){return e==n?X.empty:e==0&&n==this.content.length?this:new X(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let o=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return o[e]=n,new X(o,s)}addToStart(e){return new X([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new X(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let o=this.content[n];e(o,r,n),r+=o.nodeSize}}findDiffStart(e,n=0){return Rk(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Nk(this,e,n,r)}findIndex(e){if(e==0)return Zc(0,e);if(e==this.size)return Zc(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=this.child(n),s=r+o.nodeSize;if(s>=e)return s==e?Zc(n+1,s):Zc(n,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return X.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new X(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return X.empty;let n,r=0;for(let o=0;o<e.length;o++){let s=e[o];r+=s.nodeSize,o&&s.isText&&e[o-1].sameMarkup(s)?(n||(n=e.slice(0,o)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new X(n||e,r)}static from(e){if(!e)return X.empty;if(e instanceof X)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new X([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}X.empty=new X([],0);const ap={index:0,offset:0};function Zc(t,e){return ap.index=t,ap.offset=e,ap}function id(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!id(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!id(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let ut=class Pm{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let o=0;o<e.length;o++){let s=e[o];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,o));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,o)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&id(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let o=r.create(n.attrs);return r.checkAttrs(o.attrs),o}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Pm.none;if(e instanceof Pm)return[e];let n=e.slice();return n.sort((r,o)=>r.type.rank-o.type.rank),n}};ut.none=[];class ad extends Error{}class ie{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=Dk(this.content,e+this.openStart,n);return r&&new ie(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ie(Ik(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ie.empty;let r=n.openStart||0,o=n.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ie(X.fromJSON(e,n.content),r,o)}static maxOpen(e,n=!0){let r=0,o=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)o++;return new ie(e,r,o)}}ie.empty=new ie(X.empty,0,0);function Ik(t,e,n){let{index:r,offset:o}=t.findIndex(e),s=t.maybeChild(r),{index:i,offset:a}=t.findIndex(n);if(o==e||s.isText){if(a!=n&&!t.child(i).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=i)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(Ik(s.content,e-o-1,n-o-1)))}function Dk(t,e,n,r){let{index:o,offset:s}=t.findIndex(e),i=t.maybeChild(o);if(s==e||i.isText)return r&&!r.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=Dk(i.content,e-s-1,n,i);return a&&t.replaceChild(o,i.copy(a))}function xj(t,e,n){if(n.openStart>t.depth)throw new ad("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new ad("Inconsistent open depths");return Pk(t,e,n,0)}function Pk(t,e,n,r){let o=t.index(r),s=t.node(r);if(o==e.index(r)&&r<t.depth-n.openStart){let i=Pk(t,e,n,r+1);return s.copy(s.content.replaceChild(o,i))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let i=t.parent,a=i.content;return Ys(i,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:i,end:a}=Ej(n,t);return Ys(s,jk(t,i,a,e,r))}else return Ys(s,ld(t,e,r))}function Lk(t,e){if(!e.type.compatibleContent(t.type))throw new ad("Cannot join "+e.type.name+" onto "+t.type.name)}function Lm(t,e,n){let r=t.node(n);return Lk(r,e.node(n)),r}function qs(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function gl(t,e,n,r){let o=(e||t).node(n),s=0,i=e?e.index(n):o.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(qs(t.nodeAfter,r),s++));for(let a=s;a<i;a++)qs(o.child(a),r);e&&e.depth==n&&e.textOffset&&qs(e.nodeBefore,r)}function Ys(t,e){return t.type.checkContent(e),t.copy(e)}function jk(t,e,n,r,o){let s=t.depth>o&&Lm(t,e,o+1),i=r.depth>o&&Lm(n,r,o+1),a=[];return gl(null,t,o,a),s&&i&&e.index(o)==n.index(o)?(Lk(s,i),qs(Ys(s,jk(t,e,n,r,o+1)),a)):(s&&qs(Ys(s,ld(t,e,o+1)),a),gl(e,n,o,a),i&&qs(Ys(i,ld(n,r,o+1)),a)),gl(r,null,o,a),new X(a)}function ld(t,e,n){let r=[];if(gl(null,t,n,r),t.depth>n){let o=Lm(t,e,n+1);qs(Ys(o,ld(t,e,n+1)),r)}return gl(e,null,n,r),new X(r)}function Ej(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)o=e.node(s).copy(X.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}class jl{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(n);return r?e.child(n).cut(r):o}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],o=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)o+=r.child(s).nodeSize;return o}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return ut.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),o=e.maybeChild(n);if(!r){let a=r;r=o,o=a}let s=r.marks;for(var i=0;i<s.length;i++)s[i].type.spec.inclusive===!1&&(!o||!s[i].isInSet(o.marks))&&(s=s[i--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,o=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!o||!r[s].isInSet(o.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new $l(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],o=0,s=n;for(let i=e;;){let{index:a,offset:l}=i.content.findIndex(s),c=s-l;if(r.push(i,a,o+l),!c||(i=i.child(a),i.isText))break;s=c-1,o+=l+1}return new jl(n,r,s)}static resolveCached(e,n){let r=B0.get(e);if(r)for(let s=0;s<r.elts.length;s++){let i=r.elts[s];if(i.pos==n)return i}else B0.set(e,r=new Sj);let o=r.elts[r.i]=jl.resolve(e,n);return r.i=(r.i+1)%kj,o}}class Sj{constructor(){this.elts=[],this.i=0}}const kj=12,B0=new WeakMap;class $l{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Tj=Object.create(null);let ko=class jm{constructor(e,n,r,o=ut.none){this.type=e,this.attrs=n,this.marks=o,this.content=r||X.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,o=0){this.content.nodesBetween(e,n,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,o){return this.content.textBetween(e,n,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&id(this.attrs,n||e.defaultAttrs||Tj)&&ut.sameSet(this.marks,r||ut.none)}copy(e=null){return e==this.content?this:new jm(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new jm(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return ie.empty;let o=this.resolve(e),s=this.resolve(n),i=r?0:o.sharedDepth(n),a=o.start(i),c=o.node(i).content.cut(o.pos-a,s.pos-a);return new ie(c,o.depth-i,s.depth-i)}replace(e,n,r){return xj(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:o}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(o==e||n.isText)return n;e-=o+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let o=this.content.child(n-1);return{node:o,index:n-1,offset:r-o.nodeSize}}resolve(e){return jl.resolveCached(this,e)}resolveNoCache(e){return jl.resolve(this,e)}rangeHasMark(e,n,r){let o=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(o=!0),!o)),o}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()+")"),$k(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=X.empty,o=0,s=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,o,s),a=i&&i.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let l=o;l<s;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,o){if(o&&!this.type.allowsMarks(o))return!1;let s=this.contentMatchAt(e).matchType(r),i=s&&s.matchFragment(this.content,n);return i?i.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=ut.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!ut.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let o=X.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,o,r);return s.type.checkAttrs(s.attrs),s}};ko.prototype.text=void 0;class cd extends ko{constructor(e,n,r,o){if(super(e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):$k(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new cd(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new cd(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function $k(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class ri{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Cj(e,n);if(r.next==null)return ri.empty;let o=Fk(r);r.next&&r.err("Unexpected trailing text");let s=Ij(Nj(o));return Dj(s,r),s}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let o=this;for(let s=n;o&&s<r;s++)o=o.matchType(e.child(s).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let o=[this];function s(i,a){let l=i.matchFragment(e,r);if(l&&(!n||l.validEnd))return X.from(a.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:d}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(d)==-1){o.push(d);let f=s(d,a.concat(u));if(f)return f}}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 n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),s=o.match;if(s.matchType(e)){let i=[];for(let a=o;a.type;a=a.via)i.push(a.type);return i.reverse()}for(let i=0;i<s.next.length;i++){let{type:a,next:l}=s.next[i];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in n)&&(!o.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:o}),n[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&n(r.next[o].next)}return n(this),e.map((r,o)=>{let s=o+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)s+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return s}).join(`
7
- `)}}ri.empty=new ri(!0);class Cj{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Fk(t){let e=[];do e.push(Aj(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Aj(t){let e=[];do e.push(_j(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function _j(t){let e=Rj(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=Mj(t,e);else break;return e}function z0(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Mj(t,e){let n=z0(t),r=n;return t.eat(",")&&(t.next!="}"?r=z0(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Oj(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let o=[];for(let s in n){let i=n[s];i.isInGroup(e)&&o.push(i)}return o.length==0&&t.err("No node type or group '"+e+"' found"),o}function Rj(t){if(t.eat("(")){let e=Fk(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=Oj(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Nj(t){let e=[[]];return o(s(t,0),n()),e;function n(){return e.push([])-1}function r(i,a,l){let c={term:l,to:a};return e[i].push(c),c}function o(i,a){i.forEach(l=>l.to=a)}function s(i,a){if(i.type=="choice")return i.exprs.reduce((l,c)=>l.concat(s(c,a)),[]);if(i.type=="seq")for(let l=0;;l++){let c=s(i.exprs[l],a);if(l==i.exprs.length-1)return c;o(c,a=n())}else if(i.type=="star"){let l=n();return r(a,l),o(s(i.expr,l),l),[r(l)]}else if(i.type=="plus"){let l=n();return o(s(i.expr,a),l),o(s(i.expr,l),l),[r(l)]}else{if(i.type=="opt")return[r(a)].concat(s(i.expr,a));if(i.type=="range"){let l=a;for(let c=0;c<i.min;c++){let u=n();o(s(i.expr,l),u),l=u}if(i.max==-1)o(s(i.expr,l),l);else for(let c=i.min;c<i.max;c++){let u=n();r(l,u),o(s(i.expr,l),u),l=u}return[r(l)]}else{if(i.type=="name")return[r(a,void 0,i.value)];throw new Error("Unknown expr type")}}}}function Uk(t,e){return e-t}function H0(t,e){let n=[];return r(e),n.sort(Uk);function r(o){let s=t[o];if(s.length==1&&!s[0].term)return r(s[0].to);n.push(o);for(let i=0;i<s.length;i++){let{term:a,to:l}=s[i];!a&&n.indexOf(l)==-1&&r(l)}}}function Ij(t){let e=Object.create(null);return n(H0(t,0));function n(r){let o=[];r.forEach(i=>{t[i].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let u=0;u<o.length;u++)o[u][0]==a&&(c=o[u][1]);H0(t,l).forEach(u=>{c||o.push([a,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new ri(r.indexOf(t.length-1)>-1);for(let i=0;i<o.length;i++){let a=o[i][1].sort(Uk);s.next.push({type:o[i][0],next:e[a.join(",")]||n(a)})}return s}}function Dj(t,e){for(let n=0,r=[t];n<r.length;n++){let o=r[n],s=!o.validEnd,i=[];for(let a=0;a<o.next.length;a++){let{type:l,next:c}=o.next[a];i.push(l.name),s&&!(l.isText||l.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Bk(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function zk(t,e){let n=Object.create(null);for(let r in t){let o=e&&e[r];if(o===void 0){let s=t[r];if(s.hasDefault)o=s.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=o}return n}function Hk(t,e,n,r){for(let o in e)if(!(o in t))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${o}`);for(let o in t){let s=t[o];s.validate&&s.validate(e[o])}}function Vk(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new Lj(t,r,e[r]);return n}let V0=class Wk{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Vk(e,r.attrs),this.defaultAttrs=Bk(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==ri.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:zk(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ko(this,this.computeAttrs(e),X.from(n),ut.setFrom(r))}createChecked(e=null,n,r){return n=X.from(n),this.checkContent(n),new ko(this,this.computeAttrs(e),n,ut.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=X.from(n),n.size){let i=this.contentMatch.fillBefore(n);if(!i)return null;n=i.append(n)}let o=this.contentMatch.matchFragment(n),s=o&&o.fillBefore(X.empty,!0);return s?new ko(this,e,n.append(s),ut.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Hk(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 n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:ut.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,i)=>r[s]=new Wk(s,n,i));let o=n.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");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 Pj(t,e,n){let r=n.split("|");return o=>{let s=o===null?"null":typeof o;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${s}`)}}class Lj{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Pj(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Bf{constructor(e,n,r,o){this.name=e,this.rank=n,this.schema=r,this.spec=o,this.attrs=Vk(e,o.attrs),this.excluded=null;let s=Bk(this.attrs);this.instance=s?new ut(this,s):null}create(e=null){return!e&&this.instance?this.instance:new ut(this,zk(this.attrs,e))}static compile(e,n){let r=Object.create(null),o=0;return e.forEach((s,i)=>r[s]=new Bf(s,o++,n,i)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){Hk(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}let Kk=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let o in e)n[o]=e[o];n.nodes=Jt.from(e.nodes),n.marks=Jt.from(e.marks||{}),this.nodes=V0.compile(this.spec.nodes,this),this.marks=Bf.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let s=this.nodes[o],i=s.spec.content||"",a=s.spec.marks;if(s.contentMatch=r[i]||(r[i]=ri.parse(i,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=a=="_"?null:a?W0(this,a.split(" ")):a==""||!s.inlineContent?[]:null}for(let o in this.marks){let s=this.marks[o],i=s.spec.excludes;s.excluded=i==null?[s]:i==""?[]:W0(this,i.split(" "))}this.nodeFromJSON=o=>ko.fromJSON(this,o),this.markFromJSON=o=>ut.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof V0){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,o)}text(e,n){let r=this.nodes.text;return new cd(r,r.defaultAttrs,e,ut.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function W0(t,e){let n=[];for(let r=0;r<e.length;r++){let o=e[r],s=t.marks[o],i=s;if(s)n.push(s);else for(let a in t.marks){let l=t.marks[a];(o=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(o)>-1)&&n.push(i=l)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function jj(t){return t.tag!=null}function $j(t){return t.style!=null}let yl=class $m{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(o=>{if(jj(o))this.tags.push(o);else if($j(o)){let s=/[^=]*/.exec(o.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let s=e.nodes[o.node];return s.contentMatch.matchType(s)})}parse(e,n={}){let r=new G0(this,n,!1);return r.addAll(e,ut.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new G0(this,n,!0);return r.addAll(e,ut.none,n.from,n.to),ie.maxOpen(r.finish())}matchTag(e,n,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let s=this.tags[o];if(Bj(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let i=s.getAttrs(e);if(i===!1)continue;s.attrs=i||void 0}return s}}}matchStyle(e,n,r,o){for(let s=o?this.styles.indexOf(o)+1:0;s<this.styles.length;s++){let i=this.styles[s],a=i.style;if(!(a.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=n))){if(i.getAttrs){let l=i.getAttrs(n);if(l===!1)continue;i.attrs=l||void 0}return i}}}static schemaRules(e){let n=[];function r(o){let s=o.priority==null?50:o.priority,i=0;for(;i<n.length;i++){let a=n[i];if((a.priority==null?50:a.priority)<s)break}n.splice(i,0,o)}for(let o in e.marks){let s=e.marks[o].spec.parseDOM;s&&s.forEach(i=>{r(i=q0(i)),i.mark||i.ignore||i.clearMark||(i.mark=o)})}for(let o in e.nodes){let s=e.nodes[o].spec.parseDOM;s&&s.forEach(i=>{r(i=q0(i)),i.node||i.ignore||i.mark||(i.node=o)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new $m(e,$m.schemaRules(e)))}};const Gk={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},Fj={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},qk={ol:!0,ul:!0},Fl=1,Fm=2,bl=4;function K0(t,e,n){return e!=null?(e?Fl:0)|(e==="full"?Fm:0):t&&t.whitespace=="pre"?Fl|Fm:n&~bl}class eu{constructor(e,n,r,o,s,i){this.type=e,this.attrs=n,this.marks=r,this.solid=o,this.options=i,this.content=[],this.activeMarks=ut.none,this.match=s||(i&bl?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(X.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Fl)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-o[0].length))}}let n=X.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(X.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Gk.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class G0{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=n.topNode,s,i=K0(null,n.preserveWhitespace,0)|(r?bl:0);o?s=new eu(o.type,o.attrs,ut.none,!0,n.topMatch||o.type.contentMatch,i):r?s=new eu(null,null,ut.none,!0,null,i):s=new eu(e.schema.topNodeType,null,ut.none,!0,null,i),this.nodes=[s],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,o=this.top,s=o.options&Fm?"full":this.localPreserveWS||(o.options&Fl)>0,{schema:i}=this.parser;if(s==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
8
- `);else if(i.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(i.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(i.linebreakReplacement.create(),n,!0),a[l]&&this.insertNode(i.text(a[l]),n,!/\S/.test(a[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let a=o.content[o.content.length-1],l=e.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(i.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let o=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),a;qk.hasOwnProperty(i)&&this.parser.normalizeLists&&Uj(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:Fj.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let c,u=this.needsBlock;if(Gk.hasOwnProperty(i))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=l&&l.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(s),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,l,c,l.consuming===!1?a:void 0)}this.localPreserveWS=o}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
9
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let s=this.parser.matchedStyles[o],i=r.getPropertyValue(s);if(i)for(let a=void 0;;){let l=this.parser.matchStyle(s,i,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(c=>!l.clearMark(c)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return n}addElementByRule(e,n,r,o){let s,i;if(n.node)if(i=this.parser.schema.nodes[n.node],i.isLeaf)this.insertNode(i.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(i,n.attrs||null,r,n.preserveWhitespace);l&&(s=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let a=this.top;if(i&&i.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}s&&this.sync(a)&&this.open--}addAll(e,n,r,o){let s=r||0;for(let i=r?e.childNodes[r]:e.firstChild,a=o==null?null:e.childNodes[o];i!=a;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i,n);this.findAtPoint(e,s)}findPlace(e,n,r){let o,s;for(let i=this.open,a=0;i>=0;i--){let l=this.nodes[i],c=l.findWrapping(e);if(c&&(!o||o.length>c.length+a)&&(o=c,s=l,!c.length))break;if(l.solid){if(r)break;a+=2}}if(!o)return null;this.sync(s);for(let i=0;i<o.length;i++)n=this.enterInner(o[i],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(n=this.enterInner(s,null,n))}let o=this.findPlace(e,n,r);if(o){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let i=ut.none;for(let a of o.concat(e.marks))(s.type?s.type.allowsMarkType(a.type):Y0(a.type,e.type))&&(i=a.addToSet(i));return s.content.push(e.mark(i)),!0}return!1}enter(e,n,r,o){let s=this.findPlace(e.create(n),r,!1);return s&&(s=this.enterInner(e,n,r,!0,o)),s}enterInner(e,n,r,o=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let a=K0(e,s,i.options);i.options&bl&&i.content.length==0&&(a|=bl);let l=ut.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):Y0(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new eu(e,n,l,o,null,a)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Fl)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&n.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(o?0:1),i=(a,l)=>{for(;a>=0;a--){let c=n[a];if(c==""){if(a==n.length-1||a==0)continue;for(;l>=s;l--)if(i(a-1,l))return!0;return!1}else{let u=l>0||l==0&&o?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;l--}}return!0};return i(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function Uj(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&qk.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Bj(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function q0(t){let e={};for(let n in t)e[n]=t[n];return e}function Y0(t,e){let n=e.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(t))continue;let s=[],i=a=>{s.push(a);for(let l=0;l<a.edgeCount;l++){let{type:c,next:u}=a.edge(l);if(c==e||s.indexOf(u)<0&&i(u))return!0}};if(i(o.contentMatch))return!0}}class xi{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=lp(n).createDocumentFragment());let o=r,s=[];return e.forEach(i=>{if(s.length||i.marks.length){let a=0,l=0;for(;a<s.length&&l<i.marks.length;){let c=i.marks[l];if(!this.marks[c.type.name]){l++;continue}if(!c.eq(s[a][0])||c.type.spec.spanning===!1)break;a++,l++}for(;a<s.length;)o=s.pop()[1];for(;l<i.marks.length;){let c=i.marks[l++],u=this.serializeMark(c,i.isInline,n);u&&(s.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(i,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:o}=Pu(lp(n),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,o)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let o=e.marks.length-1;o>=0;o--){let s=this.serializeMark(e.marks[o],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let o=this.marks[e.type.name];return o&&Pu(lp(r),o(e,n),null,e.attrs)}static renderSpec(e,n,r=null,o){return Pu(e,n,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new xi(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=J0(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return J0(e.marks)}}function J0(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function lp(t){return t.document||window.document}const X0=new WeakMap;function zj(t){let e=X0.get(t);return e===void 0&&X0.set(t,e=Hj(t)),e}function Hj(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)n(r[o]);else for(let o in r)n(r[o])}return n(t),e}function Pu(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let o=e[0],s;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=zj(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 i=o.indexOf(" ");i>0&&(n=o.slice(0,i),o=o.slice(i+1));let a,l=n?t.createElementNS(n,o):t.createElement(o),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?l.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&l.style?l.style.cssText=c[d]:l.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:h,contentDOM:p}=Pu(t,f,n,r);if(l.appendChild(h),p){if(a)throw new RangeError("Multiple content holes");a=p}}}return{dom:l,contentDOM:a}}const Yk=65535,Jk=Math.pow(2,16);function Vj(t,e){return t+e*Jk}function Q0(t){return t&Yk}function Wj(t){return(t-(t&Yk))/Jk}const Xk=1,Qk=2,Lu=4,Zk=8;class Um{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Zk)>0}get deletedBefore(){return(this.delInfo&(Xk|Lu))>0}get deletedAfter(){return(this.delInfo&(Qk|Lu))>0}get deletedAcross(){return(this.delInfo&Lu)>0}}class Wn{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Wn.empty)return Wn.empty}recover(e){let n=0,r=Q0(e);if(!this.inverted)for(let o=0;o<r;o++)n+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+n+Wj(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let o=0,s=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?o:0);if(l>e)break;let c=this.ranges[a+s],u=this.ranges[a+i],d=l+c;if(e<=d){let f=c?e==l?-1:e==d?1:n:n,h=l+o+(f<0?0:u);if(r)return h;let p=e==(n<0?l:d)?null:Vj(a/3,e-l),m=e==l?Qk:e==d?Xk:Lu;return(n<0?e!=l:e!=d)&&(m|=Zk),new Um(h,m,p)}o+=u-c}return r?e+o:new Um(e+o,0,null)}touches(e,n){let r=0,o=Q0(n),s=this.inverted?2:1,i=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let c=this.ranges[a+s],u=l+c;if(e<=u&&a==o*3)return!0;r+=this.ranges[a+i]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,s=0;o<this.ranges.length;o+=3){let i=this.ranges[o],a=i-(this.inverted?s:0),l=i+(this.inverted?0:s),c=this.ranges[o+n],u=this.ranges[o+r];e(a,a+c,l,l+u),s+=u-c}}invert(){return new Wn(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Wn.empty:new Wn(e<0?[0,-e,0]:[0,0,e])}}Wn.empty=new Wn([]);class Ul{constructor(e,n,r=0,o=e?e.length:0){this.mirror=n,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Ul(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let o=e.getMirror(n);this.appendMap(e._maps[n],o!=null&&o<n?r+o:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let o=e.getMirror(n);this.appendMap(e._maps[n].invert(),o!=null&&o>n?r-o-1:void 0)}}invert(){let e=new Ul;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let o=0;for(let s=this.from;s<this.to;s++){let i=this._maps[s],a=i.mapResult(e,n);if(a.recover!=null){let l=this.getMirror(s);if(l!=null&&l>s&&l<this.to){s=l,e=this._maps[l].recover(a.recover);continue}}o|=a.delInfo,e=a.pos}return r?e:new Um(e,o,null)}}const cp=Object.create(null);class fn{getMap(){return Wn.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=cp[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in cp)throw new RangeError("Duplicate use of step JSON ID "+e);return cp[e]=n,n.prototype.jsonID=e,n}}class Mt{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Mt(e,null)}static fail(e){return new Mt(null,e)}static fromReplace(e,n,r,o){try{return Mt.ok(e.replace(n,r,o))}catch(s){if(s instanceof ad)return Mt.fail(s.message);throw s}}}function My(t,e,n){let r=[];for(let o=0;o<t.childCount;o++){let s=t.child(o);s.content.size&&(s=s.copy(My(s.content,e,s))),s.isInline&&(s=e(s,n,o)),r.push(s)}return X.fromArray(r)}class rs extends fn{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),s=new ie(My(n.content,(i,a)=>!i.isAtom||!a.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),o),n.openStart,n.openEnd);return Mt.fromReplace(e,this.from,this.to,s)}invert(){return new Tr(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new rs(n.pos,r.pos,this.mark)}merge(e){return e instanceof rs&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new rs(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new rs(n.from,n.to,e.markFromJSON(n.mark))}}fn.jsonID("addMark",rs);class Tr extends fn{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new ie(My(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),n.openStart,n.openEnd);return Mt.fromReplace(e,this.from,this.to,r)}invert(){return new rs(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Tr(n.pos,r.pos,this.mark)}merge(e){return e instanceof Tr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Tr(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Tr(n.from,n.to,e.markFromJSON(n.mark))}}fn.jsonID("removeMark",Tr);class ss extends fn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Mt.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Mt.fromReplace(e,this.pos,this.pos+1,new ie(X.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let o=0;o<n.marks.length;o++)if(!n.marks[o].isInSet(r))return new ss(this.pos,n.marks[o]);return new ss(this.pos,this.mark)}}return new oi(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ss(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ss(n.pos,e.markFromJSON(n.mark))}}fn.jsonID("addNodeMark",ss);class oi extends fn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Mt.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Mt.fromReplace(e,this.pos,this.pos+1,new ie(X.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new ss(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new oi(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new oi(n.pos,e.markFromJSON(n.mark))}}fn.jsonID("removeNodeMark",oi);class Bt extends fn{constructor(e,n,r,o=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=o}apply(e){return this.structure&&Bm(e,this.from,this.to)?Mt.fail("Structure replace would overwrite content"):Mt.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Wn([this.from,this.to-this.from,this.slice.size])}invert(e){return new Bt(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new Bt(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Bt)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?ie.empty:new ie(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Bt(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?ie.empty:new ie(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Bt(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Bt(n.from,n.to,ie.fromJSON(e,n.slice),!!n.structure)}}fn.jsonID("replace",Bt);class Ht extends fn{constructor(e,n,r,o,s,i,a=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=o,this.slice=s,this.insert=i,this.structure=a}apply(e){if(this.structure&&(Bm(e,this.from,this.gapFrom)||Bm(e,this.gapTo,this.to)))return Mt.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Mt.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Mt.fromReplace(e,this.from,this.to,r):Mt.fail("Content does not fit in gap")}getMap(){return new Wn([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Ht(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||o<n.pos||s>r.pos?null:new Ht(n.pos,r.pos,o,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,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ht(n.from,n.to,n.gapFrom,n.gapTo,ie.fromJSON(e,n.slice),n.insert,!!n.structure)}}fn.jsonID("replaceAround",Ht);function Bm(t,e,n){let r=t.resolve(e),o=n-e,s=r.depth;for(;o>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,o--;if(o>0){let i=r.node(s).maybeChild(r.indexAfter(s));for(;o>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,o--}}return!1}function Kj(t,e,n,r){let o=[],s=[],i,a;t.doc.nodesBetween(e,n,(l,c,u)=>{if(!l.isInline)return;let d=l.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+l.nodeSize,n),p=r.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(p)||(i&&i.to==f&&i.mark.eq(d[m])?i.to=h:o.push(i=new Tr(f,h,d[m])));a&&a.to==f?a.to=h:s.push(a=new rs(f,h,r))}}),o.forEach(l=>t.step(l)),s.forEach(l=>t.step(l))}function Gj(t,e,n,r){let o=[],s=0;t.doc.nodesBetween(e,n,(i,a)=>{if(!i.isInline)return;s++;let l=null;if(r instanceof Bf){let c=i.marks,u;for(;u=r.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(i.marks)&&(l=[r]):l=i.marks;if(l&&l.length){let c=Math.min(a+i.nodeSize,n);for(let u=0;u<l.length;u++){let d=l[u],f;for(let h=0;h<o.length;h++){let p=o[h];p.step==s-1&&d.eq(o[h].style)&&(f=p)}f?(f.to=c,f.step=s):o.push({style:d,from:Math.max(a,e),to:c,step:s})}}}),o.forEach(i=>t.step(new Tr(i.from,i.to,i.style)))}function Oy(t,e,n,r=n.contentMatch,o=!0){let s=t.doc.nodeAt(e),i=[],a=e+1;for(let l=0;l<s.childCount;l++){let c=s.child(l),u=a+c.nodeSize,d=r.matchType(c.type);if(!d)i.push(new Bt(a,u,ie.empty));else{r=d;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new Tr(a,u,c.marks[f]));if(o&&c.isText&&n.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new ie(X.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),i.push(new Bt(a+f.index,a+f.index+f[0].length,p))}}a=u}if(!r.validEnd){let l=r.fillBefore(X.empty,!0);t.replace(a,a,new ie(l,0,0))}for(let l=i.length-1;l>=0;l--)t.step(i[l])}function qj(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Aa(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,o=0,s=0;;--r){let i=t.$from.node(r),a=t.$from.index(r)+o,l=t.$to.indexAfter(r)-s;if(r<t.depth&&i.canReplace(a,l,n))return r;if(r==0||i.type.spec.isolating||!qj(i,a,l))break;a&&(o=1),l<i.childCount&&(s=1)}return null}function Yj(t,e,n){let{$from:r,$to:o,depth:s}=e,i=r.before(s+1),a=o.after(s+1),l=i,c=a,u=X.empty,d=0;for(let p=s,m=!1;p>n;p--)m||r.index(p)>0?(m=!0,u=X.from(r.node(p).copy(u)),d++):l--;let f=X.empty,h=0;for(let p=s,m=!1;p>n;p--)m||o.after(p+1)<o.end(p)?(m=!0,f=X.from(o.node(p).copy(f)),h++):c++;t.step(new Ht(l,c,i,a,new ie(u.append(f),d,h),u.size-d,!0))}function Ry(t,e,n=null,r=t){let o=Jj(t,e),s=o&&Xj(r,e);return s?o.map(Z0).concat({type:e,attrs:n}).concat(s.map(Z0)):null}function Z0(t){return{type:t,attrs:null}}function Jj(t,e){let{parent:n,startIndex:r,endIndex:o}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let i=s.length?s[0]:e;return n.canReplaceWith(r,o,i)?s:null}function Xj(t,e){let{parent:n,startIndex:r,endIndex:o}=t,s=n.child(r),i=e.contentMatch.findWrapping(s.type);if(!i)return null;let l=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;l&&c<o;c++)l=l.matchType(n.child(c).type);return!l||!l.validEnd?null:i}function Qj(t,e,n){let r=X.empty;for(let i=n.length-1;i>=0;i--){if(r.size){let a=n[i].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=X.from(n[i].type.create(n[i].attrs,r))}let o=e.start,s=e.end;t.step(new Ht(o,s,o,s,new ie(r,0,0),n.length,!0))}function Zj(t,e,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(i,a)=>{let l=typeof o=="function"?o(i):o;if(i.isTextblock&&!i.hasMarkup(r,l)&&e$(t.doc,t.mapping.slice(s).map(a),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&tT(t,i,a,s),Oy(t,t.mapping.slice(s).map(a,1),r,void 0,c===null);let u=t.mapping.slice(s),d=u.map(a,1),f=u.map(a+i.nodeSize,1);return t.step(new Ht(d,f,d+1,f-1,new ie(X.from(r.create(l,null,i.marks)),0,0),1,!0)),c===!0&&eT(t,i,a,s),!1}})}function eT(t,e,n,r){e.forEach((o,s)=>{if(o.isText){let i,a=/\r?\n|\r/g;for(;i=a.exec(o.text);){let l=t.mapping.slice(r).map(n+1+s+i.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function tT(t,e,n,r){e.forEach((o,s)=>{if(o.type==o.type.schema.linebreakReplacement){let i=t.mapping.slice(r).map(n+1+s);t.replaceWith(i,i+1,e.type.schema.text(`
10
- `))}})}function e$(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function t$(t,e,n,r,o){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let i=n.create(r,null,o||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,i);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Ht(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new ie(X.from(i),0,0),1,!0))}function To(t,e,n=1,r){let o=t.resolve(e),s=o.depth-n,i=r&&r[r.length-1]||o.parent;if(s<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!i.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=n-2;c>s;c--,u--){let d=o.node(c),f=o.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(h))return!1}let a=o.indexAfter(s),l=r&&r[0];return o.node(s).canReplaceWith(a,a,l?l.type:o.node(s+1).type)}function n$(t,e,n=1,r){let o=t.doc.resolve(e),s=X.empty,i=X.empty;for(let a=o.depth,l=o.depth-n,c=n-1;a>l;a--,c--){s=X.from(o.node(a).copy(s));let u=r&&r[c];i=X.from(u?u.type.create(u.attrs,i):o.node(a).copy(i))}t.step(new Bt(e,e,new ie(s.append(i),n,n),!0))}function Ss(t,e){let n=t.resolve(e),r=n.index();return nT(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function r$(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let o=0;o<e.childCount;o++){let s=e.child(o),i=s.type==r?t.type.schema.nodes.text:s.type;if(n=n.matchType(i),!n||!t.type.allowsMarks(s.marks))return!1}return n.validEnd}function nT(t,e){return!!(t&&e&&!t.isLeaf&&r$(t,e))}function zf(t,e,n=-1){let r=t.resolve(e);for(let o=r.depth;;o--){let s,i,a=r.index(o);if(o==r.depth?(s=r.nodeBefore,i=r.nodeAfter):n>0?(s=r.node(o+1),a++,i=r.node(o).maybeChild(a)):(s=r.node(o).maybeChild(a-1),i=r.node(o+1)),s&&!s.isTextblock&&nT(s,i)&&r.node(o).canReplace(a,a+1))return e;if(o==0)break;e=n<0?r.before(o):r.after(o)}}function o$(t,e,n){let r=null,{linebreakReplacement:o}=t.doc.type.schema,s=t.doc.resolve(e-n),i=s.node().type;if(o&&i.inlineContent){let u=i.whitespace=="pre",d=!!i.contentMatch.matchType(o);u&&!d?r=!1:!u&&d&&(r=!0)}let a=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);tT(t,u.node(),u.before(),a)}i.inlineContent&&Oy(t,e+n-1,i,s.node().contentMatchAt(s.index()),r==null);let l=t.mapping.slice(a),c=l.map(e-n);if(t.step(new Bt(c,l.map(e+n,-1),ie.empty,!0)),r===!0){let u=t.doc.resolve(c);eT(t,u.node(),u.before(),t.steps.length)}return t}function s$(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let s=r.index(o);if(r.node(o).canReplaceWith(s,s,n))return r.before(o+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let s=r.indexAfter(o);if(r.node(o).canReplaceWith(s,s,n))return r.after(o+1);if(s<r.node(o).childCount)return null}return null}function rT(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let o=n.content;for(let s=0;s<n.openStart;s++)o=o.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)for(let i=r.depth;i>=0;i--){let a=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,l=r.index(i)+(a>0?1:0),c=r.node(i),u=!1;if(s==1)u=c.canReplace(l,l,o);else{let d=c.contentMatchAt(l).findWrapping(o.firstChild.type);u=d&&c.canReplaceWith(l,l,d[0])}if(u)return a==0?r.pos:a<0?r.before(i+1):r.after(i+1)}return null}function Hf(t,e,n=e,r=ie.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),s=t.resolve(n);return oT(o,s,r)?new Bt(e,n,r):new i$(o,s,r).fit()}function oT(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class i${constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=X.empty;for(let o=0;o<=e.depth;o++){let s=e.node(o);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=X.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let s=this.placed,i=r.depth,a=o.depth;for(;i&&a&&s.childCount==1;)s=s.firstChild.content,i--,a--;let l=new ie(s,i,a);return e>-1?new Ht(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new Bt(r.pos,o.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let s=n.firstChild;if(n.childCount>1&&(o=0),s.type.spec.isolating&&o<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let o,s=null;r?(s=up(this.unplaced.content,r-1).firstChild,o=s.content):o=this.unplaced.content;let i=o.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],u,d=null;if(n==1&&(i?c.matchType(i.type)||(d=c.fillBefore(X.from(i),!1)):s&&l.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:a,parent:s,inject:d};if(n==2&&i&&(u=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:a,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=up(e,n);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new ie(e,n+1,Math.max(r,o.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=up(e,n);if(o.childCount<=1&&n>0){let s=e.size-n<=n+o.size;this.unplaced=new ie(rl(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new ie(rl(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:o,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let i=this.unplaced,a=r?r.content:i.content,l=i.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[n];if(o){for(let m=0;m<o.childCount;m++)u.push(o.child(m));d=d.matchFragment(o)}let h=a.size+e-(i.content.size-i.openEnd);for(;c<a.childCount;){let m=a.child(c),g=d.matchType(m.type);if(!g)break;c++,(c>1||l==0||m.content.size)&&(d=g,u.push(sT(m.mark(f.allowedMarks(m.marks)),c==1?l:0,c==a.childCount?h:-1)))}let p=c==a.childCount;p||(h=-1),this.placed=ol(this.placed,n,X.from(u)),this.frontier[n].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=a;m<h;m++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=p?e==0?ie.empty:new ie(rl(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new ie(rl(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!dp(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:o}=this.frontier[n],s=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),i=dp(e,n,o,r,s);if(i){for(let a=n-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],u=dp(e,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:n,fit:i,move:s?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=ol(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let o=e.node(r),s=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,s)}return e}openFrontierNode(e,n=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=ol(this.placed,this.depth,X.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(X.empty,!0);n.childCount&&(this.placed=ol(this.placed,this.frontier.length,n))}}function rl(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(rl(t.firstChild.content,e-1,n)))}function ol(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(ol(t.lastChild.content,e-1,n)))}function up(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function sT(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,sT(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(X.empty,!0)))),t.copy(r)}function dp(t,e,n,r,o){let s=t.node(e),i=o?t.indexAfter(e):t.index(e);if(i==s.childCount&&!n.compatibleContent(s.type))return null;let a=r.fillBefore(s.content,!0,i);return a&&!a$(n,s.content,i)?a:null}function a$(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function l$(t){return t.spec.defining||t.spec.definingForContent}function c$(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let o=t.doc.resolve(e),s=t.doc.resolve(n);if(oT(o,s,r))return t.step(new Bt(e,n,r));let i=aT(o,s);i[i.length-1]==0&&i.pop();let a=-(o.depth+1);i.unshift(a);for(let f=o.depth,h=o.pos-1;f>0;f--,h--){let p=o.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;i.indexOf(f)>-1?a=f:o.before(f)==h&&i.splice(1,0,-f)}let l=i.indexOf(a),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=l$(h.type);if(p&&!h.sameMarkup(o.node(Math.abs(a)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<i.length;m++){let g=i[(m+l)%i.length],b=!0;g<0&&(b=!1,g=-g);let S=o.node(g-1),k=o.index(g-1);if(S.canReplaceWith(k,k,p.type,p.marks))return t.replace(o.before(g),b?s.after(g):n,new ie(iT(r.content,0,r.openStart,h),h,r.openEnd))}}let d=t.steps.length;for(let f=i.length-1;f>=0&&(t.replace(e,n,r),!(t.steps.length>d));f--){let h=i[f];h<0||(e=o.before(h),n=s.after(h))}}function iT(t,e,n,r,o){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(iT(s.content,e+1,n,r,s)))}if(e>r){let s=o.contentMatchAt(0),i=s.fillBefore(t).append(t);t=i.append(s.matchFragment(i).fillBefore(X.empty,!0))}return t}function u$(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=s$(t.doc,e,r.type);o!=null&&(e=n=o)}t.replaceRange(e,n,new ie(X.from(r),0,0))}function d$(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n),s=aT(r,o);for(let i=0;i<s.length;i++){let a=s[i],l=i==s.length-1;if(l&&a==0||r.node(a).type.contentMatch.validEnd)return t.delete(r.start(a),o.end(a));if(a>0&&(l||r.node(a-1).canReplace(r.index(a-1),o.indexAfter(a-1))))return t.delete(r.before(a),o.after(a))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(e-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return t.delete(r.before(i),n);t.delete(e,n)}function aT(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let o=r;o>=0;o--){let s=t.start(o);if(s<t.pos-(t.depth-o)||e.end(o)>e.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(s==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==s-1)&&n.push(o)}return n}class Ki extends fn{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Mt.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let o=n.type.create(r,null,n.marks);return Mt.fromReplace(e,this.pos,this.pos+1,new ie(X.from(o),0,n.isLeaf?0:1))}getMap(){return Wn.empty}invert(e){return new Ki(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ki(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ki(n.pos,n.attr,n.value)}}fn.jsonID("attr",Ki);class Bl extends fn{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let o in e.attrs)n[o]=e.attrs[o];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Mt.ok(r)}getMap(){return Wn.empty}invert(e){return new Bl(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Bl(n.attr,n.value)}}fn.jsonID("docAttr",Bl);let ra=class extends Error{};ra=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};ra.prototype=Object.create(Error.prototype);ra.prototype.constructor=ra;ra.prototype.name="TransformError";class lT{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ul}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new ra(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let o=this.mapping.maps[r];r&&(e=o.map(e,1),n=o.map(n,-1)),o.forEach((s,i,a,l)=>{e=Math.min(e,a),n=Math.max(n,l)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=ie.empty){let o=Hf(this.doc,e,n,r);return o&&this.step(o),this}replaceWith(e,n,r){return this.replace(e,n,new ie(X.from(r),0,0))}delete(e,n){return this.replace(e,n,ie.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return c$(this,e,n,r),this}replaceRangeWith(e,n,r){return u$(this,e,n,r),this}deleteRange(e,n){return d$(this,e,n),this}lift(e,n){return Yj(this,e,n),this}join(e,n=1){return o$(this,e,n),this}wrap(e,n){return Qj(this,e,n),this}setBlockType(e,n=e,r,o=null){return Zj(this,e,n,r,o),this}setNodeMarkup(e,n,r=null,o){return t$(this,e,n,r,o),this}setNodeAttribute(e,n,r){return this.step(new Ki(e,n,r)),this}setDocAttribute(e,n){return this.step(new Bl(e,n)),this}addNodeMark(e,n){return this.step(new ss(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof ut)n.isInSet(r.marks)&&this.step(new oi(e,n));else{let o=r.marks,s,i=[];for(;s=n.isInSet(o);)i.push(new oi(e,s)),o=s.removeFromSet(o);for(let a=i.length-1;a>=0;a--)this.step(i[a])}return this}split(e,n=1,r){return n$(this,e,n,r),this}addMark(e,n,r){return Kj(this,e,n,r),this}removeMark(e,n,r){return Gj(this,e,n,r),this}clearIncompatible(e,n,r){return Oy(this,e,n,r),this}}const fp=Object.create(null);class Re{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new cT(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=ie.empty){let r=n.content.lastChild,o=null;for(let a=0;a<n.openEnd;a++)o=r,r=r.lastChild;let s=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:l,$to:c}=i[a],u=e.mapping.slice(s);e.replaceRange(u.map(l.pos),u.map(c.pos),a?ie.empty:n),a==0&&nw(e,s,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:i,$to:a}=o[s],l=e.mapping.slice(r),c=l.map(i.pos),u=l.map(a.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),nw(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let o=e.parent.inlineContent?new we(e):Fi(e.node(0),e.parent,e.pos,e.index(),n,r);if(o)return o;for(let s=e.depth-1;s>=0;s--){let i=n<0?Fi(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):Fi(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(i)return i}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Pn(e.node(0))}static atStart(e){return Fi(e,e,0,0,1)||new Pn(e)}static atEnd(e){return Fi(e,e,e.content.size,e.childCount,-1)||new Pn(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=fp[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in fp)throw new RangeError("Duplicate use of selection JSON ID "+e);return fp[e]=n,n.prototype.jsonID=e,n}getBookmark(){return we.between(this.$anchor,this.$head).getBookmark()}}Re.prototype.visible=!0;class cT{constructor(e,n){this.$from=e,this.$to=n}}let ew=!1;function tw(t){!ew&&!t.parent.inlineContent&&(ew=!0)}class we extends Re{constructor(e,n=e){tw(e),tw(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Re.near(r);let o=e.resolve(n.map(this.anchor));return new we(o.parent.inlineContent?o:r,r)}replace(e,n=ie.empty){if(super.replace(e,n),n==ie.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof we&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Vf(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new we(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let o=e.resolve(n);return new this(o,r==n?o:e.resolve(r))}static between(e,n,r){let o=e.pos-n.pos;if((!r||o)&&(r=o>=0?1:-1),!n.parent.inlineContent){let s=Re.findFrom(n,r,!0)||Re.findFrom(n,-r,!0);if(s)n=s.$head;else return Re.near(n,r)}return e.parent.inlineContent||(o==0?e=n:(e=(Re.findFrom(e,-r,!0)||Re.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=o<0&&(e=n))),new we(e,n)}}Re.jsonID("text",we);class Vf{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Vf(e.map(this.anchor),e.map(this.head))}resolve(e){return we.between(e.resolve(this.anchor),e.resolve(this.head))}}class me extends Re{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:o}=n.mapResult(this.anchor),s=e.resolve(o);return r?Re.near(s):new me(s)}content(){return new ie(X.from(this.node),0,0)}eq(e){return e instanceof me&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ny(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new me(e.resolve(n.anchor))}static create(e,n){return new me(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}me.prototype.visible=!1;Re.jsonID("node",me);class Ny{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Vf(r,r):new Ny(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&me.isSelectable(r)?new me(n):Re.near(n)}}class Pn extends Re{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=ie.empty){if(n==ie.empty){e.delete(0,e.doc.content.size);let r=Re.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Pn(e)}map(e){return new Pn(e)}eq(e){return e instanceof Pn}getBookmark(){return f$}}Re.jsonID("all",Pn);const f$={map(){return this},resolve(t){return new Pn(t)}};function Fi(t,e,n,r,o,s=!1){if(e.inlineContent)return we.create(t,n);for(let i=r-(o>0?0:1);o>0?i<e.childCount:i>=0;i+=o){let a=e.child(i);if(a.isAtom){if(!s&&me.isSelectable(a))return me.create(t,n-(o<0?a.nodeSize:0))}else{let l=Fi(t,a,n+o,o<0?a.childCount:0,o,s);if(l)return l}n+=a.nodeSize*o}return null}function nw(t,e,n){let r=t.steps.length-1;if(r<e)return;let o=t.steps[r];if(!(o instanceof Bt||o instanceof Ht))return;let s=t.mapping.maps[r],i;s.forEach((a,l,c,u)=>{i==null&&(i=u)}),t.setSelection(Re.near(t.doc.resolve(i),n))}const rw=1,tu=2,ow=4;let h$=class extends lT{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|rw)&~tu,this.storedMarks=null,this}get selectionSet(){return(this.updated&rw)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=tu,this}ensureMarks(e){return ut.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&tu)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~tu,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||ut.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let o=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let s=this.storedMarks;if(!s){let i=this.doc.resolve(n);s=r==n?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,o.text(e,s)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Re.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=ow,this}get scrolledIntoView(){return(this.updated&ow)>0}};function sw(t,e){return!e||!t?t:t.bind(e)}class sl{constructor(e,n,r){this.name=e,this.init=sw(n.init,r),this.apply=sw(n.apply,r)}}const p$=[new sl("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new sl("selection",{init(t,e){return t.selection||Re.atStart(e.doc)},apply(t){return t.selection}}),new sl("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new sl("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class hp{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=p$.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new sl(r.key,r.spec.state,r))})}}class Hi{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),o=null;for(;;){let s=!1;for(let i=0;i<this.config.plugins.length;i++){let a=this.config.plugins[i];if(a.spec.appendTransaction){let l=o?o[i].n:0,c=o?o[i].state:this,u=l<n.length&&a.spec.appendTransaction.call(a,l?n.slice(l):n,c,r);if(u&&r.filterTransaction(u,i)){if(u.setMeta("appendedTransaction",e),!o){o=[];for(let d=0;d<this.config.plugins.length;d++)o.push(d<i?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),s=!0}o&&(o[i]={state:r,n:n.length})}}if(!s)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Hi(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let s=r[o];n[s.name]=s.apply(e,this[s.name],this,n)}return n}get tr(){return new h$(this)}static create(e){let n=new hp(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Hi(n);for(let o=0;o<n.fields.length;o++)r[n.fields[o].name]=n.fields[o].init(e,r);return r}reconfigure(e){let n=new hp(this.schema,e.plugins),r=n.fields,o=new Hi(n);for(let s=0;s<r.length;s++){let i=r[s].name;o[i]=this.hasOwnProperty(i)?this[i]:r[s].init(e,o)}return o}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],s=o.spec.state;s&&s.toJSON&&(n[r]=s.toJSON.call(o,this[o.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new hp(e.schema,e.plugins),s=new Hi(o);return o.fields.forEach(i=>{if(i.name=="doc")s.doc=ko.fromJSON(e.schema,n.doc);else if(i.name=="selection")s.selection=Re.fromJSON(s.doc,n.selection);else if(i.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let a in r){let l=r[a],c=l.spec.state;if(l.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,a)){s[i.name]=c.fromJSON.call(l,e,n[a],s);return}}s[i.name]=i.init(e,s)}}),s}}function uT(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=uT(o,e,{})),n[r]=o}return n}class Ye{constructor(e){this.spec=e,this.props={},e.props&&uT(e.props,this,this.props),this.key=e.key?e.key.key:dT("plugin")}getState(e){return e[this.key]}}const pp=Object.create(null);function dT(t){return t in pp?t+"$"+ ++pp[t]:(pp[t]=0,t+"$")}class Je{constructor(e="key"){this.key=dT(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Iy=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function fT(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const hT=(t,e,n)=>{let r=fT(t,n);if(!r)return!1;let o=Dy(r);if(!o){let i=r.blockRange(),a=i&&Aa(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)}let s=o.nodeBefore;if(ET(t,o,e,-1))return!0;if(r.parent.content.size==0&&(oa(s,"end")||me.isSelectable(s)))for(let i=r.depth;;i--){let a=Hf(t.doc,r.before(i),r.after(i),ie.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=t.tr.step(a);l.setSelection(oa(s,"end")?Re.findFrom(l.doc.resolve(l.mapping.map(o.pos,-1)),-1):me.create(l.doc,o.pos-s.nodeSize)),e(l.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}return s.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos-s.nodeSize,o.pos).scrollIntoView()),!0):!1},m$=(t,e,n)=>{let r=fT(t,n);if(!r)return!1;let o=Dy(r);return o?pT(t,o,e):!1},g$=(t,e,n)=>{let r=gT(t,n);if(!r)return!1;let o=Py(r);return o?pT(t,o,e):!1};function pT(t,e,n){let r=e.nodeBefore,o=r,s=e.pos-1;for(;!o.isTextblock;s--){if(o.type.spec.isolating)return!1;let u=o.lastChild;if(!u)return!1;o=u}let i=e.nodeAfter,a=i,l=e.pos+1;for(;!a.isTextblock;l++){if(a.type.spec.isolating)return!1;let u=a.firstChild;if(!u)return!1;a=u}let c=Hf(t.doc,s,l,ie.empty);if(!c||c.from!=s||c instanceof Bt&&c.slice.size>=l-s)return!1;if(n){let u=t.tr.step(c);u.setSelection(we.create(u.doc,s)),n(u.scrollIntoView())}return!0}function oa(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const mT=(t,e,n)=>{let{$head:r,empty:o}=t.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=Dy(r)}let i=s&&s.nodeBefore;return!i||!me.isSelectable(i)?!1:(e&&e(t.tr.setSelection(me.create(t.doc,s.pos-i.nodeSize)).scrollIntoView()),!0)};function Dy(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function gT(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const yT=(t,e,n)=>{let r=gT(t,n);if(!r)return!1;let o=Py(r);if(!o)return!1;let s=o.nodeAfter;if(ET(t,o,e,1))return!0;if(r.parent.content.size==0&&(oa(s,"start")||me.isSelectable(s))){let i=Hf(t.doc,r.before(),r.after(),ie.empty);if(i&&i.slice.size<i.to-i.from){if(e){let a=t.tr.step(i);a.setSelection(oa(s,"start")?Re.findFrom(a.doc.resolve(a.mapping.map(o.pos)),1):me.create(a.doc,a.mapping.map(o.pos))),e(a.scrollIntoView())}return!0}}return s.isAtom&&o.depth==r.depth-1?(e&&e(t.tr.delete(o.pos,o.pos+s.nodeSize).scrollIntoView()),!0):!1},bT=(t,e,n)=>{let{$head:r,empty:o}=t.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=Py(r)}let i=s&&s.nodeAfter;return!i||!me.isSelectable(i)?!1:(e&&e(t.tr.setSelection(me.create(t.doc,s.pos)).scrollIntoView()),!0)};function Py(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const y$=(t,e)=>{let n=t.selection,r=n instanceof me,o;if(r){if(n.node.isTextblock||!Ss(t.doc,n.from))return!1;o=n.from}else if(o=zf(t.doc,n.from,-1),o==null)return!1;if(e){let s=t.tr.join(o);r&&s.setSelection(me.create(s.doc,o-t.doc.resolve(o).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},b$=(t,e)=>{let n=t.selection,r;if(n instanceof me){if(n.node.isTextblock||!Ss(t.doc,n.to))return!1;r=n.to}else if(r=zf(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},v$=(t,e)=>{let{$from:n,$to:r}=t.selection,o=n.blockRange(r),s=o&&Aa(o);return s==null?!1:(e&&e(t.tr.lift(o,s).scrollIntoView()),!0)},vT=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
11
- `).scrollIntoView()),!0)};function Ly(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const w$=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),s=n.indexAfter(-1),i=Ly(o.contentMatchAt(s));if(!i||!o.canReplaceWith(s,s,i))return!1;if(e){let a=n.after(),l=t.tr.replaceWith(a,a,i.createAndFill());l.setSelection(Re.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},wT=(t,e)=>{let n=t.selection,{$from:r,$to:o}=n;if(n instanceof Pn||r.parent.inlineContent||o.parent.inlineContent)return!1;let s=Ly(o.parent.contentMatchAt(o.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let i=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,a=t.tr.insert(i,s.createAndFill());a.setSelection(we.create(a.doc,i+1)),e(a.scrollIntoView())}return!0},xT=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let s=n.before();if(To(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),o=r&&Aa(r);return o==null?!1:(e&&e(t.tr.lift(r,o).scrollIntoView()),!0)};function x$(t){return(e,n)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof me&&e.selection.node.isBlock)return!r.parentOffset||!To(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],i,a,l=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){l=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),a=Ly(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),s.unshift(l&&a?{type:a}:null),i=h;break}else{if(h==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof we||e.selection instanceof Pn)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=To(u.doc,d,s.length,s);if(f||(s[0]=a?{type:a}:null,f=To(u.doc,d,s.length,s)),!f)return!1;if(u.split(d,s.length,s),!l&&c&&r.node(i).type!=a){let h=u.mapping.map(r.before(i)),p=u.doc.resolve(h);a&&r.node(i-1).canReplaceWith(p.index(),p.index()+1,a)&&u.setNodeMarkup(u.mapping.map(r.before(i)),a)}return n&&n(u.scrollIntoView()),!0}}const E$=x$(),S$=(t,e)=>{let{$from:n,to:r}=t.selection,o,s=n.sharedDepth(r);return s==0?!1:(o=n.before(s),e&&e(t.tr.setSelection(me.create(t.doc,o))),!0)};function k$(t,e,n){let r=e.nodeBefore,o=e.nodeAfter,s=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(o.isTextblock||Ss(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function ET(t,e,n,r){let o=e.nodeBefore,s=e.nodeAfter,i,a,l=o.type.spec.isolating||s.type.spec.isolating;if(!l&&k$(t,e,n))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(a=o.contentMatchAt(o.childCount)).findWrapping(s.type))&&a.matchType(i[0]||s.type).validEnd){if(n){let h=e.pos+s.nodeSize,p=X.empty;for(let b=i.length-1;b>=0;b--)p=X.from(i[b].create(null,p));p=X.from(o.copy(p));let m=t.tr.step(new Ht(e.pos-1,h,e.pos,h,new ie(p,1,0),i.length,!0)),g=m.doc.resolve(h+2*i.length);g.nodeAfter&&g.nodeAfter.type==o.type&&Ss(m.doc,g.pos)&&m.join(g.pos),n(m.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&l?null:Re.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&Aa(d);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(d,f).scrollIntoView()),!0;if(c&&oa(s,"start",!0)&&oa(o,"end")){let h=o,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=s,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(n){let b=X.empty;for(let k=p.length-1;k>=0;k--)b=X.from(p[k].copy(b));let S=t.tr.step(new Ht(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new ie(b,p.length,0),0,!0));n(S.scrollIntoView())}return!0}}return!1}function ST(t){return function(e,n){let r=e.selection,o=t<0?r.$from:r.$to,s=o.depth;for(;o.node(s).isInline;){if(!s)return!1;s--}return o.node(s).isTextblock?(n&&n(e.tr.setSelection(we.create(e.doc,t<0?o.start(s):o.end(s)))),!0):!1}}const T$=ST(-1),C$=ST(1);function A$(t,e=null){return function(n,r){let{$from:o,$to:s}=n.selection,i=o.blockRange(s),a=i&&Ry(i,t,e);return a?(r&&r(n.tr.wrap(i,a).scrollIntoView()),!0):!1}}function iw(t,e=null){return function(n,r){let o=!1;for(let s=0;s<n.selection.ranges.length&&!o;s++){let{$from:{pos:i},$to:{pos:a}}=n.selection.ranges[s];n.doc.nodesBetween(i,a,(l,c)=>{if(o)return!1;if(!(!l.isTextblock||l.hasMarkup(t,e)))if(l.type==t)o=!0;else{let u=n.doc.resolve(c),d=u.index();o=u.parent.canReplaceWith(d,d+1,t)}})}if(!o)return!1;if(r){let s=n.tr;for(let i=0;i<n.selection.ranges.length;i++){let{$from:{pos:a},$to:{pos:l}}=n.selection.ranges[i];s.setBlockType(a,l,t,e)}r(s.scrollIntoView())}return!0}}function jy(...t){return function(e,n,r){for(let o=0;o<t.length;o++)if(t[o](e,n,r))return!0;return!1}}jy(Iy,hT,mT);jy(Iy,yT,bT);jy(vT,wT,xT,E$);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function _$(t,e=null){return function(n,r){let{$from:o,$to:s}=n.selection,i=o.blockRange(s);if(!i)return!1;let a=r?n.tr:null;return M$(a,i,t,e)?(r&&r(a.scrollIntoView()),!0):!1}}function M$(t,e,n,r=null){let o=!1,s=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let l=i.resolve(e.start-2);s=new $l(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new $l(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let a=Ry(s,n,r,e);return a?(t&&O$(t,e,a,o,n),!0):!1}function O$(t,e,n,r,o){let s=X.empty;for(let u=n.length-1;u>=0;u--)s=X.from(n[u].type.create(n[u].attrs,s));t.step(new Ht(e.start-(r?2:0),e.end,e.start,e.end,new ie(s,0,0),n.length,!0));let i=0;for(let u=0;u<n.length;u++)n[u].type==o&&(i=u+1);let a=n.length-i,l=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&To(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=c.child(u).nodeSize;return t}function R$(t){return function(e,n){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,i=>i.childCount>0&&i.firstChild.type==t);return s?n?r.node(s.depth-1).type==t?N$(e,n,t,s):I$(e,n,s):!0:!1}}function N$(t,e,n,r){let o=t.tr,s=r.end,i=r.$to.end(r.depth);s<i&&(o.step(new Ht(s-1,i,s,i,new ie(X.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new $l(o.doc.resolve(r.$from.pos),o.doc.resolve(i),r.depth));const a=Aa(r);if(a==null)return!1;o.lift(r,a);let l=o.doc.resolve(o.mapping.map(s,-1)-1);return Ss(o.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&o.join(l.pos),e(o.scrollIntoView()),!0}function I$(t,e,n){let r=t.tr,o=n.parent;for(let h=n.end,p=n.endIndex-1,m=n.startIndex;p>m;p--)h-=o.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(n.start),i=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let a=n.startIndex==0,l=n.endIndex==o.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(a?0:1),u+1,i.content.append(l?X.empty:X.from(o))))return!1;let d=s.pos,f=d+i.nodeSize;return r.step(new Ht(d-(a?1:0),f+(l?1:0),d+1,f-1,new ie((a?X.empty:X.from(o.copy(X.empty))).append(l?X.empty:X.from(o.copy(X.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function D$(t){return function(e,n){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==t);if(!s)return!1;let i=s.startIndex;if(i==0)return!1;let a=s.parent,l=a.child(i-1);if(l.type!=t)return!1;if(n){let c=l.lastChild&&l.lastChild.type==a.type,u=X.from(c?t.create():null),d=new ie(X.from(t.create(null,X.from(a.type.create(null,u)))),c?3:1,0),f=s.start,h=s.end;n(e.tr.step(new Ht(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}const Xt=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},sa=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let zm=null;const wo=function(t,e,n){let r=zm||(zm=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},P$=function(){zm=null},si=function(t,e,n,r){return n&&(aw(t,e,n,r,-1)||aw(t,e,n,r,1))},L$=/^(img|br|input|textarea|hr)$/i;function aw(t,e,n,r,o){for(var s;;){if(t==n&&e==r)return!0;if(e==(o<0?0:rr(t))){let i=t.parentNode;if(!i||i.nodeType!=1||kc(t)||L$.test(t.nodeName)||t.contentEditable=="false")return!1;e=Xt(t)+(o<0?0:1),t=i}else if(t.nodeType==1){let i=t.childNodes[e+(o<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((s=i.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=o;else return!1;else t=i,e=o<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function j$(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=rr(t)}else if(t.parentNode&&!kc(t))e=Xt(t),t=t.parentNode;else return null}}function $$(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!kc(t))e=Xt(t)+1,t=t.parentNode;else return null}}function F$(t,e,n){for(let r=e==0,o=e==rr(t);r||o;){if(t==n)return!0;let s=Xt(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,o=o&&s==rr(t)}}function kc(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Wf=function(t){return t.focusNode&&si(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function js(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function U$(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function B$(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(rr(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(rr(r.startContainer),r.startOffset)}}}const no=typeof navigator<"u"?navigator:null,lw=typeof document<"u"?document:null,ks=no&&no.userAgent||"",Hm=/Edge\/(\d+)/.exec(ks),kT=/MSIE \d/.exec(ks),Vm=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ks),Ln=!!(kT||Vm||Hm),us=kT?document.documentMode:Vm?+Vm[1]:Hm?+Hm[1]:0,ir=!Ln&&/gecko\/(\d+)/i.test(ks);ir&&+(/Firefox\/(\d+)/.exec(ks)||[0,0])[1];const Wm=!Ln&&/Chrome\/(\d+)/.exec(ks),en=!!Wm,TT=Wm?+Wm[1]:0,un=!Ln&&!!no&&/Apple Computer/.test(no.vendor),ia=un&&(/Mobile\/\w+/.test(ks)||!!no&&no.maxTouchPoints>2),nr=ia||(no?/Mac/.test(no.platform):!1),CT=no?/Win/.test(no.platform):!1,Eo=/Android \d/.test(ks),Tc=!!lw&&"webkitFontSmoothing"in lw.documentElement.style,z$=Tc?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function H$(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function ho(t,e){return typeof t=="number"?t:t[e]}function V$(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function cw(t,e,n){let r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let i=n||t.dom;i;){if(i.nodeType!=1){i=sa(i);continue}let a=i,l=a==s.body,c=l?H$(s):V$(a),u=0,d=0;if(e.top<c.top+ho(r,"top")?d=-(c.top-e.top+ho(o,"top")):e.bottom>c.bottom-ho(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+ho(o,"top")-c.top:e.bottom-c.bottom+ho(o,"bottom")),e.left<c.left+ho(r,"left")?u=-(c.left-e.left+ho(o,"left")):e.right>c.right-ho(r,"right")&&(u=e.right-c.right+ho(o,"right")),u||d)if(l)s.defaultView.scrollBy(u,d);else{let h=a.scrollLeft,p=a.scrollTop;d&&(a.scrollTop+=d),u&&(a.scrollLeft+=u);let m=a.scrollLeft-h,g=a.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let f=l?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(f))break;i=f=="absolute"?i.offsetParent:sa(i)}}function W$(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,o;for(let s=(e.left+e.right)/2,i=n+1;i<Math.min(innerHeight,e.bottom);i+=5){let a=t.root.elementFromPoint(s,i);if(!a||a==t.dom||!t.dom.contains(a))continue;let l=a.getBoundingClientRect();if(l.top>=n-20){r=a,o=l.top;break}}return{refDOM:r,refTop:o,stack:AT(t.dom)}}function AT(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=sa(r));return e}function K$({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;_T(n,r==0?0:r-e)}function _T(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:o,left:s}=t[n];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let Ni=null;function G$(t){if(t.setActive)return t.setActive();if(Ni)return t.focus(Ni);let e=AT(t);t.focus(Ni==null?{get preventScroll(){return Ni={preventScroll:!0},!0}}:void 0),Ni||(Ni=!1,_T(e,0))}function MT(t,e){let n,r=2e8,o,s=0,i=e.top,a=e.top,l,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=wo(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=i&&p.bottom>=a){i=Math.max(p.bottom,i),a=Math.min(p.top,a);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){n=u,r=m,o=m&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&m&&(s=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!l&&p.left<=e.left&&p.right>=e.left&&(l=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=d+1)}}return!n&&l&&(n=l,o=c,r=0),n&&n.nodeType==3?q$(n,o):!n||r&&n.nodeType==1?{node:t,offset:s}:MT(n,o)}function q$(t,e){let n=t.nodeValue.length,r=document.createRange(),o;for(let s=0;s<n;s++){r.setEnd(t,s+1),r.setStart(t,s);let i=Go(r,1);if(i.top!=i.bottom&&$y(e,i)){o={node:t,offset:s+(e.left>=(i.left+i.right)/2?1:0)};break}}return r.detach(),o||{node:t,offset:0}}function $y(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Y$(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function J$(t,e,n){let{node:r,offset:o}=MT(e,n),s=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();s=i.left!=i.right&&n.left>(i.left+i.right)/2?1:-1}return t.docView.posFromDOM(r,o,s)}function X$(t,e,n,r){let o=-1;for(let s=e,i=!1;s!=t.dom;){let a=t.docView.nearestDesc(s,!0),l;if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent||!a.contentDOM)&&((l=a.dom.getBoundingClientRect()).width||l.height)&&(a.node.isBlock&&a.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(a.dom.nodeName)&&(!i&&l.left>r.left||l.top>r.top?o=a.posBefore:(!i&&l.right<r.left||l.bottom<r.top)&&(o=a.posAfter),i=!0),!a.contentDOM&&o<0&&!a.node.isText))return(a.node.isBlock?r.top<(l.top+l.bottom)/2:r.left<(l.left+l.right)/2)?a.posBefore:a.posAfter;s=a.dom.parentNode}return o>-1?o:t.docView.posFromDOM(e,n,-1)}function OT(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),s=o;;){let i=t.childNodes[s];if(i.nodeType==1){let a=i.getClientRects();for(let l=0;l<a.length;l++){let c=a[l];if($y(e,c))return OT(i,e,c)}}if((s=(s+1)%r)==o)break}return t}function Q$(t,e){let n=t.dom.ownerDocument,r,o=0,s=B$(n,e.left,e.top);s&&({node:r,offset:o}=s);let i=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),a;if(!i||!t.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=t.dom.getBoundingClientRect();if(!$y(e,c)||(i=OT(t.dom,e,c),!i))return null}if(un)for(let c=i;r&&c;c=sa(c))c.draggable&&(r=void 0);if(i=Y$(i,e),r){if(ir&&r.nodeType==1&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let u=r.childNodes[o],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&o++}let c;Tc&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==t.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?a=t.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(a=X$(t,r,o,e))}a==null&&(a=J$(t,i,e));let l=t.docView.nearestDesc(i,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function uw(t){return t.top<t.bottom||t.left<t.right}function Go(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(uw(r))return r}return Array.prototype.find.call(n,uw)||t.getBoundingClientRect()}const Z$=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function RT(t,e,n){let{node:r,offset:o,atom:s}=t.docView.domFromPos(e,n<0?-1:1),i=Tc||ir;if(r.nodeType==3)if(i&&(Z$.test(r.nodeValue)||(n<0?!o:o==r.nodeValue.length))){let l=Go(wo(r,o,o),n);if(ir&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=Go(wo(r,o-1,o-1),-1);if(c.top==l.top){let u=Go(wo(r,o,o+1),-1);if(u.top!=l.top)return za(u,u.left<c.left)}}return l}else{let l=o,c=o,u=n<0?1:-1;return n<0&&!o?(c++,u=-1):n>=0&&o==r.nodeValue.length?(l--,u=1):n<0?l--:c++,za(Go(wo(r,l,c),u),u<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&o&&(n<0||o==rr(r))){let l=r.childNodes[o-1];if(l.nodeType==1)return mp(l.getBoundingClientRect(),!1)}if(s==null&&o<rr(r)){let l=r.childNodes[o];if(l.nodeType==1)return mp(l.getBoundingClientRect(),!0)}return mp(r.getBoundingClientRect(),n>=0)}if(s==null&&o&&(n<0||o==rr(r))){let l=r.childNodes[o-1],c=l.nodeType==3?wo(l,rr(l)-(i?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return za(Go(c,1),!1)}if(s==null&&o<rr(r)){let l=r.childNodes[o];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?wo(l,0,i?0:1):l.nodeType==1?l:null:null;if(c)return za(Go(c,-1),!0)}return za(Go(r.nodeType==3?wo(r):r,-n),n>=0)}function za(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function mp(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function NT(t,e,n){let r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}function eF(t,e,n){let r=e.selection,o=n=="up"?r.$from:r.$to;return NT(t,e,()=>{let{node:s}=t.docView.domFromPos(o.pos,n=="up"?-1:1);for(;;){let a=t.docView.nearestDesc(s,!0);if(!a)break;if(a.node.isBlock){s=a.contentDOM||a.dom;break}s=a.dom.parentNode}let i=RT(t,o.pos,1);for(let a=s.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=wo(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;c<l.length;c++){let u=l[c];if(u.bottom>u.top+1&&(n=="up"?i.top-u.top>(u.bottom-i.top)*2:u.bottom-i.bottom>(i.bottom-u.top)*2))return!1}}return!0})}const tF=/[\u0590-\u08ac]/;function nF(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,s=!o,i=o==r.parent.content.size,a=t.domSelection();return a?!tF.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?s:i:NT(t,e,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),f=a.caretBidiLevel;a.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||l==p&&c==m;try{a.collapse(u,d),l&&(l!=u||c!=d)&&a.extend&&a.extend(l,c)}catch{}return f!=null&&(a.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}let dw=null,fw=null,hw=!1;function rF(t,e,n){return dw==e&&fw==n?hw:(dw=e,fw=n,hw=n=="up"||n=="down"?eF(t,e,n):nF(t,e,n))}const ar=0,pw=1,Bs=2,ro=3;class Cc{constructor(e,n,r,o){this.parent=e,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=ar,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let o=this.children[n];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,i;if(e==this.contentDOM)s=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(i)+i.size:this.posAtStart}else{let s,i;if(e==this.contentDOM)s=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(i):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=n>Xt(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!1;break}if(s.previousSibling)break}if(o==null&&n==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!0;break}if(s.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,o=e;o;o=o.parentNode){let s=this.getDesc(o),i;if(s&&(!n||s.node))if(r&&(i=s.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return s}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let o=e;o;o=o.parentNode){let s=this.getDesc(o);if(s)return s.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let o=this.children[n],s=r+o.size;if(r==e&&s!=r){for(;!o.border&&o.children.length;)for(let i=0;i<o.children.length;i++){let a=o.children[i];if(a.size){o=a;break}}return o}if(e<s)return o.descAt(e-r-o.border);r=s}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let s=0;r<this.children.length;r++){let i=this.children[r],a=s+i.size;if(a>e||i instanceof DT){o=e-s;break}s=a}if(o)return this.children[r].domFromPos(o-this.children[r].border,n);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof IT&&s.side>=0;r--);if(n<=0){let s,i=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,i=!1);return s&&n&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?Xt(s.dom)+1:0}}else{let s,i=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,n):{node:this.contentDOM,offset:s?Xt(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,s=-1;for(let i=r,a=0;;a++){let l=this.children[a],c=i+l.size;if(o==-1&&e<=c){let u=i+l.border;if(e>=u&&n<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(e,n,u);e=i;for(let d=a;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=Xt(f.dom)+1;break}e-=f.size}o==-1&&(o=0)}if(o>-1&&(c>n||a==this.children.length-1)){n=c;for(let u=a+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){s=Xt(d.dom);break}n+=d.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:n,fromOffset:o,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,o=!1){let s=Math.min(e,n),i=Math.max(e,n);for(let h=0,p=0;h<this.children.length;h++){let m=this.children[h],g=p+m.size;if(s>p&&i<g)return m.setSelection(e-p-m.border,n-p-m.border,r,o);p=g}let a=this.domFromPos(e,e?-1:1),l=n==e?a:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((ir||un)&&e==n){let{node:h,offset:p}=a;if(h.nodeType==3){if(d=!!(p&&h.nodeValue[p-1]==`
12
- `),d&&p==h.nodeValue.length)for(let m=h,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(a=l={node:g.parentNode,offset:Xt(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=h.childNodes[p-1];d=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(ir&&u.focusNode&&u.focusNode!=l.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(o=!0)}if(!(o||d&&un)&&si(a.node,a.offset,u.anchorNode,u.anchorOffset)&&si(l.node,l.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==n)&&!(d&&ir)){c.collapse(a.node,a.offset);try{e!=n&&c.extend(l.node,l.offset),f=!0}catch{}}if(!f){if(e>n){let p=a;a=l,l=p}let h=document.createRange();h.setEnd(l.node,l.offset),h.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,o=0;o<this.children.length;o++){let s=this.children[o],i=r+s.size;if(r==i?e<=i&&n>=r:e<i&&n>r){let a=r+s.border,l=i-s.border;if(e>=a&&n<=l){this.dirty=e==r||n==i?Bs:pw,e==a&&n==l&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=ro:s.markDirty(e-a,n-a);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Bs:ro}r=i}this.dirty=Bs}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Bs:pw;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class IT extends Cc{constructor(e,n,r,o){let s,i=n.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!s)return o;if(s.parent)return s.parent.posBeforeChild(s)})),!n.type.spec.raw){if(i.nodeType!=1){let a=document.createElement("span");a.appendChild(i),i=a}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=n,this.widget=n,s=this}matchesWidget(e){return this.dirty==ar&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class oF extends Cc{constructor(e,n,r,o){super(e,[],n,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class ii extends Cc{constructor(e,n,r,o,s){super(e,[],r,o),this.mark=n,this.spec=s}static create(e,n,r,o){let s=o.nodeViews[n.type.name],i=s&&s(n,o,r);return(!i||!i.dom)&&(i=xi.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new ii(e,n,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&ro||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ro&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=ar){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=ar}}slice(e,n,r){let o=ii.create(this.parent,this.mark,!0,r),s=this.children,i=this.size;n<i&&(s=Gm(s,n,i,r)),e>0&&(s=Gm(s,0,e,r));for(let a=0;a<s.length;a++)s[a].parent=o;return o.children=s,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class ds extends Cc{constructor(e,n,r,o,s,i,a,l,c){super(e,[],s,i),this.node=n,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=a}static create(e,n,r,o,s,i){let a=s.nodeViews[n.type.name],l,c=a&&a(n,s,()=>{if(!l)return i;if(l.parent)return l.parent.posBeforeChild(l)},r,o),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=xi.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=jT(u,r,n),c?l=new sF(e,n,r,o,u,d||null,f,c,s,i+1):n.isText?new Kf(e,n,r,o,u,f,s):new ds(e,n,r,o,u,d||null,f,s,i+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 n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>X.empty)}return e}matchesNode(e,n,r){return this.dirty==ar&&e.eq(this.node)&&ud(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,o=n,s=e.composing?this.localCompositionInfo(e,n):null,i=s&&s.pos>-1?s:null,a=s&&s.pos<0,l=new aF(this,i&&i.node,e);uF(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!d&&l.syncToMarks(u==this.node.childCount?ut.none:this.node.child(u).marks,r,e,u),l.placeWidget(c,e,o)},(c,u,d,f)=>{l.syncToMarks(c.marks,r,e,f);let h;l.findNodeMatch(c,u,d,f)||a&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(h=l.findIndexWithChild(s.node))>-1&&l.updateNodeAt(c,u,d,h,e)||l.updateNextNode(c,u,d,e,f,o)||l.addNode(c,u,d,e,o),o+=c.nodeSize}),l.syncToMarks([],r,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Bs)&&(i&&this.protectLocalComposition(e,i),PT(this.contentDOM,this.children,e),ia&&dF(this.dom))}localCompositionInfo(e,n){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof we)||r<n||o>n+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 i=s.nodeValue,a=fF(this.node.content,i,r-n,o-n);return a<0?null:{node:s,pos:a,text:i}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:o}){if(this.getDesc(n))return;let s=n;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 i=new oF(this,s,n,o);e.input.compositionNodes.push(i),this.children=Gm(this.children,r,r+o.length,e,i)}update(e,n,r,o){return this.dirty==ro||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,o),!0)}updateInner(e,n,r,o){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=ar}updateOuterDeco(e){if(ud(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=LT(this.dom,this.nodeDOM,Km(this.outerDeco,this.node,n),Km(e,this.node,n)),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.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function mw(t,e,n,r,o){jT(r,e,t);let s=new ds(void 0,t,e,n,r,r,r,o,0);return s.contentDOM&&s.updateChildren(o,0),s}class Kf extends ds{constructor(e,n,r,o,s,i,a){super(e,n,r,o,s,null,i,a,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,o){return this.dirty==ro||this.dirty!=ar&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=ar||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=ar,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let o=this.node.cut(e,n),s=document.createTextNode(o.text);return new Kf(this.parent,o,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=ro)}get domAtom(){return!1}isText(e){return this.node.text==e}}class DT extends Cc{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ar&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class sF extends ds{constructor(e,n,r,o,s,i,a,l,c,u){super(e,n,r,o,s,i,a,c,u),this.spec=l}update(e,n,r,o){if(this.dirty==ro)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,n,r);return s&&this.updateInner(e,n,r,o),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,o)}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 PT(t,e,n){let r=t.firstChild,o=!1;for(let s=0;s<e.length;s++){let i=e[s],a=i.dom;if(a.parentNode==t){for(;a!=r;)r=gw(r),o=!0;r=r.nextSibling}else o=!0,t.insertBefore(a,r);if(i instanceof ii){let l=r?r.previousSibling:t.lastChild;PT(i.contentDOM,i.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=gw(r),o=!0;o&&n.trackWrites==t&&(n.trackWrites=null)}const vl=function(t){t&&(this.nodeName=t)};vl.prototype=Object.create(null);const zs=[new vl];function Km(t,e,n){if(t.length==0)return zs;let r=n?zs[0]:new vl,o=[r];for(let s=0;s<t.length;s++){let i=t[s].type.attrs;if(i){i.nodeName&&o.push(r=new vl(i.nodeName));for(let a in i){let l=i[a];l!=null&&(n&&o.length==1&&o.push(r=new vl(e.isInline?"span":"div")),a=="class"?r.class=(r.class?r.class+" ":"")+l:a=="style"?r.style=(r.style?r.style+";":"")+l:a!="nodeName"&&(r[a]=l))}}}return o}function LT(t,e,n,r){if(n==zs&&r==zs)return e;let o=e;for(let s=0;s<r.length;s++){let i=r[s],a=n[s];if(s){let l;a&&a.nodeName==i.nodeName&&o!=t&&(l=o.parentNode)&&l.nodeName.toLowerCase()==i.nodeName||(l=document.createElement(i.nodeName),l.pmIsDeco=!0,l.appendChild(o),a=zs[0]),o=l}iF(o,a||zs[0],i)}return o}function iF(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)o.indexOf(r[s])==-1&&t.classList.remove(r[s]);for(let s=0;s<o.length;s++)r.indexOf(o[s])==-1&&t.classList.add(o[s]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)t.style.removeProperty(o[1])}n.style&&(t.style.cssText+=n.style)}}function jT(t,e,n){return LT(t,t,zs,Km(e,n,t.nodeType!=1))}function ud(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function gw(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class aF{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=lF(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,o){let s=0,i=this.stack.length>>1,a=Math.min(i,e.length);for(;s<a&&(s==i-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<i;)this.destroyRest(),this.top.dirty=ar,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let l=-1,c=this.top.children.length;o<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[i])&&!this.isLocked(d.dom)){l=u;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let u=ii.create(this.top,e[i],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,i++}}findNodeMatch(e,n,r,o){let s=-1,i;if(o>=this.preMatch.index&&(i=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&i.matchesNode(e,n,r))s=this.top.children.indexOf(i,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a<l;a++){let c=this.top.children[a];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){s=a;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,n,r,o,s){let i=this.top.children[o];return i.dirty==ro&&i.dom==i.contentDOM&&(i.dirty=Bs),i.update(e,n,r,s)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=n}}updateNextNode(e,n,r,o,s,i){for(let a=this.index;a<this.top.children.length;a++){let l=this.top.children[a];if(l instanceof ds){let c=this.preMatch.matched.get(l);if(c!=null&&c!=s)return!1;let u=l.dom,d,f=this.isLocked(u)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&l.dirty!=ro&&ud(n,l.outerDeco));if(!f&&l.update(e,n,r,o))return this.destroyBetween(this.index,a),l.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(l,e,n,r,o,i)))return this.destroyBetween(this.index,a),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=Bs,d.updateChildren(o,i+1),d.dirty=ar),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,o,s,i){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!ud(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let a=ds.create(this.top,n,r,o,s,i);if(a.contentDOM){a.children=e.children,e.children=[];for(let l of a.children)l.parent=a}return e.destroy(),a}addNode(e,n,r,o,s){let i=ds.create(this.top,e,n,r,o,s);i.contentDOM&&i.updateChildren(o,s+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,n,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let s=new IT(this.top,e,n,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof ii;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Kf)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((un||en)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new DT(this.top,[],r,null);n!=this.top?n.children.push(o):n.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function lF(t,e){let n=e,r=n.children.length,o=t.childCount,s=new Map,i=[];e:for(;o>0;){let a;for(;;)if(r){let c=n.children[r-1];if(c instanceof ii)n=c,r=c.children.length;else{a=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(o-1))break;--o,s.set(a,o),i.push(a)}}return{index:o,matched:s,matches:i.reverse()}}function cF(t,e){return t.type.side-e.type.side}function uF(t,e,n,r){let o=e.locals(t),s=0;if(o.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,o,e.forChild(s,u),c),s+=u.nodeSize}return}let i=0,a=[],l=null;for(let c=0;;){let u,d;for(;i<o.length&&o[i].to==s;){let g=o[i++];g.widget&&(u?(d||(d=[u])).push(g):u=g)}if(u)if(d){d.sort(cF);for(let g=0;g<d.length;g++)n(d[g],c,!!l)}else n(u,c,!!l);let f,h;if(l)h=-1,f=l,l=null;else if(c<t.childCount)h=c,f=t.child(c++);else break;for(let g=0;g<a.length;g++)a[g].to<=s&&a.splice(g--,1);for(;i<o.length&&o[i].from<=s&&o[i].to>s;)a.push(o[i++]);let p=s+f.nodeSize;if(f.isText){let g=p;i<o.length&&o[i].from<g&&(g=o[i].from);for(let b=0;b<a.length;b++)a[b].to<g&&(g=a[b].to);g<p&&(l=f.cut(g-s),f=f.cut(0,g-s),p=g,h=-1)}else for(;i<o.length&&o[i].to<p;)i++;let m=f.isInline&&!f.isLeaf?a.filter(g=>!g.inline):a.slice();r(f,m,e.forChild(s,f),h),s=p}}function dF(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function fF(t,e,n,r){for(let o=0,s=0;o<t.childCount&&s<=r;){let i=t.child(o++),a=s;if(s+=i.nodeSize,!i.isText)continue;let l=i.text;for(;o<t.childCount;){let c=t.child(o++);if(s+=c.nodeSize,!c.isText)break;l+=c.text}if(s>=n){if(s>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let c=a<r?l.lastIndexOf(e,r-a-1):-1;if(c>=0&&c+e.length+a>=n)return a+c;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}function Gm(t,e,n,r,o){let s=[];for(let i=0,a=0;i<t.length;i++){let l=t[i],c=a,u=a+=l.size;c>=n||u<=e?s.push(l):(c<e&&s.push(l.slice(0,e-c,r)),o&&(s.push(o),o=void 0),u>n&&s.push(l.slice(n-c,l.size,r)))}return s}function Fy(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let o=t.docView.nearestDesc(n.focusNode),s=o&&o.size==0,i=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(i<0)return null;let a=r.resolve(i),l,c;if(Wf(n)){for(l=i;o&&!o.node;)o=o.parent;let d=o.node;if(o&&d.isAtom&&me.isSelectable(d)&&o.parent&&!(d.isInline&&F$(n.focusNode,n.focusOffset,o.dom))){let f=o.posBefore;c=new me(i==f?a:r.resolve(f))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=i,f=i;for(let h=0;h<n.rangeCount;h++){let p=n.getRangeAt(h);d=Math.min(d,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[l,i]=f==t.state.selection.anchor?[f,d]:[d,f],a=r.resolve(i)}else l=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let u=r.resolve(l);if(!c){let d=e=="pointer"||t.state.selection.head<a.pos&&!s?1:-1;c=Uy(t,u,a,d)}return c}function $T(t){return t.editable?t.hasFocus():UT(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Co(t,e=!1){let n=t.state.selection;if(FT(t,n),!!$T(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&en){let r=t.domSelectionRange(),o=t.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&si(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)pF(t);else{let{anchor:r,head:o}=n,s,i;yw&&!(n instanceof we)&&(n.$from.parent.inlineContent||(s=bw(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(i=bw(t,n.to))),t.docView.setSelection(r,o,t,e),yw&&(s&&vw(s),i&&vw(i)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&hF(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const yw=un||en&&TT<63;function bw(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),o=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(un&&o&&o.contentEditable=="false")return gp(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return gp(o);if(s)return gp(s)}}function gp(t){return t.contentEditable="true",un&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function vw(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function hF(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=o)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!$T(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function pF(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Xt(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ln&&us<=11&&(n.disabled=!0,n.disabled=!1)}function FT(t,e){if(e instanceof me){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(ww(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else ww(t)}function ww(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Uy(t,e,n,r){return t.someProp("createSelectionBetween",o=>o(t,e,n))||we.between(e,n,r)}function xw(t){return t.editable&&!t.hasFocus()?!1:UT(t)}function UT(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function mF(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return si(e.node,e.offset,n.anchorNode,n.anchorOffset)}function qm(t,e){let{$anchor:n,$head:r}=t.selection,o=e>0?n.max(r):n.min(r),s=o.parent.inlineContent?o.depth?t.doc.resolve(e>0?o.after():o.before()):null:o;return s&&Re.findFrom(s,e)}function Xo(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Ew(t,e,n){let r=t.state.selection;if(r instanceof we)if(n.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=t.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return Xo(t,new we(r.$anchor,i))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let o=qm(t.state,e);return o&&o instanceof me?Xo(t,o):!1}else if(!(nr&&n.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let a=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=t.docView.descAt(a))&&!i.contentDOM?me.isSelectable(s)?Xo(t,new me(e<0?t.state.doc.resolve(o.pos-s.nodeSize):o)):Tc?Xo(t,new we(t.state.doc.resolve(e<0?a:a+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof me&&r.node.isInline)return Xo(t,new we(e>0?r.$to:r.$from));{let o=qm(t.state,e);return o?Xo(t,o):!1}}}function dd(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function wl(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Ii(t,e){return e<0?gF(t):yF(t)}function gF(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,s,i=!1;for(ir&&n.nodeType==1&&r<dd(n)&&wl(n.childNodes[r],-1)&&(i=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(wl(a,-1))o=n,s=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(BT(n))break;{let a=n.previousSibling;for(;a&&wl(a,-1);)o=n.parentNode,s=Xt(a),a=a.previousSibling;if(a)n=a,r=dd(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}i?Ym(t,n,r):o&&Ym(t,o,s)}function yF(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o=dd(n),s,i;for(;;)if(r<o){if(n.nodeType!=1)break;let a=n.childNodes[r];if(wl(a,1))s=n,i=++r;else break}else{if(BT(n))break;{let a=n.nextSibling;for(;a&&wl(a,1);)s=a.parentNode,i=Xt(a)+1,a=a.nextSibling;if(a)n=a,r=0,o=dd(n);else{if(n=n.parentNode,n==t.dom)break;r=o=0}}}s&&Ym(t,s,i)}function BT(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function bF(t,e){for(;t&&e==t.childNodes.length&&!kc(t);)e=Xt(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function vF(t,e){for(;t&&!e&&!kc(t);)e=Xt(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Ym(t,e,n){if(e.nodeType!=3){let s,i;(i=bF(e,n))?(e=i,n=0):(s=vF(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Wf(r)){let s=document.createRange();s.setEnd(e,n),s.setStart(e,n),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:o}=t;setTimeout(()=>{t.state==o&&Co(t)},50)}function Sw(t,e){let n=t.state.doc.resolve(e);if(!(en||CT)&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let s=t.coordsAtPos(e-1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<n.end()){let s=t.coordsAtPos(e+1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function kw(t,e,n){let r=t.state.selection;if(r instanceof we&&!r.empty||n.indexOf("s")>-1||nr&&n.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let i=qm(t.state,e);if(i&&i instanceof me)return Xo(t,i)}if(!o.parent.inlineContent){let i=e<0?o:s,a=r instanceof Pn?Re.near(i,e):Re.findFrom(i,e);return a?Xo(t,a):!1}return!1}function Tw(t,e){if(!(t.state.selection instanceof we))return!0;let{$head:n,$anchor:r,empty:o}=t.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let i=t.state.tr;return e<0?i.delete(n.pos-s.nodeSize,n.pos):i.delete(n.pos,n.pos+s.nodeSize),t.dispatch(i),!0}return!1}function Cw(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function wF(t){if(!un||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Cw(t,r,"true"),setTimeout(()=>Cw(t,r,"false"),20)}return!1}function xF(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function EF(t,e){let n=e.keyCode,r=xF(e);if(n==8||nr&&n==72&&r=="c")return Tw(t,-1)||Ii(t,-1);if(n==46&&!e.shiftKey||nr&&n==68&&r=="c")return Tw(t,1)||Ii(t,1);if(n==13||n==27)return!0;if(n==37||nr&&n==66&&r=="c"){let o=n==37?Sw(t,t.state.selection.from)=="ltr"?-1:1:-1;return Ew(t,o,r)||Ii(t,o)}else if(n==39||nr&&n==70&&r=="c"){let o=n==39?Sw(t,t.state.selection.from)=="ltr"?1:-1:1;return Ew(t,o,r)||Ii(t,o)}else{if(n==38||nr&&n==80&&r=="c")return kw(t,-1,r)||Ii(t,-1);if(n==40||nr&&n==78&&r=="c")return wF(t)||kw(t,1,r)||Ii(t,1);if(r==(nr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function By(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=t.someProp("clipboardSerializer")||xi.fromSchema(t.state.schema),a=GT(),l=a.createElement("div");l.appendChild(i.serializeFragment(r,{document:a}));let c=l.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=KT[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=a.createElement(u[h]);for(;l.firstChild;)p.appendChild(l.firstChild);l.appendChild(p),d++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
13
-
14
- `);return{dom:l,text:f,slice:e}}function zT(t,e,n,r,o){let s=o.parent.type.spec.code,i,a;if(!n&&!e)return null;let l=!!e&&(r||s||!n);if(l){if(t.someProp("transformPastedText",f=>{e=f(e,s||r,t)}),s)return a=new ie(X.from(t.state.schema.text(e.replace(/\r\n?/g,`
15
- `))),0,0),t.someProp("transformPasted",f=>{a=f(a,t,!0)}),a;let d=t.someProp("clipboardTextParser",f=>f(e,o,r,t));if(d)a=d;else{let f=o.marks(),{schema:h}=t.state,p=xi.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=i.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),i=CF(n),Tc&&AF(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(a||(a=(t.someProp("clipboardParser")||t.someProp("domParser")||yl.fromSchema(t.state.schema)).parseSlice(i,{preserveWhitespace:!!(l||u),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!SF.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)a=_F(Aw(a,+u[1],+u[2]),u[4]);else if(a=ie.maxOpen(kF(a.content,o),!0),a.openStart||a.openEnd){let d=0,f=0;for(let h=a.content.firstChild;d<a.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=a.content.lastChild;f<a.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);a=Aw(a,d,f)}return t.someProp("transformPasted",d=>{a=d(a,t,l)}),a}const SF=/^(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 kF(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let o=e.node(n).contentMatchAt(e.index(n)),s,i=[];if(t.forEach(a=>{if(!i)return;let l=o.findWrapping(a.type),c;if(!l)return i=null;if(c=i.length&&s.length&&VT(l,s,a,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=WT(i[i.length-1],s.length));let u=HT(a,l);i.push(u),o=o.matchType(u.type),s=l}}),i)return X.from(i)}return t}function HT(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,X.from(t));return t}function VT(t,e,n,r,o){if(o<t.length&&o<e.length&&t[o]==e[o]){let s=VT(t,e,n,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==t.length-1?n.type:t[o+1]))return r.copy(r.content.append(X.from(HT(n,t,o+1))))}}function WT(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,WT(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(X.empty,!0);return t.copy(n.append(r))}function Jm(t,e,n,r,o,s){let i=e<0?t.firstChild:t.lastChild,a=i.content;return t.childCount>1&&(s=0),o<r-1&&(a=Jm(a,e,n,r,o+1,s)),o>=n&&(a=e<0?i.contentMatchAt(0).fillBefore(a,s<=o).append(a):a.append(i.contentMatchAt(i.childCount).fillBefore(X.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,i.copy(a))}function Aw(t,e,n){return e<t.openStart&&(t=new ie(Jm(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new ie(Jm(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const KT={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 _w=null;function GT(){return _w||(_w=document.implementation.createHTMLDocument("title"))}let yp=null;function TF(t){let e=window.trustedTypes;return e?(yp||(yp=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),yp.createHTML(t)):t}function CF(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=GT().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),o;if((o=r&&KT[r[1].toLowerCase()])&&(t=o.map(s=>"<"+s+">").join("")+t+o.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=TF(t),o)for(let s=0;s<o.length;s++)n=n.querySelector(o[s])||n;return n}function AF(t){let e=t.querySelectorAll(en?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function _F(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:o,openStart:s,openEnd:i}=t;for(let a=r.length-2;a>=0;a-=2){let l=n.nodes[r[a]];if(!l||l.hasRequiredAttrs())break;o=X.from(l.create(r[a+1],o)),s++,i++}return new ie(o,s,i)}const wn={},xn={},MF={touchstart:!0,touchmove:!0};class OF{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function RF(t){for(let e in wn){let n=wn[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{IF(t,r)&&!zy(t,r)&&(t.editable||!(r.type in xn))&&n(t,r)},MF[e]?{passive:!0}:void 0)}un&&t.dom.addEventListener("input",()=>null),Xm(t)}function is(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function NF(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Xm(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>zy(t,r))})}function zy(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function IF(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function DF(t,e){!zy(t,e)&&wn[e.type]&&(t.editable||!(e.type in xn))&&wn[e.type](t,e)}xn.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!YT(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Eo&&en&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),ia&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",o=>o(t,js(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||EF(t,n)?n.preventDefault():is(t,"key")};xn.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};xn.keypress=(t,e)=>{let n=e;if(YT(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||nr&&n.metaKey)return;if(t.someProp("handleKeyPress",o=>o(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof we)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(n.charCode),s=()=>t.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!t.someProp("handleTextInput",i=>i(t,r.$from.pos,r.$to.pos,o,s))&&t.dispatch(s()),n.preventDefault()}};function Gf(t){return{left:t.clientX,top:t.clientY}}function PF(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Hy(t,e,n,r,o){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(t.someProp(e,a=>i>s.depth?a(t,n,s.nodeAfter,s.before(i),o,!0):a(t,n,s.node(i),s.before(i),o,!1)))return!0;return!1}function Gi(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function LF(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&me.isSelectable(r)?(Gi(t,new me(n)),!0):!1}function jF(t,e){if(e==-1)return!1;let n=t.state.selection,r,o;n instanceof me&&(r=n.node);let s=t.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let a=i>s.depth?s.nodeAfter:s.node(i);if(me.isSelectable(a)){r&&n.$from.depth>0&&i>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?o=s.before(n.$from.depth):o=s.before(i);break}}return o!=null?(Gi(t,me.create(t.state.doc,o)),!0):!1}function $F(t,e,n,r,o){return Hy(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(o?jF(t,n):LF(t,n))}function FF(t,e,n,r){return Hy(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",o=>o(t,e,r))}function UF(t,e,n,r){return Hy(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",o=>o(t,e,r))||BF(t,n,r)}function BF(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Gi(t,we.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),a=o.before(s);if(i.inlineContent)Gi(t,we.create(r,a+1,a+1+i.content.size));else if(me.isSelectable(i))Gi(t,me.create(r,a));else continue;return!0}}function Vy(t){return fd(t)}const qT=nr?"metaKey":"ctrlKey";wn.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Vy(t),o=Date.now(),s="singleClick";o-t.input.lastClick.time<500&&PF(n,t.input.lastClick)&&!n[qT]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:s,button:n.button};let i=t.posAtCoords(Gf(n));i&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new zF(t,i,n,!!r)):(s=="doubleClick"?FF:UF)(t,i.pos,i.inside,n)?n.preventDefault():is(t,"pointer"))};class zF{constructor(e,n,r,o){this.view=e,this.pos=n,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[qT],this.allowDefault=r.shiftKey;let s,i;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),i=n.inside;else{let u=e.state.doc.resolve(n.pos);s=u.parent,i=u.depth?u.before():0}const a=o?null:r.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&l.nodeDOM.nodeType==1?l.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof me&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ir&&!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)),is(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(()=>Co(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Gf(e))),this.updateAllowDefault(e),this.allowDefault||!n?is(this.view,"pointer"):$F(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||un&&this.mightDrag&&!this.mightDrag.node.isAtom||en&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Gi(this.view,Re.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):is(this.view,"pointer")}move(e){this.updateAllowDefault(e),is(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)}}wn.touchstart=t=>{t.input.lastTouch=Date.now(),Vy(t),is(t,"pointer")};wn.touchmove=t=>{t.input.lastTouch=Date.now(),is(t,"pointer")};wn.contextmenu=t=>Vy(t);function YT(t,e){return t.composing?!0:un&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const HF=Eo?5e3:-1;xn.compositionstart=xn.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof we&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||en&&CT&&VF(t)))t.markCursor=t.state.storedMarks||n.marks(),fd(t,!0),t.markCursor=null;else if(fd(t,!e.selection.empty),ir&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){let a=t.domSelection();a&&a.collapse(i,i.nodeValue.length);break}else o=i,s=-1}}t.input.composing=!0}JT(t,HF)};function VF(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}xn.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,JT(t,20))};function JT(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>fd(t),e))}function XT(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=KF());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function WF(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=j$(e.focusNode,e.focusOffset),r=$$(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let o=r.pmViewDesc,s=t.domObserver.lastChangedTextNode;if(n==s||r==s)return s;if(!o||!o.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let i=n.pmViewDesc;if(!(!i||!i.isText(n.nodeValue)))return r}}return n||r}function KF(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function fd(t,e=!1){if(!(Eo&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),XT(t),e||t.docView&&t.docView.dirty){let n=Fy(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function GF(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const zl=Ln&&us<15||ia&&z$<604;wn.copy=xn.cut=(t,e)=>{let n=e,r=t.state.selection,o=n.type=="cut";if(r.empty)return;let s=zl?null:n.clipboardData,i=r.content(),{dom:a,text:l}=By(t,i);s?(n.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):GF(t,a),o&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function qF(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function YF(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Hl(t,r.value,null,o,e):Hl(t,r.textContent,r.innerHTML,o,e)},50)}function Hl(t,e,n,r,o){let s=zT(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,o,s||ie.empty)))return!0;if(!s)return!1;let i=qF(s),a=i?t.state.tr.replaceSelectionWith(i,r):t.state.tr.replaceSelection(s);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function QT(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}xn.paste=(t,e)=>{let n=e;if(t.composing&&!Eo)return;let r=zl?null:n.clipboardData,o=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Hl(t,QT(r),r.getData("text/html"),o,n)?n.preventDefault():YF(t,n)};class ZT{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const JF=nr?"altKey":"ctrlKey";function eC(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[JF]}wn.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o=t.state.selection,s=o.empty?null:t.posAtCoords(Gf(n)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof me?o.to-1:o.to))){if(r&&r.mightDrag)i=me.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(i=me.create(t.state.doc,d.posBefore))}}let a=(i||t.state.selection).content(),{dom:l,text:c,slice:u}=By(t,a);(!n.dataTransfer.files.length||!en||TT>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(zl?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",zl||n.dataTransfer.setData("text/plain",c),t.dragging=new ZT(u,eC(t,n),i)};wn.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};xn.dragover=xn.dragenter=(t,e)=>e.preventDefault();xn.drop=(t,e)=>{try{XF(t,e,t.dragging)}finally{t.dragging=null}};function XF(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Gf(e));if(!r)return;let o=t.state.doc.resolve(r.pos),s=n&&n.slice;s?t.someProp("transformPasted",h=>{s=h(s,t,!1)}):s=zT(t,QT(e.dataTransfer),zl?null:e.dataTransfer.getData("text/html"),!1,o);let i=!!(n&&eC(t,e));if(t.someProp("handleDrop",h=>h(t,e,s||ie.empty,i))){e.preventDefault();return}if(!s)return;e.preventDefault();let a=s?rT(t.state.doc,o.pos,s):o.pos;a==null&&(a=o.pos);let l=t.state.tr;if(i){let{node:h}=n;h?h.replace(l):l.deleteSelection()}let c=l.mapping.map(a),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=l.doc;if(u?l.replaceRangeWith(c,c,s.content.firstChild):l.replaceRange(c,c,s),l.doc.eq(d))return;let f=l.doc.resolve(c);if(u&&me.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))l.setSelection(new me(f));else{let h=l.mapping.map(a);l.mapping.maps[l.mapping.maps.length-1].forEach((p,m,g,b)=>h=b),l.setSelection(Uy(t,f,l.doc.resolve(h)))}t.focus(),t.dispatch(l.setMeta("uiEvent","drop"))}wn.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Co(t)},20))};wn.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};wn.beforeinput=(t,e)=>{if(en&&Eo&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",s=>s(t,js(8,"Backspace")))))return;let{$cursor:o}=t.state.selection;o&&o.pos>0&&t.dispatch(t.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let t in xn)wn[t]=xn[t];function Vl(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class hd{constructor(e,n){this.toDOM=e,this.spec=n||Js,this.side=this.spec.side||0}map(e,n,r,o){let{pos:s,deleted:i}=e.mapResult(n.from+o,this.side<0?-1:1);return i?null:new tn(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof hd&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Vl(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class fs{constructor(e,n){this.attrs=e,this.spec=n||Js}map(e,n,r,o){let s=e.map(n.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(n.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new tn(s,i,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof fs&&Vl(this.attrs,e.attrs)&&Vl(this.spec,e.spec)}static is(e){return e.type instanceof fs}destroy(){}}class Wy{constructor(e,n){this.attrs=e,this.spec=n||Js}map(e,n,r,o){let s=e.mapResult(n.from+o,1);if(s.deleted)return null;let i=e.mapResult(n.to+o,-1);return i.deleted||i.pos<=s.pos?null:new tn(s.pos-r,i.pos-r,this)}valid(e,n){let{index:r,offset:o}=e.content.findIndex(n.from),s;return o==n.from&&!(s=e.child(r)).isText&&o+s.nodeSize==n.to}eq(e){return this==e||e instanceof Wy&&Vl(this.attrs,e.attrs)&&Vl(this.spec,e.spec)}destroy(){}}class tn{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new tn(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new tn(e,e,new hd(n,r))}static inline(e,n,r,o){return new tn(e,n,new fs(r,o))}static node(e,n,r,o){return new tn(e,n,new Wy(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof fs}get widget(){return this.type instanceof hd}}const Ui=[],Js={};class ft{constructor(e,n){this.local=e.length?e:Ui,this.children=n.length?n:Ui}static create(e,n){return n.length?pd(n,e,0,Js):sn}find(e,n,r){let o=[];return this.findInner(e??0,n??1e9,o,0,r),o}findInner(e,n,r,o,s){for(let i=0;i<this.local.length;i++){let a=this.local[i];a.from<=n&&a.to>=e&&(!s||s(a.spec))&&r.push(a.copy(a.from+o,a.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<n&&this.children[i+1]>e){let a=this.children[i]+1;this.children[i+2].findInner(e-a,n-a,r,o+a,s)}}map(e,n,r){return this==sn||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Js)}mapInner(e,n,r,o,s){let i;for(let a=0;a<this.local.length;a++){let l=this.local[a].map(e,r,o);l&&l.type.valid(n,l)?(i||(i=[])).push(l):s.onRemove&&s.onRemove(this.local[a].spec)}return this.children.length?QF(this.children,i||[],e,n,r,o,s):i?new ft(i.sort(Xs),Ui):sn}add(e,n){return n.length?this==sn?ft.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let o,s=0;e.forEach((a,l)=>{let c=l+r,u;if(u=nC(n,a,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<l;)s+=3;o[s]==l?o[s+2]=o[s+2].addInner(a,u,c+1):o.splice(s,0,l,l+a.nodeSize,pd(u,a,c+1,Js)),s+=3}});let i=tC(s?rC(n):n,-r);for(let a=0;a<i.length;a++)i[a].type.valid(e,i[a])||i.splice(a--,1);return new ft(i.length?this.local.concat(i).sort(Xs):this.local,o||this.children)}remove(e){return e.length==0||this==sn?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,a=r[s]+n,l=r[s+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>a&&d.to<l&&(e[u]=null,(i||(i=[])).push(d));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,a+1);c!=sn?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let a=0;a<o.length;a++)o[a].eq(i,n)&&(o==this.local&&(o=this.local.slice()),o.splice(a--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new ft(o,r):sn}forChild(e,n){if(this==sn)return this;if(n.isLeaf)return ft.empty;let r,o;for(let a=0;a<this.children.length;a+=3)if(this.children[a]>=e){this.children[a]==e&&(r=this.children[a+2]);break}let s=e+1,i=s+n.content.size;for(let a=0;a<this.local.length;a++){let l=this.local[a];if(l.from<i&&l.to>s&&l.type instanceof fs){let c=Math.max(s,l.from)-s,u=Math.min(i,l.to)-s;c<u&&(o||(o=[])).push(l.copy(c,u))}}if(o){let a=new ft(o.sort(Xs),Ui);return r?new es([a,r]):a}return r||sn}eq(e){if(this==e)return!0;if(!(e instanceof ft)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Ky(this.localsInner(e))}localsInner(e){if(this==sn)return Ui;if(e.inlineContent||!this.local.some(fs.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof fs||n.push(this.local[r]);return n}forEachSet(e){e(this)}}ft.empty=new ft([],[]);ft.removeOverlap=Ky;const sn=ft.empty;class es{constructor(e){this.members=e}map(e,n){const r=this.members.map(o=>o.map(e,n,Js));return es.from(r)}forChild(e,n){if(n.isLeaf)return ft.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,n);s!=sn&&(s instanceof es?r=r.concat(s.members):r.push(s))}return es.from(r)}eq(e){if(!(e instanceof es)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!n)n=s;else{r&&(n=n.slice(),r=!1);for(let i=0;i<s.length;i++)n.push(s[i])}}return n?Ky(r?n:n.sort(Xs)):Ui}static from(e){switch(e.length){case 0:return sn;case 1:return e[0];default:return new es(e.every(n=>n instanceof ft)?e:e.reduce((n,r)=>n.concat(r instanceof ft?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function QF(t,e,n,r,o,s,i){let a=t.slice();for(let c=0,u=s;c<n.maps.length;c++){let d=0;n.maps[c].forEach((f,h,p,m)=>{let g=m-p-(h-f);for(let b=0;b<a.length;b+=3){let S=a[b+1];if(S<0||f>S+u-d)continue;let k=a[b]+u-d;h>=k?a[b+1]=f<=k?-2:-1:f>=u&&g&&(a[b]+=g,a[b+1]+=g)}d+=g}),u=n.maps[c].map(u,-1)}let l=!1;for(let c=0;c<a.length;c+=3)if(a[c+1]<0){if(a[c+1]==-2){l=!0,a[c+1]=-1;continue}let u=n.map(t[c]+s),d=u-o;if(d<0||d>=r.content.size){l=!0;continue}let f=n.map(t[c+1]+s,-1),h=f-o,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==h){let b=a[c+2].mapInner(n,g,u+1,t[c]+s+1,i);b!=sn?(a[c]=d,a[c+1]=h,a[c+2]=b):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=ZF(a,t,e,n,o,s,i),u=pd(c,r,0,i);e=u.local;for(let d=0;d<a.length;d+=3)a[d+1]<0&&(a.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<a.length&&a[f]<h;)f+=3;a.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new ft(e.sort(Xs),a)}function tC(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let o=t[r];n.push(new tn(o.from+e,o.to+e,o.type))}return n}function ZF(t,e,n,r,o,s,i){function a(l,c){for(let u=0;u<l.local.length;u++){let d=l.local[u].map(r,o,c);d?n.push(d):i.onRemove&&i.onRemove(l.local[u].spec)}for(let u=0;u<l.children.length;u+=3)a(l.children[u+2],l.children[u]+c+1)}for(let l=0;l<t.length;l+=3)t[l+1]==-1&&a(t[l+2],e[l]+s+1);return n}function nC(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,o=null;for(let s=0,i;s<t.length;s++)(i=t[s])&&i.from>n&&i.to<r&&((o||(o=[])).push(i),t[s]=null);return o}function rC(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function pd(t,e,n,r){let o=[],s=!1;e.forEach((a,l)=>{let c=nC(t,a,l+n);if(c){s=!0;let u=pd(c,a,n+l+1,r);u!=sn&&o.push(l,l+a.nodeSize,u)}});let i=tC(s?rC(t):t,-n).sort(Xs);for(let a=0;a<i.length;a++)i[a].type.valid(e,i[a])||(r.onRemove&&r.onRemove(i[a].spec),i.splice(a--,1));return i.length||o.length?new ft(i,o):sn}function Xs(t,e){return t.from-e.from||t.to-e.to}function Ky(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let o=n+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==t&&(e=t.slice()),e[o]=s.copy(s.from,r.to),Mw(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),Mw(e,o,r.copy(s.from,r.to)));break}}}return e}function Mw(t,e,n){for(;e<t.length&&Xs(n,t[e])>0;)e++;t.splice(e,0,n)}function bp(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=sn&&e.push(r)}),t.cursorWrapper&&e.push(ft.create(t.state.doc,[t.cursorWrapper.deco])),es.from(e)}const eU={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},tU=Ln&&us<=11;class nU{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 rU{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new nU,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);Ln&&us<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():un&&e.composing&&r.some(o=>o.type=="childList"&&o.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),tU&&(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,eU)),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 n=0;n<e.length;n++)this.queue.push(e[n]);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(xw(this.view)){if(this.suppressingSelectionUpdates)return Co(this.view);if(Ln&&us<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&si(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 n=new Set,r;for(let s=e.focusNode;s;s=sa(s))n.add(s);for(let s=e.anchorNode;s;s=sa(s))if(n.has(s)){r=s;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.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 n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&xw(e)&&!this.ignoreSelectionChange(r),s=-1,i=-1,a=!1,l=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[u],l);d&&(s=s<0?d.from:Math.min(d.from,s),i=i<0?d.to:Math.max(d.to,i),d.typeOver&&(a=!0))}if(l.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of l)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&d.nodeType==1;){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(ir&&l.length){let u=l.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||iU(e,d)!=h)&&f.remove()}}}let c=null;s<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Wf(r)&&(c=Fy(e))&&c.eq(Re.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Co(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||o)&&(s>-1&&(e.docView.markDirty(s,i),oU(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,aU(e,l)),this.handleDOMChange(s,i,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Co(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,s=e.nextSibling;if(Ln&&us<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(o=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(s=f)}let i=o&&o.parentNode==e.target?Xt(o)+1:0,a=r.localPosFromDOM(e.target,i,-1),l=s&&s.parentNode==e.target?Xt(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,l,1);return{from:a,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Ow=new WeakMap,Rw=!1;function oU(t){if(!Ow.has(t)&&(Ow.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=ir,Rw)return;Rw=!0}}function Nw(t,e){let n=e.startContainer,r=e.startOffset,o=e.endContainer,s=e.endOffset,i=t.domAtPos(t.state.selection.anchor);return si(i.node,i.offset,o,s)&&([n,r,o,s]=[o,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:s}}function sU(t,e){if(e.getComposedRanges){let o=e.getComposedRanges(t.root)[0];if(o)return Nw(t,o)}let n;function r(o){o.preventDefault(),o.stopImmediatePropagation(),n=o.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Nw(t,n):null}function iU(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function aU(t,e){var n;let{focusNode:r,focusOffset:o}=t.domSelectionRange();for(let s of e)if(((n=s.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let i=s.nextSibling;for(;i&&i.nodeName!="TD"&&i.nodeName!="TH";)i=i.nextSibling;if(i){let a=i;for(;;){let l=a.firstChild;if(!l||l.nodeType!=1||l.contentEditable=="false"||/^(BR|IMG)$/.test(l.nodeName))break;a=l}a.insertBefore(s,a.firstChild),r==s&&t.domSelection().collapse(s,o)}else s.parentNode.removeChild(s)}}function lU(t,e,n){let{node:r,fromOffset:o,toOffset:s,from:i,to:a}=t.docView.parseRange(e,n),l=t.domSelectionRange(),c,u=l.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:l.anchorOffset}],Wf(l)||c.push({node:l.focusNode,offset:l.focusOffset})),en&&t.input.lastKeyCode===8)for(let g=s;g>o;g--){let b=r.childNodes[g-1],S=b.pmViewDesc;if(b.nodeName=="BR"&&!S){s=g;break}if(!S||S.size)break}let d=t.state.doc,f=t.someProp("domParser")||yl.fromSchema(t.state.schema),h=d.resolve(i),p=null,m=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:o,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:cU,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),p={anchor:g+i,head:b+i}}return{doc:m,sel:p,from:i,to:a}}function cU(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(un&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||un&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const uU=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function dU(t,e,n,r,o){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let A=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,E=Fy(t,A);if(E&&!t.state.selection.eq(E)){if(en&&Eo&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",N=>N(t,js(13,"Enter"))))return;let T=t.state.tr.setSelection(E);A=="pointer"?T.setMeta("pointer",!0):A=="key"&&T.scrollIntoView(),s&&T.setMeta("composition",s),t.dispatch(T)}return}let i=t.state.doc.resolve(e),a=i.sharedDepth(n);e=i.before(a+1),n=t.state.doc.resolve(n).after(a+1);let l=t.state.selection,c=lU(t,e,n),u=t.state.doc,d=u.slice(c.from,c.to),f,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(f=t.state.selection.to,h="end"):(f=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let p=pU(d.content,c.doc.content,c.from,f,h);if(p&&t.input.domChangeCount++,(ia&&t.input.lastIOSEnter>Date.now()-225||Eo)&&o.some(A=>A.nodeType==1&&!uU.test(A.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",A=>A(t,js(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&l instanceof we&&!l.empty&&l.$head.sameParent(l.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let A=Iw(t,t.state.doc,c.sel);if(A&&!A.eq(t.state.selection)){let E=t.state.tr.setSelection(A);s&&E.setMeta("composition",s),t.dispatch(E)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof we&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),Ln&&us<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),b=u.resolve(p.start),S=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=p.endA;if((ia&&t.input.lastIOSEnter>Date.now()-225&&(!S||o.some(A=>A.nodeName=="DIV"||A.nodeName=="P"))||!S&&m.pos<c.doc.content.size&&(!m.sameParent(g)||!m.parent.inlineContent)&&m.pos<g.pos&&!/\S/.test(c.doc.textBetween(m.pos,g.pos,"","")))&&t.someProp("handleKeyDown",A=>A(t,js(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&hU(u,p.start,p.endA,m,g)&&t.someProp("handleKeyDown",A=>A(t,js(8,"Backspace")))){Eo&&en&&t.domObserver.suppressSelectionUpdates();return}en&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),Eo&&!S&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(A){return A(t,js(13,"Enter"))})},20));let k=p.start,v=p.endA,_=A=>{let E=A||t.state.tr.replace(k,v,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let T=Iw(t,E.doc,c.sel);T&&!(en&&t.composing&&T.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(T.head==k||T.head==E.mapping.map(v)-1)||Ln&&T.empty&&T.head==k)&&E.setSelection(T)}return s&&E.setMeta("composition",s),E.scrollIntoView()},x;if(S)if(m.pos==g.pos){Ln&&us<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Co(t),20));let A=_(t.state.tr.delete(k,v)),E=u.resolve(p.start).marksAcross(u.resolve(p.endA));E&&A.ensureMarks(E),t.dispatch(A)}else if(p.endA==p.endB&&(x=fU(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start())))){let A=_(t.state.tr);x.type=="add"?A.addMark(k,v,x.mark):A.removeMark(k,v,x.mark),t.dispatch(A)}else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let A=m.parent.textBetween(m.parentOffset,g.parentOffset),E=()=>_(t.state.tr.insertText(A,k,v));t.someProp("handleTextInput",T=>T(t,k,v,A,E))||t.dispatch(E())}else t.dispatch(_());else t.dispatch(_())}function Iw(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Uy(t,e.resolve(n.anchor),e.resolve(n.head))}function fU(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,o=n,s=r,i,a,l;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<n.length;u++)s=n[u].removeFromSet(s);if(o.length==1&&s.length==0)a=o[0],i="add",l=u=>u.mark(a.addToSet(u.marks));else if(o.length==0&&s.length==1)a=s[0],i="remove",l=u=>u.mark(a.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(l(e.child(u)));if(X.from(c).eq(t))return{mark:a,type:i}}function hU(t,e,n,r,o){if(n-e<=o.pos-r.pos||vp(r,!0,!1)<o.pos)return!1;let s=t.resolve(e);if(!r.parent.isTextblock){let a=s.nodeAfter;return a!=null&&n==e+a.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let i=t.resolve(vp(s,!0,!0));return!i.parent.isTextblock||i.pos>n||vp(i,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function vp(t,e,n){let r=t.depth,o=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n){let s=t.node(r).maybeChild(t.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,o++}return o}function pU(t,e,n,r,o){let s=t.findDiffStart(e,n);if(s==null)return null;let{a:i,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);if(o=="end"){let l=Math.max(0,s-Math.min(i,a));r-=i+l-s}if(i<s&&t.size<e.size){let l=r<=s&&r>=i?s-r:0;s-=l,s&&s<e.size&&Dw(e.textBetween(s-1,s+1))&&(s+=l?1:-1),a=s+(a-i),i=s}else if(a<s){let l=r<=s&&r>=a?s-r:0;s-=l,s&&s<t.size&&Dw(t.textBetween(s-1,s+1))&&(s+=l?1:-1),i=s+(i-a),a=s}return{start:s,endA:i,endB:a}}function Dw(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class oC{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new OF,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Fw),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=jw(this),Lw(this),this.nodeViews=$w(this),this.docView=mw(this.state.doc,Pw(this),bp(this),this.dom,this),this.domObserver=new rU(this,(r,o,s,i)=>dU(this,r,o,s,i)),this.domObserver.start(),RF(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Xm(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Fw),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let o=this.state,s=!1,i=!1;e.storedMarks&&this.composing&&(XT(this),i=!0),this.state=e;let a=o.plugins!=e.plugins||this._props.plugins!=n.plugins;if(a||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=$w(this);gU(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(a||n.handleDOMEvents!=this._props.handleDOMEvents)&&Xm(this),this.editable=jw(this),Lw(this);let l=bp(this),c=Pw(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",d=s||!this.docView.matchesNode(e.doc,c,l);(d||!e.selection.eq(o.selection))&&(i=!0);let f=u=="preserve"&&i&&this.dom.style.overflowAnchor==null&&W$(this);if(i){this.domObserver.stop();let h=d&&(Ln||en)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&mU(o.selection,e.selection);if(d){let p=en?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=WF(this)),(s||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=mw(e.doc,c,l,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&mF(this))?Co(this,h):(FT(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&K$(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof me){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&cw(this,n.getBoundingClientRect(),e)}else cw(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,o=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let s=r.from+(this.state.doc.content.size-n.doc.content.size);(s>0&&s<this.state.doc.content.size&&this.state.doc.nodeAt(s))==r.node&&(o=s)}this.dragging=new ZT(e.slice,e.move,o<0?void 0:me.create(this.state.doc,o))}someProp(e,n){let r=this._props&&this._props[e],o;if(r!=null&&(o=n?n(r):r))return o;for(let i=0;i<this.directPlugins.length;i++){let a=this.directPlugins[i].props[e];if(a!=null&&(o=n?n(a):a))return o}let s=this.state.plugins;if(s)for(let i=0;i<s.length;i++){let a=s[i].props[e];if(a!=null&&(o=n?n(a):a))return o}}hasFocus(){if(Ln){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&&G$(this.dom),Co(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Q$(this,e)}coordsAtPos(e,n=1){return RT(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let o=this.docView.posFromDOM(e,n,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,n){return rF(this,n||this.state,e)}pasteHTML(e,n){return Hl(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Hl(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return By(this,e)}destroy(){this.docView&&(NF(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],bp(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,P$())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return DF(this,e)}domSelectionRange(){let e=this.domSelection();return e?un&&this.root.nodeType===11&&U$(this.dom.ownerDocument)==this.dom&&sU(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}oC.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Pw(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[tn.node(0,t.state.doc.content.size,e)]}function Lw(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:tn.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function jw(t){return!t.someProp("editable",e=>e(t.state)===!1)}function mU(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function $w(t){let e=Object.create(null);function n(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function gU(t,e){let n=0,r=0;for(let o in t){if(t[o]!=e[o])return!0;n++}for(let o in e)r++;return n!=r}function Fw(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var gs={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:"'"},md={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},yU=typeof navigator<"u"&&/Mac/.test(navigator.platform),bU=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Qt=0;Qt<10;Qt++)gs[48+Qt]=gs[96+Qt]=String(Qt);for(var Qt=1;Qt<=24;Qt++)gs[Qt+111]="F"+Qt;for(var Qt=65;Qt<=90;Qt++)gs[Qt]=String.fromCharCode(Qt+32),md[Qt]=String.fromCharCode(Qt);for(var wp in gs)md.hasOwnProperty(wp)||(md[wp]=gs[wp]);function vU(t){var e=yU&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||bU&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?md:gs)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const wU=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),xU=typeof navigator<"u"&&/Win/.test(navigator.platform);function EU(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,o,s,i;for(let a=0;a<e.length-1;a++){let l=e[a];if(/^(cmd|meta|m)$/i.test(l))i=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))o=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))wU?i=!0:o=!0;else throw new Error("Unrecognized modifier name: "+l)}return r&&(n="Alt-"+n),o&&(n="Ctrl-"+n),i&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function SU(t){let e=Object.create(null);for(let n in t)e[EU(n)]=t[n];return e}function xp(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function kU(t){return new Ye({props:{handleKeyDown:sC(t)}})}function sC(t){let e=SU(t);return function(n,r){let o=vU(r),s,i=e[xp(o,r)];if(i&&i(n.state,n.dispatch,n))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let a=e[xp(o,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(xU&&r.ctrlKey&&r.altKey)&&(s=gs[r.keyCode])&&s!=o){let a=e[xp(s,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}var TU=Object.defineProperty,Gy=(t,e)=>{for(var n in e)TU(t,n,{get:e[n],enumerable:!0})};function qf(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:o}=n,{storedMarks:s}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,s=n.storedMarks,n}}}var Yf=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:o}=n,s=this.buildProps(o);return Object.fromEntries(Object.entries(t).map(([i,a])=>[i,(...c)=>{const u=a(...c)(s);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(o),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:o}=this,{view:s}=r,i=[],a=!!t,l=t||o.tr,c=()=>(!a&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(l),i.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(n).map(([d,f])=>[d,(...p)=>{const m=this.buildProps(l,e),g=f(...p)(m);return i.push(g),u}])),run:c};return u}createCan(t){const{rawCommands:e,state:n}=this,r=!1,o=t||n.tr,s=this.buildProps(o,r);return{...Object.fromEntries(Object.entries(e).map(([a,l])=>[a,(...c)=>l(...c)({...s,dispatch:void 0})])),chain:()=>this.createChain(o,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:o}=this,{view:s}=r,i={tr:t,editor:r,view:s,state:qf({state:o,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([a,l])=>[a,(...c)=>l(...c)(i)]))}};return i}},iC={};Gy(iC,{blur:()=>CU,clearContent:()=>AU,clearNodes:()=>_U,command:()=>MU,createParagraphNear:()=>OU,cut:()=>RU,deleteCurrentNode:()=>NU,deleteNode:()=>IU,deleteRange:()=>DU,deleteSelection:()=>PU,enter:()=>LU,exitCode:()=>jU,extendMarkRange:()=>$U,first:()=>FU,focus:()=>BU,forEach:()=>zU,insertContent:()=>HU,insertContentAt:()=>KU,joinBackward:()=>YU,joinDown:()=>qU,joinForward:()=>JU,joinItemBackward:()=>XU,joinItemForward:()=>QU,joinTextblockBackward:()=>ZU,joinTextblockForward:()=>eB,joinUp:()=>GU,keyboardShortcut:()=>nB,lift:()=>rB,liftEmptyBlock:()=>oB,liftListItem:()=>sB,newlineInCode:()=>iB,resetAttributes:()=>aB,scrollIntoView:()=>lB,selectAll:()=>cB,selectNodeBackward:()=>uB,selectNodeForward:()=>dB,selectParentNode:()=>fB,selectTextblockEnd:()=>hB,selectTextblockStart:()=>pB,setContent:()=>mB,setMark:()=>PB,setMeta:()=>LB,setNode:()=>jB,setNodeSelection:()=>$B,setTextDirection:()=>FB,setTextSelection:()=>UB,sinkListItem:()=>BB,splitBlock:()=>zB,splitListItem:()=>HB,toggleList:()=>VB,toggleMark:()=>WB,toggleNode:()=>KB,toggleWrap:()=>GB,undoInputRule:()=>qB,unsetAllMarks:()=>YB,unsetMark:()=>JB,unsetTextDirection:()=>XB,updateAttributes:()=>QB,wrapIn:()=>ZB,wrapInList:()=>e3});var CU=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),AU=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),_U=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:o}=r;return n&&o.forEach(({$from:s,$to:i})=>{t.doc.nodesBetween(s.pos,i.pos,(a,l)=>{if(a.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(l)),f=c.resolve(u.map(l+a.nodeSize)),h=d.blockRange(f);if(!h)return;const p=Aa(h);if(a.type.isTextblock){const{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},MU=t=>e=>t(e),OU=()=>({state:t,dispatch:e})=>wT(t,e),RU=(t,e)=>({editor:n,tr:r})=>{const{state:o}=n,s=o.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const i=r.mapping.map(e);return r.insert(i,s.content),r.setSelection(new we(r.doc.resolve(Math.max(i-1,0)))),!0},NU=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const o=t.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===r.type){if(e){const a=o.before(s),l=o.after(s);t.delete(a,l).scrollIntoView()}return!0}return!1};function Ot(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var IU=t=>({tr:e,state:n,dispatch:r})=>{const o=Ot(t,n.schema),s=e.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===o){if(r){const l=s.before(i),c=s.after(i);e.delete(l,c).scrollIntoView()}return!0}return!1},DU=t=>({tr:e,dispatch:n})=>{const{from:r,to:o}=t;return n&&e.delete(r,o),!0},PU=()=>({state:t,dispatch:e})=>Iy(t,e),LU=()=>({commands:t})=>t.keyboardShortcut("Enter"),jU=()=>({state:t,dispatch:e})=>w$(t,e);function qy(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function gd(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(o=>n.strict?e[o]===t[o]:qy(e[o])?e[o].test(t[o]):e[o]===t[o]):!0}function aC(t,e,n={}){return t.find(r=>r.type===e&&gd(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function Uw(t,e,n={}){return!!aC(t,e,n)}function Yy(t,e,n){var r;if(!t||!e)return;let o=t.parent.childAfter(t.parentOffset);if((!o.node||!o.node.marks.some(u=>u.type===e))&&(o=t.parent.childBefore(t.parentOffset)),!o.node||!o.node.marks.some(u=>u.type===e)||(n=n||((r=o.node.marks[0])==null?void 0:r.attrs),!aC([...o.node.marks],e,n)))return;let i=o.index,a=t.start()+o.offset,l=i+1,c=a+o.node.nodeSize;for(;i>0&&Uw([...t.parent.child(i-1).marks],e,n);)i-=1,a-=t.parent.child(i).nodeSize;for(;l<t.parent.childCount&&Uw([...t.parent.child(l).marks],e,n);)c+=t.parent.child(l).nodeSize,l+=1;return{from:a,to:c}}function Lo(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var $U=(t,e={})=>({tr:n,state:r,dispatch:o})=>{const s=Lo(t,r.schema),{doc:i,selection:a}=n,{$from:l,from:c,to:u}=a;if(o){const d=Yy(l,s,e);if(d&&d.from<=c&&d.to>=u){const f=we.create(i,d.from,d.to);n.setSelection(f)}}return!0},FU=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function lC(t){return t instanceof we}function Hs(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function cC(t,e=null){if(!e)return null;const n=Re.atStart(t),r=Re.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const o=n.from,s=r.to;return e==="all"?we.create(t,Hs(0,o,s),Hs(t.content.size,o,s)):we.create(t,Hs(e,o,s),Hs(e,o,s))}function yd(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function aa(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function UU(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var BU=(t=null,e={})=>({editor:n,view:r,tr:o,dispatch:s})=>{e={scrollIntoView:!0,...e};const i=()=>{(aa()||yd())&&r.dom.focus(),UU()&&!aa()&&!yd()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(s&&t===null&&!lC(n.state.selection))return i(),!0;const a=cC(o.doc,t)||n.state.selection,l=n.state.selection.eq(a);return s&&(l||o.setSelection(a),l&&o.storedMarks&&o.setStoredMarks(o.storedMarks),i()),!0},zU=(t,e)=>n=>t.every((r,o)=>e(r,{...n,index:o})),HU=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),uC=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&uC(r)}return t};function nu(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return uC(n)}function Wl(t,e,n){if(t instanceof ko||t instanceof X)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,o=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return X.fromArray(t.map(a=>e.nodeFromJSON(a)));const i=e.nodeFromJSON(t);return n.errorOnInvalidContent&&i.check(),i}catch(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return Wl("",e,n)}if(o){if(n.errorOnInvalidContent){let i=!1,a="";const l=new Kk({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(i=!0,a=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?yl.fromSchema(l).parseSlice(nu(t),n.parseOptions):yl.fromSchema(l).parse(nu(t),n.parseOptions),n.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const s=yl.fromSchema(e);return n.slice?s.parseSlice(nu(t),n.parseOptions).content:s.parse(nu(t),n.parseOptions)}return Wl("",e,n)}function VU(t,e,n){const r=t.steps.length-1;if(r<e)return;const o=t.steps[r];if(!(o instanceof Bt||o instanceof Ht))return;const s=t.mapping.maps[r];let i=0;s.forEach((a,l,c,u)=>{i===0&&(i=u)}),t.setSelection(Re.near(t.doc.resolve(i),n))}var WU=t=>!("type"in t),KU=(t,e,n)=>({tr:r,dispatch:o,editor:s})=>{var i;if(o){n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let a;const l=g=>{s.emit("contentError",{editor:s,error:g,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{Wl(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(g){l(g)}try{a=Wl(e,s.schema,{parseOptions:c,errorOnInvalidContent:(i=n.errorOnInvalidContent)!=null?i:s.options.enableContentCheck})}catch(g){return l(g),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,h=!0;if((WU(a)?a:[a]).forEach(g=>{g.check(),f=f?g.isText&&g.marks.length===0:!1,h=h?g.isBlock:!1}),u===d&&h){const{parent:g}=r.doc.resolve(u);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(u-=1,d+=1)}let m;if(f){if(Array.isArray(e))m=e.map(g=>g.text||"").join("");else if(e instanceof X){let g="";e.forEach(b=>{b.text&&(g+=b.text)}),m=g}else typeof e=="object"&&e&&e.text?m=e.text:m=e;r.insertText(m,u,d)}else{m=a;const g=r.doc.resolve(u),b=g.node(),S=g.parentOffset===0,k=b.isText||b.isTextblock,v=b.content.size>0;S&&k&&v&&(u=Math.max(0,u-1)),r.replaceWith(u,d,m)}n.updateSelection&&VU(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:m}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:m})}return!0},GU=()=>({state:t,dispatch:e})=>y$(t,e),qU=()=>({state:t,dispatch:e})=>b$(t,e),YU=()=>({state:t,dispatch:e})=>hT(t,e),JU=()=>({state:t,dispatch:e})=>yT(t,e),XU=()=>({state:t,dispatch:e,tr:n})=>{try{const r=zf(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},QU=()=>({state:t,dispatch:e,tr:n})=>{try{const r=zf(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},ZU=()=>({state:t,dispatch:e})=>m$(t,e),eB=()=>({state:t,dispatch:e})=>g$(t,e);function dC(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function tB(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,o,s,i;for(let a=0;a<e.length-1;a+=1){const l=e[a];if(/^(cmd|meta|m)$/i.test(l))i=!0;else if(/^a(lt)?$/i.test(l))r=!0;else if(/^(c|ctrl|control)$/i.test(l))o=!0;else if(/^s(hift)?$/i.test(l))s=!0;else if(/^mod$/i.test(l))aa()||dC()?i=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${l}`)}return r&&(n=`Alt-${n}`),o&&(n=`Ctrl-${n}`),i&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}var nB=t=>({editor:e,view:n,tr:r,dispatch:o})=>{const s=tB(t).split(/-(?!$)/),i=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),a=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,a))});return l?.steps.forEach(c=>{const u=c.map(r.mapping);u&&o&&r.maybeStep(u)}),!0};function ys(t,e,n={}){const{from:r,to:o,empty:s}=t.selection,i=e?Ot(e,t.schema):null,a=[];t.doc.nodesBetween(r,o,(d,f)=>{if(d.isText)return;const h=Math.max(r,f),p=Math.min(o,f+d.nodeSize);a.push({node:d,from:h,to:p})});const l=o-r,c=a.filter(d=>i?i.name===d.node.type.name:!0).filter(d=>gd(d.node.attrs,n,{strict:!1}));return s?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=l}var rB=(t,e={})=>({state:n,dispatch:r})=>{const o=Ot(t,n.schema);return ys(n,o,e)?v$(n,r):!1},oB=()=>({state:t,dispatch:e})=>xT(t,e),sB=t=>({state:e,dispatch:n})=>{const r=Ot(t,e.schema);return R$(r)(e,n)},iB=()=>({state:t,dispatch:e})=>vT(t,e);function Jf(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Bw(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,o)=>(n.includes(o)||(r[o]=t[o]),r),{})}var aB=(t,e)=>({tr:n,state:r,dispatch:o})=>{let s=null,i=null;const a=Jf(typeof t=="string"?t:t.name,r.schema);if(!a)return!1;a==="node"&&(s=Ot(t,r.schema)),a==="mark"&&(i=Lo(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{s&&s===u.type&&(l=!0,o&&n.setNodeMarkup(d,void 0,Bw(u.attrs,e))),i&&u.marks.length&&u.marks.forEach(f=>{i===f.type&&(l=!0,o&&n.addMark(d,d+u.nodeSize,i.create(Bw(f.attrs,e))))})})}),l},lB=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),cB=()=>({tr:t,dispatch:e})=>{if(e){const n=new Pn(t.doc);t.setSelection(n)}return!0},uB=()=>({state:t,dispatch:e})=>mT(t,e),dB=()=>({state:t,dispatch:e})=>bT(t,e),fB=()=>({state:t,dispatch:e})=>S$(t,e),hB=()=>({state:t,dispatch:e})=>C$(t,e),pB=()=>({state:t,dispatch:e})=>T$(t,e);function Qm(t,e,n={},r={}){return Wl(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var mB=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:o,tr:s,dispatch:i,commands:a})=>{const{doc:l}=s;if(r.preserveWhitespace!=="full"){const c=Qm(t,o.schema,r,{errorOnInvalidContent:e??o.options.enableContentCheck});return i&&s.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!n),!0}return i&&s.setMeta("preventUpdate",!n),a.insertContentAt({from:0,to:l.content.size},t,{parseOptions:r,errorOnInvalidContent:e??o.options.enableContentCheck})};function fC(t,e){const n=Lo(e,t.schema),{from:r,to:o,empty:s}=t.selection,i=[];s?(t.storedMarks&&i.push(...t.storedMarks),i.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,o,l=>{i.push(...l.marks)});const a=i.find(l=>l.type.name===n.name);return a?{...a.attrs}:{}}function hC(t,e){const n=new lT(t);return e.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}function gB(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function yB(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(o,s)=>{n(o)&&r.push({node:o,pos:s})}),r}function bB(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function Xf(t){return e=>bB(e.$from,t)}function ye(t,e,n){return t.config[e]===void 0&&t.parent?ye(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?ye(t.parent,e,n):null}):t.config[e]}function Jy(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=ye(e,"addExtensions",n);return r?[e,...Jy(r())]:e}).flat(10)}function Xy(t,e){const n=xi.fromSchema(e).serializeFragment(t),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(n),o.innerHTML}function pC(t){return typeof t=="function"}function st(t,e=void 0,...n){return pC(t)?e?t.bind(e)(...n):t(...n):t}function vB(t={}){return Object.keys(t).length===0&&t.constructor===Object}function la(t){const e=t.filter(o=>o.type==="extension"),n=t.filter(o=>o.type==="node"),r=t.filter(o=>o.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function mC(t){const e=[],{nodeExtensions:n,markExtensions:r}=la(t),o=[...n,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},i=n.filter(c=>c.name!=="text").map(c=>c.name),a=r.map(c=>c.name),l=[...i,...a];return t.forEach(c=>{const u={name:c.name,options:c.options,storage:c.storage,extensions:o},d=ye(c,"addGlobalAttributes",u);if(!d)return;d().forEach(h=>{let p;Array.isArray(h.types)?p=h.types:h.types==="*"?p=l:h.types==="nodes"?p=i:h.types==="marks"?p=a:p=[],p.forEach(m=>{Object.entries(h.attributes).forEach(([g,b])=>{e.push({type:m,name:g,attribute:{...s,...b}})})})})}),o.forEach(c=>{const u={name:c.name,options:c.options,storage:c.storage},d=ye(c,"addAttributes",u);if(!d)return;const f=d();Object.entries(f).forEach(([h,p])=>{const m={...s,...p};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:c.name,name:h,attribute:m})})}),e}function wB(t){const e=[];let n="",r=!1,o=!1,s=0;const i=t.length;for(let a=0;a<i;a+=1){const l=t[a];if(l==="'"&&!o){r=!r,n+=l;continue}if(l==='"'&&!r){o=!o,n+=l;continue}if(!r&&!o){if(l==="("){s+=1,n+=l;continue}if(l===")"&&s>0){s-=1,n+=l;continue}if(l===";"&&s===0){e.push(n),n="";continue}}n+=l}return n&&e.push(n),e}function zw(t){const e=[],n=wB(t||""),r=n.length;for(let o=0;o<r;o+=1){const s=n[o],i=s.indexOf(":");if(i===-1)continue;const a=s.slice(0,i).trim(),l=s.slice(i+1).trim();a&&l&&e.push([a,l])}return e}function Qe(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([o,s])=>{if(!r[o]){r[o]=s;return}if(o==="class"){const a=s?String(s).split(" "):[],l=r[o]?r[o].split(" "):[],c=a.filter(u=>!l.includes(u));r[o]=[...l,...c].join(" ")}else if(o==="style"){const a=new Map([...zw(r[o]),...zw(s)]);r[o]=Array.from(a.entries()).map(([l,c])=>`${l}: ${c}`).join("; ")}else r[o]=s}),r},{})}function ca(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>Qe(n,r),{})}function xB(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Hw(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const o=e.reduce((s,i)=>{const a=i.attribute.parseHTML?i.attribute.parseHTML(n):xB(n.getAttribute(i.name));return a==null?s:{...s,[i.name]:a}},{});return{...r,...o}}}}function Vw(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&vB(n)?!1:n!=null))}function Ww(t){var e,n;const r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function EB(t,e){var n;const r=mC(t),{nodeExtensions:o,markExtensions:s}=la(t),i=(n=o.find(c=>ye(c,"topNode")))==null?void 0:n.name,a=Object.fromEntries(o.map(c=>{const u=r.filter(b=>b.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((b,S)=>{const k=ye(S,"extendNodeSchema",d);return{...b,...k?k(c):{}}},{}),h=Vw({...f,content:st(ye(c,"content",d)),marks:st(ye(c,"marks",d)),group:st(ye(c,"group",d)),inline:st(ye(c,"inline",d)),atom:st(ye(c,"atom",d)),selectable:st(ye(c,"selectable",d)),draggable:st(ye(c,"draggable",d)),code:st(ye(c,"code",d)),whitespace:st(ye(c,"whitespace",d)),linebreakReplacement:st(ye(c,"linebreakReplacement",d)),defining:st(ye(c,"defining",d)),isolating:st(ye(c,"isolating",d)),attrs:Object.fromEntries(u.map(Ww))}),p=st(ye(c,"parseHTML",d));p&&(h.parseDOM=p.map(b=>Hw(b,u)));const m=ye(c,"renderHTML",d);m&&(h.toDOM=b=>m({node:b,HTMLAttributes:ca(b,u)}));const g=ye(c,"renderText",d);return g&&(h.toText=g),[c.name,h]})),l=Object.fromEntries(s.map(c=>{const u=r.filter(g=>g.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((g,b)=>{const S=ye(b,"extendMarkSchema",d);return{...g,...S?S(c):{}}},{}),h=Vw({...f,inclusive:st(ye(c,"inclusive",d)),excludes:st(ye(c,"excludes",d)),group:st(ye(c,"group",d)),spanning:st(ye(c,"spanning",d)),code:st(ye(c,"code",d)),attrs:Object.fromEntries(u.map(Ww))}),p=st(ye(c,"parseHTML",d));p&&(h.parseDOM=p.map(g=>Hw(g,u)));const m=ye(c,"renderHTML",d);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:ca(g,u)})),[c.name,h]}));return new Kk({topNode:i,nodes:a,marks:l})}function SB(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function xl(t){return t.sort((n,r)=>{const o=ye(n,"priority")||100,s=ye(r,"priority")||100;return o>s?-1:o<s?1:0})}function gC(t){const e=xl(Jy(t));return SB(e.map(r=>r.name)).length,e}function yC(t,e,n){const{from:r,to:o}=e,{blockSeparator:s=`
16
-
17
- `,textSerializers:i={}}=n||{};let a="";return t.nodesBetween(r,o,(l,c,u,d)=>{var f;l.isBlock&&c>r&&(a+=s);const h=i?.[l.type.name];if(h)return u&&(a+=h({node:l,pos:c,parent:u,index:d,range:e})),!1;l.isText&&(a+=(f=l?.text)==null?void 0:f.slice(Math.max(r,c)-c,o-c))}),a}function kB(t,e){const n={from:0,to:t.content.size};return yC(t,n,e)}function bC(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function TB(t,e){const n=Ot(e,t.schema),{from:r,to:o}=t.selection,s=[];t.doc.nodesBetween(r,o,a=>{s.push(a)});const i=s.reverse().find(a=>a.type.name===n.name);return i?{...i.attrs}:{}}function vC(t,e){const n=Jf(typeof e=="string"?e:e.name,t.schema);return n==="node"?TB(t,e):n==="mark"?fC(t,e):{}}function CB(t,e=JSON.stringify){const n={};return t.filter(r=>{const o=e(r);return Object.prototype.hasOwnProperty.call(n,o)?!1:n[o]=!0})}function AB(t){const e=CB(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,i)=>i!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function wC(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((o,s)=>{const i=[];if(o.ranges.length)o.forEach((a,l)=>{i.push({from:a,to:l})});else{const{from:a,to:l}=n[s];if(a===void 0||l===void 0)return;i.push({from:a,to:l})}i.forEach(({from:a,to:l})=>{const c=e.slice(s).map(a,-1),u=e.slice(s).map(l),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),AB(r)}function Qy(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(o=>{const s=n.resolve(t),i=Yy(s,o.type);i&&r.push({mark:o,...i})}):n.nodesBetween(t,e,(o,s)=>{!o||o?.nodeSize===void 0||r.push(...o.marks.map(i=>({from:s,to:s+o.nodeSize,mark:i})))}),r}var _B=(t,e,n,r=20)=>{const o=t.doc.resolve(n);let s=r,i=null;for(;s>0&&i===null;){const a=o.node(s);a?.type.name===e?i=a:s-=1}return[i,s]};function Ha(t,e){return e.nodes[t]||e.marks[t]||null}function ju(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const o=t.find(s=>s.type===e&&s.name===r);return o?o.attribute.keepOnSplit:!1}))}var MB=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(o,s,i,a)=>{var l,c;const u=((c=(l=o.type.spec).toText)==null?void 0:c.call(l,{node:o,pos:s,parent:i,index:a}))||o.textContent||"%leaf%";n+=o.isAtom&&!o.isText?u:u.slice(0,Math.max(0,r-s))}),n};function Zm(t,e,n={}){const{empty:r,ranges:o}=t.selection,s=e?Lo(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>gd(d.attrs,n,{strict:!1}));let i=0;const a=[];if(o.forEach(({$from:d,$to:f})=>{const h=d.pos,p=f.pos;t.doc.nodesBetween(h,p,(m,g)=>{if(s&&m.inlineContent&&!m.type.allowsMarkType(s))return!1;if(!m.isText&&!m.marks.length)return;const b=Math.max(h,g),S=Math.min(p,g+m.nodeSize),k=S-b;i+=k,a.push(...m.marks.map(v=>({mark:v,from:b,to:S})))})}),i===0)return!1;const l=a.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>gd(d.mark.attrs,n,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=a.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,f)=>d+f.to-f.from,0);return(l>0?l+c:l)>=i}function OB(t,e,n={}){if(!e)return ys(t,null,n)||Zm(t,null,n);const r=Jf(e,t.schema);return r==="node"?ys(t,e,n):r==="mark"?Zm(t,e,n):!1}var RB=(t,e)=>{const{$from:n,$to:r,$anchor:o}=t.selection;if(e){const s=Xf(a=>a.type.name===e)(t.selection);if(!s)return!1;const i=t.doc.resolve(s.pos+1);return o.pos+1===i.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},NB=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function Kw(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Gw(t,e){const{nodeExtensions:n}=la(e),r=n.find(i=>i.name===t);if(!r)return!1;const o={name:r.name,options:r.options,storage:r.storage},s=st(ye(r,"group",o));return typeof s!="string"?!1:s.split(" ").includes("list")}function Qf(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return!/\S/.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let o=!0;return t.content.forEach(s=>{o!==!1&&(Qf(s,{ignoreWhitespace:n,checkChildren:e})||(o=!1))}),o}return!1}function xC(t){return t instanceof me}var Zy=class EC{constructor(e){this.position=e}static fromJSON(e){return new EC(e.position)}toJSON(){return{position:this.position}}};function SC(t,e){const n=e.mapping.mapResult(t.position);return{position:new Zy(n.pos),mapResult:n}}function IB(t){return new Zy(t)}function DB(t,e,n){var r;const{selection:o}=e;let s=null;if(lC(o)&&(s=o.$cursor),s){const a=(r=t.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(n)&&(!!n.isInSet(a)||!a.some(c=>c.type.excludes(n)))}const{ranges:i}=o;return i.some(({$from:a,$to:l})=>{let c=a.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(a.pos,l.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(n));c=h&&p}return!c}),c})}var PB=(t,e={})=>({tr:n,state:r,dispatch:o})=>{const{selection:s}=n,{empty:i,ranges:a}=s,l=Lo(t,r.schema);if(o)if(i){const c=fC(r,l);n.addStoredMark(l.create({...c,...e}))}else a.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{const p=Math.max(h,u),m=Math.min(h+f.nodeSize,d);f.marks.find(b=>b.type===l)?f.marks.forEach(b=>{l===b.type&&n.addMark(p,m,l.create({...b.attrs,...e}))}):n.addMark(p,m,l.create(e))})});return DB(r,n,l)},LB=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),jB=(t,e={})=>({state:n,dispatch:r,chain:o})=>{const s=Ot(t,n.schema);let i;return n.selection.$anchor.sameParent(n.selection.$head)&&(i=n.selection.$anchor.parent.attrs),s.isTextblock?o().command(({commands:a})=>iw(s,{...i,...e})(n)?!0:a.clearNodes()).command(({state:a})=>iw(s,{...i,...e})(a,r)).run():!1},$B=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,o=Hs(t,0,r.content.size),s=me.create(r,o);e.setSelection(s)}return!0},FB=(t,e)=>({tr:n,state:r,dispatch:o})=>{const{selection:s}=r;let i,a;return typeof e=="number"?(i=e,a=e):e&&"from"in e&&"to"in e?(i=e.from,a=e.to):(i=s.from,a=s.to),o&&n.doc.nodesBetween(i,a,(l,c)=>{l.isText||n.setNodeMarkup(c,void 0,{...l.attrs,dir:t})}),!0},UB=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:o,to:s}=typeof t=="number"?{from:t,to:t}:t,i=we.atStart(r).from,a=we.atEnd(r).to,l=Hs(o,i,a),c=Hs(s,i,a),u=we.create(r,l,c);e.setSelection(u)}return!0},BB=t=>({state:e,dispatch:n})=>{const r=Ot(t,e.schema);return D$(r)(e,n)};function qw(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(o=>e?.includes(o.type.name));t.tr.ensureMarks(r)}}var zB=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:o})=>{const{selection:s,doc:i}=e,{$from:a,$to:l}=s,c=o.extensionManager.attributes,u=ju(c,a.node().type.name,a.node().attrs);if(s instanceof me&&s.node.isBlock)return!a.parentOffset||!To(i,a.pos)?!1:(r&&(t&&qw(n,o.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const d=l.parentOffset===l.parent.content.size,f=a.depth===0?void 0:gB(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,p=To(e.doc,e.mapping.map(a.pos),1,h);if(!h&&!p&&To(e.doc,e.mapping.map(a.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:u}]:void 0),r){if(p&&(s instanceof we&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,h),f&&!d&&!a.parentOffset&&a.parent.type!==f)){const m=e.mapping.map(a.before()),g=e.doc.resolve(m);a.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(a.before()),f)}t&&qw(n,o.extensionManager.splittableMarks),e.scrollIntoView()}return p},HB=(t,e={})=>({tr:n,state:r,dispatch:o,editor:s})=>{var i;const a=Ot(t,r.schema),{$from:l,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||l.depth<2||!l.sameParent(c))return!1;const d=l.node(-1);if(d.type!==a)return!1;const f=s.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(o){let b=X.empty;const S=l.index(-1)?1:l.index(-2)?2:3;for(let E=l.depth-S;E>=l.depth-3;E-=1)b=X.from(l.node(E).copy(b));const k=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,v={...ju(f,l.node().type.name,l.node().attrs),...e},_=((i=a.contentMatch.defaultType)==null?void 0:i.createAndFill(v))||void 0;b=b.append(X.from(a.createAndFill(null,_)||void 0));const x=l.before(l.depth-(S-1));n.replace(x,l.after(-k),new ie(b,4-S,0));let A=-1;n.doc.nodesBetween(x,n.doc.content.size,(E,T)=>{if(A>-1)return!1;E.isTextblock&&E.content.size===0&&(A=T+1)}),A>-1&&n.setSelection(we.near(n.doc.resolve(A))),n.scrollIntoView()}return!0}const h=c.pos===l.end()?d.contentMatchAt(0).defaultType:null,p={...ju(f,d.type.name,d.attrs),...e},m={...ju(f,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);const g=h?[{type:a,attrs:p},{type:h,attrs:m}]:[{type:a,attrs:p}];if(!To(n.doc,l.pos,2))return!1;if(o){const{selection:b,storedMarks:S}=r,{splittableMarks:k}=s.extensionManager,v=S||b.$to.parentOffset&&b.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!v||!o)return!0;const _=v.filter(x=>k.includes(x.type.name));n.ensureMarks(_)}return!0},Ep=(t,e)=>{const n=Xf(i=>i.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const o=t.doc.nodeAt(r);return n.node.type===o?.type&&Ss(t.doc,n.pos)&&t.join(n.pos),!0},Sp=(t,e)=>{const n=Xf(i=>i.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const o=t.doc.nodeAt(r);return n.node.type===o?.type&&Ss(t.doc,r)&&t.join(r),!0},VB=(t,e,n,r={})=>({editor:o,tr:s,state:i,dispatch:a,chain:l,commands:c,can:u})=>{const{extensions:d,splittableMarks:f}=o.extensionManager,h=Ot(t,i.schema),p=Ot(e,i.schema),{selection:m,storedMarks:g}=i,{$from:b,$to:S}=m,k=b.blockRange(S),v=g||m.$to.parentOffset&&m.$from.marks();if(!k)return!1;const _=Xf(x=>Gw(x.type.name,d))(m);if(k.depth>=1&&_&&k.depth-_.depth<=1){if(_.node.type===h)return c.liftListItem(p);if(Gw(_.node.type.name,d)&&h.validContent(_.node.content)&&a)return l().command(()=>(s.setNodeMarkup(_.pos,h),!0)).command(()=>Ep(s,h)).command(()=>Sp(s,h)).run()}return!n||!v||!a?l().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Ep(s,h)).command(()=>Sp(s,h)).run():l().command(()=>{const x=u().wrapInList(h,r),A=v.filter(E=>f.includes(E.type.name));return s.ensureMarks(A),x?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Ep(s,h)).command(()=>Sp(s,h)).run()},WB=(t,e={},n={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:s=!1}=n,i=Lo(t,r.schema);return Zm(r,i,e)?o.unsetMark(i,{extendEmptyMarkRange:s}):o.setMark(i,e)},KB=(t,e,n={})=>({state:r,commands:o})=>{const s=Ot(t,r.schema),i=Ot(e,r.schema),a=ys(r,s,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?o.setNode(i,l):o.setNode(s,{...l,...n})},GB=(t,e={})=>({state:n,commands:r})=>{const o=Ot(t,n.schema);return ys(n,o,e)?r.lift(o):r.wrapIn(o,e)},qB=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const o=n[r];let s;if(o.spec.isInputRules&&(s=o.getState(t))){if(e){const i=t.tr,a=s.transform;for(let l=a.steps.length-1;l>=0;l-=1)i.step(a.steps[l].invert(a.docs[l]));if(s.text){const l=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,t.schema.text(s.text,l))}else i.delete(s.from,s.to)}return!0}}return!1},YB=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:o}=n;return r||e&&o.forEach(s=>{t.removeMark(s.$from.pos,s.$to.pos)}),!0},JB=(t,e={})=>({tr:n,state:r,dispatch:o})=>{var s;const{extendEmptyMarkRange:i=!1}=e,{selection:a}=n,l=Lo(t,r.schema),{$from:c,empty:u,ranges:d}=a;if(!o)return!0;if(u&&i){let{from:f,to:h}=a;const p=(s=c.marks().find(g=>g.type===l))==null?void 0:s.attrs,m=Yy(c,l,p);m&&(f=m.from,h=m.to),n.removeMark(f,h,l)}else d.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,l)});return n.removeStoredMark(l),!0},XB=t=>({tr:e,state:n,dispatch:r})=>{const{selection:o}=n;let s,i;return typeof t=="number"?(s=t,i=t):t&&"from"in t&&"to"in t?(s=t.from,i=t.to):(s=o.from,i=o.to),r&&e.doc.nodesBetween(s,i,(a,l)=>{if(a.isText)return;const c={...a.attrs};delete c.dir,e.setNodeMarkup(l,void 0,c)}),!0},QB=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let s=null,i=null;const a=Jf(typeof t=="string"?t:t.name,r.schema);if(!a)return!1;a==="node"&&(s=Ot(t,r.schema)),a==="mark"&&(i=Lo(t,r.schema));let l=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let f,h,p,m;n.selection.empty?r.doc.nodesBetween(u,d,(g,b)=>{s&&s===g.type&&(l=!0,p=Math.max(b,u),m=Math.min(b+g.nodeSize,d),f=b,h=g)}):r.doc.nodesBetween(u,d,(g,b)=>{b<u&&s&&s===g.type&&(l=!0,p=Math.max(b,u),m=Math.min(b+g.nodeSize,d),f=b,h=g),b>=u&&b<=d&&(s&&s===g.type&&(l=!0,o&&n.setNodeMarkup(b,void 0,{...g.attrs,...e})),i&&g.marks.length&&g.marks.forEach(S=>{if(i===S.type&&(l=!0,o)){const k=Math.max(b,u),v=Math.min(b+g.nodeSize,d);n.addMark(k,v,i.create({...S.attrs,...e}))}}))}),h&&(f!==void 0&&o&&n.setNodeMarkup(f,void 0,{...h.attrs,...e}),i&&h.marks.length&&h.marks.forEach(g=>{i===g.type&&o&&n.addMark(p,m,i.create({...g.attrs,...e}))}))}),l},ZB=(t,e={})=>({state:n,dispatch:r})=>{const o=Ot(t,n.schema);return A$(o,e)(n,r)},e3=(t,e={})=>({state:n,dispatch:r})=>{const o=Ot(t,n.schema);return _$(o,e)(n,r)},t3=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Zf=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},n3=(t,e)=>{if(qy(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith),r.push(n.replaceWith)),r};function ru(t){var e;const{editor:n,from:r,to:o,text:s,rules:i,plugin:a}=t,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(f=>f.type.spec.code))return!1;let u=!1;const d=MB(c)+s;return i.forEach(f=>{if(u)return;const h=n3(d,f.find);if(!h)return;const p=l.state.tr,m=qf({state:l.state,transaction:p}),g={from:r-(h[0].length-s.length),to:o},{commands:b,chain:S,can:k}=new Yf({editor:n,state:m});f.handler({state:m,range:g,match:h,commands:b,chain:S,can:k})===null||!p.steps.length||(f.undoable&&p.setMeta(a,{transform:p,from:r,to:o,text:s}),l.dispatch(p),u=!0)}),u}function r3(t){const{editor:e,rules:n}=t,r=new Ye({state:{init(){return null},apply(o,s,i){const a=o.getMeta(r);if(a)return a;const l=o.getMeta("applyInputRules");return l&&setTimeout(()=>{let{text:u}=l;typeof u=="string"?u=u:u=Xy(X.from(u),i.schema);const{from:d}=l,f=d+u.length;ru({editor:e,from:d,to:f,text:u,rules:n,plugin:r})}),o.selectionSet||o.docChanged?null:s}},props:{handleTextInput(o,s,i,a){return ru({editor:e,from:s,to:i,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{const{$cursor:s}=o.state.selection;s&&ru({editor:e,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(o,s){if(s.key!=="Enter")return!1;const{$cursor:i}=o.state.selection;return i?ru({editor:e,from:i.pos,to:i.pos,text:`
18
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function o3(t){return Object.prototype.toString.call(t).slice(8,-1)}function ou(t){return o3(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function kC(t,e){const n={...t};return ou(t)&&ou(e)&&Object.keys(e).forEach(r=>{ou(e[r])&&ou(t[r])?n[r]=kC(t[r],e[r]):n[r]=e[r]}),n}var eb=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...st(ye(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...st(ye(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>kC(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},jo=class TC extends eb{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new TC(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){const i=o.marks();if(!!!i.find(c=>c?.type.name===n.name))return!1;const l=i.find(c=>c?.type.name===n.name);return l&&r.removeStoredMark(l),r.insertText(" ",o.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function s3(t){return typeof t=="number"}var i3=class{constructor(t){this.find=t.find,this.handler=t.handler}},a3=(t,e,n)=>{if(qy(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(o=>{const s=[o.text];return s.index=o.index,s.input=t,s.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith),s.push(o.replaceWith)),s}):[]};function l3(t){const{editor:e,state:n,from:r,to:o,rule:s,pasteEvent:i,dropEvent:a}=t,{commands:l,chain:c,can:u}=new Yf({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,o,(h,p)=>{var m,g,b,S,k;if((g=(m=h.type)==null?void 0:m.spec)!=null&&g.code||!(h.isText||h.isTextblock||h.isInline))return;const v=(k=(S=(b=h.content)==null?void 0:b.size)!=null?S:h.nodeSize)!=null?k:0,_=Math.max(r,p),x=Math.min(o,p+v);if(_>=x)return;const A=h.isText?h.text||"":h.textBetween(_-p,x-p,void 0,"");a3(A,s.find,i).forEach(T=>{if(T.index===void 0)return;const N=_+T.index+1,I=N+T[0].length,R={from:n.tr.mapping.map(N),to:n.tr.mapping.map(I)},D=s.handler({state:n,range:R,match:T,commands:l,chain:c,can:u,pasteEvent:i,dropEvent:a});d.push(D)})}),d.every(h=>h!==null)}var su=null,c3=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function u3(t){const{editor:e,rules:n}=t;let r=null,o=!1,s=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a;try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}const l=({state:u,from:d,to:f,rule:h,pasteEvt:p})=>{const m=u.tr,g=qf({state:u,transaction:m});if(!(!l3({editor:e,state:g,from:Math.max(d-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:a})||!m.steps.length)){try{a=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{a=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return n.map(u=>new Ye({view(d){const f=p=>{var m;r=(m=d.dom.parentElement)!=null&&m.contains(p.target)?d.dom.parentElement:null,r&&(su=e)},h=()=>{su&&(su=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(d,f)=>{if(s=r===d.dom.parentElement,a=f,!s){const h=su;h?.isEditable&&setTimeout(()=>{const p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,f)=>{var h;const p=(h=f.clipboardData)==null?void 0:h.getData("text/html");return i=f,o=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(d,f,h)=>{const p=d[0],m=p.getMeta("uiEvent")==="paste"&&!o,g=p.getMeta("uiEvent")==="drop"&&!s,b=p.getMeta("applyPasteRules"),S=!!b;if(!m&&!g&&!S)return;if(S){let{text:_}=b;typeof _=="string"?_=_:_=Xy(X.from(_),h.schema);const{from:x}=b,A=x+_.length,E=c3(_);return l({rule:u,state:h,from:x,to:{b:A},pasteEvt:E})}const k=f.doc.content.findDiffStart(h.doc.content),v=f.doc.content.findDiffEnd(h.doc.content);if(!(!s3(k)||!v||k===v.b))return l({rule:u,state:h,from:k,to:v,pasteEvt:i})}}))}var eh=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=gC(t),this.schema=EB(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Ha(e.name,this.schema)},r=ye(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return xl([...this.extensions].reverse()).flatMap(r=>{const o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Ha(r.name,this.schema)},s=[],i=ye(r,"addKeyboardShortcuts",o);let a={};if(r.type==="mark"&&ye(r,"exitable",o)&&(a.ArrowRight=()=>jo.handleExit({editor:t,mark:r})),i){const f=Object.fromEntries(Object.entries(i()).map(([h,p])=>[h,()=>p({editor:t})]));a={...a,...f}}const l=kU(a);s.push(l);const c=ye(r,"addInputRules",o);if(Kw(r,t.options.enableInputRules)&&c){const f=c();if(f&&f.length){const h=r3({editor:t,rules:f}),p=Array.isArray(h)?h:[h];s.push(...p)}}const u=ye(r,"addPasteRules",o);if(Kw(r,t.options.enablePasteRules)&&u){const f=u();if(f&&f.length){const h=u3({editor:t,rules:f});s.push(...h)}}const d=ye(r,"addProseMirrorPlugins",o);if(d){const f=d();s.push(...f)}return s})}get attributes(){return mC(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=la(this.extensions);return Object.fromEntries(e.filter(n=>!!ye(n,"addNodeView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),o={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ot(n.name,this.schema)},s=ye(n,"addNodeView",o);if(!s)return[];const i=s();if(!i)return[];const a=(l,c,u,d,f)=>{const h=ca(l,r);return i({node:l,view:c,getPos:u,decorations:d,innerDecorations:f,editor:t,extension:n,HTMLAttributes:h})};return[n.name,a]}))}dispatchTransaction(t){const{editor:e}=this;return xl([...this.extensions].reverse()).reduceRight((r,o)=>{const s={name:o.name,options:o.options,storage:this.editor.extensionStorage[o.name],editor:e,type:Ha(o.name,this.schema)},i=ye(o,"dispatchTransaction",s);return i?a=>{i.call(s,{transaction:a,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return xl([...this.extensions]).reduce((r,o)=>{const s={name:o.name,options:o.options,storage:this.editor.extensionStorage[o.name],editor:e,type:Ha(o.name,this.schema)},i=ye(o,"transformPastedHTML",s);return i?(a,l)=>{const c=r(a,l);return i.call(s,c)}:r},t||(r=>r))}get markViews(){const{editor:t}=this,{markExtensions:e}=la(this.extensions);return Object.fromEntries(e.filter(n=>!!ye(n,"addMarkView")).map(n=>{const r=this.attributes.filter(a=>a.type===n.name),o={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Lo(n.name,this.schema)},s=ye(n,"addMarkView",o);if(!s)return[];const i=(a,l,c)=>{const u=ca(a,r);return s()({mark:a,view:l,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:d=>{$C(a,t,d)}})};return[n.name,i]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:Ha(e.name,this.schema)};e.type==="mark"&&((n=st(ye(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const o=ye(e,"onBeforeCreate",r),s=ye(e,"onCreate",r),i=ye(e,"onUpdate",r),a=ye(e,"onSelectionUpdate",r),l=ye(e,"onTransaction",r),c=ye(e,"onFocus",r),u=ye(e,"onBlur",r),d=ye(e,"onDestroy",r);o&&this.editor.on("beforeCreate",o),s&&this.editor.on("create",s),i&&this.editor.on("update",i),a&&this.editor.on("selectionUpdate",a),l&&this.editor.on("transaction",l),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}};eh.resolve=gC;eh.sort=xl;eh.flatten=Jy;var d3={};Gy(d3,{ClipboardTextSerializer:()=>AC,Commands:()=>_C,Delete:()=>MC,Drop:()=>OC,Editable:()=>RC,FocusEvents:()=>IC,Keymap:()=>DC,Paste:()=>PC,Tabindex:()=>LC,TextDirection:()=>jC,focusEventsPluginKey:()=>NC});var at=class CC extends eb{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new CC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},AC=at.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Ye({key:new Je("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:o}=e,{ranges:s}=o,i=Math.min(...s.map(u=>u.$from.pos)),a=Math.max(...s.map(u=>u.$to.pos)),l=bC(n);return yC(r,{from:i,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),_C=at.create({name:"commands",addCommands(){return{...iC}}}),MC=at.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,o;const s=()=>{var i,a,l,c;if((c=(l=(a=(i=this.editor.options.coreExtensionOptions)==null?void 0:i.delete)==null?void 0:a.filterTransaction)==null?void 0:l.call(a,t))!=null?c:t.getMeta("y-sync$"))return;const u=hC(t.before,[t,...e]);wC(u).forEach(h=>{u.mapping.mapResult(h.oldRange.from).deletedAfter&&u.mapping.mapResult(h.oldRange.to).deletedBefore&&u.before.nodesBetween(h.oldRange.from,h.oldRange.to,(p,m)=>{const g=m+p.nodeSize-2,b=h.oldRange.from<=m&&g<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:g,newFrom:u.mapping.map(m),newTo:u.mapping.map(g),deletedRange:h.oldRange,newRange:h.newRange,partial:!b,editor:this.editor,transaction:t,combinedTransform:u})})});const f=u.mapping;u.steps.forEach((h,p)=>{var m,g;if(h instanceof Tr){const b=f.slice(p).map(h.from,-1),S=f.slice(p).map(h.to),k=f.invert().map(b,-1),v=f.invert().map(S),_=(m=u.doc.nodeAt(b-1))==null?void 0:m.marks.some(A=>A.eq(h.mark)),x=(g=u.doc.nodeAt(S))==null?void 0:g.marks.some(A=>A.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:k,to:v},newRange:{from:b,to:S},partial:!!(x||_),editor:this.editor,transaction:t,combinedTransform:u})}})};(o=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||o?setTimeout(s,0):s()}}),OC=at.create({name:"drop",addProseMirrorPlugins(){return[new Ye({key:new Je("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),RC=at.create({name:"editable",addProseMirrorPlugins(){return[new Ye({key:new Je("editable"),props:{editable:()=>this.editor.options.editable}})]}}),NC=new Je("focusEvents"),IC=at.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Ye({key:NC,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),DC=at.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:a})=>{const{selection:l,doc:c}=a,{empty:u,$anchor:d}=l,{pos:f,parent:h}=d,p=d.parent.isTextblock&&f>0?a.doc.resolve(f-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,b=m&&p.parent.childCount===1?g===d.pos:Re.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!b||b&&d.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},s={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return aa()||dC()?s:o},addProseMirrorPlugins(){return[new Ye({key:new Je("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(m=>m.getMeta("composition")))return;const r=t.some(m=>m.docChanged)&&!e.doc.eq(n.doc),o=t.some(m=>m.getMeta("preventClearDocument"));if(!r||o)return;const{empty:s,from:i,to:a}=e.selection,l=Re.atStart(e.doc).from,c=Re.atEnd(e.doc).to;if(s||!(i===l&&a===c)||!Qf(n.doc))return;const f=n.tr,h=qf({state:n,transaction:f}),{commands:p}=new Yf({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),PC=at.create({name:"paste",addProseMirrorPlugins(){return[new Ye({key:new Je("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),LC=at.create({name:"tabindex",addProseMirrorPlugins(){return[new Ye({key:new Je("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),jC=at.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=la(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new Ye({key:new Je("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),f3=class il{constructor(e,n,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=o}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0)return;n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new il(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new il(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 il(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const o=n.isBlock&&!n.isTextblock,s=n.isAtom&&!n.isText,i=n.isInline,a=this.pos+r+(s?0:1);if(a<0||a>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(a);if(!o&&!i&&l.depth<=this.depth)return;const c=new il(l,this.editor,o,o||i?n:null);o&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===e)if(Object.keys(n).length>0){const s=o.node.attrs,i=Object.keys(n);for(let a=0;a<i.length;a+=1){const l=i[a];if(s[l]!==n[l])break}}else r=o;o=o.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let o=[];if(!this.children||this.children.length===0)return o;const s=Object.keys(n);return this.children.forEach(i=>{r&&o.length>0||(i.node.type.name===e&&s.every(l=>n[l]===i.node.attrs[l])&&o.push(i),!(r&&o.length>0)&&(o=o.concat(i.querySelectorAll(e,n,r))))}),o}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},h3=`.ProseMirror {
19
- position: relative;
20
- }
21
-
22
- .ProseMirror {
23
- word-wrap: break-word;
24
- white-space: pre-wrap;
25
- white-space: break-spaces;
26
- -webkit-font-variant-ligatures: none;
27
- font-variant-ligatures: none;
28
- font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
29
- }
30
-
31
- .ProseMirror [contenteditable="false"] {
32
- white-space: normal;
33
- }
34
-
35
- .ProseMirror [contenteditable="false"] [contenteditable="true"] {
36
- white-space: pre-wrap;
37
- }
38
-
39
- .ProseMirror pre {
40
- white-space: pre-wrap;
41
- }
42
-
43
- img.ProseMirror-separator {
44
- display: inline !important;
45
- border: none !important;
46
- margin: 0 !important;
47
- width: 0 !important;
48
- height: 0 !important;
49
- }
50
-
51
- .ProseMirror-gapcursor {
52
- display: none;
53
- pointer-events: none;
54
- position: absolute;
55
- margin: 0;
56
- }
57
-
58
- .ProseMirror-gapcursor:after {
59
- content: "";
60
- display: block;
61
- position: absolute;
62
- top: -2px;
63
- width: 20px;
64
- border-top: 1px solid black;
65
- animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
66
- }
67
-
68
- @keyframes ProseMirror-cursor-blink {
69
- to {
70
- visibility: hidden;
71
- }
72
- }
73
-
74
- .ProseMirror-hideselection *::selection {
75
- background: transparent;
76
- }
77
-
78
- .ProseMirror-hideselection *::-moz-selection {
79
- background: transparent;
80
- }
81
-
82
- .ProseMirror-hideselection * {
83
- caret-color: transparent;
84
- }
85
-
86
- .ProseMirror-focused .ProseMirror-gapcursor {
87
- display: block;
88
- }`;function p3(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute("data-tiptap-style",""),o.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(o),o}var m3=class extends t3{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:SC,createMappablePosition:IB},this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:o,moved:s})=>this.options.onDrop(r,o,s)),this.on("paste",({event:r,slice:o})=>this.options.onPaste(r,o)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=cC(e,this.options.autofocus);this.editorState=Hi.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t?.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch{}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=p3(h3,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=pC(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(o=>{const s=typeof o=="string"?`${o}$`:o.key;n=n.filter(i=>!i.key.startsWith(s))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[RC,AC.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),_C,IC,DC,LC,OC,PC,MC,jC.configure({direction:this.options.textDirection})].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o?.type));this.extensionManager=new eh(r,this)}createCommandManager(){this.commandManager=new Yf({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Qm(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=Qm(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),o=n?this.extensionManager.dispatchTransaction(r):r,s=e.transformPastedHTML,i=this.extensionManager.transformPastedHTML(s);this.editorView=new oC(t,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:o,transformPastedHTML:i,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();const l=this.view.dom;l.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(c=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(c)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),o=n.includes(t),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!o)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const i=n.findLast(c=>c.getMeta("focus")||c.getMeta("blur")),a=i?.getMeta("focus"),l=i?.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:i}),l&&this.emit("blur",{editor:this,event:l.event,transaction:i}),!(t.getMeta("preventUpdate")||!n.some(c=>c.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return vC(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return OB(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Xy(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
89
-
90
- `,textSerializers:n={}}=t||{};return kB(this.state.doc,{blockSeparator:e,textSerializers:{...bC(this.schema),...n}})}get isEmpty(){return Qf(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new f3(e,this)}get $doc(){return this.$pos(0)}};function ua(t){return new Zf({find:t.find,handler:({state:e,range:n,match:r})=>{const o=st(t.getAttributes,void 0,r);if(o===!1||o===null)return null;const{tr:s}=e,i=r[r.length-1],a=r[0];if(i){const l=a.search(/\S/),c=n.from+a.indexOf(i),u=c+i.length;if(Qy(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===t.type&&m!==h.mark.type)).filter(h=>h.to>c).length)return null;u<n.to&&s.delete(u,n.to),c>n.from&&s.delete(n.from+l,c);const f=n.from+l+i.length;s.addMark(n.from+l,f,t.type.create(o||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function g3(t){return new Zf({find:t.find,handler:({state:e,range:n,match:r})=>{const o=st(t.getAttributes,void 0,r)||{},{tr:s}=e,i=n.from;let a=n.to;const l=t.type.create(o);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=i+c;u>a?u=a:a=u+r[1].length;const d=r[0][r[0].length-1];s.insertText(d,i+r[0].length-1),s.replaceWith(u,a,l)}else if(r[0]){const c=t.type.isInline?i:i-1;s.insert(c,t.type.create(o)).delete(s.mapping.map(i),s.mapping.map(a))}s.scrollIntoView()},undoable:t.undoable})}function eg(t){return new Zf({find:t.find,handler:({state:e,range:n,match:r})=>{const o=e.doc.resolve(n.from),s=st(t.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)},undoable:t.undoable})}function da(t){return new Zf({find:t.find,handler:({state:e,range:n,match:r,chain:o})=>{const s=st(t.getAttributes,void 0,r)||{},i=e.tr.delete(n.from,n.to),l=i.doc.resolve(n.from).blockRange(),c=l&&Ry(l,t.type,s);if(!c)return null;if(i.wrap(l,c),t.keepMarks&&t.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=t.editor.extensionManager,p=f||d.$to.parentOffset&&d.$from.marks();if(p){const m=p.filter(g=>h.includes(g.type.name));i.ensureMarks(m)}}if(t.keepAttributes){const d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(d,s).run()}const u=i.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&Ss(i.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&i.join(n.from-1)},undoable:t.undoable})}function y3(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof me){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let o=r.depth;for(;o>=0;){const s=r.index(o);if(r.node(o).contentMatchAt(s).matchType(e))return!0;o-=1}return!1}function b3(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function v3(){return typeof navigator<"u"?/Firefox/.test(navigator.userAgent):!1}var w3={};Gy(w3,{createAtomBlockMarkdownSpec:()=>x3,createBlockMarkdownSpec:()=>E3,createInlineMarkdownSpec:()=>T3,parseAttributes:()=>tb,parseIndentedBlocks:()=>tg,renderNestedMarkdownContent:()=>rb,serializeAttributes:()=>nb});function tb(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}__`)),o=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(o){const c=o.map(u=>u.trim().slice(1));e.class=c.join(" ")}const s=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);s&&(e.id=s[1]);const i=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(i)).forEach(([,c,u])=>{var d;const f=parseInt(((d=u.match(/__QUOTED_(\d+)__/))==null?void 0:d[1])||"0",10),h=n[f];h&&(e[c]=h.slice(1,-1))});const l=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return l&&l.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function nb(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function x3(t){const{nodeName:e,name:n,parseAttributes:r=tb,serializeAttributes:o=nb,defaultAttributes:s={},requiredAttributes:i=[],allowedAttributes:a}=t,l=n||e,c=u=>{if(!a)return u;const d={};return a.forEach(f=>{f in u&&(d[f]=u[f])}),d};return{parseMarkdown:(u,d)=>{const f={...s,...u.attributes};return d.createNode(e,f,[])},markdownTokenizer:{name:e,level:"block",start(u){var d;const f=new RegExp(`^:::${l}(?:\\s|$)`,"m"),h=(d=u.match(f))==null?void 0:d.index;return h!==void 0?h:-1},tokenize(u,d,f){const h=new RegExp(`^:::${l}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=u.match(h);if(!p)return;const m=p[1]||"",g=r(m);if(!i.find(S=>!(S in g)))return{type:e,raw:p[0],attributes:g}}},renderMarkdown:u=>{const d=c(u.attrs||{}),f=o(d),h=f?` {${f}}`:"";return`:::${l}${h} :::`}}}function E3(t){const{nodeName:e,name:n,getContent:r,parseAttributes:o=tb,serializeAttributes:s=nb,defaultAttributes:i={},content:a="block",allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const f={};return l.forEach(h=>{h in d&&(f[h]=d[h])}),f};return{parseMarkdown:(d,f)=>{let h;if(r){const m=r(d);h=typeof m=="string"?[{type:"text",text:m}]:m}else a==="block"?h=f.parseChildren(d.tokens||[]):h=f.parseInline(d.tokens||[]);const p={...i,...d.attributes};return f.createNode(e,p,h)},markdownTokenizer:{name:e,level:"block",start(d){var f;const h=new RegExp(`^:::${c}`,"m"),p=(f=d.match(h))==null?void 0:f.index;return p!==void 0?p:-1},tokenize(d,f,h){var p;const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),g=d.match(m);if(!g)return;const[b,S=""]=g,k=o(S);let v=1;const _=b.length;let x="";const A=/^:::([\w-]*)(\s.*)?/gm,E=d.slice(_);for(A.lastIndex=0;;){const T=A.exec(E);if(T===null)break;const N=T.index,I=T[1];if(!((p=T[2])!=null&&p.endsWith(":::"))){if(I)v+=1;else if(v-=1,v===0){const R=E.slice(0,N);x=R.trim();const D=d.slice(0,_+N+T[0].length);let O=[];if(x)if(a==="block")for(O=h.blockTokens(R),O.forEach(P=>{P.text&&(!P.tokens||P.tokens.length===0)&&(P.tokens=h.inlineTokens(P.text))});O.length>0;){const P=O[O.length-1];if(P.type==="paragraph"&&(!P.text||P.text.trim()===""))O.pop();else break}else O=h.inlineTokens(x);return{type:e,raw:D,attributes:k,content:x,tokens:O}}}}}},renderMarkdown:(d,f)=>{const h=u(d.attrs||{}),p=s(h),m=p?` {${p}}`:"",g=f.renderChildren(d.content||[],`
91
-
92
- `);return`:::${c}${m}
93
-
94
- ${g}
95
-
96
- :::`}}}function S3(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,o,s,i]=r;e[o]=s||i,r=n.exec(t)}return e}function k3(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function T3(t){const{nodeName:e,name:n,getContent:r,parseAttributes:o=S3,serializeAttributes:s=k3,defaultAttributes:i={},selfClosing:a=!1,allowedAttributes:l}=t,c=n||e,u=f=>{if(!l)return f;const h={};return l.forEach(p=>{const m=typeof p=="string"?p:p.name,g=typeof p=="string"?void 0:p.skipIfDefault;if(m in f){const b=f[m];if(g!==void 0&&b===g)return;h[m]=b}}),h},d=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(f,h)=>{const p={...i,...f.attributes};if(a)return h.createNode(e,p);const m=r?r(f):f.content||"";return m?h.createNode(e,p,[h.createTextNode(m)]):h.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(f){const h=a?new RegExp(`\\[${d}\\s*[^\\]]*\\]`):new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),p=f.match(h),m=p?.index;return m!==void 0?m:-1},tokenize(f,h,p){const m=a?new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),g=f.match(m);if(!g)return;let b="",S="";if(a){const[,v]=g;S=v}else{const[,v,_]=g;S=v,b=_||""}const k=o(S.trim());return{type:e,raw:g[0],content:b.trim(),attributes:k}}},renderMarkdown:f=>{let h="";r?h=r(f):f.content&&f.content.length>0&&(h=f.content.filter(b=>b.type==="text").map(b=>b.text).join(""));const p=u(f.attrs||{}),m=s(p),g=m?` ${m}`:"";return a?`[${c}${g}]`:`[${c}${g}]${h}[/${c}]`}}}function tg(t,e,n){var r,o,s,i;const a=t.split(`
97
- `),l=[];let c="",u=0;const d=e.baseIndentSize||2;for(;u<a.length;){const f=a[u],h=f.match(e.itemPattern);if(!h){if(l.length>0)break;if(f.trim()===""){u+=1,c=`${c}${f}
98
- `;continue}else return}const p=e.extractItemData(h),{indentLevel:m,mainContent:g}=p;c=`${c}${f}
99
- `;const b=[g];for(u+=1;u<a.length;){const _=a[u];if(_.trim()===""){const A=a.slice(u+1).findIndex(N=>N.trim()!=="");if(A===-1)break;if((((o=(r=a[u+1+A].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:o.length)||0)>m){b.push(_),c=`${c}${_}
100
- `,u+=1;continue}else break}if((((i=(s=_.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:i.length)||0)>m)b.push(_),c=`${c}${_}
101
- `,u+=1;else break}let S;const k=b.slice(1);if(k.length>0){const _=k.map(x=>x.slice(m+d)).join(`
102
- `);_.trim()&&(e.customNestedParser?S=e.customNestedParser(_):S=n.blockTokens(_))}const v=e.createToken(p,S);l.push(v)}if(l.length!==0)return{items:l,raw:c}}function rb(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const o=typeof n=="function"?n(r):n,[s,...i]=t.content,a=e.renderChildren([s]);let l=`${o}${a}`;return i&&i.length>0&&i.forEach((c,u)=>{var d,f;const h=(f=(d=e.renderChild)==null?void 0:d.call(e,c,u+1))!=null?f:e.renderChildren([c]);if(h!=null){const p=h.split(`
103
- `).map(m=>m?e.indent(m):e.indent("")).join(`
104
- `);l+=c.type==="paragraph"?`
105
-
106
- ${p}`:`
107
- ${p}`}}),l}function $C(t,e,n={}){const{state:r}=e,{doc:o,tr:s}=r,i=t;o.descendants((a,l)=>{const c=s.mapping.map(l),u=s.mapping.map(l)+a.nodeSize;let d=null;if(a.marks.forEach(h=>{if(h!==i)return!1;d=h}),!d)return;let f=!1;if(Object.keys(n).forEach(h=>{n[h]!==d.attrs[h]&&(f=!0)}),f){const h=t.type.create({...t.attrs,...n});s.removeMark(c,u,t.type),s.addMark(c,u,h)}}),s.docChanged&&e.view.dispatch(s)}var C3=class{constructor(t,e,n){this.component=t,this.editor=e.editor,this.options={...n},this.mark=e.mark,this.HTMLAttributes=e.HTMLAttributes}get dom(){return this.editor.view.dom}get contentDOM(){return null}updateAttributes(t,e){$C(e||this.mark,this.editor,t)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(aa()||yd())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}},Lt=class FC extends eb{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new FC(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},A3=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,o,s,i,a;const{view:l}=this.editor,c=t.target,u=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(c)||!u)return;let d=0,f=0;if(this.dom!==u){const S=this.dom.getBoundingClientRect(),k=u.getBoundingClientRect(),v=(o=t.offsetX)!=null?o:(r=t.nativeEvent)==null?void 0:r.offsetX,_=(i=t.offsetY)!=null?i:(s=t.nativeEvent)==null?void 0:s.offsetY;d=k.x-S.x+v,f=k.y-S.y+_}const h=this.dom.cloneNode(!0);try{const S=this.dom.getBoundingClientRect();h.style.width=`${Math.round(S.width)}px`,h.style.height=`${Math.round(S.height)}px`,h.style.boxSizing="border-box",h.style.pointerEvents="none"}catch{}let p=null;try{p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(h),document.body.appendChild(p),(a=t.dataTransfer)==null||a.setDragImage(h,d,f)}finally{p&&setTimeout(()=>{try{p?.remove()}catch{}},0)}const m=this.getPos();if(typeof m!="number")return;const g=me.create(l.state.doc,m),b=l.state.tr.setSelection(g);l.dispatch(b)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const o=t.type.startsWith("drag"),s=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!s&&!o)return!0;const{isEditable:a}=this.editor,{isDragging:l}=this,c=!!this.node.type.spec.draggable,u=me.isSelectable(this.node),d=t.type==="copy",f=t.type==="paste",h=t.type==="cut",p=t.type==="mousedown";if(!c&&u&&o&&t.target===this.dom&&t.preventDefault(),c&&o&&!l&&t.target===this.dom)return t.preventDefault(),!1;if(c&&a&&!l&&p){const m=n.closest("[data-drag-handle]");m&&(this.dom===m||this.dom.contains(m))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(l||s||d||f||h||p&&u)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(aa()||yd())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function ai(t){return new i3({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:o})=>{const s=st(t.getAttributes,void 0,r,o);if(s===!1||s===null)return null;const{tr:i}=e,a=r[r.length-1],l=r[0];let c=n.to;if(a){const u=l.search(/\S/),d=n.from+l.indexOf(a),f=d+a.length;if(Qy(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===t.type&&g!==p.mark.type)).filter(p=>p.to>d).length)return null;f<n.to&&i.delete(f,n.to),d>n.from&&i.delete(n.from+u,d),c=n.from+u+a.length,i.addMark(n.from+u,c,t.type.create(s||{})),i.removeStoredMark(t.type)}}})}function UC(t,e,n={}){const{order:r="depth-first",includeRoot:o=!0,maxDepth:s=-1}=n,i=typeof e!="function";function a(c,u,d,f){if(s!==-1&&f>s)return!0;let h=!0;if(i){const p=e[c.type];p&&p(c,u,d,f)===!1&&(h=!1)}else e(c,u,d,f)===!1&&(h=!1);if(!h)return!1;if(c.content&&Array.isArray(c.content))for(let p=0;p<c.content.length;p++){const m=c.content[p];if(r==="depth-first"){if(!a(m,c,p,f+1))return!1}else if(!a(m,c,p,f+1))return!1}return!0}const l=o?0:1;o?a(t,null,0,0):t.content&&t.content.forEach((c,u)=>{a(c,t,u,l)})}function Gn(t,e,n={}){const r=[],o=n.findAll??!0;return UC(t,s=>{if(s.type===e&&(r.push(s),!o))return!1},n),r}function kp(t,e,n={}){return Gn(t,e,{...n,findAll:!1})[0]||null}function th(t,e,n={}){const r=[],o=n.findAll??!0;return UC(t,s=>{if(e(s)&&(r.push(s),!o))return!1},n),r}function BC(t,e){if(!e(t))return null;if(!t.content)return t;const n=t.content.map(r=>BC(r,e)).filter(r=>r!==null);return{...t,content:n.length>0?n:void 0}}function _3(t,e,n={}){const{containerTypes:r=["doc","paragraph","blockquote","bulletList","orderedList","listItem","table","tableRow","tableCell","tableHeader","mediaGroup"],ignoreEmptyText:o=!0}=n;let s=!1,i=!1;function a(l){if(i)return;const c=l.type;if(r.includes(c)){l.content&&l.content.forEach(a);return}if(c==="text"){const u=l.text??"";o&&u.trim()===""||(i=!0);return}if(c===e){s=!0,l.content&&l.content.forEach(a);return}i=!0}return a(t),s&&!i}function zC(t){var e,n,r="";if(typeof t=="string"||typeof t=="number")r+=t;else if(typeof t=="object")if(Array.isArray(t)){var o=t.length;for(e=0;e<o;e++)t[e]&&(n=zC(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function HC(){for(var t,e,n=0,r="",o=arguments.length;n<o;n++)(t=arguments[n])&&(e=zC(t))&&(r&&(r+=" "),r+=e);return r}const M3=(t,e)=>{const n=new Array(t.length+e.length);for(let r=0;r<t.length;r++)n[r]=t[r];for(let r=0;r<e.length;r++)n[t.length+r]=e[r];return n},O3=(t,e)=>({classGroupId:t,validator:e}),VC=(t=new Map,e=null,n)=>({nextPart:t,validators:e,classGroupId:n}),bd="-",Yw=[],R3="arbitrary..",N3=t=>{const e=D3(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return I3(i);const a=i.split(bd),l=a[0]===""&&a.length>1?1:0;return WC(a,l,e)},getConflictingClassGroupIds:(i,a)=>{if(a){const l=r[i],c=n[i];return l?c?M3(c,l):l:c||Yw}return n[i]||Yw}}},WC=(t,e,n)=>{if(t.length-e===0)return n.classGroupId;const o=t[e],s=n.nextPart.get(o);if(s){const c=WC(t,e+1,s);if(c)return c}const i=n.validators;if(i===null)return;const a=e===0?t.join(bd):t.slice(e).join(bd),l=i.length;for(let c=0;c<l;c++){const u=i[c];if(u.validator(a))return u.classGroupId}},I3=t=>t.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const e=t.slice(1,-1),n=e.indexOf(":"),r=e.slice(0,n);return r?R3+r:void 0})(),D3=t=>{const{theme:e,classGroups:n}=t;return P3(n,e)},P3=(t,e)=>{const n=VC();for(const r in t){const o=t[r];ob(o,n,r,e)}return n},ob=(t,e,n,r)=>{const o=t.length;for(let s=0;s<o;s++){const i=t[s];L3(i,e,n,r)}},L3=(t,e,n,r)=>{if(typeof t=="string"){j3(t,e,n);return}if(typeof t=="function"){$3(t,e,n,r);return}F3(t,e,n,r)},j3=(t,e,n)=>{const r=t===""?e:KC(e,t);r.classGroupId=n},$3=(t,e,n,r)=>{if(U3(t)){ob(t(r),e,n,r);return}e.validators===null&&(e.validators=[]),e.validators.push(O3(n,t))},F3=(t,e,n,r)=>{const o=Object.entries(t),s=o.length;for(let i=0;i<s;i++){const[a,l]=o[i];ob(l,KC(e,a),n,r)}},KC=(t,e)=>{let n=t;const r=e.split(bd),o=r.length;for(let s=0;s<o;s++){const i=r[s];let a=n.nextPart.get(i);a||(a=VC(),n.nextPart.set(i,a)),n=a}return n},U3=t=>"isThemeGetter"in t&&t.isThemeGetter===!0,B3=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=Object.create(null),r=Object.create(null);const o=(s,i)=>{n[s]=i,e++,e>t&&(e=0,r=n,n=Object.create(null))};return{get(s){let i=n[s];if(i!==void 0)return i;if((i=r[s])!==void 0)return o(s,i),i},set(s,i){s in n?n[s]=i:o(s,i)}}},ng="!",Jw=":",z3=[],Xw=(t,e,n,r,o)=>({modifiers:t,hasImportantModifier:e,baseClassName:n,maybePostfixModifierPosition:r,isExternal:o}),H3=t=>{const{prefix:e,experimentalParseClassName:n}=t;let r=o=>{const s=[];let i=0,a=0,l=0,c;const u=o.length;for(let m=0;m<u;m++){const g=o[m];if(i===0&&a===0){if(g===Jw){s.push(o.slice(l,m)),l=m+1;continue}if(g==="/"){c=m;continue}}g==="["?i++:g==="]"?i--:g==="("?a++:g===")"&&a--}const d=s.length===0?o:o.slice(l);let f=d,h=!1;d.endsWith(ng)?(f=d.slice(0,-1),h=!0):d.startsWith(ng)&&(f=d.slice(1),h=!0);const p=c&&c>l?c-l:void 0;return Xw(s,h,f,p)};if(e){const o=e+Jw,s=r;r=i=>i.startsWith(o)?s(i.slice(o.length)):Xw(z3,!1,i,void 0,!0)}if(n){const o=r;r=s=>n({className:s,parseClassName:o})}return r},V3=t=>{const e=new Map;return t.orderSensitiveModifiers.forEach((n,r)=>{e.set(n,1e6+r)}),n=>{const r=[];let o=[];for(let s=0;s<n.length;s++){const i=n[s],a=i[0]==="[",l=e.has(i);a||l?(o.length>0&&(o.sort(),r.push(...o),o=[]),r.push(i)):o.push(i)}return o.length>0&&(o.sort(),r.push(...o)),r}},W3=t=>({cache:B3(t.cacheSize),parseClassName:H3(t),sortModifiers:V3(t),...N3(t)}),K3=/\s+/,G3=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:s}=e,i=[],a=t.trim().split(K3);let l="";for(let c=a.length-1;c>=0;c-=1){const u=a[c],{isExternal:d,modifiers:f,hasImportantModifier:h,baseClassName:p,maybePostfixModifierPosition:m}=n(u);if(d){l=u+(l.length>0?" "+l:l);continue}let g=!!m,b=r(g?p.substring(0,m):p);if(!b){if(!g){l=u+(l.length>0?" "+l:l);continue}if(b=r(p),!b){l=u+(l.length>0?" "+l:l);continue}g=!1}const S=f.length===0?"":f.length===1?f[0]:s(f).join(":"),k=h?S+ng:S,v=k+b;if(i.indexOf(v)>-1)continue;i.push(v);const _=o(b,g);for(let x=0;x<_.length;++x){const A=_[x];i.push(k+A)}l=u+(l.length>0?" "+l:l)}return l},q3=(...t)=>{let e=0,n,r,o="";for(;e<t.length;)(n=t[e++])&&(r=GC(n))&&(o&&(o+=" "),o+=r);return o},GC=t=>{if(typeof t=="string")return t;let e,n="";for(let r=0;r<t.length;r++)t[r]&&(e=GC(t[r]))&&(n&&(n+=" "),n+=e);return n},Y3=(t,...e)=>{let n,r,o,s;const i=l=>{const c=e.reduce((u,d)=>d(u),t());return n=W3(c),r=n.cache.get,o=n.cache.set,s=a,a(l)},a=l=>{const c=r(l);if(c)return c;const u=G3(l,n);return o(l,u),u};return s=i,(...l)=>s(q3(...l))},J3=[],It=t=>{const e=n=>n[t]||J3;return e.isThemeGetter=!0,e},qC=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,YC=/^\((?:(\w[\w-]*):)?(.+)\)$/i,X3=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Q3=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Z3=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,e5=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,t5=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,n5=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ho=t=>X3.test(t),Fe=t=>!!t&&!Number.isNaN(Number(t)),Vo=t=>!!t&&Number.isInteger(Number(t)),Tp=t=>t.endsWith("%")&&Fe(t.slice(0,-1)),po=t=>Q3.test(t),JC=()=>!0,r5=t=>Z3.test(t)&&!e5.test(t),sb=()=>!1,o5=t=>t5.test(t),s5=t=>n5.test(t),i5=t=>!le(t)&&!ce(t),a5=t=>Ts(t,ZC,sb),le=t=>qC.test(t),Ds=t=>Ts(t,eA,r5),Qw=t=>Ts(t,m5,Fe),l5=t=>Ts(t,nA,JC),c5=t=>Ts(t,tA,sb),Zw=t=>Ts(t,XC,sb),u5=t=>Ts(t,QC,s5),iu=t=>Ts(t,rA,o5),ce=t=>YC.test(t),Va=t=>Ei(t,eA),d5=t=>Ei(t,tA),ex=t=>Ei(t,XC),f5=t=>Ei(t,ZC),h5=t=>Ei(t,QC),au=t=>Ei(t,rA,!0),p5=t=>Ei(t,nA,!0),Ts=(t,e,n)=>{const r=qC.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},Ei=(t,e,n=!1)=>{const r=YC.exec(t);return r?r[1]?e(r[1]):n:!1},XC=t=>t==="position"||t==="percentage",QC=t=>t==="image"||t==="url",ZC=t=>t==="length"||t==="size"||t==="bg-size",eA=t=>t==="length",m5=t=>t==="number",tA=t=>t==="family-name",nA=t=>t==="number"||t==="weight",rA=t=>t==="shadow",g5=()=>{const t=It("color"),e=It("font"),n=It("text"),r=It("font-weight"),o=It("tracking"),s=It("leading"),i=It("breakpoint"),a=It("container"),l=It("spacing"),c=It("radius"),u=It("shadow"),d=It("inset-shadow"),f=It("text-shadow"),h=It("drop-shadow"),p=It("blur"),m=It("perspective"),g=It("aspect"),b=It("ease"),S=It("animate"),k=()=>["auto","avoid","all","avoid-page","page","left","right","column"],v=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],_=()=>[...v(),ce,le],x=()=>["auto","hidden","clip","visible","scroll"],A=()=>["auto","contain","none"],E=()=>[ce,le,l],T=()=>[Ho,"full","auto",...E()],N=()=>[Vo,"none","subgrid",ce,le],I=()=>["auto",{span:["full",Vo,ce,le]},Vo,ce,le],R=()=>[Vo,"auto",ce,le],D=()=>["auto","min","max","fr",ce,le],O=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],P=()=>["start","end","center","stretch","center-safe","end-safe"],C=()=>["auto",...E()],M=()=>[Ho,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...E()],U=()=>[Ho,"screen","full","dvw","lvw","svw","min","max","fit",...E()],L=()=>[Ho,"screen","full","lh","dvh","lvh","svh","min","max","fit",...E()],F=()=>[t,ce,le],V=()=>[...v(),ex,Zw,{position:[ce,le]}],W=()=>["no-repeat",{repeat:["","x","y","space","round"]}],H=()=>["auto","cover","contain",f5,a5,{size:[ce,le]}],B=()=>[Tp,Va,Ds],$=()=>["","none","full",c,ce,le],K=()=>["",Fe,Va,Ds],Y=()=>["solid","dashed","dotted","double"],J=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Q=()=>[Fe,Tp,ex,Zw],ne=()=>["","none",p,ce,le],se=()=>["none",Fe,ce,le],te=()=>["none",Fe,ce,le],ge=()=>[Fe,ce,le],he=()=>[Ho,"full",...E()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[po],breakpoint:[po],color:[JC],container:[po],"drop-shadow":[po],ease:["in","out","in-out"],font:[i5],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[po],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[po],shadow:[po],spacing:["px",Fe],text:[po],"text-shadow":[po],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ho,le,ce,g]}],container:["container"],columns:[{columns:[Fe,le,ce,a]}],"break-after":[{"break-after":k()}],"break-before":[{"break-before":k()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:_()}],overflow:[{overflow:x()}],"overflow-x":[{"overflow-x":x()}],"overflow-y":[{"overflow-y":x()}],overscroll:[{overscroll:A()}],"overscroll-x":[{"overscroll-x":A()}],"overscroll-y":[{"overscroll-y":A()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:["visible","invisible","collapse"],z:[{z:[Vo,"auto",ce,le]}],basis:[{basis:[Ho,"full","auto",a,...E()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Fe,Ho,"auto","initial","none",le]}],grow:[{grow:["",Fe,ce,le]}],shrink:[{shrink:["",Fe,ce,le]}],order:[{order:[Vo,"first","last","none",ce,le]}],"grid-cols":[{"grid-cols":N()}],"col-start-end":[{col:I()}],"col-start":[{"col-start":R()}],"col-end":[{"col-end":R()}],"grid-rows":[{"grid-rows":N()}],"row-start-end":[{row:I()}],"row-start":[{"row-start":R()}],"row-end":[{"row-end":R()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":D()}],"auto-rows":[{"auto-rows":D()}],gap:[{gap:E()}],"gap-x":[{"gap-x":E()}],"gap-y":[{"gap-y":E()}],"justify-content":[{justify:[...O(),"normal"]}],"justify-items":[{"justify-items":[...P(),"normal"]}],"justify-self":[{"justify-self":["auto",...P()]}],"align-content":[{content:["normal",...O()]}],"align-items":[{items:[...P(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...P(),{baseline:["","last"]}]}],"place-content":[{"place-content":O()}],"place-items":[{"place-items":[...P(),"baseline"]}],"place-self":[{"place-self":["auto",...P()]}],p:[{p:E()}],px:[{px:E()}],py:[{py:E()}],ps:[{ps:E()}],pe:[{pe:E()}],pbs:[{pbs:E()}],pbe:[{pbe:E()}],pt:[{pt:E()}],pr:[{pr:E()}],pb:[{pb:E()}],pl:[{pl:E()}],m:[{m:C()}],mx:[{mx:C()}],my:[{my:C()}],ms:[{ms:C()}],me:[{me:C()}],mbs:[{mbs:C()}],mbe:[{mbe:C()}],mt:[{mt:C()}],mr:[{mr:C()}],mb:[{mb:C()}],ml:[{ml:C()}],"space-x":[{"space-x":E()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":E()}],"space-y-reverse":["space-y-reverse"],size:[{size:M()}],"inline-size":[{inline:["auto",...U()]}],"min-inline-size":[{"min-inline":["auto",...U()]}],"max-inline-size":[{"max-inline":["none",...U()]}],"block-size":[{block:["auto",...L()]}],"min-block-size":[{"min-block":["auto",...L()]}],"max-block-size":[{"max-block":["none",...L()]}],w:[{w:[a,"screen",...M()]}],"min-w":[{"min-w":[a,"screen","none",...M()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[i]},...M()]}],h:[{h:["screen","lh",...M()]}],"min-h":[{"min-h":["screen","lh","none",...M()]}],"max-h":[{"max-h":["screen","lh",...M()]}],"font-size":[{text:["base",n,Va,Ds]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,p5,l5]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Tp,le]}],"font-family":[{font:[d5,c5,e]}],"font-features":[{"font-features":[le]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,ce,le]}],"line-clamp":[{"line-clamp":[Fe,"none",ce,Qw]}],leading:[{leading:[s,...E()]}],"list-image":[{"list-image":["none",ce,le]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",ce,le]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:F()}],"text-color":[{text:F()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Y(),"wavy"]}],"text-decoration-thickness":[{decoration:[Fe,"from-font","auto",ce,Ds]}],"text-decoration-color":[{decoration:F()}],"underline-offset":[{"underline-offset":[Fe,"auto",ce,le]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:E()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ce,le]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ce,le]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:V()}],"bg-repeat":[{bg:W()}],"bg-size":[{bg:H()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Vo,ce,le],radial:["",ce,le],conic:[Vo,ce,le]},h5,u5]}],"bg-color":[{bg:F()}],"gradient-from-pos":[{from:B()}],"gradient-via-pos":[{via:B()}],"gradient-to-pos":[{to:B()}],"gradient-from":[{from:F()}],"gradient-via":[{via:F()}],"gradient-to":[{to:F()}],rounded:[{rounded:$()}],"rounded-s":[{"rounded-s":$()}],"rounded-e":[{"rounded-e":$()}],"rounded-t":[{"rounded-t":$()}],"rounded-r":[{"rounded-r":$()}],"rounded-b":[{"rounded-b":$()}],"rounded-l":[{"rounded-l":$()}],"rounded-ss":[{"rounded-ss":$()}],"rounded-se":[{"rounded-se":$()}],"rounded-ee":[{"rounded-ee":$()}],"rounded-es":[{"rounded-es":$()}],"rounded-tl":[{"rounded-tl":$()}],"rounded-tr":[{"rounded-tr":$()}],"rounded-br":[{"rounded-br":$()}],"rounded-bl":[{"rounded-bl":$()}],"border-w":[{border:K()}],"border-w-x":[{"border-x":K()}],"border-w-y":[{"border-y":K()}],"border-w-s":[{"border-s":K()}],"border-w-e":[{"border-e":K()}],"border-w-bs":[{"border-bs":K()}],"border-w-be":[{"border-be":K()}],"border-w-t":[{"border-t":K()}],"border-w-r":[{"border-r":K()}],"border-w-b":[{"border-b":K()}],"border-w-l":[{"border-l":K()}],"divide-x":[{"divide-x":K()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":K()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Y(),"hidden","none"]}],"divide-style":[{divide:[...Y(),"hidden","none"]}],"border-color":[{border:F()}],"border-color-x":[{"border-x":F()}],"border-color-y":[{"border-y":F()}],"border-color-s":[{"border-s":F()}],"border-color-e":[{"border-e":F()}],"border-color-bs":[{"border-bs":F()}],"border-color-be":[{"border-be":F()}],"border-color-t":[{"border-t":F()}],"border-color-r":[{"border-r":F()}],"border-color-b":[{"border-b":F()}],"border-color-l":[{"border-l":F()}],"divide-color":[{divide:F()}],"outline-style":[{outline:[...Y(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Fe,ce,le]}],"outline-w":[{outline:["",Fe,Va,Ds]}],"outline-color":[{outline:F()}],shadow:[{shadow:["","none",u,au,iu]}],"shadow-color":[{shadow:F()}],"inset-shadow":[{"inset-shadow":["none",d,au,iu]}],"inset-shadow-color":[{"inset-shadow":F()}],"ring-w":[{ring:K()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:F()}],"ring-offset-w":[{"ring-offset":[Fe,Ds]}],"ring-offset-color":[{"ring-offset":F()}],"inset-ring-w":[{"inset-ring":K()}],"inset-ring-color":[{"inset-ring":F()}],"text-shadow":[{"text-shadow":["none",f,au,iu]}],"text-shadow-color":[{"text-shadow":F()}],opacity:[{opacity:[Fe,ce,le]}],"mix-blend":[{"mix-blend":[...J(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":J()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Fe]}],"mask-image-linear-from-pos":[{"mask-linear-from":Q()}],"mask-image-linear-to-pos":[{"mask-linear-to":Q()}],"mask-image-linear-from-color":[{"mask-linear-from":F()}],"mask-image-linear-to-color":[{"mask-linear-to":F()}],"mask-image-t-from-pos":[{"mask-t-from":Q()}],"mask-image-t-to-pos":[{"mask-t-to":Q()}],"mask-image-t-from-color":[{"mask-t-from":F()}],"mask-image-t-to-color":[{"mask-t-to":F()}],"mask-image-r-from-pos":[{"mask-r-from":Q()}],"mask-image-r-to-pos":[{"mask-r-to":Q()}],"mask-image-r-from-color":[{"mask-r-from":F()}],"mask-image-r-to-color":[{"mask-r-to":F()}],"mask-image-b-from-pos":[{"mask-b-from":Q()}],"mask-image-b-to-pos":[{"mask-b-to":Q()}],"mask-image-b-from-color":[{"mask-b-from":F()}],"mask-image-b-to-color":[{"mask-b-to":F()}],"mask-image-l-from-pos":[{"mask-l-from":Q()}],"mask-image-l-to-pos":[{"mask-l-to":Q()}],"mask-image-l-from-color":[{"mask-l-from":F()}],"mask-image-l-to-color":[{"mask-l-to":F()}],"mask-image-x-from-pos":[{"mask-x-from":Q()}],"mask-image-x-to-pos":[{"mask-x-to":Q()}],"mask-image-x-from-color":[{"mask-x-from":F()}],"mask-image-x-to-color":[{"mask-x-to":F()}],"mask-image-y-from-pos":[{"mask-y-from":Q()}],"mask-image-y-to-pos":[{"mask-y-to":Q()}],"mask-image-y-from-color":[{"mask-y-from":F()}],"mask-image-y-to-color":[{"mask-y-to":F()}],"mask-image-radial":[{"mask-radial":[ce,le]}],"mask-image-radial-from-pos":[{"mask-radial-from":Q()}],"mask-image-radial-to-pos":[{"mask-radial-to":Q()}],"mask-image-radial-from-color":[{"mask-radial-from":F()}],"mask-image-radial-to-color":[{"mask-radial-to":F()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":v()}],"mask-image-conic-pos":[{"mask-conic":[Fe]}],"mask-image-conic-from-pos":[{"mask-conic-from":Q()}],"mask-image-conic-to-pos":[{"mask-conic-to":Q()}],"mask-image-conic-from-color":[{"mask-conic-from":F()}],"mask-image-conic-to-color":[{"mask-conic-to":F()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:V()}],"mask-repeat":[{mask:W()}],"mask-size":[{mask:H()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",ce,le]}],filter:[{filter:["","none",ce,le]}],blur:[{blur:ne()}],brightness:[{brightness:[Fe,ce,le]}],contrast:[{contrast:[Fe,ce,le]}],"drop-shadow":[{"drop-shadow":["","none",h,au,iu]}],"drop-shadow-color":[{"drop-shadow":F()}],grayscale:[{grayscale:["",Fe,ce,le]}],"hue-rotate":[{"hue-rotate":[Fe,ce,le]}],invert:[{invert:["",Fe,ce,le]}],saturate:[{saturate:[Fe,ce,le]}],sepia:[{sepia:["",Fe,ce,le]}],"backdrop-filter":[{"backdrop-filter":["","none",ce,le]}],"backdrop-blur":[{"backdrop-blur":ne()}],"backdrop-brightness":[{"backdrop-brightness":[Fe,ce,le]}],"backdrop-contrast":[{"backdrop-contrast":[Fe,ce,le]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Fe,ce,le]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Fe,ce,le]}],"backdrop-invert":[{"backdrop-invert":["",Fe,ce,le]}],"backdrop-opacity":[{"backdrop-opacity":[Fe,ce,le]}],"backdrop-saturate":[{"backdrop-saturate":[Fe,ce,le]}],"backdrop-sepia":[{"backdrop-sepia":["",Fe,ce,le]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":E()}],"border-spacing-x":[{"border-spacing-x":E()}],"border-spacing-y":[{"border-spacing-y":E()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",ce,le]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Fe,"initial",ce,le]}],ease:[{ease:["linear","initial",b,ce,le]}],delay:[{delay:[Fe,ce,le]}],animate:[{animate:["none",S,ce,le]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,ce,le]}],"perspective-origin":[{"perspective-origin":_()}],rotate:[{rotate:se()}],"rotate-x":[{"rotate-x":se()}],"rotate-y":[{"rotate-y":se()}],"rotate-z":[{"rotate-z":se()}],scale:[{scale:te()}],"scale-x":[{"scale-x":te()}],"scale-y":[{"scale-y":te()}],"scale-z":[{"scale-z":te()}],"scale-3d":["scale-3d"],skew:[{skew:ge()}],"skew-x":[{"skew-x":ge()}],"skew-y":[{"skew-y":ge()}],transform:[{transform:[ce,le,"","none","gpu","cpu"]}],"transform-origin":[{origin:_()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:he()}],"translate-x":[{"translate-x":he()}],"translate-y":[{"translate-y":he()}],"translate-z":[{"translate-z":he()}],"translate-none":["translate-none"],accent:[{accent:F()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:F()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ce,le]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":E()}],"scroll-mx":[{"scroll-mx":E()}],"scroll-my":[{"scroll-my":E()}],"scroll-ms":[{"scroll-ms":E()}],"scroll-me":[{"scroll-me":E()}],"scroll-mbs":[{"scroll-mbs":E()}],"scroll-mbe":[{"scroll-mbe":E()}],"scroll-mt":[{"scroll-mt":E()}],"scroll-mr":[{"scroll-mr":E()}],"scroll-mb":[{"scroll-mb":E()}],"scroll-ml":[{"scroll-ml":E()}],"scroll-p":[{"scroll-p":E()}],"scroll-px":[{"scroll-px":E()}],"scroll-py":[{"scroll-py":E()}],"scroll-ps":[{"scroll-ps":E()}],"scroll-pe":[{"scroll-pe":E()}],"scroll-pbs":[{"scroll-pbs":E()}],"scroll-pbe":[{"scroll-pbe":E()}],"scroll-pt":[{"scroll-pt":E()}],"scroll-pr":[{"scroll-pr":E()}],"scroll-pb":[{"scroll-pb":E()}],"scroll-pl":[{"scroll-pl":E()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ce,le]}],fill:[{fill:["none",...F()]}],"stroke-w":[{stroke:[Fe,Va,Ds,Qw]}],stroke:[{stroke:["none",...F()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},y5=Y3(g5);function oe(...t){return y5(HC(t))}const b5=t=>Object.entries(t).filter(([e])=>isNaN(Number(e))).map(([e,n])=>({key:e,label:n,value:n})),Ur=t=>t instanceof File||t instanceof Blob,tx=t=>typeof t=="string"&&(t.startsWith("http://")||t.startsWith("https://")),rg=(t,e,n)=>{if(t.size>e)return{valid:!1,error:`File size exceeds ${e/1024/1024}MB limit`};if(t instanceof File&&n.length>0){const r=t.type;if(!n.some(s=>s.endsWith("/*")?r.startsWith(s.replace("/*","")):r===s))return{valid:!1,error:"File type not allowed"}}return{valid:!0}},ib=t=>{if(!t)return null;const e=t.getJSON(),n=t.getText(),r=c=>!!c.marks?.some(u=>u.type==="customLink"),o=n.trim().split(/\s+/).filter(Boolean).length,s=n.length,i=Gn(e,"media")?.filter(c=>!c.attrs?.uploading)?.length,a=th(e,c=>r(c))?.length,l=Gn(e,"poll")?.[0]?.attrs?.choices?.length??0;return{wordCount:o,characterCount:s,mediaCount:i,linkCount:a,pollCount:l,isEmpty:t.isEmpty,hasUnsavedChanges:t.state.doc.content.size>2}};function oA({className:t,...e}){return y.jsx(yj,{"data-slot":"tabs",className:oe("flex flex-col gap-2",t),...e})}function sA({className:t,...e}){return y.jsx(bj,{"data-slot":"tabs-list",className:oe("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",t),...e})}function og({className:t,...e}){return y.jsx(vj,{"data-slot":"tabs-trigger",className:oe("data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...e})}function nx({className:t,...e}){return y.jsx(wj,{"data-slot":"tabs-content",className:oe("flex-1 outline-none",t),...e})}const iA=j.createContext(null);function ab(){const t=j.useContext(iA);if(!t)throw new Error("useAnalyticsSession must be used within AnalyticsSessionProvider");return t}const rx=t=>{let e;const n=new Set,r=(c,u)=>{const d=typeof c=="function"?c(e):c;if(!Object.is(d,e)){const f=e;e=u??(typeof d!="object"||d===null)?d:Object.assign({},e,d),n.forEach(h=>h(e,f))}},o=()=>e,a={setState:r,getState:o,getInitialState:()=>l,subscribe:c=>(n.add(c),()=>n.delete(c))},l=e=t(r,o,a);return a},aA=(t=>t?rx(t):rx),v5=t=>t;function El(t,e=v5){const n=w.default.useSyncExternalStore(t.subscribe,w.default.useCallback(()=>e(t.getState()),[t,e]),w.default.useCallback(()=>e(t.getInitialState()),[t,e]));return w.default.useDebugValue(n),n}const Ft={SESSION:{STARTED:"post_builder_session_started",COMPLETED:"post_builder_session_completed",ABANDONED:"post_builder_session_abandoned"},EDITOR:{FOCUSED:"post_builder_focused",TAB_SWITCHED:"post_builder_tab_switched"},FEATURE:{DISCOVERED:"post_builder_feature_discovered",REUSED:"post_builder_feature_reused"},MEDIA:{ADDED:"post_builder_media_added",UPLOAD_FAILED:"post_builder_media_upload_failed",REMOVED:"post_builder_media_removed"},LINK:{ADDED:"post_builder_link_added",UNFURL_FAILED:"post_builder_link_unfurl_failed"},POLL:{OPTION_ADDED:"post_builder_poll_option_added",OPTION_REMOVED:"post_builder_poll_option_removed"},CONTENT:{CREATED:"post_builder_content_created"},PUBLISH:{ATTEMPTED:"post_builder_publish_attempted",SUCCESS:"post_builder_publish_success",FAILED:"post_builder_publish_failed"}},At={undo:"undo",redo:"redo",paragraph:"paragraph",bold:"bold",italic:"italic",strike:"strikethrough",code:"code",customLink:"customLink",bulletList:"bullet_list",orderedList:"ordered_list",blockquote:"blockquote",codeBlock:"code_block",image:"image",video:"video",audio:"audio"},Cp={1:"heading_1",2:"heading_2",3:"heading_3"};class w5{sessions=new Map;createSession(e,n=Mo.Feed){const r=`pb_${Dt()}`;return this.sessions.set(r,{id:r,editorType:e,placement:n,startTime:Date.now(),lastErrorType:null,focusSources:new Set,contentCreatedFired:!1,featureUsageCounts:new Map}),r}getSession(e){return this.sessions.get(e)}deleteSession(e){this.sessions.delete(e)}markFocused(e,n){const r=this.getSession(e);return!r||r.focusSources.has(n)?!1:(r.focusSources.add(n),!0)}setLastError(e,n){const r=this.getSession(e);r&&(r.lastErrorType=n)}markContentCreated(e){const n=this.getSession(e);n&&(n.contentCreatedFired=!0)}trackFeature(e,n){const r=this.getSession(e);if(!r)return{isFirstUse:!0,usageCount:1};const s=(r.featureUsageCounts.get(n)||0)+1;return r.featureUsageCounts.set(n,s),{isFirstUse:s===1,usageCount:s}}}class x5{discoveredFeatures;usageCounts;constructor(){if(typeof window>"u"){this.discoveredFeatures=new Set,this.usageCounts=new Map;return}const e=localStorage?.getItem("pb_feature_tracker");if(e)try{const n=JSON.parse(e);this.discoveredFeatures=new Set(n?.discovered||[]),this.usageCounts=new Map(Object.entries(n?.counts||{}))}catch{this.discoveredFeatures=new Set,this.usageCounts=new Map}else this.discoveredFeatures=new Set,this.usageCounts=new Map}isFirstUse(e){return!this.discoveredFeatures.has(e)}trackUsage(e){const n=this.isFirstUse(e);n&&this.discoveredFeatures.add(e);const o=(this.usageCounts.get(e)||0)+1;return this.usageCounts.set(e,o),this.save(),{isFirstUse:n,usageCount:o}}getUsageCount(e){return this.usageCounts.get(e)||0}save(){const e={discovered:Array.from(this.discoveredFeatures),counts:Object.fromEntries(this.usageCounts)};typeof window<"u"&&localStorage?.setItem("pb_feature_tracker",JSON.stringify(e))}}var lA=typeof global=="object"&&global&&global.Object===Object&&global,E5=typeof self=="object"&&self&&self.Object===Object&&self,Lr=lA||E5||Function("return this")(),fr=Lr.Symbol,cA=Object.prototype,S5=cA.hasOwnProperty,k5=cA.toString,Wa=fr?fr.toStringTag:void 0;function T5(t){var e=S5.call(t,Wa),n=t[Wa];try{t[Wa]=void 0;var r=!0}catch{}var o=k5.call(t);return r&&(e?t[Wa]=n:delete t[Wa]),o}var C5=Object.prototype,A5=C5.toString;function _5(t){return A5.call(t)}var M5="[object Null]",O5="[object Undefined]",ox=fr?fr.toStringTag:void 0;function Si(t){return t==null?t===void 0?O5:M5:ox&&ox in Object(t)?T5(t):_5(t)}function No(t){return t!=null&&typeof t=="object"}var R5="[object Symbol]";function nh(t){return typeof t=="symbol"||No(t)&&Si(t)==R5}function lb(t,e){for(var n=-1,r=t==null?0:t.length,o=Array(r);++n<r;)o[n]=e(t[n],n,t);return o}var _r=Array.isArray,sx=fr?fr.prototype:void 0,ix=sx?sx.toString:void 0;function uA(t){if(typeof t=="string")return t;if(_r(t))return lb(t,uA)+"";if(nh(t))return ix?ix.call(t):"";var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}var N5=/\s/;function I5(t){for(var e=t.length;e--&&N5.test(t.charAt(e)););return e}var D5=/^\s+/;function P5(t){return t&&t.slice(0,I5(t)+1).replace(D5,"")}function oo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var ax=NaN,L5=/^[-+]0x[0-9a-f]+$/i,j5=/^0b[01]+$/i,$5=/^0o[0-7]+$/i,F5=parseInt;function lx(t){if(typeof t=="number")return t;if(nh(t))return ax;if(oo(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=oo(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=P5(t);var n=j5.test(t);return n||$5.test(t)?F5(t.slice(2),n?2:8):L5.test(t)?ax:+t}function dA(t){return t}var U5="[object AsyncFunction]",B5="[object Function]",z5="[object GeneratorFunction]",H5="[object Proxy]";function fA(t){if(!oo(t))return!1;var e=Si(t);return e==B5||e==z5||e==U5||e==H5}var Ap=Lr["__core-js_shared__"],cx=(function(){var t=/[^.]+$/.exec(Ap&&Ap.keys&&Ap.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function V5(t){return!!cx&&cx in t}var W5=Function.prototype,K5=W5.toString;function ki(t){if(t!=null){try{return K5.call(t)}catch{}try{return t+""}catch{}}return""}var G5=/[\\^$.*+?()[\]{}|]/g,q5=/^\[object .+?Constructor\]$/,Y5=Function.prototype,J5=Object.prototype,X5=Y5.toString,Q5=J5.hasOwnProperty,Z5=RegExp("^"+X5.call(Q5).replace(G5,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function e4(t){if(!oo(t)||V5(t))return!1;var e=fA(t)?Z5:q5;return e.test(ki(t))}function t4(t,e){return t?.[e]}function Ti(t,e){var n=t4(t,e);return e4(n)?n:void 0}var sg=Ti(Lr,"WeakMap");function n4(t,e,n){switch(n.length){case 0:return t.call(e);case 1:return t.call(e,n[0]);case 2:return t.call(e,n[0],n[1]);case 3:return t.call(e,n[0],n[1],n[2])}return t.apply(e,n)}var r4=800,o4=16,s4=Date.now;function i4(t){var e=0,n=0;return function(){var r=s4(),o=o4-(r-n);if(n=r,o>0){if(++e>=r4)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}function a4(t){return function(){return t}}var vd=(function(){try{var t=Ti(Object,"defineProperty");return t({},"",{}),t}catch{}})(),l4=vd?function(t,e){return vd(t,"toString",{configurable:!0,enumerable:!1,value:a4(e),writable:!0})}:dA,c4=i4(l4);function u4(t,e){for(var n=-1,r=t==null?0:t.length;++n<r&&e(t[n],n,t)!==!1;);return t}var d4=9007199254740991,f4=/^(?:0|[1-9]\d*)$/;function cb(t,e){var n=typeof t;return e=e??d4,!!e&&(n=="number"||n!="symbol"&&f4.test(t))&&t>-1&&t%1==0&&t<e}function hA(t,e,n){e=="__proto__"&&vd?vd(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function ub(t,e){return t===e||t!==t&&e!==e}var h4=Object.prototype,p4=h4.hasOwnProperty;function db(t,e,n){var r=t[e];(!(p4.call(t,e)&&ub(r,n))||n===void 0&&!(e in t))&&hA(t,e,n)}function m4(t,e,n,r){var o=!n;n||(n={});for(var s=-1,i=e.length;++s<i;){var a=e[s],l=void 0;l===void 0&&(l=t[a]),o?hA(n,a,l):db(n,a,l)}return n}var ux=Math.max;function g4(t,e,n){return e=ux(e===void 0?t.length-1:e,0),function(){for(var r=arguments,o=-1,s=ux(r.length-e,0),i=Array(s);++o<s;)i[o]=r[e+o];o=-1;for(var a=Array(e+1);++o<e;)a[o]=r[o];return a[e]=n(i),n4(t,this,a)}}var y4=9007199254740991;function fb(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=y4}function pA(t){return t!=null&&fb(t.length)&&!fA(t)}var b4=Object.prototype;function mA(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||b4;return t===n}function v4(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}var w4="[object Arguments]";function dx(t){return No(t)&&Si(t)==w4}var gA=Object.prototype,x4=gA.hasOwnProperty,E4=gA.propertyIsEnumerable,hb=dx((function(){return arguments})())?dx:function(t){return No(t)&&x4.call(t,"callee")&&!E4.call(t,"callee")};function S4(){return!1}var yA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,fx=yA&&typeof module=="object"&&module&&!module.nodeType&&module,k4=fx&&fx.exports===yA,hx=k4?Lr.Buffer:void 0,T4=hx?hx.isBuffer:void 0,wd=T4||S4,C4="[object Arguments]",A4="[object Array]",_4="[object Boolean]",M4="[object Date]",O4="[object Error]",R4="[object Function]",N4="[object Map]",I4="[object Number]",D4="[object Object]",P4="[object RegExp]",L4="[object Set]",j4="[object String]",$4="[object WeakMap]",F4="[object ArrayBuffer]",U4="[object DataView]",B4="[object Float32Array]",z4="[object Float64Array]",H4="[object Int8Array]",V4="[object Int16Array]",W4="[object Int32Array]",K4="[object Uint8Array]",G4="[object Uint8ClampedArray]",q4="[object Uint16Array]",Y4="[object Uint32Array]",gt={};gt[B4]=gt[z4]=gt[H4]=gt[V4]=gt[W4]=gt[K4]=gt[G4]=gt[q4]=gt[Y4]=!0;gt[C4]=gt[A4]=gt[F4]=gt[_4]=gt[U4]=gt[M4]=gt[O4]=gt[R4]=gt[N4]=gt[I4]=gt[D4]=gt[P4]=gt[L4]=gt[j4]=gt[$4]=!1;function J4(t){return No(t)&&fb(t.length)&&!!gt[Si(t)]}function pb(t){return function(e){return t(e)}}var bA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Sl=bA&&typeof module=="object"&&module&&!module.nodeType&&module,X4=Sl&&Sl.exports===bA,_p=X4&&lA.process,fa=(function(){try{var t=Sl&&Sl.require&&Sl.require("util").types;return t||_p&&_p.binding&&_p.binding("util")}catch{}})(),px=fa&&fa.isTypedArray,vA=px?pb(px):J4,Q4=Object.prototype,Z4=Q4.hasOwnProperty;function wA(t,e){var n=_r(t),r=!n&&hb(t),o=!n&&!r&&wd(t),s=!n&&!r&&!o&&vA(t),i=n||r||o||s,a=i?v4(t.length,String):[],l=a.length;for(var c in t)(e||Z4.call(t,c))&&!(i&&(c=="length"||o&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||cb(c,l)))&&a.push(c);return a}function xA(t,e){return function(n){return t(e(n))}}var ez=xA(Object.keys,Object),tz=Object.prototype,nz=tz.hasOwnProperty;function rz(t){if(!mA(t))return ez(t);var e=[];for(var n in Object(t))nz.call(t,n)&&n!="constructor"&&e.push(n);return e}function EA(t){return pA(t)?wA(t):rz(t)}function oz(t){var e=[];if(t!=null)for(var n in Object(t))e.push(n);return e}var sz=Object.prototype,iz=sz.hasOwnProperty;function az(t){if(!oo(t))return oz(t);var e=mA(t),n=[];for(var r in t)r=="constructor"&&(e||!iz.call(t,r))||n.push(r);return n}function lz(t){return pA(t)?wA(t,!0):az(t)}var cz=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,uz=/^\w*$/;function mb(t,e){if(_r(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||nh(t)?!0:uz.test(t)||!cz.test(t)||e!=null&&t in Object(e)}var Kl=Ti(Object,"create");function dz(){this.__data__=Kl?Kl(null):{},this.size=0}function fz(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var hz="__lodash_hash_undefined__",pz=Object.prototype,mz=pz.hasOwnProperty;function gz(t){var e=this.__data__;if(Kl){var n=e[t];return n===hz?void 0:n}return mz.call(e,t)?e[t]:void 0}var yz=Object.prototype,bz=yz.hasOwnProperty;function vz(t){var e=this.__data__;return Kl?e[t]!==void 0:bz.call(e,t)}var wz="__lodash_hash_undefined__";function xz(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=Kl&&e===void 0?wz:e,this}function li(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}li.prototype.clear=dz;li.prototype.delete=fz;li.prototype.get=gz;li.prototype.has=vz;li.prototype.set=xz;function Ez(){this.__data__=[],this.size=0}function rh(t,e){for(var n=t.length;n--;)if(ub(t[n][0],e))return n;return-1}var Sz=Array.prototype,kz=Sz.splice;function Tz(t){var e=this.__data__,n=rh(e,t);if(n<0)return!1;var r=e.length-1;return n==r?e.pop():kz.call(e,n,1),--this.size,!0}function Cz(t){var e=this.__data__,n=rh(e,t);return n<0?void 0:e[n][1]}function Az(t){return rh(this.__data__,t)>-1}function _z(t,e){var n=this.__data__,r=rh(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}function $o(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}$o.prototype.clear=Ez;$o.prototype.delete=Tz;$o.prototype.get=Cz;$o.prototype.has=Az;$o.prototype.set=_z;var Gl=Ti(Lr,"Map");function Mz(){this.size=0,this.__data__={hash:new li,map:new(Gl||$o),string:new li}}function Oz(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function oh(t,e){var n=t.__data__;return Oz(e)?n[typeof e=="string"?"string":"hash"]:n.map}function Rz(t){var e=oh(this,t).delete(t);return this.size-=e?1:0,e}function Nz(t){return oh(this,t).get(t)}function Iz(t){return oh(this,t).has(t)}function Dz(t,e){var n=oh(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}function Fo(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}Fo.prototype.clear=Mz;Fo.prototype.delete=Rz;Fo.prototype.get=Nz;Fo.prototype.has=Iz;Fo.prototype.set=Dz;var Pz="Expected a function";function gb(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Pz);var n=function(){var r=arguments,o=e?e.apply(this,r):r[0],s=n.cache;if(s.has(o))return s.get(o);var i=t.apply(this,r);return n.cache=s.set(o,i)||s,i};return n.cache=new(gb.Cache||Fo),n}gb.Cache=Fo;var Lz=500;function jz(t){var e=gb(t,function(r){return n.size===Lz&&n.clear(),r}),n=e.cache;return e}var $z=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Fz=/\\(\\)?/g,Uz=jz(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace($z,function(n,r,o,s){e.push(o?s.replace(Fz,"$1"):r||n)}),e});function Bz(t){return t==null?"":uA(t)}function _a(t,e){return _r(t)?t:mb(t,e)?[t]:Uz(Bz(t))}function Ma(t){if(typeof t=="string"||nh(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function sh(t,e){e=_a(e,t);for(var n=0,r=e.length;t!=null&&n<r;)t=t[Ma(e[n++])];return n&&n==r?t:void 0}function zz(t,e,n){var r=t==null?void 0:sh(t,e);return r===void 0?n:r}function yb(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}var mx=fr?fr.isConcatSpreadable:void 0;function Hz(t){return _r(t)||hb(t)||!!(mx&&t&&t[mx])}function Vz(t,e,n,r,o){var s=-1,i=t.length;for(n||(n=Hz),o||(o=[]);++s<i;){var a=t[s];n(a)?yb(o,a):o[o.length]=a}return o}function Wz(t){var e=t==null?0:t.length;return e?Vz(t):[]}function Kz(t){return c4(g4(t,void 0,Wz),t+"")}var SA=xA(Object.getPrototypeOf,Object),Gz="[object Object]",qz=Function.prototype,Yz=Object.prototype,kA=qz.toString,Jz=Yz.hasOwnProperty,Xz=kA.call(Object);function Qz(t){if(!No(t)||Si(t)!=Gz)return!1;var e=SA(t);if(e===null)return!0;var n=Jz.call(e,"constructor")&&e.constructor;return typeof n=="function"&&n instanceof n&&kA.call(n)==Xz}function Zz(t,e,n){var r=-1,o=t.length;e<0&&(e=-e>o?0:o+e),n=n>o?o:n,n<0&&(n+=o),o=e>n?0:n-e>>>0,e>>>=0;for(var s=Array(o);++r<o;)s[r]=t[r+e];return s}function eH(){this.__data__=new $o,this.size=0}function tH(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}function nH(t){return this.__data__.get(t)}function rH(t){return this.__data__.has(t)}var oH=200;function sH(t,e){var n=this.__data__;if(n instanceof $o){var r=n.__data__;if(!Gl||r.length<oH-1)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new Fo(r)}return n.set(t,e),this.size=n.size,this}function Xr(t){var e=this.__data__=new $o(t);this.size=e.size}Xr.prototype.clear=eH;Xr.prototype.delete=tH;Xr.prototype.get=nH;Xr.prototype.has=rH;Xr.prototype.set=sH;var TA=typeof exports=="object"&&exports&&!exports.nodeType&&exports,gx=TA&&typeof module=="object"&&module&&!module.nodeType&&module,iH=gx&&gx.exports===TA,yx=iH?Lr.Buffer:void 0;yx&&yx.allocUnsafe;function aH(t,e){return t.slice()}function lH(t,e){for(var n=-1,r=t==null?0:t.length,o=0,s=[];++n<r;){var i=t[n];e(i,n,t)&&(s[o++]=i)}return s}function CA(){return[]}var cH=Object.prototype,uH=cH.propertyIsEnumerable,bx=Object.getOwnPropertySymbols,AA=bx?function(t){return t==null?[]:(t=Object(t),lH(bx(t),function(e){return uH.call(t,e)}))}:CA,dH=Object.getOwnPropertySymbols,fH=dH?function(t){for(var e=[];t;)yb(e,AA(t)),t=SA(t);return e}:CA;function _A(t,e,n){var r=e(t);return _r(t)?r:yb(r,n(t))}function vx(t){return _A(t,EA,AA)}function bb(t){return _A(t,lz,fH)}var ig=Ti(Lr,"DataView"),ag=Ti(Lr,"Promise"),lg=Ti(Lr,"Set"),wx="[object Map]",hH="[object Object]",xx="[object Promise]",Ex="[object Set]",Sx="[object WeakMap]",kx="[object DataView]",pH=ki(ig),mH=ki(Gl),gH=ki(ag),yH=ki(lg),bH=ki(sg),xr=Si;(ig&&xr(new ig(new ArrayBuffer(1)))!=kx||Gl&&xr(new Gl)!=wx||ag&&xr(ag.resolve())!=xx||lg&&xr(new lg)!=Ex||sg&&xr(new sg)!=Sx)&&(xr=function(t){var e=Si(t),n=e==hH?t.constructor:void 0,r=n?ki(n):"";if(r)switch(r){case pH:return kx;case mH:return wx;case gH:return xx;case yH:return Ex;case bH:return Sx}return e});var vH=Object.prototype,wH=vH.hasOwnProperty;function xH(t){var e=t.length,n=new t.constructor(e);return e&&typeof t[0]=="string"&&wH.call(t,"index")&&(n.index=t.index,n.input=t.input),n}var xd=Lr.Uint8Array;function vb(t){var e=new t.constructor(t.byteLength);return new xd(e).set(new xd(t)),e}function EH(t,e){var n=vb(t.buffer);return new t.constructor(n,t.byteOffset,t.byteLength)}var SH=/\w*$/;function kH(t){var e=new t.constructor(t.source,SH.exec(t));return e.lastIndex=t.lastIndex,e}var Tx=fr?fr.prototype:void 0,Cx=Tx?Tx.valueOf:void 0;function TH(t){return Cx?Object(Cx.call(t)):{}}function CH(t,e){var n=vb(t.buffer);return new t.constructor(n,t.byteOffset,t.length)}var AH="[object Boolean]",_H="[object Date]",MH="[object Map]",OH="[object Number]",RH="[object RegExp]",NH="[object Set]",IH="[object String]",DH="[object Symbol]",PH="[object ArrayBuffer]",LH="[object DataView]",jH="[object Float32Array]",$H="[object Float64Array]",FH="[object Int8Array]",UH="[object Int16Array]",BH="[object Int32Array]",zH="[object Uint8Array]",HH="[object Uint8ClampedArray]",VH="[object Uint16Array]",WH="[object Uint32Array]";function KH(t,e,n){var r=t.constructor;switch(e){case PH:return vb(t);case AH:case _H:return new r(+t);case LH:return EH(t);case jH:case $H:case FH:case UH:case BH:case zH:case HH:case VH:case WH:return CH(t);case MH:return new r;case OH:case IH:return new r(t);case RH:return kH(t);case NH:return new r;case DH:return TH(t)}}var GH="[object Map]";function qH(t){return No(t)&&xr(t)==GH}var Ax=fa&&fa.isMap,YH=Ax?pb(Ax):qH,JH="[object Set]";function XH(t){return No(t)&&xr(t)==JH}var _x=fa&&fa.isSet,QH=_x?pb(_x):XH,MA="[object Arguments]",ZH="[object Array]",eV="[object Boolean]",tV="[object Date]",nV="[object Error]",OA="[object Function]",rV="[object GeneratorFunction]",oV="[object Map]",sV="[object Number]",RA="[object Object]",iV="[object RegExp]",aV="[object Set]",lV="[object String]",cV="[object Symbol]",uV="[object WeakMap]",dV="[object ArrayBuffer]",fV="[object DataView]",hV="[object Float32Array]",pV="[object Float64Array]",mV="[object Int8Array]",gV="[object Int16Array]",yV="[object Int32Array]",bV="[object Uint8Array]",vV="[object Uint8ClampedArray]",wV="[object Uint16Array]",xV="[object Uint32Array]",dt={};dt[MA]=dt[ZH]=dt[dV]=dt[fV]=dt[eV]=dt[tV]=dt[hV]=dt[pV]=dt[mV]=dt[gV]=dt[yV]=dt[oV]=dt[sV]=dt[RA]=dt[iV]=dt[aV]=dt[lV]=dt[cV]=dt[bV]=dt[vV]=dt[wV]=dt[xV]=!0;dt[nV]=dt[OA]=dt[uV]=!1;function $u(t,e,n,r,o,s){var i;if(n&&(i=o?n(t,r,o,s):n(t)),i!==void 0)return i;if(!oo(t))return t;var a=_r(t);if(a)i=xH(t);else{var l=xr(t),c=l==OA||l==rV;if(wd(t))return aH(t);if(l==RA||l==MA||c&&!o)i={};else{if(!dt[l])return o?t:{};i=KH(t,l)}}s||(s=new Xr);var u=s.get(t);if(u)return u;s.set(t,i),QH(t)?t.forEach(function(h){i.add($u(h,e,n,h,t,s))}):YH(t)&&t.forEach(function(h,p){i.set(p,$u(h,e,n,p,t,s))});var d=bb,f=a?void 0:d(t);return u4(f||t,function(h,p){f&&(p=h,h=t[p]),db(i,p,$u(h,e,n,p,t,s))}),i}var EV="__lodash_hash_undefined__";function SV(t){return this.__data__.set(t,EV),this}function kV(t){return this.__data__.has(t)}function Ed(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new Fo;++e<n;)this.add(t[e])}Ed.prototype.add=Ed.prototype.push=SV;Ed.prototype.has=kV;function TV(t,e){for(var n=-1,r=t==null?0:t.length;++n<r;)if(e(t[n],n,t))return!0;return!1}function CV(t,e){return t.has(e)}var AV=1,_V=2;function NA(t,e,n,r,o,s){var i=n&AV,a=t.length,l=e.length;if(a!=l&&!(i&&l>a))return!1;var c=s.get(t),u=s.get(e);if(c&&u)return c==e&&u==t;var d=-1,f=!0,h=n&_V?new Ed:void 0;for(s.set(t,e),s.set(e,t);++d<a;){var p=t[d],m=e[d];if(r)var g=i?r(m,p,d,e,t,s):r(p,m,d,t,e,s);if(g!==void 0){if(g)continue;f=!1;break}if(h){if(!TV(e,function(b,S){if(!CV(h,S)&&(p===b||o(p,b,n,r,s)))return h.push(S)})){f=!1;break}}else if(!(p===m||o(p,m,n,r,s))){f=!1;break}}return s.delete(t),s.delete(e),f}function MV(t){var e=-1,n=Array(t.size);return t.forEach(function(r,o){n[++e]=[o,r]}),n}function OV(t){var e=-1,n=Array(t.size);return t.forEach(function(r){n[++e]=r}),n}var RV=1,NV=2,IV="[object Boolean]",DV="[object Date]",PV="[object Error]",LV="[object Map]",jV="[object Number]",$V="[object RegExp]",FV="[object Set]",UV="[object String]",BV="[object Symbol]",zV="[object ArrayBuffer]",HV="[object DataView]",Mx=fr?fr.prototype:void 0,Mp=Mx?Mx.valueOf:void 0;function VV(t,e,n,r,o,s,i){switch(n){case HV:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case zV:return!(t.byteLength!=e.byteLength||!s(new xd(t),new xd(e)));case IV:case DV:case jV:return ub(+t,+e);case PV:return t.name==e.name&&t.message==e.message;case $V:case UV:return t==e+"";case LV:var a=MV;case FV:var l=r&RV;if(a||(a=OV),t.size!=e.size&&!l)return!1;var c=i.get(t);if(c)return c==e;r|=NV,i.set(t,e);var u=NA(a(t),a(e),r,o,s,i);return i.delete(t),u;case BV:if(Mp)return Mp.call(t)==Mp.call(e)}return!1}var WV=1,KV=Object.prototype,GV=KV.hasOwnProperty;function qV(t,e,n,r,o,s){var i=n&WV,a=vx(t),l=a.length,c=vx(e),u=c.length;if(l!=u&&!i)return!1;for(var d=l;d--;){var f=a[d];if(!(i?f in e:GV.call(e,f)))return!1}var h=s.get(t),p=s.get(e);if(h&&p)return h==e&&p==t;var m=!0;s.set(t,e),s.set(e,t);for(var g=i;++d<l;){f=a[d];var b=t[f],S=e[f];if(r)var k=i?r(S,b,f,e,t,s):r(b,S,f,t,e,s);if(!(k===void 0?b===S||o(b,S,n,r,s):k)){m=!1;break}g||(g=f=="constructor")}if(m&&!g){var v=t.constructor,_=e.constructor;v!=_&&"constructor"in t&&"constructor"in e&&!(typeof v=="function"&&v instanceof v&&typeof _=="function"&&_ instanceof _)&&(m=!1)}return s.delete(t),s.delete(e),m}var YV=1,Ox="[object Arguments]",Rx="[object Array]",lu="[object Object]",JV=Object.prototype,Nx=JV.hasOwnProperty;function XV(t,e,n,r,o,s){var i=_r(t),a=_r(e),l=i?Rx:xr(t),c=a?Rx:xr(e);l=l==Ox?lu:l,c=c==Ox?lu:c;var u=l==lu,d=c==lu,f=l==c;if(f&&wd(t)){if(!wd(e))return!1;i=!0,u=!1}if(f&&!u)return s||(s=new Xr),i||vA(t)?NA(t,e,n,r,o,s):VV(t,e,l,n,r,o,s);if(!(n&YV)){var h=u&&Nx.call(t,"__wrapped__"),p=d&&Nx.call(e,"__wrapped__");if(h||p){var m=h?t.value():t,g=p?e.value():e;return s||(s=new Xr),o(m,g,n,r,s)}}return f?(s||(s=new Xr),qV(t,e,n,r,o,s)):!1}function wb(t,e,n,r,o){return t===e?!0:t==null||e==null||!No(t)&&!No(e)?t!==t&&e!==e:XV(t,e,n,r,wb,o)}var QV=1,ZV=2;function e6(t,e,n,r){var o=n.length,s=o;if(t==null)return!s;for(t=Object(t);o--;){var i=n[o];if(i[2]?i[1]!==t[i[0]]:!(i[0]in t))return!1}for(;++o<s;){i=n[o];var a=i[0],l=t[a],c=i[1];if(i[2]){if(l===void 0&&!(a in t))return!1}else{var u=new Xr,d;if(!(d===void 0?wb(c,l,QV|ZV,r,u):d))return!1}}return!0}function IA(t){return t===t&&!oo(t)}function t6(t){for(var e=EA(t),n=e.length;n--;){var r=e[n],o=t[r];e[n]=[r,o,IA(o)]}return e}function DA(t,e){return function(n){return n==null?!1:n[t]===e&&(e!==void 0||t in Object(n))}}function n6(t){var e=t6(t);return e.length==1&&e[0][2]?DA(e[0][0],e[0][1]):function(n){return n===t||e6(n,t,e)}}function r6(t,e){return t!=null&&e in Object(t)}function o6(t,e,n){e=_a(e,t);for(var r=-1,o=e.length,s=!1;++r<o;){var i=Ma(e[r]);if(!(s=t!=null&&n(t,i)))break;t=t[i]}return s||++r!=o?s:(o=t==null?0:t.length,!!o&&fb(o)&&cb(i,o)&&(_r(t)||hb(t)))}function s6(t,e){return t!=null&&o6(t,e,r6)}var i6=1,a6=2;function l6(t,e){return mb(t)&&IA(e)?DA(Ma(t),e):function(n){var r=zz(n,t);return r===void 0&&r===e?s6(n,t):wb(e,r,i6|a6)}}function c6(t){return function(e){return e?.[t]}}function u6(t){return function(e){return sh(e,t)}}function d6(t){return mb(t)?c6(Ma(t)):u6(t)}function PA(t){return typeof t=="function"?t:t==null?dA:typeof t=="object"?_r(t)?l6(t[0],t[1]):n6(t):d6(t)}var Op=function(){return Lr.Date.now()},f6="Expected a function",h6=Math.max,p6=Math.min;function m6(t,e,n){var r,o,s,i,a,l,c=0,u=!1,d=!1,f=!0;if(typeof t!="function")throw new TypeError(f6);e=lx(e)||0,oo(n)&&(u=!!n.leading,d="maxWait"in n,s=d?h6(lx(n.maxWait)||0,e):s,f="trailing"in n?!!n.trailing:f);function h(x){var A=r,E=o;return r=o=void 0,c=x,i=t.apply(E,A),i}function p(x){return c=x,a=setTimeout(b,e),u?h(x):i}function m(x){var A=x-l,E=x-c,T=e-A;return d?p6(T,s-E):T}function g(x){var A=x-l,E=x-c;return l===void 0||A>=e||A<0||d&&E>=s}function b(){var x=Op();if(g(x))return S(x);a=setTimeout(b,m(x))}function S(x){return a=void 0,f&&r?h(x):(r=o=void 0,i)}function k(){a!==void 0&&clearTimeout(a),c=0,r=l=o=a=void 0}function v(){return a===void 0?i:S(Op())}function _(){var x=Op(),A=g(x);if(r=arguments,o=this,l=x,A){if(a===void 0)return p(l);if(d)return clearTimeout(a),a=setTimeout(b,e),h(l)}return a===void 0&&(a=setTimeout(b,e)),i}return _.cancel=k,_.flush=v,_}function g6(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}function y6(t,e){return e.length<2?t:sh(t,Zz(e,0,-1))}function b6(t){return t==null}var v6="Expected a function";function w6(t){if(typeof t!="function")throw new TypeError(v6);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}var x6=Object.prototype,E6=x6.hasOwnProperty;function S6(t,e){e=_a(e,t);var n=-1,r=e.length;if(!r)return!0;for(var o=t==null||typeof t!="object"&&typeof t!="function";++n<r;){var s=e[n];if(typeof s=="string"){if(s==="__proto__"&&!E6.call(t,"__proto__"))return!1;if(s==="constructor"&&n+1<r&&typeof e[n+1]=="string"&&e[n+1]==="prototype"){if(o&&n===0)continue;return!1}}}var i=y6(t,e);return i==null||delete i[Ma(g6(e))]}function k6(t){return Qz(t)?void 0:t}var T6=1,C6=2,A6=4,_6=Kz(function(t,e){var n={};if(t==null)return n;var r=!1;e=lb(e,function(s){return s=_a(s,t),r||(r=s.length>1),s}),m4(t,bb(t),n),r&&(n=$u(n,T6|C6|A6,k6));for(var o=e.length;o--;)S6(n,e[o]);return n});function M6(t,e,n,r){if(!oo(t))return t;e=_a(e,t);for(var o=-1,s=e.length,i=s-1,a=t;a!=null&&++o<s;){var l=Ma(e[o]),c=n;if(l==="__proto__"||l==="constructor"||l==="prototype")return t;if(o!=i){var u=a[l];c=void 0,c===void 0&&(c=oo(u)?u:cb(e[o+1])?[]:{})}db(a,l,c),a=a[l]}return t}function O6(t,e,n){for(var r=-1,o=e.length,s={};++r<o;){var i=e[r],a=sh(t,i);n(a,i)&&M6(s,_a(i,t),a)}return s}function cg(t,e){if(t==null)return{};var n=lb(bb(t),function(r){return[r]});return e=PA(e),O6(t,n,function(r,o){return e(r,o[0])})}function R6(t,e){return cg(t,w6(PA(e)))}const LA=aA((t,e)=>({sessionManager:new w5,featureUsage:new x5,enabled:!1,debug:!1,logEventFn:null,publishCrosspost:new Map,initialize:(n,r={})=>{t({logEventFn:n,enabled:r.enabled??!1,debug:r.debug??!1}),r.debug},createSession:(n,r=Mo.Feed)=>{const{sessionManager:o,logEventFn:s,enabled:i,debug:a}=e(),l=o.createSession(n,r);if(i&&s){const c=cg({compose_session_id:l,timestamp:Date.now(),editor_type:n,editor_placement:r},u=>u!=null);s(Ft.SESSION.STARTED,c)}return l},deleteSession:n=>{const{sessionManager:r,trackEvent:o}=e(),s=r.getSession(n);s&&(o(n,Ft.SESSION.COMPLETED,{session_duration_ms:Date.now()-s.startTime}),r.deleteSession(n))},trackEvent:(n,r,o={})=>{const{sessionManager:s,logEventFn:i,enabled:a,debug:l}=e();if(!a||!i)return;const c=s.getSession(n);if(!c)return;const u={compose_session_id:n,timestamp:Date.now(),editor_type:c.editorType,editor_placement:c.placement,...o},d=cg(u,f=>f!=null);i(r,d)},trackPublish:(n,r)=>{const{trackEvent:o,sessionManager:s,publishCrosspost:i}=e(),a=s.getSession(n),l=r.isCrosspost??i.get(r.postId)??!1;r.status==="attempted"?(i.set(r.postId,l),o(n,Ft.PUBLISH.ATTEMPTED,{editor_type:r.editorType,post_id:r.postId,group_id:r.groupId,post_type:r.postType,is_crosspost:l,word_count:r.wordCount,media_count:r.mediaCount,link_count:r.linkCount,formatting_features:r.formattingFeatures})):r.status==="success"?(i.delete(r.postId),o(n,Ft.PUBLISH.SUCCESS,{editor_type:r.editorType,post_id:r.postId,group_id:r.groupId,post_type:r.postType,is_crosspost:l,word_count:r.wordCount,media_count:r.mediaCount,link_count:r.linkCount,formatting_features:r.formattingFeatures,session_duration_ms:a?Date.now()-a.startTime:void 0})):(i.delete(r.postId),s.setLastError(n,r.failureReason||"unknown"),o(n,Ft.PUBLISH.FAILED,{editor_type:r.editorType,post_id:r.postId,group_id:r.groupId,post_type:r.postType,is_crosspost:l,error_type:r.failureReason,word_count:r.wordCount,media_count:r.mediaCount,link_count:r.linkCount,formatting_features:r.formattingFeatures}))},trackExplicitAbandon:(n,r)=>{const{trackEvent:o,sessionManager:s}=e(),i=s.getSession(n);o(n,Ft.SESSION.ABANDONED,{session_duration_ms:i?Date.now()-i.startTime:0,content_length:r.contentLength,has_unsaved_changes:r.hasUnsavedChanges,abandon_reason:r.abandonReason,last_error_type:i?.lastErrorType||void 0})},trackFeature:(n,r)=>{const{sessionManager:o,trackEvent:s}=e(),{isFirstUse:i,usageCount:a}=o.trackFeature(n,r);s(n,i?Ft.FEATURE.DISCOVERED:Ft.FEATURE.REUSED,{feature_name:r,...i?{}:{usage_count:a}})},trackEditorFocus:(n,r)=>{const{sessionManager:o,trackEvent:s}=e();if(!o.markFocused(n,r))return;const i=o.getSession(n);s(n,Ft.EDITOR.FOCUSED,{surface:"editor",focus_source:r,time_to_focus_ms:i?Date.now()-i.startTime:void 0})},trackTabSwitch:(n,r,o)=>{const{trackEvent:s}=e();s(n,Ft.EDITOR.TAB_SWITCHED,{surface:"editor",from_tab:r,to_tab:o})},trackContentCreated:(n,r)=>{const{sessionManager:o,trackEvent:s}=e(),i=o.getSession(n);!i||i.contentCreatedFired||(o.markContentCreated(n),s(n,Ft.CONTENT.CREATED,{editor_type:r.editorType,word_count:r.wordCount,media_count:r.mediaCount,link_count:r.linkCount,time_to_first_content_ms:Date.now()-i.startTime}))},trackMediaUploadSuccess:(n,r)=>{const{trackEvent:o}=e();o(n,Ft.MEDIA.ADDED,{editor_type:r.editorType,media_type:r.mediaType,upload_source:r.source,file_size_mb:r.fileSizeMB})},trackMediaUploadFailed:(n,r)=>{const{sessionManager:o,trackEvent:s}=e();o.setLastError(n,r.errorType),s(n,Ft.MEDIA.UPLOAD_FAILED,{editor_type:r.editorType,media_type:r.mediaType,upload_source:r.source,file_size_mb:r.fileSizeMB,error_type:r.errorType})},trackMediaRemoved:(n,r)=>{const{trackEvent:o}=e();o(n,Ft.MEDIA.REMOVED,{editor_type:r.editorType,media_type:r.mediaType})},trackLinkAdded:(n,r)=>{const{trackEvent:o}=e();o(n,Ft.LINK.ADDED,{editor_type:r?.editorType})},trackLinkUnfurlFailed:(n,r)=>{const{sessionManager:o,trackEvent:s}=e();o.setLastError(n,"link_unfurl_failed"),s(n,Ft.LINK.UNFURL_FAILED,{editor_type:r?.editorType})},trackPollOptionAdded:(n,r)=>{const{trackEvent:o}=e();o(n,Ft.POLL.OPTION_ADDED,{option_count:r.option_count,option_type:r.option_type})},trackPollOptionRemoved:(n,r)=>{const{trackEvent:o}=e();o(n,Ft.POLL.OPTION_REMOVED,{option_count:r.option_count,option_type:r.option_type})}}));function hs(t){return El(LA,t)}const ps=()=>LA.getState();function Cs(){const{sessionId:t}=ab(),e=hs();return j.useMemo(()=>({trackPublish:n=>e.trackPublish(t,n),trackAbandon:n=>e.trackExplicitAbandon(t,n),trackFeature:n=>e.trackFeature(t,n),trackEditorFocus:n=>e.trackEditorFocus(t,n),trackTabSwitch:(n,r)=>e.trackTabSwitch(t,n,r),trackContentCreated:n=>e.trackContentCreated(t,n),trackMediaUploadSuccess:n=>e.trackMediaUploadSuccess(t,n),trackMediaUploadFailed:n=>e.trackMediaUploadFailed(t,n),trackMediaRemoved:n=>e.trackMediaRemoved(t,n),trackLinkAdded:n=>e.trackLinkAdded(t,n),trackLinkUnfurlFailed:n=>e.trackLinkUnfurlFailed(t,n),trackPollOptionAdded:n=>e.trackPollOptionAdded(t,n),trackPollOptionRemoved:n=>e.trackPollOptionRemoved(t,n),sessionId:t}),[e,t])}const Ix=b5(Pe),N6=({editorTab:t,onSwitchEditorTab:e})=>{const{t:n,unauthenticatedMode:r}=kn(),{trackTabSwitch:o}=Cs(),s=r?Ix.filter(l=>l.key!==Pe.Poll):Ix,i=l=>{o(t,l),e(l)},a=l=>{switch(l){case Pe.Media:return"postTabKey";case Pe.Blog:return"blogTabKey";case Pe.Poll:return"pollTabKey";default:return"postTabKey"}};return y.jsx(oA,{defaultValue:Pe.Media,value:t,onValueChange:i,className:"w-full",children:y.jsx(sA,{className:"w-full rounded-none border-b",children:s.map(l=>y.jsx(og,{value:l.value.toString(),children:n(a(l.key),l.value)},l.value))})})};function Dx(t,[e,n]){return Math.min(n,Math.max(e,t))}function I6(t,e=globalThis?.document){const n=Ar(t);w.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var D6="DismissableLayer",ug="dismissableLayer.update",P6="dismissableLayer.pointerDownOutside",L6="dismissableLayer.focusOutside",Px,jA=w.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Oa=w.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=t,c=w.useContext(jA),[u,d]=w.useState(null),f=u?.ownerDocument??globalThis?.document,[,h]=w.useState({}),p=Ze(e,A=>d(A)),m=Array.from(c.layers),[g]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),b=m.indexOf(g),S=u?m.indexOf(u):-1,k=c.layersWithOutsidePointerEventsDisabled.size>0,v=S>=b,_=F6(A=>{const E=A.target,T=[...c.branches].some(N=>N.contains(E));!v||T||(o?.(A),i?.(A),A.defaultPrevented||a?.())},f),x=U6(A=>{const E=A.target;[...c.branches].some(N=>N.contains(E))||(s?.(A),i?.(A),A.defaultPrevented||a?.())},f);return I6(A=>{S===c.layers.size-1&&(r?.(A),!A.defaultPrevented&&a&&(A.preventDefault(),a()))},f),w.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Px=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),Lx(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Px)}},[u,f,n,c]),w.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),Lx())},[u,c]),w.useEffect(()=>{const A=()=>h({});return document.addEventListener(ug,A),()=>document.removeEventListener(ug,A)},[]),y.jsx(Oe.div,{...l,ref:p,style:{pointerEvents:k?v?"auto":"none":void 0,...t.style},onFocusCapture:ae(t.onFocusCapture,x.onFocusCapture),onBlurCapture:ae(t.onBlurCapture,x.onBlurCapture),onPointerDownCapture:ae(t.onPointerDownCapture,_.onPointerDownCapture)})});Oa.displayName=D6;var j6="DismissableLayerBranch",$6=w.forwardRef((t,e)=>{const n=w.useContext(jA),r=w.useRef(null),o=Ze(e,r);return w.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),y.jsx(Oe.div,{...t,ref:o})});$6.displayName=j6;function F6(t,e=globalThis?.document){const n=Ar(t),r=w.useRef(!1),o=w.useRef(()=>{});return w.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){$A(P6,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(e.removeEventListener("click",o.current),o.current=l,e.addEventListener("click",o.current,{once:!0})):l()}else e.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{e.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(i),e.removeEventListener("pointerdown",s),e.removeEventListener("click",o.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function U6(t,e=globalThis?.document){const n=Ar(t),r=w.useRef(!1);return w.useEffect(()=>{const o=s=>{s.target&&!r.current&&$A(L6,n,{originalEvent:s},{discrete:!1})};return e.addEventListener("focusin",o),()=>e.removeEventListener("focusin",o)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Lx(){const t=new CustomEvent(ug);document.dispatchEvent(t)}function $A(t,e,n,{discrete:r}){const o=n.originalEvent.target,s=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&o.addEventListener(t,e,{once:!0}),r?hk(o,s):o.dispatchEvent(s)}var Rp=0;function ih(){w.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??jx()),document.body.insertAdjacentElement("beforeend",t[1]??jx()),Rp++,()=>{Rp===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),Rp--}},[])}function jx(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Np="focusScope.autoFocusOnMount",Ip="focusScope.autoFocusOnUnmount",$x={bubbles:!1,cancelable:!0},B6="FocusScope",Ac=w.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=t,[a,l]=w.useState(null),c=Ar(o),u=Ar(s),d=w.useRef(null),f=Ze(e,m=>l(m)),h=w.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;w.useEffect(()=>{if(r){let m=function(k){if(h.paused||!a)return;const v=k.target;a.contains(v)?d.current=v:qo(d.current,{select:!0})},g=function(k){if(h.paused||!a)return;const v=k.relatedTarget;v!==null&&(a.contains(v)||qo(d.current,{select:!0}))},b=function(k){if(document.activeElement===document.body)for(const _ of k)_.removedNodes.length>0&&qo(a)};document.addEventListener("focusin",m),document.addEventListener("focusout",g);const S=new MutationObserver(b);return a&&S.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",g),S.disconnect()}}},[r,a,h.paused]),w.useEffect(()=>{if(a){Ux.add(h);const m=document.activeElement;if(!a.contains(m)){const b=new CustomEvent(Np,$x);a.addEventListener(Np,c),a.dispatchEvent(b),b.defaultPrevented||(z6(G6(FA(a)),{select:!0}),document.activeElement===m&&qo(a))}return()=>{a.removeEventListener(Np,c),setTimeout(()=>{const b=new CustomEvent(Ip,$x);a.addEventListener(Ip,u),a.dispatchEvent(b),b.defaultPrevented||qo(m??document.body,{select:!0}),a.removeEventListener(Ip,u),Ux.remove(h)},0)}}},[a,c,u,h]);const p=w.useCallback(m=>{if(!n&&!r||h.paused)return;const g=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,b=document.activeElement;if(g&&b){const S=m.currentTarget,[k,v]=H6(S);k&&v?!m.shiftKey&&b===v?(m.preventDefault(),n&&qo(k,{select:!0})):m.shiftKey&&b===k&&(m.preventDefault(),n&&qo(v,{select:!0})):b===S&&m.preventDefault()}},[n,r,h.paused]);return y.jsx(Oe.div,{tabIndex:-1,...i,ref:f,onKeyDown:p})});Ac.displayName=B6;function z6(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(qo(r,{select:e}),document.activeElement!==n)return}function H6(t){const e=FA(t),n=Fx(e,t),r=Fx(e.reverse(),t);return[n,r]}function FA(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function Fx(t,e){for(const n of t)if(!V6(n,{upTo:e}))return n}function V6(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function W6(t){return t instanceof HTMLInputElement&&"select"in t}function qo(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&W6(t)&&e&&t.select()}}var Ux=K6();function K6(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=Bx(t,e),t.unshift(e)},remove(e){t=Bx(t,e),t[0]?.resume()}}}function Bx(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function G6(t){return t.filter(e=>e.tagName!=="A")}const q6=["top","right","bottom","left"],bs=Math.min,Hn=Math.max,Sd=Math.round,cu=Math.floor,Qr=t=>({x:t,y:t}),Y6={left:"right",right:"left",bottom:"top",top:"bottom"};function dg(t,e,n){return Hn(t,bs(e,n))}function Io(t,e){return typeof t=="function"?t(e):t}function Do(t){return t.split("-")[0]}function Ra(t){return t.split("-")[1]}function xb(t){return t==="x"?"y":"x"}function Eb(t){return t==="y"?"height":"width"}function Jr(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function Sb(t){return xb(Jr(t))}function J6(t,e,n){n===void 0&&(n=!1);const r=Ra(t),o=Sb(t),s=Eb(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(i=kd(i)),[i,kd(i)]}function X6(t){const e=kd(t);return[fg(t),e,fg(e)]}function fg(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const zx=["left","right"],Hx=["right","left"],Q6=["top","bottom"],Z6=["bottom","top"];function e8(t,e,n){switch(t){case"top":case"bottom":return n?e?Hx:zx:e?zx:Hx;case"left":case"right":return e?Q6:Z6;default:return[]}}function t8(t,e,n,r){const o=Ra(t);let s=e8(Do(t),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),e&&(s=s.concat(s.map(fg)))),s}function kd(t){const e=Do(t);return Y6[e]+t.slice(e.length)}function n8(t){return{top:0,right:0,bottom:0,left:0,...t}}function UA(t){return typeof t!="number"?n8(t):{top:t,right:t,bottom:t,left:t}}function Td(t){const{x:e,y:n,width:r,height:o}=t;return{width:r,height:o,top:n,left:e,right:e+r,bottom:n+o,x:e,y:n}}function Vx(t,e,n){let{reference:r,floating:o}=t;const s=Jr(e),i=Sb(e),a=Eb(i),l=Do(e),c=s==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,f=r[a]/2-o[a]/2;let h;switch(l){case"top":h={x:u,y:r.y-o.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-o.width,y:d};break;default:h={x:r.x,y:r.y}}switch(Ra(e)){case"start":h[i]-=f*(n&&c?-1:1);break;case"end":h[i]+=f*(n&&c?-1:1);break}return h}async function r8(t,e){var n;e===void 0&&(e={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:h=0}=Io(e,t),p=UA(h),g=a[f?d==="floating"?"reference":"floating":d],b=Td(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(g)))==null||n?g:g.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),S=d==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,k=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),v=await(s.isElement==null?void 0:s.isElement(k))?await(s.getScale==null?void 0:s.getScale(k))||{x:1,y:1}:{x:1,y:1},_=Td(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:S,offsetParent:k,strategy:l}):S);return{top:(b.top-_.top+p.top)/v.y,bottom:(_.bottom-b.bottom+p.bottom)/v.y,left:(b.left-_.left+p.left)/v.x,right:(_.right-b.right+p.right)/v.x}}const o8=50,s8=async(t,e,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=i.detectOverflow?i:{...i,detectOverflow:r8},l=await(i.isRTL==null?void 0:i.isRTL(e));let c=await i.getElementRects({reference:t,floating:e,strategy:o}),{x:u,y:d}=Vx(c,r,l),f=r,h=0;const p={};for(let m=0;m<s.length;m++){const g=s[m];if(!g)continue;const{name:b,fn:S}=g,{x:k,y:v,data:_,reset:x}=await S({x:u,y:d,initialPlacement:r,placement:f,strategy:o,middlewareData:p,rects:c,platform:a,elements:{reference:t,floating:e}});u=k??u,d=v??d,p[b]={...p[b],..._},x&&h<o8&&(h++,typeof x=="object"&&(x.placement&&(f=x.placement),x.rects&&(c=x.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:o}):x.rects),{x:u,y:d}=Vx(c,f,l)),m=-1)}return{x:u,y:d,placement:f,strategy:o,middlewareData:p}},i8=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=e,{element:c,padding:u=0}=Io(t,e)||{};if(c==null)return{};const d=UA(u),f={x:n,y:r},h=Sb(o),p=Eb(h),m=await i.getDimensions(c),g=h==="y",b=g?"top":"left",S=g?"bottom":"right",k=g?"clientHeight":"clientWidth",v=s.reference[p]+s.reference[h]-f[h]-s.floating[p],_=f[h]-s.reference[h],x=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let A=x?x[k]:0;(!A||!await(i.isElement==null?void 0:i.isElement(x)))&&(A=a.floating[k]||s.floating[p]);const E=v/2-_/2,T=A/2-m[p]/2-1,N=bs(d[b],T),I=bs(d[S],T),R=N,D=A-m[p]-I,O=A/2-m[p]/2+E,P=dg(R,O,D),C=!l.arrow&&Ra(o)!=null&&O!==P&&s.reference[p]/2-(O<R?N:I)-m[p]/2<0,M=C?O<R?O-R:O-D:0;return{[h]:f[h]+M,data:{[h]:P,centerOffset:O-P-M,...C&&{alignmentOffset:M}},reset:C}}}),a8=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...g}=Io(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const b=Do(o),S=Jr(a),k=Do(a)===a,v=await(l.isRTL==null?void 0:l.isRTL(c.floating)),_=f||(k||!m?[kd(a)]:X6(a)),x=p!=="none";!f&&x&&_.push(...t8(a,m,p,v));const A=[a,..._],E=await l.detectOverflow(e,g),T=[];let N=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&T.push(E[b]),d){const O=J6(o,i,v);T.push(E[O[0]],E[O[1]])}if(N=[...N,{placement:o,overflows:T}],!T.every(O=>O<=0)){var I,R;const O=(((I=s.flip)==null?void 0:I.index)||0)+1,P=A[O];if(P&&(!(d==="alignment"?S!==Jr(P):!1)||N.every(U=>Jr(U.placement)===S?U.overflows[0]>0:!0)))return{data:{index:O,overflows:N},reset:{placement:P}};let C=(R=N.filter(M=>M.overflows[0]<=0).sort((M,U)=>M.overflows[1]-U.overflows[1])[0])==null?void 0:R.placement;if(!C)switch(h){case"bestFit":{var D;const M=(D=N.filter(U=>{if(x){const L=Jr(U.placement);return L===S||L==="y"}return!0}).map(U=>[U.placement,U.overflows.filter(L=>L>0).reduce((L,F)=>L+F,0)]).sort((U,L)=>U[1]-L[1])[0])==null?void 0:D[0];M&&(C=M);break}case"initialPlacement":C=a;break}if(o!==C)return{reset:{placement:C}}}return{}}}};function Wx(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Kx(t){return q6.some(e=>t[e]>=0)}const l8=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:o="referenceHidden",...s}=Io(t,e);switch(o){case"referenceHidden":{const i=await r.detectOverflow(e,{...s,elementContext:"reference"}),a=Wx(i,n.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Kx(a)}}}case"escaped":{const i=await r.detectOverflow(e,{...s,altBoundary:!0}),a=Wx(i,n.floating);return{data:{escapedOffsets:a,escaped:Kx(a)}}}default:return{}}}}},BA=new Set(["left","top"]);async function c8(t,e){const{placement:n,platform:r,elements:o}=t,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=Do(n),a=Ra(n),l=Jr(n)==="y",c=BA.has(i)?-1:1,u=s&&l?-1:1,d=Io(e,t);let{mainAxis:f,crossAxis:h,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof p=="number"&&(h=a==="end"?p*-1:p),l?{x:h*u,y:f*c}:{x:f*c,y:h*u}}const u8=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:o,y:s,placement:i,middlewareData:a}=e,l=await c8(e,t);return i===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},d8=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:o,platform:s}=e,{mainAxis:i=!0,crossAxis:a=!1,limiter:l={fn:b=>{let{x:S,y:k}=b;return{x:S,y:k}}},...c}=Io(t,e),u={x:n,y:r},d=await s.detectOverflow(e,c),f=Jr(Do(o)),h=xb(f);let p=u[h],m=u[f];if(i){const b=h==="y"?"top":"left",S=h==="y"?"bottom":"right",k=p+d[b],v=p-d[S];p=dg(k,p,v)}if(a){const b=f==="y"?"top":"left",S=f==="y"?"bottom":"right",k=m+d[b],v=m-d[S];m=dg(k,m,v)}const g=l.fn({...e,[h]:p,[f]:m});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[h]:i,[f]:a}}}}}},f8=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:o,rects:s,middlewareData:i}=e,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=Io(t,e),u={x:n,y:r},d=Jr(o),f=xb(d);let h=u[f],p=u[d];const m=Io(a,e),g=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const k=f==="y"?"height":"width",v=s.reference[f]-s.floating[k]+g.mainAxis,_=s.reference[f]+s.reference[k]-g.mainAxis;h<v?h=v:h>_&&(h=_)}if(c){var b,S;const k=f==="y"?"width":"height",v=BA.has(Do(o)),_=s.reference[d]-s.floating[k]+(v&&((b=i.offset)==null?void 0:b[d])||0)+(v?0:g.crossAxis),x=s.reference[d]+s.reference[k]+(v?0:((S=i.offset)==null?void 0:S[d])||0)-(v?g.crossAxis:0);p<_?p=_:p>x&&(p=x)}return{[f]:h,[d]:p}}}},h8=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:o,rects:s,platform:i,elements:a}=e,{apply:l=()=>{},...c}=Io(t,e),u=await i.detectOverflow(e,c),d=Do(o),f=Ra(o),h=Jr(o)==="y",{width:p,height:m}=s.floating;let g,b;d==="top"||d==="bottom"?(g=d,b=f===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(b=d,g=f==="end"?"top":"bottom");const S=m-u.top-u.bottom,k=p-u.left-u.right,v=bs(m-u[g],S),_=bs(p-u[b],k),x=!e.middlewareData.shift;let A=v,E=_;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(E=k),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(A=S),x&&!f){const N=Hn(u.left,0),I=Hn(u.right,0),R=Hn(u.top,0),D=Hn(u.bottom,0);h?E=p-2*(N!==0||I!==0?N+I:Hn(u.left,u.right)):A=m-2*(R!==0||D!==0?R+D:Hn(u.top,u.bottom))}await l({...e,availableWidth:E,availableHeight:A});const T=await i.getDimensions(a.floating);return p!==T.width||m!==T.height?{reset:{rects:!0}}:{}}}};function ah(){return typeof window<"u"}function Na(t){return zA(t)?(t.nodeName||"").toLowerCase():"#document"}function qn(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function lo(t){var e;return(e=(zA(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function zA(t){return ah()?t instanceof Node||t instanceof qn(t).Node:!1}function Mr(t){return ah()?t instanceof Element||t instanceof qn(t).Element:!1}function Uo(t){return ah()?t instanceof HTMLElement||t instanceof qn(t).HTMLElement:!1}function Gx(t){return!ah()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof qn(t).ShadowRoot}function _c(t){const{overflow:e,overflowX:n,overflowY:r,display:o}=Or(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&o!=="inline"&&o!=="contents"}function p8(t){return/^(table|td|th)$/.test(Na(t))}function lh(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const m8=/transform|translate|scale|rotate|perspective|filter/,g8=/paint|layout|strict|content/,Ps=t=>!!t&&t!=="none";let Dp;function kb(t){const e=Mr(t)?Or(t):t;return Ps(e.transform)||Ps(e.translate)||Ps(e.scale)||Ps(e.rotate)||Ps(e.perspective)||!Tb()&&(Ps(e.backdropFilter)||Ps(e.filter))||m8.test(e.willChange||"")||g8.test(e.contain||"")}function y8(t){let e=vs(t);for(;Uo(e)&&!ha(e);){if(kb(e))return e;if(lh(e))return null;e=vs(e)}return null}function Tb(){return Dp==null&&(Dp=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Dp}function ha(t){return/^(html|body|#document)$/.test(Na(t))}function Or(t){return qn(t).getComputedStyle(t)}function ch(t){return Mr(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function vs(t){if(Na(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Gx(t)&&t.host||lo(t);return Gx(e)?e.host:e}function HA(t){const e=vs(t);return ha(e)?t.ownerDocument?t.ownerDocument.body:t.body:Uo(e)&&_c(e)?e:HA(e)}function ql(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const o=HA(t),s=o===((r=t.ownerDocument)==null?void 0:r.body),i=qn(o);if(s){const a=hg(i);return e.concat(i,i.visualViewport||[],_c(o)?o:[],a&&n?ql(a):[])}else return e.concat(o,ql(o,[],n))}function hg(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function VA(t){const e=Or(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const o=Uo(t),s=o?t.offsetWidth:n,i=o?t.offsetHeight:r,a=Sd(n)!==s||Sd(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function Cb(t){return Mr(t)?t:t.contextElement}function qi(t){const e=Cb(t);if(!Uo(e))return Qr(1);const n=e.getBoundingClientRect(),{width:r,height:o,$:s}=VA(e);let i=(s?Sd(n.width):n.width)/r,a=(s?Sd(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const b8=Qr(0);function WA(t){const e=qn(t);return!Tb()||!e.visualViewport?b8:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function v8(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==qn(t)?!1:e}function ci(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const o=t.getBoundingClientRect(),s=Cb(t);let i=Qr(1);e&&(r?Mr(r)&&(i=qi(r)):i=qi(t));const a=v8(s,n,r)?WA(s):Qr(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,u=o.width/i.x,d=o.height/i.y;if(s){const f=qn(s),h=r&&Mr(r)?qn(r):r;let p=f,m=hg(p);for(;m&&r&&h!==p;){const g=qi(m),b=m.getBoundingClientRect(),S=Or(m),k=b.left+(m.clientLeft+parseFloat(S.paddingLeft))*g.x,v=b.top+(m.clientTop+parseFloat(S.paddingTop))*g.y;l*=g.x,c*=g.y,u*=g.x,d*=g.y,l+=k,c+=v,p=qn(m),m=hg(p)}}return Td({width:u,height:d,x:l,y:c})}function uh(t,e){const n=ch(t).scrollLeft;return e?e.left+n:ci(lo(t)).left+n}function KA(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-uh(t,n),o=n.top+e.scrollTop;return{x:r,y:o}}function w8(t){let{elements:e,rect:n,offsetParent:r,strategy:o}=t;const s=o==="fixed",i=lo(r),a=e?lh(e.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Qr(1);const u=Qr(0),d=Uo(r);if((d||!d&&!s)&&((Na(r)!=="body"||_c(i))&&(l=ch(r)),d)){const h=ci(r);c=qi(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}const f=i&&!d&&!s?KA(i,l):Qr(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+f.x,y:n.y*c.y-l.scrollTop*c.y+u.y+f.y}}function x8(t){return Array.from(t.getClientRects())}function E8(t){const e=lo(t),n=ch(t),r=t.ownerDocument.body,o=Hn(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=Hn(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+uh(t);const a=-n.scrollTop;return Or(r).direction==="rtl"&&(i+=Hn(e.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const qx=25;function S8(t,e){const n=qn(t),r=lo(t),o=n.visualViewport;let s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;const u=Tb();(!u||u&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=uh(r);if(c<=0){const u=r.ownerDocument,d=u.body,f=getComputedStyle(d),h=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,p=Math.abs(r.clientWidth-d.clientWidth-h);p<=qx&&(s-=p)}else c<=qx&&(s+=c);return{width:s,height:i,x:a,y:l}}function k8(t,e){const n=ci(t,!0,e==="fixed"),r=n.top+t.clientTop,o=n.left+t.clientLeft,s=Uo(t)?qi(t):Qr(1),i=t.clientWidth*s.x,a=t.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function Yx(t,e,n){let r;if(e==="viewport")r=S8(t,n);else if(e==="document")r=E8(lo(t));else if(Mr(e))r=k8(e,n);else{const o=WA(t);r={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return Td(r)}function GA(t,e){const n=vs(t);return n===e||!Mr(n)||ha(n)?!1:Or(n).position==="fixed"||GA(n,e)}function T8(t,e){const n=e.get(t);if(n)return n;let r=ql(t,[],!1).filter(a=>Mr(a)&&Na(a)!=="body"),o=null;const s=Or(t).position==="fixed";let i=s?vs(t):t;for(;Mr(i)&&!ha(i);){const a=Or(i),l=kb(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||_c(i)&&!l&&GA(t,i))?r=r.filter(u=>u!==i):o=a,i=vs(i)}return e.set(t,r),r}function C8(t){let{element:e,boundary:n,rootBoundary:r,strategy:o}=t;const i=[...n==="clippingAncestors"?lh(e)?[]:T8(e,this._c):[].concat(n),r],a=Yx(e,i[0],o);let l=a.top,c=a.right,u=a.bottom,d=a.left;for(let f=1;f<i.length;f++){const h=Yx(e,i[f],o);l=Hn(h.top,l),c=bs(h.right,c),u=bs(h.bottom,u),d=Hn(h.left,d)}return{width:c-d,height:u-l,x:d,y:l}}function A8(t){const{width:e,height:n}=VA(t);return{width:e,height:n}}function _8(t,e,n){const r=Uo(e),o=lo(e),s=n==="fixed",i=ci(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=Qr(0);function c(){l.x=uh(o)}if(r||!r&&!s)if((Na(e)!=="body"||_c(o))&&(a=ch(e)),r){const h=ci(e,!0,s,e);l.x=h.x+e.clientLeft,l.y=h.y+e.clientTop}else o&&c();s&&!r&&o&&c();const u=o&&!r&&!s?KA(o,a):Qr(0),d=i.left+a.scrollLeft-l.x-u.x,f=i.top+a.scrollTop-l.y-u.y;return{x:d,y:f,width:i.width,height:i.height}}function Pp(t){return Or(t).position==="static"}function Jx(t,e){if(!Uo(t)||Or(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return lo(t)===n&&(n=n.ownerDocument.body),n}function qA(t,e){const n=qn(t);if(lh(t))return n;if(!Uo(t)){let o=vs(t);for(;o&&!ha(o);){if(Mr(o)&&!Pp(o))return o;o=vs(o)}return n}let r=Jx(t,e);for(;r&&p8(r)&&Pp(r);)r=Jx(r,e);return r&&ha(r)&&Pp(r)&&!kb(r)?n:r||y8(t)||n}const M8=async function(t){const e=this.getOffsetParent||qA,n=this.getDimensions,r=await n(t.floating);return{reference:_8(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function O8(t){return Or(t).direction==="rtl"}const R8={convertOffsetParentRelativeRectToViewportRelativeRect:w8,getDocumentElement:lo,getClippingRect:C8,getOffsetParent:qA,getElementRects:M8,getClientRects:x8,getDimensions:A8,getScale:qi,isElement:Mr,isRTL:O8};function YA(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function N8(t,e){let n=null,r;const o=lo(t);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function i(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=t.getBoundingClientRect(),{left:u,top:d,width:f,height:h}=c;if(a||e(),!f||!h)return;const p=cu(d),m=cu(o.clientWidth-(u+f)),g=cu(o.clientHeight-(d+h)),b=cu(u),k={rootMargin:-p+"px "+-m+"px "+-g+"px "+-b+"px",threshold:Hn(0,bs(1,l))||1};let v=!0;function _(x){const A=x[0].intersectionRatio;if(A!==l){if(!v)return i();A?i(!1,A):r=setTimeout(()=>{i(!1,1e-7)},1e3)}A===1&&!YA(c,t.getBoundingClientRect())&&i(),v=!1}try{n=new IntersectionObserver(_,{...k,root:o.ownerDocument})}catch{n=new IntersectionObserver(_,k)}n.observe(t)}return i(!0),s}function I8(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=Cb(t),u=o||s?[...c?ql(c):[],...e?ql(e):[]]:[];u.forEach(b=>{o&&b.addEventListener("scroll",n,{passive:!0}),s&&b.addEventListener("resize",n)});const d=c&&a?N8(c,n):null;let f=-1,h=null;i&&(h=new ResizeObserver(b=>{let[S]=b;S&&S.target===c&&h&&e&&(h.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var k;(k=h)==null||k.observe(e)})),n()}),c&&!l&&h.observe(c),e&&h.observe(e));let p,m=l?ci(t):null;l&&g();function g(){const b=ci(t);m&&!YA(m,b)&&n(),m=b,p=requestAnimationFrame(g)}return n(),()=>{var b;u.forEach(S=>{o&&S.removeEventListener("scroll",n),s&&S.removeEventListener("resize",n)}),d?.(),(b=h)==null||b.disconnect(),h=null,l&&cancelAnimationFrame(p)}}const D8=u8,P8=d8,L8=a8,j8=h8,$8=l8,Xx=i8,F8=f8,JA=(t,e,n)=>{const r=new Map,o={platform:R8,...n},s={...o.platform,_c:r};return s8(t,e,{...o,platform:s})};var U8=typeof document<"u",B8=function(){},Fu=U8?j.useLayoutEffect:B8;function Cd(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,o;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!Cd(t[r],e[r]))return!1;return!0}if(o=Object.keys(t),n=o.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,o[r]))return!1;for(r=n;r--!==0;){const s=o[r];if(!(s==="_owner"&&t.$$typeof)&&!Cd(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function XA(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Qx(t,e){const n=XA(t);return Math.round(e*n)/n}function Lp(t){const e=w.useRef(t);return Fu(()=>{e.current=t}),e}function z8(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=t,[u,d]=w.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[f,h]=w.useState(r);Cd(f,r)||h(r);const[p,m]=w.useState(null),[g,b]=w.useState(null),S=w.useCallback(U=>{U!==x.current&&(x.current=U,m(U))},[]),k=w.useCallback(U=>{U!==A.current&&(A.current=U,b(U))},[]),v=s||p,_=i||g,x=w.useRef(null),A=w.useRef(null),E=w.useRef(u),T=l!=null,N=Lp(l),I=Lp(o),R=Lp(c),D=w.useCallback(()=>{if(!x.current||!A.current)return;const U={placement:e,strategy:n,middleware:f};I.current&&(U.platform=I.current),JA(x.current,A.current,U).then(L=>{const F={...L,isPositioned:R.current!==!1};O.current&&!Cd(E.current,F)&&(E.current=F,vi.flushSync(()=>{d(F)}))})},[f,e,n,I,R]);Fu(()=>{c===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,d(U=>({...U,isPositioned:!1})))},[c]);const O=w.useRef(!1);Fu(()=>(O.current=!0,()=>{O.current=!1}),[]),Fu(()=>{if(v&&(x.current=v),_&&(A.current=_),v&&_){if(N.current)return N.current(v,_,D);D()}},[v,_,D,N,T]);const P=w.useMemo(()=>({reference:x,floating:A,setReference:S,setFloating:k}),[S,k]),C=w.useMemo(()=>({reference:v,floating:_}),[v,_]),M=w.useMemo(()=>{const U={position:n,left:0,top:0};if(!C.floating)return U;const L=Qx(C.floating,u.x),F=Qx(C.floating,u.y);return a?{...U,transform:"translate("+L+"px, "+F+"px)",...XA(C.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:L,top:F}},[n,a,C.floating,u.x,u.y]);return w.useMemo(()=>({...u,update:D,refs:P,elements:C,floatingStyles:M}),[u,D,P,C,M])}const H8=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:o}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?Xx({element:r.current,padding:o}).fn(n):{}:r?Xx({element:r,padding:o}).fn(n):{}}}},V8=(t,e)=>{const n=D8(t);return{name:n.name,fn:n.fn,options:[t,e]}},W8=(t,e)=>{const n=P8(t);return{name:n.name,fn:n.fn,options:[t,e]}},K8=(t,e)=>({fn:F8(t).fn,options:[t,e]}),G8=(t,e)=>{const n=L8(t);return{name:n.name,fn:n.fn,options:[t,e]}},q8=(t,e)=>{const n=j8(t);return{name:n.name,fn:n.fn,options:[t,e]}},Y8=(t,e)=>{const n=$8(t);return{name:n.name,fn:n.fn,options:[t,e]}},J8=(t,e)=>{const n=H8(t);return{name:n.name,fn:n.fn,options:[t,e]}};var X8="Arrow",QA=w.forwardRef((t,e)=>{const{children:n,width:r=10,height:o=5,...s}=t;return y.jsx(Oe.svg,{...s,ref:e,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:y.jsx("polygon",{points:"0,0 30,0 15,10"})})});QA.displayName=X8;var Q8=QA;function ZA(t){const[e,n]=w.useState(void 0);return Pt(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const s=o[0];let i,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;i=c.inlineSize,a=c.blockSize}else i=t.offsetWidth,a=t.offsetHeight;n({width:i,height:a})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var Ab="Popper",[e_,As]=Pr(Ab),[Z8,t_]=e_(Ab),n_=t=>{const{__scopePopper:e,children:n}=t,[r,o]=w.useState(null);return y.jsx(Z8,{scope:e,anchor:r,onAnchorChange:o,children:n})};n_.displayName=Ab;var r_="PopperAnchor",o_=w.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...o}=t,s=t_(r_,n),i=w.useRef(null),a=Ze(e,i),l=w.useRef(null);return w.useEffect(()=>{const c=l.current;l.current=r?.current||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:y.jsx(Oe.div,{...o,ref:a})});o_.displayName=r_;var _b="PopperContent",[eW,tW]=e_(_b),s_=w.forwardRef((t,e)=>{const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:s="center",alignOffset:i=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:h="optimized",onPlaced:p,...m}=t,g=t_(_b,n),[b,S]=w.useState(null),k=Ze(e,Y=>S(Y)),[v,_]=w.useState(null),x=ZA(v),A=x?.width??0,E=x?.height??0,T=r+(s!=="center"?"-"+s:""),N=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},I=Array.isArray(c)?c:[c],R=I.length>0,D={padding:N,boundary:I.filter(rW),altBoundary:R},{refs:O,floatingStyles:P,placement:C,isPositioned:M,middlewareData:U}=z8({strategy:"fixed",placement:T,whileElementsMounted:(...Y)=>I8(...Y,{animationFrame:h==="always"}),elements:{reference:g.anchor},middleware:[V8({mainAxis:o+E,alignmentAxis:i}),l&&W8({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?K8():void 0,...D}),l&&G8({...D}),q8({...D,apply:({elements:Y,rects:J,availableWidth:Q,availableHeight:ne})=>{const{width:se,height:te}=J.reference,ge=Y.floating.style;ge.setProperty("--radix-popper-available-width",`${Q}px`),ge.setProperty("--radix-popper-available-height",`${ne}px`),ge.setProperty("--radix-popper-anchor-width",`${se}px`),ge.setProperty("--radix-popper-anchor-height",`${te}px`)}}),v&&J8({element:v,padding:a}),oW({arrowWidth:A,arrowHeight:E}),f&&Y8({strategy:"referenceHidden",...D})]}),[L,F]=l_(C),V=Ar(p);Pt(()=>{M&&V?.()},[M,V]);const W=U.arrow?.x,H=U.arrow?.y,B=U.arrow?.centerOffset!==0,[$,K]=w.useState();return Pt(()=>{b&&K(window.getComputedStyle(b).zIndex)},[b]),y.jsx("div",{ref:O.setFloating,"data-radix-popper-content-wrapper":"",style:{...P,transform:M?P.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:$,"--radix-popper-transform-origin":[U.transformOrigin?.x,U.transformOrigin?.y].join(" "),...U.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:y.jsx(eW,{scope:n,placedSide:L,onArrowChange:_,arrowX:W,arrowY:H,shouldHideArrow:B,children:y.jsx(Oe.div,{"data-side":L,"data-align":F,...m,ref:k,style:{...m.style,animation:M?void 0:"none"}})})})});s_.displayName=_b;var i_="PopperArrow",nW={top:"bottom",right:"left",bottom:"top",left:"right"},a_=w.forwardRef(function(e,n){const{__scopePopper:r,...o}=e,s=tW(i_,r),i=nW[s.placedSide];return y.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:y.jsx(Q8,{...o,ref:n,style:{...o.style,display:"block"}})})});a_.displayName=i_;function rW(t){return t!==null}var oW=t=>({name:"transformOrigin",options:t,fn(e){const{placement:n,rects:r,middlewareData:o}=e,i=o.arrow?.centerOffset!==0,a=i?0:t.arrowWidth,l=i?0:t.arrowHeight,[c,u]=l_(n),d={start:"0%",center:"50%",end:"100%"}[u],f=(o.arrow?.x??0)+a/2,h=(o.arrow?.y??0)+l/2;let p="",m="";return c==="bottom"?(p=i?d:`${f}px`,m=`${-l}px`):c==="top"?(p=i?d:`${f}px`,m=`${r.floating.height+l}px`):c==="right"?(p=`${-l}px`,m=i?d:`${h}px`):c==="left"&&(p=`${r.floating.width+l}px`,m=i?d:`${h}px`),{data:{x:p,y:m}}}});function l_(t){const[e,n="center"]=t.split("-");return[e,n]}var dh=n_,Mc=o_,fh=s_,hh=a_,sW="Portal",Ia=w.forwardRef((t,e)=>{const{container:n,...r}=t,[o,s]=w.useState(!1);Pt(()=>s(!0),[]);const i=n||o&&globalThis?.document?.body;return i?vi.default.createPortal(y.jsx(Oe.div,{...r,ref:e}),i):null});Ia.displayName=sW;function iW(t){const e=aW(t),n=w.forwardRef((r,o)=>{const{children:s,...i}=r,a=w.Children.toArray(s),l=a.find(cW);if(l){const c=l.props.children,u=a.map(d=>d===l?w.Children.count(c)>1?w.Children.only(null):w.isValidElement(c)?c.props.children:null:d);return y.jsx(e,{...i,ref:o,children:w.isValidElement(c)?w.cloneElement(c,void 0,u):null})}return y.jsx(e,{...i,ref:o,children:s})});return n.displayName=`${t}.Slot`,n}function aW(t){const e=w.forwardRef((n,r)=>{const{children:o,...s}=n;if(w.isValidElement(o)){const i=dW(o),a=uW(s,o.props);return o.type!==w.Fragment&&(a.ref=r?ao(r,i):i),w.cloneElement(o,a)}return w.Children.count(o)>1?w.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var lW=Symbol("radix.slottable");function cW(t){return w.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===lW}function uW(t,e){const n={...e};for(const r in e){const o=t[r],s=e[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{const l=s(...a);return o(...a),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...t,...n}}function dW(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}function c_(t){const e=w.useRef({value:t,previous:t});return w.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var u_=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),fW="VisuallyHidden",d_=w.forwardRef((t,e)=>y.jsx(Oe.span,{...t,ref:e,style:{...u_,...t.style}}));d_.displayName=fW;var hW=d_,pW=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Di=new WeakMap,uu=new WeakMap,du={},jp=0,f_=function(t){return t&&(t.host||f_(t.parentNode))},mW=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=f_(n);return r&&t.contains(r)?r:null}).filter(function(n){return!!n})},gW=function(t,e,n,r){var o=mW(e,Array.isArray(t)?t:[t]);du[n]||(du[n]=new WeakMap);var s=du[n],i=[],a=new Set,l=new Set(o),c=function(d){!d||a.has(d)||(a.add(d),c(d.parentNode))};o.forEach(c);var u=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(f){if(a.has(f))u(f);else try{var h=f.getAttribute(r),p=h!==null&&h!=="false",m=(Di.get(f)||0)+1,g=(s.get(f)||0)+1;Di.set(f,m),s.set(f,g),i.push(f),m===1&&p&&uu.set(f,!0),g===1&&f.setAttribute(n,"true"),p||f.setAttribute(r,"true")}catch{}})};return u(e),a.clear(),jp++,function(){i.forEach(function(d){var f=Di.get(d)-1,h=s.get(d)-1;Di.set(d,f),s.set(d,h),f||(uu.has(d)||d.removeAttribute(r),uu.delete(d)),h||d.removeAttribute(n)}),jp--,jp||(Di=new WeakMap,Di=new WeakMap,uu=new WeakMap,du={})}},ph=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),o=pW(t);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),gW(r,o,n,"aria-hidden")):function(){return null}},qr=function(){return qr=Object.assign||function(e){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},qr.apply(this,arguments)};function h_(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]]);return n}function yW(t,e,n){if(n||arguments.length===2)for(var r=0,o=e.length,s;r<o;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return t.concat(s||Array.prototype.slice.call(e))}var Uu="right-scroll-bar-position",Bu="width-before-scroll-bar",bW="with-scroll-bars-hidden",vW="--removed-body-scroll-bar-size";function $p(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function wW(t,e){var n=j.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=e,n.facade}var xW=typeof window<"u"?w.useLayoutEffect:w.useEffect,Zx=new WeakMap;function EW(t,e){var n=wW(null,function(r){return t.forEach(function(o){return $p(o,r)})});return xW(function(){var r=Zx.get(n);if(r){var o=new Set(r),s=new Set(t),i=n.current;o.forEach(function(a){s.has(a)||$p(a,null)}),s.forEach(function(a){o.has(a)||$p(a,i)})}Zx.set(n,t)},[t]),n}function SW(t){return t}function kW(t,e){e===void 0&&(e=SW);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(s){var i=e(s,r);return n.push(i),function(){n=n.filter(function(a){return a!==i})}},assignSyncMedium:function(s){for(r=!0;n.length;){var i=n;n=[],i.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var i=[];if(n.length){var a=n;n=[],a.forEach(s),i=n}var l=function(){var u=i;i=[],u.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(u){i.push(u),c()},filter:function(u){return i=i.filter(u),n}}}};return o}function TW(t){t===void 0&&(t={});var e=kW(null);return e.options=qr({async:!0,ssr:!1},t),e}var p_=function(t){var e=t.sideCar,n=h_(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return w.createElement(r,qr({},n))};p_.isSideCarExport=!0;function CW(t,e){return t.useMedium(e),p_}var m_=TW(),Fp=function(){},mh=w.forwardRef(function(t,e){var n=w.useRef(null),r=w.useState({onScrollCapture:Fp,onWheelCapture:Fp,onTouchMoveCapture:Fp}),o=r[0],s=r[1],i=t.forwardProps,a=t.children,l=t.className,c=t.removeScrollBar,u=t.enabled,d=t.shards,f=t.sideCar,h=t.noRelative,p=t.noIsolation,m=t.inert,g=t.allowPinchZoom,b=t.as,S=b===void 0?"div":b,k=t.gapMode,v=h_(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),_=f,x=EW([n,e]),A=qr(qr({},v),o);return w.createElement(w.Fragment,null,u&&w.createElement(_,{sideCar:m_,removeScrollBar:c,shards:d,noRelative:h,noIsolation:p,inert:m,setCallbacks:s,allowPinchZoom:!!g,lockRef:n,gapMode:k}),i?w.cloneElement(w.Children.only(a),qr(qr({},A),{ref:x})):w.createElement(S,qr({},A,{className:l,ref:x}),a))});mh.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};mh.classNames={fullWidth:Bu,zeroRight:Uu};var AW=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function _W(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=AW();return e&&t.setAttribute("nonce",e),t}function MW(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function OW(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var RW=function(){var t=0,e=null;return{add:function(n){t==0&&(e=_W())&&(MW(e,n),OW(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},NW=function(){var t=RW();return function(e,n){w.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},g_=function(){var t=NW(),e=function(n){var r=n.styles,o=n.dynamic;return t(r,o),null};return e},IW={left:0,top:0,right:0,gap:0},Up=function(t){return parseInt(t||"",10)||0},DW=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],o=e[t==="padding"?"paddingRight":"marginRight"];return[Up(n),Up(r),Up(o)]},PW=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return IW;var e=DW(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},LW=g_(),Yi="data-scroll-locked",jW=function(t,e,n,r){var o=t.left,s=t.top,i=t.right,a=t.gap;return n===void 0&&(n="margin"),`
108
- .`.concat(bW,` {
109
- overflow: hidden `).concat(r,`;
110
- padding-right: `).concat(a,"px ").concat(r,`;
111
- }
112
- body[`).concat(Yi,`] {
113
- overflow: hidden `).concat(r,`;
114
- overscroll-behavior: contain;
115
- `).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&`
116
- padding-left: `.concat(o,`px;
117
- padding-top: `).concat(s,`px;
118
- padding-right: `).concat(i,`px;
119
- margin-left:0;
120
- margin-top:0;
121
- margin-right: `).concat(a,"px ").concat(r,`;
122
- `),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
123
- }
124
-
125
- .`).concat(Uu,` {
126
- right: `).concat(a,"px ").concat(r,`;
127
- }
128
-
129
- .`).concat(Bu,` {
130
- margin-right: `).concat(a,"px ").concat(r,`;
131
- }
132
-
133
- .`).concat(Uu," .").concat(Uu,` {
134
- right: 0 `).concat(r,`;
135
- }
136
-
137
- .`).concat(Bu," .").concat(Bu,` {
138
- margin-right: 0 `).concat(r,`;
139
- }
140
-
141
- body[`).concat(Yi,`] {
142
- `).concat(vW,": ").concat(a,`px;
143
- }
144
- `)},e1=function(){var t=parseInt(document.body.getAttribute(Yi)||"0",10);return isFinite(t)?t:0},$W=function(){w.useEffect(function(){return document.body.setAttribute(Yi,(e1()+1).toString()),function(){var t=e1()-1;t<=0?document.body.removeAttribute(Yi):document.body.setAttribute(Yi,t.toString())}},[])},FW=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,o=r===void 0?"margin":r;$W();var s=w.useMemo(function(){return PW(o)},[o]);return w.createElement(LW,{styles:jW(s,!e,o,n?"":"!important")})},pg=!1;if(typeof window<"u")try{var fu=Object.defineProperty({},"passive",{get:function(){return pg=!0,!0}});window.addEventListener("test",fu,fu),window.removeEventListener("test",fu,fu)}catch{pg=!1}var Pi=pg?{passive:!1}:!1,UW=function(t){return t.tagName==="TEXTAREA"},y_=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!UW(t)&&n[e]==="visible")},BW=function(t){return y_(t,"overflowY")},zW=function(t){return y_(t,"overflowX")},t1=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=b_(t,r);if(o){var s=v_(t,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},HW=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},VW=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},b_=function(t,e){return t==="v"?BW(e):zW(e)},v_=function(t,e){return t==="v"?HW(e):VW(e)},WW=function(t,e){return t==="h"&&e==="rtl"?-1:1},KW=function(t,e,n,r,o){var s=WW(t,window.getComputedStyle(e).direction),i=s*r,a=n.target,l=e.contains(a),c=!1,u=i>0,d=0,f=0;do{if(!a)break;var h=v_(t,a),p=h[0],m=h[1],g=h[2],b=m-g-s*p;(p||b)&&b_(t,a)&&(d+=b,f+=p);var S=a.parentNode;a=S&&S.nodeType===Node.DOCUMENT_FRAGMENT_NODE?S.host:S}while(!l&&a!==document.body||l&&(e.contains(a)||e===a));return(u&&Math.abs(d)<1||!u&&Math.abs(f)<1)&&(c=!0),c},hu=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},n1=function(t){return[t.deltaX,t.deltaY]},r1=function(t){return t&&"current"in t?t.current:t},GW=function(t,e){return t[0]===e[0]&&t[1]===e[1]},qW=function(t){return`
145
- .block-interactivity-`.concat(t,` {pointer-events: none;}
146
- .allow-interactivity-`).concat(t,` {pointer-events: all;}
147
- `)},YW=0,Li=[];function JW(t){var e=w.useRef([]),n=w.useRef([0,0]),r=w.useRef(),o=w.useState(YW++)[0],s=w.useState(g_)[0],i=w.useRef(t);w.useEffect(function(){i.current=t},[t]),w.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var m=yW([t.lockRef.current],(t.shards||[]).map(r1),!0).filter(Boolean);return m.forEach(function(g){return g.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),m.forEach(function(g){return g.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var a=w.useCallback(function(m,g){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!i.current.allowPinchZoom;var b=hu(m),S=n.current,k="deltaX"in m?m.deltaX:S[0]-b[0],v="deltaY"in m?m.deltaY:S[1]-b[1],_,x=m.target,A=Math.abs(k)>Math.abs(v)?"h":"v";if("touches"in m&&A==="h"&&x.type==="range")return!1;var E=window.getSelection(),T=E&&E.anchorNode,N=T?T===x||T.contains(x):!1;if(N)return!1;var I=t1(A,x);if(!I)return!0;if(I?_=A:(_=A==="v"?"h":"v",I=t1(A,x)),!I)return!1;if(!r.current&&"changedTouches"in m&&(k||v)&&(r.current=_),!_)return!0;var R=r.current||_;return KW(R,g,m,R==="h"?k:v)},[]),l=w.useCallback(function(m){var g=m;if(!(!Li.length||Li[Li.length-1]!==s)){var b="deltaY"in g?n1(g):hu(g),S=e.current.filter(function(_){return _.name===g.type&&(_.target===g.target||g.target===_.shadowParent)&&GW(_.delta,b)})[0];if(S&&S.should){g.cancelable&&g.preventDefault();return}if(!S){var k=(i.current.shards||[]).map(r1).filter(Boolean).filter(function(_){return _.contains(g.target)}),v=k.length>0?a(g,k[0]):!i.current.noIsolation;v&&g.cancelable&&g.preventDefault()}}},[]),c=w.useCallback(function(m,g,b,S){var k={name:m,delta:g,target:b,should:S,shadowParent:XW(b)};e.current.push(k),setTimeout(function(){e.current=e.current.filter(function(v){return v!==k})},1)},[]),u=w.useCallback(function(m){n.current=hu(m),r.current=void 0},[]),d=w.useCallback(function(m){c(m.type,n1(m),m.target,a(m,t.lockRef.current))},[]),f=w.useCallback(function(m){c(m.type,hu(m),m.target,a(m,t.lockRef.current))},[]);w.useEffect(function(){return Li.push(s),t.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,Pi),document.addEventListener("touchmove",l,Pi),document.addEventListener("touchstart",u,Pi),function(){Li=Li.filter(function(m){return m!==s}),document.removeEventListener("wheel",l,Pi),document.removeEventListener("touchmove",l,Pi),document.removeEventListener("touchstart",u,Pi)}},[]);var h=t.removeScrollBar,p=t.inert;return w.createElement(w.Fragment,null,p?w.createElement(s,{styles:qW(o)}):null,h?w.createElement(FW,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function XW(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const QW=CW(m_,JW);var Oc=w.forwardRef(function(t,e){return w.createElement(mh,qr({},t,{ref:e,sideCar:QW}))});Oc.classNames=mh.classNames;var ZW=[" ","Enter","ArrowUp","ArrowDown"],eK=[" ","Enter"],ui="Select",[gh,yh,tK]=Ay(ui),[Da]=Pr(ui,[tK,As]),bh=As(),[nK,_s]=Da(ui),[rK,oK]=Da(ui),w_=t=>{const{__scopeSelect:e,children:n,open:r,defaultOpen:o,onOpenChange:s,value:i,defaultValue:a,onValueChange:l,dir:c,name:u,autoComplete:d,disabled:f,required:h,form:p}=t,m=bh(e),[g,b]=w.useState(null),[S,k]=w.useState(null),[v,_]=w.useState(!1),x=$f(c),[A,E]=Ro({prop:r,defaultProp:o??!1,onChange:s,caller:ui}),[T,N]=Ro({prop:i,defaultProp:a,onChange:l,caller:ui}),I=w.useRef(null),R=g?p||!!g.closest("form"):!0,[D,O]=w.useState(new Set),P=Array.from(D).map(C=>C.props.value).join(";");return y.jsx(dh,{...m,children:y.jsxs(nK,{required:h,scope:e,trigger:g,onTriggerChange:b,valueNode:S,onValueNodeChange:k,valueNodeHasChildren:v,onValueNodeHasChildrenChange:_,contentId:sr(),value:T,onValueChange:N,open:A,onOpenChange:E,dir:x,triggerPointerDownPosRef:I,disabled:f,children:[y.jsx(gh.Provider,{scope:e,children:y.jsx(rK,{scope:t.__scopeSelect,onNativeOptionAdd:w.useCallback(C=>{O(M=>new Set(M).add(C))},[]),onNativeOptionRemove:w.useCallback(C=>{O(M=>{const U=new Set(M);return U.delete(C),U})},[]),children:n})}),R?y.jsxs(z_,{"aria-hidden":!0,required:h,tabIndex:-1,name:u,autoComplete:d,value:T,onChange:C=>N(C.target.value),disabled:f,form:p,children:[T===void 0?y.jsx("option",{value:""}):null,Array.from(D)]},P):null]})})};w_.displayName=ui;var x_="SelectTrigger",E_=w.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:r=!1,...o}=t,s=bh(n),i=_s(x_,n),a=i.disabled||r,l=Ze(e,i.onTriggerChange),c=yh(n),u=w.useRef("touch"),[d,f,h]=V_(m=>{const g=c().filter(k=>!k.disabled),b=g.find(k=>k.value===i.value),S=W_(g,m,b);S!==void 0&&i.onValueChange(S.value)}),p=m=>{a||(i.onOpenChange(!0),h()),m&&(i.triggerPointerDownPosRef.current={x:Math.round(m.pageX),y:Math.round(m.pageY)})};return y.jsx(Mc,{asChild:!0,...s,children:y.jsx(Oe.button,{type:"button",role:"combobox","aria-controls":i.contentId,"aria-expanded":i.open,"aria-required":i.required,"aria-autocomplete":"none",dir:i.dir,"data-state":i.open?"open":"closed",disabled:a,"data-disabled":a?"":void 0,"data-placeholder":H_(i.value)?"":void 0,...o,ref:l,onClick:ae(o.onClick,m=>{m.currentTarget.focus(),u.current!=="mouse"&&p(m)}),onPointerDown:ae(o.onPointerDown,m=>{u.current=m.pointerType;const g=m.target;g.hasPointerCapture(m.pointerId)&&g.releasePointerCapture(m.pointerId),m.button===0&&m.ctrlKey===!1&&m.pointerType==="mouse"&&(p(m),m.preventDefault())}),onKeyDown:ae(o.onKeyDown,m=>{const g=d.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&f(m.key),!(g&&m.key===" ")&&ZW.includes(m.key)&&(p(),m.preventDefault())})})})});E_.displayName=x_;var S_="SelectValue",k_=w.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=t,l=_s(S_,n),{onValueNodeHasChildrenChange:c}=l,u=s!==void 0,d=Ze(e,l.onValueNodeChange);return Pt(()=>{c(u)},[c,u]),y.jsx(Oe.span,{...a,ref:d,style:{pointerEvents:"none"},children:H_(l.value)?y.jsx(y.Fragment,{children:i}):s})});k_.displayName=S_;var sK="SelectIcon",T_=w.forwardRef((t,e)=>{const{__scopeSelect:n,children:r,...o}=t;return y.jsx(Oe.span,{"aria-hidden":!0,...o,ref:e,children:r||"▼"})});T_.displayName=sK;var iK="SelectPortal",C_=t=>y.jsx(Ia,{asChild:!0,...t});C_.displayName=iK;var di="SelectContent",A_=w.forwardRef((t,e)=>{const n=_s(di,t.__scopeSelect),[r,o]=w.useState();if(Pt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?vi.createPortal(y.jsx(__,{scope:t.__scopeSelect,children:y.jsx(gh.Slot,{scope:t.__scopeSelect,children:y.jsx("div",{children:t.children})})}),s):null}return y.jsx(M_,{...t,ref:e})});A_.displayName=di;var vr=10,[__,Ms]=Da(di),aK="SelectContentImpl",lK=iW("SelectContent.RemoveScroll"),M_=w.forwardRef((t,e)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:s,onPointerDownOutside:i,side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:h,sticky:p,hideWhenDetached:m,avoidCollisions:g,...b}=t,S=_s(di,n),[k,v]=w.useState(null),[_,x]=w.useState(null),A=Ze(e,Y=>v(Y)),[E,T]=w.useState(null),[N,I]=w.useState(null),R=yh(n),[D,O]=w.useState(!1),P=w.useRef(!1);w.useEffect(()=>{if(k)return ph(k)},[k]),ih();const C=w.useCallback(Y=>{const[J,...Q]=R().map(te=>te.ref.current),[ne]=Q.slice(-1),se=document.activeElement;for(const te of Y)if(te===se||(te?.scrollIntoView({block:"nearest"}),te===J&&_&&(_.scrollTop=0),te===ne&&_&&(_.scrollTop=_.scrollHeight),te?.focus(),document.activeElement!==se))return},[R,_]),M=w.useCallback(()=>C([E,k]),[C,E,k]);w.useEffect(()=>{D&&M()},[D,M]);const{onOpenChange:U,triggerPointerDownPosRef:L}=S;w.useEffect(()=>{if(k){let Y={x:0,y:0};const J=ne=>{Y={x:Math.abs(Math.round(ne.pageX)-(L.current?.x??0)),y:Math.abs(Math.round(ne.pageY)-(L.current?.y??0))}},Q=ne=>{Y.x<=10&&Y.y<=10?ne.preventDefault():k.contains(ne.target)||U(!1),document.removeEventListener("pointermove",J),L.current=null};return L.current!==null&&(document.addEventListener("pointermove",J),document.addEventListener("pointerup",Q,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",J),document.removeEventListener("pointerup",Q,{capture:!0})}}},[k,U,L]),w.useEffect(()=>{const Y=()=>U(!1);return window.addEventListener("blur",Y),window.addEventListener("resize",Y),()=>{window.removeEventListener("blur",Y),window.removeEventListener("resize",Y)}},[U]);const[F,V]=V_(Y=>{const J=R().filter(se=>!se.disabled),Q=J.find(se=>se.ref.current===document.activeElement),ne=W_(J,Y,Q);ne&&setTimeout(()=>ne.ref.current.focus())}),W=w.useCallback((Y,J,Q)=>{const ne=!P.current&&!Q;(S.value!==void 0&&S.value===J||ne)&&(T(Y),ne&&(P.current=!0))},[S.value]),H=w.useCallback(()=>k?.focus(),[k]),B=w.useCallback((Y,J,Q)=>{const ne=!P.current&&!Q;(S.value!==void 0&&S.value===J||ne)&&I(Y)},[S.value]),$=r==="popper"?mg:O_,K=$===mg?{side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:h,sticky:p,hideWhenDetached:m,avoidCollisions:g}:{};return y.jsx(__,{scope:n,content:k,viewport:_,onViewportChange:x,itemRefCallback:W,selectedItem:E,onItemLeave:H,itemTextRefCallback:B,focusSelectedItem:M,selectedItemText:N,position:r,isPositioned:D,searchRef:F,children:y.jsx(Oc,{as:lK,allowPinchZoom:!0,children:y.jsx(Ac,{asChild:!0,trapped:S.open,onMountAutoFocus:Y=>{Y.preventDefault()},onUnmountAutoFocus:ae(o,Y=>{S.trigger?.focus({preventScroll:!0}),Y.preventDefault()}),children:y.jsx(Oa,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:Y=>Y.preventDefault(),onDismiss:()=>S.onOpenChange(!1),children:y.jsx($,{role:"listbox",id:S.contentId,"data-state":S.open?"open":"closed",dir:S.dir,onContextMenu:Y=>Y.preventDefault(),...b,...K,onPlaced:()=>O(!0),ref:A,style:{display:"flex",flexDirection:"column",outline:"none",...b.style},onKeyDown:ae(b.onKeyDown,Y=>{const J=Y.ctrlKey||Y.altKey||Y.metaKey;if(Y.key==="Tab"&&Y.preventDefault(),!J&&Y.key.length===1&&V(Y.key),["ArrowUp","ArrowDown","Home","End"].includes(Y.key)){let ne=R().filter(se=>!se.disabled).map(se=>se.ref.current);if(["ArrowUp","End"].includes(Y.key)&&(ne=ne.slice().reverse()),["ArrowUp","ArrowDown"].includes(Y.key)){const se=Y.target,te=ne.indexOf(se);ne=ne.slice(te+1)}setTimeout(()=>C(ne)),Y.preventDefault()}})})})})})})});M_.displayName=aK;var cK="SelectItemAlignedPosition",O_=w.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:r,...o}=t,s=_s(di,n),i=Ms(di,n),[a,l]=w.useState(null),[c,u]=w.useState(null),d=Ze(e,A=>u(A)),f=yh(n),h=w.useRef(!1),p=w.useRef(!0),{viewport:m,selectedItem:g,selectedItemText:b,focusSelectedItem:S}=i,k=w.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&m&&g&&b){const A=s.trigger.getBoundingClientRect(),E=c.getBoundingClientRect(),T=s.valueNode.getBoundingClientRect(),N=b.getBoundingClientRect();if(s.dir!=="rtl"){const se=N.left-E.left,te=T.left-se,ge=A.left-te,he=A.width+ge,xe=Math.max(he,E.width),Ee=window.innerWidth-vr,Se=Dx(te,[vr,Math.max(vr,Ee-xe)]);a.style.minWidth=he+"px",a.style.left=Se+"px"}else{const se=E.right-N.right,te=window.innerWidth-T.right-se,ge=window.innerWidth-A.right-te,he=A.width+ge,xe=Math.max(he,E.width),Ee=window.innerWidth-vr,Se=Dx(te,[vr,Math.max(vr,Ee-xe)]);a.style.minWidth=he+"px",a.style.right=Se+"px"}const I=f(),R=window.innerHeight-vr*2,D=m.scrollHeight,O=window.getComputedStyle(c),P=parseInt(O.borderTopWidth,10),C=parseInt(O.paddingTop,10),M=parseInt(O.borderBottomWidth,10),U=parseInt(O.paddingBottom,10),L=P+C+D+U+M,F=Math.min(g.offsetHeight*5,L),V=window.getComputedStyle(m),W=parseInt(V.paddingTop,10),H=parseInt(V.paddingBottom,10),B=A.top+A.height/2-vr,$=R-B,K=g.offsetHeight/2,Y=g.offsetTop+K,J=P+C+Y,Q=L-J;if(J<=B){const se=I.length>0&&g===I[I.length-1].ref.current;a.style.bottom="0px";const te=c.clientHeight-m.offsetTop-m.offsetHeight,ge=Math.max($,K+(se?H:0)+te+M),he=J+ge;a.style.height=he+"px"}else{const se=I.length>0&&g===I[0].ref.current;a.style.top="0px";const ge=Math.max(B,P+m.offsetTop+(se?W:0)+K)+Q;a.style.height=ge+"px",m.scrollTop=J-B+m.offsetTop}a.style.margin=`${vr}px 0`,a.style.minHeight=F+"px",a.style.maxHeight=R+"px",r?.(),requestAnimationFrame(()=>h.current=!0)}},[f,s.trigger,s.valueNode,a,c,m,g,b,s.dir,r]);Pt(()=>k(),[k]);const[v,_]=w.useState();Pt(()=>{c&&_(window.getComputedStyle(c).zIndex)},[c]);const x=w.useCallback(A=>{A&&p.current===!0&&(k(),S?.(),p.current=!1)},[k,S]);return y.jsx(dK,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:h,onScrollButtonChange:x,children:y.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:v},children:y.jsx(Oe.div,{...o,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});O_.displayName=cK;var uK="SelectPopperPosition",mg=w.forwardRef((t,e)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=vr,...s}=t,i=bh(n);return y.jsx(fh,{...i,...s,ref:e,align:r,collisionPadding:o,style:{boxSizing:"border-box",...s.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});mg.displayName=uK;var[dK,Mb]=Da(di,{}),gg="SelectViewport",R_=w.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:r,...o}=t,s=Ms(gg,n),i=Mb(gg,n),a=Ze(e,s.onViewportChange),l=w.useRef(0);return y.jsxs(y.Fragment,{children:[y.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),y.jsx(gh.Slot,{scope:n,children:y.jsx(Oe.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:ae(o.onScroll,c=>{const u=c.currentTarget,{contentWrapper:d,shouldExpandOnScrollRef:f}=i;if(f?.current&&d){const h=Math.abs(l.current-u.scrollTop);if(h>0){const p=window.innerHeight-vr*2,m=parseFloat(d.style.minHeight),g=parseFloat(d.style.height),b=Math.max(m,g);if(b<p){const S=b+h,k=Math.min(p,S),v=S-k;d.style.height=k+"px",d.style.bottom==="0px"&&(u.scrollTop=v>0?v:0,d.style.justifyContent="flex-end")}}}l.current=u.scrollTop})})})]})});R_.displayName=gg;var N_="SelectGroup",[fK,hK]=Da(N_),pK=w.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,o=sr();return y.jsx(fK,{scope:n,id:o,children:y.jsx(Oe.div,{role:"group","aria-labelledby":o,...r,ref:e})})});pK.displayName=N_;var I_="SelectLabel",mK=w.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,o=hK(I_,n);return y.jsx(Oe.div,{id:o.id,...r,ref:e})});mK.displayName=I_;var Ad="SelectItem",[gK,D_]=Da(Ad),P_=w.forwardRef((t,e)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=t,a=_s(Ad,n),l=Ms(Ad,n),c=a.value===r,[u,d]=w.useState(s??""),[f,h]=w.useState(!1),p=Ze(e,S=>l.itemRefCallback?.(S,r,o)),m=sr(),g=w.useRef("touch"),b=()=>{o||(a.onValueChange(r),a.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return y.jsx(gK,{scope:n,value:r,disabled:o,textId:m,isSelected:c,onItemTextChange:w.useCallback(S=>{d(k=>k||(S?.textContent??"").trim())},[]),children:y.jsx(gh.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:y.jsx(Oe.div,{role:"option","aria-labelledby":m,"data-highlighted":f?"":void 0,"aria-selected":c&&f,"data-state":c?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...i,ref:p,onFocus:ae(i.onFocus,()=>h(!0)),onBlur:ae(i.onBlur,()=>h(!1)),onClick:ae(i.onClick,()=>{g.current!=="mouse"&&b()}),onPointerUp:ae(i.onPointerUp,()=>{g.current==="mouse"&&b()}),onPointerDown:ae(i.onPointerDown,S=>{g.current=S.pointerType}),onPointerMove:ae(i.onPointerMove,S=>{g.current=S.pointerType,o?l.onItemLeave?.():g.current==="mouse"&&S.currentTarget.focus({preventScroll:!0})}),onPointerLeave:ae(i.onPointerLeave,S=>{S.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:ae(i.onKeyDown,S=>{l.searchRef?.current!==""&&S.key===" "||(eK.includes(S.key)&&b(),S.key===" "&&S.preventDefault())})})})})});P_.displayName=Ad;var al="SelectItemText",L_=w.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:o,...s}=t,i=_s(al,n),a=Ms(al,n),l=D_(al,n),c=oK(al,n),[u,d]=w.useState(null),f=Ze(e,b=>d(b),l.onItemTextChange,b=>a.itemTextRefCallback?.(b,l.value,l.disabled)),h=u?.textContent,p=w.useMemo(()=>y.jsx("option",{value:l.value,disabled:l.disabled,children:h},l.value),[l.disabled,l.value,h]),{onNativeOptionAdd:m,onNativeOptionRemove:g}=c;return Pt(()=>(m(p),()=>g(p)),[m,g,p]),y.jsxs(y.Fragment,{children:[y.jsx(Oe.span,{id:l.textId,...s,ref:f}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?vi.createPortal(s.children,i.valueNode):null]})});L_.displayName=al;var j_="SelectItemIndicator",$_=w.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return D_(j_,n).isSelected?y.jsx(Oe.span,{"aria-hidden":!0,...r,ref:e}):null});$_.displayName=j_;var yg="SelectScrollUpButton",F_=w.forwardRef((t,e)=>{const n=Ms(yg,t.__scopeSelect),r=Mb(yg,t.__scopeSelect),[o,s]=w.useState(!1),i=Ze(e,r.onScrollButtonChange);return Pt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollTop>0;s(c)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?y.jsx(B_,{...t,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});F_.displayName=yg;var bg="SelectScrollDownButton",U_=w.forwardRef((t,e)=>{const n=Ms(bg,t.__scopeSelect),r=Mb(bg,t.__scopeSelect),[o,s]=w.useState(!1),i=Ze(e,r.onScrollButtonChange);return Pt(()=>{if(n.viewport&&n.isPositioned){let a=function(){const c=l.scrollHeight-l.clientHeight,u=Math.ceil(l.scrollTop)<c;s(u)};const l=n.viewport;return a(),l.addEventListener("scroll",a),()=>l.removeEventListener("scroll",a)}},[n.viewport,n.isPositioned]),o?y.jsx(B_,{...t,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});U_.displayName=bg;var B_=w.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=t,s=Ms("SelectScrollButton",n),i=w.useRef(null),a=yh(n),l=w.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return w.useEffect(()=>()=>l(),[l]),Pt(()=>{a().find(u=>u.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[a]),y.jsx(Oe.div,{"aria-hidden":!0,...o,ref:e,style:{flexShrink:0,...o.style},onPointerDown:ae(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:ae(o.onPointerMove,()=>{s.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:ae(o.onPointerLeave,()=>{l()})})}),yK="SelectSeparator",bK=w.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return y.jsx(Oe.div,{"aria-hidden":!0,...r,ref:e})});bK.displayName=yK;var vg="SelectArrow",vK=w.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,o=bh(n),s=_s(vg,n),i=Ms(vg,n);return s.open&&i.position==="popper"?y.jsx(hh,{...o,...r,ref:e}):null});vK.displayName=vg;var wK="SelectBubbleInput",z_=w.forwardRef(({__scopeSelect:t,value:e,...n},r)=>{const o=w.useRef(null),s=Ze(r,o),i=c_(e);return w.useEffect(()=>{const a=o.current;if(!a)return;const l=window.HTMLSelectElement.prototype,u=Object.getOwnPropertyDescriptor(l,"value").set;if(i!==e&&u){const d=new Event("change",{bubbles:!0});u.call(a,e),a.dispatchEvent(d)}},[i,e]),y.jsx(Oe.select,{...n,style:{...u_,...n.style},ref:s,defaultValue:e})});z_.displayName=wK;function H_(t){return t===""||t===void 0}function V_(t){const e=Ar(t),n=w.useRef(""),r=w.useRef(0),o=w.useCallback(i=>{const a=n.current+i;e(a),(function l(c){n.current=c,window.clearTimeout(r.current),c!==""&&(r.current=window.setTimeout(()=>l(""),1e3))})(a)},[e]),s=w.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return w.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function W_(t,e,n){const o=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,s=n?t.indexOf(n):-1;let i=xK(t,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.textValue.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function xK(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var EK=w_,SK=E_,kK=k_,TK=T_,CK=C_,AK=A_,_K=R_,MK=P_,OK=L_,RK=$_,NK=F_,IK=U_;const DK=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),PK=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),o1=t=>{const e=PK(t);return e.charAt(0).toUpperCase()+e.slice(1)},K_=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),LK=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var jK={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const $K=j.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:s,iconNode:i,...a},l)=>j.createElement("svg",{ref:l,...jK,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:K_("lucide",o),...!s&&!LK(a)&&{"aria-hidden":"true"},...a},[...i.map(([c,u])=>j.createElement(c,u)),...Array.isArray(s)?s:[s]]));const Le=(t,e)=>{const n=j.forwardRef(({className:r,...o},s)=>j.createElement($K,{ref:s,iconNode:e,className:K_(`lucide-${DK(o1(t))}`,`lucide-${t}`,r),...o}));return n.displayName=o1(t),n};const FK=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],UK=Le("bold",FK);const BK=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],G_=Le("check",BK);const zK=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],q_=Le("chevron-down",zK);const HK=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],VK=Le("chevron-right",HK);const WK=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],KK=Le("chevron-up",WK);const GK=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],qK=Le("circle",GK);const YK=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],s1=Le("code",YK);const JK=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],XK=Le("ellipsis",JK);const QK=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Yl=Le("external-link",QK);const ZK=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],i1=Le("file-code-2",ZK);const e9=[["path",{d:"m15 17 5-5-5-5",key:"nf172w"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]],a1=Le("forward",e9);const t9=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],n9=Le("grip-vertical",t9);const r9=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],l1=Le("heading-1",r9);const o9=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],c1=Le("heading-2",o9);const s9=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],u1=Le("heading-3",s9);const i9=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],Y_=Le("image-plus",i9);const a9=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Ob=Le("image",a9);const l9=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],d1=Le("italic",l9);const c9=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],J_=Le("link",c9);const u9=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],d9=Le("list-ordered",u9);const f9=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],h9=Le("list",f9);const p9=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],m9=Le("loader-circle",p9);const g9=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],y9=Le("mic",g9);const b9=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],_d=Le("music",b9);const v9=[["path",{d:"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4",key:"re6nr2"}],["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["path",{d:"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"pqwjuv"}]],w9=Le("notebook-pen",v9);const x9=[["path",{d:"M21 7v6h-6",key:"3ptur4"}],["path",{d:"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6 2.3l3 2.7",key:"1kgawr"}]],E9=Le("redo",x9);const S9=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],X_=Le("search",S9);const k9=[["path",{d:"M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z",key:"117uat"}],["path",{d:"M6 12h16",key:"s4cdu5"}]],f1=Le("send-horizontal",k9);const T9=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]],C9=Le("square-pen",T9);const A9=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],h1=Le("strikethrough",A9);const _9=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],M9=Le("text-align-center",_9);const O9=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],R9=Le("text-align-end",O9);const N9=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Q_=Le("text-align-start",N9);const I9=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],p1=Le("text-quote",I9);const D9=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],P9=Le("trash-2",D9);const L9=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],wg=Le("type",L9);const j9=[["path",{d:"M3 7v6h6",key:"1v2h90"}],["path",{d:"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6 2.3L3 13",key:"1r6uu6"}]],$9=Le("undo",j9);const F9=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],U9=Le("unlink",F9);const B9=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Rb=Le("video",B9);const z9=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],co=Le("x",z9);function H9({...t}){return y.jsx(EK,{"data-slot":"select",...t})}function V9({...t}){return y.jsx(kK,{"data-slot":"select-value",...t})}function W9({className:t,size:e="default",children:n,...r}){return y.jsxs(SK,{"data-slot":"select-trigger","data-size":e,className:oe("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r,children:[n,y.jsx(TK,{asChild:!0,children:y.jsx(q_,{className:"size-4 opacity-50"})})]})}function K9({className:t,children:e,position:n="popper",align:r="center",...o}){return y.jsx(CK,{children:y.jsx("div",{id:"select-wrapper","data-theme":"select-post-builder",children:y.jsxs(AK,{"data-slot":"select-content",className:oe("z-9999 bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:n,align:r,...o,children:[y.jsx(q9,{}),y.jsx(_K,{className:oe("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:e}),y.jsx(Y9,{})]})})})}function G9({className:t,children:e,...n}){return y.jsxs(MK,{"data-slot":"select-item",className:oe("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...n,children:[y.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:y.jsx(RK,{children:y.jsx(G_,{className:"size-4"})})}),y.jsx(OK,{children:e})]})}function q9({className:t,...e}){return y.jsx(NK,{"data-slot":"select-scroll-up-button",className:oe("flex cursor-default items-center justify-center py-1",t),...e,children:y.jsx(KK,{className:"size-4"})})}function Y9({className:t,...e}){return y.jsx(IK,{"data-slot":"select-scroll-down-button",className:oe("flex cursor-default items-center justify-center py-1",t),...e,children:y.jsx(q_,{className:"size-4"})})}function J9(t,e=[]){let n=[];function r(s,i){const a=w.createContext(i);a.displayName=s+"Context";const l=n.length;n=[...n,i];const c=d=>{const{scope:f,children:h,...p}=d,m=f?.[t]?.[l]||a,g=w.useMemo(()=>p,Object.values(p));return y.jsx(m.Provider,{value:g,children:h})};c.displayName=s+"Provider";function u(d,f){const h=f?.[t]?.[l]||a,p=w.useContext(h);if(p)return p;if(i!==void 0)return i;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[c,u]}const o=()=>{const s=n.map(i=>w.createContext(i));return function(a){const l=a?.[t]||s;return w.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return o.scopeName=t,[r,X9(o,...e)]}function X9(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const d=l(s)[`__scope${c}`];return{...a,...d}},{});return w.useMemo(()=>({[`__scope${e.scopeName}`]:i}),[i])}};return n.scopeName=e.scopeName,n}var Q9=Symbol.for("react.lazy"),Md=w[" use ".trim().toString()];function Z9(t){return typeof t=="object"&&t!==null&&"then"in t}function Z_(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===Q9&&"_payload"in t&&Z9(t._payload)}function Pa(t){const e=tG(t),n=w.forwardRef((r,o)=>{let{children:s,...i}=r;Z_(s)&&typeof Md=="function"&&(s=Md(s._payload));const a=w.Children.toArray(s),l=a.find(rG);if(l){const c=l.props.children,u=a.map(d=>d===l?w.Children.count(c)>1?w.Children.only(null):w.isValidElement(c)?c.props.children:null:d);return y.jsx(e,{...i,ref:o,children:w.isValidElement(c)?w.cloneElement(c,void 0,u):null})}return y.jsx(e,{...i,ref:o,children:s})});return n.displayName=`${t}.Slot`,n}var eG=Pa("Slot");function tG(t){const e=w.forwardRef((n,r)=>{let{children:o,...s}=n;if(Z_(o)&&typeof Md=="function"&&(o=Md(o._payload)),w.isValidElement(o)){const i=sG(o),a=oG(s,o.props);return o.type!==w.Fragment&&(a.ref=r?ao(r,i):i),w.cloneElement(o,a)}return w.Children.count(o)>1?w.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var nG=Symbol("radix.slottable");function rG(t){return w.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===nG}function oG(t,e){const n={...e};for(const r in e){const o=t[r],s=e[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{const l=s(...a);return o(...a),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...t,...n}}function sG(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var iG=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Nb=iG.reduce((t,e)=>{const n=Pa(`Primitive.${e}`),r=w.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),pu={exports:{}},Bp={};var m1;function aG(){if(m1)return Bp;m1=1;var t=w.default;function e(d,f){return d===f&&(d!==0||1/d===1/f)||d!==d&&f!==f}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,o=t.useEffect,s=t.useLayoutEffect,i=t.useDebugValue;function a(d,f){var h=f(),p=r({inst:{value:h,getSnapshot:f}}),m=p[0].inst,g=p[1];return s(function(){m.value=h,m.getSnapshot=f,l(m)&&g({inst:m})},[d,h,f]),o(function(){return l(m)&&g({inst:m}),d(function(){l(m)&&g({inst:m})})},[d]),i(h),h}function l(d){var f=d.getSnapshot;d=d.value;try{var h=f();return!n(d,h)}catch{return!0}}function c(d,f){return f()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return Bp.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,Bp}var zp={};var g1;function lG(){return g1||(g1=1,process.env.NODE_ENV!=="production"&&(function(){function t(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}function e(h,p){u||o.startTransition===void 0||(u=!0);var m=p();if(!d){var g=p();s(m,g)||(d=!0)}g=i({inst:{value:m,getSnapshot:p}});var b=g[0].inst,S=g[1];return l(function(){b.value=m,b.getSnapshot=p,n(b)&&S({inst:b})},[h,m,p]),a(function(){return n(b)&&S({inst:b}),h(function(){n(b)&&S({inst:b})})},[h]),c(m),m}function n(h){var p=h.getSnapshot;h=h.value;try{var m=p();return!s(h,m)}catch{return!0}}function r(h,p){return p()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=w.default,s=typeof Object.is=="function"?Object.is:t,i=o.useState,a=o.useEffect,l=o.useLayoutEffect,c=o.useDebugValue,u=!1,d=!1,f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:e;zp.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:f,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),zp}var y1;function Ib(){return y1||(y1=1,process.env.NODE_ENV==="production"?pu.exports=aG():pu.exports=lG()),pu.exports}var Db=Ib();function cG(){return Db.useSyncExternalStore(uG,()=>!0,()=>!1)}function uG(){return()=>{}}var Pb="Avatar",[dG]=J9(Pb),[fG,eM]=dG(Pb),tM=w.forwardRef((t,e)=>{const{__scopeAvatar:n,...r}=t,[o,s]=w.useState("idle");return y.jsx(fG,{scope:n,imageLoadingStatus:o,onImageLoadingStatusChange:s,children:y.jsx(Nb.span,{...r,ref:e})})});tM.displayName=Pb;var nM="AvatarImage",rM=w.forwardRef((t,e)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:o=()=>{},...s}=t,i=eM(nM,n),a=hG(r,s),l=Ar(c=>{o(c),i.onImageLoadingStatusChange(c)});return Pt(()=>{a!=="idle"&&l(a)},[a,l]),a==="loaded"?y.jsx(Nb.img,{...s,ref:e,src:r}):null});rM.displayName=nM;var oM="AvatarFallback",sM=w.forwardRef((t,e)=>{const{__scopeAvatar:n,delayMs:r,...o}=t,s=eM(oM,n),[i,a]=w.useState(r===void 0);return w.useEffect(()=>{if(r!==void 0){const l=window.setTimeout(()=>a(!0),r);return()=>window.clearTimeout(l)}},[r]),i&&s.imageLoadingStatus!=="loaded"?y.jsx(Nb.span,{...o,ref:e}):null});sM.displayName=oM;function b1(t,e){return t?e?(t.src!==e&&(t.src=e),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function hG(t,{referrerPolicy:e,crossOrigin:n}){const r=cG(),o=w.useRef(null),s=r?(o.current||(o.current=new window.Image),o.current):null,[i,a]=w.useState(()=>b1(s,t));return Pt(()=>{a(b1(s,t))},[s,t]),Pt(()=>{const l=d=>()=>{a(d)};if(!s)return;const c=l("loaded"),u=l("error");return s.addEventListener("load",c),s.addEventListener("error",u),e&&(s.referrerPolicy=e),typeof n=="string"&&(s.crossOrigin=n),()=>{s.removeEventListener("load",c),s.removeEventListener("error",u)}},[s,n,e]),i}var pG=tM,mG=rM,gG=sM;function iM({className:t,...e}){return y.jsx(pG,{"data-slot":"avatar",className:oe("relative flex size-8 shrink-0 overflow-hidden rounded-full",t),...e})}function aM({className:t,...e}){return y.jsx(mG,{"data-slot":"avatar-image",className:oe("aspect-square size-full",t),...e})}function lM({className:t,...e}){return y.jsx(gG,{"data-slot":"avatar-fallback",className:oe("bg-muted flex size-full items-center justify-center rounded-full",t),...e})}function $s({className:t,...e}){return y.jsx("div",{"data-slot":"skeleton",className:oe("bg-accent animate-pulse rounded-md",t),...e})}const cM=({store:t,onGroupSelect:e})=>{const{core:n}=wi(),[r,o]=j.useState([]),[s,i]=j.useState(!0),[a,l]=j.useState(!1),c=j.useRef(Dt()).current,u=El(t,m=>m.groupId),d=El(t,m=>m.selectedGroupId),f=El(t,m=>m.enableGroupSelector),h=d??u??"";j.useEffect(()=>{let m=!1;return(async()=>{try{const b=await n.fetchConversationList(999,0);if(m)return;o(b??[])}catch{if(m)return}finally{m||i(!1)}})(),()=>{m=!0}},[n]),j.useEffect(()=>{if(!s){if(f&&!h){l(!0);return}l(!1)}},[h,f,s]);const p=m=>{t.getState().selectGroup(m),l(!1),e?.(m)};return s?y.jsx("div",{className:"not-prose flex items-center gap-3",children:y.jsx($s,{className:"h-8 min-w-48 max-w-80 rounded-md"})}):y.jsx("div",{className:"not-prose flex items-center gap-3",children:y.jsxs(H9,{open:a,onOpenChange:l,value:h,onValueChange:p,children:[y.jsx(W9,{size:"sm",id:`group-selector-${h}-${c}`,className:"bg-background min-w-48 max-w-80 truncate","aria-label":"Select group",children:y.jsx(V9,{className:"text-sm max-w-80 truncate",placeholder:"Select a group…"})}),y.jsx(K9,{align:"start",children:r.map(m=>y.jsxs(G9,{value:m?.conversation_id,title:m?.conversation_detail?.name,className:"max-w-80 truncate",children:[y.jsxs(iM,{className:"size-6",children:[y.jsx(aM,{src:m?.conversation_detail?.avatar??void 0}),y.jsx(lM,{children:m?.conversation_detail?.name?.charAt(0)})]}),y.jsx("span",{className:"text-sm max-w-60 truncate",children:m?.conversation_detail?.name??m?.conversation_id})]},m?.conversation_id))})]})})},yG=t=>y.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:1.5,className:"size-6",viewBox:"0 0 24 24",...t,children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12.75 8.25v7.5m6-7.5h-3V12m0 0v3.75m0-3.75H18M9.75 9.348c-1.03-1.464-2.698-1.464-3.728 0-1.03 1.465-1.03 3.84 0 5.304 1.03 1.464 2.699 1.464 3.728 0V12h-1.5M4.5 19.5h15a2.25 2.25 0 0 0 2.25-2.25V6.75A2.25 2.25 0 0 0 19.5 4.5h-15a2.25 2.25 0 0 0-2.25 2.25v10.5A2.25 2.25 0 0 0 4.5 19.5Z"})}),v1=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,w1=HC,vh=(t,e)=>n=>{var r;if(e?.variants==null)return w1(t,n?.class,n?.className);const{variants:o,defaultVariants:s}=e,i=Object.keys(o).map(c=>{const u=n?.[c],d=s?.[c];if(u===null)return null;const f=v1(u)||v1(d);return o[c][f]}),a=n&&Object.entries(n).reduce((c,u)=>{let[d,f]=u;return f===void 0||(c[d]=f),c},{}),l=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:d,className:f,...h}=u;return Object.entries(h).every(p=>{let[m,g]=p;return Array.isArray(g)?g.includes({...s,...a}[m]):{...s,...a}[m]===g})?[...c,d,f]:c},[]);return w1(t,i,l,n?.class,n?.className)},bG=vh("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),zt=j.forwardRef(({className:t,variant:e,size:n,asChild:r=!1,...o},s)=>{const i=r?eG:"button";return y.jsx(i,{className:oe(bG({variant:e,size:n,className:t})),ref:s,...o})});zt.displayName="Button";var vG=Symbol("radix.slottable");function wG(t){const e=({children:n})=>y.jsx(y.Fragment,{children:n});return e.displayName=`${t}.Slottable`,e.__radixId=vG,e}var[wh]=Pr("Tooltip",[As]),xh=As(),uM="TooltipProvider",xG=700,xg="tooltip.open",[EG,Lb]=wh(uM),dM=t=>{const{__scopeTooltip:e,delayDuration:n=xG,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=t,i=w.useRef(!0),a=w.useRef(!1),l=w.useRef(0);return w.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),y.jsx(EG,{scope:e,isOpenDelayedRef:i,delayDuration:n,onOpen:w.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:w.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:w.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};dM.displayName=uM;var Jl="Tooltip",[SG,Rc]=wh(Jl),fM=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=t,l=Lb(Jl,t.__scopeTooltip),c=xh(e),[u,d]=w.useState(null),f=sr(),h=w.useRef(0),p=i??l.disableHoverableContent,m=a??l.delayDuration,g=w.useRef(!1),[b,S]=Ro({prop:r,defaultProp:o??!1,onChange:A=>{A?(l.onOpen(),document.dispatchEvent(new CustomEvent(xg))):l.onClose(),s?.(A)},caller:Jl}),k=w.useMemo(()=>b?g.current?"delayed-open":"instant-open":"closed",[b]),v=w.useCallback(()=>{window.clearTimeout(h.current),h.current=0,g.current=!1,S(!0)},[S]),_=w.useCallback(()=>{window.clearTimeout(h.current),h.current=0,S(!1)},[S]),x=w.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{g.current=!0,S(!0),h.current=0},m)},[m,S]);return w.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),y.jsx(dh,{...c,children:y.jsx(SG,{scope:e,contentId:f,open:b,stateAttribute:k,trigger:u,onTriggerChange:d,onTriggerEnter:w.useCallback(()=>{l.isOpenDelayedRef.current?x():v()},[l.isOpenDelayedRef,x,v]),onTriggerLeave:w.useCallback(()=>{p?_():(window.clearTimeout(h.current),h.current=0)},[_,p]),onOpen:v,onClose:_,disableHoverableContent:p,children:n})})};fM.displayName=Jl;var Eg="TooltipTrigger",hM=w.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,o=Rc(Eg,n),s=Lb(Eg,n),i=xh(n),a=w.useRef(null),l=Ze(e,a,o.onTriggerChange),c=w.useRef(!1),u=w.useRef(!1),d=w.useCallback(()=>c.current=!1,[]);return w.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),y.jsx(Mc,{asChild:!0,...i,children:y.jsx(Oe.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:ae(t.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),u.current=!0)}),onPointerLeave:ae(t.onPointerLeave,()=>{o.onTriggerLeave(),u.current=!1}),onPointerDown:ae(t.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:ae(t.onFocus,()=>{c.current||o.onOpen()}),onBlur:ae(t.onBlur,o.onClose),onClick:ae(t.onClick,o.onClose)})})});hM.displayName=Eg;var jb="TooltipPortal",[kG,TG]=wh(jb,{forceMount:void 0}),pM=t=>{const{__scopeTooltip:e,forceMount:n,children:r,container:o}=t,s=Rc(jb,e);return y.jsx(kG,{scope:e,forceMount:n,children:y.jsx(Jn,{present:n||s.open,children:y.jsx(Ia,{asChild:!0,container:o,children:r})})})};pM.displayName=jb;var pa="TooltipContent",mM=w.forwardRef((t,e)=>{const n=TG(pa,t.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=t,i=Rc(pa,t.__scopeTooltip);return y.jsx(Jn,{present:r||i.open,children:i.disableHoverableContent?y.jsx(gM,{side:o,...s,ref:e}):y.jsx(CG,{side:o,...s,ref:e})})}),CG=w.forwardRef((t,e)=>{const n=Rc(pa,t.__scopeTooltip),r=Lb(pa,t.__scopeTooltip),o=w.useRef(null),s=Ze(e,o),[i,a]=w.useState(null),{trigger:l,onClose:c}=n,u=o.current,{onPointerInTransitChange:d}=r,f=w.useCallback(()=>{a(null),d(!1)},[d]),h=w.useCallback((p,m)=>{const g=p.currentTarget,b={x:p.clientX,y:p.clientY},S=OG(b,g.getBoundingClientRect()),k=RG(b,S),v=NG(m.getBoundingClientRect()),_=DG([...k,...v]);a(_),d(!0)},[d]);return w.useEffect(()=>()=>f(),[f]),w.useEffect(()=>{if(l&&u){const p=g=>h(g,u),m=g=>h(g,l);return l.addEventListener("pointerleave",p),u.addEventListener("pointerleave",m),()=>{l.removeEventListener("pointerleave",p),u.removeEventListener("pointerleave",m)}}},[l,u,h,f]),w.useEffect(()=>{if(i){const p=m=>{const g=m.target,b={x:m.clientX,y:m.clientY},S=l?.contains(g)||u?.contains(g),k=!IG(b,i);S?f():k&&(f(),c())};return document.addEventListener("pointermove",p),()=>document.removeEventListener("pointermove",p)}},[l,u,i,c,f]),y.jsx(gM,{...t,ref:s})}),[AG,_G]=wh(Jl,{isInside:!1}),MG=wG("TooltipContent"),gM=w.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=t,l=Rc(pa,n),c=xh(n),{onClose:u}=l;return w.useEffect(()=>(document.addEventListener(xg,u),()=>document.removeEventListener(xg,u)),[u]),w.useEffect(()=>{if(l.trigger){const d=f=>{f.target?.contains(l.trigger)&&u()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,u]),y.jsx(Oa,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:y.jsxs(fh,{"data-state":l.stateAttribute,...c,...a,ref:e,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[y.jsx(MG,{children:r}),y.jsx(AG,{scope:n,isInside:!0,children:y.jsx(hW,{id:l.contentId,role:"tooltip",children:o||r})})]})})});mM.displayName=pa;var yM="TooltipArrow",bM=w.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,o=xh(n);return _G(yM,n).isInside?null:y.jsx(hh,{...o,...r,ref:e})});bM.displayName=yM;function OG(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),o=Math.abs(e.right-t.x),s=Math.abs(e.left-t.x);switch(Math.min(n,r,o,s)){case s:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function RG(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function NG(t){const{top:e,right:n,bottom:r,left:o}=t;return[{x:o,y:e},{x:n,y:e},{x:n,y:r},{x:o,y:r}]}function IG(t,e){const{x:n,y:r}=t;let o=!1;for(let s=0,i=e.length-1;s<e.length;i=s++){const a=e[s],l=e[i],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(o=!o)}return o}function DG(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),PG(e)}function PG(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const o=t[r];for(;e.length>=2;){const s=e[e.length-1],i=e[e.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))e.pop();else break}e.push(o)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const o=t[r];for(;n.length>=2;){const s=n[n.length-1],i=n[n.length-2];if((s.x-i.x)*(o.y-i.y)>=(s.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var LG=dM,jG=fM,$G=hM,FG=pM,UG=mM,BG=bM;function vM({delayDuration:t=0,...e}){return y.jsx(LG,{delayDuration:t,...e})}function wM(t){return y.jsx(vM,{children:y.jsx(jG,{...t})})}const $b=j.forwardRef((t,e)=>y.jsx($G,{ref:e,...t}));$b.displayName="TooltipTrigger";const Fb=j.forwardRef(({className:t,sideOffset:e=0,children:n,...r},o)=>y.jsx(FG,{children:y.jsx("div",{"data-theme":"select-post-builder",children:y.jsxs(UG,{ref:o,sideOffset:e,className:oe("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-[--radix-tooltip-content-transform-origin] rounded-md px-3 py-1.5 text-xs text-balance",t),...r,children:[n,y.jsx(BG,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}));Fb.displayName="TooltipContent";const{getOwnPropertyNames:zG,getOwnPropertySymbols:HG}=Object,{hasOwnProperty:VG}=Object.prototype;function Hp(t,e){return function(r,o,s){return t(r,o,s)&&e(r,o,s)}}function mu(t){return function(n,r,o){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,o);const{cache:s}=o,i=s.get(n),a=s.get(r);if(i&&a)return i===r&&a===n;s.set(n,r),s.set(r,n);const l=t(n,r,o);return s.delete(n),s.delete(r),l}}function WG(t){return t?.[Symbol.toStringTag]}function x1(t){return zG(t).concat(HG(t))}const KG=Object.hasOwn||((t,e)=>VG.call(t,e));function Ci(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const GG="__v",qG="__o",YG="_owner",{getOwnPropertyDescriptor:E1,keys:S1}=Object;function JG(t,e){return t.byteLength===e.byteLength&&Od(new Uint8Array(t),new Uint8Array(e))}function XG(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function QG(t,e){return t.byteLength===e.byteLength&&Od(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function ZG(t,e){return Ci(t.getTime(),e.getTime())}function e7(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function t7(t,e){return t===e}function k1(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const o=new Array(r),s=t.entries();let i,a,l=0;for(;(i=s.next())&&!i.done;){const c=e.entries();let u=!1,d=0;for(;(a=c.next())&&!a.done;){if(o[d]){d++;continue}const f=i.value,h=a.value;if(n.equals(f[0],h[0],l,d,t,e,n)&&n.equals(f[1],h[1],f[0],h[0],t,e,n)){u=o[d]=!0;break}d++}if(!u)return!1;l++}return!0}const n7=Ci;function r7(t,e,n){const r=S1(t);let o=r.length;if(S1(e).length!==o)return!1;for(;o-- >0;)if(!xM(t,e,n,r[o]))return!1;return!0}function Ka(t,e,n){const r=x1(t);let o=r.length;if(x1(e).length!==o)return!1;let s,i,a;for(;o-- >0;)if(s=r[o],!xM(t,e,n,s)||(i=E1(t,s),a=E1(e,s),(i||a)&&(!i||!a||i.configurable!==a.configurable||i.enumerable!==a.enumerable||i.writable!==a.writable)))return!1;return!0}function o7(t,e){return Ci(t.valueOf(),e.valueOf())}function s7(t,e){return t.source===e.source&&t.flags===e.flags}function T1(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const o=new Array(r),s=t.values();let i,a;for(;(i=s.next())&&!i.done;){const l=e.values();let c=!1,u=0;for(;(a=l.next())&&!a.done;){if(!o[u]&&n.equals(i.value,a.value,i.value,a.value,t,e,n)){c=o[u]=!0;break}u++}if(!c)return!1}return!0}function Od(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function i7(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function xM(t,e,n,r){return(r===YG||r===qG||r===GG)&&(t.$$typeof||e.$$typeof)?!0:KG(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const a7="[object ArrayBuffer]",l7="[object Arguments]",c7="[object Boolean]",u7="[object DataView]",d7="[object Date]",f7="[object Error]",h7="[object Map]",p7="[object Number]",m7="[object Object]",g7="[object RegExp]",y7="[object Set]",b7="[object String]",v7={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},w7="[object URL]",x7=Object.prototype.toString;function E7({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:o,areFunctionsEqual:s,areMapsEqual:i,areNumbersEqual:a,areObjectsEqual:l,arePrimitiveWrappersEqual:c,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:f,areUrlsEqual:h,unknownTagComparators:p}){return function(g,b,S){if(g===b)return!0;if(g==null||b==null)return!1;const k=typeof g;if(k!==typeof b)return!1;if(k!=="object")return k==="number"?a(g,b,S):k==="function"?s(g,b,S):!1;const v=g.constructor;if(v!==b.constructor)return!1;if(v===Object)return l(g,b,S);if(Array.isArray(g))return e(g,b,S);if(v===Date)return r(g,b,S);if(v===RegExp)return u(g,b,S);if(v===Map)return i(g,b,S);if(v===Set)return d(g,b,S);const _=x7.call(g);if(_===d7)return r(g,b,S);if(_===g7)return u(g,b,S);if(_===h7)return i(g,b,S);if(_===y7)return d(g,b,S);if(_===m7)return typeof g.then!="function"&&typeof b.then!="function"&&l(g,b,S);if(_===w7)return h(g,b,S);if(_===f7)return o(g,b,S);if(_===l7)return l(g,b,S);if(v7[_])return f(g,b,S);if(_===a7)return t(g,b,S);if(_===u7)return n(g,b,S);if(_===c7||_===p7||_===b7)return c(g,b,S);if(p){let x=p[_];if(!x){const A=WG(g);A&&(x=p[A])}if(x)return x(g,b,S)}return!1}}function S7({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:JG,areArraysEqual:n?Ka:XG,areDataViewsEqual:QG,areDatesEqual:ZG,areErrorsEqual:e7,areFunctionsEqual:t7,areMapsEqual:n?Hp(k1,Ka):k1,areNumbersEqual:n7,areObjectsEqual:n?Ka:r7,arePrimitiveWrappersEqual:o7,areRegExpsEqual:s7,areSetsEqual:n?Hp(T1,Ka):T1,areTypedArraysEqual:n?Hp(Od,Ka):Od,areUrlsEqual:i7,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const o=mu(r.areArraysEqual),s=mu(r.areMapsEqual),i=mu(r.areObjectsEqual),a=mu(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:o,areMapsEqual:s,areObjectsEqual:i,areSetsEqual:a})}return r}function k7(t){return function(e,n,r,o,s,i,a){return t(e,n,a)}}function T7({circular:t,comparator:e,createState:n,equals:r,strict:o}){if(n)return function(a,l){const{cache:c=t?new WeakMap:void 0,meta:u}=n();return e(a,l,{cache:c,equals:r,meta:u,strict:o})};if(t)return function(a,l){return e(a,l,{cache:new WeakMap,equals:r,meta:void 0,strict:o})};const s={cache:void 0,equals:r,meta:void 0,strict:o};return function(a,l){return e(a,l,s)}}const C7=Os();Os({strict:!0});Os({circular:!0});Os({circular:!0,strict:!0});Os({createInternalComparator:()=>Ci});Os({strict:!0,createInternalComparator:()=>Ci});Os({circular:!0,createInternalComparator:()=>Ci});Os({circular:!0,createInternalComparator:()=>Ci,strict:!0});function Os(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:o=!1}=t,s=S7(t),i=E7(s),a=n?n(i):k7(i);return T7({circular:e,comparator:i,createState:r,equals:a,strict:o})}var gu={exports:{}},Vp={};var C1;function A7(){if(C1)return Vp;C1=1;var t=w.default,e=Ib();function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:n,o=e.useSyncExternalStore,s=t.useRef,i=t.useEffect,a=t.useMemo,l=t.useDebugValue;return Vp.useSyncExternalStoreWithSelector=function(c,u,d,f,h){var p=s(null);if(p.current===null){var m={hasValue:!1,value:null};p.current=m}else m=p.current;p=a(function(){function b(x){if(!S){if(S=!0,k=x,x=f(x),h!==void 0&&m.hasValue){var A=m.value;if(h(A,x))return v=A}return v=x}if(A=v,r(k,x))return A;var E=f(x);return h!==void 0&&h(A,E)?(k=x,A):(k=x,v=E)}var S=!1,k,v,_=d===void 0?null:d;return[function(){return b(u())},_===null?void 0:function(){return b(_())}]},[u,d,f,h]);var g=o(c,p[0],p[1]);return i(function(){m.hasValue=!0,m.value=g},[g]),l(g),g},Vp}var Wp={};var A1;function _7(){return A1||(A1=1,process.env.NODE_ENV!=="production"&&(function(){function t(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var e=w.default,n=Ib(),r=typeof Object.is=="function"?Object.is:t,o=n.useSyncExternalStore,s=e.useRef,i=e.useEffect,a=e.useMemo,l=e.useDebugValue;Wp.useSyncExternalStoreWithSelector=function(c,u,d,f,h){var p=s(null);if(p.current===null){var m={hasValue:!1,value:null};p.current=m}else m=p.current;p=a(function(){function b(x){if(!S){if(S=!0,k=x,x=f(x),h!==void 0&&m.hasValue){var A=m.value;if(h(A,x))return v=A}return v=x}if(A=v,r(k,x))return A;var E=f(x);return h!==void 0&&h(A,E)?(k=x,A):(k=x,v=E)}var S=!1,k,v,_=d===void 0?null:d;return[function(){return b(u())},_===null?void 0:function(){return b(_())}]},[u,d,f,h]);var g=o(c,p[0],p[1]);return i(function(){m.hasValue=!0,m.value=g},[g]),l(g),g},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Wp}var _1;function M7(){return _1||(_1=1,process.env.NODE_ENV==="production"?gu.exports=A7():gu.exports=_7()),gu.exports}var O7=M7(),R7=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},N7=({contentComponent:t})=>{const e=Db.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return y.jsx(y.Fragment,{children:Object.values(e)})};function I7(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:vi.default.createPortal(r.reactElement,r.element,n)},t.forEach(o=>o())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(o=>o())}}}var D7=class extends w.default.Component{constructor(t){var e;super(t),this.editorContentRef=w.default.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=I7(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:R7(e,this.editorContentRef),...n}),t?.contentComponent&&y.jsx(N7,{contentComponent:t.contentComponent})]})}},P7=j.forwardRef((t,e)=>{const n=w.default.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return w.default.createElement(D7,{key:n,innerRef:e,...t})}),EM=w.default.memo(P7),L7=typeof window<"u"?j.useLayoutEffect:j.useEffect,j7=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function SM(t){var e;const[n]=j.useState(()=>new j7(t.editor)),r=O7.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:C7);return L7(()=>n.watch(t.editor),[t.editor,n]),j.useDebugValue(r),r}var M1=process.env.NODE_ENV!=="production",Sg=typeof window>"u",$7=Sg||!!(typeof window<"u"&&window.next),F7=class kM{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0){if(Sg||$7){if(M1)throw new Error("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches.");return null}return this.createEditor()}if(this.options.current.immediatelyRender&&Sg&&M1)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 o,s;return(s=(o=this.options.current).onBeforeCreate)==null?void 0:s.call(o,...r)},onBlur:(...r)=>{var o,s;return(s=(o=this.options.current).onBlur)==null?void 0:s.call(o,...r)},onCreate:(...r)=>{var o,s;return(s=(o=this.options.current).onCreate)==null?void 0:s.call(o,...r)},onDestroy:(...r)=>{var o,s;return(s=(o=this.options.current).onDestroy)==null?void 0:s.call(o,...r)},onFocus:(...r)=>{var o,s;return(s=(o=this.options.current).onFocus)==null?void 0:s.call(o,...r)},onSelectionUpdate:(...r)=>{var o,s;return(s=(o=this.options.current).onSelectionUpdate)==null?void 0:s.call(o,...r)},onTransaction:(...r)=>{var o,s;return(s=(o=this.options.current).onTransaction)==null?void 0:s.call(o,...r)},onUpdate:(...r)=>{var o,s;return(s=(o=this.options.current).onUpdate)==null?void 0:s.call(o,...r)},onContentError:(...r)=>{var o,s;return(s=(o=this.options.current).onContentError)==null?void 0:s.call(o,...r)},onDrop:(...r)=>{var o,s;return(s=(o=this.options.current).onDrop)==null?void 0:s.call(o,...r)},onPaste:(...r)=>{var o,s;return(s=(o=this.options.current).onPaste)==null?void 0:s.call(o,...r)},onDelete:(...r)=>{var o,s;return(s=(o=this.options.current).onDelete)==null?void 0:s.call(o,...r)}};return new m3(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((o,s)=>{var i;return o===((i=n.extensions)==null?void 0:i[s])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?kM.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,o)=>r===e[o]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function U7(t={},e=[]){const n=j.useRef(t);n.current=t;const[r]=j.useState(()=>new F7(n)),o=Db.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return j.useDebugValue(o),j.useEffect(r.onRender(e)),SM({editor:o,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),o}var Eh=j.createContext({editor:null});Eh.Consumer;var Sh=()=>j.useContext(Eh),TM=j.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),CM=()=>j.useContext(TM);function B7({as:t="div",...e}){const{nodeViewContentRef:n,nodeViewContentChildren:r}=CM();return y.jsx(t,{...e,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...e.style},children:r})}var fi=w.default.forwardRef((t,e)=>{const{onDragStart:n}=CM(),r=t.as||"div";return y.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function O1(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function R1(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function z7(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function H7(t){if(O1(t)||R1(t))return!0;if(z7(t)){const e=t.type;if(e)return O1(e)||R1(e)}return!1}function V7(){try{if(j.version)return parseInt(j.version.split(".")[0],10)>=19}catch{}return!1}var Ub=class{constructor(t,{editor:e,props:n={},as:r="div",className:o=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),o&&this.element.classList.add(...o.split(" ")),this.editor.isInitialized?PS.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var t;if(this.destroyed)return;const e=this.component,n=this.props,r=this.editor,o=V7(),s=H7(e),i={...n};i.ref&&!(o||s)&&delete i.ref,!i.ref&&(o||s)&&(i.ref=a=>{this.ref=a}),this.reactElement=y.jsx(e,{...i}),(t=r?.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){this.destroyed||(this.props={...this.props,...t},this.render())}destroy(){var t;this.destroyed=!0;const e=this.editor;(t=e?.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}},AM=w.default.createContext({markViewContentRef:()=>{}}),W7=t=>{const{as:e="span",...n}=t,{markViewContentRef:r}=w.default.useContext(AM);return y.jsx(e,{...n,ref:r,"data-mark-view-content":""})},K7=class extends C3{constructor(t,e,n){super(t,e,n);const{as:r="span",attrs:o,className:s=""}=n||{},i={...e,updateAttributes:this.updateAttributes.bind(this)};this.contentDOMElement=document.createElement("span");const l={markViewContentRef:u=>{u&&!u.contains(this.contentDOMElement)&&u.appendChild(this.contentDOMElement)}},c=w.default.memo(u=>y.jsx(AM.Provider,{value:l,children:w.default.createElement(t,u)}));c.displayName="ReactMarkView",this.renderer=new Ub(c,{editor:e.editor,props:i,as:r,className:`mark-${e.mark.type.name} ${s}`.trim()}),o&&this.renderer.updateAttributes(o)}get dom(){return this.renderer.element}get contentDOM(){return this.contentDOMElement}};function G7(t,e={}){return n=>new K7(t,n,e)}var q7=class extends A3{constructor(t,e,n){if(super(t,e,n),this.selectionRafId=null,this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){const t=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(n,r,o){var s;return r==="storage"?(s=t.storage[e.name])!=null?s:{}:Reflect.get(n,r,o)}})}return this.cachedExtensionWithSyncedStorage}mount(){const t={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(l={})=>this.updateAttributes(l),deleteNode:()=>this.deleteNode(),ref:j.createRef()};if(!this.component.displayName){const l=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=l(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:l=>{l&&this.contentDOMElement&&l.firstChild!==this.contentDOMElement&&(l.hasAttribute("data-node-view-wrapper")&&l.removeAttribute("data-node-view-wrapper"),l.appendChild(this.contentDOMElement))}},o=this.component,s=j.memo(l=>y.jsx(TM.Provider,{value:r,children:j.createElement(o,l)}));s.displayName="ReactNodeView";let i=this.node.isInline?"span":"div";this.options.as&&(i=this.options.as);const{className:a=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Ub(s,{editor:this.editor,props:t,as:i,className:`node-${this.node.type.name} ${a}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const{from:t,to:e}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(t<=n&&e>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(t,e,n){const r=o=>{this.renderer.updateProps(o),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const o=this.node,s=this.decorations,i=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.options.update({oldNode:o,oldDecorations:s,newNode:t,newDecorations:e,oldInnerDecorations:i,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}return t===this.node&&this.decorations===e&&this.innerDecorations===n||(this.node=t,this.decorations=e,this.innerDecorations=n,r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=ca(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function Nc(t,e){return n=>n.editor.contentComponent?new q7(t,n,e):{}}var Bb=j.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});Bb.displayName="TiptapContext";var Y7=()=>j.useContext(Bb);function _M({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const o=j.useMemo(()=>({editor:r}),[r]),s=j.useMemo(()=>({editor:r}),[r]);return y.jsx(Eh.Provider,{value:s,children:y.jsx(Bb.Provider,{value:o,children:n})})}_M.displayName="Tiptap";function MM({...t}){const{editor:e}=Y7();return y.jsx(EM,{editor:e,...t})}MM.displayName="Tiptap.Content";Object.assign(_M,{Content:MM});const He=j.forwardRef(({id:t,icon:e,tooltip:n,active:r,children:o,className:s,onClick:i,...a},l)=>{const{editor:c}=Sh(),{trackFeature:u}=Cs(),{t:d}=kn(),f=h=>{i?.(h),t&&u(t),c&&requestAnimationFrame(c?.chain()?.focus)};return y.jsx(vM,{delayDuration:100,children:y.jsxs(wM,{children:[y.jsx($b,{asChild:!0,children:y.jsx(zt,{id:t,ref:l,variant:"ghost",size:"icon",className:oe("size-7 p-1.5 cursor-pointer",r&&"bg-accent text-violet-600 hover:text-violet-500",o?"size-auto":"",s),onClick:f,...a,children:o??(e&&y.jsx(e,{className:"size-full"}))})}),y.jsx(Fb,{children:d(n,n)??n})]})})});He.displayName="ToolbarButton";function J7(t){const e=X7(t),n=w.forwardRef((r,o)=>{const{children:s,...i}=r,a=w.Children.toArray(s),l=a.find(Z7);if(l){const c=l.props.children,u=a.map(d=>d===l?w.Children.count(c)>1?w.Children.only(null):w.isValidElement(c)?c.props.children:null:d);return y.jsx(e,{...i,ref:o,children:w.isValidElement(c)?w.cloneElement(c,void 0,u):null})}return y.jsx(e,{...i,ref:o,children:s})});return n.displayName=`${t}.Slot`,n}function X7(t){const e=w.forwardRef((n,r)=>{const{children:o,...s}=n;if(w.isValidElement(o)){const i=tq(o),a=eq(s,o.props);return o.type!==w.Fragment&&(a.ref=r?ao(r,i):i),w.cloneElement(o,a)}return w.Children.count(o)>1?w.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var Q7=Symbol("radix.slottable");function Z7(t){return w.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Q7}function eq(t,e){const n={...e};for(const r in e){const o=t[r],s=e[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{const l=s(...a);return o(...a),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...t,...n}}function tq(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var kg=["Enter"," "],nq=["ArrowDown","PageUp","Home"],OM=["ArrowUp","PageDown","End"],rq=[...nq,...OM],oq={ltr:[...kg,"ArrowRight"],rtl:[...kg,"ArrowLeft"]},sq={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Ic="Menu",[Xl,iq,aq]=Ay(Ic),[Ai,RM]=Pr(Ic,[aq,As,Ff]),kh=As(),NM=Ff(),[lq,_i]=Ai(Ic),[cq,Dc]=Ai(Ic),IM=t=>{const{__scopeMenu:e,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=t,a=kh(e),[l,c]=w.useState(null),u=w.useRef(!1),d=Ar(s),f=$f(o);return w.useEffect(()=>{const h=()=>{u.current=!0,document.addEventListener("pointerdown",p,{capture:!0,once:!0}),document.addEventListener("pointermove",p,{capture:!0,once:!0})},p=()=>u.current=!1;return document.addEventListener("keydown",h,{capture:!0}),()=>{document.removeEventListener("keydown",h,{capture:!0}),document.removeEventListener("pointerdown",p,{capture:!0}),document.removeEventListener("pointermove",p,{capture:!0})}},[]),y.jsx(dh,{...a,children:y.jsx(lq,{scope:e,open:n,onOpenChange:d,content:l,onContentChange:c,children:y.jsx(cq,{scope:e,onClose:w.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:i,children:r})})})};IM.displayName=Ic;var uq="MenuAnchor",zb=w.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,o=kh(n);return y.jsx(Mc,{...o,...r,ref:e})});zb.displayName=uq;var Hb="MenuPortal",[dq,DM]=Ai(Hb,{forceMount:void 0}),PM=t=>{const{__scopeMenu:e,forceMount:n,children:r,container:o}=t,s=_i(Hb,e);return y.jsx(dq,{scope:e,forceMount:n,children:y.jsx(Jn,{present:n||s.open,children:y.jsx(Ia,{asChild:!0,container:o,children:r})})})};PM.displayName=Hb;var lr="MenuContent",[fq,Vb]=Ai(lr),LM=w.forwardRef((t,e)=>{const n=DM(lr,t.__scopeMenu),{forceMount:r=n.forceMount,...o}=t,s=_i(lr,t.__scopeMenu),i=Dc(lr,t.__scopeMenu);return y.jsx(Xl.Provider,{scope:t.__scopeMenu,children:y.jsx(Jn,{present:r||s.open,children:y.jsx(Xl.Slot,{scope:t.__scopeMenu,children:i.modal?y.jsx(hq,{...o,ref:e}):y.jsx(pq,{...o,ref:e})})})})}),hq=w.forwardRef((t,e)=>{const n=_i(lr,t.__scopeMenu),r=w.useRef(null),o=Ze(e,r);return w.useEffect(()=>{const s=r.current;if(s)return ph(s)},[]),y.jsx(Wb,{...t,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:ae(t.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),pq=w.forwardRef((t,e)=>{const n=_i(lr,t.__scopeMenu);return y.jsx(Wb,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),mq=J7("MenuContent.ScrollLock"),Wb=w.forwardRef((t,e)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:h,disableOutsideScroll:p,...m}=t,g=_i(lr,n),b=Dc(lr,n),S=kh(n),k=NM(n),v=iq(n),[_,x]=w.useState(null),A=w.useRef(null),E=Ze(e,A,g.onContentChange),T=w.useRef(0),N=w.useRef(""),I=w.useRef(0),R=w.useRef(null),D=w.useRef("right"),O=w.useRef(0),P=p?Oc:w.Fragment,C=p?{as:mq,allowPinchZoom:!0}:void 0,M=L=>{const F=N.current+L,V=v().filter(Y=>!Y.disabled),W=document.activeElement,H=V.find(Y=>Y.ref.current===W)?.textValue,B=V.map(Y=>Y.textValue),$=Aq(B,F,H),K=V.find(Y=>Y.textValue===$)?.ref.current;(function Y(J){N.current=J,window.clearTimeout(T.current),J!==""&&(T.current=window.setTimeout(()=>Y(""),1e3))})(F),K&&setTimeout(()=>K.focus())};w.useEffect(()=>()=>window.clearTimeout(T.current),[]),ih();const U=w.useCallback(L=>D.current===R.current?.side&&Mq(L,R.current?.area),[]);return y.jsx(fq,{scope:n,searchRef:N,onItemEnter:w.useCallback(L=>{U(L)&&L.preventDefault()},[U]),onItemLeave:w.useCallback(L=>{U(L)||(A.current?.focus(),x(null))},[U]),onTriggerLeave:w.useCallback(L=>{U(L)&&L.preventDefault()},[U]),pointerGraceTimerRef:I,onPointerGraceIntentChange:w.useCallback(L=>{R.current=L},[]),children:y.jsx(P,{...C,children:y.jsx(Ac,{asChild:!0,trapped:o,onMountAutoFocus:ae(s,L=>{L.preventDefault(),A.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:y.jsx(Oa,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:h,children:y.jsx(vk,{asChild:!0,...k,dir:b.dir,orientation:"vertical",loop:r,currentTabStopId:_,onCurrentTabStopIdChange:x,onEntryFocus:ae(l,L=>{b.isUsingKeyboardRef.current||L.preventDefault()}),preventScrollOnEntryFocus:!0,children:y.jsx(fh,{role:"menu","aria-orientation":"vertical","data-state":QM(g.open),"data-radix-menu-content":"",dir:b.dir,...S,...m,ref:E,style:{outline:"none",...m.style},onKeyDown:ae(m.onKeyDown,L=>{const V=L.target.closest("[data-radix-menu-content]")===L.currentTarget,W=L.ctrlKey||L.altKey||L.metaKey,H=L.key.length===1;V&&(L.key==="Tab"&&L.preventDefault(),!W&&H&&M(L.key));const B=A.current;if(L.target!==B||!rq.includes(L.key))return;L.preventDefault();const K=v().filter(Y=>!Y.disabled).map(Y=>Y.ref.current);OM.includes(L.key)&&K.reverse(),Tq(K)}),onBlur:ae(t.onBlur,L=>{L.currentTarget.contains(L.target)||(window.clearTimeout(T.current),N.current="")}),onPointerMove:ae(t.onPointerMove,Ql(L=>{const F=L.target,V=O.current!==L.clientX;if(L.currentTarget.contains(F)&&V){const W=L.clientX>O.current?"right":"left";D.current=W,O.current=L.clientX}}))})})})})})})});LM.displayName=lr;var gq="MenuGroup",Kb=w.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return y.jsx(Oe.div,{role:"group",...r,ref:e})});Kb.displayName=gq;var yq="MenuLabel",jM=w.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return y.jsx(Oe.div,{...r,ref:e})});jM.displayName=yq;var Rd="MenuItem",N1="menu.itemSelect",Th=w.forwardRef((t,e)=>{const{disabled:n=!1,onSelect:r,...o}=t,s=w.useRef(null),i=Dc(Rd,t.__scopeMenu),a=Vb(Rd,t.__scopeMenu),l=Ze(e,s),c=w.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(N1,{bubbles:!0,cancelable:!0});d.addEventListener(N1,h=>r?.(h),{once:!0}),hk(d,f),f.defaultPrevented?c.current=!1:i.onClose()}};return y.jsx($M,{...o,ref:l,disabled:n,onClick:ae(t.onClick,u),onPointerDown:d=>{t.onPointerDown?.(d),c.current=!0},onPointerUp:ae(t.onPointerUp,d=>{c.current||d.currentTarget?.click()}),onKeyDown:ae(t.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||kg.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});Th.displayName=Rd;var $M=w.forwardRef((t,e)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=t,i=Vb(Rd,n),a=NM(n),l=w.useRef(null),c=Ze(e,l),[u,d]=w.useState(!1),[f,h]=w.useState("");return w.useEffect(()=>{const p=l.current;p&&h((p.textContent??"").trim())},[s.children]),y.jsx(Xl.ItemSlot,{scope:n,disabled:r,textValue:o??f,children:y.jsx(wk,{asChild:!0,...a,focusable:!r,children:y.jsx(Oe.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:ae(t.onPointerMove,Ql(p=>{r?i.onItemLeave(p):(i.onItemEnter(p),p.defaultPrevented||p.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ae(t.onPointerLeave,Ql(p=>i.onItemLeave(p))),onFocus:ae(t.onFocus,()=>d(!0)),onBlur:ae(t.onBlur,()=>d(!1))})})})}),bq="MenuCheckboxItem",FM=w.forwardRef((t,e)=>{const{checked:n=!1,onCheckedChange:r,...o}=t;return y.jsx(VM,{scope:t.__scopeMenu,checked:n,children:y.jsx(Th,{role:"menuitemcheckbox","aria-checked":Nd(n)?"mixed":n,...o,ref:e,"data-state":qb(n),onSelect:ae(o.onSelect,()=>r?.(Nd(n)?!0:!n),{checkForDefaultPrevented:!1})})})});FM.displayName=bq;var UM="MenuRadioGroup",[vq,wq]=Ai(UM,{value:void 0,onValueChange:()=>{}}),BM=w.forwardRef((t,e)=>{const{value:n,onValueChange:r,...o}=t,s=Ar(r);return y.jsx(vq,{scope:t.__scopeMenu,value:n,onValueChange:s,children:y.jsx(Kb,{...o,ref:e})})});BM.displayName=UM;var zM="MenuRadioItem",HM=w.forwardRef((t,e)=>{const{value:n,...r}=t,o=wq(zM,t.__scopeMenu),s=n===o.value;return y.jsx(VM,{scope:t.__scopeMenu,checked:s,children:y.jsx(Th,{role:"menuitemradio","aria-checked":s,...r,ref:e,"data-state":qb(s),onSelect:ae(r.onSelect,()=>o.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});HM.displayName=zM;var Gb="MenuItemIndicator",[VM,xq]=Ai(Gb,{checked:!1}),WM=w.forwardRef((t,e)=>{const{__scopeMenu:n,forceMount:r,...o}=t,s=xq(Gb,n);return y.jsx(Jn,{present:r||Nd(s.checked)||s.checked===!0,children:y.jsx(Oe.span,{...o,ref:e,"data-state":qb(s.checked)})})});WM.displayName=Gb;var Eq="MenuSeparator",KM=w.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return y.jsx(Oe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:e})});KM.displayName=Eq;var Sq="MenuArrow",GM=w.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,o=kh(n);return y.jsx(hh,{...o,...r,ref:e})});GM.displayName=Sq;var kq="MenuSub",[Fle,qM]=Ai(kq),ll="MenuSubTrigger",YM=w.forwardRef((t,e)=>{const n=_i(ll,t.__scopeMenu),r=Dc(ll,t.__scopeMenu),o=qM(ll,t.__scopeMenu),s=Vb(ll,t.__scopeMenu),i=w.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:t.__scopeMenu},u=w.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return w.useEffect(()=>u,[u]),w.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),y.jsx(zb,{asChild:!0,...c,children:y.jsx($M,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":QM(n.open),...t,ref:ao(e,o.onTriggerChange),onClick:d=>{t.onClick?.(d),!(t.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:ae(t.onPointerMove,Ql(d=>{s.onItemEnter(d),!d.defaultPrevented&&!t.disabled&&!n.open&&!i.current&&(s.onPointerGraceIntentChange(null),i.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:ae(t.onPointerLeave,Ql(d=>{u();const f=n.content?.getBoundingClientRect();if(f){const h=n.content?.dataset.side,p=h==="right",m=p?-5:5,g=f[p?"left":"right"],b=f[p?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+m,y:d.clientY},{x:g,y:f.top},{x:b,y:f.top},{x:b,y:f.bottom},{x:g,y:f.bottom}],side:h}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:ae(t.onKeyDown,d=>{const f=s.searchRef.current!=="";t.disabled||f&&d.key===" "||oq[r.dir].includes(d.key)&&(n.onOpenChange(!0),n.content?.focus(),d.preventDefault())})})})});YM.displayName=ll;var JM="MenuSubContent",XM=w.forwardRef((t,e)=>{const n=DM(lr,t.__scopeMenu),{forceMount:r=n.forceMount,...o}=t,s=_i(lr,t.__scopeMenu),i=Dc(lr,t.__scopeMenu),a=qM(JM,t.__scopeMenu),l=w.useRef(null),c=Ze(e,l);return y.jsx(Xl.Provider,{scope:t.__scopeMenu,children:y.jsx(Jn,{present:r||s.open,children:y.jsx(Xl.Slot,{scope:t.__scopeMenu,children:y.jsx(Wb,{id:a.contentId,"aria-labelledby":a.triggerId,...o,ref:c,align:"start",side:i.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{i.isUsingKeyboardRef.current&&l.current?.focus(),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:ae(t.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:ae(t.onEscapeKeyDown,u=>{i.onClose(),u.preventDefault()}),onKeyDown:ae(t.onKeyDown,u=>{const d=u.currentTarget.contains(u.target),f=sq[i.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),a.trigger?.focus(),u.preventDefault())})})})})})});XM.displayName=JM;function QM(t){return t?"open":"closed"}function Nd(t){return t==="indeterminate"}function qb(t){return Nd(t)?"indeterminate":t?"checked":"unchecked"}function Tq(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}function Cq(t,e){return t.map((n,r)=>t[(e+r)%t.length])}function Aq(t,e,n){const o=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,s=n?t.indexOf(n):-1;let i=Cq(t,Math.max(s,0));o.length===1&&(i=i.filter(c=>c!==n));const l=i.find(c=>c.toLowerCase().startsWith(o.toLowerCase()));return l!==n?l:void 0}function _q(t,e){const{x:n,y:r}=t;let o=!1;for(let s=0,i=e.length-1;s<e.length;i=s++){const a=e[s],l=e[i],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(o=!o)}return o}function Mq(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return _q(n,e)}function Ql(t){return e=>e.pointerType==="mouse"?t(e):void 0}var Oq=IM,Rq=zb,Nq=PM,Iq=LM,Dq=Kb,Pq=jM,Lq=Th,jq=FM,$q=BM,Fq=HM,Uq=WM,Bq=KM,zq=GM,Hq=YM,Vq=XM,Ch="DropdownMenu",[Wq]=Pr(Ch,[RM]),Tn=RM(),[Kq,ZM]=Wq(Ch),eO=t=>{const{__scopeDropdownMenu:e,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=t,l=Tn(e),c=w.useRef(null),[u,d]=Ro({prop:o,defaultProp:s??!1,onChange:i,caller:Ch});return y.jsx(Kq,{scope:e,triggerId:sr(),triggerRef:c,contentId:sr(),open:u,onOpenChange:d,onOpenToggle:w.useCallback(()=>d(f=>!f),[d]),modal:a,children:y.jsx(Oq,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};eO.displayName=Ch;var tO="DropdownMenuTrigger",nO=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=t,s=ZM(tO,n),i=Tn(n);return y.jsx(Rq,{asChild:!0,...i,children:y.jsx(Oe.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...o,ref:ao(e,s.triggerRef),onPointerDown:ae(t.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:ae(t.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});nO.displayName=tO;var Gq="DropdownMenuPortal",rO=t=>{const{__scopeDropdownMenu:e,...n}=t,r=Tn(e);return y.jsx(Nq,{...r,...n})};rO.displayName=Gq;var oO="DropdownMenuContent",sO=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=ZM(oO,n),s=Tn(n),i=w.useRef(!1);return y.jsx(Iq,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:e,onCloseAutoFocus:ae(t.onCloseAutoFocus,a=>{i.current||o.triggerRef.current?.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:ae(t.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!o.modal||u)&&(i.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});sO.displayName=oO;var qq="DropdownMenuGroup",iO=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Tn(n);return y.jsx(Dq,{...o,...r,ref:e})});iO.displayName=qq;var Yq="DropdownMenuLabel",aO=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Tn(n);return y.jsx(Pq,{...o,...r,ref:e})});aO.displayName=Yq;var Jq="DropdownMenuItem",lO=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Tn(n);return y.jsx(Lq,{...o,...r,ref:e})});lO.displayName=Jq;var Xq="DropdownMenuCheckboxItem",cO=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Tn(n);return y.jsx(jq,{...o,...r,ref:e})});cO.displayName=Xq;var Qq="DropdownMenuRadioGroup",uO=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Tn(n);return y.jsx($q,{...o,...r,ref:e})});uO.displayName=Qq;var Zq="DropdownMenuRadioItem",dO=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Tn(n);return y.jsx(Fq,{...o,...r,ref:e})});dO.displayName=Zq;var eY="DropdownMenuItemIndicator",fO=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Tn(n);return y.jsx(Uq,{...o,...r,ref:e})});fO.displayName=eY;var tY="DropdownMenuSeparator",hO=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Tn(n);return y.jsx(Bq,{...o,...r,ref:e})});hO.displayName=tY;var nY="DropdownMenuArrow",rY=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Tn(n);return y.jsx(zq,{...o,...r,ref:e})});rY.displayName=nY;var oY="DropdownMenuSubTrigger",pO=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Tn(n);return y.jsx(Hq,{...o,...r,ref:e})});pO.displayName=oY;var sY="DropdownMenuSubContent",mO=w.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=Tn(n);return y.jsx(Vq,{...o,...r,ref:e,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});mO.displayName=sY;var iY=eO,aY=nO,lY=rO,cY=sO,uY=iO,dY=aO,fY=lO,hY=cO,pY=uO,mY=dO,gO=fO,gY=hO,yY=pO,bY=mO;function I1(t){return y.jsx(iY,{"data-slot":"dropdown-menu",...t})}const D1=j.forwardRef((t,e)=>y.jsx(aY,{ref:e,"data-slot":"dropdown-menu-trigger",...t})),P1=j.forwardRef(({className:t,sideOffset:e,...n},r)=>y.jsx(lY,{children:y.jsx("div",{"data-theme":"select-post-builder",children:y.jsx(cY,{ref:r,"data-slot":"dropdown-menu-content",sideOffset:e??4,className:oe("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",t),...n})})}));j.forwardRef((t,e)=>y.jsx(uY,{ref:e,"data-slot":"dropdown-menu-group",...t}));const mo=j.forwardRef(({className:t,inset:e,variant:n="default",...r},o)=>y.jsx(fY,{ref:o,"data-slot":"dropdown-menu-item","data-inset":e,"data-variant":n,className:oe("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r}));j.forwardRef(({className:t,children:e,checked:n,...r},o)=>y.jsxs(hY,{ref:o,"data-slot":"dropdown-menu-checkbox-item",className:oe("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),checked:n,...r,children:[y.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:y.jsx(gO,{children:y.jsx(G_,{className:"size-4"})})}),e]}));j.forwardRef((t,e)=>y.jsx(pY,{ref:e,"data-slot":"dropdown-menu-radio-group",...t}));j.forwardRef(({className:t,children:e,...n},r)=>y.jsxs(mY,{ref:r,"data-slot":"dropdown-menu-radio-item",className:oe("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...n,children:[y.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:y.jsx(gO,{children:y.jsx(qK,{className:"size-2 fill-current"})})}),e]}));j.forwardRef(({className:t,inset:e,...n},r)=>y.jsx(dY,{ref:r,"data-slot":"dropdown-menu-label","data-inset":e,className:oe("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",t),...n}));j.forwardRef(({className:t,...e},n)=>y.jsx(gY,{ref:n,"data-slot":"dropdown-menu-separator",className:oe("bg-border -mx-1 my-1 h-px",t),...e}));j.forwardRef(({className:t,...e},n)=>y.jsx("span",{ref:n,"data-slot":"dropdown-menu-shortcut",className:oe("text-muted-foreground ml-auto text-xs tracking-widest",t),...e}));j.forwardRef(({className:t,inset:e,children:n,...r},o)=>y.jsxs(yY,{ref:o,"data-slot":"dropdown-menu-sub-trigger","data-inset":e,className:oe("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...r,children:[n,y.jsx(VK,{className:"ml-auto size-4"})]}));j.forwardRef(({className:t,...e},n)=>y.jsx(bY,{ref:n,"data-slot":"dropdown-menu-sub-content",className:oe("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg",t),...e}));var vY=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],wY=vY.reduce((t,e)=>{const n=Pa(`Primitive.${e}`),r=w.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),xY="Label",yO=w.forwardRef((t,e)=>y.jsx(wY.label,{...t,ref:e,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(t.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));yO.displayName=xY;var EY=yO;function Tg({className:t,...e}){return y.jsx(EY,{"data-slot":"label",className:oe("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",t),...e})}const ms=j.forwardRef(({className:t,...e},n)=>y.jsx(m9,{role:"status","aria-label":"Loading",className:oe("h-4 w-4 animate-spin",t),ref:n,...e}));ms.displayName="Spinner";var Ah="Switch",[SY]=Pr(Ah),[kY,TY]=SY(Ah),bO=w.forwardRef((t,e)=>{const{__scopeSwitch:n,name:r,checked:o,defaultChecked:s,required:i,disabled:a,value:l="on",onCheckedChange:c,form:u,...d}=t,[f,h]=w.useState(null),p=Ze(e,k=>h(k)),m=w.useRef(!1),g=f?u||!!f.closest("form"):!0,[b,S]=Ro({prop:o,defaultProp:s??!1,onChange:c,caller:Ah});return y.jsxs(kY,{scope:n,checked:b,disabled:a,children:[y.jsx(Oe.button,{type:"button",role:"switch","aria-checked":b,"aria-required":i,"data-state":EO(b),"data-disabled":a?"":void 0,disabled:a,value:l,...d,ref:p,onClick:ae(t.onClick,k=>{S(v=>!v),g&&(m.current=k.isPropagationStopped(),m.current||k.stopPropagation())})}),g&&y.jsx(xO,{control:f,bubbles:!m.current,name:r,value:l,checked:b,required:i,disabled:a,form:u,style:{transform:"translateX(-100%)"}})]})});bO.displayName=Ah;var vO="SwitchThumb",wO=w.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,o=TY(vO,n);return y.jsx(Oe.span,{"data-state":EO(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:e})});wO.displayName=vO;var CY="SwitchBubbleInput",xO=w.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...o},s)=>{const i=w.useRef(null),a=Ze(i,s),l=c_(n),c=ZA(e);return w.useEffect(()=>{const u=i.current;if(!u)return;const d=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(d,"checked").set;if(l!==n&&h){const p=new Event("click",{bubbles:r});h.call(u,n),u.dispatchEvent(p)}},[l,n,r]),y.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...o,tabIndex:-1,ref:a,style:{...o.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});xO.displayName=CY;function EO(t){return t?"checked":"unchecked"}var AY=bO,_Y=wO;function L1({className:t,...e}){return y.jsx(AY,{"data-slot":"switch",className:oe("peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:ring-ring/50 dark:data-[state=unchecked]:bg-input/80 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",t),...e,children:y.jsx(_Y,{"data-slot":"switch-thumb",className:oe("bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0")})})}const MY=t=>SM({editor:t,selector:e=>{if(!e?.editor)return null;const n=e.editor,r=n.isActive("codeBlock")??!1,o=n.isActive("bulletList")??!1,s=n.isActive("orderedList")??!1,i=o||s;return{isEmpty:n.isEmpty??!1,isFocused:n.isFocused??!1,isBold:n.isActive("bold")??!1,canBold:lt(n,"toggleBold"),isItalic:n.isActive("italic")??!1,canItalic:lt(n,"toggleItalic"),isStrike:n.isActive("strike")??!1,canStrike:lt(n,"toggleStrike"),isCode:n.isActive("code")??!1,canCode:lt(n,"toggleCode"),isUnderline:n.isActive("underline")??!1,canUnderline:lt(n,"toggleUnderline"),isLink:n.isActive("customLink")??!1,canLink:lt(n,"toggleLink",{href:""}),canUnlink:lt(n,"unsetLink"),isParagraph:n.isActive("paragraph")??!1,canParagraph:lt(n,"setParagraph"),isHeading1:n.isActive("heading",{level:1})??!1,canHeading1:lt(n,"setHeading",{level:1}),isHeading2:n.isActive("heading",{level:2})??!1,canHeading2:lt(n,"setHeading",{level:2}),isHeading3:n.isActive("heading",{level:3})??!1,canHeading3:lt(n,"setHeading",{level:3}),isBulletList:o,canBulletList:lt(n,"toggleBulletList")||i,isOrderedList:s,canOrderedList:lt(n,"toggleOrderedList")||i,isBlockquote:n.isActive("blockquote")??!1,canBlockquote:lt(n,"toggleBlockquote"),isCodeBlock:r,canCodeBlock:lt(n,"toggleCodeBlock"),isAlignLeft:n.isActive({textAlign:"left"})??!1,canAlignLeft:lt(n,"setTextAlign","left")&&!r,isAlignCenter:n.isActive({textAlign:"center"})??!1,canAlignCenter:lt(n,"setTextAlign","center")&&!r,isAlignRight:n.isActive({textAlign:"right"})??!1,canAlignRight:lt(n,"setTextAlign","right")&&!r,isAlignJustify:n.isActive({textAlign:"justify"})??!1,canAlignJustify:lt(n,"setTextAlign","justify")&&!r,canUnsetAlign:lt(n,"unsetTextAlign"),canInsertImage:lt(n,"insertMedia",{type:ue.Image,src:""}),canInsertVideo:lt(n,"insertMedia",{type:ue.Video,src:""}),canInsertAudio:lt(n,"insertMedia",{type:ue.Audio,src:""}),isPoll:n?.isActive("poll")??!1,canPoll:lt(n,"insertPoll",{choices:[]}),canUndo:lt(n,"undo"),canRedo:lt(n,"redo"),canClearMarks:lt(n,"unsetAllMarks"),canClearNodes:lt(n,"clearNodes")}}}),lt=(t,e,n)=>{if(!t)return!1;try{const o=t.can().chain()[e];if(typeof o!="function")return!1;const s=o,i=n!==void 0?s(n):s();return typeof i?.run=="function"?i.run():!1}catch{return!1}},j1=t=>{const{doc:e}=t.state,n=t.schema.nodes.mention;if(!n)return!1;let r=!1;return e.descendants(o=>o.type===n&&o.attrs.mentionSuggestionChar==="#"?(r=!0,!1):!r),r},OY=(t,e,n={})=>{const{debounceMs:r=0,checkOnTransaction:o=!0}=n;let s=j1(t),i=null;e(s);const a=()=>{const d=j1(t);d!==s&&(s=d,e(d))},l=()=>{r>0?(i&&clearTimeout(i),i=setTimeout(a,r)):a()},c=o?({transaction:d})=>{d.docChanged&&l()}:null,u=o?null:l;return c?t.on("transaction",c):u&&t.on("update",u),()=>{i&&(clearTimeout(i),i=null),c?t.off("transaction",c):u&&t.off("update",u)}},RY=(t,e)=>{const[n,r]=j.useState(!1),o=j.useMemo(()=>({debounceMs:e?.debounceMs,checkOnTransaction:e?.checkOnTransaction??!0}),[e?.debounceMs,e?.checkOnTransaction]);return j.useEffect(()=>{if(!t){r(!1);return}return OY(t,i=>{r(i)},o)},[t,o]),{showCrossMentionIndicator:n}},Cg=t=>{let e=!1;return t.state.doc.descendants(n=>{n.attrs.uploading===!0&&(e=!0)}),e},NY=t=>{let e=!1;return t.state.doc.descendants(n=>{n.attrs.deferred===!0&&(e=!0)}),e},IY=t=>{const[e,n]=j.useState(!1);return j.useEffect(()=>{if(!t){n(!1);return}const r=()=>n(Cg(t));return t.on("update",r),r(),()=>{t.off("update",r)}},[t]),e},SO=(t,e,n)=>t.schema.text(e,n),kO=(t,e,n,r)=>t?.schema?.nodes[e]?.create(n,r),DY=(t,e,n,r)=>kO(t,"customLink",{href:e},SO(t,n||e,r)),PY=(t,e,n)=>kO(t,"paragraph",n,e),LY=t=>{const{from:e,to:n}=t.selection;return{from:e,to:n}},TO=t=>{const{from:e,to:n}=LY(t);return t.doc.textBetween(e,n)},jY=t=>!t.selection.empty&&TO(t).length>0,$Y=t=>t.type.name,CO=(t,e)=>$Y(t)===e,FY=t=>CO(t,"text"),UY=t=>CO(t,"paragraph"),AO=t=>t.text||"",_O=t=>t.content&&t.content.size>0,BY=t=>t.content,zY=t=>t.marks,HY=t=>t.state,MO=t=>X.from(t),OO=(t,e)=>{t.forEach(e)},VY=(t,e=" ")=>t.textBetween(0,t.size,e),WY=(t,e)=>{const{from:n,to:r,empty:o}=t.selection,s=t.schema.marks[e];if(!s)return null;if(o)return(t.storedMarks??t.selection.$from.marks()).find(c=>c.type===s)?.attrs??null;let i=null;return t.doc.nodesBetween(n,r,a=>{const l=a.marks.find(c=>c.type===s);return l?(i=l.attrs,!1):!0}),i},RO=(t,e=100)=>{if(!t)return"";const{selection:n}=t.state;if(!n.empty){const{$from:s,$to:i}=n,l=t.state.doc.textBetween(s.pos,i.pos).trim();if(l)return l.substring(0,e)}const r=t.getText();return r?r.trim().substring(0,e):""};function KY({maxDuration:t=60}={}){const[e,n]=j.useState(!1),[r,o]=j.useState(0),[s,i]=j.useState(0),a=j.useRef(null),l=j.useRef(null),c=j.useRef([]),u=j.useRef(null),d=j.useRef(0),f=j.useRef(null),h=j.useRef(!1),p=j.useRef(null),m=j.useRef(null),g=j.useRef(null),b=j.useRef(null),S=j.useCallback(()=>{u.current&&(clearInterval(u.current),u.current=null),p.current&&(clearTimeout(p.current),p.current=null),b.current&&(cancelAnimationFrame(b.current),b.current=null),g.current&&(g.current.close(),g.current=null),m.current=null,l.current&&(l.current.getTracks().forEach(x=>x.stop()),l.current=null),a.current=null,c.current=[],o(0),i(0),n(!1)},[]),k=j.useCallback(()=>new Promise((x,A)=>{const E=a.current;if(!E||E.state!=="recording"){A(new Error("Not recording"));return}f.current=x,E.stop()}),[]),v=j.useCallback(async()=>{if(a.current)return;const x=await navigator.mediaDevices.getUserMedia({audio:!0});l.current=x;const A=new AudioContext;g.current=A;const E=A.createMediaStreamSource(x),T=A.createAnalyser();T.fftSize=256,E.connect(T),m.current=T;const N=new Uint8Array(T.frequencyBinCount),I=()=>{if(!m.current)return;m.current.getByteTimeDomainData(N);let D=0;for(let O=0;O<N.length;O++){const P=(N[O]-128)/128;D+=P*P}i(Math.sqrt(D/N.length)),b.current=requestAnimationFrame(I)};b.current=requestAnimationFrame(I);const R=new MediaRecorder(x);a.current=R,c.current=[],h.current=!1,R.ondataavailable=D=>{D.data.size>0&&c.current.push(D.data)},R.onstop=()=>{if(h.current){S();return}const D=new Blob(c.current,{type:R.mimeType}),O=Math.round((Date.now()-d.current)/1e3);f.current&&(f.current({blob:D,duration:O}),f.current=null),S()},R.start(250),d.current=Date.now(),n(!0),u.current=setInterval(()=>{o(Math.round((Date.now()-d.current)/1e3))},1e3),p.current=setTimeout(()=>{a.current?.state==="recording"&&k()},t*1e3)},[t,S,k]),_=j.useCallback(()=>{h.current=!0;const x=a.current;x&&x.state==="recording"?x.stop():S()},[S]);return j.useEffect(()=>()=>{h.current=!0;const x=a.current;x&&x.state==="recording"&&x.stop(),S()},[S]),{isRecording:e,duration:r,volume:s,startRecording:v,stopRecording:k,cancelRecording:_}}function GY(t,e){return e.forEach((function(n){n&&typeof n!="string"&&!Array.isArray(n)&&Object.keys(n).forEach((function(r){if(r!=="default"&&!(r in t)){var o=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:function(){return n[r]}})}}))})),Object.freeze(t)}function NO(t,e){return new Promise((function(n,r){let o;return qY(t).then((function(s){try{return o=s,n(new Blob([e.slice(0,2),o,e.slice(2)],{type:"image/jpeg"}))}catch(i){return r(i)}}),r)}))}const qY=t=>new Promise(((e,n)=>{const r=new FileReader;r.addEventListener("load",(({target:{result:o}})=>{const s=new DataView(o);let i=0;if(s.getUint16(i)!==65496)return n("not a valid JPEG");for(i+=2;;){const a=s.getUint16(i);if(a===65498)break;const l=s.getUint16(i+2);if(a===65505&&s.getUint32(i+4)===1165519206){const c=i+10;let u;switch(s.getUint16(c)){case 18761:u=!0;break;case 19789:u=!1;break;default:return n("TIFF header contains invalid endian")}if(s.getUint16(c+2,u)!==42)return n("TIFF header contains invalid version");const d=s.getUint32(c+4,u),f=c+d+2+12*s.getUint16(c+d,u);for(let h=c+d+2;h<f;h+=12)if(s.getUint16(h,u)==274){if(s.getUint16(h+2,u)!==3)return n("Orientation data type is invalid");if(s.getUint32(h+4,u)!==1)return n("Orientation data count is invalid");s.setUint16(h+8,1,u);break}return e(o.slice(i,i+2+l))}i+=2+l}return e(new Blob)})),r.readAsArrayBuffer(t)}));var Id={},YY={get exports(){return Id},set exports(t){Id=t}};(function(t){var e,n,r={};YY.exports=r,r.parse=function(o,s){for(var i=r.bin.readUshort,a=r.bin.readUint,l=0,c={},u=new Uint8Array(o),d=u.length-4;a(u,d)!=101010256;)d--;l=d,l+=4;var f=i(u,l+=4);i(u,l+=2);var h=a(u,l+=2),p=a(u,l+=4);l+=4,l=p;for(var m=0;m<f;m++){a(u,l),l+=4,l+=4,l+=4,a(u,l+=4),h=a(u,l+=4);var g=a(u,l+=4),b=i(u,l+=4),S=i(u,l+2),k=i(u,l+4);l+=6;var v=a(u,l+=8);l+=4,l+=b+S+k,r._readLocal(u,v,c,h,g,s)}return c},r._readLocal=function(o,s,i,a,l,c){var u=r.bin.readUshort,d=r.bin.readUint;d(o,s),u(o,s+=4),u(o,s+=2);var f=u(o,s+=2);d(o,s+=2),d(o,s+=4),s+=4;var h=u(o,s+=8),p=u(o,s+=2);s+=2;var m=r.bin.readUTF8(o,s,h);if(s+=h,s+=p,c)i[m]={size:l,csize:a};else{var g=new Uint8Array(o.buffer,s);if(f==0)i[m]=new Uint8Array(g.buffer.slice(s,s+a));else{if(f!=8)throw"unknown compression method: "+f;var b=new Uint8Array(l);r.inflateRaw(g,b),i[m]=b}}},r.inflateRaw=function(o,s){return r.F.inflate(o,s)},r.inflate=function(o,s){return o[0],o[1],r.inflateRaw(new Uint8Array(o.buffer,o.byteOffset+2,o.length-6),s)},r.deflate=function(o,s){s==null&&(s={level:6});var i=0,a=new Uint8Array(50+Math.floor(1.1*o.length));a[i]=120,a[i+1]=156,i+=2,i=r.F.deflateRaw(o,a,i,s.level);var l=r.adler(o,0,o.length);return a[i+0]=l>>>24&255,a[i+1]=l>>>16&255,a[i+2]=l>>>8&255,a[i+3]=l>>>0&255,new Uint8Array(a.buffer,0,i+4)},r.deflateRaw=function(o,s){s==null&&(s={level:6});var i=new Uint8Array(50+Math.floor(1.1*o.length)),a=r.F.deflateRaw(o,i,a,s.level);return new Uint8Array(i.buffer,0,a)},r.encode=function(o,s){s==null&&(s=!1);var i=0,a=r.bin.writeUint,l=r.bin.writeUshort,c={};for(var u in o){var d=!r._noNeed(u)&&!s,f=o[u],h=r.crc.crc(f,0,f.length);c[u]={cpr:d,usize:f.length,crc:h,file:d?r.deflateRaw(f):f}}for(var u in c)i+=c[u].file.length+30+46+2*r.bin.sizeUTF8(u);i+=22;var p=new Uint8Array(i),m=0,g=[];for(var u in c){var b=c[u];g.push(m),m=r._writeHeader(p,m,u,b,0)}var S=0,k=m;for(var u in c)b=c[u],g.push(m),m=r._writeHeader(p,m,u,b,1,g[S++]);var v=m-k;return a(p,m,101010256),m+=4,l(p,m+=4,S),l(p,m+=2,S),a(p,m+=2,v),a(p,m+=4,k),m+=4,m+=2,p.buffer},r._noNeed=function(o){var s=o.split(".").pop().toLowerCase();return"png,jpg,jpeg,zip".indexOf(s)!=-1},r._writeHeader=function(o,s,i,a,l,c){var u=r.bin.writeUint,d=r.bin.writeUshort,f=a.file;return u(o,s,l==0?67324752:33639248),s+=4,l==1&&(s+=2),d(o,s,20),d(o,s+=2,0),d(o,s+=2,a.cpr?8:0),u(o,s+=2,0),u(o,s+=4,a.crc),u(o,s+=4,f.length),u(o,s+=4,a.usize),d(o,s+=4,r.bin.sizeUTF8(i)),d(o,s+=2,0),s+=2,l==1&&(s+=2,s+=2,u(o,s+=6,c),s+=4),s+=r.bin.writeUTF8(o,s,i),l==0&&(o.set(f,s),s+=f.length),s},r.crc={table:(function(){for(var o=new Uint32Array(256),s=0;s<256;s++){for(var i=s,a=0;a<8;a++)1&i?i=3988292384^i>>>1:i>>>=1;o[s]=i}return o})(),update:function(o,s,i,a){for(var l=0;l<a;l++)o=r.crc.table[255&(o^s[i+l])]^o>>>8;return o},crc:function(o,s,i){return 4294967295^r.crc.update(4294967295,o,s,i)}},r.adler=function(o,s,i){for(var a=1,l=0,c=s,u=s+i;c<u;){for(var d=Math.min(c+5552,u);c<d;)l+=a+=o[c++];a%=65521,l%=65521}return l<<16|a},r.bin={readUshort:function(o,s){return o[s]|o[s+1]<<8},writeUshort:function(o,s,i){o[s]=255&i,o[s+1]=i>>8&255},readUint:function(o,s){return 16777216*o[s+3]+(o[s+2]<<16|o[s+1]<<8|o[s])},writeUint:function(o,s,i){o[s]=255&i,o[s+1]=i>>8&255,o[s+2]=i>>16&255,o[s+3]=i>>24&255},readASCII:function(o,s,i){for(var a="",l=0;l<i;l++)a+=String.fromCharCode(o[s+l]);return a},writeASCII:function(o,s,i){for(var a=0;a<i.length;a++)o[s+a]=i.charCodeAt(a)},pad:function(o){return o.length<2?"0"+o:o},readUTF8:function(o,s,i){for(var a,l="",c=0;c<i;c++)l+="%"+r.bin.pad(o[s+c].toString(16));try{a=decodeURIComponent(l)}catch{return r.bin.readASCII(o,s,i)}return a},writeUTF8:function(o,s,i){for(var a=i.length,l=0,c=0;c<a;c++){var u=i.charCodeAt(c);if((4294967168&u)==0)o[s+l]=u,l++;else if((4294965248&u)==0)o[s+l]=192|u>>6,o[s+l+1]=128|u>>0&63,l+=2;else if((4294901760&u)==0)o[s+l]=224|u>>12,o[s+l+1]=128|u>>6&63,o[s+l+2]=128|u>>0&63,l+=3;else{if((4292870144&u)!=0)throw"e";o[s+l]=240|u>>18,o[s+l+1]=128|u>>12&63,o[s+l+2]=128|u>>6&63,o[s+l+3]=128|u>>0&63,l+=4}}return l},sizeUTF8:function(o){for(var s=o.length,i=0,a=0;a<s;a++){var l=o.charCodeAt(a);if((4294967168&l)==0)i++;else if((4294965248&l)==0)i+=2;else if((4294901760&l)==0)i+=3;else{if((4292870144&l)!=0)throw"e";i+=4}}return i}},r.F={},r.F.deflateRaw=function(o,s,i,a){var l=[[0,0,0,0,0],[4,4,8,4,0],[4,5,16,8,0],[4,6,16,16,0],[4,10,16,32,0],[8,16,32,32,0],[8,16,128,128,0],[8,32,128,256,0],[32,128,258,1024,1],[32,258,258,4096,1]][a],c=r.F.U,u=r.F._goodIndex;r.F._hash;var d=r.F._putsE,f=0,h=i<<3,p=0,m=o.length;if(a==0){for(;f<m;)d(s,h,f+(I=Math.min(65535,m-f))==m?1:0),h=r.F._copyExact(o,f,I,s,h+8),f+=I;return h>>>3}var g=c.lits,b=c.strt,S=c.prev,k=0,v=0,_=0,x=0,A=0,E=0;for(m>2&&(b[E=r.F._hash(o,0)]=0),f=0;f<m;f++){if(A=E,f+1<m-2){E=r.F._hash(o,f+1);var T=f+1&32767;S[T]=b[E],b[E]=T}if(p<=f){(k>14e3||v>26697)&&m-f>100&&(p<f&&(g[k]=f-p,k+=2,p=f),h=r.F._writeBlock(f==m-1||p==m?1:0,g,k,x,o,_,f-_,s,h),k=v=x=0,_=f);var N=0;f<m-2&&(N=r.F._bestMatch(o,f,S,A,Math.min(l[2],m-f),l[3]));var I=N>>>16,R=65535&N;if(N!=0){R=65535&N;var D=u(I=N>>>16,c.of0);c.lhst[257+D]++;var O=u(R,c.df0);c.dhst[O]++,x+=c.exb[D]+c.dxb[O],g[k]=I<<23|f-p,g[k+1]=R<<16|D<<8|O,k+=2,p=f+I}else c.lhst[o[f]]++;v++}}for(_==f&&o.length!=0||(p<f&&(g[k]=f-p,k+=2,p=f),h=r.F._writeBlock(1,g,k,x,o,_,f-_,s,h),k=0,v=0,k=v=x=0,_=f);(7&h)!=0;)h++;return h>>>3},r.F._bestMatch=function(o,s,i,a,l,c){var u=32767&s,d=i[u],f=u-d+32768&32767;if(d==u||a!=r.F._hash(o,s-f))return 0;for(var h=0,p=0,m=Math.min(32767,s);f<=m&&--c!=0&&d!=u;){if(h==0||o[s+h]==o[s+h-f]){var g=r.F._howLong(o,s,f);if(g>h){if(p=f,(h=g)>=l)break;f+2<g&&(g=f+2);for(var b=0,S=0;S<g-2;S++){var k=s-f+S+32768&32767,v=k-i[k]+32768&32767;v>b&&(b=v,d=k)}}}f+=(u=d)-(d=i[u])+32768&32767}return h<<16|p},r.F._howLong=function(o,s,i){if(o[s]!=o[s-i]||o[s+1]!=o[s+1-i]||o[s+2]!=o[s+2-i])return 0;var a=s,l=Math.min(o.length,s+258);for(s+=3;s<l&&o[s]==o[s-i];)s++;return s-a},r.F._hash=function(o,s){return(o[s]<<8|o[s+1])+(o[s+2]<<4)&65535},r.saved=0,r.F._writeBlock=function(o,s,i,a,l,c,u,d,f){var h,p,m,g,b,S,k,v,_,x=r.F.U,A=r.F._putsF,E=r.F._putsE;x.lhst[256]++,p=(h=r.F.getTrees())[0],m=h[1],g=h[2],b=h[3],S=h[4],k=h[5],v=h[6],_=h[7];var T=32+((f+3&7)==0?0:8-(f+3&7))+(u<<3),N=a+r.F.contSize(x.fltree,x.lhst)+r.F.contSize(x.fdtree,x.dhst),I=a+r.F.contSize(x.ltree,x.lhst)+r.F.contSize(x.dtree,x.dhst);I+=14+3*k+r.F.contSize(x.itree,x.ihst)+(2*x.ihst[16]+3*x.ihst[17]+7*x.ihst[18]);for(var R=0;R<286;R++)x.lhst[R]=0;for(R=0;R<30;R++)x.dhst[R]=0;for(R=0;R<19;R++)x.ihst[R]=0;var D=T<N&&T<I?0:N<I?1:2;if(A(d,f,o),A(d,f+1,D),f+=3,D==0){for(;(7&f)!=0;)f++;f=r.F._copyExact(l,c,u,d,f)}else{var O,P;if(D==1&&(O=x.fltree,P=x.fdtree),D==2){r.F.makeCodes(x.ltree,p),r.F.revCodes(x.ltree,p),r.F.makeCodes(x.dtree,m),r.F.revCodes(x.dtree,m),r.F.makeCodes(x.itree,g),r.F.revCodes(x.itree,g),O=x.ltree,P=x.dtree,E(d,f,b-257),E(d,f+=5,S-1),E(d,f+=5,k-4),f+=4;for(var C=0;C<k;C++)E(d,f+3*C,x.itree[1+(x.ordr[C]<<1)]);f+=3*k,f=r.F._codeTiny(v,x.itree,d,f),f=r.F._codeTiny(_,x.itree,d,f)}for(var M=c,U=0;U<i;U+=2){for(var L=s[U],F=L>>>23,V=M+(8388607&L);M<V;)f=r.F._writeLit(l[M++],O,d,f);if(F!=0){var W=s[U+1],H=W>>16,B=W>>8&255,$=255&W;E(d,f=r.F._writeLit(257+B,O,d,f),F-x.of0[B]),f+=x.exb[B],A(d,f=r.F._writeLit($,P,d,f),H-x.df0[$]),f+=x.dxb[$],M+=F}}f=r.F._writeLit(256,O,d,f)}return f},r.F._copyExact=function(o,s,i,a,l){var c=l>>>3;return a[c]=i,a[c+1]=i>>>8,a[c+2]=255-a[c],a[c+3]=255-a[c+1],c+=4,a.set(new Uint8Array(o.buffer,s,i),c),l+(i+4<<3)},r.F.getTrees=function(){for(var o=r.F.U,s=r.F._hufTree(o.lhst,o.ltree,15),i=r.F._hufTree(o.dhst,o.dtree,15),a=[],l=r.F._lenCodes(o.ltree,a),c=[],u=r.F._lenCodes(o.dtree,c),d=0;d<a.length;d+=2)o.ihst[a[d]]++;for(d=0;d<c.length;d+=2)o.ihst[c[d]]++;for(var f=r.F._hufTree(o.ihst,o.itree,7),h=19;h>4&&o.itree[1+(o.ordr[h-1]<<1)]==0;)h--;return[s,i,f,l,u,h,a,c]},r.F.getSecond=function(o){for(var s=[],i=0;i<o.length;i+=2)s.push(o[i+1]);return s},r.F.nonZero=function(o){for(var s="",i=0;i<o.length;i+=2)o[i+1]!=0&&(s+=(i>>1)+",");return s},r.F.contSize=function(o,s){for(var i=0,a=0;a<s.length;a++)i+=s[a]*o[1+(a<<1)];return i},r.F._codeTiny=function(o,s,i,a){for(var l=0;l<o.length;l+=2){var c=o[l],u=o[l+1];a=r.F._writeLit(c,s,i,a);var d=c==16?2:c==17?3:7;c>15&&(r.F._putsE(i,a,u,d),a+=d)}return a},r.F._lenCodes=function(o,s){for(var i=o.length;i!=2&&o[i-1]==0;)i-=2;for(var a=0;a<i;a+=2){var l=o[a+1],c=a+3<i?o[a+3]:-1,u=a+5<i?o[a+5]:-1,d=a==0?-1:o[a-1];if(l==0&&c==l&&u==l){for(var f=a+5;f+2<i&&o[f+2]==l;)f+=2;(h=Math.min(f+1-a>>>1,138))<11?s.push(17,h-3):s.push(18,h-11),a+=2*h-2}else if(l==d&&c==l&&u==l){for(f=a+5;f+2<i&&o[f+2]==l;)f+=2;var h=Math.min(f+1-a>>>1,6);s.push(16,h-3),a+=2*h-2}else s.push(l,0)}return i>>>1},r.F._hufTree=function(o,s,i){var a=[],l=o.length,c=s.length,u=0;for(u=0;u<c;u+=2)s[u]=0,s[u+1]=0;for(u=0;u<l;u++)o[u]!=0&&a.push({lit:u,f:o[u]});var d=a.length,f=a.slice(0);if(d==0)return 0;if(d==1){var h=a[0].lit;return f=h==0?1:0,s[1+(h<<1)]=1,s[1+(f<<1)]=1,1}a.sort((function(v,_){return v.f-_.f}));var p=a[0],m=a[1],g=0,b=1,S=2;for(a[0]={lit:-1,f:p.f+m.f,l:p,r:m,d:0};b!=d-1;)p=g!=b&&(S==d||a[g].f<a[S].f)?a[g++]:a[S++],m=g!=b&&(S==d||a[g].f<a[S].f)?a[g++]:a[S++],a[b++]={lit:-1,f:p.f+m.f,l:p,r:m};var k=r.F.setDepth(a[b-1],0);for(k>i&&(r.F.restrictDepth(f,i,k),k=i),u=0;u<d;u++)s[1+(f[u].lit<<1)]=f[u].d;return k},r.F.setDepth=function(o,s){return o.lit!=-1?(o.d=s,s):Math.max(r.F.setDepth(o.l,s+1),r.F.setDepth(o.r,s+1))},r.F.restrictDepth=function(o,s,i){var a=0,l=1<<i-s,c=0;for(o.sort((function(d,f){return f.d==d.d?d.f-f.f:f.d-d.d})),a=0;a<o.length&&o[a].d>s;a++){var u=o[a].d;o[a].d=s,c+=l-(1<<i-u)}for(c>>>=i-s;c>0;)(u=o[a].d)<s?(o[a].d++,c-=1<<s-u-1):a++;for(;a>=0;a--)o[a].d==s&&c<0&&(o[a].d--,c++);c!=0},r.F._goodIndex=function(o,s){var i=0;return s[16|i]<=o&&(i|=16),s[8|i]<=o&&(i|=8),s[4|i]<=o&&(i|=4),s[2|i]<=o&&(i|=2),s[1|i]<=o&&(i|=1),i},r.F._writeLit=function(o,s,i,a){return r.F._putsF(i,a,s[o<<1]),a+s[1+(o<<1)]},r.F.inflate=function(o,s){var i=Uint8Array;if(o[0]==3&&o[1]==0)return s||new i(0);var a=r.F,l=a._bitsF,c=a._bitsE,u=a._decodeTiny,d=a.makeCodes,f=a.codes2map,h=a._get17,p=a.U,m=s==null;m&&(s=new i(o.length>>>2<<3));for(var g,b,S=0,k=0,v=0,_=0,x=0,A=0,E=0,T=0,N=0;S==0;)if(S=l(o,N,1),k=l(o,N+1,2),N+=3,k!=0){if(m&&(s=r.F._check(s,T+(1<<17))),k==1&&(g=p.flmap,b=p.fdmap,A=511,E=31),k==2){v=c(o,N,5)+257,_=c(o,N+5,5)+1,x=c(o,N+10,4)+4,N+=14;for(var I=0;I<38;I+=2)p.itree[I]=0,p.itree[I+1]=0;var R=1;for(I=0;I<x;I++){var D=c(o,N+3*I,3);p.itree[1+(p.ordr[I]<<1)]=D,D>R&&(R=D)}N+=3*x,d(p.itree,R),f(p.itree,R,p.imap),g=p.lmap,b=p.dmap,N=u(p.imap,(1<<R)-1,v+_,o,N,p.ttree);var O=a._copyOut(p.ttree,0,v,p.ltree);A=(1<<O)-1;var P=a._copyOut(p.ttree,v,_,p.dtree);E=(1<<P)-1,d(p.ltree,O),f(p.ltree,O,g),d(p.dtree,P),f(p.dtree,P,b)}for(;;){var C=g[h(o,N)&A];N+=15&C;var M=C>>>4;if(!(M>>>8))s[T++]=M;else{if(M==256)break;var U=T+M-254;if(M>264){var L=p.ldef[M-257];U=T+(L>>>3)+c(o,N,7&L),N+=7&L}var F=b[h(o,N)&E];N+=15&F;var V=F>>>4,W=p.ddef[V],H=(W>>>4)+l(o,N,15&W);for(N+=15&W,m&&(s=r.F._check(s,T+(1<<17)));T<U;)s[T]=s[T++-H],s[T]=s[T++-H],s[T]=s[T++-H],s[T]=s[T++-H];T=U}}}else{(7&N)!=0&&(N+=8-(7&N));var B=4+(N>>>3),$=o[B-4]|o[B-3]<<8;m&&(s=r.F._check(s,T+$)),s.set(new i(o.buffer,o.byteOffset+B,$),T),N=B+$<<3,T+=$}return s.length==T?s:s.slice(0,T)},r.F._check=function(o,s){var i=o.length;if(s<=i)return o;var a=new Uint8Array(Math.max(i<<1,s));return a.set(o,0),a},r.F._decodeTiny=function(o,s,i,a,l,c){for(var u=r.F._bitsE,d=r.F._get17,f=0;f<i;){var h=o[d(a,l)&s];l+=15&h;var p=h>>>4;if(p<=15)c[f]=p,f++;else{var m=0,g=0;p==16?(g=3+u(a,l,2),l+=2,m=c[f-1]):p==17?(g=3+u(a,l,3),l+=3):p==18&&(g=11+u(a,l,7),l+=7);for(var b=f+g;f<b;)c[f]=m,f++}}return l},r.F._copyOut=function(o,s,i,a){for(var l=0,c=0,u=a.length>>>1;c<i;){var d=o[c+s];a[c<<1]=0,a[1+(c<<1)]=d,d>l&&(l=d),c++}for(;c<u;)a[c<<1]=0,a[1+(c<<1)]=0,c++;return l},r.F.makeCodes=function(o,s){for(var i,a,l,c,u=r.F.U,d=o.length,f=u.bl_count,h=0;h<=s;h++)f[h]=0;for(h=1;h<d;h+=2)f[o[h]]++;var p=u.next_code;for(i=0,f[0]=0,a=1;a<=s;a++)i=i+f[a-1]<<1,p[a]=i;for(l=0;l<d;l+=2)(c=o[l+1])!=0&&(o[l]=p[c],p[c]++)},r.F.codes2map=function(o,s,i){for(var a=o.length,l=r.F.U.rev15,c=0;c<a;c+=2)if(o[c+1]!=0)for(var u=c>>1,d=o[c+1],f=u<<4|d,h=s-d,p=o[c]<<h,m=p+(1<<h);p!=m;)i[l[p]>>>15-s]=f,p++},r.F.revCodes=function(o,s){for(var i=r.F.U.rev15,a=15-s,l=0;l<o.length;l+=2){var c=o[l]<<s-o[l+1];o[l]=i[c]>>>a}},r.F._putsE=function(o,s,i){i<<=7&s;var a=s>>>3;o[a]|=i,o[a+1]|=i>>>8},r.F._putsF=function(o,s,i){i<<=7&s;var a=s>>>3;o[a]|=i,o[a+1]|=i>>>8,o[a+2]|=i>>>16},r.F._bitsE=function(o,s,i){return(o[s>>>3]|o[1+(s>>>3)]<<8)>>>(7&s)&(1<<i)-1},r.F._bitsF=function(o,s,i){return(o[s>>>3]|o[1+(s>>>3)]<<8|o[2+(s>>>3)]<<16)>>>(7&s)&(1<<i)-1},r.F._get17=function(o,s){return(o[s>>>3]|o[1+(s>>>3)]<<8|o[2+(s>>>3)]<<16)>>>(7&s)},r.F._get25=function(o,s){return(o[s>>>3]|o[1+(s>>>3)]<<8|o[2+(s>>>3)]<<16|o[3+(s>>>3)]<<24)>>>(7&s)},r.F.U=(e=Uint16Array,n=Uint32Array,{next_code:new e(16),bl_count:new e(16),ordr:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],of0:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],exb:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],ldef:new e(32),df0:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],dxb:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],ddef:new n(32),flmap:new e(512),fltree:[],fdmap:new e(32),fdtree:[],lmap:new e(32768),ltree:[],ttree:[],dmap:new e(32768),dtree:[],imap:new e(512),itree:[],rev15:new e(32768),lhst:new n(286),dhst:new n(30),ihst:new n(19),lits:new n(15e3),strt:new e(65536),prev:new e(32768)}),(function(){for(var o=r.F.U,s=0;s<32768;s++){var i=s;i=(4278255360&(i=(4042322160&(i=(3435973836&(i=(2863311530&i)>>>1|(1431655765&i)<<1))>>>2|(858993459&i)<<2))>>>4|(252645135&i)<<4))>>>8|(16711935&i)<<8,o.rev15[s]=(i>>>16|i<<16)>>>17}function a(l,c,u){for(;c--!=0;)l.push(0,u)}for(s=0;s<32;s++)o.ldef[s]=o.of0[s]<<3|o.exb[s],o.ddef[s]=o.df0[s]<<4|o.dxb[s];a(o.fltree,144,8),a(o.fltree,112,9),a(o.fltree,24,7),a(o.fltree,8,8),r.F.makeCodes(o.fltree,9),r.F.codes2map(o.fltree,9,o.flmap),r.F.revCodes(o.fltree,9),a(o.fdtree,32,5),r.F.makeCodes(o.fdtree,5),r.F.codes2map(o.fdtree,5,o.fdmap),r.F.revCodes(o.fdtree,5),a(o.itree,19,0),a(o.ltree,286,0),a(o.dtree,30,0),a(o.ttree,320,0)})()})();var JY=GY({__proto__:null,default:Id},[Id]);const gr=(function(){var t={nextZero(u,d){for(;u[d]!=0;)d++;return d},readUshort:(u,d)=>u[d]<<8|u[d+1],writeUshort(u,d,f){u[d]=f>>8&255,u[d+1]=255&f},readUint:(u,d)=>16777216*u[d]+(u[d+1]<<16|u[d+2]<<8|u[d+3]),writeUint(u,d,f){u[d]=f>>24&255,u[d+1]=f>>16&255,u[d+2]=f>>8&255,u[d+3]=255&f},readASCII(u,d,f){let h="";for(let p=0;p<f;p++)h+=String.fromCharCode(u[d+p]);return h},writeASCII(u,d,f){for(let h=0;h<f.length;h++)u[d+h]=f.charCodeAt(h)},readBytes(u,d,f){const h=[];for(let p=0;p<f;p++)h.push(u[d+p]);return h},pad:u=>u.length<2?`0${u}`:u,readUTF8(u,d,f){let h,p="";for(let m=0;m<f;m++)p+=`%${t.pad(u[d+m].toString(16))}`;try{h=decodeURIComponent(p)}catch{return t.readASCII(u,d,f)}return h}};function e(u,d,f,h){const p=d*f,m=s(h),g=Math.ceil(d*m/8),b=new Uint8Array(4*p),S=new Uint32Array(b.buffer),{ctype:k}=h,{depth:v}=h,_=t.readUshort;if(k==6){const L=p<<2;if(v==8)for(var x=0;x<L;x+=4)b[x]=u[x],b[x+1]=u[x+1],b[x+2]=u[x+2],b[x+3]=u[x+3];if(v==16)for(x=0;x<L;x++)b[x]=u[x<<1]}else if(k==2){const L=h.tabs.tRNS;if(L==null){if(v==8)for(x=0;x<p;x++){var A=3*x;S[x]=255<<24|u[A+2]<<16|u[A+1]<<8|u[A]}if(v==16)for(x=0;x<p;x++)A=6*x,S[x]=255<<24|u[A+4]<<16|u[A+2]<<8|u[A]}else{var E=L[0];const F=L[1],V=L[2];if(v==8)for(x=0;x<p;x++){var T=x<<2;A=3*x,S[x]=255<<24|u[A+2]<<16|u[A+1]<<8|u[A],u[A]==E&&u[A+1]==F&&u[A+2]==V&&(b[T+3]=0)}if(v==16)for(x=0;x<p;x++)T=x<<2,A=6*x,S[x]=255<<24|u[A+4]<<16|u[A+2]<<8|u[A],_(u,A)==E&&_(u,A+2)==F&&_(u,A+4)==V&&(b[T+3]=0)}}else if(k==3){const L=h.tabs.PLTE,F=h.tabs.tRNS,V=F?F.length:0;if(v==1)for(var N=0;N<f;N++){var I=N*g,R=N*d;for(x=0;x<d;x++){T=R+x<<2;var D=3*(O=u[I+(x>>3)]>>7-((7&x)<<0)&1);b[T]=L[D],b[T+1]=L[D+1],b[T+2]=L[D+2],b[T+3]=O<V?F[O]:255}}if(v==2)for(N=0;N<f;N++)for(I=N*g,R=N*d,x=0;x<d;x++)T=R+x<<2,D=3*(O=u[I+(x>>2)]>>6-((3&x)<<1)&3),b[T]=L[D],b[T+1]=L[D+1],b[T+2]=L[D+2],b[T+3]=O<V?F[O]:255;if(v==4)for(N=0;N<f;N++)for(I=N*g,R=N*d,x=0;x<d;x++)T=R+x<<2,D=3*(O=u[I+(x>>1)]>>4-((1&x)<<2)&15),b[T]=L[D],b[T+1]=L[D+1],b[T+2]=L[D+2],b[T+3]=O<V?F[O]:255;if(v==8)for(x=0;x<p;x++){var O;T=x<<2,D=3*(O=u[x]),b[T]=L[D],b[T+1]=L[D+1],b[T+2]=L[D+2],b[T+3]=O<V?F[O]:255}}else if(k==4){if(v==8)for(x=0;x<p;x++){T=x<<2;var P=u[C=x<<1];b[T]=P,b[T+1]=P,b[T+2]=P,b[T+3]=u[C+1]}if(v==16)for(x=0;x<p;x++){var C;T=x<<2,P=u[C=x<<2],b[T]=P,b[T+1]=P,b[T+2]=P,b[T+3]=u[C+2]}}else if(k==0)for(E=h.tabs.tRNS?h.tabs.tRNS:-1,N=0;N<f;N++){const L=N*g,F=N*d;if(v==1)for(var M=0;M<d;M++){var U=(P=255*(u[L+(M>>>3)]>>>7-(7&M)&1))==255*E?0:255;S[F+M]=U<<24|P<<16|P<<8|P}else if(v==2)for(M=0;M<d;M++)U=(P=85*(u[L+(M>>>2)]>>>6-((3&M)<<1)&3))==85*E?0:255,S[F+M]=U<<24|P<<16|P<<8|P;else if(v==4)for(M=0;M<d;M++)U=(P=17*(u[L+(M>>>1)]>>>4-((1&M)<<2)&15))==17*E?0:255,S[F+M]=U<<24|P<<16|P<<8|P;else if(v==8)for(M=0;M<d;M++)U=(P=u[L+M])==E?0:255,S[F+M]=U<<24|P<<16|P<<8|P;else if(v==16)for(M=0;M<d;M++)P=u[L+(M<<1)],U=_(u,L+(M<<1))==E?0:255,S[F+M]=U<<24|P<<16|P<<8|P}return b}function n(u,d,f,h){const p=s(u),m=Math.ceil(f*p/8),g=new Uint8Array((m+1+u.interlace)*h);return d=u.tabs.CgBI?o(d,g):r(d,g),u.interlace==0?d=i(d,u,0,f,h):u.interlace==1&&(d=(function(S,k){const v=k.width,_=k.height,x=s(k),A=x>>3,E=Math.ceil(v*x/8),T=new Uint8Array(_*E);let N=0;const I=[0,0,4,0,2,0,1],R=[0,4,0,2,0,1,0],D=[8,8,8,4,4,2,2],O=[8,8,4,4,2,2,1];let P=0;for(;P<7;){const M=D[P],U=O[P];let L=0,F=0,V=I[P];for(;V<_;)V+=M,F++;let W=R[P];for(;W<v;)W+=U,L++;const H=Math.ceil(L*x/8);i(S,k,N,L,F);let B=0,$=I[P];for(;$<_;){let K=R[P],Y=N+B*H<<3;for(;K<v;){var C;if(x==1&&(C=(C=S[Y>>3])>>7-(7&Y)&1,T[$*E+(K>>3)]|=C<<7-((7&K)<<0)),x==2&&(C=(C=S[Y>>3])>>6-(7&Y)&3,T[$*E+(K>>2)]|=C<<6-((3&K)<<1)),x==4&&(C=(C=S[Y>>3])>>4-(7&Y)&15,T[$*E+(K>>1)]|=C<<4-((1&K)<<2)),x>=8){const J=$*E+K*A;for(let Q=0;Q<A;Q++)T[J+Q]=S[(Y>>3)+Q]}Y+=x,K+=U}B++,$+=M}L*F!=0&&(N+=F*(1+H)),P+=1}return T})(d,u)),d}function r(u,d){return o(new Uint8Array(u.buffer,2,u.length-6),d)}var o=(function(){const u={H:{}};return u.H.N=function(d,f){const h=Uint8Array;let p,m,g=0,b=0,S=0,k=0,v=0,_=0,x=0,A=0,E=0;if(d[0]==3&&d[1]==0)return f||new h(0);const T=u.H,N=T.b,I=T.e,R=T.R,D=T.n,O=T.A,P=T.Z,C=T.m,M=f==null;for(M&&(f=new h(d.length>>>2<<5));g==0;)if(g=N(d,E,1),b=N(d,E+1,2),E+=3,b!=0){if(M&&(f=u.H.W(f,A+(1<<17))),b==1&&(p=C.J,m=C.h,_=511,x=31),b==2){S=I(d,E,5)+257,k=I(d,E+5,5)+1,v=I(d,E+10,4)+4,E+=14;let L=1;for(var U=0;U<38;U+=2)C.Q[U]=0,C.Q[U+1]=0;for(U=0;U<v;U++){const W=I(d,E+3*U,3);C.Q[1+(C.X[U]<<1)]=W,W>L&&(L=W)}E+=3*v,D(C.Q,L),O(C.Q,L,C.u),p=C.w,m=C.d,E=R(C.u,(1<<L)-1,S+k,d,E,C.v);const F=T.V(C.v,0,S,C.C);_=(1<<F)-1;const V=T.V(C.v,S,k,C.D);x=(1<<V)-1,D(C.C,F),O(C.C,F,p),D(C.D,V),O(C.D,V,m)}for(;;){const L=p[P(d,E)&_];E+=15&L;const F=L>>>4;if(!(F>>>8))f[A++]=F;else{if(F==256)break;{let V=A+F-254;if(F>264){const K=C.q[F-257];V=A+(K>>>3)+I(d,E,7&K),E+=7&K}const W=m[P(d,E)&x];E+=15&W;const H=W>>>4,B=C.c[H],$=(B>>>4)+N(d,E,15&B);for(E+=15&B;A<V;)f[A]=f[A++-$],f[A]=f[A++-$],f[A]=f[A++-$],f[A]=f[A++-$];A=V}}}}else{(7&E)!=0&&(E+=8-(7&E));const L=4+(E>>>3),F=d[L-4]|d[L-3]<<8;M&&(f=u.H.W(f,A+F)),f.set(new h(d.buffer,d.byteOffset+L,F),A),E=L+F<<3,A+=F}return f.length==A?f:f.slice(0,A)},u.H.W=function(d,f){const h=d.length;if(f<=h)return d;const p=new Uint8Array(h<<1);return p.set(d,0),p},u.H.R=function(d,f,h,p,m,g){const b=u.H.e,S=u.H.Z;let k=0;for(;k<h;){const v=d[S(p,m)&f];m+=15&v;const _=v>>>4;if(_<=15)g[k]=_,k++;else{let x=0,A=0;_==16?(A=3+b(p,m,2),m+=2,x=g[k-1]):_==17?(A=3+b(p,m,3),m+=3):_==18&&(A=11+b(p,m,7),m+=7);const E=k+A;for(;k<E;)g[k]=x,k++}}return m},u.H.V=function(d,f,h,p){let m=0,g=0;const b=p.length>>>1;for(;g<h;){const S=d[g+f];p[g<<1]=0,p[1+(g<<1)]=S,S>m&&(m=S),g++}for(;g<b;)p[g<<1]=0,p[1+(g<<1)]=0,g++;return m},u.H.n=function(d,f){const h=u.H.m,p=d.length;let m,g,b,S;const k=h.j;for(var v=0;v<=f;v++)k[v]=0;for(v=1;v<p;v+=2)k[d[v]]++;const _=h.K;for(m=0,k[0]=0,g=1;g<=f;g++)m=m+k[g-1]<<1,_[g]=m;for(b=0;b<p;b+=2)S=d[b+1],S!=0&&(d[b]=_[S],_[S]++)},u.H.A=function(d,f,h){const p=d.length,m=u.H.m.r;for(let g=0;g<p;g+=2)if(d[g+1]!=0){const b=g>>1,S=d[g+1],k=b<<4|S,v=f-S;let _=d[g]<<v;const x=_+(1<<v);for(;_!=x;)h[m[_]>>>15-f]=k,_++}},u.H.l=function(d,f){const h=u.H.m.r,p=15-f;for(let m=0;m<d.length;m+=2){const g=d[m]<<f-d[m+1];d[m]=h[g]>>>p}},u.H.M=function(d,f,h){h<<=7&f;const p=f>>>3;d[p]|=h,d[p+1]|=h>>>8},u.H.I=function(d,f,h){h<<=7&f;const p=f>>>3;d[p]|=h,d[p+1]|=h>>>8,d[p+2]|=h>>>16},u.H.e=function(d,f,h){return(d[f>>>3]|d[1+(f>>>3)]<<8)>>>(7&f)&(1<<h)-1},u.H.b=function(d,f,h){return(d[f>>>3]|d[1+(f>>>3)]<<8|d[2+(f>>>3)]<<16)>>>(7&f)&(1<<h)-1},u.H.Z=function(d,f){return(d[f>>>3]|d[1+(f>>>3)]<<8|d[2+(f>>>3)]<<16)>>>(7&f)},u.H.i=function(d,f){return(d[f>>>3]|d[1+(f>>>3)]<<8|d[2+(f>>>3)]<<16|d[3+(f>>>3)]<<24)>>>(7&f)},u.H.m=(function(){const d=Uint16Array,f=Uint32Array;return{K:new d(16),j:new d(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new d(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new f(32),J:new d(512),_:[],h:new d(32),$:[],w:new d(32768),C:[],v:[],d:new d(32768),D:[],u:new d(512),Q:[],r:new d(32768),s:new f(286),Y:new f(30),a:new f(19),t:new f(15e3),k:new d(65536),g:new d(32768)}})(),(function(){const d=u.H.m;for(var f=0;f<32768;f++){let p=f;p=(2863311530&p)>>>1|(1431655765&p)<<1,p=(3435973836&p)>>>2|(858993459&p)<<2,p=(4042322160&p)>>>4|(252645135&p)<<4,p=(4278255360&p)>>>8|(16711935&p)<<8,d.r[f]=(p>>>16|p<<16)>>>17}function h(p,m,g){for(;m--!=0;)p.push(0,g)}for(f=0;f<32;f++)d.q[f]=d.S[f]<<3|d.T[f],d.c[f]=d.p[f]<<4|d.z[f];h(d._,144,8),h(d._,112,9),h(d._,24,7),h(d._,8,8),u.H.n(d._,9),u.H.A(d._,9,d.J),u.H.l(d._,9),h(d.$,32,5),u.H.n(d.$,5),u.H.A(d.$,5,d.h),u.H.l(d.$,5),h(d.Q,19,0),h(d.C,286,0),h(d.D,30,0),h(d.v,320,0)})(),u.H.N})();function s(u){return[1,null,3,1,2,null,4][u.ctype]*u.depth}function i(u,d,f,h,p){let m=s(d);const g=Math.ceil(h*m/8);let b,S;m=Math.ceil(m/8);let k=u[f],v=0;if(k>1&&(u[f]=[0,0,1][k-2]),k==3)for(v=m;v<g;v++)u[v+1]=u[v+1]+(u[v+1-m]>>>1)&255;for(let _=0;_<p;_++)if(b=f+_*g,S=b+_+1,k=u[S-1],v=0,k==0)for(;v<g;v++)u[b+v]=u[S+v];else if(k==1){for(;v<m;v++)u[b+v]=u[S+v];for(;v<g;v++)u[b+v]=u[S+v]+u[b+v-m]}else if(k==2)for(;v<g;v++)u[b+v]=u[S+v]+u[b+v-g];else if(k==3){for(;v<m;v++)u[b+v]=u[S+v]+(u[b+v-g]>>>1);for(;v<g;v++)u[b+v]=u[S+v]+(u[b+v-g]+u[b+v-m]>>>1)}else{for(;v<m;v++)u[b+v]=u[S+v]+a(0,u[b+v-g],0);for(;v<g;v++)u[b+v]=u[S+v]+a(u[b+v-m],u[b+v-g],u[b+v-m-g])}return u}function a(u,d,f){const h=u+d-f,p=h-u,m=h-d,g=h-f;return p*p<=m*m&&p*p<=g*g?u:m*m<=g*g?d:f}function l(u,d,f){f.width=t.readUint(u,d),d+=4,f.height=t.readUint(u,d),d+=4,f.depth=u[d],d++,f.ctype=u[d],d++,f.compress=u[d],d++,f.filter=u[d],d++,f.interlace=u[d],d++}function c(u,d,f,h,p,m,g,b,S){const k=Math.min(d,p),v=Math.min(f,m);let _=0,x=0;for(let P=0;P<v;P++)for(let C=0;C<k;C++)if(g>=0&&b>=0?(_=P*d+C<<2,x=(b+P)*p+g+C<<2):(_=(-b+P)*d-g+C<<2,x=P*p+C<<2),S==0)h[x]=u[_],h[x+1]=u[_+1],h[x+2]=u[_+2],h[x+3]=u[_+3];else if(S==1){var A=u[_+3]*.00392156862745098,E=u[_]*A,T=u[_+1]*A,N=u[_+2]*A,I=h[x+3]*(1/255),R=h[x]*I,D=h[x+1]*I,O=h[x+2]*I;const M=1-A,U=A+I*M,L=U==0?0:1/U;h[x+3]=255*U,h[x+0]=(E+R*M)*L,h[x+1]=(T+D*M)*L,h[x+2]=(N+O*M)*L}else if(S==2)A=u[_+3],E=u[_],T=u[_+1],N=u[_+2],I=h[x+3],R=h[x],D=h[x+1],O=h[x+2],A==I&&E==R&&T==D&&N==O?(h[x]=0,h[x+1]=0,h[x+2]=0,h[x+3]=0):(h[x]=E,h[x+1]=T,h[x+2]=N,h[x+3]=A);else if(S==3){if(A=u[_+3],E=u[_],T=u[_+1],N=u[_+2],I=h[x+3],R=h[x],D=h[x+1],O=h[x+2],A==I&&E==R&&T==D&&N==O)continue;if(A<220&&I>20)return!1}return!0}return{decode:function(d){const f=new Uint8Array(d);let h=8;const p=t,m=p.readUshort,g=p.readUint,b={tabs:{},frames:[]},S=new Uint8Array(f.length);let k,v=0,_=0;const x=[137,80,78,71,13,10,26,10];for(var A=0;A<8;A++)if(f[A]!=x[A])throw"The input is not a PNG file!";for(;h<f.length;){const P=p.readUint(f,h);h+=4;const C=p.readASCII(f,h,4);if(h+=4,C=="IHDR")l(f,h,b);else if(C=="iCCP"){for(var E=h;f[E]!=0;)E++;p.readASCII(f,h,E-h),f[E+1];const M=f.slice(E+2,h+P);let U=null;try{U=r(M)}catch{U=o(M)}b.tabs[C]=U}else if(C=="CgBI")b.tabs[C]=f.slice(h,h+4);else if(C=="IDAT"){for(A=0;A<P;A++)S[v+A]=f[h+A];v+=P}else if(C=="acTL")b.tabs[C]={num_frames:g(f,h),num_plays:g(f,h+4)},k=new Uint8Array(f.length);else if(C=="fcTL"){_!=0&&((O=b.frames[b.frames.length-1]).data=n(b,k.slice(0,_),O.rect.width,O.rect.height),_=0);const M={x:g(f,h+12),y:g(f,h+16),width:g(f,h+4),height:g(f,h+8)};let U=m(f,h+22);U=m(f,h+20)/(U==0?100:U);const L={rect:M,delay:Math.round(1e3*U),dispose:f[h+24],blend:f[h+25]};b.frames.push(L)}else if(C=="fdAT"){for(A=0;A<P-4;A++)k[_+A]=f[h+A+4];_+=P-4}else if(C=="pHYs")b.tabs[C]=[p.readUint(f,h),p.readUint(f,h+4),f[h+8]];else if(C=="cHRM")for(b.tabs[C]=[],A=0;A<8;A++)b.tabs[C].push(p.readUint(f,h+4*A));else if(C=="tEXt"||C=="zTXt"){b.tabs[C]==null&&(b.tabs[C]={});var T=p.nextZero(f,h),N=p.readASCII(f,h,T-h),I=h+P-T-1;if(C=="tEXt")D=p.readASCII(f,T+1,I);else{var R=r(f.slice(T+2,T+2+I));D=p.readUTF8(R,0,R.length)}b.tabs[C][N]=D}else if(C=="iTXt"){b.tabs[C]==null&&(b.tabs[C]={}),T=0,E=h,T=p.nextZero(f,E),N=p.readASCII(f,E,T-E);const M=f[E=T+1];var D;f[E+1],E+=2,T=p.nextZero(f,E),p.readASCII(f,E,T-E),E=T+1,T=p.nextZero(f,E),p.readUTF8(f,E,T-E),I=P-((E=T+1)-h),M==0?D=p.readUTF8(f,E,I):(R=r(f.slice(E,E+I)),D=p.readUTF8(R,0,R.length)),b.tabs[C][N]=D}else if(C=="PLTE")b.tabs[C]=p.readBytes(f,h,P);else if(C=="hIST"){const M=b.tabs.PLTE.length/3;for(b.tabs[C]=[],A=0;A<M;A++)b.tabs[C].push(m(f,h+2*A))}else if(C=="tRNS")b.ctype==3?b.tabs[C]=p.readBytes(f,h,P):b.ctype==0?b.tabs[C]=m(f,h):b.ctype==2&&(b.tabs[C]=[m(f,h),m(f,h+2),m(f,h+4)]);else if(C=="gAMA")b.tabs[C]=p.readUint(f,h)/1e5;else if(C=="sRGB")b.tabs[C]=f[h];else if(C=="bKGD")b.ctype==0||b.ctype==4?b.tabs[C]=[m(f,h)]:b.ctype==2||b.ctype==6?b.tabs[C]=[m(f,h),m(f,h+2),m(f,h+4)]:b.ctype==3&&(b.tabs[C]=f[h]);else if(C=="IEND")break;h+=P,p.readUint(f,h),h+=4}var O;return _!=0&&((O=b.frames[b.frames.length-1]).data=n(b,k.slice(0,_),O.rect.width,O.rect.height)),b.data=n(b,S,b.width,b.height),delete b.compress,delete b.interlace,delete b.filter,b},toRGBA8:function(d){const f=d.width,h=d.height;if(d.tabs.acTL==null)return[e(d.data,f,h,d).buffer];const p=[];d.frames[0].data==null&&(d.frames[0].data=d.data);const m=f*h*4,g=new Uint8Array(m),b=new Uint8Array(m),S=new Uint8Array(m);for(let v=0;v<d.frames.length;v++){const _=d.frames[v],x=_.rect.x,A=_.rect.y,E=_.rect.width,T=_.rect.height,N=e(_.data,E,T,d);if(v!=0)for(var k=0;k<m;k++)S[k]=g[k];if(_.blend==0?c(N,E,T,g,f,h,x,A,0):_.blend==1&&c(N,E,T,g,f,h,x,A,1),p.push(g.buffer.slice(0)),_.dispose!=0){if(_.dispose==1)c(b,E,T,g,f,h,x,A,0);else if(_.dispose==2)for(k=0;k<m;k++)g[k]=S[k]}}return p},_paeth:a,_copyTile:c,_bin:t}})();(function(){const{_copyTile:t}=gr,{_bin:e}=gr,n=gr._paeth;var r={table:(function(){const E=new Uint32Array(256);for(let T=0;T<256;T++){let N=T;for(let I=0;I<8;I++)1&N?N=3988292384^N>>>1:N>>>=1;E[T]=N}return E})(),update(E,T,N,I){for(let R=0;R<I;R++)E=r.table[255&(E^T[N+R])]^E>>>8;return E},crc:(E,T,N)=>4294967295^r.update(4294967295,E,T,N)};function o(E,T,N,I){T[N]+=E[0]*I>>4,T[N+1]+=E[1]*I>>4,T[N+2]+=E[2]*I>>4,T[N+3]+=E[3]*I>>4}function s(E){return Math.max(0,Math.min(255,E))}function i(E,T){const N=E[0]-T[0],I=E[1]-T[1],R=E[2]-T[2],D=E[3]-T[3];return N*N+I*I+R*R+D*D}function a(E,T,N,I,R,D,O){O==null&&(O=1);const P=I.length,C=[];for(var M=0;M<P;M++){const $=I[M];C.push([$>>>0&255,$>>>8&255,$>>>16&255,$>>>24&255])}for(M=0;M<P;M++){let $=4294967295;for(var U=0,L=0;L<P;L++){var F=i(C[M],C[L]);L!=M&&F<$&&($=F,U=L)}}const V=new Uint32Array(R.buffer),W=new Int16Array(T*N*4),H=[0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5];for(M=0;M<H.length;M++)H[M]=255*((H[M]+.5)/16-.5);for(let $=0;$<N;$++)for(let K=0;K<T;K++){var B;M=4*($*T+K),O!=2?B=[s(E[M]+W[M]),s(E[M+1]+W[M+1]),s(E[M+2]+W[M+2]),s(E[M+3]+W[M+3])]:(F=H[4*(3&$)+(3&K)],B=[s(E[M]+F),s(E[M+1]+F),s(E[M+2]+F),s(E[M+3]+F)]),U=0;let Y=16777215;for(L=0;L<P;L++){const ne=i(B,C[L]);ne<Y&&(Y=ne,U=L)}const J=C[U],Q=[B[0]-J[0],B[1]-J[1],B[2]-J[2],B[3]-J[3]];O==1&&(K!=T-1&&o(Q,W,M+4,7),$!=N-1&&(K!=0&&o(Q,W,M+4*T-4,3),o(Q,W,M+4*T,5),K!=T-1&&o(Q,W,M+4*T+4,1))),D[M>>2]=U,V[M>>2]=I[U]}}function l(E,T,N,I,R){R==null&&(R={});const{crc:D}=r,O=e.writeUint,P=e.writeUshort,C=e.writeASCII;let M=8;const U=E.frames.length>1;let L,F=!1,V=33+(U?20:0);if(R.sRGB!=null&&(V+=13),R.pHYs!=null&&(V+=21),R.iCCP!=null&&(L=pako.deflate(R.iCCP),V+=21+L.length+4),E.ctype==3){for(var W=E.plte.length,H=0;H<W;H++)E.plte[H]>>>24!=255&&(F=!0);V+=8+3*W+4+(F?8+1*W+4:0)}for(var B=0;B<E.frames.length;B++)U&&(V+=38),V+=(J=E.frames[B]).cimg.length+12,B!=0&&(V+=4);V+=12;const $=new Uint8Array(V),K=[137,80,78,71,13,10,26,10];for(H=0;H<8;H++)$[H]=K[H];if(O($,M,13),M+=4,C($,M,"IHDR"),M+=4,O($,M,T),M+=4,O($,M,N),M+=4,$[M]=E.depth,M++,$[M]=E.ctype,M++,$[M]=0,M++,$[M]=0,M++,$[M]=0,M++,O($,M,D($,M-17,17)),M+=4,R.sRGB!=null&&(O($,M,1),M+=4,C($,M,"sRGB"),M+=4,$[M]=R.sRGB,M++,O($,M,D($,M-5,5)),M+=4),R.iCCP!=null){const Q=13+L.length;O($,M,Q),M+=4,C($,M,"iCCP"),M+=4,C($,M,"ICC profile"),M+=11,M+=2,$.set(L,M),M+=L.length,O($,M,D($,M-(Q+4),Q+4)),M+=4}if(R.pHYs!=null&&(O($,M,9),M+=4,C($,M,"pHYs"),M+=4,O($,M,R.pHYs[0]),M+=4,O($,M,R.pHYs[1]),M+=4,$[M]=R.pHYs[2],M++,O($,M,D($,M-13,13)),M+=4),U&&(O($,M,8),M+=4,C($,M,"acTL"),M+=4,O($,M,E.frames.length),M+=4,O($,M,R.loop!=null?R.loop:0),M+=4,O($,M,D($,M-12,12)),M+=4),E.ctype==3){for(O($,M,3*(W=E.plte.length)),M+=4,C($,M,"PLTE"),M+=4,H=0;H<W;H++){const Q=3*H,ne=E.plte[H],se=255&ne,te=ne>>>8&255,ge=ne>>>16&255;$[M+Q+0]=se,$[M+Q+1]=te,$[M+Q+2]=ge}if(M+=3*W,O($,M,D($,M-3*W-4,3*W+4)),M+=4,F){for(O($,M,W),M+=4,C($,M,"tRNS"),M+=4,H=0;H<W;H++)$[M+H]=E.plte[H]>>>24&255;M+=W,O($,M,D($,M-W-4,W+4)),M+=4}}let Y=0;for(B=0;B<E.frames.length;B++){var J=E.frames[B];U&&(O($,M,26),M+=4,C($,M,"fcTL"),M+=4,O($,M,Y++),M+=4,O($,M,J.rect.width),M+=4,O($,M,J.rect.height),M+=4,O($,M,J.rect.x),M+=4,O($,M,J.rect.y),M+=4,P($,M,I[B]),M+=2,P($,M,1e3),M+=2,$[M]=J.dispose,M++,$[M]=J.blend,M++,O($,M,D($,M-30,30)),M+=4);const Q=J.cimg;O($,M,(W=Q.length)+(B==0?0:4)),M+=4;const ne=M;C($,M,B==0?"IDAT":"fdAT"),M+=4,B!=0&&(O($,M,Y++),M+=4),$.set(Q,M),M+=W,O($,M,D($,ne,M-ne)),M+=4}return O($,M,0),M+=4,C($,M,"IEND"),M+=4,O($,M,D($,M-4,4)),M+=4,$.buffer}function c(E,T,N){for(let I=0;I<E.frames.length;I++){const R=E.frames[I];R.rect.width;const D=R.rect.height,O=new Uint8Array(D*R.bpl+D);R.cimg=h(R.img,D,R.bpp,R.bpl,O,T,N)}}function u(E,T,N,I,R){const D=R[0],O=R[1],P=R[2],C=R[3],M=R[4],U=R[5];let L=6,F=8,V=255;for(var W=0;W<E.length;W++){const Ee=new Uint8Array(E[W]);for(var H=Ee.length,B=0;B<H;B+=4)V&=Ee[B+3]}const $=V!=255,K=(function(Se,_e,Me,Ke,Ge,Be){const je=[];for(var $e=0;$e<Se.length;$e++){const tt=new Uint8Array(Se[$e]),et=new Uint32Array(tt.buffer);var pe;let qe=0,jt=0,q=_e,re=Me,de=Ke?1:0;if($e!=0){const We=Be||Ke||$e==1||je[$e-2].dispose!=0?1:2;let Ae=0,ot=1e9;for(let ht=0;ht<We;ht++){var Ne=new Uint8Array(Se[$e-1-ht]);const hn=new Uint32Array(Se[$e-1-ht]);let nn=_e,pt=Me,ve=-1,nt=-1;for(let rt=0;rt<Me;rt++)for(let $t=0;$t<_e;$t++)et[Ve=rt*_e+$t]!=hn[Ve]&&($t<nn&&(nn=$t),$t>ve&&(ve=$t),rt<pt&&(pt=rt),rt>nt&&(nt=rt));ve==-1&&(nn=pt=ve=nt=0),Ge&&((1&nn)==1&&nn--,(1&pt)==1&&pt--);const Ce=(ve-nn+1)*(nt-pt+1);Ce<ot&&(ot=Ce,Ae=ht,qe=nn,jt=pt,q=ve-nn+1,re=nt-pt+1)}Ne=new Uint8Array(Se[$e-1-Ae]),Ae==1&&(je[$e-1].dispose=2),pe=new Uint8Array(q*re*4),t(Ne,_e,Me,pe,q,re,-qe,-jt,0),de=t(tt,_e,Me,pe,q,re,-qe,-jt,3)?1:0,de==1?f(tt,_e,Me,pe,{x:qe,y:jt,width:q,height:re}):t(tt,_e,Me,pe,q,re,-qe,-jt,0)}else pe=tt.slice(0);je.push({rect:{x:qe,y:jt,width:q,height:re},img:pe,blend:de,dispose:0})}if(Ke)for($e=0;$e<je.length;$e++){if((vt=je[$e]).blend==1)continue;const tt=vt.rect,et=je[$e-1].rect,qe=Math.min(tt.x,et.x),jt=Math.min(tt.y,et.y),q={x:qe,y:jt,width:Math.max(tt.x+tt.width,et.x+et.width)-qe,height:Math.max(tt.y+tt.height,et.y+et.height)-jt};je[$e-1].dispose=1,$e-1!=0&&d(Se,_e,Me,je,$e-1,q,Ge),d(Se,_e,Me,je,$e,q,Ge)}let Ie=0;if(Se.length!=1)for(var Ve=0;Ve<je.length;Ve++){var vt;Ie+=(vt=je[Ve]).rect.width*vt.rect.height}return je})(E,T,N,D,O,P),Y={},J=[],Q=[];if(I!=0){const Ee=[];for(B=0;B<K.length;B++)Ee.push(K[B].img.buffer);const Se=(function(Ge){let Be=0;for(var je=0;je<Ge.length;je++)Be+=Ge[je].byteLength;const $e=new Uint8Array(Be);let pe=0;for(je=0;je<Ge.length;je++){const Ne=new Uint8Array(Ge[je]),Ie=Ne.length;for(let Ve=0;Ve<Ie;Ve+=4){let vt=Ne[Ve],tt=Ne[Ve+1],et=Ne[Ve+2];const qe=Ne[Ve+3];qe==0&&(vt=tt=et=0),$e[pe+Ve]=vt,$e[pe+Ve+1]=tt,$e[pe+Ve+2]=et,$e[pe+Ve+3]=qe}pe+=Ie}return $e.buffer})(Ee),_e=m(Se,I);for(B=0;B<_e.plte.length;B++)J.push(_e.plte[B].est.rgba);let Me=0;for(B=0;B<K.length;B++){const Ke=(se=K[B]).img.length;var ne=new Uint8Array(_e.inds.buffer,Me>>2,Ke>>2);Q.push(ne);const Ge=new Uint8Array(_e.abuf,Me,Ke);U&&a(se.img,se.rect.width,se.rect.height,J,Ge,ne),se.img.set(Ge),Me+=Ke}}else for(W=0;W<K.length;W++){var se=K[W];const Ee=new Uint32Array(se.img.buffer);var te=se.rect.width;for(H=Ee.length,ne=new Uint8Array(H),Q.push(ne),B=0;B<H;B++){const Se=Ee[B];if(B!=0&&Se==Ee[B-1])ne[B]=ne[B-1];else if(B>te&&Se==Ee[B-te])ne[B]=ne[B-te];else{let _e=Y[Se];if(_e==null&&(Y[Se]=_e=J.length,J.push(Se),J.length>=300))break;ne[B]=_e}}}const ge=J.length;for(ge<=256&&M==0&&(F=ge<=2?1:ge<=4?2:ge<=16?4:8,F=Math.max(F,C)),W=0;W<K.length;W++){(se=K[W]).rect.x,se.rect.y,te=se.rect.width;const Ee=se.rect.height;let Se=se.img;new Uint32Array(Se.buffer);let _e=4*te,Me=4;if(ge<=256&&M==0){_e=Math.ceil(F*te/8);var he=new Uint8Array(_e*Ee);const Ke=Q[W];for(let Ge=0;Ge<Ee;Ge++){B=Ge*_e;const Be=Ge*te;if(F==8)for(var xe=0;xe<te;xe++)he[B+xe]=Ke[Be+xe];else if(F==4)for(xe=0;xe<te;xe++)he[B+(xe>>1)]|=Ke[Be+xe]<<4-4*(1&xe);else if(F==2)for(xe=0;xe<te;xe++)he[B+(xe>>2)]|=Ke[Be+xe]<<6-2*(3&xe);else if(F==1)for(xe=0;xe<te;xe++)he[B+(xe>>3)]|=Ke[Be+xe]<<7-1*(7&xe)}Se=he,L=3,Me=1}else if($==0&&K.length==1){he=new Uint8Array(te*Ee*3);const Ke=te*Ee;for(B=0;B<Ke;B++){const Ge=3*B,Be=4*B;he[Ge]=Se[Be],he[Ge+1]=Se[Be+1],he[Ge+2]=Se[Be+2]}Se=he,L=2,Me=3,_e=3*te}se.img=Se,se.bpl=_e,se.bpp=Me}return{ctype:L,depth:F,plte:J,frames:K}}function d(E,T,N,I,R,D,O){const P=Uint8Array,C=Uint32Array,M=new P(E[R-1]),U=new C(E[R-1]),L=R+1<E.length?new P(E[R+1]):null,F=new P(E[R]),V=new C(F.buffer);let W=T,H=N,B=-1,$=-1;for(let Y=0;Y<D.height;Y++)for(let J=0;J<D.width;J++){const Q=D.x+J,ne=D.y+Y,se=ne*T+Q,te=V[se];te==0||I[R-1].dispose==0&&U[se]==te&&(L==null||L[4*se+3]!=0)||(Q<W&&(W=Q),Q>B&&(B=Q),ne<H&&(H=ne),ne>$&&($=ne))}B==-1&&(W=H=B=$=0),O&&((1&W)==1&&W--,(1&H)==1&&H--),D={x:W,y:H,width:B-W+1,height:$-H+1};const K=I[R];K.rect=D,K.blend=1,K.img=new Uint8Array(D.width*D.height*4),I[R-1].dispose==0?(t(M,T,N,K.img,D.width,D.height,-D.x,-D.y,0),f(F,T,N,K.img,D)):t(F,T,N,K.img,D.width,D.height,-D.x,-D.y,0)}function f(E,T,N,I,R){t(E,T,N,I,R.width,R.height,-R.x,-R.y,2)}function h(E,T,N,I,R,D,O){const P=[];let C,M=[0,1,2,3,4];D!=-1?M=[D]:(T*I>5e5||N==1)&&(M=[0]),O&&(C={level:0});const U=JY;for(var L=0;L<M.length;L++){for(let W=0;W<T;W++)p(R,E,W,I,N,M[L]);P.push(U.deflate(R,C))}let F,V=1e9;for(L=0;L<P.length;L++)P[L].length<V&&(F=L,V=P[L].length);return P[F]}function p(E,T,N,I,R,D){const O=N*I;let P=O+N;if(E[P]=D,P++,D==0)if(I<500)for(var C=0;C<I;C++)E[P+C]=T[O+C];else E.set(new Uint8Array(T.buffer,O,I),P);else if(D==1){for(C=0;C<R;C++)E[P+C]=T[O+C];for(C=R;C<I;C++)E[P+C]=T[O+C]-T[O+C-R]+256&255}else if(N==0){for(C=0;C<R;C++)E[P+C]=T[O+C];if(D==2)for(C=R;C<I;C++)E[P+C]=T[O+C];if(D==3)for(C=R;C<I;C++)E[P+C]=T[O+C]-(T[O+C-R]>>1)+256&255;if(D==4)for(C=R;C<I;C++)E[P+C]=T[O+C]-n(T[O+C-R],0,0)+256&255}else{if(D==2)for(C=0;C<I;C++)E[P+C]=T[O+C]+256-T[O+C-I]&255;if(D==3){for(C=0;C<R;C++)E[P+C]=T[O+C]+256-(T[O+C-I]>>1)&255;for(C=R;C<I;C++)E[P+C]=T[O+C]+256-(T[O+C-I]+T[O+C-R]>>1)&255}if(D==4){for(C=0;C<R;C++)E[P+C]=T[O+C]+256-n(0,T[O+C-I],0)&255;for(C=R;C<I;C++)E[P+C]=T[O+C]+256-n(T[O+C-R],T[O+C-I],T[O+C-R-I])&255}}}function m(E,T){const N=new Uint8Array(E),I=N.slice(0),R=new Uint32Array(I.buffer),D=g(I,T),O=D[0],P=D[1],C=N.length,M=new Uint8Array(C>>2);let U;if(N.length<2e7)for(var L=0;L<C;L+=4)U=b(O,F=N[L]*(1/255),V=N[L+1]*(1/255),W=N[L+2]*(1/255),H=N[L+3]*(1/255)),M[L>>2]=U.ind,R[L>>2]=U.est.rgba;else for(L=0;L<C;L+=4){var F=N[L]*.00392156862745098,V=N[L+1]*(1/255),W=N[L+2]*(1/255),H=N[L+3]*(1/255);for(U=O;U.left;)U=S(U.est,F,V,W,H)<=0?U.left:U.right;M[L>>2]=U.ind,R[L>>2]=U.est.rgba}return{abuf:I.buffer,inds:M,plte:P}}function g(E,T,N){N==null&&(N=1e-4);const I=new Uint32Array(E.buffer),R={i0:0,i1:E.length,bst:null,est:null,tdst:0,left:null,right:null};R.bst=_(E,R.i0,R.i1),R.est=x(R.bst);const D=[R];for(;D.length<T;){let P=0,C=0;for(var O=0;O<D.length;O++)D[O].est.L>P&&(P=D[O].est.L,C=O);if(P<N)break;const M=D[C],U=k(E,I,M.i0,M.i1,M.est.e,M.est.eMq255);if(M.i0>=U||M.i1<=U){M.est.L=0;continue}const L={i0:M.i0,i1:U,bst:null,est:null,tdst:0,left:null,right:null};L.bst=_(E,L.i0,L.i1),L.est=x(L.bst);const F={i0:U,i1:M.i1,bst:null,est:null,tdst:0,left:null,right:null};for(F.bst={R:[],m:[],N:M.bst.N-L.bst.N},O=0;O<16;O++)F.bst.R[O]=M.bst.R[O]-L.bst.R[O];for(O=0;O<4;O++)F.bst.m[O]=M.bst.m[O]-L.bst.m[O];F.est=x(F.bst),M.left=L,M.right=F,D[C]=L,D.push(F)}for(D.sort(((P,C)=>C.bst.N-P.bst.N)),O=0;O<D.length;O++)D[O].ind=O;return[R,D]}function b(E,T,N,I,R){if(E.left==null)return E.tdst=(function(L,F,V,W,H){const B=F-L[0],$=V-L[1],K=W-L[2],Y=H-L[3];return B*B+$*$+K*K+Y*Y})(E.est.q,T,N,I,R),E;const D=S(E.est,T,N,I,R);let O=E.left,P=E.right;D>0&&(O=E.right,P=E.left);const C=b(O,T,N,I,R);if(C.tdst<=D*D)return C;const M=b(P,T,N,I,R);return M.tdst<C.tdst?M:C}function S(E,T,N,I,R){const{e:D}=E;return D[0]*T+D[1]*N+D[2]*I+D[3]*R-E.eMq}function k(E,T,N,I,R,D){for(I-=4;N<I;){for(;v(E,N,R)<=D;)N+=4;for(;v(E,I,R)>D;)I-=4;if(N>=I)break;const O=T[N>>2];T[N>>2]=T[I>>2],T[I>>2]=O,N+=4,I-=4}for(;v(E,N,R)>D;)N-=4;return N+4}function v(E,T,N){return E[T]*N[0]+E[T+1]*N[1]+E[T+2]*N[2]+E[T+3]*N[3]}function _(E,T,N){const I=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],R=[0,0,0,0],D=N-T>>2;for(let O=T;O<N;O+=4){const P=E[O]*.00392156862745098,C=E[O+1]*(1/255),M=E[O+2]*(1/255),U=E[O+3]*(1/255);R[0]+=P,R[1]+=C,R[2]+=M,R[3]+=U,I[0]+=P*P,I[1]+=P*C,I[2]+=P*M,I[3]+=P*U,I[5]+=C*C,I[6]+=C*M,I[7]+=C*U,I[10]+=M*M,I[11]+=M*U,I[15]+=U*U}return I[4]=I[1],I[8]=I[2],I[9]=I[6],I[12]=I[3],I[13]=I[7],I[14]=I[11],{R:I,m:R,N:D}}function x(E){const{R:T}=E,{m:N}=E,{N:I}=E,R=N[0],D=N[1],O=N[2],P=N[3],C=I==0?0:1/I,M=[T[0]-R*R*C,T[1]-R*D*C,T[2]-R*O*C,T[3]-R*P*C,T[4]-D*R*C,T[5]-D*D*C,T[6]-D*O*C,T[7]-D*P*C,T[8]-O*R*C,T[9]-O*D*C,T[10]-O*O*C,T[11]-O*P*C,T[12]-P*R*C,T[13]-P*D*C,T[14]-P*O*C,T[15]-P*P*C],U=M,L=A;let F=[Math.random(),Math.random(),Math.random(),Math.random()],V=0,W=0;if(I!=0)for(let B=0;B<16&&(F=L.multVec(U,F),W=Math.sqrt(L.dot(F,F)),F=L.sml(1/W,F),!(B!=0&&Math.abs(W-V)<1e-9));B++)V=W;const H=[R*C,D*C,O*C,P*C];return{Cov:M,q:H,e:F,L:V,eMq255:L.dot(L.sml(255,H),F),eMq:L.dot(F,H),rgba:(Math.round(255*H[3])<<24|Math.round(255*H[2])<<16|Math.round(255*H[1])<<8|Math.round(255*H[0])<<0)>>>0}}var A={multVec:(E,T)=>[E[0]*T[0]+E[1]*T[1]+E[2]*T[2]+E[3]*T[3],E[4]*T[0]+E[5]*T[1]+E[6]*T[2]+E[7]*T[3],E[8]*T[0]+E[9]*T[1]+E[10]*T[2]+E[11]*T[3],E[12]*T[0]+E[13]*T[1]+E[14]*T[2]+E[15]*T[3]],dot:(E,T)=>E[0]*T[0]+E[1]*T[1]+E[2]*T[2]+E[3]*T[3],sml:(E,T)=>[E*T[0],E*T[1],E*T[2],E*T[3]]};gr.encode=function(T,N,I,R,D,O,P){R==null&&(R=0),P==null&&(P=!1);const C=u(T,N,I,R,[!1,!1,!1,0,P,!1]);return c(C,-1),l(C,N,I,D,O)},gr.encodeLL=function(T,N,I,R,D,O,P,C){const M={ctype:0+(R==1?0:2)+(D==0?0:4),depth:O,frames:[]},U=(R+D)*O,L=U*N;for(let F=0;F<T.length;F++)M.frames.push({rect:{x:0,y:0,width:N,height:I},img:new Uint8Array(T[F]),blend:0,dispose:1,bpp:Math.ceil(U/8),bpl:Math.ceil(L/8)});return c(M,0,!0),l(M,N,I,P,C)},gr.encode.compress=u,gr.encode.dither=a,gr.quantize=m,gr.quantize.getKDtree=g,gr.quantize.getNearest=b})();const IO={toArrayBuffer(t,e){const n=t.width,r=t.height,o=n<<2,s=t.getContext("2d").getImageData(0,0,n,r),i=new Uint32Array(s.data.buffer),a=(32*n+31)/32<<2,l=a*r,c=122+l,u=new ArrayBuffer(c),d=new DataView(u),f=1<<20;let h,p,m,g,b=f,S=0,k=0,v=0;function _(E){d.setUint16(k,E,!0),k+=2}function x(E){d.setUint32(k,E,!0),k+=4}function A(E){k+=E}_(19778),x(c),A(4),x(122),x(108),x(n),x(-r>>>0),_(1),_(32),x(3),x(l),x(2835),x(2835),A(8),x(16711680),x(65280),x(255),x(4278190080),x(1466527264),(function E(){for(;S<r&&b>0;){for(g=122+S*a,h=0;h<o;)b--,p=i[v++],m=p>>>24,d.setUint32(g+h,p<<8|m),h+=4;S++}v<i.length?(b=f,setTimeout(E,IO._dly)):e(u)})()},toBlob(t,e){this.toArrayBuffer(t,(n=>{e(new Blob([n],{type:"image/bmp"}))}))},_dly:9};var On={CHROME:"CHROME",FIREFOX:"FIREFOX",DESKTOP_SAFARI:"DESKTOP_SAFARI",IE:"IE",IOS:"IOS",ETC:"ETC"},XY={[On.CHROME]:16384,[On.FIREFOX]:11180,[On.DESKTOP_SAFARI]:16384,[On.IE]:8192,[On.IOS]:4096,[On.ETC]:8192};const Yb=typeof window<"u",DO=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,Dd=Yb&&window.cordova&&window.cordova.require&&window.cordova.require("cordova/modulemapper"),QY=(Yb||DO)&&(Dd&&Dd.getOriginalSymbol(window,"File")||typeof File<"u"&&File),PO=(Yb||DO)&&(Dd&&Dd.getOriginalSymbol(window,"FileReader")||typeof FileReader<"u"&&FileReader);function Jb(t,e,n=Date.now()){return new Promise((r=>{const o=t.split(","),s=o[0].match(/:(.*?);/)[1],i=globalThis.atob(o[1]);let a=i.length;const l=new Uint8Array(a);for(;a--;)l[a]=i.charCodeAt(a);const c=new Blob([l],{type:s});c.name=e,c.lastModified=n,r(c)}))}function LO(t){return new Promise(((e,n)=>{const r=new PO;r.onload=()=>e(r.result),r.onerror=o=>n(o),r.readAsDataURL(t)}))}function jO(t){return new Promise(((e,n)=>{const r=new Image;r.onload=()=>e(r),r.onerror=o=>n(o),r.src=t}))}function Vs(){if(Vs.cachedResult!==void 0)return Vs.cachedResult;let t=On.ETC;const{userAgent:e}=navigator;return/Chrom(e|ium)/i.test(e)?t=On.CHROME:/iP(ad|od|hone)/i.test(e)&&/WebKit/i.test(e)?t=On.IOS:/Safari/i.test(e)?t=On.DESKTOP_SAFARI:/Firefox/i.test(e)?t=On.FIREFOX:(/MSIE/i.test(e)||document.documentMode)&&(t=On.IE),Vs.cachedResult=t,Vs.cachedResult}function $O(t,e){const n=Vs(),r=XY[n];let o=t,s=e,i=o*s;const a=o>s?s/o:o/s;for(;i>r*r;){const l=(r+o)/2,c=(r+s)/2;l<c?(s=c,o=c*a):(s=l*a,o=l),i=o*s}return{width:o,height:s}}function _h(t,e){let n,r;try{if(n=new OffscreenCanvas(t,e),r=n.getContext("2d"),r===null)throw new Error("getContext of OffscreenCanvas returns null")}catch{n=document.createElement("canvas"),r=n.getContext("2d")}return n.width=t,n.height=e,[n,r]}function FO(t,e){const{width:n,height:r}=$O(t.width,t.height),[o,s]=_h(n,r);return e&&/jpe?g/.test(e)&&(s.fillStyle="white",s.fillRect(0,0,o.width,o.height)),s.drawImage(t,0,0,o.width,o.height),o}function zu(){return zu.cachedResult!==void 0||(zu.cachedResult=["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&typeof document<"u"&&"ontouchend"in document),zu.cachedResult}function Pd(t,e={}){return new Promise((function(n,r){let o,s;var i=function(){try{return s=FO(o,e.fileType||t.type),n([o,s])}catch(l){return r(l)}},a=function(l){try{var c=function(u){try{throw u}catch(d){return r(d)}};try{let u;return LO(t).then((function(d){try{return u=d,jO(u).then((function(f){try{return o=f,(function(){try{return i()}catch(h){return r(h)}})()}catch(h){return c(h)}}),c)}catch(f){return c(f)}}),c)}catch(u){c(u)}}catch(u){return r(u)}};try{if(zu()||[On.DESKTOP_SAFARI,On.MOBILE_SAFARI].includes(Vs()))throw new Error("Skip createImageBitmap on IOS and Safari");return createImageBitmap(t).then((function(l){try{return o=l,i()}catch{return a()}}),a)}catch{a()}}))}function Ld(t,e,n,r,o=1){return new Promise((function(s,i){let a;if(e==="image/png"){let c,u,d;return c=t.getContext("2d"),{data:u}=c.getImageData(0,0,t.width,t.height),d=gr.encode([u.buffer],t.width,t.height,4096*o),a=new Blob([d],{type:e}),a.name=n,a.lastModified=r,l.call(this)}{let c=function(){return l.call(this)};if(e==="image/bmp")return new Promise((u=>IO.toBlob(t,u))).then((function(u){try{return a=u,a.name=n,a.lastModified=r,c.call(this)}catch(d){return i(d)}}).bind(this),i);{let u=function(){return c.call(this)};if(typeof OffscreenCanvas=="function"&&t instanceof OffscreenCanvas)return t.convertToBlob({type:e,quality:o}).then((function(d){try{return a=d,a.name=n,a.lastModified=r,u.call(this)}catch(f){return i(f)}}).bind(this),i);{let d;return d=t.toDataURL(e,o),Jb(d,n,r).then((function(f){try{return a=f,u.call(this)}catch(h){return i(h)}}).bind(this),i)}}}function l(){return s(a)}}))}function Kr(t){t.width=0,t.height=0}function Vi(){return new Promise((function(t,e){let n,r,o,s;return Vi.cachedResult!==void 0?t(Vi.cachedResult):Jb("data:image/jpeg;base64,/9j/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAYAAAAAAAD/2wCEAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAf/AABEIAAEAAgMBEQACEQEDEQH/xABKAAEAAAAAAAAAAAAAAAAAAAALEAEAAAAAAAAAAAAAAAAAAAAAAQEAAAAAAAAAAAAAAAAAAAAAEQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIRAxEAPwA/8H//2Q==","test.jpg",Date.now()).then((function(i){try{return n=i,Pd(n).then((function(a){try{return r=a[1],Ld(r,n.type,n.name,n.lastModified).then((function(l){try{return o=l,Kr(r),Pd(o).then((function(c){try{return s=c[0],Vi.cachedResult=s.width===1&&s.height===2,t(Vi.cachedResult)}catch(u){return e(u)}}),e)}catch(c){return e(c)}}),e)}catch(l){return e(l)}}),e)}catch(a){return e(a)}}),e)}))}function UO(t){return new Promise(((e,n)=>{const r=new PO;r.onload=o=>{const s=new DataView(o.target.result);if(s.getUint16(0,!1)!=65496)return e(-2);const i=s.byteLength;let a=2;for(;a<i;){if(s.getUint16(a+2,!1)<=8)return e(-1);const l=s.getUint16(a,!1);if(a+=2,l==65505){if(s.getUint32(a+=2,!1)!=1165519206)return e(-1);const c=s.getUint16(a+=6,!1)==18761;a+=s.getUint32(a+4,c);const u=s.getUint16(a,c);a+=2;for(let d=0;d<u;d++)if(s.getUint16(a+12*d,c)==274)return e(s.getUint16(a+12*d+8,c))}else{if((65280&l)!=65280)break;a+=s.getUint16(a,!1)}}return e(-1)},r.onerror=o=>n(o),r.readAsArrayBuffer(t)}))}function BO(t,e){const{width:n}=t,{height:r}=t,{maxWidthOrHeight:o}=e;let s,i=t;return isFinite(o)&&(n>o||r>o)&&([i,s]=_h(n,r),n>r?(i.width=o,i.height=r/n*o):(i.width=n/r*o,i.height=o),s.drawImage(t,0,0,i.width,i.height),Kr(t)),i}function zO(t,e){const{width:n}=t,{height:r}=t,[o,s]=_h(n,r);switch(e>4&&e<9?(o.width=r,o.height=n):(o.width=n,o.height=r),e){case 2:s.transform(-1,0,0,1,n,0);break;case 3:s.transform(-1,0,0,-1,n,r);break;case 4:s.transform(1,0,0,-1,0,r);break;case 5:s.transform(0,1,1,0,0,0);break;case 6:s.transform(0,1,-1,0,r,0);break;case 7:s.transform(0,-1,-1,0,r,n);break;case 8:s.transform(0,-1,1,0,0,n)}return s.drawImage(t,0,0,n,r),Kr(t),o}function $1(t,e,n=0){return new Promise((function(r,o){let s,i,a,l,c,u,d,f,h,p,m,g,b,S,k,v,_,x,A,E;function T(I=5){if(e.signal&&e.signal.aborted)throw e.signal.reason;s+=I,e.onProgress(Math.min(s,100))}function N(I){if(e.signal&&e.signal.aborted)throw e.signal.reason;s=Math.min(Math.max(I,s),100),e.onProgress(s)}return s=n,i=e.maxIteration||10,a=1024*e.maxSizeMB*1024,T(),Pd(t,e).then((function(I){try{return[,l]=I,T(),c=BO(l,e),T(),new Promise((function(R,D){var O;if(!(O=e.exifOrientation))return UO(t).then((function(C){try{return O=C,P.call(this)}catch(M){return D(M)}}).bind(this),D);function P(){return R(O)}return P.call(this)})).then((function(R){try{return u=R,T(),Vi().then((function(D){try{return d=D?c:zO(c,u),T(),f=e.initialQuality||1,h=e.fileType||t.type,Ld(d,h,t.name,t.lastModified,f).then((function(O){try{{let C=function(){if(i--&&(k>a||k>b)){let U,L;return U=E?.95*A.width:A.width,L=E?.95*A.height:A.height,[_,x]=_h(U,L),x.drawImage(A,0,0,U,L),f*=h==="image/png"?.85:.95,Ld(_,h,t.name,t.lastModified,f).then((function(F){try{return v=F,Kr(A),A=_,k=v.size,N(Math.min(99,Math.floor((S-k)/(S-a)*100))),C}catch(V){return o(V)}}),o)}return[1]},M=function(){return Kr(A),Kr(_),Kr(c),Kr(d),Kr(l),N(100),r(v)};if(p=O,T(),m=p.size>a,g=p.size>t.size,!m&&!g)return N(100),r(p);var P;return b=t.size,S=p.size,k=S,A=d,E=!e.alwaysKeepResolution&&m,(P=(function(U){for(;U;){if(U.then)return void U.then(P,o);try{if(U.pop){if(U.length)return U.pop()?M.call(this):U;U=C}else U=U.call(this)}catch(L){return o(L)}}}).bind(this))(C)}}catch(C){return o(C)}}).bind(this),o)}catch(O){return o(O)}}).bind(this),o)}catch(D){return o(D)}}).bind(this),o)}catch(R){return o(R)}}).bind(this),o)}))}const ZY=`
148
- let scriptImported = false
149
- self.addEventListener('message', async (e) => {
150
- const { file, id, imageCompressionLibUrl, options } = e.data
151
- options.onProgress = (progress) => self.postMessage({ progress, id })
152
- try {
153
- if (!scriptImported) {
154
- // console.log('[worker] importScripts', imageCompressionLibUrl)
155
- self.importScripts(imageCompressionLibUrl)
156
- scriptImported = true
157
- }
158
- // console.log('[worker] self', self)
159
- const compressedFile = await imageCompression(file, options)
160
- self.postMessage({ file: compressedFile, id })
161
- } catch (e) {
162
- // console.error('[worker] error', e)
163
- self.postMessage({ error: e.message + '\\n' + e.stack, id })
164
- }
165
- })
166
- `;let Kp;function eJ(t,e){return new Promise(((n,r)=>{Kp||(Kp=(function(i){const a=[];return a.push(i),URL.createObjectURL(new Blob(a))})(ZY));const o=new Worker(Kp);o.addEventListener("message",(function(i){if(e.signal&&e.signal.aborted)o.terminate();else if(i.data.progress===void 0){if(i.data.error)return r(new Error(i.data.error)),void o.terminate();n(i.data.file),o.terminate()}else e.onProgress(i.data.progress)})),o.addEventListener("error",r),e.signal&&e.signal.addEventListener("abort",(()=>{r(e.signal.reason),o.terminate()})),o.postMessage({file:t,imageCompressionLibUrl:e.libURL,options:{...e,onProgress:void 0,signal:void 0}})}))}function Yt(t,e){return new Promise((function(n,r){let o,s,i,a,l,c;if(o={...e},i=0,{onProgress:a}=o,o.maxSizeMB=o.maxSizeMB||Number.POSITIVE_INFINITY,l=typeof o.useWebWorker!="boolean"||o.useWebWorker,delete o.useWebWorker,o.onProgress=h=>{i=h,typeof a=="function"&&a(i)},!(t instanceof Blob||t instanceof QY))return r(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(t.type))return r(new Error("The file given is not an image"));if(c=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,!l||typeof Worker!="function"||c)return $1(t,o).then((function(h){try{return s=h,f.call(this)}catch(p){return r(p)}}).bind(this),r);var u=(function(){try{return f.call(this)}catch(h){return r(h)}}).bind(this),d=function(h){try{return $1(t,o).then((function(p){try{return s=p,u()}catch(m){return r(m)}}),r)}catch(p){return r(p)}};try{return o.libURL=o.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.2/dist/browser-image-compression.js",eJ(t,o).then((function(h){try{return s=h,u()}catch{return d()}}),d)}catch{d()}function f(){try{s.name=t.name,s.lastModified=t.lastModified}catch{}try{o.preserveExif&&t.type==="image/jpeg"&&(!o.fileType||o.fileType&&o.fileType===t.type)&&(s=NO(t,s))}catch{}return n(s)}}))}Yt.getDataUrlFromFile=LO,Yt.getFilefromDataUrl=Jb,Yt.loadImage=jO,Yt.drawImageInCanvas=FO,Yt.drawFileInCanvas=Pd,Yt.canvasToFile=Ld,Yt.getExifOrientation=UO,Yt.handleMaxWidthOrHeight=BO,Yt.followExifOrientation=zO,Yt.cleanupCanvasMemory=Kr,Yt.isAutoOrientationInBrowser=Vi,Yt.approximateBelowMaximumCanvasSizeOfBrowser=$O,Yt.copyExifWithoutOrientation=NO,Yt.getBrowserName=Vs,Yt.version="2.0.2";const tJ=j.lazy(()=>Promise.resolve().then(()=>fZ).then(t=>({default:t.ImageSearchModal}))),nJ=j.lazy(()=>Promise.resolve().then(()=>require("./voice-recording-overlay-B_bP08If.js")).then(t=>({default:t.VoiceRecordingOverlay}))),rJ=j.lazy(()=>Promise.resolve().then(()=>HZ).then(t=>({default:t.LinkDecoratorModal}))),oJ={[Pe.Blog]:{showFormatting:!0,showImage:!0,showVideo:!0,showAudio:!0,showImageSearch:!0,showLink:!0},[Pe.Media]:{showFormatting:!1,showImage:!0,showVideo:!0,showAudio:!1,showImageSearch:!0,showLink:!0},[Pe.Poll]:{}},sJ=500,iJ=({actions:t,editorType:e,children:n,isSubmitting:r,onSubmit:o,placement:s,onVoiceComment:i,onVoiceRecord:a,onQuickGif:l,hideSubmitButton:c})=>{const u=j.useRef(null),[d,f]=j.useState(null),[h,p]=j.useState(!1),[m,g]=j.useState(!1),[b,S]=j.useState(!1),{editor:k}=Sh(),v=MY(k),{showCrossMentionIndicator:_}=RY(k,{debounceMs:150}),{trackFeature:x}=Cs(),{t:A,allowSendWhileUploading:E,unauthenticatedMode:T}=kn(),{fileStore:N}=wi(),{isRecording:I,duration:R,volume:D,startRecording:O,stopRecording:P,cancelRecording:C}=KY({maxDuration:60}),[M,U]=j.useState(!1),L=IY(k),F=s===Mo.Comment&&!!i&&v?.isEmpty&&!r&&!I&&!T,V=async()=>{try{await O()}catch{Zt.error("Could not access microphone. Please check your browser permissions.")}},W=async()=>{if(I)try{const{blob:pe,duration:Ne}=await P();if(E&&a){a({blob:pe,voiceTime:Ne});return}U(!0);const Ie=pe.type.split("/")[1]?.split(";")[0]??"webm",Ve=new File([pe],`${Dt()}.${Ie}`),vt=await N.uploadVoiceV2(Ve);vt?.url&&i?.({voiceUrl:vt.url,voiceTime:Ne})}catch{}finally{U(!1)}},H=()=>{C()},B=j.useRef(null),$=j.useRef(!1),K=j.useRef(!1),[Y,J]=j.useState(!1),Q=()=>{if(!k)return!1;const pe=k.getJSON(),Ne=Gn(pe,"media"),Ie=Gn(pe,"mediaGroup");return Ne.length>0||Ie.length>0},ne=()=>!!l&&!I&&!!k&&k.getText().trim().length>0&&!Q()&&!T,se=()=>{B.current&&(clearTimeout(B.current),B.current=null)},te=()=>{se(),$.current=!1,J(!1)},ge=()=>{K.current=!1,$.current=!1,ne()&&(B.current=setTimeout(()=>{$.current=!0,J(!0)},sJ))},he=()=>{if(se(),$.current){$.current=!1,J(!1);const pe=k?.getText().trim()??"";pe&&l&&(K.current=!0,l({text:pe,sendCrossMention:b}))}},xe=()=>{te()};if(!k)return null;const Ee=oJ[e],Se=pe=>{if(v?.isLink){k.chain().focus().unsetLink().run(),pe.preventDefault();return}p(!0)},_e=(pe,Ne,Ie,Ve)=>{const vt=e===Pe.Blog&&Ne||pe;if(Ie){k.commands.updateLink(Ie,{href:pe,text:vt,previewPayload:Ve});return}k.commands.insertLink({href:pe,text:vt,previewPayload:Ve})},Me=()=>{const pe=k.getJSON();return Gn(pe,"media").length>=10?(Zt.error(`You can upload up to ${Er} files per post. Please remove some files before adding new ones.`),!0):!1},Ke=()=>{if(e!==Pe.Media){u?.current?.click();return}Me()||u?.current?.click()},Ge=async pe=>{const Ne=pe.target.files;if(!Ne||!d)return;let Ie=Array.from(Ne);Ie.length>Er&&(Zt.error(`You can upload up to ${Er} files per post. Picking the first ${Er} files`),Ie=Ie.slice(0,Er));const Ve=pl,vt=Ve/(1024*1024),tt=Ie.filter(et=>et.size>Ve);if(tt.length>0){const et=tt.map(qe=>qe.name).join(", ");if(Zt.error(`${tt.length>1?"Some files exceed":`"${et}" exceeds`} the ${vt}MB limit`),Ie=Ie.filter(qe=>qe.size<=Ve),Ie.length===0){pe.target.value="";return}}d===ue.Image&&(Ie=await Promise.all(Ie.map(async et=>{try{return await Yt(et,{maxSizeMB:10})}catch{return et}}))),Ie.forEach(et=>{let qe=d;et.type.startsWith("image/")?qe=ue.Image:et.type.startsWith("video/")?qe=ue.Video:et.type.startsWith("audio/")&&(qe=ue.Audio),k.commands.insertMediaWithUpload({source:et,type:qe,mediaType:Vn.MEDIA_ITEM})}),pe.target.value=""},Be=pe=>{if(Me()){pe.preventDefault();return}g(!0)},je=(pe,Ne)=>{Ne&&x(Ne===Yr.Gif?"gif_search":"image_search"),k?.commands.insertMediaWithUpload({source:pe,type:ue.Image,mediaType:Vn.IMAGE_ITEM,searchFrom:Ne})},$e=pe=>pe?.isHeading1?l1:pe?.isHeading2?c1:pe?.isHeading3?u1:wg;return y.jsxs("div",{className:"flex flex-col grow overflow-y-auto",children:[Ee.showFormatting&&y.jsxs("div",{className:"shrink-0 flex flex-wrap items-center gap-2 sm:gap-2 p-2",children:[y.jsx(He,{id:At.undo,icon:$9,tooltip:"undoKey",onClick:t?.undo,disabled:!v?.canUndo}),y.jsx(He,{id:At.redo,icon:E9,tooltip:"redoKey",onClick:t?.redo,disabled:!v?.canRedo}),y.jsxs(I1,{children:[y.jsx(D1,{asChild:!0,children:y.jsx(He,{tooltip:"headingOptionsKey",icon:$e(v),"aria-label":"More formatting options"})}),y.jsx(P1,{align:"start",className:"w-44 px-1 py-1",children:y.jsxs("div",{className:"flex flex-col items-stretch gap-1",children:[y.jsx(mo,{asChild:!0,children:y.jsxs(He,{id:At.paragraph,className:"w-full justify-start",tooltip:"paragraphKey",onClick:t?.setParagraph,active:v?.isParagraph,disabled:!v?.canParagraph,children:[y.jsx(wg,{})," ",A("paragraphKey")]})}),y.jsx(mo,{asChild:!0,children:y.jsxs(He,{id:Cp[1],className:"w-full justify-start",tooltip:"heading1Key",onClick:()=>t?.toggleHeading(1),active:v?.isHeading1,disabled:!v?.canHeading1,children:[y.jsx(l1,{})," ",A("heading1Key")]})}),y.jsx(mo,{asChild:!0,children:y.jsxs(He,{id:Cp[2],className:"w-full justify-start",tooltip:"heading2Key",onClick:()=>t?.toggleHeading(2),active:v?.isHeading2,disabled:!v?.canHeading2,children:[y.jsx(c1,{})," ",A("heading2Key")]})}),y.jsx(mo,{asChild:!0,children:y.jsxs(He,{id:Cp[3],className:"w-full justify-start",tooltip:"heading3Key",onClick:()=>t?.toggleHeading(3),active:v?.isHeading3,disabled:!v?.canHeading3,children:[y.jsx(u1,{})," ",A("heading3Key")]})})]})})]}),y.jsx(Ga,{}),y.jsx(He,{id:At.bold,icon:UK,tooltip:"boldKey",onClick:t?.toggleBold,active:v?.isBold,disabled:!v?.canBold}),y.jsxs("div",{className:"hidden xl:flex items-center gap-2",children:[y.jsx(He,{id:At.italic,icon:d1,tooltip:"italicKey",onClick:t?.toggleItalic,active:v?.isItalic,disabled:!v?.canItalic}),y.jsx(He,{id:At.strike,icon:h1,tooltip:"strikethroughKey",onClick:t?.toggleStrikethrough,active:v?.isStrike,disabled:!v?.canStrike})]}),y.jsx(Ga,{}),y.jsx(He,{id:At.bulletList,icon:h9,tooltip:"bulletListKey",onClick:t?.toggleBulletList,active:v?.isBulletList,disabled:!v?.canBulletList}),y.jsx(He,{id:At.orderedList,icon:d9,tooltip:"orderedListKey",onClick:t?.toggleOrderedList,active:v?.isOrderedList,disabled:!v?.canOrderedList}),y.jsx(Ga,{}),y.jsxs("div",{className:"hidden xl:flex flex-wrap items-center gap-2",children:[y.jsx(He,{id:At.blockquote,icon:p1,tooltip:"blockquoteKey",onClick:t?.toggleBlockquote,active:v?.isBlockquote,disabled:!v?.canBlockquote}),y.jsx(He,{id:At.code,icon:s1,tooltip:"codeKey",onClick:t?.toggleCode,active:v?.isCode,disabled:!v?.canCode}),y.jsx(He,{id:At.codeBlock,icon:i1,tooltip:"codeBlockKey",onClick:t?.toggleCodeBlock,active:v?.isCodeBlock,disabled:!v?.canCodeBlock})]}),y.jsx("div",{className:"flex xl:hidden",children:y.jsxs(I1,{children:[y.jsx(D1,{asChild:!0,children:y.jsx(He,{tooltip:"moreOptionsKey",icon:XK,"aria-label":"More formatting options"})}),y.jsx(P1,{align:"end",className:"w-fit px-2 py-1",children:y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(mo,{asChild:!0,children:y.jsx(He,{id:At.italic,icon:d1,tooltip:"italicKey",onClick:t?.toggleItalic,active:v?.isItalic,disabled:!v?.canItalic})}),y.jsx(mo,{asChild:!0,children:y.jsx(He,{id:At.strike,icon:h1,tooltip:"strikethroughKey",onClick:t?.toggleStrikethrough,active:v?.isStrike,disabled:!v?.canStrike})}),y.jsx(mo,{asChild:!0,children:y.jsx(He,{id:At.blockquote,icon:p1,tooltip:"blockquoteKey",onClick:t?.toggleBlockquote,active:v?.isBlockquote,disabled:!v?.canBlockquote})}),y.jsx(mo,{asChild:!0,children:y.jsx(He,{id:At.code,icon:s1,tooltip:"codeKey",onClick:t?.toggleCode,active:v?.isCode,disabled:!v?.canCode})}),y.jsx(mo,{asChild:!0,children:y.jsx(He,{id:At.codeBlock,icon:i1,tooltip:"codeBlockKey",onClick:t?.toggleCodeBlock,active:v?.isCodeBlock,disabled:!v?.canCodeBlock})})]})})]})})]}),y.jsxs("div",{className:"relative grow flex flex-col overflow-y-auto",children:[I&&y.jsx(j.Suspense,{fallback:null,children:y.jsx(nJ,{isRecording:I,duration:R,volume:D})}),n]}),_&&y.jsxs("div",{className:"sm:hidden flex flex-col gap-1 px-2",children:[y.jsxs("div",{className:"flex items-center space-x-2",children:[y.jsx(L1,{id:"send-cross-mention",checked:b,onCheckedChange:S}),y.jsxs(Tg,{htmlFor:"send-cross-mention",className:"text-xs",children:["Cross-post to groups you #mention? ",y.jsx(a1,{className:"size-4"})]})]}),b&&y.jsx("span",{className:"text-xs text-muted-foreground",children:A("crossPostLimitKey")})]}),y.jsxs("div",{className:oe("shrink-0 flex items-center sm:gap-2 p-2 border-t",c&&!Ee.showImage&&!Ee.showVideo&&!Ee.showImageSearch&&!Ee.showLink&&"hidden"),children:[y.jsx("input",{ref:u,type:"file",multiple:!0,maxLength:2,accept:`${O0[ue.Image]}, ${O0[ue.Video]}`,hidden:!0,onChange:Ge}),Ee.showImage&&y.jsx(He,{id:At.image,icon:Y_,tooltip:"insertImageKey",disabled:I||!v?.canInsertImage,onMouseOver:()=>f(ue.Image),onClick:Ke}),Ee.showVideo&&y.jsx(He,{id:At.video,icon:Rb,disabled:I||!v?.canInsertVideo,tooltip:"insertVideoKey",onMouseOver:()=>f(ue.Video),onClick:Ke}),Ee.showAudio&&y.jsx(He,{id:At.audio,icon:_d,disabled:I||!v?.canInsertAudio,tooltip:"insertAudioKey",onMouseOver:()=>f(ue.Audio),onClick:Ke}),Ee.showImageSearch&&!T&&y.jsxs(y.Fragment,{children:[y.jsx(He,{onClick:Be,disabled:I||!v?.canInsertImage,icon:yG,tooltip:"searchGifOrImagesKey",className:"p-1 [&>svg]:size-5!"}),m&&y.jsx(j.Suspense,{fallback:null,children:y.jsx(tJ,{open:m,onOpenChange:g,onImageSelect:je,initialQuery:RO(k)})})]}),Ee.showLink&&y.jsxs(y.Fragment,{children:[y.jsx(Ga,{}),y.jsx(He,{id:At.customLink,icon:J_,tooltip:"addLinkPreviewKey",onClick:Se,active:v?.isLink,disabled:I||!v?.canLink}),h&&y.jsx(j.Suspense,{fallback:null,children:y.jsx(rJ,{hideTextInput:!0,open:h,onOpenChange:p,onInsertLink:_e})})]}),_&&y.jsxs(y.Fragment,{children:[y.jsx(Ga,{}),y.jsxs("div",{className:"hidden sm:flex flex-col gap-1 px-2",children:[y.jsxs("div",{className:"flex items-center space-x-2",children:[y.jsx(L1,{id:"send-cross-mention",checked:b,onCheckedChange:S}),y.jsxs(Tg,{htmlFor:"send-cross-mention",children:[A("crossPostKey")," ",y.jsx(a1,{})]})]}),b&&y.jsx("span",{className:"text-xs text-muted-foreground",children:A("crossPostLimitKey")})]})]}),I?y.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[y.jsx(zt,{variant:"outline",onClick:H,className:"cursor-pointer active:scale-95",children:y.jsx(co,{})}),y.jsx(zt,{onClick:()=>{W()},disabled:M,className:oe("cursor-pointer bg-primary-send text-primary-send-fg hover:bg-primary-send/85 active:scale-95"),children:M?y.jsx(ms,{}):y.jsx(f1,{})})]}):F?y.jsx(zt,{onClick:()=>{V()},disabled:M,className:oe("cursor-pointer bg-primary-send text-primary-send-fg hover:bg-primary-send/85 active:scale-95 w-fit ml-auto"),children:M?y.jsx(ms,{}):y.jsx(y9,{})}):c?null:y.jsxs(wM,{children:[y.jsx($b,{asChild:!0,children:y.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[Y&&y.jsx("span",{className:"text-xs text-muted-foreground px-2","data-testid":"quick-gif-generating",children:A("quickGifGeneratingKey")}),y.jsxs(zt,{disabled:v?.isEmpty||r||!E&&L,onPointerDown:ge,onPointerUp:he,onPointerLeave:xe,onPointerCancel:xe,onClick:pe=>{if(K.current){K.current=!1,pe.preventDefault();return}o(b)},className:oe("cursor-pointer bg-primary-send text-primary-send-fg hover:bg-primary-send/85 active:scale-95 w-fit",(!E&&L||r)&&"pointer-events-none"),children:[A("postKey")," ",r?y.jsx(ms,{}):y.jsx(f1,{})]})]})}),y.jsx(Fb,{side:"top",hidden:!L||E,children:A("uploadsInProgressKey")})]})]})]})},Ga=()=>y.jsx("div",{className:"h-3 w-px bg-border"});function aJ(t){const e=lJ(t),n=w.forwardRef((r,o)=>{const{children:s,...i}=r,a=w.Children.toArray(s),l=a.find(uJ);if(l){const c=l.props.children,u=a.map(d=>d===l?w.Children.count(c)>1?w.Children.only(null):w.isValidElement(c)?c.props.children:null:d);return y.jsx(e,{...i,ref:o,children:w.isValidElement(c)?w.cloneElement(c,void 0,u):null})}return y.jsx(e,{...i,ref:o,children:s})});return n.displayName=`${t}.Slot`,n}function lJ(t){const e=w.forwardRef((n,r)=>{const{children:o,...s}=n;if(w.isValidElement(o)){const i=fJ(o),a=dJ(s,o.props);return o.type!==w.Fragment&&(a.ref=r?ao(r,i):i),w.cloneElement(o,a)}return w.Children.count(o)>1?w.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var cJ=Symbol("radix.slottable");function uJ(t){return w.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===cJ}function dJ(t,e){const n={...e};for(const r in e){const o=t[r],s=e[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{const l=s(...a);return o(...a),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...t,...n}}function fJ(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Mh="Dialog",[HO]=Pr(Mh),[hJ,jr]=HO(Mh),VO=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=t,a=w.useRef(null),l=w.useRef(null),[c,u]=Ro({prop:r,defaultProp:o??!1,onChange:s,caller:Mh});return y.jsx(hJ,{scope:e,triggerRef:a,contentRef:l,contentId:sr(),titleId:sr(),descriptionId:sr(),open:c,onOpenChange:u,onOpenToggle:w.useCallback(()=>u(d=>!d),[u]),modal:i,children:n})};VO.displayName=Mh;var WO="DialogTrigger",KO=w.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=jr(WO,n),s=Ze(e,o.triggerRef);return y.jsx(Oe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Zb(o.open),...r,ref:s,onClick:ae(t.onClick,o.onOpenToggle)})});KO.displayName=WO;var Xb="DialogPortal",[pJ,GO]=HO(Xb,{forceMount:void 0}),qO=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:o}=t,s=jr(Xb,e);return y.jsx(pJ,{scope:e,forceMount:n,children:w.Children.map(r,i=>y.jsx(Jn,{present:n||s.open,children:y.jsx(Ia,{asChild:!0,container:o,children:i})}))})};qO.displayName=Xb;var jd="DialogOverlay",YO=w.forwardRef((t,e)=>{const n=GO(jd,t.__scopeDialog),{forceMount:r=n.forceMount,...o}=t,s=jr(jd,t.__scopeDialog);return s.modal?y.jsx(Jn,{present:r||s.open,children:y.jsx(gJ,{...o,ref:e})}):null});YO.displayName=jd;var mJ=aJ("DialogOverlay.RemoveScroll"),gJ=w.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=jr(jd,n);return y.jsx(Oc,{as:mJ,allowPinchZoom:!0,shards:[o.contentRef],children:y.jsx(Oe.div,{"data-state":Zb(o.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),hi="DialogContent",JO=w.forwardRef((t,e)=>{const n=GO(hi,t.__scopeDialog),{forceMount:r=n.forceMount,...o}=t,s=jr(hi,t.__scopeDialog);return y.jsx(Jn,{present:r||s.open,children:s.modal?y.jsx(yJ,{...o,ref:e}):y.jsx(bJ,{...o,ref:e})})});JO.displayName=hi;var yJ=w.forwardRef((t,e)=>{const n=jr(hi,t.__scopeDialog),r=w.useRef(null),o=Ze(e,n.contentRef,r);return w.useEffect(()=>{const s=r.current;if(s)return ph(s)},[]),y.jsx(XO,{...t,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ae(t.onCloseAutoFocus,s=>{s.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:ae(t.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:ae(t.onFocusOutside,s=>s.preventDefault())})}),bJ=w.forwardRef((t,e)=>{const n=jr(hi,t.__scopeDialog),r=w.useRef(!1),o=w.useRef(!1);return y.jsx(XO,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{t.onCloseAutoFocus?.(s),s.defaultPrevented||(r.current||n.triggerRef.current?.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{t.onInteractOutside?.(s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;n.triggerRef.current?.contains(i)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),XO=w.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=t,a=jr(hi,n),l=w.useRef(null),c=Ze(e,l);return ih(),y.jsxs(y.Fragment,{children:[y.jsx(Ac,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:y.jsx(Oa,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":Zb(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),y.jsxs(y.Fragment,{children:[y.jsx(vJ,{titleId:a.titleId}),y.jsx(xJ,{contentRef:l,descriptionId:a.descriptionId})]})]})}),Qb="DialogTitle",QO=w.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=jr(Qb,n);return y.jsx(Oe.h2,{id:o.titleId,...r,ref:e})});QO.displayName=Qb;var ZO="DialogDescription",eR=w.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=jr(ZO,n);return y.jsx(Oe.p,{id:o.descriptionId,...r,ref:e})});eR.displayName=ZO;var tR="DialogClose",nR=w.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=jr(tR,n);return y.jsx(Oe.button,{type:"button",...r,ref:e,onClick:ae(t.onClick,()=>o.onOpenChange(!1))})});nR.displayName=tR;function Zb(t){return t?"open":"closed"}var rR="DialogTitleWarning",[Ule,oR]=L2(rR,{contentName:hi,titleName:Qb,docsSlug:"dialog"}),vJ=({titleId:t})=>{const e=oR(rR),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
167
-
168
- If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
169
-
170
- For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return w.useEffect(()=>{if(t){const r=document.getElementById(t)}},[n,t]),null},wJ="DialogDescriptionWarning",xJ=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${oR(wJ).contentName}}.`;return w.useEffect(()=>{const o=t.current?.getAttribute("aria-describedby");if(e&&o){const s=document.getElementById(e)}},[r,t,e]),null},sR=VO,EJ=KO,iR=qO,aR=YO,lR=JO,cR=QO,SJ=eR,ev=nR;function Pc({...t}){return y.jsx(sR,{"data-slot":"dialog",...t})}const uR=j.forwardRef((t,e)=>y.jsx(EJ,{ref:e,"data-slot":"dialog-trigger",...t}));function kJ({...t}){return y.jsx(iR,{"data-slot":"dialog-portal",...t})}const dR=j.forwardRef((t,e)=>y.jsx(ev,{ref:e,"data-slot":"dialog-close",...t})),TJ=j.forwardRef(({className:t,...e},n)=>y.jsx(aR,{ref:n,"data-slot":"dialog-overlay",className:oe("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",t),...e})),Lc=j.forwardRef(({className:t,children:e,showCloseButton:n=!0,...r},o)=>y.jsxs(kJ,{children:[y.jsx("div",{"data-theme":"select-post-builder",children:y.jsx(TJ,{className:"z-9999 backdrop-blur-sm"})}),y.jsx("div",{"data-theme":"select-post-builder",children:y.jsxs(lR,{ref:o,"data-slot":"dialog-content","data-theme":"select-post-builder",className:oe("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-99999 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",t),...r,children:[e,n&&y.jsxs(ev,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[y.jsx(co,{}),y.jsx("span",{className:"sr-only",children:"Close"})]})]})})]})),jc=j.forwardRef(({className:t,...e},n)=>y.jsx("div",{ref:n,"data-slot":"dialog-header",className:oe("flex flex-col gap-2 text-center sm:text-left",t),...e})),fR=j.forwardRef(({className:t,...e},n)=>y.jsx("div",{ref:n,"data-slot":"dialog-footer",className:oe("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})),$c=j.forwardRef((t,e)=>y.jsx(cR,{ref:e,"data-slot":"dialog-title",className:oe("text-lg leading-none font-semibold"),...t})),CJ=j.forwardRef(({className:t,...e},n)=>y.jsx(SJ,{ref:n,"data-slot":"dialog-description",className:oe("text-muted-foreground text-sm",t),...e}));var yn=(t=>(t.POST_PUBLISH_ATTEMPTED="select:post_publish_attempted",t.POST_PUBLISH_SUCCESSFUL="select:post_publish_success",t.POST_PUBLISH_FAILED="select:post_publish_failed",t.POST_SESSION_ROTATED="select:post_session_rotated",t.DRAFT_REHYDRATE_REQUEST="select:draft_rehydrate_request",t))(yn||{});const AJ=150;function _J(t,e){return t!==null&&e-t<=AJ?"user":"auto"}function MJ({editor:t,editorType:e,idleTimeout:n=3e5}){const{sessionId:r}=ab(),o=j.useRef(),s=j.useRef(!1),i=ps(),a=j.useCallback(()=>ib(t),[t]),l=j.useCallback(()=>{o.current&&clearTimeout(o.current),!(!t||!r||s.current)&&(o.current=setTimeout(()=>{const u=a();u&&!u.isEmpty&&(i.trackExplicitAbandon(r,{contentLength:u.characterCount,hasUnsavedChanges:u.hasUnsavedChanges,abandonReason:"idle_timeout"}),s.current=!0)},n))},[t,r,n,i,a]),c=j.useCallback(()=>{if(!t||!r)return;const u=a();u&&(u.wordCount>=1||u.mediaCount>0||u.linkCount>0||u?.pollCount>0)&&i.trackContentCreated(r,{editorType:e,wordCount:u.wordCount,mediaCount:u.mediaCount,linkCount:u.linkCount})},[t,r,i,e,a]);j.useEffect(()=>{if(!t||!r)return;let u=null;const d=m=>{!(m.target instanceof Node)||!t.view.dom?.contains(m.target)||(u=performance.now(),i.trackEditorFocus(r,"user"))},f=m=>{m.key==="Tab"&&(u=performance.now())},h=()=>{i.trackEditorFocus(r,_J(u,performance.now())),c(),l()},p=()=>{c(),l()};return document.addEventListener("pointerdown",d,!0),document.addEventListener("keydown",f,!0),t.on("focus",h),t.on("update",p),()=>{document.removeEventListener("pointerdown",d,!0),document.removeEventListener("keydown",f,!0),t.off("focus",h),t.off("update",p)}},[t,r,i,l,c]),j.useEffect(()=>{if(!r)return;const u=()=>{if(s.current)return;const d=a();d&&!d.isEmpty&&(i.trackExplicitAbandon(r,{contentLength:d.characterCount,hasUnsavedChanges:d.hasUnsavedChanges,abandonReason:"navigation"}),s.current=!0)};return window.addEventListener("beforeunload",u),()=>{window.removeEventListener("beforeunload",u),o.current&&clearTimeout(o.current)}},[r,i,a]),j.useEffect(()=>()=>{o.current&&clearTimeout(o.current),i.deleteSession(r)},[i,r])}const OJ=()=>{const{sessionId:t,editorType:e,placement:n}=ab(),r=hs(a=>a.trackPublish),o=hs(a=>a.deleteSession),s=hs(a=>a.createSession),i=j.useRef(new Set);j.useEffect(()=>{if(!t)return;const a=c=>{const{postId:u,postType:d,groupId:f}=c.detail;if(!u||i.current.has(u))return;i.current.add(u),r(t,{status:"success",editorType:e,postId:u,groupId:f,postType:d}),o(t);const h=s(e,n);window.dispatchEvent(new CustomEvent(yn.POST_SESSION_ROTATED,{detail:{newSessionId:h,oldSessionId:t}}))},l=c=>{const{postId:u,postType:d,groupId:f,failureReason:h}=c.detail;if(!u||i.current.has(u))return;i.current.add(u),r(t,{status:"failed",editorType:e,postId:u,groupId:f,postType:d,failureReason:h}),o(t);const p=s(e,n);window.dispatchEvent(new CustomEvent(yn.POST_SESSION_ROTATED,{detail:{newSessionId:p,oldSessionId:t}}))};return window.addEventListener(yn.POST_PUBLISH_SUCCESSFUL,a),window.addEventListener(yn.POST_PUBLISH_FAILED,l),()=>{window.removeEventListener(yn.POST_PUBLISH_SUCCESSFUL,a),window.removeEventListener(yn.POST_PUBLISH_FAILED,l)}},[t,e,n,r,o,s])},cl=(t,e)=>{const n=["shared"];return t&&n.push(t),e&&n.push(e),n.join(":")+"-draft"},Hu=(t,e)=>{const n=["Poll"];return t&&n.push(t),e&&n.push(e),n.join(":")+"-draft"},hR=new Set(["bold","italic","strike","underline","code","superscript","subscript"]),Oh=t=>{if(!t)return"";let e="";const n=r=>{r.type==="text"&&r.text&&(e+=r.text),r.content&&Array.isArray(r.content)&&r.content.forEach(o=>n(o))};return n(t),e.trim()},RJ=t=>{if(!t?.content)return"";const e=t.content.filter(r=>r.type==="paragraph");let n="";return e.forEach(r=>{r.content&&r.content.forEach(o=>{o.type==="text"&&o.text&&(n+=o.text)})}),n.trim()},pR=t=>{if(!t||!t.content)return!0;if(RJ(t))return!1;const n=t.content.find(r=>r.type==="poll");return!(n?.attrs?.choices&&Array.isArray(n.attrs.choices)&&n.attrs.choices.length>0)},NJ=t=>!t||!t.content?!0:!(Oh(t).length>0||t.content.some(o=>o.type==="media"||o.type==="mediaGroup"&&o.content&&o.content.length>0)||t.content.some(o=>o.type==="linkPreview")),IJ=t=>t?.content?t.content.filter(e=>e.type==="paragraph"):[],DJ=t=>{if(!t?.content)return[];const e=[];for(const n of t.content)n.type==="media"?e.push(n):n.type==="mediaGroup"&&n.content&&e.push(...n.content.filter(r=>r.type==="media"));return e},mR=(t,e)=>{const n=r=>{const o=r.content?.map(n);if(r.type==="text"&&r.marks){const s=r.marks.map(i=>i.type==="customLink"?{...i,attrs:{...i.attrs,isLinkMode:e}}:i);return{...r,marks:s,content:o}}return o?{...r,content:o}:r};return n(t)},ul=t=>t.content?{...t,content:t.content.map(e=>{if(e.type==="text"&&e.marks){const n=e.marks.filter(r=>!hR.has(r.type??""));return{...e,marks:n.length>0?n:void 0}}return e.content?ul(e):e})}:t,PJ=t=>{const e=new Set(["linkPreview","media","mediaGroup","embed","image"]);return t.map(n=>n?.content?{...n,content:n.content.map(r=>{if(e.has(r?.type||""))return null;if(r?.type==="text"&&r?.marks){const o=r.marks.filter(s=>{const i=s?.type??"";return i==="link"||i==="customLink"||!hR.has(i)}).map(s=>s.type==="customLink"?{...s,type:"link"}:s);return{...r,marks:o.length>0?o:void 0}}return r}).filter(r=>r!==null)}:n)},gR=(t,e)=>{const n=[];return t.length>0?n.push(...t):n.push({type:"paragraph"}),n.push(e||{type:"poll",attrs:{choices:[]}}),{type:"doc",content:n}},LJ=t=>{if(!t?.content)return{type:"doc",content:[{type:"paragraph"}]};const e=[],n=[];for(const o of t.content)switch(o.type){case"paragraph":e.push(ul(o));break;case"media":n.push(o);break;case"mediaGroup":o.content&&n.push(...o.content.filter(s=>s.type==="media"));break;case"linkPreview":break;case"heading":e.push(ul({...o,type:"paragraph",attrs:void 0}));break;case"blockquote":case"bulletList":case"orderedList":if(o.content){for(const s of o.content)if(s.type==="paragraph")e.push(ul(s));else if(s.type==="listItem"&&s.content)for(const i of s.content)i.type==="paragraph"&&e.push(ul(i))}break;case"codeBlock":o.content&&e.push({type:"paragraph",content:o.content});break}for(e.length===0&&e.push({type:"paragraph"});e.length>1;){const o=e[e.length-1];if(!o.content||o.content.length===0||o.content.every(i=>i.type==="text"&&!i.text?.trim()))e.pop();else break}const r=[...e];return n.length>0&&r.push({type:"mediaGroup",content:n.slice(0,Er)}),mR({type:"doc",content:r},!0)},jJ=t=>{if(!t?.content)return{type:"doc",content:[{type:"paragraph"}]};const e=[];for(const n of t.content)n.type==="mediaGroup"&&n.content?e.push(...n.content.filter(r=>r.type==="media")):n.type==="linkPreview"||e.push(n);return e.length===0&&e.push({type:"paragraph"}),mR({type:"doc",content:e},!1)},yR=(t,e)=>{let n=IJ(t);return n=PJ(n),gR(n,e)},$J=t=>t?.content?t.content.filter(n=>n.type==="paragraph").map(n=>n?.content?{...n,content:n.content.map(r=>r?.type==="text"&&r?.marks?{...r,marks:r.marks.map(o=>o.type==="link"?{...o,type:"customLink"}:o)}:r)}:n):[],FJ=(t,e,n)=>{const r=Hu(e,n),o=localStorage.getItem(r);let s;if(o)try{s=JSON.parse(o).content?.find(c=>c.type==="poll")}catch{}if(!Oh(t)){if(!s||!s.attrs?.choices?.length)localStorage.removeItem(r);else{const l=gR([],s);localStorage.setItem(r,JSON.stringify(l))}return}const a=yR(t,s);localStorage.setItem(r,JSON.stringify(a))},UJ=(t,e,n)=>{const r=cl(e,n),o=localStorage.getItem(r),s=$J(t);if(!Oh({type:"doc",content:s}))return;let a=[],l=null;if(o)try{const d=JSON.parse(o);d.content&&(a=DJ(d),l=d.content.find(f=>f.type==="linkPreview")??null)}catch{}const c=[...s];if(l&&c.push(l),a.length>0&&c.push(...a),c.length===0)return;const u={type:"doc",content:c};localStorage.setItem(r,JSON.stringify(u))},bR=(t,e)=>{const n=j.useCallback(s=>{if(!e||typeof window>"u"||typeof localStorage>"u")return null;if(s===Pe.Poll){const l=Hu(t,e),c=localStorage.getItem(l);if(c)try{return JSON.parse(c)}catch{return null}const u=cl(t,e),d=localStorage.getItem(u);if(d)try{const f=JSON.parse(d);if(Oh(f))return yR(f)}catch{}return null}const i=cl(t,e),a=localStorage.getItem(i);if(!a)return null;try{const l=JSON.parse(a);return s===Pe.Media?LJ(l):s===Pe.Blog?jJ(l):l}catch{return null}},[t,e]),r=j.useCallback((s,i)=>{if(!e||typeof window>"u"||typeof localStorage>"u"||!i)return;const a=i.getJSON(),l=BC(a,c=>!c?.attrs?.uploading&&!c?.attrs?.deferred);if(l)if(s===Pe.Poll){if(pR(l))return;const c=Hu(t,e);localStorage.setItem(c,JSON.stringify(l)),UJ(l,t,e)}else{const c=i.isEmpty,u=cl(t,e),d=!!localStorage.getItem(u);if(!(d||!c)||NJ(l)&&!d)return;localStorage.setItem(u,JSON.stringify(l)),FJ(l,t,e)}},[t,e]),o=j.useCallback(()=>{e&&(typeof window>"u"||typeof localStorage>"u"||(localStorage.removeItem(cl(t,e)),localStorage.removeItem(Hu(t,e))))},[t,e]);return{saveCurrentTabContent:r,getTabContent:n,clearContent:o}},BJ=t=>{const e=t.postId&&t.groupId?"post":t.groupId?"group":"global";return aA((n,r)=>({contextType:e,groupId:t.groupId??null,postId:t.postId??null,selectedGroupId:t.groupId??null,enableGroupSelector:!t.groupId,editor:null,editorTab:null,setEditor:(o,s=null)=>n({editor:o,editorTab:s}),setContext:o=>n({contextType:o,enableGroupSelector:o==="global"}),setGroupId:o=>n({groupId:o,selectedGroupId:o??null,enableGroupSelector:!o}),setPostId:o=>n({postId:o}),selectGroup:o=>n({selectedGroupId:o}),getMentionParams:()=>{const{contextType:o,groupId:s,postId:i,selectedGroupId:a}=r();if(o==="post"&&s&&i)return{groupId:s,postId:i};const l=a||s||void 0;return l?{groupId:l}:null}}))};var $d=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},zJ=/^\s*>\s$/,HJ=Lt.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return $d("blockquote",{...Qe(this.options.HTMLAttributes,t),children:$d("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(o=>{const a=e.renderChildren([o]).split(`
171
- `).map(l=>l.trim()===""?n:`${n} ${l}`);r.push(a.join(`
172
- `))}),r.join(`
173
- ${n}
174
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[da({find:zJ,type:this.type})]}}),VJ=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,WJ=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,KJ=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,GJ=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,qJ=jo.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return $d("strong",{...Qe(this.options.HTMLAttributes,t),children:$d("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ua({find:VJ,type:this.type}),ua({find:KJ,type:this.type})]},addPasteRules(){return[ai({find:WJ,type:this.type}),ai({find:GJ,type:this.type})]}}),YJ=/(^|[^`])`([^`]+)`(?!`)$/,JJ=/(^|[^`])`([^`]+)`(?!`)/g,XJ=jo.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Qe(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ua({find:YJ,type:this.type})]},addPasteRules(){return[ai({find:JJ,type:this.type})]}}),Gp=4,QJ=/^```([a-z]+)?[\s\n]$/,ZJ=/^~~~([a-z]+)?[\s\n]$/,eX=Lt.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Gp,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const s=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(i=>i.startsWith(n)).map(i=>i.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Qe(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const o=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${o}`,e.renderChildren(t.content),"```"].join(`
175
- `):r=`\`\`\`${o}
176
-
177
- \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Gp,{state:r}=t,{selection:o}=r,{$from:s,empty:i}=o;if(s.parent.type!==this.type)return!1;const a=" ".repeat(n);return i?t.commands.insertContent(a):t.commands.command(({tr:l})=>{const{from:c,to:u}=o,h=r.doc.textBetween(c,u,`
178
- `,`
179
- `).split(`
180
- `).map(p=>a+p).join(`
181
- `);return l.replaceWith(c,u,r.schema.text(h)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Gp,{state:r}=t,{selection:o}=r,{$from:s,empty:i}=o;return s.parent.type!==this.type?!1:i?t.commands.command(({tr:a})=>{var l;const{pos:c}=s,u=s.start(),d=s.end(),h=r.doc.textBetween(u,d,`
182
- `,`
183
- `).split(`
184
- `);let p=0,m=0;const g=c-u;for(let x=0;x<h.length;x+=1){if(m+h[x].length>=g){p=x;break}m+=h[x].length+1}const S=((l=h[p].match(/^ */))==null?void 0:l[0])||"",k=Math.min(S.length,n);if(k===0)return!0;let v=u;for(let x=0;x<p;x+=1)v+=h[x].length+1;return a.delete(v,v+k),c-v<=k&&a.setSelection(we.create(a.doc,v)),!0}):t.commands.command(({tr:a})=>{const{from:l,to:c}=o,f=r.doc.textBetween(l,c,`
185
- `,`
186
- `).split(`
187
- `).map(h=>{var p;const m=((p=h.match(/^ */))==null?void 0:p[0])||"",g=Math.min(m.length,n);return h.slice(g)}).join(`
188
- `);return a.replaceWith(l,c,r.schema.text(f)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,i=r.parent.textContent.endsWith(`
189
-
190
- `);return!s||!i?!1:t.chain().command(({tr:a})=>(a.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:o,empty:s}=n;if(!s||o.parent.type!==this.type||!(o.parentOffset===o.parent.nodeSize-2))return!1;const a=o.after();return a===void 0?!1:r.nodeAt(a)?t.commands.command(({tr:c})=>(c.setSelection(Re.near(r.resolve(a))),!0)):t.commands.exitCode()}}},addInputRules(){return[eg({find:QJ,type:this.type,getAttributes:t=>({language:t[1]})}),eg({find:ZJ,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Ye({key:new Je("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,s=o?.mode;if(!n||!s)return!1;const{tr:i,schema:a}=t.state,l=a.text(n.replace(/\r\n?/g,`
191
- `));return i.replaceSelectionWith(this.type.create({language:s},l)),i.selection.$from.parent.type!==this.type&&i.setSelection(we.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),t.dispatch(i),!0}}})]}}),vR=Lt.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
192
-
193
- `):""}),tX=vR,wR=Lt.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",Qe(this.options.HTMLAttributes,t)]},renderText(){return`
194
- `},renderMarkdown:()=>`
195
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:o,storedMarks:s}=n;if(o.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:a}=r.extensionManager,l=s||o.$to.parentOffset&&o.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&l&&i){const d=l.filter(f=>a.includes(f.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),xR=wR,nX=Lt.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(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Qe(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,o="#".repeat(r);return t.content?`${o} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>eg({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),rX=Lt.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Qe(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!y3(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,o=t();return xC(n)?o.insertContentAt(r.pos,{type:this.name}):o.insertContent({type:this.name}),o.command(({state:s,tr:i,dispatch:a})=>{if(a){const{$to:l}=i.selection,c=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?i.setSelection(we.create(i.doc,l.pos+1)):l.nodeAfter.isBlock?i.setSelection(me.create(i.doc,l.pos)):i.setSelection(we.create(i.doc,l.pos));else{const u=s.schema.nodes[this.options.nextNodeType]||l.parent.type.contentMatch.defaultType,d=u?.create();d&&(i.insert(c,d),i.setSelection(we.create(i.doc,c+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[g3({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),oX=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,sX=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,iX=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,aX=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,lX=jo.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Qe(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ua({find:oX,type:this.type}),ua({find:iX,type:this.type})]},addPasteRules(){return[ai({find:sX,type:this.type}),ai({find:aX,type:this.type})]}});const cX="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",uX="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Ag="numeric",_g="ascii",Mg="alpha",kl="asciinumeric",dl="alphanumeric",Og="domain",ER="emoji",dX="scheme",fX="slashscheme",qp="whitespace";function hX(t,e){return t in e||(e[t]=[]),e[t]}function Ws(t,e,n){e[Ag]&&(e[kl]=!0,e[dl]=!0),e[_g]&&(e[kl]=!0,e[Mg]=!0),e[kl]&&(e[dl]=!0),e[Mg]&&(e[dl]=!0),e[dl]&&(e[Og]=!0),e[ER]&&(e[Og]=!0);for(const r in e){const o=hX(r,n);o.indexOf(t)<0&&o.push(t)}}function pX(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Rn(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Rn.groups={};Rn.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const o=e.jr[r][0],s=e.jr[r][1];if(s&&o.test(t))return s}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let o=0;o<t.length;o++)this.tt(t[o],e,n,r)},tr(t,e,n,r){r=r||Rn.groups;let o;return e&&e.j?o=e:(o=new Rn(e),n&&r&&Ws(e,n,r)),this.jr.push([t,o]),o},ts(t,e,n,r){let o=this;const s=t.length;if(!s)return o;for(let i=0;i<s-1;i++)o=o.tt(t[i]);return o.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||Rn.groups;const o=this;if(e&&e.j)return o.j[t]=e,e;const s=e;let i,a=o.go(t);if(a?(i=new Rn,Object.assign(i.j,a.j),i.jr.push.apply(i.jr,a.jr),i.jd=a.jd,i.t=a.t):i=new Rn,s){if(r)if(i.t&&typeof i.t=="string"){const l=Object.assign(pX(i.t,r),n);Ws(s,l,r)}else n&&Ws(s,n,r);i.t=s}return o.j[t]=i,i}};const De=(t,e,n,r,o)=>t.ta(e,n,r,o),St=(t,e,n,r,o)=>t.tr(e,n,r,o),F1=(t,e,n,r,o)=>t.ts(e,n,r,o),Z=(t,e,n,r,o)=>t.tt(e,n,r,o),vo="WORD",Rg="UWORD",SR="ASCIINUMERICAL",kR="ALPHANUMERICAL",Zl="LOCALHOST",Ng="TLD",Ig="UTLD",Vu="SCHEME",Bi="SLASH_SCHEME",tv="NUM",Dg="WS",nv="NL",Tl="OPENBRACE",Cl="CLOSEBRACE",Fd="OPENBRACKET",Ud="CLOSEBRACKET",Bd="OPENPAREN",zd="CLOSEPAREN",Hd="OPENANGLEBRACKET",Vd="CLOSEANGLEBRACKET",Wd="FULLWIDTHLEFTPAREN",Kd="FULLWIDTHRIGHTPAREN",Gd="LEFTCORNERBRACKET",qd="RIGHTCORNERBRACKET",Yd="LEFTWHITECORNERBRACKET",Jd="RIGHTWHITECORNERBRACKET",Xd="FULLWIDTHLESSTHAN",Qd="FULLWIDTHGREATERTHAN",Zd="AMPERSAND",ef="APOSTROPHE",tf="ASTERISK",Qo="AT",nf="BACKSLASH",rf="BACKTICK",of="CARET",ts="COLON",rv="COMMA",sf="DOLLAR",Vr="DOT",af="EQUALS",ov="EXCLAMATION",er="HYPHEN",Al="PERCENT",lf="PIPE",cf="PLUS",uf="POUND",_l="QUERY",sv="QUOTE",TR="FULLWIDTHMIDDLEDOT",iv="SEMI",Wr="SLASH",Ml="TILDE",df="UNDERSCORE",CR="EMOJI",ff="SYM";var AR=Object.freeze({__proto__:null,ALPHANUMERICAL:kR,AMPERSAND:Zd,APOSTROPHE:ef,ASCIINUMERICAL:SR,ASTERISK:tf,AT:Qo,BACKSLASH:nf,BACKTICK:rf,CARET:of,CLOSEANGLEBRACKET:Vd,CLOSEBRACE:Cl,CLOSEBRACKET:Ud,CLOSEPAREN:zd,COLON:ts,COMMA:rv,DOLLAR:sf,DOT:Vr,EMOJI:CR,EQUALS:af,EXCLAMATION:ov,FULLWIDTHGREATERTHAN:Qd,FULLWIDTHLEFTPAREN:Wd,FULLWIDTHLESSTHAN:Xd,FULLWIDTHMIDDLEDOT:TR,FULLWIDTHRIGHTPAREN:Kd,HYPHEN:er,LEFTCORNERBRACKET:Gd,LEFTWHITECORNERBRACKET:Yd,LOCALHOST:Zl,NL:nv,NUM:tv,OPENANGLEBRACKET:Hd,OPENBRACE:Tl,OPENBRACKET:Fd,OPENPAREN:Bd,PERCENT:Al,PIPE:lf,PLUS:cf,POUND:uf,QUERY:_l,QUOTE:sv,RIGHTCORNERBRACKET:qd,RIGHTWHITECORNERBRACKET:Jd,SCHEME:Vu,SEMI:iv,SLASH:Wr,SLASH_SCHEME:Bi,SYM:ff,TILDE:Ml,TLD:Ng,UNDERSCORE:df,UTLD:Ig,UWORD:Rg,WORD:vo,WS:Dg});const go=/[a-z]/,qa=new RegExp("\\p{L}","u"),Yp=new RegExp("\\p{Emoji}","u"),yo=/\d/,Jp=/\s/,U1="\r",Xp=`
196
- `,mX="️",gX="‍",Qp="";let yu=null,bu=null;function yX(t=[]){const e={};Rn.groups=e;const n=new Rn;yu==null&&(yu=B1(cX)),bu==null&&(bu=B1(uX)),Z(n,"'",ef),Z(n,"{",Tl),Z(n,"}",Cl),Z(n,"[",Fd),Z(n,"]",Ud),Z(n,"(",Bd),Z(n,")",zd),Z(n,"<",Hd),Z(n,">",Vd),Z(n,"(",Wd),Z(n,")",Kd),Z(n,"「",Gd),Z(n,"」",qd),Z(n,"『",Yd),Z(n,"』",Jd),Z(n,"<",Xd),Z(n,">",Qd),Z(n,"&",Zd),Z(n,"*",tf),Z(n,"@",Qo),Z(n,"`",rf),Z(n,"^",of),Z(n,":",ts),Z(n,",",rv),Z(n,"$",sf),Z(n,".",Vr),Z(n,"=",af),Z(n,"!",ov),Z(n,"-",er),Z(n,"%",Al),Z(n,"|",lf),Z(n,"+",cf),Z(n,"#",uf),Z(n,"?",_l),Z(n,'"',sv),Z(n,"/",Wr),Z(n,";",iv),Z(n,"~",Ml),Z(n,"_",df),Z(n,"\\",nf),Z(n,"・",TR);const r=St(n,yo,tv,{[Ag]:!0});St(r,yo,r);const o=St(r,go,SR,{[kl]:!0}),s=St(r,qa,kR,{[dl]:!0}),i=St(n,go,vo,{[_g]:!0});St(i,yo,o),St(i,go,i),St(o,yo,o),St(o,go,o);const a=St(n,qa,Rg,{[Mg]:!0});St(a,go),St(a,yo,s),St(a,qa,a),St(s,yo,s),St(s,go),St(s,qa,s);const l=Z(n,Xp,nv,{[qp]:!0}),c=Z(n,U1,Dg,{[qp]:!0}),u=St(n,Jp,Dg,{[qp]:!0});Z(n,Qp,u),Z(c,Xp,l),Z(c,Qp,u),St(c,Jp,u),Z(u,U1),Z(u,Xp),St(u,Jp,u),Z(u,Qp,u);const d=St(n,Yp,CR,{[ER]:!0});Z(d,"#"),St(d,Yp,d),Z(d,mX,d);const f=Z(d,gX);Z(f,"#"),St(f,Yp,d);const h=[[go,i],[yo,o]],p=[[go,null],[qa,a],[yo,s]];for(let m=0;m<yu.length;m++)Wo(n,yu[m],Ng,vo,h);for(let m=0;m<bu.length;m++)Wo(n,bu[m],Ig,Rg,p);Ws(Ng,{tld:!0,ascii:!0},e),Ws(Ig,{utld:!0,alpha:!0},e),Wo(n,"file",Vu,vo,h),Wo(n,"mailto",Vu,vo,h),Wo(n,"http",Bi,vo,h),Wo(n,"https",Bi,vo,h),Wo(n,"ftp",Bi,vo,h),Wo(n,"ftps",Bi,vo,h),Ws(Vu,{scheme:!0,ascii:!0},e),Ws(Bi,{slashscheme:!0,ascii:!0},e),t=t.sort((m,g)=>m[0]>g[0]?1:-1);for(let m=0;m<t.length;m++){const g=t[m][0],S=t[m][1]?{[dX]:!0}:{[fX]:!0};g.indexOf("-")>=0?S[Og]=!0:go.test(g)?yo.test(g)?S[kl]=!0:S[_g]=!0:S[Ag]=!0,F1(n,g,g,S)}return F1(n,"localhost",Zl,{ascii:!0}),n.jd=new Rn(ff),{start:n,tokens:Object.assign({groups:e},AR)}}function _R(t,e){const n=bX(e.replace(/[A-Z]/g,a=>a.toLowerCase())),r=n.length,o=[];let s=0,i=0;for(;i<r;){let a=t,l=null,c=0,u=null,d=-1,f=-1;for(;i<r&&(l=a.go(n[i]));)a=l,a.accepts()?(d=0,f=0,u=a):d>=0&&(d+=n[i].length,f++),c+=n[i].length,s+=n[i].length,i++;s-=d,i-=f,c-=d,o.push({t:u.t,v:e.slice(s-c,s),s:s-c,e:s})}return o}function bX(t){const e=[],n=t.length;let r=0;for(;r<n;){let o=t.charCodeAt(r),s,i=o<55296||o>56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(i),r+=i.length}return e}function Wo(t,e,n,r,o){let s;const i=e.length;for(let a=0;a<i-1;a++){const l=e[a];t.j[l]?s=t.j[l]:(s=new Rn(r),s.jr=o.slice(),t.j[l]=s),t=s}return s=new Rn(n),s.jr=o.slice(),t.j[e[i-1]]=s,s}function B1(t){const e=[],n=[];let r=0,o="0123456789";for(;r<t.length;){let s=0;for(;o.indexOf(t[r+s])>=0;)s++;if(s>0){e.push(n.join(""));for(let i=parseInt(t.substring(r,r+s),10);i>0;i--)n.pop();r+=s}else n.push(t[r]),r++}return e}const ec={defaultProtocol:"http",events:null,format:z1,formatHref:z1,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function av(t,e=null){let n=Object.assign({},ec);t&&(n=Object.assign(n,t instanceof av?t.o:t));const r=n.ignoreTags,o=[];for(let s=0;s<r.length;s++)o.push(r[s].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=o}av.prototype={o:ec,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let o=this.o[t];return o&&(typeof o=="object"?(o=n.t in o?o[n.t]:ec[t],typeof o=="function"&&r&&(o=o(e,n))):typeof o=="function"&&r&&(o=o(e,n.t,n)),o)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function z1(t){return t}function MR(t,e){this.t="token",this.v=t,this.tk=e}MR.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=ec.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),o=t.get("tagName",n,e),s=this.toFormattedString(t),i={},a=t.get("className",n,e),l=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return i.href=r,a&&(i.class=a),l&&(i.target=l),c&&(i.rel=c),u&&Object.assign(i,u),{tagName:o,attributes:i,content:s,eventListeners:d}}};function Rh(t,e){class n extends MR{constructor(o,s){super(o,s),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const H1=Rh("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),V1=Rh("text"),vX=Rh("nl"),vu=Rh("url",{isLink:!0,toHref(t=ec.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Zl&&t[1].t===ts}}),Qn=t=>new Rn(t);function wX({groups:t}){const e=t.domain.concat([Zd,tf,Qo,nf,rf,of,sf,af,er,tv,Al,lf,cf,uf,Wr,ff,Ml,df]),n=[ef,ts,rv,Vr,ov,Al,_l,sv,iv,Hd,Vd,Tl,Cl,Ud,Fd,Bd,zd,Wd,Kd,Gd,qd,Yd,Jd,Xd,Qd],r=[Zd,ef,tf,nf,rf,of,sf,af,er,Tl,Cl,Al,lf,cf,uf,_l,Wr,ff,Ml,df],o=Qn(),s=Z(o,Ml);De(s,r,s),De(s,t.domain,s);const i=Qn(),a=Qn(),l=Qn();De(o,t.domain,i),De(o,t.scheme,a),De(o,t.slashscheme,l),De(i,r,s),De(i,t.domain,i);const c=Z(i,Qo);Z(s,Qo,c),Z(a,Qo,c),Z(l,Qo,c);const u=Z(s,Vr);De(u,r,s),De(u,t.domain,s);const d=Qn();De(c,t.domain,d),De(d,t.domain,d);const f=Z(d,Vr);De(f,t.domain,d);const h=Qn(H1);De(f,t.tld,h),De(f,t.utld,h),Z(c,Zl,h);const p=Z(d,er);Z(p,er,p),De(p,t.domain,d),De(h,t.domain,d),Z(h,Vr,f),Z(h,er,p);const m=Z(h,ts);De(m,t.numeric,H1);const g=Z(i,er),b=Z(i,Vr);Z(g,er,g),De(g,t.domain,i),De(b,r,s),De(b,t.domain,i);const S=Qn(vu);De(b,t.tld,S),De(b,t.utld,S),De(S,t.domain,i),De(S,r,s),Z(S,Vr,b),Z(S,er,g),Z(S,Qo,c);const k=Z(S,ts),v=Qn(vu);De(k,t.numeric,v);const _=Qn(vu),x=Qn();De(_,e,_),De(_,n,x),De(x,e,_),De(x,n,x),Z(S,Wr,_),Z(v,Wr,_);const A=Z(a,ts),E=Z(l,ts),T=Z(E,Wr),N=Z(T,Wr);De(a,t.domain,i),Z(a,Vr,b),Z(a,er,g),De(l,t.domain,i),Z(l,Vr,b),Z(l,er,g),De(A,t.domain,_),Z(A,Wr,_),Z(A,_l,_),De(N,t.domain,_),De(N,e,_),Z(N,Wr,_);const I=[[Tl,Cl],[Fd,Ud],[Bd,zd],[Hd,Vd],[Wd,Kd],[Gd,qd],[Yd,Jd],[Xd,Qd]];for(let R=0;R<I.length;R++){const[D,O]=I[R],P=Z(_,D);Z(x,D,P),Z(P,O,_);const C=Qn(vu);De(P,e,C);const M=Qn();De(P,n),De(C,e,C),De(C,n,M),De(M,e,C),De(M,n,M),Z(C,O,_),Z(M,O,_)}return Z(o,Zl,S),Z(o,nv,vX),{start:o,tokens:AR}}function xX(t,e,n){let r=n.length,o=0,s=[],i=[];for(;o<r;){let a=t,l=null,c=null,u=0,d=null,f=-1;for(;o<r&&!(l=a.go(n[o].t));)i.push(n[o++]);for(;o<r&&(c=l||a.go(n[o].t));)l=null,a=c,a.accepts()?(f=0,d=a):f>=0&&f++,o++,u++;if(f<0)o-=u,o<r&&(i.push(n[o]),o++);else{i.length>0&&(s.push(Zp(V1,e,i)),i=[]),o-=f,u-=f;const h=d.t,p=n.slice(o-u,o);s.push(Zp(h,e,p))}}return i.length>0&&s.push(Zp(V1,e,i)),s}function Zp(t,e,n){const r=n[0].s,o=n[n.length-1].e,s=e.slice(r,o);return new t(s,n)}const EX=typeof console<"u"&&console&&console.warn||(()=>{}),SX="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",yt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function kX(){return Rn.groups={},yt.scanner=null,yt.parser=null,yt.tokenQueue=[],yt.pluginQueue=[],yt.customSchemes=[],yt.initialized=!1,yt}function W1(t,e=!1){if(yt.initialized&&EX(`linkifyjs: already initialized - will not register custom scheme "${t}" ${SX}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
197
- 1. Must only contain digits, lowercase ASCII letters or "-"
198
- 2. Cannot start or end with "-"
199
- 3. "-" cannot repeat`);yt.customSchemes.push([t,e])}function TX(){yt.scanner=yX(yt.customSchemes);for(let t=0;t<yt.tokenQueue.length;t++)yt.tokenQueue[t][1]({scanner:yt.scanner});yt.parser=wX(yt.scanner.tokens);for(let t=0;t<yt.pluginQueue.length;t++)yt.pluginQueue[t][1]({scanner:yt.scanner,parser:yt.parser});return yt.initialized=!0,yt}function lv(t){return yt.initialized||TX(),xX(yt.parser.start,t,_R(yt.scanner.start,t))}lv.scan=_R;function OR(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new av(n),o=lv(t),s=[];for(let i=0;i<o.length;i++){const a=o[i];a.isLink&&(!e||a.t===e)&&r.check(a)&&s.push(a.toFormattedObject(r))}return s}var cv="[\0-   ᠎ -\u2029  ]",CX=new RegExp(cv),AX=new RegExp(`${cv}$`),_X=new RegExp(cv,"g");function MX(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function OX(t){return new Ye({key:new Je("autolink"),appendTransaction:(e,n,r)=>{const o=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!o||s)return;const{tr:i}=r,a=hC(n.doc,[...e]);if(wC(a).forEach(({newRange:c})=>{const u=yB(r.doc,c,h=>h.isTextblock);let d,f;if(u.length>1)d=u[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){const h=r.doc.textBetween(c.from,c.to," "," ");if(!AX.test(h))return;d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&f){const h=f.split(CX).filter(Boolean);if(h.length<=0)return!1;const p=h[h.length-1],m=d.pos+f.lastIndexOf(p);if(!p)return!1;const g=lv(p).map(b=>b.toObject(t.defaultProtocol));if(!MX(g))return!1;g.filter(b=>b.isLink).map(b=>({...b,from:m+b.start+1,to:m+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{Qy(b.from,b.to,r.doc).some(S=>S.mark.type===t.type)||i.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!i.steps.length)return i}})}function RX(t){return new Ye({key:new Je("handleClickLink"),props:{handleClick:(e,n,r)=>{var o,s;if(r.button!==0||!e.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{const l=r.target;if(!l)return!1;const c=t.editor.view.dom;i=l.closest("a"),i&&!c.contains(i)&&(i=null)}if(!i)return!1;let a=!1;if(t.enableClickSelection&&(a=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const l=vC(e.state,t.type.name),c=(o=i.href)!=null?o:l.href,u=(s=i.target)!=null?s:l.target;c&&(window.open(c,u),a=!0)}return a}}})}function NX(t){return new Ye({key:new Je("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:o}=t,{state:s}=e,{selection:i}=s,{empty:a}=i;if(a)return!1;let l="";r.content.forEach(u=>{l+=u.textContent});const c=OR(l,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===l);return!l||!c||o!==void 0&&!o(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function Yo(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const o=typeof r=="string"?r:r.scheme;o&&n.push(o)}),!t||t.replace(_X,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var RR=jo.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate),this.options.protocols.forEach(t=>{if(typeof t=="string"){W1(t);return}W1(t.scheme,t.optionalSlashes)})},onDestroy(){kX()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Yo(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const o=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(o)||!/\./.test(o))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Yo(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Yo(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Qe(this.options.HTMLAttributes,t),0]:["a",Qe(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,o,s;const i=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",a=(s=(o=t.attrs)==null?void 0:o.title)!=null?s:"",l=e.renderChildren(t);return a?`[${l}](${i} "${a}")`:`[${l}](${i})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Yo(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Yo(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[ai({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,o=OR(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:i=>!!Yo(i,n),protocols:n,defaultProtocol:r}));o.length&&o.forEach(s=>{this.options.shouldAutoLink(s.value)&&e.push({text:s.value,data:{href:s.href},index:s.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(OX({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!Yo(o,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(RX({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(NX({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),NR=RR,IX=Object.defineProperty,DX=(t,e)=>{for(var n in e)IX(t,n,{get:e[n],enumerable:!0})},PX="listItem",K1="textStyle",G1=/^\s*([-+*])\s$/,IR=Lt.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:t}){return["ul",Qe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
200
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(PX,this.editor.getAttributes(K1)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=da({find:G1,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=da({find:G1,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(K1),editor:this.editor})),[t]}}),DR=Lt.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Qe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(o=>o.type==="paragraph"))n=e.parseChildren(t.tokens);else{const o=t.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(o.tokens)}],t.tokens.length>1){const i=t.tokens.slice(1),a=e.parseChildren(i);n.push(...a)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>rb(t,e,r=>{var o,s;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((s=(o=r.meta)==null?void 0:o.parentAttrs)==null?void 0:s.start)||1)+r.index}. `:"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),LX={};DX(LX,{findListItemPos:()=>Fc,getNextListDepth:()=>uv,handleBackspace:()=>Pg,handleDelete:()=>Lg,hasListBefore:()=>PR,hasListItemAfter:()=>jX,hasListItemBefore:()=>LR,listItemHasSubList:()=>jR,nextListIsDeeper:()=>$R,nextListIsHigher:()=>FR});var Fc=(t,e)=>{const{$from:n}=e.selection,r=Ot(t,e.schema);let o=null,s=n.depth,i=n.pos,a=null;for(;s>0&&a===null;)o=n.node(s),o.type===r?a=s:(s-=1,i-=1);return a===null?null:{$pos:e.doc.resolve(i),depth:a}},uv=(t,e)=>{const n=Fc(t,e);if(!n)return!1;const[,r]=_B(e,t,n.$pos.pos+4);return r},PR=(t,e,n)=>{const{$anchor:r}=t.selection,o=Math.max(0,r.pos-2),s=t.doc.resolve(o).node();return!(!s||!n.includes(s.type.name))},LR=(t,e)=>{var n;const{$anchor:r}=e.selection,o=e.doc.resolve(r.pos-2);return!(o.index()===0||((n=o.nodeBefore)==null?void 0:n.type.name)!==t)},jR=(t,e,n)=>{if(!n)return!1;const r=Ot(t,e.schema);let o=!1;return n.descendants(s=>{s.type===r&&(o=!0)}),o},Pg=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!ys(t.state,e)&&PR(t.state,e,n)){const{$anchor:a}=t.state.selection,l=t.state.doc.resolve(a.before()-1),c=[];l.node().descendants((f,h)=>{f.type.name===e&&c.push({node:f,pos:h})});const u=c.at(-1);if(!u)return!1;const d=t.state.doc.resolve(l.start()+u.pos+1);return t.chain().cut({from:a.start()-1,to:a.end()+1},d.end()).joinForward().run()}if(!ys(t.state,e)||!NB(t.state))return!1;const r=Fc(e,t.state);if(!r)return!1;const s=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),i=jR(e,t.state,s);return LR(e,t.state)&&!i?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},$R=(t,e)=>{const n=uv(t,e),r=Fc(t,e);return!r||!n?!1:n>r.depth},FR=(t,e)=>{const n=uv(t,e),r=Fc(t,e);return!r||!n?!1:n<r.depth},Lg=(t,e)=>{if(!ys(t.state,e)||!RB(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:o}=n;return!n.empty&&r.sameParent(o)?!1:$R(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():FR(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},jX=(t,e)=>{var n;const{$anchor:r}=e.selection,o=e.doc.resolve(r.pos-r.parentOffset-2);return!(o.index()===o.parent.childCount-1||((n=o.nodeAfter)==null?void 0:n.type.name)!==t)},UR=at.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Lg(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Lg(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Pg(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Pg(t,n,r)&&(e=!0)}),e}}}}),q1=/^(\s*)(\d+)\.\s+(.*)$/,$X=/^\s/;function FX(t){const e=[];let n=0,r=0;for(;n<t.length;){const o=t[n],s=o.match(q1);if(!s)break;const[,i,a,l]=s,c=i.length;let u=l,d=n+1;const f=[o];for(;d<t.length;){const h=t[d];if(h.match(q1))break;if(h.trim()==="")f.push(h),u+=`
201
- `,d+=1;else if(h.match($X))f.push(h),u+=`
202
- ${h.slice(c+2)}`,d+=1;else break}e.push({indent:c,number:parseInt(a,10),content:u.trim(),raw:f.join(`
203
- `)}),r=d,n=d}return[e,r]}function BR(t,e,n){var r;const o=[];let s=0;for(;s<t.length;){const i=t[s];if(i.indent===e){const a=i.content.split(`
204
- `),l=((r=a[0])==null?void 0:r.trim())||"",c=[];l&&c.push({type:"paragraph",raw:l,tokens:n.inlineTokens(l)});const u=a.slice(1).join(`
205
- `).trim();if(u){const h=n.blockTokens(u);c.push(...h)}let d=s+1;const f=[];for(;d<t.length&&t[d].indent>e;)f.push(t[d]),d+=1;if(f.length>0){const h=Math.min(...f.map(m=>m.indent)),p=BR(f,h,n);c.push({type:"list",ordered:!0,start:f[0].number,items:p,raw:f.map(m=>m.raw).join(`
206
- `)})}o.push({type:"list_item",raw:i.raw,tokens:c}),s=d}else s+=1}return o}function UX(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(o=>{if(o.type==="paragraph"||o.type==="list"||o.type==="blockquote"||o.type==="code")r.push(...e.parseChildren([o]));else if(o.type==="text"&&o.tokens){const s=e.parseChildren([o]);r.push({type:"paragraph",content:s})}else{const s=e.parseChildren([o]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var BX="listItem",Y1="textStyle",J1=/^(\d+)\.\s$/,zR=Lt.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:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",Qe(this.options.HTMLAttributes,n),0]:["ol",Qe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?UX(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
207
- `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const o=t.split(`
208
- `),[s,i]=FX(o);if(s.length===0)return;const a=BR(s,0,n);return a.length===0?void 0:{type:"list",ordered:!0,start:((r=s[0])==null?void 0:r.number)||1,items:a,raw:o.slice(0,i).join(`
209
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(BX,this.editor.getAttributes(Y1)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=da({find:J1,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=da({find:J1,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Y1)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),zX=/^\s*(\[([( |x])?\])\s$/,HX=Lt.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Qe(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const o=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return rb(t,e,o)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const o=document.createElement("li"),s=document.createElement("label"),i=document.createElement("span"),a=document.createElement("input"),l=document.createElement("div"),c=d=>{var f,h;a.ariaLabel=((h=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:h.call(f,d,a.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};c(t),s.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",d=>d.preventDefault()),a.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const p=n();if(typeof p!="number")return!1;const m=h.doc.nodeAt(p);return h.setNodeMarkup(p,void 0,{...m?.attrs,checked:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{o.setAttribute(d,f)}),o.dataset.checked=t.attrs.checked,a.checked=t.attrs.checked,s.append(a,i),o.append(s,l),Object.entries(e).forEach(([d,f])=>{o.setAttribute(d,f)});let u=new Set(Object.keys(e));return{dom:o,contentDOM:l,update:d=>{if(d.type!==this.type)return!1;o.dataset.checked=d.attrs.checked,a.checked=d.attrs.checked,c(d);const f=r.extensionManager.attributes,h=ca(d,f),p=new Set(Object.keys(h)),m=this.options.HTMLAttributes;return u.forEach(g=>{p.has(g)||(g in m?o.setAttribute(g,m[g]):o.removeAttribute(g))}),Object.entries(h).forEach(([g,b])=>{b==null?g in m?o.setAttribute(g,m[g]):o.removeAttribute(g):o.setAttribute(g,b)}),u=p,!0}}}},addInputRules(){return[da({find:zX,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),VX=Lt.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",Qe(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
210
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=s=>{const i=tg(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,l)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.mainContent),nestedTokens:l}),customNestedParser:r},n);return i?[{type:"taskList",raw:i.raw,items:i.items}]:n.blockTokens(s)},o=tg(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,i)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.mainContent),nestedTokens:i}),customNestedParser:r},n);if(o)return{type:"taskList",raw:o.raw,items:o.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});at.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(IR.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(DR.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(UR.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(zR.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(HX.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(VX.configure(this.options.taskList)),t}});var X1="&nbsp;",WX=" ",HR=Lt.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Qe(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===X1||r[0].text===WX)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?X1:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),VR=HR,KX=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,GX=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,qX=jo.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",Qe(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ua({find:KX,type:this.type})]},addPasteRules(){return[ai({find:GX,type:this.type})]}}),WR=Lt.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),KR=WR,YX=jo.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",Qe(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const o=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!o)return;const s=o[2].trim();return{type:"underline",raw:o[0],text:s,tokens:n.inlineTokens(s)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function JX(t={}){return new Ye({view(e){return new XX(e,t)}})}class XX{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let s=i=>{this[o](i)};return e.dom.addEventListener(o,s),{name:o,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.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),n=!e.parent.inlineContent,r,o=this.editorView.dom,s=o.getBoundingClientRect(),i=s.width/o.offsetWidth,a=s.height/o.offsetHeight;if(n){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),m=d?p.bottom:p.top;d&&f&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*a;r={left:p.left,right:p.right,top:m-g,bottom:m+g}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*i;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let l=this.editorView.dom.offsetParent;this.element||(this.element=l.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!l||l==document.body&&getComputedStyle(l).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=l.getBoundingClientRect(),f=d.width/l.offsetWidth,h=d.height/l.offsetHeight;c=d.left-l.scrollLeft*f,u=d.top-l.scrollTop*h}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/a+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/a+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),o=r&&r.type.spec.disableDropCursor,s=typeof o=="function"?o(this.editorView,n,e):o;if(n&&!s){let i=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let a=rT(this.editorView.state.doc,i,this.editorView.dragging.slice);a!=null&&(i=a)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class kt extends Re{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return kt.valid(r)?new kt(r):Re.near(r)}content(){return ie.empty}eq(e){return e instanceof kt&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new kt(e.resolve(n.pos))}getBookmark(){return new dv(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!QX(e)||!ZX(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let o=n.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&kt.valid(e))return e;let o=e.pos,s=null;for(let i=e.depth;;i--){let a=e.node(i);if(n>0?e.indexAfter(i)<a.childCount:e.index(i)>0){s=a.child(n>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;o+=n;let l=e.doc.resolve(o);if(kt.valid(l))return l}for(;;){let i=n>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!me.isSelectable(s)){e=e.doc.resolve(o+s.nodeSize*n),r=!1;continue e}break}s=i,o+=n;let a=e.doc.resolve(o);if(kt.valid(a))return a}return null}}}kt.prototype.visible=!1;kt.findFrom=kt.findGapCursorFrom;Re.jsonID("gapcursor",kt);class dv{constructor(e){this.pos=e}map(e){return new dv(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return kt.valid(n)?new kt(n):Re.near(n)}}function GR(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function QX(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||GR(o.type))return!0;if(o.inlineContent)return!1}}return!0}function ZX(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(n);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||GR(o.type))return!0;if(o.inlineContent)return!1}}return!0}function eQ(){return new Ye({props:{decorations:oQ,createSelectionBetween(t,e,n){return e.pos==n.pos&&kt.valid(n)?new kt(n):null},handleClick:nQ,handleKeyDown:tQ,handleDOMEvents:{beforeinput:rQ}}})}const tQ=sC({ArrowLeft:wu("horiz",-1),ArrowRight:wu("horiz",1),ArrowUp:wu("vert",-1),ArrowDown:wu("vert",1)});function wu(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,s){let i=r.selection,a=e>0?i.$to:i.$from,l=i.empty;if(i instanceof we){if(!s.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=kt.findGapCursorFrom(a,e,l);return c?(o&&o(r.tr.setSelection(new kt(c))),!0):!1}}function nQ(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!kt.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&me.isSelectable(t.state.doc.nodeAt(o.inside))?!1:(t.dispatch(t.state.tr.setSelection(new kt(r))),!0)}function rQ(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof kt))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let o=X.empty;for(let i=r.length-1;i>=0;i--)o=X.from(r[i].createAndFill(null,o));let s=t.state.tr.replace(n.pos,n.pos,new ie(o,0,0));return s.setSelection(we.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function oQ(t){if(!(t.selection instanceof kt))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ft.create(t.doc,[tn.widget(t.selection.head,e,{key:"gapcursor"})])}var hf=200,Vt=function(){};Vt.prototype.append=function(e){return e.length?(e=Vt.from(e),!this.length&&e||e.length<hf&&this.leafAppend(e)||this.length<hf&&e.leafPrepend(this)||this.appendInner(e)):this};Vt.prototype.prepend=function(e){return e.length?Vt.from(e).append(this):this};Vt.prototype.appendInner=function(e){return new sQ(this,e)};Vt.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Vt.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Vt.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Vt.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};Vt.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(s,i){return o.push(e(s,i))},n,r),o};Vt.from=function(e){return e instanceof Vt?e:e&&e.length?new qR(e):Vt.empty};var qR=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,s){return o==0&&s==this.length?this:new e(this.values.slice(o,s))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,s,i,a){for(var l=s;l<i;l++)if(o(this.values[l],a+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,i,a){for(var l=s-1;l>=i;l--)if(o(this.values[l],a+l)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=hf)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=hf)return new e(o.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Vt);Vt.empty=new qR([]);var sQ=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.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,o,s,i){var a=this.left.length;if(o<a&&this.left.forEachInner(r,o,Math.min(s,a),i)===!1||s>a&&this.right.forEachInner(r,Math.max(o-a,0),Math.min(this.length,s)-a,i+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,s,i){var a=this.left.length;if(o>a&&this.right.forEachInvertedInner(r,o-a,Math.max(s,a)-a,i+a)===!1||s<a&&this.left.forEachInvertedInner(r,Math.min(o,a),s,i)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var s=this.left.length;return o<=s?this.left.slice(r,o):r>=s?this.right.slice(r-s,o-s):this.left.slice(r,s).append(this.right.slice(0,o-s))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,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})(Vt);const iQ=500;class Sr{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,s;n&&(o=this.remapping(r,this.items.length),s=o.maps.length);let i=e.tr,a,l,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){o||(o=this.remapping(r,f+1),s=o.maps.length),s--,u.push(d);return}if(o){u.push(new Ko(d.map));let h=d.step.map(o.slice(s)),p;h&&i.maybeStep(h).doc&&(p=i.mapping.maps[i.mapping.maps.length-1],c.push(new Ko(p,void 0,void 0,c.length+u.length))),s--,p&&o.appendMap(p,s)}else i.maybeStep(d.step);if(d.selection)return a=o?d.selection.map(o.slice(s)):d.selection,l=new Sr(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:l,transform:i,selection:a}}addTransform(e,n,r,o){let s=[],i=this.eventCount,a=this.items,l=!o&&a.length?a.get(a.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new Ko(e.mapping.maps[u],d,n),h;(h=l&&l.merge(f))&&(f=h,u?s.pop():a=a.slice(0,a.length-1)),s.push(f),n&&(i++,n=void 0),o||(l=f)}let c=i-r.depth;return c>lQ&&(a=aQ(a,c),i-=c),new Sr(a.append(s),i)}remapping(e,n){let r=new Ul;return this.items.forEach((o,s)=>{let i=o.mirrorOffset!=null&&s-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,i)},e,n),r}addMaps(e){return this.eventCount==0?this:new Sr(this.items.append(e.map(n=>new Ko(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-n),s=e.mapping,i=e.steps.length,a=this.eventCount;this.items.forEach(f=>{f.selection&&a--},o);let l=n;this.items.forEach(f=>{let h=s.getMirror(--l);if(h==null)return;i=Math.min(i,h);let p=s.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(s.slice(l+1,h));g&&a++,r.push(new Ko(p,m,g))}else r.push(new Ko(p))},o);let c=[];for(let f=n;f<i;f++)c.push(new Ko(s.maps[f]));let u=this.items.slice(0,o).append(c).append(r),d=new Sr(u,a);return d.emptyItemCount()>iQ&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,o=[],s=0;return this.items.forEach((i,a)=>{if(a>=e)o.push(i),i.selection&&s++;else if(i.step){let l=i.step.map(n.slice(r)),c=l&&l.getMap();if(r--,c&&n.appendMap(c,r),l){let u=i.selection&&i.selection.map(n.slice(r));u&&s++;let d=new Ko(c.invert(),l,u),f,h=o.length-1;(f=o.length&&o[h].merge(d))?o[h]=f:o.push(d)}}else i.map&&r--},this.items.length,0),new Sr(Vt.from(o.reverse()),s)}}Sr.empty=new Sr(Vt.empty,0);function aQ(t,e){let n;return t.forEach((r,o)=>{if(r.selection&&e--==0)return n=o,!1}),t.slice(n)}let Ko=class YR{constructor(e,n,r,o){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new YR(n.getMap().invert(),n,this.selection)}}};class Zo{constructor(e,n,r,o,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=o,this.prevComposition=s}}const lQ=20;function cQ(t,e,n,r){let o=n.getMeta(Qs),s;if(o)return o.historyState;n.getMeta(fQ)&&(t=new Zo(t.done,t.undone,null,0,-1));let i=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(i&&i.getMeta(Qs))return i.getMeta(Qs).redo?new Zo(t.done.addTransform(n,void 0,r,Wu(e)),t.undone,Q1(n.mapping.maps),t.prevTime,t.prevComposition):new Zo(t.done,t.undone.addTransform(n,void 0,r,Wu(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let a=n.getMeta("composition"),l=t.prevTime==0||!i&&t.prevComposition!=a&&(t.prevTime<(n.time||0)-r.newGroupDelay||!uQ(n,t.prevRanges)),c=i?em(t.prevRanges,n.mapping):Q1(n.mapping.maps);return new Zo(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,Wu(e)),Sr.empty,c,n.time,a??t.prevComposition)}else return(s=n.getMeta("rebased"))?new Zo(t.done.rebased(n,s),t.undone.rebased(n,s),em(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Zo(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),em(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function uQ(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,o)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&o>=e[s]&&(n=!0)}),n}function Q1(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,o,s,i)=>e.push(s,i));return e}function em(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let o=e.map(t[r],1),s=e.map(t[r+1],-1);o<=s&&n.push(o,s)}return n}function dQ(t,e,n){let r=Wu(e),o=Qs.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let i=s.selection.resolve(s.transform.doc),a=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),o,r),l=new Zo(n?a:s.remaining,n?s.remaining:a,null,0,-1);return s.transform.setSelection(i).setMeta(Qs,{redo:n,historyState:l})}let tm=!1,Z1=null;function Wu(t){let e=t.plugins;if(Z1!=e){tm=!1,Z1=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){tm=!0;break}}return tm}const Qs=new Je("history"),fQ=new Je("closeHistory");function hQ(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Ye({key:Qs,state:{init(){return new Zo(Sr.empty,Sr.empty,null,0,-1)},apply(e,n,r){return cQ(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,o=r=="historyUndo"?XR:r=="historyRedo"?QR:null;return!o||!e.editable?!1:(n.preventDefault(),o(e.state,e.dispatch))}}}})}function JR(t,e){return(n,r)=>{let o=Qs.getState(n);if(!o||(t?o.undone:o.done).eventCount==0)return!1;if(r){let s=dQ(o,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const XR=JR(!1,!0),QR=JR(!0,!0);at.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Ye({key:new Je("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const o=this.options.limit;if(o==null||o===0){t=!0;return}const s=this.storage.characters({node:r.doc});if(s>o){const i=s-o,a=0,l=i,c=r.tr.deleteRange(a,l);return t=!0,c}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const o=this.storage.characters({node:n.doc}),s=this.storage.characters({node:e.doc});if(s<=r||o>r&&s>r&&s<=o)return!0;if(o>r&&s>r&&s>o||!e.getMeta("paste"))return!1;const a=e.selection.$head.pos,l=s-r,c=a-l,u=a;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}});var pQ=at.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[JX(this.options)]}});at.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Ye({key:new Je("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:o}=e,s=[];if(!n||!r)return ft.create(t,[]);let i=0;this.options.mode==="deepest"&&t.descendants((l,c)=>{if(l.isText)return;if(!(o>=c&&o<=c+l.nodeSize-1))return!1;i+=1});let a=0;return t.descendants((l,c)=>{if(l.isText||!(o>=c&&o<=c+l.nodeSize-1))return!1;if(a+=1,this.options.mode==="deepest"&&i-a>0||this.options.mode==="shallowest"&&a>1)return this.options.mode==="deepest";s.push(tn.node(c,c+l.nodeSize,{class:this.options.className}))}),ft.create(t,s)}}})]}});var mQ=at.create({name:"gapCursor",addProseMirrorPlugins(){return[eQ()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=st(ye(t,"allowGapCursor",n)))!=null?e:null}}}),eE="placeholder";function gQ(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var yQ=at.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:eE,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${gQ(this.options.dataAttribute)}`:`data-${eE}`;return[new Ye({key:new Je("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:o}=n,s=[];if(!r)return null;const i=this.editor.isEmpty;return e.descendants((a,l)=>{const c=o>=l&&o<=l+a.nodeSize,u=!a.isLeaf&&Qf(a);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];i&&d.push(this.options.emptyEditorClass);const f=tn.node(l,l+a.nodeSize,{class:d.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:l,hasAnchor:c}):this.options.placeholder});s.push(f)}return this.options.includeChildren}),ft.create(e,s)}}})]}});at.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Ye({key:new Je("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||xC(n.selection)||t.view.dragging?null:ft.create(n.doc,[tn.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function tE({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var bQ=at.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Je(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new Ye({key:e,appendTransaction:(o,s,i)=>{const{doc:a,tr:l,schema:c}=i,u=e.getState(i),d=a.content.size,f=c.nodes[n];if(u)return l.insert(d,f.create())},state:{init:(o,s)=>{const i=s.tr.doc.lastChild;return!tE({node:i,types:r})},apply:(o,s)=>{if(!o.docChanged||o.getMeta("__uniqueIDTransaction"))return s;const i=o.doc.lastChild;return!tE({node:i,types:r})}}})]}}),vQ=at.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>XR(t,e),redo:()=>({state:t,dispatch:e})=>QR(t,e)}},addProseMirrorPlugins(){return[hQ(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()}}}),wQ=at.create({name:"starterKit",addExtensions(){var t,e,n,r;const o=[];return this.options.bold!==!1&&o.push(qJ.configure(this.options.bold)),this.options.blockquote!==!1&&o.push(HJ.configure(this.options.blockquote)),this.options.bulletList!==!1&&o.push(IR.configure(this.options.bulletList)),this.options.code!==!1&&o.push(XJ.configure(this.options.code)),this.options.codeBlock!==!1&&o.push(eX.configure(this.options.codeBlock)),this.options.document!==!1&&o.push(vR.configure(this.options.document)),this.options.dropcursor!==!1&&o.push(pQ.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&o.push(mQ.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&o.push(wR.configure(this.options.hardBreak)),this.options.heading!==!1&&o.push(nX.configure(this.options.heading)),this.options.undoRedo!==!1&&o.push(vQ.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&o.push(rX.configure(this.options.horizontalRule)),this.options.italic!==!1&&o.push(lX.configure(this.options.italic)),this.options.listItem!==!1&&o.push(DR.configure(this.options.listItem)),this.options.listKeymap!==!1&&o.push(UR.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&o.push(RR.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&o.push(zR.configure(this.options.orderedList)),this.options.paragraph!==!1&&o.push(HR.configure(this.options.paragraph)),this.options.strike!==!1&&o.push(qX.configure(this.options.strike)),this.options.text!==!1&&o.push(WR.configure(this.options.text)),this.options.underline!==!1&&o.push(YX.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&o.push(bQ.configure((r=this.options)==null?void 0:r.trailingNode)),o}}),xQ=wQ,EQ=at.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:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},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")}}}),SQ=EQ,kQ=jo.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",Qe(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),TQ=kQ,CQ=jo.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",Qe(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),AQ=CQ;const _Q=({children:t,width:e=100,minWidth:n=20,maxWidth:r=100,onResize:o,selected:s=!1,className:i=""})=>{const[a,l]=j.useState(!1),[c,u]=j.useState(null),[d,f]=j.useState(e),h=j.useRef(null),p=j.useRef(0),m=j.useRef(e),g=j.useRef(0),b=j.useRef(null),S=(x,A)=>{x.preventDefault(),p.current=x.clientX,m.current=d,u(A),l(!0)},k=()=>{if(!h.current||!c)return;const x=h.current.parentElement?.offsetWidth||1,E=g.current/x*100;let T=m.current;c==="right"?T=m.current+E:c==="left"&&(T=m.current-E),T=Math.min(r,Math.max(n,T)),f(T),o?.(T),b.current=null},v=x=>{!a||!c||(g.current=x.clientX-p.current,b.current||(b.current=requestAnimationFrame(k)))},_=()=>{l(!1),u(null),b.current&&(cancelAnimationFrame(b.current),b.current=null)};return j.useEffect(()=>{if(a)return window.addEventListener("mousemove",v),window.addEventListener("mouseup",_),()=>{window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",_)}},[a]),y.jsxs("div",{ref:h,className:oe("relative group",s?"ring-2 ring-blue-400 rounded-md":"",i),style:{width:`${d}%`},children:[t,y.jsx("div",{onMouseDown:x=>S(x,"left"),className:"absolute left-2 top-1/2 -translate-y-1/2 w-2 h-8 bg-blue-500 rounded-full cursor-col-resize opacity-0 group-hover:opacity-100"}),y.jsx("div",{onMouseDown:x=>S(x,"right"),className:"absolute right-2 top-1/2 -translate-y-1/2 w-2 h-8 bg-blue-500 rounded-full cursor-col-resize opacity-0 group-hover:opacity-100"})]})},ZR=({open:t,align:e,onAlign:n,onDelete:r})=>t?y.jsxs("div",{className:"z-999 bg-popover/40 border border-border/20 backdrop-blur-2xl text-popover-foreground rounded-lg outline-hidden absolute p-1 top-6 right-3 gap-3 w-fit flex items-center",children:[typeof n=="function"&&y.jsxs(y.Fragment,{children:[y.jsx(He,{active:e===_t.LEFT,icon:Q_,tooltip:"alignLeftKey",onClick:()=>n(_t.LEFT)}),y.jsx(He,{active:e===_t.CENTER,icon:M9,tooltip:"alignCenterKey",onClick:()=>n(_t.CENTER)}),y.jsx(He,{active:e===_t.RIGHT,icon:R9,tooltip:"alignRightKey",onClick:()=>n(_t.RIGHT)})]}),y.jsx(He,{variant:"destructive",className:"bg-transparent hover:bg-accent text-red-300 hover:text-destructive",icon:P9,tooltip:"deleteKey",onClick:r})]}):null;var MQ=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],OQ=MQ.reduce((t,e)=>{const n=Pa(`Primitive.${e}`),r=w.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),RQ="AspectRatio",eN=w.forwardRef((t,e)=>{const{ratio:n=1/1,style:r,...o}=t;return y.jsx("div",{style:{position:"relative",width:"100%",paddingBottom:`${100/n}%`},"data-radix-aspect-ratio-wrapper":"",children:y.jsx(OQ.div,{...o,ref:e,style:{...r,position:"absolute",top:0,right:0,bottom:0,left:0}})})});eN.displayName=RQ;var NQ=eN;function IQ({...t}){return y.jsx(NQ,{"data-slot":"aspect-ratio",...t})}function DQ(t,e=[]){let n=[];function r(s,i){const a=w.createContext(i);a.displayName=s+"Context";const l=n.length;n=[...n,i];const c=d=>{const{scope:f,children:h,...p}=d,m=f?.[t]?.[l]||a,g=w.useMemo(()=>p,Object.values(p));return y.jsx(m.Provider,{value:g,children:h})};c.displayName=s+"Provider";function u(d,f){const h=f?.[t]?.[l]||a,p=w.useContext(h);if(p)return p;if(i!==void 0)return i;throw new Error(`\`${d}\` must be used within \`${s}\``)}return[c,u]}const o=()=>{const s=n.map(i=>w.createContext(i));return function(a){const l=a?.[t]||s;return w.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return o.scopeName=t,[r,PQ(o,...e)]}function PQ(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(s){const i=r.reduce((a,{useScope:l,scopeName:c})=>{const d=l(s)[`__scope${c}`];return{...a,...d}},{});return w.useMemo(()=>({[`__scope${e.scopeName}`]:i}),[i])}};return n.scopeName=e.scopeName,n}var LQ=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],tN=LQ.reduce((t,e)=>{const n=Pa(`Primitive.${e}`),r=w.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),fv="Progress",jQ=100,[$Q]=DQ(fv),[FQ,UQ]=$Q(fv),nN=w.forwardRef((t,e)=>{const{__scopeProgress:n,value:r=null,max:o,getValueLabel:s=BQ,...i}=t;(o||o===0)&&nE(o);const a=nE(o)?o:jQ;r!==null&&rE(r,a);const l=rE(r,a)?r:null,c=pf(l)?s(l,a):void 0;return y.jsx(FQ,{scope:n,value:l,max:a,children:y.jsx(tN.div,{"aria-valuemax":a,"aria-valuemin":0,"aria-valuenow":pf(l)?l:void 0,"aria-valuetext":c,role:"progressbar","data-state":sN(l,a),"data-value":l??void 0,"data-max":a,...i,ref:e})})});nN.displayName=fv;var rN="ProgressIndicator",oN=w.forwardRef((t,e)=>{const{__scopeProgress:n,...r}=t,o=UQ(rN,n);return y.jsx(tN.div,{"data-state":sN(o.value,o.max),"data-value":o.value??void 0,"data-max":o.max,...r,ref:e})});oN.displayName=rN;function BQ(t,e){return`${Math.round(t/e*100)}%`}function sN(t,e){return t==null?"indeterminate":t===e?"complete":"loading"}function pf(t){return typeof t=="number"}function nE(t){return pf(t)&&!isNaN(t)&&t>0}function rE(t,e){return pf(t)&&!isNaN(t)&&t<=e&&t>=0}var zQ=nN,HQ=oN;function iN({className:t,value:e,...n}){return y.jsx(zQ,{"data-slot":"progress",className:oe("bg-primary/20 relative h-2 w-full overflow-hidden rounded-full",t),...n,children:y.jsx(HQ,{"data-slot":"progress-indicator",className:"bg-primary h-full w-full flex-1 transition-all",style:{transform:`translateX(-${100-(e||0)}%)`}})})}const aN=({open:t,onOpenChange:e,src:n,type:r,alt:o})=>y.jsx(sR,{open:t,onOpenChange:e,children:y.jsx(iR,{children:y.jsxs("div",{"data-theme":"select-post-builder",children:[y.jsx(aR,{className:"fixed inset-0 bg-black/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",style:{zIndex:999999},onClick:()=>e(!1)}),y.jsxs(lR,{className:"fixed inset-0 flex items-center justify-center pointer-events-none",style:{zIndex:999999,padding:"5rem 2rem 2rem"},onInteractOutside:()=>e(!1),children:[y.jsx(cR,{className:"sr-only",children:"Media Preview"}),y.jsxs("div",{className:"relative pointer-events-auto max-w-[80vw] max-h-[75vh]",children:[y.jsxs(ev,{className:"absolute top-3 right-3 z-10 rounded-full bg-black/40 backdrop-blur-md border border-white/20 shadow-lg hover:bg-black/60 p-2 text-white transition-colors cursor-pointer",children:[y.jsx(co,{className:"size-4"}),y.jsx("span",{className:"sr-only",children:"Close"})]}),r===ue.Image&&y.jsx("img",{src:n,alt:o||"Preview",className:"max-w-[80vw] max-h-[75vh] object-contain rounded-lg shadow-2xl"}),r===ue.Video&&y.jsx("video",{src:n,controls:!0,autoPlay:!0,className:"max-w-[80vw] max-h-[75vh] rounded-lg shadow-2xl"}),r===ue.Audio&&y.jsx("div",{className:"bg-white p-8 rounded-lg min-w-80 shadow-2xl",children:y.jsx("audio",{src:n,controls:!0,autoPlay:!0,className:"w-full"})})]})]})]})})}),VQ=({node:t,updateAttributes:e,editor:n,selected:r,getPos:o})=>{const[s,i]=j.useState(!1),{trackMediaRemoved:a}=Cs(),l=()=>{const u=o()??NaN;if(!Number.isFinite(u))return;const d=n.view.dom?.getAttribute("data-editor-type");n.chain().focus().deleteRange({from:u,to:u+t.nodeSize}).focus().run(),a({editorType:d,mediaType:t?.attrs?.type})},c=u=>e({align:u});return t.attrs.uploading?y.jsx(fi,{className:oe("flex my-4",t.attrs.align===_t.CENTER?"justify-center":t.attrs.align===_t.RIGHT?"justify-end":""),children:y.jsxs("div",{className:"w-full max-w-full",children:[y.jsxs("div",{className:"relative bg-muted rounded-lg overflow-hidden",children:[y.jsx(IQ,{ratio:t.attrs.type===ue.Audio?4/1:16/4,className:oe("flex items-center justify-center bg-muted"),children:y.jsxs("div",{className:"text-center space-y-3",children:[y.jsxs("div",{className:"flex justify-center",children:[t.attrs.type===ue.Image&&y.jsx(Ob,{className:"w-12 h-12 text-muted-foreground/50"}),t.attrs.type===ue.Video&&y.jsx(Rb,{className:"w-12 h-12 text-muted-foreground/50"}),t.attrs.type===ue.Audio&&y.jsx(_d,{className:"w-12 h-12 text-muted-foreground/50"})]}),y.jsxs("p",{className:"text-sm text-muted-foreground font-medium",children:["Uploading ",t.attrs.type,"..."]})]})}),y.jsx("div",{className:"absolute bottom-0 left-0 right-0 p-4",children:y.jsx(iN,{value:t.attrs.progress??0,className:"h-2"})}),y.jsx("button",{onClick:l,className:"absolute top-2 right-2 p-2 bg-background/90 hover:bg-background rounded-full shadow-sm transition-colors",title:"Cancel upload",children:y.jsx(co,{className:"w-4 h-4"})})]}),y.jsxs("p",{className:"text-xs text-muted-foreground text-center mt-2",children:[Math.round(t.attrs.progress??0),"%"]})]})}):y.jsxs(fi,{"data-drag-handle":!0,className:oe("flex",t.attrs.align===_t.CENTER?"justify-center":t.attrs.align===_t.RIGHT?"justify-end":""),children:[t.attrs.type===ue.Image?y.jsx(oE,{open:r,mediaType:t.attrs.type,align:t.attrs.align,onResize:u=>e({maxWidth:u}),onAlign:c,onDelete:l,children:y.jsx("img",{src:t.attrs.src,alt:t.attrs.caption,className:oe("object-contain w-full h-auto rounded-lg cursor-pointer",r&&"border-2 border-blue-500"),onDoubleClick:()=>i(!0)})}):t.attrs.type===ue.Video?y.jsx(oE,{open:r,mediaType:t.attrs.type,align:t.attrs.align,onResize:u=>e({maxWidth:u}),onAlign:c,onDelete:l,children:y.jsx("video",{src:t.attrs.src,poster:t.attrs.payload?.sources?.thumbnail?.url,controls:!0,className:oe("object-contain w-full h-auto",r&&"border-2 border-blue-500"),onDoubleClick:()=>i(!0)})}):t.attrs.type===ue.Audio?y.jsxs("div",{className:"relative p-4 bg-accent/20 border border-border/20 w-full",children:[y.jsx(ZR,{open:r,align:t.attrs.align,onAlign:c,onDelete:l}),y.jsx("audio",{src:t.attrs.src,controls:!0,className:oe("w-full",r&&"rounded-full border-2 border-blue-500")})]}):y.jsx("div",{className:"p-4 text-sm text-gray-600",children:"Unsupported media"}),y.jsx(aN,{open:s,onOpenChange:i,src:t.attrs.src,type:t.attrs.type,alt:t.attrs.caption})]})},oE=({open:t,align:e,onAlign:n,onDelete:r,onResize:o,mediaType:s,children:i})=>y.jsxs(_Q,{onResize:o,className:oe(s===ue.Audio&&"relative p-4 bg-accent/50"),children:[y.jsx(ZR,{open:t,align:e,onAlign:n,onDelete:r}),i]}),WQ=/\.(mp4|webm|ogg|mov)(\?|#|$)/i,KQ=t=>t.imageType?.startsWith("video/")||WQ.test(t.sources?.original?.url??""),GQ=t=>t?.sourceType==="image/gif"&&KQ(t),lN=(t,e)=>{if(t===ue.Video&&GQ(e)){const n=e.sources?.thumbnail?.url;return{autoplay:!0,loop:!0,muted:!0,playsinline:!0,...n?{poster:n}:{}}}return t===ue.Video||t===ue.Audio?{controls:!0}:{}},cN=t=>e=>({state:n,commands:r})=>{const{doc:o}=n;let s=null,i=null;return o.descendants((a,l)=>{if(a.type.name===t&&a.attrs.uid===e)return s=l,i=a.nodeSize,!1}),s!==null&&i!==null?r.deleteRange({from:s,to:Number(s)+Number(i)}):!1},uN=t=>(e,n)=>({state:r,dispatch:o})=>{if(!o)return!1;const{doc:s,tr:i}=r;let a=!1;return s.descendants((l,c)=>{if(l.type.name===t&&l.attrs.uid===e)return i.setNodeMarkup(c,void 0,{...l.attrs,...n}),a=!0,!1}),a?(o(i),!0):!1},qQ=t=>e=>({state:n,dispatch:r})=>{if(!r)return!1;const{doc:o,schema:s}=n;let i=n.tr,a=!1;const l=[];if(o.descendants((c,u)=>{c.isText&&c.marks?.length&&c.marks.forEach(d=>{d.type.name===t&&d.attrs.uid===e&&(l.push({from:u,to:u+c.nodeSize}),a=!0)})}),a){const c=s.marks[t];c&&(l.forEach(({from:u,to:d})=>{i=i.removeMark(u,d,c)}),r(i))}return a},YQ=t=>(e,n)=>({state:r,dispatch:o})=>{if(!o)return!1;const{doc:s,schema:i}=r;let a=r.tr,l=!1;const c=[];return s.descendants((u,d)=>{u.isText&&u.marks?.length&&u.marks.forEach(f=>{f.type.name===t&&f.attrs.uid===e&&(c.push({from:d,to:d+u.nodeSize,mark:f}),l=!0)})}),l&&(c.forEach(({from:u,to:d,mark:f})=>{const h={...f.attrs,...n},p=i.marks[t];p&&(a=a.removeMark(u,d,p),a=a.addMark(u,d,p.create(h)))}),o(a)),l},Br={uid:"",src:"",type:ue.Image,style:"object-fit: contain; width: 100%; border-radius: 0.5rem;",maxWidth:NL,align:_t.LEFT,caption:"",uploading:!1,progress:0},dN=Lt.create({name:"media",group:"block",atom:!0,addAttributes(){return{uid:{default:Br.uid},src:{default:Br.src},type:{default:Br.type},style:{default:Br.style},maxWidth:{default:Br.maxWidth},align:{default:Br.align},caption:{default:Br.caption},uploading:{default:Br.uploading},progress:{default:Br.progress},deferred:{default:!1},payload:{default:null}}},draggable(){return!this?.options?.attrs?.uploading&&!this?.options?.attrs?.mediaMode},selectable(){return!this?.options?.attrs?.mediaMode},parseHTML(){return[{tag:"div[data-media]",getAttrs:t=>{const e=t.getAttribute("data-payload");return{uid:t.getAttribute("data-uid")||"",src:t.getAttribute("data-src")||"",type:t.getAttribute("data-type")||ue.Image,align:t.getAttribute("data-align")||_t.LEFT,caption:t.getAttribute("data-caption")||"",style:t.getAttribute("style")||Br.style,payload:e?JSON.parse(e):null}}}]},renderHTML({HTMLAttributes:t}){const{uid:e,src:n,style:r,type:o,align:s,maxWidth:i,caption:a,payload:l}=t,c=Ey[o],u=Qe({style:JQ(s),"data-media":!0,"data-uid":e,"data-type":o,"data-src":n,"data-caption":a||"","data-align":s,...l?{"data-payload":JSON.stringify(l)}:{}}),d=Qe({src:n,style:XQ(r,o,i)},lN(o,l));return["div",u,[c,d]]},addNodeView(){return Nc(VQ)},addCommands(){return{insertMedia:t=>({commands:e,chain:n})=>this?.options?.attrs?.mediaMode?n().insertContent([{type:this.name,attrs:t}]).command(({tr:r,dispatch:o})=>{if(o){const s=r.doc.content.size,i=r.doc.resolve(s);r.setSelection(we.near(i))}return!0}).run():e.insertContent([{type:this.name,attrs:t},{type:"paragraph"}]),updateMediaByUid:uN(this.name),deleteMediaByUid:cN(this.name),updateMediaProgress:(t,e)=>({commands:n})=>n.updateMediaByUid(t,{progress:e}),deleteAllUploadingMedia:()=>({state:t,dispatch:e})=>{const{tr:n,doc:r}=t,o=[];return r.descendants((s,i)=>{(s.attrs.uploading===!0||s.attrs.deferred===!0)&&o.push(i)}),o.length===0||(o.reverse().forEach(s=>{const i=n.doc.nodeAt(s);i&&n.delete(s,s+i.nodeSize)}),e&&e(n)),!0}}},addKeyboardShortcuts(){return{Backspace:()=>{const{selection:t,doc:e}=this.editor.state,r=t.$anchor.nodeBefore;if(r?.type.name===this.name&&r.attrs.uploading)return Zt.info("Please wait for upload to complete or cancel it first"),!0;const o=e.nodeAt(t.from);return o?.type.name===this.name&&o.attrs.uploading?(Zt.info("Please wait for upload to complete or cancel it first"),!0):!1},Delete:()=>{const{selection:t,doc:e}=this.editor.state,r=t.$anchor.nodeAfter;if(r?.type.name===this.name&&r.attrs.uploading)return Zt.info("Please wait for upload to complete or cancel it first"),!0;const o=e.nodeAt(t.from);return o?.type.name===this.name&&o.attrs.uploading?(Zt.info("Please wait for upload to complete or cancel it first"),!0):!1}}}}),JQ=t=>`width: 100%; display: flex; justify-content: ${QQ(t)}; margin:16px 0`,XQ=(t,e,n)=>`${t}; max-width: ${e===ue.Audio?"100%":`${n}%`}; ${e!==ue.Audio?"height: auto;":""}`,QQ=t=>({[_t.LEFT]:"flex-start",[_t.CENTER]:"center",[_t.RIGHT]:"flex-end"})[t]||"flex-start",ZQ=({choice:t,index:e,canRemove:n,onRemove:r})=>{const o=dr[e%dr.length];return y.jsxs("div",{style:{backgroundColor:o},className:oe("relative rounded-xl flex items-center justify-center h-32 group overflow-hidden transition-all duration-200 hover:scale-[1.02] hover:shadow-md"),children:[y.jsx("span",{className:"text-center text-white font-medium px-4 py-3 text-sm sm:text-base leading-relaxed wrap-break-word w-full",children:t.text}),n&&y.jsx(fN,{onRemove:r,index:e}),y.jsx(hN,{number:e+1})]})},eZ=({choice:t,index:e,canRemove:n,onRemove:r})=>{const o=t.sources.original.url||t.sources.thumbnail.url,s=o.startsWith("blob:");return j.useEffect(()=>{if(o.startsWith("blob:"))return()=>URL.revokeObjectURL(o)},[o]),y.jsxs("div",{style:{backgroundColor:dr[e%dr.length]},className:"relative rounded-xl flex items-center justify-center h-32 group overflow-hidden transition-all duration-200 hover:scale-[1.02] hover:shadow-md bg-muted",children:[t.imageType.includes("video")?y.jsx("video",{src:t?.sources?.original?.url,className:"object-cover w-full h-full"}):y.jsx(tZ,{src:o,blurDataURL:t?.sources?.placeholder?.url,alt:`Poll choice ${e+1}`,width:t?.sources?.original?.width,height:t?.sources?.original?.height}),s&&y.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-1.5 bg-black/40 text-white pointer-events-none",children:[y.jsx(ms,{className:"h-5 w-5"}),y.jsx("span",{className:"text-xs font-medium",children:"Uploading..."})]}),n&&y.jsx(fN,{onRemove:r,index:e}),y.jsx(hN,{number:e+1})]})},fN=({onRemove:t,index:e})=>y.jsx("button",{onClick:t,className:"z-20 cursor-pointer absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity bg-background hover:bg-red-100 hover:text-destructive rounded-full p-1.5 shadow-md","aria-label":`Remove choice ${e+1}`,children:y.jsx(co,{className:"h-4 w-4"})}),hN=({number:t})=>y.jsx("div",{className:"absolute bottom-2 left-2 bg-background/80 backdrop-blur-sm text-foreground text-xs font-semibold rounded-full h-6 w-6 flex items-center justify-center shadow-sm",children:t}),tZ=({src:t,blurDataURL:e,alt:n,width:r,height:o,className:s="",...i})=>{const a=c=>c.startsWith("data:")?c:`data:image/png;base64,${c}`,l=r/o;return y.jsxs("div",{className:"relative overflow-hidden size-full",style:{aspectRatio:l},children:[e&&y.jsx("img",{src:a(e),alt:"","aria-hidden":!0,className:"z-10 absolute inset-0 size-full object-cover scale-110 transition-opacity duration-500"}),y.jsx("img",{src:t,alt:n,width:r,height:o,loading:"lazy",decoding:"async",className:oe("relative z-10 object-cover w-full h-full transition-opacity duration-500",l<1&&"object-contain",s),...i})]})},Nh=j.forwardRef(({className:t,type:e,...n},r)=>y.jsx("input",{ref:r,type:e,"data-slot":"input",className:oe("file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...n}));Nh.displayName="Input";const nZ=({open:t,onOpenChange:e,value:n,onChange:r,onSubmit:o,disabled:s})=>{const{t:i}=kn(),a=n.length>Gs.MAX_TEXT_LENGTH*.9,l=c=>{c.key==="Enter"&&(c.preventDefault(),o())};return y.jsx(Pc,{open:t,onOpenChange:e,children:y.jsxs(Lc,{children:[y.jsx(jc,{children:y.jsx($c,{children:i("addTextOptionKey")})}),y.jsxs("div",{className:"flex flex-col gap-2",children:[y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx(Nh,{autoFocus:!0,placeholder:i("enterTextOptionKey"),value:n,onChange:c=>r(c.target.value),onKeyDown:l,maxLength:Gs.MAX_TEXT_LENGTH,disabled:s,className:"transition-all"}),y.jsxs(zt,{onClick:o,disabled:!n.trim()||s,className:"shrink-0",size:"default",children:[y.jsx(wg,{className:"h-4 w-4 sm:mr-2"}),y.jsx("span",{className:"hidden sm:inline",children:i("addKey")})]})]}),y.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[y.jsx("span",{children:i("pressEnterToAddKey")}),y.jsxs("span",{className:oe("font-mono",a&&"text-amber-600 dark:text-amber-400 font-semibold"),children:[n.length,"/",Gs.MAX_TEXT_LENGTH]})]})]})]})})},rZ=({disabled:t,onFiles:e,onOpenSearch:n,onOpenText:r})=>{const{t:o}=kn(),s=j.useRef(null),[i,a]=j.useState(!1),l=h=>{t||(h.preventDefault(),h.stopPropagation(),a(!0))},c=h=>{h.preventDefault(),h.stopPropagation(),a(!1)},u=h=>{if(t)return;h.preventDefault(),h.stopPropagation(),a(!1);const p=Array.from(h.dataTransfer.files).filter(m=>m.type.startsWith("image/")||m.type.startsWith("video/"));p.length>0&&e(p)},d=h=>{const p=h.target.files;p&&(e(Array.from(p)),h.target.value="")},f="cursor-pointer flex-1 flex items-center justify-center text-muted-foreground transition-colors hover:bg-primary/10 hover:text-primary disabled:opacity-50 disabled:pointer-events-none";return y.jsxs(y.Fragment,{children:[y.jsx("input",{ref:s,type:"file",accept:"image/*,video/*",multiple:!0,className:"hidden",onChange:d,disabled:t,"aria-label":o("uploadKey")}),y.jsx("div",{onDragOver:l,onDragLeave:c,onDrop:u,className:oe("rounded-xl border-2 border-dashed h-32 overflow-hidden transition-all duration-200",i?"border-primary bg-primary/10 text-primary scale-[1.02] shadow-md":"border-muted-foreground/20"),children:i?y.jsxs("div",{className:"pointer-events-none flex h-full flex-col items-center justify-center gap-2 text-primary",children:[y.jsx(Ob,{className:"h-5 w-5 animate-bounce"}),y.jsx("span",{className:"text-xs font-medium",children:"Drop here"})]}):y.jsxs("div",{className:"flex h-full flex-col",children:[y.jsx("button",{type:"button",disabled:t,onClick:()=>s.current?.click(),"aria-label":o("uploadKey"),className:f,children:y.jsx(Y_,{className:"h-6 w-6"})}),y.jsx("button",{type:"button",disabled:t,onClick:n,"aria-label":o("searchGifOrImagesKey"),className:oe(f,"border-t border-border"),children:y.jsx(X_,{className:"h-6 w-6"})}),y.jsx("button",{type:"button",disabled:t,onClick:r,"aria-label":o("addTextOptionKey"),className:oe(f,"border-t border-border"),children:y.jsx(w9,{className:"h-6 w-6"})})]})})]})},oZ=({slotNumber:t})=>y.jsx("div",{className:"flex h-32 select-none items-center justify-center rounded-xl border-2 border-dashed border-muted-foreground/15 text-2xl font-bold text-muted-foreground/25 ",children:t}),sZ=()=>y.jsxs("div",{className:"flex h-32 flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-primary/50 bg-primary/5 text-primary ",children:[y.jsx(ms,{}),y.jsx("span",{className:"text-xs font-medium",children:"Uploading..."})]});function iZ({className:t,...e}){return y.jsx("div",{"data-slot":"card",className:oe("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",t),...e})}var jg=function(t,e){return jg=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var o in r)r.hasOwnProperty(o)&&(n[o]=r[o])},jg(t,e)};function aZ(t,e){jg(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var Ol=function(){return Ol=Object.assign||function(e){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},Ol.apply(this,arguments)};function lZ(t,e,n,r){var o,s=!1,i=0;function a(){o&&clearTimeout(o)}function l(){a(),s=!0}typeof e!="boolean"&&(r=n,n=e,e=void 0);function c(){var u=this,d=Date.now()-i,f=arguments;if(s)return;function h(){i=Date.now(),n.apply(u,f)}function p(){o=void 0}r&&!o&&h(),a(),r===void 0&&d>t?h():e!==!0&&(o=setTimeout(r?p:h,r===void 0?t-d:t))}return c.cancel=l,c}var Ji={Pixel:"Pixel",Percent:"Percent"},sE={unit:Ji.Percent,value:.8};function iE(t){return typeof t=="number"?{unit:Ji.Percent,value:t*100}:typeof t=="string"?t.match(/^(\d*(\.\d+)?)px$/)?{unit:Ji.Pixel,value:parseFloat(t)}:t.match(/^(\d*(\.\d+)?)%$/)?{unit:Ji.Percent,value:parseFloat(t)}:sE:sE}var cZ=(function(t){aZ(e,t);function e(n){var r=t.call(this,n)||this;return r.lastScrollTop=0,r.actionTriggered=!1,r.startY=0,r.currentY=0,r.dragging=!1,r.maxPullDownDistance=0,r.getScrollableTarget=function(){return r.props.scrollableTarget instanceof HTMLElement?r.props.scrollableTarget:typeof r.props.scrollableTarget=="string"?document.getElementById(r.props.scrollableTarget):(r.props.scrollableTarget,null)},r.onStart=function(o){r.lastScrollTop||(r.dragging=!0,o instanceof MouseEvent?r.startY=o.pageY:o instanceof TouchEvent&&(r.startY=o.touches[0].pageY),r.currentY=r.startY,r._infScroll&&(r._infScroll.style.willChange="transform",r._infScroll.style.transition="transform 0.2s cubic-bezier(0,0,0.31,1)"))},r.onMove=function(o){r.dragging&&(o instanceof MouseEvent?r.currentY=o.pageY:o instanceof TouchEvent&&(r.currentY=o.touches[0].pageY),!(r.currentY<r.startY)&&(r.currentY-r.startY>=Number(r.props.pullDownToRefreshThreshold)&&r.setState({pullToRefreshThresholdBreached:!0}),!(r.currentY-r.startY>r.maxPullDownDistance*1.5)&&r._infScroll&&(r._infScroll.style.overflow="visible",r._infScroll.style.transform="translate3d(0px, "+(r.currentY-r.startY)+"px, 0px)")))},r.onEnd=function(){r.startY=0,r.currentY=0,r.dragging=!1,r.state.pullToRefreshThresholdBreached&&(r.props.refreshFunction&&r.props.refreshFunction(),r.setState({pullToRefreshThresholdBreached:!1})),requestAnimationFrame(function(){r._infScroll&&(r._infScroll.style.overflow="auto",r._infScroll.style.transform="none",r._infScroll.style.willChange="unset")})},r.onScrollListener=function(o){typeof r.props.onScroll=="function"&&setTimeout(function(){return r.props.onScroll&&r.props.onScroll(o)},0);var s=r.props.height||r._scrollableNode?o.target:document.documentElement.scrollTop?document.documentElement:document.body;if(!r.actionTriggered){var i=r.props.inverse?r.isElementAtTop(s,r.props.scrollThreshold):r.isElementAtBottom(s,r.props.scrollThreshold);i&&r.props.hasMore&&(r.actionTriggered=!0,r.setState({showLoader:!0}),r.props.next&&r.props.next()),r.lastScrollTop=s.scrollTop}},r.state={showLoader:!1,pullToRefreshThresholdBreached:!1,prevDataLength:n.dataLength},r.throttledOnScrollListener=lZ(150,r.onScrollListener).bind(r),r.onStart=r.onStart.bind(r),r.onMove=r.onMove.bind(r),r.onEnd=r.onEnd.bind(r),r}return e.prototype.componentDidMount=function(){if(typeof this.props.dataLength>"u")throw new Error('mandatory prop "dataLength" is missing. The prop is needed when loading more content. Check README.md for usage');if(this._scrollableNode=this.getScrollableTarget(),this.el=this.props.height?this._infScroll:this._scrollableNode||window,this.el&&this.el.addEventListener("scroll",this.throttledOnScrollListener),typeof this.props.initialScrollY=="number"&&this.el&&this.el instanceof HTMLElement&&this.el.scrollHeight>this.props.initialScrollY&&this.el.scrollTo(0,this.props.initialScrollY),this.props.pullDownToRefresh&&this.el&&(this.el.addEventListener("touchstart",this.onStart),this.el.addEventListener("touchmove",this.onMove),this.el.addEventListener("touchend",this.onEnd),this.el.addEventListener("mousedown",this.onStart),this.el.addEventListener("mousemove",this.onMove),this.el.addEventListener("mouseup",this.onEnd),this.maxPullDownDistance=this._pullDown&&this._pullDown.firstChild&&this._pullDown.firstChild.getBoundingClientRect().height||0,this.forceUpdate(),typeof this.props.refreshFunction!="function"))throw new Error(`Mandatory prop "refreshFunction" missing.
211
- Pull Down To Refresh functionality will not work
212
- as expected. Check README.md for usage'`)},e.prototype.componentWillUnmount=function(){this.el&&(this.el.removeEventListener("scroll",this.throttledOnScrollListener),this.props.pullDownToRefresh&&(this.el.removeEventListener("touchstart",this.onStart),this.el.removeEventListener("touchmove",this.onMove),this.el.removeEventListener("touchend",this.onEnd),this.el.removeEventListener("mousedown",this.onStart),this.el.removeEventListener("mousemove",this.onMove),this.el.removeEventListener("mouseup",this.onEnd)))},e.prototype.componentDidUpdate=function(n){this.props.dataLength!==n.dataLength&&(this.actionTriggered=!1,this.setState({showLoader:!1}))},e.getDerivedStateFromProps=function(n,r){var o=n.dataLength!==r.prevDataLength;return o?Ol(Ol({},r),{prevDataLength:n.dataLength}):null},e.prototype.isElementAtTop=function(n,r){r===void 0&&(r=.8);var o=n===document.body||n===document.documentElement?window.screen.availHeight:n.clientHeight,s=iE(r);return s.unit===Ji.Pixel?n.scrollTop<=s.value+o-n.scrollHeight+1:n.scrollTop<=s.value/100+o-n.scrollHeight+1},e.prototype.isElementAtBottom=function(n,r){r===void 0&&(r=.8);var o=n===document.body||n===document.documentElement?window.screen.availHeight:n.clientHeight,s=iE(r);return s.unit===Ji.Pixel?n.scrollTop+o>=n.scrollHeight-s.value:n.scrollTop+o>=s.value/100*n.scrollHeight},e.prototype.render=function(){var n=this,r=Ol({height:this.props.height||"auto",overflow:"auto",WebkitOverflowScrolling:"touch"},this.props.style),o=this.props.hasChildren||!!(this.props.children&&this.props.children instanceof Array&&this.props.children.length),s=this.props.pullDownToRefresh&&this.props.height?{overflow:"auto"}:{};return w.default.createElement("div",{style:s,className:"infinite-scroll-component__outerdiv"},w.default.createElement("div",{className:"infinite-scroll-component "+(this.props.className||""),ref:function(i){return n._infScroll=i},style:r},this.props.pullDownToRefresh&&w.default.createElement("div",{style:{position:"relative"},ref:function(i){return n._pullDown=i}},w.default.createElement("div",{style:{position:"absolute",left:0,right:0,top:-1*this.maxPullDownDistance}},this.state.pullToRefreshThresholdBreached?this.props.releaseToRefreshContent:this.props.pullDownToRefreshContent)),this.props.children,!this.state.showLoader&&!o&&this.props.hasMore&&this.props.loader,this.state.showLoader&&this.props.hasMore&&this.props.loader,!this.props.hasMore&&this.props.endMessage))},e})(j.Component);function uZ(t=20){const[e,n]=j.useState({offset:0,limit:t,hasMore:!0,isLoading:!1}),r=j.useCallback(()=>{n({offset:0,limit:t,hasMore:!0,isLoading:!1})},[t]),o=j.useCallback(()=>{n(a=>({...a,offset:a.offset+a.limit}))},[]),s=j.useCallback(a=>{n(l=>({...l,isLoading:a}))},[]),i=j.useCallback(a=>{n(l=>({...l,hasMore:a}))},[]);return{...e,reset:r,loadMore:o,setLoading:s,setHasMore:i}}function aE(t){const{core:e}=wi(),[n,r]=j.useState([]),[o,s]=j.useState(""),i=uZ(),a=j.useCallback(async({offset:d,limit:f,query:h,reset:p=!1})=>{i.setLoading(!0);try{const m=h?await e.searchWebImage(h,f,d):await e.fetchTrendyWebImage(f,d);m.length===0?i.setHasMore(!1):r(g=>p?m:[...g,...m])}catch{i.setHasMore(!1)}finally{i.setLoading(!1)}},[e,i]),l=j.useCallback(async({offset:d,limit:f,query:h="",reset:p=!1})=>{i.setLoading(!0);try{const m=h?await e.searchWebGif(h,f,d):await e.fetchTrendyWebGif(f,d);m.length===0?i.setHasMore(!1):r(g=>p?m:[...g,...m])}catch{i.setHasMore(!1)}finally{i.setLoading(!1)}},[e,i]),c=j.useCallback(d=>t==="images"?a(d):l(d),[t,a,l]),u=j.useCallback(()=>{r([]),s(""),i.reset()},[i]);return{items:n,...i,searchQuery:o,setSearchQuery:s,fetch:c,reset:u}}const dZ=6e4,nm={limit:IL,offset:0,query:"",reset:!0};function pN({open:t,onOpenChange:e,onImageSelect:n,initialQuery:r,children:o}){const{t:s}=kn(),[i,a]=j.useState("gifs"),[l,c]=j.useState(r??""),u=j.useRef(null),d=j.useRef(),f=aE("images"),h=aE("gifs"),p=j.useRef(h),m=j.useRef({gifs:{query:"",timestamp:0},images:{query:"",timestamp:0}}),g=j.useCallback((E,T)=>{const N=m.current[E];return N.query===T&&Date.now()-N.timestamp<dZ},[]),b=j.useCallback((E,T)=>{m.current[E]={query:T,timestamp:Date.now()}},[]);j.useEffect(()=>{if(!t)return;const E=r??"";c(E);const T={...nm,query:E};return h.fetch(T).catch(N=>{}),f.fetch(T).catch(N=>{}),b("gifs",E),b("images",E),d.current=setTimeout(()=>{u.current?.select()},0),()=>{clearTimeout(d.current)}},[t]),j.useEffect(()=>{p.current=i==="images"?f:h},[i,f,h]);const S=E=>{clearTimeout(d.current),k.cancel(),e?.(E),E||(f.reset(),h.reset(),c(""),m.current={gifs:{query:"",timestamp:0},images:{query:"",timestamp:0}})},k=j.useMemo(()=>m6(async(E,T)=>{const N=p.current;N.reset(),await N.fetch({...nm,query:E}),b(T,E)},500),[b]);j.useEffect(()=>()=>{k.cancel(),clearTimeout(d.current)},[k]);const v=j.useCallback(E=>{c(E),k(E,i)?.catch(T=>{})},[k,i]),_=j.useCallback(E=>{const T=E;if(k.cancel(),a(T),g(T,l))return;const N=T==="images"?f:h;N.reset(),N.fetch({...nm,query:l}).then(()=>b(T,l)).catch(I=>{})},[k,l,g,f,h,b]),x=j.useCallback(async()=>{const E=p.current,T=E.offset+E.limit;E.loadMore(),await E.fetch({offset:T,limit:E.limit,query:l})},[l]),A=j.useCallback(E=>{n?.(E,i==="gifs"?Yr?.Gif:i==="images"?Yr.Image:void 0),e(!1)},[i,n,e]);return y.jsxs(Pc,{open:t,onOpenChange:S,children:[y.jsx(uR,{asChild:!0,children:o??y.jsx(zt,{children:"Open Search Modal"})}),y.jsxs(Lc,{className:"max-w-4xl w-full h-[80vh] flex flex-col overflow-hidden px-0 py-0 -translate-1/2",children:[y.jsx(jc,{className:"p-4 border-b bg-accent",children:y.jsx($c,{children:s("mediaSearchTitleKey")})}),y.jsxs(oA,{defaultValue:"gifs",value:i,onValueChange:_,className:"flex-1 grow flex flex-col overflow-y-auto",children:[y.jsx("div",{className:"px-4",children:y.jsxs(sA,{className:"grid w-full grid-cols-2",children:[y.jsx(og,{value:"gifs",children:s("gifSearchKey")}),y.jsx(og,{value:"images",children:s("imageSearchKey")})]})}),y.jsx(hv,{ref:u,value:l,onChange:v,placeholder:s(i==="gifs"?"searchGifPlaceholder":"searchIMagePlaceholder")}),y.jsx(nx,{value:"images",className:"flex-1 grow mt-4 overflow-y-auto",children:y.jsx($g,{items:f.items,onItemClick:A,hasMore:f.hasMore,loadMore:x,scrollTargetId:R0.images})}),y.jsx(nx,{value:"gifs",className:"flex-1 grow mt-4 overflow-y-auto",children:y.jsx($g,{items:h.items,onItemClick:A,hasMore:h.hasMore,loadMore:x,scrollTargetId:R0.gifs})})]})]})]})}const hv=w.default.forwardRef(({value:t,onChange:e,placeholder:n},r)=>y.jsx("div",{className:"mt-2 px-4",children:y.jsxs("div",{className:"relative",children:[y.jsx(X_,{className:"absolute left-3 top-1/2 -translate-y-1/2 transform-none h-4 w-4 text-muted-foreground"}),y.jsx(Nh,{ref:r,type:"text",placeholder:n,value:t,onChange:o=>e(o.target.value),className:"pl-9"})]})}));hv.displayName="SearchBar";function $g({items:t,onItemClick:e,hasMore:n,loadMore:r,scrollTargetId:o}){const s=a=>a?.thumbnail?.url||a?.source?.url,i=a=>a?.source?.url||a?.thumbnail?.url;return y.jsx("div",{id:o,className:"h-full overflow-y-auto",children:y.jsx(cZ,{dataLength:t.length,next:r,hasMore:n,loader:y.jsx("div",{className:"flex justify-center py-4",children:y.jsx(ms,{className:"h-6 w-6"})}),endMessage:y.jsx("p",{className:"text-center text-muted-foreground py-4",children:t.length===0?"No items found":"No more items to load"}),scrollableTarget:o,children:y.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 py-2 px-4",children:t.map(a=>y.jsx(iZ,{className:"py-0 overflow-hidden cursor-pointer hover:ring-2 hover:ring-primary transition-all",onClick:()=>e(i(a)),children:y.jsx("img",{loading:"lazy",src:s(a),alt:"Media item",className:"w-full h-32 object-cover"})},i(a)))})})})}const fZ=Object.freeze(Object.defineProperty({__proto__:null,ImageSearchModal:pN,MediaGrid:$g,SearchBar:hv},Symbol.toStringTag,{value:"Module"})),pv=(t,e=Vn.MEDIA_ITEM,n)=>({key:Dt(),type:e,imageType:t?.type,sourceType:t?.source_type,...n?{searchFrom:n}:{},sources:{original:{url:t?.high_resolution??t?.url,width:t?.width,height:t?.height,isBase64:!1},thumbnail:{url:t?.thumbnail,width:t?.width,height:t?.height,isBase64:!1},...t?.placeholder?{placeholder:{url:t?.placeholder,width:t?.width,height:t?.height,isBase64:!0}}:{}},playableDuration:t?.playableDuration??null}),hZ=t=>"text"in t,pZ=(t,e)=>({key:Dt(),type:So.POLL_TEXT_ITEM,option_id:Dt(),option_color:dr[e%dr.length],text:t.trim()}),lE=(t,e,n)=>{const o=t?.type?.includes("video")?So.POLL_MEDIA_ITEM:So.POLL_IMAGE_ITEM;return{...pv(t,o,n),option_color:dr[e%dr.length],option_id:Dt()}},mZ=(t,e,n)=>{const r=t.type.startsWith("video/");return{key:Dt(),type:r?So.POLL_MEDIA_ITEM:So.POLL_IMAGE_ITEM,imageType:t.type,sources:{original:{url:e,width:0,height:0,isBase64:!1},thumbnail:{url:e,width:0,height:0,isBase64:!1},placeholder:{url:"",width:0,height:0,isBase64:!0}},playableDuration:null,option_color:dr[n%dr.length],option_id:Dt()}},mN=t=>t.length!==1?t:t.concat(t).map((e,n)=>({...e,key:e?.key??Dt(),option_id:n===0?e.option_id:Dt(),option_color:dr[n%dr.length]})),Zn=t=>"type"in t&&t.type==="placeholder",gZ=({choices:t,onChange:e})=>{const{fileStore:n}=wi(),{allowSendWhileUploading:r,t:o}=kn(),{editor:s}=Sh(),[i,a]=j.useState(""),[l,c]=j.useState(!1),[u,d]=j.useState(!1),[f,h]=j.useState(t),{trackPollOptionAdded:p,trackPollOptionRemoved:m,trackMediaUploadFailed:g,trackMediaUploadSuccess:b}=Cs(),S=j.useRef(!1);j.useEffect(()=>{S.current||h(t),S.current=!1},[t]);const k=Gs.MAX-f.length,v=f.length<Gs.MAX,_=f.filter(O=>!Zn(O)),x=_.length>=Gs.MIN,A=j.useRef(_.length);j.useEffect(()=>{const O=A.current,P=_.length;A.current=P,O===0&&P>=1&&requestAnimationFrame(()=>{if(!s||s.isDestroyed)return;let C="";if(s.state.doc.forEach(U=>{U.type.name==="paragraph"&&(C+=U.textContent)}),C.trim())return;const M=o("pollQuestionPlaceholderKey");s.chain().insertContentAt(1,M).setTextSelection({from:1,to:1+M.length}).focus().run()})},[_.length,s,o]);const E=O=>{const P=O.filter(C=>!Zn(C));S.current=!0,e(P)},T=O=>{h(O),setTimeout(()=>{E(O)},0)},N=()=>{if(!i.trim()||!v)return;const O=pZ(i,f.length),P=[...f,O];T(P),p({option_count:P.length,option_type:"text"}),a(""),c(!1)},I=async O=>{if(!O||!v)return;let P=O.slice(0,k);const C=P.filter(V=>!rg(V,pl,[]).valid);if(C.length>0){const V=C.map(W=>`"${W.name}"`).join(", ");if(Zt.error(`${C.length>1?"Some files exceed":`${V} exceeds`} the ${pl/1024/1024}MB limit`),P=P.filter(W=>rg(W,pl,[]).valid),P.length===0)return}const M=f.length;if(P=await Promise.all(P.map(async V=>{if(V.type.startsWith("image/"))try{return await Yt(V,{maxSizeMB:10})}catch{return V}return V})),!r){const V=P.map((H,B)=>({type:"placeholder",key:`placeholder-${Date.now()}-${B}`})),W=[...f,...V];h(W);try{const H=P.map(async($,K)=>{try{const Y=await n.uploadImage($);return b({editorType:Pe.Poll,mediaType:$.type.startsWith("video/")?"video":"image",fileSizeMB:$.size/1048576,source:"local"}),lE(Y,M+K)}catch{return g({editorType:Pe.Poll,mediaType:$.type.startsWith("video/")?"video":"image",fileSizeMB:$.size/1048576,source:"local",errorType:"server_error"}),null}}),B=await Promise.all(H);h($=>{const K=[...$];B.forEach((J,Q)=>{const ne=M+Q;J!==null&&ne<K.length&&(K[ne]=J)});const Y=K.filter(J=>!Zn(J));return B?.forEach(J=>{J!==null&&p({option_count:Y.length,option_type:N0[J.type]})}),setTimeout(()=>{E(Y)},0),Y})}catch{h(B=>{const $=B.filter(K=>!Zn(K));return setTimeout(()=>{E($)},0),$})}return}const U=s?.storage?.poll;if(!U)return;const L=P.map((V,W)=>{const H=URL.createObjectURL(V);return{placeholder:mZ(V,H,M+W),blob:V,blobUrl:H}}),F=[...f,...L.map(V=>V.placeholder)];h(F),setTimeout(()=>E(F),0),L.forEach(({placeholder:V,blob:W})=>{const H=new AbortController,B=W instanceof File?W:new File([W],V.key,{type:W.type}),$=n.uploadChunked(B,void 0,H.signal).then(K=>({...V,imageType:K.type??V.imageType,sourceType:K.source_type,sources:{original:{url:K.high_resolution??K.url,width:K.width??0,height:K.height??0,isBase64:!1},thumbnail:{url:K.thumbnail??K.url,width:K.width??0,height:K.height??0,isBase64:!1},placeholder:{url:K.placeholder??"",width:K.width??0,height:K.height??0,isBase64:!0}}}));$.catch(()=>{}),$.then(K=>{h(Y=>{const J=Y.map(Q=>!Zn(Q)&&Q.key===V.key?K:Q);return setTimeout(()=>E(J),0),J})}).catch(()=>{}),U.registerPendingUpload(V.key,{blob:W,promise:$,abort:()=>H.abort()})})},R=async(O,P)=>{if(!v)return;const C=f.length,M={type:"placeholder",key:`placeholder-${Date.now()}`},U=[...f,M];h(U);try{const L=await n.uploadUrl(O),F=lE(L,C,P),V=P===Yr.Gif||L?.url?.toLowerCase().includes(".gif");b({editorType:Pe.Poll,mediaType:V?"gif":"image",fileSizeMB:0,source:P===Yr?.Gif?"gif_search":"image_search"}),h(W=>{const H=[...W];return C<H.length&&Zn(H[C])&&(H[C]=F),p({option_count:H.filter(B=>!Zn(B)).length,option_type:V?"gif":"image"}),setTimeout(()=>{E(H)},0),H})}catch{g({editorType:Pe.Poll,mediaType:P===Yr.Gif?"gif":"image",fileSizeMB:0,source:P===Yr.Gif?"gif_search":"image_search",errorType:"server_error"}),h(F=>{const V=F.filter(W=>!Zn(W));return setTimeout(()=>{E(V)},0),V})}},D=O=>{if(!x)return;const P=f[O];if(!Zn(P)){const M=s?.storage?.poll,U=M?.getPendingUpload?.(P.key);U&&(U.abort(),M.clearPendingUpload(P.key))}const C=f.filter((M,U)=>U!==O);Zn(P)||m({option_count:C.filter(M=>!Zn(M)).length,option_type:N0[P.type]}),T(C)};return y.jsxs("div",{"data-type":"poll",className:"w-full",children:[y.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:gap-4 lg:grid-cols-4",children:[f.map((O,P)=>Zn(O)?y.jsx(sZ,{},O.key):hZ(O)?y.jsx(ZQ,{choice:O,index:P,canRemove:x,onRemove:()=>D(P)},O.key):y.jsx(eZ,{choice:O,index:P,canRemove:x,onRemove:()=>D(P)},O.key)),v&&y.jsx(rZ,{disabled:!v,onFiles:O=>{I(O)},onOpenSearch:()=>d(!0),onOpenText:()=>c(!0)}),Array.from({length:Math.max(0,k-1)}).map((O,P)=>y.jsx(oZ,{slotNumber:f.length+2+P},`empty-${P}`))]}),y.jsx(nZ,{open:l,onOpenChange:c,value:i,onChange:a,onSubmit:N,disabled:!v}),u&&y.jsx(pN,{open:u,onOpenChange:d,onImageSelect:(O,P)=>{R(O,P)},initialQuery:RO(s)})]})},yZ=({node:t,updateAttributes:e})=>{const{choices:n}=t.attrs,r=o=>{e({choices:o})};return y.jsx(fi,{"data-type":"poll","data-drag-handle":"false",className:"not-prose mt-5 select-none",children:y.jsx(gZ,{choices:n,onChange:r,onRemovePoll:()=>{}})})},gN=Lt.create({name:"poll",group:"block",atom:!0,draggable:!1,selectable:!1,addAttributes(){return{choices:{default:[]}}},parseHTML(){return[{tag:'div[data-type="poll"]'}]},renderHTML({HTMLAttributes:t}){return["div",Qe(t,{"data-type":"poll"})]},addNodeView(){return Nc(yZ)},addStorage(){const t=new Map;return{pendingUploads:t,getPendingUpload(e){return t.get(e)},registerPendingUpload(e,n){t.set(e,n)},clearPendingUpload(e){t.delete(e)}}},addCommands(){return{insertPoll:t=>({chain:e})=>e().insertContent({type:this.name,attrs:t}).run()}},addProseMirrorPlugins(){const t=this.name;return[new Ye({key:new Je("pollKeyHandlerPlugin"),props:{handleKeyDown:(e,n)=>{const{state:r}=e,{selection:o}=r,s=n.key;if(s!=="Backspace"&&s!=="Delete")return!1;if(o instanceof me&&o.node.type.name===t)return n.preventDefault(),!0;const{$from:i,empty:a}=o;if(a&&i){const l=i.nodeBefore;if(l&&l.type.name===t&&s==="Backspace")return n.preventDefault(),!0;const c=i.nodeAfter;if(c&&c.type.name===t&&s==="Delete")return n.preventDefault(),!0}return!1},handleDOMEvents:{mousedown:(e,n)=>{const r=n,o=r.target;if(!o||o.closest('input, textarea, button, select, [contenteditable="true"]'))return!1;const s=o.closest('[data-type="poll"]')??null;if(!s)return!1;r.preventDefault();const i=e.posAtDOM(s,0);if(typeof i=="number"){const a=e.state.doc.resolve(i);let l=i;const c=a.nodeAfter;if(c&&c.type.name===t&&(l=i+c.nodeSize),l<=e.state.doc.content.size){const u=e.state.tr.setSelection(we.create(e.state.doc,l));e.dispatch(u),e.focus()}}return!0}}},appendTransaction:(e,n,r)=>{const o=a=>{let l=0;return a.descendants(c=>{c.type.name===t&&l++}),l},s=o(n.doc),i=o(r.doc);if(s>0&&i===0){const a=r.tr;return a.replaceWith(0,r.doc.content.size,n.doc.content),a}}})]}});var bZ=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],vZ=bZ.reduce((t,e)=>{const n=Pa(`Primitive.${e}`),r=w.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{}),wZ="Separator",cE="horizontal",xZ=["horizontal","vertical"],yN=w.forwardRef((t,e)=>{const{decorative:n,orientation:r=cE,...o}=t,s=EZ(r)?r:cE,a=n?{role:"none"}:{"aria-orientation":s==="vertical"?s:void 0,role:"separator"};return y.jsx(vZ.div,{"data-orientation":s,...a,...o,ref:e})});yN.displayName=wZ;function EZ(t){return xZ.includes(t)}var SZ=yN;function uE({className:t,orientation:e="horizontal",decorative:n=!0,...r}){return y.jsx(SZ,{"data-slot":"separator",decorative:n,orientation:e,className:oe("bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",t),...r})}function kZ({className:t,...e}){return y.jsx("fieldset",{"data-slot":"field-set",className:oe("flex flex-col gap-6","has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",t),...e})}function TZ({className:t,...e}){return y.jsx("div",{"data-slot":"field-group",className:oe("group/field-group @container/field-group flex w-full flex-col gap-7 data-[slot=checkbox-group]:gap-3 [&>[data-slot=field-group]]:gap-4",t),...e})}const CZ=vh("group/field flex w-full gap-3 data-[invalid=true]:text-destructive",{variants:{orientation:{vertical:["flex-col [&>*]:w-full [&>.sr-only]:w-auto"],horizontal:["flex-row items-center","[&>[data-slot=field-label]]:flex-auto","has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"],responsive:["flex-col [&>*]:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto","@md/field-group:[&>[data-slot=field-label]]:flex-auto","@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"]}},defaultVariants:{orientation:"vertical"}});function dE({className:t,orientation:e="vertical",...n}){return y.jsx("div",{role:"group","data-slot":"field","data-orientation":e,className:oe(CZ({orientation:e}),t),...n})}function fE({className:t,...e}){return y.jsx(Tg,{"data-slot":"field-label",className:oe("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4","has-data-[state=checked]:bg-primary/5 has-data-[state=checked]:border-primary dark:has-data-[state=checked]:bg-primary/10",t),...e})}function AZ({className:t,children:e,errors:n,...r}){const o=j.useMemo(()=>e||(n?n?.length===1&&n[0]?.message?n[0].message:y.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:n.map((s,i)=>s?.message&&y.jsx("li",{children:s.message},i))}):null),[e,n]);return o?y.jsx("div",{role:"alert","data-slot":"field-error",className:oe("text-destructive text-sm font-normal",t),...r,children:o}):null}function _Z({className:t,...e}){return y.jsx("textarea",{"data-slot":"textarea",className:oe("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),...e})}const Fg=j.forwardRef(({className:t,...e},n)=>y.jsx("div",{ref:n,"data-slot":"input-group",role:"group",className:oe("group/input-group border-input dark:bg-input/30 relative flex w-full items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none","h-9 min-w-0 has-[>textarea]:h-auto","has-[>[data-align=inline-start]]:[&>input]:pl-2","has-[>[data-align=inline-end]]:[&>input]:pr-2","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3","has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-[3px]","has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40",t),...e}));Fg.displayName="InputGroup";const MZ=vh("text-muted-foreground flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*='size-'])]:size-4 [&>kbd]:rounded-[calc(var(--radius)-5px)] group-data-[disabled=true]/input-group:opacity-50",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]","block-start":"order-first w-full justify-start px-3 pt-3 [.border-b]:pb-3 group-has-[>input]/input-group:pt-2.5","block-end":"order-last w-full justify-start px-3 pb-3 [.border-t]:pt-3 group-has-[>input]/input-group:pb-2.5"}},defaultVariants:{align:"inline-start"}}),Ug=j.forwardRef(({className:t,align:e="inline-start",...n},r)=>y.jsx("div",{ref:r,role:"group","data-slot":"input-group-addon","data-align":e,className:oe(MZ({align:e}),t),onClick:o=>{o.target.closest("button")||o.currentTarget.parentElement?.querySelector("input")?.focus()},...n}));Ug.displayName="InputGroupAddon";const OZ=vh("text-sm shadow-none flex gap-2 items-center",{variants:{size:{xs:"h-6 gap-1 px-2 rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-3.5 has-[>svg]:px-2",sm:"h-8 px-2.5 gap-1.5 rounded-md has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}}),RZ=j.forwardRef(({className:t,type:e="button",variant:n="ghost",size:r="xs",...o},s)=>y.jsx(zt,{ref:s,type:e,"data-size":r,variant:n,className:oe(OZ({size:r}),t),...o}));RZ.displayName="InputGroupButton";const NZ=j.forwardRef(({className:t,...e},n)=>y.jsx("span",{ref:n,className:oe("text-muted-foreground flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",t),...e}));NZ.displayName="InputGroupText";const Bg=j.forwardRef(({className:t,ref:e,...n},r)=>y.jsx(Nh,{ref:r,"data-slot":"input-group-control",className:oe("flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent",t),...n}));Bg.displayName="InputGroupInput";const IZ=j.forwardRef(({className:t,...e},n)=>y.jsx(_Z,{ref:n,"data-slot":"input-group-control",className:oe("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent",t),...e}));IZ.displayName="InputGroupTextarea";const DZ=/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/i,bN=/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?(?:[^\s&]*&)*v=|youtu\.be\/)[\w-]+(?:[^\s]*)/gi,PZ=/(?:v=|\/)([a-zA-Z0-9_-]{11})(?:[?&].*)?$/,vN=/^(?:https?:\/\/)?(?:www\.)?open\.spotify\.com\/(track|playlist|album)\/[A-Za-z0-9_-]+/gi,LZ=/[\n\r]/g,bn=t=>t?`https://${t.trim().replace(/\s+/g,"").replace(/^(https?:\/\/)+/i,"")}`:"",ns=t=>DZ.test(t),jZ=async t=>{try{return(await Et.head(t,{timeout:5e3})).headers["content-type"]}catch{return null}},$Z=async t=>{try{const n=await jZ(t);if(n?.startsWith("image/"))return{type:ue.Image,src:t};if(n?.startsWith("video/"))return{type:ue.Video,src:t};if(n?.startsWith("audio/"))return{type:ue.Audio,src:t}}catch{}const e=t.split(".").pop()?.toLowerCase();if(e){if(["jpg","jpeg","png","gif","webp","avif"].includes(e))return{type:ue.Image,src:t};if(["mp4","webm","mov","mkv"].includes(e))return{type:ue.Video,src:t};if(["mp3","wav","ogg","aac"].includes(e))return{type:ue.Audio,src:t}}return null},Zs=t=>({linkDesc:t?.description,linkIcon:"",linkImage:{width:t?.image?.width,height:t?.image?.height,url:t?.image?.high_resolution??t?.image?.url??t?.image?.thumbnail??t?.image?.placeholder},linkTitle:t?.title,linkUrl:t?.url,text:t?.title,type:Vn.LINK_ITEM}),FZ=t=>{const e=[],n=/(https?:\/\/[^\s]+)/g;let r=0,o;for(;(o=n.exec(t))!==null;)o.index>r&&e.push({type:"text",content:t.slice(r,o.index)}),e.push({type:"url",content:o[0]}),r=o.index+o[0].length;return r<t.length&&e.push({type:"text",content:t.slice(r)}),e},UZ=(t,e)=>{const n=AO(e),r=zY(e),o=FZ(n);return o.length===0?[e]:o.map(s=>s.type==="url"?DY(t,s.content,s.content,r):SO(t,s.content,r))},BZ=(t,e)=>{if(!_O(e))return e;const n=[],r=BY(e);return OO(r,o=>{if(FY(o)&&AO(o)){const s=UZ(t,o);n.push(...s)}else n.push(o)}),PY(t,MO(n),e.attrs)},zZ=(t,e)=>{const n=[];return OO(e.content,r=>{UY(r)&&_O(r)?n.push(BZ(t,r)):n.push(r)}),new ie(MO(n),e.openStart,e.openEnd)},wN=({defaultValues:t,open:e,onOpenChange:n,onInsertLink:r,hideTextInput:o=!1,children:s})=>{const{editor:i}=Sh(),{core:a}=wi(),{t:l,unauthenticatedMode:c}=kn(),[u,d]=j.useState(t?.uid??null),[f,h]=j.useState(t?.link??""),[p,m]=j.useState(t?.text||""),[g,b]=j.useState(void 0),[S,k]=j.useState(!1),[v,_]=j.useState(!1),x=j.useRef(null),A=D=>{if(n?.(D),!D||!i)return;const O=WY(i?.state,"customLink"),P=bn(O?.href??"");b(ns(P)),k(ns(P)),d(O?.uid??null),h(O?.href??""),m(O?.text||O?.href||"")},E=D=>{const O=D.target.value;if(O==="https:/")return;const P=bn(O);b(ns(P)),h(P)},T=D=>m(D.target.value),N=()=>{const D=ns(f);b(D)},I=(D,O,P)=>{if(c){r(D,O,P,void 0),n?.(!1);return}_(!0);let C;a?.resolveUrl(D)?.then(M=>C=M)?.catch(M=>{})?.finally(()=>{const M=Zs(C);_(!1),r(D,O,P,M),n?.(!1)})},R=D=>{if(D.key==="Enter"){if(D.preventDefault(),x.current===D.target||o)return I(f,p,u??void 0);x?.current?.focus()}};return j.useEffect(()=>{if(!t?.link)return;const D=ns(t?.link);b(D),k(D),d(t?.uid??null),h(t?.link??""),m(t?.text||"")},[t]),y.jsxs(Pc,{open:e,onOpenChange:A,children:[s?y.jsx(uR,{asChild:!0,children:s}):null,y.jsxs(Lc,{className:"-translate-1/2",children:[y.jsx(jc,{children:y.jsx($c,{children:l(S?"updateLinkKey":"insertLinkKey")})}),y.jsx(kZ,{children:y.jsxs(TZ,{className:"gap-3",children:[y.jsxs(dE,{className:"gap-1.5",children:[y.jsxs(fE,{children:[l("linkInputLabelKey")," ",y.jsx("span",{className:"text-destructive",children:"*"})]}),y.jsxs(Fg,{children:[y.jsx(Bg,{value:f,onChange:E,onBlur:N,onKeyDown:R,placeholder:"https://x.com/shadcn"}),y.jsx(Ug,{children:y.jsx(J_,{})})]}),!g&&g!==void 0&&y.jsx(AZ,{errors:[{message:l("invalidLinkKey")}]})]}),!o&&y.jsxs(dE,{className:"gap-1.5",children:[y.jsx(fE,{children:l("linkTextInputLabelKey")}),y.jsxs(Fg,{children:[y.jsx(Bg,{ref:x,value:p,onChange:T,onKeyDown:R,placeholder:l("linkTextInputLabelKey")}),y.jsx(Ug,{children:y.jsx(Q_,{})})]})]})]})}),y.jsxs(fR,{children:[y.jsx(zt,{variant:"secondary",onClick:()=>n?.(!1),children:l("cancelKey")}),y.jsxs(zt,{disabled:!g||v,onClick:()=>I(f,p,u??void 0),children:[v&&y.jsx(ms,{}),l(S?"updateKey":"insertKey")]})]})]})]})},HZ=Object.freeze(Object.defineProperty({__proto__:null,LinkDecoratorModal:wN},Symbol.toStringTag,{value:"Module"}));function VZ(t){const e=WZ(t),n=w.forwardRef((r,o)=>{const{children:s,...i}=r,a=w.Children.toArray(s),l=a.find(GZ);if(l){const c=l.props.children,u=a.map(d=>d===l?w.Children.count(c)>1?w.Children.only(null):w.isValidElement(c)?c.props.children:null:d);return y.jsx(e,{...i,ref:o,children:w.isValidElement(c)?w.cloneElement(c,void 0,u):null})}return y.jsx(e,{...i,ref:o,children:s})});return n.displayName=`${t}.Slot`,n}function WZ(t){const e=w.forwardRef((n,r)=>{const{children:o,...s}=n;if(w.isValidElement(o)){const i=YZ(o),a=qZ(s,o.props);return o.type!==w.Fragment&&(a.ref=r?ao(r,i):i),w.cloneElement(o,a)}return w.Children.count(o)>1?w.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var KZ=Symbol("radix.slottable");function GZ(t){return w.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===KZ}function qZ(t,e){const n={...e};for(const r in e){const o=t[r],s=e[r];/^on[A-Z]/.test(r)?o&&s?n[r]=(...a)=>{const l=s(...a);return o(...a),l}:o&&(n[r]=o):r==="style"?n[r]={...o,...s}:r==="className"&&(n[r]=[o,s].filter(Boolean).join(" "))}return{...t,...n}}function YZ(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var Ih="Popover",[xN]=Pr(Ih,[As]),Uc=As(),[JZ,Rs]=xN(Ih),EN=t=>{const{__scopePopover:e,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!1}=t,a=Uc(e),l=w.useRef(null),[c,u]=w.useState(!1),[d,f]=Ro({prop:r,defaultProp:o??!1,onChange:s,caller:Ih});return y.jsx(dh,{...a,children:y.jsx(JZ,{scope:e,contentId:sr(),triggerRef:l,open:d,onOpenChange:f,onOpenToggle:w.useCallback(()=>f(h=>!h),[f]),hasCustomAnchor:c,onCustomAnchorAdd:w.useCallback(()=>u(!0),[]),onCustomAnchorRemove:w.useCallback(()=>u(!1),[]),modal:i,children:n})})};EN.displayName=Ih;var SN="PopoverAnchor",XZ=w.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=Rs(SN,n),s=Uc(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:a}=o;return w.useEffect(()=>(i(),()=>a()),[i,a]),y.jsx(Mc,{...s,...r,ref:e})});XZ.displayName=SN;var kN="PopoverTrigger",TN=w.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=Rs(kN,n),s=Uc(n),i=Ze(e,o.triggerRef),a=y.jsx(Oe.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":ON(o.open),...r,ref:i,onClick:ae(t.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:y.jsx(Mc,{asChild:!0,...s,children:a})});TN.displayName=kN;var mv="PopoverPortal",[QZ,ZZ]=xN(mv,{forceMount:void 0}),CN=t=>{const{__scopePopover:e,forceMount:n,children:r,container:o}=t,s=Rs(mv,e);return y.jsx(QZ,{scope:e,forceMount:n,children:y.jsx(Jn,{present:n||s.open,children:y.jsx(Ia,{asChild:!0,container:o,children:r})})})};CN.displayName=mv;var ma="PopoverContent",AN=w.forwardRef((t,e)=>{const n=ZZ(ma,t.__scopePopover),{forceMount:r=n.forceMount,...o}=t,s=Rs(ma,t.__scopePopover);return y.jsx(Jn,{present:r||s.open,children:s.modal?y.jsx(tee,{...o,ref:e}):y.jsx(nee,{...o,ref:e})})});AN.displayName=ma;var eee=VZ("PopoverContent.RemoveScroll"),tee=w.forwardRef((t,e)=>{const n=Rs(ma,t.__scopePopover),r=w.useRef(null),o=Ze(e,r),s=w.useRef(!1);return w.useEffect(()=>{const i=r.current;if(i)return ph(i)},[]),y.jsx(Oc,{as:eee,allowPinchZoom:!0,children:y.jsx(_N,{...t,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ae(t.onCloseAutoFocus,i=>{i.preventDefault(),s.current||n.triggerRef.current?.focus()}),onPointerDownOutside:ae(t.onPointerDownOutside,i=>{const a=i.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;s.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:ae(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),nee=w.forwardRef((t,e)=>{const n=Rs(ma,t.__scopePopover),r=w.useRef(!1),o=w.useRef(!1);return y.jsx(_N,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{t.onCloseAutoFocus?.(s),s.defaultPrevented||(r.current||n.triggerRef.current?.focus(),s.preventDefault()),r.current=!1,o.current=!1},onInteractOutside:s=>{t.onInteractOutside?.(s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=s.target;n.triggerRef.current?.contains(i)&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&o.current&&s.preventDefault()}})}),_N=w.forwardRef((t,e)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,disableOutsidePointerEvents:i,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...d}=t,f=Rs(ma,n),h=Uc(n);return ih(),y.jsx(Ac,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:y.jsx(Oa,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>f.onOpenChange(!1),children:y.jsx(fh,{"data-state":ON(f.open),role:"dialog",id:f.contentId,...h,...d,ref:e,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),MN="PopoverClose",ree=w.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=Rs(MN,n);return y.jsx(Oe.button,{type:"button",...r,ref:e,onClick:ae(t.onClick,()=>o.onOpenChange(!1))})});ree.displayName=MN;var oee="PopoverArrow",see=w.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=Uc(n);return y.jsx(hh,{...o,...r,ref:e})});see.displayName=oee;function ON(t){return t?"open":"closed"}var iee=EN,aee=TN,lee=CN,cee=AN;function uee({...t}){return y.jsx(iee,{"data-slot":"popover",...t})}function dee({...t}){return y.jsx(aee,{"data-slot":"popover-trigger",...t})}function fee({className:t,align:e="center",sideOffset:n=4,children:r,...o}){return y.jsx(lee,{children:y.jsx("div",{"data-theme":"select-post-builder",children:y.jsx(cee,{"data-slot":"popover-content",align:e,sideOffset:n,className:oe("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",t),...o,children:r})})})}const hee=({mark:t,editor:e})=>{const[n,r]=j.useState(!1),[o,s]=j.useState(!1),i=l=>{s(l),l||r(!1)},a=(l,c,u,d)=>{if(!e.view)return;const f=t?.attrs?.isLinkMode?l:c||l;if(u){e.commands.updateLink(u,{href:l,text:f,previewPayload:d});return}};return y.jsxs(uee,{open:n,onOpenChange:r,children:[y.jsx(dee,{className:"text-left",children:y.jsx(W7,{className:"text-blue-600 underline hover:text-blue-700 cursor-pointer focus-within:outline-0"})}),y.jsxs(fee,{onOpenAutoFocus:l=>l.preventDefault(),side:"top",align:"center",className:"flex gap-2 items-center p-1 max-w-fit w-fit",children:[y.jsx(He,{size:"icon",tooltip:"visitLinkKey",onClick:()=>window.open(t.attrs.href,"_blank","noopener,noreferrer"),children:y.jsx(Yl,{})}),y.jsx(wN,{open:o,onOpenChange:i,defaultValues:{link:t?.attrs?.href??"",text:t?.attrs?.text??"",uid:t?.attrs?.uid??""},onInsertLink:a,hideTextInput:t?.attrs?.isLinkMode,children:y.jsx(He,{size:"icon",tooltip:"editLinkKey",children:y.jsx(C9,{})})}),y.jsx(He,{size:"icon",tooltip:"unsetLinkKey",onClick:()=>{r(!1),e.commands.unsetLink(),t?.attrs?.uid&&e.commands.deleteLinkPreviewByUid(t?.attrs?.uid)},className:oe(t?.attrs?.isLinkMode?"hidden":""),children:y.jsx(U9,{})})]})]})},pee=Object.freeze({status:"idle",metadata:null});class mee{entries=new Map;inflight=new Map;listeners=new Map;get(e){return this.entries.get(e)??pee}getResolved(e){const n=this.entries.get(e);return n?.status==="resolved"?n.metadata:null}seed(e,n){const r=this.get(e).status;r==="resolved"||r==="loading"||this.setEntry(e,{status:"resolved",metadata:n})}ensure(e,n){const r=this.getResolved(e);if(r!==null)return Promise.resolve(r);const o=this.inflight.get(e);if(o)return o;this.setEntry(e,{status:"loading",metadata:null});const s=n(e).then(i=>(this.inflight.delete(e),i?(this.setEntry(e,{status:"resolved",metadata:i}),i):(this.setEntry(e,{status:"failed",metadata:null}),null))).catch(i=>(this.inflight.delete(e),this.setEntry(e,{status:"failed",metadata:null,error:i}),null));return this.inflight.set(e,s),s}subscribe(e,n){let r=this.listeners.get(e);return r||(r=new Set,this.listeners.set(e,r)),r.add(n),()=>{r?.delete(n),r?.size===0&&this.listeners.delete(e)}}clear(){this.entries.clear(),this.inflight.clear(),this.listeners.clear()}setEntry(e,n){this.entries.set(e,n),this.listeners.get(e)?.forEach(r=>r(n))}}const Wi=new mee,gee=t=>{if(!t?.linkUrl)return null;const e=t.linkImage?.url??"";return{url:t.linkUrl,title:t.linkTitle??"",description:t.linkDesc??"",image:{filename:"",type:"",placeholder:"",thumbnail:"",width:t.linkImage?.width??0,height:t.linkImage?.height??0,url:e,high_resolution:e}}},hE=t=>{try{return new URL(t).hostname}catch{return null}},yee=(t,e)=>{let n=0;const r=o=>{if(o.type==="text"&&o.marks)for(const s of o.marks){if(s.type!=="customLink")continue;const i=s.attrs?.href,a=s.attrs?.previewPayload;if(!i||!a)continue;const l=a.linkUrl?hE(bn(a.linkUrl)):null,c=hE(bn(i));if(l&&c&&l!==c)continue;const u=gee(a);u&&(e.seed(bn(i),u),n+=1)}o.content?.forEach(r)};return r(t),n},RN="linkAutoResolve:rehydrate";function gv(t,e){return!t||!e?!1:t===e||t.name===e.name}function bee(t){return ns(bn(t.trim()))}function zg(t,e){if(!t||!e)return!1;try{let n=!1;return t.state.doc.descendants(r=>{if(r&&r.type&&r.type.name==="linkPreview"&&r.attrs?.uid===e)return n=!0,!1}),n}catch{return!1}}function rm(t,e){if(!t||!e)return!1;try{let n=!1;return t.state.doc.descendants(r=>{if(n)return!1;if(r?.isText&&r.marks?.length){for(const o of r.marks)if(o.type?.name==="customLink"&&o.attrs?.uid===e)return n=!0,!1}}),n}catch{return!1}}function Ku(t){if(!t)return null;try{let e=null;return t.state.doc.descendants((n,r)=>{if(n&&n.type&&n.type.name==="linkPreview")return e={node:n,pos:r},!1}),e}catch{return null}}function vee(t,e){if(!(!t||!e))try{let n=null,r=0;if(t.state.doc.descendants((o,s)=>{if(o&&o.type&&o.type.name==="linkPreview"&&o.attrs?.uid===e)return n=s,r=o.nodeSize,!1}),n!==null&&r>0){const o=t.state.tr;o&&(o.delete(n,Number(n)+r),t.view.dispatch(o))}}catch{}}function wee(t){return t?.image?.high_resolution??t?.image?.url??t?.image?.thumbnail??t?.image?.placeholder??null}function xee(t){if(!t?.view?.dom)return;const e=t.view.dom.getAttribute("data-session-id"),n=t.view.dom.getAttribute("data-editor-type");e&&ps().trackLinkUnfurlFailed(e,{editorType:n})}function Eee(t,e){const n=t.doc.content.findDiffStart(e.doc.content);if(n==null)return null;const r=t.doc.content.findDiffEnd(e.doc.content),o=t.doc.content.size,s=e.doc.content.size;return r?{fromOld:Math.max(0,Math.min(n,r.a)),toOld:Math.max(n,Math.min(r.a,o)),fromNew:Math.max(0,Math.min(n,r.b)),toNew:Math.max(n,Math.min(r.b,s))}:{fromOld:Math.max(0,n),toOld:o,fromNew:Math.max(0,n),toNew:s}}function Hg(t,e,n,r){const o=new Map;return n>=r||t.doc.nodesBetween(n,r,(s,i)=>{!s.isText||!s.marks?.length||s.marks.forEach(a=>{if(gv(a.type,e)&&a.attrs?.href){const l=a.attrs.uid;l&&!o.has(l)&&o.set(l,{uid:l,href:a.attrs.href,pos:i,nodeSize:s.nodeSize})}})}),o}function See(t,e,n,r,o,s,i){if(!t||!e||!n||!o)return null;let a=null,l=!1;try{t.doc.nodesBetween(s,i,(c,u)=>{!c||!c.isText||!c.marks?.length||c.marks.forEach(d=>{if(!(!d||!d.type||!d.attrs)&&gv(d.type,e)&&d.attrs?.uid){const f=c.text||"",h=d.attrs.href||"";if(f!==h){const p=bee(f);if(a||(a=t.tr),!a)return;if(p){const m=e.create({...d.attrs,href:bn(f)});if(!m)return;a=a.removeMark(u,u+c.nodeSize,e),a=a.addMark(u,u+c.nodeSize,m),l=!0,o.processedLinks.delete(d.attrs.uid),r&&queueMicrotask(()=>{try{Ku(n)&&d.attrs?.uid}catch{}})}else a=a.removeMark(u,u+c.nodeSize,e),l=!0,queueMicrotask(()=>{try{d.attrs?.uid&&vee(n,d.attrs.uid)}catch{}}),d.attrs?.uid&&(o.processedLinks.delete(d.attrs.uid),o.resolvingLinks.delete(d.attrs.uid))}}})})}catch{return null}return l?a:null}function pE(t,e,n,r,o,s=!0){const i=new Map;let a=null,l=!1;return n>=r?{tr:null,newUids:i}:(t.doc.nodesBetween(n,r,(c,u)=>{!c.isText||!c.marks?.length||c.marks.forEach(d=>{if(gv(d.type,e)&&d.attrs?.href&&!d.attrs.uid){const f=Dt();if(s&&o){const p=ps(),m=o?.view?.dom?.getAttribute("data-session-id"),g=o?.view?.dom?.getAttribute("data-editor-type");m&&p.trackLinkAdded(m,{editorType:g})}const h=e.create({...d.attrs,uid:f});if(a||(a=t.tr),!a)return;a=a.removeMark(u,u+c.nodeSize,e),a=a.addMark(u,u+c.nodeSize,h),l=!0,i.set(f,{uid:f,href:d.attrs.href,pos:u,nodeSize:c.nodeSize})}})}),{tr:l?a:null,newUids:i})}function NN(t,e,n,r,o){const s=[];return t.forEach((i,a)=>{e.has(a)||(r.processedLinks.delete(a),r.resolvingLinks.delete(a))}),n.forEach(i=>{!r.processedLinks.has(i.uid)&&!r.resolvingLinks.has(i.uid)&&s.push(i)}),e.forEach((i,a)=>{if(!(r.processedLinks.has(a)||r.resolvingLinks.has(a)||n.has(a))){if(o(a)){r.processedLinks.add(a);return}t.has(a)||s.push(i)}}),s}function kee(){return{resolvingLinks:new Set,processedLinks:new Set}}function IN(t,e,n){if(!n||t.length<=1)return t;const r=t.reduce((o,s)=>s.pos>o.pos?s:o);return t.forEach(o=>{o.uid!==r.uid&&e.processedLinks.add(o.uid)}),[r]}function Tee(t,e,n,r){const o=t.schema.marks.customLink;if(!o)return;const s=Hg(t,o,0,t.doc.content.size),i=IN(NN(new Map,s,new Map,n,a=>zg(e.editor,a)),n,r);i.length!==0&&queueMicrotask(()=>{i.forEach(a=>{if(!(n.processedLinks.has(a.uid)||n.resolvingLinks.has(a.uid))){if(zg(e.editor,a.uid)){n.processedLinks.add(a.uid);return}DN(a,e,r,n)}})})}function DN(t,e,n,r){if(e.unauthenticatedMode)return;const{api:o,editor:s}=e,i=e.store??Wi,a=Gn(s?.getJSON(),"mediaGroup");if(!o||n&&a.length>=1)return;const l=bn(t.href),c=m=>({uid:t.uid,href:m.url,title:m.title,image:wee(m),description:m.description,domain:new URL(m.url).hostname,loading:!1}),u=m=>{if(!s||s.isDestroyed||!rm(s,t.uid))return;const g=c(m);if(n){const b=Ku(s);if(b){const{pos:S}=b,k=s.state.tr;k.setNodeMarkup(S,void 0,g),s.view.dispatch(k)}else s.commands.setLinkPreview(g);s.commands.updateLinkByUid(t.uid,{previewPayload:Zs(m)})}else s.chain().updateLinkByUid(t.uid,{previewPayload:Zs(m)}).updateLinkPreviewByUid(t.uid,g).run()},d=i.getResolved(l);if(d){if(r.processedLinks.add(t.uid),!s||s.isDestroyed||!rm(s,t.uid))return;n?u(d):(s.commands.insertLinkPreviewAfterLink(t.uid,c(d)),s.commands.updateLinkByUid(t.uid,{previewPayload:Zs(d)}));return}r.resolvingLinks.add(t.uid);const f={uid:t.uid,href:t.href,loading:!0,title:null,image:null,description:null,domain:null};let h=null;if(n){const m=Ku(s);if(!m)s.commands.setLinkPreview(f);else if(m.node.attrs?.loading!==!0){h={...m.node.attrs};const g=s.state.tr;g.setNodeMarkup(m.pos,void 0,{...f,uid:m.node.attrs.uid}),s.view.dispatch(g)}}else s.commands.insertLinkPreviewAfterLink(t.uid,f);const p=()=>{if(!s||s.isDestroyed)return;if(!h){s.commands.deleteLinkPreviewByUid(t.uid);return}const m=h.uid,g=Ku(s);if(g&&g.node.attrs?.uid===m){const b=s.state.tr;b.setNodeMarkup(g.pos,void 0,h),s.view.dispatch(b)}};i.ensure(l,m=>o.resolveUrl(m)).then(m=>{if(r.resolvingLinks.delete(t.uid),!s||s.isDestroyed)return;if(m){if(r.processedLinks.add(t.uid),h&&!rm(s,t.uid)){p();return}u(m);return}p(),i.get(l).error!==void 0?xee(s):r.processedLinks.add(t.uid)}).catch(()=>{r.resolvingLinks.delete(t.uid),p()})}function Cee(t){const e=new Set;t.doc.descendants(o=>{o?.isText&&o.marks?.length&&o.marks.forEach(s=>{s.type?.name==="customLink"&&s.attrs?.uid&&e.add(s.attrs.uid)})});const n=[];if(t.doc.descendants((o,s)=>{if(o?.type?.name==="linkPreview"){const i=o.attrs?.uid;return(!i||!e.has(i))&&n.push({pos:s,size:o.nodeSize}),!1}}),n.length===0)return null;let r=t.tr;return n.sort((o,s)=>s.pos-o.pos).forEach(({pos:o,size:s})=>{r=r.delete(o,o+s)}),r}function Aee(t,e=!1){const n=new Je("linkAutoResolve");return new Ye({key:n,state:{init(){return kee()},apply(r,o){return o}},appendTransaction:(r,o,s)=>{const i=r.some(_=>typeof _.getMeta=="function"&&_.getMeta(RN)),a=s.schema.marks.customLink;if(!a)return null;const l=n.getState(s);if(!l)return null;if(i){try{yee(s.doc.toJSON(),t.store??Wi)}catch{}Tee(s,t,l,e);const{tr:_}=pE(s,a,0,s.doc.content.size,t.editor,!1);return _??null}if(!r.some(_=>_.docChanged))return null;const c=Eee(o,s);if(!c)return null;const u=n.getState(s);if(!u)return null;const d=e?See(s,a,t.editor,e,u,0,s.doc.content.size):null,f=Hg(o,a,c.fromOld,c.toOld),h=Hg(s,a,c.fromNew,c.toNew),p=t?.editor,{tr:m,newUids:g}=pE(s,a,c.fromNew,c.toNew,p),b=NN(f,h,g,u,_=>zg(t.editor,_)),S=IN(b,u,e);S.length>0?queueMicrotask(()=>{S.forEach(_=>{DN(_,t,e,u)})}):b.length;let k=null;if(d&&m)try{m.steps.forEach((_,x)=>{if(_&&d){d.step(_);const A=m.mapping.maps[x];A&&d.mapping.appendMap(A)}}),k=d}catch{k=d}else k=d??m??null;const v=Cee(s);if(v){if(!k)return v;try{v.steps.forEach((_,x)=>{if(_&&k){k.step(_);const A=v.mapping.maps[x];A&&k.mapping.appendMap(A)}})}catch{}}return k}})}const _ee=({selected:t,href:e,title:n,description:r,image:o,domain:s,onClickDelete:i})=>{const{t:a}=kn(),l=j.useMemo(()=>{try{return s||new URL(e).hostname}catch{return"unknown"}},[e,s]),c=u=>{u.preventDefault(),u.stopPropagation(),i()};return y.jsxs("div",{className:oe("not-prose relative w-full group my-4",t?"ring-2 ring-blue-500 ring-offset-2 rounded-lg":""),children:[y.jsxs("div",{className:"flex items-center gap-2 absolute z-50 right-2 top-1",children:[y.jsx(He,{asChild:!0,tooltip:"visitLinkKey",children:y.jsxs("span",{className:"relative",children:[y.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"absolute inset-0"}),y.jsx(Yl,{})]})}),y.jsx(He,{tooltip:"removeLinkPreviewKey",onClick:c,"aria-label":a("removeLinkPreviewKey"),type:"button",size:"icon",className:"cursor-pointer size-6 shadow-none bg-transparent group-hover:bg-destructive/5 hover:bg-destructive/10 text-destructive hover:text-destructive",children:y.jsx(co,{})})]}),y.jsx("div",{className:"relative z-0 w-full",children:y.jsxs("div",{className:"group flex items-center gap-3 rounded-lg border bg-accent/30 p-3 transition-all hover:border-foreground/20 hover:shadow-sm",children:[o&&y.jsx("div",{className:"relative h-16 w-16 shrink-0 overflow-hidden rounded-md bg-muted",children:y.jsx("img",{src:o,alt:n,className:"size-16 object-cover transition-transform group-hover:scale-105"})}),y.jsxs("div",{className:"min-w-0 flex-1",children:[y.jsx("h3",{className:"truncate text-sm font-semibold leading-tight text-foreground",children:n}),y.jsx("p",{className:"line-clamp-1 text-xs text-muted-foreground",children:r}),y.jsxs("div",{className:"mt-1 flex items-center gap-1 text-xs text-muted-foreground",children:[y.jsx("span",{className:"truncate",children:l}),y.jsx(Yl,{className:"h-3 w-3 shrink-0 opacity-50"})]})]})]})})]})},Mee=({selected:t,href:e,title:n,description:r,image:o,domain:s,onClickDelete:i})=>{const{t:a}=kn(),l=j.useMemo(()=>{try{return s||new URL(e).hostname}catch{return"unknown"}},[e,s]),c=u=>{u.preventDefault(),u.stopPropagation(),i()};return y.jsxs("div",{className:oe("not-prose relative w-full group mt-4",t?"ring-2 ring-blue-500 ring-offset-2 rounded-lg":""),children:[y.jsxs("div",{className:"flex items-center gap-2 absolute z-50 right-3 top-3",children:[y.jsx(He,{asChild:!0,tooltip:"visitLinkKey",className:"cursor-pointer backdrop-blur-2xl size-6 shadow-none group-hover:bg-accent/70 group-hover:text-accent-foreground text-primary-send",children:y.jsxs("span",{className:"relative",children:[y.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"absolute inset-0"}),y.jsx(Yl,{})]})}),y.jsx(He,{tooltip:"removeLinkPreviewKey",onClick:c,"aria-label":a("removeLinkPreviewKey"),type:"button",size:"icon",className:"cursor-pointer backdrop-blur-2xl size-6 shadow-none bg-transparent group-hover:bg-red-50/70 hover:bg-red-50 text-destructive hover:text-destructive",children:y.jsx(co,{})})]}),y.jsx("div",{className:"relative z-0 w-full",children:y.jsxs("div",{className:"group overflow-hidden flex flex-col rounded-lg border bg-accent/30 transition-all hover:border-foreground/20 hover:shadow-sm",children:[o&&y.jsx("div",{className:"relative h-80 w-full shrink-0 overflow-hidden bg-muted border-b",children:y.jsx("img",{src:o,alt:n,className:"size-full object-cover transition-transform group-hover:scale-105"})}),y.jsxs("div",{className:"min-w-0 flex-1 p-3",children:[y.jsxs("div",{className:"mt-1 flex items-center gap-1 text-xs text-muted-foreground",children:[y.jsx("span",{className:"truncate",children:l}),y.jsx(Yl,{className:"h-3 w-3 shrink-0 opacity-50"})]}),y.jsx("h3",{className:"mt-1 mb-2 truncate text-lg font-semibold leading-tight text-foreground",children:n}),y.jsx("p",{className:"line-clamp-2 text-sm text-muted-foreground",children:r})]})]})})]})},Oee=({node:t,deleteNode:e,selected:n,editor:r})=>{const{loading:o,href:s,domain:i,variant:a}=t.attrs,{t:l}=kn(),c=j.useMemo(()=>{try{return i||new URL(s).hostname}catch{return"unknown"}},[s,i]),u=()=>{const d=t.attrs.uid;d&&r.commands.updateLinkByUid(d,{previewPayload:null,unfurlDisabled:!0}),e()};return o?y.jsx(fi,{children:y.jsx($s,{className:"w-full h-24 my-4 flex items-center justify-center rounded-lg",children:y.jsx("span",{className:"text-sm text-muted-foreground",children:l("fetchingMetadataKey")})})}):s?y.jsx(fi,{contentEditable:!1,"data-drag-handle":!0,children:a===Ec.Compact?y.jsx(_ee,{...t.attrs,selected:n,domain:c,onClickDelete:u}):y.jsx(Mee,{...t.attrs,selected:n,domain:c,onClickDelete:u})}):null};function PN(t,e,n,r){let o=null;if(n.doc.descendants((c,u)=>{if(o!==null)return!1;if(c.isText&&c.marks){for(const d of c.marks)if(d.type.name==="customLink"&&d.attrs.uid===t)return o=u,!1}}),o===null)return!1;const s=n.doc.resolve(o);if(s.depth>1)return!1;let i=!1;if(n.doc.descendants(c=>{if(c.type.name==="linkPreview"&&c.attrs.uid===t)return i=!0,!1}),i)return!1;let a=s.after(1);for(;a<n.doc.content.size;){const c=n.doc.nodeAt(a);if(c?.type.name!=="linkPreview")break;const u=c.attrs.uid;let d=null;if(u&&n.doc.descendants((f,h)=>{if(d!==null)return!1;if(f.isText&&f.marks){for(const p of f.marks)if(p.type.name==="customLink"&&p.attrs.uid===u)return d=h,!1}}),d!==null&&d<o)a+=c.nodeSize;else break}if(!r)return!0;const l=n.schema.nodes.linkPreview;return l?(r(n.tr.insert(a,l.create(e))),!0):!1}function Vg(t){let e=null;return t.doc.descendants((n,r)=>{if(e)return!1;if(n.type.name==="linkPreview")return e={node:n,pos:r},!1}),e}function LN(t,e,n){const r=e.schema.nodes.linkPreview;if(!r)return!1;let o=e.doc.content.size;return e.doc.forEach((s,i)=>{s.type.name!=="mediaGroup"&&(o=i+s.nodeSize)}),n&&n(e.tr.insert(o,r.create(t))),!0}function Ree(t,e,n){if(!t.linkMode)return PN(t.uid,t.attributes,e,n);const r=Vg(e);if(!r)return LN(t.attributes,e,n);if(!n)return!0;const o=e.tr;return o.setNodeMarkup(r.pos,void 0,{...t.attributes,uid:r.node.attrs.uid??t.attributes.uid}),n(o),!0}const jN=Lt.create({name:"linkPreview",group:"block",atom:!0,addOptions(){return{variant:Ec.Compact,selectable:!0,draggable:!0}},draggable(){return this?.options?.draggable??!0},selectable(){return this?.options?.selectable??!0},addAttributes(){return{variant:{default:this.options.variant},uid:{default:null},href:{default:null},title:{default:null},description:{default:null},image:{default:null},domain:{default:null},loading:{default:!1}}},parseHTML(){return[{tag:"div[data-link-preview]",getAttrs:t=>{if(typeof t=="string")return!1;const e=t,n=e.querySelector("a");return{href:e.getAttribute("data-href")||n?.getAttribute("href")||"",uid:e.getAttribute("data-uid")||null,title:e.getAttribute("data-title")||null,description:e.getAttribute("data-description")||null,image:e.getAttribute("data-image")||null,domain:e.getAttribute("data-domain")||null}}}]},renderHTML({node:t}){const{href:e,uid:n,title:r,description:o,image:s,domain:i}=t.attrs;if(!e)return["div",{}];const a=[["a",{href:e,target:"_blank",rel:"noopener noreferrer",class:"absolute inset-0 z-30","aria-label":r||e}],["div",{class:"relative z-20 flex items-center gap-3 w-full"},...s?[["div",{class:"relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md bg-muted"},["img",{src:s,alt:r||"",class:"h-full w-full object-cover transition-transform group-hover:scale-105"}]]]:[],["div",{class:"min-w-0 flex-1"},...r?[["h3",{class:"truncate text-sm font-semibold leading-tight text-foreground"},r]]:[],...o?[["p",{class:"line-clamp-1 text-xs text-muted-foreground"},o]]:[],...i?[["div",{class:"mt-1 flex items-center gap-1 text-xs text-muted-foreground"},["span",{class:"truncate"},i]]]:[]]]];return["div",{"data-link-preview":"","data-href":e,"data-uid":n||"","data-title":r||"","data-description":o||"","data-image":s||"","data-domain":i||"",class:"not-prose my-4 relative group flex items-center gap-3 rounded-lg border bg-card p-3 transition-all hover:border-foreground/20 hover:shadow-sm"},...a]},addNodeView(){return Nc(Oee)},addCommands(){return{setLinkPreview:t=>({state:e,dispatch:n,commands:r,editor:o})=>{if(t.uid){let s=!1;if(o.state.doc.descendants(i=>{if(i.type.name===this.name&&i.attrs.uid===t.uid)return s=!0,!1}),s)return r.updateLinkPreviewByUid(t.uid,t)}return LN(t,e,n)},updateLinkPreviewByUid:uN(this.name),deleteLinkPreviewByUid:cN(this.name),updateLinkPreview:t=>({commands:e})=>e.updateAttributes(this.name,t),insertLinkPreviewAfterLink:(t,e)=>({state:n,dispatch:r})=>PN(t,e,n,r),insertLinkPreviewForMode:t=>({state:e,dispatch:n})=>Ree(t,e,n)}},addKeyboardShortcuts(){return{"Mod-Shift-k":()=>this.editor.commands.setLinkPreview({href:"",title:null,description:null,image:null,domain:null}),Backspace:()=>{const{selection:t}=this.editor.state,{$anchor:e}=t;return e.parent.type.name===this.name&&e.parentOffset===0?this.editor.commands.deleteNode(this.name):!1}}}}),om=(t,e)=>{if(e!==Pe.Media)return!1;const n=t?.getJSON(),r=n?Gn(n,"media"):[],o=n?Gn(n,"mediaGroup"):[];return r.length>0||o.length>0},$N=NR.extend({name:"customLink",priority:990,addOptions(){return{...this?.parent?.(),autolink:!0,api:void 0,unauthenticatedMode:!1}},addAttributes(){return{...this?.parent?.(),text:{default:null},uid:{default:null,parseHTML:()=>null,renderHTML:()=>({})},isLinkMode:{default:this?.options?.linkMode??!1,parseHTML:()=>null,renderHTML:()=>({})},previewPayload:{default:null,parseHTML:()=>null,renderHTML:()=>({})},unfurlDisabled:{default:!1,parseHTML:()=>null,renderHTML:()=>({})}}},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Yo(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Qe(this.options.HTMLAttributes,t),0]:["a",Qe(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{...this?.parent?.(),insertLink:t=>({chain:e,editor:n})=>{const r=ps(),{href:o,text:s}=t,i=Nee(n),a=this.options.linkMode&&i?i:Dt(),l=n?.view?.dom?.getAttribute("data-editor-type"),c=om(n,l),u=e().insertContent([{type:"text",text:s,marks:[{type:"customLink",attrs:{uid:a,href:o,text:s,previewPayload:null}}]},this.options.linkMode?{type:"text",text:" "}:null].filter(m=>m!==null));let d=null;if(!c&&!this.options.unauthenticatedMode){if(this.options.linkMode){const m=Vg(n.state);m&&m.node.attrs?.uid===a&&m.node.attrs?.loading!==!0&&(d={...m.node.attrs})}u.insertLinkPreviewForMode({uid:a,linkMode:!!this.options.linkMode,attributes:{uid:a,loading:!0,href:o,title:null,description:null,image:null,domain:null}})}u.run();const f=n?.view?.dom?.getAttribute("data-session-id")??"",h=this.options.api,p=()=>{if(!n||n.isDestroyed)return;if(!d){n.commands.deleteLinkPreviewByUid(a);return}const m=Vg(n.state);if(m&&m.node.attrs?.uid===d.uid){const g=n.state.tr;g.setNodeMarkup(m.pos,void 0,d),n.view.dispatch(g)}};return h&&!this.options.unauthenticatedMode&&Wi.ensure(bn(o),m=>h.resolveUrl(m)).then(m=>{if(r?.trackLinkAdded(f,{editorType:l}),!n||n.isDestroyed)return;if(!m){Wi.get(bn(o)).error!==void 0&&r?.trackLinkUnfurlFailed(f,{editorType:l}),p();return}const g=Zs(m),b=n?.view?.dom?.getAttribute("data-editor-type"),S=om(n,b),k=n?.chain()?.updateLinkByUid(a,{href:o,text:s,previewPayload:g});S||k?.updateLinkPreviewByUid(a,{loading:!1,href:m.url,title:m.title,image:m.image?.url??null,description:m.description,domain:new URL(m.url).hostname}),k?.run()}).catch(()=>{}),!0},updateLink:(t,e)=>({state:n,dispatch:r,editor:o})=>{if(!r)return!1;const{doc:s,schema:i,tr:a}=n;let l=a,c=!1;const u=[];return s.descendants((d,f)=>{d.isText&&d.marks?.length&&d.marks.forEach(h=>{h.type.name==="customLink"&&h.attrs.uid===t&&(u.push({from:f,to:f+d.nodeSize,mark:h,oldText:d.text||""}),c=!0)})}),c&&(u.sort((d,f)=>f.from-d.from),u.forEach(({from:d,to:f,mark:h,oldText:p})=>{const m={...h.attrs,href:e.href??h.attrs.href,text:e.text||e.href||h.attrs.text,previewPayload:e?.previewPayload??h?.attrs?.previewPayload},g=e.text??e.href??p,b=i.marks.customLink;if(b){l=l.delete(d,f);const S=i.text(g,[b.create(m)]);l=l.insert(d,S)}}),r(l),e.href&&queueMicrotask(()=>{const d=this.options.api;if(!d||this.options.unauthenticatedMode)return;const f=bn(e.href);Wi.ensure(f,h=>d.resolveUrl(h)).then(h=>{if(!o||o.isDestroyed)return;if(!h){if(Wi.get(f).error!==void 0){const v=o?.view?.dom?.getAttribute("data-session-id")??"",_=o?.view?.dom?.getAttribute("data-editor-type");ps()?.trackLinkUnfurlFailed(v,{editorType:_})}o.commands.deleteLinkPreviewByUid(t);return}const p=Zs(h);let m=!1;o.state.doc.descendants(k=>{if(k.type.name==="linkPreview"&&k.attrs.uid===t)return m=!0,!1}),o.commands.updateLinkByUid(t,{...e,previewPayload:p});const g={uid:t,href:h.url,title:h.title,image:h.image?.url??null,description:h.description,domain:new URL(h.url).hostname,loading:!1},b=o?.view?.dom?.getAttribute("data-editor-type"),S=om(o,b);m&&!S?o.commands.updateLinkPreviewByUid(t,g):!m&&!S&&o.commands.setLinkPreview(g)}).catch(()=>{})})),c},updateLinkByUid:YQ("customLink"),deleteLinkByUid:qQ("customLink"),rehydrateLinkPreviews:()=>({tr:t,dispatch:e})=>(e&&e(t.setMeta(RN,!0)),!0)}},addMarkView(){return G7(hee)},addKeyboardShortcuts(){return{"Mod-a":({editor:t})=>(t.view.focus(),t.commands.selectAll(),!0),Backspace:({editor:t})=>{const{empty:e}=t.state.selection;if(!e||!(t.state.storedMarks||t.state.selection.$from.marks()).find(l=>l.type.name==="customLink"))return!1;const o=t.state.selection.$from,s=o.nodeBefore,i=o.nodeAfter;return s&&s.marks.some(l=>l.type.name==="customLink")||i&&i.marks.some(l=>l.type.name==="customLink")||t.commands.unsetMark("customLink"),!1}}},addProseMirrorPlugins(){const t=this.parent?.()??[],e=Aee({api:this?.options?.api,editor:this.editor,unauthenticatedMode:this?.options?.unauthenticatedMode},this.options?.linkMode);return[...t,e]}}),Nee=t=>{const{doc:e}=t.state;let n=null;return e.descendants(r=>{if(r.type.name==="linkPreview")return n=r.attrs.uid,!1}),n},Iee=t=>t.includes("spotify.com/embed/track"),Dee=({node:t,selected:e,editor:n,updateAttributes:r,deleteNode:o})=>{const[s,i]=j.useState(t.attrs.previewPayload),{core:a}=wi(),{unauthenticatedMode:l}=kn(),{src:c}=t.attrs,u=()=>{o(),n.chain().focus()};return j.useEffect(()=>{l||!s&&t?.attrs?.src&&a.resolveUrl(bn(t?.attrs?.src)).then(d=>{const f=Zs(d);i(f),r({previewPayload:f})}).catch(d=>{}).finally(()=>{})},[a,t.attrs.src,s,r,l]),y.jsxs(fi,{"data-drag-handle":!0,className:oe("relative p-4 bg-accent",e&&"border-2 border-blue-500"),children:[y.jsx("iframe",{src:c,allowFullScreen:!0,className:oe("w-full rounded-md",Iee(c)?"h-38":"h-96")}),y.jsx(zt,{onClick:u,size:"icon",variant:"ghost",className:"absolute right-2 top-2 bg-background border hover:shadow-lg size-auto p-1.5 rounded-full",children:y.jsx(co,{})})]},c)};const{entries:FN,setPrototypeOf:mE,isFrozen:Pee,getPrototypeOf:Lee,getOwnPropertyDescriptor:jee}=Object;let{freeze:En,seal:hr,create:Wg}=Object,{apply:Kg,construct:Gg}=typeof Reflect<"u"&&Reflect;En||(En=function(e){return e});hr||(hr=function(e){return e});Kg||(Kg=function(e,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),s=2;s<r;s++)o[s-2]=arguments[s];return e.apply(n,o)});Gg||(Gg=function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return new e(...r)});const xu=Sn(Array.prototype.forEach),$ee=Sn(Array.prototype.lastIndexOf),gE=Sn(Array.prototype.pop),Ya=Sn(Array.prototype.push),Fee=Sn(Array.prototype.splice),Gu=Sn(String.prototype.toLowerCase),sm=Sn(String.prototype.toString),im=Sn(String.prototype.match),Ja=Sn(String.prototype.replace),Uee=Sn(String.prototype.indexOf),Bee=Sn(String.prototype.trim),wr=Sn(Object.prototype.hasOwnProperty),mn=Sn(RegExp.prototype.test),Xa=zee(TypeError);function Sn(t){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Kg(t,e,r)}}function zee(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Gg(t,n)}}function ze(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Gu;mE&&mE(t,null);let r=e.length;for(;r--;){let o=e[r];if(typeof o=="string"){const s=n(o);s!==o&&(Pee(e)||(e[r]=s),o=s)}t[o]=!0}return t}function Hee(t){for(let e=0;e<t.length;e++)wr(t,e)||(t[e]=null);return t}function Hr(t){const e=Wg(null);for(const[n,r]of FN(t))wr(t,n)&&(Array.isArray(r)?e[n]=Hee(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=Hr(r):e[n]=r);return e}function Qa(t,e){for(;t!==null;){const r=jee(t,e);if(r){if(r.get)return Sn(r.get);if(typeof r.value=="function")return Sn(r.value)}t=Lee(t)}function n(){return null}return n}const yE=En(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),am=En(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),lm=En(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Vee=En(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),cm=En(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Wee=En(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),bE=En(["#text"]),vE=En(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),um=En(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),wE=En(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Eu=En(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Kee=hr(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Gee=hr(/<%[\w\W]*|[\w\W]*%>/gm),qee=hr(/\$\{[\w\W]*/gm),Yee=hr(/^data-[\-\w.\u00B7-\uFFFF]+$/),Jee=hr(/^aria-[\-\w]+$/),UN=hr(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Xee=hr(/^(?:\w+script|data):/i),Qee=hr(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),BN=hr(/^html$/i),Zee=hr(/^[a-z][.\w]*(-[.\w]+)+$/i);var xE=Object.freeze({__proto__:null,ARIA_ATTR:Jee,ATTR_WHITESPACE:Qee,CUSTOM_ELEMENT:Zee,DATA_ATTR:Yee,DOCTYPE_NAME:BN,ERB_EXPR:Gee,IS_ALLOWED_URI:UN,IS_SCRIPT_OR_DATA:Xee,MUSTACHE_EXPR:Kee,TMPLIT_EXPR:qee});const Za={element:1,text:3,progressingInstruction:7,comment:8,document:9},ete=function(){return typeof window>"u"?null:window},tte=function(e,n){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let r=null;const o="data-tt-policy-suffix";n&&n.hasAttribute(o)&&(r=n.getAttribute(o));const s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML(i){return i},createScriptURL(i){return i}})}catch{return null}},EE=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function zN(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ete();const e=be=>zN(be);if(e.version="3.3.1",e.removed=[],!t||!t.document||t.document.nodeType!==Za.document||!t.Element)return e.isSupported=!1,e;let{document:n}=t;const r=n,o=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:i,Node:a,Element:l,NodeFilter:c,NamedNodeMap:u=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:d,DOMParser:f,trustedTypes:h}=t,p=l.prototype,m=Qa(p,"cloneNode"),g=Qa(p,"remove"),b=Qa(p,"nextSibling"),S=Qa(p,"childNodes"),k=Qa(p,"parentNode");if(typeof i=="function"){const be=n.createElement("template");be.content&&be.content.ownerDocument&&(n=be.content.ownerDocument)}let v,_="";const{implementation:x,createNodeIterator:A,createDocumentFragment:E,getElementsByTagName:T}=n,{importNode:N}=r;let I=EE();e.isSupported=typeof FN=="function"&&typeof k=="function"&&x&&x.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:R,ERB_EXPR:D,TMPLIT_EXPR:O,DATA_ATTR:P,ARIA_ATTR:C,IS_SCRIPT_OR_DATA:M,ATTR_WHITESPACE:U,CUSTOM_ELEMENT:L}=xE;let{IS_ALLOWED_URI:F}=xE,V=null;const W=ze({},[...yE,...am,...lm,...cm,...bE]);let H=null;const B=ze({},[...vE,...um,...wE,...Eu]);let $=Object.seal(Wg(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),K=null,Y=null;const J=Object.seal(Wg(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Q=!0,ne=!0,se=!1,te=!0,ge=!1,he=!0,xe=!1,Ee=!1,Se=!1,_e=!1,Me=!1,Ke=!1,Ge=!0,Be=!1;const je="user-content-";let $e=!0,pe=!1,Ne={},Ie=null;const Ve=ze({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let vt=null;const tt=ze({},["audio","video","img","source","image","track"]);let et=null;const qe=ze({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),jt="http://www.w3.org/1998/Math/MathML",q="http://www.w3.org/2000/svg",re="http://www.w3.org/1999/xhtml";let de=re,We=!1,Ae=null;const ot=ze({},[jt,q,re],sm);let ht=ze({},["mi","mo","mn","ms","mtext"]),hn=ze({},["annotation-xml"]);const nn=ze({},["title","style","font","a","script"]);let pt=null;const ve=["application/xhtml+xml","text/html"],nt="text/html";let Ce=null,rt=null;const $t=n.createElement("form"),mt=function(z){return z instanceof RegExp||z instanceof Function},rn=function(){let z=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(rt&&rt===z)){if((!z||typeof z!="object")&&(z={}),z=Hr(z),pt=ve.indexOf(z.PARSER_MEDIA_TYPE)===-1?nt:z.PARSER_MEDIA_TYPE,Ce=pt==="application/xhtml+xml"?sm:Gu,V=wr(z,"ALLOWED_TAGS")?ze({},z.ALLOWED_TAGS,Ce):W,H=wr(z,"ALLOWED_ATTR")?ze({},z.ALLOWED_ATTR,Ce):B,Ae=wr(z,"ALLOWED_NAMESPACES")?ze({},z.ALLOWED_NAMESPACES,sm):ot,et=wr(z,"ADD_URI_SAFE_ATTR")?ze(Hr(qe),z.ADD_URI_SAFE_ATTR,Ce):qe,vt=wr(z,"ADD_DATA_URI_TAGS")?ze(Hr(tt),z.ADD_DATA_URI_TAGS,Ce):tt,Ie=wr(z,"FORBID_CONTENTS")?ze({},z.FORBID_CONTENTS,Ce):Ve,K=wr(z,"FORBID_TAGS")?ze({},z.FORBID_TAGS,Ce):Hr({}),Y=wr(z,"FORBID_ATTR")?ze({},z.FORBID_ATTR,Ce):Hr({}),Ne=wr(z,"USE_PROFILES")?z.USE_PROFILES:!1,Q=z.ALLOW_ARIA_ATTR!==!1,ne=z.ALLOW_DATA_ATTR!==!1,se=z.ALLOW_UNKNOWN_PROTOCOLS||!1,te=z.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ge=z.SAFE_FOR_TEMPLATES||!1,he=z.SAFE_FOR_XML!==!1,xe=z.WHOLE_DOCUMENT||!1,_e=z.RETURN_DOM||!1,Me=z.RETURN_DOM_FRAGMENT||!1,Ke=z.RETURN_TRUSTED_TYPE||!1,Se=z.FORCE_BODY||!1,Ge=z.SANITIZE_DOM!==!1,Be=z.SANITIZE_NAMED_PROPS||!1,$e=z.KEEP_CONTENT!==!1,pe=z.IN_PLACE||!1,F=z.ALLOWED_URI_REGEXP||UN,de=z.NAMESPACE||re,ht=z.MATHML_TEXT_INTEGRATION_POINTS||ht,hn=z.HTML_INTEGRATION_POINTS||hn,$=z.CUSTOM_ELEMENT_HANDLING||{},z.CUSTOM_ELEMENT_HANDLING&&mt(z.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&($.tagNameCheck=z.CUSTOM_ELEMENT_HANDLING.tagNameCheck),z.CUSTOM_ELEMENT_HANDLING&&mt(z.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&($.attributeNameCheck=z.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),z.CUSTOM_ELEMENT_HANDLING&&typeof z.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&($.allowCustomizedBuiltInElements=z.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ge&&(ne=!1),Me&&(_e=!0),Ne&&(V=ze({},bE),H=[],Ne.html===!0&&(ze(V,yE),ze(H,vE)),Ne.svg===!0&&(ze(V,am),ze(H,um),ze(H,Eu)),Ne.svgFilters===!0&&(ze(V,lm),ze(H,um),ze(H,Eu)),Ne.mathMl===!0&&(ze(V,cm),ze(H,wE),ze(H,Eu))),z.ADD_TAGS&&(typeof z.ADD_TAGS=="function"?J.tagCheck=z.ADD_TAGS:(V===W&&(V=Hr(V)),ze(V,z.ADD_TAGS,Ce))),z.ADD_ATTR&&(typeof z.ADD_ATTR=="function"?J.attributeCheck=z.ADD_ATTR:(H===B&&(H=Hr(H)),ze(H,z.ADD_ATTR,Ce))),z.ADD_URI_SAFE_ATTR&&ze(et,z.ADD_URI_SAFE_ATTR,Ce),z.FORBID_CONTENTS&&(Ie===Ve&&(Ie=Hr(Ie)),ze(Ie,z.FORBID_CONTENTS,Ce)),z.ADD_FORBID_CONTENTS&&(Ie===Ve&&(Ie=Hr(Ie)),ze(Ie,z.ADD_FORBID_CONTENTS,Ce)),$e&&(V["#text"]=!0),xe&&ze(V,["html","head","body"]),V.table&&(ze(V,["tbody"]),delete K.tbody),z.TRUSTED_TYPES_POLICY){if(typeof z.TRUSTED_TYPES_POLICY.createHTML!="function")throw Xa('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof z.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Xa('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');v=z.TRUSTED_TYPES_POLICY,_=v.createHTML("")}else v===void 0&&(v=tte(h,o)),v!==null&&typeof _=="string"&&(_=v.createHTML(""));En&&En(z),rt=z}},Is=ze({},[...am,...lm,...Vee]),An=ze({},[...cm,...Wee]),Un=function(z){let ee=k(z);(!ee||!ee.tagName)&&(ee={namespaceURI:de,tagName:"template"});const fe=Gu(z.tagName),wt=Gu(ee.tagName);return Ae[z.namespaceURI]?z.namespaceURI===q?ee.namespaceURI===re?fe==="svg":ee.namespaceURI===jt?fe==="svg"&&(wt==="annotation-xml"||ht[wt]):!!Is[fe]:z.namespaceURI===jt?ee.namespaceURI===re?fe==="math":ee.namespaceURI===q?fe==="math"&&hn[wt]:!!An[fe]:z.namespaceURI===re?ee.namespaceURI===q&&!hn[wt]||ee.namespaceURI===jt&&!ht[wt]?!1:!An[fe]&&(nn[fe]||!Is[fe]):!!(pt==="application/xhtml+xml"&&Ae[z.namespaceURI]):!1},Bn=function(z){Ya(e.removed,{element:z});try{k(z).removeChild(z)}catch{g(z)}},pn=function(z,ee){try{Ya(e.removed,{attribute:ee.getAttributeNode(z),from:ee})}catch{Ya(e.removed,{attribute:null,from:ee})}if(ee.removeAttribute(z),z==="is")if(_e||Me)try{Bn(ee)}catch{}else try{ee.setAttribute(z,"")}catch{}},Jh=function(z){let ee=null,fe=null;if(Se)z="<remove></remove>"+z;else{const Ct=im(z,/^[\r\n\t ]+/);fe=Ct&&Ct[0]}pt==="application/xhtml+xml"&&de===re&&(z='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+z+"</body></html>");const wt=v?v.createHTML(z):z;if(de===re)try{ee=new f().parseFromString(wt,pt)}catch{}if(!ee||!ee.documentElement){ee=x.createDocument(de,"template",null);try{ee.documentElement.innerHTML=We?_:wt}catch{}}const on=ee.body||ee.documentElement;return z&&fe&&on.insertBefore(n.createTextNode(fe),on.childNodes[0]||null),de===re?T.call(ee,xe?"html":"body")[0]:xe?ee.documentElement:on},o0=function(z){return A.call(z.ownerDocument||z,z,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Xh=function(z){return z instanceof d&&(typeof z.nodeName!="string"||typeof z.textContent!="string"||typeof z.removeChild!="function"||!(z.attributes instanceof u)||typeof z.removeAttribute!="function"||typeof z.setAttribute!="function"||typeof z.namespaceURI!="string"||typeof z.insertBefore!="function"||typeof z.hasChildNodes!="function")},s0=function(z){return typeof a=="function"&&z instanceof a};function uo(be,z,ee){xu(be,fe=>{fe.call(e,z,ee,rt)})}const i0=function(z){let ee=null;if(uo(I.beforeSanitizeElements,z,null),Xh(z))return Bn(z),!0;const fe=Ce(z.nodeName);if(uo(I.uponSanitizeElement,z,{tagName:fe,allowedTags:V}),he&&z.hasChildNodes()&&!s0(z.firstElementChild)&&mn(/<[/\w!]/g,z.innerHTML)&&mn(/<[/\w!]/g,z.textContent)||z.nodeType===Za.progressingInstruction||he&&z.nodeType===Za.comment&&mn(/<[/\w]/g,z.data))return Bn(z),!0;if(!(J.tagCheck instanceof Function&&J.tagCheck(fe))&&(!V[fe]||K[fe])){if(!K[fe]&&l0(fe)&&($.tagNameCheck instanceof RegExp&&mn($.tagNameCheck,fe)||$.tagNameCheck instanceof Function&&$.tagNameCheck(fe)))return!1;if($e&&!Ie[fe]){const wt=k(z)||z.parentNode,on=S(z)||z.childNodes;if(on&&wt){const Ct=on.length;for(let _n=Ct-1;_n>=0;--_n){const fo=m(on[_n],!0);fo.__removalCount=(z.__removalCount||0)+1,wt.insertBefore(fo,b(z))}}}return Bn(z),!0}return z instanceof l&&!Un(z)||(fe==="noscript"||fe==="noembed"||fe==="noframes")&&mn(/<\/no(script|embed|frames)/i,z.innerHTML)?(Bn(z),!0):(ge&&z.nodeType===Za.text&&(ee=z.textContent,xu([R,D,O],wt=>{ee=Ja(ee,wt," ")}),z.textContent!==ee&&(Ya(e.removed,{element:z.cloneNode()}),z.textContent=ee)),uo(I.afterSanitizeElements,z,null),!1)},a0=function(z,ee,fe){if(Ge&&(ee==="id"||ee==="name")&&(fe in n||fe in $t))return!1;if(!(ne&&!Y[ee]&&mn(P,ee))){if(!(Q&&mn(C,ee))){if(!(J.attributeCheck instanceof Function&&J.attributeCheck(ee,z))){if(!H[ee]||Y[ee]){if(!(l0(z)&&($.tagNameCheck instanceof RegExp&&mn($.tagNameCheck,z)||$.tagNameCheck instanceof Function&&$.tagNameCheck(z))&&($.attributeNameCheck instanceof RegExp&&mn($.attributeNameCheck,ee)||$.attributeNameCheck instanceof Function&&$.attributeNameCheck(ee,z))||ee==="is"&&$.allowCustomizedBuiltInElements&&($.tagNameCheck instanceof RegExp&&mn($.tagNameCheck,fe)||$.tagNameCheck instanceof Function&&$.tagNameCheck(fe))))return!1}else if(!et[ee]){if(!mn(F,Ja(fe,U,""))){if(!((ee==="src"||ee==="xlink:href"||ee==="href")&&z!=="script"&&Uee(fe,"data:")===0&&vt[z])){if(!(se&&!mn(M,Ja(fe,U,"")))){if(fe)return!1}}}}}}}return!0},l0=function(z){return z!=="annotation-xml"&&im(z,L)},c0=function(z){uo(I.beforeSanitizeAttributes,z,null);const{attributes:ee}=z;if(!ee||Xh(z))return;const fe={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:H,forceKeepAttr:void 0};let wt=ee.length;for(;wt--;){const on=ee[wt],{name:Ct,namespaceURI:_n,value:fo}=on,Ri=Ce(Ct),Qh=fo;let Gt=Ct==="value"?Qh:Bee(Qh);if(fe.attrName=Ri,fe.attrValue=Gt,fe.keepAttr=!0,fe.forceKeepAttr=void 0,uo(I.uponSanitizeAttribute,z,fe),Gt=fe.attrValue,Be&&(Ri==="id"||Ri==="name")&&(pn(Ct,z),Gt=je+Gt),he&&mn(/((--!?|])>)|<\/(style|title|textarea)/i,Gt)){pn(Ct,z);continue}if(Ri==="attributename"&&im(Gt,"href")){pn(Ct,z);continue}if(fe.forceKeepAttr)continue;if(!fe.keepAttr){pn(Ct,z);continue}if(!te&&mn(/\/>/i,Gt)){pn(Ct,z);continue}ge&&xu([R,D,O],d0=>{Gt=Ja(Gt,d0," ")});const u0=Ce(z.nodeName);if(!a0(u0,Ri,Gt)){pn(Ct,z);continue}if(v&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!_n)switch(h.getAttributeType(u0,Ri)){case"TrustedHTML":{Gt=v.createHTML(Gt);break}case"TrustedScriptURL":{Gt=v.createScriptURL(Gt);break}}if(Gt!==Qh)try{_n?z.setAttributeNS(_n,Ct,Gt):z.setAttribute(Ct,Gt),Xh(z)?Bn(z):gE(e.removed)}catch{pn(Ct,z)}}uo(I.afterSanitizeAttributes,z,null)},ZD=function be(z){let ee=null;const fe=o0(z);for(uo(I.beforeSanitizeShadowDOM,z,null);ee=fe.nextNode();)uo(I.uponSanitizeShadowNode,ee,null),i0(ee),c0(ee),ee.content instanceof s&&be(ee.content);uo(I.afterSanitizeShadowDOM,z,null)};return e.sanitize=function(be){let z=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ee=null,fe=null,wt=null,on=null;if(We=!be,We&&(be="<!-->"),typeof be!="string"&&!s0(be))if(typeof be.toString=="function"){if(be=be.toString(),typeof be!="string")throw Xa("dirty is not a string, aborting")}else throw Xa("toString is not a function");if(!e.isSupported)return be;if(Ee||rn(z),e.removed=[],typeof be=="string"&&(pe=!1),pe){if(be.nodeName){const fo=Ce(be.nodeName);if(!V[fo]||K[fo])throw Xa("root node is forbidden and cannot be sanitized in-place")}}else if(be instanceof a)ee=Jh("<!---->"),fe=ee.ownerDocument.importNode(be,!0),fe.nodeType===Za.element&&fe.nodeName==="BODY"||fe.nodeName==="HTML"?ee=fe:ee.appendChild(fe);else{if(!_e&&!ge&&!xe&&be.indexOf("<")===-1)return v&&Ke?v.createHTML(be):be;if(ee=Jh(be),!ee)return _e?null:Ke?_:""}ee&&Se&&Bn(ee.firstChild);const Ct=o0(pe?be:ee);for(;wt=Ct.nextNode();)i0(wt),c0(wt),wt.content instanceof s&&ZD(wt.content);if(pe)return be;if(_e){if(Me)for(on=E.call(ee.ownerDocument);ee.firstChild;)on.appendChild(ee.firstChild);else on=ee;return(H.shadowroot||H.shadowrootmode)&&(on=N.call(r,on,!0)),on}let _n=xe?ee.outerHTML:ee.innerHTML;return xe&&V["!doctype"]&&ee.ownerDocument&&ee.ownerDocument.doctype&&ee.ownerDocument.doctype.name&&mn(BN,ee.ownerDocument.doctype.name)&&(_n="<!DOCTYPE "+ee.ownerDocument.doctype.name+`>
213
- `+_n),ge&&xu([R,D,O],fo=>{_n=Ja(_n,fo," ")}),v&&Ke?v.createHTML(_n):_n},e.setConfig=function(){let be=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};rn(be),Ee=!0},e.clearConfig=function(){rt=null,Ee=!1},e.isValidAttribute=function(be,z,ee){rt||rn({});const fe=Ce(be),wt=Ce(z);return a0(fe,wt,ee)},e.addHook=function(be,z){typeof z=="function"&&Ya(I[be],z)},e.removeHook=function(be,z){if(z!==void 0){const ee=$ee(I[be],z);return ee===-1?void 0:Fee(I[be],ee,1)[0]}return gE(I[be])},e.removeHooks=function(be){I[be]=[]},e.removeAllHooks=function(){I=EE()},e}var nte=zN();const rte=["youtube.com","www.youtube.com","youtube-nocookie.com","www.youtube-nocookie.com","open.spotify.com","spotify.com"];function HN(t){try{const e=new URL(t);if(e.protocol!=="https:")return!1;const n=e.hostname.toLowerCase();return rte.some(r=>n===r||n.endsWith(`.${r}`))}catch{return!1}}const ote=t=>{const e={ADD_TAGS:["iframe"],ADD_ATTR:["src","width","height","frameborder","allowfullscreen","allow","sandbox","loading","referrerpolicy","title"],ALLOWED_URI_REGEXP:/^https:\/\//,RETURN_TRUSTED_TYPE:!1};return t.addHook("uponSanitizeElement",(n,r)=>{if(r.tagName==="iframe"){const s=n.getAttribute("src")||"";HN(s)||n.parentNode?.removeChild(n)}}),e};function ste(t){const e=nte(window);try{const n=ote(e),r=e.sanitize(t,n);if(!r.includes("<iframe"))return null;const o=r.match(/<iframe[^>]*src=["']([^"']+)["']/i);return!o||!o[1]||!HN(o[1])?null:o[1]}catch{return null}}const VN=t=>new RegExp(bN).test(t.trim()),WN=t=>new RegExp(vN).test(t.trim()),SE=t=>{const e=t.trim();if(VN(e)){const r=e.match(PZ)?.[1];return r?`https://www.youtube.com/embed/${r}`:null}if(WN(e)){const n=e.match(/open\.spotify\.com\/(track|playlist|album)\/([A-Za-z0-9]+)/);if(!n)return null;const[,r,o]=n;return`https://open.spotify.com/embed/${r}/${o}?utm_source=generator`}return null},ite=t=>VN(t)||WN(t),kE=t=>e=>{const n=[],r=new RegExp(t.source,"gi");let o;for(;(o=r.exec(e))!==null;)n.push({index:o.index,text:o[0],match:o});return n.length>0?n:null},ate=Lt.create({name:"iframe",group:"block",atom:!0,selectable:!0,draggable:!0,priority:1e3,addOptions(){return{api:void 0}},addAttributes(){return{src:{default:null},width:{default:"100%"},maxWidth:{default:"100%",renderHTML:t=>({style:`max-width: ${t.maxWidth}`})},height:{default:"320"},previewPayload:{default:null,parseHTML:()=>null,renderHTML:()=>({})}}},parseHTML(){return[{tag:"iframe[src]"}]},renderHTML({HTMLAttributes:t}){return["iframe",Qe(t,{class:"my-4"})]},addNodeView(){return Nc(Dee)},addPasteRules(){return[{find:/<iframe.*?src="(.*?)".*?<\/iframe>/gi,handler:({state:t,range:e,match:n})=>{const r=n[0],o=ste(r);if(!o){Zt.error("🚨 Your pasted iframe is not safe to render");return}const s=this.type.create({src:o,previewPayload:null});t.tr.replaceRangeWith(e.from,e.to,s)}},{find:kE(bN),handler:({state:t,range:e,match:n})=>{const r=n[0],o=SE(r);if(!o)return;const s=this.type.create({src:o});t.tr.replaceRangeWith(e.from,e.to,s)}},{find:kE(vN),handler:({state:t,range:e,match:n})=>{const r=n[0],o=SE(r);if(!o)return;const s=this.type.create({src:o});t.tr.replaceRangeWith(e.from,e.to,s)}}]},addCommands(){return{setIframe:t=>({tr:e,dispatch:n})=>{const r=this.type.create(t);return n&&e.replaceSelectionWith(r),!0}}}}),lte=t=>{const e=t.clipboardData;return e&&e.getData("text/plain")||null},cte=(t,e,n,r,o=!1)=>{n.preventDefault();const s=bn(e);return o?(t.chain().focus().insertLink({href:s,text:e}).run(),!0):r&&t.commands.insertMediaWithUpload?($Z(s).then(i=>{i?t.commands.insertMediaWithUpload({source:i?.src,type:i?.type,mediaType:Vn.MEDIA_ITEM}):t.chain().focus().insertLink({href:s,text:e}).run()}).catch(i=>{t.chain().focus().insertLink({href:s,text:e}).run()}),!0):(t.chain().focus().insertLink({href:s,text:e}).run(),!0)},ute=(t,e,n)=>{const r=HY(t);if(!jY(r))return!1;const o=TO(r),s=bn(e);return n.chain().focus().deleteSelection().insertLink({href:s,text:o}).run(),!0},dte=(t,e)=>(n,r)=>{try{const o=lte(r);if(!o||!ns(o))return!1;const s=o.trim();return ite(s)&&e?.autoEmbed?(r.preventDefault(),!1):!n.state.selection.empty&&e?.autoLinkSelection?(r.preventDefault(),ute(n,s,t)):cte(t,s,r,e?.autoDetectMedia??!0,e?.unauthenticatedMode??!1)}catch{return!1}},fte=t=>e=>{const n=VY(e.content);if(ns(n.trim()))return e;try{return zZ(t,e)}catch{return e}},KN=at.create({name:"smartLinkPaste",priority:998,addOptions(){return{enableTransformPasted:!1,autoDetectMedia:!0,autoEmbed:!0,autoLinkSelection:!0,api:void 0,unauthenticatedMode:!1}},addProseMirrorPlugins(){const{editor:t,options:e}=this,n={handlePaste:dte(t,e)};return e.enableTransformPasted&&(n.transformPasted=fte(t)),[new Ye({key:new Je("smartLinkPaste"),props:n})]}}),yv=(t,e)=>t?.startsWith("video/")?ue.Video:t?.startsWith("audio/")?ue.Audio:e,GN=t=>typeof t=="string"&&t in Ey,hte=async t=>{const{file:e,api:n,onProgress:r,mediaItemType:o,signal:s}=t,i=e instanceof File?e:new File([e],"upload.bin",{type:e.type}),a=await n.uploadChunked(i,r,s);return pv(a,o)},pte=async t=>{const e=t?.url,n=t?.api,r=t?.onProgress,o=t?.mediaItemType,s=t?.searchFrom;r&&r(25);const i=mte(r,25,90);try{const a=await n.uploadUrl(e),l=pv(a,o,s);return i&&clearInterval(i),r&&r(100),l}catch(a){throw i&&clearInterval(i),a}};function mte(t,e,n){if(!t)return null;let r=e;const o=5,i=setInterval(()=>{r+=o,r>=n&&(r=n,clearInterval(i)),t(r)},300);return i}const qN=at.create({name:"smartMediaUpload",priority:999,addOptions(){return{api:void 0,maxFileSize:pl,allowedFileTypes:["image/*","video/*","audio/*"],maxConcurrentUploads:Er,onUploadStart:void 0,onUploadProgress:void 0,onUploadComplete:void 0,onUploadError:void 0,unauthenticatedMode:!1}},addCommands(){return{insertMediaWithUpload:({source:t,type:e,caption:n,mediaType:r,searchFrom:o})=>({commands:s,editor:i})=>{const a=Dt(),l=this.options;if(!l.api)return!1;let c="local";if(o===Yr.Gif?c="gif_search":o===Yr.Image?c="image_search":tx(t)?c="url":Ur(t)&&(c="local"),Ur(t)){const d=rg(t,l.maxFileSize,l.allowedFileTypes);if(!d.valid){Zt.error(d.error),l.onUploadError?.(a,new Error(d.error));const{sessionId:f,editorType:h}=this.storage.getAnalyticsContext(i);return f&&h&&ps().trackMediaUploadFailed(f,{editorType:h,mediaType:Du[e],fileSizeMB:t.size/(1024*1024),source:c,errorType:d?.error?.includes("size")?"file_too_large":"unsupported_format"}),!1}}const u=Ur(t)?URL.createObjectURL(t):t;return l.unauthenticatedMode?(s.insertMedia({uid:a,src:u,type:e,caption:n||"",uploading:!1,progress:0,deferred:!0}),Ur(t)&&(this.storage.blobUrls.set(a,u),this.storage.itemBlobs.set(a,t)),this.storage.deferredUids.add(a),r!==void 0&&this.storage.deferredMediaTypes.set(a,r),!0):(s.insertMedia({uid:a,src:u,type:e,caption:n||"",uploading:!0,progress:0}),Ur(t)&&this.storage.blobUrls.set(a,u),this.storage.uploadQueue.push({uid:a,source:t,type:e,caption:n,uploadSource:c}),this.storage.processUploadQueue(i,r,o),!0)},resumeDeferredUploads:t=>({editor:e,commands:n})=>{const r=[];e.state.doc.descendants(s=>{s.type.name==="media"&&s.attrs.deferred===!0&&r.push({uid:s.attrs.uid,type:s.attrs.type,caption:s.attrs.caption})});let o=0;if(r.forEach(({uid:s,type:i,caption:a})=>{const l=t.get(s);if(!l){n.deleteMediaByUid(s);return}this.storage.deferredUids.delete(s);const c=Ur(l),u=c?URL.createObjectURL(l):l;if(c){const d=this.storage.blobUrls.get(s);d&&URL.revokeObjectURL(d),this.storage.blobUrls.set(s,u),this.storage.itemBlobs.set(s,l)}n.updateMediaByUid(s,{src:u,deferred:!1,uploading:!0,progress:0}),this.storage.uploadQueue.push({uid:s,source:l,type:i,caption:a,uploadSource:c?"local":"url",mediaItemType:this.storage.deferredMediaTypes.get(s)}),this.storage.deferredMediaTypes.delete(s),o++}),typeof this.storage.processUploadQueue=="function"){const s=Math.min(o,this.options.maxConcurrentUploads??Er);for(let i=0;i<s;i++)this.storage.processUploadQueue(e,Vn.MEDIA_ITEM,void 0)}return!0}}},addStorage(){return{uploadQueue:[],activeUploads:0,blobUrls:new Map,itemPromises:new Map,itemBlobs:new Map,itemAborts:new Map,deferredUids:new Set,deferredMediaTypes:new Map,getPendingUpload(t){const e=this.itemPromises.get(t),n=this.itemBlobs.get(t),r=this.itemAborts.get(t);if(n)return e?{blob:n,promise:e,abort:r}:{blob:n,promise:void 0,abort:void 0}},processUploadQueue:null,getAnalyticsContext:t=>{const e=t.view?.dom?.getAttribute("data-session-id")||"",n=t.view?.dom?.getAttribute("data-editor-type");return{sessionId:e,editorType:n}}}},onCreate(){const t=async(e,n,r)=>{const{maxConcurrentUploads:o}=this.options;if(this.storage.activeUploads>=o||this.storage.uploadQueue.length===0)return;const s=this.storage.uploadQueue.shift();this.storage.activeUploads++;const i=this.options,a=s.mediaItemType??n,l=new AbortController;this.storage.itemAborts.set(s.uid,()=>l.abort()),Ur(s.source)&&this.storage.itemBlobs.set(s.uid,s.source);const c=(async()=>{if(i.onUploadStart?.(s.uid),Ur(s.source))return hte({file:s.source,api:i.api,mediaItemType:a,signal:l.signal,onProgress:u=>{e.commands.updateMediaProgress(s.uid,u),i.onUploadProgress?.(s.uid,u)}});if(tx(bn(s.source)))return pte({url:s.source,api:i.api,mediaItemType:a,searchFrom:r,onProgress:u=>{e.commands.updateMediaProgress(s.uid,u),i.onUploadProgress?.(s.uid,u)}});throw new Error("Invalid source type")})();this.storage.itemPromises.set(s.uid,c),await(async()=>{try{const u=await c,d=this.storage.blobUrls.get(s.uid);d&&(URL.revokeObjectURL(d),this.storage.blobUrls.delete(s.uid));const f=u?.sources?.original?.url||u?.sources?.thumbnail?.url;if(f?e.commands.updateMediaByUid(s.uid,{src:f,type:yv(u?.imageType,s.type),uploading:!1,progress:100,payload:u}):e.commands.deleteMediaByUid(s.uid),i.onUploadComplete?.(s.uid,f),f){const{sessionId:h,editorType:p}=this.storage.getAnalyticsContext(e);if(h&&p){const m=ps();let g="unknown",b=0;Ur(s.source)&&(g=s.source.type||"unknown",b=s.source.size/1048576);const S=g?.toLowerCase()==="image/gif";m.trackMediaUploadSuccess(h,{editorType:p,mediaType:S?"gif":Du[s.type],fileSizeMB:b,source:s.uploadSource})}}}catch(u){const d=this.storage.blobUrls.get(s.uid);d&&(URL.revokeObjectURL(d),this.storage.blobUrls.delete(s.uid)),e.commands.deleteMediaByUid(s.uid),i.onUploadError?.(s.uid,u);const{sessionId:f,editorType:h}=this.storage.getAnalyticsContext(e);if(f&&h){const p=ps();let m=0;Ur(s.source)&&(m=s.source.size/1048576);let g="server_error";const b=u.message;b.includes("network")||b.includes("fetch")?g="network_error":b.includes("format")||b.includes("type")?g="unsupported_format":(b.includes("size")||b.includes("large"))&&(g="file_too_large"),p.trackMediaUploadFailed(f,{editorType:h,mediaType:Du[s.type],fileSizeMB:m,source:s.uploadSource,errorType:g})}}finally{this.storage.itemPromises.delete(s.uid),this.storage.itemBlobs.delete(s.uid),this.storage.itemAborts.delete(s.uid),this.storage.activeUploads--,this.storage.processUploadQueue(e,n,r)}})().catch(u=>{}),this.storage.uploadQueue.length>0&&this.storage.processUploadQueue(e,n,r)};if(this.storage.processUploadQueue=t,this.storage.uploadQueue.length>0){const e=Math.min(this.storage.uploadQueue.length,this.options.maxConcurrentUploads??Er);for(let n=0;n<e;n++)t(this.editor,Vn.MEDIA_ITEM,void 0)}},onUpdate(){if(this.storage.deferredUids.size===0)return;const t=new Set;this.editor.state.doc.descendants(e=>{e.type.name==="media"&&e.attrs.deferred&&t.add(e.attrs.uid)}),this.storage.deferredUids.forEach(e=>{if(t.has(e))return;const n=this.storage.blobUrls.get(e);n&&URL.revokeObjectURL(n),this.storage.blobUrls.delete(e),this.storage.itemBlobs.delete(e),this.storage.deferredUids.delete(e),this.storage.deferredMediaTypes.delete(e)})},onDestroy(){this.storage.blobUrls.forEach(t=>URL.revokeObjectURL(t)),this.storage.blobUrls.clear(),this.storage.itemPromises.clear(),this.storage.itemBlobs.clear(),this.storage.itemAborts.clear(),this.storage.deferredUids.clear(),this.storage.deferredMediaTypes.clear()},addProseMirrorPlugins(){const{editor:t}=this;return[new Ye({key:new Je("smartMediaUpload"),props:{handleDrop:(e,n)=>{const r=Array.from(n.dataTransfer?.files||[]);return r.length===0?!1:r.length>Er?(Zt.error(`You can upload at most ${Er} media files at a time`),!1):(n.preventDefault(),r.forEach(o=>{let s;if(o.type.startsWith("image/"))s=ue.Image;else if(o.type.startsWith("video/"))s=ue.Video;else if(o.type.startsWith("audio/"))s=ue.Audio;else return;t.commands.insertMediaWithUpload({source:o,type:s,mediaType:Vn.MEDIA_ITEM})}),!0)},handlePaste:(e,n)=>{const o=Array.from(n.clipboardData?.items||[]).filter(s=>s.type.startsWith("image/"));return o.length===0?!1:(n.preventDefault(),o.forEach(s=>{const i=s.getAsFile();if(i){const a=i.type.toLowerCase()==="image/gif";t.commands.insertMediaWithUpload({source:i,type:ue.Image,mediaType:a?Vn.IMAGE_ITEM:Vn.MEDIA_ITEM})}}),!0)}}})]}});function gte(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:s,startOfLine:i,$position:a}=t,l=r&&!o,c=b3(n),u=new RegExp(`\\s${c}$`),d=i?"^":"",f=o?"":c,h=l?new RegExp(`${d}${c}.*?(?=\\s${f}|$)`,"gm"):new RegExp(`${d}(?:^)?${c}[^\\s${f}]*`,"gm"),p=((e=a.nodeBefore)==null?void 0:e.isText)&&a.nodeBefore.text;if(!p)return null;const m=a.pos-p.length,g=Array.from(p.matchAll(h)).pop();if(!g||g.input===void 0||g.index===void 0)return null;const b=g.input.slice(Math.max(0,g.index-1),g.index),S=new RegExp(`^[${s?.join("")}\0]?$`).test(b);if(s!==null&&!S)return null;const k=m+g.index;let v=k+g[0].length;return l&&u.test(p.slice(v-1,v+1))&&(g[0]+=" ",v+=1),k<a.pos&&v>=a.pos?{range:{from:k,to:v},query:g[0].slice(n.length),text:g[0]}:null}var yte=new Je("suggestion");function bte({pluginKey:t=yte,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:o=!1,allowedPrefixes:s=[" "],startOfLine:i=!1,decorationTag:a="span",decorationClass:l="suggestion",decorationContent:c="",decorationEmptyClass:u="is-empty",command:d=()=>null,items:f=()=>[],render:h=()=>({}),allow:p=()=>!0,findSuggestionMatch:m=gte,shouldShow:g}){let b;const S=h?.(),k=()=>{const A=e.state.selection.$anchor.pos,E=e.view.coordsAtPos(A),{top:T,right:N,bottom:I,left:R}=E;try{return new DOMRect(R,T,N-R,I-T)}catch{return null}},v=(A,E)=>E?()=>{const T=t.getState(e.state),N=T?.decorationId,I=A.dom.querySelector(`[data-decoration-id="${N}"]`);return I?.getBoundingClientRect()||null}:k;function _(A,E){var T;try{const I=t.getState(A.state),R=I?.decorationId?A.dom.querySelector(`[data-decoration-id="${I.decorationId}"]`):null,D={editor:e,range:I?.range||{from:0,to:0},query:I?.query||null,text:I?.text||null,items:[],command:O=>d({editor:e,range:I?.range||{from:0,to:0},props:O}),decorationNode:R,clientRect:v(A,R)};(T=S?.onExit)==null||T.call(S,D)}catch{}const N=A.state.tr.setMeta(E,{exit:!0});A.dispatch(N)}const x=new Ye({key:t,view(){return{update:async(A,E)=>{var T,N,I,R,D,O,P;const C=(T=this.key)==null?void 0:T.getState(E),M=(N=this.key)==null?void 0:N.getState(A.state),U=C.active&&M.active&&C.range.from!==M.range.from,L=!C.active&&M.active,F=C.active&&!M.active,V=!L&&!F&&C.query!==M.query,W=L||U&&V,H=V||U,B=F||U&&V;if(!W&&!H&&!B)return;const $=B&&!W?C:M,K=A.dom.querySelector(`[data-decoration-id="${$.decorationId}"]`);b={editor:e,range:$.range,query:$.query,text:$.text,items:[],command:Y=>d({editor:e,range:$.range,props:Y}),decorationNode:K,clientRect:v(A,K)},W&&((I=S?.onBeforeStart)==null||I.call(S,b)),H&&((R=S?.onBeforeUpdate)==null||R.call(S,b)),(H||W)&&(b.items=await f({editor:e,query:$.query})),B&&((D=S?.onExit)==null||D.call(S,b)),H&&((O=S?.onUpdate)==null||O.call(S,b)),W&&((P=S?.onStart)==null||P.call(S,b))},destroy:()=>{var A;b&&((A=S?.onExit)==null||A.call(S,b))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(A,E,T,N){const{isEditable:I}=e,{composing:R}=e.view,{selection:D}=A,{empty:O,from:P}=D,C={...E},M=A.getMeta(t);if(M&&M.exit)return C.active=!1,C.decorationId=null,C.range={from:0,to:0},C.query=null,C.text=null,C;if(C.composing=R,I&&(O||e.view.composing)){(P<E.range.from||P>E.range.to)&&!R&&!E.composing&&(C.active=!1);const U=m({char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:s,startOfLine:i,$position:D.$from}),L=`id_${Math.floor(Math.random()*4294967295)}`;U&&p({editor:e,state:N,range:U.range,isActive:E.active})&&(!g||g({editor:e,range:U.range,query:U.query,text:U.text,transaction:A}))?(C.active=!0,C.decorationId=E.decorationId?E.decorationId:L,C.range=U.range,C.query=U.query,C.text=U.text):C.active=!1}else C.active=!1;return C.active||(C.decorationId=null,C.range={from:0,to:0},C.query=null,C.text=null),C}},props:{handleKeyDown(A,E){var T,N,I,R;const{active:D,range:O}=x.getState(A.state);if(!D)return!1;if(E.key==="Escape"||E.key==="Esc"){const C=x.getState(A.state),M=(T=b?.decorationNode)!=null?T:null,U=M??(C?.decorationId?A.dom.querySelector(`[data-decoration-id="${C.decorationId}"]`):null);if(((N=S?.onKeyDown)==null?void 0:N.call(S,{view:A,event:E,range:C.range}))||!1)return!0;const F={editor:e,range:C.range,query:C.query,text:C.text,items:[],command:V=>d({editor:e,range:C.range,props:V}),decorationNode:U,clientRect:U?()=>U.getBoundingClientRect()||null:null};return(I=S?.onExit)==null||I.call(S,F),_(A,t),!0}return((R=S?.onKeyDown)==null?void 0:R.call(S,{view:A,event:E,range:O}))||!1},decorations(A){const{active:E,range:T,decorationId:N,query:I}=x.getState(A);if(!E)return null;const R=!I?.length,D=[l];return R&&D.push(u),ft.create(A.doc,[tn.inline(T.from,T.to,{nodeName:a,class:D.join(" "),"data-decoration-id":N,"data-decoration-content":c})])}}});return x}var jn="top",pr="bottom",mr="right",$n="left",bv="auto",Bc=[jn,pr,mr,$n],ga="start",tc="end",vte="clippingParents",YN="viewport",el="popper",wte="reference",TE=Bc.reduce(function(t,e){return t.concat([e+"-"+ga,e+"-"+tc])},[]),JN=[].concat(Bc,[bv]).reduce(function(t,e){return t.concat([e,e+"-"+ga,e+"-"+tc])},[]),xte="beforeRead",Ete="read",Ste="afterRead",kte="beforeMain",Tte="main",Cte="afterMain",Ate="beforeWrite",_te="write",Mte="afterWrite",Ote=[xte,Ete,Ste,kte,Tte,Cte,Ate,_te,Mte];function so(t){return t?(t.nodeName||"").toLowerCase():null}function Yn(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function pi(t){var e=Yn(t).Element;return t instanceof e||t instanceof Element}function cr(t){var e=Yn(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function vv(t){if(typeof ShadowRoot>"u")return!1;var e=Yn(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function Rte(t){var e=t.state;Object.keys(e.elements).forEach(function(n){var r=e.styles[n]||{},o=e.attributes[n]||{},s=e.elements[n];!cr(s)||!so(s)||(Object.assign(s.style,r),Object.keys(o).forEach(function(i){var a=o[i];a===!1?s.removeAttribute(i):s.setAttribute(i,a===!0?"":a)}))})}function Nte(t){var e=t.state,n={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,n.popper),e.styles=n,e.elements.arrow&&Object.assign(e.elements.arrow.style,n.arrow),function(){Object.keys(e.elements).forEach(function(r){var o=e.elements[r],s=e.attributes[r]||{},i=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:n[r]),a=i.reduce(function(l,c){return l[c]="",l},{});!cr(o)||!so(o)||(Object.assign(o.style,a),Object.keys(s).forEach(function(l){o.removeAttribute(l)}))})}}const XN={name:"applyStyles",enabled:!0,phase:"write",fn:Rte,effect:Nte,requires:["computeStyles"]};function Zr(t){return t.split("-")[0]}var ei=Math.max,mf=Math.min,ya=Math.round;function qg(){var t=navigator.userAgentData;return t!=null&&t.brands&&Array.isArray(t.brands)?t.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function QN(){return!/^((?!chrome|android).)*safari/i.test(qg())}function ba(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),o=1,s=1;e&&cr(t)&&(o=t.offsetWidth>0&&ya(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&ya(r.height)/t.offsetHeight||1);var i=pi(t)?Yn(t):window,a=i.visualViewport,l=!QN()&&n,c=(r.left+(l&&a?a.offsetLeft:0))/o,u=(r.top+(l&&a?a.offsetTop:0))/s,d=r.width/o,f=r.height/s;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c,x:c,y:u}}function wv(t){var e=ba(t),n=t.offsetWidth,r=t.offsetHeight;return Math.abs(e.width-n)<=1&&(n=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:t.offsetLeft,y:t.offsetTop,width:n,height:r}}function ZN(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&vv(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Po(t){return Yn(t).getComputedStyle(t)}function Ite(t){return["table","td","th"].indexOf(so(t))>=0}function Ns(t){return((pi(t)?t.ownerDocument:t.document)||window.document).documentElement}function Dh(t){return so(t)==="html"?t:t.assignedSlot||t.parentNode||(vv(t)?t.host:null)||Ns(t)}function CE(t){return!cr(t)||Po(t).position==="fixed"?null:t.offsetParent}function Dte(t){var e=/firefox/i.test(qg()),n=/Trident/i.test(qg());if(n&&cr(t)){var r=Po(t);if(r.position==="fixed")return null}var o=Dh(t);for(vv(o)&&(o=o.host);cr(o)&&["html","body"].indexOf(so(o))<0;){var s=Po(o);if(s.transform!=="none"||s.perspective!=="none"||s.contain==="paint"||["transform","perspective"].indexOf(s.willChange)!==-1||e&&s.willChange==="filter"||e&&s.filter&&s.filter!=="none")return o;o=o.parentNode}return null}function zc(t){for(var e=Yn(t),n=CE(t);n&&Ite(n)&&Po(n).position==="static";)n=CE(n);return n&&(so(n)==="html"||so(n)==="body"&&Po(n).position==="static")?e:n||Dte(t)||e}function xv(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function Rl(t,e,n){return ei(t,mf(e,n))}function Pte(t,e,n){var r=Rl(t,e,n);return r>n?n:r}function eI(){return{top:0,right:0,bottom:0,left:0}}function tI(t){return Object.assign({},eI(),t)}function nI(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var Lte=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,tI(typeof e!="number"?e:nI(e,Bc))};function jte(t){var e,n=t.state,r=t.name,o=t.options,s=n.elements.arrow,i=n.modifiersData.popperOffsets,a=Zr(n.placement),l=xv(a),c=[$n,mr].indexOf(a)>=0,u=c?"height":"width";if(!(!s||!i)){var d=Lte(o.padding,n),f=wv(s),h=l==="y"?jn:$n,p=l==="y"?pr:mr,m=n.rects.reference[u]+n.rects.reference[l]-i[l]-n.rects.popper[u],g=i[l]-n.rects.reference[l],b=zc(s),S=b?l==="y"?b.clientHeight||0:b.clientWidth||0:0,k=m/2-g/2,v=d[h],_=S-f[u]-d[p],x=S/2-f[u]/2+k,A=Rl(v,x,_),E=l;n.modifiersData[r]=(e={},e[E]=A,e.centerOffset=A-x,e)}}function $te(t){var e=t.state,n=t.options,r=n.element,o=r===void 0?"[data-popper-arrow]":r;o!=null&&(typeof o=="string"&&(o=e.elements.popper.querySelector(o),!o)||ZN(e.elements.popper,o)&&(e.elements.arrow=o))}const Fte={name:"arrow",enabled:!0,phase:"main",fn:jte,effect:$te,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function va(t){return t.split("-")[1]}var Ute={top:"auto",right:"auto",bottom:"auto",left:"auto"};function Bte(t,e){var n=t.x,r=t.y,o=e.devicePixelRatio||1;return{x:ya(n*o)/o||0,y:ya(r*o)/o||0}}function AE(t){var e,n=t.popper,r=t.popperRect,o=t.placement,s=t.variation,i=t.offsets,a=t.position,l=t.gpuAcceleration,c=t.adaptive,u=t.roundOffsets,d=t.isFixed,f=i.x,h=f===void 0?0:f,p=i.y,m=p===void 0?0:p,g=typeof u=="function"?u({x:h,y:m}):{x:h,y:m};h=g.x,m=g.y;var b=i.hasOwnProperty("x"),S=i.hasOwnProperty("y"),k=$n,v=jn,_=window;if(c){var x=zc(n),A="clientHeight",E="clientWidth";if(x===Yn(n)&&(x=Ns(n),Po(x).position!=="static"&&a==="absolute"&&(A="scrollHeight",E="scrollWidth")),x=x,o===jn||(o===$n||o===mr)&&s===tc){v=pr;var T=d&&x===_&&_.visualViewport?_.visualViewport.height:x[A];m-=T-r.height,m*=l?1:-1}if(o===$n||(o===jn||o===pr)&&s===tc){k=mr;var N=d&&x===_&&_.visualViewport?_.visualViewport.width:x[E];h-=N-r.width,h*=l?1:-1}}var I=Object.assign({position:a},c&&Ute),R=u===!0?Bte({x:h,y:m},Yn(n)):{x:h,y:m};if(h=R.x,m=R.y,l){var D;return Object.assign({},I,(D={},D[v]=S?"0":"",D[k]=b?"0":"",D.transform=(_.devicePixelRatio||1)<=1?"translate("+h+"px, "+m+"px)":"translate3d("+h+"px, "+m+"px, 0)",D))}return Object.assign({},I,(e={},e[v]=S?m+"px":"",e[k]=b?h+"px":"",e.transform="",e))}function zte(t){var e=t.state,n=t.options,r=n.gpuAcceleration,o=r===void 0?!0:r,s=n.adaptive,i=s===void 0?!0:s,a=n.roundOffsets,l=a===void 0?!0:a,c={placement:Zr(e.placement),variation:va(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:o,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,AE(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:i,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,AE(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const Hte={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:zte,data:{}};var Su={passive:!0};function Vte(t){var e=t.state,n=t.instance,r=t.options,o=r.scroll,s=o===void 0?!0:o,i=r.resize,a=i===void 0?!0:i,l=Yn(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&c.forEach(function(u){u.addEventListener("scroll",n.update,Su)}),a&&l.addEventListener("resize",n.update,Su),function(){s&&c.forEach(function(u){u.removeEventListener("scroll",n.update,Su)}),a&&l.removeEventListener("resize",n.update,Su)}}const Wte={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:Vte,data:{}};var Kte={left:"right",right:"left",bottom:"top",top:"bottom"};function qu(t){return t.replace(/left|right|bottom|top/g,function(e){return Kte[e]})}var Gte={start:"end",end:"start"};function _E(t){return t.replace(/start|end/g,function(e){return Gte[e]})}function Ev(t){var e=Yn(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function Sv(t){return ba(Ns(t)).left+Ev(t).scrollLeft}function qte(t,e){var n=Yn(t),r=Ns(t),o=n.visualViewport,s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;var c=QN();(c||!c&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a+Sv(t),y:l}}function Yte(t){var e,n=Ns(t),r=Ev(t),o=(e=t.ownerDocument)==null?void 0:e.body,s=ei(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),i=ei(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),a=-r.scrollLeft+Sv(t),l=-r.scrollTop;return Po(o||n).direction==="rtl"&&(a+=ei(n.clientWidth,o?o.clientWidth:0)-s),{width:s,height:i,x:a,y:l}}function kv(t){var e=Po(t),n=e.overflow,r=e.overflowX,o=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function rI(t){return["html","body","#document"].indexOf(so(t))>=0?t.ownerDocument.body:cr(t)&&kv(t)?t:rI(Dh(t))}function Nl(t,e){var n;e===void 0&&(e=[]);var r=rI(t),o=r===((n=t.ownerDocument)==null?void 0:n.body),s=Yn(r),i=o?[s].concat(s.visualViewport||[],kv(r)?r:[]):r,a=e.concat(i);return o?a:a.concat(Nl(Dh(i)))}function Yg(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function Jte(t,e){var n=ba(t,!1,e==="fixed");return n.top=n.top+t.clientTop,n.left=n.left+t.clientLeft,n.bottom=n.top+t.clientHeight,n.right=n.left+t.clientWidth,n.width=t.clientWidth,n.height=t.clientHeight,n.x=n.left,n.y=n.top,n}function ME(t,e,n){return e===YN?Yg(qte(t,n)):pi(e)?Jte(e,n):Yg(Yte(Ns(t)))}function Xte(t){var e=Nl(Dh(t)),n=["absolute","fixed"].indexOf(Po(t).position)>=0,r=n&&cr(t)?zc(t):t;return pi(r)?e.filter(function(o){return pi(o)&&ZN(o,r)&&so(o)!=="body"}):[]}function Qte(t,e,n,r){var o=e==="clippingParents"?Xte(t):[].concat(e),s=[].concat(o,[n]),i=s[0],a=s.reduce(function(l,c){var u=ME(t,c,r);return l.top=ei(u.top,l.top),l.right=mf(u.right,l.right),l.bottom=mf(u.bottom,l.bottom),l.left=ei(u.left,l.left),l},ME(t,i,r));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}function oI(t){var e=t.reference,n=t.element,r=t.placement,o=r?Zr(r):null,s=r?va(r):null,i=e.x+e.width/2-n.width/2,a=e.y+e.height/2-n.height/2,l;switch(o){case jn:l={x:i,y:e.y-n.height};break;case pr:l={x:i,y:e.y+e.height};break;case mr:l={x:e.x+e.width,y:a};break;case $n:l={x:e.x-n.width,y:a};break;default:l={x:e.x,y:e.y}}var c=o?xv(o):null;if(c!=null){var u=c==="y"?"height":"width";switch(s){case ga:l[c]=l[c]-(e[u]/2-n[u]/2);break;case tc:l[c]=l[c]+(e[u]/2-n[u]/2);break}}return l}function nc(t,e){e===void 0&&(e={});var n=e,r=n.placement,o=r===void 0?t.placement:r,s=n.strategy,i=s===void 0?t.strategy:s,a=n.boundary,l=a===void 0?vte:a,c=n.rootBoundary,u=c===void 0?YN:c,d=n.elementContext,f=d===void 0?el:d,h=n.altBoundary,p=h===void 0?!1:h,m=n.padding,g=m===void 0?0:m,b=tI(typeof g!="number"?g:nI(g,Bc)),S=f===el?wte:el,k=t.rects.popper,v=t.elements[p?S:f],_=Qte(pi(v)?v:v.contextElement||Ns(t.elements.popper),l,u,i),x=ba(t.elements.reference),A=oI({reference:x,element:k,placement:o}),E=Yg(Object.assign({},k,A)),T=f===el?E:x,N={top:_.top-T.top+b.top,bottom:T.bottom-_.bottom+b.bottom,left:_.left-T.left+b.left,right:T.right-_.right+b.right},I=t.modifiersData.offset;if(f===el&&I){var R=I[o];Object.keys(N).forEach(function(D){var O=[mr,pr].indexOf(D)>=0?1:-1,P=[jn,pr].indexOf(D)>=0?"y":"x";N[D]+=R[P]*O})}return N}function Zte(t,e){e===void 0&&(e={});var n=e,r=n.placement,o=n.boundary,s=n.rootBoundary,i=n.padding,a=n.flipVariations,l=n.allowedAutoPlacements,c=l===void 0?JN:l,u=va(r),d=u?a?TE:TE.filter(function(p){return va(p)===u}):Bc,f=d.filter(function(p){return c.indexOf(p)>=0});f.length===0&&(f=d);var h=f.reduce(function(p,m){return p[m]=nc(t,{placement:m,boundary:o,rootBoundary:s,padding:i})[Zr(m)],p},{});return Object.keys(h).sort(function(p,m){return h[p]-h[m]})}function ene(t){if(Zr(t)===bv)return[];var e=qu(t);return[_E(t),e,_E(e)]}function tne(t){var e=t.state,n=t.options,r=t.name;if(!e.modifiersData[r]._skip){for(var o=n.mainAxis,s=o===void 0?!0:o,i=n.altAxis,a=i===void 0?!0:i,l=n.fallbackPlacements,c=n.padding,u=n.boundary,d=n.rootBoundary,f=n.altBoundary,h=n.flipVariations,p=h===void 0?!0:h,m=n.allowedAutoPlacements,g=e.options.placement,b=Zr(g),S=b===g,k=l||(S||!p?[qu(g)]:ene(g)),v=[g].concat(k).reduce(function(B,$){return B.concat(Zr($)===bv?Zte(e,{placement:$,boundary:u,rootBoundary:d,padding:c,flipVariations:p,allowedAutoPlacements:m}):$)},[]),_=e.rects.reference,x=e.rects.popper,A=new Map,E=!0,T=v[0],N=0;N<v.length;N++){var I=v[N],R=Zr(I),D=va(I)===ga,O=[jn,pr].indexOf(R)>=0,P=O?"width":"height",C=nc(e,{placement:I,boundary:u,rootBoundary:d,altBoundary:f,padding:c}),M=O?D?mr:$n:D?pr:jn;_[P]>x[P]&&(M=qu(M));var U=qu(M),L=[];if(s&&L.push(C[R]<=0),a&&L.push(C[M]<=0,C[U]<=0),L.every(function(B){return B})){T=I,E=!1;break}A.set(I,L)}if(E)for(var F=p?3:1,V=function($){var K=v.find(function(Y){var J=A.get(Y);if(J)return J.slice(0,$).every(function(Q){return Q})});if(K)return T=K,"break"},W=F;W>0;W--){var H=V(W);if(H==="break")break}e.placement!==T&&(e.modifiersData[r]._skip=!0,e.placement=T,e.reset=!0)}}const nne={name:"flip",enabled:!0,phase:"main",fn:tne,requiresIfExists:["offset"],data:{_skip:!1}};function OE(t,e,n){return n===void 0&&(n={x:0,y:0}),{top:t.top-e.height-n.y,right:t.right-e.width+n.x,bottom:t.bottom-e.height+n.y,left:t.left-e.width-n.x}}function RE(t){return[jn,mr,pr,$n].some(function(e){return t[e]>=0})}function rne(t){var e=t.state,n=t.name,r=e.rects.reference,o=e.rects.popper,s=e.modifiersData.preventOverflow,i=nc(e,{elementContext:"reference"}),a=nc(e,{altBoundary:!0}),l=OE(i,r),c=OE(a,o,s),u=RE(l),d=RE(c);e.modifiersData[n]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}const one={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:rne};function sne(t,e,n){var r=Zr(t),o=[$n,jn].indexOf(r)>=0?-1:1,s=typeof n=="function"?n(Object.assign({},e,{placement:t})):n,i=s[0],a=s[1];return i=i||0,a=(a||0)*o,[$n,mr].indexOf(r)>=0?{x:a,y:i}:{x:i,y:a}}function ine(t){var e=t.state,n=t.options,r=t.name,o=n.offset,s=o===void 0?[0,0]:o,i=JN.reduce(function(u,d){return u[d]=sne(d,e.rects,s),u},{}),a=i[e.placement],l=a.x,c=a.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=c),e.modifiersData[r]=i}const ane={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:ine};function lne(t){var e=t.state,n=t.name;e.modifiersData[n]=oI({reference:e.rects.reference,element:e.rects.popper,placement:e.placement})}const cne={name:"popperOffsets",enabled:!0,phase:"read",fn:lne,data:{}};function une(t){return t==="x"?"y":"x"}function dne(t){var e=t.state,n=t.options,r=t.name,o=n.mainAxis,s=o===void 0?!0:o,i=n.altAxis,a=i===void 0?!1:i,l=n.boundary,c=n.rootBoundary,u=n.altBoundary,d=n.padding,f=n.tether,h=f===void 0?!0:f,p=n.tetherOffset,m=p===void 0?0:p,g=nc(e,{boundary:l,rootBoundary:c,padding:d,altBoundary:u}),b=Zr(e.placement),S=va(e.placement),k=!S,v=xv(b),_=une(v),x=e.modifiersData.popperOffsets,A=e.rects.reference,E=e.rects.popper,T=typeof m=="function"?m(Object.assign({},e.rects,{placement:e.placement})):m,N=typeof T=="number"?{mainAxis:T,altAxis:T}:Object.assign({mainAxis:0,altAxis:0},T),I=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,R={x:0,y:0};if(x){if(s){var D,O=v==="y"?jn:$n,P=v==="y"?pr:mr,C=v==="y"?"height":"width",M=x[v],U=M+g[O],L=M-g[P],F=h?-E[C]/2:0,V=S===ga?A[C]:E[C],W=S===ga?-E[C]:-A[C],H=e.elements.arrow,B=h&&H?wv(H):{width:0,height:0},$=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:eI(),K=$[O],Y=$[P],J=Rl(0,A[C],B[C]),Q=k?A[C]/2-F-J-K-N.mainAxis:V-J-K-N.mainAxis,ne=k?-A[C]/2+F+J+Y+N.mainAxis:W+J+Y+N.mainAxis,se=e.elements.arrow&&zc(e.elements.arrow),te=se?v==="y"?se.clientTop||0:se.clientLeft||0:0,ge=(D=I?.[v])!=null?D:0,he=M+Q-ge-te,xe=M+ne-ge,Ee=Rl(h?mf(U,he):U,M,h?ei(L,xe):L);x[v]=Ee,R[v]=Ee-M}if(a){var Se,_e=v==="x"?jn:$n,Me=v==="x"?pr:mr,Ke=x[_],Ge=_==="y"?"height":"width",Be=Ke+g[_e],je=Ke-g[Me],$e=[jn,$n].indexOf(b)!==-1,pe=(Se=I?.[_])!=null?Se:0,Ne=$e?Be:Ke-A[Ge]-E[Ge]-pe+N.altAxis,Ie=$e?Ke+A[Ge]+E[Ge]-pe-N.altAxis:je,Ve=h&&$e?Pte(Ne,Ke,Ie):Rl(h?Ne:Be,Ke,h?Ie:je);x[_]=Ve,R[_]=Ve-Ke}e.modifiersData[r]=R}}const fne={name:"preventOverflow",enabled:!0,phase:"main",fn:dne,requiresIfExists:["offset"]};function hne(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function pne(t){return t===Yn(t)||!cr(t)?Ev(t):hne(t)}function mne(t){var e=t.getBoundingClientRect(),n=ya(e.width)/t.offsetWidth||1,r=ya(e.height)/t.offsetHeight||1;return n!==1||r!==1}function gne(t,e,n){n===void 0&&(n=!1);var r=cr(e),o=cr(e)&&mne(e),s=Ns(e),i=ba(t,o,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((so(e)!=="body"||kv(s))&&(a=pne(e)),cr(e)?(l=ba(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):s&&(l.x=Sv(s))),{x:i.left+a.scrollLeft-l.x,y:i.top+a.scrollTop-l.y,width:i.width,height:i.height}}function yne(t){var e=new Map,n=new Set,r=[];t.forEach(function(s){e.set(s.name,s)});function o(s){n.add(s.name);var i=[].concat(s.requires||[],s.requiresIfExists||[]);i.forEach(function(a){if(!n.has(a)){var l=e.get(a);l&&o(l)}}),r.push(s)}return t.forEach(function(s){n.has(s.name)||o(s)}),r}function bne(t){var e=yne(t);return Ote.reduce(function(n,r){return n.concat(e.filter(function(o){return o.phase===r}))},[])}function vne(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function wne(t){var e=t.reduce(function(n,r){var o=n[r.name];return n[r.name]=o?Object.assign({},o,r,{options:Object.assign({},o.options,r.options),data:Object.assign({},o.data,r.data)}):r,n},{});return Object.keys(e).map(function(n){return e[n]})}var NE={placement:"bottom",modifiers:[],strategy:"absolute"};function IE(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return!e.some(function(r){return!(r&&typeof r.getBoundingClientRect=="function")})}function xne(t){t===void 0&&(t={});var e=t,n=e.defaultModifiers,r=n===void 0?[]:n,o=e.defaultOptions,s=o===void 0?NE:o;return function(a,l,c){c===void 0&&(c=s);var u={placement:"bottom",orderedModifiers:[],options:Object.assign({},NE,s),modifiersData:{},elements:{reference:a,popper:l},attributes:{},styles:{}},d=[],f=!1,h={state:u,setOptions:function(b){var S=typeof b=="function"?b(u.options):b;m(),u.options=Object.assign({},s,u.options,S),u.scrollParents={reference:pi(a)?Nl(a):a.contextElement?Nl(a.contextElement):[],popper:Nl(l)};var k=bne(wne([].concat(r,u.options.modifiers)));return u.orderedModifiers=k.filter(function(v){return v.enabled}),p(),h.update()},forceUpdate:function(){if(!f){var b=u.elements,S=b.reference,k=b.popper;if(IE(S,k)){u.rects={reference:gne(S,zc(k),u.options.strategy==="fixed"),popper:wv(k)},u.reset=!1,u.placement=u.options.placement,u.orderedModifiers.forEach(function(N){return u.modifiersData[N.name]=Object.assign({},N.data)});for(var v=0;v<u.orderedModifiers.length;v++){if(u.reset===!0){u.reset=!1,v=-1;continue}var _=u.orderedModifiers[v],x=_.fn,A=_.options,E=A===void 0?{}:A,T=_.name;typeof x=="function"&&(u=x({state:u,options:E,name:T,instance:h})||u)}}}},update:vne(function(){return new Promise(function(g){h.forceUpdate(),g(u)})}),destroy:function(){m(),f=!0}};if(!IE(a,l))return h;h.setOptions(c).then(function(g){!f&&c.onFirstUpdate&&c.onFirstUpdate(g)});function p(){u.orderedModifiers.forEach(function(g){var b=g.name,S=g.options,k=S===void 0?{}:S,v=g.effect;if(typeof v=="function"){var _=v({state:u,name:b,instance:h,options:k}),x=function(){};d.push(_||x)}})}function m(){d.forEach(function(g){return g()}),d=[]}return h}}var Ene=[Wte,cne,Hte,XN,ane,nne,fne,Fte,one],Sne=xne({defaultModifiers:Ene}),kne="tippy-box",sI="tippy-content",Tne="tippy-backdrop",iI="tippy-arrow",aI="tippy-svg-arrow",Ls={passive:!0,capture:!0},lI=function(){return document.body};function Cne(t,e){return{}.hasOwnProperty.call(t,e)}function dm(t,e,n){if(Array.isArray(t)){var r=t[e];return r??(Array.isArray(n)?n[e]:n)}return t}function Tv(t,e){var n={}.toString.call(t);return n.indexOf("[object")===0&&n.indexOf(e+"]")>-1}function cI(t,e){return typeof t=="function"?t.apply(void 0,e):t}function DE(t,e){if(e===0)return t;var n;return function(r){clearTimeout(n),n=setTimeout(function(){t(r)},e)}}function Ane(t,e){var n=Object.assign({},t);return e.forEach(function(r){delete n[r]}),n}function _ne(t){return t.split(/\s+/).filter(Boolean)}function zi(t){return[].concat(t)}function PE(t,e){t.indexOf(e)===-1&&t.push(e)}function Mne(t){return t.filter(function(e,n){return t.indexOf(e)===n})}function One(t){return t.split("-")[0]}function gf(t){return[].slice.call(t)}function LE(t){return Object.keys(t).reduce(function(e,n){return t[n]!==void 0&&(e[n]=t[n]),e},{})}function Il(){return document.createElement("div")}function rc(t){return["Element","Fragment"].some(function(e){return Tv(t,e)})}function Rne(t){return Tv(t,"NodeList")}function Nne(t){return Tv(t,"MouseEvent")}function Ine(t){return!!(t&&t._tippy&&t._tippy.reference===t)}function Dne(t){return rc(t)?[t]:Rne(t)?gf(t):Array.isArray(t)?t:gf(document.querySelectorAll(t))}function fm(t,e){t.forEach(function(n){n&&(n.style.transitionDuration=e+"ms")})}function jE(t,e){t.forEach(function(n){n&&n.setAttribute("data-state",e)})}function Pne(t){var e,n=zi(t),r=n[0];return r!=null&&(e=r.ownerDocument)!=null&&e.body?r.ownerDocument:document}function Lne(t,e){var n=e.clientX,r=e.clientY;return t.every(function(o){var s=o.popperRect,i=o.popperState,a=o.props,l=a.interactiveBorder,c=One(i.placement),u=i.modifiersData.offset;if(!u)return!0;var d=c==="bottom"?u.top.y:0,f=c==="top"?u.bottom.y:0,h=c==="right"?u.left.x:0,p=c==="left"?u.right.x:0,m=s.top-r+d>l,g=r-s.bottom-f>l,b=s.left-n+h>l,S=n-s.right-p>l;return m||g||b||S})}function hm(t,e,n){var r=e+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(o){t[r](o,n)})}function $E(t,e){for(var n=e;n;){var r;if(t.contains(n))return!0;n=n.getRootNode==null||(r=n.getRootNode())==null?void 0:r.host}return!1}var Gr={isTouch:!1},FE=0;function jne(){Gr.isTouch||(Gr.isTouch=!0,window.performance&&document.addEventListener("mousemove",uI))}function uI(){var t=performance.now();t-FE<20&&(Gr.isTouch=!1,document.removeEventListener("mousemove",uI)),FE=t}function $ne(){var t=document.activeElement;if(Ine(t)){var e=t._tippy;t.blur&&!e.state.isVisible&&t.blur()}}function Fne(){document.addEventListener("touchstart",jne,Ls),window.addEventListener("blur",$ne)}var Une=typeof window<"u"&&typeof document<"u",Bne=Une?!!window.msCrypto:!1;function ji(t){var e=t==="destroy"?"n already-":" ";return[t+"() was called on a"+e+"destroyed instance. This is a no-op but","indicates a potential memory leak."].join(" ")}function UE(t){var e=/[ \t]{2,}/g,n=/^[ \t]*/gm;return t.replace(e," ").replace(n,"").trim()}function zne(t){return UE(`
214
- %ctippy.js
215
-
216
- %c`+UE(t)+`
217
-
218
- %c👷‍ This is a development-only message. It will be removed in production.
219
- `)}function dI(t){return[zne(t),"color: #00C584; font-size: 1.3em; font-weight: bold;","line-height: 1.5","color: #a6a095;"]}var oc;process.env.NODE_ENV!=="production"&&Hne();function Hne(){oc=new Set}function xo(t,e){if(t&&!oc.has(e)){var n;oc.add(e),(n=console).warn.apply(n,dI(e))}}function Jg(t,e){if(t&&!oc.has(e)){var n;oc.add(e),(n=console).error.apply(n,dI(e))}}function Vne(t){var e=!t,n=Object.prototype.toString.call(t)==="[object Object]"&&!t.addEventListener;Jg(e,["tippy() was passed","`"+String(t)+"`","as its targets (first) argument. Valid types are: String, Element,","Element[], or NodeList."].join(" ")),Jg(n,["tippy() was passed a plain object which is not supported as an argument","for virtual positioning. Use props.getReferenceClientRect instead."].join(" "))}var fI={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},Wne={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},Kn=Object.assign({appendTo:lI,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},fI,Wne),Kne=Object.keys(Kn),Gne=function(e){process.env.NODE_ENV!=="production"&&pI(e,[]);var n=Object.keys(e);n.forEach(function(r){Kn[r]=e[r]})};function hI(t){var e=t.plugins||[],n=e.reduce(function(r,o){var s=o.name,i=o.defaultValue;if(s){var a;r[s]=t[s]!==void 0?t[s]:(a=Kn[s])!=null?a:i}return r},{});return Object.assign({},t,n)}function qne(t,e){var n=e?Object.keys(hI(Object.assign({},Kn,{plugins:e}))):Kne,r=n.reduce(function(o,s){var i=(t.getAttribute("data-tippy-"+s)||"").trim();if(!i)return o;if(s==="content")o[s]=i;else try{o[s]=JSON.parse(i)}catch{o[s]=i}return o},{});return r}function BE(t,e){var n=Object.assign({},e,{content:cI(e.content,[t])},e.ignoreAttributes?{}:qne(t,e.plugins));return n.aria=Object.assign({},Kn.aria,n.aria),n.aria={expanded:n.aria.expanded==="auto"?e.interactive:n.aria.expanded,content:n.aria.content==="auto"?e.interactive?null:"describedby":n.aria.content},n}function pI(t,e){t===void 0&&(t={}),e===void 0&&(e=[]);var n=Object.keys(t);n.forEach(function(r){var o=Ane(Kn,Object.keys(fI)),s=!Cne(o,r);s&&(s=e.filter(function(i){return i.name===r}).length===0),xo(s,["`"+r+"`","is not a valid prop. You may have spelled it incorrectly, or if it's","a plugin, forgot to pass it in an array as props.plugins.",`
220
-
221
- `,`All props: https://atomiks.github.io/tippyjs/v6/all-props/
222
- `,"Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "))})}var Yne=function(){return"innerHTML"};function Xg(t,e){t[Yne()]=e}function zE(t){var e=Il();return t===!0?e.className=iI:(e.className=aI,rc(t)?e.appendChild(t):Xg(e,t)),e}function HE(t,e){rc(e.content)?(Xg(t,""),t.appendChild(e.content)):typeof e.content!="function"&&(e.allowHTML?Xg(t,e.content):t.textContent=e.content)}function Qg(t){var e=t.firstElementChild,n=gf(e.children);return{box:e,content:n.find(function(r){return r.classList.contains(sI)}),arrow:n.find(function(r){return r.classList.contains(iI)||r.classList.contains(aI)}),backdrop:n.find(function(r){return r.classList.contains(Tne)})}}function mI(t){var e=Il(),n=Il();n.className=kne,n.setAttribute("data-state","hidden"),n.setAttribute("tabindex","-1");var r=Il();r.className=sI,r.setAttribute("data-state","hidden"),HE(r,t.props),e.appendChild(n),n.appendChild(r),o(t.props,t.props);function o(s,i){var a=Qg(e),l=a.box,c=a.content,u=a.arrow;i.theme?l.setAttribute("data-theme",i.theme):l.removeAttribute("data-theme"),typeof i.animation=="string"?l.setAttribute("data-animation",i.animation):l.removeAttribute("data-animation"),i.inertia?l.setAttribute("data-inertia",""):l.removeAttribute("data-inertia"),l.style.maxWidth=typeof i.maxWidth=="number"?i.maxWidth+"px":i.maxWidth,i.role?l.setAttribute("role",i.role):l.removeAttribute("role"),(s.content!==i.content||s.allowHTML!==i.allowHTML)&&HE(c,t.props),i.arrow?u?s.arrow!==i.arrow&&(l.removeChild(u),l.appendChild(zE(i.arrow))):l.appendChild(zE(i.arrow)):u&&l.removeChild(u)}return{popper:e,onUpdate:o}}mI.$$tippy=!0;var Jne=1,ku=[],pm=[];function Xne(t,e){var n=BE(t,Object.assign({},Kn,hI(LE(e)))),r,o,s,i=!1,a=!1,l=!1,c=!1,u,d,f,h=[],p=DE(he,n.interactiveDebounce),m,g=Jne++,b=null,S=Mne(n.plugins),k={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},v={id:g,reference:t,popper:Il(),popperInstance:b,props:n,state:k,plugins:S,clearDelayTimeouts:Ne,setProps:Ie,setContent:Ve,show:vt,hide:tt,hideWithInteractivity:et,enable:$e,disable:pe,unmount:qe,destroy:jt};if(!n.render)return process.env.NODE_ENV!=="production"&&Jg(!0,"render() function has not been supplied."),v;var _=n.render(v),x=_.popper,A=_.onUpdate;x.setAttribute("data-tippy-root",""),x.id="tippy-"+v.id,v.popper=x,t._tippy=v,x._tippy=v;var E=S.map(function(q){return q.fn(v)}),T=t.hasAttribute("aria-expanded");return se(),F(),M(),U("onCreate",[v]),n.showOnCreate&&Be(),x.addEventListener("mouseenter",function(){v.props.interactive&&v.state.isVisible&&v.clearDelayTimeouts()}),x.addEventListener("mouseleave",function(){v.props.interactive&&v.props.trigger.indexOf("mouseenter")>=0&&O().addEventListener("mousemove",p)}),v;function N(){var q=v.props.touch;return Array.isArray(q)?q:[q,0]}function I(){return N()[0]==="hold"}function R(){var q;return!!((q=v.props.render)!=null&&q.$$tippy)}function D(){return m||t}function O(){var q=D().parentNode;return q?Pne(q):document}function P(){return Qg(x)}function C(q){return v.state.isMounted&&!v.state.isVisible||Gr.isTouch||u&&u.type==="focus"?0:dm(v.props.delay,q?0:1,Kn.delay)}function M(q){q===void 0&&(q=!1),x.style.pointerEvents=v.props.interactive&&!q?"":"none",x.style.zIndex=""+v.props.zIndex}function U(q,re,de){if(de===void 0&&(de=!0),E.forEach(function(Ae){Ae[q]&&Ae[q].apply(Ae,re)}),de){var We;(We=v.props)[q].apply(We,re)}}function L(){var q=v.props.aria;if(q.content){var re="aria-"+q.content,de=x.id,We=zi(v.props.triggerTarget||t);We.forEach(function(Ae){var ot=Ae.getAttribute(re);if(v.state.isVisible)Ae.setAttribute(re,ot?ot+" "+de:de);else{var ht=ot&&ot.replace(de,"").trim();ht?Ae.setAttribute(re,ht):Ae.removeAttribute(re)}})}}function F(){if(!(T||!v.props.aria.expanded)){var q=zi(v.props.triggerTarget||t);q.forEach(function(re){v.props.interactive?re.setAttribute("aria-expanded",v.state.isVisible&&re===D()?"true":"false"):re.removeAttribute("aria-expanded")})}}function V(){O().removeEventListener("mousemove",p),ku=ku.filter(function(q){return q!==p})}function W(q){if(!(Gr.isTouch&&(l||q.type==="mousedown"))){var re=q.composedPath&&q.composedPath()[0]||q.target;if(!(v.props.interactive&&$E(x,re))){if(zi(v.props.triggerTarget||t).some(function(de){return $E(de,re)})){if(Gr.isTouch||v.state.isVisible&&v.props.trigger.indexOf("click")>=0)return}else U("onClickOutside",[v,q]);v.props.hideOnClick===!0&&(v.clearDelayTimeouts(),v.hide(),a=!0,setTimeout(function(){a=!1}),v.state.isMounted||K())}}}function H(){l=!0}function B(){l=!1}function $(){var q=O();q.addEventListener("mousedown",W,!0),q.addEventListener("touchend",W,Ls),q.addEventListener("touchstart",B,Ls),q.addEventListener("touchmove",H,Ls)}function K(){var q=O();q.removeEventListener("mousedown",W,!0),q.removeEventListener("touchend",W,Ls),q.removeEventListener("touchstart",B,Ls),q.removeEventListener("touchmove",H,Ls)}function Y(q,re){Q(q,function(){!v.state.isVisible&&x.parentNode&&x.parentNode.contains(x)&&re()})}function J(q,re){Q(q,re)}function Q(q,re){var de=P().box;function We(Ae){Ae.target===de&&(hm(de,"remove",We),re())}if(q===0)return re();hm(de,"remove",d),hm(de,"add",We),d=We}function ne(q,re,de){de===void 0&&(de=!1);var We=zi(v.props.triggerTarget||t);We.forEach(function(Ae){Ae.addEventListener(q,re,de),h.push({node:Ae,eventType:q,handler:re,options:de})})}function se(){I()&&(ne("touchstart",ge,{passive:!0}),ne("touchend",xe,{passive:!0})),_ne(v.props.trigger).forEach(function(q){if(q!=="manual")switch(ne(q,ge),q){case"mouseenter":ne("mouseleave",xe);break;case"focus":ne(Bne?"focusout":"blur",Ee);break;case"focusin":ne("focusout",Ee);break}})}function te(){h.forEach(function(q){var re=q.node,de=q.eventType,We=q.handler,Ae=q.options;re.removeEventListener(de,We,Ae)}),h=[]}function ge(q){var re,de=!1;if(!(!v.state.isEnabled||Se(q)||a)){var We=((re=u)==null?void 0:re.type)==="focus";u=q,m=q.currentTarget,F(),!v.state.isVisible&&Nne(q)&&ku.forEach(function(Ae){return Ae(q)}),q.type==="click"&&(v.props.trigger.indexOf("mouseenter")<0||i)&&v.props.hideOnClick!==!1&&v.state.isVisible?de=!0:Be(q),q.type==="click"&&(i=!de),de&&!We&&je(q)}}function he(q){var re=q.target,de=D().contains(re)||x.contains(re);if(!(q.type==="mousemove"&&de)){var We=Ge().concat(x).map(function(Ae){var ot,ht=Ae._tippy,hn=(ot=ht.popperInstance)==null?void 0:ot.state;return hn?{popperRect:Ae.getBoundingClientRect(),popperState:hn,props:n}:null}).filter(Boolean);Lne(We,q)&&(V(),je(q))}}function xe(q){var re=Se(q)||v.props.trigger.indexOf("click")>=0&&i;if(!re){if(v.props.interactive){v.hideWithInteractivity(q);return}je(q)}}function Ee(q){v.props.trigger.indexOf("focusin")<0&&q.target!==D()||v.props.interactive&&q.relatedTarget&&x.contains(q.relatedTarget)||je(q)}function Se(q){return Gr.isTouch?I()!==q.type.indexOf("touch")>=0:!1}function _e(){Me();var q=v.props,re=q.popperOptions,de=q.placement,We=q.offset,Ae=q.getReferenceClientRect,ot=q.moveTransition,ht=R()?Qg(x).arrow:null,hn=Ae?{getBoundingClientRect:Ae,contextElement:Ae.contextElement||D()}:t,nn={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(nt){var Ce=nt.state;if(R()){var rt=P(),$t=rt.box;["placement","reference-hidden","escaped"].forEach(function(mt){mt==="placement"?$t.setAttribute("data-placement",Ce.placement):Ce.attributes.popper["data-popper-"+mt]?$t.setAttribute("data-"+mt,""):$t.removeAttribute("data-"+mt)}),Ce.attributes.popper={}}}},pt=[{name:"offset",options:{offset:We}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!ot}},nn];R()&&ht&&pt.push({name:"arrow",options:{element:ht,padding:3}}),pt.push.apply(pt,re?.modifiers||[]),v.popperInstance=Sne(hn,x,Object.assign({},re,{placement:de,onFirstUpdate:f,modifiers:pt}))}function Me(){v.popperInstance&&(v.popperInstance.destroy(),v.popperInstance=null)}function Ke(){var q=v.props.appendTo,re,de=D();v.props.interactive&&q===lI||q==="parent"?re=de.parentNode:re=cI(q,[de]),re.contains(x)||re.appendChild(x),v.state.isMounted=!0,_e(),process.env.NODE_ENV!=="production"&&xo(v.props.interactive&&q===Kn.appendTo&&de.nextElementSibling!==x,["Interactive tippy element may not be accessible via keyboard","navigation because it is not directly after the reference element","in the DOM source order.",`
223
-
224
- `,"Using a wrapper <div> or <span> tag around the reference element","solves this by creating a new parentNode context.",`
225
-
226
- `,"Specifying `appendTo: document.body` silences this warning, but it","assumes you are using a focus management solution to handle","keyboard navigation.",`
227
-
228
- `,"See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "))}function Ge(){return gf(x.querySelectorAll("[data-tippy-root]"))}function Be(q){v.clearDelayTimeouts(),q&&U("onTrigger",[v,q]),$();var re=C(!0),de=N(),We=de[0],Ae=de[1];Gr.isTouch&&We==="hold"&&Ae&&(re=Ae),re?r=setTimeout(function(){v.show()},re):v.show()}function je(q){if(v.clearDelayTimeouts(),U("onUntrigger",[v,q]),!v.state.isVisible){K();return}if(!(v.props.trigger.indexOf("mouseenter")>=0&&v.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(q.type)>=0&&i)){var re=C(!1);re?o=setTimeout(function(){v.state.isVisible&&v.hide()},re):s=requestAnimationFrame(function(){v.hide()})}}function $e(){v.state.isEnabled=!0}function pe(){v.hide(),v.state.isEnabled=!1}function Ne(){clearTimeout(r),clearTimeout(o),cancelAnimationFrame(s)}function Ie(q){if(process.env.NODE_ENV!=="production"&&xo(v.state.isDestroyed,ji("setProps")),!v.state.isDestroyed){U("onBeforeUpdate",[v,q]),te();var re=v.props,de=BE(t,Object.assign({},re,LE(q),{ignoreAttributes:!0}));v.props=de,se(),re.interactiveDebounce!==de.interactiveDebounce&&(V(),p=DE(he,de.interactiveDebounce)),re.triggerTarget&&!de.triggerTarget?zi(re.triggerTarget).forEach(function(We){We.removeAttribute("aria-expanded")}):de.triggerTarget&&t.removeAttribute("aria-expanded"),F(),M(),A&&A(re,de),v.popperInstance&&(_e(),Ge().forEach(function(We){requestAnimationFrame(We._tippy.popperInstance.forceUpdate)})),U("onAfterUpdate",[v,q])}}function Ve(q){v.setProps({content:q})}function vt(){process.env.NODE_ENV!=="production"&&xo(v.state.isDestroyed,ji("show"));var q=v.state.isVisible,re=v.state.isDestroyed,de=!v.state.isEnabled,We=Gr.isTouch&&!v.props.touch,Ae=dm(v.props.duration,0,Kn.duration);if(!(q||re||de||We)&&!D().hasAttribute("disabled")&&(U("onShow",[v],!1),v.props.onShow(v)!==!1)){if(v.state.isVisible=!0,R()&&(x.style.visibility="visible"),M(),$(),v.state.isMounted||(x.style.transition="none"),R()){var ot=P(),ht=ot.box,hn=ot.content;fm([ht,hn],0)}f=function(){var pt;if(!(!v.state.isVisible||c)){if(c=!0,x.offsetHeight,x.style.transition=v.props.moveTransition,R()&&v.props.animation){var ve=P(),nt=ve.box,Ce=ve.content;fm([nt,Ce],Ae),jE([nt,Ce],"visible")}L(),F(),PE(pm,v),(pt=v.popperInstance)==null||pt.forceUpdate(),U("onMount",[v]),v.props.animation&&R()&&J(Ae,function(){v.state.isShown=!0,U("onShown",[v])})}},Ke()}}function tt(){process.env.NODE_ENV!=="production"&&xo(v.state.isDestroyed,ji("hide"));var q=!v.state.isVisible,re=v.state.isDestroyed,de=!v.state.isEnabled,We=dm(v.props.duration,1,Kn.duration);if(!(q||re||de)&&(U("onHide",[v],!1),v.props.onHide(v)!==!1)){if(v.state.isVisible=!1,v.state.isShown=!1,c=!1,i=!1,R()&&(x.style.visibility="hidden"),V(),K(),M(!0),R()){var Ae=P(),ot=Ae.box,ht=Ae.content;v.props.animation&&(fm([ot,ht],We),jE([ot,ht],"hidden"))}L(),F(),v.props.animation?R()&&Y(We,v.unmount):v.unmount()}}function et(q){process.env.NODE_ENV!=="production"&&xo(v.state.isDestroyed,ji("hideWithInteractivity")),O().addEventListener("mousemove",p),PE(ku,p),p(q)}function qe(){process.env.NODE_ENV!=="production"&&xo(v.state.isDestroyed,ji("unmount")),v.state.isVisible&&v.hide(),v.state.isMounted&&(Me(),Ge().forEach(function(q){q._tippy.unmount()}),x.parentNode&&x.parentNode.removeChild(x),pm=pm.filter(function(q){return q!==v}),v.state.isMounted=!1,U("onHidden",[v]))}function jt(){process.env.NODE_ENV!=="production"&&xo(v.state.isDestroyed,ji("destroy")),!v.state.isDestroyed&&(v.clearDelayTimeouts(),v.unmount(),te(),delete t._tippy,v.state.isDestroyed=!0,U("onDestroy",[v]))}}function Hc(t,e){e===void 0&&(e={});var n=Kn.plugins.concat(e.plugins||[]);process.env.NODE_ENV!=="production"&&(Vne(t),pI(e,n)),Fne();var r=Object.assign({},e,{plugins:n}),o=Dne(t);if(process.env.NODE_ENV!=="production"){var s=rc(r.content),i=o.length>1;xo(s&&i,["tippy() was passed an Element as the `content` prop, but more than","one tippy instance was created by this invocation. This means the","content element will only be appended to the last tippy instance.",`
229
-
230
- `,"Instead, pass the .innerHTML of the element, or use a function that","returns a cloned version of the element instead.",`
231
-
232
- `,`1) content: element.innerHTML
233
- `,"2) content: () => element.cloneNode(true)"].join(" "))}var a=o.reduce(function(l,c){var u=c&&Xne(c,r);return u&&l.push(u),l},[]);return rc(t)?a[0]:a}Hc.defaultProps=Kn;Hc.setDefaultProps=Gne;Hc.currentInput=Gr;Object.assign({},XN,{effect:function(e){var n=e.state,r={popper:{position:n.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(n.elements.popper.style,r.popper),n.styles=r,n.elements.arrow&&Object.assign(n.elements.arrow.style,r.arrow)}});Hc.setDefaultProps({render:mI});function Qne({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){return{editor:t,char:r,pluginKey:new Je,command:({editor:o,range:s,props:i})=>{const c=o.getText()?.replace(LZ," ")?.trim()?.lastIndexOf(r);o.view.state.selection.$to.nodeAfter?.text?.startsWith(" ")&&(s.to+=1),o.chain().focus().insertContentAt(s,[{type:n,attrs:{...i,mentionSuggestionChar:r,matchStartPosition:c}},{type:"text",text:" "}]).run(),o.view.dom.ownerDocument.defaultView?.getSelection()?.collapseToEnd()},allow:({state:o,range:s})=>{const i=o.doc.resolve(s.from),a=o.schema.nodes[n];return!!i.parent.type.contentMatch.matchType(a)},...e}}function gI(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>Qne({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function VE(t,e){const n=gI(t),r=n.find(o=>o.char===e);return r||(n.length?n[0]:null)}const Zne=Lt.create({name:"mention",priority:101,addOptions(){return{HTMLAttributes:{},renderText({node:t,suggestion:e}){return`${e?.char??"@"}${t.attrs.label??t.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e,suggestion:n}){return["span",Qe(this.HTMLAttributes,t.HTMLAttributes),`${n?.char??"@"}${e.attrs.label??e.attrs.id}`]},suggestions:[],suggestion:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-mention-id"),renderHTML:t=>t.id?{"data-mention-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-mention-label"),renderHTML:t=>t.label?{"data-mention-label":t.label}:{}},mentionSuggestionChar:{default:"@",parseHTML:t=>t.getAttribute("data-mention-suggestion-char"),renderHTML:t=>({"data-mention-suggestion-char":t.mentionSuggestionChar})},avatar:{default:null,parseHTML:t=>t.getAttribute("data-mention-avatar"),renderHTML:t=>t.avatar?{"data-mention-avatar":t.avatar}:{}},inThisThread:{default:1,parseHTML:t=>t.getAttribute("data-mention-in-this-thread"),renderHTML:t=>t.inThisThread?{"data-mention-in-this-thread":t.inThisThread}:{}},name:{default:null,parseHTML:t=>t.getAttribute("data-mention-name"),renderHTML:t=>t.name?{"data-mention-name":t.name}:{}},selectId:{default:null,parseHTML:t=>t.getAttribute("data-mention-select-id"),renderHTML:t=>t.selectId?{"data-mention-select-id":t.selectId}:{}},type:{default:null,parseHTML:t=>t.getAttribute("data-mention-type"),renderHTML:t=>t.type?{"data-mention-type":t.type}:{}},from:{default:hl.Post,parseHTML:t=>t.getAttribute("data-mention-from"),renderHTML:t=>t.from?{"data-mention-from":t.from}:{}},isCrossExposureEnable:{default:null,parseHTML:t=>t.getAttribute("data-mention-is-cross-exposure-enable"),renderHTML:t=>t.isCrossExposureEnable?{"data-mention-is-cross-exposure-enable":t.isCrossExposureEnable}:{}},matchStartPosition:{default:-1,parseHTML:t=>t.getAttribute("data-mention-match-start-position"),renderHTML:t=>t.matchStartPosition?{"data-mention-match-start-position":t.matchStartPosition}:{}}}},parseHTML(){return[{tag:'span[data-type="mention"]'},{tag:'a[data-type="mention"]'}]},renderHTML({node:t,HTMLAttributes:e}){const n=VE(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return["span",Qe({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t,suggestion:n})];const r={...this.options},o=this.editor?.isFocused;r.HTMLAttributes=Qe({"data-type":this.name},this.options.HTMLAttributes,e);const s=this.options.renderHTML({options:r,node:t,suggestion:n,isFocused:o});return typeof s=="string"?["span",Qe({"data-type":this.name},this.options.HTMLAttributes,e),s]:s},renderText({node:t}){const e={options:this.options,node:t,suggestion:VE(this,t.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?this.options.renderLabel(e):this.options.renderText(e)},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1;const{selection:r}=e,{empty:o,anchor:s}=r;if(!o)return!1;let i=new ko,a=0;return e.doc.nodesBetween(s-1,s,(l,c)=>{if(l.type.name===this.name)return n=!0,i=l,a=c,!1}),n&&t.insertText(this.options.deleteTriggerWithBackspace?"":i.attrs.mentionSuggestionChar,a,a+i.nodeSize),n})}},addProseMirrorPlugins(){return gI(this).map(bte)}});var tl={exports:{}},WE;function ere(){if(WE)return tl.exports;WE=1;var t={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",Ấ:"A",Ắ:"A",Ẳ:"A",Ẵ:"A",Ặ:"A",Æ:"AE",Ầ:"A",Ằ:"A",Ȃ:"A",Ả:"A",Ạ:"A",Ẩ:"A",Ẫ:"A",Ậ:"A",Ç:"C",Ḉ:"C",È:"E",É:"E",Ê:"E",Ë:"E",Ế:"E",Ḗ:"E",Ề:"E",Ḕ:"E",Ḝ:"E",Ȇ:"E",Ẻ:"E",Ẽ:"E",Ẹ:"E",Ể:"E",Ễ:"E",Ệ:"E",Ì:"I",Í:"I",Î:"I",Ï:"I",Ḯ:"I",Ȋ:"I",Ỉ:"I",Ị:"I",Ð:"D",Ñ:"N",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",Ố:"O",Ṍ:"O",Ṓ:"O",Ȏ:"O",Ỏ:"O",Ọ:"O",Ổ:"O",Ỗ:"O",Ộ:"O",Ờ:"O",Ở:"O",Ỡ:"O",Ớ:"O",Ợ:"O",Ù:"U",Ú:"U",Û:"U",Ü:"U",Ủ:"U",Ụ:"U",Ử:"U",Ữ:"U",Ự:"U",Ý:"Y",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",ấ:"a",ắ:"a",ẳ:"a",ẵ:"a",ặ:"a",æ:"ae",ầ:"a",ằ:"a",ȃ:"a",ả:"a",ạ:"a",ẩ:"a",ẫ:"a",ậ:"a",ç:"c",ḉ:"c",è:"e",é:"e",ê:"e",ë:"e",ế:"e",ḗ:"e",ề:"e",ḕ:"e",ḝ:"e",ȇ:"e",ẻ:"e",ẽ:"e",ẹ:"e",ể:"e",ễ:"e",ệ:"e",ì:"i",í:"i",î:"i",ï:"i",ḯ:"i",ȋ:"i",ỉ:"i",ị:"i",ð:"d",ñ:"n",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",ố:"o",ṍ:"o",ṓ:"o",ȏ:"o",ỏ:"o",ọ:"o",ổ:"o",ỗ:"o",ộ:"o",ờ:"o",ở:"o",ỡ:"o",ớ:"o",ợ:"o",ù:"u",ú:"u",û:"u",ü:"u",ủ:"u",ụ:"u",ử:"u",ữ:"u",ự:"u",ý:"y",ÿ:"y",Ā:"A",ā:"a",Ă:"A",ă:"a",Ą:"A",ą:"a",Ć:"C",ć:"c",Ĉ:"C",ĉ:"c",Ċ:"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",Ģ:"G",ģ:"g",Ĥ:"H",ĥ:"h",Ħ:"H",ħ:"h",Ḫ:"H",ḫ:"h",Ĩ:"I",ĩ:"i",Ī:"I",ī:"i",Ĭ:"I",ĭ:"i",Į:"I",į:"i",İ:"I",ı:"i",IJ:"IJ",ij:"ij",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",Ḱ:"K",ḱ:"k",K̆:"K",k̆:"k",Ĺ:"L",ĺ:"l",Ļ:"L",ļ:"l",Ľ:"L",ľ:"l",Ŀ:"L",ŀ:"l",Ł:"l",ł:"l",Ḿ:"M",ḿ:"m",M̆:"M",m̆:"m",Ń:"N",ń:"n",Ņ:"N",ņ:"n",Ň:"N",ň:"n",ʼn:"n",N̆:"N",n̆:"n",Ō:"O",ō:"o",Ŏ:"O",ŏ:"o",Ő:"O",ő:"o",Œ:"OE",œ:"oe",P̆:"P",p̆:"p",Ŕ:"R",ŕ:"r",Ŗ:"R",ŗ:"r",Ř:"R",ř:"r",R̆:"R",r̆:"r",Ȓ:"R",ȓ:"r",Ś:"S",ś:"s",Ŝ:"S",ŝ:"s",Ş:"S",Ș:"S",ș:"s",ş:"s",Š:"S",š:"s",Ţ:"T",ţ:"t",ț:"t",Ț:"T",Ť:"T",ť:"t",Ŧ:"T",ŧ:"t",T̆:"T",t̆:"t",Ũ:"U",ũ:"u",Ū:"U",ū:"u",Ŭ:"U",ŭ:"u",Ů:"U",ů:"u",Ű:"U",ű:"u",Ų:"U",ų:"u",Ȗ:"U",ȗ:"u",V̆:"V",v̆:"v",Ŵ:"W",ŵ:"w",Ẃ:"W",ẃ:"w",X̆:"X",x̆:"x",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Y̆:"Y",y̆:"y",Ź:"Z",ź:"z",Ż:"Z",ż:"z",Ž:"Z",ž:"z",ſ:"s",ƒ:"f",Ơ:"O",ơ:"o",Ư:"U",ư:"u",Ǎ:"A",ǎ:"a",Ǐ:"I",ǐ:"i",Ǒ:"O",ǒ:"o",Ǔ:"U",ǔ:"u",Ǖ:"U",ǖ:"u",Ǘ:"U",ǘ:"u",Ǚ:"U",ǚ:"u",Ǜ:"U",ǜ:"u",Ứ:"U",ứ:"u",Ṹ:"U",ṹ:"u",Ǻ:"A",ǻ:"a",Ǽ:"AE",ǽ:"ae",Ǿ:"O",ǿ:"o",Þ:"TH",þ:"th",Ṕ:"P",ṕ:"p",Ṥ:"S",ṥ:"s",X́:"X",x́:"x",Ѓ:"Г",ѓ:"г",Ќ:"К",ќ:"к",A̋:"A",a̋:"a",E̋:"E",e̋:"e",I̋:"I",i̋:"i",Ǹ:"N",ǹ:"n",Ồ:"O",ồ:"o",Ṑ:"O",ṑ:"o",Ừ:"U",ừ:"u",Ẁ:"W",ẁ:"w",Ỳ:"Y",ỳ:"y",Ȁ:"A",ȁ:"a",Ȅ:"E",ȅ:"e",Ȉ:"I",ȉ:"i",Ȍ:"O",ȍ:"o",Ȑ:"R",ȑ:"r",Ȕ:"U",ȕ:"u",B̌:"B",b̌:"b",Č̣:"C",č̣:"c",Ê̌:"E",ê̌:"e",F̌:"F",f̌:"f",Ǧ:"G",ǧ:"g",Ȟ:"H",ȟ:"h",J̌:"J",ǰ:"j",Ǩ:"K",ǩ:"k",M̌:"M",m̌:"m",P̌:"P",p̌:"p",Q̌:"Q",q̌:"q",Ř̩:"R",ř̩:"r",Ṧ:"S",ṧ:"s",V̌:"V",v̌:"v",W̌:"W",w̌:"w",X̌:"X",x̌:"x",Y̌:"Y",y̌:"y",A̧:"A",a̧:"a",B̧:"B",b̧:"b",Ḑ:"D",ḑ:"d",Ȩ:"E",ȩ:"e",Ɛ̧:"E",ɛ̧:"e",Ḩ:"H",ḩ:"h",I̧:"I",i̧:"i",Ɨ̧:"I",ɨ̧:"i",M̧:"M",m̧:"m",O̧:"O",o̧:"o",Q̧:"Q",q̧:"q",U̧:"U",u̧:"u",X̧:"X",x̧:"x",Z̧:"Z",z̧:"z",й:"и",Й:"И",ё:"е",Ё:"Е"},e=Object.keys(t).join("|"),n=new RegExp(e,"g"),r=new RegExp(e,"");function o(a){return t[a]}var s=function(a){return a.replace(n,o)},i=function(a){return!!a.match(r)};return tl.exports=s,tl.exports.has=i,tl.exports.remove=s,tl.exports}var tre=ere();const nre=Sy(tre);const gn={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0},rre=(t,e)=>String(t.rankedValue).localeCompare(String(e.rankedValue));function fl(t,e,n={}){const{keys:r,threshold:o=gn.MATCHES,baseSort:s=rre,sorter:i=c=>c.sort((u,d)=>lre(u,d,s))}=n,a=t.reduce(l,[]);return i(a).map(({item:c})=>c);function l(c,u,d){const f=ore(u,r,e,n),{rank:h,keyThreshold:p=o}=f;return h>=p&&c.push({...f,item:u,index:d}),c}}fl.rankings=gn;function ore(t,e,n,r){if(!e){const s=t;return{rankedValue:s,rank:KE(s,n,r),keyIndex:-1,keyThreshold:r.threshold}}return dre(t,e).reduce(({rank:s,rankedValue:i,keyIndex:a,keyThreshold:l},{itemValue:c,attributes:u},d)=>{let f=KE(c,n,r),h=i;const{minRanking:p,maxRanking:m,threshold:g}=u;return f<p&&f>=gn.MATCHES?f=p:f>m&&(f=m),f>s&&(s=f,a=d,l=g,h=c),{rankedValue:h,rank:s,keyIndex:a,keyThreshold:l}},{rankedValue:t,rank:gn.NO_MATCH,keyIndex:-1,keyThreshold:r.threshold})}function*sre(t,e){let n=-1;for(;(n=t.indexOf(e,n+1))>-1;)yield n;return-1}function KE(t,e,n){if(t=GE(t,n),e=GE(e,n),e.length>t.length)return gn.NO_MATCH;if(t===e)return gn.CASE_SENSITIVE_EQUAL;t=t.toLowerCase(),e=e.toLowerCase();const r=sre(t,e),o=r.next(),s=o.value;if(t.length===e.length&&s===0)return gn.EQUAL;if(s===0)return gn.STARTS_WITH;let i=o;for(;!i.done;){if(i.value>0&&t[i.value-1]===" ")return gn.WORD_STARTS_WITH;i=r.next()}return s>0?gn.CONTAINS:e.length===1?gn.NO_MATCH:ire(t).includes(e)?gn.ACRONYM:are(t,e)}function ire(t){let e="",n=" ";for(let r=0;r<t.length;r++){const o=t.charAt(r);(n===" "||n==="-")&&!(o===" "||o==="-")&&(e+=o),n=o}return e}function are(t,e){let n=0,r=0;function o(l,c,u){for(let d=u,f=c.length;d<f;d++)if(c[d]===l)return n+=1,d+1;return-1}function s(l){const c=1/l,u=n/e.length;return gn.MATCHES+u*c}const i=o(e[0],t,0);if(i<0)return gn.NO_MATCH;r=i;for(let l=1,c=e.length;l<c;l++){const u=e[l];if(r=o(u,t,r),!(r>-1))return gn.NO_MATCH}const a=r-i;return s(a)}function lre(t,e,n){const{rank:s,keyIndex:i}=t,{rank:a,keyIndex:l}=e;return s===a?i===l?n(t,e):i<l?-1:1:s>a?-1:1}function GE(t,{keepDiacritics:e}){return t=`${t}`,e||(t=nre(t)),t}function cre(t,e){typeof e=="object"&&(e=e.key);let n;if(typeof e=="function")n=e(t);else if(t==null)n=null;else if(Object.hasOwnProperty.call(t,e))n=t[e];else{if(e.includes("."))return ure(e,t);n=null}return n==null?[]:Array.isArray(n)?n:[String(n)]}function ure(t,e){const n=t.split(".");let r=[e];for(let o=0,s=n.length;o<s;o++){const i=n[o];let a=[];for(let l=0,c=r.length;l<c;l++){const u=r[l];if(u!=null)if(Object.hasOwnProperty.call(u,i)){const d=u[i];d!=null&&a.push(d)}else i==="*"&&(a=a.concat(u))}r=a}return Array.isArray(r[0])?[].concat(...r):r}function dre(t,e){const n=[];for(let r=0,o=e.length;r<o;r++){const s=e[r],i=fre(s),a=cre(t,s);for(let l=0,c=a.length;l<c;l++)n.push({itemValue:a[l],attributes:i})}return n}const qE={maxRanking:1/0,minRanking:-1/0};function fre(t){return typeof t=="string"?qE:{...qE,...t}}const yI=j.forwardRef((t,e)=>{const[n,r]=j.useState(0),o=j.useRef([]),s=t.char==="@",i=j.useMemo(()=>t.query?s?fl(t.items,t.query,{keys:["label","email"],threshold:fl.rankings.CONTAINS}):fl(t.items,t.query,{keys:["label","selectId",d=>d.selectId?.replace(/[^a-z0-9]/gi,"")??""],threshold:fl.rankings.CONTAINS}):t.items,[t.items,t.query,s]),a=d=>{const f=i[d];f&&t.command({...f,id:f?.id,label:f?.label})},l=()=>{r(d=>(d+i.length-1)%i.length)},c=()=>{r(d=>(d+1)%i.length)},u=()=>{a(n)};return j.useEffect(()=>{r(0)},[i]),j.useEffect(()=>{const d=o.current[n];d&&d.scrollIntoView({block:"nearest",behavior:"instant"})},[n]),j.useImperativeHandle(e,()=>({onKeyDown:d=>d.key==="ArrowUp"?(l(),!0):d.key==="ArrowDown"?(c(),!0):d.key==="Enter"&&i.length>0?(u(),!0):!1})),y.jsxs("div",{className:"w-80 rounded-lg border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-lg overflow-hidden",children:[y.jsx("div",{className:"px-3 py-2 border-b border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/50",children:y.jsxs("div",{className:"flex items-center gap-2",children:[y.jsx("svg",{className:"h-4 w-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:y.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),y.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:t.query?y.jsxs(y.Fragment,{children:["Searching for: ",y.jsx("span",{className:"font-medium",children:t.query})]}):`Search ${s?"users":"hashtags"}...`})]})}),y.jsxs("div",{className:"px-3 py-1.5 text-xs font-semibold text-gray-500 dark:text-gray-400 uppercase tracking-wider bg-gray-50 dark:bg-gray-900/50",children:[s?"Users":"Hashtags"," (",i.length,")"]}),y.jsx("ul",{className:"max-h-64 overflow-y-auto",children:i.length===0?y.jsx("div",{className:"p-4 text-center text-sm text-gray-500 dark:text-gray-400",children:t.query?`No ${s?"users":"hashtags"} found for "${t.query}"`:`No ${s?"users":"hashtags"} found`}):y.jsx("div",{className:"p-1",children:i.map((d,f)=>y.jsxs("li",{ref:h=>{o.current[f]=h},onClick:()=>a(f),className:`flex items-center gap-3 px-3 py-2.5 cursor-pointer rounded-md transition-colors ${n===f?"bg-blue-50 dark:bg-blue-900/20":"hover:bg-gray-50 dark:hover:bg-gray-700/50"}`,children:[y.jsx(iM,{className:"size-9 shrink-0 bg-linear-to-br from-blue-400 to-blue-600",children:d.avatar?y.jsx(aM,{src:d.avatar,alt:d.label}):y.jsx(lM,{className:"text-white bg-transparent font-medium text-sm",children:d.label?.charAt(0).toUpperCase()})}),y.jsx("div",{className:"flex flex-col min-w-0 flex-1",children:s?y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100 truncate",children:d.label}),d.email&&y.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:d.email})]}):y.jsxs(y.Fragment,{children:[y.jsxs("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100 truncate",children:["#",d.label]}),d.selectId&&y.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:d.selectId})]})})]},d.id))})}),y.jsx("div",{className:"px-3 py-2 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900/50",children:y.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500 dark:text-gray-400",children:[y.jsxs("div",{className:"flex items-center gap-1",children:[y.jsx("kbd",{className:"px-1.5 py-0.5 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded text-xs",children:"↑↓"}),y.jsx("span",{children:"Navigate"})]}),y.jsxs("div",{className:"flex items-center gap-1",children:[y.jsx("kbd",{className:"px-1.5 py-0.5 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded text-xs",children:"↵"}),y.jsx("span",{children:"Select"})]}),y.jsxs("div",{className:"flex items-center gap-1",children:[y.jsx("kbd",{className:"px-1.5 py-0.5 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded text-xs",children:"Esc"}),y.jsx("span",{children:"Close"})]})]})})]})});yI.displayName="MentionList";const hre=()=>typeof window<"u"&&window.ReactNativeWebView!==void 0,pre=(t,e,n,r)=>({fetchMentions:async()=>{const i=n.getState().getMentionParams();if(!i)return[];const{groupId:a,postId:l}=i,u=(l?await e.getRecommendationPost(a,l,0,999):await e.getRecommendationGroup(a,0,999)).entries?.filter(d=>!!d?.user_details)?.map(d=>({id:d?.user_details?.id,label:d?.user_details?.name,avatar:d?.user_details?.avatar,inThisThread:1,name:d?.user_details?.name,selectId:d.user_details?.username,type:Iu.User,from:hl.Post}))??[];if(r){const d={id:r.id,label:r.name,avatar:r.avatar,inThisThread:1,name:r.name,selectId:r.username,type:Iu.User,from:hl.Post},f=u.filter(h=>h.id!==r.id);return[d,...f]}return u},fetchHashtags:async()=>{const{selectedGroupId:i,groupId:a}=n.getState();return i??a?(await t.fetchConversationList(999,0)).map(u=>({id:u?.conversation_id,label:u?.conversation_detail?.name,avatar:u?.conversation_detail?.avatar,inThisThread:1,name:u?.conversation_detail?.name,selectId:u?.conversation_detail?.select_id,type:Iu.Group,from:hl.Post,isCrossExposureEnable:u?.conversation_detail?.allow_cross_exposure})):[]}});function YE(t,e){return{char:t,items:async()=>await e(),render:()=>{let n,r;return{onStart:o=>{n=new Ub(yI,{props:{...o,char:t},editor:o.editor}),o.clientRect&&(r=Hc("body",{getReferenceClientRect:o.clientRect,appendTo:()=>document.body,theme:"select-post-builder",content:n.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"}))},onUpdate(o){n.updateProps({...o,char:t}),!(!o.clientRect||!r?.[0])&&r[0].setProps({getReferenceClientRect:o.clientRect})},onKeyDown(o){return o.event.key==="Escape"?(r?.[0]?.hide(),!0):n?.ref?.onKeyDown(o.event)??!1},onExit(){r?.[0]?.destroy(),n?.destroy()}}}}}const mre=(t,e,n,r)=>{const o=pre(t,e,n,r);return Zne.configure({HTMLAttributes:{class:"inline-block px-1.5 py-0.5 rounded font-medium no-underline cursor-pointer transition-all duration-200"},renderText({node:s,suggestion:i}){return`${i?.char??"@"}${s.attrs.label??s.attrs.id}`},renderHTML({node:s,suggestion:i,isFocused:a}){const l=i?.char??"@",c=s?.attrs?.avatar,u=s?.attrs?.type,d=s?.attrs?.from,f=s?.attrs?.inThisThread,h=s?.attrs?.isCrossExposureEnable,p=s?.attrs?.matchStartPosition,m=s?.attrs?.selectId,g=s.attrs.label??s.attrs.id,b=s.attrs.id,S=s?.attrs?.name,k=hre(),_={"data-type":"mention","data-id":b,"data-label":g,"data-mention-suggestion-char":l,"data-mention-id":b,"data-mention-label":g,"data-mention-avatar":c,"data-mention-in-this-thread":f,"data-mention-name":S,"data-mention-select-id":m,"data-mention-type":u,"data-mention-from":d,"data-mention-is-cross-exposure-enable":h,"data-mention-match-start-position":p,class:"inline-block rounded italic font-medium cursor-pointer transition-all duration-200 text-blue-700 dark:text-blue-300"};if(k){const A=l==="@"?`window.ReactNativeWebView.postMessage(JSON.stringify({type: 'mention', userId: '${b}'}))`:`window.ReactNativeWebView.postMessage(JSON.stringify({type: 'hashtag', groupId: '${b}'}))`;return["span",{..._,onclick:A},`${l}${g}`]}const x=l==="@"?`/users/${b}`:`/groups/${b}`;return["a",{..._,...a?{}:{href:x,target:"_blank"},"data-mention-link":"true"},`${l}${g}`]},suggestions:[YE("@",o.fetchMentions),YE("#",o.fetchHashtags)]})},bI=at.create({name:"customEnterHardBreak",addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.setHardBreak()}}}),gre=({node:t,editor:e})=>{const[n,r]=j.useState(null),{trackMediaRemoved:o}=Cs(),s=a=>{const l=a?.attrs?.uid,c=e?.view?.dom?.getAttribute("data-editor-type")||Pe.Media;e.commands.deleteMediaByUid(l),o({mediaType:Du[a?.attrs?.type],editorType:c})},i=t?.content?.content||[];return y.jsxs(fi,{className:"not-prose media-group-wrapper select-none leading-none mt-12",contentEditable:!1,children:[y.jsxs("div",{className:"flex flex-wrap gap-2 leading-none mt-auto",children:[i.map((a,l)=>{const c=a?.attrs?.uploading,u=a?.attrs?.progress||0;return y.jsxs("div",{className:"relative group leading-none",children:[y.jsx(zt,{size:"icon",onClick:()=>s(a),className:"absolute size-6 top-1 right-1 z-10 p-1.5 bg-red-50 hover:bg-red-100 text-destructive rounded-full shadow-lg transition-all opacity-100 group-hover:scale-110",title:"Delete media",children:y.jsx(co,{className:"w-3.5 h-3.5"})}),c?y.jsxs("div",{className:"size-20 bg-muted rounded-lg border border-border flex items-center justify-center relative overflow-hidden",children:[y.jsxs("div",{className:"text-center space-y-2",children:[a.attrs.type===ue.Image&&y.jsx(Ob,{className:"w-8 h-8 text-muted-foreground/50 mx-auto"}),a.attrs.type===ue.Video&&y.jsx(Rb,{className:"w-8 h-8 text-muted-foreground/50 mx-auto"}),a.attrs.type===ue.Audio&&y.jsx(_d,{className:"w-8 h-8 text-muted-foreground/50 mx-auto"}),y.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(u),"%"]})]}),y.jsx("div",{className:"absolute bottom-0 left-0 right-0 p-2",children:y.jsx(iN,{value:u,className:"h-1"})})]}):y.jsxs(y.Fragment,{children:[a.attrs.type===ue.Image&&y.jsx("img",{src:a.attrs.src,alt:a.attrs.caption||"",className:"size-20 object-cover rounded-lg border border-border cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>r({src:a.attrs.src,type:ue.Image})}),a.attrs.type===ue.Video&&y.jsx("video",{src:a.attrs.src,className:"size-20 object-cover rounded-lg border border-border cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>r({src:a.attrs.src,type:ue.Video})}),a.attrs.type===ue.Audio&&y.jsx("div",{className:"size-20 flex items-center justify-center bg-accent rounded-lg border border-border",children:y.jsx(_d,{className:"w-8 h-8 text-muted-foreground"})})]}),a.attrs.caption&&!c&&y.jsx("p",{className:"text-xs text-muted-foreground text-center mt-1 truncate w-32",children:a.attrs.caption})]},a?.attrs?.uid||l)}),y.jsx("div",{className:"hidden",children:y.jsx(B7,{})})]}),n&&y.jsx(aN,{open:!!n,onOpenChange:a=>!a&&r(null),src:n.src,type:n.type})]})},yre=new Je("mediaMode"),bre=()=>{let t=!1;return new Ye({key:yre,appendTransaction(e,n,r){if(t||!e.some(s=>s.docChanged)||e.some(s=>s.getMeta("mediaMode-plugin"))||e.some(s=>s.getMeta("addToHistory")===!1))return null;try{t=!0;const s=r.tr;let i=!1;const a=[];if(r.doc.forEach((p,m)=>{p.type.name==="media"&&a.push({node:p,pos:m,size:p.nodeSize})}),a.length===0){let p=!1,m=null;if(r.doc.forEach((g,b)=>{g.type.name==="mediaGroup"&&(p=!0,g.content.size===0&&(s.delete(b,b+g.nodeSize),i=!0)),g.type.name==="paragraph"&&g.descendants(S=>{S.marks&&S.marks.forEach(k=>{k.type.name==="customLink"&&k.attrs.previewPayload&&(m=k.attrs.previewPayload)})})}),i&&p&&m){let g=!1;if(s.doc.forEach(b=>{b.type.name==="linkPreview"&&(g=!0)}),!g&&r.schema.nodes.linkPreview){const b=m,S=r.schema.nodes.linkPreview.create({uid:Dt(),href:b.linkUrl??"",title:b.linkTitle??"",description:b.linkDesc??"",image:b.linkImage?.url??"",variant:Ec.Extended});s.insert(s.doc.content.size,S),i=!0}}return i&&(s.setMeta("addToHistory",!1),s.setMeta("mediaMode-plugin",!0)),i?s:null}let l=null,c=null;r.doc.forEach((p,m)=>{p.type.name==="linkPreview"&&(l=m,c=p.nodeSize)}),l!==null&&c!==null&&(s.delete(l,Number(l)+Number(c)),i=!0);const u=i?s.doc:r.doc,d=[];u.forEach((p,m)=>{p.type.name==="media"&&d.push({node:p,pos:m,size:p.nodeSize})});let f=null,h=null;if(u.forEach((p,m)=>{p.type.name==="mediaGroup"&&(f=m,h=p)}),f!==null&&h){const p=h.content.size;[...d].sort((_,x)=>x.pos-_.pos).forEach(({pos:_,size:x})=>{s.delete(_,_+x)});const b=d.filter(_=>_.pos<f).reduce((_,x)=>_+x.size,0),k=f-b+1+p;let v=0;d.forEach(({node:_})=>{s.insert(k+v,_),v+=_.nodeSize}),i=!0}else{if(!r.schema.nodes.mediaGroup)return null;const p=d.map(b=>b.node);if(p.some(b=>!b||b.type.name!=="media"))return null;const m=r.schema.nodes.mediaGroup.create({},p);[...d].sort((b,S)=>S.pos-b.pos).forEach(({pos:b,size:S})=>{s.delete(b,b+S)}),s.insert(s.doc.content.size,m),i=!0}if(i){const p=s.doc.content.size;if(p>=0&&p<=s.doc.content.size)try{const m=s.doc.resolve(p);s.setSelection(we.near(m))}catch{}s.setMeta("addToHistory",!1),s.setMeta("mediaMode-plugin",!0)}return i?s:null}catch{return null}finally{t=!1}}})},vre=Lt.create({name:"mediaGroup",group:"block",content:"media*",atom:!1,selectable:!1,draggable:!1,addOptions(){return{mediaMode:!1}},parseHTML(){return[{tag:"div[data-media-group]"}]},renderHTML({HTMLAttributes:t}){return["div",Qe(t,{"data-media-group":""}),0]},addNodeView(){return Nc(gre)},addProseMirrorPlugins(){return this.options.mediaMode?[bre()]:[]}}),vI=at.create({name:"stripHyperlinkText",addProseMirrorPlugins(){return[new Ye({key:new Je("stripHyperlinkText"),props:{transformPastedHTML(t){const e=new DOMParser().parseFromString(t,"text/html");return e.querySelectorAll("a[href]").forEach(n=>{const r=n.href||n.getAttribute("href")||"",o=n.textContent?.trim()??"";if(r&&o&&o!==r){const s=n.parentNode;s&&(s.insertBefore(e.createTextNode(`${o} (`),n),n.textContent=r,n.after(e.createTextNode(")")))}}),e.body.innerHTML}}})]}}),wre=NR.extend({addAttributes(){return{...this.parent?.(),uid:{default:null,parseHTML:()=>null,renderHTML:()=>({})},text:{default:null,parseHTML:()=>null,renderHTML:()=>({})},previewPayload:{default:null,parseHTML:()=>null,renderHTML:()=>({})}}}}),xre={class:"bg-muted text-foreground border border-border font-mono leading-snug rounded px-0.5 py-px after:content-none before:content-none"},Ere={class:"bg-muted text-foreground border border-border font-mono leading-snug rounded"},Cv=t=>tX.extend({content:t}),Sre=Cv("paragraph+ poll"),kre=Cv("paragraph+ media? linkPreview? mediaGroup?");Cv("paragraph linkPreview?");const Tre=({includeLink:t=!1,includeDocument:e=!0})=>({...e?{}:{document:!1},...t?{}:{link:!1},code:{HTMLAttributes:xre},codeBlock:{HTMLAttributes:Ere}}),Av=t=>yQ.configure({placeholder:t,showOnlyWhenEditable:!0}),_v=(t,e,n,r)=>mre(t,e,n,r),Cre=({editorType:t,api:e,store:n,user:r,t:o,placeholder:s,unauthenticatedMode:i})=>{const l={[Pe.Blog]:Are,[Pe.Media]:Mre,[Pe.Poll]:_re}[t];return l?l({api:e,store:n,user:r,t:o,placeholder:s,unauthenticatedMode:i}):[]},Are=({api:t,store:e,user:n,placeholder:r,unauthenticatedMode:o})=>{const{core:s,mfs:i,fileStore:a}=t;return[xQ.configure(Tre({includeLink:!1})),Av(r??`What's on your mind, ${n?.name?n?.name:""}`),TQ,AQ,SQ.configure({types:["heading","paragraph","media"],alignments:[_t.LEFT,_t.CENTER,_t.RIGHT],defaultAlignment:_t.LEFT}),dN,gN,ate.configure({api:s}),$N.configure({openOnClick:!1,linkOnPaste:!1,api:s,unauthenticatedMode:o}),jN,_v(s,i,e,n),qN.configure({api:a,unauthenticatedMode:o}),KN.configure({api:s,unauthenticatedMode:o})]},_re=({api:t,store:e,user:n,t:r})=>{const{core:o,mfs:s}=t;return[Sre,VR,KR,wre.configure({HTMLAttributes:{class:"underline"}}),xR,Av(r("pollQuestionPlaceholderKey")),bI,gN,_v(o,s,e,n),vI]},Mre=({api:t,store:e,user:n,placeholder:r,unauthenticatedMode:o})=>{const{core:s,mfs:i,fileStore:a}=t;return[kre,VR,KR,xR,Av(r??`What's on your mind, ${n?.name?n?.name:""}`),bI,dN.configure({attrs:{mediaMode:!0}}),vre.configure({mediaMode:!0}),$N.configure({openOnClick:!1,linkOnPaste:!1,api:s,linkMode:!0,unauthenticatedMode:o}),jN.configure({variant:Ec.Extended,draggable:!1}),_v(s,i,e,n),qN.configure({api:a,unauthenticatedMode:o}),KN.configure({api:s,autoEmbed:!1,autoLinkSelection:!1,unauthenticatedMode:o}),vI]},Ore=()=>({attributes:{class:oe(`max-w-full min-h-44 prose prose-sm sm:prose-base px-4 py-2 prose-img:my-3
234
-
235
- prose-blockquote:p-4 prose-blockquote:my-4 prose-blockquote:border-s-4
236
- prose-blockquote:border-gray-300 prose-blockquote:bg-gray-50
237
- prose-blockquote:dark:border-gray-500 prose-blockquote:dark:bg-gray-800
238
-
239
- prose-blockquote:[&>p]:text-xl prose-blockquote:[&>p]:italic prose-blockquote:[&>p]:font-medium prose-blockquote:[&>p]:leading-relaxed prose-blockquote:[&>p]:text-gray-900 prose-blockquote:[&>p]:dark:text-white
240
-
241
-
242
- prose-figcaption:text-xs prose-code:text-sm
243
- prose-codeblock:text-sm prose-a:text-blue-500 focus:outline-none`)}}),Rre=t=>({undo:()=>t?.chain().focus().undo().run(),redo:()=>t?.chain().focus().redo().run(),toggleHeading:e=>t?.chain().focus().toggleHeading({level:e}).run(),setParagraph:()=>t?.chain().focus().setParagraph().run(),toggleBold:()=>t?.chain().focus().toggleBold().run(),toggleItalic:()=>t?.chain().focus().toggleItalic().run(),toggleStrikethrough:()=>t?.chain().focus().toggleStrike().run(),toggleUnderline:()=>t?.chain().focus().toggleUnderline().run(),insertLink:e=>t?.chain().focus().setLink({href:e}).run(),toggleBulletList:()=>t?.chain().focus().toggleBulletList().run(),toggleOrderedList:()=>t?.chain().focus().toggleOrderedList().run(),toggleBlockquote:()=>t?.chain().focus().toggleBlockquote().run(),toggleCode:()=>t?.chain().focus().toggleCode().run(),toggleCodeBlock:()=>t?.chain().focus().toggleCodeBlock().run(),toggleTextAlign:e=>t?.chain().focus().setTextAlign(e).run(),insertPoll:()=>t?.chain().focus().insertContent({type:"poll"}).run(),insertMedia:(e,n)=>{t?.chain()?.focus()?.insertContent([{type:"media",attrs:{src:e,type:n}},{type:"paragraph"}])?.run()}}),Nre=t=>{t.chain().focus().insertContent({type:"paragraph"}).insertContent({type:"poll"}).command(({tr:e})=>{const{doc:n}=e;let r=-1;if(n.descendants((o,s)=>{if(o.type.name==="paragraph"&&r===-1)return r=s,!1}),r>=0){const o=n.nodeAt(r);if(o){const s=r+o.nodeSize-1,i=e.doc.resolve(s);e.setSelection(we.near(i))}}return!0}).run()},Mv=t=>({html:t?.getHTML(),json:t?.getJSON(),text:t?.getText()}),Ov=t=>({postId:Dt(),timestamp:new Date().getTime(),specialType:ik.POST,...t&&{conversationId:t}}),Rv=t=>({mentionData:Gn(t,"mention")?.map(r=>_6(R6(r.attrs,b6),["mentionSuggestionChar","label"]))?.filter(r=>Object.keys(r).length>0)}),Ire=(t,e,n)=>{const r=Gn(t,"media"),o=[];for(const s of r){if(s.attrs?.payload){o.push(s.attrs.payload);continue}if(!n?.allowPending||!e)continue;const i=s.attrs?.uid;if(!i)continue;const a=e.storage?.smartMediaUpload?.blobUrls?.get(i);if(!a)continue;const l=s.attrs?.width??0,c=s.attrs?.height??0,u=s.attrs?.type,d=u==="video"?"video/mp4":u==="audio"?"audio/mpeg":"image/jpeg";o.push({key:i,type:Vn.MEDIA_ITEM,imageType:d,playableDuration:0,sources:{original:{url:a,width:l,height:c,isBase64:!1},thumbnail:{url:a,width:l,height:c,isBase64:!1},placeholder:{url:a,width:l,height:c,isBase64:!1}}})}return{items:o}},wI=t=>!!t.marks?.some(e=>e.type==="customLink"),Dre=t=>(th(t,e=>wI(e))??[]).some(e=>e.marks?.some(n=>n.type==="customLink"&&n.attrs?.unfurlDisabled===!0)),Pre=t=>{const n=th(t,o=>wI(o))?.flatMap(o=>o?.marks?.filter(s=>s?.type==="customLink"&&s?.attrs?.previewPayload));return{items:Array.of(n?.at(-1)?.attrs?.previewPayload).filter(Boolean)}},Lre=t=>({items:Gn(t,"poll")[0].attrs?.choices}),jre=t=>{if(!t)return!1;const e=t,n=t,r=e?.linkUrl,o=n?.sources,s=o?.original?.url||o?.thumbnail?.url;return!!(r||s)},$re=({editor:t,sendCrossMention:e,groupId:n,allowSendWhileUploading:r})=>{const{html:o,json:s}=Mv(t),i=Ov(n),{mentionData:a}=Rv(s),l=kp(s,"media"),c=kp(s,"iframe"),u=kp(s,"text"),f=u?.marks?.some(k=>k.type==="customLink")?u?.marks?.find(k=>k.type==="customLink")?.attrs?.previewPayload:null,h=th(s,k=>k?.type==="text"&&(k?.marks?.some(v=>v?.type!=="customLink")??!0))?.at(0),m=_3(s,"iframe")?c?.attrs?.previewPayload?.linkTitle??c?.attrs?.src??"":h?.text??u?.text??"";let g;if(l?.attrs?.payload)g=l.attrs.payload;else if(l&&r&&l.attrs?.uid){const k=l.attrs.uid,v=t.storage?.smartMediaUpload?.blobUrls?.get(k);if(v){const _=l.attrs?.width??0,x=l.attrs?.height??0,A=l.attrs?.type,E=A==="video"?"video/mp4":A==="audio"?"audio/mpeg":"image/jpeg";g={key:k,type:Vn.MEDIA_ITEM,imageType:E,playableDuration:0,sources:{original:{url:v,width:_,height:x,isBase64:!1},thumbnail:{url:v,width:_,height:x,isBase64:!1},placeholder:{url:v,width:_,height:x,isBase64:!1}}}}}const b=[g,c?.attrs?.previewPayload,f].filter(jre)?.filter((k,v)=>v===0),S=o;return{...i,type:b?.length>0?cs.NEW_POST_MEDIA:cs.NEW_POST_MESSAGE,body:m,items:b,htmlBody:S,sendCrossMention:e,mentionData:a}},Fre=({editor:t,sendCrossMention:e,groupId:n,allowSendWhileUploading:r})=>{const{json:o,text:s}=Mv(t),i=Ov(n),a=s?.trim()??"",{mentionData:l}=Rv(o),{items:c}=Ire(o,t,{allowPending:!!r}),{items:u}=Pre(o),d=c?.length>0?c:u?.length>0?u:[];return!a&&c.length===0?{error:"Your post is empty. Add text or media to share your thoughts."}:{...i,type:c?.length>0?cs.NEW_POST_MEDIA:u?.length>0?cs.NEW_POST_LINK:cs.NEW_POST_MESSAGE,body:a,items:d,mentionData:l,sendCrossMention:e,disableUnfurl:Dre(o)||void 0}},Ure=({editor:t,sendCrossMention:e,groupId:n})=>{const{json:r,text:o}=Mv(t),s=Ov(n),i=o,{mentionData:a}=Rv(r),{items:l}=Lre(r),c=mN(l);return{...s,type:cs.NEW_POST_POLL,body:i,items:c,mentionData:a,sendCrossMention:e}},xI=(t,e)=>{switch(t){case Pe.Blog:return $re(e);case Pe.Media:return Fre(e);case Pe.Poll:return Ure(e);default:return null}},Bre=({editorType:t,placement:e,groupId:n,postId:r,user:o,disableNavigationWarning:s,initialContent:i,resumeDeferredMedia:a,placeholder:l})=>{const[,c]=j.useState(0),[u,d]=j.useState(!1),f=wi(),{allowSendWhileUploading:h,unauthenticatedMode:p,t:m}=kn(),g=j.useMemo(()=>BJ({groupId:n,postId:r}),[n,r]),{getTabContent:b,saveCurrentTabContent:S,clearContent:k}=bR(e,n),v=j.useRef({store:g,groupId:n,allowSendWhileUploading:h,saveCurrentTabContent:S,clearContent:k});v.current={store:g,groupId:n,allowSendWhileUploading:h,saveCurrentTabContent:S,clearContent:k};const _=j.useCallback(()=>{const{editor:B,editorTab:$}=v.current.store.getState();return!B||B.isDestroyed||$===null?null:{editor:B,tab:$}},[]),x=j.useRef(!1),A=j.useRef(!1),E=j.useRef(!1),T=j.useRef(i?t:null),N=!!i&&T.current===t;j.useEffect(()=>{d(!0),c(B=>B+1)},[]);const I=j.useMemo(()=>!!b(t),[t,b]),R=U7({extensions:Cre({editorType:t,api:f,store:g,user:o,t:m,placeholder:l,unauthenticatedMode:p}),content:N?i:b(t)??"",editorProps:Ore(),onCreate:({editor:B})=>{g.getState().setEditor(B,t),t===Pe.Blog&&B?.chain()?.focus("end")?.run(),t===Pe.Media&&B?.chain()?.focus("end")?.run(),t===Pe.Poll&&!I&&Nre(B),t===Pe.Poll&&I&&B?.chain()?.focus("end")?.run()},onUnmount:({editor:B})=>{if(A.current||x.current||E.current){x.current=!1,A.current=!1,E.current=!1;return}S(t,B)},immediatelyRender:!1,shouldRerenderOnTransaction:!1},[t,e,u]);j.useEffect(()=>{R&&!R.isDestroyed&&g.getState().setEditor(R,t)},[g,R,t]),j.useEffect(()=>{if(s)return;const B=$=>{R&&!R.isEmpty&&$.preventDefault()};return window.addEventListener("beforeunload",B),()=>window.removeEventListener("beforeunload",B)},[R,s]),j.useEffect(()=>{let B;if(!u||!R||!R?.view||t===Pe.Poll||N)return;const $=b(t);return $&&R?.isEditable&&(B=setTimeout(()=>{R.commands.setContent($),R.commands.rehydrateLinkPreviews()},0)),()=>{B&&clearTimeout(B)}},[R,t,e,b,u,i,N]),j.useEffect(()=>{const B=$=>{const K=$.detail;if(!K||K.groupId!==n||K.editorType&&K.editorType!==t||!R||R.isDestroyed)return;const Y=b(t);Y&&(R.commands.setContent(Y),R.commands.rehydrateLinkPreviews())};return window.addEventListener(yn.DRAFT_REHYDRATE_REQUEST,B),()=>{window.removeEventListener(yn.DRAFT_REHYDRATE_REQUEST,B)}},[R,t,n,b]);const D=j.useMemo(()=>R?Rre(R):null,[R]),O=j.useCallback(()=>{R&&!R.isDestroyed&&(S(t,R),x.current=!0)},[R,t,S]),P=j.useCallback(()=>{const B=_();B&&v.current.saveCurrentTabContent(B.tab,B.editor)},[_]),C=j.useCallback(()=>{A.current=!0,v.current.clearContent()},[]),M=j.useCallback(()=>{E.current=!0},[]),U=j.useCallback(()=>{_()?.editor.commands.focus("end")},[_]),L=j.useCallback(B=>{_()?.editor.commands.setContent(B)},[_]),F=j.useCallback(()=>{const B=_();if(!B)return null;const{groupId:$,allowSendWhileUploading:K}=v.current,Y=B.editor.getHTML(),J=B.editor.getJSON(),Q=B.editor.getText(),ne=xI(B.tab,{editor:B.editor,sendCrossMention:!1,groupId:$,allowSendWhileUploading:K});return{html:Y,json:J,text:Q,payload:ne??{}}},[_]),V=j.useCallback(()=>{const B=_();B&&(v.current.clearContent(),B.editor.chain().focus().clearContent().run())},[_]),W=j.useCallback(B=>{_()?.editor.commands.resumeDeferredUploads(B)},[_]),H=j.useRef(new WeakSet);return j.useEffect(()=>{!R||R.isDestroyed||!a||H.current.has(R)||(H.current.add(R),R.commands.resumeDeferredUploads(a))},[R,a]),{editor:R,actions:D,store:g,isMounted:u,saveBeforeSwitch:O,saveDraft:P,discardDraft:C,skipNextUnmountSave:M,keepEditing:U,setContent:L,getContent:F,clearEditor:V,resumeDeferredUploads:W}},eo=()=>new Map,Zg=t=>{const e=eo();return t.forEach((n,r)=>{e.set(r,n)}),e},Bo=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r};const zre=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},mi=()=>new Set,mm=t=>t[t.length-1],Hre=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},gi=Array.from,Nv=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},Iv=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},Vre=(t,e)=>{const n=new Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n},wa=Array.isArray;class EI{constructor(){this._observers=eo()}on(e,n){return Bo(this._observers,e,mi).add(n),n}once(e,n){const r=(...o)=>{this.off(e,r),n(...o)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return gi((this._observers.get(e)||eo()).values()).forEach(r=>r(...n))}destroy(){this._observers=eo()}}const Rr=Math.floor,Yu=Math.abs,xa=(t,e)=>t<e?t:e,ws=(t,e)=>t>e?t:e,SI=t=>t!==0?t<0:1/t<0,JE=1,XE=2,gm=4,ym=8,sc=32,Ao=64,vn=128,Wre=1<<29,Ph=31,ey=63,ti=127,Kre=2147483647,yf=Number.MAX_SAFE_INTEGER,QE=Number.MIN_SAFE_INTEGER,Gre=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&Rr(t)===t),kI=String.fromCharCode,qre=t=>t.toLowerCase(),Yre=/^\s*/g,Jre=t=>t.replace(Yre,""),Xre=/([A-Z])/g,ZE=(t,e)=>Jre(t.replace(Xre,n=>`${e}${qre(n)}`)),Qre=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let o=0;o<n;o++)r[o]=e.codePointAt(o);return r},ic=typeof TextEncoder<"u"?new TextEncoder:null,Zre=t=>ic.encode(t),eoe=ic?Zre:Qre;let Dl=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Dl&&Dl.decode(new Uint8Array).length===1&&(Dl=null);const toe=(t,e)=>Vre(e,()=>t).join("");class Vc{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Wc=()=>new Vc,noe=t=>{const e=Wc();return t(e),Cr(e)},roe=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},Cr=t=>{const e=new Uint8Array(roe(t));let n=0;for(let r=0;r<t.bufs.length;r++){const o=t.bufs[r];e.set(o,n),n+=o.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},ooe=(t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(ws(n,e)*2),t.cpos=0)},Ut=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},ty=Ut,Xe=(t,e)=>{for(;e>ti;)Ut(t,vn|ti&e),e=Rr(e/128);Ut(t,ti&e)},Dv=(t,e)=>{const n=SI(e);for(n&&(e=-e),Ut(t,(e>ey?vn:0)|(n?Ao:0)|ey&e),e=Rr(e/64);e>0;)Ut(t,(e>ti?vn:0)|ti&e),e=Rr(e/128)},ny=new Uint8Array(3e4),soe=ny.length/3,ioe=(t,e)=>{if(e.length<soe){const n=ic.encodeInto(e,ny).written||0;Xe(t,n);for(let r=0;r<n;r++)Ut(t,ny[r])}else zn(t,eoe(e))},aoe=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;Xe(t,r);for(let o=0;o<r;o++)Ut(t,n.codePointAt(o))},Xi=ic&&ic.encodeInto?ioe:aoe,Lh=(t,e)=>{const n=t.cbuf.length,r=t.cpos,o=xa(n-r,e.length),s=e.length-o;t.cbuf.set(e.subarray(0,o),r),t.cpos+=o,s>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(ws(n*2,s)),t.cbuf.set(e.subarray(o)),t.cpos=s)},zn=(t,e)=>{Xe(t,e.byteLength),Lh(t,e)},Pv=(t,e)=>{ooe(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},loe=(t,e)=>Pv(t,4).setFloat32(0,e,!1),coe=(t,e)=>Pv(t,8).setFloat64(0,e,!1),uoe=(t,e)=>Pv(t,8).setBigInt64(0,e,!1),eS=new DataView(new ArrayBuffer(4)),doe=t=>(eS.setFloat32(0,t),eS.getFloat32(0)===t),Ea=(t,e)=>{switch(typeof e){case"string":Ut(t,119),Xi(t,e);break;case"number":Gre(e)&&Yu(e)<=Kre?(Ut(t,125),Dv(t,e)):doe(e)?(Ut(t,124),loe(t,e)):(Ut(t,123),coe(t,e));break;case"bigint":Ut(t,122),uoe(t,e);break;case"object":if(e===null)Ut(t,126);else if(wa(e)){Ut(t,117),Xe(t,e.length);for(let n=0;n<e.length;n++)Ea(t,e[n])}else if(e instanceof Uint8Array)Ut(t,116),zn(t,e);else{Ut(t,118);const n=Object.keys(e);Xe(t,n.length);for(let r=0;r<n.length;r++){const o=n[r];Xi(t,o),Ea(t,e[o])}}break;case"boolean":Ut(t,e?120:121);break;default:Ut(t,127)}};class tS extends Vc{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Xe(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const nS=t=>{t.count>0&&(Dv(t.encoder,t.count===1?t.s:-t.s),t.count>1&&Xe(t.encoder,t.count-2))};class Ju{constructor(){this.encoder=new Vc,this.s=0,this.count=0}write(e){this.s===e?this.count++:(nS(this),this.count=1,this.s=e)}toUint8Array(){return nS(this),Cr(this.encoder)}}const rS=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);Dv(t.encoder,e),t.count>1&&Xe(t.encoder,t.count-2)}};class bm{constructor(){this.encoder=new Vc,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(rS(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return rS(this),Cr(this.encoder)}}class foe{constructor(){this.sarr=[],this.s="",this.lensE=new Ju}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Vc;return this.sarr.push(this.s),this.s="",Xi(e,this.sarr.join("")),Lh(e,this.lensE.toUint8Array()),Cr(e)}}const io=t=>new Error(t),ur=()=>{throw io("Method unimplemented")},dn=()=>{throw io("Unexpected case")},TI=io("Unexpected end of array"),CI=io("Integer out of Range");class jh{constructor(e){this.arr=e,this.pos=0}}const Lv=t=>new jh(t),hoe=t=>t.pos!==t.arr.length,poe=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},tr=t=>poe(t,bt(t)),ac=t=>t.arr[t.pos++],bt=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const o=t.arr[t.pos++];if(e=e+(o&ti)*n,n*=128,o<vn)return e;if(e>yf)throw CI}throw TI},jv=t=>{let e=t.arr[t.pos++],n=e&ey,r=64;const o=(e&Ao)>0?-1:1;if((e&vn)===0)return o*n;const s=t.arr.length;for(;t.pos<s;){if(e=t.arr[t.pos++],n=n+(e&ti)*r,r*=128,e<vn)return o*n;if(n>yf)throw CI}throw TI},moe=t=>{let e=bt(t);if(e===0)return"";{let n=String.fromCodePoint(ac(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(ac(t));else for(;e>0;){const r=e<1e4?e:1e4,o=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,o),e-=r}return decodeURIComponent(escape(n))}},goe=t=>Dl.decode(tr(t)),ry=Dl?goe:moe,$v=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},yoe=t=>$v(t,4).getFloat32(0,!1),boe=t=>$v(t,8).getFloat64(0,!1),voe=t=>$v(t,8).getBigInt64(0,!1),woe=[t=>{},t=>null,jv,yoe,boe,voe,t=>!1,t=>!0,ry,t=>{const e=bt(t),n={};for(let r=0;r<e;r++){const o=ry(t);n[o]=bf(t)}return n},t=>{const e=bt(t),n=[];for(let r=0;r<e;r++)n.push(bf(t));return n},tr],bf=t=>woe[127-ac(t)](t);class oS extends jh{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),hoe(this)?this.count=bt(this)+1:this.count=-1),this.count--,this.s}}class Xu extends jh{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=jv(this);const e=SI(this.s);this.count=1,e&&(this.s=-this.s,this.count=bt(this)+2)}return this.count--,this.s}}class vm extends jh{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=jv(this),n=e&1;this.diff=Rr(e/2),this.count=1,n&&(this.count=bt(this)+2)}return this.s+=this.diff,this.count--,this.s}}class xoe{constructor(e){this.decoder=new Xu(e),this.str=ry(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const Eoe=crypto.getRandomValues.bind(crypto),Soe=Math.random,AI=()=>Eoe(new Uint32Array(1))[0],koe=t=>t[Rr(Soe()*t.length)],Toe="10000000-1000-4000-8000"+-1e11,Coe=()=>Toe.replace(/[018]/g,t=>(t^AI()&15>>t/4).toString(16)),Aoe=Date.now,sS=t=>new Promise(t);Promise.all.bind(Promise);const iS=t=>t===void 0?null:t;class _oe{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let _I=new _oe,Moe=!0;try{typeof localStorage<"u"&&localStorage&&(_I=localStorage,Moe=!1)}catch{}const Ooe=_I,lc=Symbol("Equality"),MI=(t,e)=>t===e||!!t?.[lc]?.(e)||!1,Roe=t=>typeof t=="object",Noe=Object.assign,OI=Object.keys,Ioe=(t,e)=>{for(const n in t)e(t[n],n)},vf=t=>OI(t).length,Doe=t=>{for(const e in t)return!1;return!0},La=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},Fv=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),Poe=(t,e)=>t===e||vf(t)===vf(e)&&La(t,(n,r)=>(n!==void 0||Fv(e,r))&&MI(e[r],n)),Loe=Object.freeze,RI=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&RI(t[e])}return Loe(t)},Uv=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&Uv(t,e,n+1)}},Qu=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[lc]!=null)return t[lc](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!Qu(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(vf(t)!==vf(e))return!1;for(const n in t)if(!Fv(t,n)||!Qu(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Qu(t[n],e[n]))return!1;break;default:return!1}return!0},joe=(t,e)=>e.includes(t),Sa=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",NI=typeof window<"u"&&typeof document<"u"&&!Sa;let zr;const $oe=()=>{if(zr===void 0)if(Sa){zr=eo();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&zr.set(e,""),e=r):e!==null&&(zr.set(e,r),e=null)}e!==null&&zr.set(e,"")}else typeof location=="object"?(zr=eo(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");zr.set(`--${ZE(e,"-")}`,n),zr.set(`-${ZE(e,"-")}`,n)}})):zr=eo();return zr},oy=t=>$oe().has(t),wf=t=>iS(Sa?process.env[t.toUpperCase().replaceAll("-","_")]:Ooe.getItem(t)),II=t=>oy("--"+t)||wf(t)!==null,Foe=II("production"),Uoe=Sa&&joe(process.env.FORCE_COLOR,["true","1","2"]),Ble=Uoe||!oy("--no-colors")&&!II("no-color")&&(!Sa||process.stdout.isTTY)&&(!Sa||oy("--color")||wf("COLORTERM")!==null||(wf("TERM")||"").includes("color")),Boe=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=kI(t[n]);return btoa(e)},zoe=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),Hoe=NI?Boe:zoe,Voe=t=>noe(e=>Ea(e,t));class Woe{constructor(e,n){this.left=e,this.right=n}}const bo=(t,e)=>new Woe(t,e),aS=t=>t.next()>=.5,wm=(t,e,n)=>Rr(t.next()*(n+1-e)+e),DI=(t,e,n)=>Rr(t.next()*(n+1-e)+e),Bv=(t,e,n)=>DI(t,e,n),Koe=t=>kI(Bv(t,97,122)),Goe=(t,e=0,n=20)=>{const r=Bv(t,e,n);let o="";for(let s=0;s<r;s++)o+=Koe(t);return o},xm=(t,e)=>e[Bv(t,0,e.length-1)],qoe=Symbol("0schema");class Yoe{constructor(){this._rerrs=[]}extend(e,n,r,o=null){this._rerrs.push({path:e,expected:n,has:r,message:o})}toString(){const e=[];for(let n=this._rerrs.length-1;n>0;n--){const r=this._rerrs[n];e.push(toe(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
244
- `)}}const sy=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[lc]?MI(t,e):wa(t)?Nv(t,n=>Iv(e,r=>sy(n,r))):Roe(t)?La(t,(n,r)=>sy(n,e[r])):!1;class Cn{static _dilutes=!1;extends(e){let[n,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,n]=[n,r]),sy(n,r)}equals(e){return this.constructor===e.constructor&&Qu(this.shape,e.shape)}[qoe](){return!0}[lc](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){ur()}get nullable(){return ja(this,zh)}get optional(){return new jI(this)}cast(e){return lS(e,this),e}expect(e){return lS(e,this),e}}class zv extends Cn{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n=void 0){const r=e?.constructor===this.shape&&(this._c==null||this._c(e));return!r&&n?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),r}}const Nt=(t,e=null)=>new zv(t,e);Nt(zv);class Hv extends Cn{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape(e);return!r&&n?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),r}}const Kt=t=>new Hv(t);Nt(Hv);class $h extends Cn{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape.some(o=>o===e);return!r&&n?.extend(null,this.shape.join(" | "),e.toString()),r}}const Fh=(...t)=>new $h(t),PI=Nt($h),Joe=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),LI=t=>{if(ka.check(t))return[Joe(t)];if(PI.check(t))return t.shape.map(e=>e+"");if(KI.check(t))return["[+-]?\\d+.?\\d*"];if(GI.check(t))return[".*"];if(xf.check(t))return t.shape.map(LI).flat(1);dn()};class Xoe extends Cn{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(LI).map(n=>`(${n.join("|")})`).join("")+"$")}check(e,n){const r=this._r.exec(e)!=null;return!r&&n?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),r}}Nt(Xoe);const Qoe=Symbol("optional");class jI extends Cn{constructor(e){super(),this.shape=e}check(e,n){const r=e===void 0||this.shape.check(e);return!r&&n?.extend(null,"undefined (optional)","()"),r}get[Qoe](){return!0}}const Zoe=Nt(jI);class ese extends Cn{check(e,n){return n?.extend(null,"never",typeof e),!1}}Nt(ese);class Uh extends Cn{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}static _dilutes=!0;get partial(){return new Uh(this.shape,!0)}check(e,n){return e==null?(n?.extend(null,"object","null"),!1):La(this.shape,(r,o)=>{const s=this._isPartial&&!Fv(e,o)||r.check(e[o],n);return!s&&n?.extend(o.toString(),r.toString(),typeof e[o],"Object property does not match"),s})}}const tse=t=>new Uh(t),nse=Nt(Uh),rse=Kt(t=>t!=null&&(t.constructor===Object||t.constructor==null));class $I extends Cn{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&La(e,(r,o)=>{const s=this.shape.keys.check(o,n);return!s&&n?.extend(o+"","Record",typeof e,s?"Key doesn't match schema":"Value doesn't match value"),s&&this.shape.values.check(r,n)})}}const FI=(t,e)=>new $I(t,e),ose=Nt($I);class UI extends Cn{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&La(this.shape,(r,o)=>{const s=r.check(e[o],n);return!s&&n?.extend(o.toString(),"Tuple",typeof r),s})}}const sse=(...t)=>new UI(t);Nt(UI);class BI extends Cn{constructor(e){super(),this.shape=e.length===1?e[0]:new Vv(e)}check(e,n){const r=wa(e)&&Nv(e,o=>this.shape.check(o));return!r&&n?.extend(null,"Array",""),r}}const zI=(...t)=>new BI(t),ise=Nt(BI),ase=Kt(t=>wa(t));class HI extends Cn{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n){const r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&n?.extend(null,this.shape.name,e?.constructor.name),r}}const lse=(t,e=null)=>new HI(t,e);Nt(HI);const cse=lse(Cn);class use extends Cn{constructor(e){super(),this.len=e.length-1,this.args=sse(...e.slice(-1)),this.res=e[this.len]}check(e,n){const r=e.constructor===Function&&e.length<=this.len;return!r&&n?.extend(null,"function",typeof e),r}}const dse=Nt(use),fse=Kt(t=>typeof t=="function");class hse extends Cn{constructor(e){super(),this.shape=e}check(e,n){const r=Nv(this.shape,o=>o.check(e,n));return!r&&n?.extend(null,"Intersectinon",typeof e),r}}Nt(hse,t=>t.shape.length>0);class Vv extends Cn{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,n){const r=Iv(this.shape,o=>o.check(e,n));return n?.extend(null,"Union",typeof e),r}}const ja=(...t)=>t.findIndex(e=>xf.check(e))>=0?ja(...t.map(e=>cc(e)).map(e=>xf.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new Vv(t),xf=Nt(Vv),VI=()=>!0,Ef=Kt(VI),pse=Nt(Hv,t=>t.shape===VI),Wv=Kt(t=>typeof t=="bigint"),mse=Kt(t=>t===Wv),WI=Kt(t=>typeof t=="symbol");Kt(t=>t===WI);const Qi=Kt(t=>typeof t=="number"),KI=Kt(t=>t===Qi),ka=Kt(t=>typeof t=="string"),GI=Kt(t=>t===ka),Bh=Kt(t=>typeof t=="boolean"),gse=Kt(t=>t===Bh),qI=Fh(void 0);Nt($h,t=>t.shape.length===1&&t.shape[0]===void 0);Fh(void 0);const zh=Fh(null),yse=Nt($h,t=>t.shape.length===1&&t.shape[0]===null);Nt(Uint8Array);Nt(zv,t=>t.shape===Uint8Array);const bse=ja(Qi,ka,zh,qI,Wv,Bh,WI);(()=>{const t=zI(Ef),e=FI(ka,Ef),n=ja(Qi,ka,zh,Bh,t,e);return t.shape=n,e.shape.values=n,n})();const cc=t=>{if(cse.check(t))return t;if(rse.check(t)){const e={};for(const n in t)e[n]=cc(t[n]);return tse(e)}else{if(ase.check(t))return ja(...t.map(cc));if(bse.check(t))return Fh(t);if(fse.check(t))return Nt(t)}dn()},lS=Foe?()=>{}:(t,e)=>{const n=new Yoe;if(!e.check(t,n))throw io(`Expected value to be of type ${e.constructor.name}.
245
- ${n.toString()}`)};class vse{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:cc(e),h:n}),this}else(e){return this.if(Ef,e)}done(){return(e,n)=>{for(let r=0;r<this.patterns.length;r++){const o=this.patterns[r];if(o.if.check(e))return o.h(e,n)}throw io("Unhandled pattern")}}}const wse=t=>new vse(t),YI=wse(Ef).if(KI,(t,e)=>wm(e,QE,yf)).if(GI,(t,e)=>Goe(e)).if(gse,(t,e)=>aS(e)).if(mse,(t,e)=>BigInt(wm(e,QE,yf))).if(xf,(t,e)=>$i(e,xm(e,t.shape))).if(nse,(t,e)=>{const n={};for(const r in t.shape){let o=t.shape[r];if(Zoe.check(o)){if(aS(e))continue;o=o.shape}n[r]=YI(o,e)}return n}).if(ise,(t,e)=>{const n=[],r=DI(e,0,42);for(let o=0;o<r;o++)n.push($i(e,t.shape));return n}).if(PI,(t,e)=>xm(e,t.shape)).if(yse,(t,e)=>null).if(dse,(t,e)=>{const n=$i(e,t.res);return()=>n}).if(pse,(t,e)=>$i(e,xm(e,[Qi,ka,zh,qI,Wv,Bh,zI(Qi),FI(ja("a","b","c"),Qi)]))).if(ose,(t,e)=>{const n={},r=wm(e,0,3);for(let o=0;o<r;o++){const s=$i(e,t.shape.keys),i=$i(e,t.shape.values);n[s]=i}return n}).done(),$i=(t,e)=>YI(cc(e),t),Kc=typeof document<"u"?document:{};Kt(t=>t.nodeType===kse);typeof DOMParser<"u"&&new DOMParser;Kt(t=>t.nodeType===xse);Kt(t=>t.nodeType===Ese);const xse=Kc.ELEMENT_NODE,Ese=Kc.TEXT_NODE,Sse=Kc.DOCUMENT_NODE,kse=Kc.DOCUMENT_FRAGMENT_NODE;Kt(t=>t.nodeType===Sse);const Tse=t=>class{constructor(n){this._=n}destroy(){t(this._)}},Cse=Tse(clearTimeout),JI=(t,e)=>new Cse(setTimeout(e,t)),zo=Symbol,XI=zo(),QI=zo(),Ase=zo(),_se=zo(),Mse=zo(),ZI=zo(),Ose=zo(),Kv=zo(),Rse=zo();const Hle={[XI]:bo("font-weight","bold"),[QI]:bo("font-weight","normal"),[Ase]:bo("color","blue"),[Mse]:bo("color","green"),[_se]:bo("color","grey"),[ZI]:bo("color","red"),[Ose]:bo("color","purple"),[Kv]:bo("color","orange"),[Rse]:bo("color","black")};const Nse=(...t)=>{tD.forEach(e=>e.print(t))},eD=(...t)=>{t.unshift(Kv),tD.forEach(e=>e.print(t))},tD=mi(),nD=t=>({[Symbol.iterator](){return this},next:t}),Ise=(t,e)=>nD(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Em=(t,e)=>nD(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class Gv{constructor(e,n){this.clock=e,this.len=n}}class $a{constructor(){this.clients=new Map}}const xs=(t,e,n)=>e.clients.forEach((r,o)=>{const s=t.doc.store.clients.get(o);if(s!=null){const i=s[s.length-1],a=i.id.clock+i.length;for(let l=0,c=r[l];l<r.length&&c.clock<a;c=r[++l])uD(t,s,c.clock,c.len,n)}}),Dse=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const o=Rr((n+r)/2),s=t[o],i=s.clock;if(i<=e){if(e<i+s.len)return o;n=o+1}else r=o-1}return null},Fa=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&Dse(n,e.clock)!==null},qv=t=>{t.clients.forEach(e=>{e.sort((o,s)=>o.clock-s.clock);let n,r;for(n=1,r=1;n<e.length;n++){const o=e[r-1],s=e[n];o.clock+o.len>=s.clock?o.len=ws(o.len,s.clock+s.len-o.clock):(r<n&&(e[r]=s),r++)}e.length=r})},iy=t=>{const e=new $a;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,o)=>{if(!e.clients.has(o)){const s=r.slice();for(let i=n+1;i<t.length;i++)Hre(s,t[i].clients.get(o)||[]);e.clients.set(o,s)}});return qv(e),e},uc=(t,e,n,r)=>{Bo(t.clients,e,()=>[]).push(new Gv(n,r))},rD=()=>new $a,Pse=t=>{const e=rD();return t.clients.forEach((n,r)=>{const o=[];for(let s=0;s<n.length;s++){const i=n[s];if(i.deleted){const a=i.id.clock;let l=i.length;if(s+1<n.length)for(let c=n[s+1];s+1<n.length&&c.deleted;c=n[++s+1])l+=c.length;o.push(new Gv(a,l))}}o.length>0&&e.clients.set(r,o)}),e},Yv=(t,e)=>{Xe(t.restEncoder,e.clients.size),gi(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),Xe(t.restEncoder,n);const o=r.length;Xe(t.restEncoder,o);for(let s=0;s<o;s++){const i=r[s];t.writeDsClock(i.clock),t.writeDsLen(i.len)}})},Lse=t=>{const e=new $a,n=bt(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const o=bt(t.restDecoder),s=bt(t.restDecoder);if(s>0){const i=Bo(e.clients,o,()=>[]);for(let a=0;a<s;a++)i.push(new Gv(t.readDsClock(),t.readDsLen()))}}return e},cS=(t,e,n)=>{const r=new $a,o=bt(t.restDecoder);for(let s=0;s<o;s++){t.resetDsCurVal();const i=bt(t.restDecoder),a=bt(t.restDecoder),l=n.clients.get(i)||[],c=Tt(n,i);for(let u=0;u<a;u++){const d=t.readDsClock(),f=d+t.readDsLen();if(d<c){c<f&&uc(r,i,c,f-c);let h=Nr(l,d),p=l[h];for(!p.deleted&&p.id.clock<d&&(l.splice(h+1,0,Mf(e,p,d-p.id.clock)),h++);h<l.length&&(p=l[h++],p.id.clock<f);)p.deleted||(f<p.id.clock+p.length&&l.splice(h,0,Mf(e,p,f-p.id.clock)),p.delete(e))}else uc(r,i,d,f-d)}}if(r.clients.size>0){const s=new Hh;return Xe(s.restEncoder,0),Yv(s,r),s.toUint8Array()}return null},oD=AI;class Mi extends EI{constructor({guid:e=Coe(),collectionid:n=null,gc:r=!0,gcFilter:o=()=>!0,meta:s=null,autoLoad:i=!1,shouldLoad:a=!0}={}){super(),this.gc=r,this.gcFilter=o,this.clientID=oD(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new lD,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=a,this.autoLoad=i,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=sS(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const l=()=>sS(c=>{const u=d=>{(d===void 0||d===!0)&&(this.off("sync",u),c())};this.on("sync",u)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const e=this._item;e!==null&&!this.shouldLoad&&ct(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(gi(this.subdocs).map(e=>e.guid))}transact(e,n=null){return ct(this,e,n)}get(e,n=Wt){const r=Bo(this.share,e,()=>{const s=new n;return s._integrate(this,null),s}),o=r.constructor;if(n!==Wt&&o!==n)if(o===Wt){const s=new n;s._map=r._map,r._map.forEach(i=>{for(;i!==null;i=i.left)i.parent=s}),s._start=r._start;for(let i=s._start;i!==null;i=i.right)i.parent=s;return s._length=r._length,this.share.set(e,s),s._integrate(this,null),s}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,ta)}getText(e=""){return this.get(e,Es)}getMap(e=""){return this.get(e,Ta)}getXmlElement(e=""){return this.get(e,ln)}getXmlFragment(e=""){return this.get(e,yi)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,gi(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new Mi({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,ct(e.parent.doc,r=>{const o=n.doc;e.deleted||r.subdocsAdded.add(o),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class jse{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=bt(this.restDecoder),this.dsCurrVal}readDsLen(){const e=bt(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Sf extends jse{constructor(e){super(e),this.keys=[],bt(e),this.keyClockDecoder=new vm(tr(e)),this.clientDecoder=new Xu(tr(e)),this.leftClockDecoder=new vm(tr(e)),this.rightClockDecoder=new vm(tr(e)),this.infoDecoder=new oS(tr(e),ac),this.stringDecoder=new xoe(tr(e)),this.parentInfoDecoder=new oS(tr(e),ac),this.typeRefDecoder=new Xu(tr(e)),this.lenDecoder=new Xu(tr(e))}readLeftID(){return new Zi(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Zi(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return bf(this.restDecoder)}readBuf(){return tr(this.restDecoder)}readJSON(){return bf(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class $se{constructor(){this.restEncoder=Wc()}toUint8Array(){return Cr(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Xe(this.restEncoder,e)}writeDsLen(e){Xe(this.restEncoder,e)}}class Fse extends $se{writeLeftID(e){Xe(this.restEncoder,e.client),Xe(this.restEncoder,e.clock)}writeRightID(e){Xe(this.restEncoder,e.client),Xe(this.restEncoder,e.clock)}writeClient(e){Xe(this.restEncoder,e)}writeInfo(e){ty(this.restEncoder,e)}writeString(e){Xi(this.restEncoder,e)}writeParentInfo(e){Xe(this.restEncoder,e?1:0)}writeTypeRef(e){Xe(this.restEncoder,e)}writeLen(e){Xe(this.restEncoder,e)}writeAny(e){Ea(this.restEncoder,e)}writeBuf(e){zn(this.restEncoder,e)}writeJSON(e){Xi(this.restEncoder,JSON.stringify(e))}writeKey(e){Xi(this.restEncoder,e)}}class Use{constructor(){this.restEncoder=Wc(),this.dsCurrVal=0}toUint8Array(){return Cr(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,Xe(this.restEncoder,n)}writeDsLen(e){e===0&&dn(),Xe(this.restEncoder,e-1),this.dsCurrVal+=e}}class Hh extends Use{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new bm,this.clientEncoder=new Ju,this.leftClockEncoder=new bm,this.rightClockEncoder=new bm,this.infoEncoder=new tS(ty),this.stringEncoder=new foe,this.parentInfoEncoder=new tS(ty),this.typeRefEncoder=new Ju,this.lenEncoder=new Ju}toUint8Array(){const e=Wc();return Xe(e,0),zn(e,this.keyClockEncoder.toUint8Array()),zn(e,this.clientEncoder.toUint8Array()),zn(e,this.leftClockEncoder.toUint8Array()),zn(e,this.rightClockEncoder.toUint8Array()),zn(e,Cr(this.infoEncoder)),zn(e,this.stringEncoder.toUint8Array()),zn(e,Cr(this.parentInfoEncoder)),zn(e,this.typeRefEncoder.toUint8Array()),zn(e,this.lenEncoder.toUint8Array()),Lh(e,Cr(this.restEncoder)),Cr(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Ea(this.restEncoder,e)}writeBuf(e){zn(this.restEncoder,e)}writeJSON(e){Ea(this.restEncoder,e)}writeKey(e){const n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}}const Bse=(t,e,n,r)=>{r=ws(r,e[0].id.clock);const o=Nr(e,r);Xe(t.restEncoder,e.length-o),t.writeClient(n),Xe(t.restEncoder,r);const s=e[o];s.write(t,r-s.id.clock);for(let i=o+1;i<e.length;i++)e[i].write(t,0)},sD=(t,e,n)=>{const r=new Map;n.forEach((o,s)=>{Tt(e,s)>o&&r.set(s,o)}),Vh(e).forEach((o,s)=>{n.has(s)||r.set(s,0)}),Xe(t.restEncoder,r.size),gi(r.entries()).sort((o,s)=>s[0]-o[0]).forEach(([o,s])=>{Bse(t,e.clients.get(o),o,s)})},zse=(t,e)=>{const n=eo(),r=bt(t.restDecoder);for(let o=0;o<r;o++){const s=bt(t.restDecoder),i=new Array(s),a=t.readClient();let l=bt(t.restDecoder);n.set(a,{i:0,refs:i});for(let c=0;c<s;c++){const u=t.readInfo();switch(Ph&u){case 0:{const d=t.readLen();i[c]=new or(Ue(a,l),d),l+=d;break}case 10:{const d=bt(t.restDecoder);i[c]=new kr(Ue(a,l),d),l+=d;break}default:{const d=(u&(Ao|vn))===0,f=new it(Ue(a,l),null,(u&vn)===vn?t.readLeftID():null,null,(u&Ao)===Ao?t.readRightID():null,d?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,d&&(u&sc)===sc?t.readString():null,ND(t,u));i[c]=f,l+=f.length}}}}return n},Hse=(t,e,n)=>{const r=[];let o=gi(n.keys()).sort((h,p)=>h-p);if(o.length===0)return null;const s=()=>{if(o.length===0)return null;let h=n.get(o[o.length-1]);for(;h.refs.length===h.i;)if(o.pop(),o.length>0)h=n.get(o[o.length-1]);else return null;return h};let i=s();if(i===null)return null;const a=new lD,l=new Map,c=(h,p)=>{const m=l.get(h);(m==null||m>p)&&l.set(h,p)};let u=i.refs[i.i++];const d=new Map,f=()=>{for(const h of r){const p=h.id.client,m=n.get(p);m?(m.i--,a.clients.set(p,m.refs.slice(m.i)),n.delete(p),m.i=0,m.refs=[]):a.clients.set(p,[h]),o=o.filter(g=>g!==p)}r.length=0};for(;;){if(u.constructor!==kr){const p=Bo(d,u.id.client,()=>Tt(e,u.id.client))-u.id.clock;if(p<0)r.push(u),c(u.id.client,u.id.clock-1),f();else{const m=u.getMissing(t,e);if(m!==null){r.push(u);const g=n.get(m)||{refs:[],i:0};if(g.refs.length===g.i)c(m,Tt(e,m)),f();else{u=g.refs[g.i++];continue}}else(p===0||p<u.length)&&(u.integrate(t,p),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(i!==null&&i.i<i.refs.length)u=i.refs[i.i++];else{if(i=s(),i===null)break;u=i.refs[i.i++]}}if(a.clients.size>0){const h=new Hh;return sD(h,a,new Map),Xe(h.restEncoder,0),{missing:l,update:h.toUint8Array()}}return null},Vse=(t,e)=>sD(t,e.doc.store,e.beforeState),Wse=(t,e,n,r=new Sf(t))=>ct(e,o=>{o.local=!1;let s=!1;const i=o.doc,a=i.store,l=zse(r,i),c=Hse(o,a,l),u=a.pendingStructs;if(u){for(const[f,h]of u.missing)if(h<Tt(a,f)){s=!0;break}if(c){for(const[f,h]of c.missing){const p=u.missing.get(f);(p==null||p>h)&&u.missing.set(f,h)}u.update=bS([u.update,c.update])}}else a.pendingStructs=c;const d=cS(r,o,a);if(a.pendingDs){const f=new Sf(Lv(a.pendingDs));bt(f.restDecoder);const h=cS(f,o,a);d&&h?a.pendingDs=bS([d,h]):a.pendingDs=d||h}else a.pendingDs=d;if(s){const f=a.pendingStructs.update;a.pendingStructs=null,ay(o.doc,f)}},n,!1),ay=(t,e,n,r=Sf)=>{const o=Lv(e);Wse(o,t,n,new r(o))};class Kse{constructor(){this.l=[]}}const uS=()=>new Kse,dS=(t,e)=>t.l.push(e),fS=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(o=>e!==o),t.l.length},iD=(t,e,n)=>Uv(t.l,[e,n]);class Zi{constructor(e,n){this.client=e,this.clock=n}}const Tu=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,Ue=(t,e)=>new Zi(t,e),dc=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw dn()},fc=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class kf{constructor(e,n,r,o=0){this.type=e,this.tname=n,this.item=r,this.assoc=o}}class Gse{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const qse=(t,e,n=0)=>new Gse(t,e,n),Cu=(t,e,n)=>{let r=null,o=null;return t._item===null?o=dc(t):r=Ue(t._item.id.client,t._item.id.clock),new kf(r,o,e,n)},Sm=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Cu(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Cu(t,Ue(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Cu(t,r.lastId,n);r=r.right}return Cu(t,null,n)},Yse=(t,e)=>{const n=ea(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},Jse=(t,e,n=!0)=>{const r=e.store,o=t.item,s=t.type,i=t.tname,a=t.assoc;let l=null,c=0;if(o!==null){if(Tt(r,o.client)<=o.clock)return null;const u=n?dy(r,o):Yse(r,o),d=u.item;if(!(d instanceof it))return null;if(l=d.parent,l._item===null||!l._item.deleted){c=d.deleted||!d.countable?0:u.diff+(a>=0?0:1);let f=d.left;for(;f!==null;)!f.deleted&&f.countable&&(c+=f.length),f=f.left}}else{if(i!==null)l=e.get(i);else if(s!==null){if(Tt(r,s.client)<=s.clock)return null;const{item:u}=n?dy(r,s):{item:ea(r,s)};if(u instanceof it&&u.content instanceof $r)l=u.content.type;else return null}else throw dn();a>=0?c=l._length:c=0}return qse(l,c,t.assoc)};class Jv{constructor(e,n){this.ds=e,this.sv=n}}const aD=(t,e)=>new Jv(t,e),km=t=>aD(Pse(t.store),Vh(t.store)),Fs=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Fa(e.ds,t.id),ly=(t,e)=>{const n=Bo(t.meta,ly,mi),r=t.doc.store;n.has(e)||(e.sv.forEach((o,s)=>{o<Tt(r,s)&&Nn(t,Ue(s,o))}),xs(t,e.ds,o=>{}),n.add(e))};class lD{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Vh=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const o=n[n.length-1];e.set(r,o.id.clock+o.length)}),e},Tt=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},cD=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw dn()}n.push(e)},Nr=(t,e)=>{let n=0,r=t.length-1,o=t[r],s=o.id.clock;if(s===e)return r;let i=Rr(e/(s+o.length-1)*r);for(;n<=r;){if(o=t[i],s=o.id.clock,s<=e){if(e<s+o.length)return i;n=i+1}else r=i-1;i=Rr((n+r)/2)}throw dn()},Xse=(t,e)=>{const n=t.clients.get(e.client);return n[Nr(n,e.clock)]},ea=Xse,cy=(t,e,n)=>{const r=Nr(e,n),o=e[r];return o.id.clock<n&&o instanceof it?(e.splice(r+1,0,Mf(t,o,n-o.id.clock)),r+1):r},Nn=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[cy(t,n,e.clock)]},hS=(t,e,n)=>{const r=e.clients.get(n.client),o=Nr(r,n.clock),s=r[o];return n.clock!==s.id.clock+s.length-1&&s.constructor!==or&&r.splice(o+1,0,Mf(t,s,n.clock-s.id.clock+1)),s},Qse=(t,e,n)=>{const r=t.clients.get(e.id.client);r[Nr(r,e.id.clock)]=n},uD=(t,e,n,r,o)=>{if(r===0)return;const s=n+r;let i=cy(t,e,n),a;do a=e[i++],s<a.id.clock+a.length&&cy(t,e,s),o(a);while(i<e.length&&e[i].id.clock<s)};class Zse{constructor(e,n,r){this.doc=e,this.deleteSet=new $a,this.beforeState=Vh(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const pS=(t,e)=>e.deleteSet.clients.size===0&&!zre(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(qv(e.deleteSet),Vse(t,e),Yv(t,e.deleteSet),!0),mS=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&Bo(t.changed,e,mi).add(n)},Zu=(t,e)=>{let n=t[e],r=t[e-1],o=e;for(;o>0;n=r,r=t[--o-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof it&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const s=e-o;return s&&t.splice(e+1-s,s),s},eie=(t,e,n)=>{for(const[r,o]of t.clients.entries()){const s=e.clients.get(r);for(let i=o.length-1;i>=0;i--){const a=o[i],l=a.clock+a.len;for(let c=Nr(s,a.clock),u=s[c];c<s.length&&u.id.clock<l;u=s[++c]){const d=s[c];if(a.clock+a.len<=d.id.clock)break;d instanceof it&&d.deleted&&!d.keep&&n(d)&&d.gc(e,!1)}}}},tie=(t,e)=>{t.clients.forEach((n,r)=>{const o=e.clients.get(r);for(let s=n.length-1;s>=0;s--){const i=n[s],a=xa(o.length-1,1+Nr(o,i.clock+i.len-1));for(let l=a,c=o[l];l>0&&c.id.clock>=i.clock;c=o[l])l-=1+Zu(o,l)}})},dD=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,o=r.store,s=n.deleteSet,i=n._mergeStructs;try{qv(s),n.afterState=Vh(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const a=[];n.changed.forEach((l,c)=>a.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(n,l)})),a.push(()=>{n.changedParentTypes.forEach((l,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(l=l.filter(u=>u.target._item===null||!u.target._item.deleted),l.forEach(u=>{u.currentTarget=c,u._path=null}),l.sort((u,d)=>u.path.length-d.path.length),a.push(()=>{iD(c._dEH,l,n)}))}),a.push(()=>r.emit("afterTransaction",[n,r])),a.push(()=>{n._needFormattingCleanup&&xie(n)})}),Uv(a,[])}finally{r.gc&&eie(s,o,r.gcFilter),tie(s,o),n.afterState.forEach((u,d)=>{const f=n.beforeState.get(d)||0;if(f!==u){const h=o.clients.get(d),p=ws(Nr(h,f),1);for(let m=h.length-1;m>=p;)m-=1+Zu(h,m)}});for(let u=i.length-1;u>=0;u--){const{client:d,clock:f}=i[u].id,h=o.clients.get(d),p=Nr(h,f);p+1<h.length&&Zu(h,p+1)>1||p>0&&Zu(h,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(Nse(Kv,XI,"[yjs] ",QI,ZI,"Changed the client-id because another client seems to be using it."),r.clientID=oD()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const u=new Fse;pS(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const u=new Hh;pS(u,n)&&r.emit("updateV2",[u.toUint8Array(),n.origin,r,n])}const{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:c}=n;(a.size>0||c.size>0||l.size>0)&&(a.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),c.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:l,added:a,removed:c},r,n]),c.forEach(u=>u.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):dD(t,e+1)}}},ct=(t,e,n=null,r=!0)=>{const o=t._transactionCleanups;let s=!1,i=null;t._transaction===null&&(s=!0,t._transaction=new Zse(t,n,r),o.push(t._transaction),o.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{i=e(t._transaction)}finally{if(s){const a=t._transaction===o[0];t._transaction=null,a&&dD(o,0)}}return i};class nie{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const gS=(t,e,n)=>{xs(t,n.deletions,r=>{r instanceof it&&e.scope.some(o=>o===t.doc||fc(o,r))&&t0(r,!1)})},yS=(t,e,n)=>{let r=null;const o=t.doc,s=t.scope;ct(o,a=>{for(;e.length>0&&t.currStackItem===null;){const l=o.store,c=e.pop(),u=new Set,d=[];let f=!1;xs(a,c.insertions,h=>{if(h instanceof it){if(h.redone!==null){let{item:p,diff:m}=dy(l,h.id);m>0&&(p=Nn(a,Ue(p.id.client,p.id.clock+m))),h=p}!h.deleted&&s.some(p=>p===a.doc||fc(p,h))&&d.push(h)}}),xs(a,c.deletions,h=>{h instanceof it&&s.some(p=>p===a.doc||fc(p,h))&&!Fa(c.insertions,h.id)&&u.add(h)}),u.forEach(h=>{f=RD(a,h,u,c.insertions,t.ignoreRemoteMapChanges,t)!==null||f});for(let h=d.length-1;h>=0;h--){const p=d[h];t.deleteFilter(p)&&(p.delete(a),f=!0)}t.currStackItem=f?c:null}a.changed.forEach((l,c)=>{l.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=a},t);const i=t.currStackItem;if(i!=null){const a=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:i,type:n,changedParentTypes:a,origin:t},t]),t.currStackItem=null}return i};class fD extends EI{constructor(e,{captureTimeout:n=500,captureTransaction:r=l=>!0,deleteFilter:o=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:i=!1,doc:a=wa(e)?e[0].doc:e instanceof Mi?e:e.doc}={}){super(),this.scope=[],this.doc=a,this.addToScope(e),this.deleteFilter=o,s.add(this),this.trackedOrigins=s,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=i,this.captureTimeout=n,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(g=>l.changedParentTypes.has(g)||g===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;const c=this.undoing,u=this.redoing,d=c?this.redoStack:this.undoStack;c?this.stopCapturing():u||this.clear(!1,!0);const f=new $a;l.afterState.forEach((g,b)=>{const S=l.beforeState.get(b)||0,k=g-S;k>0&&uc(f,b,S,k)});const h=Aoe();let p=!1;if(this.lastChange>0&&h-this.lastChange<this.captureTimeout&&d.length>0&&!c&&!u){const g=d[d.length-1];g.deletions=iy([g.deletions,l.deleteSet]),g.insertions=iy([g.insertions,f])}else d.push(new nie(l.deleteSet,f)),p=!0;!c&&!u&&(this.lastChange=h),xs(l,l.deleteSet,g=>{g instanceof it&&this.scope.some(b=>b===l.doc||fc(b,g))&&t0(g,!0)});const m=[{stackItem:d[d.length-1],origin:l.origin,type:c?"redo":"undo",changedParentTypes:l.changedParentTypes},this];p?this.emit("stack-item-added",m):this.emit("stack-item-updated",m)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const n=new Set(this.scope);e=wa(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof Wt?r.doc!==this.doc:r!==this.doc)&&eD("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(o=>gS(r,this,o)),this.undoStack=[]),n&&(this.redoStack.forEach(o=>gS(r,this,o)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=yS(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=yS(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*rie(t){const e=bt(t.restDecoder);for(let n=0;n<e;n++){const r=bt(t.restDecoder),o=t.readClient();let s=bt(t.restDecoder);for(let i=0;i<r;i++){const a=t.readInfo();if(a===10){const l=bt(t.restDecoder);yield new kr(Ue(o,s),l),s+=l}else if((Ph&a)!==0){const l=(a&(Ao|vn))===0,c=new it(Ue(o,s),null,(a&vn)===vn?t.readLeftID():null,null,(a&Ao)===Ao?t.readRightID():null,l?t.readParentInfo()?t.readString():t.readLeftID():null,l&&(a&sc)===sc?t.readString():null,ND(t,a));yield c,s+=c.length}else{const l=t.readLen();yield new or(Ue(o,s),l),s+=l}}}}class oie{constructor(e,n){this.gen=rie(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===kr);return this.curr}}class sie{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const iie=(t,e)=>{if(t.constructor===or){const{client:n,clock:r}=t.id;return new or(Ue(n,r+e),t.length-e)}else if(t.constructor===kr){const{client:n,clock:r}=t.id;return new kr(Ue(n,r+e),t.length-e)}else{const n=t,{client:r,clock:o}=n.id;return new it(Ue(r,o+e),null,Ue(r,o+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},bS=(t,e=Sf,n=Hh)=>{if(t.length===1)return t[0];const r=t.map(u=>new e(Lv(u)));let o=r.map(u=>new oie(u,!0)),s=null;const i=new n,a=new sie(i);for(;o=o.filter(f=>f.curr!==null),o.sort((f,h)=>{if(f.curr.id.client===h.curr.id.client){const p=f.curr.id.clock-h.curr.id.clock;return p===0?f.curr.constructor===h.curr.constructor?0:f.curr.constructor===kr?1:-1:p}else return h.curr.id.client-f.curr.id.client}),o.length!==0;){const u=o[0],d=u.curr.id.client;if(s!==null){let f=u.curr,h=!1;for(;f!==null&&f.id.clock+f.length<=s.struct.id.clock+s.struct.length&&f.id.client>=s.struct.id.client;)f=u.next(),h=!0;if(f===null||f.id.client!==d||h&&f.id.clock>s.struct.id.clock+s.struct.length)continue;if(d!==s.struct.id.client)nl(a,s.struct,s.offset),s={struct:f,offset:0},u.next();else if(s.struct.id.clock+s.struct.length<f.id.clock)if(s.struct.constructor===kr)s.struct.length=f.id.clock+f.length-s.struct.id.clock;else{nl(a,s.struct,s.offset);const p=f.id.clock-s.struct.id.clock-s.struct.length;s={struct:new kr(Ue(d,s.struct.id.clock+s.struct.length),p),offset:0}}else{const p=s.struct.id.clock+s.struct.length-f.id.clock;p>0&&(s.struct.constructor===kr?s.struct.length-=p:f=iie(f,p)),s.struct.mergeWith(f)||(nl(a,s.struct,s.offset),s={struct:f,offset:0},u.next())}}else s={struct:u.curr,offset:0},u.next();for(let f=u.curr;f!==null&&f.id.client===d&&f.id.clock===s.struct.id.clock+s.struct.length&&f.constructor!==kr;f=u.next())nl(a,s.struct,s.offset),s={struct:f,offset:0}}s!==null&&(nl(a,s.struct,s.offset),s=null),aie(a);const l=r.map(u=>Lse(u)),c=iy(l);return Yv(i,c),i.toUint8Array()},hD=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:Cr(t.encoder.restEncoder)}),t.encoder.restEncoder=Wc(),t.written=0)},nl=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&hD(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),Xe(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},aie=t=>{hD(t);const e=t.encoder.restEncoder;Xe(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];Xe(e,r.written),Lh(e,r.restEncoder)}},vS="You must not compute changes after the event-handler fired.";class Wh{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=lie(this.currentTarget,this.target))}deletes(e){return Fa(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw io(vS);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(o=>{if(o!==null){const s=n._map.get(o);let i,a;if(this.adds(s)){let l=s.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(s))if(l!==null&&this.deletes(l))i="delete",a=mm(l.content.getContent());else return;else l!==null&&this.deletes(l)?(i="update",a=mm(l.content.getContent())):(i="add",a=void 0)}else if(this.deletes(s))i="delete",a=mm(s.content.getContent());else return;e.set(o,{action:i,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw io(vS);const n=this.target,r=mi(),o=mi(),s=[];if(e={added:r,deleted:o,delta:s,keys:this.keys},this.transaction.changed.get(n).has(null)){let a=null;const l=()=>{a&&s.push(a)};for(let c=n._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((a===null||a.delete===void 0)&&(l(),a={delete:0}),a.delete+=c.length,o.add(c)):this.adds(c)?((a===null||a.insert===void 0)&&(l(),a={insert:[]}),a.insert=a.insert.concat(c.content.getContent()),r.add(c)):((a===null||a.retain===void 0)&&(l(),a={retain:0}),a.retain+=c.length);a!==null&&a.retain===void 0&&l()}this._changes=e}return e}}const lie=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,o=e._item.parent._start;for(;o!==e._item&&o!==null;)!o.deleted&&o.countable&&(r+=o.length),o=o.right;n.unshift(r)}e=e._item.parent}return n},cn=()=>{eD("Invalid access: Add Yjs type to a document before reading data.")},pD=80;let Xv=0;class cie{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=Xv++}}const uie=t=>{t.timestamp=Xv++},mD=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Xv++},die=(t,e,n)=>{if(t.length>=pD){const r=t.reduce((o,s)=>o.timestamp<s.timestamp?o:s);return mD(r,e,n),r}else{const r=new cie(e,n);return t.push(r),r}},Kh=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((s,i)=>Yu(e-s.index)<Yu(e-i.index)?s:i);let r=t._start,o=0;for(n!==null&&(r=n.p,o=n.index,uie(n));r.right!==null&&o<e;){if(!r.deleted&&r.countable){if(e<o+r.length)break;o+=r.length}r=r.right}for(;r.left!==null&&o>e;)r=r.left,!r.deleted&&r.countable&&(o-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(o-=r.length);return n!==null&&Yu(n.index-o)<r.parent.length/pD?(mD(n,r,o),n):die(t._searchMarker,r,o)},hc=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const o=t[r];if(n>0){let s=o.p;for(s.marker=!1;s&&(s.deleted||!s.countable);)s=s.left,s&&!s.deleted&&s.countable&&(o.index-=s.length);if(s===null||s.marker===!0){t.splice(r,1);continue}o.p=s,s.marker=!0}(e<o.index||n>0&&e===o.index)&&(o.index=ws(e,o.index+n))}},Gh=(t,e,n)=>{const r=t,o=e.changedParentTypes;for(;Bo(o,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;iD(r._eH,n,e)};class Wt{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=uS(),this._dEH=uS(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw ur()}clone(){throw ur()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){dS(this._eH,e)}observeDeep(e){dS(this._dEH,e)}unobserve(e){fS(this._eH,e)}unobserveDeep(e){fS(this._dEH,e)}toJSON(){}}const gD=(t,e,n)=>{t.doc??cn(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const o=[];let s=t._start;for(;s!==null&&r>0;){if(s.countable&&!s.deleted){const i=s.content.getContent();if(i.length<=e)e-=i.length;else{for(let a=e;a<i.length&&r>0;a++)o.push(i[a]),r--;e=0}}s=s.right}return o},yD=t=>{t.doc??cn();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let o=0;o<r.length;o++)e.push(r[o])}n=n.right}return e},bD=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&Fs(r,e)){const o=r.content.getContent();for(let s=0;s<o.length;s++)n.push(o[s])}r=r.right}return n},pc=(t,e)=>{let n=0,r=t._start;for(t.doc??cn();r!==null;){if(r.countable&&!r.deleted){const o=r.content.getContent();for(let s=0;s<o.length;s++)e(o[s],n++,t)}r=r.right}},vD=(t,e)=>{const n=[];return pc(t,(r,o)=>{n.push(e(r,o,t))}),n},fie=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const o=n[r++];return n.length<=r&&(n=null),{done:!1,value:o}}}},wD=(t,e)=>{t.doc??cn();const n=Kh(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Tf=(t,e,n,r)=>{let o=n;const s=t.doc,i=s.clientID,a=s.store,l=n===null?e._start:n.right;let c=[];const u=()=>{c.length>0&&(o=new it(Ue(i,Tt(a,i)),o,o&&o.lastId,l,l&&l.id,e,null,new bi(c)),o.integrate(t,0),c=[])};r.forEach(d=>{if(d===null)c.push(d);else switch(d.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(d);break;default:switch(u(),d.constructor){case Uint8Array:case ArrayBuffer:o=new it(Ue(i,Tt(a,i)),o,o&&o.lastId,l,l&&l.id,e,null,new Gc(new Uint8Array(d))),o.integrate(t,0);break;case Mi:o=new it(Ue(i,Tt(a,i)),o,o&&o.lastId,l,l&&l.id,e,null,new qc(d)),o.integrate(t,0);break;default:if(d instanceof Wt)o=new it(Ue(i,Tt(a,i)),o,o&&o.lastId,l,l&&l.id,e,null,new $r(d)),o.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},xD=()=>io("Length exceeded!"),ED=(t,e,n,r)=>{if(n>e._length)throw xD();if(n===0)return e._searchMarker&&hc(e._searchMarker,n,r.length),Tf(t,e,null,r);const o=n,s=Kh(e,n);let i=e._start;for(s!==null&&(i=s.p,n-=s.index,n===0&&(i=i.prev,n+=i&&i.countable&&!i.deleted?i.length:0));i!==null;i=i.right)if(!i.deleted&&i.countable){if(n<=i.length){n<i.length&&Nn(t,Ue(i.id.client,i.id.clock+n));break}n-=i.length}return e._searchMarker&&hc(e._searchMarker,o,r.length),Tf(t,e,i,r)},hie=(t,e,n)=>{let o=(e._searchMarker||[]).reduce((s,i)=>i.index>s.index?i:s,{index:0,p:e._start}).p;if(o)for(;o.right;)o=o.right;return Tf(t,e,o,n)},SD=(t,e,n,r)=>{if(r===0)return;const o=n,s=r,i=Kh(e,n);let a=e._start;for(i!==null&&(a=i.p,n-=i.index);a!==null&&n>0;a=a.right)!a.deleted&&a.countable&&(n<a.length&&Nn(t,Ue(a.id.client,a.id.clock+n)),n-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&Nn(t,Ue(a.id.client,a.id.clock+r)),a.delete(t),r-=a.length),a=a.right;if(r>0)throw xD();e._searchMarker&&hc(e._searchMarker,o,-s+r)},Cf=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},Qv=(t,e,n,r)=>{const o=e._map.get(n)||null,s=t.doc,i=s.clientID;let a;if(r==null)a=new bi([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:a=new bi([r]);break;case Uint8Array:a=new Gc(r);break;case Mi:a=new qc(r);break;default:if(r instanceof Wt)a=new $r(r);else throw new Error("Unexpected content type")}new it(Ue(i,Tt(s.store,i)),o,o&&o.lastId,null,null,e,n,a).integrate(t,0)},Zv=(t,e)=>{t.doc??cn();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},kD=t=>{const e={};return t.doc??cn(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},TD=(t,e)=>{t.doc??cn();const n=t._map.get(e);return n!==void 0&&!n.deleted},pie=(t,e)=>{const n={};return t._map.forEach((r,o)=>{let s=r;for(;s!==null&&(!e.sv.has(s.id.client)||s.id.clock>=(e.sv.get(s.id.client)||0));)s=s.left;s!==null&&Fs(s,e)&&(n[o]=s.content.getContent()[s.length-1])}),n},Au=t=>(t.doc??cn(),Ise(t._map.entries(),e=>!e[1].deleted));class mie extends Wh{}class ta extends Wt{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new ta;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ta}clone(){const e=new ta;return e.insert(0,this.toArray().map(n=>n instanceof Wt?n.clone():n)),e}get length(){return this.doc??cn(),this._length}_callObserver(e,n){super._callObserver(e,n),Gh(this,e,new mie(this,e))}insert(e,n){this.doc!==null?ct(this.doc,r=>{ED(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?ct(this.doc,n=>{hie(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?ct(this.doc,r=>{SD(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return wD(this,e)}toArray(){return yD(this)}slice(e=0,n=this.length){return gD(this,e,n)}toJSON(){return this.map(e=>e instanceof Wt?e.toJSON():e)}map(e){return vD(this,e)}forEach(e){pc(this,e)}[Symbol.iterator](){return fie(this)}_write(e){e.writeTypeRef(Uie)}}const gie=t=>new ta;class yie extends Wh{constructor(e,n,r){super(e,n),this.keysChanged=r}}class Ta extends Wt{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,o)=>{this.set(o,r)}),this._prelimContent=null}_copy(){return new Ta}clone(){const e=new Ta;return this.forEach((n,r)=>{e.set(r,n instanceof Wt?n.clone():n)}),e}_callObserver(e,n){Gh(this,e,new yie(this,e,n))}toJSON(){this.doc??cn();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const o=n.content.getContent()[n.length-1];e[r]=o instanceof Wt?o.toJSON():o}}),e}get size(){return[...Au(this)].length}keys(){return Em(Au(this),e=>e[0])}values(){return Em(Au(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Em(Au(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??cn(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?ct(this.doc,n=>{Cf(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?ct(this.doc,r=>{Qv(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return Zv(this,e)}has(e){return TD(this,e)}clear(){this.doc!==null?ct(this.doc,e=>{this.forEach(function(n,r,o){Cf(e,o,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(Bie)}}const bie=t=>new Ta,as=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&Poe(t,e);class uy{constructor(e,n,r,o){this.left=e,this.right=n,this.index=r,this.currentAttributes=o}forward(){this.right===null&&dn(),this.right.content.constructor===Rt?this.right.deleted||Ua(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const wS=(t,e,n)=>{for(;e.right!==null&&n>0;)e.right.content.constructor===Rt?e.right.deleted||Ua(e.currentAttributes,e.right.content):e.right.deleted||(n<e.right.length&&Nn(t,Ue(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length),e.left=e.right,e.right=e.right.right;return e},_u=(t,e,n,r)=>{const o=new Map,s=r?Kh(e,n):null;if(s){const i=new uy(s.p.left,s.p,s.index,o);return wS(t,i,n-s.index)}else{const i=new uy(null,e._start,0,o);return wS(t,i,n)}},CD=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Rt&&as(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const o=t.doc,s=o.clientID;r.forEach((i,a)=>{const l=n.left,c=n.right,u=new it(Ue(s,Tt(o.store,s)),l,l&&l.lastId,c,c&&c.id,e,null,new Rt(a,i));u.integrate(t,0),n.right=u,n.forward()})},Ua=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},AD=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Rt&&as(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},_D=(t,e,n,r)=>{const o=t.doc,s=o.clientID,i=new Map;for(const a in r){const l=r[a],c=n.currentAttributes.get(a)??null;if(!as(c,l)){i.set(a,c);const{left:u,right:d}=n;n.right=new it(Ue(s,Tt(o.store,s)),u,u&&u.lastId,d,d&&d.id,e,null,new Rt(a,l)),n.right.integrate(t,0),n.forward()}}return i},Tm=(t,e,n,r,o)=>{n.currentAttributes.forEach((f,h)=>{o[h]===void 0&&(o[h]=null)});const s=t.doc,i=s.clientID;AD(n,o);const a=_D(t,e,n,o),l=r.constructor===String?new Ir(r):r instanceof Wt?new $r(r):new Oi(r);let{left:c,right:u,index:d}=n;e._searchMarker&&hc(e._searchMarker,n.index,l.getLength()),u=new it(Ue(i,Tt(s.store,i)),c,c&&c.lastId,u,u&&u.id,e,null,l),u.integrate(t,0),n.right=u,n.index=d,n.forward(),CD(t,e,n,a)},xS=(t,e,n,r,o)=>{const s=t.doc,i=s.clientID;AD(n,o);const a=_D(t,e,n,o);e:for(;n.right!==null&&(r>0||a.size>0&&(n.right.deleted||n.right.content.constructor===Rt));){if(!n.right.deleted)switch(n.right.content.constructor){case Rt:{const{key:l,value:c}=n.right.content,u=o[l];if(u!==void 0){if(as(u,c))a.delete(l);else{if(r===0)break e;a.set(l,c)}n.right.delete(t)}else n.currentAttributes.set(l,c);break}default:r<n.right.length&&Nn(t,Ue(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
246
- `;n.right=new it(Ue(i,Tt(s.store,i)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new Ir(l)),n.right.integrate(t,0),n.forward()}CD(t,e,n,a)},MD=(t,e,n,r,o)=>{let s=e;const i=eo();for(;s&&(!s.countable||s.deleted);){if(!s.deleted&&s.content.constructor===Rt){const c=s.content;i.set(c.key,c)}s=s.right}let a=0,l=!1;for(;e!==s;){if(n===e&&(l=!0),!e.deleted){const c=e.content;if(c.constructor===Rt){const{key:u,value:d}=c,f=r.get(u)??null;(i.get(u)!==c||f===d)&&(e.delete(t),a++,!l&&(o.get(u)??null)===d&&f!==d&&(f===null?o.delete(u):o.set(u,f))),!l&&!e.deleted&&Ua(o,c)}}e=e.right}return a},vie=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Rt){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},wie=t=>{let e=0;return ct(t.doc,n=>{let r=t._start,o=t._start,s=eo();const i=Zg(s);for(;o;)o.deleted===!1&&(o.content.constructor===Rt?Ua(i,o.content):(e+=MD(n,r,o,s,i),s=Zg(i),r=o)),o=o.right}),e},xie=t=>{const e=new Set,n=t.doc;for(const[r,o]of t.afterState.entries()){const s=t.beforeState.get(r)||0;o!==s&&uD(t,n.store.clients.get(r),s,o,i=>{!i.deleted&&i.content.constructor===Rt&&i.constructor!==or&&e.add(i.parent)})}ct(n,r=>{xs(t,t.deleteSet,o=>{if(o instanceof or||!o.parent._hasFormatting||e.has(o.parent))return;const s=o.parent;o.content.constructor===Rt?e.add(s):vie(r,o)});for(const o of e)wie(o)})},ES=(t,e,n)=>{const r=n,o=Zg(e.currentAttributes),s=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case $r:case Oi:case Ir:n<e.right.length&&Nn(t,Ue(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}s&&MD(t,s,e.right,o,e.currentAttributes);const i=(e.left||e.right).parent;return i._searchMarker&&hc(i._searchMarker,e.index,-r+n),e};class Eie extends Wh{constructor(e,n,r){super(e,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(o=>{o===null?this.childListChanged=!0:this.keysChanged.add(o)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,n=[];ct(e,r=>{const o=new Map,s=new Map;let i=this.target._start,a=null;const l={};let c="",u=0,d=0;const f=()=>{if(a!==null){let h=null;switch(a){case"delete":d>0&&(h={delete:d}),d=0;break;case"insert":(typeof c=="object"||c.length>0)&&(h={insert:c},o.size>0&&(h.attributes={},o.forEach((p,m)=>{p!==null&&(h.attributes[m]=p)}))),c="";break;case"retain":u>0&&(h={retain:u},Doe(l)||(h.attributes=Noe({},l))),u=0;break}h&&n.push(h),a=null}};for(;i!==null;){switch(i.content.constructor){case $r:case Oi:this.adds(i)?this.deletes(i)||(f(),a="insert",c=i.content.getContent()[0],f()):this.deletes(i)?(a!=="delete"&&(f(),a="delete"),d+=1):i.deleted||(a!=="retain"&&(f(),a="retain"),u+=1);break;case Ir:this.adds(i)?this.deletes(i)||(a!=="insert"&&(f(),a="insert"),c+=i.content.str):this.deletes(i)?(a!=="delete"&&(f(),a="delete"),d+=i.length):i.deleted||(a!=="retain"&&(f(),a="retain"),u+=i.length);break;case Rt:{const{key:h,value:p}=i.content;if(this.adds(i)){if(!this.deletes(i)){const m=o.get(h)??null;as(m,p)?p!==null&&i.delete(r):(a==="retain"&&f(),as(p,s.get(h)??null)?delete l[h]:l[h]=p)}}else if(this.deletes(i)){s.set(h,p);const m=o.get(h)??null;as(m,p)||(a==="retain"&&f(),l[h]=m)}else if(!i.deleted){s.set(h,p);const m=l[h];m!==void 0&&(as(m,p)?m!==null&&i.delete(r):(a==="retain"&&f(),p===null?delete l[h]:l[h]=p))}i.deleted||(a==="insert"&&f(),Ua(o,i.content));break}}i=i.right}for(f();n.length>0;){const h=n[n.length-1];if(h.retain!==void 0&&h.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class Es extends Wt{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??cn(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(r=>r())}catch{}this._pending=null}_copy(){return new Es}clone(){const e=new Es;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new Eie(this,e,n);Gh(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??cn();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Ir&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?ct(this.doc,r=>{const o=new uy(null,this._start,0,new Map);for(let s=0;s<e.length;s++){const i=e[s];if(i.insert!==void 0){const a=!n&&typeof i.insert=="string"&&s===e.length-1&&o.right===null&&i.insert.slice(-1)===`
247
- `?i.insert.slice(0,-1):i.insert;(typeof a!="string"||a.length>0)&&Tm(r,this,o,a,i.attributes||{})}else i.retain!==void 0?xS(r,this,o,i.retain,i.attributes||{}):i.delete!==void 0&&ES(r,o,i.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??cn();const o=[],s=new Map,i=this.doc;let a="",l=this._start;function c(){if(a.length>0){const d={};let f=!1;s.forEach((p,m)=>{f=!0,d[m]=p});const h={insert:a};f&&(h.attributes=d),o.push(h),a=""}}const u=()=>{for(;l!==null;){if(Fs(l,e)||n!==void 0&&Fs(l,n))switch(l.content.constructor){case Ir:{const d=s.get("ychange");e!==void 0&&!Fs(l,e)?(d===void 0||d.user!==l.id.client||d.type!=="removed")&&(c(),s.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!Fs(l,n)?(d===void 0||d.user!==l.id.client||d.type!=="added")&&(c(),s.set("ychange",r?r("added",l.id):{type:"added"})):d!==void 0&&(c(),s.delete("ychange")),a+=l.content.str;break}case $r:case Oi:{c();const d={insert:l.content.getContent()[0]};if(s.size>0){const f={};d.attributes=f,s.forEach((h,p)=>{f[p]=h})}o.push(d);break}case Rt:Fs(l,e)&&(c(),Ua(s,l.content));break}l=l.right}c()};return e||n?ct(i,d=>{e&&ly(d,e),n&&ly(d,n),u()},"cleanup"):u(),o}insert(e,n,r){if(n.length<=0)return;const o=this.doc;o!==null?ct(o,s=>{const i=_u(s,this,e,!r);r||(r={},i.currentAttributes.forEach((a,l)=>{r[l]=a})),Tm(s,this,i,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const o=this.doc;o!==null?ct(o,s=>{const i=_u(s,this,e,!r);Tm(s,this,i,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;const r=this.doc;r!==null?ct(r,o=>{ES(o,_u(o,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const o=this.doc;o!==null?ct(o,s=>{const i=_u(s,this,e,!1);i.right!==null&&xS(s,this,i,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?ct(this.doc,n=>{Cf(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?ct(this.doc,r=>{Qv(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return Zv(this,e)}getAttributes(){return kD(this)}_write(e){e.writeTypeRef(zie)}}const Sie=t=>new Es;class Cm{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??cn()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===ln||n.constructor===yi)&&n._start!==null)e=n._start;else for(;e!==null;){const r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class yi extends Wt{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new yi}clone(){const e=new yi;return e.insert(0,this.toArray().map(n=>n instanceof Wt?n.clone():n)),e}get length(){return this.doc??cn(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Cm(this,e)}querySelector(e){e=e.toUpperCase();const r=new Cm(this,o=>o.nodeName&&o.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),gi(new Cm(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){Gh(this,e,new Cie(this,n,e))}toString(){return vD(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const o=e.createDocumentFragment();return r!==void 0&&r._createAssociation(o,this),pc(this,s=>{o.insertBefore(s.toDOM(e,n,r),null)}),o}insert(e,n){this.doc!==null?ct(this.doc,r=>{ED(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)ct(this.doc,r=>{const o=e&&e instanceof Wt?e._item:e;Tf(r,this,o,n)});else{const r=this._prelimContent,o=e===null?0:r.findIndex(s=>s===e)+1;if(o===0&&e!==null)throw io("Reference item not found");r.splice(o,0,...n)}}delete(e,n=1){this.doc!==null?ct(this.doc,r=>{SD(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return yD(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return wD(this,e)}slice(e=0,n=this.length){return gD(this,e,n)}forEach(e){pc(this,e)}_write(e){e.writeTypeRef(Vie)}}const kie=t=>new yi;class ln extends yi{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((r,o)=>{this.setAttribute(o,r)}),this._prelimAttrs=null}_copy(){return new ln(this.nodeName)}clone(){const e=new ln(this.nodeName),n=this.getAttributes();return Ioe(n,(r,o)=>{e.setAttribute(o,r)}),e.insert(0,this.toArray().map(r=>r instanceof Wt?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const a in e)r.push(a);r.sort();const o=r.length;for(let a=0;a<o;a++){const l=r[a];n.push(l+'="'+e[l]+'"')}const s=this.nodeName.toLocaleLowerCase(),i=n.length>0?" "+n.join(" "):"";return`<${s}${i}>${super.toString()}</${s}>`}removeAttribute(e){this.doc!==null?ct(this.doc,n=>{Cf(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?ct(this.doc,r=>{Qv(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return Zv(this,e)}hasAttribute(e){return TD(this,e)}getAttributes(e){return e?pie(this,e):kD(this)}toDOM(e=document,n={},r){const o=e.createElement(this.nodeName),s=this.getAttributes();for(const i in s){const a=s[i];typeof a=="string"&&o.setAttribute(i,a)}return pc(this,i=>{o.appendChild(i.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(o,this),o}_write(e){e.writeTypeRef(Hie),e.writeKey(this.nodeName)}}const Tie=t=>new ln(t.readKey());class Cie extends Wh{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(o=>{o===null?this.childListChanged=!0:this.attributesChanged.add(o)})}}class Af extends Ta{constructor(e){super(),this.hookName=e}_copy(){return new Af(this.hookName)}clone(){const e=new Af(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const o=n[this.hookName];let s;return o!==void 0?s=o.createDom(this):s=document.createElement(this.hookName),s.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef(Wie),e.writeKey(this.hookName)}}const Aie=t=>new Af(t.readKey());class Fn extends Es{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new Fn}clone(){const e=new Fn;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const o=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(o,this),o}toString(){return this.toDelta().map(e=>{const n=[];for(const o in e.attributes){const s=[];for(const i in e.attributes[o])s.push({key:i,value:e.attributes[o][i]});s.sort((i,a)=>i.key<a.key?-1:1),n.push({nodeName:o,attrs:s})}n.sort((o,s)=>o.nodeName<s.nodeName?-1:1);let r="";for(let o=0;o<n.length;o++){const s=n[o];r+=`<${s.nodeName}`;for(let i=0;i<s.attrs.length;i++){const a=s.attrs[i];r+=` ${a.key}="${a.value}"`}r+=">"}r+=e.insert;for(let o=n.length-1;o>=0;o--)r+=`</${n[o].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(Kie)}}const _ie=t=>new Fn;class e0{constructor(e,n){this.id=e,this.length=n}get deleted(){throw ur()}mergeWith(e){return!1}write(e,n,r){throw ur()}integrate(e,n){throw ur()}}const Mie=0;class or extends e0{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),cD(e.doc.store,this)}write(e,n){e.writeInfo(Mie),e.writeLen(this.length-n)}getMissing(e,n){return null}}class Gc{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Gc(this.content)}splice(e){throw ur()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const Oie=t=>new Gc(t.readBuf());class mc{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new mc(this.len)}splice(e){const n=new mc(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){uc(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const Rie=t=>new mc(t.readLen()),OD=(t,e)=>new Mi({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class qc{constructor(e){e._item,this.doc=e;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new qc(OD(this.doc.guid,this.opts))}splice(e){throw ur()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const Nie=t=>new qc(OD(t.readString(),t.readAny()));class Oi{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Oi(this.embed)}splice(e){throw ur()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const Iie=t=>new Oi(t.readJSON());class Rt{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Rt(this.key,this.value)}splice(e){throw ur()}mergeWith(e){return!1}integrate(e,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const Die=t=>new Rt(t.readKey(),t.readJSON());class _f{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new _f(this.arr)}splice(e){const n=new _f(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let o=n;o<r;o++){const s=this.arr[o];e.writeString(s===void 0?"undefined":JSON.stringify(s))}}getRef(){return 2}}const Pie=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const o=t.readString();o==="undefined"?n.push(void 0):n.push(JSON.parse(o))}return new _f(n)},Lie=wf("node_env")==="development";class bi{constructor(e){this.arr=e,Lie&&RI(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new bi(this.arr)}splice(e){const n=new bi(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let o=n;o<r;o++){const s=this.arr[o];e.writeAny(s)}}getRef(){return 8}}const jie=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new bi(n)};class Ir{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Ir(this.str)}splice(e){const n=new Ir(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const $ie=t=>new Ir(t.readString()),Fie=[gie,bie,Sie,Tie,kie,Aie,_ie],Uie=0,Bie=1,zie=2,Hie=3,Vie=4,Wie=5,Kie=6;class $r{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new $r(this.type._copy())}splice(e){throw ur()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const Gie=t=>new $r(Fie[t.readTypeRef()](t)),dy=(t,e)=>{let n=e,r=0,o;do r>0&&(n=Ue(n.client,n.clock+r)),o=ea(t,n),r=n.clock-o.id.clock,n=o.redone;while(n!==null&&o instanceof it);return{item:o,diff:r}},t0=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},Mf=(t,e,n)=>{const{client:r,clock:o}=e.id,s=new it(Ue(r,o+n),e,Ue(r,o+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&s.markDeleted(),e.keep&&(s.keep=!0),e.redone!==null&&(s.redone=Ue(e.redone.client,e.redone.clock+n)),e.right=s,s.right!==null&&(s.right.left=s),t._mergeStructs.push(s),s.parentSub!==null&&s.right===null&&s.parent._map.set(s.parentSub,s),e.length=n,s},SS=(t,e)=>Iv(t,n=>Fa(n.deletions,e)),RD=(t,e,n,r,o,s)=>{const i=t.doc,a=i.store,l=i.clientID,c=e.redone;if(c!==null)return Nn(t,c);let u=e.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||RD(t,u,n,r,o,s)===null))return null;for(;u.redone!==null;)u=Nn(t,u.redone)}const h=u===null?e.parent:u.content.type;if(e.parentSub===null){for(d=e.left,f=e;d!==null;){let b=d;for(;b!==null&&b.parent._item!==u;)b=b.redone===null?null:Nn(t,b.redone);if(b!==null&&b.parent._item===u){d=b;break}d=d.left}for(;f!==null;){let b=f;for(;b!==null&&b.parent._item!==u;)b=b.redone===null?null:Nn(t,b.redone);if(b!==null&&b.parent._item===u){f=b;break}f=f.right}}else if(f=null,e.right&&!o){for(d=e;d!==null&&d.right!==null&&(d.right.redone||Fa(r,d.right.id)||SS(s.undoStack,d.right.id)||SS(s.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Nn(t,d.redone);if(d&&d.right!==null)return null}else d=h._map.get(e.parentSub)||null;const p=Tt(a,l),m=Ue(l,p),g=new it(m,d,d&&d.lastId,f,f&&f.id,h,e.parentSub,e.content.copy());return e.redone=m,t0(g,!0),g.integrate(t,0),g};class it extends e0{constructor(e,n,r,o,s,i,a,l){super(e,l.getLength()),this.origin=r,this.left=n,this.right=o,this.rightOrigin=s,this.parent=i,this.parentSub=a,this.redone=null,this.content=l,this.info=this.content.isCountable()?XE:0}set marker(e){(this.info&ym)>0!==e&&(this.info^=ym)}get marker(){return(this.info&ym)>0}get keep(){return(this.info&JE)>0}set keep(e){this.keep!==e&&(this.info^=JE)}get countable(){return(this.info&XE)>0}get deleted(){return(this.info&gm)>0}set deleted(e){this.deleted!==e&&(this.info^=gm)}markDeleted(){this.info|=gm}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Tt(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Tt(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Zi&&this.id.client!==this.parent.client&&this.parent.clock>=Tt(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=hS(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Nn(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===or||this.right&&this.right.constructor===or)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===it?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===it&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Zi){const r=ea(n,this.parent);r.constructor===or?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=hS(e,e.doc.store,Ue(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,o;if(r!==null)o=r.right;else if(this.parentSub!==null)for(o=this.parent._map.get(this.parentSub)||null;o!==null&&o.left!==null;)o=o.left;else o=this.parent._start;const s=new Set,i=new Set;for(;o!==null&&o!==this.right;){if(i.add(o),s.add(o),Tu(this.origin,o.origin)){if(o.id.client<this.id.client)r=o,s.clear();else if(Tu(this.rightOrigin,o.rightOrigin))break}else if(o.origin!==null&&i.has(ea(e.doc.store,o.origin)))s.has(ea(e.doc.store,o.origin))||(r=o,s.clear());else break;o=o.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),cD(e.doc.store,this),this.content.integrate(e,this),mS(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new or(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:Ue(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Tu(e.origin,this.lastId)&&this.right===e&&Tu(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),uc(e.deleteSet,this.id.client,this.id.clock,this.length),mS(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw dn();this.content.gc(e),n?Qse(e,this,new or(this.id,this.length)):this.content=new mc(this.length)}write(e,n){const r=n>0?Ue(this.id.client,this.id.clock+n-1):this.origin,o=this.rightOrigin,s=this.parentSub,i=this.content.getRef()&Ph|(r===null?0:vn)|(o===null?0:Ao)|(s===null?0:sc);if(e.writeInfo(i),r!==null&&e.writeLeftID(r),o!==null&&e.writeRightID(o),r===null&&o===null){const a=this.parent;if(a._item!==void 0){const l=a._item;if(l===null){const c=dc(a);e.writeParentInfo(!0),e.writeString(c)}else e.writeParentInfo(!1),e.writeLeftID(l.id)}else a.constructor===String?(e.writeParentInfo(!0),e.writeString(a)):a.constructor===Zi?(e.writeParentInfo(!1),e.writeLeftID(a)):dn();s!==null&&e.writeString(s)}this.content.write(e,n)}}const ND=(t,e)=>qie[e&Ph](t),qie=[()=>{dn()},Rie,Pie,Oie,$ie,Iie,Die,Gie,jie,Nie,()=>{dn()}],Yie=10;class kr extends e0{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){dn()}write(e,n){e.writeInfo(Yie),Xe(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const ID=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},DD="__ $YJS$ __";ID[DD];ID[DD]=!0;const Jie=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},Xie=/[\uD800-\uDBFF]/,Qie=/[\uDC00-\uDFFF]/,Zie=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&Xie.test(t[n-1])&&n--;r+n<t.length&&r+n<e.length&&t[t.length-r-1]===e[e.length-r-1];)r++;return r>0&&Qie.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},eae=Zie,to=(t,e)=>t>>>e|t<<32-e,tae=t=>to(t,2)^to(t,13)^to(t,22),nae=t=>to(t,6)^to(t,11)^to(t,25),rae=t=>to(t,7)^to(t,18)^t>>>3,oae=t=>to(t,17)^to(t,19)^t>>>10,sae=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),iae=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class aae{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(iae),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let d=16;d<64;d++)n[d]=oae(n[d-2])+n[d-7]+rae(n[d-15])+n[d-16];let r=e[0],o=e[1],s=e[2],i=e[3],a=e[4],l=e[5],c=e[6],u=e[7];for(let d=0,f,h;d<64;d++)f=u+nae(a)+(a&l^~a&c)+sae[d]+n[d]>>>0,h=tae(r)+(r&o^r&s^o&s)>>>0,u=c,c=l,l=a,a=i+f>>>0,i=s,s=o,o=r,r=f+h>>>0;e[0]+=r,e[1]+=o,e[2]+=s,e[3]+=i,e[4]+=a,e[5]+=l,e[6]+=c,e[7]+=u}digest(e){let n=0;for(;n+56<=e.length;){let i=0;for(;i<16&&n+3<e.length;i++)this._W[i]=e[n++]<<24|e[n++]<<16|e[n++]<<8|e[n++];if(n%64!==0){for(this._W.fill(0,i,16);n<e.length;)this._W[i]|=e[n]<<(3-n%4)*8,n++;this._W[i]|=vn<<(3-n%4)*8}this._updateHash()}const r=n%64!==0;this._W.fill(0,0,16);let o=0;for(;n<e.length;o++)for(let i=3;i>=0&&n<e.length;i--)this._W[o]|=e[n++]<<i*8;r||(this._W[o-(n%4===0?0:1)]|=vn<<(3-n%4)*8),this._W[14]=e.byteLength/Wre,this._W[15]=e.byteLength*8,this._updateHash();const s=new Uint8Array(32);for(let i=0;i<this._H.length;i++)for(let a=0;a<4;a++)s[i*4+a]=this._H[i]>>>(3-a)*8;return s}}const lae=t=>new aae().digest(t),xt=new Je("y-sync"),_o=new Je("y-undo");new Je("yjs-cursor");const cae=t=>{for(let n=6;n<t.length;n++)t[n%6]=t[n%6]^t[n];return t.slice(0,6)},uae=t=>Hoe(cae(lae(Voe(t)))),Of=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!Fa(e.ds,t.id),dae=[{light:"#ecd44433",dark:"#ecd444"}],fae=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=mi();t.forEach(o=>r.add(o)),e=e.filter(o=>!r.has(o))}t.set(n,koe(e))}return t.get(n)},hae=(t,{colors:e=dae,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:o=()=>{},mapping:s}={})=>{let i=!1;const a=new gae(t,s),l=new Ye({props:{editable:c=>{const u=xt.getState(c);return u.snapshot==null&&u.prevSnapshot==null}},key:xt,state:{init:(c,u)=>({type:t,doc:t.doc,binding:a,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(c,u)=>{const d=c.getMeta(xt);if(d!==void 0){u=Object.assign({},u);for(const f in d)u[f]=d[f]}return u.addToHistory=c.getMeta("addToHistory")!==!1,u.isChangeOrigin=d!==void 0&&!!d.isChangeOrigin,u.isUndoRedoOperation=d!==void 0&&!!d.isChangeOrigin&&!!d.isUndoRedoOperation,a.prosemirrorView!==null&&d!==void 0&&(d.snapshot!=null||d.prevSnapshot!=null)&&JI(0,()=>{a.prosemirrorView!=null&&(d.restore==null?a._renderSnapshot(d.snapshot,d.prevSnapshot,u):(a._renderSnapshot(d.snapshot,d.snapshot,u),delete u.restore,delete u.snapshot,delete u.prevSnapshot,a.mux(()=>{a._prosemirrorChanged(a.prosemirrorView.state.doc)})))}),u}},view:c=>(a.initView(c),s==null&&a._forceRerender(),o(),{update:()=>{const u=l.getState(c.state);if(u.snapshot==null&&u.prevSnapshot==null&&(i||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(i=!0,u.addToHistory===!1&&!u.isChangeOrigin){const d=_o.getState(c.state),f=d&&d.undoManager;f&&f.stopCapturing()}a.mux(()=>{u.doc.transact(d=>{d.meta.set("addToHistory",u.addToHistory),a._prosemirrorChanged(c.state.doc)},xt)})}},destroy:()=>{a.destroy()}})});return l},pae=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new Pn(t.doc));else if(e.type==="node"){const r=Pl(n.doc,n.type,e.anchor,n.mapping);t.setSelection(mae(t,r))}else{const r=Pl(n.doc,n.type,e.anchor,n.mapping),o=Pl(n.doc,n.type,e.head,n.mapping);r!==null&&o!==null&&t.setSelection(we.between(t.doc.resolve(r),t.doc.resolve(o)))}},mae=(t,e)=>{const n=t.doc.resolve(e);return n.nodeAfter?me.create(t.doc,e):we.near(n)},fy=(t,e)=>({type:e.selection.jsonID,anchor:Nf(e.selection.anchor,t.type,t.mapping),head:Nf(e.selection.head,t.type,t.mapping)});class gae{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=Jie(),this.mapping=n,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=fy(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(NI&&this._domSelectionInView===null&&(JI(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;const n=this.prosemirrorView._root.createRange();n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const o=n.getBoundingClientRect(),s=Kc.documentElement;return o.bottom>=0&&o.right>=0&&o.left<=(window.innerWidth||s.clientWidth||0)&&o.top<=(window.innerHeight||s.clientHeight||0)}renderSnapshot(e,n){n||(n=aD(rD(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(xt,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>ed(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ie(X.from(e),0,0));n.setMeta(xt,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(o=>ed(o,this.prosemirrorView.state.schema,this)).filter(o=>o!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ie(X.from(n),0,0));if(e){const o=xa(ws(e.anchor,0),r.doc.content.size),s=xa(ws(e.head,0),r.doc.content.size);r.setSelection(we.create(r.doc,o,s))}this.prosemirrorView.dispatch(r.setMeta(xt,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let o=this.doc,s=this.type;if(e||(e=km(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&dn(),o=new Mi({gc:!1}),ay(o,n),n=km(o),ay(o,e),e=km(o),s._item===null){const i=Array.from(this.doc.share.keys()).find(a=>this.doc.share.get(a)===this.type);s=o.getXmlFragment(i)}else{const i=o.store.clients.get(s._item.id.client)??[],a=Nr(i,s._item.id.clock);s=i[a].content.type}this.mapping.clear(),this.mux(()=>{o.transact(i=>{const a=r.permanentUserData;a&&a.dss.forEach(d=>{xs(i,d,f=>{})});const l=(d,f)=>{const h=d==="added"?a.getUserByClientId(f.client):a.getUserByDeletedId(f);return{user:h,type:d,color:fae(r.colorMapping,r.colors,h)}},c=bD(s,new Jv(n.ds,e.sv)).map(d=>!d._item.deleted||Of(d._item,e)||Of(d._item,n)?ed(d,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,n,l):null).filter(d=>d!==null),u=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ie(X.from(c),0,0));this.prosemirrorView.dispatch(u.setMeta(xt,{isChangeOrigin:!0}))},xt)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=xt.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const o=(a,l)=>this.mapping.delete(l);xs(n,n.deleteSet,a=>{if(a.constructor===it){const l=a.content.type;l&&this.mapping.delete(l)}}),n.changed.forEach(o),n.changedParentTypes.forEach(o);const s=this.type.toArray().map(a=>PD(a,this.prosemirrorView.state.schema,this)).filter(a=>a!==null);let i=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new ie(X.from(s),0,0));pae(i,this.beforeTransactionSelection,this),i=i.setMeta(xt,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof fD}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&i.scrollIntoView(),this.prosemirrorView.dispatch(i)})}_prosemirrorChanged(e){this.doc.transact(()=>{py(this.doc,this.type,e,this),this.beforeTransactionSelection=fy(this,this.prosemirrorView.state)},xt)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const PD=(t,e,n,r,o,s)=>{const i=n.mapping.get(t);if(i===void 0){if(t instanceof ln)return ed(t,e,n,r,o,s);throw ur()}return i},ed=(t,e,n,r,o,s)=>{const i=[],a=l=>{if(l instanceof ln){const c=PD(l,e,n,r,o,s);c!==null&&i.push(c)}else{const c=l._item.right?.content?.type;c instanceof Es&&!c._item.deleted&&c._item.id.client===c.doc.clientID&&(l.applyDelta([{retain:l.length},...c.toDelta()]),c.doc.transact(d=>{c._item.delete(d)}));const u=yae(l,e,n,r,o,s);u!==null&&u.forEach(d=>{d!==null&&i.push(d)})}};r===void 0||o===void 0?t.toArray().forEach(a):bD(t,new Jv(o.ds,r.sv)).forEach(a);try{const l=t.getAttributes(r);r!==void 0&&(Of(t._item,r)?Of(t._item,o)||(l.ychange=s?s("added",t._item.id):{type:"added"}):l.ychange=s?s("removed",t._item.id):{type:"removed"});const c=e.node(t.nodeName,l,i);return n.mapping.set(t,c),c}catch{return t.doc.transact(c=>{t._item.delete(c)},xt),n.mapping.delete(t),null}},yae=(t,e,n,r,o,s)=>{const i=[],a=t.toDelta(r,o,s);try{for(let l=0;l<a.length;l++){const c=a[l];i.push(e.text(c.insert,Sae(c.attributes,e)))}}catch{return t.doc.transact(c=>{t._item.delete(c)},xt),null}return i},bae=(t,e)=>{const n=new Fn,r=t.map(o=>({insert:o.text,attributes:jD(o.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},vae=(t,e)=>{const n=new ln(t.type.name);for(const r in t.attrs){const o=t.attrs[r];o!==null&&r!=="ychange"&&n.setAttribute(r,o)}return n.insert(0,qh(t).map(r=>hy(r,e))),e.mapping.set(n,t),n},hy=(t,e)=>t instanceof Array?bae(t,e):vae(t,e),kS=t=>typeof t=="object"&&t!==null,n0=(t,e)=>{const n=Object.keys(t).filter(o=>t[o]!==null);let r=n.length===Object.keys(e).filter(o=>e[o]!==null).length;for(let o=0;o<n.length&&r;o++){const s=n[o],i=t[s],a=e[s];r=s==="ychange"||i===a||kS(i)&&kS(a)&&n0(i,a)}return r},qh=t=>{const e=t.content.content,n=[];for(let r=0;r<e.length;r++){const o=e[r];if(o.isText){const s=[];for(let i=e[r];r<e.length&&i.isText;i=e[++r])s.push(i);r--,n.push(s)}else n.push(o)}return n},LD=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,o)=>r.insert===e[o].text&&OI(r.attributes||{}).length===e[o].marks.length&&La(r.attributes,(s,i)=>{const a=r0(i),l=e[o].marks;return l.find(u=>u.type.name===a)?n0(s,l.find(u=>u.type.name===a)?.attrs):!1}))},gc=(t,e)=>{if(t instanceof ln&&!(e instanceof Array)&&my(t,e)){const n=qh(e);return t._length===n.length&&n0(t.getAttributes(),e.attrs)&&t.toArray().every((r,o)=>gc(r,n[o]))}return t instanceof Fn&&e instanceof Array&&LD(t,e)},Rf=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),TS=(t,e,n)=>{const r=t.toArray(),o=qh(e),s=o.length,i=r.length,a=xa(i,s);let l=0,c=0,u=!1;for(;l<a;l++){const d=r[l],f=o[l];if(Rf(n.mapping.get(d),f))u=!0;else if(!gc(d,f))break}for(;l+c<a;c++){const d=r[i-c-1],f=o[s-c-1];if(Rf(n.mapping.get(d),f))u=!0;else if(!gc(d,f))break}return{equalityFactor:l+c,foundMappedChild:u}},wae=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Ir?e+=n.content.str:n.content instanceof Rt&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},xae=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:o}=wae(t),s=e.map(c=>({insert:c.text,attributes:Object.assign({},r,jD(c.marks,n))})),{insert:i,remove:a,index:l}=eae(o,s.map(c=>c.insert).join(""));t.delete(l,a),t.insert(l,i),t.applyDelta(s.map(c=>({retain:c.insert.length,attributes:c.attributes})))},Eae=/(.*)(--[a-zA-Z0-9+/=]{8})$/,r0=t=>Eae.exec(t)?.[1]??t,Sae=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(r0(r),t[r]));return n},jD=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const o=Bo(e.isOMark,r.type,()=>!r.type.excludes(r.type));n[o?`${r.type.name}--${uae(r.toJSON())}`:r.type.name]=r.attrs}}),n},py=(t,e,n,r)=>{if(e instanceof ln&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof ln){const d=e.getAttributes(),f=n.attrs;for(const h in f)f[h]!==null?d[h]!==f[h]&&h!=="ychange"&&e.setAttribute(h,f[h]):e.removeAttribute(h);for(const h in d)f[h]===void 0&&e.removeAttribute(h)}const o=qh(n),s=o.length,i=e.toArray(),a=i.length,l=xa(s,a);let c=0,u=0;for(;c<l;c++){const d=i[c],f=o[c];if(!Rf(r.mapping.get(d),f))if(gc(d,f))r.mapping.set(d,f);else break}for(;u+c+1<l;u++){const d=i[a-u-1],f=o[s-u-1];if(!Rf(r.mapping.get(d),f))if(gc(d,f))r.mapping.set(d,f);else break}t.transact(()=>{for(;a-c-u>0&&s-c-u>0;){const f=i[c],h=o[c],p=i[a-u-1],m=o[s-u-1];if(f instanceof Fn&&h instanceof Array)LD(f,h)||xae(f,h,r),c+=1;else{let g=f instanceof ln&&my(f,h),b=p instanceof ln&&my(p,m);if(g&&b){const S=TS(f,h,r),k=TS(p,m,r);S.foundMappedChild&&!k.foundMappedChild?b=!1:!S.foundMappedChild&&k.foundMappedChild||S.equalityFactor<k.equalityFactor?g=!1:b=!1}g?(py(t,f,h,r),c+=1):b?(py(t,p,m,r),u+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[hy(h,r)]),c+=1)}}const d=a-c-u;if(a===1&&s===0&&i[0]instanceof Fn?(r.mapping.delete(i[0]),i[0].delete(0,i[0].length)):d>0&&(e.slice(c,c+d).forEach(f=>r.mapping.delete(f)),e.delete(c,d)),c+u<s){const f=[];for(let h=c;h<s-u;h++)f.push(hy(o[h],r));e.insert(c,f)}},xt)},my=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name,Nf=(t,e,n)=>{if(t===0)return Sm(e,0,-1);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof Fn){if(r._length>=t)return Sm(r,t,-1);if(t-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,t--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const o=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t<o)r=r._first.content.type,t--;else{if(t===1&&r._length===0&&o>1)return new kf(r._item===null?null:r._item.id,r._item===null?dc(r):null,null);if(t-=o,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(t===0)return r=r._item===null?r:r._item.parent,new kf(r._item===null?null:r._item.id,r._item===null?dc(r):null,null);do r=r._item.parent,t--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw dn();if(t===0&&r.constructor!==Fn&&r!==e)return kae(r._item.parent,r._item)}return Sm(e,e._length,-1)},kae=(t,e)=>{let n=null,r=null;return t._item===null?r=dc(t):n=Ue(t._item.id.client,t._item.id.clock),new kf(n,r,e.id)},Pl=(t,e,n,r)=>{const o=Jse(n,t);if(o===null||o.type!==e&&!fc(e,o.type._item))return null;let s=o.type,i=0;if(s.constructor===Fn)i=o.index;else if(s._item===null||!s._item.deleted){let a=s._first,l=0;for(;l<s._length&&l<o.index&&a!==null;){if(!a.deleted){const c=a.content.type;l++,c instanceof Fn?i+=c._length:i+=r.get(c).nodeSize}a=a.right}i+=1}for(;s!==e&&s._item!==null;){const a=s._item.parent;if(a._item===null||!a._item.deleted){i+=1;let l=a._first;for(;l!==null;){const c=l.content.type;if(c===s)break;l.deleted||(c instanceof Fn?i+=c._length:i+=r.get(c).nodeSize),l=l.right}}s=a}return i-1};function Tae(t){const e=t.toArray(),n=r=>{let o;if(r instanceof Fn)o=r.toDelta().map(i=>{const a={type:"text",text:i.insert};return i.attributes&&(a.marks=Object.keys(i.attributes).map(l=>{const c=i.attributes[l],d={type:r0(l)};return Object.keys(c)&&(d.attrs=c),d})),a});else if(r instanceof ln){o={type:r.nodeName};const s=r.getAttributes();Object.keys(s).length&&(o.attrs=s);const i=r.toArray();i.length&&(o.content=i.map(n).flat())}else dn();return o};return{type:"doc",content:e.map(n)}}const Cae=t=>{const e=_o.getState(t).undoManager;if(e!=null)return e.undo(),!0},Aae=t=>{const e=_o.getState(t).undoManager;if(e!=null)return e.redo(),!0},_ae=new Set(["paragraph"]),Mae=(t,e)=>!(t instanceof it)||!(t.content instanceof $r)||!(t.content.type instanceof Es||t.content.type instanceof ln&&e.has(t.content.type.nodeName))||t.content.type._length===0,Oae=({protectedNodes:t=_ae,trackedOrigins:e=[],undoManager:n=null}={})=>new Ye({key:_o,state:{init:(r,o)=>{const s=xt.getState(o),i=n||new fD(s.type,{trackedOrigins:new Set([xt].concat(e)),deleteFilter:a=>Mae(a,t),captureTransaction:a=>a.meta.get("addToHistory")!==!1});return{undoManager:i,prevSel:null,hasUndoOps:i.undoStack.length>0,hasRedoOps:i.redoStack.length>0}},apply:(r,o,s,i)=>{const a=xt.getState(i).binding,l=o.undoManager,c=l.undoStack.length>0,u=l.redoStack.length>0;return a?{undoManager:l,prevSel:fy(a,s),hasUndoOps:c,hasRedoOps:u}:c!==o.hasUndoOps||u!==o.hasRedoOps?Object.assign({},o,{hasUndoOps:l.undoStack.length>0,hasRedoOps:l.redoStack.length>0}):o}},view:r=>{const o=xt.getState(r.state),s=_o.getState(r.state).undoManager;return s.on("stack-item-added",({stackItem:i})=>{const a=o.binding;a&&i.meta.set(a,_o.getState(r.state).prevSel)}),s.on("stack-item-popped",({stackItem:i})=>{const a=o.binding;a&&(a.beforeTransactionSelection=i.meta.get(a)||a.beforeTransactionSelection)}),{destroy:()=>{s.destroy()}}}});function $D(t){return!!t.getMeta(xt)}function Rae(t,e){const n=xt.getState(t);return Pl(n.doc,n.type,e,n.binding.mapping)||0}function FD(t,e){const n=xt.getState(t);return Nf(e,n.type,n.binding.mapping)}var td=class UD extends Zy{constructor(e,n){super(e),this.yRelativePosition=n}static fromJSON(e){return new UD(e.position,e.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function Nae(t,e){const n=FD(e,t);return new td(t,n)}function Iae(t,e,n){const r=t instanceof td?t.yRelativePosition:null;if($D(e)&&r){const i=Rae(n,r);return{position:new td(i,r),mapResult:null}}const o=SC(t,e),s=o.position.position;return{position:new td(s,r??FD(n,s)),mapResult:o.mapResult}}at.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(t=>t.name==="undoRedo")},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(t,e)=>Iae(t,e,this.editor.state),this.editor.utils.createMappablePosition=t=>Nae(t,this.editor.state)},addCommands(){return{undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),_o.getState(e).undoManager.undoStack.length===0?!1:n?Cae(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),_o.getState(e).undoManager.redoStack.length===0?!1:n?Aae(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){var t;const e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),n=Oae(this.options.yUndoOptions),r=n.spec.view;n.spec.view=i=>{const{undoManager:a}=_o.getState(i.state);a.restore&&(a.restore(),a.restore=()=>{});const l=r?r(i):void 0;return{destroy:()=>{const c=a.trackedOrigins.has(a),u=a._observers;a.restore=()=>{c&&a.trackedOrigins.add(a),a.doc.on("afterTransaction",a.afterTransactionHandler),a._observers=u},l?.destroy&&l.destroy()}}};const o={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender},s=hae(e,o);return this.editor.options.enableContentCheck&&((t=e.doc)==null||t.on("beforeTransaction",()=>{try{const i=Tae(e);if(i.content.length===0)return;this.editor.schema.nodeFromJSON(i).check()}catch(i){return this.editor.emit("contentError",{error:i,editor:this.editor,disableCollaboration:()=>{var a;(a=e.doc)==null||a.destroy(),this.storage.isDisabled=!0}}),!1}})),[s,n,this.editor.options.enableContentCheck&&new Ye({key:new Je("filterInvalidContent"),filterTransaction:()=>{var i;return this.storage.isDisabled!==!1&&((i=e.doc)==null||i.destroy()),!0}})].filter(Boolean)}});function CS(t){if(!t.length)return ft.empty;const e=[],n=t[0].$from.node(0);return t.forEach(r=>{const o=r.$from.pos,s=r.$from.nodeAfter;s&&e.push(tn.node(o,o+s.nodeSize,{class:"ProseMirror-selectednoderange"}))}),ft.create(n,e)}function Yh(t,e,n){const r=[],o=t.node(0);typeof n=="number"&&n>=0||(t.sameParent(e)?n=Math.max(0,t.sharedDepth(e.pos)-1):n=t.sharedDepth(e.pos));const s=new $l(t,e,n),i=s.depth===0?0:o.resolve(s.start).posAtIndex(0);return s.parent.forEach((a,l)=>{const c=i+l,u=c+a.nodeSize;if(c<s.start||c>=s.end)return;const d=new cT(o.resolve(c),o.resolve(u));r.push(d)}),r}var Dae=class BD{constructor(e,n){this.anchor=e,this.head=n}map(e){return new BD(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return new ls(n,r)}},ls=class Jo extends Re{constructor(e,n,r,o=1){const{doc:s}=e,i=e===n,a=e.pos===s.content.size&&n.pos===s.content.size,l=i&&!a?s.resolve(n.pos+(o>0?1:-1)):n,c=i&&a?s.resolve(e.pos-(o>0?1:-1)):e,u=Yh(c.min(l),c.max(l),r),d=l.pos>=e.pos?u[0].$from:u[u.length-1].$to,f=l.pos>=e.pos?u[u.length-1].$to:u[0].$from;super(d,f,u),this.depth=r}get $to(){return this.ranges[this.ranges.length-1].$to}eq(e){return e instanceof Jo&&e.$from.pos===this.$from.pos&&e.$to.pos===this.$to.pos}map(e,n){const r=e.resolve(n.map(this.anchor)),o=e.resolve(n.map(this.head));return new Jo(r,o)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:e}=this.$from;if(this.isForwards&&this.ranges.length>1){const o=this.ranges.slice(0,-1),s=o[0].$from,i=o[o.length-1].$to;return new Jo(s,i,this.depth)}const n=this.ranges[0],r=e.resolve(Math.max(0,n.$from.pos-1));return new Jo(this.$anchor,r,this.depth)}extendForwards(){const{doc:e}=this.$from;if(this.isBackwards&&this.ranges.length>1){const o=this.ranges.slice(1),s=o[0].$from,i=o[o.length-1].$to;return new Jo(i,s,this.depth)}const n=this.ranges[this.ranges.length-1],r=e.resolve(Math.min(e.content.size,n.$to.pos+1));return new Jo(this.$anchor,r,this.depth)}static fromJSON(e,n){return new Jo(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r,o,s=1){return new this(e.resolve(n),e.resolve(r),o,s)}getBookmark(){return new Dae(this.anchor,this.head)}};ls.prototype.visible=!1;function Mu(t){return t instanceof ls}at.create({name:"nodeRange",addOptions(){return{depth:void 0,key:"Mod"}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:o,selection:s,tr:i}=r,{anchor:a,head:l}=s;if(!Mu(s)){const u=ls.create(o,a,l,e,-1);return i.setSelection(u),n.dispatch(i),!0}const c=s.extendBackwards();return i.setSelection(c),n.dispatch(i),!0},"Shift-ArrowDown":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:o,selection:s,tr:i}=r,{anchor:a,head:l}=s;if(!Mu(s)){const u=ls.create(o,a,l,e);return i.setSelection(u),n.dispatch(i),!0}const c=s.extendForwards();return i.setSelection(c),n.dispatch(i),!0},"Mod-a":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:o,tr:s}=r,i=ls.create(o,0,o.content.size,e);return s.setSelection(i),n.dispatch(s),!0}}},onSelectionUpdate(){const{selection:t}=this.editor.state;Mu(t)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let t=!1,e=!1;return[new Ye({key:new Je("nodeRange"),props:{attributes:()=>t?{class:"ProseMirror-noderangeselection"}:{class:""},handleDOMEvents:{mousedown:(n,r)=>{const{key:o}=this.options,s=/Mac/.test(navigator.platform),i=!!r.shiftKey,a=!!r.ctrlKey,l=!!r.altKey,c=!!r.metaKey,u=s?c:a;return(o==null||o==="Shift"&&i||o==="Control"&&a||o==="Alt"&&l||o==="Meta"&&c||o==="Mod"&&u)&&(e=!0),e&&document.addEventListener("mouseup",()=>{e=!1;const{state:d}=n,{doc:f,selection:h,tr:p}=d,{$anchor:m,$head:g}=h;if(m.sameParent(g))return;const b=ls.create(f,m.pos,g.pos,this.options.depth);p.setSelection(b),n.dispatch(p)},{once:!0}),!1}},decorations:n=>{const{selection:r}=n,o=Mu(r);if(t=!1,!e)return o?(t=!0,CS(r.ranges)):null;const{$from:s,$to:i}=r;if(!o&&s.sameParent(i))return null;const a=Yh(s,i,this.options.depth);return a.length?(t=!0,CS(a)):null}}})]}});function Pae(t){let e="";const n=getComputedStyle(t);for(let r=0;r<n.length;r+=1)e+=`${n[r]}:${n.getPropertyValue(n[r])};`;return e}function Lae(t){const e=t.cloneNode(!0),n=[t,...Array.from(t.getElementsByTagName("*"))],r=[e,...Array.from(e.getElementsByTagName("*"))];return n.forEach((o,s)=>{r[s].style.cssText=Pae(o)}),e}var jae={id:"listItemFirstChild",evaluate:({parent:t,isFirst:e})=>e&&t&&["listItem","taskItem"].includes(t.type.name)?1e3:0},$ae={id:"listWrapperDeprioritize",evaluate:({node:t})=>{const e=["listItem","taskItem"],n=t.firstChild;return n&&e.includes(n.type.name)?1e3:0}},Fae={id:"tableStructure",evaluate:({node:t,parent:e})=>["tableRow","tableCell","tableHeader"].includes(t.type.name)||e&&e.type.name==="tableHeader"?1e3:0},Uae={id:"inlineContent",evaluate:({node:t})=>t.isInline||t.isText?1e3:0},Bae=[jae,$ae,Fae,Uae],AS={edges:["left","top"],threshold:12,strength:500};function Am(t){return t===void 0||t==="left"?{...AS}:t==="right"?{edges:["right","top"],threshold:12,strength:500}:t==="both"?{edges:["left","right","top"],threshold:12,strength:500}:t==="none"?{edges:[],threshold:0,strength:0}:{...AS,...t}}function zae(t,e,n){if(n.edges.length===0)return!1;const r=e.getBoundingClientRect(),{threshold:o,edges:s}=n;return s.some(i=>i==="left"?t.x-r.left<o:i==="right"?r.right-t.x<o:i==="top"?t.y-r.top<o:i==="bottom"?r.bottom-t.y<o:!1)}function Hae(t,e,n,r){return!e||n.edges.length===0?0:zae(t,e,n)?n.strength*r:0}var Vae=1e3;function _S(t,e,n,r){let o=Vae,s=!1;if(e.every(a=>{const l=a.evaluate(t);return o-=l,o<=0?(s=!0,!1):!0}),s)return-1;const i=t.view.nodeDOM(t.pos);return o-=Hae(r,i,n,t.depth),o<=0?-1:o}function MS(t,e,n){return Array.from({length:e},(o,s)=>e-1-s).some(o=>n.includes(t.node(o).type.name))}function Wae(t,e,n){if(!Number.isFinite(e.x)||!Number.isFinite(e.y))return null;const r=t.posAtCoords({left:e.x,top:e.y});if(!r)return null;const{doc:o}=t.state,s=o.resolve(r.pos),i=[];n.defaultRules&&i.push(...Bae),i.push(...n.rules);const l=Array.from({length:s.depth},(d,f)=>s.depth-f).map(d=>{const f=s.node(d),h=s.before(d);if(n.allowedContainers&&d>0&&!MS(s,d,n.allowedContainers))return null;const p=d>0?s.node(d-1):null,m=d>0?s.index(d-1):0,g=p?p.childCount:1,b={node:f,pos:h,depth:d,parent:p,index:m,isFirst:m===0,isLast:m===g-1,$pos:s,view:t},S=_S(b,i,n.edgeDetection,e);if(S<0)return null;const k=t.nodeDOM(h);return{node:f,pos:h,depth:d,score:S,dom:k}}).filter(d=>d!==null),c=s.nodeAfter;if(c&&c.isAtom&&!c.isInline){const d=r.pos,f=s.depth+1,h=s.parent,p=s.index(),m=h.childCount;let g=!0;if(n.allowedContainers&&(g=MS(s,f,n.allowedContainers)),g){const b={node:c,pos:d,depth:f,parent:h,index:p,isFirst:p===0,isLast:p===m-1,$pos:s,view:t},S=_S(b,i,n.edgeDetection,e);if(S>=0){const k=t.nodeDOM(d);k&&l.push({node:c,pos:d,depth:f,score:S,dom:k})}}}if(l.length===0)return null;l.sort((d,f)=>f.score!==d.score?f.score-d.score:f.depth-d.depth);const u=l[0];return u.dom?{node:u.node,pos:u.pos,dom:u.dom}:null}function Kae(t,e){let n=t;for(;n?.parentElement&&n.parentElement!==e.dom;)n=n.parentElement;return n?.parentElement===e.dom?n:void 0}function OS(t){return Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)&&t.width>0&&t.height>0}function Gae(t,e,n,r=5){if(!Number.isFinite(e)||!Number.isFinite(n))return null;const o=t.dom,s=o.firstElementChild,i=o.lastElementChild;if(!s||!i)return null;const a=s.getBoundingClientRect(),l=i.getBoundingClientRect();if(!OS(a)||!OS(l))return null;const c=Math.min(Math.max(a.top+r,n),l.bottom-r),u=.5,d=Math.abs(a.left-l.left)<u,f=Math.abs(a.right-l.right)<u;let h=a;d&&f&&(h=a);const p=Math.min(Math.max(h.left+r,e),h.right-r);return!Number.isFinite(p)||!Number.isFinite(c)?null:{x:p,y:c}}var zD=t=>{const{x:e,y:n,editor:r,nestedOptions:o}=t,{view:s,state:i}=r,a=Gae(s,e,n,5);if(!a)return{resultElement:null,resultNode:null,pos:null};const{x:l,y:c}=a;if(o?.enabled){const p=Wae(s,{x:l,y:c},o);return p?{resultElement:p.dom,resultNode:p.node,pos:p.pos}:{resultElement:null,resultNode:null,pos:null}}const u=s.root.elementsFromPoint(l,c);let d;if(Array.prototype.some.call(u,p=>{if(!s.dom.contains(p))return!1;const m=Kae(p,s);return m?(d=m,!0):!1}),!d)return{resultElement:null,resultNode:null,pos:null};let f;try{f=s.posAtDOM(d,0)}catch{return{resultElement:null,resultNode:null,pos:null}}const h=i.doc.nodeAt(f);if(!h){const p=i.doc.resolve(f),m=p.parent;return{resultElement:d,resultNode:m,pos:p.start()}}return{resultElement:d,resultNode:h,pos:f}};function HD(t){var e;(e=t.parentNode)==null||e.removeChild(t)}function qae(t,e,n,r){const{doc:o}=e.view.state;if(n?.enabled&&r?.node&&r.pos>=0){const c=r.pos,u=r.pos+r.node.nodeSize;return[{$from:o.resolve(c),$to:o.resolve(u)}]}const s=zD({editor:e,x:t.clientX,y:t.clientY,nestedOptions:n});if(!s.resultNode||s.pos===null)return[];const i=s.resultNode.isText||s.resultNode.isAtom?0:-1,a=o.resolve(s.pos),l=o.resolve(s.pos+s.resultNode.nodeSize+i);return Yh(a,l,0)}function Yae(t,e,n,r){const{view:o}=e;if(!t.dataTransfer)return;const{empty:s,$from:i,$to:a}=o.state.selection,l=qae(t,e,n,r),c=Yh(i,a,0),u=c.some(v=>l.find(_=>_.$from===v.$from&&_.$to===v.$to)),d=s||!u?l:c;if(!d.length)return;const{tr:f}=o.state,h=document.createElement("div"),p=d[0].$from.pos,m=d[d.length-1].$to.pos,g=n?.enabled&&r?.node;let b,S;g?(b=o.state.doc.slice(p,m),S=me.create(o.state.doc,p)):(S=ls.create(o.state.doc,p,m),b=S.content()),d.forEach(v=>{const _=o.nodeDOM(v.$from.pos),x=Lae(_);h.append(x)}),h.style.position="absolute",h.style.top="-10000px",document.body.append(h),t.dataTransfer.clearData(),t.dataTransfer.setDragImage(h,0,0);const k=S instanceof me?S:void 0;o.dragging={slice:b,move:!0,node:k},f.setSelection(S),o.dispatch(f),document.addEventListener("drop",()=>HD(h),{once:!0})}var RS=(t,e)=>{const n=t.resolve(e),{depth:r}=n;return r===0?e:n.pos-n.parentOffset-1},NS=(t,e)=>{const n=t.nodeAt(e),r=t.resolve(e);let{depth:o}=r,s=n;for(;o>0;){const i=r.node(o);o-=1,o===0&&(s=i)}return s},_m=(t,e)=>{const n=xt.getState(t);return n?Nf(e,n.type,n.binding.mapping):null},Jae=(t,e)=>{const n=xt.getState(t);return n?Pl(n.doc,n.type,e,n.binding.mapping)||0:-1},IS=(t,e)=>{let n=e;for(;n?.parentNode&&n.parentNode!==t.dom;)n=n.parentNode;return n},VD=new Je("dragHandle"),WD=({pluginKey:t=VD,element:e,editor:n,computePositionConfig:r,getReferencedVirtualElement:o,onNodeChange:s,onElementDragStart:i,onElementDragEnd:a,nestedOptions:l})=>{const c=document.createElement("div");let u=!1,d=null,f=-1,h,p=null,m=null;function g(){e&&(e.style.visibility="hidden",e.style.pointerEvents="none")}function b(){if(e){if(!n.isEditable){g();return}e.style.visibility="",e.style.pointerEvents="auto"}}function S(x){const A=o?.()||{getBoundingClientRect:()=>x.getBoundingClientRect()};JA(A,e,r).then(E=>{Object.assign(e.style,{position:E.strategy,left:`${E.x}px`,top:`${E.y}px`})})}function k(x){i?.(x),Yae(x,n,l,{node:d,pos:f}),e&&(e.dataset.dragging="true"),setTimeout(()=>{e&&(e.style.pointerEvents="none")},0)}function v(x){a?.(x),g(),e&&(e.style.pointerEvents="auto",e.dataset.dragging="false")}function _(){if(v3()){const x=n.view.dom;requestAnimationFrame(()=>{x.isContentEditable&&(x.contentEditable="false",x.contentEditable="true")})}}return e.addEventListener("dragstart",k),e.addEventListener("dragend",v),document.addEventListener("drop",_),c.appendChild(e),{unbind(){e.removeEventListener("dragstart",k),e.removeEventListener("dragend",v),document.removeEventListener("drop",_),p&&(cancelAnimationFrame(p),p=null,m=null)},plugin:new Ye({key:typeof t=="string"?new Je(t):t,state:{init(){return{locked:!1}},apply(x,A,E,T){const N=x.getMeta("lockDragHandle"),I=x.getMeta("hideDragHandle");if(N!==void 0&&(u=N),I)return g(),u=!1,d=null,f=-1,s?.({editor:n,node:null,pos:-1}),A;if(x.docChanged&&f!==-1&&e)if($D(x)){const R=Jae(T,h);R!==f&&(f=R)}else{const R=x.mapping.map(f);R!==f&&(f=R,h=_m(T,f))}return A}},view:x=>{var A;return e.draggable=!0,e.style.pointerEvents="auto",e.dataset.dragging="false",(A=n.view.dom.parentElement)==null||A.appendChild(c),c.style.pointerEvents="none",c.style.position="absolute",c.style.top="0",c.style.left="0",{update(E,T){if(!e)return;if(!n.isEditable){g();return}if(u?e.draggable=!1:e.draggable=!0,x.state.doc.eq(T.doc)||f===-1)return;let N=x.nodeDOM(f);if(N=IS(x,N),N===x.dom||N?.nodeType!==1)return;const I=x.posAtDOM(N,0),R=NS(n.state.doc,I),D=RS(n.state.doc,I);d=R,f=D,h=_m(x.state,f),s?.({editor:n,node:d,pos:f}),S(N)},destroy(){e.removeEventListener("dragstart",k),e.removeEventListener("dragend",v),document.removeEventListener("drop",_),p&&(cancelAnimationFrame(p),p=null,m=null),e&&HD(c)}}},props:{handleDOMEvents:{keydown(x){return!e||u||x.hasFocus()&&(g(),d=null,f=-1,s?.({editor:n,node:null,pos:-1})),!1},mouseleave(x,A){return u||A.target&&!c.contains(A.relatedTarget)&&(g(),d=null,f=-1,s?.({editor:n,node:null,pos:-1})),!1},mousemove(x,A){return!e||u||(m={x:A.clientX,y:A.clientY},p)||(p=requestAnimationFrame(()=>{if(p=null,!m)return;const{x:E,y:T}=m;m=null;const N=zD({x:E,y:T,editor:n,nestedOptions:l});if(!N.resultElement)return;let I=N.resultElement,R=N.resultNode,D=N.pos;if(!l?.enabled){if(I=IS(x,I),I===x.dom||I?.nodeType!==1)return;const O=x.posAtDOM(I,0);R=NS(n.state.doc,O),D=RS(n.state.doc,O)}R!==d&&(d=R,f=D??-1,h=_m(x.state,f),s?.({editor:n,node:d,pos:f}),S(I),b())})),!1}}}})}};function KD(t){var e,n;return t===!1||t===void 0?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:Am("none")}:t===!0?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:Am("left")}:{enabled:!0,rules:(e=t.rules)!=null?e:[],defaultRules:(n=t.defaultRules)!=null?n:!0,allowedContainers:t.allowedContainers,edgeDetection:Am(t.edgeDetection)}}var gy={placement:"left-start",strategy:"absolute"};at.create({name:"dragHandle",addOptions(){return{render(){const t=document.createElement("div");return t.classList.add("drag-handle"),t},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0,nested:!1}},addCommands(){return{lockDragHandle:()=>({editor:t})=>(this.options.locked=!0,t.commands.setMeta("lockDragHandle",this.options.locked)),unlockDragHandle:()=>({editor:t})=>(this.options.locked=!1,t.commands.setMeta("lockDragHandle",this.options.locked)),toggleDragHandle:()=>({editor:t})=>(this.options.locked=!this.options.locked,t.commands.setMeta("lockDragHandle",this.options.locked))}},addProseMirrorPlugins(){const t=this.options.render(),e=KD(this.options.nested);return[WD({computePositionConfig:{...gy,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:t,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd,nestedOptions:e}).plugin]}});var Xae=t=>{const{className:e="drag-handle",children:n,editor:r,pluginKey:o=VD,onNodeChange:s,onElementDragStart:i,onElementDragEnd:a,computePositionConfig:l=gy,nested:c=!1}=t,[u,d]=j.useState(null),f=j.useRef(null),h=j.useMemo(()=>KD(c),[JSON.stringify(c)]);return j.useEffect(()=>{let p=null;return u?r.isDestroyed?()=>{f.current=null}:(f.current||(p=WD({editor:r,element:u,pluginKey:o,computePositionConfig:{...gy,...l},onElementDragStart:i,onElementDragEnd:a,onNodeChange:s,nestedOptions:h}),f.current=p.plugin,r.registerPlugin(f.current)),()=>{r.unregisterPlugin(o),f.current=null,p&&(p.unbind(),p=null)}):()=>{f.current=null}},[u,r,s,o,l,i,a,h]),y.jsx("div",{className:e,style:{visibility:"hidden",position:"absolute"},"data-dragging":"false",ref:d,children:n})},Qae=Xae;const GD=({editor:t,actions:e,editorTab:n,onSwitchEditor:r,isSubmitting:o,clearOnSuccess:s,onCreatePost:i,onVoiceComment:a,onVoiceRecord:l,onQuickGif:c,className:u,store:d,placement:f,hideSubmitButton:h,hideGroupSelector:p})=>{const[m,g]=j.useState(!1),[b,S]=j.useState(!0),[k,v]=j.useState(null),{trackPublish:_}=Cs(),{t:x,allowSendWhileUploading:A,unauthenticatedMode:E}=kn(),T=El(d,F=>F.groupId)??void 0,{clearContent:N}=bR(f,T);OJ(),MJ({editor:t,editorType:n});const I=j.useRef(null),[R,D]=j.useState(),O=j.useCallback(F=>{if(t&&(Cg(t)||NY(t))){v(F);return}I.current&&D(I.current.offsetHeight),r(F)},[t,r]);j.useEffect(()=>{if(R&&t){const F=()=>D(void 0),V=setTimeout(F,50);return t.once("update",F),()=>{clearTimeout(V),t.off("update",F)}}},[R,t]),j.useEffect(()=>{const F=()=>{const{groupId:W,selectedGroupId:H}=d.getState();S(!!(W||H))};F();const V=d.subscribe(F);return()=>V()},[d]);const P=F=>{F.preventDefault(),g(!0)},C=F=>{F.preventDefault(),g(!1)},M=F=>{F.preventDefault(),g(!1)},U=()=>{const F=document.querySelector('[aria-label="Select group"]');F&&F.click()},L=j.useCallback(F=>{if(!t)return;const V=t?.getHTML(),W=t?.getJSON(),H=t?.getText(),{selectedGroupId:B,groupId:$}=d.getState(),K=B||$||void 0,Y=A||E,J=xI(n,{editor:t,sendCrossMention:F,groupId:K,allowSendWhileUploading:Y}),Q=J?.type===cs.NEW_POST_POLL;if(J?.error){Zt.error(J.error);return}if(!J?.postId)return;if(Q&&J.items?.length===0)return Zt.warning(`At least ${Gs.MIN} option is mandatory to create a poll post`);typeof window<"u"&&window.dispatchEvent(new CustomEvent(yn.POST_PUBLISH_ATTEMPTED,{detail:{postId:J.postId,postType:J.type}}));const ne=ib(t);_({editorType:n,status:"attempted",postId:J?.postId,postType:J?.type,isCrosspost:F,...ne});let se;if(Y){const ge=new Map;for(const he of J.items??[]){if(!("sources"in he)||!he.sources?.original?.url?.startsWith("blob:"))continue;const xe="option_id"in he?t.storage?.poll?.getPendingUpload?.(he.key):t.storage?.smartMediaUpload?.getPendingUpload?.(he.key);xe&&ge.set(he.key,xe)}if(n!==Pe.Poll){const he=Gn(W,"media");for(const xe of he){const Ee=xe?.attrs?.uid,Se=xe?.attrs?.src;if(typeof Ee!="string"||!(typeof Se=="string"&&Se.startsWith("blob:"))&&xe?.attrs?.deferred!==!0||ge.has(Ee))continue;const Me=t.storage?.smartMediaUpload?.getPendingUpload?.(Ee);Me&&ge.set(Ee,Me)}}ge.size>0&&(se=ge)}i?.({payload:J,html:V,json:W,text:H,pendingUploads:se},{restoreContent:()=>{const{editor:ge,editorTab:he}=d.getState();he===n&&(!ge||ge.isDestroyed||ge.commands.setContent(W))}}),s&&(N(),n===Pe.Poll?t?.chain()?.focus()?.setContent({type:"doc",content:[{type:"paragraph"},{type:"poll"}]})?.run():t?.chain()?.focus()?.clearContent()?.run())},[A,E,N,s,t,n,i,d,_]);return j.useEffect(()=>{const F=V=>{if((V.ctrlKey||V.metaKey)&&V.key==="Enter"){if(!t?.isFocused)return;if(V.preventDefault(),!A&&t&&Cg(t)){Zt.error(x("uploadsInProgressKey"));return}L(!1)}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[t,L,A,x]),y.jsxs("div",{ref:I,style:{minHeight:R?`${R}px`:void 0},className:oe("post-builder-editor bg-background border rounded-md overflow-hidden max-h-full grow flex flex-col transition-all duration-300 ease-in-out relative",f===Mo.Comment&&"min-h-32",u),children:[!b&&!p&&y.jsx("div",{className:"z-50 absolute inset-0 bg-foreground/30 backdrop-blur-xs flex items-center justify-center rounded-md pointer-events-none",children:y.jsx(zt,{variant:"outline",size:"lg",onClick:U,className:"pointer-events-auto cursor-pointer hover:animate-none animate-pulse",children:"Please select a group first"})}),f!==Mo.Comment&&y.jsx(N6,{editorTab:n,onSwitchEditorTab:O}),y.jsx(iJ,{editor:t,actions:e,isSubmitting:o,onSubmit:L,editorType:n,placement:f,onVoiceComment:a,onVoiceRecord:l,onQuickGif:c,hideSubmitButton:h,children:y.jsxs("div",{className:"relative flex flex-col grow overflow-y-auto",children:[m&&y.jsx("div",{className:"pointer-events-none z-50 absolute inset-0 bg-accent/10 border border-dashed flex items-center justify-center",children:y.jsx("h2",{children:"Drop Here"})}),y.jsxs("div",{onDragOver:P,onDragLeave:C,onDrop:M,className:"flex flex-col grow",children:[y.jsx(Qae,{editor:t,className:oe("pr-2",n!==Pe.Blog&&"hidden size-0 overflow-hidden pointer-events-none"),children:y.jsx(zt,{variant:"ghost",className:"bg-white cursor-grab py-0.5 px-0 border size-auto",children:y.jsx(n9,{className:"text-muted-foreground"})})}),y.jsx(EM,{className:"grow","data-theme":"select-post-builder",editor:t})]})]})}),y.jsx(Pc,{open:!!k,onOpenChange:F=>!F&&v(null),children:y.jsxs(Lc,{children:[y.jsxs(jc,{children:[y.jsx($c,{children:x("cancelUploadTitleKey")}),y.jsx(CJ,{children:x("cancelUploadDescriptionKey")})]}),y.jsxs(fR,{children:[y.jsx(dR,{asChild:!0,children:y.jsx(zt,{variant:"outline",children:x("stayKey")})}),y.jsx(zt,{variant:"destructive",onClick:()=>{k&&(t.commands.deleteAllUploadingMedia(),I.current&&D(I.current.offsetHeight),r(k),v(null))},children:x("continueKey")})]})]})})]})},Zae=({user:t,store:e,hideGroupSelector:n,open:r,onOpenChange:o,onGroupSelect:s,placement:i,...a})=>{const{trackAbandon:l}=Cs(),c=u=>{if(o(u),u)return;const d=ib(a.editor);l({editorType:a.editorTab,abandonReason:"user_closed",contentLength:d?.characterCount??0,hasUnsavedChanges:d?.hasUnsavedChanges??!1})};return y.jsxs(Pc,{modal:!1,open:r,onOpenChange:c,children:[y.jsx("div",{className:"z-999 fixed inset-0 bg-black/50 backdrop-blur-sm",onClick:()=>c(!1)}),y.jsxs(Lc,{onInteractOutside:u=>u.preventDefault(),onOpenAutoFocus:u=>u.preventDefault(),className:"z-9999 bg-transparent shadow-none border-0 p-3 lg:max-w-4xl shrink-0 max-h-[calc(100dvh-7rem)]! flex flex-col overflow-y-auto -translate-1/2",showCloseButton:!1,children:[y.jsxs(jc,{children:[y.jsx($c,{className:"sr-only",children:"Post Builder Modal"}),!n&&y.jsxs("div",{className:"flex items-center justify-between gap-3",children:[y.jsx(cM,{user:t,store:e,onGroupSelect:s}),y.jsx(dR,{asChild:!0,children:y.jsx(zt,{variant:"outline",size:"icon",children:y.jsx(co,{})})})]})]}),y.jsx(GD,{...a,store:e,placement:i})]})]})};var ele=(t,e,n,r,o,s,i,a)=>{let l=document.documentElement,c=["light","dark"];function u(h){(Array.isArray(t)?t:[t]).forEach(p=>{let m=p==="class",g=m&&s?o.map(b=>s[b]||b):o;m?(l.classList.remove(...g),l.classList.add(s&&s[h]?s[h]:h)):l.setAttribute(p,h)}),d(h)}function d(h){a&&c.includes(h)&&(l.style.colorScheme=h)}function f(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(r)u(r);else try{let h=localStorage.getItem(e)||n,p=i&&h==="system"?f():h;u(p)}catch{}},tle=w.createContext(void 0),nle={setTheme:t=>{},themes:[]},rle=()=>{var t;return(t=w.useContext(tle))!=null?t:nle};w.memo(({forcedTheme:t,storageKey:e,attribute:n,enableSystem:r,enableColorScheme:o,defaultTheme:s,value:i,themes:a,nonce:l,scriptProps:c})=>{let u=JSON.stringify([n,e,s,t,a,i,r,o]).slice(1,-1);return w.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${ele.toString()})(${u})`}})});const ole=({...t})=>{const{theme:e="system"}=rle();return y.jsx(E2,{theme:e,className:"toaster group z-90",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...t})};function sle({editorType:t,placement:e,sessionId:n,children:r}){return y.jsx(iA.Provider,{value:{sessionId:n,editorType:t,placement:e},children:r})}const ile=({placement:t=Mo.Feed,groupId:e,postId:n,user:r,hideGroupSelector:o=!1,clearOnSuccess:s=!0,openModal:i,onModalOpenChange:a,isSubmitting:l,onCreatePost:c,onVoiceComment:u,onVoiceRecord:d,onQuickGif:f,onGroupSelect:h,onDirtyStateChange:p,onReady:m,disableNavigationWarning:g,initialContent:b,resumeDeferredMedia:S,initialTab:k,hideSubmitButton:v,onEditorTabChange:_,placeholder:x})=>{const[A,E]=j.useState(k??Pe.Media),[T,N]=j.useState(""),I=hs(te=>te.createSession),R=hs(te=>te.deleteSession),D=hs(te=>te.trackEditorFocus),{editor:O,actions:P,store:C,isMounted:M,saveBeforeSwitch:U,keepEditing:L,saveDraft:F,discardDraft:V,skipNextUnmountSave:W,setContent:H,getContent:B,clearEditor:$,resumeDeferredUploads:K}=Bre({editorType:A,placement:t,groupId:e,postId:n,user:r,disableNavigationWarning:g,initialContent:b,resumeDeferredMedia:S,placeholder:x}),Y=j.useCallback(te=>{f?.({...te,onSent:$})},[f,$]),J=j.useCallback(te=>{U(),E(te),_?.(te)},[U,_]),Q=j.useMemo(()=>({editor:O}),[O]);j.useEffect(()=>{if(t===Mo.Modal&&!i)return;const te=I(Pe.Media,t);return N(te),()=>{R(te)}},[I,R,i,t]),j.useEffect(()=>{const te=ge=>{if(!O)return;const{newSessionId:he}=ge.detail;N(he),O.isFocused&&D(he,"auto")};return window.addEventListener(yn.POST_SESSION_ROTATED,te),()=>{window.removeEventListener(yn.POST_SESSION_ROTATED,te)}},[O,D]),j.useEffect(()=>{const te=ge=>{const he=ge.detail;!he||he.groupId!==e||he.editorType&&he.editorType!==A&&(W(),E(he.editorType),_?.(he.editorType))};return window.addEventListener(yn.DRAFT_REHYDRATE_REQUEST,te),()=>{window.removeEventListener(yn.DRAFT_REHYDRATE_REQUEST,te)}},[e,A,_,W]),j.useEffect(()=>{if(!O||!T)return;const te=requestAnimationFrame(()=>{O.view?.dom&&(O.view.dom.setAttribute("data-session-id",T),O.view.dom.setAttribute("data-editor-type",A))});return()=>cancelAnimationFrame(te)},[O,T,A]);const ne=j.useRef(!1);j.useEffect(()=>{if(!O||!p)return;const te=()=>{const ge=A===Pe.Poll?!pR(O.getJSON()):!O.isEmpty;ge!==ne.current&&(ne.current=ge,p(ge))};return O.on("update",te),()=>{O.off("update",te)}},[O,p,A]);const se=j.useRef(!1);return j.useEffect(()=>{!O||se.current||!m||(se.current=!0,m({saveDraft:F,discardDraft:V,keepEditing:L,setContent:H,getContent:B,clearEditor:$,resumeDeferredUploads:K}))},[O,m,F,V,L,H,B,$,K]),!M||!O?y.jsx(ale,{}):y.jsx(sle,{sessionId:T,editorType:A,placement:t,children:y.jsxs("div",{className:"max-w-full w-full","data-theme":"select-post-builder",children:[y.jsx(Eh.Provider,{value:Q,children:i?y.jsx(Zae,{placement:t,hideGroupSelector:o,user:r,editor:O,editorTab:A,onSwitchEditor:J,store:C,actions:P,open:i,onOpenChange:a,onCreatePost:c,onVoiceComment:u,onVoiceRecord:d,onQuickGif:f?Y:void 0,isSubmitting:l,clearOnSuccess:s,onGroupSelect:h}):y.jsxs("div",{className:"prose-blockquote: flex-1 flex flex-col space-y-3 max-w-full max-h-[calc(100dvh-7rem)] bg-transparent",children:[!o&&y.jsx(cM,{user:r,store:C,onGroupSelect:h}),y.jsx(GD,{editor:O,actions:P,editorTab:A,onSwitchEditor:J,store:C,isSubmitting:l,onCreatePost:c,onVoiceComment:u,onVoiceRecord:d,onQuickGif:f?Y:void 0,clearOnSuccess:s,placement:t,hideSubmitButton:v,hideGroupSelector:o})]})}),y.jsx(ole,{position:"top-center"})]})})},ale=()=>y.jsx("div",{className:"max-w-full w-full","data-theme":"select-post-builder",children:y.jsxs("div",{className:"space-y-3",children:[y.jsx($s,{className:"h-8 w-48"}),y.jsxs("div",{className:"min-h-60 w-full flex flex-col overflow-hidden rounded-lg border",children:[y.jsx($s,{className:"h-10 rounded-b-none"}),y.jsx(uE,{}),y.jsx($s,{className:"h-44 rounded-none"}),y.jsx(uE,{}),y.jsx($s,{className:"h-[47px] rounded-t-none flex items-center justify-end p-2",children:y.jsx($s,{className:"h-full w-20 bg-accent-foreground/20"})})]})]})}),lle={addKey:"Add",cancelKey:"Cancel",deleteKey:"Delete",editKey:"Edit",updateKey:"Update",insertKey:"Insert",uploadKey:"Upload",postKey:"Post",crossPostKey:"Cross-post to groups you #mention?",crossPostLimitKey:"Only the first 3 groups you #mention are cross-posted",postTabKey:"Post",blogTabKey:"Blog",pollTabKey:"Poll",alignLeftKey:"Align Left",alignCenterKey:"Align Center",alignRightKey:"Align Right",undoKey:"Undo",redoKey:"Redo",headingOptionsKey:"Heading Options",paragraphKey:"Paragraph",heading1Key:"Heading 1",heading2Key:"Heading 2",heading3Key:"Heading 3",boldKey:"Bold",italicKey:"Italic",strikethroughKey:"Strikethrough",bulletListKey:"Bullet List",orderedListKey:"Ordered List",blockquoteKey:"BlockQuote",codeKey:"Code",codeBlockKey:"Codeblock",moreOptionsKey:"More formatting options",insertImageKey:"Insert Image",insertVideoKey:"Insert Video",insertAudioKey:"Insert Audio",searchGifOrImagesKey:"Search Gif/Images Online",mediaSearchTitleKey:"Search Media",gifSearchKey:"GIF Search",imageSearchKey:"Image Search",searchGifPlaceholder:"Search GIFs...",searchIMagePlaceholder:"Search Images...",addLinkPreviewKey:"Add link with preview",editLinkKey:"Edit Link",visitLinkKey:"Visit Link",unsetLinkKey:"Unset Link",linkInputLabelKey:"Link URL",linkTextInputLabelKey:"Text to display",invalidLinkKey:"Please enter a valid URL",insertLinkKey:"Insert Link",updateLinkKey:"Update Link",removeLinkPreviewKey:"Remove Link Preview",fetchingMetadataKey:"Fetching Link Metadata...",pollQuestionPlaceholderKey:"Which one would you select?",addTextOptionKey:"Add text option",enterTextOptionKey:"Enter a text option...",pressEnterToAddKey:"Press Enter to add",quickGifGeneratingKey:"Text → GIF…",cancelUploadTitleKey:"Cancel upload?",cancelUploadDescriptionKey:"Switching tabs will cancel your current upload and remove the media from your post.",stayKey:"Stay",continueKey:"Continue",uploadsInProgressKey:"Please wait for all uploads to finish"},DS={addKey:"general_add",cancelKey:"cancel",deleteKey:"general_delete",editKey:"general_edit",updateKey:"general_update",insertKey:"general_insert",uploadKey:"general_upload",postKey:"general_send_post",crossPostKey:"cross_mention_title",crossPostLimitKey:"cross_mention_limit_hint",postTabKey:"post_builder_tab_post_title",blogTabKey:"post_builder_tab_blog_title",pollTabKey:"post_builder_tab_poll_title",alignLeftKey:"post_builder_formatting_tooltip_align_left",alignCenterKey:"post_builder_formatting_tooltip_align_center",alignRightKey:"post_builder_formatting_tooltip_align_right",undoKey:"post_builder_formatting_tooltip_undo",redoKey:"post_builder_formatting_tooltip_redo",headingOptionsKey:"post_builder_formatting_tooltip_heading_options",paragraphKey:"post_builder_formatting_tooltip_paragraph",heading1Key:"post_builder_formatting_tooltip_heading_one",heading2Key:"post_builder_formatting_tooltip_heading_two",heading3Key:"post_builder_formatting_tooltip_heading_three",boldKey:"post_builder_formatting_tooltip_bold",italicKey:"post_builder_formatting_tooltip_italic",strikethroughKey:"post_builder_formatting_tooltip_strikethrough",bulletListKey:"post_builder_formatting_tooltip_list_bullet",orderedListKey:"post_builder_formatting_tooltip_list_ordered",blockquoteKey:"post_builder_formatting_tooltip_blockquote",codeKey:"post_builder_formatting_tooltip_code",codeBlockKey:"post_builder_formatting_tooltip_codeblock",moreOptionsKey:"post_builder_formatting_tooltip_more_options",insertImageKey:"post_builder_tooltip_insert_image",insertVideoKey:"post_builder_tooltip_insert_video",insertAudioKey:"post_builder_tooltip_insert_audio",searchGifOrImagesKey:"post_builder_tooltip_search_gif_or_image",mediaSearchTitleKey:"post_builder_media_search_modal_title",gifSearchKey:"post_builder_media_search_tab_gif_title",imageSearchKey:"post_builder_media_search_tab_image_title",searchGifPlaceholder:"post_builder_media_search_input_gif_placeholder",searchIMagePlaceholder:"post_builder_media_search_input_image_placeholder",addLinkPreviewKey:"post_builder_tooltip_link_add",editLinkKey:"post_builder_tooltip_link_edit",visitLinkKey:"post_builder_tooltip_link_visit",unsetLinkKey:"post_builder_tooltip_link_unset",linkInputLabelKey:"post_builder_link_input_label",linkTextInputLabelKey:"post_builder_link_text_input_label",invalidLinkKey:"post_builder_link_input_invalid",insertLinkKey:"post_builder_link_insert_modal_title",updateLinkKey:"post_builder_link_update_modal_title",removeLinkPreviewKey:"post_builder_tooltip_link_remove_preview",fetchingMetadataKey:"post_builder_link_loading_metadata_placeholder",pollQuestionPlaceholderKey:"post_builder_poll_question_input_placeholder",addTextOptionKey:"post_builder_poll_add_text_option_input_label",enterTextOptionKey:"post_builder_poll_add_text_option_input_placeholder",pressEnterToAddKey:"post_builder_poll_add_text_option_input_command",quickGifGeneratingKey:"post_detail_quick_gif_generating",cancelUploadTitleKey:"post_builder_upload_guard_cancel_title",cancelUploadDescriptionKey:"post_builder_upload_guard_cancel_description",stayKey:"post_builder_upload_guard_stay",continueKey:"post_builder_upload_guard_continue",uploadsInProgressKey:"post_builder_upload_guard_in_progress"},cle=({children:t,apiBaseURL:e,authToken:n,toI18N:r,i18nKeys:o=DS,logEvent:s,allowSendWhileUploading:i=!1,unauthenticatedMode:a=!1})=>{const l=hs(f=>f.initialize),c=j.useCallback((f,h)=>{const m={...DS,...o}[f],g=r(m);if(g!==m)return g;const b=lle[f];return b||h||f},[r,o]),u=j.useMemo(()=>{const f=new C2(e.core,n,r),h=new P2(e.mfs,n,r),p=new N2(e.fileStore,n,r);return f.initApi(),h.initApi(),p.initApi(),{core:f,mfs:h,fileStore:p}},[n,e,r]);j.useEffect(()=>{l(s,{debug:!0,enabled:!0})},[l,s]);const d=j.useMemo(()=>({authToken:n,t:c,i18nKeys:o,api:u,logEvent:s,allowSendWhileUploading:i,unauthenticatedMode:a}),[n,c,o,u,s,i,a]);return y.jsx(fk.Provider,{value:d,children:t})};function ule(t,e,n){if(!t)return t;const r=qD(t,e,n);return JD(r,o=>{if(o.attrs?.uid!==e)return o;const s=n.sources?.original?.url??o.attrs.src,i=o.attrs.type;return{...o,attrs:{...o.attrs,src:s,type:yv(n.imageType,GN(i)?i:ue.Image),uploading:!1,progress:100,payload:n}}})}function dle(t){if(!t)return t;const e=YD(t);return ple(e,hle)}function qD(t,e,n){if(t.type==="poll"){const r=t.attrs?.choices??[];return Array.isArray(r)?{...t,attrs:{...t.attrs,choices:r.map(o=>o?.key===e?{...o,...fle(n)}:o)}}:t}return t.content?{...t,content:t.content.map(r=>qD(r,e,n))}:t}const fle=({sources:t,imageType:e,sourceType:n})=>({sources:t,...e!==void 0?{imageType:e}:{},...n!==void 0?{sourceType:n}:{}});function YD(t){if(t.type==="poll"){const e=t.attrs?.choices??[];return Array.isArray(e)?{...t,attrs:{...t.attrs,choices:e.filter(n=>!(n?.sources?.original?.url??"").startsWith("blob:"))}}:t}return t.content?{...t,content:t.content.map(e=>YD(e))}:t}function hle(t){if(t.type!=="media")return!1;const e=t.attrs??{};return e.uploading===!0||e.deferred===!0||typeof e.src=="string"&&e.src.startsWith("blob:")}function JD(t,e){return t.type==="media"?e(t):t.content?{...t,content:t.content.map(n=>JD(n,e))}:t}function ple(t,e){return XD(t,e)??t}function XD(t,e){if(t.type==="media"&&e(t))return null;if(!t.content)return t;const n=[];for(const r of t.content){const o=XD(r,e);o!==null&&n.push(o)}return t.type==="mediaGroup"&&n.length===0?null:{...t,content:n}}function mle(t,e,n){if(!t)return t;const r=QD(t),o=r.body.querySelector(`div[data-media][data-uid="${ble(e)}"]`);if(!o)return t;const s=n.sources?.original?.url??o.getAttribute("data-src")??"",i=o.getAttribute("data-type"),a=yv(n.imageType,GN(i)?i:ue.Image);o.setAttribute("data-type",a),o.setAttribute("data-src",s),o.setAttribute("data-payload",JSON.stringify(n));const l=o.querySelector("img, video, audio"),c=r.createElement(Ey[a]);c.setAttribute("src",s);const u=l?.getAttribute("style");u&&c.setAttribute("style",u);for(const[d,f]of Object.entries(lN(a,n)))c.setAttribute(d,String(f));return l?l.replaceWith(c):o.appendChild(c),r.body.innerHTML}function gle(t){if(!t)return t;const e=QD(t);return e.body.querySelectorAll("div[data-media]").forEach(n=>{yle(n)&&n.remove()}),e.body.querySelectorAll("div[data-media-group]").forEach(n=>{n.querySelector("div[data-media]")===null&&n.remove()}),e.body.innerHTML}function yle(t){const e=t.getAttribute("data-src")??"";return!e||e.startsWith("blob:")?!0:(t.querySelector("img, video, audio")?.getAttribute("src")??"").startsWith("blob:")}function QD(t){return new DOMParser().parseFromString(`<body>${t}</body>`,"text/html")}function ble(t){return t.replace(/(["\\])/g,"\\$1")}exports.EditorPlacement=Mo;exports.EditorTypes=Pe;exports.PostBuilderEditor=ile;exports.PostBuilderEvents=yn;exports.PostBuilderProvider=cle;exports.applyResolvedMediaItem=ule;exports.applyResolvedMediaItemToHtml=mle;exports.ensurePollMinimum=mN;exports.getDefaultExportFromCjs=Sy;exports.stripPendingMediaFromHtml=gle;exports.stripPendingMediaFromJsonBody=dle;