@select-org/select-post-builder 1.0.5 → 1.0.6

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,526 +0,0 @@
1
- (function(vt,M){typeof exports=="object"&&typeof module<"u"?M(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],M):(vt=typeof globalThis<"u"?globalThis:vt||self,M(vt.PostBuilder={},vt.React,vt.ReactDOM))})(this,(function(vt,M,la){"use strict";function Iv(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 b=Iv(M),oc=Iv(la);function Dv(t,e){return function(){return t.apply(e,arguments)}}const{toString:_N}=Object.prototype,{getPrototypeOf:zf}=Object,{iterator:sc,toStringTag:Pv}=Symbol,ic=(t=>e=>{const n=_N.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),or=t=>(t=t.toLowerCase(),e=>ic(e)===t),ac=t=>e=>typeof e===t,{isArray:ni}=Array,ri=ac("undefined");function ca(t){return t!==null&&!ri(t)&&t.constructor!==null&&!ri(t.constructor)&&pn(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const Lv=or("ArrayBuffer");function NN(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&Lv(t.buffer),e}const RN=ac("string"),pn=ac("function"),jv=ac("number"),ua=t=>t!==null&&typeof t=="object",IN=t=>t===!0||t===!1,lc=t=>{if(ic(t)!=="object")return!1;const e=zf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Pv in t)&&!(sc in t)},DN=t=>{if(!ua(t)||ca(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},PN=or("Date"),LN=or("File"),jN=or("Blob"),$N=or("FileList"),BN=t=>ua(t)&&pn(t.pipe),FN=t=>{let e;return t&&(typeof FormData=="function"&&t instanceof FormData||pn(t.append)&&((e=ic(t))==="formdata"||e==="object"&&pn(t.toString)&&t.toString()==="[object FormData]"))},HN=or("URLSearchParams"),[zN,UN,VN,WN]=["ReadableStream","Request","Response","Headers"].map(or),GN=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function da(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let r,o;if(typeof t!="object"&&(t=[t]),ni(t))for(r=0,o=t.length;r<o;r++)e.call(null,t[r],r,t);else{if(ca(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 $v(t,e){if(ca(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 ps=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Bv=t=>!ri(t)&&t!==ps;function Uf(){const{caseless:t,skipUndefined:e}=Bv(this)&&this||{},n={},r=(o,s)=>{const i=t&&$v(n,s)||s;lc(n[i])&&lc(o)?n[i]=Uf(n[i],o):lc(o)?n[i]=Uf({},o):ni(o)?n[i]=o.slice():(!e||!ri(o))&&(n[i]=o)};for(let o=0,s=arguments.length;o<s;o++)arguments[o]&&da(arguments[o],r);return n}const qN=(t,e,n,{allOwnKeys:r}={})=>(da(e,(o,s)=>{n&&pn(o)?t[s]=Dv(o,n):t[s]=o},{allOwnKeys:r}),t),KN=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),YN=(t,e,n,r)=>{t.prototype=Object.create(e.prototype,r),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},JN=(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&&zf(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},XN=(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},QN=t=>{if(!t)return null;if(ni(t))return t;let e=t.length;if(!jv(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},ZN=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&zf(Uint8Array)),eR=(t,e)=>{const r=(t&&t[sc]).call(t);let o;for(;(o=r.next())&&!o.done;){const s=o.value;e.call(t,s[0],s[1])}},tR=(t,e)=>{let n;const r=[];for(;(n=t.exec(e))!==null;)r.push(n);return r},nR=or("HTMLFormElement"),rR=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),Fv=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),oR=or("RegExp"),Hv=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),r={};da(n,(o,s)=>{let i;(i=e(o,s,t))!==!1&&(r[s]=i||o)}),Object.defineProperties(t,r)},sR=t=>{Hv(t,(e,n)=>{if(pn(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=t[n];if(pn(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+"'")})}})},iR=(t,e)=>{const n={},r=o=>{o.forEach(s=>{n[s]=!0})};return ni(t)?r(t):r(String(t).split(e)),n},aR=()=>{},lR=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function cR(t){return!!(t&&pn(t.append)&&t[Pv]==="FormData"&&t[sc])}const uR=t=>{const e=new Array(10),n=(r,o)=>{if(ua(r)){if(e.indexOf(r)>=0)return;if(ca(r))return r;if(!("toJSON"in r)){e[o]=r;const s=ni(r)?[]:{};return da(r,(i,a)=>{const l=n(i,o+1);!ri(l)&&(s[a]=l)}),e[o]=void 0,s}}return r};return n(t,0)},dR=or("AsyncFunction"),fR=t=>t&&(ua(t)||pn(t))&&pn(t.then)&&pn(t.catch),zv=((t,e)=>t?setImmediate:e?((n,r)=>(ps.addEventListener("message",({source:o,data:s})=>{o===ps&&s===n&&r.length&&r.shift()()},!1),o=>{r.push(o),ps.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",pn(ps.postMessage)),hR=typeof queueMicrotask<"u"?queueMicrotask.bind(ps):typeof process<"u"&&process.nextTick||zv,I={isArray:ni,isArrayBuffer:Lv,isBuffer:ca,isFormData:FN,isArrayBufferView:NN,isString:RN,isNumber:jv,isBoolean:IN,isObject:ua,isPlainObject:lc,isEmptyObject:DN,isReadableStream:zN,isRequest:UN,isResponse:VN,isHeaders:WN,isUndefined:ri,isDate:PN,isFile:LN,isBlob:jN,isRegExp:oR,isFunction:pn,isStream:BN,isURLSearchParams:HN,isTypedArray:ZN,isFileList:$N,forEach:da,merge:Uf,extend:qN,trim:GN,stripBOM:KN,inherits:YN,toFlatObject:JN,kindOf:ic,kindOfTest:or,endsWith:XN,toArray:QN,forEachEntry:eR,matchAll:tR,isHTMLForm:nR,hasOwnProperty:Fv,hasOwnProp:Fv,reduceDescriptors:Hv,freezeMethods:sR,toObjectSet:iR,toCamelCase:rR,noop:aR,toFiniteNumber:lR,findKey:$v,global:ps,isContextDefined:Bv,isSpecCompliantForm:cR,toJSONObject:uR,isAsyncFn:dR,isThenable:fR,setImmediate:zv,asap:hR,isIterable:t=>t!=null&&pn(t[sc])};function Te(t,e,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}I.inherits(Te,Error,{toJSON:function(){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:I.toJSONObject(this.config),code:this.code,status:this.status}}});const Uv=Te.prototype,Vv={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{Vv[t]={value:t}}),Object.defineProperties(Te,Vv),Object.defineProperty(Uv,"isAxiosError",{value:!0}),Te.from=(t,e,n,r,o,s)=>{const i=Object.create(Uv);I.toFlatObject(t,i,function(u){return u!==Error.prototype},c=>c!=="isAxiosError");const a=t&&t.message?t.message:"Error",l=e==null&&t?t.code:e;return Te.call(i,a,l,n,r,o),t&&i.cause==null&&Object.defineProperty(i,"cause",{value:t,configurable:!0}),i.name=t&&t.name||"Error",s&&Object.assign(i,s),i};const pR=null;function Vf(t){return I.isPlainObject(t)||I.isArray(t)}function Wv(t){return I.endsWith(t,"[]")?t.slice(0,-2):t}function Gv(t,e,n){return t?t.concat(e).map(function(o,s){return o=Wv(o),!n&&s?"["+o+"]":o}).join(n?".":""):e}function mR(t){return I.isArray(t)&&!t.some(Vf)}const gR=I.toFlatObject(I,{},null,function(e){return/^is[A-Z]/.test(e)});function cc(t,e,n){if(!I.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,n=I.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,y){return!I.isUndefined(y[m])});const r=n.metaTokens,o=n.visitor||u,s=n.dots,i=n.indexes,l=(n.Blob||typeof Blob<"u"&&Blob)&&I.isSpecCompliantForm(e);if(!I.isFunction(o))throw new TypeError("visitor must be a function");function c(p){if(p===null)return"";if(I.isDate(p))return p.toISOString();if(I.isBoolean(p))return p.toString();if(!l&&I.isBlob(p))throw new Te("Blob is not supported. Use a Buffer instead.");return I.isArrayBuffer(p)||I.isTypedArray(p)?l&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function u(p,m,y){let v=p;if(p&&!y&&typeof p=="object"){if(I.endsWith(m,"{}"))m=r?m:m.slice(0,-2),p=JSON.stringify(p);else if(I.isArray(p)&&mR(p)||(I.isFileList(p)||I.endsWith(m,"[]"))&&(v=I.toArray(p)))return m=Wv(m),v.forEach(function(E,x){!(I.isUndefined(E)||E===null)&&e.append(i===!0?Gv([m],x,s):i===null?m:m+"[]",c(E))}),!1}return Vf(p)?!0:(e.append(Gv(y,m,s),c(p)),!1)}const d=[],f=Object.assign(gR,{defaultVisitor:u,convertValue:c,isVisitable:Vf});function h(p,m){if(!I.isUndefined(p)){if(d.indexOf(p)!==-1)throw Error("Circular reference detected in "+m.join("."));d.push(p),I.forEach(p,function(v,w){(!(I.isUndefined(v)||v===null)&&o.call(e,v,I.isString(w)?w.trim():w,m,f))===!0&&h(v,m?m.concat(w):[w])}),d.pop()}}if(!I.isObject(t))throw new TypeError("data must be an object");return h(t),e}function qv(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function Wf(t,e){this._pairs=[],t&&cc(t,this,e)}const Kv=Wf.prototype;Kv.append=function(e,n){this._pairs.push([e,n])},Kv.toString=function(e){const n=e?function(r){return e.call(this,r,qv)}:qv;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function yR(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Yv(t,e,n){if(!e)return t;const r=n&&n.encode||yR;I.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let s;if(o?s=o(e,n):s=I.isURLSearchParams(e)?e.toString():new Wf(e,n).toString(r),s){const i=t.indexOf("#");i!==-1&&(t=t.slice(0,i)),t+=(t.indexOf("?")===-1?"?":"&")+s}return t}class Jv{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){I.forEach(this.handlers,function(r){r!==null&&e(r)})}}const Xv={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},vR={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Wf,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Gf=typeof window<"u"&&typeof document<"u",qf=typeof navigator=="object"&&navigator||void 0,bR=Gf&&(!qf||["ReactNative","NativeScript","NS"].indexOf(qf.product)<0),xR=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",wR=Gf&&window.location.href||"http://localhost",Kt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Gf,hasStandardBrowserEnv:bR,hasStandardBrowserWebWorkerEnv:xR,navigator:qf,origin:wR},Symbol.toStringTag,{value:"Module"})),...vR};function ER(t,e){return cc(t,new Kt.classes.URLSearchParams,{visitor:function(n,r,o,s){return Kt.isNode&&I.isBuffer(n)?(this.append(r,n.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...e})}function SR(t){return I.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function kR(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 Qv(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&&I.isArray(o)?o.length:i,l?(I.hasOwnProp(o,i)?o[i]=[o[i],r]:o[i]=r,!a):((!o[i]||!I.isObject(o[i]))&&(o[i]=[]),e(n,r,o[i],s)&&I.isArray(o[i])&&(o[i]=kR(o[i])),!a)}if(I.isFormData(t)&&I.isFunction(t.entries)){const n={};return I.forEachEntry(t,(r,o)=>{e(SR(r),o,n,0)}),n}return null}function CR(t,e,n){if(I.isString(t))try{return(e||JSON.parse)(t),I.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}const fa={transitional:Xv,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,s=I.isObject(e);if(s&&I.isHTMLForm(e)&&(e=new FormData(e)),I.isFormData(e))return o?JSON.stringify(Qv(e)):e;if(I.isArrayBuffer(e)||I.isBuffer(e)||I.isStream(e)||I.isFile(e)||I.isBlob(e)||I.isReadableStream(e))return e;if(I.isArrayBufferView(e))return e.buffer;if(I.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 ER(e,this.formSerializer).toString();if((a=I.isFileList(e))||r.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return cc(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return s||o?(n.setContentType("application/json",!1),CR(e)):e}],transformResponse:[function(e){const n=this.transitional||fa.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(I.isResponse(e)||I.isReadableStream(e))return e;if(e&&I.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:Kt.classes.FormData,Blob:Kt.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};I.forEach(["delete","get","head","post","put","patch"],t=>{fa.headers[t]={}});const TR=I.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"]),AR=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]&&TR[n])&&(n==="set-cookie"?e[n]?e[n].push(r):e[n]=[r]:e[n]=e[n]?e[n]+", "+r:r)}),e},Zv=Symbol("internals");function ha(t){return t&&String(t).trim().toLowerCase()}function uc(t){return t===!1||t==null?t:I.isArray(t)?t.map(uc):String(t)}function MR(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 OR=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function Kf(t,e,n,r,o){if(I.isFunction(r))return r.call(this,e,n);if(o&&(e=n),!!I.isString(e)){if(I.isString(r))return e.indexOf(r)!==-1;if(I.isRegExp(r))return r.test(e)}}function _R(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,r)=>n.toUpperCase()+r)}function NR(t,e){const n=I.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 mn=class{constructor(e){e&&this.set(e)}set(e,n,r){const o=this;function s(a,l,c){const u=ha(l);if(!u)throw new Error("header name must be a non-empty string");const d=I.findKey(o,u);(!d||o[d]===void 0||c===!0||c===void 0&&o[d]!==!1)&&(o[d||l]=uc(a))}const i=(a,l)=>I.forEach(a,(c,u)=>s(c,u,l));if(I.isPlainObject(e)||e instanceof this.constructor)i(e,n);else if(I.isString(e)&&(e=e.trim())&&!OR(e))i(AR(e),n);else if(I.isObject(e)&&I.isIterable(e)){let a={},l,c;for(const u of e){if(!I.isArray(u))throw TypeError("Object iterator must return a key-value pair");a[c=u[0]]=(l=a[c])?I.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=ha(e),e){const r=I.findKey(this,e);if(r){const o=this[r];if(!n)return o;if(n===!0)return MR(o);if(I.isFunction(n))return n.call(this,o,r);if(I.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=ha(e),e){const r=I.findKey(this,e);return!!(r&&this[r]!==void 0&&(!n||Kf(this,this[r],r,n)))}return!1}delete(e,n){const r=this;let o=!1;function s(i){if(i=ha(i),i){const a=I.findKey(r,i);a&&(!n||Kf(r,r[a],a,n))&&(delete r[a],o=!0)}}return I.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||Kf(this,this[s],s,e,!0))&&(delete this[s],o=!0)}return o}normalize(e){const n=this,r={};return I.forEach(this,(o,s)=>{const i=I.findKey(r,s);if(i){n[i]=uc(o),delete n[s];return}const a=e?_R(s):String(s).trim();a!==s&&delete n[s],n[a]=uc(o),r[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const n=Object.create(null);return I.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=e&&I.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[Zv]=this[Zv]={accessors:{}}).accessors,o=this.prototype;function s(i){const a=ha(i);r[a]||(NR(o,i),r[a]=!0)}return I.isArray(e)?e.forEach(s):s(e),this}};mn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),I.reduceDescriptors(mn.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[n]=r}}}),I.freezeMethods(mn);function Yf(t,e){const n=this||fa,r=e||n,o=mn.from(r.headers);let s=r.data;return I.forEach(t,function(a){s=a.call(n,s,o.normalize(),e?e.status:void 0)}),o.normalize(),s}function eb(t){return!!(t&&t.__CANCEL__)}function oi(t,e,n){Te.call(this,t??"canceled",Te.ERR_CANCELED,e,n),this.name="CanceledError"}I.inherits(oi,Te,{__CANCEL__:!0});function tb(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 RR(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function IR(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 DR(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 dc=(t,e,n=3)=>{let r=0;const o=IR(50,250);return DR(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)},nb=(t,e)=>{const n=t!=null;return[r=>e[0]({lengthComputable:n,total:t,loaded:r}),e[1]]},rb=t=>(...e)=>I.asap(()=>t(...e)),PR=Kt.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,Kt.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(Kt.origin),Kt.navigator&&/(msie|trident)/i.test(Kt.navigator.userAgent)):()=>!0,LR=Kt.hasStandardBrowserEnv?{write(t,e,n,r,o,s){const i=[t+"="+encodeURIComponent(e)];I.isNumber(n)&&i.push("expires="+new Date(n).toGMTString()),I.isString(r)&&i.push("path="+r),I.isString(o)&&i.push("domain="+o),s===!0&&i.push("secure"),document.cookie=i.join("; ")},read(t){const e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove(t){this.write(t,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function jR(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function $R(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function ob(t,e,n){let r=!jR(e);return t&&(r||n==!1)?$R(t,e):e}const sb=t=>t instanceof mn?{...t}:t;function ms(t,e){e=e||{};const n={};function r(c,u,d,f){return I.isPlainObject(c)&&I.isPlainObject(u)?I.merge.call({caseless:f},c,u):I.isPlainObject(u)?I.merge({},u):I.isArray(u)?u.slice():u}function o(c,u,d,f){if(I.isUndefined(u)){if(!I.isUndefined(c))return r(void 0,c,d,f)}else return r(c,u,d,f)}function s(c,u){if(!I.isUndefined(u))return r(void 0,u)}function i(c,u){if(I.isUndefined(u)){if(!I.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(sb(c),sb(u),d,!0)};return I.forEach(Object.keys({...t,...e}),function(u){const d=l[u]||o,f=d(t[u],e[u],u);I.isUndefined(f)&&d!==a||(n[u]=f)}),n}const ib=t=>{const e=ms({},t);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:s,headers:i,auth:a}=e;if(e.headers=i=mn.from(i),e.url=Yv(ob(e.baseURL,e.url,e.allowAbsoluteUrls),t.params,t.paramsSerializer),a&&i.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),I.isFormData(n)){if(Kt.hasStandardBrowserEnv||Kt.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(I.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(Kt.hasStandardBrowserEnv&&(r&&I.isFunction(r)&&(r=r(e)),r||r!==!1&&PR(e.url))){const l=o&&s&&LR.read(s);l&&i.set(o,l)}return e},BR=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(n,r){const o=ib(t);let s=o.data;const i=mn.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 y=new XMLHttpRequest;y.open(o.method.toUpperCase(),o.url,!0),y.timeout=o.timeout;function v(){if(!y)return;const E=mn.from("getAllResponseHeaders"in y&&y.getAllResponseHeaders()),k={data:!a||a==="text"||a==="json"?y.responseText:y.response,status:y.status,statusText:y.statusText,headers:E,config:t,request:y};tb(function(C){n(C),m()},function(C){r(C),m()},k),y=null}"onloadend"in y?y.onloadend=v:y.onreadystatechange=function(){!y||y.readyState!==4||y.status===0&&!(y.responseURL&&y.responseURL.indexOf("file:")===0)||setTimeout(v)},y.onabort=function(){y&&(r(new Te("Request aborted",Te.ECONNABORTED,t,y)),y=null)},y.onerror=function(x){const k=x&&x.message?x.message:"Network Error",S=new Te(k,Te.ERR_NETWORK,t,y);S.event=x||null,r(S),y=null},y.ontimeout=function(){let x=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const k=o.transitional||Xv;o.timeoutErrorMessage&&(x=o.timeoutErrorMessage),r(new Te(x,k.clarifyTimeoutError?Te.ETIMEDOUT:Te.ECONNABORTED,t,y)),y=null},s===void 0&&i.setContentType(null),"setRequestHeader"in y&&I.forEach(i.toJSON(),function(x,k){y.setRequestHeader(k,x)}),I.isUndefined(o.withCredentials)||(y.withCredentials=!!o.withCredentials),a&&a!=="json"&&(y.responseType=o.responseType),c&&([f,p]=dc(c,!0),y.addEventListener("progress",f)),l&&y.upload&&([d,h]=dc(l),y.upload.addEventListener("progress",d),y.upload.addEventListener("loadend",h)),(o.cancelToken||o.signal)&&(u=E=>{y&&(r(!E||E.type?new oi(null,t,y):E),y.abort(),y=null)},o.cancelToken&&o.cancelToken.subscribe(u),o.signal&&(o.signal.aborted?u():o.signal.addEventListener("abort",u)));const w=RR(o.url);if(w&&Kt.protocols.indexOf(w)===-1){r(new Te("Unsupported protocol "+w+":",Te.ERR_BAD_REQUEST,t));return}y.send(s||null)})},FR=(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 oi(u instanceof Error?u.message:u))}};let i=e&&setTimeout(()=>{i=null,s(new Te(`timeout ${e} of 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=()=>I.asap(a),l}},HR=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},zR=async function*(t,e){for await(const n of UR(t))yield*HR(n,e)},UR=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()}},ab=(t,e,n,r)=>{const o=zR(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})},lb=64*1024,{isFunction:fc}=I,VR=(({Request:t,Response:e})=>({Request:t,Response:e}))(I.global),{ReadableStream:cb,TextEncoder:ub}=I.global,db=(t,...e)=>{try{return!!t(...e)}catch{return!1}},WR=t=>{t=I.merge.call({skipUndefined:!0},VR,t);const{fetch:e,Request:n,Response:r}=t,o=e?fc(e):typeof fetch=="function",s=fc(n),i=fc(r);if(!o)return!1;const a=o&&fc(cb),l=o&&(typeof ub=="function"?(p=>m=>p.encode(m))(new ub):async p=>new Uint8Array(await new n(p).arrayBuffer())),c=s&&a&&db(()=>{let p=!1;const m=new n(Kt.origin,{body:new cb,method:"POST",get duplex(){return p=!0,"half"}}).headers.has("Content-Type");return p&&!m}),u=i&&a&&db(()=>I.isReadableStream(new r("").body)),d={stream:u&&(p=>p.body)};o&&["text","arrayBuffer","blob","formData","stream"].forEach(p=>{!d[p]&&(d[p]=(m,y)=>{let v=m&&m[p];if(v)return v.call(m);throw new Te(`Response type '${p}' is not supported`,Te.ERR_NOT_SUPPORT,y)})});const f=async p=>{if(p==null)return 0;if(I.isBlob(p))return p.size;if(I.isSpecCompliantForm(p))return(await new n(Kt.origin,{method:"POST",body:p}).arrayBuffer()).byteLength;if(I.isArrayBufferView(p)||I.isArrayBuffer(p))return p.byteLength;if(I.isURLSearchParams(p)&&(p=p+""),I.isString(p))return(await l(p)).byteLength},h=async(p,m)=>{const y=I.toFiniteNumber(p.getContentLength());return y??f(m)};return async p=>{let{url:m,method:y,data:v,signal:w,cancelToken:E,timeout:x,onDownloadProgress:k,onUploadProgress:S,responseType:C,headers:T,withCredentials:N="same-origin",fetchOptions:_}=ib(p),L=e||fetch;C=C?(C+"").toLowerCase():"text";let $=FR([w,E&&E.toAbortSignal()],x),B=null;const z=$&&$.unsubscribe&&(()=>{$.unsubscribe()});let j;try{if(S&&c&&y!=="get"&&y!=="head"&&(j=await h(T,v))!==0){let ne=new n(m,{method:"POST",body:v,duplex:"half"}),ye;if(I.isFormData(v)&&(ye=ne.headers.get("content-type"))&&T.setContentType(ye),ne.body){const[G,Z]=nb(j,dc(rb(S)));v=ab(ne.body,lb,G,Z)}}I.isString(N)||(N=N?"include":"omit");const P=s&&"credentials"in n.prototype,H={..._,signal:$,method:y.toUpperCase(),headers:T.normalize().toJSON(),body:v,duplex:"half",credentials:P?N:void 0};B=s&&new n(m,H);let R=await(s?L(B,_):L(m,H));const V=u&&(C==="stream"||C==="response");if(u&&(k||V&&z)){const ne={};["status","statusText","headers"].forEach(J=>{ne[J]=R[J]});const ye=I.toFiniteNumber(R.headers.get("content-length")),[G,Z]=k&&nb(ye,dc(rb(k),!0))||[];R=new r(ab(R.body,lb,G,()=>{Z&&Z(),z&&z()}),ne)}C=C||"text";let ie=await d[I.findKey(d,C)||"text"](R,p);return!V&&z&&z(),await new Promise((ne,ye)=>{tb(ne,ye,{data:ie,headers:mn.from(R.headers),status:R.status,statusText:R.statusText,config:p,request:B})})}catch(P){throw z&&z(),P&&P.name==="TypeError"&&/Load failed|fetch/i.test(P.message)?Object.assign(new Te("Network Error",Te.ERR_NETWORK,p,B),{cause:P.cause||P}):Te.from(P,P&&P.code,p,B)}}},GR=new Map,fb=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=GR;for(;a--;)l=s[a],c=u.get(l),c===void 0&&u.set(l,c=a?new Map:WR(e)),u=c;return c};fb();const Jf={http:pR,xhr:BR,fetch:{get:fb}};I.forEach(Jf,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const hb=t=>`- ${t}`,qR=t=>I.isFunction(t)||t===null||t===!1,pb={getAdapter:(t,e)=>{t=I.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,!qR(r)&&(o=Jf[(a=String(r)).toLowerCase()],o===void 0))throw new Te(`Unknown adapter '${a}'`);if(o&&(I.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(hb).join(`
5
- `):" "+hb(i[0]):"as no adapter specified";throw new Te("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return o},adapters:Jf};function Xf(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new oi(null,t)}function mb(t){return Xf(t),t.headers=mn.from(t.headers),t.data=Yf.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),pb.getAdapter(t.adapter||fa.adapter,t)(t).then(function(r){return Xf(t),r.data=Yf.call(t,t.transformResponse,r),r.headers=mn.from(r.headers),r},function(r){return eb(r)||(Xf(t),r&&r.response&&(r.response.data=Yf.call(t,t.transformResponse,r.response),r.response.headers=mn.from(r.response.headers))),Promise.reject(r)})}const gb="1.12.2",hc={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{hc[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}});const yb={};hc.transitional=function(e,n,r){function o(s,i){return"[Axios v"+gb+"] 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&&!yb[i]&&(yb[i]=!0,console.warn(o(i," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(s,i,a):!0}},hc.spelling=function(e){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};function KR(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 pc={assertOptions:KR,validators:hc},kr=pc.validators;let gs=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Jv,response:new Jv}}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=ms(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:s}=n;r!==void 0&&pc.assertOptions(r,{silentJSONParsing:kr.transitional(kr.boolean),forcedJSONParsing:kr.transitional(kr.boolean),clarifyTimeoutError:kr.transitional(kr.boolean)},!1),o!=null&&(I.isFunction(o)?n.paramsSerializer={serialize:o}:pc.assertOptions(o,{encode:kr.function,serialize:kr.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),pc.assertOptions(n,{baseUrl:kr.spelling("baseURL"),withXsrfToken:kr.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=s&&I.merge(s.common,s[n.method]);s&&I.forEach(["delete","get","head","post","put","patch","common"],p=>{delete s[p]}),n.headers=mn.concat(i,s);const a=[];let l=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(l=l&&m.synchronous,a.unshift(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=[mb.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(y){m.call(this,y);break}}try{u=mb.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=ms(this.defaults,e);const n=ob(e.baseURL,e.url,e.allowAbsoluteUrls);return Yv(n,e.params,e.paramsSerializer)}};I.forEach(["delete","get","head","options"],function(e){gs.prototype[e]=function(n,r){return this.request(ms(r||{},{method:e,url:n,data:(r||{}).data}))}}),I.forEach(["post","put","patch"],function(e){function n(r){return function(s,i,a){return this.request(ms(a||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:s,data:i}))}}gs.prototype[e]=n(),gs.prototype[e+"Form"]=n(!0)});let YR=class EN{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 oi(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 EN(function(o){e=o}),cancel:e}}};function JR(t){return function(n){return t.apply(null,n)}}function XR(t){return I.isObject(t)&&t.isAxiosError===!0}const Qf={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};Object.entries(Qf).forEach(([t,e])=>{Qf[e]=t});function vb(t){const e=new gs(t),n=Dv(gs.prototype.request,e);return I.extend(n,gs.prototype,e,{allOwnKeys:!0}),I.extend(n,e,null,{allOwnKeys:!0}),n.create=function(o){return vb(ms(t,o))},n}const ft=vb(fa);ft.Axios=gs,ft.CanceledError=oi,ft.CancelToken=YR,ft.isCancel=eb,ft.VERSION=gb,ft.toFormData=cc,ft.AxiosError=Te,ft.Cancel=ft.CanceledError,ft.all=function(e){return Promise.all(e)},ft.spread=JR,ft.isAxiosError=XR,ft.mergeConfig=ms,ft.AxiosHeaders=mn,ft.formToJSON=t=>Qv(I.isHTMLForm(t)?new FormData(t):t),ft.getAdapter=pb.getAdapter,ft.HttpStatusCode=Qf,ft.default=ft;const{Axios:eee,AxiosError:bb,CanceledError:tee,isCancel:nee,CancelToken:ree,VERSION:oee,all:see,Cancel:iee,isAxiosError:aee,spread:lee,toFormData:cee,AxiosHeaders:uee,HttpStatusCode:dee,formToJSON:fee,getAdapter:hee,mergeConfig:pee}=ft;var mc=(t=>(t.Post="post",t.Comment="comment",t))(mc||{}),xb=(t=>(t[t.POST=0]="POST",t[t.FEATURED_POST=1]="FEATURED_POST",t))(xb||{}),Zf=(t=>(t.User="mention",t.Group="hashtag",t))(Zf||{}),pa=(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))(pa||{}),be=(t=>(t.Image="image",t.Video="video",t.Audio="audio",t.File="file",t))(be||{}),To=(t=>(t.MEDIA_ITEM="mediaItem",t.IMAGE_ITEM="imageItem",t))(To||{}),eh=(t=>(t.Gif="GifSearch",t.Image="ImageSearch",t))(eh||{}),ht=(t=>(t.Text="Text",t.Media="Media",t.Link="Link",t.Poll="Poll",t))(ht||{}),Ze=(t=>(t.LEFT="left",t.CENTER="center",t.RIGHT="right",t))(Ze||{}),gc=(t=>(t.Compact="compact",t.Extended="extended",t))(gc||{}),yc=(t=>(t.POLL_TEXT_ITEM="pollTextItem",t.POLL_IMAGE_ITEM="pollImageItem",t.POLL_MEDIA_ITEM="pollMediaItem",t))(yc||{});const QR=300,ZR={[be.Image]:"img",[be.Video]:"video",[be.Audio]:"audio",[be.File]:"div"},eI={[be.Image]:"image/*",[be.Video]:"video/*",[be.Audio]:"audio/*",[be.File]:"file/*"},Cr={http:{CLIENT_ERROR:"http_client_error",UNAUTHORIZED:"invalid_jwt_token",SERVER_ERROR:"http_server_error",NETWORK_ERROR:"http_network_error",UNKNOWN_ERROR:"http_unknown_error",NOT_FOUND:"general_no_result",ENTITY_TOO_LARGE:"image_upload_file_size_too_big"}},tI=20,wb={images:"scrollableDiv-images",gifs:"scrollableDiv-gifs"},nI=300*1e3,ma=10,rI=50*1024*1024;class qr extends Error{httpCode=0;static className="HTTPError";constructor(e,n){super(e),this.name=qr.className,this.message=e,this.httpCode=n}}function vc(t,e,n){if(t&&t instanceof bb&&!t.isAxiosError)throw t;if(!t)throw new qr(e(Cr.http.UNKNOWN_ERROR),0);if(t instanceof bb){const{response:r}=t;if(!r||!r.status)throw new qr(e(Cr.http.NETWORK_ERROR),0);const{status:o}=r;if(o&&o<300)return null;throw o&&o>=500&&o<600?new qr(e(Cr.http.SERVER_ERROR),o):o&&o===401?(n(Cr.http.UNAUTHORIZED),new qr(e(Cr.http.UNAUTHORIZED),o)):o&&o===413?new qr(e(Cr.http.ENTITY_TOO_LARGE),o):o&&o>399&&o<500?new qr(e(Cr.http.CLIENT_ERROR),o):new qr(e(Cr.http.UNKNOWN_ERROR),o)}}function bc(t){return t&&t.status?t.status:t&&t.response&&t.response.status?t.response.status:-1}function oI(t){if(!t.response)return"Network error. Please check your internet connection.";const e=bc(t?.response),n=t.response.data,r=n?.message||n?.error||n?.detail;if(r)return r;switch(e){case 400:return"Invalid Request Payload";case 401:return"Authentication required. Please log in.";case 403:return"You do not have permission to perform this action.";case 404:return"The requested resource was not found.";case 422:return"Invalid data provided.";case 429:return"Too many requests. Please try again later.";case 500:case 502:case 503:case 504:return"Server error. Please try again later.";default:return"Something went wrong. Please try again."}}function th(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var nh,Eb;function sI(){if(Eb)return nh;Eb=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 nh=e=>!t.has(e&&e.code),nh}var iI=sI();const aI=th(iI),rh="axios-retry";function Sb(t){const e=["ERR_CANCELED","ECONNABORTED"];return t.response||!t.code||e.includes(t.code)?!1:aI(t)}const kb=["get","head","options"],lI=kb.concat(["put","delete"]);function oh(t){return t.code!=="ECONNABORTED"&&(!t.response||t.response.status===429||t.response.status>=500&&t.response.status<=599)}function cI(t){return t.config?.method?oh(t)&&kb.indexOf(t.config.method)!==-1:!1}function Cb(t){return t.config?.method?oh(t)&&lI.indexOf(t.config.method)!==-1:!1}function Tb(t){return Sb(t)||Cb(t)}function sh(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 uI(t=0,e=void 0){return Math.max(0,sh(e))}function dI(t=0,e=void 0,n=100){const r=2**t*n,o=Math.max(r,sh(e)),s=o*.2*Math.random();return o+s}function fI(t=100){return(e=0,n=void 0)=>{const r=e*t;return Math.max(r,sh(n))}}const hI={retries:3,retryCondition:Tb,retryDelay:uI,shouldResetTimeout:!1,onRetry:()=>{},onMaxRetryTimesExceeded:()=>{},validateResponse:null};function pI(t,e){return{...hI,...e,...t[rh]}}function Ab(t,e,n=!1){const r=pI(t,e||{});return r.retryCount=r.retryCount||0,(!r.lastRequestTime||n)&&(r.lastRequestTime=Date.now()),t[rh]=r,r}function mI(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 gI(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 yI(t,e,n,r){e.retryCount+=1;const{retryDelay:o,shouldResetTimeout:s,onRetry:i}=e,a=o(e.retryCount,n);if(mI(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 vI(t,e){t.retryCount>=t.retries&&await t.onMaxRetryTimesExceeded(e,t.retryCount)}const Kr=(t,e)=>{const n=t.interceptors.request.use(o=>(Ab(o,e,!0),o[rh]?.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=Ab(s,e);return o.response&&i.validateResponse?.(o.response)?o.response:await gI(i,o)?yI(t,i,o,s):(await vI(i,o),Promise.reject(o))});return{requestInterceptorId:n,responseInterceptorId:r}};Kr.isNetworkError=Sb,Kr.isSafeRequestError=cI,Kr.isIdempotentRequestError=Cb,Kr.isNetworkOrIdempotentRequestError=Tb,Kr.exponentialDelay=dI,Kr.linearDelay=fI,Kr.isRetryableError=oh;function bI(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 xI=t=>{switch(t){case"success":return SI;case"info":return CI;case"warning":return kI;case"error":return TI;default:return null}},wI=Array(12).fill(0),EI=({visible:t,className:e})=>M.createElement("div",{className:["sonner-loading-wrapper",e].filter(Boolean).join(" "),"data-visible":t},M.createElement("div",{className:"sonner-spinner"},wI.map((n,r)=>M.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),SI=M.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},M.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"})),kI=M.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},M.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"})),CI=M.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},M.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"})),TI=M.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},M.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"})),AI=M.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"},M.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),M.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),MI=()=>{const[t,e]=M.useState(document.hidden);return M.useEffect(()=>{const n=()=>{e(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),t};let ih=1;class OI{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:ih++,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],M.isValidElement(c))s=!1,this.create({id:r,type:"default",message:c});else if(NI(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"&&!M.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"&&!M.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"&&!M.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"&&!M.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||ih++;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 gn=new OI,_I=(t,e)=>{const n=e?.id||ih++;return gn.addToast({title:t,...e,id:n}),n},NI=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",RI=_I,II=()=>gn.toasts,DI=()=>gn.getActiveToasts(),Ao=Object.assign(RI,{success:gn.success,info:gn.info,warning:gn.warning,error:gn.error,custom:gn.custom,message:gn.message,promise:gn.promise,dismiss:gn.dismiss,loading:gn.loading},{getHistory:II,getToasts:DI});bI("[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 xc(t){return t.label!==void 0}const PI=3,LI="24px",jI="16px",Mb=4e3,$I=356,BI=14,FI=45,HI=200;function Tr(...t){return t.filter(Boolean).join(" ")}function zI(t){const[e,n]=t.split("-"),r=[];return e&&r.push(e),n&&r.push(n),r}const UI=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:y,index:v,toasts:w,expanded:E,removeToast:x,defaultRichColors:k,closeButton:S,style:C,cancelButtonStyle:T,actionButtonStyle:N,className:_="",descriptionClassName:L="",duration:$,position:B,gap:z,expandByDefault:j,classNames:P,icons:H,closeButtonAriaLabel:R="Close toast"}=t,[V,ie]=M.useState(null),[ne,ye]=M.useState(null),[G,Z]=M.useState(!1),[J,me]=M.useState(!1),[U,ee]=M.useState(!1),[Oe,he]=M.useState(!1),[we,Se]=M.useState(!1),[Ve,ut]=M.useState(0),[dt,Ot]=M.useState(0),yt=M.useRef(d.duration||$||Mb),_t=M.useRef(null),xt=M.useRef(null),Nt=v===0,Gt=v+1<=m,it=d.type,Rt=d.dismissible!==!1,Tn=d.className||"",An=d.descriptionClassName||"",Bt=M.useMemo(()=>y.findIndex(ve=>ve.toastId===d.id)||0,[y,d.id]),fn=M.useMemo(()=>{var ve;return(ve=d.closeButton)!=null?ve:S},[d.closeButton,S]),er=M.useMemo(()=>d.duration||$||Mb,[d.duration,$]),Vr=M.useRef(0),$n=M.useRef(0),Wr=M.useRef(0),hn=M.useRef(null),[Sr,D]=B.split("-"),X=M.useMemo(()=>y.reduce((ve,Ke,Ee)=>Ee>=Bt?ve:ve+Ke.height,0),[y,Bt]),ae=MI(),De=d.invert||u,ke=it==="loading";$n.current=M.useMemo(()=>Bt*z+X,[Bt,X]),M.useEffect(()=>{yt.current=er},[er]),M.useEffect(()=>{Z(!0)},[]),M.useEffect(()=>{const ve=xt.current;if(ve){const Ke=ve.getBoundingClientRect().height;return Ot(Ke),p(Ee=>[{toastId:d.id,height:Ke,position:d.position},...Ee]),()=>p(Ee=>Ee.filter(at=>at.toastId!==d.id))}},[p,d.id]),M.useLayoutEffect(()=>{if(!G)return;const ve=xt.current,Ke=ve.style.height;ve.style.height="auto";const Ee=ve.getBoundingClientRect().height;ve.style.height=Ke,Ot(Ee),p(at=>at.find(Qe=>Qe.toastId===d.id)?at.map(Qe=>Qe.toastId===d.id?{...Qe,height:Ee}:Qe):[{toastId:d.id,height:Ee,position:d.position},...at])},[G,d.title,d.description,p,d.id,d.jsx,d.action,d.cancel]);const qe=M.useCallback(()=>{me(!0),ut($n.current),p(ve=>ve.filter(Ke=>Ke.toastId!==d.id)),setTimeout(()=>{x(d)},HI)},[d,x,p,$n]);M.useEffect(()=>{if(d.promise&&it==="loading"||d.duration===1/0||d.type==="loading")return;let ve;return E||h||ae?(()=>{if(Wr.current<Vr.current){const at=new Date().getTime()-Vr.current;yt.current=yt.current-at}Wr.current=new Date().getTime()})():(()=>{yt.current!==1/0&&(Vr.current=new Date().getTime(),ve=setTimeout(()=>{d.onAutoClose==null||d.onAutoClose.call(d,d),qe()},yt.current))})(),()=>clearTimeout(ve)},[E,h,d,it,ae,qe]),M.useEffect(()=>{d.delete&&(qe(),d.onDismiss==null||d.onDismiss.call(d,d))},[qe,d.delete]);function wt(){var ve;if(H?.loading){var Ke;return M.createElement("div",{className:Tr(P?.loader,d==null||(Ke=d.classNames)==null?void 0:Ke.loader,"sonner-loader"),"data-visible":it==="loading"},H.loading)}return M.createElement(EI,{className:Tr(P?.loader,d==null||(ve=d.classNames)==null?void 0:ve.loader),visible:it==="loading"})}const en=d.icon||H?.[it]||xI(it);var Gr,Ft;return M.createElement("li",{tabIndex:0,ref:xt,className:Tr(_,Tn,P?.toast,d==null||(e=d.classNames)==null?void 0:e.toast,P?.default,P?.[it],d==null||(n=d.classNames)==null?void 0:n[it]),"data-sonner-toast":"","data-rich-colors":(Gr=d.richColors)!=null?Gr:k,"data-styled":!(d.jsx||d.unstyled||f),"data-mounted":G,"data-promise":!!d.promise,"data-swiped":we,"data-removed":J,"data-visible":Gt,"data-y-position":Sr,"data-x-position":D,"data-index":v,"data-front":Nt,"data-swiping":U,"data-dismissible":Rt,"data-type":it,"data-invert":De,"data-swipe-out":Oe,"data-swipe-direction":ne,"data-expanded":!!(E||j&&G),"data-testid":d.testId,style:{"--index":v,"--toasts-before":v,"--z-index":w.length-v,"--offset":`${J?Ve:$n.current}px`,"--initial-height":j?"auto":`${dt}px`,...C,...d.style},onDragEnd:()=>{ee(!1),ie(null),hn.current=null},onPointerDown:ve=>{ve.button!==2&&(ke||!Rt||(_t.current=new Date,ut($n.current),ve.target.setPointerCapture(ve.pointerId),ve.target.tagName!=="BUTTON"&&(ee(!0),hn.current={x:ve.clientX,y:ve.clientY})))},onPointerUp:()=>{var ve,Ke,Ee;if(Oe||!Rt)return;hn.current=null;const at=Number(((ve=xt.current)==null?void 0:ve.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),tr=Number(((Ke=xt.current)==null?void 0:Ke.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Qe=new Date().getTime()-((Ee=_t.current)==null?void 0:Ee.getTime()),A=V==="x"?at:tr,W=Math.abs(A)/Qe;if(Math.abs(A)>=FI||W>.11){ut($n.current),d.onDismiss==null||d.onDismiss.call(d,d),ye(V==="x"?at>0?"right":"left":tr>0?"down":"up"),qe(),he(!0);return}else{var Y,ce;(Y=xt.current)==null||Y.style.setProperty("--swipe-amount-x","0px"),(ce=xt.current)==null||ce.style.setProperty("--swipe-amount-y","0px")}Se(!1),ee(!1),ie(null)},onPointerMove:ve=>{var Ke,Ee,at;if(!hn.current||!Rt||((Ke=window.getSelection())==null?void 0:Ke.toString().length)>0)return;const Qe=ve.clientY-hn.current.y,A=ve.clientX-hn.current.x;var W;const Y=(W=t.swipeDirections)!=null?W:zI(B);!V&&(Math.abs(A)>1||Math.abs(Qe)>1)&&ie(Math.abs(A)>Math.abs(Qe)?"x":"y");let ce={x:0,y:0};const Ne=Ce=>1/(1.5+Math.abs(Ce)/20);if(V==="y"){if(Y.includes("top")||Y.includes("bottom"))if(Y.includes("top")&&Qe<0||Y.includes("bottom")&&Qe>0)ce.y=Qe;else{const Ce=Qe*Ne(Qe);ce.y=Math.abs(Ce)<Math.abs(Qe)?Ce:Qe}}else if(V==="x"&&(Y.includes("left")||Y.includes("right")))if(Y.includes("left")&&A<0||Y.includes("right")&&A>0)ce.x=A;else{const Ce=A*Ne(A);ce.x=Math.abs(Ce)<Math.abs(A)?Ce:A}(Math.abs(ce.x)>0||Math.abs(ce.y)>0)&&Se(!0),(Ee=xt.current)==null||Ee.style.setProperty("--swipe-amount-x",`${ce.x}px`),(at=xt.current)==null||at.style.setProperty("--swipe-amount-y",`${ce.y}px`)}},fn&&!d.jsx&&it!=="loading"?M.createElement("button",{"aria-label":R,"data-disabled":ke,"data-close-button":!0,onClick:ke||!Rt?()=>{}:()=>{qe(),d.onDismiss==null||d.onDismiss.call(d,d)},className:Tr(P?.closeButton,d==null||(r=d.classNames)==null?void 0:r.closeButton)},(Ft=H?.close)!=null?Ft:AI):null,(it||d.icon||d.promise)&&d.icon!==null&&(H?.[it]!==null||d.icon)?M.createElement("div",{"data-icon":"",className:Tr(P?.icon,d==null||(o=d.classNames)==null?void 0:o.icon)},d.promise||d.type==="loading"&&!d.icon?d.icon||wt():null,d.type!=="loading"?en:null):null,M.createElement("div",{"data-content":"",className:Tr(P?.content,d==null||(s=d.classNames)==null?void 0:s.content)},M.createElement("div",{"data-title":"",className:Tr(P?.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?M.createElement("div",{"data-description":"",className:Tr(L,An,P?.description,d==null||(a=d.classNames)==null?void 0:a.description)},typeof d.description=="function"?d.description():d.description):null),M.isValidElement(d.cancel)?d.cancel:d.cancel&&xc(d.cancel)?M.createElement("button",{"data-button":!0,"data-cancel":!0,style:d.cancelButtonStyle||T,onClick:ve=>{xc(d.cancel)&&Rt&&(d.cancel.onClick==null||d.cancel.onClick.call(d.cancel,ve),qe())},className:Tr(P?.cancelButton,d==null||(l=d.classNames)==null?void 0:l.cancelButton)},d.cancel.label):null,M.isValidElement(d.action)?d.action:d.action&&xc(d.action)?M.createElement("button",{"data-button":!0,"data-action":!0,style:d.actionButtonStyle||N,onClick:ve=>{xc(d.action)&&(d.action.onClick==null||d.action.onClick.call(d.action,ve),!ve.defaultPrevented&&qe())},className:Tr(P?.actionButton,d==null||(c=d.classNames)==null?void 0:c.actionButton)},d.action.label):null)};function Ob(){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 VI(t,e){const n={};return[t,e].forEach((r,o)=>{const s=o===1,i=s?"--mobile-offset":"--offset",a=s?jI:LI;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 WI=M.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:y=PI,toastOptions:v,dir:w=Ob(),gap:E=BI,icons:x,containerAriaLabel:k="Notifications"}=e,[S,C]=M.useState([]),T=M.useMemo(()=>r?S.filter(G=>G.toasterId===r):S.filter(G=>!G.toasterId),[S,r]),N=M.useMemo(()=>Array.from(new Set([s].concat(T.filter(G=>G.position).map(G=>G.position)))),[T,s]),[_,L]=M.useState([]),[$,B]=M.useState(!1),[z,j]=M.useState(!1),[P,H]=M.useState(f!=="system"?f:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),R=M.useRef(null),V=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),ie=M.useRef(null),ne=M.useRef(!1),ye=M.useCallback(G=>{C(Z=>{var J;return(J=Z.find(me=>me.id===G.id))!=null&&J.delete||gn.dismiss(G.id),Z.filter(({id:me})=>me!==G.id)})},[]);return M.useEffect(()=>gn.subscribe(G=>{if(G.dismiss){requestAnimationFrame(()=>{C(Z=>Z.map(J=>J.id===G.id?{...J,delete:!0}:J))});return}setTimeout(()=>{la.flushSync(()=>{C(Z=>{const J=Z.findIndex(me=>me.id===G.id);return J!==-1?[...Z.slice(0,J),{...Z[J],...G},...Z.slice(J+1)]:[G,...Z]})})})}),[S]),M.useEffect(()=>{if(f!=="system"){H(f);return}if(f==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?H("dark"):H("light")),typeof window>"u")return;const G=window.matchMedia("(prefers-color-scheme: dark)");try{G.addEventListener("change",({matches:Z})=>{H(Z?"dark":"light")})}catch{G.addListener(({matches:J})=>{try{H(J?"dark":"light")}catch(me){console.error(me)}})}},[f]),M.useEffect(()=>{S.length<=1&&B(!1)},[S]),M.useEffect(()=>{const G=Z=>{var J;if(i.every(ee=>Z[ee]||Z.code===ee)){var U;B(!0),(U=R.current)==null||U.focus()}Z.code==="Escape"&&(document.activeElement===R.current||(J=R.current)!=null&&J.contains(document.activeElement))&&B(!1)};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},[i]),M.useEffect(()=>{if(R.current)return()=>{ie.current&&(ie.current.focus({preventScroll:!0}),ie.current=null,ne.current=!1)}},[R.current]),M.createElement("section",{ref:n,"aria-label":`${k} ${V}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},N.map((G,Z)=>{var J;const[me,U]=G.split("-");return T.length?M.createElement("ol",{key:G,dir:w==="auto"?Ob():w,tabIndex:-1,ref:R,className:c,"data-sonner-toaster":!0,"data-sonner-theme":P,"data-y-position":me,"data-x-position":U,style:{"--front-toast-height":`${((J=_[0])==null?void 0:J.height)||0}px`,"--width":`${$I}px`,"--gap":`${E}px`,...m,...VI(u,d)},onBlur:ee=>{ne.current&&!ee.currentTarget.contains(ee.relatedTarget)&&(ne.current=!1,ie.current&&(ie.current.focus({preventScroll:!0}),ie.current=null))},onFocus:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||ne.current||(ne.current=!0,ie.current=ee.relatedTarget)},onMouseEnter:()=>B(!0),onMouseMove:()=>B(!0),onMouseLeave:()=>{z||B(!1)},onDragEnd:()=>B(!1),onPointerDown:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||j(!0)},onPointerUp:()=>j(!1)},T.filter(ee=>!ee.position&&Z===0||ee.position===G).map((ee,Oe)=>{var he,we;return M.createElement(UI,{key:ee.id,icons:x,index:Oe,toast:ee,defaultRichColors:h,duration:(he=v?.duration)!=null?he:p,className:v?.className,descriptionClassName:v?.descriptionClassName,invert:o,visibleToasts:y,closeButton:(we=v?.closeButton)!=null?we:l,interacting:z,position:G,style:v?.style,unstyled:v?.unstyled,classNames:v?.classNames,cancelButtonStyle:v?.cancelButtonStyle,actionButtonStyle:v?.actionButtonStyle,closeButtonAriaLabel:v?.closeButtonAriaLabel,removeToast:ye,toasts:T.filter(Se=>Se.position==ee.position),heights:_.filter(Se=>Se.position==ee.position),setHeights:L,expandByDefault:a,gap:E,expanded:$,swipeDirections:e.swipeDirections})})):null}))}),GI=18e4,qI="http://localhost:3000/api",_b=()=>"en-US";function ah(t){const{token:e,baseURL:n=qI,timeout:r=GI}=t,o=ft.create({baseURL:n,timeout:r,headers:{"accept-encoding":"gzip","Content-Type":t.isFileStore?"multipart/form-data":"application/json",...t.isFileStore?{}:{"content-language":_b()}},...t.isFileStore?{}:{withCredentials:!0},validateStatus:s=>s<300});return Kr(o,{retries:3,retryDelay:Kr.exponentialDelay,retryCondition:s=>{const i=bc(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=oI(s);return Ao.error(i),vc(s,t.t,()=>{}),Promise.reject(s)}),o}const Nb=new Map,wc=new Map,Ec=(t,e)=>async()=>{const n=Date.now(),r=Nb.get(t);if(r&&n-r.timestamp<nI)return r.data;const o=wc.get(t);if(o)return o.promise;const s=e().then(i=>(Nb.set(t,{data:i,timestamp:n}),wc.delete(t),i)).catch(i=>{throw wc.delete(t),i});return wc.set(t,{promise:s,timestamp:n}),s};class KI{isAuthorize;url;language;onError;api;token;toI18N;constructor(e,n,r,o){this.isAuthorize=!1,this.url=`${e}v1/`,this.language=o??_b(),this.onError=()=>{},this.toI18N=r,this.initApi(),this.token=n}setToken(e){this.isAuthorize=!!e,this.token=e}addErrorListener(e){this.onError=e}throwHTTPError(e){return vc(e,this.toI18N,this.onError)}initApi(){this.api=ah({baseURL:this.url,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}getAllGroup(){return this.api.get("/group/").then(e=>e.data).catch(e=>this.throwHTTPError(e))}fetchGroupConversations(e,n){return Ec("group-conversations",()=>this.api.post("/group/fetch/conversations",{amount:e,from_time:n}).then(s=>s.data).catch(s=>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=>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=>this.throwHTTPError(s))}fetchRandomGif(e){return this.api.get("search/gifs/random",{params:{q:e}}).then(n=>n.data).catch(n=>this.throwHTTPError(n))}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=>this.throwHTTPError(o))}fetchTrendyWebImage(e,n){return this.api.get("search/images/trending",{params:{l:e,o:n}}).then(r=>r.data).catch(r=>this.throwHTTPError(r))}resolveUrl(e){return Ec(e,()=>this.api.post("url/resolve",{url:e}).then(o=>o.data).catch(o=>this.throwHTTPError(o)))()}resolveUrlForText(e){return this.api.post("url/resolve-text",{body:e}).then(n=>n.data).catch(n=>this.throwHTTPError(n))}}const Ht=[];for(let t=0;t<256;++t)Ht.push((t+256).toString(16).slice(1));function YI(t,e=0){return(Ht[t[e+0]]+Ht[t[e+1]]+Ht[t[e+2]]+Ht[t[e+3]]+"-"+Ht[t[e+4]]+Ht[t[e+5]]+"-"+Ht[t[e+6]]+Ht[t[e+7]]+"-"+Ht[t[e+8]]+Ht[t[e+9]]+"-"+Ht[t[e+10]]+Ht[t[e+11]]+Ht[t[e+12]]+Ht[t[e+13]]+Ht[t[e+14]]+Ht[t[e+15]]).toLowerCase()}let lh;const JI=new Uint8Array(16);function XI(){if(!lh){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");lh=crypto.getRandomValues.bind(crypto)}return lh(JI)}const Rb={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function QI(t,e,n){t=t||{};const r=t.random??t.rng?.()??XI();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,YI(r)}function Yr(t,e,n){return Rb.randomUUID&&!t?Rb.randomUUID():QI(t)}class ZI{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 vc(e,this.toI18N,()=>{})}setToken(e){this.isAuthorize=!0,this.token=e}initApi(){this.isAuthorize=!1,this.api=ah({baseURL:this.url,t:this.toI18N,token:this.token,isFileStore:!0})}uploadUrl(e){const n={compress:!0,crop_square:!0,source_url:e};return this.api.post("/api/v1/upload/url",n,{headers:{"Content-Type":"application/json"}}).then(r=>r?.data?.data).catch(r=>this.throwHTTPError(r))}uploadImage(e){const n=new FormData;return n.set("file",e),n.set("compress","true"),n.set("target_name",Yr()),this.api.post("/api/v1/upload/file",n).then(r=>r.data?.data??{}).catch(r=>this.throwHTTPError(r))}getFileNameAndExt(e){return e.split("/").pop()}}class eD{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 vc(e,this.toI18N,()=>{})}setToken(e){this.isAuthorize=!0,this.token=e}initApi(){this.api=ah({baseURL:this.url,t:this.toI18N,token:this.token,isFileStore:!1})}getRecommendationPost(e,n,r=0,o=10,s=[],i=[],a="",l=["user_data","post_counter"]){const c=`post-recommendation:${e}${n?`:${n}`:""}`;return Ec(c,()=>this.api.post("/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=>{if([400,404].indexOf(bc(d))>-1)throw new Error(this.toI18N(Cr.http.NOT_FOUND));return this.throwHTTPError(d)}))()}getRecommendationGroup(e,n=0,r=10,o=[],s=[],i="",a=["user_data"]){const l=`group-recommendation:${e}`;return Ec(l,()=>this.api.post("/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=>{if([400,404].indexOf(bc(u))>-1)throw new Error(this.toI18N(Cr.http.NOT_FOUND));return this.throwHTTPError(u)}))()}}const Ib=M.createContext(null),tD=()=>{const t=M.useContext(Ib);if(!t)throw new Error("usePostBuilder must be used within PostBuilderProvider");return t},ga=()=>{const{api:t}=tD();return t};var Sc={exports:{}},si={};/*
7
- object-assign
8
- (c) Sindre Sorhus
9
- @license MIT
10
- */var ch,Db;function Pb(){if(Db)return ch;Db=1;var t=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function r(s){if(s==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(s)}function o(){try{if(!Object.assign)return!1;var s=new String("abc");if(s[5]="de",Object.getOwnPropertyNames(s)[0]==="5")return!1;for(var i={},a=0;a<10;a++)i["_"+String.fromCharCode(a)]=a;var l=Object.getOwnPropertyNames(i).map(function(u){return i[u]});if(l.join("")!=="0123456789")return!1;var c={};return"abcdefghijklmnopqrst".split("").forEach(function(u){c[u]=u}),Object.keys(Object.assign({},c)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return ch=o()?Object.assign:function(s,i){for(var a,l=r(s),c,u=1;u<arguments.length;u++){a=Object(arguments[u]);for(var d in a)e.call(a,d)&&(l[d]=a[d]);if(t){c=t(a);for(var f=0;f<c.length;f++)n.call(a,c[f])&&(l[c[f]]=a[c[f]])}}return l},ch}/** @license React v17.0.2
11
- * react-jsx-runtime.production.min.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var Lb;function nD(){if(Lb)return si;Lb=1,Pb();var t=M,e=60103;if(si.Fragment=60107,typeof Symbol=="function"&&Symbol.for){var n=Symbol.for;e=n("react.element"),si.Fragment=n("react.fragment")}var r=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o=Object.prototype.hasOwnProperty,s={key:!0,ref:!0,__self:!0,__source:!0};function i(a,l,c){var u,d={},f=null,h=null;c!==void 0&&(f=""+c),l.key!==void 0&&(f=""+l.key),l.ref!==void 0&&(h=l.ref);for(u in l)o.call(l,u)&&!s.hasOwnProperty(u)&&(d[u]=l[u]);if(a&&a.defaultProps)for(u in l=a.defaultProps,l)d[u]===void 0&&(d[u]=l[u]);return{$$typeof:e,type:a,key:f,ref:h,props:d,_owner:r.current}}return si.jsx=i,si.jsxs=i,si}var uh={};/** @license React v17.0.2
18
- * react-jsx-runtime.development.js
19
- *
20
- * Copyright (c) Facebook, Inc. and its affiliates.
21
- *
22
- * This source code is licensed under the MIT license found in the
23
- * LICENSE file in the root directory of this source tree.
24
- */var jb;function rD(){return jb||(jb=1,(function(t){process.env.NODE_ENV!=="production"&&(function(){var e=M,n=Pb(),r=60103,o=60106;t.Fragment=60107;var s=60108,i=60114,a=60109,l=60110,c=60112,u=60113,d=60120,f=60115,h=60116,p=60121,m=60122,y=60117,v=60129,w=60131;if(typeof Symbol=="function"&&Symbol.for){var E=Symbol.for;r=E("react.element"),o=E("react.portal"),t.Fragment=E("react.fragment"),s=E("react.strict_mode"),i=E("react.profiler"),a=E("react.provider"),l=E("react.context"),c=E("react.forward_ref"),u=E("react.suspense"),d=E("react.suspense_list"),f=E("react.memo"),h=E("react.lazy"),p=E("react.block"),m=E("react.server.block"),y=E("react.fundamental"),E("react.scope"),E("react.opaque.id"),v=E("react.debug_trace_mode"),E("react.offscreen"),w=E("react.legacy_hidden")}var x=typeof Symbol=="function"&&Symbol.iterator,k="@@iterator";function S(A){if(A===null||typeof A!="object")return null;var W=x&&A[x]||A[k];return typeof W=="function"?W:null}var C=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function T(A){{for(var W=arguments.length,Y=new Array(W>1?W-1:0),ce=1;ce<W;ce++)Y[ce-1]=arguments[ce];N("error",A,Y)}}function N(A,W,Y){{var ce=C.ReactDebugCurrentFrame,Ne=ce.getStackAddendum();Ne!==""&&(W+="%s",Y=Y.concat([Ne]));var Ce=Y.map(function(je){return""+je});Ce.unshift("Warning: "+W),Function.prototype.apply.call(console[A],console,Ce)}}var _=!1;function L(A){return!!(typeof A=="string"||typeof A=="function"||A===t.Fragment||A===i||A===v||A===s||A===u||A===d||A===w||_||typeof A=="object"&&A!==null&&(A.$$typeof===h||A.$$typeof===f||A.$$typeof===a||A.$$typeof===l||A.$$typeof===c||A.$$typeof===y||A.$$typeof===p||A[0]===m))}function $(A,W,Y){var ce=W.displayName||W.name||"";return A.displayName||(ce!==""?Y+"("+ce+")":Y)}function B(A){return A.displayName||"Context"}function z(A){if(A==null)return null;if(typeof A.tag=="number"&&T("Received an unexpected object in getComponentName(). This is likely a bug in React. Please file an issue."),typeof A=="function")return A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case t.Fragment:return"Fragment";case o:return"Portal";case i:return"Profiler";case s:return"StrictMode";case u:return"Suspense";case d:return"SuspenseList"}if(typeof A=="object")switch(A.$$typeof){case l:var W=A;return B(W)+".Consumer";case a:var Y=A;return B(Y._context)+".Provider";case c:return $(A,A.render,"ForwardRef");case f:return z(A.type);case p:return z(A._render);case h:{var ce=A,Ne=ce._payload,Ce=ce._init;try{return z(Ce(Ne))}catch{return null}}}return null}var j=0,P,H,R,V,ie,ne,ye;function G(){}G.__reactDisabledLog=!0;function Z(){{if(j===0){P=console.log,H=console.info,R=console.warn,V=console.error,ie=console.group,ne=console.groupCollapsed,ye=console.groupEnd;var A={configurable:!0,enumerable:!0,value:G,writable:!0};Object.defineProperties(console,{info:A,log:A,warn:A,error:A,group:A,groupCollapsed:A,groupEnd:A})}j++}}function J(){{if(j--,j===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:n({},A,{value:P}),info:n({},A,{value:H}),warn:n({},A,{value:R}),error:n({},A,{value:V}),group:n({},A,{value:ie}),groupCollapsed:n({},A,{value:ne}),groupEnd:n({},A,{value:ye})})}j<0&&T("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var me=C.ReactCurrentDispatcher,U;function ee(A,W,Y){{if(U===void 0)try{throw Error()}catch(Ne){var ce=Ne.stack.trim().match(/\n( *(at )?)/);U=ce&&ce[1]||""}return`
25
- `+U+A}}var Oe=!1,he;{var we=typeof WeakMap=="function"?WeakMap:Map;he=new we}function Se(A,W){if(!A||Oe)return"";{var Y=he.get(A);if(Y!==void 0)return Y}var ce;Oe=!0;var Ne=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ce;Ce=me.current,me.current=null,Z();try{if(W){var je=function(){throw Error()};if(Object.defineProperty(je.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(je,[])}catch(rr){ce=rr}Reflect.construct(A,[],je)}else{try{je.call()}catch(rr){ce=rr}A.call(je.prototype)}}else{try{throw Error()}catch(rr){ce=rr}A()}}catch(rr){if(rr&&ce&&typeof rr.stack=="string"){for(var Pe=rr.stack.split(`
26
- `),It=ce.stack.split(`
27
- `),lt=Pe.length-1,We=It.length-1;lt>=1&&We>=0&&Pe[lt]!==It[We];)We--;for(;lt>=1&&We>=0;lt--,We--)if(Pe[lt]!==It[We]){if(lt!==1||We!==1)do if(lt--,We--,We<0||Pe[lt]!==It[We]){var nr=`
28
- `+Pe[lt].replace(" at new "," at ");return typeof A=="function"&&he.set(A,nr),nr}while(lt>=1&&We>=0);break}}}finally{Oe=!1,me.current=Ce,J(),Error.prepareStackTrace=Ne}var ko=A?A.displayName||A.name:"",rc=ko?ee(ko):"";return typeof A=="function"&&he.set(A,rc),rc}function Ve(A,W,Y){return Se(A,!1)}function ut(A){var W=A.prototype;return!!(W&&W.isReactComponent)}function dt(A,W,Y){if(A==null)return"";if(typeof A=="function")return Se(A,ut(A));if(typeof A=="string")return ee(A);switch(A){case u:return ee("Suspense");case d:return ee("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case c:return Ve(A.render);case f:return dt(A.type,W,Y);case p:return Ve(A._render);case h:{var ce=A,Ne=ce._payload,Ce=ce._init;try{return dt(Ce(Ne),W,Y)}catch{}}}return""}var Ot={},yt=C.ReactDebugCurrentFrame;function _t(A){if(A){var W=A._owner,Y=dt(A.type,A._source,W?W.type:null);yt.setExtraStackFrame(Y)}else yt.setExtraStackFrame(null)}function xt(A,W,Y,ce,Ne){{var Ce=Function.call.bind(Object.prototype.hasOwnProperty);for(var je in A)if(Ce(A,je)){var Pe=void 0;try{if(typeof A[je]!="function"){var It=Error((ce||"React class")+": "+Y+" type `"+je+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[je]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw It.name="Invariant Violation",It}Pe=A[je](W,je,ce,Y,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(lt){Pe=lt}Pe&&!(Pe instanceof Error)&&(_t(Ne),T("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ce||"React class",Y,je,typeof Pe),_t(null)),Pe instanceof Error&&!(Pe.message in Ot)&&(Ot[Pe.message]=!0,_t(Ne),T("Failed %s type: %s",Y,Pe.message),_t(null))}}}var Nt=C.ReactCurrentOwner,Gt=Object.prototype.hasOwnProperty,it={key:!0,ref:!0,__self:!0,__source:!0},Rt,Tn;function An(A){if(Gt.call(A,"ref")){var W=Object.getOwnPropertyDescriptor(A,"ref").get;if(W&&W.isReactWarning)return!1}return A.ref!==void 0}function Bt(A){if(Gt.call(A,"key")){var W=Object.getOwnPropertyDescriptor(A,"key").get;if(W&&W.isReactWarning)return!1}return A.key!==void 0}function fn(A,W){typeof A.ref=="string"&&Nt.current}function er(A,W){{var Y=function(){Rt||(Rt=!0,T("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",W))};Y.isReactWarning=!0,Object.defineProperty(A,"key",{get:Y,configurable:!0})}}function Vr(A,W){{var Y=function(){Tn||(Tn=!0,T("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",W))};Y.isReactWarning=!0,Object.defineProperty(A,"ref",{get:Y,configurable:!0})}}var $n=function(A,W,Y,ce,Ne,Ce,je){var Pe={$$typeof:r,type:A,key:W,ref:Y,props:je,_owner:Ce};return Pe._store={},Object.defineProperty(Pe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Pe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ce}),Object.defineProperty(Pe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ne}),Object.freeze&&(Object.freeze(Pe.props),Object.freeze(Pe)),Pe};function Wr(A,W,Y,ce,Ne){{var Ce,je={},Pe=null,It=null;Y!==void 0&&(Pe=""+Y),Bt(W)&&(Pe=""+W.key),An(W)&&(It=W.ref,fn(W,Ne));for(Ce in W)Gt.call(W,Ce)&&!it.hasOwnProperty(Ce)&&(je[Ce]=W[Ce]);if(A&&A.defaultProps){var lt=A.defaultProps;for(Ce in lt)je[Ce]===void 0&&(je[Ce]=lt[Ce])}if(Pe||It){var We=typeof A=="function"?A.displayName||A.name||"Unknown":A;Pe&&er(je,We),It&&Vr(je,We)}return $n(A,Pe,It,Ne,ce,Nt.current,je)}}var hn=C.ReactCurrentOwner,Sr=C.ReactDebugCurrentFrame;function D(A){if(A){var W=A._owner,Y=dt(A.type,A._source,W?W.type:null);Sr.setExtraStackFrame(Y)}else Sr.setExtraStackFrame(null)}var X;X=!1;function ae(A){return typeof A=="object"&&A!==null&&A.$$typeof===r}function De(){{if(hn.current){var A=z(hn.current.type);if(A)return`
29
-
30
- Check the render method of \``+A+"`."}return""}}function ke(A){return""}var qe={};function wt(A){{var W=De();if(!W){var Y=typeof A=="string"?A:A.displayName||A.name;Y&&(W=`
31
-
32
- Check the top-level render call using <`+Y+">.")}return W}}function en(A,W){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var Y=wt(W);if(qe[Y])return;qe[Y]=!0;var ce="";A&&A._owner&&A._owner!==hn.current&&(ce=" It was passed a child from "+z(A._owner.type)+"."),D(A),T('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',Y,ce),D(null)}}function Gr(A,W){{if(typeof A!="object")return;if(Array.isArray(A))for(var Y=0;Y<A.length;Y++){var ce=A[Y];ae(ce)&&en(ce,W)}else if(ae(A))A._store&&(A._store.validated=!0);else if(A){var Ne=S(A);if(typeof Ne=="function"&&Ne!==A.entries)for(var Ce=Ne.call(A),je;!(je=Ce.next()).done;)ae(je.value)&&en(je.value,W)}}}function Ft(A){{var W=A.type;if(W==null||typeof W=="string")return;var Y;if(typeof W=="function")Y=W.propTypes;else if(typeof W=="object"&&(W.$$typeof===c||W.$$typeof===f))Y=W.propTypes;else return;if(Y){var ce=z(W);xt(Y,A.props,"prop",ce,A)}else if(W.PropTypes!==void 0&&!X){X=!0;var Ne=z(W);T("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ne||"Unknown")}typeof W.getDefaultProps=="function"&&!W.getDefaultProps.isReactClassApproved&&T("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ve(A){{for(var W=Object.keys(A.props),Y=0;Y<W.length;Y++){var ce=W[Y];if(ce!=="children"&&ce!=="key"){D(A),T("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ce),D(null);break}}A.ref!==null&&(D(A),T("Invalid attribute `ref` supplied to `React.Fragment`."),D(null))}}function Ke(A,W,Y,ce,Ne,Ce){{var je=L(A);if(!je){var Pe="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(Pe+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var It=ke();It?Pe+=It:Pe+=De();var lt;A===null?lt="null":Array.isArray(A)?lt="array":A!==void 0&&A.$$typeof===r?(lt="<"+(z(A.type)||"Unknown")+" />",Pe=" Did you accidentally export a JSX literal instead of a component?"):lt=typeof A,T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",lt,Pe)}var We=Wr(A,W,Y,Ne,Ce);if(We==null)return We;if(je){var nr=W.children;if(nr!==void 0)if(ce)if(Array.isArray(nr)){for(var ko=0;ko<nr.length;ko++)Gr(nr[ko],A);Object.freeze&&Object.freeze(nr)}else T("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Gr(nr,A)}return A===t.Fragment?ve(We):Ft(We),We}}function Ee(A,W,Y){return Ke(A,W,Y,!0)}function at(A,W,Y){return Ke(A,W,Y,!1)}var tr=at,Qe=Ee;t.jsx=tr,t.jsxs=Qe})()})(uh)),uh}var $b;function oD(){return $b||($b=1,process.env.NODE_ENV==="production"?Sc.exports=nD():Sc.exports=rD()),Sc.exports}var g=oD();const sD=({children:t,apiBaseURL:e,authToken:n,toI18N:r,i18nKeys:o})=>{const s=M.useCallback((l,c)=>{const u=r(o[l]);return u||c||l},[r,o]),i=M.useMemo(()=>{const l=new KI(e.core,n,r),c=new eD(e.mfs,n,r),u=new ZI(e.fileStore,n,r);return l.initApi(),c.initApi(),u.initApi(),{core:l,mfs:c,fileStore:u}},[n,e,r]),a=M.useMemo(()=>({authToken:n,t:s,i18nKeys:o,api:i}),[i,n,s,o]);return g.jsx(Ib.Provider,{value:a,children:t})};function te(t,e,{checkForDefaultPrevented:n=!0}={}){return function(o){if(t?.(o),n===!1||!o.defaultPrevented)return e?.(o)}}function iD(t,e){const n=b.createContext(e),r=s=>{const{children:i,...a}=s,l=b.useMemo(()=>a,Object.values(a));return g.jsx(n.Provider,{value:l,children:i})};r.displayName=t+"Provider";function o(s){const i=b.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 On(t,e=[]){let n=[];function r(s,i){const a=b.createContext(i),l=n.length;n=[...n,i];const c=d=>{const{scope:f,children:h,...p}=d,m=f?.[t]?.[l]||a,y=b.useMemo(()=>p,Object.values(p));return g.jsx(m.Provider,{value:y,children:h})};c.displayName=s+"Provider";function u(d,f){const h=f?.[t]?.[l]||a,p=b.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=>b.createContext(i));return function(a){const l=a?.[t]||s;return b.useMemo(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return o.scopeName=t,[r,aD(o,...e)]}function aD(...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 b.useMemo(()=>({[`__scope${e.scopeName}`]:i}),[i])}};return n.scopeName=e.scopeName,n}function Bb(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}function kc(...t){return e=>{let n=!1;const r=t.map(o=>{const s=Bb(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():Bb(t[o],null)}}}}function $e(...t){return b.useCallback(kc(...t),t)}function Mo(t){const e=cD(t),n=b.forwardRef((r,o)=>{const{children:s,...i}=r,a=b.Children.toArray(s),l=a.find(dD);if(l){const c=l.props.children,u=a.map(d=>d===l?b.Children.count(c)>1?b.Children.only(null):b.isValidElement(c)?c.props.children:null:d);return g.jsx(e,{...i,ref:o,children:b.isValidElement(c)?b.cloneElement(c,void 0,u):null})}return g.jsx(e,{...i,ref:o,children:s})});return n.displayName=`${t}.Slot`,n}var lD=Mo("Slot");function cD(t){const e=b.forwardRef((n,r)=>{const{children:o,...s}=n;if(b.isValidElement(o)){const i=hD(o),a=fD(s,o.props);return o.type!==b.Fragment&&(a.ref=r?kc(r,i):i),b.cloneElement(o,a)}return b.Children.count(o)>1?b.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var Fb=Symbol("radix.slottable");function uD(t){const e=({children:n})=>g.jsx(g.Fragment,{children:n});return e.displayName=`${t}.Slottable`,e.__radixId=Fb,e}function dD(t){return b.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===Fb}function fD(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 hD(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 dh(t){const e=t+"CollectionProvider",[n,r]=On(e),[o,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),i=m=>{const{scope:y,children:v}=m,w=M.useRef(null),E=M.useRef(new Map).current;return g.jsx(o,{scope:y,itemMap:E,collectionRef:w,children:v})};i.displayName=e;const a=t+"CollectionSlot",l=Mo(a),c=M.forwardRef((m,y)=>{const{scope:v,children:w}=m,E=s(a,v),x=$e(y,E.collectionRef);return g.jsx(l,{ref:x,children:w})});c.displayName=a;const u=t+"CollectionItemSlot",d="data-radix-collection-item",f=Mo(u),h=M.forwardRef((m,y)=>{const{scope:v,children:w,...E}=m,x=M.useRef(null),k=$e(y,x),S=s(u,v);return M.useEffect(()=>(S.itemMap.set(x,{ref:x,...E}),()=>void S.itemMap.delete(x))),g.jsx(f,{[d]:"",ref:k,children:w})});h.displayName=u;function p(m){const y=s(t+"CollectionConsumer",m);return M.useCallback(()=>{const w=y.collectionRef.current;if(!w)return[];const E=Array.from(w.querySelectorAll(`[${d}]`));return Array.from(y.itemMap.values()).sort((S,C)=>E.indexOf(S.ref.current)-E.indexOf(C.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:i,Slot:c,ItemSlot:h},p,r]}var Tt=globalThis?.document?b.useLayoutEffect:()=>{},pD=b[" useId ".trim().toString()]||(()=>{}),mD=0;function Bn(t){const[e,n]=b.useState(pD());return Tt(()=>{n(r=>r??String(mD++))},[t]),e?`radix-${e}`:""}var gD=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],ge=gD.reduce((t,e)=>{const n=Mo(`Primitive.${e}`),r=b.forwardRef((o,s)=>{const{asChild:i,...a}=o,l=i?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),g.jsx(l,{...a,ref:s})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function Hb(t,e){t&&oc.flushSync(()=>t.dispatchEvent(e))}function sr(t){const e=b.useRef(t);return b.useEffect(()=>{e.current=t}),b.useMemo(()=>(...n)=>e.current?.(...n),[])}var yD=b[" useInsertionEffect ".trim().toString()]||Tt;function Jr({prop:t,defaultProp:e,onChange:n=()=>{},caller:r}){const[o,s,i]=vD({defaultProp:e,onChange:n}),a=t!==void 0,l=a?t:o;{const u=b.useRef(t!==void 0);b.useEffect(()=>{const d=u.current;d!==a&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${a?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=a},[a,r])}const c=b.useCallback(u=>{if(a){const d=bD(u)?u(t):u;d!==t&&i.current?.(d)}else s(u)},[a,t,s,i]);return[l,c]}function vD({defaultProp:t,onChange:e}){const[n,r]=b.useState(t),o=b.useRef(n),s=b.useRef(e);return yD(()=>{s.current=e},[e]),b.useEffect(()=>{o.current!==n&&(s.current?.(n),o.current=n)},[n,o]),[n,r,s]}function bD(t){return typeof t=="function"}var xD=b.createContext(void 0);function Cc(t){const e=b.useContext(xD);return t||e||"ltr"}var fh="rovingFocusGroup.onEntryFocus",wD={bubbles:!1,cancelable:!0},ya="RovingFocusGroup",[hh,zb,ED]=dh(ya),[SD,Tc]=On(ya,[ED]),[kD,CD]=SD(ya),Ub=b.forwardRef((t,e)=>g.jsx(hh.Provider,{scope:t.__scopeRovingFocusGroup,children:g.jsx(hh.Slot,{scope:t.__scopeRovingFocusGroup,children:g.jsx(TD,{...t,ref:e})})}));Ub.displayName=ya;var TD=b.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=b.useRef(null),h=$e(e,f),p=Cc(s),[m,y]=Jr({prop:i,defaultProp:a??null,onChange:l,caller:ya}),[v,w]=b.useState(!1),E=sr(c),x=zb(n),k=b.useRef(!1),[S,C]=b.useState(0);return b.useEffect(()=>{const T=f.current;if(T)return T.addEventListener(fh,E),()=>T.removeEventListener(fh,E)},[E]),g.jsx(kD,{scope:n,orientation:r,dir:p,loop:o,currentTabStopId:m,onItemFocus:b.useCallback(T=>y(T),[y]),onItemShiftTab:b.useCallback(()=>w(!0),[]),onFocusableItemAdd:b.useCallback(()=>C(T=>T+1),[]),onFocusableItemRemove:b.useCallback(()=>C(T=>T-1),[]),children:g.jsx(ge.div,{tabIndex:v||S===0?-1:0,"data-orientation":r,...d,ref:h,style:{outline:"none",...t.style},onMouseDown:te(t.onMouseDown,()=>{k.current=!0}),onFocus:te(t.onFocus,T=>{const N=!k.current;if(T.target===T.currentTarget&&N&&!v){const _=new CustomEvent(fh,wD);if(T.currentTarget.dispatchEvent(_),!_.defaultPrevented){const L=x().filter(P=>P.focusable),$=L.find(P=>P.active),B=L.find(P=>P.id===m),j=[$,B,...L].filter(Boolean).map(P=>P.ref.current);Gb(j,u)}}k.current=!1}),onBlur:te(t.onBlur,()=>w(!1))})})}),Vb="RovingFocusGroupItem",Wb=b.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:o=!1,tabStopId:s,children:i,...a}=t,l=Bn(),c=s||l,u=CD(Vb,n),d=u.currentTabStopId===c,f=zb(n),{onFocusableItemAdd:h,onFocusableItemRemove:p,currentTabStopId:m}=u;return b.useEffect(()=>{if(r)return h(),()=>p()},[r,h,p]),g.jsx(hh.ItemSlot,{scope:n,id:c,focusable:r,active:o,children:g.jsx(ge.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...a,ref:e,onMouseDown:te(t.onMouseDown,y=>{r?u.onItemFocus(c):y.preventDefault()}),onFocus:te(t.onFocus,()=>u.onItemFocus(c)),onKeyDown:te(t.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){u.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const v=OD(y,u.orientation,u.dir);if(v!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let E=f().filter(x=>x.focusable).map(x=>x.ref.current);if(v==="last")E.reverse();else if(v==="prev"||v==="next"){v==="prev"&&E.reverse();const x=E.indexOf(y.currentTarget);E=u.loop?_D(E,x+1):E.slice(x+1)}setTimeout(()=>Gb(E))}}),children:typeof i=="function"?i({isCurrentTabStop:d,hasTabStop:m!=null}):i})})});Wb.displayName=Vb;var AD={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function MD(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function OD(t,e,n){const r=MD(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return AD[r]}function Gb(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function _D(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var qb=Ub,Kb=Wb;function ND(t,e){return b.useReducer((n,r)=>e[n][r]??n,t)}var _n=t=>{const{present:e,children:n}=t,r=RD(e),o=typeof n=="function"?n({present:r.isPresent}):b.Children.only(n),s=$e(r.ref,ID(o));return typeof n=="function"||r.isPresent?b.cloneElement(o,{ref:s}):null};_n.displayName="Presence";function RD(t){const[e,n]=b.useState(),r=b.useRef(null),o=b.useRef(t),s=b.useRef("none"),i=t?"mounted":"unmounted",[a,l]=ND(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return b.useEffect(()=>{const c=Ac(r.current);s.current=a==="mounted"?c:"none"},[a]),Tt(()=>{const c=r.current,u=o.current;if(u!==t){const f=s.current,h=Ac(c);t?l("MOUNT"):h==="none"||c?.display==="none"?l("UNMOUNT"):l(u&&f!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=t}},[t,l]),Tt(()=>{if(e){let c;const u=e.ownerDocument.defaultView??window,d=h=>{const m=Ac(r.current).includes(CSS.escape(h.animationName));if(h.target===e&&m&&(l("ANIMATION_END"),!o.current)){const y=e.style.animationFillMode;e.style.animationFillMode="forwards",c=u.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=y)})}},f=h=>{h.target===e&&(s.current=Ac(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:b.useCallback(c=>{r.current=c?getComputedStyle(c):null,n(c)},[])}}function Ac(t){return t?.animationName||"none"}function ID(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 Mc="Tabs",[DD]=On(Mc,[Tc]),Yb=Tc(),[PD,ph]=DD(Mc),Jb=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:o,defaultValue:s,orientation:i="horizontal",dir:a,activationMode:l="automatic",...c}=t,u=Cc(a),[d,f]=Jr({prop:r,onChange:o,defaultProp:s??"",caller:Mc});return g.jsx(PD,{scope:n,baseId:Bn(),value:d,onValueChange:f,orientation:i,dir:u,activationMode:l,children:g.jsx(ge.div,{dir:u,"data-orientation":i,...c,ref:e})})});Jb.displayName=Mc;var Xb="TabsList",Qb=b.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...o}=t,s=ph(Xb,n),i=Yb(n);return g.jsx(qb,{asChild:!0,...i,orientation:s.orientation,dir:s.dir,loop:r,children:g.jsx(ge.div,{role:"tablist","aria-orientation":s.orientation,...o,ref:e})})});Qb.displayName=Xb;var Zb="TabsTrigger",e0=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:o=!1,...s}=t,i=ph(Zb,n),a=Yb(n),l=r0(i.baseId,r),c=o0(i.baseId,r),u=r===i.value;return g.jsx(Kb,{asChild:!0,...a,focusable:!o,active:u,children:g.jsx(ge.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:te(t.onMouseDown,d=>{!o&&d.button===0&&d.ctrlKey===!1?i.onValueChange(r):d.preventDefault()}),onKeyDown:te(t.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&i.onValueChange(r)}),onFocus:te(t.onFocus,()=>{const d=i.activationMode!=="manual";!u&&!o&&d&&i.onValueChange(r)})})})});e0.displayName=Zb;var t0="TabsContent",n0=b.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:o,children:s,...i}=t,a=ph(t0,n),l=r0(a.baseId,r),c=o0(a.baseId,r),u=r===a.value,d=b.useRef(u);return b.useEffect(()=>{const f=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(f)},[]),g.jsx(_n,{present:o||u,children:({present:f})=>g.jsx(ge.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})})});n0.displayName=t0;function r0(t,e){return`${t}-trigger-${e}`}function o0(t,e){return`${t}-content-${e}`}var LD=Jb,jD=Qb,$D=e0,BD=n0;function s0(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=s0(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function i0(){for(var t,e,n=0,r="",o=arguments.length;n<o;n++)(t=arguments[n])&&(e=s0(t))&&(r&&(r+=" "),r+=e);return r}const mh="-",FD=t=>{const e=zD(t),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=t;return{getClassGroupId:i=>{const a=i.split(mh);return a[0]===""&&a.length!==1&&a.shift(),a0(a,e)||HD(i)},getConflictingClassGroupIds:(i,a)=>{const l=n[i]||[];return a&&r[i]?[...l,...r[i]]:l}}},a0=(t,e)=>{if(t.length===0)return e.classGroupId;const n=t[0],r=e.nextPart.get(n),o=r?a0(t.slice(1),r):void 0;if(o)return o;if(e.validators.length===0)return;const s=t.join(mh);return e.validators.find(({validator:i})=>i(s))?.classGroupId},l0=/^\[(.+)\]$/,HD=t=>{if(l0.test(t)){const e=l0.exec(t)[1],n=e?.substring(0,e.indexOf(":"));if(n)return"arbitrary.."+n}},zD=t=>{const{theme:e,classGroups:n}=t,r={nextPart:new Map,validators:[]};for(const o in n)gh(n[o],r,o,e);return r},gh=(t,e,n,r)=>{t.forEach(o=>{if(typeof o=="string"){const s=o===""?e:c0(e,o);s.classGroupId=n;return}if(typeof o=="function"){if(UD(o)){gh(o(r),e,n,r);return}e.validators.push({validator:o,classGroupId:n});return}Object.entries(o).forEach(([s,i])=>{gh(i,c0(e,s),n,r)})})},c0=(t,e)=>{let n=t;return e.split(mh).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},UD=t=>t.isThemeGetter,VD=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,n=new Map,r=new Map;const o=(s,i)=>{n.set(s,i),e++,e>t&&(e=0,r=n,n=new Map)};return{get(s){let i=n.get(s);if(i!==void 0)return i;if((i=r.get(s))!==void 0)return o(s,i),i},set(s,i){n.has(s)?n.set(s,i):o(s,i)}}},yh="!",vh=":",WD=vh.length,GD=t=>{const{prefix:e,experimentalParseClassName:n}=t;let r=o=>{const s=[];let i=0,a=0,l=0,c;for(let p=0;p<o.length;p++){let m=o[p];if(i===0&&a===0){if(m===vh){s.push(o.slice(l,p)),l=p+WD;continue}if(m==="/"){c=p;continue}}m==="["?i++:m==="]"?i--:m==="("?a++:m===")"&&a--}const u=s.length===0?o:o.substring(l),d=qD(u),f=d!==u,h=c&&c>l?c-l:void 0;return{modifiers:s,hasImportantModifier:f,baseClassName:d,maybePostfixModifierPosition:h}};if(e){const o=e+vh,s=r;r=i=>i.startsWith(o)?s(i.substring(o.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:i,maybePostfixModifierPosition:void 0}}if(n){const o=r;r=s=>n({className:s,parseClassName:o})}return r},qD=t=>t.endsWith(yh)?t.substring(0,t.length-1):t.startsWith(yh)?t.substring(1):t,KD=t=>{const e=Object.fromEntries(t.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const o=[];let s=[];return r.forEach(i=>{i[0]==="["||e[i]?(o.push(...s.sort(),i),s=[]):s.push(i)}),o.push(...s.sort()),o}},YD=t=>({cache:VD(t.cacheSize),parseClassName:GD(t),sortModifiers:KD(t),...FD(t)}),JD=/\s+/,XD=(t,e)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:o,sortModifiers:s}=e,i=[],a=t.trim().split(JD);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 y=!!m,v=r(y?p.substring(0,m):p);if(!v){if(!y){l=u+(l.length>0?" "+l:l);continue}if(v=r(p),!v){l=u+(l.length>0?" "+l:l);continue}y=!1}const w=s(f).join(":"),E=h?w+yh:w,x=E+v;if(i.includes(x))continue;i.push(x);const k=o(v,y);for(let S=0;S<k.length;++S){const C=k[S];i.push(E+C)}l=u+(l.length>0?" "+l:l)}return l};function QD(){let t=0,e,n,r="";for(;t<arguments.length;)(e=arguments[t++])&&(n=u0(e))&&(r&&(r+=" "),r+=n);return r}const u0=t=>{if(typeof t=="string")return t;let e,n="";for(let r=0;r<t.length;r++)t[r]&&(e=u0(t[r]))&&(n&&(n+=" "),n+=e);return n};function ZD(t,...e){let n,r,o,s=i;function i(l){const c=e.reduce((u,d)=>d(u),t());return n=YD(c),r=n.cache.get,o=n.cache.set,s=a,a(l)}function a(l){const c=r(l);if(c)return c;const u=XD(l,n);return o(l,u),u}return function(){return s(QD.apply(null,arguments))}}const At=t=>{const e=n=>n[t]||[];return e.isThemeGetter=!0,e},d0=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,f0=/^\((?:(\w[\w-]*):)?(.+)\)$/i,eP=/^\d+\/\d+$/,tP=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,nP=/\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$/,rP=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,oP=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,sP=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,ii=t=>eP.test(t),Re=t=>!!t&&!Number.isNaN(Number(t)),Oo=t=>!!t&&Number.isInteger(Number(t)),bh=t=>t.endsWith("%")&&Re(t.slice(0,-1)),Xr=t=>tP.test(t),iP=()=>!0,aP=t=>nP.test(t)&&!rP.test(t),h0=()=>!1,lP=t=>oP.test(t),cP=t=>sP.test(t),uP=t=>!oe(t)&&!se(t),dP=t=>ai(t,v0,h0),oe=t=>d0.test(t),ys=t=>ai(t,b0,aP),xh=t=>ai(t,gP,Re),p0=t=>ai(t,g0,h0),fP=t=>ai(t,y0,cP),Oc=t=>ai(t,x0,lP),se=t=>f0.test(t),va=t=>li(t,b0),hP=t=>li(t,yP),m0=t=>li(t,g0),pP=t=>li(t,v0),mP=t=>li(t,y0),_c=t=>li(t,x0,!0),ai=(t,e,n)=>{const r=d0.exec(t);return r?r[1]?e(r[1]):n(r[2]):!1},li=(t,e,n=!1)=>{const r=f0.exec(t);return r?r[1]?e(r[1]):n:!1},g0=t=>t==="position"||t==="percentage",y0=t=>t==="image"||t==="url",v0=t=>t==="length"||t==="size"||t==="bg-size",b0=t=>t==="length",gP=t=>t==="number",yP=t=>t==="family-name",x0=t=>t==="shadow",vP=ZD(()=>{const t=At("color"),e=At("font"),n=At("text"),r=At("font-weight"),o=At("tracking"),s=At("leading"),i=At("breakpoint"),a=At("container"),l=At("spacing"),c=At("radius"),u=At("shadow"),d=At("inset-shadow"),f=At("text-shadow"),h=At("drop-shadow"),p=At("blur"),m=At("perspective"),y=At("aspect"),v=At("ease"),w=At("animate"),E=()=>["auto","avoid","all","avoid-page","page","left","right","column"],x=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],k=()=>[...x(),se,oe],S=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],T=()=>[se,oe,l],N=()=>[ii,"full","auto",...T()],_=()=>[Oo,"none","subgrid",se,oe],L=()=>["auto",{span:["full",Oo,se,oe]},Oo,se,oe],$=()=>[Oo,"auto",se,oe],B=()=>["auto","min","max","fr",se,oe],z=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],j=()=>["start","end","center","stretch","center-safe","end-safe"],P=()=>["auto",...T()],H=()=>[ii,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...T()],R=()=>[t,se,oe],V=()=>[...x(),m0,p0,{position:[se,oe]}],ie=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ne=()=>["auto","cover","contain",pP,dP,{size:[se,oe]}],ye=()=>[bh,va,ys],G=()=>["","none","full",c,se,oe],Z=()=>["",Re,va,ys],J=()=>["solid","dashed","dotted","double"],me=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],U=()=>[Re,bh,m0,p0],ee=()=>["","none",p,se,oe],Oe=()=>["none",Re,se,oe],he=()=>["none",Re,se,oe],we=()=>[Re,se,oe],Se=()=>[ii,"full",...T()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Xr],breakpoint:[Xr],color:[iP],container:[Xr],"drop-shadow":[Xr],ease:["in","out","in-out"],font:[uP],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Xr],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Xr],shadow:[Xr],spacing:["px",Re],text:[Xr],"text-shadow":[Xr],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",ii,oe,se,y]}],container:["container"],columns:[{columns:[Re,oe,se,a]}],"break-after":[{"break-after":E()}],"break-before":[{"break-before":E()}],"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:k()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:N()}],"inset-x":[{"inset-x":N()}],"inset-y":[{"inset-y":N()}],start:[{start:N()}],end:[{end:N()}],top:[{top:N()}],right:[{right:N()}],bottom:[{bottom:N()}],left:[{left:N()}],visibility:["visible","invisible","collapse"],z:[{z:[Oo,"auto",se,oe]}],basis:[{basis:[ii,"full","auto",a,...T()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Re,ii,"auto","initial","none",oe]}],grow:[{grow:["",Re,se,oe]}],shrink:[{shrink:["",Re,se,oe]}],order:[{order:[Oo,"first","last","none",se,oe]}],"grid-cols":[{"grid-cols":_()}],"col-start-end":[{col:L()}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":_()}],"row-start-end":[{row:L()}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":B()}],"auto-rows":[{"auto-rows":B()}],gap:[{gap:T()}],"gap-x":[{"gap-x":T()}],"gap-y":[{"gap-y":T()}],"justify-content":[{justify:[...z(),"normal"]}],"justify-items":[{"justify-items":[...j(),"normal"]}],"justify-self":[{"justify-self":["auto",...j()]}],"align-content":[{content:["normal",...z()]}],"align-items":[{items:[...j(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...j(),{baseline:["","last"]}]}],"place-content":[{"place-content":z()}],"place-items":[{"place-items":[...j(),"baseline"]}],"place-self":[{"place-self":["auto",...j()]}],p:[{p:T()}],px:[{px:T()}],py:[{py:T()}],ps:[{ps:T()}],pe:[{pe:T()}],pt:[{pt:T()}],pr:[{pr:T()}],pb:[{pb:T()}],pl:[{pl:T()}],m:[{m:P()}],mx:[{mx:P()}],my:[{my:P()}],ms:[{ms:P()}],me:[{me:P()}],mt:[{mt:P()}],mr:[{mr:P()}],mb:[{mb:P()}],ml:[{ml:P()}],"space-x":[{"space-x":T()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":T()}],"space-y-reverse":["space-y-reverse"],size:[{size:H()}],w:[{w:[a,"screen",...H()]}],"min-w":[{"min-w":[a,"screen","none",...H()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[i]},...H()]}],h:[{h:["screen","lh",...H()]}],"min-h":[{"min-h":["screen","lh","none",...H()]}],"max-h":[{"max-h":["screen","lh",...H()]}],"font-size":[{text:["base",n,va,ys]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,se,xh]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",bh,oe]}],"font-family":[{font:[hP,oe,e]}],"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,se,oe]}],"line-clamp":[{"line-clamp":[Re,"none",se,xh]}],leading:[{leading:[s,...T()]}],"list-image":[{"list-image":["none",se,oe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",se,oe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:R()}],"text-color":[{text:R()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...J(),"wavy"]}],"text-decoration-thickness":[{decoration:[Re,"from-font","auto",se,ys]}],"text-decoration-color":[{decoration:R()}],"underline-offset":[{"underline-offset":[Re,"auto",se,oe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:T()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",se,oe]}],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",se,oe]}],"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:ie()}],"bg-size":[{bg:ne()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Oo,se,oe],radial:["",se,oe],conic:[Oo,se,oe]},mP,fP]}],"bg-color":[{bg:R()}],"gradient-from-pos":[{from:ye()}],"gradient-via-pos":[{via:ye()}],"gradient-to-pos":[{to:ye()}],"gradient-from":[{from:R()}],"gradient-via":[{via:R()}],"gradient-to":[{to:R()}],rounded:[{rounded:G()}],"rounded-s":[{"rounded-s":G()}],"rounded-e":[{"rounded-e":G()}],"rounded-t":[{"rounded-t":G()}],"rounded-r":[{"rounded-r":G()}],"rounded-b":[{"rounded-b":G()}],"rounded-l":[{"rounded-l":G()}],"rounded-ss":[{"rounded-ss":G()}],"rounded-se":[{"rounded-se":G()}],"rounded-ee":[{"rounded-ee":G()}],"rounded-es":[{"rounded-es":G()}],"rounded-tl":[{"rounded-tl":G()}],"rounded-tr":[{"rounded-tr":G()}],"rounded-br":[{"rounded-br":G()}],"rounded-bl":[{"rounded-bl":G()}],"border-w":[{border:Z()}],"border-w-x":[{"border-x":Z()}],"border-w-y":[{"border-y":Z()}],"border-w-s":[{"border-s":Z()}],"border-w-e":[{"border-e":Z()}],"border-w-t":[{"border-t":Z()}],"border-w-r":[{"border-r":Z()}],"border-w-b":[{"border-b":Z()}],"border-w-l":[{"border-l":Z()}],"divide-x":[{"divide-x":Z()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":Z()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...J(),"hidden","none"]}],"divide-style":[{divide:[...J(),"hidden","none"]}],"border-color":[{border:R()}],"border-color-x":[{"border-x":R()}],"border-color-y":[{"border-y":R()}],"border-color-s":[{"border-s":R()}],"border-color-e":[{"border-e":R()}],"border-color-t":[{"border-t":R()}],"border-color-r":[{"border-r":R()}],"border-color-b":[{"border-b":R()}],"border-color-l":[{"border-l":R()}],"divide-color":[{divide:R()}],"outline-style":[{outline:[...J(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Re,se,oe]}],"outline-w":[{outline:["",Re,va,ys]}],"outline-color":[{outline:R()}],shadow:[{shadow:["","none",u,_c,Oc]}],"shadow-color":[{shadow:R()}],"inset-shadow":[{"inset-shadow":["none",d,_c,Oc]}],"inset-shadow-color":[{"inset-shadow":R()}],"ring-w":[{ring:Z()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:R()}],"ring-offset-w":[{"ring-offset":[Re,ys]}],"ring-offset-color":[{"ring-offset":R()}],"inset-ring-w":[{"inset-ring":Z()}],"inset-ring-color":[{"inset-ring":R()}],"text-shadow":[{"text-shadow":["none",f,_c,Oc]}],"text-shadow-color":[{"text-shadow":R()}],opacity:[{opacity:[Re,se,oe]}],"mix-blend":[{"mix-blend":[...me(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":me()}],"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":[Re]}],"mask-image-linear-from-pos":[{"mask-linear-from":U()}],"mask-image-linear-to-pos":[{"mask-linear-to":U()}],"mask-image-linear-from-color":[{"mask-linear-from":R()}],"mask-image-linear-to-color":[{"mask-linear-to":R()}],"mask-image-t-from-pos":[{"mask-t-from":U()}],"mask-image-t-to-pos":[{"mask-t-to":U()}],"mask-image-t-from-color":[{"mask-t-from":R()}],"mask-image-t-to-color":[{"mask-t-to":R()}],"mask-image-r-from-pos":[{"mask-r-from":U()}],"mask-image-r-to-pos":[{"mask-r-to":U()}],"mask-image-r-from-color":[{"mask-r-from":R()}],"mask-image-r-to-color":[{"mask-r-to":R()}],"mask-image-b-from-pos":[{"mask-b-from":U()}],"mask-image-b-to-pos":[{"mask-b-to":U()}],"mask-image-b-from-color":[{"mask-b-from":R()}],"mask-image-b-to-color":[{"mask-b-to":R()}],"mask-image-l-from-pos":[{"mask-l-from":U()}],"mask-image-l-to-pos":[{"mask-l-to":U()}],"mask-image-l-from-color":[{"mask-l-from":R()}],"mask-image-l-to-color":[{"mask-l-to":R()}],"mask-image-x-from-pos":[{"mask-x-from":U()}],"mask-image-x-to-pos":[{"mask-x-to":U()}],"mask-image-x-from-color":[{"mask-x-from":R()}],"mask-image-x-to-color":[{"mask-x-to":R()}],"mask-image-y-from-pos":[{"mask-y-from":U()}],"mask-image-y-to-pos":[{"mask-y-to":U()}],"mask-image-y-from-color":[{"mask-y-from":R()}],"mask-image-y-to-color":[{"mask-y-to":R()}],"mask-image-radial":[{"mask-radial":[se,oe]}],"mask-image-radial-from-pos":[{"mask-radial-from":U()}],"mask-image-radial-to-pos":[{"mask-radial-to":U()}],"mask-image-radial-from-color":[{"mask-radial-from":R()}],"mask-image-radial-to-color":[{"mask-radial-to":R()}],"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":x()}],"mask-image-conic-pos":[{"mask-conic":[Re]}],"mask-image-conic-from-pos":[{"mask-conic-from":U()}],"mask-image-conic-to-pos":[{"mask-conic-to":U()}],"mask-image-conic-from-color":[{"mask-conic-from":R()}],"mask-image-conic-to-color":[{"mask-conic-to":R()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:V()}],"mask-repeat":[{mask:ie()}],"mask-size":[{mask:ne()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",se,oe]}],filter:[{filter:["","none",se,oe]}],blur:[{blur:ee()}],brightness:[{brightness:[Re,se,oe]}],contrast:[{contrast:[Re,se,oe]}],"drop-shadow":[{"drop-shadow":["","none",h,_c,Oc]}],"drop-shadow-color":[{"drop-shadow":R()}],grayscale:[{grayscale:["",Re,se,oe]}],"hue-rotate":[{"hue-rotate":[Re,se,oe]}],invert:[{invert:["",Re,se,oe]}],saturate:[{saturate:[Re,se,oe]}],sepia:[{sepia:["",Re,se,oe]}],"backdrop-filter":[{"backdrop-filter":["","none",se,oe]}],"backdrop-blur":[{"backdrop-blur":ee()}],"backdrop-brightness":[{"backdrop-brightness":[Re,se,oe]}],"backdrop-contrast":[{"backdrop-contrast":[Re,se,oe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Re,se,oe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Re,se,oe]}],"backdrop-invert":[{"backdrop-invert":["",Re,se,oe]}],"backdrop-opacity":[{"backdrop-opacity":[Re,se,oe]}],"backdrop-saturate":[{"backdrop-saturate":[Re,se,oe]}],"backdrop-sepia":[{"backdrop-sepia":["",Re,se,oe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":T()}],"border-spacing-x":[{"border-spacing-x":T()}],"border-spacing-y":[{"border-spacing-y":T()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",se,oe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Re,"initial",se,oe]}],ease:[{ease:["linear","initial",v,se,oe]}],delay:[{delay:[Re,se,oe]}],animate:[{animate:["none",w,se,oe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,se,oe]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:Oe()}],"rotate-x":[{"rotate-x":Oe()}],"rotate-y":[{"rotate-y":Oe()}],"rotate-z":[{"rotate-z":Oe()}],scale:[{scale:he()}],"scale-x":[{"scale-x":he()}],"scale-y":[{"scale-y":he()}],"scale-z":[{"scale-z":he()}],"scale-3d":["scale-3d"],skew:[{skew:we()}],"skew-x":[{"skew-x":we()}],"skew-y":[{"skew-y":we()}],transform:[{transform:[se,oe,"","none","gpu","cpu"]}],"transform-origin":[{origin:k()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Se()}],"translate-x":[{"translate-x":Se()}],"translate-y":[{"translate-y":Se()}],"translate-z":[{"translate-z":Se()}],"translate-none":["translate-none"],accent:[{accent:R()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:R()}],"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",se,oe]}],"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":T()}],"scroll-mx":[{"scroll-mx":T()}],"scroll-my":[{"scroll-my":T()}],"scroll-ms":[{"scroll-ms":T()}],"scroll-me":[{"scroll-me":T()}],"scroll-mt":[{"scroll-mt":T()}],"scroll-mr":[{"scroll-mr":T()}],"scroll-mb":[{"scroll-mb":T()}],"scroll-ml":[{"scroll-ml":T()}],"scroll-p":[{"scroll-p":T()}],"scroll-px":[{"scroll-px":T()}],"scroll-py":[{"scroll-py":T()}],"scroll-ps":[{"scroll-ps":T()}],"scroll-pe":[{"scroll-pe":T()}],"scroll-pt":[{"scroll-pt":T()}],"scroll-pr":[{"scroll-pr":T()}],"scroll-pb":[{"scroll-pb":T()}],"scroll-pl":[{"scroll-pl":T()}],"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",se,oe]}],fill:[{fill:["none",...R()]}],"stroke-w":[{stroke:[Re,va,ys,xh]}],stroke:[{stroke:["none",...R()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","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","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","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-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-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-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-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"]}});function re(...t){return vP(i0(t))}const w0=t=>Object.entries(t).filter(([e])=>isNaN(Number(e))).map(([e,n])=>({label:e,value:n})),Nc=t=>t instanceof File||t instanceof Blob,bP=t=>typeof t=="string"&&(t.startsWith("http://")||t.startsWith("https://")),xP=(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}};function E0({className:t,...e}){return g.jsx(LD,{"data-slot":"tabs",className:re("flex flex-col gap-2",t),...e})}function S0({className:t,...e}){return g.jsx(jD,{"data-slot":"tabs-list",className:re("bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",t),...e})}function wh({className:t,...e}){return g.jsx($D,{"data-slot":"tabs-trigger",className:re("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 k0({className:t,...e}){return g.jsx(BD,{"data-slot":"tabs-content",className:re("flex-1 outline-none",t),...e})}var Rc={exports:{}},Eh={};/**
33
- * @license React
34
- * use-sync-external-store-shim.production.js
35
- *
36
- * Copyright (c) Meta Platforms, Inc. and affiliates.
37
- *
38
- * This source code is licensed under the MIT license found in the
39
- * LICENSE file in the root directory of this source tree.
40
- */var C0;function wP(){if(C0)return Eh;C0=1;var t=M;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,y=p[1];return s(function(){m.value=h,m.getSnapshot=f,l(m)&&y({inst:m})},[d,h,f]),o(function(){return l(m)&&y({inst:m}),d(function(){l(m)&&y({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 Eh.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,Eh}var Sh={};/**
41
- * @license React
42
- * use-sync-external-store-shim.development.js
43
- *
44
- * Copyright (c) Meta Platforms, Inc. and affiliates.
45
- *
46
- * This source code is licensed under the MIT license found in the
47
- * LICENSE file in the root directory of this source tree.
48
- */var T0;function EP(){return T0||(T0=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,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var m=p();if(!d){var y=p();s(m,y)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}y=i({inst:{value:m,getSnapshot:p}});var v=y[0].inst,w=y[1];return l(function(){v.value=m,v.getSnapshot=p,n(v)&&w({inst:v})},[h,m,p]),a(function(){return n(v)&&w({inst:v}),h(function(){n(v)&&w({inst:v})})},[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=M,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;Sh.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())})()),Sh}var A0;function kh(){return A0||(A0=1,process.env.NODE_ENV==="production"?Rc.exports=wP():Rc.exports=EP()),Rc.exports}var Ch=kh();function zt(t){this.content=t}zt.prototype={constructor:zt,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 zt(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 zt(n)},addToStart:function(t,e){return new zt([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new zt(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 zt(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=zt.from(t),t.size?new zt(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=zt.from(t),t.size?new zt(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=zt.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}},zt.from=function(t){if(t instanceof zt)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new zt(e)};function M0(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=M0(o.content,s.content,n+1);if(i!=null)return i}n+=o.nodeSize}}function O0(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=O0(i.content,a.content,n-1,r-1);if(c)return c}n-=l,r-=l}}class F{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 F(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 F(r,o)}cutByIndex(e,n){return e==n?F.empty:e==0&&n==this.content.length?this:new F(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 F(o,s)}addToStart(e){return new F([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new F(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 M0(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return O0(this,e,n,r)}findIndex(e){if(e==0)return Ic(0,e);if(e==this.size)return Ic(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?Ic(n+1,s):Ic(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 F.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new F(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return F.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 F(n||e,r)}static from(e){if(!e)return F.empty;if(e instanceof F)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new F([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}F.empty=new F([],0);const Th={index:0,offset:0};function Ic(t,e){return Th.index=t,Th.offset=e,Th}function Dc(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(!Dc(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Dc(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Ye=class Ov{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&&Dc(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 Ov.none;if(e instanceof Ov)return[e];let n=e.slice();return n.sort((r,o)=>r.type.rank-o.type.rank),n}};Ye.none=[];class Pc extends Error{}class Q{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=N0(this.content,e+this.openStart,n);return r&&new Q(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Q(_0(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 Q.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 Q(F.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 Q(e,r,o)}}Q.empty=new Q(F.empty,0,0);function _0(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(_0(s.content,e-o-1,n-o-1)))}function N0(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=N0(i.content,e-s-1,n,i);return a&&t.replaceChild(o,i.copy(a))}function SP(t,e,n){if(n.openStart>t.depth)throw new Pc("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Pc("Inconsistent open depths");return R0(t,e,n,0)}function R0(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=R0(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 bs(i,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:i,end:a}=kP(n,t);return bs(s,D0(t,i,a,e,r))}else return bs(s,Lc(t,e,r))}function I0(t,e){if(!e.type.compatibleContent(t.type))throw new Pc("Cannot join "+e.type.name+" onto "+t.type.name)}function Ah(t,e,n){let r=t.node(n);return I0(r,e.node(n)),r}function vs(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 ba(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&&(vs(t.nodeAfter,r),s++));for(let a=s;a<i;a++)vs(o.child(a),r);e&&e.depth==n&&e.textOffset&&vs(e.nodeBefore,r)}function bs(t,e){return t.type.checkContent(e),t.copy(e)}function D0(t,e,n,r,o){let s=t.depth>o&&Ah(t,e,o+1),i=r.depth>o&&Ah(n,r,o+1),a=[];return ba(null,t,o,a),s&&i&&e.index(o)==n.index(o)?(I0(s,i),vs(bs(s,D0(t,e,n,r,o+1)),a)):(s&&vs(bs(s,Lc(t,e,o+1)),a),ba(e,n,o,a),i&&vs(bs(i,Lc(n,r,o+1)),a)),ba(r,null,o,a),new F(a)}function Lc(t,e,n){let r=[];if(ba(null,t,n,r),t.depth>n){let o=Ah(t,e,n+1);vs(bs(o,Lc(t,e,n+1)),r)}return ba(e,null,n,r),new F(r)}function kP(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(F.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}class xa{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 Ye.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 wa(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 xa(n,r,s)}static resolveCached(e,n){let r=P0.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 P0.set(e,r=new CP);let o=r.elts[r.i]=xa.resolve(e,n);return r.i=(r.i+1)%TP,o}}class CP{constructor(){this.elts=[],this.i=0}}const TP=12,P0=new WeakMap;class wa{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 AP=Object.create(null);let Qr=class _v{constructor(e,n,r,o=Ye.none){this.type=e,this.attrs=n,this.marks=o,this.content=r||F.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&&Dc(this.attrs,n||e.defaultAttrs||AP)&&Ye.sameSet(this.marks,r||Ye.none)}copy(e=null){return e==this.content?this:new _v(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new _v(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 Q.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 Q(c,o.depth-i,s.depth-i)}replace(e,n,r){return SP(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 xa.resolveCached(this,e)}resolveNoCache(e){return xa.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()+")"),L0(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=F.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=Ye.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(!Ye.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=F.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,o,r);return s.type.checkAttrs(s.attrs),s}};Qr.prototype.text=void 0;class jc extends Qr{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):L0(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 jc(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new jc(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 L0(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class xs{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new MP(e,n);if(r.next==null)return xs.empty;let o=j0(r);r.next&&r.err("Unexpected trailing text");let s=PP(DP(o));return LP(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 F.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(`
49
- `)}}xs.empty=new xs(!0);class MP{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 j0(t){let e=[];do e.push(OP(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function OP(t){let e=[];do e.push(_P(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function _P(t){let e=IP(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=NP(t,e);else break;return e}function $0(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function NP(t,e){let n=$0(t),r=n;return t.eat(",")&&(t.next!="}"?r=$0(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function RP(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 IP(t){if(t.eat("(")){let e=j0(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=RP(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 DP(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 B0(t,e){return e-t}function F0(t,e){let n=[];return r(e),n.sort(B0);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 PP(t){let e=Object.create(null);return n(F0(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]);F0(t,l).forEach(u=>{c||o.push([a,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new xs(r.indexOf(t.length-1)>-1);for(let i=0;i<o.length;i++){let a=o[i][1].sort(B0);s.next.push({type:o[i][0],next:e[a.join(",")]||n(a)})}return s}}function LP(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 H0(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 z0(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 U0(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 V0(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new $P(t,r,e[r]);return n}let W0=class SN{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=V0(e,r.attrs),this.defaultAttrs=H0(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==xs.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:z0(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Qr(this,this.computeAttrs(e),F.from(n),Ye.setFrom(r))}createChecked(e=null,n,r){return n=F.from(n),this.checkContent(n),new Qr(this,this.computeAttrs(e),n,Ye.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=F.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(F.empty,!0);return s?new Qr(this,e,n.append(s),Ye.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){U0(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:Ye.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,i)=>r[s]=new SN(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 jP(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 $P{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?jP(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class $c{constructor(e,n,r,o){this.name=e,this.rank=n,this.schema=r,this.spec=o,this.attrs=V0(e,o.attrs),this.excluded=null;let s=H0(this.attrs);this.instance=s?new Ye(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Ye(this,z0(this.attrs,e))}static compile(e,n){let r=Object.create(null),o=0;return e.forEach((s,i)=>r[s]=new $c(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){U0(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class G0{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=zt.from(e.nodes),n.marks=zt.from(e.marks||{}),this.nodes=W0.compile(this.spec.nodes,this),this.marks=$c.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]=xs.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?q0(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==""?[]:q0(this,i.split(" "))}this.nodeFromJSON=o=>Qr.fromJSON(this,o),this.markFromJSON=o=>Ye.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 W0){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 jc(r,r.defaultAttrs,e,Ye.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 q0(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 BP(t){return t.tag!=null}function FP(t){return t.style!=null}let Ea=class Nv{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(o=>{if(BP(o))this.tags.push(o);else if(FP(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 X0(this,n,!1);return r.addAll(e,Ye.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new X0(this,n,!0);return r.addAll(e,Ye.none,n.from,n.to),Q.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(UP(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 Nv(e,Nv.schemaRules(e)))}};const K0={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},HP={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Y0={ol:!0,ul:!0},Sa=1,Mh=2,ka=4;function J0(t,e,n){return e!=null?(e?Sa:0)|(e==="full"?Mh:0):t&&t.whitespace=="pre"?Sa|Mh:n&~ka}class Bc{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=Ye.none,this.match=s||(i&ka?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(F.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&Sa)){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=F.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(F.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&&!K0.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class X0{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=J0(null,n.preserveWhitespace,0)|(r?ka:0);o?s=new Bc(o.type,o.attrs,Ye.none,!0,n.topMatch||o.type.contentMatch,i):r?s=new Bc(null,null,Ye.none,!0,null,i):s=new Bc(e.schema.topNodeType,null,Ye.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&Mh?"full":this.localPreserveWS||(o.options&Sa)>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,`
50
- `);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;Y0.hasOwnProperty(i)&&this.parser.normalizeLists&&zP(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:HP.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(K0.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(`
51
- `),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=Ye.none;for(let a of o.concat(e.marks))(s.type?s.type.allowsMarkType(a.type):Z0(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=J0(e,s,i.options);i.options&ka&&i.content.length==0&&(a|=ka);let l=Ye.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):Z0(c.type,e))?(l=c.addToSet(l),!1):!0),this.nodes.push(new Bc(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|=Sa)}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 zP(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Y0.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function UP(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 Z0(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 ws{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Oh(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}=Fc(Oh(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&&Fc(Oh(r),o(e,n),null,e.attrs)}static renderSpec(e,n,r=null,o){return Fc(e,n,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ws(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=ex(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return ex(e.marks)}}function ex(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Oh(t){return t.document||window.document}const tx=new WeakMap;function VP(t){let e=tx.get(t);return e===void 0&&tx.set(t,e=WP(t)),e}function WP(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 Fc(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=VP(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}=Fc(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 nx=65535,rx=Math.pow(2,16);function GP(t,e){return t+e*rx}function ox(t){return t&nx}function qP(t){return(t-(t&nx))/rx}const sx=1,ix=2,Hc=4,ax=8;class _h{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ax)>0}get deletedBefore(){return(this.delInfo&(sx|Hc))>0}get deletedAfter(){return(this.delInfo&(ix|Hc))>0}get deletedAcross(){return(this.delInfo&Hc)>0}}class Nn{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Nn.empty)return Nn.empty}recover(e){let n=0,r=ox(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+qP(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:GP(a/3,e-l),m=e==l?ix:e==d?sx:Hc;return(n<0?e!=l:e!=d)&&(m|=ax),new _h(h,m,p)}o+=u-c}return r?e+o:new _h(e+o,0,null)}touches(e,n){let r=0,o=ox(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 Nn(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Nn.empty:new Nn(e<0?[0,-e,0]:[0,0,e])}}Nn.empty=new Nn([]);class Ca{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 Ca(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 Ca;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 _h(e,o,null)}}const Nh=Object.create(null);class Yt{getMap(){return Nn.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Nh[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 Nh)throw new RangeError("Duplicate use of step JSON ID "+e);return Nh[e]=n,n.prototype.jsonID=e,n}}class Et{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Et(e,null)}static fail(e){return new Et(null,e)}static fromReplace(e,n,r,o){try{return Et.ok(e.replace(n,r,o))}catch(s){if(s instanceof Pc)return Et.fail(s.message);throw s}}}function Rh(t,e,n){let r=[];for(let o=0;o<t.childCount;o++){let s=t.child(o);s.content.size&&(s=s.copy(Rh(s.content,e,s))),s.isInline&&(s=e(s,n,o)),r.push(s)}return F.fromArray(r)}class _o extends Yt{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 Q(Rh(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 Et.fromReplace(e,this.from,this.to,s)}invert(){return new ir(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 _o(n.pos,r.pos,this.mark)}merge(e){return e instanceof _o&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new _o(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 _o(n.from,n.to,e.markFromJSON(n.mark))}}Yt.jsonID("addMark",_o);class ir extends Yt{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 Q(Rh(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),n.openStart,n.openEnd);return Et.fromReplace(e,this.from,this.to,r)}invert(){return new _o(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 ir(n.pos,r.pos,this.mark)}merge(e){return e instanceof ir&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ir(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 ir(n.from,n.to,e.markFromJSON(n.mark))}}Yt.jsonID("removeMark",ir);class No extends Yt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Et.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Et.fromReplace(e,this.pos,this.pos+1,new Q(F.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 No(this.pos,n.marks[o]);return new No(this.pos,this.mark)}}return new Es(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new No(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 No(n.pos,e.markFromJSON(n.mark))}}Yt.jsonID("addNodeMark",No);class Es extends Yt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Et.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Et.fromReplace(e,this.pos,this.pos+1,new Q(F.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new No(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Es(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 Es(n.pos,e.markFromJSON(n.mark))}}Yt.jsonID("removeNodeMark",Es);class Dt extends Yt{constructor(e,n,r,o=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=o}apply(e){return this.structure&&Ih(e,this.from,this.to)?Et.fail("Structure replace would overwrite content"):Et.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Nn([this.from,this.to-this.from,this.slice.size])}invert(e){return new Dt(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 Dt(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Dt)||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?Q.empty:new Q(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Dt(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?Q.empty:new Q(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Dt(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 Dt(n.from,n.to,Q.fromJSON(e,n.slice),!!n.structure)}}Yt.jsonID("replace",Dt);class Pt extends Yt{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&&(Ih(e,this.from,this.gapFrom)||Ih(e,this.gapTo,this.to)))return Et.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Et.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Et.fromReplace(e,this.from,this.to,r):Et.fail("Content does not fit in gap")}getMap(){return new Nn([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 Pt(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 Pt(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 Pt(n.from,n.to,n.gapFrom,n.gapTo,Q.fromJSON(e,n.slice),n.insert,!!n.structure)}}Yt.jsonID("replaceAround",Pt);function Ih(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 KP(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 ir(f,h,d[m])));a&&a.to==f?a.to=h:s.push(a=new _o(f,h,r))}}),o.forEach(l=>t.step(l)),s.forEach(l=>t.step(l))}function YP(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 $c){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 ir(i.from,i.to,i.style)))}function Dh(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 Dt(a,u,Q.empty));else{r=d;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new ir(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 Q(F.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),i.push(new Dt(a+f.index,a+f.index+f[0].length,p))}}a=u}if(!r.validEnd){let l=r.fillBefore(F.empty,!0);t.replace(a,a,new Q(l,0,0))}for(let l=i.length-1;l>=0;l--)t.step(i[l])}function JP(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function ci(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let o=t.$from.node(r),s=t.$from.index(r),i=t.$to.indexAfter(r);if(r<t.depth&&o.canReplace(s,i,n))return r;if(r==0||o.type.spec.isolating||!JP(o,s,i))break}return null}function XP(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=F.empty,d=0;for(let p=s,m=!1;p>n;p--)m||r.index(p)>0?(m=!0,u=F.from(r.node(p).copy(u)),d++):l--;let f=F.empty,h=0;for(let p=s,m=!1;p>n;p--)m||o.after(p+1)<o.end(p)?(m=!0,f=F.from(o.node(p).copy(f)),h++):c++;t.step(new Pt(l,c,i,a,new Q(u.append(f),d,h),u.size-d,!0))}function Ph(t,e,n=null,r=t){let o=QP(t,e),s=o&&ZP(r,e);return s?o.map(lx).concat({type:e,attrs:n}).concat(s.map(lx)):null}function lx(t){return{type:t,attrs:null}}function QP(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 ZP(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 eL(t,e,n){let r=F.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=F.from(n[i].type.create(n[i].attrs,r))}let o=e.start,s=e.end;t.step(new Pt(o,s,o,s,new Q(r,0,0),n.length,!0))}function tL(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)&&nL(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&&ux(t,i,a,s),Dh(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 Pt(d,f,d+1,f-1,new Q(F.from(r.create(l,null,i.marks)),0,0),1,!0)),c===!0&&cx(t,i,a,s),!1}})}function cx(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 ux(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(`
52
- `))}})}function nL(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function rL(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 Pt(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new Q(F.from(i),0,0),1,!0))}function Zr(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 oL(t,e,n=1,r){let o=t.doc.resolve(e),s=F.empty,i=F.empty;for(let a=o.depth,l=o.depth-n,c=n-1;a>l;a--,c--){s=F.from(o.node(a).copy(s));let u=r&&r[c];i=F.from(u?u.type.create(u.attrs,i):o.node(a).copy(i))}t.step(new Dt(e,e,new Q(s.append(i),n,n),!0))}function Ro(t,e){let n=t.resolve(e),r=n.index();return dx(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function sL(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 dx(t,e){return!!(t&&e&&!t.isLeaf&&sL(t,e))}function zc(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&&dx(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 iL(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);ux(t,u.node(),u.before(),a)}i.inlineContent&&Dh(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 Dt(c,l.map(e+n,-1),Q.empty,!0)),r===!0){let u=t.doc.resolve(c);cx(t,u.node(),u.before(),t.steps.length)}return t}function aL(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 fx(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 Uc(t,e,n=e,r=Q.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),s=t.resolve(n);return hx(o,s,r)?new Dt(e,n,r):new lL(o,s,r).fit()}function hx(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class lL{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=F.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=F.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 Q(s,i,a);return e>-1?new Pt(r.pos,e,this.$to.pos,this.$to.end(),l,n):l.size||r.pos!=this.$to.pos?new Dt(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=Lh(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(F.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=Lh(e,n);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new Q(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=Lh(e,n);if(o.childCount<=1&&n>0){let s=e.size-n<=n+o.size;this.unplaced=new Q(Ta(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new Q(Ta(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),y=d.matchType(m.type);if(!y)break;c++,(c>1||l==0||m.content.size)&&(d=y,u.push(px(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=Aa(this.placed,n,F.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,y=a;m<h;m++){let v=y.lastChild;this.frontier.push({type:v.type,match:v.contentMatchAt(v.childCount)}),y=v.content}this.unplaced=p?e==0?Q.empty:new Q(Ta(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new Q(Ta(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||!jh(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=jh(e,n,o,r,s);if(i){for(let a=n-1;a>=0;a--){let{match:l,type:c}=this.frontier[a],u=jh(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=Aa(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=Aa(this.placed,this.depth,F.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(F.empty,!0);n.childCount&&(this.placed=Aa(this.placed,this.frontier.length,n))}}function Ta(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Ta(t.firstChild.content,e-1,n)))}function Aa(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Aa(t.lastChild.content,e-1,n)))}function Lh(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function px(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,px(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(F.empty,!0)))),t.copy(r)}function jh(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&&!cL(n,s.content,i)?a:null}function cL(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function uL(t){return t.spec.defining||t.spec.definingForContent}function dL(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let o=t.doc.resolve(e),s=t.doc.resolve(n);if(hx(o,s,r))return t.step(new Dt(e,n,r));let i=gx(o,t.doc.resolve(n));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=uL(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 y=i[(m+l)%i.length],v=!0;y<0&&(v=!1,y=-y);let w=o.node(y-1),E=o.index(y-1);if(w.canReplaceWith(E,E,p.type,p.marks))return t.replace(o.before(y),v?s.after(y):n,new Q(mx(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 mx(t,e,n,r,o){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(mx(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(F.empty,!0))}return t}function fL(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=aL(t.doc,e,r.type);o!=null&&(e=n=o)}t.replaceRange(e,n,new Q(F.from(r),0,0))}function hL(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n),s=gx(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 gx(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 ui extends Yt{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 Et.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 Et.fromReplace(e,this.pos,this.pos+1,new Q(F.from(o),0,n.isLeaf?0:1))}getMap(){return Nn.empty}invert(e){return new ui(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 ui(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 ui(n.pos,n.attr,n.value)}}Yt.jsonID("attr",ui);class Ma extends Yt{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 Et.ok(r)}getMap(){return Nn.empty}invert(e){return new Ma(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 Ma(n.attr,n.value)}}Yt.jsonID("docAttr",Ma);let di=class extends Error{};di=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},di.prototype=Object.create(Error.prototype),di.prototype.constructor=di,di.prototype.name="TransformError";class yx{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ca}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new di(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}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=Q.empty){let o=Uc(this.doc,e,n,r);return o&&this.step(o),this}replaceWith(e,n,r){return this.replace(e,n,new Q(F.from(r),0,0))}delete(e,n){return this.replace(e,n,Q.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return dL(this,e,n,r),this}replaceRangeWith(e,n,r){return fL(this,e,n,r),this}deleteRange(e,n){return hL(this,e,n),this}lift(e,n){return XP(this,e,n),this}join(e,n=1){return iL(this,e,n),this}wrap(e,n){return eL(this,e,n),this}setBlockType(e,n=e,r,o=null){return tL(this,e,n,r,o),this}setNodeMarkup(e,n,r=null,o){return rL(this,e,n,r,o),this}setNodeAttribute(e,n,r){return this.step(new ui(e,n,r)),this}setDocAttribute(e,n){return this.step(new Ma(e,n)),this}addNodeMark(e,n){return this.step(new No(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 Ye)n.isInSet(r.marks)&&this.step(new Es(e,n));else{let o=r.marks,s,i=[];for(;s=n.isInSet(o);)i.push(new Es(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 oL(this,e,n,r),this}addMark(e,n,r){return KP(this,e,n,r),this}removeMark(e,n,r){return YP(this,e,n,r),this}clearIncompatible(e,n,r){return Dh(this,e,n,r),this}}const $h=Object.create(null);class Me{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new vx(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=Q.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?Q.empty:n),a==0&&wx(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),wx(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let o=e.parent.inlineContent?new pe(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 yn(e.node(0))}static atStart(e){return fi(e,e,0,0,1)||new yn(e)}static atEnd(e){return fi(e,e,e.content.size,e.childCount,-1)||new yn(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=$h[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 $h)throw new RangeError("Duplicate use of selection JSON ID "+e);return $h[e]=n,n.prototype.jsonID=e,n}getBookmark(){return pe.between(this.$anchor,this.$head).getBookmark()}}Me.prototype.visible=!0;class vx{constructor(e,n){this.$from=e,this.$to=n}}let bx=!1;function xx(t){!bx&&!t.parent.inlineContent&&(bx=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class pe extends Me{constructor(e,n=e){xx(e),xx(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 Me.near(r);let o=e.resolve(n.map(this.anchor));return new pe(o.parent.inlineContent?o:r,r)}replace(e,n=Q.empty){if(super.replace(e,n),n==Q.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof pe&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Vc(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 pe(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=Me.findFrom(n,r,!0)||Me.findFrom(n,-r,!0);if(s)n=s.$head;else return Me.near(n,r)}return e.parent.inlineContent||(o==0?e=n:(e=(Me.findFrom(e,-r,!0)||Me.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=o<0&&(e=n))),new pe(e,n)}}Me.jsonID("text",pe);class Vc{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Vc(e.map(this.anchor),e.map(this.head))}resolve(e){return pe.between(e.resolve(this.anchor),e.resolve(this.head))}}class ue extends Me{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?Me.near(s):new ue(s)}content(){return new Q(F.from(this.node),0,0)}eq(e){return e instanceof ue&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Bh(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ue(e.resolve(n.anchor))}static create(e,n){return new ue(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}ue.prototype.visible=!1,Me.jsonID("node",ue);class Bh{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Vc(r,r):new Bh(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&ue.isSelectable(r)?new ue(n):Me.near(n)}}class yn extends Me{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Q.empty){if(n==Q.empty){e.delete(0,e.doc.content.size);let r=Me.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new yn(e)}map(e){return new yn(e)}eq(e){return e instanceof yn}getBookmark(){return pL}}Me.jsonID("all",yn);const pL={map(){return this},resolve(t){return new yn(t)}};function fi(t,e,n,r,o,s=!1){if(e.inlineContent)return pe.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&&ue.isSelectable(a))return ue.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 wx(t,e,n){let r=t.steps.length-1;if(r<e)return;let o=t.steps[r];if(!(o instanceof Dt||o instanceof Pt))return;let s=t.mapping.maps[r],i;s.forEach((a,l,c,u)=>{i==null&&(i=u)}),t.setSelection(Me.near(t.doc.resolve(i),n))}const Ex=1,Wc=2,Sx=4;let mL=class extends yx{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|Ex)&~Wc,this.storedMarks=null,this}get selectionSet(){return(this.updated&Ex)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Wc,this}ensureMarks(e){return Ye.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&Wc)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Wc,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)||Ye.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),r=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.setSelection(Me.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|=Sx,this}get scrolledIntoView(){return(this.updated&Sx)>0}};function kx(t,e){return!e||!t?t:t.bind(e)}class Oa{constructor(e,n,r){this.name=e,this.init=kx(n.init,r),this.apply=kx(n.apply,r)}}const gL=[new Oa("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Oa("selection",{init(t,e){return t.selection||Me.atStart(e.doc)},apply(t){return t.selection}}),new Oa("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Oa("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Fh{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=gL.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 Oa(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 mL(this)}static create(e){let n=new Fh(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 Fh(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 Fh(e.schema,e.plugins),s=new hi(o);return o.fields.forEach(i=>{if(i.name=="doc")s.doc=Qr.fromJSON(e.schema,n.doc);else if(i.name=="selection")s.selection=Me.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 Cx(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=Cx(o,e,{})),n[r]=o}return n}class He{constructor(e){this.spec=e,this.props={},e.props&&Cx(e.props,this,this.props),this.key=e.key?e.key.key:Tx("plugin")}getState(e){return e[this.key]}}const Hh=Object.create(null);function Tx(t){return t in Hh?t+"$"+ ++Hh[t]:(Hh[t]=0,t+"$")}class Ue{constructor(e="key"){this.key=Tx(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const zh=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Ax(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Mx=(t,e,n)=>{let r=Ax(t,n);if(!r)return!1;let o=Uh(r);if(!o){let i=r.blockRange(),a=i&&ci(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)}let s=o.nodeBefore;if(jx(t,o,e,-1))return!0;if(r.parent.content.size==0&&(pi(s,"end")||ue.isSelectable(s)))for(let i=r.depth;;i--){let a=Uc(t.doc,r.before(i),r.after(i),Q.empty);if(a&&a.slice.size<a.to-a.from){if(e){let l=t.tr.step(a);l.setSelection(pi(s,"end")?Me.findFrom(l.doc.resolve(l.mapping.map(o.pos,-1)),-1):ue.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},yL=(t,e,n)=>{let r=Ax(t,n);if(!r)return!1;let o=Uh(r);return o?Ox(t,o,e):!1},vL=(t,e,n)=>{let r=Nx(t,n);if(!r)return!1;let o=Vh(r);return o?Ox(t,o,e):!1};function Ox(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=Uc(t.doc,s,l,Q.empty);if(!c||c.from!=s||c instanceof Dt&&c.slice.size>=l-s)return!1;if(n){let u=t.tr.step(c);u.setSelection(pe.create(u.doc,s)),n(u.scrollIntoView())}return!0}function pi(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 _x=(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=Uh(r)}let i=s&&s.nodeBefore;return!i||!ue.isSelectable(i)?!1:(e&&e(t.tr.setSelection(ue.create(t.doc,s.pos-i.nodeSize)).scrollIntoView()),!0)};function Uh(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 Nx(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Rx=(t,e,n)=>{let r=Nx(t,n);if(!r)return!1;let o=Vh(r);if(!o)return!1;let s=o.nodeAfter;if(jx(t,o,e,1))return!0;if(r.parent.content.size==0&&(pi(s,"start")||ue.isSelectable(s))){let i=Uc(t.doc,r.before(),r.after(),Q.empty);if(i&&i.slice.size<i.to-i.from){if(e){let a=t.tr.step(i);a.setSelection(pi(s,"start")?Me.findFrom(a.doc.resolve(a.mapping.map(o.pos)),1):ue.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},Ix=(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=Vh(r)}let i=s&&s.nodeAfter;return!i||!ue.isSelectable(i)?!1:(e&&e(t.tr.setSelection(ue.create(t.doc,s.pos)).scrollIntoView()),!0)};function Vh(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 bL=(t,e)=>{let n=t.selection,r=n instanceof ue,o;if(r){if(n.node.isTextblock||!Ro(t.doc,n.from))return!1;o=n.from}else if(o=zc(t.doc,n.from,-1),o==null)return!1;if(e){let s=t.tr.join(o);r&&s.setSelection(ue.create(s.doc,o-t.doc.resolve(o).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},xL=(t,e)=>{let n=t.selection,r;if(n instanceof ue){if(n.node.isTextblock||!Ro(t.doc,n.to))return!1;r=n.to}else if(r=zc(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},wL=(t,e)=>{let{$from:n,$to:r}=t.selection,o=n.blockRange(r),s=o&&ci(o);return s==null?!1:(e&&e(t.tr.lift(o,s).scrollIntoView()),!0)},Dx=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
53
- `).scrollIntoView()),!0)};function Wh(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 EL=(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=Wh(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(Me.near(l.doc.resolve(a),1)),e(l.scrollIntoView())}return!0},Px=(t,e)=>{let n=t.selection,{$from:r,$to:o}=n;if(n instanceof yn||r.parent.inlineContent||o.parent.inlineContent)return!1;let s=Wh(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(pe.create(a.doc,i+1)),e(a.scrollIntoView())}return!0},Lx=(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(Zr(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),o=r&&ci(r);return o==null?!1:(e&&e(t.tr.lift(r,o).scrollIntoView()),!0)};function SL(t){return(e,n)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof ue&&e.selection.node.isBlock)return!r.parentOffset||!Zr(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=Wh(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 pe||e.selection instanceof yn)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=Zr(u.doc,d,s.length,s);if(f||(s[0]=a?{type:a}:null,f=Zr(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 kL=SL(),CL=(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(ue.create(t.doc,o))),!0)};function TL(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||Ro(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function jx(t,e,n,r){let o=e.nodeBefore,s=e.nodeAfter,i,a,l=o.type.spec.isolating||s.type.spec.isolating;if(!l&&TL(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=F.empty;for(let v=i.length-1;v>=0;v--)p=F.from(i[v].create(null,p));p=F.from(o.copy(p));let m=t.tr.step(new Pt(e.pos-1,h,e.pos,h,new Q(p,1,0),i.length,!0)),y=m.doc.resolve(h+2*i.length);y.nodeAfter&&y.nodeAfter.type==o.type&&Ro(m.doc,y.pos)&&m.join(y.pos),n(m.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&l?null:Me.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&ci(d);if(f!=null&&f>=e.depth)return n&&n(t.tr.lift(d,f).scrollIntoView()),!0;if(c&&pi(s,"start",!0)&&pi(o,"end")){let h=o,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=s,y=1;for(;!m.isTextblock;m=m.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(n){let v=F.empty;for(let E=p.length-1;E>=0;E--)v=F.from(p[E].copy(v));let w=t.tr.step(new Pt(e.pos-p.length,e.pos+s.nodeSize,e.pos+y,e.pos+s.nodeSize-y,new Q(v,p.length,0),0,!0));n(w.scrollIntoView())}return!0}}return!1}function $x(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(pe.create(e.doc,t<0?o.start(s):o.end(s)))),!0):!1}}const AL=$x(-1),ML=$x(1);function OL(t,e=null){return function(n,r){let{$from:o,$to:s}=n.selection,i=o.blockRange(s),a=i&&Ph(i,t,e);return a?(r&&r(n.tr.wrap(i,a).scrollIntoView()),!0):!1}}function Bx(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 Gh(...t){return function(e,n,r){for(let o=0;o<t.length;o++)if(t[o](e,n,r))return!0;return!1}}Gh(zh,Mx,_x),Gh(zh,Rx,Ix),Gh(Dx,Px,Lx,kL),typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function _L(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 NL(a,i,t,e)?(r&&r(a.scrollIntoView()),!0):!1}}function NL(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 wa(l,l,e.depth),e.endIndex<e.parent.childCount&&(e=new wa(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let a=Ph(s,n,r,e);return a?(t&&RL(t,e,a,o,n),!0):!1}function RL(t,e,n,r,o){let s=F.empty;for(let u=n.length-1;u>=0;u--)s=F.from(n[u].type.create(n[u].attrs,s));t.step(new Pt(e.start-(r?2:0),e.end,e.start,e.end,new Q(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&&Zr(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=c.child(u).nodeSize;return t}function IL(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?DL(e,n,t,s):PL(e,n,s):!0:!1}}function DL(t,e,n,r){let o=t.tr,s=r.end,i=r.$to.end(r.depth);s<i&&(o.step(new Pt(s-1,i,s,i,new Q(F.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new wa(o.doc.resolve(r.$from.pos),o.doc.resolve(i),r.depth));const a=ci(r);if(a==null)return!1;o.lift(r,a);let l=o.doc.resolve(o.mapping.map(s,-1)-1);return Ro(o.doc,l.pos)&&l.nodeBefore.type==l.nodeAfter.type&&o.join(l.pos),e(o.scrollIntoView()),!0}function PL(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?F.empty:F.from(o))))return!1;let d=s.pos,f=d+i.nodeSize;return r.step(new Pt(d-(a?1:0),f+(l?1:0),d+1,f-1,new Q((a?F.empty:F.from(o.copy(F.empty))).append(l?F.empty:F.from(o.copy(F.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}function LL(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=F.from(c?t.create():null),d=new Q(F.from(t.create(null,F.from(a.type.create(null,u)))),c?3:1,0),f=s.start,h=s.end;n(e.tr.step(new Pt(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}const Ut=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},mi=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let qh=null;const eo=function(t,e,n){let r=qh||(qh=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},jL=function(){qh=null},Ss=function(t,e,n,r){return n&&(Fx(t,e,n,r,-1)||Fx(t,e,n,r,1))},$L=/^(img|br|input|textarea|hr)$/i;function Fx(t,e,n,r,o){for(var s;;){if(t==n&&e==r)return!0;if(e==(o<0?0:Fn(t))){let i=t.parentNode;if(!i||i.nodeType!=1||_a(t)||$L.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ut(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?Fn(t):0}else return!1}}function Fn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function BL(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=Fn(t)}else if(t.parentNode&&!_a(t))e=Ut(t),t=t.parentNode;else return null}}function FL(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&&!_a(t))e=Ut(t)+1,t=t.parentNode;else return null}}function HL(t,e,n){for(let r=e==0,o=e==Fn(t);r||o;){if(t==n)return!0;let s=Ut(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,o=o&&s==Fn(t)}}function _a(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 Gc=function(t){return t.focusNode&&Ss(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function ks(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function zL(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function UL(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Fn(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Fn(r.startContainer),r.startOffset)}}}const Ar=typeof navigator<"u"?navigator:null,Hx=typeof document<"u"?document:null,Io=Ar&&Ar.userAgent||"",Kh=/Edge\/(\d+)/.exec(Io),zx=/MSIE \d/.exec(Io),Yh=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Io),vn=!!(zx||Yh||Kh),Do=zx?document.documentMode:Yh?+Yh[1]:Kh?+Kh[1]:0,Hn=!vn&&/gecko\/(\d+)/i.test(Io);Hn&&+(/Firefox\/(\d+)/.exec(Io)||[0,0])[1];const Jh=!vn&&/Chrome\/(\d+)/.exec(Io),Jt=!!Jh,Ux=Jh?+Jh[1]:0,nn=!vn&&!!Ar&&/Apple Computer/.test(Ar.vendor),gi=nn&&(/Mobile\/\w+/.test(Io)||!!Ar&&Ar.maxTouchPoints>2),zn=gi||(Ar?/Mac/.test(Ar.platform):!1),VL=Ar?/Win/.test(Ar.platform):!1,to=/Android \d/.test(Io),Na=!!Hx&&"webkitFontSmoothing"in Hx.documentElement.style,WL=Na?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function GL(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 no(t,e){return typeof t=="number"?t:t[e]}function qL(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 Vx(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=mi(i);continue}let a=i,l=a==s.body,c=l?GL(s):qL(a),u=0,d=0;if(e.top<c.top+no(r,"top")?d=-(c.top-e.top+no(o,"top")):e.bottom>c.bottom-no(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+no(o,"top")-c.top:e.bottom-c.bottom+no(o,"bottom")),e.left<c.left+no(r,"left")?u=-(c.left-e.left+no(o,"left")):e.right>c.right-no(r,"right")&&(u=e.right-c.right+no(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,y=a.scrollTop-p;e={left:e.left-m,top:e.top-y,right:e.right-m,bottom:e.bottom-y}}let f=l?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(f))break;i=f=="absolute"?i.offsetParent:mi(i)}}function KL(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:Wx(t.dom)}}function Wx(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=mi(r));return e}function YL({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Gx(n,r==0?0:r-e)}function Gx(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 yi=null;function JL(t){if(t.setActive)return t.setActive();if(yi)return t.focus(yi);let e=Wx(t);t.focus(yi==null?{get preventScroll(){return yi={preventScroll:!0},!0}}:void 0),yi||(yi=!1,Gx(e,0))}function qx(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=eo(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?XL(n,o):!n||r&&n.nodeType==1?{node:t,offset:s}:qx(n,o)}function XL(t,e){let n=t.nodeValue.length,r=document.createRange();for(let o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);let s=Po(r,1);if(s.top!=s.bottom&&Xh(e,s))return{node:t,offset:o+(e.left>=(s.left+s.right)/2?1:0)}}return{node:t,offset:0}}function Xh(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function QL(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function ZL(t,e,n){let{node:r,offset:o}=qx(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 ej(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 Kx(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(Xh(e,c))return Kx(i,e,c)}}if((s=(s+1)%r)==o)break}return t}function tj(t,e){let n=t.dom.ownerDocument,r,o=0,s=UL(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(!Xh(e,c)||(i=Kx(t.dom,e,c),!i))return null}if(nn)for(let c=i;r&&c;c=mi(c))c.draggable&&(r=void 0);if(i=QL(i,e),r){if(Hn&&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;Na&&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=ej(t,r,o,e))}a==null&&(a=ZL(t,i,e));let l=t.docView.nearestDesc(i,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function Yx(t){return t.top<t.bottom||t.left<t.right}function Po(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Yx(r))return r}return Array.prototype.find.call(n,Yx)||t.getBoundingClientRect()}const nj=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Jx(t,e,n){let{node:r,offset:o,atom:s}=t.docView.domFromPos(e,n<0?-1:1),i=Na||Hn;if(r.nodeType==3)if(i&&(nj.test(r.nodeValue)||(n<0?!o:o==r.nodeValue.length))){let l=Po(eo(r,o,o),n);if(Hn&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=Po(eo(r,o-1,o-1),-1);if(c.top==l.top){let u=Po(eo(r,o,o+1),-1);if(u.top!=l.top)return Ra(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++,Ra(Po(eo(r,l,c),u),u<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&o&&(n<0||o==Fn(r))){let l=r.childNodes[o-1];if(l.nodeType==1)return Qh(l.getBoundingClientRect(),!1)}if(s==null&&o<Fn(r)){let l=r.childNodes[o];if(l.nodeType==1)return Qh(l.getBoundingClientRect(),!0)}return Qh(r.getBoundingClientRect(),n>=0)}if(s==null&&o&&(n<0||o==Fn(r))){let l=r.childNodes[o-1],c=l.nodeType==3?eo(l,Fn(l)-(i?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Ra(Po(c,1),!1)}if(s==null&&o<Fn(r)){let l=r.childNodes[o];for(;l.pmViewDesc&&l.pmViewDesc.ignoreForCoords;)l=l.nextSibling;let c=l?l.nodeType==3?eo(l,0,i?0:1):l.nodeType==1?l:null:null;if(c)return Ra(Po(c,-1),!0)}return Ra(Po(r.nodeType==3?eo(r):r,-n),n>=0)}function Ra(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 Qh(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 Xx(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 rj(t,e,n){let r=e.selection,o=n=="up"?r.$from:r.$to;return Xx(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=Jx(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=eo(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 oj=/[\u0590-\u08ac]/;function sj(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?!oj.test(r.parent.textContent)||!a.modify?n=="left"||n=="backward"?s:i:Xx(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(),y=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),y}):r.pos==r.start()||r.pos==r.end()}let Qx=null,Zx=null,ew=!1;function ij(t,e,n){return Qx==e&&Zx==n?ew:(Qx=e,Zx=n,ew=n=="up"||n=="down"?rj(t,e,n):sj(t,e,n))}const Un=0,tw=1,Cs=2,Mr=3;class Ia{constructor(e,n,r,o){this.parent=e,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=Un,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>Ut(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 ow){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 nw&&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?Ut(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?Ut(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=Ut(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=Ut(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],y=p+m.size;if(s>p&&i<y)return m.setSelection(e-p-m.border,n-p-m.border,r,o);p=y}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((Hn||nn)&&e==n){let{node:h,offset:p}=a;if(h.nodeType==3){if(d=!!(p&&h.nodeValue[p-1]==`
54
- `),d&&p==h.nodeValue.length)for(let m=h,y;m;m=m.parentNode){if(y=m.nextSibling){y.nodeName=="BR"&&(a=l={node:y.parentNode,offset:Ut(y)+1});break}let v=m.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let m=h.childNodes[p-1];d=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Hn&&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&&nn)&&Ss(a.node,a.offset,u.anchorNode,u.anchorOffset)&&Ss(l.node,l.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==n)&&!(d&&Hn)){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?Cs:tw,e==a&&n==l&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Mr:s.markDirty(e-a,n-a);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Cs:Mr}r=i}this.dirty=Cs}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Cs:tw;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class nw extends Ia{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==Un&&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 aj extends Ia{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 Ts extends Ia{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=ws.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Ts(e,n,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&Mr||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Mr&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Un){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Un}}slice(e,n,r){let o=Ts.create(this.parent,this.mark,!0,r),s=this.children,i=this.size;n<i&&(s=ep(s,n,i,r)),e>0&&(s=ep(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 Lo extends Ia{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}=ws.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=aw(u,r,n),c?l=new lj(e,n,r,o,u,d||null,f,c,s,i+1):n.isText?new qc(e,n,r,o,u,f,s):new Lo(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=()=>F.empty)}return e}matchesNode(e,n,r){return this.dirty==Un&&e.eq(this.node)&&Kc(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 uj(this,i&&i.node,e);hj(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?l.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!d&&l.syncToMarks(u==this.node.childCount?Ye.none:this.node.child(u).marks,r,e),l.placeWidget(c,e,o)},(c,u,d,f)=>{l.syncToMarks(c.marks,r,e);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),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Cs)&&(i&&this.protectLocalComposition(e,i),sw(this.contentDOM,this.children,e),gi&&pj(this.dom))}localCompositionInfo(e,n){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof pe)||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=mj(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 aj(this,s,n,o);e.input.compositionNodes.push(i),this.children=ep(this.children,r,r+o.length,e,i)}update(e,n,r,o){return this.dirty==Mr||!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=Un}updateOuterDeco(e){if(Kc(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=iw(this.dom,this.nodeDOM,Zh(this.outerDeco,this.node,n),Zh(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 rw(t,e,n,r,o){aw(r,e,t);let s=new Lo(void 0,t,e,n,r,r,r,o,0);return s.contentDOM&&s.updateChildren(o,0),s}class qc extends Lo{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==Mr||this.dirty!=Un&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Un||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=Un,!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 qc(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=Mr)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ow extends Ia{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Un&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class lj extends Lo{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==Mr)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 sw(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=lw(r),o=!0;r=r.nextSibling}else o=!0,t.insertBefore(a,r);if(i instanceof Ts){let l=r?r.previousSibling:t.lastChild;sw(i.contentDOM,i.children,n),r=l?l.nextSibling:t.firstChild}}for(;r;)r=lw(r),o=!0;o&&n.trackWrites==t&&(n.trackWrites=null)}const Da=function(t){t&&(this.nodeName=t)};Da.prototype=Object.create(null);const As=[new Da];function Zh(t,e,n){if(t.length==0)return As;let r=n?As[0]:new Da,o=[r];for(let s=0;s<t.length;s++){let i=t[s].type.attrs;if(i){i.nodeName&&o.push(r=new Da(i.nodeName));for(let a in i){let l=i[a];l!=null&&(n&&o.length==1&&o.push(r=new Da(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 iw(t,e,n,r){if(n==As&&r==As)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=As[0]),o=l}cj(o,a||As[0],i)}return o}function cj(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 aw(t,e,n){return iw(t,t,As,Zh(e,n,t.nodeType!=1))}function Kc(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 lw(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class uj{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=dj(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){let o=0,s=this.stack.length>>1,i=Math.min(s,e.length);for(;o<i&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=Un,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1;for(let l=this.index;l<Math.min(this.index+3,this.top.children.length);l++){let c=this.top.children[l];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){a=l;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let l=Ts.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,s++}}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==Mr&&i.dom==i.contentDOM&&(i.dirty=Cs),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 Lo){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!=Mr&&Kc(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=Cs,d.updateChildren(o,i+1),d.dirty=Un),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)||!Kc(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let a=Lo.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=Lo.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 nw(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 Ts;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof qc)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((nn||Jt)&&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 ow(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 dj(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 Ts)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 fj(t,e){return t.type.side-e.type.side}function hj(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 y=o[i++];y.widget&&(u?(d||(d=[u])).push(y):u=y)}if(u)if(d){d.sort(fj);for(let y=0;y<d.length;y++)n(d[y],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 y=0;y<a.length;y++)a[y].to<=s&&a.splice(y--,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 y=p;i<o.length&&o[i].from<y&&(y=o[i].from);for(let v=0;v<a.length;v++)a[v].to<y&&(y=a[v].to);y<p&&(l=f.cut(y-s),f=f.cut(0,y-s),p=y,h=-1)}else for(;i<o.length&&o[i].to<p;)i++;let m=f.isInline&&!f.isLeaf?a.filter(y=>!y.inline):a.slice();r(f,m,e.forChild(s,f),h),s=p}}function pj(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 mj(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 ep(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 tp(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(Gc(n)){for(l=i;o&&!o.node;)o=o.parent;let d=o.node;if(o&&d.isAtom&&ue.isSelectable(d)&&o.parent&&!(d.isInline&&HL(n.focusNode,n.focusOffset,o.dom))){let f=o.posBefore;c=new ue(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=rp(t,u,a,d)}return c}function cw(t){return t.editable?t.hasFocus():gw(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function ro(t,e=!1){let n=t.state.selection;if(hw(t,n),!!cw(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Jt){let r=t.domSelectionRange(),o=t.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Ss(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)yj(t);else{let{anchor:r,head:o}=n,s,i;uw&&!(n instanceof pe)&&(n.$from.parent.inlineContent||(s=dw(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(i=dw(t,n.to))),t.docView.setSelection(r,o,t,e),uw&&(s&&fw(s),i&&fw(i)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&gj(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const uw=nn||Jt&&Ux<63;function dw(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(nn&&o&&o.contentEditable=="false")return np(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return np(o);if(s)return np(s)}}function np(t){return t.contentEditable="true",nn&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function fw(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function gj(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(()=>{(!cw(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function yj(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ut(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&vn&&Do<=11&&(n.disabled=!0,n.disabled=!1)}function hw(t,e){if(e instanceof ue){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(pw(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else pw(t)}function pw(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function rp(t,e,n,r){return t.someProp("createSelectionBetween",o=>o(t,e,n))||pe.between(e,n,r)}function mw(t){return t.editable&&!t.hasFocus()?!1:gw(t)}function gw(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 vj(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Ss(e.node,e.offset,n.anchorNode,n.anchorOffset)}function op(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&&Me.findFrom(s,e)}function jo(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function yw(t,e,n){let r=t.state.selection;if(r instanceof pe)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 jo(t,new pe(r.$anchor,i))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let o=op(t.state,e);return o&&o instanceof ue?jo(t,o):!1}else if(!(zn&&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?ue.isSelectable(s)?jo(t,new ue(e<0?t.state.doc.resolve(o.pos-s.nodeSize):o)):Na?jo(t,new pe(t.state.doc.resolve(e<0?a:a+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof ue&&r.node.isInline)return jo(t,new pe(e>0?r.$to:r.$from));{let o=op(t.state,e);return o?jo(t,o):!1}}}function Yc(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Pa(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function vi(t,e){return e<0?bj(t):xj(t)}function bj(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,s,i=!1;for(Hn&&n.nodeType==1&&r<Yc(n)&&Pa(n.childNodes[r],-1)&&(i=!0);;)if(r>0){if(n.nodeType!=1)break;{let a=n.childNodes[r-1];if(Pa(a,-1))o=n,s=--r;else if(a.nodeType==3)n=a,r=n.nodeValue.length;else break}}else{if(vw(n))break;{let a=n.previousSibling;for(;a&&Pa(a,-1);)o=n.parentNode,s=Ut(a),a=a.previousSibling;if(a)n=a,r=Yc(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}i?sp(t,n,r):o&&sp(t,o,s)}function xj(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o=Yc(n),s,i;for(;;)if(r<o){if(n.nodeType!=1)break;let a=n.childNodes[r];if(Pa(a,1))s=n,i=++r;else break}else{if(vw(n))break;{let a=n.nextSibling;for(;a&&Pa(a,1);)s=a.parentNode,i=Ut(a)+1,a=a.nextSibling;if(a)n=a,r=0,o=Yc(n);else{if(n=n.parentNode,n==t.dom)break;r=o=0}}}s&&sp(t,s,i)}function vw(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function wj(t,e){for(;t&&e==t.childNodes.length&&!_a(t);)e=Ut(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 Ej(t,e){for(;t&&!e&&!_a(t);)e=Ut(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 sp(t,e,n){if(e.nodeType!=3){let s,i;(i=wj(e,n))?(e=i,n=0):(s=Ej(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Gc(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&&ro(t)},50)}function bw(t,e){let n=t.state.doc.resolve(e);if(!(Jt||VL)&&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 xw(t,e,n){let r=t.state.selection;if(r instanceof pe&&!r.empty||n.indexOf("s")>-1||zn&&n.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let i=op(t.state,e);if(i&&i instanceof ue)return jo(t,i)}if(!o.parent.inlineContent){let i=e<0?o:s,a=r instanceof yn?Me.near(i,e):Me.findFrom(i,e);return a?jo(t,a):!1}return!1}function ww(t,e){if(!(t.state.selection instanceof pe))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 Ew(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Sj(t){if(!nn||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;Ew(t,r,"true"),setTimeout(()=>Ew(t,r,"false"),20)}return!1}function kj(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Cj(t,e){let n=e.keyCode,r=kj(e);if(n==8||zn&&n==72&&r=="c")return ww(t,-1)||vi(t,-1);if(n==46&&!e.shiftKey||zn&&n==68&&r=="c")return ww(t,1)||vi(t,1);if(n==13||n==27)return!0;if(n==37||zn&&n==66&&r=="c"){let o=n==37?bw(t,t.state.selection.from)=="ltr"?-1:1:-1;return yw(t,o,r)||vi(t,o)}else if(n==39||zn&&n==70&&r=="c"){let o=n==39?bw(t,t.state.selection.from)=="ltr"?1:-1:1;return yw(t,o,r)||vi(t,o)}else{if(n==38||zn&&n==80&&r=="c")return xw(t,-1,r)||vi(t,-1);if(n==40||zn&&n==78&&r=="c")return Sj(t)||xw(t,1,r)||vi(t,1);if(r==(zn?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function ip(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")||ws.fromSchema(t.state.schema),a=_w(),l=a.createElement("div");l.appendChild(i.serializeFragment(r,{document:a}));let c=l.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=Mw[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,`
55
-
56
- `);return{dom:l,text:f,slice:e}}function Sw(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 Q(F.from(t.state.schema.text(e.replace(/\r\n?/g,`
57
- `))),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=ws.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let y=i.appendChild(document.createElement("p"));m&&y.appendChild(p.serializeNode(h.text(m,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),i=Oj(n),Na&&_j(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")||Ea.fromSchema(t.state.schema)).parseSlice(i,{preserveWhitespace:!!(l||u),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Tj.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)a=Nj(Aw(a,+u[1],+u[2]),u[4]);else if(a=Q.maxOpen(Aj(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 Tj=/^(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 Aj(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&&Cw(l,s,a,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=Tw(i[i.length-1],s.length));let u=kw(a,l);i.push(u),o=o.matchType(u.type),s=l}}),i)return F.from(i)}return t}function kw(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,F.from(t));return t}function Cw(t,e,n,r,o){if(o<t.length&&o<e.length&&t[o]==e[o]){let s=Cw(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(F.from(kw(n,t,o+1))))}}function Tw(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Tw(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(F.empty,!0);return t.copy(n.append(r))}function ap(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=ap(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(F.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,i.copy(a))}function Aw(t,e,n){return e<t.openStart&&(t=new Q(ap(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Q(ap(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Mw={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 Ow=null;function _w(){return Ow||(Ow=document.implementation.createHTMLDocument("title"))}let lp=null;function Mj(t){let e=window.trustedTypes;return e?(lp||(lp=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),lp.createHTML(t)):t}function Oj(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=_w().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),o;if((o=r&&Mw[r[1].toLowerCase()])&&(t=o.map(s=>"<"+s+">").join("")+t+o.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=Mj(t),o)for(let s=0;s<o.length;s++)n=n.querySelector(o[s])||n;return n}function _j(t){let e=t.querySelectorAll(Jt?"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 Nj(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=F.from(l.create(r[a+1],o)),s++,i++}return new Q(o,s,i)}const rn={},on={},Rj={touchstart:!0,touchmove:!0};class Ij{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.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Dj(t){for(let e in rn){let n=rn[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Lj(t,r)&&!up(t,r)&&(t.editable||!(r.type in on))&&n(t,r)},Rj[e]?{passive:!0}:void 0)}nn&&t.dom.addEventListener("input",()=>null),cp(t)}function $o(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Pj(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 cp(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>up(t,r))})}function up(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Lj(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 jj(t,e){!up(t,e)&&rn[e.type]&&(t.editable||!(e.type in on))&&rn[e.type](t,e)}on.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Rw(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(to&&Jt&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),gi&&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,ks(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Cj(t,n)?n.preventDefault():$o(t,"key")},on.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)},on.keypress=(t,e)=>{let n=e;if(Rw(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||zn&&n.metaKey)return;if(t.someProp("handleKeyPress",o=>o(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof pe)||!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 Jc(t){return{left:t.clientX,top:t.clientY}}function $j(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function dp(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 bi(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 Bj(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&ue.isSelectable(r)?(bi(t,new ue(n)),!0):!1}function Fj(t,e){if(e==-1)return!1;let n=t.state.selection,r,o;n instanceof ue&&(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(ue.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?(bi(t,ue.create(t.state.doc,o)),!0):!1}function Hj(t,e,n,r,o){return dp(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(o?Fj(t,n):Bj(t,n))}function zj(t,e,n,r){return dp(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",o=>o(t,e,r))}function Uj(t,e,n,r){return dp(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",o=>o(t,e,r))||Vj(t,n,r)}function Vj(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(bi(t,pe.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)bi(t,pe.create(r,a+1,a+1+i.content.size));else if(ue.isSelectable(i))bi(t,ue.create(r,a));else continue;return!0}}function fp(t){return Xc(t)}const Nw=zn?"metaKey":"ctrlKey";rn.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=fp(t),o=Date.now(),s="singleClick";o-t.input.lastClick.time<500&&$j(n,t.input.lastClick)&&!n[Nw]&&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(Jc(n));i&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Wj(t,i,n,!!r)):(s=="doubleClick"?zj:Uj)(t,i.pos,i.inside,n)?n.preventDefault():$o(t,"pointer"))};class Wj{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[Nw],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 ue&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Hn&&!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)),$o(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(()=>ro(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(Jc(e))),this.updateAllowDefault(e),this.allowDefault||!n?$o(this.view,"pointer"):Hj(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||nn&&this.mightDrag&&!this.mightDrag.node.isAtom||Jt&&!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)?(bi(this.view,Me.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):$o(this.view,"pointer")}move(e){this.updateAllowDefault(e),$o(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)}}rn.touchstart=t=>{t.input.lastTouch=Date.now(),fp(t),$o(t,"pointer")},rn.touchmove=t=>{t.input.lastTouch=Date.now(),$o(t,"pointer")},rn.contextmenu=t=>fp(t);function Rw(t,e){return t.composing?!0:nn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Gj=to?5e3:-1;on.compositionstart=on.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof pe&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),Xc(t,!0),t.markCursor=null;else if(Xc(t,!e.selection.empty),Hn&&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}Iw(t,Gj)},on.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.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,Iw(t,20))};function Iw(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Xc(t),e))}function Dw(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Kj());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function qj(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=BL(e.focusNode,e.focusOffset),r=FL(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 Kj(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Xc(t,e=!1){if(!(to&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Dw(t),e||t.docView&&t.docView.dirty){let n=tp(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 Yj(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 La=vn&&Do<15||gi&&WL<604;rn.copy=on.cut=(t,e)=>{let n=e,r=t.state.selection,o=n.type=="cut";if(r.empty)return;let s=La?null:n.clipboardData,i=r.content(),{dom:a,text:l}=ip(t,i);s?(n.preventDefault(),s.clearData(),s.setData("text/html",a.innerHTML),s.setData("text/plain",l)):Yj(t,a),o&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Jj(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Xj(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?ja(t,r.value,null,o,e):ja(t,r.textContent,r.innerHTML,o,e)},50)}function ja(t,e,n,r,o){let s=Sw(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",l=>l(t,o,s||Q.empty)))return!0;if(!s)return!1;let i=Jj(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 Pw(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," "):""}on.paste=(t,e)=>{let n=e;if(t.composing&&!to)return;let r=La?null:n.clipboardData,o=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&ja(t,Pw(r),r.getData("text/html"),o,n)?n.preventDefault():Xj(t,n)};class Lw{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const Qj=zn?"altKey":"ctrlKey";function jw(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[Qj]}rn.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(Jc(n)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof ue?o.to-1:o.to))){if(r&&r.mightDrag)i=ue.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=ue.create(t.state.doc,d.posBefore))}}let a=(i||t.state.selection).content(),{dom:l,text:c,slice:u}=ip(t,a);(!n.dataTransfer.files.length||!Jt||Ux>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(La?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",La||n.dataTransfer.setData("text/plain",c),t.dragging=new Lw(u,jw(t,n),i)},rn.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)},on.dragover=on.dragenter=(t,e)=>e.preventDefault(),on.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let o=t.posAtCoords(Jc(n));if(!o)return;let s=t.state.doc.resolve(o.pos),i=r&&r.slice;i?t.someProp("transformPasted",p=>{i=p(i,t,!1)}):i=Sw(t,Pw(n.dataTransfer),La?null:n.dataTransfer.getData("text/html"),!1,s);let a=!!(r&&jw(t,n));if(t.someProp("handleDrop",p=>p(t,n,i||Q.empty,a))){n.preventDefault();return}if(!i)return;n.preventDefault();let l=i?fx(t.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let c=t.state.tr;if(a){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(l),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(f))return;let h=c.doc.resolve(u);if(d&&ue.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new ue(h));else{let p=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((m,y,v,w)=>p=w),c.setSelection(rp(t,h,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))},rn.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())&&ro(t)},20))},rn.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)},rn.beforeinput=(t,e)=>{if(Jt&&to&&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,ks(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 on)rn[t]=on[t];function $a(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 Qc{constructor(e,n){this.toDOM=e,this.spec=n||Ms,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 Vt(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Qc&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&$a(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Bo{constructor(e,n){this.attrs=e,this.spec=n||Ms}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 Vt(s,i,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Bo&&$a(this.attrs,e.attrs)&&$a(this.spec,e.spec)}static is(e){return e.type instanceof Bo}destroy(){}}class hp{constructor(e,n){this.attrs=e,this.spec=n||Ms}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 Vt(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 hp&&$a(this.attrs,e.attrs)&&$a(this.spec,e.spec)}destroy(){}}class Vt{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Vt(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 Vt(e,e,new Qc(n,r))}static inline(e,n,r,o){return new Vt(e,n,new Bo(r,o))}static node(e,n,r,o){return new Vt(e,n,new hp(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Bo}get widget(){return this.type instanceof Qc}}const xi=[],Ms={};class et{constructor(e,n){this.local=e.length?e:xi,this.children=n.length?n:xi}static create(e,n){return n.length?Zc(n,e,0,Ms):Xt}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==Xt||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Ms)}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?Zj(this.children,i||[],e,n,r,o,s):i?new et(i.sort(Os),xi):Xt}add(e,n){return n.length?this==Xt?et.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=Bw(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,Zc(u,a,c+1,Ms)),s+=3}});let i=$w(s?Fw(n):n,-r);for(let a=0;a<i.length;a++)i[a].type.valid(e,i[a])||i.splice(a--,1);return new et(i.length?this.local.concat(i).sort(Os):this.local,o||this.children)}remove(e){return e.length==0||this==Xt?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!=Xt?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 et(o,r):Xt}forChild(e,n){if(this==Xt)return this;if(n.isLeaf)return et.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 Bo){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 et(o.sort(Os),xi);return r?new Fo([a,r]):a}return r||Xt}eq(e){if(this==e)return!0;if(!(e instanceof et)||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 pp(this.localsInner(e))}localsInner(e){if(this==Xt)return xi;if(e.inlineContent||!this.local.some(Bo.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Bo||n.push(this.local[r]);return n}forEachSet(e){e(this)}}et.empty=new et([],[]),et.removeOverlap=pp;const Xt=et.empty;class Fo{constructor(e){this.members=e}map(e,n){const r=this.members.map(o=>o.map(e,n,Ms));return Fo.from(r)}forChild(e,n){if(n.isLeaf)return et.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,n);s!=Xt&&(s instanceof Fo?r=r.concat(s.members):r.push(s))}return Fo.from(r)}eq(e){if(!(e instanceof Fo)||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?pp(r?n:n.sort(Os)):xi}static from(e){switch(e.length){case 0:return Xt;case 1:return e[0];default:return new Fo(e.every(n=>n instanceof et)?e:e.reduce((n,r)=>n.concat(r instanceof et?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function Zj(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 y=m-p-(h-f);for(let v=0;v<a.length;v+=3){let w=a[v+1];if(w<0||f>w+u-d)continue;let E=a[v]+u-d;h>=E?a[v+1]=f<=E?-2:-1:f>=u&&y&&(a[v]+=y,a[v+1]+=y)}d+=y}),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),y=r.maybeChild(p);if(y&&m==d&&m+y.nodeSize==h){let v=a[c+2].mapInner(n,y,u+1,t[c]+s+1,i);v!=Xt?(a[c]=d,a[c+1]=h,a[c+2]=v):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=e2(a,t,e,n,o,s,i),u=Zc(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 et(e.sort(Os),a)}function $w(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 Vt(o.from+e,o.to+e,o.type))}return n}function e2(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 Bw(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 Fw(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Zc(t,e,n,r){let o=[],s=!1;e.forEach((a,l)=>{let c=Bw(t,a,l+n);if(c){s=!0;let u=Zc(c,a,n+l+1,r);u!=Xt&&o.push(l,l+a.nodeSize,u)}});let i=$w(s?Fw(t):t,-n).sort(Os);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 et(i,o):Xt}function Os(t,e){return t.from-e.from||t.to-e.to}function pp(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),Hw(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),Hw(e,o,r.copy(s.from,r.to)));break}}}return e}function Hw(t,e,n){for(;e<t.length&&Os(n,t[e])>0;)e++;t.splice(e,0,n)}function mp(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Xt&&e.push(r)}),t.cursorWrapper&&e.push(et.create(t.state.doc,[t.cursorWrapper.deco])),Fo.from(e)}const t2={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},n2=vn&&Do<=11;class r2{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 o2{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new r2,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]);vn&&Do<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),n2&&(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,t2)),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(mw(this.view)){if(this.suppressingSelectionUpdates)return ro(this.view);if(vn&&Do<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ss(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=mi(s))n.add(s);for(let s=e.anchorNode;s;s=mi(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)&&mw(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(Hn&&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||a2(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&&Gc(r)&&(c=tp(e))&&c.eq(Me.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ro(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||o)&&(s>-1&&(e.docView.markDirty(s,i),s2(e)),this.handleDOMChange(s,i,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ro(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(vn&&Do<=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?Ut(o)+1:0,a=r.localPosFromDOM(e.target,i,-1),l=s&&s.parentNode==e.target?Ut(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 zw=new WeakMap,Uw=!1;function s2(t){if(!zw.has(t)&&(zw.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Hn,Uw)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Uw=!0}}function Vw(t,e){let n=e.startContainer,r=e.startOffset,o=e.endContainer,s=e.endOffset,i=t.domAtPos(t.state.selection.anchor);return Ss(i.node,i.offset,o,s)&&([n,r,o,s]=[o,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:s}}function i2(t,e){if(e.getComposedRanges){let o=e.getComposedRanges(t.root)[0];if(o)return Vw(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?Vw(t,n):null}function a2(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 l2(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}],Gc(l)||c.push({node:l.focusNode,offset:l.focusOffset})),Jt&&t.input.lastKeyCode===8)for(let y=s;y>o;y--){let v=r.childNodes[y-1],w=v.pmViewDesc;if(v.nodeName=="BR"&&!w){s=y;break}if(!w||w.size)break}let d=t.state.doc,f=t.someProp("domParser")||Ea.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:c2,context:h});if(c&&c[0].pos!=null){let y=c[0].pos,v=c[1]&&c[1].pos;v==null&&(v=y),p={anchor:y+i,head:v+i}}return{doc:m,sel:p,from:i,to:a}}function c2(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(nn&&/^(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||nn&&/^(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 u2=/^(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 d2(t,e,n,r,o){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let C=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,T=tp(t,C);if(T&&!t.state.selection.eq(T)){if(Jt&&to&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",_=>_(t,ks(13,"Enter"))))return;let N=t.state.tr.setSelection(T);C=="pointer"?N.setMeta("pointer",!0):C=="key"&&N.scrollIntoView(),s&&N.setMeta("composition",s),t.dispatch(N)}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=l2(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=p2(d.content,c.doc.content,c.from,f,h);if(p&&t.input.domChangeCount++,(gi&&t.input.lastIOSEnter>Date.now()-225||to)&&o.some(C=>C.nodeType==1&&!u2.test(C.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",C=>C(t,ks(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&l instanceof pe&&!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 C=Ww(t,t.state.doc,c.sel);if(C&&!C.eq(t.state.selection)){let T=t.state.tr.setSelection(C);s&&T.setMeta("composition",s),t.dispatch(T)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof pe&&(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)),vn&&Do<=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),y=c.doc.resolveNoCache(p.endB-c.from),v=u.resolve(p.start),w=m.sameParent(y)&&m.parent.inlineContent&&v.end()>=p.endA;if((gi&&t.input.lastIOSEnter>Date.now()-225&&(!w||o.some(C=>C.nodeName=="DIV"||C.nodeName=="P"))||!w&&m.pos<c.doc.content.size&&(!m.sameParent(y)||!m.parent.inlineContent)&&m.pos<y.pos&&!/\S/.test(c.doc.textBetween(m.pos,y.pos,"","")))&&t.someProp("handleKeyDown",C=>C(t,ks(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&h2(u,p.start,p.endA,m,y)&&t.someProp("handleKeyDown",C=>C(t,ks(8,"Backspace")))){to&&Jt&&t.domObserver.suppressSelectionUpdates();return}Jt&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),to&&!w&&m.start()!=y.start()&&y.parentOffset==0&&m.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(C){return C(t,ks(13,"Enter"))})},20));let E=p.start,x=p.endA,k=C=>{let T=C||t.state.tr.replace(E,x,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let N=Ww(t,T.doc,c.sel);N&&!(Jt&&t.composing&&N.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(N.head==E||N.head==T.mapping.map(x)-1)||vn&&N.empty&&N.head==E)&&T.setSelection(N)}return s&&T.setMeta("composition",s),T.scrollIntoView()},S;if(w)if(m.pos==y.pos){vn&&Do<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>ro(t),20));let C=k(t.state.tr.delete(E,x)),T=u.resolve(p.start).marksAcross(u.resolve(p.endA));T&&C.ensureMarks(T),t.dispatch(C)}else if(p.endA==p.endB&&(S=f2(m.parent.content.cut(m.parentOffset,y.parentOffset),v.parent.content.cut(v.parentOffset,p.endA-v.start())))){let C=k(t.state.tr);S.type=="add"?C.addMark(E,x,S.mark):C.removeMark(E,x,S.mark),t.dispatch(C)}else if(m.parent.child(m.index()).isText&&m.index()==y.index()-(y.textOffset?0:1)){let C=m.parent.textBetween(m.parentOffset,y.parentOffset),T=()=>k(t.state.tr.insertText(C,E,x));t.someProp("handleTextInput",N=>N(t,E,x,C,T))||t.dispatch(T())}else t.dispatch(k());else t.dispatch(k())}function Ww(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:rp(t,e.resolve(n.anchor),e.resolve(n.head))}function f2(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(F.from(c).eq(t))return{mark:a,type:i}}function h2(t,e,n,r,o){if(n-e<=o.pos-r.pos||gp(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(gp(s,!0,!0));return!i.parent.isTextblock||i.pos>n||gp(i,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function gp(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 p2(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&&Gw(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&&Gw(t.textBetween(s-1,s+1))&&(s+=l?1:-1),i=s+(i-a),a=s}return{start:s,endA:i,endB:a}}function Gw(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 qw{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 Ij,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Qw),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),Yw(this),this.nodeViews=Xw(this),this.docView=rw(this.state.doc,Kw(this),mp(this),this.dom,this),this.domObserver=new o2(this,(r,o,s,i)=>d2(this,r,o,s,i)),this.domObserver.start(),Dj(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&&cp(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Qw),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&&(Dw(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=Xw(this);g2(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(a||n.handleDOMEvents!=this._props.handleDOMEvents)&&cp(this),this.editable=Jw(this),Yw(this);let l=mp(this),c=Kw(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&&KL(this);if(i){this.domObserver.stop();let h=d&&(vn||Jt)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&m2(o.selection,e.selection);if(d){let p=Jt?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=qj(this)),(s||!this.docView.update(e.doc,c,l,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=rw(e.doc,c,l,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&vj(this))?ro(this,h):(hw(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&&YL(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 ue){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Vx(this,n.getBoundingClientRect(),e)}else Vx(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(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&&this.state.doc.nodeAt(s))==r.node&&(o=s)}this.dragging=new Lw(e.slice,e.move,o<0?void 0:ue.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(vn){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&&JL(this.dom),ro(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 tj(this,e)}coordsAtPos(e,n=1){return Jx(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 ij(this,n||this.state,e)}pasteHTML(e,n){return ja(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return ja(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return ip(this,e)}destroy(){this.docView&&(Pj(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],mp(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,jL())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return jj(this,e)}domSelectionRange(){let e=this.domSelection();return e?nn&&this.root.nodeType===11&&zL(this.dom.ownerDocument)==this.dom&&i2(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}qw.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Kw(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"),[Vt.node(0,t.state.doc.content.size,e)]}function Yw(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:Vt.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 m2(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 Xw(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 g2(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 Qw(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")}for(var Ho={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:"'"},eu={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},y2=typeof navigator<"u"&&/Mac/.test(navigator.platform),v2=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Wt=0;Wt<10;Wt++)Ho[48+Wt]=Ho[96+Wt]=String(Wt);for(var Wt=1;Wt<=24;Wt++)Ho[Wt+111]="F"+Wt;for(var Wt=65;Wt<=90;Wt++)Ho[Wt]=String.fromCharCode(Wt+32),eu[Wt]=String.fromCharCode(Wt);for(var yp in Ho)eu.hasOwnProperty(yp)||(eu[yp]=Ho[yp]);function b2(t){var e=y2&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||v2&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?eu:Ho)[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 x2=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),w2=typeof navigator<"u"&&/Win/.test(navigator.platform);function E2(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))x2?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 S2(t){let e=Object.create(null);for(let n in t)e[E2(n)]=t[n];return e}function vp(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 k2(t){return new He({props:{handleKeyDown:Zw(t)}})}function Zw(t){let e=S2(t);return function(n,r){let o=b2(r),s,i=e[vp(o,r)];if(i&&i(n.state,n.dispatch,n))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let a=e[vp(o,r,!1)];if(a&&a(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(w2&&r.ctrlKey&&r.altKey)&&(s=Ho[r.keyCode])&&s!=o){let a=e[vp(s,r)];if(a&&a(n.state,n.dispatch,n))return!0}}return!1}}var C2=Object.defineProperty,bp=(t,e)=>{for(var n in e)C2(t,n,{get:e[n],enumerable:!0})};function tu(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 nu=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),y=f(...p)(m);return i.push(y),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:tu({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}},eE={};bp(eE,{blur:()=>T2,clearContent:()=>A2,clearNodes:()=>M2,command:()=>O2,createParagraphNear:()=>_2,cut:()=>N2,deleteCurrentNode:()=>R2,deleteNode:()=>I2,deleteRange:()=>D2,deleteSelection:()=>P2,enter:()=>L2,exitCode:()=>j2,extendMarkRange:()=>$2,first:()=>B2,focus:()=>F2,forEach:()=>H2,insertContent:()=>z2,insertContentAt:()=>W2,joinBackward:()=>K2,joinDown:()=>q2,joinForward:()=>Y2,joinItemBackward:()=>J2,joinItemForward:()=>X2,joinTextblockBackward:()=>Q2,joinTextblockForward:()=>Z2,joinUp:()=>G2,keyboardShortcut:()=>t$,lift:()=>n$,liftEmptyBlock:()=>r$,liftListItem:()=>o$,newlineInCode:()=>s$,resetAttributes:()=>i$,scrollIntoView:()=>a$,selectAll:()=>l$,selectNodeBackward:()=>c$,selectNodeForward:()=>u$,selectParentNode:()=>d$,selectTextblockEnd:()=>f$,selectTextblockStart:()=>h$,setContent:()=>p$,setMark:()=>R$,setMeta:()=>I$,setNode:()=>D$,setNodeSelection:()=>P$,setTextSelection:()=>L$,sinkListItem:()=>j$,splitBlock:()=>$$,splitListItem:()=>B$,toggleList:()=>F$,toggleMark:()=>H$,toggleNode:()=>z$,toggleWrap:()=>U$,undoInputRule:()=>V$,unsetAllMarks:()=>W$,unsetMark:()=>G$,updateAttributes:()=>q$,wrapIn:()=>K$,wrapInList:()=>Y$});var T2=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),A2=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),M2=()=>({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=ci(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},O2=t=>e=>t(e),_2=()=>({state:t,dispatch:e})=>Px(t,e),N2=(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 pe(r.doc.resolve(Math.max(i-1,0)))),!0},R2=()=>({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 St(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 I2=t=>({tr:e,state:n,dispatch:r})=>{const o=St(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},D2=t=>({tr:e,dispatch:n})=>{const{from:r,to:o}=t;return n&&e.delete(r,o),!0},P2=()=>({state:t,dispatch:e})=>zh(t,e),L2=()=>({commands:t})=>t.keyboardShortcut("Enter"),j2=()=>({state:t,dispatch:e})=>EL(t,e);function xp(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function ru(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(o=>n.strict?e[o]===t[o]:xp(e[o])?e[o].test(t[o]):e[o]===t[o]):!0}function tE(t,e,n={}){return t.find(r=>r.type===e&&ru(Object.fromEntries(Object.keys(n).map(o=>[o,r.attrs[o]])),n))}function nE(t,e,n={}){return!!tE(t,e,n)}function wp(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),!tE([...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&&nE([...t.parent.child(i-1).marks],e,n);)i-=1,a-=t.parent.child(i).nodeSize;for(;l<t.parent.childCount&&nE([...t.parent.child(l).marks],e,n);)c+=t.parent.child(l).nodeSize,l+=1;return{from:a,to:c}}function oo(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 $2=(t,e={})=>({tr:n,state:r,dispatch:o})=>{const s=oo(t,r.schema),{doc:i,selection:a}=n,{$from:l,from:c,to:u}=a;if(o){const d=wp(l,s,e);if(d&&d.from<=c&&d.to>=u){const f=pe.create(i,d.from,d.to);n.setSelection(f)}}return!0},B2=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 rE(t){return t instanceof pe}function _s(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function oE(t,e=null){if(!e)return null;const n=Me.atStart(t),r=Me.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const o=n.from,s=r.to;return e==="all"?pe.create(t,_s(0,o,s),_s(t.content.size,o,s)):pe.create(t,_s(e,o,s),_s(e,o,s))}function Ep(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Ba(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var F2=(t=null,e={})=>({editor:n,view:r,tr:o,dispatch:s})=>{e={scrollIntoView:!0,...e};const i=()=>{(Ba()||Ep())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(s&&t===null&&!rE(n.state.selection))return i(),!0;const a=oE(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},H2=(t,e)=>n=>t.every((r,o)=>e(r,{...n,index:o})),z2=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),sE=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&&sE(r)}return t};function ou(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 sE(n)}function Fa(t,e,n){if(t instanceof Qr||t instanceof F)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 F.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 console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",s),Fa("",e,n)}if(o){if(n.errorOnInvalidContent){let i=!1,a="";const l=new G0({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?Ea.fromSchema(l).parseSlice(ou(t),n.parseOptions):Ea.fromSchema(l).parse(ou(t),n.parseOptions),n.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${a}`)})}const s=Ea.fromSchema(e);return n.slice?s.parseSlice(ou(t),n.parseOptions).content:s.parse(ou(t),n.parseOptions)}return Fa("",e,n)}function U2(t,e,n){const r=t.steps.length-1;if(r<e)return;const o=t.steps[r];if(!(o instanceof Dt||o instanceof Pt))return;const s=t.mapping.maps[r];let i=0;s.forEach((a,l,c,u)=>{i===0&&(i=u)}),t.setSelection(Me.near(t.doc.resolve(i),n))}var V2=t=>!("type"in t),W2=(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=y=>{s.emit("contentError",{editor:s,error:y,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{Fa(e,s.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(y){l(y)}try{a=Fa(e,s.schema,{parseOptions:c,errorOnInvalidContent:(i=n.errorOnInvalidContent)!=null?i:s.options.enableContentCheck})}catch(y){return l(y),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},f=!0,h=!0;if((V2(a)?a:[a]).forEach(y=>{y.check(),f=f?y.isText&&y.marks.length===0:!1,h=h?y.isBlock:!1}),u===d&&h){const{parent:y}=r.doc.resolve(u);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(u-=1,d+=1)}let m;if(f){if(Array.isArray(e))m=e.map(y=>y.text||"").join("");else if(e instanceof F){let y="";e.forEach(v=>{v.text&&(y+=v.text)}),m=y}else typeof e=="object"&&e&&e.text?m=e.text:m=e;r.insertText(m,u,d)}else{m=a;const y=r.doc.resolve(u),v=y.node(),w=y.parentOffset===0,E=v.isText||v.isTextblock,x=v.content.size>0;w&&E&&x&&(u=Math.max(0,u-1)),r.replaceWith(u,d,m)}n.updateSelection&&U2(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},G2=()=>({state:t,dispatch:e})=>bL(t,e),q2=()=>({state:t,dispatch:e})=>xL(t,e),K2=()=>({state:t,dispatch:e})=>Mx(t,e),Y2=()=>({state:t,dispatch:e})=>Rx(t,e),J2=()=>({state:t,dispatch:e,tr:n})=>{try{const r=zc(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},X2=()=>({state:t,dispatch:e,tr:n})=>{try{const r=zc(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Q2=()=>({state:t,dispatch:e})=>yL(t,e),Z2=()=>({state:t,dispatch:e})=>vL(t,e);function iE(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function e$(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))Ba()||iE()?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 t$=t=>({editor:e,view:n,tr:r,dispatch:o})=>{const s=e$(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 zo(t,e,n={}){const{from:r,to:o,empty:s}=t.selection,i=e?St(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=>ru(d.node.attrs,n,{strict:!1}));return s?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=l}var n$=(t,e={})=>({state:n,dispatch:r})=>{const o=St(t,n.schema);return zo(n,o,e)?wL(n,r):!1},r$=()=>({state:t,dispatch:e})=>Lx(t,e),o$=t=>({state:e,dispatch:n})=>{const r=St(t,e.schema);return IL(r)(e,n)},s$=()=>({state:t,dispatch:e})=>Dx(t,e);function su(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function aE(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 i$=(t,e)=>({tr:n,state:r,dispatch:o})=>{let s=null,i=null;const a=su(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(s=St(t,r.schema)),a==="mark"&&(i=oo(t,r.schema)),o&&n.selection.ranges.forEach(l=>{r.doc.nodesBetween(l.$from.pos,l.$to.pos,(c,u)=>{s&&s===c.type&&n.setNodeMarkup(u,void 0,aE(c.attrs,e)),i&&c.marks.length&&c.marks.forEach(d=>{i===d.type&&n.addMark(u,u+c.nodeSize,i.create(aE(d.attrs,e)))})})}),!0):!1},a$=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),l$=()=>({tr:t,dispatch:e})=>{if(e){const n=new yn(t.doc);t.setSelection(n)}return!0},c$=()=>({state:t,dispatch:e})=>_x(t,e),u$=()=>({state:t,dispatch:e})=>Ix(t,e),d$=()=>({state:t,dispatch:e})=>CL(t,e),f$=()=>({state:t,dispatch:e})=>ML(t,e),h$=()=>({state:t,dispatch:e})=>AL(t,e);function Sp(t,e,n={},r={}){return Fa(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var p$=(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=Sp(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 lE(t,e){const n=oo(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 cE(t,e){const n=new yx(t);return e.forEach(r=>{r.steps.forEach(o=>{n.step(o)})}),n}function m$(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 g$(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(o,s)=>{n(o)&&r.push({node:o,pos:s})}),r}function y$(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 iu(t){return e=>y$(e.$from,t)}function de(t,e,n){return t.config[e]===void 0&&t.parent?de(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?de(t.parent,e,n):null}):t.config[e]}function kp(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=de(e,"addExtensions",n);return r?[e,...kp(r())]:e}).flat(10)}function Cp(t,e){const n=ws.fromSchema(e).serializeFragment(t),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(n),o.innerHTML}function uE(t){return typeof t=="function"}function Ge(t,e=void 0,...n){return uE(t)?e?t.bind(e)(...n):t(...n):t}function v$(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Ha(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 dE(t){const e=[],{nodeExtensions:n,markExtensions:r}=Ha(t),o=[...n,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(i=>{const a={name:i.name,options:i.options,storage:i.storage,extensions:o},l=de(i,"addGlobalAttributes",a);if(!l)return;l().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([f,h])=>{e.push({type:d,name:f,attribute:{...s,...h}})})})})}),o.forEach(i=>{const a={name:i.name,options:i.options,storage:i.storage},l=de(i,"addAttributes",a);if(!l)return;const c=l();Object.entries(c).forEach(([u,d])=>{const f={...s,...d};typeof f?.default=="function"&&(f.default=f.default()),f?.isRequired&&f?.default===void 0&&delete f.default,e.push({type:i.name,name:u,attribute:f})})}),e}function Be(...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=s?s.split(";").map(u=>u.trim()).filter(Boolean):[],l=r[o]?r[o].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;l.forEach(u=>{const[d,f]=u.split(":").map(h=>h.trim());c.set(d,f)}),a.forEach(u=>{const[d,f]=u.split(":").map(h=>h.trim());c.set(d,f)}),r[o]=Array.from(c.entries()).map(([u,d])=>`${u}: ${d}`).join("; ")}else r[o]=s}),r},{})}function za(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)=>Be(n,r),{})}function b$(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function fE(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):b$(n.getAttribute(i.name));return a==null?s:{...s,[i.name]:a}},{});return{...r,...o}}}}function hE(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&v$(n)?!1:n!=null))}function x$(t,e){var n;const r=dE(t),{nodeExtensions:o,markExtensions:s}=Ha(t),i=(n=o.find(c=>de(c,"topNode")))==null?void 0:n.name,a=Object.fromEntries(o.map(c=>{const u=r.filter(v=>v.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((v,w)=>{const E=de(w,"extendNodeSchema",d);return{...v,...E?E(c):{}}},{}),h=hE({...f,content:Ge(de(c,"content",d)),marks:Ge(de(c,"marks",d)),group:Ge(de(c,"group",d)),inline:Ge(de(c,"inline",d)),atom:Ge(de(c,"atom",d)),selectable:Ge(de(c,"selectable",d)),draggable:Ge(de(c,"draggable",d)),code:Ge(de(c,"code",d)),whitespace:Ge(de(c,"whitespace",d)),linebreakReplacement:Ge(de(c,"linebreakReplacement",d)),defining:Ge(de(c,"defining",d)),isolating:Ge(de(c,"isolating",d)),attrs:Object.fromEntries(u.map(v=>{var w,E;return[v.name,{default:(w=v?.attribute)==null?void 0:w.default,validate:(E=v?.attribute)==null?void 0:E.validate}]}))}),p=Ge(de(c,"parseHTML",d));p&&(h.parseDOM=p.map(v=>fE(v,u)));const m=de(c,"renderHTML",d);m&&(h.toDOM=v=>m({node:v,HTMLAttributes:za(v,u)}));const y=de(c,"renderText",d);return y&&(h.toText=y),[c.name,h]})),l=Object.fromEntries(s.map(c=>{const u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((y,v)=>{const w=de(v,"extendMarkSchema",d);return{...y,...w?w(c):{}}},{}),h=hE({...f,inclusive:Ge(de(c,"inclusive",d)),excludes:Ge(de(c,"excludes",d)),group:Ge(de(c,"group",d)),spanning:Ge(de(c,"spanning",d)),code:Ge(de(c,"code",d)),attrs:Object.fromEntries(u.map(y=>{var v,w;return[y.name,{default:(v=y?.attribute)==null?void 0:v.default,validate:(w=y?.attribute)==null?void 0:w.validate}]}))}),p=Ge(de(c,"parseHTML",d));p&&(h.parseDOM=p.map(y=>fE(y,u)));const m=de(c,"renderHTML",d);return m&&(h.toDOM=y=>m({mark:y,HTMLAttributes:za(y,u)})),[c.name,h]}));return new G0({topNode:i,nodes:a,marks:l})}function w$(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Tp(t){return t.sort((n,r)=>{const o=de(n,"priority")||100,s=de(r,"priority")||100;return o>s?-1:o<s?1:0})}function pE(t){const e=Tp(kp(t)),n=w$(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function mE(t,e,n){const{from:r,to:o}=e,{blockSeparator:s=`
58
-
59
- `,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 E$(t,e){const n={from:0,to:t.content.size};return mE(t,n,e)}function gE(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function S$(t,e){const n=St(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 yE(t,e){const n=su(typeof e=="string"?e:e.name,t.schema);return n==="node"?S$(t,e):n==="mark"?lE(t,e):{}}function k$(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 C$(t){const e=k$(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 vE(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}})})}),C$(r)}function Ap(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(o=>{const s=n.resolve(t),i=wp(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 T$=(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 Mp(t,e){return e.nodes[t]||e.marks[t]||null}function au(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 A$=(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 Op(t,e,n={}){const{empty:r,ranges:o}=t.selection,s=e?oo(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>ru(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,y)=>{if(!m.isText&&!m.marks.length)return;const v=Math.max(h,y),w=Math.min(p,y+m.nodeSize),E=w-v;i+=E,a.push(...m.marks.map(x=>({mark:x,from:v,to:w})))})}),i===0)return!1;const l=a.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>ru(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 M$(t,e,n={}){if(!e)return zo(t,null,n)||Op(t,null,n);const r=su(e,t.schema);return r==="node"?zo(t,e,n):r==="mark"?Op(t,e,n):!1}var O$=(t,e)=>{const{$from:n,$to:r,$anchor:o}=t.selection;if(e){const s=iu(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)},_$=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function bE(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function xE(t,e){const{nodeExtensions:n}=Ha(e),r=n.find(i=>i.name===t);if(!r)return!1;const o={name:r.name,options:r.options,storage:r.storage},s=Ge(de(r,"group",o));return typeof s!="string"?!1:s.split(" ").includes("list")}function lu(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.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&&(lu(s,{ignoreWhitespace:n,checkChildren:e})||(o=!1))}),o}return!1}function wE(t){return t instanceof ue}function N$(t,e,n){var r;const{selection:o}=e;let s=null;if(rE(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 R$=(t,e={})=>({tr:n,state:r,dispatch:o})=>{const{selection:s}=n,{empty:i,ranges:a}=s,l=oo(t,r.schema);if(o)if(i){const c=lE(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(v=>v.type===l)?f.marks.forEach(v=>{l===v.type&&n.addMark(p,m,l.create({...v.attrs,...e}))}):n.addMark(p,m,l.create(e))})});return N$(r,n,l)},I$=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),D$=(t,e={})=>({state:n,dispatch:r,chain:o})=>{const s=St(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})=>Bx(s,{...i,...e})(n)?!0:a.clearNodes()).command(({state:a})=>Bx(s,{...i,...e})(a,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},P$=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,o=_s(t,0,r.content.size),s=ue.create(r,o);e.setSelection(s)}return!0},L$=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:o,to:s}=typeof t=="number"?{from:t,to:t}:t,i=pe.atStart(r).from,a=pe.atEnd(r).to,l=_s(o,i,a),c=_s(s,i,a),u=pe.create(r,l,c);e.setSelection(u)}return!0},j$=t=>({state:e,dispatch:n})=>{const r=St(t,e.schema);return LL(r)(e,n)};function EE(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 $$=({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=au(c,a.node().type.name,a.node().attrs);if(s instanceof ue&&s.node.isBlock)return!a.parentOffset||!Zr(i,a.pos)?!1:(r&&(t&&EE(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:m$(a.node(-1).contentMatchAt(a.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,p=Zr(e.doc,e.mapping.map(a.pos),1,h);if(!h&&!p&&Zr(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 pe&&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()),y=e.doc.resolve(m);a.node(-1).canReplaceWith(y.index(),y.index()+1,f)&&e.setNodeMarkup(e.mapping.map(a.before()),f)}t&&EE(n,o.extensionManager.splittableMarks),e.scrollIntoView()}return p},B$=(t,e={})=>({tr:n,state:r,dispatch:o,editor:s})=>{var i;const a=St(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 v=F.empty;const w=l.index(-1)?1:l.index(-2)?2:3;for(let T=l.depth-w;T>=l.depth-3;T-=1)v=F.from(l.node(T).copy(v));const E=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,x={...au(f,l.node().type.name,l.node().attrs),...e},k=((i=a.contentMatch.defaultType)==null?void 0:i.createAndFill(x))||void 0;v=v.append(F.from(a.createAndFill(null,k)||void 0));const S=l.before(l.depth-(w-1));n.replace(S,l.after(-E),new Q(v,4-w,0));let C=-1;n.doc.nodesBetween(S,n.doc.content.size,(T,N)=>{if(C>-1)return!1;T.isTextblock&&T.content.size===0&&(C=N+1)}),C>-1&&n.setSelection(pe.near(n.doc.resolve(C))),n.scrollIntoView()}return!0}const h=c.pos===l.end()?d.contentMatchAt(0).defaultType:null,p={...au(f,d.type.name,d.attrs),...e},m={...au(f,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);const y=h?[{type:a,attrs:p},{type:h,attrs:m}]:[{type:a,attrs:p}];if(!Zr(n.doc,l.pos,2))return!1;if(o){const{selection:v,storedMarks:w}=r,{splittableMarks:E}=s.extensionManager,x=w||v.$to.parentOffset&&v.$from.marks();if(n.split(l.pos,2,y).scrollIntoView(),!x||!o)return!0;const k=x.filter(S=>E.includes(S.type.name));n.ensureMarks(k)}return!0},_p=(t,e)=>{const n=iu(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&&Ro(t.doc,n.pos)&&t.join(n.pos),!0},Np=(t,e)=>{const n=iu(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&&Ro(t.doc,r)&&t.join(r),!0},F$=(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=St(t,i.schema),p=St(e,i.schema),{selection:m,storedMarks:y}=i,{$from:v,$to:w}=m,E=v.blockRange(w),x=y||m.$to.parentOffset&&m.$from.marks();if(!E)return!1;const k=iu(S=>xE(S.type.name,d))(m);if(E.depth>=1&&k&&E.depth-k.depth<=1){if(k.node.type===h)return c.liftListItem(p);if(xE(k.node.type.name,d)&&h.validContent(k.node.content)&&a)return l().command(()=>(s.setNodeMarkup(k.pos,h),!0)).command(()=>_p(s,h)).command(()=>Np(s,h)).run()}return!n||!x||!a?l().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>_p(s,h)).command(()=>Np(s,h)).run():l().command(()=>{const S=u().wrapInList(h,r),C=x.filter(T=>f.includes(T.type.name));return s.ensureMarks(C),S?!0:c.clearNodes()}).wrapInList(h,r).command(()=>_p(s,h)).command(()=>Np(s,h)).run()},H$=(t,e={},n={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:s=!1}=n,i=oo(t,r.schema);return Op(r,i,e)?o.unsetMark(i,{extendEmptyMarkRange:s}):o.setMark(i,e)},z$=(t,e,n={})=>({state:r,commands:o})=>{const s=St(t,r.schema),i=St(e,r.schema),a=zo(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})},U$=(t,e={})=>({state:n,commands:r})=>{const o=St(t,n.schema);return zo(n,o,e)?r.lift(o):r.wrapIn(o,e)},V$=()=>({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},W$=()=>({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},G$=(t,e={})=>({tr:n,state:r,dispatch:o})=>{var s;const{extendEmptyMarkRange:i=!1}=e,{selection:a}=n,l=oo(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(y=>y.type===l))==null?void 0:s.attrs,m=wp(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},q$=(t,e={})=>({tr:n,state:r,dispatch:o})=>{let s=null,i=null;const a=su(typeof t=="string"?t:t.name,r.schema);return a?(a==="node"&&(s=St(t,r.schema)),a==="mark"&&(i=oo(t,r.schema)),o&&n.selection.ranges.forEach(l=>{const c=l.$from.pos,u=l.$to.pos;let d,f,h,p;n.selection.empty?r.doc.nodesBetween(c,u,(m,y)=>{s&&s===m.type&&(h=Math.max(y,c),p=Math.min(y+m.nodeSize,u),d=y,f=m)}):r.doc.nodesBetween(c,u,(m,y)=>{y<c&&s&&s===m.type&&(h=Math.max(y,c),p=Math.min(y+m.nodeSize,u),d=y,f=m),y>=c&&y<=u&&(s&&s===m.type&&n.setNodeMarkup(y,void 0,{...m.attrs,...e}),i&&m.marks.length&&m.marks.forEach(v=>{if(i===v.type){const w=Math.max(y,c),E=Math.min(y+m.nodeSize,u);n.addMark(w,E,i.create({...v.attrs,...e}))}}))}),f&&(d!==void 0&&n.setNodeMarkup(d,void 0,{...f.attrs,...e}),i&&f.marks.length&&f.marks.forEach(m=>{i===m.type&&n.addMark(h,p,i.create({...m.attrs,...e}))}))}),!0):!1},K$=(t,e={})=>({state:n,dispatch:r})=>{const o=St(t,n.schema);return OL(o,e)(n,r)},Y$=(t,e={})=>({state:n,dispatch:r})=>{const o=St(t,n.schema);return _L(o,e)(n,r)},J$=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={}}},cu=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},X$=(t,e)=>{if(xp(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function uu(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=A$(c)+s;return i.forEach(f=>{if(u)return;const h=X$(d,f.find);if(!h)return;const p=l.state.tr,m=tu({state:l.state,transaction:p}),y={from:r-(h[0].length-s.length),to:o},{commands:v,chain:w,can:E}=new nu({editor:n,state:m});f.handler({state:m,range:y,match:h,commands:v,chain:w,can:E})===null||!p.steps.length||(f.undoable&&p.setMeta(a,{transform:p,from:r,to:o,text:s}),l.dispatch(p),u=!0)}),u}function Q$(t){const{editor:e,rules:n}=t,r=new He({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=Cp(F.from(u),i.schema);const{from:d}=l,f=d+u.length;uu({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 uu({editor:e,from:s,to:i,text:a,rules:n,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{const{$cursor:s}=o.state.selection;s&&uu({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?uu({editor:e,from:i.pos,to:i.pos,text:`
60
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function Z$(t){return Object.prototype.toString.call(t).slice(8,-1)}function du(t){return Z$(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function SE(t,e){const n={...t};return du(t)&&du(e)&&Object.keys(e).forEach(r=>{du(e[r])&&du(t[r])?n[r]=SE(t[r],e[r]):n[r]=e[r]}),n}var Rp=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{...Ge(de(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...Ge(de(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>SE(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}},so=class kN extends Rp{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new kN(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 eB(t){return typeof t=="number"}var tB=class{constructor(t){this.find=t.find,this.handler=t.handler}},nB=(t,e,n)=>{if(xp(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)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(o.replaceWith)),s}):[]};function rB(t){const{editor:e,state:n,from:r,to:o,rule:s,pasteEvent:i,dropEvent:a}=t,{commands:l,chain:c,can:u}=new nu({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,o,(h,p)=>{var m,y,v,w,E;if((y=(m=h.type)==null?void 0:m.spec)!=null&&y.code||!(h.isText||h.isTextblock||h.isInline))return;const x=(E=(w=(v=h.content)==null?void 0:v.size)!=null?w:h.nodeSize)!=null?E:0,k=Math.max(r,p),S=Math.min(o,p+x);if(k>=S)return;const C=h.isText?h.text||"":h.textBetween(k-p,S-p,void 0,"");nB(C,s.find,i).forEach(N=>{if(N.index===void 0)return;const _=k+N.index+1,L=_+N[0].length,$={from:n.tr.mapping.map(_),to:n.tr.mapping.map(L)},B=s.handler({state:n,range:$,match:N,commands:l,chain:c,can:u,pasteEvent:i,dropEvent:a});d.push(B)})}),d.every(h=>h!==null)}var fu=null,oB=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function sB(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,y=tu({state:u,transaction:m});if(!(!rB({editor:e,state:y,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 He({view(d){const f=p=>{var m;r=(m=d.dom.parentElement)!=null&&m.contains(p.target)?d.dom.parentElement:null,r&&(fu=e)},h=()=>{fu&&(fu=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=fu;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,y=p.getMeta("uiEvent")==="drop"&&!s,v=p.getMeta("applyPasteRules"),w=!!v;if(!m&&!y&&!w)return;if(w){let{text:k}=v;typeof k=="string"?k=k:k=Cp(F.from(k),h.schema);const{from:S}=v,C=S+k.length,T=oB(k);return l({rule:u,state:h,from:S,to:{b:C},pasteEvt:T})}const E=f.doc.content.findDiffStart(h.doc.content),x=f.doc.content.findDiffEnd(h.doc.content);if(!(!eB(E)||!x||E===x.b))return l({rule:u,state:h,from:E,to:x,pasteEvt:i})}}))}var hu=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=pE(t),this.schema=x$(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:Mp(e.name,this.schema)},r=de(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Tp([...this.extensions].reverse()).flatMap(r=>{const o={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:Mp(r.name,this.schema)},s=[],i=de(r,"addKeyboardShortcuts",o);let a={};if(r.type==="mark"&&de(r,"exitable",o)&&(a.ArrowRight=()=>so.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=k2(a);s.push(l);const c=de(r,"addInputRules",o);if(bE(r,t.options.enableInputRules)&&c){const f=c();if(f&&f.length){const h=Q$({editor:t,rules:f}),p=Array.isArray(h)?h:[h];s.push(...p)}}const u=de(r,"addPasteRules",o);if(bE(r,t.options.enablePasteRules)&&u){const f=u();if(f&&f.length){const h=sB({editor:t,rules:f});s.push(...h)}}const d=de(r,"addProseMirrorPlugins",o);if(d){const f=d();s.push(...f)}return s})}get attributes(){return dE(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Ha(this.extensions);return Object.fromEntries(e.filter(n=>!!de(n,"addNodeView")).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:St(n.name,this.schema)},s=de(n,"addNodeView",o);if(!s)return[];const i=(a,l,c,u,d)=>{const f=za(a,r);return s()({node:a,view:l,getPos:c,decorations:u,innerDecorations:d,editor:t,extension:n,HTMLAttributes:f})};return[n.name,i]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=Ha(this.extensions);return Object.fromEntries(e.filter(n=>!!de(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:oo(n.name,this.schema)},s=de(n,"addMarkView",o);if(!s)return[];const i=(a,l,c)=>{const u=za(a,r);return s()({mark:a,view:l,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:d=>{DE(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:Mp(e.name,this.schema)};e.type==="mark"&&((n=Ge(de(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const o=de(e,"onBeforeCreate",r),s=de(e,"onCreate",r),i=de(e,"onUpdate",r),a=de(e,"onSelectionUpdate",r),l=de(e,"onTransaction",r),c=de(e,"onFocus",r),u=de(e,"onBlur",r),d=de(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)})}};hu.resolve=pE,hu.sort=Tp,hu.flatten=kp;var iB={};bp(iB,{ClipboardTextSerializer:()=>kE,Commands:()=>CE,Delete:()=>TE,Drop:()=>AE,Editable:()=>ME,FocusEvents:()=>_E,Keymap:()=>NE,Paste:()=>RE,Tabindex:()=>IE,focusEventsPluginKey:()=>OE});var Je=class CN extends Rp{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new CN(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},kE=Je.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new He({key:new Ue("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=gE(n);return mE(r,{from:i,to:a},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}}),CE=Je.create({name:"commands",addCommands(){return{...eE}}}),TE=Je.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=cE(t.before,[t,...e]);vE(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 y=m+p.nodeSize-2,v=h.oldRange.from<=m&&y<=h.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:y,newFrom:u.mapping.map(m),newTo:u.mapping.map(y),deletedRange:h.oldRange,newRange:h.newRange,partial:!v,editor:this.editor,transaction:t,combinedTransform:u})})});const f=u.mapping;u.steps.forEach((h,p)=>{var m,y;if(h instanceof ir){const v=f.slice(p).map(h.from,-1),w=f.slice(p).map(h.to),E=f.invert().map(v,-1),x=f.invert().map(w),k=(m=u.doc.nodeAt(v-1))==null?void 0:m.marks.some(C=>C.eq(h.mark)),S=(y=u.doc.nodeAt(w))==null?void 0:y.marks.some(C=>C.eq(h.mark));this.editor.emit("delete",{type:"mark",mark:h.mark,from:h.from,to:h.to,deletedRange:{from:E,to:x},newRange:{from:v,to:w},partial:!!(S||k),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()}}),AE=Je.create({name:"drop",addProseMirrorPlugins(){return[new He({key:new Ue("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),ME=Je.create({name:"editable",addProseMirrorPlugins(){return[new He({key:new Ue("editable"),props:{editable:()=>this.editor.options.editable}})]}}),OE=new Ue("focusEvents"),_E=Je.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new He({key:OE,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}}}})]}}),NE=Je.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,y=d.pos-d.parentOffset,v=m&&p.parent.childCount===1?y===d.pos:Me.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!v||v&&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 Ba()||iE()?s:o},addProseMirrorPlugins(){return[new He({key:new Ue("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=Me.atStart(e.doc).from,c=Me.atEnd(e.doc).to;if(s||!(i===l&&a===c)||!lu(n.doc))return;const f=n.tr,h=tu({state:n,transaction:f}),{commands:p}=new nu({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),RE=Je.create({name:"paste",addProseMirrorPlugins(){return[new He({key:new Ue("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),IE=Je.create({name:"tabindex",addProseMirrorPlugins(){return[new He({key:new Ue("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),aB=class aa{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){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new aa(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 aa(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 aa(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=this.pos+r+(s?0:1);if(i<0||i>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(i);if(!o&&a.depth<=this.depth)return;const l=new aa(a,this.editor,o,o?n:null);o&&(l.actualDepth=this.depth+1),e.push(new aa(a,this.editor,o,o?n:null))}),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)}},lB=`.ProseMirror {
61
- position: relative;
62
- }
63
-
64
- .ProseMirror {
65
- word-wrap: break-word;
66
- white-space: pre-wrap;
67
- white-space: break-spaces;
68
- -webkit-font-variant-ligatures: none;
69
- font-variant-ligatures: none;
70
- font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
71
- }
72
-
73
- .ProseMirror [contenteditable="false"] {
74
- white-space: normal;
75
- }
76
-
77
- .ProseMirror [contenteditable="false"] [contenteditable="true"] {
78
- white-space: pre-wrap;
79
- }
80
-
81
- .ProseMirror pre {
82
- white-space: pre-wrap;
83
- }
84
-
85
- img.ProseMirror-separator {
86
- display: inline !important;
87
- border: none !important;
88
- margin: 0 !important;
89
- width: 0 !important;
90
- height: 0 !important;
91
- }
92
-
93
- .ProseMirror-gapcursor {
94
- display: none;
95
- pointer-events: none;
96
- position: absolute;
97
- margin: 0;
98
- }
99
-
100
- .ProseMirror-gapcursor:after {
101
- content: "";
102
- display: block;
103
- position: absolute;
104
- top: -2px;
105
- width: 20px;
106
- border-top: 1px solid black;
107
- animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
108
- }
109
-
110
- @keyframes ProseMirror-cursor-blink {
111
- to {
112
- visibility: hidden;
113
- }
114
- }
115
-
116
- .ProseMirror-hideselection *::selection {
117
- background: transparent;
118
- }
119
-
120
- .ProseMirror-hideselection *::-moz-selection {
121
- background: transparent;
122
- }
123
-
124
- .ProseMirror-hideselection * {
125
- caret-color: transparent;
126
- }
127
-
128
- .ProseMirror-focused .ProseMirror-gapcursor {
129
- display: block;
130
- }`;function cB(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 uB=class extends J${constructor(t={}){super(),this.css=null,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,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},this.isCapturingTransaction=!1,this.capturedTransaction=null,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=oE(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.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)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=cB(lB,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=uE(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?[ME,kE.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),CE,_E,NE,IE,AE,RE,TE].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 hu(r,this)}createCommandManager(){this.commandManager=new nu({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=Sp(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=Sp(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new qw(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS();const r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${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 yE(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return M$(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Cp(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
131
-
132
- `,textSerializers:n={}}=t||{};return E$(this.state.doc,{blockSeparator:e,textSerializers:{...gE(this.schema),...n}})}get isEmpty(){return lu(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 aB(e,this)}get $doc(){return this.$pos(0)}};function wi(t){return new cu({find:t.find,handler:({state:e,range:n,match:r})=>{const o=Ge(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(Ap(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 dB(t){return new cu({find:t.find,handler:({state:e,range:n,match:r})=>{const o=Ge(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 Ip(t){return new cu({find:t.find,handler:({state:e,range:n,match:r})=>{const o=e.doc.resolve(n.from),s=Ge(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 Ei(t){return new cu({find:t.find,handler:({state:e,range:n,match:r,chain:o})=>{const s=Ge(t.getAttributes,void 0,r)||{},i=e.tr.delete(n.from,n.to),l=i.doc.resolve(n.from).blockRange(),c=l&&Ph(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(y=>h.includes(y.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&&Ro(i.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&i.join(n.from-1)},undoable:t.undoable})}function fB(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof ue){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 hB(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var pB={};bp(pB,{createAtomBlockMarkdownSpec:()=>mB,createBlockMarkdownSpec:()=>gB,createInlineMarkdownSpec:()=>bB,parseAttributes:()=>Dp,parseIndentedBlocks:()=>Lp,renderNestedMarkdownContent:()=>jp,serializeAttributes:()=>Pp});function Dp(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 Pp(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 mB(t){const{nodeName:e,name:n,parseAttributes:r=Dp,serializeAttributes:o=Pp,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]||"",y=r(m);if(!i.find(w=>!(w in y)))return{type:e,raw:p[0],attributes:y}}},renderMarkdown:u=>{const d=c(u.attrs||{}),f=o(d),h=f?` {${f}}`:"";return`:::${l}${h} :::`}}}function gB(t){const{nodeName:e,name:n,getContent:r,parseAttributes:o=Dp,serializeAttributes:s=Pp,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`),y=d.match(m);if(!y)return;const[v,w=""]=y,E=o(w);let x=1;const k=v.length;let S="";const C=/^:::([\w-]*)(\s.*)?/gm,T=d.slice(k);for(C.lastIndex=0;;){const N=C.exec(T);if(N===null)break;const _=N.index,L=N[1];if(!((p=N[2])!=null&&p.endsWith(":::"))){if(L)x+=1;else if(x-=1,x===0){const $=T.slice(0,_);S=$.trim();const B=d.slice(0,k+_+N[0].length);let z=[];if(S)if(a==="block")for(z=h.blockTokens($),z.forEach(j=>{j.text&&(!j.tokens||j.tokens.length===0)&&(j.tokens=h.inlineTokens(j.text))});z.length>0;){const j=z[z.length-1];if(j.type==="paragraph"&&(!j.text||j.text.trim()===""))z.pop();else break}else z=h.inlineTokens(S);return{type:e,raw:B,attributes:E,content:S,tokens:z}}}}}},renderMarkdown:(d,f)=>{const h=u(d.attrs||{}),p=s(h),m=p?` {${p}}`:"",y=f.renderChildren(d.content||[],`
133
-
134
- `);return`:::${c}${m}
135
-
136
- ${y}
137
-
138
- :::`}}}function yB(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 vB(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function bB(t){const{nodeName:e,name:n,getContent:r,parseAttributes:o=yB,serializeAttributes:s=vB,defaultAttributes:i={},selfClosing:a=!1,allowedAttributes:l}=t,c=n||e,u=f=>{if(!l)return f;const h={};return l.forEach(p=>{p in f&&(h[p]=f[p])}),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}\\]`),y=f.match(m);if(!y)return;let v="",w="";if(a){const[,x]=y;w=x}else{const[,x,k]=y;w=x,v=k||""}const E=o(w.trim());return{type:e,raw:y[0],content:v.trim(),attributes:E}}},renderMarkdown:f=>{let h="";r?h=r(f):f.content&&f.content.length>0&&(h=f.content.filter(v=>v.type==="text").map(v=>v.text).join(""));const p=u(f.attrs||{}),m=s(p),y=m?` ${m}`:"";return a?`[${c}${y}]`:`[${c}${y}]${h}[/${c}]`}}}function Lp(t,e,n){var r,o,s,i;const a=t.split(`
139
- `),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;continue}else return}const p=e.extractItemData(h),{indentLevel:m,mainContent:y}=p;c=`${c}${f}
140
- `;const v=[y];for(u+=1;u<a.length;){const k=a[u];if(k.trim()===""){const C=a.slice(u+1).findIndex(_=>_.trim()!=="");if(C===-1)break;if((((o=(r=a[u+1+C].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:o.length)||0)>m){v.push(k),c=`${c}${k}
141
- `,u+=1;continue}else break}if((((i=(s=k.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:i.length)||0)>m)v.push(k),c=`${c}${k}
142
- `,u+=1;else break}let w;const E=v.slice(1);if(E.length>0){const k=E.map(S=>S.slice(m+d)).join(`
143
- `);k.trim()&&(e.customNestedParser?w=e.customNestedParser(k):w=n.blockTokens(k))}const x=e.createToken(p,w);l.push(x)}if(l.length!==0)return{items:l,raw:c.trim()}}function jp(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]),l=[`${o}${a}`];return i&&i.length>0&&i.forEach(c=>{const u=e.renderChildren([c]);if(u){const d=u.split(`
144
- `).map(f=>f?e.indent(f):"").join(`
145
- `);l.push(d)}}),l.join(`
146
- `)}function DE(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 xB=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){DE(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"&&(Ba()||Ep())&&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)}},Mt=class TN extends Rp{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new TN(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},wB=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 w=this.dom.getBoundingClientRect(),E=u.getBoundingClientRect(),x=(o=t.offsetX)!=null?o:(r=t.nativeEvent)==null?void 0:r.offsetX,k=(i=t.offsetY)!=null?i:(s=t.nativeEvent)==null?void 0:s.offsetY;d=E.x-w.x+x,f=E.y-w.y+k}const h=this.dom.cloneNode(!0);try{const w=this.dom.getBoundingClientRect();h.style.width=`${Math.round(w.width)}px`,h.style.height=`${Math.round(w.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 y=ue.create(l.state.doc,m),v=l.state.tr.setSelection(y);l.dispatch(v)}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=ue.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"&&(Ba()||Ep())&&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 Ns(t){return new tB({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:o})=>{const s=Ge(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(Ap(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(y=>y===t.type&&y!==p.mark.type)).filter(p=>p.to>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)}}})}var $p,PE;function EB(){return PE||(PE=1,$p=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,o,s;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!t(e[o],n[o]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(o of e.entries())if(!n.has(o[0]))return!1;for(o of e.entries())if(!t(o[1],n.get(o[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(o of e.entries())if(!n.has(o[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(o=r;o--!==0;)if(e[o]!==n[o])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(s=Object.keys(e),r=s.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,s[o]))return!1;for(o=r;o--!==0;){var i=s[o];if(!(i==="_owner"&&e.$$typeof)&&!t(e[i],n[i]))return!1}return!0}return e!==e&&n!==n}),$p}var SB=EB();const kB=th(SB);var pu={exports:{}},Bp={};/**
147
- * @license React
148
- * use-sync-external-store-shim/with-selector.production.js
149
- *
150
- * Copyright (c) Meta Platforms, Inc. and affiliates.
151
- *
152
- * This source code is licensed under the MIT license found in the
153
- * LICENSE file in the root directory of this source tree.
154
- */var LE;function CB(){if(LE)return Bp;LE=1;var t=M,e=kh();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 Bp.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 v(S){if(!w){if(w=!0,E=S,S=f(S),h!==void 0&&m.hasValue){var C=m.value;if(h(C,S))return x=C}return x=S}if(C=x,r(E,S))return C;var T=f(S);return h!==void 0&&h(C,T)?(E=S,C):(E=S,x=T)}var w=!1,E,x,k=d===void 0?null:d;return[function(){return v(u())},k===null?void 0:function(){return v(k())}]},[u,d,f,h]);var y=o(c,p[0],p[1]);return i(function(){m.hasValue=!0,m.value=y},[y]),l(y),y},Bp}var Fp={};/**
155
- * @license React
156
- * use-sync-external-store-shim/with-selector.development.js
157
- *
158
- * Copyright (c) Meta Platforms, Inc. and affiliates.
159
- *
160
- * This source code is licensed under the MIT license found in the
161
- * LICENSE file in the root directory of this source tree.
162
- */var jE;function TB(){return jE||(jE=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=M,n=kh(),r=typeof Object.is=="function"?Object.is:t,o=n.useSyncExternalStore,s=e.useRef,i=e.useEffect,a=e.useMemo,l=e.useDebugValue;Fp.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 v(S){if(!w){if(w=!0,E=S,S=f(S),h!==void 0&&m.hasValue){var C=m.value;if(h(C,S))return x=C}return x=S}if(C=x,r(E,S))return C;var T=f(S);return h!==void 0&&h(C,T)?(E=S,C):(E=S,x=T)}var w=!1,E,x,k=d===void 0?null:d;return[function(){return v(u())},k===null?void 0:function(){return v(k())}]},[u,d,f,h]);var y=o(c,p[0],p[1]);return i(function(){m.hasValue=!0,m.value=y},[y]),l(y),y},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Fp}var $E;function AB(){return $E||($E=1,process.env.NODE_ENV==="production"?pu.exports=CB():pu.exports=TB()),pu.exports}var MB=AB(),OB=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},_B=({contentComponent:t})=>{const e=Ch.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return g.jsx(g.Fragment,{children:Object.values(e)})};function NB(){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]:la.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 RB=class extends M.Component{constructor(t){var e;super(t),this.editorContentRef=M.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(t.view.dom),t.setOptions({element:e}),t.contentComponent=NB(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.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.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return g.jsxs(g.Fragment,{children:[g.jsx("div",{ref:OB(e,this.editorContentRef),...n}),t?.contentComponent&&g.jsx(_B,{contentComponent:t.contentComponent})]})}},IB=M.forwardRef((t,e)=>{const n=M.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return M.createElement(RB,{key:n,innerRef:e,...t})}),DB=M.memo(IB),PB=typeof window<"u"?M.useLayoutEffect:M.useEffect,LB=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 BE(t){var e;const[n]=M.useState(()=>new LB(t.editor)),r=MB.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:kB);return PB(()=>n.watch(t.editor),[t.editor,n]),M.useDebugValue(r),r}var FE=process.env.NODE_ENV!=="production",Hp=typeof window>"u",jB=Hp||!!(typeof window<"u"&&window.next),$B=class AN{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(Hp||jB){if(FE)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&&Hp&&FE)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 uB(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?AN.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 BB(t={},e=[]){const n=M.useRef(t);n.current=t;const[r]=M.useState(()=>new $B(n)),o=Ch.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return M.useDebugValue(o),M.useEffect(r.onRender(e)),BE({editor:o,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),o}var zp=M.createContext({editor:null});zp.Consumer;var mu=()=>M.useContext(zp),HE=M.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),zE=()=>M.useContext(HE);function UE({as:t="div",...e}){const{nodeViewContentRef:n,nodeViewContentChildren:r}=zE();return g.jsx(t,{...e,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...e.style},children:r})}var Uo=M.forwardRef((t,e)=>{const{onDragStart:n}=zE(),r=t.as||"div";return g.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function VE(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function WE(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function FB(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function HB(t){if(VE(t)||WE(t))return!0;if(FB(t)){const e=t.type;if(e)return VE(e)||WE(e)}return!1}function zB(){try{if(M.version)return parseInt(M.version.split(".")[0],10)>=19}catch{}return!1}var Up=class{constructor(t,{editor:e,props:n={},as:r="div",className:o=""}){this.ref=null,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?la.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var t;const e=this.component,n=this.props,r=this.editor,o=zB(),s=HB(e),i={...n};i.ref&&!(o||s)&&delete i.ref,!i.ref&&(o||s)&&(i.ref=a=>{this.ref=a}),this.reactElement=g.jsx(e,{...i}),(t=r?.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){this.props={...this.props,...t},this.render()}destroy(){var t;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])})}},GE=M.createContext({markViewContentRef:()=>{}}),UB=t=>{const{as:e="span",...n}=t,{markViewContentRef:r}=M.useContext(GE);return g.jsx(e,{...n,ref:r,"data-mark-view-content":""})},VB=class extends xB{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=M.memo(u=>g.jsx(GE.Provider,{value:l,children:M.createElement(t,u)}));c.displayName="ReactMarkView",this.renderer=new Up(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 WB(t,e={}){return n=>new VB(t,n,e)}var GB=class extends wB{constructor(t,e,n){if(super(t,e,n),!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)}}mount(){const t={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(l={})=>this.updateAttributes(l),deleteNode:()=>this.deleteNode(),ref:M.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=M.memo(l=>g.jsx(HE.Provider,{value:r,children:M.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 Up(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(){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})})}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})),!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}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=za(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function Ua(t,e){return n=>n.editor.contentComponent?new GB(t,n,e):{}}const Vp=()=>{const{editor:t}=mu(),e=o=>{if(typeof window>"u"||typeof localStorage>"u"||!t||t.isEmpty)return;const s=t?.getJSON();localStorage.setItem(`${o}-draft`,JSON.stringify(s))},n=M.useCallback(o=>{const s=localStorage.getItem(`${o}-draft`);return s?JSON.parse(s):null},[]);return{saveCurrentTabContent:e,getTabContent:n,clearContent:()=>{w0(ht).forEach(s=>localStorage.removeItem(`${s.value}-draft`))}}},qB=w0(ht),KB=({editorTab:t,onSwitchEditorTab:e})=>{const{saveCurrentTabContent:n}=Vp(),r=o=>{n(t),e(o)};return g.jsx(E0,{defaultValue:ht.Text,value:t,onValueChange:r,className:"w-full",children:g.jsx(S0,{className:"w-full rounded-none border-b",children:qB.map(o=>g.jsx(wh,{value:o.value.toString(),children:o.label},o.value))})})},qE=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,KE=i0,Wp=(t,e)=>n=>{var r;if(e?.variants==null)return KE(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=qE(u)||qE(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,y]=p;return Array.isArray(y)?y.includes({...s,...a}[m]):{...s,...a}[m]===y})?[...c,d,f]:c},[]);return KE(t,i,l,n?.class,n?.className)},YB=Wp("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"}}),Rn=b.forwardRef(({className:t,variant:e,size:n,asChild:r=!1,...o},s)=>{const i=r?lD:"button";return g.jsx(i,{className:re(YB({variant:e,size:n,className:t})),ref:s,...o})});Rn.displayName="Button";function JB(t,e=globalThis?.document){const n=sr(t);b.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 XB="DismissableLayer",Gp="dismissableLayer.update",QB="dismissableLayer.pointerDownOutside",ZB="dismissableLayer.focusOutside",YE,JE=b.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Si=b.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:s,onInteractOutside:i,onDismiss:a,...l}=t,c=b.useContext(JE),[u,d]=b.useState(null),f=u?.ownerDocument??globalThis?.document,[,h]=b.useState({}),p=$e(e,C=>d(C)),m=Array.from(c.layers),[y]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),v=m.indexOf(y),w=u?m.indexOf(u):-1,E=c.layersWithOutsidePointerEventsDisabled.size>0,x=w>=v,k=nF(C=>{const T=C.target,N=[...c.branches].some(_=>_.contains(T));!x||N||(o?.(C),i?.(C),C.defaultPrevented||a?.())},f),S=rF(C=>{const T=C.target;[...c.branches].some(_=>_.contains(T))||(s?.(C),i?.(C),C.defaultPrevented||a?.())},f);return JB(C=>{w===c.layers.size-1&&(r?.(C),!C.defaultPrevented&&a&&(C.preventDefault(),a()))},f),b.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(YE=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),XE(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=YE)}},[u,f,n,c]),b.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),XE())},[u,c]),b.useEffect(()=>{const C=()=>h({});return document.addEventListener(Gp,C),()=>document.removeEventListener(Gp,C)},[]),g.jsx(ge.div,{...l,ref:p,style:{pointerEvents:E?x?"auto":"none":void 0,...t.style},onFocusCapture:te(t.onFocusCapture,S.onFocusCapture),onBlurCapture:te(t.onBlurCapture,S.onBlurCapture),onPointerDownCapture:te(t.onPointerDownCapture,k.onPointerDownCapture)})});Si.displayName=XB;var eF="DismissableLayerBranch",tF=b.forwardRef((t,e)=>{const n=b.useContext(JE),r=b.useRef(null),o=$e(e,r);return b.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),g.jsx(ge.div,{...t,ref:o})});tF.displayName=eF;function nF(t,e=globalThis?.document){const n=sr(t),r=b.useRef(!1),o=b.useRef(()=>{});return b.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){QE(QB,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 rF(t,e=globalThis?.document){const n=sr(t),r=b.useRef(!1);return b.useEffect(()=>{const o=s=>{s.target&&!r.current&&QE(ZB,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 XE(){const t=new CustomEvent(Gp);document.dispatchEvent(t)}function QE(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?Hb(o,s):o.dispatchEvent(s)}const oF=["top","right","bottom","left"],Vo=Math.min,In=Math.max,gu=Math.round,yu=Math.floor,Or=t=>({x:t,y:t}),sF={left:"right",right:"left",bottom:"top",top:"bottom"},iF={start:"end",end:"start"};function qp(t,e,n){return In(t,Vo(e,n))}function io(t,e){return typeof t=="function"?t(e):t}function ao(t){return t.split("-")[0]}function ki(t){return t.split("-")[1]}function Kp(t){return t==="x"?"y":"x"}function Yp(t){return t==="y"?"height":"width"}const aF=new Set(["top","bottom"]);function _r(t){return aF.has(ao(t))?"y":"x"}function Jp(t){return Kp(_r(t))}function lF(t,e,n){n===void 0&&(n=!1);const r=ki(t),o=Jp(t),s=Yp(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(i=vu(i)),[i,vu(i)]}function cF(t){const e=vu(t);return[Xp(t),e,Xp(e)]}function Xp(t){return t.replace(/start|end/g,e=>iF[e])}const ZE=["left","right"],eS=["right","left"],uF=["top","bottom"],dF=["bottom","top"];function fF(t,e,n){switch(t){case"top":case"bottom":return n?e?eS:ZE:e?ZE:eS;case"left":case"right":return e?uF:dF;default:return[]}}function hF(t,e,n,r){const o=ki(t);let s=fF(ao(t),n==="start",r);return o&&(s=s.map(i=>i+"-"+o),e&&(s=s.concat(s.map(Xp)))),s}function vu(t){return t.replace(/left|right|bottom|top/g,e=>sF[e])}function pF(t){return{top:0,right:0,bottom:0,left:0,...t}}function tS(t){return typeof t!="number"?pF(t):{top:t,right:t,bottom:t,left:t}}function bu(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 nS(t,e,n){let{reference:r,floating:o}=t;const s=_r(e),i=Jp(e),a=Yp(i),l=ao(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(ki(e)){case"start":h[i]-=f*(n&&c?-1:1);break;case"end":h[i]+=f*(n&&c?-1:1);break}return h}const mF=async(t,e,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=n,a=s.filter(Boolean),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}=nS(c,r,l),f=r,h={},p=0;for(let m=0;m<a.length;m++){const{name:y,fn:v}=a[m],{x:w,y:E,data:x,reset:k}=await v({x:u,y:d,initialPlacement:r,placement:f,strategy:o,middlewareData:h,rects:c,platform:i,elements:{reference:t,floating:e}});u=w??u,d=E??d,h={...h,[y]:{...h[y],...x}},k&&p<=50&&(p++,typeof k=="object"&&(k.placement&&(f=k.placement),k.rects&&(c=k.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:o}):k.rects),{x:u,y:d}=nS(c,f,l)),m=-1)}return{x:u,y:d,placement:f,strategy:o,middlewareData:h}};async function Va(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=tS(h),y=a[f?d==="floating"?"reference":"floating":d],v=bu(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),w=d==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,E=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),x=await(s.isElement==null?void 0:s.isElement(E))?await(s.getScale==null?void 0:s.getScale(E))||{x:1,y:1}:{x:1,y:1},k=bu(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:E,strategy:l}):w);return{top:(v.top-k.top+p.top)/x.y,bottom:(k.bottom-v.bottom+p.bottom)/x.y,left:(v.left-k.left+p.left)/x.x,right:(k.right-v.right+p.right)/x.x}}const gF=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=tS(u),f={x:n,y:r},h=Jp(o),p=Yp(h),m=await i.getDimensions(c),y=h==="y",v=y?"top":"left",w=y?"bottom":"right",E=y?"clientHeight":"clientWidth",x=s.reference[p]+s.reference[h]-f[h]-s.floating[p],k=f[h]-s.reference[h],S=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let C=S?S[E]:0;(!C||!await(i.isElement==null?void 0:i.isElement(S)))&&(C=a.floating[E]||s.floating[p]);const T=x/2-k/2,N=C/2-m[p]/2-1,_=Vo(d[v],N),L=Vo(d[w],N),$=_,B=C-m[p]-L,z=C/2-m[p]/2+T,j=qp($,z,B),P=!l.arrow&&ki(o)!=null&&z!==j&&s.reference[p]/2-(z<$?_:L)-m[p]/2<0,H=P?z<$?z-$:z-B:0;return{[h]:f[h]+H,data:{[h]:j,centerOffset:z-j-H,...P&&{alignmentOffset:H}},reset:P}}}),yF=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,...y}=io(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const v=ao(o),w=_r(a),E=ao(a)===a,x=await(l.isRTL==null?void 0:l.isRTL(c.floating)),k=f||(E||!m?[vu(a)]:cF(a)),S=p!=="none";!f&&S&&k.push(...hF(a,m,p,x));const C=[a,...k],T=await Va(e,y),N=[];let _=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&N.push(T[v]),d){const z=lF(o,i,x);N.push(T[z[0]],T[z[1]])}if(_=[..._,{placement:o,overflows:N}],!N.every(z=>z<=0)){var L,$;const z=(((L=s.flip)==null?void 0:L.index)||0)+1,j=C[z];if(j&&(!(d==="alignment"?w!==_r(j):!1)||_.every(R=>_r(R.placement)===w?R.overflows[0]>0:!0)))return{data:{index:z,overflows:_},reset:{placement:j}};let P=($=_.filter(H=>H.overflows[0]<=0).sort((H,R)=>H.overflows[1]-R.overflows[1])[0])==null?void 0:$.placement;if(!P)switch(h){case"bestFit":{var B;const H=(B=_.filter(R=>{if(S){const V=_r(R.placement);return V===w||V==="y"}return!0}).map(R=>[R.placement,R.overflows.filter(V=>V>0).reduce((V,ie)=>V+ie,0)]).sort((R,V)=>R[1]-V[1])[0])==null?void 0:B[0];H&&(P=H);break}case"initialPlacement":P=a;break}if(o!==P)return{reset:{placement:P}}}return{}}}};function rS(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function oS(t){return oF.some(e=>t[e]>=0)}const vF=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...o}=io(t,e);switch(r){case"referenceHidden":{const s=await Va(e,{...o,elementContext:"reference"}),i=rS(s,n.reference);return{data:{referenceHiddenOffsets:i,referenceHidden:oS(i)}}}case"escaped":{const s=await Va(e,{...o,altBoundary:!0}),i=rS(s,n.floating);return{data:{escapedOffsets:i,escaped:oS(i)}}}default:return{}}}}},sS=new Set(["left","top"]);async function bF(t,e){const{placement:n,platform:r,elements:o}=t,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=ao(n),a=ki(n),l=_r(n)==="y",c=sS.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 xF=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 bF(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}}}}},wF=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:o}=e,{mainAxis:s=!0,crossAxis:i=!1,limiter:a={fn:y=>{let{x:v,y:w}=y;return{x:v,y:w}}},...l}=io(t,e),c={x:n,y:r},u=await Va(e,l),d=_r(ao(o)),f=Kp(d);let h=c[f],p=c[d];if(s){const y=f==="y"?"top":"left",v=f==="y"?"bottom":"right",w=h+u[y],E=h-u[v];h=qp(w,h,E)}if(i){const y=d==="y"?"top":"left",v=d==="y"?"bottom":"right",w=p+u[y],E=p-u[v];p=qp(w,p,E)}const m=a.fn({...e,[f]:h,[d]:p});return{...m,data:{x:m.x-n,y:m.y-r,enabled:{[f]:s,[d]:i}}}}}},EF=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=_r(o),f=Kp(d);let h=u[f],p=u[d];const m=io(a,e),y=typeof m=="number"?{mainAxis:m,crossAxis:0}:{mainAxis:0,crossAxis:0,...m};if(l){const E=f==="y"?"height":"width",x=s.reference[f]-s.floating[E]+y.mainAxis,k=s.reference[f]+s.reference[E]-y.mainAxis;h<x?h=x:h>k&&(h=k)}if(c){var v,w;const E=f==="y"?"width":"height",x=sS.has(ao(o)),k=s.reference[d]-s.floating[E]+(x&&((v=i.offset)==null?void 0:v[d])||0)+(x?0:y.crossAxis),S=s.reference[d]+s.reference[E]+(x?0:((w=i.offset)==null?void 0:w[d])||0)-(x?y.crossAxis:0);p<k?p=k:p>S&&(p=S)}return{[f]:h,[d]:p}}}},SF=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 Va(e,c),d=ao(o),f=ki(o),h=_r(o)==="y",{width:p,height:m}=s.floating;let y,v;d==="top"||d==="bottom"?(y=d,v=f===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?"start":"end")?"left":"right"):(v=d,y=f==="end"?"top":"bottom");const w=m-u.top-u.bottom,E=p-u.left-u.right,x=Vo(m-u[y],w),k=Vo(p-u[v],E),S=!e.middlewareData.shift;let C=x,T=k;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(T=E),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(C=w),S&&!f){const _=In(u.left,0),L=In(u.right,0),$=In(u.top,0),B=In(u.bottom,0);h?T=p-2*(_!==0||L!==0?_+L:In(u.left,u.right)):C=m-2*($!==0||B!==0?$+B:In(u.top,u.bottom))}await l({...e,availableWidth:T,availableHeight:C});const N=await i.getDimensions(a.floating);return p!==N.width||m!==N.height?{reset:{rects:!0}}:{}}}};function xu(){return typeof window<"u"}function Ci(t){return iS(t)?(t.nodeName||"").toLowerCase():"#document"}function Dn(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Nr(t){var e;return(e=(iS(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function iS(t){return xu()?t instanceof Node||t instanceof Dn(t).Node:!1}function ar(t){return xu()?t instanceof Element||t instanceof Dn(t).Element:!1}function Rr(t){return xu()?t instanceof HTMLElement||t instanceof Dn(t).HTMLElement:!1}function aS(t){return!xu()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Dn(t).ShadowRoot}const kF=new Set(["inline","contents"]);function Wa(t){const{overflow:e,overflowX:n,overflowY:r,display:o}=lr(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!kF.has(o)}const CF=new Set(["table","td","th"]);function TF(t){return CF.has(Ci(t))}const AF=[":popover-open",":modal"];function wu(t){return AF.some(e=>{try{return t.matches(e)}catch{return!1}})}const MF=["transform","translate","scale","rotate","perspective"],OF=["transform","translate","scale","rotate","perspective","filter"],_F=["paint","layout","strict","content"];function Qp(t){const e=Zp(),n=ar(t)?lr(t):t;return MF.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||OF.some(r=>(n.willChange||"").includes(r))||_F.some(r=>(n.contain||"").includes(r))}function NF(t){let e=Wo(t);for(;Rr(e)&&!Ti(e);){if(Qp(e))return e;if(wu(e))return null;e=Wo(e)}return null}function Zp(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const RF=new Set(["html","body","#document"]);function Ti(t){return RF.has(Ci(t))}function lr(t){return Dn(t).getComputedStyle(t)}function Eu(t){return ar(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Wo(t){if(Ci(t)==="html")return t;const e=t.assignedSlot||t.parentNode||aS(t)&&t.host||Nr(t);return aS(e)?e.host:e}function lS(t){const e=Wo(t);return Ti(e)?t.ownerDocument?t.ownerDocument.body:t.body:Rr(e)&&Wa(e)?e:lS(e)}function Ga(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const o=lS(t),s=o===((r=t.ownerDocument)==null?void 0:r.body),i=Dn(o);if(s){const a=em(i);return e.concat(i,i.visualViewport||[],Wa(o)?o:[],a&&n?Ga(a):[])}return e.concat(o,Ga(o,[],n))}function em(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function cS(t){const e=lr(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const o=Rr(t),s=o?t.offsetWidth:n,i=o?t.offsetHeight:r,a=gu(n)!==s||gu(r)!==i;return a&&(n=s,r=i),{width:n,height:r,$:a}}function tm(t){return ar(t)?t:t.contextElement}function Ai(t){const e=tm(t);if(!Rr(e))return Or(1);const n=e.getBoundingClientRect(),{width:r,height:o,$:s}=cS(e);let i=(s?gu(n.width):n.width)/r,a=(s?gu(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const IF=Or(0);function uS(t){const e=Dn(t);return!Zp()||!e.visualViewport?IF:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function DF(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Dn(t)?!1:e}function Rs(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const o=t.getBoundingClientRect(),s=tm(t);let i=Or(1);e&&(r?ar(r)&&(i=Ai(r)):i=Ai(t));const a=DF(s,n,r)?uS(s):Or(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=Dn(s),h=r&&ar(r)?Dn(r):r;let p=f,m=em(p);for(;m&&r&&h!==p;){const y=Ai(m),v=m.getBoundingClientRect(),w=lr(m),E=v.left+(m.clientLeft+parseFloat(w.paddingLeft))*y.x,x=v.top+(m.clientTop+parseFloat(w.paddingTop))*y.y;l*=y.x,c*=y.y,u*=y.x,d*=y.y,l+=E,c+=x,p=Dn(m),m=em(p)}}return bu({width:u,height:d,x:l,y:c})}function Su(t,e){const n=Eu(t).scrollLeft;return e?e.left+n:Rs(Nr(t)).left+n}function dS(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Su(t,n),o=n.top+e.scrollTop;return{x:r,y:o}}function PF(t){let{elements:e,rect:n,offsetParent:r,strategy:o}=t;const s=o==="fixed",i=Nr(r),a=e?wu(e.floating):!1;if(r===i||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=Or(1);const u=Or(0),d=Rr(r);if((d||!d&&!s)&&((Ci(r)!=="body"||Wa(i))&&(l=Eu(r)),Rr(r))){const h=Rs(r);c=Ai(r),u.x=h.x+r.clientLeft,u.y=h.y+r.clientTop}const f=i&&!d&&!s?dS(i,l):Or(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 LF(t){return Array.from(t.getClientRects())}function jF(t){const e=Nr(t),n=Eu(t),r=t.ownerDocument.body,o=In(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=In(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+Su(t);const a=-n.scrollTop;return lr(r).direction==="rtl"&&(i+=In(e.clientWidth,r.clientWidth)-o),{width:o,height:s,x:i,y:a}}const fS=25;function $F(t,e){const n=Dn(t),r=Nr(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=Zp();(!u||u&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}const c=Su(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<=fS&&(s-=p)}else c<=fS&&(s+=c);return{width:s,height:i,x:a,y:l}}const BF=new Set(["absolute","fixed"]);function FF(t,e){const n=Rs(t,!0,e==="fixed"),r=n.top+t.clientTop,o=n.left+t.clientLeft,s=Rr(t)?Ai(t):Or(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 hS(t,e,n){let r;if(e==="viewport")r=$F(t,n);else if(e==="document")r=jF(Nr(t));else if(ar(e))r=FF(e,n);else{const o=uS(t);r={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return bu(r)}function pS(t,e){const n=Wo(t);return n===e||!ar(n)||Ti(n)?!1:lr(n).position==="fixed"||pS(n,e)}function HF(t,e){const n=e.get(t);if(n)return n;let r=Ga(t,[],!1).filter(a=>ar(a)&&Ci(a)!=="body"),o=null;const s=lr(t).position==="fixed";let i=s?Wo(t):t;for(;ar(i)&&!Ti(i);){const a=lr(i),l=Qp(i);!l&&a.position==="fixed"&&(o=null),(s?!l&&!o:!l&&a.position==="static"&&!!o&&BF.has(o.position)||Wa(i)&&!l&&pS(t,i))?r=r.filter(u=>u!==i):o=a,i=Wo(i)}return e.set(t,r),r}function zF(t){let{element:e,boundary:n,rootBoundary:r,strategy:o}=t;const i=[...n==="clippingAncestors"?wu(e)?[]:HF(e,this._c):[].concat(n),r],a=i[0],l=i.reduce((c,u)=>{const d=hS(e,u,o);return c.top=In(d.top,c.top),c.right=Vo(d.right,c.right),c.bottom=Vo(d.bottom,c.bottom),c.left=In(d.left,c.left),c},hS(e,a,o));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function UF(t){const{width:e,height:n}=cS(t);return{width:e,height:n}}function VF(t,e,n){const r=Rr(e),o=Nr(e),s=n==="fixed",i=Rs(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=Or(0);function c(){l.x=Su(o)}if(r||!r&&!s)if((Ci(e)!=="body"||Wa(o))&&(a=Eu(e)),r){const h=Rs(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?dS(o,a):Or(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 nm(t){return lr(t).position==="static"}function mS(t,e){if(!Rr(t)||lr(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Nr(t)===n&&(n=n.ownerDocument.body),n}function gS(t,e){const n=Dn(t);if(wu(t))return n;if(!Rr(t)){let o=Wo(t);for(;o&&!Ti(o);){if(ar(o)&&!nm(o))return o;o=Wo(o)}return n}let r=mS(t,e);for(;r&&TF(r)&&nm(r);)r=mS(r,e);return r&&Ti(r)&&nm(r)&&!Qp(r)?n:r||NF(t)||n}const WF=async function(t){const e=this.getOffsetParent||gS,n=this.getDimensions,r=await n(t.floating);return{reference:VF(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function GF(t){return lr(t).direction==="rtl"}const qF={convertOffsetParentRelativeRectToViewportRelativeRect:PF,getDocumentElement:Nr,getClippingRect:zF,getOffsetParent:gS,getElementRects:WF,getClientRects:LF,getDimensions:UF,getScale:Ai,isElement:ar,isRTL:GF};function yS(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function KF(t,e){let n=null,r;const o=Nr(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=yu(d),m=yu(o.clientWidth-(u+f)),y=yu(o.clientHeight-(d+h)),v=yu(u),E={rootMargin:-p+"px "+-m+"px "+-y+"px "+-v+"px",threshold:In(0,Vo(1,l))||1};let x=!0;function k(S){const C=S[0].intersectionRatio;if(C!==l){if(!x)return i();C?i(!1,C):r=setTimeout(()=>{i(!1,1e-7)},1e3)}C===1&&!yS(c,t.getBoundingClientRect())&&i(),x=!1}try{n=new IntersectionObserver(k,{...E,root:o.ownerDocument})}catch{n=new IntersectionObserver(k,E)}n.observe(t)}return i(!0),s}function YF(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=tm(t),u=o||s?[...c?Ga(c):[],...Ga(e)]:[];u.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),s&&v.addEventListener("resize",n)});const d=c&&a?KF(c,n):null;let f=-1,h=null;i&&(h=new ResizeObserver(v=>{let[w]=v;w&&w.target===c&&h&&(h.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var E;(E=h)==null||E.observe(e)})),n()}),c&&!l&&h.observe(c),h.observe(e));let p,m=l?Rs(t):null;l&&y();function y(){const v=Rs(t);m&&!yS(m,v)&&n(),m=v,p=requestAnimationFrame(y)}return n(),()=>{var v;u.forEach(w=>{o&&w.removeEventListener("scroll",n),s&&w.removeEventListener("resize",n)}),d?.(),(v=h)==null||v.disconnect(),h=null,l&&cancelAnimationFrame(p)}}const JF=xF,XF=wF,QF=yF,ZF=SF,eH=vF,vS=gF,tH=EF,bS=(t,e,n)=>{const r=new Map,o={platform:qF,...n},s={...o.platform,_c:r};return mF(t,e,{...o,platform:s})};var nH=typeof document<"u",rH=function(){},ku=nH?M.useLayoutEffect:rH;function Cu(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(!Cu(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)&&!Cu(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function xS(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function wS(t,e){const n=xS(t);return Math.round(e*n)/n}function rm(t){const e=b.useRef(t);return ku(()=>{e.current=t}),e}function oH(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]=b.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[f,h]=b.useState(r);Cu(f,r)||h(r);const[p,m]=b.useState(null),[y,v]=b.useState(null),w=b.useCallback(R=>{R!==S.current&&(S.current=R,m(R))},[]),E=b.useCallback(R=>{R!==C.current&&(C.current=R,v(R))},[]),x=s||p,k=i||y,S=b.useRef(null),C=b.useRef(null),T=b.useRef(u),N=l!=null,_=rm(l),L=rm(o),$=rm(c),B=b.useCallback(()=>{if(!S.current||!C.current)return;const R={placement:e,strategy:n,middleware:f};L.current&&(R.platform=L.current),bS(S.current,C.current,R).then(V=>{const ie={...V,isPositioned:$.current!==!1};z.current&&!Cu(T.current,ie)&&(T.current=ie,oc.flushSync(()=>{d(ie)}))})},[f,e,n,L,$]);ku(()=>{c===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(R=>({...R,isPositioned:!1})))},[c]);const z=b.useRef(!1);ku(()=>(z.current=!0,()=>{z.current=!1}),[]),ku(()=>{if(x&&(S.current=x),k&&(C.current=k),x&&k){if(_.current)return _.current(x,k,B);B()}},[x,k,B,_,N]);const j=b.useMemo(()=>({reference:S,floating:C,setReference:w,setFloating:E}),[w,E]),P=b.useMemo(()=>({reference:x,floating:k}),[x,k]),H=b.useMemo(()=>{const R={position:n,left:0,top:0};if(!P.floating)return R;const V=wS(P.floating,u.x),ie=wS(P.floating,u.y);return a?{...R,transform:"translate("+V+"px, "+ie+"px)",...xS(P.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:V,top:ie}},[n,a,P.floating,u.x,u.y]);return b.useMemo(()=>({...u,update:B,refs:j,elements:P,floatingStyles:H}),[u,B,j,P,H])}const sH=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?vS({element:r.current,padding:o}).fn(n):{}:r?vS({element:r,padding:o}).fn(n):{}}}},iH=(t,e)=>({...JF(t),options:[t,e]}),aH=(t,e)=>({...XF(t),options:[t,e]}),lH=(t,e)=>({...tH(t),options:[t,e]}),cH=(t,e)=>({...QF(t),options:[t,e]}),uH=(t,e)=>({...ZF(t),options:[t,e]}),dH=(t,e)=>({...eH(t),options:[t,e]}),fH=(t,e)=>({...sH(t),options:[t,e]});var hH="Arrow",ES=b.forwardRef((t,e)=>{const{children:n,width:r=10,height:o=5,...s}=t;return g.jsx(ge.svg,{...s,ref:e,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:g.jsx("polygon",{points:"0,0 30,0 15,10"})})});ES.displayName=hH;var pH=ES;function SS(t){const[e,n]=b.useState(void 0);return Tt(()=>{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 om="Popper",[kS,Go]=On(om),[mH,CS]=kS(om),TS=t=>{const{__scopePopper:e,children:n}=t,[r,o]=b.useState(null);return g.jsx(mH,{scope:e,anchor:r,onAnchorChange:o,children:n})};TS.displayName=om;var AS="PopperAnchor",MS=b.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...o}=t,s=CS(AS,n),i=b.useRef(null),a=$e(e,i),l=b.useRef(null);return b.useEffect(()=>{const c=l.current;l.current=r?.current||i.current,c!==l.current&&s.onAnchorChange(l.current)}),r?null:g.jsx(ge.div,{...o,ref:a})});MS.displayName=AS;var sm="PopperContent",[gH,yH]=kS(sm),OS=b.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,y=CS(sm,n),[v,w]=b.useState(null),E=$e(e,U=>w(U)),[x,k]=b.useState(null),S=SS(x),C=S?.width??0,T=S?.height??0,N=r+(s!=="center"?"-"+s:""),_=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},L=Array.isArray(c)?c:[c],$=L.length>0,B={padding:_,boundary:L.filter(bH),altBoundary:$},{refs:z,floatingStyles:j,placement:P,isPositioned:H,middlewareData:R}=oH({strategy:"fixed",placement:N,whileElementsMounted:(...U)=>YF(...U,{animationFrame:h==="always"}),elements:{reference:y.anchor},middleware:[iH({mainAxis:o+T,alignmentAxis:i}),l&&aH({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?lH():void 0,...B}),l&&cH({...B}),uH({...B,apply:({elements:U,rects:ee,availableWidth:Oe,availableHeight:he})=>{const{width:we,height:Se}=ee.reference,Ve=U.floating.style;Ve.setProperty("--radix-popper-available-width",`${Oe}px`),Ve.setProperty("--radix-popper-available-height",`${he}px`),Ve.setProperty("--radix-popper-anchor-width",`${we}px`),Ve.setProperty("--radix-popper-anchor-height",`${Se}px`)}}),x&&fH({element:x,padding:a}),xH({arrowWidth:C,arrowHeight:T}),f&&dH({strategy:"referenceHidden",...B})]}),[V,ie]=RS(P),ne=sr(p);Tt(()=>{H&&ne?.()},[H,ne]);const ye=R.arrow?.x,G=R.arrow?.y,Z=R.arrow?.centerOffset!==0,[J,me]=b.useState();return Tt(()=>{v&&me(window.getComputedStyle(v).zIndex)},[v]),g.jsx("div",{ref:z.setFloating,"data-radix-popper-content-wrapper":"",style:{...j,transform:H?j.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:J,"--radix-popper-transform-origin":[R.transformOrigin?.x,R.transformOrigin?.y].join(" "),...R.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:g.jsx(gH,{scope:n,placedSide:V,onArrowChange:k,arrowX:ye,arrowY:G,shouldHideArrow:Z,children:g.jsx(ge.div,{"data-side":V,"data-align":ie,...m,ref:E,style:{...m.style,animation:H?void 0:"none"}})})})});OS.displayName=sm;var _S="PopperArrow",vH={top:"bottom",right:"left",bottom:"top",left:"right"},NS=b.forwardRef(function(e,n){const{__scopePopper:r,...o}=e,s=yH(_S,r),i=vH[s.placedSide];return g.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:g.jsx(pH,{...o,ref:n,style:{...o.style,display:"block"}})})});NS.displayName=_S;function bH(t){return t!==null}var xH=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]=RS(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 RS(t){const[e,n="center"]=t.split("-");return[e,n]}var Tu=TS,qa=MS,Au=OS,Mu=NS,wH="Portal",Mi=b.forwardRef((t,e)=>{const{container:n,...r}=t,[o,s]=b.useState(!1);Tt(()=>s(!0),[]);const i=n||o&&globalThis?.document?.body;return i?la.createPortal(g.jsx(ge.div,{...r,ref:e}),i):null});Mi.displayName=wH;var IS=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"}),EH="VisuallyHidden",DS=b.forwardRef((t,e)=>g.jsx(ge.span,{...t,ref:e,style:{...IS,...t.style}}));DS.displayName=EH;var SH=DS,[Ou]=On("Tooltip",[Go]),_u=Go(),PS="TooltipProvider",kH=700,im="tooltip.open",[CH,am]=Ou(PS),LS=t=>{const{__scopeTooltip:e,delayDuration:n=kH,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:s}=t,i=b.useRef(!0),a=b.useRef(!1),l=b.useRef(0);return b.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),g.jsx(CH,{scope:e,isOpenDelayedRef:i,delayDuration:n,onOpen:b.useCallback(()=>{window.clearTimeout(l.current),i.current=!1},[]),onClose:b.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>i.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:b.useCallback(c=>{a.current=c},[]),disableHoverableContent:o,children:s})};LS.displayName=PS;var Ka="Tooltip",[TH,Ya]=Ou(Ka),jS=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:o,onOpenChange:s,disableHoverableContent:i,delayDuration:a}=t,l=am(Ka,t.__scopeTooltip),c=_u(e),[u,d]=b.useState(null),f=Bn(),h=b.useRef(0),p=i??l.disableHoverableContent,m=a??l.delayDuration,y=b.useRef(!1),[v,w]=Jr({prop:r,defaultProp:o??!1,onChange:C=>{C?(l.onOpen(),document.dispatchEvent(new CustomEvent(im))):l.onClose(),s?.(C)},caller:Ka}),E=b.useMemo(()=>v?y.current?"delayed-open":"instant-open":"closed",[v]),x=b.useCallback(()=>{window.clearTimeout(h.current),h.current=0,y.current=!1,w(!0)},[w]),k=b.useCallback(()=>{window.clearTimeout(h.current),h.current=0,w(!1)},[w]),S=b.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{y.current=!0,w(!0),h.current=0},m)},[m,w]);return b.useEffect(()=>()=>{h.current&&(window.clearTimeout(h.current),h.current=0)},[]),g.jsx(Tu,{...c,children:g.jsx(TH,{scope:e,contentId:f,open:v,stateAttribute:E,trigger:u,onTriggerChange:d,onTriggerEnter:b.useCallback(()=>{l.isOpenDelayedRef.current?S():x()},[l.isOpenDelayedRef,S,x]),onTriggerLeave:b.useCallback(()=>{p?k():(window.clearTimeout(h.current),h.current=0)},[k,p]),onOpen:x,onClose:k,disableHoverableContent:p,children:n})})};jS.displayName=Ka;var lm="TooltipTrigger",$S=b.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,o=Ya(lm,n),s=am(lm,n),i=_u(n),a=b.useRef(null),l=$e(e,a,o.onTriggerChange),c=b.useRef(!1),u=b.useRef(!1),d=b.useCallback(()=>c.current=!1,[]);return b.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),g.jsx(qa,{asChild:!0,...i,children:g.jsx(ge.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:l,onPointerMove:te(t.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(o.onTriggerEnter(),u.current=!0)}),onPointerLeave:te(t.onPointerLeave,()=>{o.onTriggerLeave(),u.current=!1}),onPointerDown:te(t.onPointerDown,()=>{o.open&&o.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:te(t.onFocus,()=>{c.current||o.onOpen()}),onBlur:te(t.onBlur,o.onClose),onClick:te(t.onClick,o.onClose)})})});$S.displayName=lm;var cm="TooltipPortal",[AH,MH]=Ou(cm,{forceMount:void 0}),BS=t=>{const{__scopeTooltip:e,forceMount:n,children:r,container:o}=t,s=Ya(cm,e);return g.jsx(AH,{scope:e,forceMount:n,children:g.jsx(_n,{present:n||s.open,children:g.jsx(Mi,{asChild:!0,container:o,children:r})})})};BS.displayName=cm;var Oi="TooltipContent",FS=b.forwardRef((t,e)=>{const n=MH(Oi,t.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...s}=t,i=Ya(Oi,t.__scopeTooltip);return g.jsx(_n,{present:r||i.open,children:i.disableHoverableContent?g.jsx(HS,{side:o,...s,ref:e}):g.jsx(OH,{side:o,...s,ref:e})})}),OH=b.forwardRef((t,e)=>{const n=Ya(Oi,t.__scopeTooltip),r=am(Oi,t.__scopeTooltip),o=b.useRef(null),s=$e(e,o),[i,a]=b.useState(null),{trigger:l,onClose:c}=n,u=o.current,{onPointerInTransitChange:d}=r,f=b.useCallback(()=>{a(null),d(!1)},[d]),h=b.useCallback((p,m)=>{const y=p.currentTarget,v={x:p.clientX,y:p.clientY},w=IH(v,y.getBoundingClientRect()),E=DH(v,w),x=PH(m.getBoundingClientRect()),k=jH([...E,...x]);a(k),d(!0)},[d]);return b.useEffect(()=>()=>f(),[f]),b.useEffect(()=>{if(l&&u){const p=y=>h(y,u),m=y=>h(y,l);return l.addEventListener("pointerleave",p),u.addEventListener("pointerleave",m),()=>{l.removeEventListener("pointerleave",p),u.removeEventListener("pointerleave",m)}}},[l,u,h,f]),b.useEffect(()=>{if(i){const p=m=>{const y=m.target,v={x:m.clientX,y:m.clientY},w=l?.contains(y)||u?.contains(y),E=!LH(v,i);w?f():E&&(f(),c())};return document.addEventListener("pointermove",p),()=>document.removeEventListener("pointermove",p)}},[l,u,i,c,f]),g.jsx(HS,{...t,ref:s})}),[_H,NH]=Ou(Ka,{isInside:!1}),RH=uD("TooltipContent"),HS=b.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":o,onEscapeKeyDown:s,onPointerDownOutside:i,...a}=t,l=Ya(Oi,n),c=_u(n),{onClose:u}=l;return b.useEffect(()=>(document.addEventListener(im,u),()=>document.removeEventListener(im,u)),[u]),b.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]),g.jsx(Si,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:g.jsxs(Au,{"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:[g.jsx(RH,{children:r}),g.jsx(_H,{scope:n,isInside:!0,children:g.jsx(SH,{id:l.contentId,role:"tooltip",children:o||r})})]})})});FS.displayName=Oi;var zS="TooltipArrow",US=b.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,o=_u(n);return NH(zS,n).isInside?null:g.jsx(Mu,{...o,...r,ref:e})});US.displayName=zS;function IH(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 DH(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 PH(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 LH(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 jH(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),$H(e)}function $H(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 BH=LS,FH=jS,HH=$S,zH=BS,UH=FS,VH=US;function VS({delayDuration:t=0,...e}){return g.jsx(BH,{delayDuration:t,...e})}function WH(t){return g.jsx(VS,{children:g.jsx(FH,{...t})})}const WS=b.forwardRef((t,e)=>g.jsx(HH,{ref:e,...t}));WS.displayName="TooltipTrigger";const GS=b.forwardRef(({className:t,sideOffset:e=0,children:n,...r},o)=>g.jsx(zH,{children:g.jsx("div",{"data-theme":"select-post-builder",children:g.jsxs(UH,{ref:o,sideOffset:e,className:re("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,g.jsx(VH,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]})})}));GS.displayName="TooltipContent";const xe=b.forwardRef(({icon:t,tooltip:e,active:n,children:r,className:o,onClick:s,...i},a)=>{const{editor:l}=mu(),c=u=>{s?.(u),l&&requestAnimationFrame(l?.chain()?.focus)};return g.jsx(VS,{delayDuration:100,children:g.jsxs(WH,{children:[g.jsx(WS,{asChild:!0,children:g.jsx(Rn,{ref:a,variant:"ghost",size:"icon",className:re("size-7 p-1.5 cursor-pointer",n&&"bg-accent text-violet-600 hover:text-violet-500",r?"size-auto":"",o),onClick:c,...i,children:r??(t&&g.jsx(t,{className:"size-full"}))})}),g.jsx(GS,{children:e})]})})});xe.displayName="ToolbarButton";var um="focusScope.autoFocusOnMount",dm="focusScope.autoFocusOnUnmount",qS={bubbles:!1,cancelable:!0},GH="FocusScope",Ja=b.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:s,...i}=t,[a,l]=b.useState(null),c=sr(o),u=sr(s),d=b.useRef(null),f=$e(e,m=>l(m)),h=b.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;b.useEffect(()=>{if(r){let m=function(E){if(h.paused||!a)return;const x=E.target;a.contains(x)?d.current=x:qo(d.current,{select:!0})},y=function(E){if(h.paused||!a)return;const x=E.relatedTarget;x!==null&&(a.contains(x)||qo(d.current,{select:!0}))},v=function(E){if(document.activeElement===document.body)for(const k of E)k.removedNodes.length>0&&qo(a)};document.addEventListener("focusin",m),document.addEventListener("focusout",y);const w=new MutationObserver(v);return a&&w.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",m),document.removeEventListener("focusout",y),w.disconnect()}}},[r,a,h.paused]),b.useEffect(()=>{if(a){JS.add(h);const m=document.activeElement;if(!a.contains(m)){const v=new CustomEvent(um,qS);a.addEventListener(um,c),a.dispatchEvent(v),v.defaultPrevented||(qH(QH(KS(a)),{select:!0}),document.activeElement===m&&qo(a))}return()=>{a.removeEventListener(um,c),setTimeout(()=>{const v=new CustomEvent(dm,qS);a.addEventListener(dm,u),a.dispatchEvent(v),v.defaultPrevented||qo(m??document.body,{select:!0}),a.removeEventListener(dm,u),JS.remove(h)},0)}}},[a,c,u,h]);const p=b.useCallback(m=>{if(!n&&!r||h.paused)return;const y=m.key==="Tab"&&!m.altKey&&!m.ctrlKey&&!m.metaKey,v=document.activeElement;if(y&&v){const w=m.currentTarget,[E,x]=KH(w);E&&x?!m.shiftKey&&v===x?(m.preventDefault(),n&&qo(E,{select:!0})):m.shiftKey&&v===E&&(m.preventDefault(),n&&qo(x,{select:!0})):v===w&&m.preventDefault()}},[n,r,h.paused]);return g.jsx(ge.div,{tabIndex:-1,...i,ref:f,onKeyDown:p})});Ja.displayName=GH;function qH(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(qo(r,{select:e}),document.activeElement!==n)return}function KH(t){const e=KS(t),n=YS(e,t),r=YS(e.reverse(),t);return[n,r]}function KS(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 YS(t,e){for(const n of t)if(!YH(n,{upTo:e}))return n}function YH(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 JH(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&&JH(t)&&e&&t.select()}}var JS=XH();function XH(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=XS(t,e),t.unshift(e)},remove(e){t=XS(t,e),t[0]?.resume()}}}function XS(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function QH(t){return t.filter(e=>e.tagName!=="A")}var fm=0;function Nu(){b.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??QS()),document.body.insertAdjacentElement("beforeend",t[1]??QS()),fm++,()=>{fm===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),fm--}},[])}function QS(){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 Ir=function(){return Ir=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},Ir.apply(this,arguments)};function ZS(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 ZH(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))}typeof SuppressedError=="function"&&SuppressedError;var Ru="right-scroll-bar-position",Iu="width-before-scroll-bar",ez="with-scroll-bars-hidden",tz="--removed-body-scroll-bar-size";function hm(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function nz(t,e){var n=M.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 rz=typeof window<"u"?b.useLayoutEffect:b.useEffect,ek=new WeakMap;function oz(t,e){var n=nz(null,function(r){return t.forEach(function(o){return hm(o,r)})});return rz(function(){var r=ek.get(n);if(r){var o=new Set(r),s=new Set(t),i=n.current;o.forEach(function(a){s.has(a)||hm(a,null)}),s.forEach(function(a){o.has(a)||hm(a,i)})}ek.set(n,t)},[t]),n}function sz(t){return t}function iz(t,e){e===void 0&&(e=sz);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 az(t){t===void 0&&(t={});var e=iz(null);return e.options=Ir({async:!0,ssr:!1},t),e}var tk=function(t){var e=t.sideCar,n=ZS(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return b.createElement(r,Ir({},n))};tk.isSideCarExport=!0;function lz(t,e){return t.useMedium(e),tk}var nk=az(),pm=function(){},Du=b.forwardRef(function(t,e){var n=b.useRef(null),r=b.useState({onScrollCapture:pm,onWheelCapture:pm,onTouchMoveCapture:pm}),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,y=t.allowPinchZoom,v=t.as,w=v===void 0?"div":v,E=t.gapMode,x=ZS(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=f,S=oz([n,e]),C=Ir(Ir({},x),o);return b.createElement(b.Fragment,null,u&&b.createElement(k,{sideCar:nk,removeScrollBar:c,shards:d,noRelative:h,noIsolation:p,inert:m,setCallbacks:s,allowPinchZoom:!!y,lockRef:n,gapMode:E}),i?b.cloneElement(b.Children.only(a),Ir(Ir({},C),{ref:S})):b.createElement(w,Ir({},C,{className:l,ref:S}),a))});Du.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Du.classNames={fullWidth:Iu,zeroRight:Ru};var cz=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function uz(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=cz();return e&&t.setAttribute("nonce",e),t}function dz(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function fz(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var hz=function(){var t=0,e=null;return{add:function(n){t==0&&(e=uz())&&(dz(e,n),fz(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},pz=function(){var t=hz();return function(e,n){b.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},rk=function(){var t=pz(),e=function(n){var r=n.styles,o=n.dynamic;return t(r,o),null};return e},mz={left:0,top:0,right:0,gap:0},mm=function(t){return parseInt(t||"",10)||0},gz=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[mm(n),mm(r),mm(o)]},yz=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return mz;var e=gz(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])}},vz=rk(),_i="data-scroll-locked",bz=function(t,e,n,r){var o=t.left,s=t.top,i=t.right,a=t.gap;return n===void 0&&(n="margin"),`
163
- .`.concat(ez,` {
164
- overflow: hidden `).concat(r,`;
165
- padding-right: `).concat(a,"px ").concat(r,`;
166
- }
167
- body[`).concat(_i,`] {
168
- overflow: hidden `).concat(r,`;
169
- overscroll-behavior: contain;
170
- `).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&`
171
- padding-left: `.concat(o,`px;
172
- padding-top: `).concat(s,`px;
173
- padding-right: `).concat(i,`px;
174
- margin-left:0;
175
- margin-top:0;
176
- margin-right: `).concat(a,"px ").concat(r,`;
177
- `),n==="padding"&&"padding-right: ".concat(a,"px ").concat(r,";")].filter(Boolean).join(""),`
178
- }
179
-
180
- .`).concat(Ru,` {
181
- right: `).concat(a,"px ").concat(r,`;
182
- }
183
-
184
- .`).concat(Iu,` {
185
- margin-right: `).concat(a,"px ").concat(r,`;
186
- }
187
-
188
- .`).concat(Ru," .").concat(Ru,` {
189
- right: 0 `).concat(r,`;
190
- }
191
-
192
- .`).concat(Iu," .").concat(Iu,` {
193
- margin-right: 0 `).concat(r,`;
194
- }
195
-
196
- body[`).concat(_i,`] {
197
- `).concat(tz,": ").concat(a,`px;
198
- }
199
- `)},ok=function(){var t=parseInt(document.body.getAttribute(_i)||"0",10);return isFinite(t)?t:0},xz=function(){b.useEffect(function(){return document.body.setAttribute(_i,(ok()+1).toString()),function(){var t=ok()-1;t<=0?document.body.removeAttribute(_i):document.body.setAttribute(_i,t.toString())}},[])},wz=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,o=r===void 0?"margin":r;xz();var s=b.useMemo(function(){return yz(o)},[o]);return b.createElement(vz,{styles:bz(s,!e,o,n?"":"!important")})},gm=!1;if(typeof window<"u")try{var Pu=Object.defineProperty({},"passive",{get:function(){return gm=!0,!0}});window.addEventListener("test",Pu,Pu),window.removeEventListener("test",Pu,Pu)}catch{gm=!1}var Ni=gm?{passive:!1}:!1,Ez=function(t){return t.tagName==="TEXTAREA"},sk=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!Ez(t)&&n[e]==="visible")},Sz=function(t){return sk(t,"overflowY")},kz=function(t){return sk(t,"overflowX")},ik=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var o=ak(t,r);if(o){var s=lk(t,r),i=s[1],a=s[2];if(i>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},Cz=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},Tz=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},ak=function(t,e){return t==="v"?Sz(e):kz(e)},lk=function(t,e){return t==="v"?Cz(e):Tz(e)},Az=function(t,e){return t==="h"&&e==="rtl"?-1:1},Mz=function(t,e,n,r,o){var s=Az(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=lk(t,a),p=h[0],m=h[1],y=h[2],v=m-y-s*p;(p||v)&&ak(t,a)&&(d+=v,f+=p);var w=a.parentNode;a=w&&w.nodeType===Node.DOCUMENT_FRAGMENT_NODE?w.host:w}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},Lu=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},ck=function(t){return[t.deltaX,t.deltaY]},uk=function(t){return t&&"current"in t?t.current:t},Oz=function(t,e){return t[0]===e[0]&&t[1]===e[1]},_z=function(t){return`
200
- .block-interactivity-`.concat(t,` {pointer-events: none;}
201
- .allow-interactivity-`).concat(t,` {pointer-events: all;}
202
- `)},Nz=0,Ri=[];function Rz(t){var e=b.useRef([]),n=b.useRef([0,0]),r=b.useRef(),o=b.useState(Nz++)[0],s=b.useState(rk)[0],i=b.useRef(t);b.useEffect(function(){i.current=t},[t]),b.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(o));var m=ZH([t.lockRef.current],(t.shards||[]).map(uk),!0).filter(Boolean);return m.forEach(function(y){return y.classList.add("allow-interactivity-".concat(o))}),function(){document.body.classList.remove("block-interactivity-".concat(o)),m.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(o))})}}},[t.inert,t.lockRef.current,t.shards]);var a=b.useCallback(function(m,y){if("touches"in m&&m.touches.length===2||m.type==="wheel"&&m.ctrlKey)return!i.current.allowPinchZoom;var v=Lu(m),w=n.current,E="deltaX"in m?m.deltaX:w[0]-v[0],x="deltaY"in m?m.deltaY:w[1]-v[1],k,S=m.target,C=Math.abs(E)>Math.abs(x)?"h":"v";if("touches"in m&&C==="h"&&S.type==="range")return!1;var T=ik(C,S);if(!T)return!0;if(T?k=C:(k=C==="v"?"h":"v",T=ik(C,S)),!T)return!1;if(!r.current&&"changedTouches"in m&&(E||x)&&(r.current=k),!k)return!0;var N=r.current||k;return Mz(N,y,m,N==="h"?E:x)},[]),l=b.useCallback(function(m){var y=m;if(!(!Ri.length||Ri[Ri.length-1]!==s)){var v="deltaY"in y?ck(y):Lu(y),w=e.current.filter(function(k){return k.name===y.type&&(k.target===y.target||y.target===k.shadowParent)&&Oz(k.delta,v)})[0];if(w&&w.should){y.cancelable&&y.preventDefault();return}if(!w){var E=(i.current.shards||[]).map(uk).filter(Boolean).filter(function(k){return k.contains(y.target)}),x=E.length>0?a(y,E[0]):!i.current.noIsolation;x&&y.cancelable&&y.preventDefault()}}},[]),c=b.useCallback(function(m,y,v,w){var E={name:m,delta:y,target:v,should:w,shadowParent:Iz(v)};e.current.push(E),setTimeout(function(){e.current=e.current.filter(function(x){return x!==E})},1)},[]),u=b.useCallback(function(m){n.current=Lu(m),r.current=void 0},[]),d=b.useCallback(function(m){c(m.type,ck(m),m.target,a(m,t.lockRef.current))},[]),f=b.useCallback(function(m){c(m.type,Lu(m),m.target,a(m,t.lockRef.current))},[]);b.useEffect(function(){return Ri.push(s),t.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,Ni),document.addEventListener("touchmove",l,Ni),document.addEventListener("touchstart",u,Ni),function(){Ri=Ri.filter(function(m){return m!==s}),document.removeEventListener("wheel",l,Ni),document.removeEventListener("touchmove",l,Ni),document.removeEventListener("touchstart",u,Ni)}},[]);var h=t.removeScrollBar,p=t.inert;return b.createElement(b.Fragment,null,p?b.createElement(s,{styles:_z(o)}):null,h?b.createElement(wz,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function Iz(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const Dz=lz(nk,Rz);var Xa=b.forwardRef(function(t,e){return b.createElement(Du,Ir({},t,{ref:e,sideCar:Dz}))});Xa.classNames=Du.classNames;var Pz=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Ii=new WeakMap,ju=new WeakMap,$u={},ym=0,dk=function(t){return t&&(t.host||dk(t.parentNode))},Lz=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=dk(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},jz=function(t,e,n,r){var o=Lz(e,Array.isArray(t)?t:[t]);$u[n]||($u[n]=new WeakMap);var s=$u[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=(Ii.get(f)||0)+1,y=(s.get(f)||0)+1;Ii.set(f,m),s.set(f,y),i.push(f),m===1&&p&&ju.set(f,!0),y===1&&f.setAttribute(n,"true"),p||f.setAttribute(r,"true")}catch(v){console.error("aria-hidden: cannot operate on ",f,v)}})};return u(e),a.clear(),ym++,function(){i.forEach(function(d){var f=Ii.get(d)-1,h=s.get(d)-1;Ii.set(d,f),s.set(d,h),f||(ju.has(d)||d.removeAttribute(r),ju.delete(d)),h||d.removeAttribute(n)}),ym--,ym||(Ii=new WeakMap,Ii=new WeakMap,ju=new WeakMap,$u={})}},Bu=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),o=Pz(t);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),jz(r,o,n,"aria-hidden")):function(){return null}},Fu="Dialog",[fk]=On(Fu),[$z,cr]=fk(Fu),hk=t=>{const{__scopeDialog:e,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!0}=t,a=b.useRef(null),l=b.useRef(null),[c,u]=Jr({prop:r,defaultProp:o??!1,onChange:s,caller:Fu});return g.jsx($z,{scope:e,triggerRef:a,contentRef:l,contentId:Bn(),titleId:Bn(),descriptionId:Bn(),open:c,onOpenChange:u,onOpenToggle:b.useCallback(()=>u(d=>!d),[u]),modal:i,children:n})};hk.displayName=Fu;var pk="DialogTrigger",mk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=cr(pk,n),s=$e(e,o.triggerRef);return g.jsx(ge.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":xm(o.open),...r,ref:s,onClick:te(t.onClick,o.onOpenToggle)})});mk.displayName=pk;var vm="DialogPortal",[Bz,gk]=fk(vm,{forceMount:void 0}),yk=t=>{const{__scopeDialog:e,forceMount:n,children:r,container:o}=t,s=cr(vm,e);return g.jsx(Bz,{scope:e,forceMount:n,children:b.Children.map(r,i=>g.jsx(_n,{present:n||s.open,children:g.jsx(Mi,{asChild:!0,container:o,children:i})}))})};yk.displayName=vm;var Hu="DialogOverlay",vk=b.forwardRef((t,e)=>{const n=gk(Hu,t.__scopeDialog),{forceMount:r=n.forceMount,...o}=t,s=cr(Hu,t.__scopeDialog);return s.modal?g.jsx(_n,{present:r||s.open,children:g.jsx(Hz,{...o,ref:e})}):null});vk.displayName=Hu;var Fz=Mo("DialogOverlay.RemoveScroll"),Hz=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=cr(Hu,n);return g.jsx(Xa,{as:Fz,allowPinchZoom:!0,shards:[o.contentRef],children:g.jsx(ge.div,{"data-state":xm(o.open),...r,ref:e,style:{pointerEvents:"auto",...r.style}})})}),Is="DialogContent",bk=b.forwardRef((t,e)=>{const n=gk(Is,t.__scopeDialog),{forceMount:r=n.forceMount,...o}=t,s=cr(Is,t.__scopeDialog);return g.jsx(_n,{present:r||s.open,children:s.modal?g.jsx(zz,{...o,ref:e}):g.jsx(Uz,{...o,ref:e})})});bk.displayName=Is;var zz=b.forwardRef((t,e)=>{const n=cr(Is,t.__scopeDialog),r=b.useRef(null),o=$e(e,n.contentRef,r);return b.useEffect(()=>{const s=r.current;if(s)return Bu(s)},[]),g.jsx(xk,{...t,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:te(t.onCloseAutoFocus,s=>{s.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:te(t.onPointerDownOutside,s=>{const i=s.detail.originalEvent,a=i.button===0&&i.ctrlKey===!0;(i.button===2||a)&&s.preventDefault()}),onFocusOutside:te(t.onFocusOutside,s=>s.preventDefault())})}),Uz=b.forwardRef((t,e)=>{const n=cr(Is,t.__scopeDialog),r=b.useRef(!1),o=b.useRef(!1);return g.jsx(xk,{...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()}})}),xk=b.forwardRef((t,e)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:o,onCloseAutoFocus:s,...i}=t,a=cr(Is,n),l=b.useRef(null),c=$e(e,l);return Nu(),g.jsxs(g.Fragment,{children:[g.jsx(Ja,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:g.jsx(Si,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":xm(a.open),...i,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),g.jsxs(g.Fragment,{children:[g.jsx(Vz,{titleId:a.titleId}),g.jsx(Gz,{contentRef:l,descriptionId:a.descriptionId})]})]})}),bm="DialogTitle",wk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=cr(bm,n);return g.jsx(ge.h2,{id:o.titleId,...r,ref:e})});wk.displayName=bm;var Ek="DialogDescription",Sk=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=cr(Ek,n);return g.jsx(ge.p,{id:o.descriptionId,...r,ref:e})});Sk.displayName=Ek;var kk="DialogClose",Ck=b.forwardRef((t,e)=>{const{__scopeDialog:n,...r}=t,o=cr(kk,n);return g.jsx(ge.button,{type:"button",...r,ref:e,onClick:te(t.onClick,()=>o.onOpenChange(!1))})});Ck.displayName=kk;function xm(t){return t?"open":"closed"}var Tk="DialogTitleWarning",[yee,Ak]=iD(Tk,{contentName:Is,titleName:bm,docsSlug:"dialog"}),Vz=({titleId:t})=>{const e=Ak(Tk),n=`\`${e.contentName}\` requires a \`${e.titleName}\` for the component to be accessible for screen reader users.
203
-
204
- If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
205
-
206
- For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return b.useEffect(()=>{t&&(document.getElementById(t)||console.error(n))},[n,t]),null},Wz="DialogDescriptionWarning",Gz=({contentRef:t,descriptionId:e})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ak(Wz).contentName}}.`;return b.useEffect(()=>{const o=t.current?.getAttribute("aria-describedby");e&&o&&(document.getElementById(e)||console.warn(r))},[r,t,e]),null},qz=hk,Kz=mk,Yz=yk,Jz=vk,Xz=bk,Qz=wk,Zz=Sk,Mk=Ck;/**
207
- * @license lucide-react v0.544.0 - ISC
208
- *
209
- * This source code is licensed under the ISC license.
210
- * See the LICENSE file in the root directory of this source tree.
211
- */const eU=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),tU=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Ok=t=>{const e=tU(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(),nU=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};/**
212
- * @license lucide-react v0.544.0 - ISC
213
- *
214
- * This source code is licensed under the ISC license.
215
- * See the LICENSE file in the root directory of this source tree.
216
- */var rU={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"};/**
217
- * @license lucide-react v0.544.0 - ISC
218
- *
219
- * This source code is licensed under the ISC license.
220
- * See the LICENSE file in the root directory of this source tree.
221
- */const oU=M.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:o="",children:s,iconNode:i,...a},l)=>M.createElement("svg",{ref:l,...rU,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_k("lucide",o),...!s&&!nU(a)&&{"aria-hidden":"true"},...a},[...i.map(([c,u])=>M.createElement(c,u)),...Array.isArray(s)?s:[s]]));/**
222
- * @license lucide-react v0.544.0 - ISC
223
- *
224
- * This source code is licensed under the ISC license.
225
- * See the LICENSE file in the root directory of this source tree.
226
- */const Ae=(t,e)=>{const n=M.forwardRef(({className:r,...o},s)=>M.createElement(oU,{ref:s,iconNode:e,className:_k(`lucide-${eU(Ok(t))}`,`lucide-${t}`,r),...o}));return n.displayName=Ok(t),n};/**
227
- * @license lucide-react v0.544.0 - ISC
228
- *
229
- * This source code is licensed under the ISC license.
230
- * See the LICENSE file in the root directory of this source tree.
231
- */const sU=Ae("bold",[["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"}]]);/**
232
- * @license lucide-react v0.544.0 - ISC
233
- *
234
- * This source code is licensed under the ISC license.
235
- * See the LICENSE file in the root directory of this source tree.
236
- */const Nk=Ae("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
237
- * @license lucide-react v0.544.0 - ISC
238
- *
239
- * This source code is licensed under the ISC license.
240
- * See the LICENSE file in the root directory of this source tree.
241
- */const Rk=Ae("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
242
- * @license lucide-react v0.544.0 - ISC
243
- *
244
- * This source code is licensed under the ISC license.
245
- * See the LICENSE file in the root directory of this source tree.
246
- */const iU=Ae("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
247
- * @license lucide-react v0.544.0 - ISC
248
- *
249
- * This source code is licensed under the ISC license.
250
- * See the LICENSE file in the root directory of this source tree.
251
- */const aU=Ae("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);/**
252
- * @license lucide-react v0.544.0 - ISC
253
- *
254
- * This source code is licensed under the ISC license.
255
- * See the LICENSE file in the root directory of this source tree.
256
- */const lU=Ae("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
257
- * @license lucide-react v0.544.0 - ISC
258
- *
259
- * This source code is licensed under the ISC license.
260
- * See the LICENSE file in the root directory of this source tree.
261
- */const Ik=Ae("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);/**
262
- * @license lucide-react v0.544.0 - ISC
263
- *
264
- * This source code is licensed under the ISC license.
265
- * See the LICENSE file in the root directory of this source tree.
266
- */const cU=Ae("ellipsis",[["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"}]]);/**
267
- * @license lucide-react v0.544.0 - ISC
268
- *
269
- * This source code is licensed under the ISC license.
270
- * See the LICENSE file in the root directory of this source tree.
271
- */const Qa=Ae("external-link",[["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"}]]);/**
272
- * @license lucide-react v0.544.0 - ISC
273
- *
274
- * This source code is licensed under the ISC license.
275
- * See the LICENSE file in the root directory of this source tree.
276
- */const Dk=Ae("file-code-2",[["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"}]]);/**
277
- * @license lucide-react v0.544.0 - ISC
278
- *
279
- * This source code is licensed under the ISC license.
280
- * See the LICENSE file in the root directory of this source tree.
281
- */const Pk=Ae("forward",[["path",{d:"m15 17 5-5-5-5",key:"nf172w"}],["path",{d:"M4 18v-2a4 4 0 0 1 4-4h12",key:"jmiej9"}]]);/**
282
- * @license lucide-react v0.544.0 - ISC
283
- *
284
- * This source code is licensed under the ISC license.
285
- * See the LICENSE file in the root directory of this source tree.
286
- */const uU=Ae("grip-vertical",[["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"}]]);/**
287
- * @license lucide-react v0.544.0 - ISC
288
- *
289
- * This source code is licensed under the ISC license.
290
- * See the LICENSE file in the root directory of this source tree.
291
- */const Lk=Ae("heading-1",[["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"}]]);/**
292
- * @license lucide-react v0.544.0 - ISC
293
- *
294
- * This source code is licensed under the ISC license.
295
- * See the LICENSE file in the root directory of this source tree.
296
- */const jk=Ae("heading-2",[["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"}]]);/**
297
- * @license lucide-react v0.544.0 - ISC
298
- *
299
- * This source code is licensed under the ISC license.
300
- * See the LICENSE file in the root directory of this source tree.
301
- */const $k=Ae("heading-3",[["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"}]]);/**
302
- * @license lucide-react v0.544.0 - ISC
303
- *
304
- * This source code is licensed under the ISC license.
305
- * See the LICENSE file in the root directory of this source tree.
306
- */const Bk=Ae("heading-4",[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]]);/**
307
- * @license lucide-react v0.544.0 - ISC
308
- *
309
- * This source code is licensed under the ISC license.
310
- * See the LICENSE file in the root directory of this source tree.
311
- */const Fk=Ae("heading-5",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]]);/**
312
- * @license lucide-react v0.544.0 - ISC
313
- *
314
- * This source code is licensed under the ISC license.
315
- * See the LICENSE file in the root directory of this source tree.
316
- */const Hk=Ae("heading-6",[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]]);/**
317
- * @license lucide-react v0.544.0 - ISC
318
- *
319
- * This source code is licensed under the ISC license.
320
- * See the LICENSE file in the root directory of this source tree.
321
- */const dU=Ae("image-play",[["path",{d:"M15 15.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997a1 1 0 0 1-1.517-.86z",key:"nrt1m3"}],["path",{d:"M21 12.17V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6",key:"99hgts"}],["path",{d:"m6 21 5-5",key:"1wyjai"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);/**
322
- * @license lucide-react v0.544.0 - ISC
323
- *
324
- * This source code is licensed under the ISC license.
325
- * See the LICENSE file in the root directory of this source tree.
326
- */const zk=Ae("image-plus",[["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"}]]);/**
327
- * @license lucide-react v0.544.0 - ISC
328
- *
329
- * This source code is licensed under the ISC license.
330
- * See the LICENSE file in the root directory of this source tree.
331
- */const wm=Ae("image",[["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"}]]);/**
332
- * @license lucide-react v0.544.0 - ISC
333
- *
334
- * This source code is licensed under the ISC license.
335
- * See the LICENSE file in the root directory of this source tree.
336
- */const Uk=Ae("italic",[["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"}]]);/**
337
- * @license lucide-react v0.544.0 - ISC
338
- *
339
- * This source code is licensed under the ISC license.
340
- * See the LICENSE file in the root directory of this source tree.
341
- */const Em=Ae("link",[["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"}]]);/**
342
- * @license lucide-react v0.544.0 - ISC
343
- *
344
- * This source code is licensed under the ISC license.
345
- * See the LICENSE file in the root directory of this source tree.
346
- */const fU=Ae("list-ordered",[["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"}]]);/**
347
- * @license lucide-react v0.544.0 - ISC
348
- *
349
- * This source code is licensed under the ISC license.
350
- * See the LICENSE file in the root directory of this source tree.
351
- */const hU=Ae("list",[["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"}]]);/**
352
- * @license lucide-react v0.544.0 - ISC
353
- *
354
- * This source code is licensed under the ISC license.
355
- * See the LICENSE file in the root directory of this source tree.
356
- */const pU=Ae("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
357
- * @license lucide-react v0.544.0 - ISC
358
- *
359
- * This source code is licensed under the ISC license.
360
- * See the LICENSE file in the root directory of this source tree.
361
- */const zu=Ae("music",[["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"}]]);/**
362
- * @license lucide-react v0.544.0 - ISC
363
- *
364
- * This source code is licensed under the ISC license.
365
- * See the LICENSE file in the root directory of this source tree.
366
- */const mU=Ae("redo",[["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"}]]);/**
367
- * @license lucide-react v0.544.0 - ISC
368
- *
369
- * This source code is licensed under the ISC license.
370
- * See the LICENSE file in the root directory of this source tree.
371
- */const Vk=Ae("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);/**
372
- * @license lucide-react v0.544.0 - ISC
373
- *
374
- * This source code is licensed under the ISC license.
375
- * See the LICENSE file in the root directory of this source tree.
376
- */const gU=Ae("send-horizontal",[["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"}]]);/**
377
- * @license lucide-react v0.544.0 - ISC
378
- *
379
- * This source code is licensed under the ISC license.
380
- * See the LICENSE file in the root directory of this source tree.
381
- */const yU=Ae("square-pen",[["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"}]]);/**
382
- * @license lucide-react v0.544.0 - ISC
383
- *
384
- * This source code is licensed under the ISC license.
385
- * See the LICENSE file in the root directory of this source tree.
386
- */const Wk=Ae("strikethrough",[["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"}]]);/**
387
- * @license lucide-react v0.544.0 - ISC
388
- *
389
- * This source code is licensed under the ISC license.
390
- * See the LICENSE file in the root directory of this source tree.
391
- */const Sm=Ae("text-align-center",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]]);/**
392
- * @license lucide-react v0.544.0 - ISC
393
- *
394
- * This source code is licensed under the ISC license.
395
- * See the LICENSE file in the root directory of this source tree.
396
- */const km=Ae("text-align-end",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]]);/**
397
- * @license lucide-react v0.544.0 - ISC
398
- *
399
- * This source code is licensed under the ISC license.
400
- * See the LICENSE file in the root directory of this source tree.
401
- */const Uu=Ae("text-align-start",[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]]);/**
402
- * @license lucide-react v0.544.0 - ISC
403
- *
404
- * This source code is licensed under the ISC license.
405
- * See the LICENSE file in the root directory of this source tree.
406
- */const Cm=Ae("trash-2",[["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"}]]);/**
407
- * @license lucide-react v0.544.0 - ISC
408
- *
409
- * This source code is licensed under the ISC license.
410
- * See the LICENSE file in the root directory of this source tree.
411
- */const Tm=Ae("type",[["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"}]]);/**
412
- * @license lucide-react v0.544.0 - ISC
413
- *
414
- * This source code is licensed under the ISC license.
415
- * See the LICENSE file in the root directory of this source tree.
416
- */const vU=Ae("underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);/**
417
- * @license lucide-react v0.544.0 - ISC
418
- *
419
- * This source code is licensed under the ISC license.
420
- * See the LICENSE file in the root directory of this source tree.
421
- */const bU=Ae("undo",[["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"}]]);/**
422
- * @license lucide-react v0.544.0 - ISC
423
- *
424
- * This source code is licensed under the ISC license.
425
- * See the LICENSE file in the root directory of this source tree.
426
- */const xU=Ae("unlink",[["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"}]]);/**
427
- * @license lucide-react v0.544.0 - ISC
428
- *
429
- * This source code is licensed under the ISC license.
430
- * See the LICENSE file in the root directory of this source tree.
431
- */const Am=Ae("video",[["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"}]]);/**
432
- * @license lucide-react v0.544.0 - ISC
433
- *
434
- * This source code is licensed under the ISC license.
435
- * See the LICENSE file in the root directory of this source tree.
436
- */const Di=Ae("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function Mm({...t}){return g.jsx(qz,{"data-slot":"dialog",...t})}const Gk=b.forwardRef((t,e)=>g.jsx(Kz,{ref:e,"data-slot":"dialog-trigger",...t}));function wU({...t}){return g.jsx(Yz,{"data-slot":"dialog-portal",...t})}const EU=b.forwardRef((t,e)=>g.jsx(Mk,{ref:e,"data-slot":"dialog-close",...t})),SU=b.forwardRef(({className:t,...e},n)=>g.jsx(Jz,{ref:n,"data-slot":"dialog-overlay",className:re("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})),Om=b.forwardRef(({className:t,children:e,showCloseButton:n=!0,...r},o)=>g.jsxs(wU,{children:[g.jsx("div",{"data-theme":"select-post-builder",children:g.jsx(SU,{className:"backdrop-blur-sm"})}),g.jsx("div",{"data-theme":"select-post-builder",children:g.jsxs(Xz,{ref:o,"data-slot":"dialog-content","data-theme":"select-post-builder",className:re("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-50 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&&g.jsxs(Mk,{"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:[g.jsx(Di,{}),g.jsx("span",{className:"sr-only",children:"Close"})]})]})})]})),_m=b.forwardRef(({className:t,...e},n)=>g.jsx("div",{ref:n,"data-slot":"dialog-header",className:re("flex flex-col gap-2 text-center sm:text-left",t),...e})),kU=b.forwardRef(({className:t,...e},n)=>g.jsx("div",{ref:n,"data-slot":"dialog-footer",className:re("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",t),...e})),Nm=b.forwardRef((t,e)=>g.jsx(Qz,{ref:e,"data-slot":"dialog-title",className:re("text-lg leading-none font-semibold"),...t}));b.forwardRef(({className:t,...e},n)=>g.jsx(Zz,{ref:n,"data-slot":"dialog-description",className:re("text-muted-foreground text-sm",t),...e}));var CU="Label",qk=b.forwardRef((t,e)=>g.jsx(ge.label,{...t,ref:e,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(t.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));qk.displayName=CU;var TU=qk;function Rm({className:t,...e}){return g.jsx(TU,{"data-slot":"label",className:re("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})}function AU({className:t,...e}){return g.jsx("fieldset",{"data-slot":"field-set",className:re("flex flex-col gap-6","has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",t),...e})}function MU({className:t,...e}){return g.jsx("div",{"data-slot":"field-group",className:re("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 OU=Wp("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 Kk({className:t,orientation:e="vertical",...n}){return g.jsx("div",{role:"group","data-slot":"field","data-orientation":e,className:re(OU({orientation:e}),t),...n})}function Yk({className:t,...e}){return g.jsx(Rm,{"data-slot":"field-label",className:re("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 _U({className:t,children:e,errors:n,...r}){const o=M.useMemo(()=>e||(n?n?.length===1&&n[0]?.message?n[0].message:g.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:n.map((s,i)=>s?.message&&g.jsx("li",{children:s.message},i))}):null),[e,n]);return o?g.jsx("div",{role:"alert","data-slot":"field-error",className:re("text-destructive text-sm font-normal",t),...r,children:o}):null}function Im({className:t,type:e,...n}){return g.jsx("input",{type:e,"data-slot":"input",className:re("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})}function Jk({className:t,...e}){return g.jsx("div",{"data-slot":"input-group",role:"group",className:re("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})}const NU=Wp("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"}});function Xk({className:t,align:e="inline-start",...n}){return g.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":e,className:re(NU({align:e}),t),onClick:r=>{r.target.closest("button")||r.currentTarget.parentElement?.querySelector("input")?.focus()},...n})}function Qk({className:t,...e}){return g.jsx(Im,{"data-slot":"input-group-control",className:re("flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent",t),...e})}const Vu=M.forwardRef(({className:t,...e},n)=>g.jsx(pU,{role:"status","aria-label":"Loading",className:re("h-4 w-4 animate-spin",t),ref:n,...e}));Vu.displayName="Spinner";const RU=/^(?:(?:(?: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,Zk=/^(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)[\w-]+/gi,IU=/(?:v=|\/)([a-zA-Z0-9_-]{11})(?:[?&].*)?$/,e1=/^(?:https?:\/\/)?(?:www\.)?open\.spotify\.com\/(track|playlist|album)\/[A-Za-z0-9_-]+/gi,DU=/[\n\r]/g,t1=(t,e,n)=>t.schema.text(e,n),n1=(t,e,n,r)=>t?.schema?.nodes[e]?.create(n,r),PU=(t,e,n,r)=>n1(t,"customLink",{href:e},t1(t,n||e,r)),LU=(t,e,n)=>n1(t,"paragraph",n,e),jU=t=>{const{from:e,to:n}=t.selection;return{from:e,to:n}},r1=t=>{const{from:e,to:n}=jU(t);return t.doc.textBetween(e,n)},$U=t=>!t.selection.empty&&r1(t).length>0,BU=t=>t.type.name,o1=(t,e)=>BU(t)===e,FU=t=>o1(t,"text"),HU=t=>o1(t,"paragraph"),s1=t=>t.text||"",i1=t=>t.content&&t.content.size>0,zU=t=>t.content,UU=t=>t.marks,VU=t=>t.state,a1=t=>F.from(t),l1=(t,e)=>{t.forEach(e)},WU=(t,e=" ")=>t.textBetween(0,t.size,e),GU=(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},Za=t=>t?.startsWith("http://")||t?.startsWith("https://")?t:`https://${t}`,Ds=t=>RU.test(t),qU=async t=>{try{return(await ft.head(t,{timeout:5e3})).headers["content-type"]}catch{return null}},KU=async t=>{try{const n=await qU(t);if(n?.startsWith("image/"))return{type:be.Image,src:t};if(n?.startsWith("video/"))return{type:be.Video,src:t};if(n?.startsWith("audio/"))return{type:be.Audio,src:t}}catch(n){console.warn("HEAD request failed, falling back to mime detection:",n)}const e=t.split(".").pop()?.toLowerCase();if(e){if(["jpg","jpeg","png","gif","webp","avif"].includes(e))return{type:be.Image,src:t};if(["mp4","webm","mov","mkv"].includes(e))return{type:be.Video,src:t};if(["mp3","wav","ogg","aac"].includes(e))return{type:be.Audio,src:t}}return null},YU=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},JU=(t,e)=>{const n=s1(e),r=UU(e),o=YU(n);return o.length===0?[e]:o.map(s=>s.type==="url"?PU(t,s.content,s.content,r):t1(t,s.content,r))},XU=(t,e)=>{if(!i1(e))return e;const n=[],r=zU(e);return l1(r,o=>{if(FU(o)&&s1(o)){const s=JU(t,o);n.push(...s)}else n.push(o)}),LU(t,a1(n),e.attrs)},QU=(t,e)=>{const n=[];return l1(e.content,r=>{HU(r)&&i1(r)?n.push(XU(t,r)):n.push(r)}),new Q(a1(n),e.openStart,e.openEnd)},Dm=({defaultValues:t,open:e,onOpenChange:n,onInsertLink:r,hideTextInput:o=!1,children:s})=>{const{editor:i}=mu(),{core:a}=ga(),[l,c]=M.useState(t?.uid??null),[u,d]=M.useState(t?.link??""),[f,h]=M.useState(t?.text??""),[p,m]=M.useState(void 0),[y,v]=M.useState(!1),[w,E]=M.useState(!1),x=_=>{if(n?.(_),!_||!i)return;const L=GU(i?.state,"customLink"),$=Za(L?.href??"");m(Ds($)),v(Ds($)),c(L?.uid??null),d(L?.href??""),h(L?.text??L?.href??"")},k=_=>{const L=_.target.value;if(L==="https:/")return;const $=Za(L);m(Ds($)),d($)},S=_=>h(_.target.value),C=()=>{const _=Ds(u);m(_),_&&(o||(E(!0),a?.resolveUrl(u)?.catch(L=>console.log(L))?.finally(()=>E(!1))))},T=(_,L,$)=>{if(o){E(!0),a?.resolveUrl(_)?.catch(B=>console.log(B))?.finally(()=>{E(!1),r(_,L,$),n?.(!1)});return}r(_,L,$),n?.(!1)},N=_=>{_.key==="Enter"&&n?.(!1)};return M.useEffect(()=>{if(console.log({defaultValues:t}),!t?.link)return;const _=Ds(t?.link);m(_),v(_),c(t?.uid??null),d(t?.link??""),h(t?.text??"")},[t]),g.jsxs(Mm,{open:e,onOpenChange:x,children:[s?g.jsx(Gk,{asChild:!0,children:s}):null,g.jsxs(Om,{onKeyDown:N,className:"-translate-1/2",children:[g.jsx(_m,{children:g.jsx(Nm,{children:"Add Link"})}),g.jsx(AU,{children:g.jsxs(MU,{className:"gap-3",children:[g.jsxs(Kk,{className:"gap-1.5",children:[g.jsxs(Yk,{children:["Link ",g.jsx("span",{className:"text-destructive",children:"*"})]}),g.jsxs(Jk,{children:[g.jsx(Qk,{value:u,onChange:k,onBlur:C,placeholder:"https://x.com/shadcn"}),g.jsx(Xk,{children:g.jsx(Em,{})})]}),!p&&p!==void 0&&g.jsx(_U,{errors:[{message:"Invalid link"}]})]}),!o&&g.jsxs(Kk,{className:"gap-1.5",children:[g.jsx(Yk,{children:"Text to display"}),g.jsxs(Jk,{children:[g.jsx(Qk,{value:f,onChange:S,placeholder:"Text to display"}),g.jsx(Xk,{children:g.jsx(Uu,{})})]})]})]})}),g.jsxs(kU,{children:[g.jsx(Rn,{variant:"secondary",children:"Cancel"}),g.jsxs(Rn,{disabled:!p||w,onClick:()=>T(u,f,l??void 0),children:[w&&g.jsx(Vu,{}),y?"Update":"Insert"]})]})]})]})};function ZU({className:t,...e}){return g.jsx("div",{"data-slot":"card",className:re("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",t),...e})}/*! *****************************************************************************
437
- Copyright (c) Microsoft Corporation. All rights reserved.
438
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
439
- this file except in compliance with the License. You may obtain a copy of the
440
- License at http://www.apache.org/licenses/LICENSE-2.0
441
-
442
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
443
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
444
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
445
- MERCHANTABLITY OR NON-INFRINGEMENT.
446
-
447
- See the Apache Version 2.0 License for specific language governing permissions
448
- and limitations under the License.
449
- ***************************************************************************** */var Pm=function(t,e){return Pm=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])},Pm(t,e)};function eV(t,e){Pm(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var el=function(){return el=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},el.apply(this,arguments)};function tV(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 Pi={Pixel:"Pixel",Percent:"Percent"},c1={unit:Pi.Percent,value:.8};function u1(t){return typeof t=="number"?{unit:Pi.Percent,value:t*100}:typeof t=="string"?t.match(/^(\d*(\.\d+)?)px$/)?{unit:Pi.Pixel,value:parseFloat(t)}:t.match(/^(\d*(\.\d+)?)%$/)?{unit:Pi.Percent,value:parseFloat(t)}:(console.warn('scrollThreshold format is invalid. Valid formats: "120px", "50%"...'),c1):(console.warn("scrollThreshold should be string or number"),c1)}var nV=(function(t){eV(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&&console.warn(`You are trying to pass scrollableTarget but it is null. This might
450
- happen because the element may not have been added to DOM yet.
451
- See https://github.com/ankeetmaini/react-infinite-scroll-component/issues/59 for more info.
452
- `),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=tV(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.
453
- Pull Down To Refresh functionality will not work
454
- 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?el(el({},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=u1(r);return s.unit===Pi.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=u1(r);return s.unit===Pi.Pixel?n.scrollTop+o>=n.scrollHeight-s.value:n.scrollTop+o>=s.value/100*n.scrollHeight},e.prototype.render=function(){var n=this,r=el({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 M.createElement("div",{style:s,className:"infinite-scroll-component__outerdiv"},M.createElement("div",{className:"infinite-scroll-component "+(this.props.className||""),ref:function(i){return n._infScroll=i},style:r},this.props.pullDownToRefresh&&M.createElement("div",{style:{position:"relative"},ref:function(i){return n._pullDown=i}},M.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})(M.Component);function rV(t=20){const[e,n]=M.useState({offset:0,limit:t,hasMore:!0,isLoading:!1}),r=M.useCallback(()=>{n({offset:0,limit:t,hasMore:!0,isLoading:!1})},[t]),o=M.useCallback(()=>{n(a=>({...a,offset:a.offset+a.limit}))},[]),s=M.useCallback(a=>{n(l=>({...l,isLoading:a}))},[]),i=M.useCallback(a=>{n(l=>({...l,hasMore:a}))},[]);return{...e,reset:r,loadMore:o,setLoading:s,setHasMore:i}}function d1(t){const{core:e}=ga(),[n,r]=M.useState([]),[o,s]=M.useState(""),i=rV(),a=M.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(y=>p?m:[...y,...m])}catch(m){console.error("Error fetching images:",m),i.setHasMore(!1)}finally{i.setLoading(!1)}},[e,i]),l=M.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(y=>p?m:[...y,...m])}catch(m){console.error("Error fetching gifs:",m),i.setHasMore(!1)}finally{i.setLoading(!1)}},[e,i]),c=M.useCallback(d=>t==="images"?a(d):l(d),[t,a,l]),u=M.useCallback(()=>{r([]),s(""),i.reset()},[i]);return{items:n,...i,searchQuery:o,setSearchQuery:s,fetch:c,reset:u}}var f1=typeof global=="object"&&global&&global.Object===Object&&global,oV=typeof self=="object"&&self&&self.Object===Object&&self,ur=f1||oV||Function("return this")(),Vn=ur.Symbol,h1=Object.prototype,sV=h1.hasOwnProperty,iV=h1.toString,tl=Vn?Vn.toStringTag:void 0;function aV(t){var e=sV.call(t,tl),n=t[tl];try{t[tl]=void 0;var r=!0}catch{}var o=iV.call(t);return r&&(e?t[tl]=n:delete t[tl]),o}var lV=Object.prototype,cV=lV.toString;function uV(t){return cV.call(t)}var dV="[object Null]",fV="[object Undefined]",p1=Vn?Vn.toStringTag:void 0;function Ps(t){return t==null?t===void 0?fV:dV:p1&&p1 in Object(t)?aV(t):uV(t)}function lo(t){return t!=null&&typeof t=="object"}var hV="[object Symbol]";function Wu(t){return typeof t=="symbol"||lo(t)&&Ps(t)==hV}function Lm(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 dr=Array.isArray,m1=Vn?Vn.prototype:void 0,g1=m1?m1.toString:void 0;function y1(t){if(typeof t=="string")return t;if(dr(t))return Lm(t,y1)+"";if(Wu(t))return g1?g1.call(t):"";var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}var pV=/\s/;function mV(t){for(var e=t.length;e--&&pV.test(t.charAt(e)););return e}var gV=/^\s+/;function yV(t){return t&&t.slice(0,mV(t)+1).replace(gV,"")}function Dr(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var v1=NaN,vV=/^[-+]0x[0-9a-f]+$/i,bV=/^0b[01]+$/i,xV=/^0o[0-7]+$/i,wV=parseInt;function b1(t){if(typeof t=="number")return t;if(Wu(t))return v1;if(Dr(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=Dr(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=yV(t);var n=bV.test(t);return n||xV.test(t)?wV(t.slice(2),n?2:8):vV.test(t)?v1:+t}function x1(t){return t}var EV="[object AsyncFunction]",SV="[object Function]",kV="[object GeneratorFunction]",CV="[object Proxy]";function w1(t){if(!Dr(t))return!1;var e=Ps(t);return e==SV||e==kV||e==EV||e==CV}var jm=ur["__core-js_shared__"],E1=(function(){var t=/[^.]+$/.exec(jm&&jm.keys&&jm.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function TV(t){return!!E1&&E1 in t}var AV=Function.prototype,MV=AV.toString;function Ls(t){if(t!=null){try{return MV.call(t)}catch{}try{return t+""}catch{}}return""}var OV=/[\\^$.*+?()[\]{}|]/g,_V=/^\[object .+?Constructor\]$/,NV=Function.prototype,RV=Object.prototype,IV=NV.toString,DV=RV.hasOwnProperty,PV=RegExp("^"+IV.call(DV).replace(OV,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function LV(t){if(!Dr(t)||TV(t))return!1;var e=w1(t)?PV:_V;return e.test(Ls(t))}function jV(t,e){return t?.[e]}function js(t,e){var n=jV(t,e);return LV(n)?n:void 0}var $m=js(ur,"WeakMap");function $V(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 BV=800,FV=16,HV=Date.now;function zV(t){var e=0,n=0;return function(){var r=HV(),o=FV-(r-n);if(n=r,o>0){if(++e>=BV)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}function UV(t){return function(){return t}}var Gu=(function(){try{var t=js(Object,"defineProperty");return t({},"",{}),t}catch{}})(),VV=Gu?function(t,e){return Gu(t,"toString",{configurable:!0,enumerable:!1,value:UV(e),writable:!0})}:x1,WV=zV(VV);function GV(t,e){for(var n=-1,r=t==null?0:t.length;++n<r&&e(t[n],n,t)!==!1;);return t}var qV=9007199254740991,KV=/^(?:0|[1-9]\d*)$/;function Bm(t,e){var n=typeof t;return e=e??qV,!!e&&(n=="number"||n!="symbol"&&KV.test(t))&&t>-1&&t%1==0&&t<e}function S1(t,e,n){e=="__proto__"&&Gu?Gu(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function Fm(t,e){return t===e||t!==t&&e!==e}var YV=Object.prototype,JV=YV.hasOwnProperty;function Hm(t,e,n){var r=t[e];(!(JV.call(t,e)&&Fm(r,n))||n===void 0&&!(e in t))&&S1(t,e,n)}function XV(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?S1(n,a,l):Hm(n,a,l)}return n}var k1=Math.max;function QV(t,e,n){return e=k1(e===void 0?t.length-1:e,0),function(){for(var r=arguments,o=-1,s=k1(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),$V(t,this,a)}}var ZV=9007199254740991;function zm(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=ZV}function C1(t){return t!=null&&zm(t.length)&&!w1(t)}var e3=Object.prototype;function T1(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||e3;return t===n}function t3(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}var n3="[object Arguments]";function A1(t){return lo(t)&&Ps(t)==n3}var M1=Object.prototype,r3=M1.hasOwnProperty,o3=M1.propertyIsEnumerable,Um=A1((function(){return arguments})())?A1:function(t){return lo(t)&&r3.call(t,"callee")&&!o3.call(t,"callee")};function s3(){return!1}var O1=typeof vt=="object"&&vt&&!vt.nodeType&&vt,_1=O1&&typeof module=="object"&&module&&!module.nodeType&&module,i3=_1&&_1.exports===O1,N1=i3?ur.Buffer:void 0,a3=N1?N1.isBuffer:void 0,qu=a3||s3,l3="[object Arguments]",c3="[object Array]",u3="[object Boolean]",d3="[object Date]",f3="[object Error]",h3="[object Function]",p3="[object Map]",m3="[object Number]",g3="[object Object]",y3="[object RegExp]",v3="[object Set]",b3="[object String]",x3="[object WeakMap]",w3="[object ArrayBuffer]",E3="[object DataView]",S3="[object Float32Array]",k3="[object Float64Array]",C3="[object Int8Array]",T3="[object Int16Array]",A3="[object Int32Array]",M3="[object Uint8Array]",O3="[object Uint8ClampedArray]",_3="[object Uint16Array]",N3="[object Uint32Array]",rt={};rt[S3]=rt[k3]=rt[C3]=rt[T3]=rt[A3]=rt[M3]=rt[O3]=rt[_3]=rt[N3]=!0,rt[l3]=rt[c3]=rt[w3]=rt[u3]=rt[E3]=rt[d3]=rt[f3]=rt[h3]=rt[p3]=rt[m3]=rt[g3]=rt[y3]=rt[v3]=rt[b3]=rt[x3]=!1;function R3(t){return lo(t)&&zm(t.length)&&!!rt[Ps(t)]}function Vm(t){return function(e){return t(e)}}var R1=typeof vt=="object"&&vt&&!vt.nodeType&&vt,nl=R1&&typeof module=="object"&&module&&!module.nodeType&&module,I3=nl&&nl.exports===R1,Wm=I3&&f1.process,Li=(function(){try{var t=nl&&nl.require&&nl.require("util").types;return t||Wm&&Wm.binding&&Wm.binding("util")}catch{}})(),I1=Li&&Li.isTypedArray,D1=I1?Vm(I1):R3,D3=Object.prototype,P3=D3.hasOwnProperty;function P1(t,e){var n=dr(t),r=!n&&Um(t),o=!n&&!r&&qu(t),s=!n&&!r&&!o&&D1(t),i=n||r||o||s,a=i?t3(t.length,String):[],l=a.length;for(var c in t)(e||P3.call(t,c))&&!(i&&(c=="length"||o&&(c=="offset"||c=="parent")||s&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||Bm(c,l)))&&a.push(c);return a}function L1(t,e){return function(n){return t(e(n))}}var L3=L1(Object.keys,Object),j3=Object.prototype,$3=j3.hasOwnProperty;function B3(t){if(!T1(t))return L3(t);var e=[];for(var n in Object(t))$3.call(t,n)&&n!="constructor"&&e.push(n);return e}function j1(t){return C1(t)?P1(t):B3(t)}function F3(t){var e=[];if(t!=null)for(var n in Object(t))e.push(n);return e}var H3=Object.prototype,z3=H3.hasOwnProperty;function U3(t){if(!Dr(t))return F3(t);var e=T1(t),n=[];for(var r in t)r=="constructor"&&(e||!z3.call(t,r))||n.push(r);return n}function V3(t){return C1(t)?P1(t,!0):U3(t)}var W3=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,G3=/^\w*$/;function Gm(t,e){if(dr(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||Wu(t)?!0:G3.test(t)||!W3.test(t)||e!=null&&t in Object(e)}var rl=js(Object,"create");function q3(){this.__data__=rl?rl(null):{},this.size=0}function K3(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var Y3="__lodash_hash_undefined__",J3=Object.prototype,X3=J3.hasOwnProperty;function Q3(t){var e=this.__data__;if(rl){var n=e[t];return n===Y3?void 0:n}return X3.call(e,t)?e[t]:void 0}var Z3=Object.prototype,e5=Z3.hasOwnProperty;function t5(t){var e=this.__data__;return rl?e[t]!==void 0:e5.call(e,t)}var n5="__lodash_hash_undefined__";function r5(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=rl&&e===void 0?n5:e,this}function $s(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])}}$s.prototype.clear=q3,$s.prototype.delete=K3,$s.prototype.get=Q3,$s.prototype.has=t5,$s.prototype.set=r5;function o5(){this.__data__=[],this.size=0}function Ku(t,e){for(var n=t.length;n--;)if(Fm(t[n][0],e))return n;return-1}var s5=Array.prototype,i5=s5.splice;function a5(t){var e=this.__data__,n=Ku(e,t);if(n<0)return!1;var r=e.length-1;return n==r?e.pop():i5.call(e,n,1),--this.size,!0}function l5(t){var e=this.__data__,n=Ku(e,t);return n<0?void 0:e[n][1]}function c5(t){return Ku(this.__data__,t)>-1}function u5(t,e){var n=this.__data__,r=Ku(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}function co(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])}}co.prototype.clear=o5,co.prototype.delete=a5,co.prototype.get=l5,co.prototype.has=c5,co.prototype.set=u5;var ol=js(ur,"Map");function d5(){this.size=0,this.__data__={hash:new $s,map:new(ol||co),string:new $s}}function f5(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function Yu(t,e){var n=t.__data__;return f5(e)?n[typeof e=="string"?"string":"hash"]:n.map}function h5(t){var e=Yu(this,t).delete(t);return this.size-=e?1:0,e}function p5(t){return Yu(this,t).get(t)}function m5(t){return Yu(this,t).has(t)}function g5(t,e){var n=Yu(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}function uo(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])}}uo.prototype.clear=d5,uo.prototype.delete=h5,uo.prototype.get=p5,uo.prototype.has=m5,uo.prototype.set=g5;var y5="Expected a function";function qm(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(y5);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(qm.Cache||uo),n}qm.Cache=uo;var v5=500;function b5(t){var e=qm(t,function(r){return n.size===v5&&n.clear(),r}),n=e.cache;return e}var x5=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,w5=/\\(\\)?/g,E5=b5(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(x5,function(n,r,o,s){e.push(o?s.replace(w5,"$1"):r||n)}),e});function S5(t){return t==null?"":y1(t)}function ji(t,e){return dr(t)?t:Gm(t,e)?[t]:E5(S5(t))}function $i(t){if(typeof t=="string"||Wu(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Ju(t,e){e=ji(e,t);for(var n=0,r=e.length;t!=null&&n<r;)t=t[$i(e[n++])];return n&&n==r?t:void 0}function k5(t,e,n){var r=t==null?void 0:Ju(t,e);return r===void 0?n:r}function Km(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}var $1=Vn?Vn.isConcatSpreadable:void 0;function C5(t){return dr(t)||Um(t)||!!($1&&t&&t[$1])}function T5(t,e,n,r,o){var s=-1,i=t.length;for(n||(n=C5),o||(o=[]);++s<i;){var a=t[s];n(a)?Km(o,a):o[o.length]=a}return o}function A5(t){var e=t==null?0:t.length;return e?T5(t):[]}function M5(t){return WV(QV(t,void 0,A5),t+"")}var B1=L1(Object.getPrototypeOf,Object),O5="[object Object]",_5=Function.prototype,N5=Object.prototype,F1=_5.toString,R5=N5.hasOwnProperty,I5=F1.call(Object);function D5(t){if(!lo(t)||Ps(t)!=O5)return!1;var e=B1(t);if(e===null)return!0;var n=R5.call(e,"constructor")&&e.constructor;return typeof n=="function"&&n instanceof n&&F1.call(n)==I5}function P5(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 L5(){this.__data__=new co,this.size=0}function j5(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}function $5(t){return this.__data__.get(t)}function B5(t){return this.__data__.has(t)}var F5=200;function H5(t,e){var n=this.__data__;if(n instanceof co){var r=n.__data__;if(!ol||r.length<F5-1)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new uo(r)}return n.set(t,e),this.size=n.size,this}function Pr(t){var e=this.__data__=new co(t);this.size=e.size}Pr.prototype.clear=L5,Pr.prototype.delete=j5,Pr.prototype.get=$5,Pr.prototype.has=B5,Pr.prototype.set=H5;var H1=typeof vt=="object"&&vt&&!vt.nodeType&&vt,z1=H1&&typeof module=="object"&&module&&!module.nodeType&&module,z5=z1&&z1.exports===H1,U1=z5?ur.Buffer:void 0;U1&&U1.allocUnsafe;function U5(t,e){return t.slice()}function V5(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 V1(){return[]}var W5=Object.prototype,G5=W5.propertyIsEnumerable,W1=Object.getOwnPropertySymbols,G1=W1?function(t){return t==null?[]:(t=Object(t),V5(W1(t),function(e){return G5.call(t,e)}))}:V1,q5=Object.getOwnPropertySymbols,K5=q5?function(t){for(var e=[];t;)Km(e,G1(t)),t=B1(t);return e}:V1;function q1(t,e,n){var r=e(t);return dr(t)?r:Km(r,n(t))}function K1(t){return q1(t,j1,G1)}function Ym(t){return q1(t,V3,K5)}var Jm=js(ur,"DataView"),Xm=js(ur,"Promise"),Qm=js(ur,"Set"),Y1="[object Map]",Y5="[object Object]",J1="[object Promise]",X1="[object Set]",Q1="[object WeakMap]",Z1="[object DataView]",J5=Ls(Jm),X5=Ls(ol),Q5=Ls(Xm),Z5=Ls(Qm),e4=Ls($m),fr=Ps;(Jm&&fr(new Jm(new ArrayBuffer(1)))!=Z1||ol&&fr(new ol)!=Y1||Xm&&fr(Xm.resolve())!=J1||Qm&&fr(new Qm)!=X1||$m&&fr(new $m)!=Q1)&&(fr=function(t){var e=Ps(t),n=e==Y5?t.constructor:void 0,r=n?Ls(n):"";if(r)switch(r){case J5:return Z1;case X5:return Y1;case Q5:return J1;case Z5:return X1;case e4:return Q1}return e});var t4=Object.prototype,n4=t4.hasOwnProperty;function r4(t){var e=t.length,n=new t.constructor(e);return e&&typeof t[0]=="string"&&n4.call(t,"index")&&(n.index=t.index,n.input=t.input),n}var Xu=ur.Uint8Array;function Zm(t){var e=new t.constructor(t.byteLength);return new Xu(e).set(new Xu(t)),e}function o4(t,e){var n=Zm(t.buffer);return new t.constructor(n,t.byteOffset,t.byteLength)}var s4=/\w*$/;function i4(t){var e=new t.constructor(t.source,s4.exec(t));return e.lastIndex=t.lastIndex,e}var eC=Vn?Vn.prototype:void 0,tC=eC?eC.valueOf:void 0;function a4(t){return tC?Object(tC.call(t)):{}}function l4(t,e){var n=Zm(t.buffer);return new t.constructor(n,t.byteOffset,t.length)}var c4="[object Boolean]",u4="[object Date]",d4="[object Map]",f4="[object Number]",h4="[object RegExp]",p4="[object Set]",m4="[object String]",g4="[object Symbol]",y4="[object ArrayBuffer]",v4="[object DataView]",b4="[object Float32Array]",x4="[object Float64Array]",w4="[object Int8Array]",E4="[object Int16Array]",S4="[object Int32Array]",k4="[object Uint8Array]",C4="[object Uint8ClampedArray]",T4="[object Uint16Array]",A4="[object Uint32Array]";function M4(t,e,n){var r=t.constructor;switch(e){case y4:return Zm(t);case c4:case u4:return new r(+t);case v4:return o4(t);case b4:case x4:case w4:case E4:case S4:case k4:case C4:case T4:case A4:return l4(t);case d4:return new r;case f4:case m4:return new r(t);case h4:return i4(t);case p4:return new r;case g4:return a4(t)}}var O4="[object Map]";function _4(t){return lo(t)&&fr(t)==O4}var nC=Li&&Li.isMap,N4=nC?Vm(nC):_4,R4="[object Set]";function I4(t){return lo(t)&&fr(t)==R4}var rC=Li&&Li.isSet,D4=rC?Vm(rC):I4,oC="[object Arguments]",P4="[object Array]",L4="[object Boolean]",j4="[object Date]",$4="[object Error]",sC="[object Function]",B4="[object GeneratorFunction]",F4="[object Map]",H4="[object Number]",iC="[object Object]",z4="[object RegExp]",U4="[object Set]",V4="[object String]",W4="[object Symbol]",G4="[object WeakMap]",q4="[object ArrayBuffer]",K4="[object DataView]",Y4="[object Float32Array]",J4="[object Float64Array]",X4="[object Int8Array]",Q4="[object Int16Array]",Z4="[object Int32Array]",eW="[object Uint8Array]",tW="[object Uint8ClampedArray]",nW="[object Uint16Array]",rW="[object Uint32Array]",tt={};tt[oC]=tt[P4]=tt[q4]=tt[K4]=tt[L4]=tt[j4]=tt[Y4]=tt[J4]=tt[X4]=tt[Q4]=tt[Z4]=tt[F4]=tt[H4]=tt[iC]=tt[z4]=tt[U4]=tt[V4]=tt[W4]=tt[eW]=tt[tW]=tt[nW]=tt[rW]=!0,tt[$4]=tt[sC]=tt[G4]=!1;function Qu(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(!Dr(t))return t;var a=dr(t);if(a)i=r4(t);else{var l=fr(t),c=l==sC||l==B4;if(qu(t))return U5(t);if(l==iC||l==oC||c&&!o)i={};else{if(!tt[l])return o?t:{};i=M4(t,l)}}s||(s=new Pr);var u=s.get(t);if(u)return u;s.set(t,i),D4(t)?t.forEach(function(h){i.add(Qu(h,e,n,h,t,s))}):N4(t)&&t.forEach(function(h,p){i.set(p,Qu(h,e,n,p,t,s))});var d=Ym,f=a?void 0:d(t);return GV(f||t,function(h,p){f&&(p=h,h=t[p]),Hm(i,p,Qu(h,e,n,p,t,s))}),i}var oW="__lodash_hash_undefined__";function sW(t){return this.__data__.set(t,oW),this}function iW(t){return this.__data__.has(t)}function Zu(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new uo;++e<n;)this.add(t[e])}Zu.prototype.add=Zu.prototype.push=sW,Zu.prototype.has=iW;function aW(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 lW(t,e){return t.has(e)}var cW=1,uW=2;function aC(t,e,n,r,o,s){var i=n&cW,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&uW?new Zu:void 0;for(s.set(t,e),s.set(e,t);++d<a;){var p=t[d],m=e[d];if(r)var y=i?r(m,p,d,e,t,s):r(p,m,d,t,e,s);if(y!==void 0){if(y)continue;f=!1;break}if(h){if(!aW(e,function(v,w){if(!lW(h,w)&&(p===v||o(p,v,n,r,s)))return h.push(w)})){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 dW(t){var e=-1,n=Array(t.size);return t.forEach(function(r,o){n[++e]=[o,r]}),n}function fW(t){var e=-1,n=Array(t.size);return t.forEach(function(r){n[++e]=r}),n}var hW=1,pW=2,mW="[object Boolean]",gW="[object Date]",yW="[object Error]",vW="[object Map]",bW="[object Number]",xW="[object RegExp]",wW="[object Set]",EW="[object String]",SW="[object Symbol]",kW="[object ArrayBuffer]",CW="[object DataView]",lC=Vn?Vn.prototype:void 0,eg=lC?lC.valueOf:void 0;function TW(t,e,n,r,o,s,i){switch(n){case CW:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case kW:return!(t.byteLength!=e.byteLength||!s(new Xu(t),new Xu(e)));case mW:case gW:case bW:return Fm(+t,+e);case yW:return t.name==e.name&&t.message==e.message;case xW:case EW:return t==e+"";case vW:var a=dW;case wW:var l=r&hW;if(a||(a=fW),t.size!=e.size&&!l)return!1;var c=i.get(t);if(c)return c==e;r|=pW,i.set(t,e);var u=aC(a(t),a(e),r,o,s,i);return i.delete(t),u;case SW:if(eg)return eg.call(t)==eg.call(e)}return!1}var AW=1,MW=Object.prototype,OW=MW.hasOwnProperty;function _W(t,e,n,r,o,s){var i=n&AW,a=K1(t),l=a.length,c=K1(e),u=c.length;if(l!=u&&!i)return!1;for(var d=l;d--;){var f=a[d];if(!(i?f in e:OW.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 y=i;++d<l;){f=a[d];var v=t[f],w=e[f];if(r)var E=i?r(w,v,f,e,t,s):r(v,w,f,t,e,s);if(!(E===void 0?v===w||o(v,w,n,r,s):E)){m=!1;break}y||(y=f=="constructor")}if(m&&!y){var x=t.constructor,k=e.constructor;x!=k&&"constructor"in t&&"constructor"in e&&!(typeof x=="function"&&x instanceof x&&typeof k=="function"&&k instanceof k)&&(m=!1)}return s.delete(t),s.delete(e),m}var NW=1,cC="[object Arguments]",uC="[object Array]",ed="[object Object]",RW=Object.prototype,dC=RW.hasOwnProperty;function IW(t,e,n,r,o,s){var i=dr(t),a=dr(e),l=i?uC:fr(t),c=a?uC:fr(e);l=l==cC?ed:l,c=c==cC?ed:c;var u=l==ed,d=c==ed,f=l==c;if(f&&qu(t)){if(!qu(e))return!1;i=!0,u=!1}if(f&&!u)return s||(s=new Pr),i||D1(t)?aC(t,e,n,r,o,s):TW(t,e,l,n,r,o,s);if(!(n&NW)){var h=u&&dC.call(t,"__wrapped__"),p=d&&dC.call(e,"__wrapped__");if(h||p){var m=h?t.value():t,y=p?e.value():e;return s||(s=new Pr),o(m,y,n,r,s)}}return f?(s||(s=new Pr),_W(t,e,n,r,o,s)):!1}function tg(t,e,n,r,o){return t===e?!0:t==null||e==null||!lo(t)&&!lo(e)?t!==t&&e!==e:IW(t,e,n,r,tg,o)}var DW=1,PW=2;function LW(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 Pr,d;if(!(d===void 0?tg(c,l,DW|PW,r,u):d))return!1}}return!0}function fC(t){return t===t&&!Dr(t)}function jW(t){for(var e=j1(t),n=e.length;n--;){var r=e[n],o=t[r];e[n]=[r,o,fC(o)]}return e}function hC(t,e){return function(n){return n==null?!1:n[t]===e&&(e!==void 0||t in Object(n))}}function $W(t){var e=jW(t);return e.length==1&&e[0][2]?hC(e[0][0],e[0][1]):function(n){return n===t||LW(n,t,e)}}function BW(t,e){return t!=null&&e in Object(t)}function FW(t,e,n){e=ji(e,t);for(var r=-1,o=e.length,s=!1;++r<o;){var i=$i(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&&zm(o)&&Bm(i,o)&&(dr(t)||Um(t)))}function HW(t,e){return t!=null&&FW(t,e,BW)}var zW=1,UW=2;function VW(t,e){return Gm(t)&&fC(e)?hC($i(t),e):function(n){var r=k5(n,t);return r===void 0&&r===e?HW(n,t):tg(e,r,zW|UW)}}function WW(t){return function(e){return e?.[t]}}function GW(t){return function(e){return Ju(e,t)}}function qW(t){return Gm(t)?WW($i(t)):GW(t)}function pC(t){return typeof t=="function"?t:t==null?x1:typeof t=="object"?dr(t)?VW(t[0],t[1]):$W(t):qW(t)}var ng=function(){return ur.Date.now()},KW="Expected a function",YW=Math.max,JW=Math.min;function XW(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(KW);e=b1(e)||0,Dr(n)&&(u=!!n.leading,d="maxWait"in n,s=d?YW(b1(n.maxWait)||0,e):s,f="trailing"in n?!!n.trailing:f);function h(S){var C=r,T=o;return r=o=void 0,c=S,i=t.apply(T,C),i}function p(S){return c=S,a=setTimeout(v,e),u?h(S):i}function m(S){var C=S-l,T=S-c,N=e-C;return d?JW(N,s-T):N}function y(S){var C=S-l,T=S-c;return l===void 0||C>=e||C<0||d&&T>=s}function v(){var S=ng();if(y(S))return w(S);a=setTimeout(v,m(S))}function w(S){return a=void 0,f&&r?h(S):(r=o=void 0,i)}function E(){a!==void 0&&clearTimeout(a),c=0,r=l=o=a=void 0}function x(){return a===void 0?i:w(ng())}function k(){var S=ng(),C=y(S);if(r=arguments,o=this,l=S,C){if(a===void 0)return p(l);if(d)return clearTimeout(a),a=setTimeout(v,e),h(l)}return a===void 0&&(a=setTimeout(v,e)),i}return k.cancel=E,k.flush=x,k}function QW(t){var e=t==null?0:t.length;return e?t[e-1]:void 0}function ZW(t,e){return e.length<2?t:Ju(t,P5(e,0,-1))}function e6(t){return t==null}var t6="Expected a function";function n6(t){if(typeof t!="function")throw new TypeError(t6);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)}}function r6(t,e){return e=ji(e,t),t=ZW(t,e),t==null||delete t[$i(QW(e))]}function o6(t){return D5(t)?void 0:t}var s6=1,i6=2,a6=4,l6=M5(function(t,e){var n={};if(t==null)return n;var r=!1;e=Lm(e,function(s){return s=ji(s,t),r||(r=s.length>1),s}),XV(t,Ym(t),n),r&&(n=Qu(n,s6|i6|a6,o6));for(var o=e.length;o--;)r6(n,e[o]);return n});function c6(t,e,n,r){if(!Dr(t))return t;e=ji(e,t);for(var o=-1,s=e.length,i=s-1,a=t;a!=null&&++o<s;){var l=$i(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=Dr(u)?u:Bm(e[o+1])?[]:{})}Hm(a,l,c),a=a[l]}return t}function u6(t,e,n){for(var r=-1,o=e.length,s={};++r<o;){var i=e[r],a=Ju(t,i);n(a,i)&&c6(s,ji(i,t),a)}return s}function d6(t,e){if(t==null)return{};var n=Lm(Ym(t),function(r){return[r]});return e=pC(e),u6(t,n,function(r,o){return e(r,o[0])})}function f6(t,e){return d6(t,n6(pC(e)))}const rg={limit:tI,offset:0,query:"",reset:!0};function mC({open:t,onOpenChange:e,onImageSelect:n,children:r}){const[o,s]=b.useState("gifs"),[i,a]=b.useState(""),l=d1("images"),c=d1("gifs"),u=b.useRef(c);b.useEffect(()=>{u.current=o==="images"?l:c},[o,l,c]);const d=v=>{if(e?.(v),!v){l.reset(),c.reset(),a("");return}c.fetch(rg).catch(w=>console.log(w)),l.fetch(rg).catch(w=>console.log(w))},f=b.useMemo(()=>XW(async v=>{const w=u.current;w.reset(),await w.fetch({...rg,query:v})},500),[]);b.useEffect(()=>()=>{f.cancel()},[f]);const h=b.useCallback(v=>{a(v),f(v)?.catch(w=>console.log(w))},[f]),p=b.useCallback(v=>{s(v),a("")},[]),m=b.useCallback(async()=>{const v=u.current,w=v.offset+v.limit;v.loadMore(),await v.fetch({offset:w,limit:v.limit,query:i})},[i]),y=b.useCallback(v=>{n?.(v,o==="gifs"?eh?.Gif:o==="images"?eh.Image:void 0),e(!1)},[o,n,e]);return g.jsxs(Mm,{open:t,onOpenChange:d,children:[g.jsx(Gk,{asChild:!0,children:r??g.jsx(Rn,{children:"Open Search Modal"})}),g.jsxs(Om,{className:"max-w-4xl w-full h-[80vh] flex flex-col overflow-hidden px-0 py-0 -translate-1/2",children:[g.jsx(_m,{className:"p-4 border-b bg-accent",children:g.jsx(Nm,{children:"Search Media"})}),g.jsxs(E0,{defaultValue:"gifs",value:o,onValueChange:p,className:"flex-1 grow flex flex-col overflow-y-auto",children:[g.jsx("div",{className:"px-4",children:g.jsxs(S0,{className:"grid w-full grid-cols-2",children:[g.jsx(wh,{value:"gifs",children:"GIF Search"}),g.jsx(wh,{value:"images",children:"Image Search"})]})}),g.jsx(h6,{value:i,onChange:h,placeholder:`Search ${o}...`}),g.jsx(k0,{value:"images",className:"flex-1 grow mt-4 overflow-y-auto",children:g.jsx(gC,{items:l.items,onItemClick:y,hasMore:l.hasMore,loadMore:m,scrollTargetId:wb.images})}),g.jsx(k0,{value:"gifs",className:"flex-1 grow mt-4 overflow-y-auto",children:g.jsx(gC,{items:c.items,onItemClick:y,hasMore:c.hasMore,loadMore:m,scrollTargetId:wb.gifs})})]})]})]})}function h6({value:t,onChange:e,placeholder:n}){return g.jsx("div",{className:"mt-2 px-4",children:g.jsxs("div",{className:"relative",children:[g.jsx(Vk,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),g.jsx(Im,{type:"text",placeholder:n,value:t,onChange:r=>e(r.target.value),className:"pl-9"})]})})}function gC({items:t,onItemClick:e,hasMore:n,loadMore:r,scrollTargetId:o}){const s=i=>i?.source?.url||i?.thumbnail?.url;return g.jsx("div",{id:o,className:"h-full overflow-y-auto",children:g.jsx(nV,{dataLength:t.length,next:r,hasMore:n,loader:g.jsx("div",{className:"flex justify-center py-4",children:g.jsx(Vu,{className:"h-6 w-6"})}),endMessage:g.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:g.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4 py-2 px-4",children:t.map(i=>g.jsx(ZU,{className:"py-0 overflow-hidden cursor-pointer hover:ring-2 hover:ring-primary transition-all",onClick:()=>e(s(i)),children:g.jsx("img",{loading:"lazy",src:s(i),alt:"Media item",className:"w-full h-32 object-cover"})},s(i)))})})})}var og=["Enter"," "],p6=["ArrowDown","PageUp","Home"],yC=["ArrowUp","PageDown","End"],m6=[...p6,...yC],g6={ltr:[...og,"ArrowRight"],rtl:[...og,"ArrowLeft"]},y6={ltr:["ArrowLeft"],rtl:["ArrowRight"]},sl="Menu",[il,v6,b6]=dh(sl),[Bs,vC]=On(sl,[b6,Go,Tc]),td=Go(),bC=Tc(),[x6,Fs]=Bs(sl),[w6,al]=Bs(sl),xC=t=>{const{__scopeMenu:e,open:n=!1,children:r,dir:o,onOpenChange:s,modal:i=!0}=t,a=td(e),[l,c]=b.useState(null),u=b.useRef(!1),d=sr(s),f=Cc(o);return b.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})}},[]),g.jsx(Tu,{...a,children:g.jsx(x6,{scope:e,open:n,onOpenChange:d,content:l,onContentChange:c,children:g.jsx(w6,{scope:e,onClose:b.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:i,children:r})})})};xC.displayName=sl;var E6="MenuAnchor",sg=b.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,o=td(n);return g.jsx(qa,{...o,...r,ref:e})});sg.displayName=E6;var ig="MenuPortal",[S6,wC]=Bs(ig,{forceMount:void 0}),EC=t=>{const{__scopeMenu:e,forceMount:n,children:r,container:o}=t,s=Fs(ig,e);return g.jsx(S6,{scope:e,forceMount:n,children:g.jsx(_n,{present:n||s.open,children:g.jsx(Mi,{asChild:!0,container:o,children:r})})})};EC.displayName=ig;var Wn="MenuContent",[k6,ag]=Bs(Wn),SC=b.forwardRef((t,e)=>{const n=wC(Wn,t.__scopeMenu),{forceMount:r=n.forceMount,...o}=t,s=Fs(Wn,t.__scopeMenu),i=al(Wn,t.__scopeMenu);return g.jsx(il.Provider,{scope:t.__scopeMenu,children:g.jsx(_n,{present:r||s.open,children:g.jsx(il.Slot,{scope:t.__scopeMenu,children:i.modal?g.jsx(C6,{...o,ref:e}):g.jsx(T6,{...o,ref:e})})})})}),C6=b.forwardRef((t,e)=>{const n=Fs(Wn,t.__scopeMenu),r=b.useRef(null),o=$e(e,r);return b.useEffect(()=>{const s=r.current;if(s)return Bu(s)},[]),g.jsx(lg,{...t,ref:o,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:te(t.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),T6=b.forwardRef((t,e)=>{const n=Fs(Wn,t.__scopeMenu);return g.jsx(lg,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),A6=Mo("MenuContent.ScrollLock"),lg=b.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,y=Fs(Wn,n),v=al(Wn,n),w=td(n),E=bC(n),x=v6(n),[k,S]=b.useState(null),C=b.useRef(null),T=$e(e,C,y.onContentChange),N=b.useRef(0),_=b.useRef(""),L=b.useRef(0),$=b.useRef(null),B=b.useRef("right"),z=b.useRef(0),j=p?Xa:b.Fragment,P=p?{as:A6,allowPinchZoom:!0}:void 0,H=V=>{const ie=_.current+V,ne=x().filter(U=>!U.disabled),ye=document.activeElement,G=ne.find(U=>U.ref.current===ye)?.textValue,Z=ne.map(U=>U.textValue),J=B6(Z,ie,G),me=ne.find(U=>U.textValue===J)?.ref.current;(function U(ee){_.current=ee,window.clearTimeout(N.current),ee!==""&&(N.current=window.setTimeout(()=>U(""),1e3))})(ie),me&&setTimeout(()=>me.focus())};b.useEffect(()=>()=>window.clearTimeout(N.current),[]),Nu();const R=b.useCallback(V=>B.current===$.current?.side&&H6(V,$.current?.area),[]);return g.jsx(k6,{scope:n,searchRef:_,onItemEnter:b.useCallback(V=>{R(V)&&V.preventDefault()},[R]),onItemLeave:b.useCallback(V=>{R(V)||(C.current?.focus(),S(null))},[R]),onTriggerLeave:b.useCallback(V=>{R(V)&&V.preventDefault()},[R]),pointerGraceTimerRef:L,onPointerGraceIntentChange:b.useCallback(V=>{$.current=V},[]),children:g.jsx(j,{...P,children:g.jsx(Ja,{asChild:!0,trapped:o,onMountAutoFocus:te(s,V=>{V.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:i,children:g.jsx(Si,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:h,children:g.jsx(qb,{asChild:!0,...E,dir:v.dir,orientation:"vertical",loop:r,currentTabStopId:k,onCurrentTabStopIdChange:S,onEntryFocus:te(l,V=>{v.isUsingKeyboardRef.current||V.preventDefault()}),preventScrollOnEntryFocus:!0,children:g.jsx(Au,{role:"menu","aria-orientation":"vertical","data-state":FC(y.open),"data-radix-menu-content":"",dir:v.dir,...w,...m,ref:T,style:{outline:"none",...m.style},onKeyDown:te(m.onKeyDown,V=>{const ne=V.target.closest("[data-radix-menu-content]")===V.currentTarget,ye=V.ctrlKey||V.altKey||V.metaKey,G=V.key.length===1;ne&&(V.key==="Tab"&&V.preventDefault(),!ye&&G&&H(V.key));const Z=C.current;if(V.target!==Z||!m6.includes(V.key))return;V.preventDefault();const me=x().filter(U=>!U.disabled).map(U=>U.ref.current);yC.includes(V.key)&&me.reverse(),j6(me)}),onBlur:te(t.onBlur,V=>{V.currentTarget.contains(V.target)||(window.clearTimeout(N.current),_.current="")}),onPointerMove:te(t.onPointerMove,cl(V=>{const ie=V.target,ne=z.current!==V.clientX;if(V.currentTarget.contains(ie)&&ne){const ye=V.clientX>z.current?"right":"left";B.current=ye,z.current=V.clientX}}))})})})})})})});SC.displayName=Wn;var M6="MenuGroup",cg=b.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(ge.div,{role:"group",...r,ref:e})});cg.displayName=M6;var O6="MenuLabel",kC=b.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(ge.div,{...r,ref:e})});kC.displayName=O6;var nd="MenuItem",CC="menu.itemSelect",rd=b.forwardRef((t,e)=>{const{disabled:n=!1,onSelect:r,...o}=t,s=b.useRef(null),i=al(nd,t.__scopeMenu),a=ag(nd,t.__scopeMenu),l=$e(e,s),c=b.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(CC,{bubbles:!0,cancelable:!0});d.addEventListener(CC,h=>r?.(h),{once:!0}),Hb(d,f),f.defaultPrevented?c.current=!1:i.onClose()}};return g.jsx(TC,{...o,ref:l,disabled:n,onClick:te(t.onClick,u),onPointerDown:d=>{t.onPointerDown?.(d),c.current=!0},onPointerUp:te(t.onPointerUp,d=>{c.current||d.currentTarget?.click()}),onKeyDown:te(t.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||og.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});rd.displayName=nd;var TC=b.forwardRef((t,e)=>{const{__scopeMenu:n,disabled:r=!1,textValue:o,...s}=t,i=ag(nd,n),a=bC(n),l=b.useRef(null),c=$e(e,l),[u,d]=b.useState(!1),[f,h]=b.useState("");return b.useEffect(()=>{const p=l.current;p&&h((p.textContent??"").trim())},[s.children]),g.jsx(il.ItemSlot,{scope:n,disabled:r,textValue:o??f,children:g.jsx(Kb,{asChild:!0,...a,focusable:!r,children:g.jsx(ge.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:te(t.onPointerMove,cl(p=>{r?i.onItemLeave(p):(i.onItemEnter(p),p.defaultPrevented||p.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:te(t.onPointerLeave,cl(p=>i.onItemLeave(p))),onFocus:te(t.onFocus,()=>d(!0)),onBlur:te(t.onBlur,()=>d(!1))})})})}),_6="MenuCheckboxItem",AC=b.forwardRef((t,e)=>{const{checked:n=!1,onCheckedChange:r,...o}=t;return g.jsx(RC,{scope:t.__scopeMenu,checked:n,children:g.jsx(rd,{role:"menuitemcheckbox","aria-checked":od(n)?"mixed":n,...o,ref:e,"data-state":dg(n),onSelect:te(o.onSelect,()=>r?.(od(n)?!0:!n),{checkForDefaultPrevented:!1})})})});AC.displayName=_6;var MC="MenuRadioGroup",[N6,R6]=Bs(MC,{value:void 0,onValueChange:()=>{}}),OC=b.forwardRef((t,e)=>{const{value:n,onValueChange:r,...o}=t,s=sr(r);return g.jsx(N6,{scope:t.__scopeMenu,value:n,onValueChange:s,children:g.jsx(cg,{...o,ref:e})})});OC.displayName=MC;var _C="MenuRadioItem",NC=b.forwardRef((t,e)=>{const{value:n,...r}=t,o=R6(_C,t.__scopeMenu),s=n===o.value;return g.jsx(RC,{scope:t.__scopeMenu,checked:s,children:g.jsx(rd,{role:"menuitemradio","aria-checked":s,...r,ref:e,"data-state":dg(s),onSelect:te(r.onSelect,()=>o.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});NC.displayName=_C;var ug="MenuItemIndicator",[RC,I6]=Bs(ug,{checked:!1}),IC=b.forwardRef((t,e)=>{const{__scopeMenu:n,forceMount:r,...o}=t,s=I6(ug,n);return g.jsx(_n,{present:r||od(s.checked)||s.checked===!0,children:g.jsx(ge.span,{...o,ref:e,"data-state":dg(s.checked)})})});IC.displayName=ug;var D6="MenuSeparator",DC=b.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(ge.div,{role:"separator","aria-orientation":"horizontal",...r,ref:e})});DC.displayName=D6;var P6="MenuArrow",PC=b.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,o=td(n);return g.jsx(Mu,{...o,...r,ref:e})});PC.displayName=P6;var L6="MenuSub",[ite,LC]=Bs(L6),ll="MenuSubTrigger",jC=b.forwardRef((t,e)=>{const n=Fs(ll,t.__scopeMenu),r=al(ll,t.__scopeMenu),o=LC(ll,t.__scopeMenu),s=ag(ll,t.__scopeMenu),i=b.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:t.__scopeMenu},u=b.useCallback(()=>{i.current&&window.clearTimeout(i.current),i.current=null},[]);return b.useEffect(()=>u,[u]),b.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),g.jsx(sg,{asChild:!0,...c,children:g.jsx(TC,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":o.contentId,"data-state":FC(n.open),...t,ref:kc(e,o.onTriggerChange),onClick:d=>{t.onClick?.(d),!(t.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:te(t.onPointerMove,cl(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:te(t.onPointerLeave,cl(d=>{u();const f=n.content?.getBoundingClientRect();if(f){const h=n.content?.dataset.side,p=h==="right",m=p?-5:5,y=f[p?"left":"right"],v=f[p?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+m,y:d.clientY},{x:y,y:f.top},{x:v,y:f.top},{x:v,y:f.bottom},{x:y,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:te(t.onKeyDown,d=>{const f=s.searchRef.current!=="";t.disabled||f&&d.key===" "||g6[r.dir].includes(d.key)&&(n.onOpenChange(!0),n.content?.focus(),d.preventDefault())})})})});jC.displayName=ll;var $C="MenuSubContent",BC=b.forwardRef((t,e)=>{const n=wC(Wn,t.__scopeMenu),{forceMount:r=n.forceMount,...o}=t,s=Fs(Wn,t.__scopeMenu),i=al(Wn,t.__scopeMenu),a=LC($C,t.__scopeMenu),l=b.useRef(null),c=$e(e,l);return g.jsx(il.Provider,{scope:t.__scopeMenu,children:g.jsx(_n,{present:r||s.open,children:g.jsx(il.Slot,{scope:t.__scopeMenu,children:g.jsx(lg,{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:te(t.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:te(t.onEscapeKeyDown,u=>{i.onClose(),u.preventDefault()}),onKeyDown:te(t.onKeyDown,u=>{const d=u.currentTarget.contains(u.target),f=y6[i.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),a.trigger?.focus(),u.preventDefault())})})})})})});BC.displayName=$C;function FC(t){return t?"open":"closed"}function od(t){return t==="indeterminate"}function dg(t){return od(t)?"indeterminate":t?"checked":"unchecked"}function j6(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}function $6(t,e){return t.map((n,r)=>t[(e+r)%t.length])}function B6(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=$6(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 F6(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 H6(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return F6(n,e)}function cl(t){return e=>e.pointerType==="mouse"?t(e):void 0}var z6=xC,U6=sg,V6=EC,W6=SC,G6=cg,q6=kC,K6=rd,Y6=AC,J6=OC,X6=NC,Q6=IC,Z6=DC,e8=PC,t8=jC,n8=BC,sd="DropdownMenu",[r8]=On(sd,[vC]),sn=vC(),[o8,HC]=r8(sd),zC=t=>{const{__scopeDropdownMenu:e,children:n,dir:r,open:o,defaultOpen:s,onOpenChange:i,modal:a=!0}=t,l=sn(e),c=b.useRef(null),[u,d]=Jr({prop:o,defaultProp:s??!1,onChange:i,caller:sd});return g.jsx(o8,{scope:e,triggerId:Bn(),triggerRef:c,contentId:Bn(),open:u,onOpenChange:d,onOpenToggle:b.useCallback(()=>d(f=>!f),[d]),modal:a,children:g.jsx(z6,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};zC.displayName=sd;var UC="DropdownMenuTrigger",VC=b.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...o}=t,s=HC(UC,n),i=sn(n);return g.jsx(U6,{asChild:!0,...i,children:g.jsx(ge.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:kc(e,s.triggerRef),onPointerDown:te(t.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:te(t.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});VC.displayName=UC;var s8="DropdownMenuPortal",WC=t=>{const{__scopeDropdownMenu:e,...n}=t,r=sn(e);return g.jsx(V6,{...r,...n})};WC.displayName=s8;var GC="DropdownMenuContent",qC=b.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=HC(GC,n),s=sn(n),i=b.useRef(!1);return g.jsx(W6,{id:o.contentId,"aria-labelledby":o.triggerId,...s,...r,ref:e,onCloseAutoFocus:te(t.onCloseAutoFocus,a=>{i.current||o.triggerRef.current?.focus(),i.current=!1,a.preventDefault()}),onInteractOutside:te(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)"}})});qC.displayName=GC;var i8="DropdownMenuGroup",KC=b.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=sn(n);return g.jsx(G6,{...o,...r,ref:e})});KC.displayName=i8;var a8="DropdownMenuLabel",YC=b.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=sn(n);return g.jsx(q6,{...o,...r,ref:e})});YC.displayName=a8;var l8="DropdownMenuItem",JC=b.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=sn(n);return g.jsx(K6,{...o,...r,ref:e})});JC.displayName=l8;var c8="DropdownMenuCheckboxItem",XC=b.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=sn(n);return g.jsx(Y6,{...o,...r,ref:e})});XC.displayName=c8;var u8="DropdownMenuRadioGroup",QC=b.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=sn(n);return g.jsx(J6,{...o,...r,ref:e})});QC.displayName=u8;var d8="DropdownMenuRadioItem",ZC=b.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=sn(n);return g.jsx(X6,{...o,...r,ref:e})});ZC.displayName=d8;var f8="DropdownMenuItemIndicator",eT=b.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=sn(n);return g.jsx(Q6,{...o,...r,ref:e})});eT.displayName=f8;var h8="DropdownMenuSeparator",tT=b.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=sn(n);return g.jsx(Z6,{...o,...r,ref:e})});tT.displayName=h8;var p8="DropdownMenuArrow",m8=b.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=sn(n);return g.jsx(e8,{...o,...r,ref:e})});m8.displayName=p8;var g8="DropdownMenuSubTrigger",nT=b.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=sn(n);return g.jsx(t8,{...o,...r,ref:e})});nT.displayName=g8;var y8="DropdownMenuSubContent",rT=b.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,o=sn(n);return g.jsx(n8,{...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)"}})});rT.displayName=y8;var v8=zC,b8=VC,x8=WC,w8=qC,E8=KC,S8=YC,k8=JC,C8=XC,T8=QC,A8=ZC,oT=eT,M8=tT,O8=nT,_8=rT;function sT(t){return g.jsx(v8,{"data-slot":"dropdown-menu",...t})}const iT=b.forwardRef((t,e)=>g.jsx(b8,{ref:e,"data-slot":"dropdown-menu-trigger",...t})),aT=b.forwardRef(({className:t,sideOffset:e,...n},r)=>g.jsx(x8,{children:g.jsx("div",{"data-theme":"select-post-builder",children:g.jsx(w8,{ref:r,"data-slot":"dropdown-menu-content",sideOffset:e??4,className:re("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})})}));b.forwardRef((t,e)=>g.jsx(E8,{ref:e,"data-slot":"dropdown-menu-group",...t}));const bn=b.forwardRef(({className:t,inset:e,variant:n="default",...r},o)=>g.jsx(k8,{ref:o,"data-slot":"dropdown-menu-item","data-inset":e,"data-variant":n,className:re("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}));b.forwardRef(({className:t,children:e,checked:n,...r},o)=>g.jsxs(C8,{ref:o,"data-slot":"dropdown-menu-checkbox-item",className:re("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:[g.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:g.jsx(oT,{children:g.jsx(Nk,{className:"size-4"})})}),e]})),b.forwardRef((t,e)=>g.jsx(T8,{ref:e,"data-slot":"dropdown-menu-radio-group",...t})),b.forwardRef(({className:t,children:e,...n},r)=>g.jsxs(A8,{ref:r,"data-slot":"dropdown-menu-radio-item",className:re("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:[g.jsx("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:g.jsx(oT,{children:g.jsx(lU,{className:"size-2 fill-current"})})}),e]})),b.forwardRef(({className:t,inset:e,...n},r)=>g.jsx(S8,{ref:r,"data-slot":"dropdown-menu-label","data-inset":e,className:re("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",t),...n})),b.forwardRef(({className:t,...e},n)=>g.jsx(M8,{ref:n,"data-slot":"dropdown-menu-separator",className:re("bg-border -mx-1 my-1 h-px",t),...e})),b.forwardRef(({className:t,...e},n)=>g.jsx("span",{ref:n,"data-slot":"dropdown-menu-shortcut",className:re("text-muted-foreground ml-auto text-xs tracking-widest",t),...e})),b.forwardRef(({className:t,inset:e,children:n,...r},o)=>g.jsxs(O8,{ref:o,"data-slot":"dropdown-menu-sub-trigger","data-inset":e,className:re("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,g.jsx(iU,{className:"ml-auto size-4"})]})),b.forwardRef(({className:t,...e},n)=>g.jsx(_8,{ref:n,"data-slot":"dropdown-menu-sub-content",className:re("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}));function lT(t){const e=b.useRef({value:t,previous:t});return b.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}var id="Switch",[N8]=On(id),[R8,I8]=N8(id),cT=b.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]=b.useState(null),p=$e(e,E=>h(E)),m=b.useRef(!1),y=f?u||!!f.closest("form"):!0,[v,w]=Jr({prop:o,defaultProp:s??!1,onChange:c,caller:id});return g.jsxs(R8,{scope:n,checked:v,disabled:a,children:[g.jsx(ge.button,{type:"button",role:"switch","aria-checked":v,"aria-required":i,"data-state":hT(v),"data-disabled":a?"":void 0,disabled:a,value:l,...d,ref:p,onClick:te(t.onClick,E=>{w(x=>!x),y&&(m.current=E.isPropagationStopped(),m.current||E.stopPropagation())})}),y&&g.jsx(fT,{control:f,bubbles:!m.current,name:r,value:l,checked:v,required:i,disabled:a,form:u,style:{transform:"translateX(-100%)"}})]})});cT.displayName=id;var uT="SwitchThumb",dT=b.forwardRef((t,e)=>{const{__scopeSwitch:n,...r}=t,o=I8(uT,n);return g.jsx(ge.span,{"data-state":hT(o.checked),"data-disabled":o.disabled?"":void 0,...r,ref:e})});dT.displayName=uT;var D8="SwitchBubbleInput",fT=b.forwardRef(({__scopeSwitch:t,control:e,checked:n,bubbles:r=!0,...o},s)=>{const i=b.useRef(null),a=$e(i,s),l=lT(n),c=SS(e);return b.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]),g.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}})});fT.displayName=D8;function hT(t){return t?"checked":"unchecked"}var P8=cT,L8=dT;function pT({className:t,...e}){return g.jsx(P8,{"data-slot":"switch",className:re("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:g.jsx(L8,{"data-slot":"switch-thumb",className:re("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 j8=t=>BE({editor:t,selector:e=>{if(!e?.editor)return null;const n=e.editor,r=n.isActive("codeBlock")??!1;return{isEmpty:n.isEmpty??!1,isFocused:n.isFocused??!1,isBold:n.isActive("bold")??!1,canBold:ze(n,"toggleBold"),isItalic:n.isActive("italic")??!1,canItalic:ze(n,"toggleItalic"),isStrike:n.isActive("strike")??!1,canStrike:ze(n,"toggleStrike"),isCode:n.isActive("code")??!1,canCode:ze(n,"toggleCode"),isUnderline:n.isActive("underline")??!1,canUnderline:ze(n,"toggleUnderline"),isLink:n.isActive("customLink")??!1,canLink:ze(n,"toggleLink",{href:""}),canUnlink:ze(n,"unsetLink"),isParagraph:n.isActive("paragraph")??!1,canParagraph:ze(n,"setParagraph"),isHeading1:n.isActive("heading",{level:1})??!1,canHeading1:ze(n,"setHeading",{level:1}),isHeading2:n.isActive("heading",{level:2})??!1,canHeading2:ze(n,"setHeading",{level:2}),isHeading3:n.isActive("heading",{level:3})??!1,canHeading3:ze(n,"setHeading",{level:3}),isHeading4:n.isActive("heading",{level:4})??!1,canHeading4:ze(n,"setHeading",{level:4}),isHeading5:n.isActive("heading",{level:5})??!1,canHeading5:ze(n,"setHeading",{level:5}),isHeading6:n.isActive("heading",{level:6})??!1,canHeading6:ze(n,"setHeading",{level:6}),isBulletList:n.isActive("bulletList")??!1,canBulletList:ze(n,"toggleBulletList"),isOrderedList:n.isActive("orderedList")??!1,canOrderedList:ze(n,"toggleOrderedList"),isTaskList:n.isActive("taskList")??!1,canTaskList:ze(n,"toggleTaskList"),isBlockquote:n.isActive("blockquote")??!1,canBlockquote:ze(n,"toggleBlockquote"),isCodeBlock:r,canCodeBlock:ze(n,"toggleCodeBlock"),isAlignLeft:n.isActive({textAlign:"left"})??!1,canAlignLeft:ze(n,"setTextAlign","left")&&!r,isAlignCenter:n.isActive({textAlign:"center"})??!1,canAlignCenter:ze(n,"setTextAlign","center")&&!r,isAlignRight:n.isActive({textAlign:"right"})??!1,canAlignRight:ze(n,"setTextAlign","right")&&!r,isAlignJustify:n.isActive({textAlign:"justify"})??!1,canAlignJustify:ze(n,"setTextAlign","justify")&&!r,canUnsetAlign:ze(n,"unsetTextAlign"),canInsertImage:ze(n,"insertMedia",{type:be.Image,src:""}),canInsertVideo:ze(n,"insertMedia",{type:be.Video,src:""}),canInsertAudio:ze(n,"insertMedia",{type:be.Audio,src:""}),isPoll:n?.isActive("poll")??!1,canPoll:ze(n,"insertPoll",{choices:[]}),canUndo:ze(n,"undo"),canRedo:ze(n,"redo"),canClearMarks:ze(n,"unsetAllMarks"),canClearNodes:ze(n,"clearNodes")}}}),ze=(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}},mT=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},$8=(t,e,n={})=>{const{debounceMs:r=0,checkOnTransaction:o=!0}=n;let s=mT(t),i=null;e(s);const a=()=>{const d=mT(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)}},B8=(t,e)=>{const[n,r]=M.useState(!1),o=M.useMemo(()=>({debounceMs:e?.debounceMs,checkOnTransaction:e?.checkOnTransaction??!0}),[e?.debounceMs,e?.checkOnTransaction]);return M.useEffect(()=>{if(!t){r(!1);return}return $8(t,i=>{r(i)},o)},[t,o]),{showCrossMentionIndicator:n}};function F8(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 ul(t,e,n={}){const r=[],o=n.findAll??!0;return F8(t,s=>{if(s.type===e&&(r.push(s),!o))return!1},n),r}function gT(t,e,n={}){return ul(t,e,{...n,findAll:!1})[0]||null}const H8={[ht.Text]:{showFormatting:!0,showImage:!0,showVideo:!0,showAudio:!0,showImageSearch:!0},[ht.Media]:{showFormatting:!1,showImage:!0,showVideo:!0,showAudio:!1,showImageSearch:!0},[ht.Link]:{showLink:!0},[ht.Poll]:{}},z8=({actions:t,editorType:e,children:n,isSubmitting:r,onSubmit:o})=>{const s=M.useRef(null),[i,a]=M.useState(null),[l,c]=M.useState(!1),[u,d]=M.useState(!1),[f,h]=M.useState(!1),{editor:p}=mu(),m=j8(p),{showCrossMentionIndicator:y}=B8(p,{debounceMs:150});if(!p)return null;const v=H8[e],w=_=>{m?.isLink&&(p.chain().focus().unsetLink().run(),_.preventDefault())},E=(_,L,$)=>{const B=e===ht.Text?L??_:_;if($){p.commands.updateLink($,{href:_,text:B});return}p.commands.insertLink({href:_,text:B})},x=()=>{const _=p.getJSON();return ul(_,"media").length>=10?(Ao.error(`You can upload up to ${ma} files per post. Please remove some files before adding new ones.`),!0):!1},k=()=>{if(e!==ht.Media){s?.current?.click();return}x()||s?.current?.click()},S=_=>{const L=_.target.files;L?.length&&Array.from({length:e===ht.Media?ma:L?.length}).forEach((B,z)=>{const j=L.item(z);!j||!i||p.commands.insertMediaWithUpload({source:j,type:i,mediaType:To.MEDIA_ITEM})}),_.target.value=""},C=_=>{if(x()){_.preventDefault();return}},T=(_,L)=>{p?.commands.insertMediaWithUpload({source:_,type:be.Image,mediaType:To.IMAGE_ITEM,searchFrom:L})},N=_=>_?.isHeading1?Lk:_?.isHeading2?jk:_?.isHeading3?$k:_?.isHeading4?Bk:_?.isHeading5?Fk:_?.isHeading6?Hk:Tm;return g.jsxs("div",{className:"flex flex-col grow overflow-y-auto",children:[v.showFormatting&&g.jsxs("div",{className:"shrink-0 flex flex-wrap items-center gap-2 sm:gap-2 p-2",children:[g.jsx(xe,{icon:bU,tooltip:"Undo",onClick:t.undo,disabled:!m?.canUndo}),g.jsx(xe,{icon:mU,tooltip:"Redo",onClick:t.redo,disabled:!m?.canRedo}),g.jsxs(sT,{children:[g.jsx(iT,{asChild:!0,children:g.jsx(xe,{tooltip:"Heading Options",icon:N(m),"aria-label":"More formatting options"})}),g.jsx(aT,{align:"start",className:"w-44 px-1 py-1",children:g.jsxs("div",{className:"flex flex-col items-stretch gap-1",children:[g.jsx(bn,{asChild:!0,children:g.jsxs(xe,{className:"w-full justify-start",tooltip:"Paragraph",onClick:t.setParagraph,active:m?.isParagraph,disabled:!m?.canParagraph,children:[g.jsx(Tm,{})," Paragraph"]})}),g.jsx(bn,{asChild:!0,children:g.jsxs(xe,{className:"w-full justify-start",tooltip:"Heading One",onClick:()=>t.toggleHeading(1),active:m?.isHeading1,disabled:!m?.canHeading1,children:[g.jsx(Lk,{})," Heading 1"]})}),g.jsx(bn,{asChild:!0,children:g.jsxs(xe,{className:"w-full justify-start",tooltip:"Heading Two",onClick:()=>t.toggleHeading(2),active:m?.isHeading2,disabled:!m?.canHeading2,children:[g.jsx(jk,{})," Heading 2"]})}),g.jsx(bn,{asChild:!0,children:g.jsxs(xe,{className:"w-full justify-start",tooltip:"Heading Three",onClick:()=>t.toggleHeading(3),active:m?.isHeading3,disabled:!m?.canHeading3,children:[g.jsx($k,{})," Heading 3"]})}),g.jsx(bn,{asChild:!0,children:g.jsxs(xe,{className:"w-full justify-start",tooltip:"Heading Four",onClick:()=>t.toggleHeading(4),active:m?.isHeading4,disabled:!m?.canHeading4,children:[g.jsx(Bk,{})," Heading 4"]})}),g.jsx(bn,{asChild:!0,children:g.jsxs(xe,{className:"w-full justify-start",tooltip:"Heading Five",onClick:()=>t.toggleHeading(5),active:m?.isHeading5,disabled:!m?.canHeading5,children:[g.jsx(Fk,{})," Heading 5"]})}),g.jsx(bn,{asChild:!0,children:g.jsxs(xe,{className:"w-full justify-start",tooltip:"Heading Six",onClick:()=>t.toggleHeading(6),active:m?.isHeading6,disabled:!m?.canHeading6,children:[g.jsx(Hk,{})," Heading 6"]})})]})})]}),g.jsx(Bi,{}),g.jsx(xe,{icon:sU,tooltip:"Bold",onClick:t.toggleBold,active:m?.isBold,disabled:!m?.canBold}),g.jsxs("div",{className:"hidden xl:flex items-center gap-2",children:[g.jsx(xe,{icon:Uk,tooltip:"Italic",onClick:t.toggleItalic,active:m?.isItalic,disabled:!m?.canItalic}),g.jsx(xe,{icon:Wk,tooltip:"Strikethrough",onClick:t.toggleStrikethrough,active:m?.isStrike,disabled:!m?.canStrike})]}),g.jsx(xe,{icon:vU,tooltip:"Underline",onClick:t.toggleUnderline,active:m?.isUnderline,disabled:!m?.canUnderline}),g.jsx(Bi,{}),g.jsx(Dm,{open:l,onOpenChange:c,onInsertLink:E,children:g.jsx(xe,{icon:Em,tooltip:"Link",onClick:w,active:m?.isLink,disabled:!m?.canLink})}),g.jsx(xe,{icon:hU,tooltip:"Bullet List",onClick:t.toggleBulletList,active:m?.isBulletList,disabled:!m?.canBulletList}),g.jsx(xe,{icon:fU,tooltip:"Ordered List",onClick:t.toggleOrderedList,active:m?.isOrderedList,disabled:!m?.canOrderedList}),g.jsx(Bi,{}),g.jsxs("div",{className:"hidden xl:flex flex-wrap items-center gap-2",children:[g.jsx(xe,{icon:Ik,tooltip:"Code",onClick:t.toggleCode,active:m?.isCode,disabled:!m?.canCode}),g.jsx(xe,{icon:Dk,tooltip:"Codeblock",onClick:t.toggleCodeBlock,active:m?.isCodeBlock,disabled:!m?.canCodeBlock}),g.jsx(Bi,{}),g.jsx(xe,{icon:Uu,tooltip:"Align Left",onClick:()=>t.toggleTextAlign(Ze.LEFT),active:m?.isAlignLeft,disabled:!m?.canAlignLeft}),g.jsx(xe,{icon:Sm,tooltip:"Align Center",onClick:()=>t.toggleTextAlign(Ze.CENTER),active:m?.isAlignCenter,disabled:!m?.canAlignCenter}),g.jsx(xe,{icon:km,tooltip:"Align Right",onClick:()=>t.toggleTextAlign(Ze.RIGHT),active:m?.isAlignRight,disabled:!m?.canAlignRight})]}),g.jsx("div",{className:"flex xl:hidden",children:g.jsxs(sT,{children:[g.jsx(iT,{asChild:!0,children:g.jsx(xe,{tooltip:"More formatting options",icon:cU,"aria-label":"More formatting options"})}),g.jsx(aT,{align:"end",className:"w-fit px-2 py-1",children:g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(bn,{asChild:!0,children:g.jsx(xe,{icon:Uk,tooltip:"Italic",onClick:t.toggleItalic,active:m?.isItalic,disabled:!m?.canItalic})}),g.jsx(bn,{asChild:!0,children:g.jsx(xe,{icon:Wk,tooltip:"Strikethrough",onClick:t.toggleStrikethrough,active:m?.isStrike,disabled:!m?.canStrike})}),g.jsx(bn,{asChild:!0,children:g.jsx(xe,{icon:Ik,tooltip:"Code",onClick:t.toggleCode,active:m?.isCode,disabled:!m?.canCode})}),g.jsx(bn,{asChild:!0,children:g.jsx(xe,{icon:Dk,tooltip:"Codeblock",onClick:t.toggleCodeBlock,active:m?.isCodeBlock,disabled:!m?.canCodeBlock})}),g.jsx(bn,{asChild:!0,children:g.jsx(xe,{icon:Uu,tooltip:"Align Left",onClick:()=>t.toggleTextAlign(Ze.LEFT),active:m?.isAlignLeft,disabled:!m?.canAlignLeft})}),g.jsx(bn,{asChild:!0,children:g.jsx(xe,{icon:Sm,tooltip:"Align Center",onClick:()=>t.toggleTextAlign(Ze.CENTER),active:m?.isAlignCenter,disabled:!m?.canAlignCenter})}),g.jsx(bn,{asChild:!0,children:g.jsx(xe,{icon:km,tooltip:"Align Right",onClick:()=>t.toggleTextAlign(Ze.RIGHT),active:m?.isAlignRight,disabled:!m?.canAlignRight})})]})})]})})]}),n,y&&g.jsxs("div",{className:"sm:hidden flex items-center space-x-2 px-2",children:[g.jsx(pT,{id:"send-cross-mention",checked:f,onCheckedChange:h}),g.jsxs(Rm,{htmlFor:"send-cross-mention",className:"text-xs",children:["Cross-post to groups you #mention? ",g.jsx(Pk,{className:"size-4"})]})]}),g.jsxs("div",{className:"shrink-0 flex items-center sm:gap-2 p-2 border-t",children:[g.jsx("input",{ref:s,type:"file",multiple:!0,maxLength:2,accept:eI[i||be.Image],hidden:!0,onChange:S}),v.showImage&&g.jsx(xe,{icon:zk,tooltip:"Insert Image",disabled:!m?.canInsertImage,onMouseOver:()=>a(be.Image),onClick:k}),v.showVideo&&g.jsx(xe,{icon:Am,disabled:!m?.canInsertVideo,tooltip:"Insert Video",onMouseOver:()=>a(be.Video),onClick:k}),v.showAudio&&g.jsx(xe,{icon:zu,disabled:!m?.canInsertAudio,tooltip:"Insert Audio",onMouseOver:()=>a(be.Audio),onClick:k}),v.showImageSearch&&g.jsxs(g.Fragment,{children:[g.jsx(Bi,{}),g.jsx(mC,{open:u,onOpenChange:d,onImageSelect:T,children:g.jsx(xe,{onClick:C,disabled:!m?.canInsertImage,icon:dU,tooltip:"Search Gif/Images Online"})})]}),v.showLink&&g.jsx(Dm,{hideTextInput:!0,open:l,onOpenChange:c,onInsertLink:E,children:g.jsx(xe,{icon:Em,tooltip:"Add link with preview",onClick:w,active:m?.isLink,disabled:!m?.canLink})}),y&&g.jsxs(g.Fragment,{children:[g.jsx(Bi,{}),g.jsxs("div",{className:"hidden sm:flex items-center space-x-2 px-2",children:[g.jsx(pT,{id:"send-cross-mention"}),g.jsxs(Rm,{htmlFor:"send-cross-mention",children:["Cross-post to groups you #mention? ",g.jsx(Pk,{})]})]})]}),g.jsxs(Rn,{disabled:m?.isEmpty||r,onClick:()=>o(f),className:re("cursor-pointer bg-primary-send hover:bg-primary-send/85 active:scale-95 w-fit ml-auto"),children:["Post ",r?g.jsx(Vu,{}):g.jsx(gU,{})]})]})]})},Bi=()=>g.jsx("div",{className:"h-3 w-px bg-border"}),yT=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},U8=(t=>t?yT(t):yT),V8=t=>{const e=t.postId&&t.groupId?"post":t.groupId?"group":"global";return U8((n,r)=>({contextType:e,groupId:t.groupId??null,postId:t.postId??null,selectedGroupId:t.groupId??null,enableGroupSelector:!t.groupId,editor:null,setEditor:o=>n({editor:o}),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 ad=(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]},W8=/^\s*>\s$/,G8=Mt.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return ad("blockquote",{...Be(this.options.HTMLAttributes,t),children:ad("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=[];return t.content.forEach(o=>{const i=e.renderChildren(o).split(`
455
- `).map(a=>`> ${a}`).join(`
456
- `);n.push(i)}),n.flatMap(o=>[o,"> "]).slice(0,-1).join(`
457
- `)},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[Ei({find:W8,type:this.type})]}}),q8=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,K8=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Y8=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,J8=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,X8=so.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 ad("strong",{...Be(this.options.HTMLAttributes,t),children:ad("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[wi({find:q8,type:this.type}),wi({find:Y8,type:this.type})]},addPasteRules(){return[Ns({find:K8,type:this.type}),Ns({find:J8,type:this.type})]}}),Q8=/(^|[^`])`([^`]+)`(?!`)$/,Z8=/(^|[^`])`([^`]+)`(?!`)/g,eG=so.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Be(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[wi({find:Q8,type:this.type})]},addPasteRules(){return[Ns({find:Z8,type:this.type})]}}),fg=4,tG=/^```([a-z]+)?[\s\n]$/,nG=/^~~~([a-z]+)?[\s\n]$/,rG=Mt.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:fg,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",Be(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(`
458
- `):r=`\`\`\`${o}
459
-
460
- \`\`\``,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:fg,{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,`
461
- `,`
462
- `).split(`
463
- `).map(p=>a+p).join(`
464
- `);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:fg,{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,`
465
- `,`
466
- `).split(`
467
- `);let p=0,m=0;const y=c-u;for(let S=0;S<h.length;S+=1){if(m+h[S].length>=y){p=S;break}m+=h[S].length+1}const w=((l=h[p].match(/^ */))==null?void 0:l[0])||"",E=Math.min(w.length,n);if(E===0)return!0;let x=u;for(let S=0;S<p;S+=1)x+=h[S].length+1;return a.delete(x,x+E),c-x<=E&&a.setSelection(pe.create(a.doc,x)),!0}):t.commands.command(({tr:a})=>{const{from:l,to:c}=o,f=r.doc.textBetween(l,c,`
468
- `,`
469
- `).split(`
470
- `).map(h=>{var p;const m=((p=h.match(/^ */))==null?void 0:p[0])||"",y=Math.min(m.length,n);return h.slice(y)}).join(`
471
- `);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(`
472
-
473
- `);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(Me.near(r.resolve(a))),!0)):t.commands.exitCode()}}},addInputRules(){return[Ip({find:tG,type:this.type,getAttributes:t=>({language:t[1]})}),Ip({find:nG,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new He({key:new Ue("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,`
474
- `));return i.replaceSelectionWith(this.type.create({language:s},l)),i.selection.$from.parent.type!==this.type&&i.setSelection(pe.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),t.dispatch(i),!0}}})]}}),vT=Mt.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
475
-
476
- `):""}),oG=vT,bT=Mt.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",Be(this.options.HTMLAttributes,t)]},renderText(){return`
477
- `},renderMarkdown:(t,e)=>e.indent(`
478
- `),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()}}}),hg=bT,sG=Mt.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]}`,Be(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=>Ip({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),iG=Mt.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Be(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!fB(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,o=t();return wE(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(pe.create(i.doc,l.pos+1)):l.nodeAfter.isBlock?i.setSelection(ue.create(i.doc,l.pos)):i.setSelection(pe.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(pe.create(i.doc,c+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[dB({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),aG=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,lG=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,cG=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,uG=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,dG=so.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",Be(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[wi({find:aG,type:this.type}),wi({find:cG,type:this.type})]},addPasteRules(){return[Ns({find:lG,type:this.type}),Ns({find:uG,type:this.type})]}});const fG="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",hG="ελ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",pg="numeric",mg="ascii",gg="alpha",dl="asciinumeric",fl="alphanumeric",yg="domain",xT="emoji",pG="scheme",mG="slashscheme",vg="whitespace";function gG(t,e){return t in e||(e[t]=[]),e[t]}function Hs(t,e,n){e[pg]&&(e[dl]=!0,e[fl]=!0),e[mg]&&(e[dl]=!0,e[gg]=!0),e[dl]&&(e[fl]=!0),e[gg]&&(e[fl]=!0),e[fl]&&(e[yg]=!0),e[xT]&&(e[yg]=!0);for(const r in e){const o=gG(r,n);o.indexOf(t)<0&&o.push(t)}}function yG(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function xn(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}xn.groups={},xn.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||xn.groups;let o;return e&&e.j?o=e:(o=new xn(e),n&&r&&Hs(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||xn.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 xn,Object.assign(i.j,a.j),i.jr.push.apply(i.jr,a.jr),i.jd=a.jd,i.t=a.t):i=new xn,s){if(r)if(i.t&&typeof i.t=="string"){const l=Object.assign(yG(i.t,r),n);Hs(s,l,r)}else n&&Hs(s,n,r);i.t=s}return o.j[t]=i,i}};const _e=(t,e,n,r,o)=>t.ta(e,n,r,o),pt=(t,e,n,r,o)=>t.tr(e,n,r,o),wT=(t,e,n,r,o)=>t.ts(e,n,r,o),q=(t,e,n,r,o)=>t.tt(e,n,r,o),fo="WORD",bg="UWORD",ET="ASCIINUMERICAL",ST="ALPHANUMERICAL",hl="LOCALHOST",xg="TLD",wg="UTLD",ld="SCHEME",Fi="SLASH_SCHEME",Eg="NUM",Sg="WS",kg="NL",pl="OPENBRACE",ml="CLOSEBRACE",cd="OPENBRACKET",ud="CLOSEBRACKET",dd="OPENPAREN",fd="CLOSEPAREN",hd="OPENANGLEBRACKET",pd="CLOSEANGLEBRACKET",md="FULLWIDTHLEFTPAREN",gd="FULLWIDTHRIGHTPAREN",yd="LEFTCORNERBRACKET",vd="RIGHTCORNERBRACKET",bd="LEFTWHITECORNERBRACKET",xd="RIGHTWHITECORNERBRACKET",wd="FULLWIDTHLESSTHAN",Ed="FULLWIDTHGREATERTHAN",Sd="AMPERSAND",kd="APOSTROPHE",Cd="ASTERISK",Ko="AT",Td="BACKSLASH",Ad="BACKTICK",Md="CARET",Yo="COLON",Cg="COMMA",Od="DOLLAR",Lr="DOT",_d="EQUALS",Tg="EXCLAMATION",Gn="HYPHEN",gl="PERCENT",Nd="PIPE",Rd="PLUS",Id="POUND",yl="QUERY",Ag="QUOTE",kT="FULLWIDTHMIDDLEDOT",Mg="SEMI",jr="SLASH",vl="TILDE",Dd="UNDERSCORE",CT="EMOJI",Pd="SYM";var TT=Object.freeze({__proto__:null,ALPHANUMERICAL:ST,AMPERSAND:Sd,APOSTROPHE:kd,ASCIINUMERICAL:ET,ASTERISK:Cd,AT:Ko,BACKSLASH:Td,BACKTICK:Ad,CARET:Md,CLOSEANGLEBRACKET:pd,CLOSEBRACE:ml,CLOSEBRACKET:ud,CLOSEPAREN:fd,COLON:Yo,COMMA:Cg,DOLLAR:Od,DOT:Lr,EMOJI:CT,EQUALS:_d,EXCLAMATION:Tg,FULLWIDTHGREATERTHAN:Ed,FULLWIDTHLEFTPAREN:md,FULLWIDTHLESSTHAN:wd,FULLWIDTHMIDDLEDOT:kT,FULLWIDTHRIGHTPAREN:gd,HYPHEN:Gn,LEFTCORNERBRACKET:yd,LEFTWHITECORNERBRACKET:bd,LOCALHOST:hl,NL:kg,NUM:Eg,OPENANGLEBRACKET:hd,OPENBRACE:pl,OPENBRACKET:cd,OPENPAREN:dd,PERCENT:gl,PIPE:Nd,PLUS:Rd,POUND:Id,QUERY:yl,QUOTE:Ag,RIGHTCORNERBRACKET:vd,RIGHTWHITECORNERBRACKET:xd,SCHEME:ld,SEMI:Mg,SLASH:jr,SLASH_SCHEME:Fi,SYM:Pd,TILDE:vl,TLD:xg,UNDERSCORE:Dd,UTLD:wg,UWORD:bg,WORD:fo,WS:Sg});const ho=/[a-z]/,bl=new RegExp("\\p{L}","u"),Og=new RegExp("\\p{Emoji}","u"),po=/\d/,_g=/\s/,AT="\r",Ng=`
479
- `,vG="️",bG="‍",Rg="";let Ld=null,jd=null;function xG(t=[]){const e={};xn.groups=e;const n=new xn;Ld==null&&(Ld=OT(fG)),jd==null&&(jd=OT(hG)),q(n,"'",kd),q(n,"{",pl),q(n,"}",ml),q(n,"[",cd),q(n,"]",ud),q(n,"(",dd),q(n,")",fd),q(n,"<",hd),q(n,">",pd),q(n,"(",md),q(n,")",gd),q(n,"「",yd),q(n,"」",vd),q(n,"『",bd),q(n,"』",xd),q(n,"<",wd),q(n,">",Ed),q(n,"&",Sd),q(n,"*",Cd),q(n,"@",Ko),q(n,"`",Ad),q(n,"^",Md),q(n,":",Yo),q(n,",",Cg),q(n,"$",Od),q(n,".",Lr),q(n,"=",_d),q(n,"!",Tg),q(n,"-",Gn),q(n,"%",gl),q(n,"|",Nd),q(n,"+",Rd),q(n,"#",Id),q(n,"?",yl),q(n,'"',Ag),q(n,"/",jr),q(n,";",Mg),q(n,"~",vl),q(n,"_",Dd),q(n,"\\",Td),q(n,"・",kT);const r=pt(n,po,Eg,{[pg]:!0});pt(r,po,r);const o=pt(r,ho,ET,{[dl]:!0}),s=pt(r,bl,ST,{[fl]:!0}),i=pt(n,ho,fo,{[mg]:!0});pt(i,po,o),pt(i,ho,i),pt(o,po,o),pt(o,ho,o);const a=pt(n,bl,bg,{[gg]:!0});pt(a,ho),pt(a,po,s),pt(a,bl,a),pt(s,po,s),pt(s,ho),pt(s,bl,s);const l=q(n,Ng,kg,{[vg]:!0}),c=q(n,AT,Sg,{[vg]:!0}),u=pt(n,_g,Sg,{[vg]:!0});q(n,Rg,u),q(c,Ng,l),q(c,Rg,u),pt(c,_g,u),q(u,AT),q(u,Ng),pt(u,_g,u),q(u,Rg,u);const d=pt(n,Og,CT,{[xT]:!0});q(d,"#"),pt(d,Og,d),q(d,vG,d);const f=q(d,bG);q(f,"#"),pt(f,Og,d);const h=[[ho,i],[po,o]],p=[[ho,null],[bl,a],[po,s]];for(let m=0;m<Ld.length;m++)Jo(n,Ld[m],xg,fo,h);for(let m=0;m<jd.length;m++)Jo(n,jd[m],wg,bg,p);Hs(xg,{tld:!0,ascii:!0},e),Hs(wg,{utld:!0,alpha:!0},e),Jo(n,"file",ld,fo,h),Jo(n,"mailto",ld,fo,h),Jo(n,"http",Fi,fo,h),Jo(n,"https",Fi,fo,h),Jo(n,"ftp",Fi,fo,h),Jo(n,"ftps",Fi,fo,h),Hs(ld,{scheme:!0,ascii:!0},e),Hs(Fi,{slashscheme:!0,ascii:!0},e),t=t.sort((m,y)=>m[0]>y[0]?1:-1);for(let m=0;m<t.length;m++){const y=t[m][0],w=t[m][1]?{[pG]:!0}:{[mG]:!0};y.indexOf("-")>=0?w[yg]=!0:ho.test(y)?po.test(y)?w[dl]=!0:w[mg]=!0:w[pg]=!0,wT(n,y,y,w)}return wT(n,"localhost",hl,{ascii:!0}),n.jd=new xn(Pd),{start:n,tokens:Object.assign({groups:e},TT)}}function MT(t,e){const n=wG(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 wG(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 Jo(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 xn(r),s.jr=o.slice(),t.j[l]=s),t=s}return s=new xn(n),s.jr=o.slice(),t.j[e[i-1]]=s,s}function OT(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 xl={defaultProtocol:"http",events:null,format:_T,formatHref:_T,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Ig(t,e=null){let n=Object.assign({},xl);t&&(n=Object.assign(n,t instanceof Ig?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}Ig.prototype={o:xl,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]:xl[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 _T(t){return t}function NT(t,e){this.t="token",this.v=t,this.tk=e}NT.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=xl.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 $d(t,e){class n extends NT{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 RT=$d("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),IT=$d("text"),EG=$d("nl"),Bd=$d("url",{isLink:!0,toHref(t=xl.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==hl&&t[1].t===Yo}}),qn=t=>new xn(t);function SG({groups:t}){const e=t.domain.concat([Sd,Cd,Ko,Td,Ad,Md,Od,_d,Gn,Eg,gl,Nd,Rd,Id,jr,Pd,vl,Dd]),n=[kd,Yo,Cg,Lr,Tg,gl,yl,Ag,Mg,hd,pd,pl,ml,ud,cd,dd,fd,md,gd,yd,vd,bd,xd,wd,Ed],r=[Sd,kd,Cd,Td,Ad,Md,Od,_d,Gn,pl,ml,gl,Nd,Rd,Id,yl,jr,Pd,vl,Dd],o=qn(),s=q(o,vl);_e(s,r,s),_e(s,t.domain,s);const i=qn(),a=qn(),l=qn();_e(o,t.domain,i),_e(o,t.scheme,a),_e(o,t.slashscheme,l),_e(i,r,s),_e(i,t.domain,i);const c=q(i,Ko);q(s,Ko,c),q(a,Ko,c),q(l,Ko,c);const u=q(s,Lr);_e(u,r,s),_e(u,t.domain,s);const d=qn();_e(c,t.domain,d),_e(d,t.domain,d);const f=q(d,Lr);_e(f,t.domain,d);const h=qn(RT);_e(f,t.tld,h),_e(f,t.utld,h),q(c,hl,h);const p=q(d,Gn);q(p,Gn,p),_e(p,t.domain,d),_e(h,t.domain,d),q(h,Lr,f),q(h,Gn,p);const m=q(h,Yo);_e(m,t.numeric,RT);const y=q(i,Gn),v=q(i,Lr);q(y,Gn,y),_e(y,t.domain,i),_e(v,r,s),_e(v,t.domain,i);const w=qn(Bd);_e(v,t.tld,w),_e(v,t.utld,w),_e(w,t.domain,i),_e(w,r,s),q(w,Lr,v),q(w,Gn,y),q(w,Ko,c);const E=q(w,Yo),x=qn(Bd);_e(E,t.numeric,x);const k=qn(Bd),S=qn();_e(k,e,k),_e(k,n,S),_e(S,e,k),_e(S,n,S),q(w,jr,k),q(x,jr,k);const C=q(a,Yo),T=q(l,Yo),N=q(T,jr),_=q(N,jr);_e(a,t.domain,i),q(a,Lr,v),q(a,Gn,y),_e(l,t.domain,i),q(l,Lr,v),q(l,Gn,y),_e(C,t.domain,k),q(C,jr,k),q(C,yl,k),_e(_,t.domain,k),_e(_,e,k),q(_,jr,k);const L=[[pl,ml],[cd,ud],[dd,fd],[hd,pd],[md,gd],[yd,vd],[bd,xd],[wd,Ed]];for(let $=0;$<L.length;$++){const[B,z]=L[$],j=q(k,B);q(S,B,j),q(j,z,k);const P=qn(Bd);_e(j,e,P);const H=qn();_e(j,n),_e(P,e,P),_e(P,n,H),_e(H,e,P),_e(H,n,H),q(P,z,k),q(H,z,k)}return q(o,hl,w),q(o,kg,EG),{start:o,tokens:TT}}function kG(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(Dg(IT,e,i)),i=[]),o-=f,u-=f;const h=d.t,p=n.slice(o-u,o);s.push(Dg(h,e,p))}}return i.length>0&&s.push(Dg(IT,e,i)),s}function Dg(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 CG=typeof console<"u"&&console&&console.warn||(()=>{}),TG="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",ot={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function AG(){return xn.groups={},ot.scanner=null,ot.parser=null,ot.tokenQueue=[],ot.pluginQueue=[],ot.customSchemes=[],ot.initialized=!1,ot}function DT(t,e=!1){if(ot.initialized&&CG(`linkifyjs: already initialized - will not register custom scheme "${t}" ${TG}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
480
- 1. Must only contain digits, lowercase ASCII letters or "-"
481
- 2. Cannot start or end with "-"
482
- 3. "-" cannot repeat`);ot.customSchemes.push([t,e])}function MG(){ot.scanner=xG(ot.customSchemes);for(let t=0;t<ot.tokenQueue.length;t++)ot.tokenQueue[t][1]({scanner:ot.scanner});ot.parser=SG(ot.scanner.tokens);for(let t=0;t<ot.pluginQueue.length;t++)ot.pluginQueue[t][1]({scanner:ot.scanner,parser:ot.parser});return ot.initialized=!0,ot}function Pg(t){return ot.initialized||MG(),kG(ot.parser.start,t,MT(ot.scanner.start,t))}Pg.scan=MT;function PT(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 Ig(n),o=Pg(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 Lg="[\0-   ᠎ -\u2029  ]",OG=new RegExp(Lg),_G=new RegExp(`${Lg}$`),NG=new RegExp(Lg,"g");function RG(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function IG(t){return new He({key:new Ue("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=cE(n.doc,[...e]);if(vE(a).forEach(({newRange:c})=>{const u=g$(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(!_G.test(h))return;d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&f){const h=f.split(OG).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 y=Pg(p).map(v=>v.toObject(t.defaultProtocol));if(!RG(y))return!1;y.filter(v=>v.isLink).map(v=>({...v,from:m+v.start+1,to:m+v.end+1})).filter(v=>r.schema.marks.code?!r.doc.rangeHasMark(v.from,v.to,r.schema.marks.code):!0).filter(v=>t.validate(v.value)).filter(v=>t.shouldAutoLink(v.value)).forEach(v=>{Ap(v.from,v.to,r.doc).some(w=>w.mark.type===t.type)||i.addMark(v.from,v.to,t.type.create({href:v.href}))})}}),!!i.steps.length)return i}})}function DG(t){return new He({key:new Ue("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{let u=r.target;const d=[];for(;u.nodeName!=="DIV";)d.push(u),u=u.parentNode;i=d.find(f=>f.nodeName==="A")}if(!i)return!1;const a=yE(e.state,t.type.name),l=(o=i?.href)!=null?o:a.href,c=(s=i?.target)!=null?s:a.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),i&&l?(window.open(l,c),!0):!1}}})}function PG(t){return new He({key:new Ue("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=PT(l,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===l);return!l||!c||o!==void 0&&!o(c.href)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function Xo(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(NG,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var LT=so.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){DT(t);return}DT(t.scheme,t.optionalSlashes)})},onDestroy(){AG()},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)=>!!Xo(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},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}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Xo(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=>!!Xo(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Be(this.options.HTMLAttributes,t),0]:["a",Be(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;const r=((n=t.attrs)==null?void 0:n.href)||"";return`[${e.renderChildren(t)}](${r})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Xo(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=>!!Xo(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[Ns({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,o=PT(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:i=>!!Xo(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(IG({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!Xo(o,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(DG({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(PG({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),jg=LT,LG=Object.defineProperty,jG=(t,e)=>{for(var n in e)LG(t,n,{get:e[n],enumerable:!0})},$G="listItem",jT="textStyle",$T=/^\s*([-+*])\s$/,BT=Mt.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",Be(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,`
483
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes($G,this.editor.getAttributes(jT)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Ei({find:$T,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ei({find:$T,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(jT),editor:this.editor})),[t]}}),FT=Mt.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Be(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)=>jp(t,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",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)}}}),BG={};jG(BG,{findListItemPos:()=>wl,getNextListDepth:()=>$g,handleBackspace:()=>Bg,handleDelete:()=>Fg,hasListBefore:()=>HT,hasListItemAfter:()=>FG,hasListItemBefore:()=>zT,listItemHasSubList:()=>UT,nextListIsDeeper:()=>VT,nextListIsHigher:()=>WT});var wl=(t,e)=>{const{$from:n}=e.selection,r=St(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}},$g=(t,e)=>{const n=wl(t,e);if(!n)return!1;const[,r]=T$(e,t,n.$pos.pos+4);return r},HT=(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))},zT=(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)},UT=(t,e,n)=>{if(!n)return!1;const r=St(t,e.schema);let o=!1;return n.descendants(s=>{s.type===r&&(o=!0)}),o},Bg=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!zo(t.state,e)&&HT(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(!zo(t.state,e)||!_$(t.state))return!1;const r=wl(e,t.state);if(!r)return!1;const s=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),i=UT(e,t.state,s);return zT(e,t.state)&&!i?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},VT=(t,e)=>{const n=$g(t,e),r=wl(t,e);return!r||!n?!1:n>r.depth},WT=(t,e)=>{const n=$g(t,e),r=wl(t,e);return!r||!n?!1:n<r.depth},Fg=(t,e)=>{if(!zo(t.state,e)||!O$(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:o}=n;return!n.empty&&r.sameParent(o)?!1:VT(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():WT(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},FG=(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)},GT=Je.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&&Fg(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&&Fg(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&&Bg(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&&Bg(t,n,r)&&(e=!0)}),e}}}}),qT=/^(\s*)(\d+)\.\s+(.*)$/,HG=/^\s/;function zG(t){const e=[];let n=0,r=0;for(;n<t.length;){const o=t[n],s=o.match(qT);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(qT))break;if(h.trim()==="")f.push(h),u+=`
484
- `,d+=1;else if(h.match(HG))f.push(h),u+=`
485
- ${h.slice(c+2)}`,d+=1;else break}e.push({indent:c,number:parseInt(a,10),content:u.trim(),raw:f.join(`
486
- `)}),r=d,n=d}return[e,r]}function KT(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(`
487
- `),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(`
488
- `).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=KT(f,h,n);c.push({type:"list",ordered:!0,start:f[0].number,items:p,raw:f.map(m=>m.raw).join(`
489
- `)})}o.push({type:"list_item",raw:i.raw,tokens:c}),s=d}else s+=1}return o}function UG(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 VG="listItem",YT="textStyle",JT=/^(\d+)\.\s$/,XT=Mt.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",Be(this.options.HTMLAttributes,n),0]:["ol",Be(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?UG(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,`
490
- `):"",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(`
491
- `),[s,i]=zG(o);if(s.length===0)return;const a=KT(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(`
492
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(VG,this.editor.getAttributes(YT)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Ei({find:JT,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=Ei({find:JT,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(YT)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),WG=/^\s*(\[([( |x])?\])\s$/,GG=Mt.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",Be(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 jp(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=u=>{var d,f;a.ariaLabel=((f=(d=this.options.a11y)==null?void 0:d.checkboxLabel)==null?void 0:f.call(d,u,a.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};return c(t),s.contentEditable="false",a.type="checkbox",a.addEventListener("mousedown",u=>u.preventDefault()),a.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){a.checked=!a.checked;return}const{checked:d}=u.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const h=n();if(typeof h!="number")return!1;const p=f.doc.nodeAt(h);return f.setNodeMarkup(h,void 0,{...p?.attrs,checked:d}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,d)||(a.checked=!a.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,d])=>{o.setAttribute(u,d)}),o.dataset.checked=t.attrs.checked,a.checked=t.attrs.checked,s.append(a,i),o.append(s,l),Object.entries(e).forEach(([u,d])=>{o.setAttribute(u,d)}),{dom:o,contentDOM:l,update:u=>u.type!==this.type?!1:(o.dataset.checked=u.attrs.checked,a.checked=u.attrs.checked,c(u),!0)}}},addInputRules(){return[Ei({find:WG,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),qG=Mt.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",Be(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,`
493
- `):"",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=Lp(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=Lp(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()}}});Je.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(BT.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(FT.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(GT.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(XT.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(GG.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(qG.configure(this.options.taskList)),t}});var QT=Mt.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Be(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];return n.length===1&&n[0].type==="image"?e.parseChildren([n[0]]):e.createNode("paragraph",void 0,e.parseInline(n))},renderMarkdown:(t,e)=>!t||!Array.isArray(t.content)?"":e.renderChildren(t.content),addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Hg=QT,KG=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,YG=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,JG=so.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",Be(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[wi({find:KG,type:this.type})]},addPasteRules(){return[Ns({find:YG,type:this.type})]}}),ZT=Mt.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),zg=ZT,XG=so.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",Be(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 QG(t={}){return new He({view(e){return new ZG(e,t)}})}class ZG{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 y=this.width/2*a;r={left:p.left,right:p.right,top:m-y,bottom:m+y}}}}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=fx(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 mt extends Me{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return mt.valid(r)?new mt(r):Me.near(r)}content(){return Q.empty}eq(e){return e instanceof mt&&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 mt(e.resolve(n.pos))}getBookmark(){return new Ug(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!e9(e)||!t9(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&&mt.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(mt.valid(l))return l}for(;;){let i=n>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!ue.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(mt.valid(a))return a}return null}}}mt.prototype.visible=!1,mt.findFrom=mt.findGapCursorFrom,Me.jsonID("gapcursor",mt);class Ug{constructor(e){this.pos=e}map(e){return new Ug(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return mt.valid(n)?new mt(n):Me.near(n)}}function eA(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function e9(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||eA(o.type))return!0;if(o.inlineContent)return!1}}return!0}function t9(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||eA(o.type))return!0;if(o.inlineContent)return!1}}return!0}function n9(){return new He({props:{decorations:i9,createSelectionBetween(t,e,n){return e.pos==n.pos&&mt.valid(n)?new mt(n):null},handleClick:o9,handleKeyDown:r9,handleDOMEvents:{beforeinput:s9}}})}const r9=Zw({ArrowLeft:Fd("horiz",-1),ArrowRight:Fd("horiz",1),ArrowUp:Fd("vert",-1),ArrowDown:Fd("vert",1)});function Fd(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 pe){if(!s.endOfTextblock(n)||a.depth==0)return!1;l=!1,a=r.doc.resolve(e>0?a.after():a.before())}let c=mt.findGapCursorFrom(a,e,l);return c?(o&&o(r.tr.setSelection(new mt(c))),!0):!1}}function o9(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!mt.valid(r))return!1;let o=t.posAtCoords({left:n.clientX,top:n.clientY});return o&&o.inside>-1&&ue.isSelectable(t.state.doc.nodeAt(o.inside))?!1:(t.dispatch(t.state.tr.setSelection(new mt(r))),!0)}function s9(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof mt))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=F.empty;for(let i=r.length-1;i>=0;i--)o=F.from(r[i].createAndFill(null,o));let s=t.state.tr.replace(n.pos,n.pos,new Q(o,0,0));return s.setSelection(pe.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function i9(t){if(!(t.selection instanceof mt))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",et.create(t.doc,[Vt.widget(t.selection.head,e,{key:"gapcursor"})])}var Hd=200,Lt=function(){};Lt.prototype.append=function(e){return e.length?(e=Lt.from(e),!this.length&&e||e.length<Hd&&this.leafAppend(e)||this.length<Hd&&e.leafPrepend(this)||this.appendInner(e)):this},Lt.prototype.prepend=function(e){return e.length?Lt.from(e).append(this):this},Lt.prototype.appendInner=function(e){return new a9(this,e)},Lt.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Lt.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))},Lt.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Lt.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)},Lt.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},Lt.from=function(e){return e instanceof Lt?e:e&&e.length?new tA(e):Lt.empty};var tA=(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<=Hd)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Hd)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})(Lt);Lt.empty=new tA([]);var a9=(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})(Lt);const l9=500;class hr{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 Qo(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 Qo(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 hr(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 Qo(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>u9&&(a=c9(a,c),i-=c),new hr(a.append(s),i)}remapping(e,n){let r=new Ca;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 hr(this.items.append(e.map(n=>new Qo(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]),y=f.selection&&f.selection.map(s.slice(l+1,h));y&&a++,r.push(new Qo(p,m,y))}else r.push(new Qo(p))},o);let c=[];for(let f=n;f<i;f++)c.push(new Qo(s.maps[f]));let u=this.items.slice(0,o).append(c).append(r),d=new hr(u,a);return d.emptyItemCount()>l9&&(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 Qo(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 hr(Lt.from(o.reverse()),s)}}hr.empty=new hr(Lt.empty,0);function c9(t,e){let n;return t.forEach((r,o)=>{if(r.selection&&e--==0)return n=o,!1}),t.slice(n)}let Qo=class MN{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 MN(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 u9=20;function d9(t,e,n,r){let o=n.getMeta(zs),s;if(o)return o.historyState;n.getMeta(p9)&&(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(zs))return i.getMeta(zs).redo?new Zo(t.done.addTransform(n,void 0,r,zd(e)),t.undone,nA(n.mapping.maps),t.prevTime,t.prevComposition):new Zo(t.done,t.undone.addTransform(n,void 0,r,zd(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||!f9(n,t.prevRanges)),c=i?Vg(t.prevRanges,n.mapping):nA(n.mapping.maps);return new Zo(t.done.addTransform(n,l?e.selection.getBookmark():void 0,r,zd(e)),hr.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),Vg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Zo(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Vg(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function f9(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 nA(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 Vg(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 h9(t,e,n){let r=zd(e),o=zs.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(zs,{redo:n,historyState:l})}let Wg=!1,rA=null;function zd(t){let e=t.plugins;if(rA!=e){Wg=!1,rA=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Wg=!0;break}}return Wg}const zs=new Ue("history"),p9=new Ue("closeHistory");function m9(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new He({key:zs,state:{init(){return new Zo(hr.empty,hr.empty,null,0,-1)},apply(e,n,r){return d9(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,o=r=="historyUndo"?sA:r=="historyRedo"?iA:null;return o?(n.preventDefault(),o(e.state,e.dispatch)):!1}}}})}function oA(t,e){return(n,r)=>{let o=zs.getState(n);if(!o||(t?o.undone:o.done).eventCount==0)return!1;if(r){let s=h9(o,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const sA=oA(!1,!0),iA=oA(!0,!0);Je.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 He({key:new Ue("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;console.warn(`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`);const 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 g9=Je.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[QG(this.options)]}});Je.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new He({key:new Ue("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:o}=e,s=[];if(!n||!r)return et.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(Vt.node(c,c+l.nodeSize,{class:this.options.className}))}),et.create(t,s)}}})]}});var y9=Je.create({name:"gapCursor",addProseMirrorPlugins(){return[n9()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=Ge(de(t,"allowGapCursor",n)))!=null?e:null}}}),v9=Je.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new He({key:new Ue("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,o=[];if(!n)return null;const s=this.editor.isEmpty;return t.descendants((i,a)=>{const l=r>=a&&r<=a+i.nodeSize,c=!i.isLeaf&&lu(i);if((l||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];s&&u.push(this.options.emptyEditorClass);const d=Vt.node(a,a+i.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:i,pos:a,hasAnchor:l}):this.options.placeholder});o.push(d)}return this.options.includeChildren}),et.create(t,o)}}})]}});Je.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new He({key:new Ue("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||wE(n.selection)||t.view.dragging?null:et.create(n.doc,[Vt.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function aA({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var b9=Je.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Ue(this.name),n=((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||this.options.node||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,o])=>o).filter(o=>(this.options.notAfter||[]).concat(n).includes(o.name));return[new He({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!aA({node:i,types:r})},apply:(o,s)=>{if(!o.docChanged)return s;const i=o.doc.lastChild;return!aA({node:i,types:r})}}})]}}),x9=Je.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>sA(t,e),redo:()=>({state:t,dispatch:e})=>iA(t,e)}},addProseMirrorPlugins(){return[m9(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()}}}),w9=Je.create({name:"starterKit",addExtensions(){var t,e,n,r;const o=[];return this.options.bold!==!1&&o.push(X8.configure(this.options.bold)),this.options.blockquote!==!1&&o.push(G8.configure(this.options.blockquote)),this.options.bulletList!==!1&&o.push(BT.configure(this.options.bulletList)),this.options.code!==!1&&o.push(eG.configure(this.options.code)),this.options.codeBlock!==!1&&o.push(rG.configure(this.options.codeBlock)),this.options.document!==!1&&o.push(vT.configure(this.options.document)),this.options.dropcursor!==!1&&o.push(g9.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&o.push(y9.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&o.push(bT.configure(this.options.hardBreak)),this.options.heading!==!1&&o.push(sG.configure(this.options.heading)),this.options.undoRedo!==!1&&o.push(x9.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&o.push(iG.configure(this.options.horizontalRule)),this.options.italic!==!1&&o.push(dG.configure(this.options.italic)),this.options.listItem!==!1&&o.push(FT.configure(this.options.listItem)),this.options.listKeymap!==!1&&o.push(GT.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&o.push(LT.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&o.push(XT.configure(this.options.orderedList)),this.options.paragraph!==!1&&o.push(QT.configure(this.options.paragraph)),this.options.strike!==!1&&o.push(JG.configure(this.options.strike)),this.options.text!==!1&&o.push(ZT.configure(this.options.text)),this.options.underline!==!1&&o.push(XG.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&o.push(b9.configure((r=this.options)==null?void 0:r.trailingNode)),o}}),E9=w9,S9=Je.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})).every(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(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")}}}),k9=S9,C9=so.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",Be(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()}}}),T9=C9,A9=so.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",Be(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()}}}),M9=A9;const O9=({children:t,width:e=100,minWidth:n=20,maxWidth:r=100,onResize:o,selected:s=!1,className:i=""})=>{const[a,l]=M.useState(!1),[c,u]=M.useState(null),[d,f]=M.useState(e),h=M.useRef(null),p=M.useRef(0),m=M.useRef(e),y=M.useRef(0),v=M.useRef(null),w=(S,C)=>{S.preventDefault(),p.current=S.clientX,m.current=d,u(C),l(!0)},E=()=>{if(!h.current||!c)return;const S=h.current.parentElement?.offsetWidth||1,T=y.current/S*100;let N=m.current;c==="right"?N=m.current+T:c==="left"&&(N=m.current-T),N=Math.min(r,Math.max(n,N)),f(N),o?.(N),v.current=null},x=S=>{!a||!c||(y.current=S.clientX-p.current,v.current||(v.current=requestAnimationFrame(E)))},k=()=>{l(!1),u(null),v.current&&(cancelAnimationFrame(v.current),v.current=null)};return M.useEffect(()=>{if(a)return window.addEventListener("mousemove",x),window.addEventListener("mouseup",k),()=>{window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",k)}},[a]),g.jsxs("div",{ref:h,className:re("relative group",s?"ring-2 ring-blue-400 rounded-md":"",i),style:{width:`${d}%`},children:[t,g.jsx("div",{onMouseDown:S=>w(S,"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"}),g.jsx("div",{onMouseDown:S=>w(S,"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"})]})},lA=({open:t,align:e,onAlign:n,onDelete:r})=>t?g.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"&&g.jsxs(g.Fragment,{children:[g.jsx(xe,{active:e===Ze.LEFT,icon:Uu,tooltip:"Align left",onClick:()=>n(Ze.LEFT)}),g.jsx(xe,{active:e===Ze.CENTER,icon:Sm,tooltip:"Align center",onClick:()=>n(Ze.CENTER)}),g.jsx(xe,{active:e===Ze.RIGHT,icon:km,tooltip:"Align right",onClick:()=>n(Ze.RIGHT)})]}),g.jsx(xe,{variant:"destructive",className:"bg-transparent hover:bg-accent text-red-300 hover:text-destructive",icon:Cm,tooltip:"Delete",onClick:r})]}):null;var Gg="Progress",qg=100,[_9]=On(Gg),[N9,R9]=_9(Gg),cA=b.forwardRef((t,e)=>{const{__scopeProgress:n,value:r=null,max:o,getValueLabel:s=I9,...i}=t;(o||o===0)&&!hA(o)&&console.error(D9(`${o}`,"Progress"));const a=hA(o)?o:qg;r!==null&&!pA(r,a)&&console.error(P9(`${r}`,"Progress"));const l=pA(r,a)?r:null,c=Ud(l)?s(l,a):void 0;return g.jsx(N9,{scope:n,value:l,max:a,children:g.jsx(ge.div,{"aria-valuemax":a,"aria-valuemin":0,"aria-valuenow":Ud(l)?l:void 0,"aria-valuetext":c,role:"progressbar","data-state":fA(l,a),"data-value":l??void 0,"data-max":a,...i,ref:e})})});cA.displayName=Gg;var uA="ProgressIndicator",dA=b.forwardRef((t,e)=>{const{__scopeProgress:n,...r}=t,o=R9(uA,n);return g.jsx(ge.div,{"data-state":fA(o.value,o.max),"data-value":o.value??void 0,"data-max":o.max,...r,ref:e})});dA.displayName=uA;function I9(t,e){return`${Math.round(t/e*100)}%`}function fA(t,e){return t==null?"indeterminate":t===e?"complete":"loading"}function Ud(t){return typeof t=="number"}function hA(t){return Ud(t)&&!isNaN(t)&&t>0}function pA(t,e){return Ud(t)&&!isNaN(t)&&t<=e&&t>=0}function D9(t,e){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${e}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${qg}\`.`}function P9(t,e){return`Invalid prop \`value\` of value \`${t}\` supplied to \`${e}\`. The \`value\` prop must be:
494
- - a positive number
495
- - less than the value passed to \`max\` (or ${qg} if no \`max\` prop is set)
496
- - \`null\` or \`undefined\` if the progress is indeterminate.
497
-
498
- Defaulting to \`null\`.`}var L9=cA,j9=dA;function mA({className:t,value:e,...n}){return g.jsx(L9,{"data-slot":"progress",className:re("bg-primary/20 relative h-2 w-full overflow-hidden rounded-full",t),...n,children:g.jsx(j9,{"data-slot":"progress-indicator",className:"bg-primary h-full w-full flex-1 transition-all",style:{transform:`translateX(-${100-(e||0)}%)`}})})}var $9="AspectRatio",gA=b.forwardRef((t,e)=>{const{ratio:n=1/1,style:r,...o}=t;return g.jsx("div",{style:{position:"relative",width:"100%",paddingBottom:`${100/n}%`},"data-radix-aspect-ratio-wrapper":"",children:g.jsx(ge.div,{...o,ref:e,style:{...r,position:"absolute",top:0,right:0,bottom:0,left:0}})})});gA.displayName=$9;var B9=gA;function F9({...t}){return g.jsx(B9,{"data-slot":"aspect-ratio",...t})}const H9=({node:t,updateAttributes:e,editor:n,getPos:r})=>{const[o,s]=M.useState(!1);M.useEffect(()=>{const l=()=>{const c=n.state.selection;(c instanceof ue?c.node:null)===t?requestAnimationFrame(()=>s(!0)):s(!1)};return l(),n.on("selectionUpdate",l),()=>{n.off("selectionUpdate",l)}},[n,t]);const i=()=>{const l=r()??NaN;Number.isFinite(l)&&n.chain().focus().deleteRange({from:l,to:l+t.nodeSize}).focus().run()},a=l=>e({align:l});return t.attrs.uploading?g.jsx(Uo,{className:re("flex my-4",t.attrs.align===Ze.CENTER?"justify-center":t.attrs.align===Ze.RIGHT?"justify-end":""),children:g.jsxs("div",{className:"w-full max-w-full",children:[g.jsxs("div",{className:"relative bg-muted rounded-lg overflow-hidden",children:[g.jsx(F9,{ratio:t.attrs.type===be.Audio?4/1:16/4,className:re("flex items-center justify-center bg-muted"),children:g.jsxs("div",{className:"text-center space-y-3",children:[g.jsxs("div",{className:"flex justify-center",children:[t.attrs.type===be.Image&&g.jsx(wm,{className:"w-12 h-12 text-muted-foreground/50"}),t.attrs.type===be.Video&&g.jsx(Am,{className:"w-12 h-12 text-muted-foreground/50"}),t.attrs.type===be.Audio&&g.jsx(zu,{className:"w-12 h-12 text-muted-foreground/50"})]}),g.jsxs("p",{className:"text-sm text-muted-foreground font-medium",children:["Uploading ",t.attrs.type,"..."]})]})}),g.jsx("div",{className:"absolute bottom-0 left-0 right-0 p-4",children:g.jsx(mA,{value:t.attrs.progress??0,className:"h-2"})}),g.jsx("button",{onClick:i,className:"absolute top-2 right-2 p-2 bg-background/90 hover:bg-background rounded-full shadow-sm transition-colors",title:"Cancel upload",children:g.jsx(Di,{className:"w-4 h-4"})})]}),g.jsxs("p",{className:"text-xs text-muted-foreground text-center mt-2",children:[Math.round(t.attrs.progress??0),"%"]})]})}):g.jsx(Uo,{"data-drag-handle":!0,className:re("flex",t.attrs.align===Ze.CENTER?"justify-center":t.attrs.align===Ze.RIGHT?"justify-end":""),children:t.attrs.type===be.Image?g.jsx(yA,{open:o,mediaType:t.attrs.type,align:t.attrs.align,onResize:l=>e({maxWidth:l}),onAlign:a,onDelete:i,children:g.jsx("img",{src:t.attrs.src,alt:t.attrs.caption,className:re("object-contain w-full h-auto rounded-lg",o&&"border-2 border-blue-500")})}):t.attrs.type===be.Video?g.jsx(yA,{open:o,mediaType:t.attrs.type,align:t.attrs.align,onResize:l=>e({maxWidth:l}),onAlign:a,onDelete:i,children:g.jsx("video",{src:t.attrs.src,controls:!0,className:re("object-contain w-full h-auto",o&&"border-2 border-blue-500")})}):t.attrs.type===be.Audio?g.jsxs("div",{className:"relative p-4 bg-accent/20 border border-border/20 w-full",children:[g.jsx(lA,{open:o,align:t.attrs.align,onAlign:a,onDelete:i}),g.jsx("audio",{src:t.attrs.src,controls:!0,className:re("w-full",o&&"rounded-full border-2 border-blue-500")})]}):g.jsx("div",{className:"p-4 text-sm text-gray-600",children:"Unsupported media"})})},yA=({open:t,align:e,onAlign:n,onDelete:r,onResize:o,mediaType:s,children:i})=>g.jsxs(O9,{onResize:o,className:re(s===be.Audio&&"relative p-4 bg-accent/50"),children:[g.jsx(lA,{open:t,align:e,onAlign:n,onDelete:r}),i]}),vA=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},bA=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},z9=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},U9=t=>(e,n)=>({state:r,dispatch:o})=>{if(console.log("=== UPDATE MARK COMMAND START ==="),console.log("markName:",t),console.log("uid:",e),console.log("attrs:",n),console.log("state.doc:",r.doc.toJSON()),!o)return console.log("No dispatch, returning false"),!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=>{console.log("Checking mark:",{markType:f.type.name,markUid:f.attrs.uid,targetMarkName:t,targetUid:e,matches:f.type.name===t&&f.attrs.uid===e}),f.type.name===t&&f.attrs.uid===e&&(c.push({from:d,to:d+u.nodeSize,mark:f}),l=!0,console.log("Found matching mark at:",{from:d,to:d+u.nodeSize}))})}),console.log("Total positions found:",c.length),console.log("Positions:",c),l&&(c.forEach(({from:u,to:d,mark:f})=>{const h={...f.attrs,...n},p=i.marks[t];console.log("Applying update:",{from:u,to:d,oldAttrs:f.attrs,newAttrs:h}),p&&(console.log("Before removeMark - tr.doc:",a.doc.toJSON()),a=a.removeMark(u,d,p),console.log("After removeMark - tr.doc:",a.doc.toJSON()),a=a.addMark(u,d,p.create(h)),console.log("After addMark - tr.doc:",a.doc.toJSON()))}),console.log("About to dispatch transaction"),console.log("Final tr.doc:",a.doc.toJSON()),console.log("Original state.doc:",r.doc.toJSON()),o(a),console.log("Transaction dispatched successfully")),console.log("=== UPDATE MARK COMMAND END ==="),l},$r={uid:"",src:"",type:be.Image,style:"object-fit: contain; width: 100%; border-radius: 0.5rem;",maxWidth:QR,align:Ze.LEFT,caption:"",uploading:!1,progress:0},xA=Mt.create({name:"media",group:"block",atom:!0,addAttributes(){return{uid:{default:$r.uid},src:{default:$r.src},type:{default:$r.type},style:{default:$r.style},maxWidth:{default:$r.maxWidth},align:{default:$r.align},caption:{default:$r.caption},uploading:{default:$r.uploading},progress:{default:$r.progress},payload:{default:null,parseHTML:()=>null,renderHTML:()=>({})}}},draggable(){return!this?.options?.attrs?.uploading&&!this?.options?.attrs?.mediaMode},selectable(){return!this?.options?.attrs?.mediaMode},parseHTML(){return[{tag:"div[data-media]",getAttrs:t=>({uid:t.getAttribute("data-uid")||"",src:t.getAttribute("data-src")||"",type:t.getAttribute("data-type")||be.Image,align:t.getAttribute("data-align")||Ze.LEFT,caption:t.getAttribute("data-caption")||"",style:t.getAttribute("style")||$r.style})}]},renderHTML({HTMLAttributes:t}){const{uid:e,src:n,style:r,type:o,align:s,maxWidth:i,caption:a}=t,l=ZR[o],c=Be({style:V9(s),"data-media":!0,"data-uid":e,"data-type":o,"data-src":n,"data-caption":a||"","data-align":s}),u=Be({src:n,style:W9(r,o,i)},{controls:o===be.Audio||o===be.Video});return["div",c,[l,u]]},addNodeView(){return Ua(H9)},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(pe.near(i))}return!0}).run():e.insertContent([{type:this.name,attrs:t},{type:"paragraph"}]),updateMediaByUid:bA(this.name),deleteMediaByUid:vA(this.name),updateMediaProgress:(t,e)=>({commands:n})=>n.updateMediaByUid(t,{progress:e})}},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 Ao.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?(Ao.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 Ao.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?(Ao.info("Please wait for upload to complete or cancel it first"),!0):!1}}}}),V9=t=>`width: 100%; display: flex; justify-content: ${G9(t)}; margin:16px 0`,W9=(t,e,n)=>`${t}; max-width: ${e===be.Audio?"100%":`${n}%`}; ${e!==be.Audio?"height: auto;":""}`,G9=t=>({[Ze.LEFT]:"flex-start",[Ze.CENTER]:"center",[Ze.RIGHT]:"flex-end"})[t]||"flex-start",es=["#0091d5","#fcc600","#ce50a0","#139e6b"],ts={MIN:1,MAX:4,MAX_TEXT_LENGTH:50},q9=({choice:t,index:e,canRemove:n,onRemove:r})=>{const o=es[e%es.length];return g.jsxs("div",{style:{backgroundColor:o},className:re("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:[g.jsx("span",{className:"text-center text-white font-medium px-4 py-3 text-sm sm:text-base leading-relaxed break-words w-full",children:t.text}),n&&g.jsx(wA,{onRemove:r,index:e}),g.jsx(EA,{number:e+1})]})},K9=({choice:t,index:e,canRemove:n,onRemove:r})=>g.jsxs("div",{style:{backgroundColor:es[e%es.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")?g.jsx("video",{src:t?.sources?.original?.url,className:"object-cover w-full h-full"}):g.jsx("img",{src:t.sources.original.url||t.sources.thumbnail.url,alt:`Poll choice ${e+1}`,className:"object-cover w-full h-full"}),n&&g.jsx(wA,{onRemove:r,index:e}),g.jsx(EA,{number:e+1})]}),wA=({onRemove:t,index:e})=>g.jsx("button",{onClick:t,className:"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:g.jsx(Di,{className:"h-4 w-4"})}),EA=({number:t})=>g.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}),Y9=({value:t,onChange:e,onSubmit:n,disabled:r})=>{const o=i=>{i.key==="Enter"&&(i.preventDefault(),n())},s=t.length>ts.MAX_TEXT_LENGTH*.9;return g.jsx("div",{className:"flex flex-col gap-2",children:g.jsx("div",{className:"flex items-end gap-2",children:g.jsxs("div",{className:"flex-1 space-y-1.5",children:[g.jsx("label",{htmlFor:"poll-text-input",className:"text-sm font-medium text-foreground",children:"Add text option"}),g.jsxs("div",{className:"flex items-center sm:gap-3 gap-1",children:[g.jsx(Im,{id:"poll-text-input",placeholder:"Enter a text option...",value:t,onChange:i=>e(i.target.value),onKeyDown:o,maxLength:ts.MAX_TEXT_LENGTH,disabled:r,className:"transition-all"}),g.jsxs(Rn,{onClick:n,disabled:!t.trim()||r,className:"shrink-0",size:"default",children:[g.jsx(Tm,{className:"h-4 w-4 sm:mr-2"}),g.jsx("span",{className:"hidden sm:inline",children:"Add"})]})]}),g.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[g.jsx("span",{children:"Press Enter to add"}),g.jsxs("span",{className:re("font-mono",s&&"text-amber-600 dark:text-amber-400 font-semibold"),children:[t.length,"/",ts.MAX_TEXT_LENGTH]})]})]})})})},J9=({onFileSelect:t,onImageSelect:e,disabled:n})=>{const r=M.useRef(null),[o,s]=M.useState(!1),i=a=>{const l=a.target.files;if(!l)return;const c=Array.from(l);t(c),a.target.value=""};return g.jsxs("div",{className:"flex xl:flex-wrap items-center gap-2",children:[g.jsxs(Rn,{variant:"ghost",className:"flex-1 cursor-pointer flex items-center justify-center gap-2 bg-accent/50 border border-border/40 hover:bg-accent transition-colors",disabled:n,onClick:()=>r.current?.click(),children:[g.jsx(zk,{className:"h-4 w-4"}),"Upload"]}),g.jsx("input",{ref:r,type:"file",accept:"image/*,video/*",multiple:!0,className:"hidden",onChange:i,disabled:n,"aria-label":"Upload image or video for poll choice"}),g.jsx(mC,{open:o,onOpenChange:s,onImageSelect:e,children:g.jsxs(Rn,{disabled:n,className:"cursor-pointer flex-1",children:[g.jsx(Vk,{})," Search Images"]})})]})},X9=({choiceCount:t,remainingSlots:e})=>g.jsxs("div",{className:"sm:px-4 sm:py-2 p-2 border-b border-border bg-muted/30 flex items-center justify-between",children:[g.jsxs("div",{children:[g.jsx("h3",{className:"font-semibold sm:text-lg",children:"Create Poll"}),g.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[t," of ",ts.MAX," options added"]})]}),e>0&&g.jsxs("span",{className:"text-xs font-medium px-2.5 py-1 rounded-full bg-primary/10 text-primary",children:[e," slot",e!==1?"s":""," left"]})]}),Q9=({slotNumber:t,disabled:e,onDrop:n})=>{const r=M.useRef(null),[o,s]=M.useState(!1),i=u=>{u.preventDefault(),u.stopPropagation(),s(!0)},a=u=>{u.preventDefault(),u.stopPropagation(),s(!1)},l=u=>{u.preventDefault(),u.stopPropagation(),s(!1);const d=Array.from(u.dataTransfer.files).filter(f=>f.type.startsWith("image/")||f.type.startsWith("video/"));d.length>0&&n(d)},c=u=>{const d=u.target.files;if(!d)return;const f=Array.from(d);n(f),u.target.value=""};return g.jsxs(g.Fragment,{children:[g.jsx("input",{ref:r,type:"file",accept:"image/*,video/*",multiple:!0,className:"hidden",onChange:c,disabled:e,"aria-label":"Upload image or video for poll choice"}),g.jsxs("div",{onDragOver:i,onDragLeave:a,onDrop:l,onClick:()=>r.current?.click(),className:re("cursor-pointer rounded-xl border-2 border-dashed min-h-16 lg:min-h-32 flex flex-col items-center justify-center text-sm lg:gap-2 transition-all duration-200",o?"border-primary bg-primary/10 text-primary scale-[1.02] shadow-md":"border-muted-foreground/20 text-muted-foreground/60 bg-muted/20"),children:[g.jsx("div",{className:re("text-xl lg:text-2xl font-bold transition-colors",o?"text-primary/50":"text-muted-foreground/30"),children:t}),g.jsx("span",{className:"text-xs",children:o?"Drop here":"Drag & Drop"}),o&&g.jsx(wm,{className:"h-5 w-5 animate-bounce"})]})]})},Kg=(t,e=To.MEDIA_ITEM,n)=>({key:Yr(),type:e,imageType:t.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}),Z9=t=>"text"in t,eq=(t,e)=>({key:Yr(),type:yc.POLL_TEXT_ITEM,option_id:Yr(),option_color:es[e%es.length],text:t.trim()}),SA=(t,e,n)=>{const o=t?.type?.includes("video")?yc.POLL_MEDIA_ITEM:yc.POLL_IMAGE_ITEM;return{...Kg(t,o,n),option_color:es[e%es.length],option_id:Yr()}},tq=({choices:t,onChange:e})=>{const{fileStore:n}=ga(),[r,o]=M.useState(""),s=ts.MAX-t.length,i=t.length<ts.MAX,a=t.length>ts.MIN,l=()=>{if(!r.trim()||!i)return;const f=eq(r,t.length);e([...t,f]),o("")},c=async f=>{if(!f||!i)return;const p=f.slice(0,s).map(async(v,w)=>{try{const E=await n.uploadImage(v);return SA(E,w)}catch(E){return console.error("Upload failed for",v.name,E),null}}),y=(await Promise.all(p)).filter(v=>v!==null);e([...t,...y])},u=(f,h)=>{const p=ts.MAX-s;n.uploadUrl(f).then(m=>{const y=SA(m,p,h);e([...t,y])}).catch(m=>console.log(m))},d=f=>{if(!a)return;const h=t.filter((p,m)=>m!==f);e(h)};return console.log({choices:t}),g.jsxs("div",{"data-type":"poll",className:"w-full border border-border rounded-xl bg-card shadow-sm overflow-hidden",children:[g.jsx(X9,{choiceCount:t.length,remainingSlots:s}),g.jsxs("div",{className:"sm:p-4 p-2 space-y-6",children:[g.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 sm:gap-4",children:[t.map((f,h)=>Z9(f)?g.jsx(q9,{choice:f,index:h,canRemove:a,onRemove:()=>d(h)},f.key):g.jsx(K9,{choice:f,index:h,canRemove:a,onRemove:()=>d(h)},f.key)),Array.from({length:s}).map((f,h)=>g.jsx(Q9,{disabled:!i,onDrop:c,slotNumber:t.length+h+1},`empty-${h}`))]}),g.jsxs("div",{className:"space-y-3",children:[g.jsx(Y9,{value:r,onChange:o,onSubmit:l,disabled:!i}),g.jsx(J9,{onFileSelect:c,onImageSelect:u,disabled:!i}),!i&&g.jsx("p",{className:"text-xs text-muted-foreground text-center py-2 bg-muted/50 rounded-lg",children:"Maximum number of choices reached. Remove a choice to add more."})]})]})]})},nq=({node:t,updateAttributes:e})=>{const{choices:n}=t.attrs,r=o=>{e({choices:o})};return g.jsx(Uo,{"data-type":"poll","data-drag-handle":"false",className:"not-prose",children:g.jsx(tq,{choices:n,onChange:r,onRemovePoll:()=>{}})})},kA=Mt.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",Be(t,{"data-type":"poll"})]},addNodeView(){return Ua(nq)},addCommands(){return{insertPoll:t=>({chain:e})=>e().insertContent({type:this.name,attrs:t}).run()}},addProseMirrorPlugins(){const t=this.name;return[new He({props:{handleKeyDown:(e,n)=>{const{state:r}=e,{selection:o}=r,s=n.key;if(s!=="Backspace"&&s!=="Delete")return!1;if(o instanceof ue&&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(pe.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 Vd="Popover",[CA]=On(Vd,[Go]),El=Go(),[rq,ns]=CA(Vd),TA=t=>{const{__scopePopover:e,children:n,open:r,defaultOpen:o,onOpenChange:s,modal:i=!1}=t,a=El(e),l=b.useRef(null),[c,u]=b.useState(!1),[d,f]=Jr({prop:r,defaultProp:o??!1,onChange:s,caller:Vd});return g.jsx(Tu,{...a,children:g.jsx(rq,{scope:e,contentId:Bn(),triggerRef:l,open:d,onOpenChange:f,onOpenToggle:b.useCallback(()=>f(h=>!h),[f]),hasCustomAnchor:c,onCustomAnchorAdd:b.useCallback(()=>u(!0),[]),onCustomAnchorRemove:b.useCallback(()=>u(!1),[]),modal:i,children:n})})};TA.displayName=Vd;var AA="PopoverAnchor",oq=b.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=ns(AA,n),s=El(n),{onCustomAnchorAdd:i,onCustomAnchorRemove:a}=o;return b.useEffect(()=>(i(),()=>a()),[i,a]),g.jsx(qa,{...s,...r,ref:e})});oq.displayName=AA;var MA="PopoverTrigger",OA=b.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=ns(MA,n),s=El(n),i=$e(e,o.triggerRef),a=g.jsx(ge.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":DA(o.open),...r,ref:i,onClick:te(t.onClick,o.onOpenToggle)});return o.hasCustomAnchor?a:g.jsx(qa,{asChild:!0,...s,children:a})});OA.displayName=MA;var Yg="PopoverPortal",[sq,iq]=CA(Yg,{forceMount:void 0}),_A=t=>{const{__scopePopover:e,forceMount:n,children:r,container:o}=t,s=ns(Yg,e);return g.jsx(sq,{scope:e,forceMount:n,children:g.jsx(_n,{present:n||s.open,children:g.jsx(Mi,{asChild:!0,container:o,children:r})})})};_A.displayName=Yg;var Hi="PopoverContent",NA=b.forwardRef((t,e)=>{const n=iq(Hi,t.__scopePopover),{forceMount:r=n.forceMount,...o}=t,s=ns(Hi,t.__scopePopover);return g.jsx(_n,{present:r||s.open,children:s.modal?g.jsx(lq,{...o,ref:e}):g.jsx(cq,{...o,ref:e})})});NA.displayName=Hi;var aq=Mo("PopoverContent.RemoveScroll"),lq=b.forwardRef((t,e)=>{const n=ns(Hi,t.__scopePopover),r=b.useRef(null),o=$e(e,r),s=b.useRef(!1);return b.useEffect(()=>{const i=r.current;if(i)return Bu(i)},[]),g.jsx(Xa,{as:aq,allowPinchZoom:!0,children:g.jsx(RA,{...t,ref:o,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:te(t.onCloseAutoFocus,i=>{i.preventDefault(),s.current||n.triggerRef.current?.focus()}),onPointerDownOutside:te(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:te(t.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1})})})}),cq=b.forwardRef((t,e)=>{const n=ns(Hi,t.__scopePopover),r=b.useRef(!1),o=b.useRef(!1);return g.jsx(RA,{...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()}})}),RA=b.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=ns(Hi,n),h=El(n);return Nu(),g.jsx(Ja,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:o,onUnmountAutoFocus:s,children:g.jsx(Si,{asChild:!0,disableOutsidePointerEvents:i,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>f.onOpenChange(!1),children:g.jsx(Au,{"data-state":DA(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)"}})})})}),IA="PopoverClose",uq=b.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=ns(IA,n);return g.jsx(ge.button,{type:"button",...r,ref:e,onClick:te(t.onClick,()=>o.onOpenChange(!1))})});uq.displayName=IA;var dq="PopoverArrow",fq=b.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,o=El(n);return g.jsx(Mu,{...o,...r,ref:e})});fq.displayName=dq;function DA(t){return t?"open":"closed"}var hq=TA,pq=OA,mq=_A,gq=NA;function yq({...t}){return g.jsx(hq,{"data-slot":"popover",...t})}function vq({...t}){return g.jsx(pq,{"data-slot":"popover-trigger",...t})}function bq({className:t,align:e="center",sideOffset:n=4,children:r,...o}){return g.jsx(mq,{children:g.jsx("div",{"data-theme":"select-post-builder",children:g.jsx(gq,{"data-slot":"popover-content",align:e,sideOffset:n,className:re("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 xq=({mark:t,editor:e})=>{const[n,r]=b.useState(!1),[o,s]=b.useState(!1),i=l=>{s(l),l||r(!1)},a=(l,c,u)=>{if(!e.view)return;const d=c||l;if(u){e.commands.updateLink(u,{href:l,text:d});return}};return g.jsxs(yq,{open:n,onOpenChange:r,children:[g.jsx(vq,{children:g.jsx(UB,{className:"text-blue-600 underline hover:text-blue-700 cursor-pointer focus-within:outline-0"})}),g.jsxs(bq,{onOpenAutoFocus:l=>l.preventDefault(),side:"top",align:"center",className:"flex gap-2 items-center p-1 max-w-fit w-fit",children:[g.jsx(xe,{size:"icon",tooltip:"Open Link",onClick:()=>window.open(t.attrs.href,"_blank"),children:g.jsx(Qa,{})}),g.jsx(Dm,{open:o,onOpenChange:i,defaultValues:{link:t?.attrs?.href??"",text:t?.attrs?.text??"",uid:t?.attrs?.uid??""},onInsertLink:a,children:g.jsx(xe,{size:"icon",tooltip:"Edit Link",children:g.jsx(yU,{})})}),g.jsx(xe,{size:"icon",tooltip:"Unset Link",onClick:()=>{r(!1),e.commands.unsetLink(),t?.attrs?.uid&&e.commands.deleteLinkPreviewByUid(t?.attrs?.uid)},children:g.jsx(xU,{})})]})]})},PA=jg.extend({name:"customLink",addOptions(){return{...this?.parent?.(),api:void 0}},addAttributes(){return{...this?.parent?.(),text:{default:null},uid:{default:null,parseHTML:()=>null,renderHTML:()=>({})}}},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Xo(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",Be(this.options.HTMLAttributes,t),0]:["a",Be(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{...this?.parent?.(),insertLink:t=>({chain:e,editor:n})=>{const{href:r,text:o}=t,s=Yr(),i=wq(n),a=this.options.linkMode?i??s:s;return e().insertContent([{type:"text",text:o,marks:[{type:"customLink",attrs:{uid:s,href:r,text:o}}]},this.options.linkMode?{type:"text",text:" "}:null].filter(l=>l!==null))?.setLinkPreview({uid:a,loading:!0,href:""})?.run(),this?.options?.api?.resolveUrl(r)?.then(l=>{if(l){n?.chain()?.updateLinkPreviewByUid(a,{loading:!1,href:l.url,title:l.title,image:l.image?.url??null,description:l.description,domain:new URL(l.url).hostname})?.run();return}n.commands.deleteLinkPreviewByUid(s)})?.catch(()=>n.commands.deleteLinkPreviewByUid(s)),!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},y=e.text??e.href??p,v=i.marks.customLink;if(v){l=l.delete(d,f);const w=i.text(y,[v.create(m)]);l=l.insert(d,w)}}),r(l),e.href&&queueMicrotask(()=>{this.options.api?.resolveUrl(e.href)?.then(d=>{if(console.log({metadata:d}),d){let f=!1;o.state.doc.descendants(p=>{if(p.type.name==="linkPreview"&&p.attrs.uid===t)return f=!0,!1});const h={uid:t,href:d.url,title:d.title,image:d.image?.url??null,description:d.description,domain:new URL(d.url).hostname,loading:!1};f?o.commands.updateLinkPreviewByUid(t,h):o.commands.setLinkPreview(h)}else o.commands.deleteLinkPreviewByUid(t)}).catch(d=>{console.log("LINK UPDATE ERR::",{err:d}),o.commands.deleteLinkPreviewByUid(t)})})),c},updateLinkByUid:U9("customLink"),deleteLinkByUid:z9("customLink")}},addMarkView(){return WB(xq)},addKeyboardShortcuts(){return{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}}}}),wq=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},Eq=t=>t.includes("spotify.com/embed/track"),Sq=({node:t,selected:e,editor:n,deleteNode:r})=>{const{src:o}=t.attrs,s=()=>{r(),n.chain().focus()};return g.jsxs(Uo,{"data-drag-handle":!0,className:re("relative p-4 bg-accent",e&&"border-2 border-blue-500"),children:[g.jsx("iframe",{src:o,allowFullScreen:!0,className:re("w-full rounded-md",Eq(o)?"h-38":"h-96")}),g.jsx(Rn,{onClick:s,size:"icon",variant:"ghost",className:"absolute right-2 top-2 bg-background border hover:shadow-lg size-auto p-1.5 rounded-full",children:g.jsx(Di,{})})]},o)};/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */const{entries:LA,setPrototypeOf:jA,isFrozen:kq,getPrototypeOf:Cq,getOwnPropertyDescriptor:Tq}=Object;let{freeze:an,seal:Kn,create:Jg}=Object,{apply:Xg,construct:Qg}=typeof Reflect<"u"&&Reflect;an||(an=function(e){return e}),Kn||(Kn=function(e){return e}),Xg||(Xg=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)}),Qg||(Qg=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 Wd=cn(Array.prototype.forEach),Aq=cn(Array.prototype.lastIndexOf),$A=cn(Array.prototype.pop),Sl=cn(Array.prototype.push),Mq=cn(Array.prototype.splice),Gd=cn(String.prototype.toLowerCase),Zg=cn(String.prototype.toString),ey=cn(String.prototype.match),kl=cn(String.prototype.replace),Oq=cn(String.prototype.indexOf),_q=cn(String.prototype.trim),pr=cn(Object.prototype.hasOwnProperty),ln=cn(RegExp.prototype.test),Cl=Nq(TypeError);function cn(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 Xg(t,e,r)}}function Nq(t){return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return Qg(t,n)}}function Le(t,e){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Gd;jA&&jA(t,null);let r=e.length;for(;r--;){let o=e[r];if(typeof o=="string"){const s=n(o);s!==o&&(kq(e)||(e[r]=s),o=s)}t[o]=!0}return t}function Rq(t){for(let e=0;e<t.length;e++)pr(t,e)||(t[e]=null);return t}function mo(t){const e=Jg(null);for(const[n,r]of LA(t))pr(t,n)&&(Array.isArray(r)?e[n]=Rq(r):r&&typeof r=="object"&&r.constructor===Object?e[n]=mo(r):e[n]=r);return e}function Tl(t,e){for(;t!==null;){const r=Tq(t,e);if(r){if(r.get)return cn(r.get);if(typeof r.value=="function")return cn(r.value)}t=Cq(t)}function n(){return null}return n}const BA=an(["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"]),ty=an(["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"]),ny=an(["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"]),Iq=an(["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"]),ry=an(["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"]),Dq=an(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),FA=an(["#text"]),HA=an(["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"]),oy=an(["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"]),zA=an(["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"]),qd=an(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Pq=Kn(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Lq=Kn(/<%[\w\W]*|[\w\W]*%>/gm),jq=Kn(/\$\{[\w\W]*/gm),$q=Kn(/^data-[\-\w.\u00B7-\uFFFF]+$/),Bq=Kn(/^aria-[\-\w]+$/),UA=Kn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Fq=Kn(/^(?:\w+script|data):/i),Hq=Kn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),VA=Kn(/^html$/i),zq=Kn(/^[a-z][.\w]*(-[.\w]+)+$/i);var WA=Object.freeze({__proto__:null,ARIA_ATTR:Bq,ATTR_WHITESPACE:Hq,CUSTOM_ELEMENT:zq,DATA_ATTR:$q,DOCTYPE_NAME:VA,ERB_EXPR:Lq,IS_ALLOWED_URI:UA,IS_SCRIPT_OR_DATA:Fq,MUSTACHE_EXPR:Pq,TMPLIT_EXPR:jq});const Al={element:1,text:3,progressingInstruction:7,comment:8,document:9},Uq=function(){return typeof window>"u"?null:window},Vq=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 console.warn("TrustedTypes policy "+s+" could not be created."),null}},GA=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function qA(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Uq();const e=fe=>qA(fe);if(e.version="3.3.0",e.removed=[],!t||!t.document||t.document.nodeType!==Al.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=Tl(p,"cloneNode"),y=Tl(p,"remove"),v=Tl(p,"nextSibling"),w=Tl(p,"childNodes"),E=Tl(p,"parentNode");if(typeof i=="function"){const fe=n.createElement("template");fe.content&&fe.content.ownerDocument&&(n=fe.content.ownerDocument)}let x,k="";const{implementation:S,createNodeIterator:C,createDocumentFragment:T,getElementsByTagName:N}=n,{importNode:_}=r;let L=GA();e.isSupported=typeof LA=="function"&&typeof E=="function"&&S&&S.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:$,ERB_EXPR:B,TMPLIT_EXPR:z,DATA_ATTR:j,ARIA_ATTR:P,IS_SCRIPT_OR_DATA:H,ATTR_WHITESPACE:R,CUSTOM_ELEMENT:V}=WA;let{IS_ALLOWED_URI:ie}=WA,ne=null;const ye=Le({},[...BA,...ty,...ny,...ry,...FA]);let G=null;const Z=Le({},[...HA,...oy,...zA,...qd]);let J=Object.seal(Jg(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}})),me=null,U=null;const ee=Object.seal(Jg(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Oe=!0,he=!0,we=!1,Se=!0,Ve=!1,ut=!0,dt=!1,Ot=!1,yt=!1,_t=!1,xt=!1,Nt=!1,Gt=!0,it=!1;const Rt="user-content-";let Tn=!0,An=!1,Bt={},fn=null;const er=Le({},["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 Vr=null;const $n=Le({},["audio","video","img","source","image","track"]);let Wr=null;const hn=Le({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Sr="http://www.w3.org/1998/Math/MathML",D="http://www.w3.org/2000/svg",X="http://www.w3.org/1999/xhtml";let ae=X,De=!1,ke=null;const qe=Le({},[Sr,D,X],Zg);let wt=Le({},["mi","mo","mn","ms","mtext"]),en=Le({},["annotation-xml"]);const Gr=Le({},["title","style","font","a","script"]);let Ft=null;const ve=["application/xhtml+xml","text/html"],Ke="text/html";let Ee=null,at=null;const tr=n.createElement("form"),Qe=function(O){return O instanceof RegExp||O instanceof Function},A=function(){let O=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(at&&at===O)){if((!O||typeof O!="object")&&(O={}),O=mo(O),Ft=ve.indexOf(O.PARSER_MEDIA_TYPE)===-1?Ke:O.PARSER_MEDIA_TYPE,Ee=Ft==="application/xhtml+xml"?Zg:Gd,ne=pr(O,"ALLOWED_TAGS")?Le({},O.ALLOWED_TAGS,Ee):ye,G=pr(O,"ALLOWED_ATTR")?Le({},O.ALLOWED_ATTR,Ee):Z,ke=pr(O,"ALLOWED_NAMESPACES")?Le({},O.ALLOWED_NAMESPACES,Zg):qe,Wr=pr(O,"ADD_URI_SAFE_ATTR")?Le(mo(hn),O.ADD_URI_SAFE_ATTR,Ee):hn,Vr=pr(O,"ADD_DATA_URI_TAGS")?Le(mo($n),O.ADD_DATA_URI_TAGS,Ee):$n,fn=pr(O,"FORBID_CONTENTS")?Le({},O.FORBID_CONTENTS,Ee):er,me=pr(O,"FORBID_TAGS")?Le({},O.FORBID_TAGS,Ee):mo({}),U=pr(O,"FORBID_ATTR")?Le({},O.FORBID_ATTR,Ee):mo({}),Bt=pr(O,"USE_PROFILES")?O.USE_PROFILES:!1,Oe=O.ALLOW_ARIA_ATTR!==!1,he=O.ALLOW_DATA_ATTR!==!1,we=O.ALLOW_UNKNOWN_PROTOCOLS||!1,Se=O.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Ve=O.SAFE_FOR_TEMPLATES||!1,ut=O.SAFE_FOR_XML!==!1,dt=O.WHOLE_DOCUMENT||!1,_t=O.RETURN_DOM||!1,xt=O.RETURN_DOM_FRAGMENT||!1,Nt=O.RETURN_TRUSTED_TYPE||!1,yt=O.FORCE_BODY||!1,Gt=O.SANITIZE_DOM!==!1,it=O.SANITIZE_NAMED_PROPS||!1,Tn=O.KEEP_CONTENT!==!1,An=O.IN_PLACE||!1,ie=O.ALLOWED_URI_REGEXP||UA,ae=O.NAMESPACE||X,wt=O.MATHML_TEXT_INTEGRATION_POINTS||wt,en=O.HTML_INTEGRATION_POINTS||en,J=O.CUSTOM_ELEMENT_HANDLING||{},O.CUSTOM_ELEMENT_HANDLING&&Qe(O.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(J.tagNameCheck=O.CUSTOM_ELEMENT_HANDLING.tagNameCheck),O.CUSTOM_ELEMENT_HANDLING&&Qe(O.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(J.attributeNameCheck=O.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),O.CUSTOM_ELEMENT_HANDLING&&typeof O.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(J.allowCustomizedBuiltInElements=O.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Ve&&(he=!1),xt&&(_t=!0),Bt&&(ne=Le({},FA),G=[],Bt.html===!0&&(Le(ne,BA),Le(G,HA)),Bt.svg===!0&&(Le(ne,ty),Le(G,oy),Le(G,qd)),Bt.svgFilters===!0&&(Le(ne,ny),Le(G,oy),Le(G,qd)),Bt.mathMl===!0&&(Le(ne,ry),Le(G,zA),Le(G,qd))),O.ADD_TAGS&&(typeof O.ADD_TAGS=="function"?ee.tagCheck=O.ADD_TAGS:(ne===ye&&(ne=mo(ne)),Le(ne,O.ADD_TAGS,Ee))),O.ADD_ATTR&&(typeof O.ADD_ATTR=="function"?ee.attributeCheck=O.ADD_ATTR:(G===Z&&(G=mo(G)),Le(G,O.ADD_ATTR,Ee))),O.ADD_URI_SAFE_ATTR&&Le(Wr,O.ADD_URI_SAFE_ATTR,Ee),O.FORBID_CONTENTS&&(fn===er&&(fn=mo(fn)),Le(fn,O.FORBID_CONTENTS,Ee)),Tn&&(ne["#text"]=!0),dt&&Le(ne,["html","head","body"]),ne.table&&(Le(ne,["tbody"]),delete me.tbody),O.TRUSTED_TYPES_POLICY){if(typeof O.TRUSTED_TYPES_POLICY.createHTML!="function")throw Cl('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof O.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Cl('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');x=O.TRUSTED_TYPES_POLICY,k=x.createHTML("")}else x===void 0&&(x=Vq(h,o)),x!==null&&typeof k=="string"&&(k=x.createHTML(""));an&&an(O),at=O}},W=Le({},[...ty,...ny,...Iq]),Y=Le({},[...ry,...Dq]),ce=function(O){let K=E(O);(!K||!K.tagName)&&(K={namespaceURI:ae,tagName:"template"});const le=Gd(O.tagName),ct=Gd(K.tagName);return ke[O.namespaceURI]?O.namespaceURI===D?K.namespaceURI===X?le==="svg":K.namespaceURI===Sr?le==="svg"&&(ct==="annotation-xml"||wt[ct]):!!W[le]:O.namespaceURI===Sr?K.namespaceURI===X?le==="math":K.namespaceURI===D?le==="math"&&en[ct]:!!Y[le]:O.namespaceURI===X?K.namespaceURI===D&&!en[ct]||K.namespaceURI===Sr&&!wt[ct]?!1:!Y[le]&&(Gr[le]||!W[le]):!!(Ft==="application/xhtml+xml"&&ke[O.namespaceURI]):!1},Ne=function(O){Sl(e.removed,{element:O});try{E(O).removeChild(O)}catch{y(O)}},Ce=function(O,K){try{Sl(e.removed,{attribute:K.getAttributeNode(O),from:K})}catch{Sl(e.removed,{attribute:null,from:K})}if(K.removeAttribute(O),O==="is")if(_t||xt)try{Ne(K)}catch{}else try{K.setAttribute(O,"")}catch{}},je=function(O){let K=null,le=null;if(yt)O="<remove></remove>"+O;else{const Ct=ey(O,/^[\r\n\t ]+/);le=Ct&&Ct[0]}Ft==="application/xhtml+xml"&&ae===X&&(O='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+O+"</body></html>");const ct=x?x.createHTML(O):O;if(ae===X)try{K=new f().parseFromString(ct,Ft)}catch{}if(!K||!K.documentElement){K=S.createDocument(ae,"template",null);try{K.documentElement.innerHTML=De?k:ct}catch{}}const tn=K.body||K.documentElement;return O&&le&&tn.insertBefore(n.createTextNode(le),tn.childNodes[0]||null),ae===X?N.call(K,dt?"html":"body")[0]:dt?K.documentElement:tn},Pe=function(O){return C.call(O.ownerDocument||O,O,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},It=function(O){return O instanceof d&&(typeof O.nodeName!="string"||typeof O.textContent!="string"||typeof O.removeChild!="function"||!(O.attributes instanceof u)||typeof O.removeAttribute!="function"||typeof O.setAttribute!="function"||typeof O.namespaceURI!="string"||typeof O.insertBefore!="function"||typeof O.hasChildNodes!="function")},lt=function(O){return typeof a=="function"&&O instanceof a};function We(fe,O,K){Wd(fe,le=>{le.call(e,O,K,at)})}const nr=function(O){let K=null;if(We(L.beforeSanitizeElements,O,null),It(O))return Ne(O),!0;const le=Ee(O.nodeName);if(We(L.uponSanitizeElement,O,{tagName:le,allowedTags:ne}),ut&&O.hasChildNodes()&&!lt(O.firstElementChild)&&ln(/<[/\w!]/g,O.innerHTML)&&ln(/<[/\w!]/g,O.textContent)||O.nodeType===Al.progressingInstruction||ut&&O.nodeType===Al.comment&&ln(/<[/\w]/g,O.data))return Ne(O),!0;if(!(ee.tagCheck instanceof Function&&ee.tagCheck(le))&&(!ne[le]||me[le])){if(!me[le]&&rc(le)&&(J.tagNameCheck instanceof RegExp&&ln(J.tagNameCheck,le)||J.tagNameCheck instanceof Function&&J.tagNameCheck(le)))return!1;if(Tn&&!fn[le]){const ct=E(O)||O.parentNode,tn=w(O)||O.childNodes;if(tn&&ct){const Ct=tn.length;for(let Mn=Ct-1;Mn>=0;--Mn){const Co=m(tn[Mn],!0);Co.__removalCount=(O.__removalCount||0)+1,ct.insertBefore(Co,v(O))}}}return Ne(O),!0}return O instanceof l&&!ce(O)||(le==="noscript"||le==="noembed"||le==="noframes")&&ln(/<\/no(script|embed|frames)/i,O.innerHTML)?(Ne(O),!0):(Ve&&O.nodeType===Al.text&&(K=O.textContent,Wd([$,B,z],ct=>{K=kl(K,ct," ")}),O.textContent!==K&&(Sl(e.removed,{element:O.cloneNode()}),O.textContent=K)),We(L.afterSanitizeElements,O,null),!1)},ko=function(O,K,le){if(Gt&&(K==="id"||K==="name")&&(le in n||le in tr))return!1;if(!(he&&!U[K]&&ln(j,K))){if(!(Oe&&ln(P,K))){if(!(ee.attributeCheck instanceof Function&&ee.attributeCheck(K,O))){if(!G[K]||U[K]){if(!(rc(O)&&(J.tagNameCheck instanceof RegExp&&ln(J.tagNameCheck,O)||J.tagNameCheck instanceof Function&&J.tagNameCheck(O))&&(J.attributeNameCheck instanceof RegExp&&ln(J.attributeNameCheck,K)||J.attributeNameCheck instanceof Function&&J.attributeNameCheck(K,O))||K==="is"&&J.allowCustomizedBuiltInElements&&(J.tagNameCheck instanceof RegExp&&ln(J.tagNameCheck,le)||J.tagNameCheck instanceof Function&&J.tagNameCheck(le))))return!1}else if(!Wr[K]){if(!ln(ie,kl(le,R,""))){if(!((K==="src"||K==="xlink:href"||K==="href")&&O!=="script"&&Oq(le,"data:")===0&&Vr[O])){if(!(we&&!ln(H,kl(le,R,"")))){if(le)return!1}}}}}}}return!0},rc=function(O){return O!=="annotation-xml"&&ey(O,V)},rr=function(O){We(L.beforeSanitizeAttributes,O,null);const{attributes:K}=O;if(!K||It(O))return;const le={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:G,forceKeepAttr:void 0};let ct=K.length;for(;ct--;){const tn=K[ct],{name:Ct,namespaceURI:Mn,value:Co}=tn,ia=Ee(Ct),Mv=Co;let qt=Ct==="value"?Mv:_q(Mv);if(le.attrName=ia,le.attrValue=qt,le.keepAttr=!0,le.forceKeepAttr=void 0,We(L.uponSanitizeAttribute,O,le),qt=le.attrValue,it&&(ia==="id"||ia==="name")&&(Ce(Ct,O),qt=Rt+qt),ut&&ln(/((--!?|])>)|<\/(style|title|textarea)/i,qt)){Ce(Ct,O);continue}if(ia==="attributename"&&ey(qt,"href")){Ce(Ct,O);continue}if(le.forceKeepAttr)continue;if(!le.keepAttr){Ce(Ct,O);continue}if(!Se&&ln(/\/>/i,qt)){Ce(Ct,O);continue}Ve&&Wd([$,B,z],wN=>{qt=kl(qt,wN," ")});const xN=Ee(O.nodeName);if(!ko(xN,ia,qt)){Ce(Ct,O);continue}if(x&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!Mn)switch(h.getAttributeType(xN,ia)){case"TrustedHTML":{qt=x.createHTML(qt);break}case"TrustedScriptURL":{qt=x.createScriptURL(qt);break}}if(qt!==Mv)try{Mn?O.setAttributeNS(Mn,Ct,qt):O.setAttribute(Ct,qt),It(O)?Ne(O):$A(e.removed)}catch{Ce(Ct,O)}}We(L.afterSanitizeAttributes,O,null)},qZ=function fe(O){let K=null;const le=Pe(O);for(We(L.beforeSanitizeShadowDOM,O,null);K=le.nextNode();)We(L.uponSanitizeShadowNode,K,null),nr(K),rr(K),K.content instanceof s&&fe(K.content);We(L.afterSanitizeShadowDOM,O,null)};return e.sanitize=function(fe){let O=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},K=null,le=null,ct=null,tn=null;if(De=!fe,De&&(fe="<!-->"),typeof fe!="string"&&!lt(fe))if(typeof fe.toString=="function"){if(fe=fe.toString(),typeof fe!="string")throw Cl("dirty is not a string, aborting")}else throw Cl("toString is not a function");if(!e.isSupported)return fe;if(Ot||A(O),e.removed=[],typeof fe=="string"&&(An=!1),An){if(fe.nodeName){const Co=Ee(fe.nodeName);if(!ne[Co]||me[Co])throw Cl("root node is forbidden and cannot be sanitized in-place")}}else if(fe instanceof a)K=je("<!---->"),le=K.ownerDocument.importNode(fe,!0),le.nodeType===Al.element&&le.nodeName==="BODY"||le.nodeName==="HTML"?K=le:K.appendChild(le);else{if(!_t&&!Ve&&!dt&&fe.indexOf("<")===-1)return x&&Nt?x.createHTML(fe):fe;if(K=je(fe),!K)return _t?null:Nt?k:""}K&&yt&&Ne(K.firstChild);const Ct=Pe(An?fe:K);for(;ct=Ct.nextNode();)nr(ct),rr(ct),ct.content instanceof s&&qZ(ct.content);if(An)return fe;if(_t){if(xt)for(tn=T.call(K.ownerDocument);K.firstChild;)tn.appendChild(K.firstChild);else tn=K;return(G.shadowroot||G.shadowrootmode)&&(tn=_.call(r,tn,!0)),tn}let Mn=dt?K.outerHTML:K.innerHTML;return dt&&ne["!doctype"]&&K.ownerDocument&&K.ownerDocument.doctype&&K.ownerDocument.doctype.name&&ln(VA,K.ownerDocument.doctype.name)&&(Mn="<!DOCTYPE "+K.ownerDocument.doctype.name+`>
499
- `+Mn),Ve&&Wd([$,B,z],Co=>{Mn=kl(Mn,Co," ")}),x&&Nt?x.createHTML(Mn):Mn},e.setConfig=function(){let fe=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};A(fe),Ot=!0},e.clearConfig=function(){at=null,Ot=!1},e.isValidAttribute=function(fe,O,K){at||A({});const le=Ee(fe),ct=Ee(O);return ko(le,ct,K)},e.addHook=function(fe,O){typeof O=="function"&&Sl(L[fe],O)},e.removeHook=function(fe,O){if(O!==void 0){const K=Aq(L[fe],O);return K===-1?void 0:Mq(L[fe],K,1)[0]}return $A(L[fe])},e.removeHooks=function(fe){L[fe]=[]},e.removeAllHooks=function(){L=GA()},e}var sy=qA();const Wq=["youtube.com","www.youtube.com","youtube-nocookie.com","www.youtube-nocookie.com","open.spotify.com","spotify.com"];function KA(t){try{const e=new URL(t);if(e.protocol!=="https:")return!1;const n=e.hostname.toLowerCase();return Wq.some(r=>n===r||n.endsWith(`.${r}`))}catch{return!1}}const Gq=()=>{const t={ADD_TAGS:["iframe"],ADD_ATTR:["src","width","height","frameborder","allowfullscreen","allow","sandbox","loading","referrerpolicy","title"],ALLOWED_URI_REGEXP:/^https:\/\//};return sy.addHook("uponSanitizeElement",(e,n)=>{if(n.tagName==="iframe"){const o=e.getAttribute("src")||"";KA(o)||(console.warn("🚨 Blocked iframe from non-allowed domain:",o),e.parentNode?.removeChild(e))}}),t};function qq(t){try{const e=Gq(),n=sy.sanitize(t,e);if(!n.includes("<iframe"))return console.warn("⚠️ No valid iframe found after sanitization"),null;const r=n.match(/<iframe[^>]*src=["']([^"']+)["']/i);return!r||!r[1]||!KA(r[1])?null:r[1]}catch(e){return console.error("🚨 Error sanitizing iframe:",e),null}finally{sy.removeAllHooks()}}const YA=t=>new RegExp(Zk).test(t.trim()),JA=t=>new RegExp(e1).test(t.trim()),XA=t=>{const e=t.trim();if(YA(e)){const r=e.match(IU)?.[1];return r?`https://www.youtube.com/embed/${r}`:null}if(JA(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},QA=t=>YA(t)||JA(t),ZA=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 console.log({match:o,matches:n}),n.length>0?n:null},Kq=Mt.create({name:"iframe",group:"block",atom:!0,selectable:!0,draggable:!0,priority:1e3,addAttributes(){return{src:{default:null},width:{default:"100%"},maxWidth:{default:"100%",renderHTML:t=>({style:`max-width: ${t.maxWidth}`})},height:{default:"320"}}},parseHTML(){return[{tag:"iframe[src]"}]},renderHTML({HTMLAttributes:t}){return["iframe",Be(t,{class:"my-4"})]},addNodeView(){return Ua(Sq)},addPasteRules(){return[{find:/<iframe.*?src="(.*?)".*?<\/iframe>/gi,handler:({state:t,range:e,match:n})=>{const r=n[0],o=qq(r);if(!o){console.warn("🚨 Blocked unsafe iframe paste"),Ao.error("🚨 Your pasted iframe is not safe to render");return}console.log("✅ Safe iframe URL validated:",o);const s=this.type.create({src:o});t.tr.replaceRangeWith(e.from,e.to,s)}},{find:ZA(Zk),handler:({state:t,range:e,match:n})=>{const r=n[0],o=XA(r);if(console.log({match:n,fullUrl:r,embedUrl:o}),!o)return;const s=this.type.create({src:o});t.tr.replaceRangeWith(e.from,e.to,s)}},{find:ZA(e1),handler:({state:t,range:e,match:n})=>{const r=n[0],o=XA(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}}}}),Yq=t=>{const e=t.clipboardData;return e&&e.getData("text/plain")||null},Jq=(t,e,n,r)=>{n.preventDefault();const o=Za(e);return r&&t.commands.insertMediaWithUpload&&KU(o).then(s=>{s&&t.commands.insertMediaWithUpload({source:s?.src,type:s?.type,mediaType:To.MEDIA_ITEM})}).catch(s=>console.error("[SmartLinkPaste] Media detection failed, falling back to link:",s)),console.log("[SmartLinkPaste] Inserting as link node"),t.chain().focus().insertLink({href:o,text:e}).run(),!0},Xq=(t,e,n)=>{const r=VU(t);if(!$U(r))return!1;const o=r1(r),s=Za(e);return n.chain().focus().deleteSelection().insertLink({href:s,text:o}).run(),!0},Qq=(t,e)=>(n,r)=>{try{const o=Yq(r);if(!o||!Ds(o))return!1;const s=o.trim();return console.log("[SmartLinkPaste] Valid URL detected:",QA(s)),QA(s)&&e?.autoEmbed?(r.preventDefault(),!1):!n.state.selection.empty&&e?.autoLinkSelection?(r.preventDefault(),Xq(n,s,t)):Jq(t,s,r,e?.autoDetectMedia??!0)}catch(o){return console.error("[SmartLinkPaste] Error:",o),!1}},Zq=t=>e=>{const n=WU(e.content);if(Ds(n.trim()))return e;try{return console.log("[SmartLinkPaste] Transforming inline URLs in pasted content"),QU(t,e)}catch(r){return console.error("[SmartLinkPaste] Transform error:",r),e}},eM=Je.create({name:"smartLinkPaste",addOptions(){return{enableTransformPasted:!1,autoDetectMedia:!0,autoEmbed:!0,autoLinkSelection:!0,api:void 0}},addProseMirrorPlugins(){const{editor:t,options:e}=this,n={handlePaste:Qq(t,e)};return e.enableTransformPasted&&(n.transformPasted=Zq(t)),[new He({key:new Ue("smartLinkPaste"),props:n})]}}),eK=async t=>{const e=t?.file,n=t?.api,r=t?.onProgress,o=t?.mediaItemType,s=e instanceof File?e:new File([e],"upload.bin",{type:e.type});r&&r(10);const i=tM(r,10,90);try{const a=await n.uploadImage(s),l=Kg(a,o);return i&&clearInterval(i),r&&r(100),l}catch(a){throw i&&clearInterval(i),a}},tK=async t=>{const e=t?.url,n=t?.api,r=t?.onProgress,o=t?.mediaItemType,s=t?.searchFrom;r&&r(25);const i=tM(r,25,90);try{const a=await n.uploadUrl(e),l=Kg(a,o,s);return i&&clearInterval(i),r&&r(100),l}catch(a){throw i&&clearInterval(i),a}};function tM(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 nM=Je.create({name:"smartMediaUpload",addOptions(){return{api:void 0,maxFileSize:rI,allowedFileTypes:["image/*","video/*","audio/*"],maxConcurrentUploads:ma,onUploadStart:void 0,onUploadProgress:void 0,onUploadComplete:void 0,onUploadError:void 0}},addCommands(){return{insertMediaWithUpload:({source:t,type:e,caption:n,mediaType:r,searchFrom:o})=>({commands:s,editor:i})=>{const a=Yr(),l=this.options;if(!l.api)return console.error("API instance not provided to SmartMediaUpload"),!1;if(Nc(t)){const u=xP(t,l.maxFileSize,l.allowedFileTypes);if(!u.valid)return console.error("File validation failed:",u.error),l.onUploadError?.(a,new Error(u.error)),!1}const c=Nc(t)?URL.createObjectURL(t):t;return s.insertMedia({uid:a,src:c,type:e,caption:n||"",uploading:!0,progress:0}),Nc(t)&&this.storage.blobUrls.set(a,c),this.storage.uploadQueue.push({uid:a,source:t,type:e,caption:n}),this.storage.processUploadQueue(i,r,o),!0}}},addStorage(){return{uploadQueue:[],activeUploads:0,blobUrls:new Map,processUploadQueue:null}},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;await(async()=>{try{i.onUploadStart?.(s.uid);let a;if(Nc(s.source))a=await eK({file:s.source,api:i.api,mediaItemType:n,onProgress:u=>{e.commands.updateMediaProgress(s.uid,u),i.onUploadProgress?.(s.uid,u)}});else if(bP(Za(s.source)))a=await tK({url:s.source,api:i.api,mediaItemType:n,searchFrom:r,onProgress:u=>{e.commands.updateMediaProgress(s.uid,u),i.onUploadProgress?.(s.uid,u)}});else throw new Error("Invalid source type");const l=this.storage.blobUrls.get(s.uid);l&&(URL.revokeObjectURL(l),this.storage.blobUrls.delete(s.uid));const c=a?.sources?.original?.url||a?.sources?.thumbnail?.url;c?e.commands.updateMediaByUid(s.uid,{src:c,uploading:!1,progress:100,payload:a}):e.commands.deleteMediaByUid(s.uid),i.onUploadComplete?.(s.uid,c)}catch(a){console.error("Upload failed:",a);const l=this.storage.blobUrls.get(s.uid);l&&(URL.revokeObjectURL(l),this.storage.blobUrls.delete(s.uid)),e.commands.deleteMediaByUid(s.uid),i.onUploadError?.(s.uid,a)}finally{this.storage.activeUploads--,this.storage.processUploadQueue(e)}})().catch(a=>console.log(a)),this.storage.uploadQueue.length>0&&this.storage.processUploadQueue(e)};this.storage.processUploadQueue=t},onDestroy(){this.storage.blobUrls.forEach(t=>URL.revokeObjectURL(t)),this.storage.blobUrls.clear()},addProseMirrorPlugins(){const{editor:t}=this;return[new He({key:new Ue("smartMediaUpload"),props:{handleDrop:(e,n)=>{const r=Array.from(n.dataTransfer?.files||[]);return r.length===0?!1:r.length>ma?(Ao.error(`You can upload at most ${ma} media files at a time`),!1):(n.preventDefault(),r.forEach(o=>{let s;if(o.type.startsWith("image/"))s=be.Image;else if(o.type.startsWith("video/"))s=be.Video;else if(o.type.startsWith("audio/"))s=be.Audio;else return;t.commands.insertMediaWithUpload({source:o,type:s,mediaType:To.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:be.Image,mediaType:a?To.IMAGE_ITEM:To.MEDIA_ITEM})}}),!0)}}})]}});function nK(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:s,startOfLine:i,$position:a}=t,l=r&&!o,c=hB(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,y=Array.from(p.matchAll(h)).pop();if(!y||y.input===void 0||y.index===void 0)return null;const v=y.input.slice(Math.max(0,y.index-1),y.index),w=new RegExp(`^[${s?.join("")}\0]?$`).test(v);if(s!==null&&!w)return null;const E=m+y.index;let x=E+y[0].length;return l&&u.test(p.slice(x-1,x+1))&&(y[0]+=" ",x+=1),E<a.pos&&x>=a.pos?{range:{from:E,to:x},query:y[0].slice(n.length),text:y[0]}:null}var rK=new Ue("suggestion");function oK({pluginKey:t=rK,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=nK}){let y;const v=h?.(),w=()=>{const S=e.state.selection.$anchor.pos,C=e.view.coordsAtPos(S),{top:T,right:N,bottom:_,left:L}=C;try{return new DOMRect(L,T,N-L,_-T)}catch{return null}},E=(S,C)=>C?()=>{const T=t.getState(e.state),N=T?.decorationId,_=S.dom.querySelector(`[data-decoration-id="${N}"]`);return _?.getBoundingClientRect()||null}:w;function x(S,C){var T;try{const _=t.getState(S.state),L=_?.decorationId?S.dom.querySelector(`[data-decoration-id="${_.decorationId}"]`):null,$={editor:e,range:_?.range||{from:0,to:0},query:_?.query||null,text:_?.text||null,items:[],command:B=>d({editor:e,range:_?.range||{from:0,to:0},props:B}),decorationNode:L,clientRect:E(S,L)};(T=v?.onExit)==null||T.call(v,$)}catch{}const N=S.state.tr.setMeta(C,{exit:!0});S.dispatch(N)}const k=new He({key:t,view(){return{update:async(S,C)=>{var T,N,_,L,$,B,z;const j=(T=this.key)==null?void 0:T.getState(C),P=(N=this.key)==null?void 0:N.getState(S.state),H=j.active&&P.active&&j.range.from!==P.range.from,R=!j.active&&P.active,V=j.active&&!P.active,ie=!R&&!V&&j.query!==P.query,ne=R||H&&ie,ye=ie||H,G=V||H&&ie;if(!ne&&!ye&&!G)return;const Z=G&&!ne?j:P,J=S.dom.querySelector(`[data-decoration-id="${Z.decorationId}"]`);y={editor:e,range:Z.range,query:Z.query,text:Z.text,items:[],command:me=>d({editor:e,range:Z.range,props:me}),decorationNode:J,clientRect:E(S,J)},ne&&((_=v?.onBeforeStart)==null||_.call(v,y)),ye&&((L=v?.onBeforeUpdate)==null||L.call(v,y)),(ye||ne)&&(y.items=await f({editor:e,query:Z.query})),G&&(($=v?.onExit)==null||$.call(v,y)),ye&&((B=v?.onUpdate)==null||B.call(v,y)),ne&&((z=v?.onStart)==null||z.call(v,y))},destroy:()=>{var S;y&&((S=v?.onExit)==null||S.call(v,y))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(S,C,T,N){const{isEditable:_}=e,{composing:L}=e.view,{selection:$}=S,{empty:B,from:z}=$,j={...C},P=S.getMeta(t);if(P&&P.exit)return j.active=!1,j.decorationId=null,j.range={from:0,to:0},j.query=null,j.text=null,j;if(j.composing=L,_&&(B||e.view.composing)){(z<C.range.from||z>C.range.to)&&!L&&!C.composing&&(j.active=!1);const H=m({char:n,allowSpaces:r,allowToIncludeChar:o,allowedPrefixes:s,startOfLine:i,$position:$.$from}),R=`id_${Math.floor(Math.random()*4294967295)}`;H&&p({editor:e,state:N,range:H.range,isActive:C.active})?(j.active=!0,j.decorationId=C.decorationId?C.decorationId:R,j.range=H.range,j.query=H.query,j.text=H.text):j.active=!1}else j.active=!1;return j.active||(j.decorationId=null,j.range={from:0,to:0},j.query=null,j.text=null),j}},props:{handleKeyDown(S,C){var T,N,_,L;const{active:$,range:B}=k.getState(S.state);if(!$)return!1;if(C.key==="Escape"||C.key==="Esc"){const j=k.getState(S.state),P=(T=y?.decorationNode)!=null?T:null,H=P??(j?.decorationId?S.dom.querySelector(`[data-decoration-id="${j.decorationId}"]`):null);if(((N=v?.onKeyDown)==null?void 0:N.call(v,{view:S,event:C,range:j.range}))||!1)return!0;const V={editor:e,range:j.range,query:j.query,text:j.text,items:[],command:ie=>d({editor:e,range:j.range,props:ie}),decorationNode:H,clientRect:H?()=>H.getBoundingClientRect()||null:null};return(_=v?.onExit)==null||_.call(v,V),x(S,t),!0}return((L=v?.onKeyDown)==null?void 0:L.call(v,{view:S,event:C,range:B}))||!1},decorations(S){const{active:C,range:T,decorationId:N,query:_}=k.getState(S);if(!C)return null;const L=!_?.length,$=[l];return L&&$.push(u),et.create(S.doc,[Vt.inline(T.from,T.to,{nodeName:a,class:$.join(" "),"data-decoration-id":N,"data-decoration-content":c})])}}});return k}var wn="top",Yn="bottom",Jn="right",En="left",iy="auto",Ml=[wn,Yn,Jn,En],zi="start",Ol="end",sK="clippingParents",rM="viewport",_l="popper",iK="reference",oM=Ml.reduce(function(t,e){return t.concat([e+"-"+zi,e+"-"+Ol])},[]),sM=[].concat(Ml,[iy]).reduce(function(t,e){return t.concat([e,e+"-"+zi,e+"-"+Ol])},[]),aK="beforeRead",lK="read",cK="afterRead",uK="beforeMain",dK="main",fK="afterMain",hK="beforeWrite",pK="write",mK="afterWrite",gK=[aK,lK,cK,uK,dK,fK,hK,pK,mK];function Br(t){return t?(t.nodeName||"").toLowerCase():null}function Pn(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function Us(t){var e=Pn(t).Element;return t instanceof e||t instanceof Element}function Xn(t){var e=Pn(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function ay(t){if(typeof ShadowRoot>"u")return!1;var e=Pn(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function yK(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];!Xn(s)||!Br(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 vK(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},{});!Xn(o)||!Br(o)||(Object.assign(o.style,a),Object.keys(s).forEach(function(l){o.removeAttribute(l)}))})}}const iM={name:"applyStyles",enabled:!0,phase:"write",fn:yK,effect:vK,requires:["computeStyles"]};function Fr(t){return t.split("-")[0]}var Vs=Math.max,Kd=Math.min,Ui=Math.round;function ly(){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 aM(){return!/^((?!chrome|android).)*safari/i.test(ly())}function Vi(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),o=1,s=1;e&&Xn(t)&&(o=t.offsetWidth>0&&Ui(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&Ui(r.height)/t.offsetHeight||1);var i=Us(t)?Pn(t):window,a=i.visualViewport,l=!aM()&&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 cy(t){var e=Vi(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 lM(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&ay(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function go(t){return Pn(t).getComputedStyle(t)}function bK(t){return["table","td","th"].indexOf(Br(t))>=0}function rs(t){return((Us(t)?t.ownerDocument:t.document)||window.document).documentElement}function Yd(t){return Br(t)==="html"?t:t.assignedSlot||t.parentNode||(ay(t)?t.host:null)||rs(t)}function cM(t){return!Xn(t)||go(t).position==="fixed"?null:t.offsetParent}function xK(t){var e=/firefox/i.test(ly()),n=/Trident/i.test(ly());if(n&&Xn(t)){var r=go(t);if(r.position==="fixed")return null}var o=Yd(t);for(ay(o)&&(o=o.host);Xn(o)&&["html","body"].indexOf(Br(o))<0;){var s=go(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 Nl(t){for(var e=Pn(t),n=cM(t);n&&bK(n)&&go(n).position==="static";)n=cM(n);return n&&(Br(n)==="html"||Br(n)==="body"&&go(n).position==="static")?e:n||xK(t)||e}function uy(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function Rl(t,e,n){return Vs(t,Kd(e,n))}function wK(t,e,n){var r=Rl(t,e,n);return r>n?n:r}function uM(){return{top:0,right:0,bottom:0,left:0}}function dM(t){return Object.assign({},uM(),t)}function fM(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var EK=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,dM(typeof e!="number"?e:fM(e,Ml))};function SK(t){var e,n=t.state,r=t.name,o=t.options,s=n.elements.arrow,i=n.modifiersData.popperOffsets,a=Fr(n.placement),l=uy(a),c=[En,Jn].indexOf(a)>=0,u=c?"height":"width";if(!(!s||!i)){var d=EK(o.padding,n),f=cy(s),h=l==="y"?wn:En,p=l==="y"?Yn:Jn,m=n.rects.reference[u]+n.rects.reference[l]-i[l]-n.rects.popper[u],y=i[l]-n.rects.reference[l],v=Nl(s),w=v?l==="y"?v.clientHeight||0:v.clientWidth||0:0,E=m/2-y/2,x=d[h],k=w-f[u]-d[p],S=w/2-f[u]/2+E,C=Rl(x,S,k),T=l;n.modifiersData[r]=(e={},e[T]=C,e.centerOffset=C-S,e)}}function kK(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)||lM(e.elements.popper,o)&&(e.elements.arrow=o))}const CK={name:"arrow",enabled:!0,phase:"main",fn:SK,effect:kK,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Wi(t){return t.split("-")[1]}var TK={top:"auto",right:"auto",bottom:"auto",left:"auto"};function AK(t,e){var n=t.x,r=t.y,o=e.devicePixelRatio||1;return{x:Ui(n*o)/o||0,y:Ui(r*o)/o||0}}function hM(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,y=typeof u=="function"?u({x:h,y:m}):{x:h,y:m};h=y.x,m=y.y;var v=i.hasOwnProperty("x"),w=i.hasOwnProperty("y"),E=En,x=wn,k=window;if(c){var S=Nl(n),C="clientHeight",T="clientWidth";if(S===Pn(n)&&(S=rs(n),go(S).position!=="static"&&a==="absolute"&&(C="scrollHeight",T="scrollWidth")),S=S,o===wn||(o===En||o===Jn)&&s===Ol){x=Yn;var N=d&&S===k&&k.visualViewport?k.visualViewport.height:S[C];m-=N-r.height,m*=l?1:-1}if(o===En||(o===wn||o===Yn)&&s===Ol){E=Jn;var _=d&&S===k&&k.visualViewport?k.visualViewport.width:S[T];h-=_-r.width,h*=l?1:-1}}var L=Object.assign({position:a},c&&TK),$=u===!0?AK({x:h,y:m},Pn(n)):{x:h,y:m};if(h=$.x,m=$.y,l){var B;return Object.assign({},L,(B={},B[x]=w?"0":"",B[E]=v?"0":"",B.transform=(k.devicePixelRatio||1)<=1?"translate("+h+"px, "+m+"px)":"translate3d("+h+"px, "+m+"px, 0)",B))}return Object.assign({},L,(e={},e[x]=w?m+"px":"",e[E]=v?h+"px":"",e.transform="",e))}function MK(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:Fr(e.placement),variation:Wi(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,hM(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,hM(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 OK={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:MK,data:{}};var Jd={passive:!0};function _K(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=Pn(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&c.forEach(function(u){u.addEventListener("scroll",n.update,Jd)}),a&&l.addEventListener("resize",n.update,Jd),function(){s&&c.forEach(function(u){u.removeEventListener("scroll",n.update,Jd)}),a&&l.removeEventListener("resize",n.update,Jd)}}const NK={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:_K,data:{}};var RK={left:"right",right:"left",bottom:"top",top:"bottom"};function Xd(t){return t.replace(/left|right|bottom|top/g,function(e){return RK[e]})}var IK={start:"end",end:"start"};function pM(t){return t.replace(/start|end/g,function(e){return IK[e]})}function dy(t){var e=Pn(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function fy(t){return Vi(rs(t)).left+dy(t).scrollLeft}function DK(t,e){var n=Pn(t),r=rs(t),o=n.visualViewport,s=r.clientWidth,i=r.clientHeight,a=0,l=0;if(o){s=o.width,i=o.height;var c=aM();(c||!c&&e==="fixed")&&(a=o.offsetLeft,l=o.offsetTop)}return{width:s,height:i,x:a+fy(t),y:l}}function PK(t){var e,n=rs(t),r=dy(t),o=(e=t.ownerDocument)==null?void 0:e.body,s=Vs(n.scrollWidth,n.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),i=Vs(n.scrollHeight,n.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),a=-r.scrollLeft+fy(t),l=-r.scrollTop;return go(o||n).direction==="rtl"&&(a+=Vs(n.clientWidth,o?o.clientWidth:0)-s),{width:s,height:i,x:a,y:l}}function hy(t){var e=go(t),n=e.overflow,r=e.overflowX,o=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+o+r)}function mM(t){return["html","body","#document"].indexOf(Br(t))>=0?t.ownerDocument.body:Xn(t)&&hy(t)?t:mM(Yd(t))}function Il(t,e){var n;e===void 0&&(e=[]);var r=mM(t),o=r===((n=t.ownerDocument)==null?void 0:n.body),s=Pn(r),i=o?[s].concat(s.visualViewport||[],hy(r)?r:[]):r,a=e.concat(i);return o?a:a.concat(Il(Yd(i)))}function py(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function LK(t,e){var n=Vi(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 gM(t,e,n){return e===rM?py(DK(t,n)):Us(e)?LK(e,n):py(PK(rs(t)))}function jK(t){var e=Il(Yd(t)),n=["absolute","fixed"].indexOf(go(t).position)>=0,r=n&&Xn(t)?Nl(t):t;return Us(r)?e.filter(function(o){return Us(o)&&lM(o,r)&&Br(o)!=="body"}):[]}function $K(t,e,n,r){var o=e==="clippingParents"?jK(t):[].concat(e),s=[].concat(o,[n]),i=s[0],a=s.reduce(function(l,c){var u=gM(t,c,r);return l.top=Vs(u.top,l.top),l.right=Kd(u.right,l.right),l.bottom=Kd(u.bottom,l.bottom),l.left=Vs(u.left,l.left),l},gM(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 yM(t){var e=t.reference,n=t.element,r=t.placement,o=r?Fr(r):null,s=r?Wi(r):null,i=e.x+e.width/2-n.width/2,a=e.y+e.height/2-n.height/2,l;switch(o){case wn:l={x:i,y:e.y-n.height};break;case Yn:l={x:i,y:e.y+e.height};break;case Jn:l={x:e.x+e.width,y:a};break;case En:l={x:e.x-n.width,y:a};break;default:l={x:e.x,y:e.y}}var c=o?uy(o):null;if(c!=null){var u=c==="y"?"height":"width";switch(s){case zi:l[c]=l[c]-(e[u]/2-n[u]/2);break;case Ol:l[c]=l[c]+(e[u]/2-n[u]/2);break}}return l}function Dl(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?sK:a,c=n.rootBoundary,u=c===void 0?rM:c,d=n.elementContext,f=d===void 0?_l:d,h=n.altBoundary,p=h===void 0?!1:h,m=n.padding,y=m===void 0?0:m,v=dM(typeof y!="number"?y:fM(y,Ml)),w=f===_l?iK:_l,E=t.rects.popper,x=t.elements[p?w:f],k=$K(Us(x)?x:x.contextElement||rs(t.elements.popper),l,u,i),S=Vi(t.elements.reference),C=yM({reference:S,element:E,placement:o}),T=py(Object.assign({},E,C)),N=f===_l?T:S,_={top:k.top-N.top+v.top,bottom:N.bottom-k.bottom+v.bottom,left:k.left-N.left+v.left,right:N.right-k.right+v.right},L=t.modifiersData.offset;if(f===_l&&L){var $=L[o];Object.keys(_).forEach(function(B){var z=[Jn,Yn].indexOf(B)>=0?1:-1,j=[wn,Yn].indexOf(B)>=0?"y":"x";_[B]+=$[j]*z})}return _}function BK(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?sM:l,u=Wi(r),d=u?a?oM:oM.filter(function(p){return Wi(p)===u}):Ml,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]=Dl(t,{placement:m,boundary:o,rootBoundary:s,padding:i})[Fr(m)],p},{});return Object.keys(h).sort(function(p,m){return h[p]-h[m]})}function FK(t){if(Fr(t)===iy)return[];var e=Xd(t);return[pM(t),e,pM(e)]}function HK(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,y=e.options.placement,v=Fr(y),w=v===y,E=l||(w||!p?[Xd(y)]:FK(y)),x=[y].concat(E).reduce(function(Z,J){return Z.concat(Fr(J)===iy?BK(e,{placement:J,boundary:u,rootBoundary:d,padding:c,flipVariations:p,allowedAutoPlacements:m}):J)},[]),k=e.rects.reference,S=e.rects.popper,C=new Map,T=!0,N=x[0],_=0;_<x.length;_++){var L=x[_],$=Fr(L),B=Wi(L)===zi,z=[wn,Yn].indexOf($)>=0,j=z?"width":"height",P=Dl(e,{placement:L,boundary:u,rootBoundary:d,altBoundary:f,padding:c}),H=z?B?Jn:En:B?Yn:wn;k[j]>S[j]&&(H=Xd(H));var R=Xd(H),V=[];if(s&&V.push(P[$]<=0),a&&V.push(P[H]<=0,P[R]<=0),V.every(function(Z){return Z})){N=L,T=!1;break}C.set(L,V)}if(T)for(var ie=p?3:1,ne=function(J){var me=x.find(function(U){var ee=C.get(U);if(ee)return ee.slice(0,J).every(function(Oe){return Oe})});if(me)return N=me,"break"},ye=ie;ye>0;ye--){var G=ne(ye);if(G==="break")break}e.placement!==N&&(e.modifiersData[r]._skip=!0,e.placement=N,e.reset=!0)}}const zK={name:"flip",enabled:!0,phase:"main",fn:HK,requiresIfExists:["offset"],data:{_skip:!1}};function vM(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 bM(t){return[wn,Jn,Yn,En].some(function(e){return t[e]>=0})}function UK(t){var e=t.state,n=t.name,r=e.rects.reference,o=e.rects.popper,s=e.modifiersData.preventOverflow,i=Dl(e,{elementContext:"reference"}),a=Dl(e,{altBoundary:!0}),l=vM(i,r),c=vM(a,o,s),u=bM(l),d=bM(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 VK={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:UK};function WK(t,e,n){var r=Fr(t),o=[En,wn].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,[En,Jn].indexOf(r)>=0?{x:a,y:i}:{x:i,y:a}}function GK(t){var e=t.state,n=t.options,r=t.name,o=n.offset,s=o===void 0?[0,0]:o,i=sM.reduce(function(u,d){return u[d]=WK(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 qK={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:GK};function KK(t){var e=t.state,n=t.name;e.modifiersData[n]=yM({reference:e.rects.reference,element:e.rects.popper,placement:e.placement})}const YK={name:"popperOffsets",enabled:!0,phase:"read",fn:KK,data:{}};function JK(t){return t==="x"?"y":"x"}function XK(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,y=Dl(e,{boundary:l,rootBoundary:c,padding:d,altBoundary:u}),v=Fr(e.placement),w=Wi(e.placement),E=!w,x=uy(v),k=JK(x),S=e.modifiersData.popperOffsets,C=e.rects.reference,T=e.rects.popper,N=typeof m=="function"?m(Object.assign({},e.rects,{placement:e.placement})):m,_=typeof N=="number"?{mainAxis:N,altAxis:N}:Object.assign({mainAxis:0,altAxis:0},N),L=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,$={x:0,y:0};if(S){if(s){var B,z=x==="y"?wn:En,j=x==="y"?Yn:Jn,P=x==="y"?"height":"width",H=S[x],R=H+y[z],V=H-y[j],ie=h?-T[P]/2:0,ne=w===zi?C[P]:T[P],ye=w===zi?-T[P]:-C[P],G=e.elements.arrow,Z=h&&G?cy(G):{width:0,height:0},J=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:uM(),me=J[z],U=J[j],ee=Rl(0,C[P],Z[P]),Oe=E?C[P]/2-ie-ee-me-_.mainAxis:ne-ee-me-_.mainAxis,he=E?-C[P]/2+ie+ee+U+_.mainAxis:ye+ee+U+_.mainAxis,we=e.elements.arrow&&Nl(e.elements.arrow),Se=we?x==="y"?we.clientTop||0:we.clientLeft||0:0,Ve=(B=L?.[x])!=null?B:0,ut=H+Oe-Ve-Se,dt=H+he-Ve,Ot=Rl(h?Kd(R,ut):R,H,h?Vs(V,dt):V);S[x]=Ot,$[x]=Ot-H}if(a){var yt,_t=x==="x"?wn:En,xt=x==="x"?Yn:Jn,Nt=S[k],Gt=k==="y"?"height":"width",it=Nt+y[_t],Rt=Nt-y[xt],Tn=[wn,En].indexOf(v)!==-1,An=(yt=L?.[k])!=null?yt:0,Bt=Tn?it:Nt-C[Gt]-T[Gt]-An+_.altAxis,fn=Tn?Nt+C[Gt]+T[Gt]-An-_.altAxis:Rt,er=h&&Tn?wK(Bt,Nt,fn):Rl(h?Bt:it,Nt,h?fn:Rt);S[k]=er,$[k]=er-Nt}e.modifiersData[r]=$}}const QK={name:"preventOverflow",enabled:!0,phase:"main",fn:XK,requiresIfExists:["offset"]};function ZK(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function e7(t){return t===Pn(t)||!Xn(t)?dy(t):ZK(t)}function t7(t){var e=t.getBoundingClientRect(),n=Ui(e.width)/t.offsetWidth||1,r=Ui(e.height)/t.offsetHeight||1;return n!==1||r!==1}function n7(t,e,n){n===void 0&&(n=!1);var r=Xn(e),o=Xn(e)&&t7(e),s=rs(e),i=Vi(t,o,n),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(r||!r&&!n)&&((Br(e)!=="body"||hy(s))&&(a=e7(e)),Xn(e)?(l=Vi(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):s&&(l.x=fy(s))),{x:i.left+a.scrollLeft-l.x,y:i.top+a.scrollTop-l.y,width:i.width,height:i.height}}function r7(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 o7(t){var e=r7(t);return gK.reduce(function(n,r){return n.concat(e.filter(function(o){return o.phase===r}))},[])}function s7(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function i7(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 xM={placement:"bottom",modifiers:[],strategy:"absolute"};function wM(){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 a7(t){t===void 0&&(t={});var e=t,n=e.defaultModifiers,r=n===void 0?[]:n,o=e.defaultOptions,s=o===void 0?xM:o;return function(a,l,c){c===void 0&&(c=s);var u={placement:"bottom",orderedModifiers:[],options:Object.assign({},xM,s),modifiersData:{},elements:{reference:a,popper:l},attributes:{},styles:{}},d=[],f=!1,h={state:u,setOptions:function(v){var w=typeof v=="function"?v(u.options):v;m(),u.options=Object.assign({},s,u.options,w),u.scrollParents={reference:Us(a)?Il(a):a.contextElement?Il(a.contextElement):[],popper:Il(l)};var E=o7(i7([].concat(r,u.options.modifiers)));return u.orderedModifiers=E.filter(function(x){return x.enabled}),p(),h.update()},forceUpdate:function(){if(!f){var v=u.elements,w=v.reference,E=v.popper;if(wM(w,E)){u.rects={reference:n7(w,Nl(E),u.options.strategy==="fixed"),popper:cy(E)},u.reset=!1,u.placement=u.options.placement,u.orderedModifiers.forEach(function(_){return u.modifiersData[_.name]=Object.assign({},_.data)});for(var x=0;x<u.orderedModifiers.length;x++){if(u.reset===!0){u.reset=!1,x=-1;continue}var k=u.orderedModifiers[x],S=k.fn,C=k.options,T=C===void 0?{}:C,N=k.name;typeof S=="function"&&(u=S({state:u,options:T,name:N,instance:h})||u)}}}},update:s7(function(){return new Promise(function(y){h.forceUpdate(),y(u)})}),destroy:function(){m(),f=!0}};if(!wM(a,l))return h;h.setOptions(c).then(function(y){!f&&c.onFirstUpdate&&c.onFirstUpdate(y)});function p(){u.orderedModifiers.forEach(function(y){var v=y.name,w=y.options,E=w===void 0?{}:w,x=y.effect;if(typeof x=="function"){var k=x({state:u,name:v,instance:h,options:E}),S=function(){};d.push(k||S)}})}function m(){d.forEach(function(y){return y()}),d=[]}return h}}var l7=[NK,YK,OK,iM,qK,zK,QK,CK,VK],c7=a7({defaultModifiers:l7}),u7="tippy-box",EM="tippy-content",d7="tippy-backdrop",SM="tippy-arrow",kM="tippy-svg-arrow",Ws={passive:!0,capture:!0},CM=function(){return document.body};function f7(t,e){return{}.hasOwnProperty.call(t,e)}function my(t,e,n){if(Array.isArray(t)){var r=t[e];return r??(Array.isArray(n)?n[e]:n)}return t}function gy(t,e){var n={}.toString.call(t);return n.indexOf("[object")===0&&n.indexOf(e+"]")>-1}function TM(t,e){return typeof t=="function"?t.apply(void 0,e):t}function AM(t,e){if(e===0)return t;var n;return function(r){clearTimeout(n),n=setTimeout(function(){t(r)},e)}}function h7(t,e){var n=Object.assign({},t);return e.forEach(function(r){delete n[r]}),n}function p7(t){return t.split(/\s+/).filter(Boolean)}function Gi(t){return[].concat(t)}function MM(t,e){t.indexOf(e)===-1&&t.push(e)}function m7(t){return t.filter(function(e,n){return t.indexOf(e)===n})}function g7(t){return t.split("-")[0]}function Qd(t){return[].slice.call(t)}function OM(t){return Object.keys(t).reduce(function(e,n){return t[n]!==void 0&&(e[n]=t[n]),e},{})}function Pl(){return document.createElement("div")}function Ll(t){return["Element","Fragment"].some(function(e){return gy(t,e)})}function y7(t){return gy(t,"NodeList")}function v7(t){return gy(t,"MouseEvent")}function b7(t){return!!(t&&t._tippy&&t._tippy.reference===t)}function x7(t){return Ll(t)?[t]:y7(t)?Qd(t):Array.isArray(t)?t:Qd(document.querySelectorAll(t))}function yy(t,e){t.forEach(function(n){n&&(n.style.transitionDuration=e+"ms")})}function _M(t,e){t.forEach(function(n){n&&n.setAttribute("data-state",e)})}function w7(t){var e,n=Gi(t),r=n[0];return r!=null&&(e=r.ownerDocument)!=null&&e.body?r.ownerDocument:document}function E7(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=g7(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,y=r-s.bottom-f>l,v=s.left-n+h>l,w=n-s.right-p>l;return m||y||v||w})}function vy(t,e,n){var r=e+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(o){t[r](o,n)})}function NM(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 Hr={isTouch:!1},RM=0;function S7(){Hr.isTouch||(Hr.isTouch=!0,window.performance&&document.addEventListener("mousemove",IM))}function IM(){var t=performance.now();t-RM<20&&(Hr.isTouch=!1,document.removeEventListener("mousemove",IM)),RM=t}function k7(){var t=document.activeElement;if(b7(t)){var e=t._tippy;t.blur&&!e.state.isVisible&&t.blur()}}function C7(){document.addEventListener("touchstart",S7,Ws),window.addEventListener("blur",k7)}var T7=typeof window<"u"&&typeof document<"u",A7=T7?!!window.msCrypto:!1;function qi(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 DM(t){var e=/[ \t]{2,}/g,n=/^[ \t]*/gm;return t.replace(e," ").replace(n,"").trim()}function M7(t){return DM(`
500
- %ctippy.js
501
-
502
- %c`+DM(t)+`
503
-
504
- %c👷‍ This is a development-only message. It will be removed in production.
505
- `)}function PM(t){return[M7(t),"color: #00C584; font-size: 1.3em; font-weight: bold;","line-height: 1.5","color: #a6a095;"]}var jl;process.env.NODE_ENV!=="production"&&O7();function O7(){jl=new Set}function yo(t,e){if(t&&!jl.has(e)){var n;jl.add(e),(n=console).warn.apply(n,PM(e))}}function by(t,e){if(t&&!jl.has(e)){var n;jl.add(e),(n=console).error.apply(n,PM(e))}}function _7(t){var e=!t,n=Object.prototype.toString.call(t)==="[object Object]"&&!t.addEventListener;by(e,["tippy() was passed","`"+String(t)+"`","as its targets (first) argument. Valid types are: String, Element,","Element[], or NodeList."].join(" ")),by(n,["tippy() was passed a plain object which is not supported as an argument","for virtual positioning. Use props.getReferenceClientRect instead."].join(" "))}var LM={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},N7={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},Ln=Object.assign({appendTo:CM,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},LM,N7),R7=Object.keys(Ln),I7=function(e){process.env.NODE_ENV!=="production"&&BM(e,[]);var n=Object.keys(e);n.forEach(function(r){Ln[r]=e[r]})};function jM(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=Ln[s])!=null?a:i}return r},{});return Object.assign({},t,n)}function D7(t,e){var n=e?Object.keys(jM(Object.assign({},Ln,{plugins:e}))):R7,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 $M(t,e){var n=Object.assign({},e,{content:TM(e.content,[t])},e.ignoreAttributes?{}:D7(t,e.plugins));return n.aria=Object.assign({},Ln.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 BM(t,e){t===void 0&&(t={}),e===void 0&&(e=[]);var n=Object.keys(t);n.forEach(function(r){var o=h7(Ln,Object.keys(LM)),s=!f7(o,r);s&&(s=e.filter(function(i){return i.name===r}).length===0),yo(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.",`
506
-
507
- `,`All props: https://atomiks.github.io/tippyjs/v6/all-props/
508
- `,"Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "))})}var P7=function(){return"innerHTML"};function xy(t,e){t[P7()]=e}function FM(t){var e=Pl();return t===!0?e.className=SM:(e.className=kM,Ll(t)?e.appendChild(t):xy(e,t)),e}function HM(t,e){Ll(e.content)?(xy(t,""),t.appendChild(e.content)):typeof e.content!="function"&&(e.allowHTML?xy(t,e.content):t.textContent=e.content)}function wy(t){var e=t.firstElementChild,n=Qd(e.children);return{box:e,content:n.find(function(r){return r.classList.contains(EM)}),arrow:n.find(function(r){return r.classList.contains(SM)||r.classList.contains(kM)}),backdrop:n.find(function(r){return r.classList.contains(d7)})}}function zM(t){var e=Pl(),n=Pl();n.className=u7,n.setAttribute("data-state","hidden"),n.setAttribute("tabindex","-1");var r=Pl();r.className=EM,r.setAttribute("data-state","hidden"),HM(r,t.props),e.appendChild(n),n.appendChild(r),o(t.props,t.props);function o(s,i){var a=wy(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)&&HM(c,t.props),i.arrow?u?s.arrow!==i.arrow&&(l.removeChild(u),l.appendChild(FM(i.arrow))):l.appendChild(FM(i.arrow)):u&&l.removeChild(u)}return{popper:e,onUpdate:o}}zM.$$tippy=!0;var L7=1,Zd=[],Ey=[];function j7(t,e){var n=$M(t,Object.assign({},Ln,jM(OM(e)))),r,o,s,i=!1,a=!1,l=!1,c=!1,u,d,f,h=[],p=AM(ut,n.interactiveDebounce),m,y=L7++,v=null,w=m7(n.plugins),E={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},x={id:y,reference:t,popper:Pl(),popperInstance:v,props:n,state:E,plugins:w,clearDelayTimeouts:Bt,setProps:fn,setContent:er,show:Vr,hide:$n,hideWithInteractivity:Wr,enable:Tn,disable:An,unmount:hn,destroy:Sr};if(!n.render)return process.env.NODE_ENV!=="production"&&by(!0,"render() function has not been supplied."),x;var k=n.render(x),S=k.popper,C=k.onUpdate;S.setAttribute("data-tippy-root",""),S.id="tippy-"+x.id,x.popper=S,t._tippy=x,S._tippy=x;var T=w.map(function(D){return D.fn(x)}),N=t.hasAttribute("aria-expanded");return we(),ie(),H(),R("onCreate",[x]),n.showOnCreate&&it(),S.addEventListener("mouseenter",function(){x.props.interactive&&x.state.isVisible&&x.clearDelayTimeouts()}),S.addEventListener("mouseleave",function(){x.props.interactive&&x.props.trigger.indexOf("mouseenter")>=0&&z().addEventListener("mousemove",p)}),x;function _(){var D=x.props.touch;return Array.isArray(D)?D:[D,0]}function L(){return _()[0]==="hold"}function $(){var D;return!!((D=x.props.render)!=null&&D.$$tippy)}function B(){return m||t}function z(){var D=B().parentNode;return D?w7(D):document}function j(){return wy(S)}function P(D){return x.state.isMounted&&!x.state.isVisible||Hr.isTouch||u&&u.type==="focus"?0:my(x.props.delay,D?0:1,Ln.delay)}function H(D){D===void 0&&(D=!1),S.style.pointerEvents=x.props.interactive&&!D?"":"none",S.style.zIndex=""+x.props.zIndex}function R(D,X,ae){if(ae===void 0&&(ae=!0),T.forEach(function(ke){ke[D]&&ke[D].apply(ke,X)}),ae){var De;(De=x.props)[D].apply(De,X)}}function V(){var D=x.props.aria;if(D.content){var X="aria-"+D.content,ae=S.id,De=Gi(x.props.triggerTarget||t);De.forEach(function(ke){var qe=ke.getAttribute(X);if(x.state.isVisible)ke.setAttribute(X,qe?qe+" "+ae:ae);else{var wt=qe&&qe.replace(ae,"").trim();wt?ke.setAttribute(X,wt):ke.removeAttribute(X)}})}}function ie(){if(!(N||!x.props.aria.expanded)){var D=Gi(x.props.triggerTarget||t);D.forEach(function(X){x.props.interactive?X.setAttribute("aria-expanded",x.state.isVisible&&X===B()?"true":"false"):X.removeAttribute("aria-expanded")})}}function ne(){z().removeEventListener("mousemove",p),Zd=Zd.filter(function(D){return D!==p})}function ye(D){if(!(Hr.isTouch&&(l||D.type==="mousedown"))){var X=D.composedPath&&D.composedPath()[0]||D.target;if(!(x.props.interactive&&NM(S,X))){if(Gi(x.props.triggerTarget||t).some(function(ae){return NM(ae,X)})){if(Hr.isTouch||x.state.isVisible&&x.props.trigger.indexOf("click")>=0)return}else R("onClickOutside",[x,D]);x.props.hideOnClick===!0&&(x.clearDelayTimeouts(),x.hide(),a=!0,setTimeout(function(){a=!1}),x.state.isMounted||me())}}}function G(){l=!0}function Z(){l=!1}function J(){var D=z();D.addEventListener("mousedown",ye,!0),D.addEventListener("touchend",ye,Ws),D.addEventListener("touchstart",Z,Ws),D.addEventListener("touchmove",G,Ws)}function me(){var D=z();D.removeEventListener("mousedown",ye,!0),D.removeEventListener("touchend",ye,Ws),D.removeEventListener("touchstart",Z,Ws),D.removeEventListener("touchmove",G,Ws)}function U(D,X){Oe(D,function(){!x.state.isVisible&&S.parentNode&&S.parentNode.contains(S)&&X()})}function ee(D,X){Oe(D,X)}function Oe(D,X){var ae=j().box;function De(ke){ke.target===ae&&(vy(ae,"remove",De),X())}if(D===0)return X();vy(ae,"remove",d),vy(ae,"add",De),d=De}function he(D,X,ae){ae===void 0&&(ae=!1);var De=Gi(x.props.triggerTarget||t);De.forEach(function(ke){ke.addEventListener(D,X,ae),h.push({node:ke,eventType:D,handler:X,options:ae})})}function we(){L()&&(he("touchstart",Ve,{passive:!0}),he("touchend",dt,{passive:!0})),p7(x.props.trigger).forEach(function(D){if(D!=="manual")switch(he(D,Ve),D){case"mouseenter":he("mouseleave",dt);break;case"focus":he(A7?"focusout":"blur",Ot);break;case"focusin":he("focusout",Ot);break}})}function Se(){h.forEach(function(D){var X=D.node,ae=D.eventType,De=D.handler,ke=D.options;X.removeEventListener(ae,De,ke)}),h=[]}function Ve(D){var X,ae=!1;if(!(!x.state.isEnabled||yt(D)||a)){var De=((X=u)==null?void 0:X.type)==="focus";u=D,m=D.currentTarget,ie(),!x.state.isVisible&&v7(D)&&Zd.forEach(function(ke){return ke(D)}),D.type==="click"&&(x.props.trigger.indexOf("mouseenter")<0||i)&&x.props.hideOnClick!==!1&&x.state.isVisible?ae=!0:it(D),D.type==="click"&&(i=!ae),ae&&!De&&Rt(D)}}function ut(D){var X=D.target,ae=B().contains(X)||S.contains(X);if(!(D.type==="mousemove"&&ae)){var De=Gt().concat(S).map(function(ke){var qe,wt=ke._tippy,en=(qe=wt.popperInstance)==null?void 0:qe.state;return en?{popperRect:ke.getBoundingClientRect(),popperState:en,props:n}:null}).filter(Boolean);E7(De,D)&&(ne(),Rt(D))}}function dt(D){var X=yt(D)||x.props.trigger.indexOf("click")>=0&&i;if(!X){if(x.props.interactive){x.hideWithInteractivity(D);return}Rt(D)}}function Ot(D){x.props.trigger.indexOf("focusin")<0&&D.target!==B()||x.props.interactive&&D.relatedTarget&&S.contains(D.relatedTarget)||Rt(D)}function yt(D){return Hr.isTouch?L()!==D.type.indexOf("touch")>=0:!1}function _t(){xt();var D=x.props,X=D.popperOptions,ae=D.placement,De=D.offset,ke=D.getReferenceClientRect,qe=D.moveTransition,wt=$()?wy(S).arrow:null,en=ke?{getBoundingClientRect:ke,contextElement:ke.contextElement||B()}:t,Gr={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Ke){var Ee=Ke.state;if($()){var at=j(),tr=at.box;["placement","reference-hidden","escaped"].forEach(function(Qe){Qe==="placement"?tr.setAttribute("data-placement",Ee.placement):Ee.attributes.popper["data-popper-"+Qe]?tr.setAttribute("data-"+Qe,""):tr.removeAttribute("data-"+Qe)}),Ee.attributes.popper={}}}},Ft=[{name:"offset",options:{offset:De}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!qe}},Gr];$()&&wt&&Ft.push({name:"arrow",options:{element:wt,padding:3}}),Ft.push.apply(Ft,X?.modifiers||[]),x.popperInstance=c7(en,S,Object.assign({},X,{placement:ae,onFirstUpdate:f,modifiers:Ft}))}function xt(){x.popperInstance&&(x.popperInstance.destroy(),x.popperInstance=null)}function Nt(){var D=x.props.appendTo,X,ae=B();x.props.interactive&&D===CM||D==="parent"?X=ae.parentNode:X=TM(D,[ae]),X.contains(S)||X.appendChild(S),x.state.isMounted=!0,_t(),process.env.NODE_ENV!=="production"&&yo(x.props.interactive&&D===Ln.appendTo&&ae.nextElementSibling!==S,["Interactive tippy element may not be accessible via keyboard","navigation because it is not directly after the reference element","in the DOM source order.",`
509
-
510
- `,"Using a wrapper <div> or <span> tag around the reference element","solves this by creating a new parentNode context.",`
511
-
512
- `,"Specifying `appendTo: document.body` silences this warning, but it","assumes you are using a focus management solution to handle","keyboard navigation.",`
513
-
514
- `,"See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "))}function Gt(){return Qd(S.querySelectorAll("[data-tippy-root]"))}function it(D){x.clearDelayTimeouts(),D&&R("onTrigger",[x,D]),J();var X=P(!0),ae=_(),De=ae[0],ke=ae[1];Hr.isTouch&&De==="hold"&&ke&&(X=ke),X?r=setTimeout(function(){x.show()},X):x.show()}function Rt(D){if(x.clearDelayTimeouts(),R("onUntrigger",[x,D]),!x.state.isVisible){me();return}if(!(x.props.trigger.indexOf("mouseenter")>=0&&x.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(D.type)>=0&&i)){var X=P(!1);X?o=setTimeout(function(){x.state.isVisible&&x.hide()},X):s=requestAnimationFrame(function(){x.hide()})}}function Tn(){x.state.isEnabled=!0}function An(){x.hide(),x.state.isEnabled=!1}function Bt(){clearTimeout(r),clearTimeout(o),cancelAnimationFrame(s)}function fn(D){if(process.env.NODE_ENV!=="production"&&yo(x.state.isDestroyed,qi("setProps")),!x.state.isDestroyed){R("onBeforeUpdate",[x,D]),Se();var X=x.props,ae=$M(t,Object.assign({},X,OM(D),{ignoreAttributes:!0}));x.props=ae,we(),X.interactiveDebounce!==ae.interactiveDebounce&&(ne(),p=AM(ut,ae.interactiveDebounce)),X.triggerTarget&&!ae.triggerTarget?Gi(X.triggerTarget).forEach(function(De){De.removeAttribute("aria-expanded")}):ae.triggerTarget&&t.removeAttribute("aria-expanded"),ie(),H(),C&&C(X,ae),x.popperInstance&&(_t(),Gt().forEach(function(De){requestAnimationFrame(De._tippy.popperInstance.forceUpdate)})),R("onAfterUpdate",[x,D])}}function er(D){x.setProps({content:D})}function Vr(){process.env.NODE_ENV!=="production"&&yo(x.state.isDestroyed,qi("show"));var D=x.state.isVisible,X=x.state.isDestroyed,ae=!x.state.isEnabled,De=Hr.isTouch&&!x.props.touch,ke=my(x.props.duration,0,Ln.duration);if(!(D||X||ae||De)&&!B().hasAttribute("disabled")&&(R("onShow",[x],!1),x.props.onShow(x)!==!1)){if(x.state.isVisible=!0,$()&&(S.style.visibility="visible"),H(),J(),x.state.isMounted||(S.style.transition="none"),$()){var qe=j(),wt=qe.box,en=qe.content;yy([wt,en],0)}f=function(){var Ft;if(!(!x.state.isVisible||c)){if(c=!0,S.offsetHeight,S.style.transition=x.props.moveTransition,$()&&x.props.animation){var ve=j(),Ke=ve.box,Ee=ve.content;yy([Ke,Ee],ke),_M([Ke,Ee],"visible")}V(),ie(),MM(Ey,x),(Ft=x.popperInstance)==null||Ft.forceUpdate(),R("onMount",[x]),x.props.animation&&$()&&ee(ke,function(){x.state.isShown=!0,R("onShown",[x])})}},Nt()}}function $n(){process.env.NODE_ENV!=="production"&&yo(x.state.isDestroyed,qi("hide"));var D=!x.state.isVisible,X=x.state.isDestroyed,ae=!x.state.isEnabled,De=my(x.props.duration,1,Ln.duration);if(!(D||X||ae)&&(R("onHide",[x],!1),x.props.onHide(x)!==!1)){if(x.state.isVisible=!1,x.state.isShown=!1,c=!1,i=!1,$()&&(S.style.visibility="hidden"),ne(),me(),H(!0),$()){var ke=j(),qe=ke.box,wt=ke.content;x.props.animation&&(yy([qe,wt],De),_M([qe,wt],"hidden"))}V(),ie(),x.props.animation?$()&&U(De,x.unmount):x.unmount()}}function Wr(D){process.env.NODE_ENV!=="production"&&yo(x.state.isDestroyed,qi("hideWithInteractivity")),z().addEventListener("mousemove",p),MM(Zd,p),p(D)}function hn(){process.env.NODE_ENV!=="production"&&yo(x.state.isDestroyed,qi("unmount")),x.state.isVisible&&x.hide(),x.state.isMounted&&(xt(),Gt().forEach(function(D){D._tippy.unmount()}),S.parentNode&&S.parentNode.removeChild(S),Ey=Ey.filter(function(D){return D!==x}),x.state.isMounted=!1,R("onHidden",[x]))}function Sr(){process.env.NODE_ENV!=="production"&&yo(x.state.isDestroyed,qi("destroy")),!x.state.isDestroyed&&(x.clearDelayTimeouts(),x.unmount(),Se(),delete t._tippy,x.state.isDestroyed=!0,R("onDestroy",[x]))}}function $l(t,e){e===void 0&&(e={});var n=Ln.plugins.concat(e.plugins||[]);process.env.NODE_ENV!=="production"&&(_7(t),BM(e,n)),C7();var r=Object.assign({},e,{plugins:n}),o=x7(t);if(process.env.NODE_ENV!=="production"){var s=Ll(r.content),i=o.length>1;yo(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.",`
515
-
516
- `,"Instead, pass the .innerHTML of the element, or use a function that","returns a cloned version of the element instead.",`
517
-
518
- `,`1) content: element.innerHTML
519
- `,"2) content: () => element.cloneNode(true)"].join(" "))}var a=o.reduce(function(l,c){var u=c&&j7(c,r);return u&&l.push(u),l},[]);return Ll(t)?a[0]:a}$l.defaultProps=Ln,$l.setDefaultProps=I7,$l.currentInput=Hr,Object.assign({},iM,{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)}}),$l.setDefaultProps({render:zM});function $7({editor:t,overrideSuggestionOptions:e,extensionName:n,char:r="@"}){return{editor:t,char:r,pluginKey:new Ue,command:({editor:o,range:s,props:i})=>{const c=o.getText()?.replace(DU," ")?.trim()?.lastIndexOf(r);console.log({matchStartPosition:c}),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 UM(t){return(t.options.suggestions.length?t.options.suggestions:[t.options.suggestion]).map(e=>$7({editor:t.editor,overrideSuggestionOptions:e,extensionName:t.name,char:e.char}))}function VM(t,e){const n=UM(t),r=n.find(o=>o.char===e);return r||(n.length?n[0]:null)}const B7=Mt.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",Be(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-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-label"),renderHTML:t=>t.label?{"data-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:()=>null,renderHTML:()=>({})},inThisThread:{default:1,parseHTML:()=>null,renderHTML:()=>({})},name:{default:null,parseHTML:()=>null,renderHTML:()=>({})},selectId:{default:null,parseHTML:()=>null,renderHTML:()=>({})},type:{default:null,parseHTML:()=>null,renderHTML:()=>({})},from:{default:mc.Post,parseHTML:()=>null,renderHTML:()=>({})},isCrossExposureEnable:{default:null,parseHTML:()=>null,renderHTML:()=>({})},matchStartPosition:{default:-1,parseHTML:()=>null,renderHTML:()=>({})}}},parseHTML(){return[{tag:'span[data-type="mention"]'},{tag:'a[data-type="mention"]'}]},renderHTML({node:t,HTMLAttributes:e}){const n=VM(this,t.attrs.mentionSuggestionChar);if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",Be({"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=Be({"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",Be({"data-type":this.name},this.options.HTMLAttributes,e),s]:s},renderText({node:t}){const e={options:this.options,node:t,suggestion:VM(this,t.attrs.mentionSuggestionChar)};return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),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 Qr,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 UM(this).map(oK)}});var Bl={exports:{}},WM;function F7(){if(WM)return Bl.exports;WM=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 Bl.exports=s,Bl.exports.has=i,Bl.exports.remove=s,Bl.exports}var H7=F7();const z7=th(H7);/**
520
- * @name match-sorter
521
- * @license MIT license.
522
- * @copyright (c) 2020 Kent C. Dodds
523
- * @author Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)
524
- */const un={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0},U7=(t,e)=>String(t.rankedValue).localeCompare(String(e.rankedValue));function Sy(t,e,n={}){const{keys:r,threshold:o=un.MATCHES,baseSort:s=U7,sorter:i=c=>c.sort((u,d)=>K7(u,d,s))}=n,a=t.reduce(l,[]);return i(a).map(({item:c})=>c);function l(c,u,d){const f=V7(u,r,e,n),{rank:h,keyThreshold:p=o}=f;return h>=p&&c.push({...f,item:u,index:d}),c}}Sy.rankings=un;function V7(t,e,n,r){if(!e){const s=t;return{rankedValue:s,rank:GM(s,n,r),keyIndex:-1,keyThreshold:r.threshold}}return X7(t,e).reduce(({rank:s,rankedValue:i,keyIndex:a,keyThreshold:l},{itemValue:c,attributes:u},d)=>{let f=GM(c,n,r),h=i;const{minRanking:p,maxRanking:m,threshold:y}=u;return f<p&&f>=un.MATCHES?f=p:f>m&&(f=m),f>s&&(s=f,a=d,l=y,h=c),{rankedValue:h,rank:s,keyIndex:a,keyThreshold:l}},{rankedValue:t,rank:un.NO_MATCH,keyIndex:-1,keyThreshold:r.threshold})}function*W7(t,e){let n=-1;for(;(n=t.indexOf(e,n+1))>-1;)yield n;return-1}function GM(t,e,n){if(t=qM(t,n),e=qM(e,n),e.length>t.length)return un.NO_MATCH;if(t===e)return un.CASE_SENSITIVE_EQUAL;t=t.toLowerCase(),e=e.toLowerCase();const r=W7(t,e),o=r.next(),s=o.value;if(t.length===e.length&&s===0)return un.EQUAL;if(s===0)return un.STARTS_WITH;let i=o;for(;!i.done;){if(i.value>0&&t[i.value-1]===" ")return un.WORD_STARTS_WITH;i=r.next()}return s>0?un.CONTAINS:e.length===1?un.NO_MATCH:G7(t).includes(e)?un.ACRONYM:q7(t,e)}function G7(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 q7(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 un.MATCHES+u*c}const i=o(e[0],t,0);if(i<0)return un.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 un.NO_MATCH}const a=r-i;return s(a)}function K7(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 qM(t,{keepDiacritics:e}){return t=`${t}`,e||(t=z7(t)),t}function Y7(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 J7(e,t);n=null}return n==null?[]:Array.isArray(n)?n:[String(n)]}function J7(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 X7(t,e){const n=[];for(let r=0,o=e.length;r<o;r++){const s=e[r],i=Q7(s),a=Y7(t,s);for(let l=0,c=a.length;l<c;l++)n.push({itemValue:a[l],attributes:i})}return n}const KM={maxRanking:1/0,minRanking:-1/0};function Q7(t){return typeof t=="string"?KM:{...KM,...t}}const YM=M.forwardRef((t,e)=>{const[n,r]=M.useState(0),o=M.useRef([]),s=M.useMemo(()=>t.query?Sy(t.items,t.query,{keys:["label","email"],threshold:Sy.rankings.CONTAINS}):t.items,[t.items,t.query]),i=d=>{const f=s[d];f&&t.command({...f,id:f?.id,label:f?.label})},a=()=>{r(d=>(d+s.length-1)%s.length)},l=()=>{r(d=>(d+1)%s.length)},c=()=>{i(n)};M.useEffect(()=>{r(0)},[s]),M.useEffect(()=>{const d=o.current[n];d&&d.scrollIntoView({block:"nearest",behavior:"instant"})},[n]),M.useImperativeHandle(e,()=>({onKeyDown:d=>d.key==="ArrowUp"?(a(),!0):d.key==="ArrowDown"?(l(),!0):d.key==="Enter"&&s.length>0?(c(),!0):!1}));const u=t.char==="@";return g.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:[g.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:g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("svg",{className:"h-4 w-4 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:g.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),g.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:t.query?g.jsxs(g.Fragment,{children:["Searching for: ",g.jsx("span",{className:"font-medium",children:t.query})]}):`Search ${u?"users":"hashtags"}...`})]})}),g.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:[u?"Users":"Hashtags"," (",s.length,")"]}),g.jsx("ul",{className:"max-h-64 overflow-y-auto",children:s.length===0?g.jsx("div",{className:"p-4 text-center text-sm text-gray-500 dark:text-gray-400",children:t.query?`No ${u?"users":"hashtags"} found for "${t.query}"`:`No ${u?"users":"hashtags"} found`}):g.jsx("div",{className:"p-1",children:s.map((d,f)=>g.jsx("li",{ref:h=>{o.current[f]=h},onClick:()=>i(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:u?g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"h-9 w-9 flex-shrink-0 rounded-full bg-gradient-to-br from-blue-400 to-blue-600 flex items-center justify-center",children:d.avatar?g.jsx("img",{src:d.avatar,alt:d.label,className:"h-9 w-9 rounded-full object-cover"}):g.jsx("span",{className:"text-white font-medium text-sm",children:d.label?.charAt(0).toUpperCase()})}),g.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[g.jsx("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100 truncate",children:d.label}),d.email&&g.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:d.email})]})]}):g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-md bg-gradient-to-br from-purple-400 to-purple-600",children:g.jsx("svg",{className:"h-5 w-5 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:g.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 20l4-16m2 16l4-16M6 9h14M4 15h14"})})}),g.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[g.jsxs("span",{className:"font-medium text-sm text-gray-900 dark:text-gray-100 truncate",children:["#",d.label]}),d.count!==void 0&&g.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:[d.count.toLocaleString()," posts"]})]})]})},d.id))})}),g.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:g.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-500 dark:text-gray-400",children:[g.jsxs("div",{className:"flex items-center gap-1",children:[g.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:"↑↓"}),g.jsx("span",{children:"Navigate"})]}),g.jsxs("div",{className:"flex items-center gap-1",children:[g.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:"↵"}),g.jsx("span",{children:"Select"})]}),g.jsxs("div",{className:"flex items-center gap-1",children:[g.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"}),g.jsx("span",{children:"Close"})]})]})})]})});YM.displayName="MentionList";const Z7=()=>typeof window<"u"&&window.ReactNativeWebView!==void 0,eY=(t,e,n)=>({fetchMentions:async()=>{const s=n.getState().getMentionParams();if(!s)return console.error("DEBUG MENTION SERVICE::","No group id or post id has been provided"),[];const{groupId:i,postId:a}=s;return console.log({groupId:i,postId:a}),(a?await e.getRecommendationPost(i,a,0,999):await e.getRecommendationGroup(i,0,999)).entries?.filter(c=>!!c?.user_data)?.map(c=>({id:c?.user_data?.id,label:c?.user_data?.name,avatar:c?.user_data?.avatar,inThisThread:1,name:c?.user_data?.name,selectId:c.user_data?.username,type:Zf.User,from:mc.Post}))},fetchHashtags:async()=>{const{selectedGroupId:s,groupId:i}=n.getState(),a=s??i;return a?(await t.fetchGroupConversations(999,0)).entries.filter(c=>c?.group_id!==a).map(c=>({id:c?.group_id,label:c?.group?.name,avatar:c?.group?.avatar,inThisThread:1,name:c?.group?.name,selectId:c?.group?.select_id,type:Zf.Group,from:mc.Post,isCrossExposureEnable:c?.group?.allow_cross_exposure})):(console.warn("DEBUG HASHTAG SERVICE::","No active group selected or provided"),[])}});function JM(t,e){return{char:t,items:async()=>await e(),render:()=>{let n,r;return{onStart:o=>{n=new Up(YM,{props:{...o,char:t},editor:o.editor}),o.clientRect&&(r=$l("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].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 tY=(t,e,n)=>{const r=eY(t,e,n);return B7.configure({HTMLAttributes:{class:"inline-block px-1.5 py-0.5 rounded font-medium no-underline cursor-pointer transition-all duration-200"},renderText({node:o,suggestion:s}){return`${s?.char??"@"}${o.attrs.label??o.attrs.id}`},renderHTML({node:o,suggestion:s,isFocused:i}){const a=s?.char??"@",l=o.attrs.label??o.attrs.id,c=o.attrs.id,u=Z7(),f={"data-type":"mention","data-id":c,"data-label":l,"data-mention-suggestion-char":a,class:a==="@"?"inline-block px-1.5 py-0.5 rounded font-medium cursor-pointer transition-all duration-200 bg-blue-100 text-blue-700 hover:bg-blue-200 dark:bg-blue-900/30 dark:text-blue-300 dark:hover:bg-blue-900/50":"inline-block px-1.5 py-0.5 rounded font-medium cursor-pointer transition-all duration-200 bg-purple-100 text-purple-700 hover:bg-purple-200 dark:bg-purple-900/30 dark:text-purple-300 dark:hover:bg-purple-900/50"};if(u){const p=a==="@"?`window.ReactNativeWebView.postMessage(JSON.stringify({type: 'mention', userId: '${c}'}))`:`window.ReactNativeWebView.postMessage(JSON.stringify({type: 'hashtag', groupId: '${c}'}))`;return["span",{...f,onclick:p},`${a}${l}`]}const h=a==="@"?`/user/${c}`:`/hashtag/${c}`;return["a",{...f,...i?{}:{href:h,target:"_blank"},"data-mention-link":"true"},`${a}${l}`]},suggestions:[JM("@",r.fetchMentions),JM("#",r.fetchHashtags)]})};function nY({className:t,...e}){return g.jsx("div",{"data-slot":"skeleton",className:re("bg-accent animate-pulse rounded-md",t),...e})}const rY=({selected:t,href:e,title:n,description:r,image:o,domain:s,onClickDelete:i})=>{const a=b.useMemo(()=>{try{return s||new URL(e).hostname}catch{return"unknown"}},[e,s]),l=c=>{c.preventDefault(),c.stopPropagation(),i()};return g.jsxs("div",{className:re("not-prose relative w-full group my-4",t?"ring-2 ring-blue-500 ring-offset-2 rounded-lg":""),children:[g.jsxs("div",{className:"flex items-center gap-2 absolute z-50 right-2 top-1",children:[g.jsx(xe,{asChild:!0,tooltip:"Visit Link",children:g.jsxs("span",{className:"relative",children:[g.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"absolute inset-0"}),g.jsx(Qa,{})]})}),g.jsx(xe,{tooltip:"Remove Link Preview",onClick:l,"aria-label":"Delete link preview",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:g.jsx(Cm,{})})]}),g.jsx("div",{className:"relative z-0 w-full",children:g.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:[g.jsx("div",{className:"relative h-16 w-16 flex-shrink-0 overflow-hidden rounded-md bg-muted",children:g.jsx("img",{src:o,alt:n,className:"size-16 object-cover transition-transform group-hover:scale-105"})}),g.jsxs("div",{className:"min-w-0 flex-1",children:[g.jsx("h3",{className:"truncate text-sm font-semibold leading-tight text-foreground",children:n}),g.jsx("p",{className:"line-clamp-1 text-xs text-muted-foreground",children:r}),g.jsxs("div",{className:"mt-1 flex items-center gap-1 text-xs text-muted-foreground",children:[g.jsx("span",{className:"truncate",children:a}),g.jsx(Qa,{className:"h-3 w-3 flex-shrink-0 opacity-50"})]})]})]})})]})},oY=({selected:t,href:e,title:n,description:r,image:o,domain:s,onClickDelete:i})=>{const a=b.useMemo(()=>{try{return s||new URL(e).hostname}catch{return"unknown"}},[e,s]),l=c=>{c.preventDefault(),c.stopPropagation(),i()};return g.jsxs("div",{className:re("not-prose relative w-full group mt-4",t?"ring-2 ring-blue-500 ring-offset-2 rounded-lg":""),children:[g.jsxs("div",{className:"flex items-center gap-2 absolute z-50 right-3 top-3",children:[g.jsx(xe,{asChild:!0,tooltip:"Visit Link",className:"cursor-pointer backdrop-blur-2xl size-6 shadow-none group-hover:bg-accent/70 group-hover:text-accent-foreground text-primary-send",children:g.jsxs("span",{className:"relative",children:[g.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"absolute inset-0"}),g.jsx(Qa,{})]})}),g.jsx(xe,{tooltip:"Remove Link Preview",onClick:l,"aria-label":"Delete link preview",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:g.jsx(Cm,{})})]}),g.jsx("div",{className:"relative z-0 w-full",children:g.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:[g.jsx("div",{className:"relative h-80 w-full flex-shrink-0 overflow-hidden bg-muted border-b",children:g.jsx("img",{src:o,alt:n,className:"size-full object-cover transition-transform group-hover:scale-105"})}),g.jsxs("div",{className:"min-w-0 flex-1 p-3",children:[g.jsxs("div",{className:"mt-1 flex items-center gap-1 text-xs text-muted-foreground",children:[g.jsx("span",{className:"truncate",children:a}),g.jsx(Qa,{className:"h-3 w-3 flex-shrink-0 opacity-50"})]}),g.jsx("h3",{className:"mt-1 mb-2 truncate text-lg font-semibold leading-tight text-foreground",children:n}),g.jsx("p",{className:"line-clamp-2 text-sm text-muted-foreground",children:r})]})]})})]})},sY=({node:t,deleteNode:e,selected:n})=>{const{loading:r,href:o,domain:s,variant:i}=t.attrs,a=b.useMemo(()=>{try{return s||new URL(o).hostname}catch{return"unknown"}},[o,s]);return r?g.jsx(Uo,{children:g.jsx(nY,{className:"w-full h-24 flex items-center justify-center rounded-lg",children:g.jsx("span",{className:"text-sm text-muted-foreground",children:"Fetching Link Metadata..."})})}):o?g.jsx(Uo,{contentEditable:!1,"data-drag-handle":!0,children:i===gc.Compact?g.jsx(rY,{...t.attrs,selected:n,domain:a,onClickDelete:e}):g.jsx(oY,{...t.attrs,selected:n,domain:a,onClickDelete:e})}):null},XM=Mt.create({name:"linkPreview",group:"block",atom:!0,addOptions(){return{variant:gc.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(console.log("INSIDE RENDER HTML::",{href:e,image:s}),!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 Ua(sY)},addCommands(){return{setLinkPreview:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t}),updateLinkPreviewByUid:bA(this.name),deleteLinkPreviewByUid:vA(this.name),updateLinkPreview:t=>({commands:e})=>e.updateAttributes(this.name,t)}},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}}}}),ky=Je.create({name:"customEnterHardBreak",addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.setHardBreak()}}}),iY=({node:t,editor:e})=>{const n=o=>{e.commands.deleteMediaByUid(o)},r=t?.content?.content||[];return console.log("MediaGroupView render:",{contentSize:t?.content?.size,mediaCount:r?.length,nodes:r?.map(o=>({type:o?.type?.name,uid:o?.attrs?.uid}))}),r.length===0?g.jsxs(Uo,{className:"media-group-wrapper",children:[g.jsx("div",{className:"flex flex-wrap gap-2 p-8 bg-muted/30 rounded-lg border border-dashed border-border mt-4",children:g.jsx("p",{className:"text-sm text-muted-foreground w-full text-center",children:"No media added yet"})}),g.jsx("div",{className:"hidden",children:g.jsx(UE,{})})]}):g.jsx(Uo,{className:"not-prose media-group-wrapper select-none leading-none mt-12",contentEditable:!1,children:g.jsxs("div",{className:"flex flex-wrap gap-2 leading-none mt-auto",children:[r.map((o,s)=>{const i=o?.attrs?.uploading,a=o?.attrs?.progress||0;return g.jsxs("div",{className:"relative group leading-none",children:[g.jsx(Rn,{size:"icon",onClick:()=>n(o.attrs.uid),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:g.jsx(Di,{className:"w-3.5 h-3.5"})}),i?g.jsxs("div",{className:"size-20 bg-muted rounded-lg border border-border flex items-center justify-center relative overflow-hidden",children:[g.jsxs("div",{className:"text-center space-y-2",children:[o.attrs.type===be.Image&&g.jsx(wm,{className:"w-8 h-8 text-muted-foreground/50 mx-auto"}),o.attrs.type===be.Video&&g.jsx(Am,{className:"w-8 h-8 text-muted-foreground/50 mx-auto"}),o.attrs.type===be.Audio&&g.jsx(zu,{className:"w-8 h-8 text-muted-foreground/50 mx-auto"}),g.jsxs("p",{className:"text-xs text-muted-foreground",children:[Math.round(a),"%"]})]}),g.jsx("div",{className:"absolute bottom-0 left-0 right-0 p-2",children:g.jsx(mA,{value:a,className:"h-1"})})]}):g.jsxs(g.Fragment,{children:[o.attrs.type===be.Image&&g.jsx("img",{src:o.attrs.src,alt:o.attrs.caption||"",className:"size-20 object-cover rounded-lg border border-border"}),o.attrs.type===be.Video&&g.jsx("video",{src:o.attrs.src,className:"size-20 object-cover rounded-lg border border-border"}),o.attrs.type===be.Audio&&g.jsx("div",{className:"size-20 flex items-center justify-center bg-accent rounded-lg border border-border",children:g.jsx(zu,{className:"w-8 h-8 text-muted-foreground"})})]}),o.attrs.caption&&!i&&g.jsx("p",{className:"text-xs text-muted-foreground text-center mt-1 truncate w-32",children:o.attrs.caption})]},o?.attrs?.uid||s)}),g.jsx("div",{className:"hidden",children:g.jsx(UE,{})})]})})},aY=new Ue("mediaMode"),lY=()=>{let t=!1;return new He({key:aY,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((u,d)=>{u.type.name==="media"&&a.push({node:u,pos:d,size:u.nodeSize})}),a.length===0)return r.doc.forEach((u,d)=>{u.type.name==="mediaGroup"&&u.content.size===0&&(s.delete(d,d+u.nodeSize),i=!0)}),i&&(s.setMeta("addToHistory",!1),s.setMeta("mediaMode-plugin",!0)),i?s:null;let l=null,c=null;if(r.doc.forEach((u,d)=>{u.type.name==="mediaGroup"&&(l=d,c=u)}),l!==null&&c){const u=c.content.size;[...a].sort((v,w)=>w.pos-v.pos).forEach(({pos:v,size:w})=>{s.delete(v,v+w)});const h=a.filter(v=>v.pos<l).reduce((v,w)=>v+w.size,0),m=l-h+1+u;let y=0;a.forEach(({node:v})=>{s.insert(m+y,v),y+=v.nodeSize}),i=!0}else{if(!r.schema.nodes.mediaGroup)return null;const u=a.map(h=>h.node);if(u.some(h=>!h||h.type.name!=="media"))return console.warn("Invalid media nodes detected, skipping group creation"),null;const d=r.schema.nodes.mediaGroup.create({},u);[...a].sort((h,p)=>p.pos-h.pos).forEach(({pos:h,size:p})=>{s.delete(h,h+p)}),s.insert(s.doc.content.size,d),i=!0}if(i){const u=s.doc.content.size;if(u>=0&&u<=s.doc.content.size)try{const d=s.doc.resolve(u);s.setSelection(pe.near(d))}catch(d){console.warn("Could not set selection:",d)}s.setMeta("addToHistory",!1),s.setMeta("mediaMode-plugin",!0)}return i?s:null}catch(s){return console.error("MediaMode plugin error:",s),null}finally{t=!1}}})},cY=Mt.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",Be(t,{"data-media-group":""}),0]},addNodeView(){return Ua(iY)},addProseMirrorPlugins(){return this.options.mediaMode?[lY()]:[]}}),uY={class:"bg-muted text-foreground border border-border font-mono leading-snug rounded px-0.5 py-px after:content-none before:content-none"},dY={class:"bg-muted text-foreground border border-border font-mono leading-snug rounded"},Cy=t=>oG.extend({content:t}),fY=Cy("paragraph poll"),hY=Cy("paragraph media? mediaGroup?"),pY=Cy("paragraph linkPreview?"),mY=({includeLink:t=!1,includeDocument:e=!0})=>({...e?{}:{document:!1},...t?{}:{link:!1},code:{HTMLAttributes:uY},codeBlock:{HTMLAttributes:dY}}),ef=t=>v9.configure({placeholder:t,showOnlyWhenEditable:!0}),tf=(t,e,n)=>tY(t,e,n),gY=({editorType:t,api:e,store:n,user:r})=>{const s={[ht.Text]:yY,[ht.Media]:bY,[ht.Link]:xY,[ht.Poll]:vY}[t];return s?s({api:e,store:n,user:r}):[]},yY=({api:t,store:e,user:n})=>{const{core:r,mfs:o,fileStore:s}=t;return[E9.configure(mY({includeLink:!1})),ef(`What's on your mind, ${n?.name?n?.name:""}`),T9,M9,k9.configure({types:["heading","paragraph","media"],alignments:[Ze.LEFT,Ze.CENTER,Ze.RIGHT],defaultAlignment:Ze.LEFT}),xA,kA,Kq,PA.configure({openOnClick:!1,linkOnPaste:!1,api:r}),XM,tf(r,o,e),nM.configure({api:s}),eM.configure({api:r})]},vY=({api:t,store:e})=>{const{core:n,mfs:r}=t;return[fY,Hg,zg,jg,hg,ef("Ask a Question"),ky,kA,tf(n,r,e)]},bY=({api:t,store:e,user:n})=>{const{core:r,mfs:o,fileStore:s}=t;return[hY,Hg,zg,jg,hg,ef(`What's on your mind, ${n?.name?n?.name:""}`),ky,xA.configure({attrs:{mediaMode:!0}}),cY.configure({mediaMode:!0}),tf(r,o,e),nM.configure({api:s})]},xY=({api:t,store:e,user:n})=>{const{core:r,mfs:o}=t;return[pY,Hg,zg,hg,ef(`What's on your mind, ${n?.name?n?.name:""}`),ky,PA.configure({openOnClick:!1,linkOnPaste:!1,api:r,linkMode:!0}),XM.configure({variant:gc.Extended,selectable:!1,draggable:!1}),eM.configure({api:r,autoEmbed:!1,autoLinkSelection:!1}),tf(r,o,e)]},wY=()=>({attributes:{class:re("max-w-full prose prose-sm sm:prose-base px-4 py-2 prose-img:my-3 prose-figcaption:text-xs prose-code:text-sm prose-codeblock:text-sm prose-a:text-blue-500 focus:outline-none")}}),EY=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(),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()}}),SY=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(pe.near(i))}}return!0}).run()},kY=({editorType:t,groupId:e,postId:n,user:r})=>{const[,o]=M.useState(0),s=ga(),i=M.useMemo(()=>V8({groupId:e,postId:n}),[e,n]),{getTabContent:a}=Vp();M.useEffect(()=>{o(u=>u+1)},[]);const l=BB({extensions:gY({editorType:t,api:s,store:i,user:r}),content:"",editorProps:wY(),onCreate:({editor:u})=>{i.getState().setEditor(u),t===ht.Poll&&SY(u)},immediatelyRender:!1},[t]);M.useEffect(()=>{const u=a(t);u&&l?.isEditable&&l.commands.setContent(u)},[l,t,a]);const c=EY(l);return{editor:l,actions:c,store:i}},mr=()=>new Map,Ty=t=>{const e=mr();return t.forEach((n,r)=>{e.set(r,n)}),e},vo=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},CY=(t,e)=>{const n=[];for(const[r,o]of t)n.push(e(o,r));return n},TY=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},Gs=()=>new Set,Ay=t=>t[t.length-1],AY=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},qs=Array.from,MY=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},My=Array.isArray;class QM{constructor(){this._observers=mr()}on(e,n){return vo(this._observers,e,Gs).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 qs((this._observers.get(e)||mr()).values()).forEach(r=>r(...n))}destroy(){this._observers=mr()}}const bo=Math.floor,nf=Math.abs,Ki=(t,e)=>t<e?t:e,ss=(t,e)=>t>e?t:e,ZM=t=>t!==0?t<0:1/t<0,eO=1,tO=2,Oy=4,_y=8,Fl=32,xo=64,dn=128,OY=1<<29,rf=31,Ny=63,Ks=127,_Y=2147483647,nO=Number.MAX_SAFE_INTEGER,NY=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&bo(t)===t),RY=String.fromCharCode,IY=t=>t.toLowerCase(),DY=/^\s*/g,PY=t=>t.replace(DY,""),LY=/([A-Z])/g,rO=(t,e)=>PY(t.replace(LY,n=>`${e}${IY(n)}`)),jY=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},Hl=typeof TextEncoder<"u"?new TextEncoder:null,$Y=Hl?t=>Hl.encode(t):jY;let zl=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});zl&&zl.decode(new Uint8Array).length===1&&(zl=null);class Ul{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Vl=()=>new Ul,BY=t=>{const e=Vl();return t(e),gr(e)},FY=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},gr=t=>{const e=new Uint8Array(FY(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},HY=(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(ss(n,e)*2),t.cpos=0)},jt=(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},Ry=jt,Fe=(t,e)=>{for(;e>Ks;)jt(t,dn|Ks&e),e=bo(e/128);jt(t,Ks&e)},Iy=(t,e)=>{const n=ZM(e);for(n&&(e=-e),jt(t,(e>Ny?dn:0)|(n?xo:0)|Ny&e),e=bo(e/64);e>0;)jt(t,(e>Ks?dn:0)|Ks&e),e=bo(e/128)},Dy=new Uint8Array(3e4),zY=Dy.length/3,UY=(t,e)=>{if(e.length<zY){const n=Hl.encodeInto(e,Dy).written||0;Fe(t,n);for(let r=0;r<n;r++)jt(t,Dy[r])}else jn(t,$Y(e))},VY=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;Fe(t,r);for(let o=0;o<r;o++)jt(t,n.codePointAt(o))},Yi=Hl&&Hl.encodeInto?UY:VY,of=(t,e)=>{const n=t.cbuf.length,r=t.cpos,o=Ki(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(ss(n*2,s)),t.cbuf.set(e.subarray(o)),t.cpos=s)},jn=(t,e)=>{Fe(t,e.byteLength),of(t,e)},Py=(t,e)=>{HY(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},WY=(t,e)=>Py(t,4).setFloat32(0,e,!1),GY=(t,e)=>Py(t,8).setFloat64(0,e,!1),qY=(t,e)=>Py(t,8).setBigInt64(0,e,!1),oO=new DataView(new ArrayBuffer(4)),KY=t=>(oO.setFloat32(0,t),oO.getFloat32(0)===t),Ji=(t,e)=>{switch(typeof e){case"string":jt(t,119),Yi(t,e);break;case"number":NY(e)&&nf(e)<=_Y?(jt(t,125),Iy(t,e)):KY(e)?(jt(t,124),WY(t,e)):(jt(t,123),GY(t,e));break;case"bigint":jt(t,122),qY(t,e);break;case"object":if(e===null)jt(t,126);else if(My(e)){jt(t,117),Fe(t,e.length);for(let n=0;n<e.length;n++)Ji(t,e[n])}else if(e instanceof Uint8Array)jt(t,116),jn(t,e);else{jt(t,118);const n=Object.keys(e);Fe(t,n.length);for(let r=0;r<n.length;r++){const o=n[r];Yi(t,o),Ji(t,e[o])}}break;case"boolean":jt(t,e?120:121);break;default:jt(t,127)}};class sO extends Ul{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&Fe(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const iO=t=>{t.count>0&&(Iy(t.encoder,t.count===1?t.s:-t.s),t.count>1&&Fe(t.encoder,t.count-2))};class sf{constructor(){this.encoder=new Ul,this.s=0,this.count=0}write(e){this.s===e?this.count++:(iO(this),this.count=1,this.s=e)}toUint8Array(){return iO(this),gr(this.encoder)}}const aO=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);Iy(t.encoder,e),t.count>1&&Fe(t.encoder,t.count-2)}};class Ly{constructor(){this.encoder=new Ul,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(aO(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return aO(this),gr(this.encoder)}}class YY{constructor(){this.sarr=[],this.s="",this.lensE=new sf}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 Ul;return this.sarr.push(this.s),this.s="",Yi(e,this.sarr.join("")),of(e,this.lensE.toUint8Array()),gr(e)}}const is=t=>new Error(t),yr=()=>{throw is("Method unimplemented")},Sn=()=>{throw is("Unexpected case")},lO=is("Unexpected end of array"),cO=is("Integer out of Range");class af{constructor(e){this.arr=e,this.pos=0}}const jy=t=>new af(t),JY=t=>t.pos!==t.arr.length,XY=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Qn=t=>XY(t,st(t)),Wl=t=>t.arr[t.pos++],st=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&Ks)*n,n*=128,o<dn)return e;if(e>nO)throw cO}throw lO},$y=t=>{let e=t.arr[t.pos++],n=e&Ny,r=64;const o=(e&xo)>0?-1:1;if((e&dn)===0)return o*n;const s=t.arr.length;for(;t.pos<s;){if(e=t.arr[t.pos++],n=n+(e&Ks)*r,r*=128,e<dn)return o*n;if(n>nO)throw cO}throw lO},By=zl?t=>zl.decode(Qn(t)):t=>{let e=st(t);if(e===0)return"";{let n=String.fromCodePoint(Wl(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(Wl(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))}},Fy=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},QY=[t=>{},t=>null,$y,t=>Fy(t,4).getFloat32(0,!1),t=>Fy(t,8).getFloat64(0,!1),t=>Fy(t,8).getBigInt64(0,!1),t=>!1,t=>!0,By,t=>{const e=st(t),n={};for(let r=0;r<e;r++){const o=By(t);n[o]=lf(t)}return n},t=>{const e=st(t),n=[];for(let r=0;r<e;r++)n.push(lf(t));return n},Qn],lf=t=>QY[127-Wl(t)](t);class uO extends af{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),JY(this)?this.count=st(this)+1:this.count=-1),this.count--,this.s}}class cf extends af{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=$y(this);const e=ZM(this.s);this.count=1,e&&(this.s=-this.s,this.count=st(this)+2)}return this.count--,this.s}}class Hy extends af{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=$y(this),n=e&1;this.diff=bo(e/2),this.count=1,n&&(this.count=st(this)+2)}return this.s+=this.diff,this.count--,this.s}}class ZY{constructor(e){this.decoder=new cf(e),this.str=By(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 eJ=crypto.getRandomValues.bind(crypto),tJ=Math.random,dO=()=>eJ(new Uint32Array(1))[0],nJ=t=>t[bo(tJ()*t.length)],rJ="10000000-1000-4000-8000"+-1e11,oJ=()=>rJ.replace(/[018]/g,t=>(t^dO()&15>>t/4).toString(16)),sJ=Date.now,fO=t=>new Promise(t);Promise.all.bind(Promise);const hO=t=>t===void 0?null:t;class iJ{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let pO=new iJ,aJ=!0;try{typeof localStorage<"u"&&localStorage&&(pO=localStorage,aJ=!1)}catch{}const lJ=pO,cJ=Object.assign,mO=Object.keys,uJ=(t,e)=>{for(const n in t)e(t[n],n)},gO=t=>mO(t).length,dJ=t=>{for(const e in t)return!1;return!0},yO=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},fJ=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),hJ=(t,e)=>t===e||gO(t)===gO(e)&&yO(t,(n,r)=>(n!==void 0||fJ(e,r))&&e[r]===n),pJ=Object.freeze,vO=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&vO(t[e])}return pJ(t)},zy=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&zy(t,e,n+1)}},mJ=(t,e)=>e.includes(t),Xi=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",bO=typeof window<"u"&&typeof document<"u"&&!Xi;let zr;const gJ=()=>{if(zr===void 0)if(Xi){zr=mr();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=mr(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");zr.set(`--${rO(e,"-")}`,n),zr.set(`-${rO(e,"-")}`,n)}})):zr=mr();return zr},Uy=t=>gJ().has(t),uf=t=>hO(Xi?process.env[t.toUpperCase().replaceAll("-","_")]:lJ.getItem(t)),xO=t=>Uy("--"+t)||uf(t)!==null;xO("production");const yJ=Xi&&mJ(process.env.FORCE_COLOR,["true","1","2"])||!Uy("--no-colors")&&!xO("no-color")&&(!Xi||process.stdout.isTTY)&&(!Xi||Uy("--color")||uf("COLORTERM")!==null||(uf("TERM")||"").includes("color")),vJ=bO?t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=RY(t[n]);return btoa(e)}:t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),bJ=t=>BY(e=>Ji(e,t));class xJ{constructor(e,n){this.left=e,this.right=n}}const wo=(t,e)=>new xJ(t,e),wJ=typeof document<"u"?document:{};typeof DOMParser<"u"&&new DOMParser;const EJ=t=>CY(t,(e,n)=>`${n}:${e};`).join(""),SJ=(t=>class{constructor(n){this._=n}destroy(){t(this._)}})(clearTimeout),wO=(t,e)=>new SJ(setTimeout(e,t)),Eo=Symbol,EO=Eo(),SO=Eo(),kJ=Eo(),CJ=Eo(),TJ=Eo(),kO=Eo(),AJ=Eo(),Vy=Eo(),MJ=Eo(),OJ=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r<t.length;r++){const o=t[r];if(o===void 0)break;if(o.constructor===String||o.constructor===Number)e.push(o);else if(o.constructor===Object)break}for(r>0&&n.push(e.join(""));r<t.length;r++){const o=t[r];o instanceof Symbol||n.push(o)}return n},_J={[EO]:wo("font-weight","bold"),[SO]:wo("font-weight","normal"),[kJ]:wo("color","blue"),[TJ]:wo("color","green"),[CJ]:wo("color","grey"),[kO]:wo("color","red"),[AJ]:wo("color","purple"),[Vy]:wo("color","orange"),[MJ]:wo("color","black")},CO=yJ?t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[],r=mr();let o=[],s=0;for(;s<t.length;s++){const i=t[s],a=_J[i];if(a!==void 0)r.set(a.left,a.right);else{if(i===void 0)break;if(i.constructor===String||i.constructor===Number){const l=EJ(r);s>0||l.length>0?(e.push("%c"+i),n.push(l)):e.push(i)}else break}}for(s>0&&(o=n,o.unshift(e.join("")));s<t.length;s++){const i=t[s];i instanceof Symbol||o.push(i)}return o}:OJ,NJ=(...t)=>{console.log(...CO(t)),AO.forEach(e=>e.print(t))},TO=(...t)=>{console.warn(...CO(t)),t.unshift(Vy),AO.forEach(e=>e.print(t))},AO=Gs(),MO=t=>({[Symbol.iterator](){return this},next:t}),RJ=(t,e)=>MO(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Wy=(t,e)=>MO(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class Gy{constructor(e,n){this.clock=e,this.len=n}}class Qi{constructor(){this.clients=new Map}}const as=(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])HO(t,s,c.clock,c.len,n)}}),IJ=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const o=bo((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},Zi=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&IJ(n,e.clock)!==null},qy=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=ss(o.len,s.clock+s.len-o.clock):(r<n&&(e[r]=s),r++)}e.length=r})},Ky=t=>{const e=new Qi;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++)AY(s,t[i].clients.get(o)||[]);e.clients.set(o,s)}});return qy(e),e},Gl=(t,e,n,r)=>{vo(t.clients,e,()=>[]).push(new Gy(n,r))},OO=()=>new Qi,DJ=t=>{const e=OO();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 Gy(a,l))}}o.length>0&&e.clients.set(r,o)}),e},Yy=(t,e)=>{Fe(t.restEncoder,e.clients.size),qs(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),Fe(t.restEncoder,n);const o=r.length;Fe(t.restEncoder,o);for(let s=0;s<o;s++){const i=r[s];t.writeDsClock(i.clock),t.writeDsLen(i.len)}})},PJ=t=>{const e=new Qi,n=st(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const o=st(t.restDecoder),s=st(t.restDecoder);if(s>0){const i=vo(e.clients,o,()=>[]);for(let a=0;a<s;a++)i.push(new Gy(t.readDsClock(),t.readDsLen()))}}return e},_O=(t,e,n)=>{const r=new Qi,o=st(t.restDecoder);for(let s=0;s<o;s++){t.resetDsCurVal();const i=st(t.restDecoder),a=st(t.restDecoder),l=n.clients.get(i)||[],c=bt(n,i);for(let u=0;u<a;u++){const d=t.readDsClock(),f=d+t.readDsLen();if(d<c){c<f&&Gl(r,i,c,f-c);let h=vr(l,d),p=l[h];for(!p.deleted&&p.id.clock<d&&(l.splice(h+1,0,Af(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,Af(e,p,f-p.id.clock)),p.delete(e))}else Gl(r,i,d,f-d)}}if(r.clients.size>0){const s=new ff;return Fe(s.restEncoder,0),Yy(s,r),s.toUint8Array()}return null},NO=dO;class Ys extends QM{constructor({guid:e=oJ(),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=NO(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new $O,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=fO(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const l=()=>fO(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&&Xe(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(qs(this.subdocs).map(e=>e.guid))}transact(e,n=null){return Xe(this,e,n)}get(e,n=$t){const r=vo(this.share,e,()=>{const s=new n;return s._integrate(this,null),s}),o=r.constructor;if(n!==$t&&o!==n)if(o===$t){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,na)}getText(e=""){return this.get(e,cs)}getMap(e=""){return this.get(e,ra)}getXmlElement(e=""){return this.get(e,Zt)}getXmlFragment(e=""){return this.get(e,Xs)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,qs(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new Ys({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,Xe(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 LJ{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=st(this.restDecoder),this.dsCurrVal}readDsLen(){const e=st(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class df extends LJ{constructor(e){super(e),this.keys=[],st(e),this.keyClockDecoder=new Hy(Qn(e)),this.clientDecoder=new cf(Qn(e)),this.leftClockDecoder=new Hy(Qn(e)),this.rightClockDecoder=new Hy(Qn(e)),this.infoDecoder=new uO(Qn(e),Wl),this.stringDecoder=new ZY(Qn(e)),this.parentInfoDecoder=new uO(Qn(e),Wl),this.typeRefDecoder=new cf(Qn(e)),this.lenDecoder=new cf(Qn(e))}readLeftID(){return new ea(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ea(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 lf(this.restDecoder)}readBuf(){return Qn(this.restDecoder)}readJSON(){return lf(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 jJ{constructor(){this.restEncoder=Vl()}toUint8Array(){return gr(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){Fe(this.restEncoder,e)}writeDsLen(e){Fe(this.restEncoder,e)}}class $J extends jJ{writeLeftID(e){Fe(this.restEncoder,e.client),Fe(this.restEncoder,e.clock)}writeRightID(e){Fe(this.restEncoder,e.client),Fe(this.restEncoder,e.clock)}writeClient(e){Fe(this.restEncoder,e)}writeInfo(e){Ry(this.restEncoder,e)}writeString(e){Yi(this.restEncoder,e)}writeParentInfo(e){Fe(this.restEncoder,e?1:0)}writeTypeRef(e){Fe(this.restEncoder,e)}writeLen(e){Fe(this.restEncoder,e)}writeAny(e){Ji(this.restEncoder,e)}writeBuf(e){jn(this.restEncoder,e)}writeJSON(e){Yi(this.restEncoder,JSON.stringify(e))}writeKey(e){Yi(this.restEncoder,e)}}class BJ{constructor(){this.restEncoder=Vl(),this.dsCurrVal=0}toUint8Array(){return gr(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,Fe(this.restEncoder,n)}writeDsLen(e){e===0&&Sn(),Fe(this.restEncoder,e-1),this.dsCurrVal+=e}}class ff extends BJ{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Ly,this.clientEncoder=new sf,this.leftClockEncoder=new Ly,this.rightClockEncoder=new Ly,this.infoEncoder=new sO(Ry),this.stringEncoder=new YY,this.parentInfoEncoder=new sO(Ry),this.typeRefEncoder=new sf,this.lenEncoder=new sf}toUint8Array(){const e=Vl();return Fe(e,0),jn(e,this.keyClockEncoder.toUint8Array()),jn(e,this.clientEncoder.toUint8Array()),jn(e,this.leftClockEncoder.toUint8Array()),jn(e,this.rightClockEncoder.toUint8Array()),jn(e,gr(this.infoEncoder)),jn(e,this.stringEncoder.toUint8Array()),jn(e,gr(this.parentInfoEncoder)),jn(e,this.typeRefEncoder.toUint8Array()),jn(e,this.lenEncoder.toUint8Array()),of(e,gr(this.restEncoder)),gr(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){Ji(this.restEncoder,e)}writeBuf(e){jn(this.restEncoder,e)}writeJSON(e){Ji(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 FJ=(t,e,n,r)=>{r=ss(r,e[0].id.clock);const o=vr(e,r);Fe(t.restEncoder,e.length-o),t.writeClient(n),Fe(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)},RO=(t,e,n)=>{const r=new Map;n.forEach((o,s)=>{bt(e,s)>o&&r.set(s,o)}),gf(e).forEach((o,s)=>{n.has(s)||r.set(s,0)}),Fe(t.restEncoder,r.size),qs(r.entries()).sort((o,s)=>s[0]-o[0]).forEach(([o,s])=>{FJ(t,e.clients.get(o),o,s)})},HJ=(t,e)=>{const n=mr(),r=st(t.restDecoder);for(let o=0;o<r;o++){const s=st(t.restDecoder),i=new Array(s),a=t.readClient();let l=st(t.restDecoder);n.set(a,{i:0,refs:i});for(let c=0;c<s;c++){const u=t.readInfo();switch(rf&u){case 0:{const d=t.readLen();i[c]=new Zn(Ie(a,l),d),l+=d;break}case 10:{const d=st(t.restDecoder);i[c]=new wr(Ie(a,l),d),l+=d;break}default:{const d=(u&(xo|dn))===0,f=new nt(Ie(a,l),null,(u&dn)===dn?t.readLeftID():null,null,(u&xo)===xo?t.readRightID():null,d?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,d&&(u&Fl)===Fl?t.readString():null,b_(t,u));i[c]=f,l+=f.length}}}}return n},zJ=(t,e,n)=>{const r=[];let o=qs(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 $O,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(y=>y!==p)}r.length=0};for(;;){if(u.constructor!==wr){const p=vo(d,u.id.client,()=>bt(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 y=n.get(m)||{refs:[],i:0};if(y.refs.length===y.i)c(m,bt(e,m)),f();else{u=y.refs[y.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 ff;return RO(h,a,new Map),Fe(h.restEncoder,0),{missing:l,update:h.toUint8Array()}}return null},UJ=(t,e)=>RO(t,e.doc.store,e.beforeState),VJ=(t,e,n,r=new df(t))=>Xe(e,o=>{o.local=!1;let s=!1;const i=o.doc,a=i.store,l=HJ(r,i),c=zJ(o,a,l),u=a.pendingStructs;if(u){for(const[f,h]of u.missing)if(h<bt(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=KO([u.update,c.update])}}else a.pendingStructs=c;const d=_O(r,o,a);if(a.pendingDs){const f=new df(jy(a.pendingDs));st(f.restDecoder);const h=_O(f,o,a);d&&h?a.pendingDs=KO([d,h]):a.pendingDs=d||h}else a.pendingDs=d;if(s){const f=a.pendingStructs.update;a.pendingStructs=null,Jy(o.doc,f)}},n,!1),Jy=(t,e,n,r=df)=>{const o=jy(e);VJ(o,t,n,new r(o))};class WJ{constructor(){this.l=[]}}const IO=()=>new WJ,DO=(t,e)=>t.l.push(e),PO=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(o=>e!==o),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},LO=(t,e,n)=>zy(t.l,[e,n]);class ea{constructor(e,n){this.client=e,this.clock=n}}const hf=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,Ie=(t,e)=>new ea(t,e),ql=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Sn()},Kl=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class pf{constructor(e,n,r,o=0){this.type=e,this.tname=n,this.item=r,this.assoc=o}}class GJ{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const qJ=(t,e,n=0)=>new GJ(t,e,n),mf=(t,e,n)=>{let r=null,o=null;return t._item===null?o=ql(t):r=Ie(t._item.id.client,t._item.id.clock),new pf(r,o,e,n)},Xy=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return mf(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return mf(t,Ie(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return mf(t,r.lastId,n);r=r.right}return mf(t,null,n)},KJ=(t,e)=>{const n=ta(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},YJ=(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(bt(r,o.client)<=o.clock)return null;const u=n?cv(r,o):KJ(r,o),d=u.item;if(!(d instanceof nt))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(bt(r,s.client)<=s.clock)return null;const{item:u}=n?cv(r,s):{item:ta(r,s)};if(u instanceof nt&&u.content instanceof xr)l=u.content.type;else return null}else throw Sn();a>=0?c=l._length:c=0}return qJ(l,c,t.assoc)};class Qy{constructor(e,n){this.ds=e,this.sv=n}}const jO=(t,e)=>new Qy(t,e),Zy=t=>jO(DJ(t.store),gf(t.store)),Js=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Zi(e.ds,t.id),ev=(t,e)=>{const n=vo(t.meta,ev,Gs),r=t.doc.store;n.has(e)||(e.sv.forEach((o,s)=>{o<bt(r,s)&&kn(t,Ie(s,o))}),as(t,e.ds,o=>{}),n.add(e))};class $O{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const gf=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},bt=(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},BO=(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 Sn()}n.push(e)},vr=(t,e)=>{let n=0,r=t.length-1,o=t[r],s=o.id.clock;if(s===e)return r;let i=bo(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=bo((n+r)/2)}throw Sn()},ta=(t,e)=>{const n=t.clients.get(e.client);return n[vr(n,e.clock)]},tv=(t,e,n)=>{const r=vr(e,n),o=e[r];return o.id.clock<n&&o instanceof nt?(e.splice(r+1,0,Af(t,o,n-o.id.clock)),r+1):r},kn=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[tv(t,n,e.clock)]},FO=(t,e,n)=>{const r=e.clients.get(n.client),o=vr(r,n.clock),s=r[o];return n.clock!==s.id.clock+s.length-1&&s.constructor!==Zn&&r.splice(o+1,0,Af(t,s,n.clock-s.id.clock+1)),s},JJ=(t,e,n)=>{const r=t.clients.get(e.id.client);r[vr(r,e.id.clock)]=n},HO=(t,e,n,r,o)=>{if(r===0)return;const s=n+r;let i=tv(t,e,n),a;do a=e[i++],s<a.id.clock+a.length&&tv(t,e,s),o(a);while(i<e.length&&e[i].id.clock<s)};class XJ{constructor(e,n,r){this.doc=e,this.deleteSet=new Qi,this.beforeState=gf(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 zO=(t,e)=>e.deleteSet.clients.size===0&&!TY(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(qy(e.deleteSet),UJ(t,e),Yy(t,e.deleteSet),!0),UO=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&vo(t.changed,e,Gs).add(n)},yf=(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 nt&&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},QJ=(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=vr(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 nt&&d.deleted&&!d.keep&&n(d)&&d.gc(e,!1)}}}},ZJ=(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=Ki(o.length-1,1+vr(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+yf(o,l)}})},VO=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,o=r.store,s=n.deleteSet,i=n._mergeStructs;try{qy(s),n.afterState=gf(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),LO(c._dEH,l,n))})}),a.push(()=>r.emit("afterTransaction",[n,r])),zy(a,[]),n._needFormattingCleanup&&bX(n)}finally{r.gc&&QJ(s,o,r.gcFilter),ZJ(s,o),n.afterState.forEach((u,d)=>{const f=n.beforeState.get(d)||0;if(f!==u){const h=o.clients.get(d),p=ss(vr(h,f),1);for(let m=h.length-1;m>=p;)m-=1+yf(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=vr(h,f);p+1<h.length&&yf(h,p+1)>1||p>0&&yf(h,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(NJ(Vy,EO,"[yjs] ",SO,kO,"Changed the client-id because another client seems to be using it."),r.clientID=NO()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const u=new $J;zO(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const u=new ff;zO(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])):VO(t,e+1)}}},Xe=(t,e,n=null,r=!0)=>{const o=t._transactionCleanups;let s=!1,i=null;t._transaction===null&&(s=!0,t._transaction=new XJ(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&&VO(o,0)}}return i};class eX{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const WO=(t,e,n)=>{as(t,n.deletions,r=>{r instanceof nt&&e.scope.some(o=>o===t.doc||Kl(o,r))&&uv(r,!1)})},GO=(t,e,n)=>{let r=null;const o=t.doc,s=t.scope;Xe(o,a=>{for(;e.length>0&&t.currStackItem===null;){const l=o.store,c=e.pop(),u=new Set,d=[];let f=!1;as(a,c.insertions,h=>{if(h instanceof nt){if(h.redone!==null){let{item:p,diff:m}=cv(l,h.id);m>0&&(p=kn(a,Ie(p.id.client,p.id.clock+m))),h=p}!h.deleted&&s.some(p=>p===a.doc||Kl(p,h))&&d.push(h)}}),as(a,c.deletions,h=>{h instanceof nt&&s.some(p=>p===a.doc||Kl(p,h))&&!Zi(c.insertions,h.id)&&u.add(h)}),u.forEach(h=>{f=v_(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 qO extends QM{constructor(e,{captureTimeout:n=500,captureTransaction:r=l=>!0,deleteFilter:o=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:i=!1,doc:a=My(e)?e[0].doc:e instanceof Ys?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(y=>l.changedParentTypes.has(y)||y===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 Qi;l.afterState.forEach((y,v)=>{const w=l.beforeState.get(v)||0,E=y-w;E>0&&Gl(f,v,w,E)});const h=sJ();let p=!1;if(this.lastChange>0&&h-this.lastChange<this.captureTimeout&&d.length>0&&!c&&!u){const y=d[d.length-1];y.deletions=Ky([y.deletions,l.deleteSet]),y.insertions=Ky([y.insertions,f])}else d.push(new eX(l.deleteSet,f)),p=!0;!c&&!u&&(this.lastChange=h),as(l,l.deleteSet,y=>{y instanceof nt&&this.scope.some(v=>v===l.doc||Kl(v,y))&&uv(y,!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=My(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof $t?r.doc!==this.doc:r!==this.doc)&&TO("[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=>WO(r,this,o)),this.undoStack=[]),n&&(this.redoStack.forEach(o=>WO(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=GO(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=GO(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*tX(t){const e=st(t.restDecoder);for(let n=0;n<e;n++){const r=st(t.restDecoder),o=t.readClient();let s=st(t.restDecoder);for(let i=0;i<r;i++){const a=t.readInfo();if(a===10){const l=st(t.restDecoder);yield new wr(Ie(o,s),l),s+=l}else if((rf&a)!==0){const l=(a&(xo|dn))===0,c=new nt(Ie(o,s),null,(a&dn)===dn?t.readLeftID():null,null,(a&xo)===xo?t.readRightID():null,l?t.readParentInfo()?t.readString():t.readLeftID():null,l&&(a&Fl)===Fl?t.readString():null,b_(t,a));yield c,s+=c.length}else{const l=t.readLen();yield new Zn(Ie(o,s),l),s+=l}}}}class nX{constructor(e,n){this.gen=tX(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===wr);return this.curr}}class rX{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const oX=(t,e)=>{if(t.constructor===Zn){const{client:n,clock:r}=t.id;return new Zn(Ie(n,r+e),t.length-e)}else if(t.constructor===wr){const{client:n,clock:r}=t.id;return new wr(Ie(n,r+e),t.length-e)}else{const n=t,{client:r,clock:o}=n.id;return new nt(Ie(r,o+e),null,Ie(r,o+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},KO=(t,e=df,n=ff)=>{if(t.length===1)return t[0];const r=t.map(u=>new e(jy(u)));let o=r.map(u=>new nX(u,!0)),s=null;const i=new n,a=new rX(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===wr?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)Yl(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===wr)s.struct.length=f.id.clock+f.length-s.struct.id.clock;else{Yl(a,s.struct,s.offset);const p=f.id.clock-s.struct.id.clock-s.struct.length;s={struct:new wr(Ie(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===wr?s.struct.length-=p:f=oX(f,p)),s.struct.mergeWith(f)||(Yl(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!==wr;f=u.next())Yl(a,s.struct,s.offset),s={struct:f,offset:0}}s!==null&&(Yl(a,s.struct,s.offset),s=null),sX(a);const l=r.map(u=>PJ(u)),c=Ky(l);return Yy(i,c),i.toUint8Array()},YO=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:gr(t.encoder.restEncoder)}),t.encoder.restEncoder=Vl(),t.written=0)},Yl=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&YO(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),Fe(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},sX=t=>{YO(t);const e=t.encoder.restEncoder;Fe(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];Fe(e,r.written),of(e,r.restEncoder)}},JO="You must not compute changes after the event-handler fired.";class vf{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=iX(this.currentTarget,this.target))}deletes(e){return Zi(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw is(JO);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=Ay(l.content.getContent());else return;else l!==null&&this.deletes(l)?(i="update",a=Ay(l.content.getContent())):(i="add",a=void 0)}else if(this.deletes(s))i="delete",a=Ay(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 is(JO);const n=this.target,r=Gs(),o=Gs(),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 iX=(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},Qt=()=>{TO("Invalid access: Add Yjs type to a document before reading data.")},XO=80;let nv=0;class aX{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=nv++}}const lX=t=>{t.timestamp=nv++},QO=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=nv++},cX=(t,e,n)=>{if(t.length>=XO){const r=t.reduce((o,s)=>o.timestamp<s.timestamp?o:s);return QO(r,e,n),r}else{const r=new aX(e,n);return t.push(r),r}},bf=(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)=>nf(e-s.index)<nf(e-i.index)?s:i);let r=t._start,o=0;for(n!==null&&(r=n.p,o=n.index,lX(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&&nf(n.index-o)<r.parent.length/XO?(QO(n,r,o),n):cX(t._searchMarker,r,o)},Jl=(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=ss(e,o.index+n))}},xf=(t,e,n)=>{const r=t,o=e.changedParentTypes;for(;vo(o,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;LO(r._eH,n,e)};class $t{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=IO(),this._dEH=IO(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw yr()}clone(){throw yr()}_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){DO(this._eH,e)}observeDeep(e){DO(this._dEH,e)}unobserve(e){PO(this._eH,e)}unobserveDeep(e){PO(this._dEH,e)}toJSON(){}}const ZO=(t,e,n)=>{t.doc??Qt(),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},e_=t=>{t.doc??Qt();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},t_=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&Js(r,e)){const o=r.content.getContent();for(let s=0;s<o.length;s++)n.push(o[s])}r=r.right}return n},Xl=(t,e)=>{let n=0,r=t._start;for(t.doc??Qt();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}},n_=(t,e)=>{const n=[];return Xl(t,(r,o)=>{n.push(e(r,o,t))}),n},uX=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}}}},r_=(t,e)=>{t.doc??Qt();const n=bf(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}},wf=(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 nt(Ie(i,bt(a,i)),o,o&&o.lastId,l,l&&l.id,e,null,new Zs(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 nt(Ie(i,bt(a,i)),o,o&&o.lastId,l,l&&l.id,e,null,new Ql(new Uint8Array(d))),o.integrate(t,0);break;case Ys:o=new nt(Ie(i,bt(a,i)),o,o&&o.lastId,l,l&&l.id,e,null,new ec(d)),o.integrate(t,0);break;default:if(d instanceof $t)o=new nt(Ie(i,bt(a,i)),o,o&&o.lastId,l,l&&l.id,e,null,new xr(d)),o.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},o_=()=>is("Length exceeded!"),s_=(t,e,n,r)=>{if(n>e._length)throw o_();if(n===0)return e._searchMarker&&Jl(e._searchMarker,n,r.length),wf(t,e,null,r);const o=n,s=bf(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&&kn(t,Ie(i.id.client,i.id.clock+n));break}n-=i.length}return e._searchMarker&&Jl(e._searchMarker,o,r.length),wf(t,e,i,r)},dX=(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 wf(t,e,o,n)},i_=(t,e,n,r)=>{if(r===0)return;const o=n,s=r,i=bf(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&&kn(t,Ie(a.id.client,a.id.clock+n)),n-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&kn(t,Ie(a.id.client,a.id.clock+r)),a.delete(t),r-=a.length),a=a.right;if(r>0)throw o_();e._searchMarker&&Jl(e._searchMarker,o,-s+r)},Ef=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},rv=(t,e,n,r)=>{const o=e._map.get(n)||null,s=t.doc,i=s.clientID;let a;if(r==null)a=new Zs([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:a=new Zs([r]);break;case Uint8Array:a=new Ql(r);break;case Ys:a=new ec(r);break;default:if(r instanceof $t)a=new xr(r);else throw new Error("Unexpected content type")}new nt(Ie(i,bt(s.store,i)),o,o&&o.lastId,null,null,e,n,a).integrate(t,0)},ov=(t,e)=>{t.doc??Qt();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},a_=t=>{const e={};return t.doc??Qt(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},l_=(t,e)=>{t.doc??Qt();const n=t._map.get(e);return n!==void 0&&!n.deleted},fX=(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&&Js(s,e)&&(n[o]=s.content.getContent()[s.length-1])}),n},Sf=t=>(t.doc??Qt(),RJ(t._map.entries(),e=>!e[1].deleted));class hX extends vf{}class na extends $t{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new na;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new na}clone(){const e=new na;return e.insert(0,this.toArray().map(n=>n instanceof $t?n.clone():n)),e}get length(){return this.doc??Qt(),this._length}_callObserver(e,n){super._callObserver(e,n),xf(this,e,new hX(this,e))}insert(e,n){this.doc!==null?Xe(this.doc,r=>{s_(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?Xe(this.doc,n=>{dX(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?Xe(this.doc,r=>{i_(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return r_(this,e)}toArray(){return e_(this)}slice(e=0,n=this.length){return ZO(this,e,n)}toJSON(){return this.map(e=>e instanceof $t?e.toJSON():e)}map(e){return n_(this,e)}forEach(e){Xl(this,e)}[Symbol.iterator](){return uX(this)}_write(e){e.writeTypeRef($X)}}const pX=t=>new na;class mX extends vf{constructor(e,n,r){super(e,n),this.keysChanged=r}}class ra extends $t{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 ra}clone(){const e=new ra;return this.forEach((n,r)=>{e.set(r,n instanceof $t?n.clone():n)}),e}_callObserver(e,n){xf(this,e,new mX(this,e,n))}toJSON(){this.doc??Qt();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const o=n.content.getContent()[n.length-1];e[r]=o instanceof $t?o.toJSON():o}}),e}get size(){return[...Sf(this)].length}keys(){return Wy(Sf(this),e=>e[0])}values(){return Wy(Sf(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Wy(Sf(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??Qt(),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?Xe(this.doc,n=>{Ef(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?Xe(this.doc,r=>{rv(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return ov(this,e)}has(e){return l_(this,e)}clear(){this.doc!==null?Xe(this.doc,e=>{this.forEach(function(n,r,o){Ef(e,o,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(BX)}}const gX=t=>new ra,ls=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&hJ(t,e);class sv{constructor(e,n,r,o){this.left=e,this.right=n,this.index=r,this.currentAttributes=o}forward(){switch(this.right===null&&Sn(),this.right.content.constructor){case kt:this.right.deleted||oa(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const c_=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case kt:e.right.deleted||oa(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n<e.right.length&&kn(t,Ie(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},kf=(t,e,n,r)=>{const o=new Map,s=r?bf(e,n):null;if(s){const i=new sv(s.p.left,s.p,s.index,o);return c_(t,i,n-s.index)}else{const i=new sv(null,e._start,0,o);return c_(t,i,n)}},u_=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===kt&&ls(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 nt(Ie(s,bt(o.store,s)),l,l&&l.lastId,c,c&&c.id,e,null,new kt(a,i));u.integrate(t,0),n.right=u,n.forward()})},oa=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},d_=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===kt&&ls(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},f_=(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(!ls(c,l)){i.set(a,c);const{left:u,right:d}=n;n.right=new nt(Ie(s,bt(o.store,s)),u,u&&u.lastId,d,d&&d.id,e,null,new kt(a,l)),n.right.integrate(t,0),n.forward()}}return i},iv=(t,e,n,r,o)=>{n.currentAttributes.forEach((f,h)=>{o[h]===void 0&&(o[h]=null)});const s=t.doc,i=s.clientID;d_(n,o);const a=f_(t,e,n,o),l=r.constructor===String?new br(r):r instanceof $t?new xr(r):new Qs(r);let{left:c,right:u,index:d}=n;e._searchMarker&&Jl(e._searchMarker,n.index,l.getLength()),u=new nt(Ie(i,bt(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(),u_(t,e,n,a)},h_=(t,e,n,r,o)=>{const s=t.doc,i=s.clientID;d_(n,o);const a=f_(t,e,n,o);e:for(;n.right!==null&&(r>0||a.size>0&&(n.right.deleted||n.right.content.constructor===kt));){if(!n.right.deleted)switch(n.right.content.constructor){case kt:{const{key:l,value:c}=n.right.content,u=o[l];if(u!==void 0){if(ls(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&&kn(t,Ie(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+=`
525
- `;n.right=new nt(Ie(i,bt(s.store,i)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new br(l)),n.right.integrate(t,0),n.forward()}u_(t,e,n,a)},p_=(t,e,n,r,o)=>{let s=e;const i=mr();for(;s&&(!s.countable||s.deleted);){if(!s.deleted&&s.content.constructor===kt){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;switch(c.constructor){case kt:{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&&oa(o,c);break}}}e=e.right}return a},yX=(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===kt){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},vX=t=>{let e=0;return Xe(t.doc,n=>{let r=t._start,o=t._start,s=mr();const i=Ty(s);for(;o;){if(o.deleted===!1)switch(o.content.constructor){case kt:oa(i,o.content);break;default:e+=p_(n,r,o,s,i),s=Ty(i),r=o;break}o=o.right}}),e},bX=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&&HO(t,n.store.clients.get(r),s,o,i=>{!i.deleted&&i.content.constructor===kt&&i.constructor!==Zn&&e.add(i.parent)})}Xe(n,r=>{as(t,t.deleteSet,o=>{if(o instanceof Zn||!o.parent._hasFormatting||e.has(o.parent))return;const s=o.parent;o.content.constructor===kt?e.add(s):yX(r,o)});for(const o of e)vX(o)})},m_=(t,e,n)=>{const r=n,o=Ty(e.currentAttributes),s=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case xr:case Qs:case br:n<e.right.length&&kn(t,Ie(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}s&&p_(t,s,e.right,o,e.currentAttributes);const i=(e.left||e.right).parent;return i._searchMarker&&Jl(i._searchMarker,e.index,-r+n),e};class xX extends vf{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=[];Xe(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},dJ(l)||(h.attributes=cJ({},l))),u=0;break}h&&n.push(h),a=null}};for(;i!==null;){switch(i.content.constructor){case xr:case Qs: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 br: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 kt:{const{key:h,value:p}=i.content;if(this.adds(i)){if(!this.deletes(i)){const m=o.get(h)??null;ls(m,p)?p!==null&&i.delete(r):(a==="retain"&&f(),ls(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;ls(m,p)||(a==="retain"&&f(),l[h]=m)}else if(!i.deleted){s.set(h,p);const m=l[h];m!==void 0&&(ls(m,p)?m!==null&&i.delete(r):(a==="retain"&&f(),p===null?delete l[h]:l[h]=p))}i.deleted||(a==="insert"&&f(),oa(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 cs extends $t{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Qt(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new cs}clone(){const e=new cs;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new xX(this,e,n);xf(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Qt();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===br&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?Xe(this.doc,r=>{const o=new sv(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)===`
526
- `?i.insert.slice(0,-1):i.insert;(typeof a!="string"||a.length>0)&&iv(r,this,o,a,i.attributes||{})}else i.retain!==void 0?h_(r,this,o,i.retain,i.attributes||{}):i.delete!==void 0&&m_(r,o,i.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??Qt();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(Js(l,e)||n!==void 0&&Js(l,n))switch(l.content.constructor){case br:{const d=s.get("ychange");e!==void 0&&!Js(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&&!Js(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 xr:case Qs:{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 kt:Js(l,e)&&(c(),oa(s,l.content));break}l=l.right}c()};return e||n?Xe(i,d=>{e&&ev(d,e),n&&ev(d,n),u()},"cleanup"):u(),o}insert(e,n,r){if(n.length<=0)return;const o=this.doc;o!==null?Xe(o,s=>{const i=kf(s,this,e,!r);r||(r={},i.currentAttributes.forEach((a,l)=>{r[l]=a})),iv(s,this,i,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const o=this.doc;o!==null?Xe(o,s=>{const i=kf(s,this,e,!r);iv(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?Xe(r,o=>{m_(o,kf(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?Xe(o,s=>{const i=kf(s,this,e,!1);i.right!==null&&h_(s,this,i,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?Xe(this.doc,n=>{Ef(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?Xe(this.doc,r=>{rv(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return ov(this,e)}getAttributes(){return a_(this)}_write(e){e.writeTypeRef(FX)}}const wX=t=>new cs;class av{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Qt()}[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===Zt||n.constructor===Xs)&&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 Xs extends $t{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 Xs}clone(){const e=new Xs;return e.insert(0,this.toArray().map(n=>n instanceof $t?n.clone():n)),e}get length(){return this.doc??Qt(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new av(this,e)}querySelector(e){e=e.toUpperCase();const r=new av(this,o=>o.nodeName&&o.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),qs(new av(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){xf(this,e,new kX(this,n,e))}toString(){return n_(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),Xl(this,s=>{o.insertBefore(s.toDOM(e,n,r),null)}),o}insert(e,n){this.doc!==null?Xe(this.doc,r=>{s_(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)Xe(this.doc,r=>{const o=e&&e instanceof $t?e._item:e;wf(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 is("Reference item not found");r.splice(o,0,...n)}}delete(e,n=1){this.doc!==null?Xe(this.doc,r=>{i_(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return e_(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return r_(this,e)}slice(e=0,n=this.length){return ZO(this,e,n)}forEach(e){Xl(this,e)}_write(e){e.writeTypeRef(zX)}}const EX=t=>new Xs;class Zt extends Xs{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 Zt(this.nodeName)}clone(){const e=new Zt(this.nodeName),n=this.getAttributes();return uJ(n,(r,o)=>{typeof r=="string"&&e.setAttribute(o,r)}),e.insert(0,this.toArray().map(r=>r instanceof $t?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?Xe(this.doc,n=>{Ef(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?Xe(this.doc,r=>{rv(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return ov(this,e)}hasAttribute(e){return l_(this,e)}getAttributes(e){return e?fX(this,e):a_(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 Xl(this,i=>{o.appendChild(i.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(o,this),o}_write(e){e.writeTypeRef(HX),e.writeKey(this.nodeName)}}const SX=t=>new Zt(t.readKey());class kX extends vf{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 Cf extends ra{constructor(e){super(),this.hookName=e}_copy(){return new Cf(this.hookName)}clone(){const e=new Cf(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(UX),e.writeKey(this.hookName)}}const CX=t=>new Cf(t.readKey());class Cn extends cs{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 Cn}clone(){const e=new Cn;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(VX)}}const TX=t=>new Cn;class lv{constructor(e,n){this.id=e,this.length=n}get deleted(){throw yr()}mergeWith(e){return!1}write(e,n,r){throw yr()}integrate(e,n){throw yr()}}const AX=0;class Zn extends lv{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),BO(e.doc.store,this)}write(e,n){e.writeInfo(AX),e.writeLen(this.length-n)}getMissing(e,n){return null}}class Ql{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Ql(this.content)}splice(e){throw yr()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const MX=t=>new Ql(t.readBuf());class Zl{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Zl(this.len)}splice(e){const n=new Zl(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){Gl(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 OX=t=>new Zl(t.readLen()),g_=(t,e)=>new Ys({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class ec{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),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 ec(g_(this.doc.guid,this.opts))}splice(e){throw yr()}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 _X=t=>new ec(g_(t.readString(),t.readAny()));class Qs{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Qs(this.embed)}splice(e){throw yr()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const NX=t=>new Qs(t.readJSON());class kt{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new kt(this.key,this.value)}splice(e){throw yr()}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 RX=t=>new kt(t.readKey(),t.readJSON());class Tf{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Tf(this.arr)}splice(e){const n=new Tf(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 IX=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 Tf(n)},DX=uf("node_env")==="development";class Zs{constructor(e){this.arr=e,DX&&vO(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Zs(this.arr)}splice(e){const n=new Zs(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 PX=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new Zs(n)};class br{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new br(this.str)}splice(e){const n=new br(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 LX=t=>new br(t.readString()),jX=[pX,gX,wX,SX,EX,CX,TX],$X=0,BX=1,FX=2,HX=3,zX=4,UX=5,VX=6;class xr{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new xr(this.type._copy())}splice(e){throw yr()}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 WX=t=>new xr(jX[t.readTypeRef()](t)),cv=(t,e)=>{let n=e,r=0,o;do r>0&&(n=Ie(n.client,n.clock+r)),o=ta(t,n),r=n.clock-o.id.clock,n=o.redone;while(n!==null&&o instanceof nt);return{item:o,diff:r}},uv=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},Af=(t,e,n)=>{const{client:r,clock:o}=e.id,s=new nt(Ie(r,o+n),e,Ie(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=Ie(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},y_=(t,e)=>MY(t,n=>Zi(n.deletions,e)),v_=(t,e,n,r,o,s)=>{const i=t.doc,a=i.store,l=i.clientID,c=e.redone;if(c!==null)return kn(t,c);let u=e.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||v_(t,u,n,r,o,s)===null))return null;for(;u.redone!==null;)u=kn(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 v=d;for(;v!==null&&v.parent._item!==u;)v=v.redone===null?null:kn(t,v.redone);if(v!==null&&v.parent._item===u){d=v;break}d=d.left}for(;f!==null;){let v=f;for(;v!==null&&v.parent._item!==u;)v=v.redone===null?null:kn(t,v.redone);if(v!==null&&v.parent._item===u){f=v;break}f=f.right}}else if(f=null,e.right&&!o){for(d=e;d!==null&&d.right!==null&&(d.right.redone||Zi(r,d.right.id)||y_(s.undoStack,d.right.id)||y_(s.redoStack,d.right.id));)for(d=d.right;d.redone;)d=kn(t,d.redone);if(d&&d.right!==null)return null}else d=h._map.get(e.parentSub)||null;const p=bt(a,l),m=Ie(l,p),y=new nt(m,d,d&&d.lastId,f,f&&f.id,h,e.parentSub,e.content.copy());return e.redone=m,uv(y,!0),y.integrate(t,0),y};let nt=class Rv extends lv{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()?tO:0}set marker(e){(this.info&_y)>0!==e&&(this.info^=_y)}get marker(){return(this.info&_y)>0}get keep(){return(this.info&eO)>0}set keep(e){this.keep!==e&&(this.info^=eO)}get countable(){return(this.info&tO)>0}get deleted(){return(this.info&Oy)>0}set deleted(e){this.deleted!==e&&(this.info^=Oy)}markDeleted(){this.info|=Oy}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=bt(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=bt(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ea&&this.id.client!==this.parent.client&&this.parent.clock>=bt(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=FO(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=kn(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Zn||this.right&&this.right.constructor===Zn)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Rv?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===Rv&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===ea){const r=ta(n,this.parent);r.constructor===Zn?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=FO(e,e.doc.store,Ie(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),hf(this.origin,o.origin)){if(o.id.client<this.id.client)r=o,s.clear();else if(hf(this.rightOrigin,o.rightOrigin))break}else if(o.origin!==null&&i.has(ta(e.doc.store,o.origin)))s.has(ta(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),BO(e.doc.store,this),this.content.integrate(e,this),UO(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Zn(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:Ie(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&hf(e.origin,this.lastId)&&this.right===e&&hf(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(),Gl(e.deleteSet,this.id.client,this.id.clock,this.length),UO(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw Sn();this.content.gc(e),n?JJ(e,this,new Zn(this.id,this.length)):this.content=new Zl(this.length)}write(e,n){const r=n>0?Ie(this.id.client,this.id.clock+n-1):this.origin,o=this.rightOrigin,s=this.parentSub,i=this.content.getRef()&rf|(r===null?0:dn)|(o===null?0:xo)|(s===null?0:Fl);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=ql(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===ea?(e.writeParentInfo(!1),e.writeLeftID(a)):Sn();s!==null&&e.writeString(s)}this.content.write(e,n)}};const b_=(t,e)=>GX[e&rf](t),GX=[()=>{Sn()},OX,IX,MX,LX,NX,RX,WX,PX,_X,()=>{Sn()}],qX=10;class wr extends lv{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){Sn()}write(e,n){e.writeInfo(qX),Fe(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const x_=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},w_="__ $YJS$ __";x_[w_]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),x_[w_]=!0;const KX=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},YX=/[\uD800-\uDBFF]/,JX=/[\uDC00-\uDFFF]/,XX=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&YX.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&&JX.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},Ur=(t,e)=>t>>>e|t<<32-e,QX=t=>Ur(t,2)^Ur(t,13)^Ur(t,22),ZX=t=>Ur(t,6)^Ur(t,11)^Ur(t,25),eQ=t=>Ur(t,7)^Ur(t,18)^t>>>3,tQ=t=>Ur(t,17)^Ur(t,19)^t>>>10,nQ=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]),rQ=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class oQ{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(rQ),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let d=16;d<64;d++)n[d]=tQ(n[d-2])+n[d-7]+eQ(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+ZX(a)+(a&l^~a&c)+nQ[d]+n[d]>>>0,h=QX(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]|=dn<<(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)]|=dn<<(3-n%4)*8),this._W[14]=e.byteLength/OY,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 sQ=t=>new oQ().digest(t),gt=new Ue("y-sync"),So=new Ue("y-undo");new Ue("yjs-cursor");const iQ=t=>{for(let n=6;n<t.length;n++)t[n%6]=t[n%6]^t[n];return t.slice(0,6)},aQ=t=>vJ(iQ(sQ(bJ(t)))),Mf=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!Zi(e.ds,t.id),lQ=[{light:"#ecd44433",dark:"#ecd444"}],cQ=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=Gs();t.forEach(o=>r.add(o)),e=e.filter(o=>!r.has(o))}t.set(n,nJ(e))}return t.get(n)},uQ=(t,{colors:e=lQ,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:o=()=>{},mapping:s}={})=>{let i=!1;const a=new fQ(t,s),l=new He({props:{editable:c=>{const u=gt.getState(c);return u.snapshot==null&&u.prevSnapshot==null}},key:gt,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(gt);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)&&wO(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=So.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)},gt)})}},destroy:()=>{a.destroy()}})});return l},dQ=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new yn(t.doc));else if(e.type==="node"){const r=Rf(n.doc,n.type,e.anchor,n.mapping);t.setSelection(ue.create(t.doc,r))}else{const r=Rf(n.doc,n.type,e.anchor,n.mapping),o=Rf(n.doc,n.type,e.head,n.mapping);r!==null&&o!==null&&t.setSelection(pe.between(t.doc.resolve(r),t.doc.resolve(o)))}},dv=(t,e)=>({type:e.selection.jsonID,anchor:yv(e.selection.anchor,t.type,t.mapping),head:yv(e.selection.head,t.type,t.mapping)});class fQ{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=KX(),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=dv(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()?(bO&&this._domSelectionInView===null&&(wO(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=wJ.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=jO(OO(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(gt,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>Of(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Q(F.from(e),0,0));n.setMeta(gt,{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=>Of(o,this.prosemirrorView.state.schema,this)).filter(o=>o!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Q(F.from(n),0,0));if(e){const o=Ki(ss(e.anchor,0),r.doc.content.size),s=Ki(ss(e.head,0),r.doc.content.size);r.setSelection(pe.create(r.doc,o,s))}this.prosemirrorView.dispatch(r.setMeta(gt,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let o=this.doc,s=this.type;if(e||(e=Zy(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&Sn(),o=new Ys({gc:!1}),Jy(o,n),n=Zy(o),Jy(o,e),e=Zy(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=vr(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=>{as(i,d,f=>{})});const l=(d,f)=>{const h=d==="added"?a.getUserByClientId(f.client):a.getUserByDeletedId(f);return{user:h,type:d,color:cQ(r.colorMapping,r.colors,h)}},c=t_(s,new Qy(n.ds,e.sv)).map(d=>!d._item.deleted||Mf(d._item,e)||Mf(d._item,n)?Of(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 Q(F.from(c),0,0));this.prosemirrorView.dispatch(u.setMeta(gt,{isChangeOrigin:!0}))},gt)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=gt.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);as(n,n.deleteSet,a=>{if(a.constructor===nt){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=>E_(a,this.prosemirrorView.state.schema,this)).filter(a=>a!==null);let i=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Q(F.from(s),0,0));dQ(i,this.beforeTransactionSelection,this),i=i.setMeta(gt,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof qO}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&i.scrollIntoView(),this.prosemirrorView.dispatch(i)})}_prosemirrorChanged(e){this.doc.transact(()=>{mv(this.doc,this.type,e,this),this.beforeTransactionSelection=dv(this,this.prosemirrorView.state)},gt)}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 E_=(t,e,n,r,o,s)=>{const i=n.mapping.get(t);if(i===void 0){if(t instanceof Zt)return Of(t,e,n,r,o,s);throw yr()}return i},Of=(t,e,n,r,o,s)=>{const i=[],a=l=>{if(l instanceof Zt){const c=E_(l,e,n,r,o,s);c!==null&&i.push(c)}else{const c=l._item.right?.content?.type;c instanceof cs&&!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=hQ(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):t_(t,new Qy(o.ds,r.sv)).forEach(a);try{const l=t.getAttributes(r);r!==void 0&&(Mf(t._item,r)?Mf(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)},gt),n.mapping.delete(t),null}},hQ=(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,bQ(c.attributes,e)))}}catch{return t.doc.transact(c=>{t._item.delete(c)},gt),null}return i},pQ=(t,e)=>{const n=new Cn,r=t.map(o=>({insert:o.text,attributes:T_(o.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},mQ=(t,e)=>{const n=new Zt(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,_f(t).map(r=>fv(r,e))),e.mapping.set(n,t),n},fv=(t,e)=>t instanceof Array?pQ(t,e):mQ(t,e),S_=t=>typeof t=="object"&&t!==null,hv=(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||S_(i)&&S_(a)&&hv(i,a)}return r},_f=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},k_=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,o)=>r.insert===e[o].text&&mO(r.attributes||{}).length===e[o].marks.length&&yO(r.attributes,(s,i)=>{const a=pv(i),l=e[o].marks;return hv(s,l.find(c=>c.type.name===a)?.attrs)}))},tc=(t,e)=>{if(t instanceof Zt&&!(e instanceof Array)&&gv(t,e)){const n=_f(e);return t._length===n.length&&hv(t.getAttributes(),e.attrs)&&t.toArray().every((r,o)=>tc(r,n[o]))}return t instanceof Cn&&e instanceof Array&&k_(t,e)},Nf=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),C_=(t,e,n)=>{const r=t.toArray(),o=_f(e),s=o.length,i=r.length,a=Ki(i,s);let l=0,c=0,u=!1;for(;l<a;l++){const d=r[l],f=o[l];if(Nf(n.mapping.get(d),f))u=!0;else if(!tc(d,f))break}for(;l+c<a;c++){const d=r[i-c-1],f=o[s-c-1];if(Nf(n.mapping.get(d),f))u=!0;else if(!tc(d,f))break}return{equalityFactor:l+c,foundMappedChild:u}},gQ=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof br?e+=n.content.str:n.content instanceof kt&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},yQ=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:o}=gQ(t),s=e.map(c=>({insert:c.text,attributes:Object.assign({},r,T_(c.marks,n))})),{insert:i,remove:a,index:l}=XX(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})))},vQ=/(.*)(--[a-zA-Z0-9+/=]{8})$/,pv=t=>vQ.exec(t)?.[1]??t,bQ=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(pv(r),t[r]));return n},T_=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const o=vo(e.isOMark,r.type,()=>!r.type.excludes(r.type));n[o?`${r.type.name}--${aQ(r.toJSON())}`:r.type.name]=r.attrs}}),n},mv=(t,e,n,r)=>{if(e instanceof Zt&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof Zt){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=_f(n),s=o.length,i=e.toArray(),a=i.length,l=Ki(s,a);let c=0,u=0;for(;c<l;c++){const d=i[c],f=o[c];if(!Nf(r.mapping.get(d),f))if(tc(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(!Nf(r.mapping.get(d),f))if(tc(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 Cn&&h instanceof Array)k_(f,h)||yQ(f,h,r),c+=1;else{let y=f instanceof Zt&&gv(f,h),v=p instanceof Zt&&gv(p,m);if(y&&v){const w=C_(f,h,r),E=C_(p,m,r);w.foundMappedChild&&!E.foundMappedChild?v=!1:!w.foundMappedChild&&E.foundMappedChild||w.equalityFactor<E.equalityFactor?y=!1:v=!1}y?(mv(t,f,h,r),c+=1):v?(mv(t,p,m,r),u+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[fv(h,r)]),c+=1)}}const d=a-c-u;if(a===1&&s===0&&i[0]instanceof Cn?(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(fv(o[h],r));e.insert(c,f)}},gt)},gv=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name,yv=(t,e,n)=>{if(t===0)return Xy(e,0,-1);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof Cn){if(r._length>=t)return Xy(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 pf(r._item===null?null:r._item.id,r._item===null?ql(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 pf(r._item===null?null:r._item.id,r._item===null?ql(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 Sn();if(t===0&&r.constructor!==Cn&&r!==e)return xQ(r._item.parent,r._item)}return Xy(e,e._length,-1)},xQ=(t,e)=>{let n=null,r=null;return t._item===null?r=ql(t):n=Ie(t._item.id.client,t._item.id.clock),new pf(n,r,e.id)},Rf=(t,e,n,r)=>{const o=YJ(n,t);if(o===null||o.type!==e&&!Kl(e,o.type._item))return null;let s=o.type,i=0;if(s.constructor===Cn)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 Cn?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 Cn?i+=c._length:i+=r.get(c).nodeSize),l=l.right}}s=a}return i-1};function wQ(t){const e=t.toArray(),n=r=>{let o;if(r instanceof Cn)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:pv(l)};return Object.keys(c)&&(d.attrs=c),d})),a});else if(r instanceof Zt){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 Sn();return o};return{type:"doc",content:e.map(n)}}const EQ=t=>{const e=So.getState(t).undoManager;if(e!=null)return e.undo(),!0},SQ=t=>{const e=So.getState(t).undoManager;if(e!=null)return e.redo(),!0},kQ=new Set(["paragraph"]),CQ=(t,e)=>!(t instanceof nt)||!(t.content instanceof xr)||!(t.content.type instanceof cs||t.content.type instanceof Zt&&e.has(t.content.type.nodeName))||t.content.type._length===0,TQ=({protectedNodes:t=kQ,trackedOrigins:e=[],undoManager:n=null}={})=>new He({key:So,state:{init:(r,o)=>{const s=gt.getState(o),i=n||new qO(s.type,{trackedOrigins:new Set([gt].concat(e)),deleteFilter:a=>CQ(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=gt.getState(i).binding,l=o.undoManager,c=l.undoStack.length>0,u=l.redoStack.length>0;return a?{undoManager:l,prevSel:dv(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=gt.getState(r.state),s=So.getState(r.state).undoManager;return s.on("stack-item-added",({stackItem:i})=>{const a=o.binding;a&&i.meta.set(a,So.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()}}}});Je.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")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".')},addCommands(){return{undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),So.getState(e).undoManager.undoStack.length===0?!1:n?EQ(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),So.getState(e).undoManager.redoStack.length===0?!1:n?SQ(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=TQ(this.options.yUndoOptions),r=n.spec.view;n.spec.view=i=>{const{undoManager:a}=So.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=uQ(e,o);return this.editor.options.enableContentCheck&&((t=e.doc)==null||t.on("beforeTransaction",()=>{try{const i=wQ(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 He({key:new Ue("filterInvalidContent"),filterTransaction:()=>{var i;return this.storage.isDisabled!==!1&&((i=e.doc)==null||i.destroy()),!0}})].filter(Boolean)}});function AQ(t){return!!t.getMeta(gt)}function A_(t){if(!t.length)return et.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(Vt.node(o,o+s.nodeSize,{class:"ProseMirror-selectednoderange"}))}),et.create(n,e)}function If(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 wa(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 vx(o.resolve(c),o.resolve(u));r.push(d)}),r}var MQ=class ON{constructor(e,n){this.anchor=e,this.head=n}map(e){return new ON(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return new us(n,r)}},us=class hs extends Me{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=If(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 hs&&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 hs(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 hs(s,i,this.depth)}const n=this.ranges[0],r=e.resolve(Math.max(0,n.$from.pos-1));return new hs(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 hs(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 hs(this.$anchor,r,this.depth)}static fromJSON(e,n){return new hs(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 MQ(this.anchor,this.head)}};us.prototype.visible=!1;function Df(t){return t instanceof us}Je.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(!Df(s)){const u=us.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(!Df(s)){const u=us.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=us.create(o,0,o.content.size,e);return s.setSelection(i),n.dispatch(s),!0}}},onSelectionUpdate(){const{selection:t}=this.editor.state;Df(t)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let t=!1,e=!1;return[new He({key:new Ue("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:y}=h;if(m.sameParent(y))return;const v=us.create(f,m.pos,y.pos,this.options.depth);p.setSelection(v),n.dispatch(p)},{once:!0}),!1}},decorations:n=>{const{selection:r}=n,o=Df(r);if(t=!1,!e)return o?(t=!0,A_(r.ranges)):null;const{$from:s,$to:i}=r;if(!o&&s.sameParent(i))return null;const a=If(s,i,this.options.depth);return a.length?(t=!0,A_(a)):null}}})]}});function OQ(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 _Q(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=OQ(o)}),e}var M_=t=>{const{x:e,y:n,direction:r="right",editor:o,bandHeight:s=5}=t,i={top:n-s,bottom:n+s,left:r==="right"?e:0,right:r==="right"?window.innerWidth-e:e},l=[...o.view.dom.querySelectorAll("*")].filter(h=>o.view.posAtDOM(h,0)>=0).filter(h=>{const p=h.getBoundingClientRect();return!(p.bottom<i.top||p.top>i.bottom||p.right<i.left||p.left>i.right)});if(!l||l.length===0)return{resultElement:null,resultNode:null,pos:null};const c=l[0],u=o.view.posAtDOM(c,0);if(u===-1)return{resultElement:c,resultNode:null,pos:null};const d=o.state.doc.resolve(u);if(d.nodeAfter){const h=o.view.nodeDOM(d.pos);if(h&&h===c)return{resultElement:c,resultNode:d.nodeAfter,pos:u}}const f=o.state.doc.nodeAt(u-1);return{resultElement:c,resultNode:f,pos:u}};function Pf(t,e){return window.getComputedStyle(t)[e]}function NQ(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function RQ(t,e,n){const r=parseInt(Pf(t.dom,"paddingLeft"),10),o=parseInt(Pf(t.dom,"paddingRight"),10),s=parseInt(Pf(t.dom,"borderLeftWidth"),10),i=parseInt(Pf(t.dom,"borderLeftWidth"),10),a=t.dom.getBoundingClientRect();return{left:NQ(e,a.left+r+s,a.right-o-i),top:n}}function O_(t){var e;(e=t.parentNode)==null||e.removeChild(t)}function IQ(t,e){const{doc:n}=e.view.state,r=M_({editor:e,x:t.clientX,y:t.clientY,direction:"right"});if(!r.resultNode||r.pos===null)return[];const o=t.clientX,s=RQ(e.view,o,t.clientY),i=e.view.posAtCoords(s);if(!i)return[];const{pos:a}=i;if(!n.resolve(a).parent)return[];const c=n.resolve(r.pos),u=n.resolve(r.pos+1);return If(c,u,0)}function DQ(t,e){const{view:n}=e;if(!t.dataTransfer)return;const{empty:r,$from:o,$to:s}=n.state.selection,i=IQ(t,e),a=If(o,s,0),l=a.some(y=>i.find(v=>v.$from===y.$from&&v.$to===y.$to)),c=r||!l?i:a;if(!c.length)return;const{tr:u}=n.state,d=document.createElement("div"),f=c[0].$from.pos,h=c[c.length-1].$to.pos,p=us.create(n.state.doc,f,h),m=p.content();c.forEach(y=>{const v=n.nodeDOM(y.$from.pos),w=_Q(v);d.append(w)}),d.style.position="absolute",d.style.top="-10000px",document.body.append(d),t.dataTransfer.clearData(),t.dataTransfer.setDragImage(d,0,0),n.dragging={slice:m,move:!0},u.setSelection(p),n.dispatch(u),document.addEventListener("drop",()=>O_(d),{once:!0})}var __=(t,e)=>{const n=t.resolve(e),{depth:r}=n;return r===0?e:n.pos-n.parentOffset-1},N_=(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},vv=(t,e)=>{const n=gt.getState(t);return n?yv(e,n.type,n.binding.mapping):null},PQ=(t,e)=>{const n=gt.getState(t);return n?Rf(n.doc,n.type,e,n.binding.mapping)||0:-1},R_=(t,e)=>{let n=e;for(;n?.parentNode&&n.parentNode!==t.dom;)n=n.parentNode;return n},I_=new Ue("dragHandle"),D_=({pluginKey:t=I_,element:e,editor:n,computePositionConfig:r,getReferencedVirtualElement:o,onNodeChange:s,onElementDragStart:i,onElementDragEnd:a})=>{const l=document.createElement("div");let c=!1,u=null,d=-1,f,h=null,p=null;function m(){e&&(e.style.visibility="hidden",e.style.pointerEvents="none")}function y(){if(e){if(!n.isEditable){m();return}e.style.visibility="",e.style.pointerEvents="auto"}}function v(x){const k=o?.()||{getBoundingClientRect:()=>x.getBoundingClientRect()};bS(k,e,r).then(S=>{Object.assign(e.style,{position:S.strategy,left:`${S.x}px`,top:`${S.y}px`})})}function w(x){i?.(x),DQ(x,n),setTimeout(()=>{e&&(e.style.pointerEvents="none")},0)}function E(x){a?.(x),m(),e&&(e.style.pointerEvents="auto")}return e.addEventListener("dragstart",w),e.addEventListener("dragend",E),l.appendChild(e),{unbind(){e.removeEventListener("dragstart",w),e.removeEventListener("dragend",E),h&&(cancelAnimationFrame(h),h=null,p=null)},plugin:new He({key:typeof t=="string"?new Ue(t):t,state:{init(){return{locked:!1}},apply(x,k,S,C){const T=x.getMeta("lockDragHandle"),N=x.getMeta("hideDragHandle");if(T!==void 0&&(c=T),N)return m(),c=!1,u=null,d=-1,s?.({editor:n,node:null,pos:-1}),k;if(x.docChanged&&d!==-1&&e)if(AQ(x)){const _=PQ(C,f);_!==d&&(d=_)}else{const _=x.mapping.map(d);_!==d&&(d=_,f=vv(C,d))}return k}},view:x=>{var k;return e.draggable=!0,e.style.pointerEvents="auto",(k=n.view.dom.parentElement)==null||k.appendChild(l),l.style.pointerEvents="none",l.style.position="absolute",l.style.top="0",l.style.left="0",{update(S,C){if(!e)return;if(!n.isEditable){m();return}if(c?e.draggable=!1:e.draggable=!0,x.state.doc.eq(C.doc)||d===-1)return;let T=x.nodeDOM(d);if(T=R_(x,T),T===x.dom||T?.nodeType!==1)return;const N=x.posAtDOM(T,0),_=N_(n.state.doc,N),L=__(n.state.doc,N);u=_,d=L,f=vv(x.state,d),s?.({editor:n,node:u,pos:d}),v(T)},destroy(){h&&(cancelAnimationFrame(h),h=null,p=null),e&&O_(l)}}},props:{handleDOMEvents:{keydown(x){return!e||c||x.hasFocus()&&(m(),u=null,d=-1,s?.({editor:n,node:null,pos:-1})),!1},mouseleave(x,k){return c||k.target&&!l.contains(k.relatedTarget)&&(m(),u=null,d=-1,s?.({editor:n,node:null,pos:-1})),!1},mousemove(x,k){return!e||c||(p={x:k.clientX,y:k.clientY},h)||(h=requestAnimationFrame(()=>{if(h=null,!p)return;const{x:S,y:C}=p;p=null;const T=M_({x:S,y:C,direction:"right",editor:n});if(!T.resultElement)return;let N=T.resultElement;if(N=R_(x,N),N===x.dom||N?.nodeType!==1)return;const _=x.posAtDOM(N,0),L=N_(n.state.doc,_);if(L!==u){const $=__(n.state.doc,_);u=L,d=$,f=vv(x.state,d),s?.({editor:n,node:u,pos:d}),v(N),y()}})),!1}}}})}},bv={placement:"left-start",strategy:"absolute"};Je.create({name:"dragHandle",addOptions(){return{render(){const t=document.createElement("div");return t.classList.add("drag-handle"),t},computePositionConfig:{},locked:!1,onNodeChange:()=>null}},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();return[D_({computePositionConfig:{...bv,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:t,editor:this.editor,onNodeChange:this.options.onNodeChange}).plugin]}});var LQ=t=>{const{className:e="drag-handle",children:n,editor:r,pluginKey:o=I_,onNodeChange:s,onElementDragStart:i,onElementDragEnd:a,computePositionConfig:l=bv}=t,[c,u]=M.useState(null),d=M.useRef(null);return M.useEffect(()=>{let f=null;return c?r.isDestroyed?()=>{d.current=null}:(d.current||(f=D_({editor:r,element:c,pluginKey:o,computePositionConfig:{...bv,...l},onElementDragStart:i,onElementDragEnd:a,onNodeChange:s}),d.current=f.plugin,r.registerPlugin(d.current)),()=>{r.unregisterPlugin(o),d.current=null,f&&(f.unbind(),f=null)}):()=>{d.current=null}},[c,r,s,o,l,i,a]),g.jsx("div",{className:e,style:{visibility:"hidden",position:"absolute"},ref:u,children:n})},jQ=LQ;const P_=({editor:t,actions:e,editorTab:n,onSwitchEditor:r,isSubmitting:o,onSubmit:s,className:i})=>g.jsxs("div",{className:re("post-builder-editor bg-background border rounded-md overflow-hidden min-h-60 max-h-full grow flex flex-col overflow-y-auto transition-all duration-300 ease-in-out",i),children:[g.jsx(KB,{editorTab:n,onSwitchEditorTab:r}),g.jsx(z8,{editor:t,actions:e,isSubmitting:o,onSubmit:s,editorType:n,children:g.jsxs("div",{className:"flex flex-col grow overflow-y-auto",children:[g.jsx(jQ,{editor:t,className:re(" pr-2",n!==ht.Text&&"hidden size-0 overflow-hidden pointer-events-none"),children:g.jsx(Rn,{variant:"ghost",className:"bg-white cursor-grab py-0.5 px-0 border size-auto",children:g.jsx(uU,{className:"text-muted-foreground"})})}),g.jsx(DB,{className:"grow overflow-y-auto","data-theme":"select-post-builder",editor:t})]})})]});function L_(t,[e,n]){return Math.min(n,Math.max(e,t))}var $Q=[" ","Enter","ArrowUp","ArrowDown"],BQ=[" ","Enter"],ei="Select",[Lf,jf,FQ]=dh(ei),[sa]=On(ei,[FQ,Go]),$f=Go(),[HQ,ds]=sa(ei),[zQ,UQ]=sa(ei),j_=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=$f(e),[y,v]=b.useState(null),[w,E]=b.useState(null),[x,k]=b.useState(!1),S=Cc(c),[C,T]=Jr({prop:r,defaultProp:o??!1,onChange:s,caller:ei}),[N,_]=Jr({prop:i,defaultProp:a,onChange:l,caller:ei}),L=b.useRef(null),$=y?p||!!y.closest("form"):!0,[B,z]=b.useState(new Set),j=Array.from(B).map(P=>P.props.value).join(";");return g.jsx(Tu,{...m,children:g.jsxs(HQ,{required:h,scope:e,trigger:y,onTriggerChange:v,valueNode:w,onValueNodeChange:E,valueNodeHasChildren:x,onValueNodeHasChildrenChange:k,contentId:Bn(),value:N,onValueChange:_,open:C,onOpenChange:T,dir:S,triggerPointerDownPosRef:L,disabled:f,children:[g.jsx(Lf.Provider,{scope:e,children:g.jsx(zQ,{scope:t.__scopeSelect,onNativeOptionAdd:b.useCallback(P=>{z(H=>new Set(H).add(P))},[]),onNativeOptionRemove:b.useCallback(P=>{z(H=>{const R=new Set(H);return R.delete(P),R})},[]),children:n})}),$?g.jsxs(sN,{"aria-hidden":!0,required:h,tabIndex:-1,name:u,autoComplete:d,value:N,onChange:P=>_(P.target.value),disabled:f,form:p,children:[N===void 0?g.jsx("option",{value:""}):null,Array.from(B)]},j):null]})})};j_.displayName=ei;var $_="SelectTrigger",B_=b.forwardRef((t,e)=>{const{__scopeSelect:n,disabled:r=!1,...o}=t,s=$f(n),i=ds($_,n),a=i.disabled||r,l=$e(e,i.onTriggerChange),c=jf(n),u=b.useRef("touch"),[d,f,h]=aN(m=>{const y=c().filter(E=>!E.disabled),v=y.find(E=>E.value===i.value),w=lN(y,m,v);w!==void 0&&i.onValueChange(w.value)}),p=m=>{a||(i.onOpenChange(!0),h()),m&&(i.triggerPointerDownPosRef.current={x:Math.round(m.pageX),y:Math.round(m.pageY)})};return g.jsx(qa,{asChild:!0,...s,children:g.jsx(ge.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":iN(i.value)?"":void 0,...o,ref:l,onClick:te(o.onClick,m=>{m.currentTarget.focus(),u.current!=="mouse"&&p(m)}),onPointerDown:te(o.onPointerDown,m=>{u.current=m.pointerType;const y=m.target;y.hasPointerCapture(m.pointerId)&&y.releasePointerCapture(m.pointerId),m.button===0&&m.ctrlKey===!1&&m.pointerType==="mouse"&&(p(m),m.preventDefault())}),onKeyDown:te(o.onKeyDown,m=>{const y=d.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&f(m.key),!(y&&m.key===" ")&&$Q.includes(m.key)&&(p(),m.preventDefault())})})})});B_.displayName=$_;var F_="SelectValue",H_=b.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:o,children:s,placeholder:i="",...a}=t,l=ds(F_,n),{onValueNodeHasChildrenChange:c}=l,u=s!==void 0,d=$e(e,l.onValueNodeChange);return Tt(()=>{c(u)},[c,u]),g.jsx(ge.span,{...a,ref:d,style:{pointerEvents:"none"},children:iN(l.value)?g.jsx(g.Fragment,{children:i}):s})});H_.displayName=F_;var VQ="SelectIcon",z_=b.forwardRef((t,e)=>{const{__scopeSelect:n,children:r,...o}=t;return g.jsx(ge.span,{"aria-hidden":!0,...o,ref:e,children:r||"▼"})});z_.displayName=VQ;var WQ="SelectPortal",U_=t=>g.jsx(Mi,{asChild:!0,...t});U_.displayName=WQ;var ti="SelectContent",V_=b.forwardRef((t,e)=>{const n=ds(ti,t.__scopeSelect),[r,o]=b.useState();if(Tt(()=>{o(new DocumentFragment)},[]),!n.open){const s=r;return s?oc.createPortal(g.jsx(W_,{scope:t.__scopeSelect,children:g.jsx(Lf.Slot,{scope:t.__scopeSelect,children:g.jsx("div",{children:t.children})})}),s):null}return g.jsx(G_,{...t,ref:e})});V_.displayName=ti;var Er=10,[W_,fs]=sa(ti),GQ="SelectContentImpl",qQ=Mo("SelectContent.RemoveScroll"),G_=b.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:y,...v}=t,w=ds(ti,n),[E,x]=b.useState(null),[k,S]=b.useState(null),C=$e(e,U=>x(U)),[T,N]=b.useState(null),[_,L]=b.useState(null),$=jf(n),[B,z]=b.useState(!1),j=b.useRef(!1);b.useEffect(()=>{if(E)return Bu(E)},[E]),Nu();const P=b.useCallback(U=>{const[ee,...Oe]=$().map(Se=>Se.ref.current),[he]=Oe.slice(-1),we=document.activeElement;for(const Se of U)if(Se===we||(Se?.scrollIntoView({block:"nearest"}),Se===ee&&k&&(k.scrollTop=0),Se===he&&k&&(k.scrollTop=k.scrollHeight),Se?.focus(),document.activeElement!==we))return},[$,k]),H=b.useCallback(()=>P([T,E]),[P,T,E]);b.useEffect(()=>{B&&H()},[B,H]);const{onOpenChange:R,triggerPointerDownPosRef:V}=w;b.useEffect(()=>{if(E){let U={x:0,y:0};const ee=he=>{U={x:Math.abs(Math.round(he.pageX)-(V.current?.x??0)),y:Math.abs(Math.round(he.pageY)-(V.current?.y??0))}},Oe=he=>{U.x<=10&&U.y<=10?he.preventDefault():E.contains(he.target)||R(!1),document.removeEventListener("pointermove",ee),V.current=null};return V.current!==null&&(document.addEventListener("pointermove",ee),document.addEventListener("pointerup",Oe,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ee),document.removeEventListener("pointerup",Oe,{capture:!0})}}},[E,R,V]),b.useEffect(()=>{const U=()=>R(!1);return window.addEventListener("blur",U),window.addEventListener("resize",U),()=>{window.removeEventListener("blur",U),window.removeEventListener("resize",U)}},[R]);const[ie,ne]=aN(U=>{const ee=$().filter(we=>!we.disabled),Oe=ee.find(we=>we.ref.current===document.activeElement),he=lN(ee,U,Oe);he&&setTimeout(()=>he.ref.current.focus())}),ye=b.useCallback((U,ee,Oe)=>{const he=!j.current&&!Oe;(w.value!==void 0&&w.value===ee||he)&&(N(U),he&&(j.current=!0))},[w.value]),G=b.useCallback(()=>E?.focus(),[E]),Z=b.useCallback((U,ee,Oe)=>{const he=!j.current&&!Oe;(w.value!==void 0&&w.value===ee||he)&&L(U)},[w.value]),J=r==="popper"?xv:q_,me=J===xv?{side:a,sideOffset:l,align:c,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:h,sticky:p,hideWhenDetached:m,avoidCollisions:y}:{};return g.jsx(W_,{scope:n,content:E,viewport:k,onViewportChange:S,itemRefCallback:ye,selectedItem:T,onItemLeave:G,itemTextRefCallback:Z,focusSelectedItem:H,selectedItemText:_,position:r,isPositioned:B,searchRef:ie,children:g.jsx(Xa,{as:qQ,allowPinchZoom:!0,children:g.jsx(Ja,{asChild:!0,trapped:w.open,onMountAutoFocus:U=>{U.preventDefault()},onUnmountAutoFocus:te(o,U=>{w.trigger?.focus({preventScroll:!0}),U.preventDefault()}),children:g.jsx(Si,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:s,onPointerDownOutside:i,onFocusOutside:U=>U.preventDefault(),onDismiss:()=>w.onOpenChange(!1),children:g.jsx(J,{role:"listbox",id:w.contentId,"data-state":w.open?"open":"closed",dir:w.dir,onContextMenu:U=>U.preventDefault(),...v,...me,onPlaced:()=>z(!0),ref:C,style:{display:"flex",flexDirection:"column",outline:"none",...v.style},onKeyDown:te(v.onKeyDown,U=>{const ee=U.ctrlKey||U.altKey||U.metaKey;if(U.key==="Tab"&&U.preventDefault(),!ee&&U.key.length===1&&ne(U.key),["ArrowUp","ArrowDown","Home","End"].includes(U.key)){let he=$().filter(we=>!we.disabled).map(we=>we.ref.current);if(["ArrowUp","End"].includes(U.key)&&(he=he.slice().reverse()),["ArrowUp","ArrowDown"].includes(U.key)){const we=U.target,Se=he.indexOf(we);he=he.slice(Se+1)}setTimeout(()=>P(he)),U.preventDefault()}})})})})})})});G_.displayName=GQ;var KQ="SelectItemAlignedPosition",q_=b.forwardRef((t,e)=>{const{__scopeSelect:n,onPlaced:r,...o}=t,s=ds(ti,n),i=fs(ti,n),[a,l]=b.useState(null),[c,u]=b.useState(null),d=$e(e,C=>u(C)),f=jf(n),h=b.useRef(!1),p=b.useRef(!0),{viewport:m,selectedItem:y,selectedItemText:v,focusSelectedItem:w}=i,E=b.useCallback(()=>{if(s.trigger&&s.valueNode&&a&&c&&m&&y&&v){const C=s.trigger.getBoundingClientRect(),T=c.getBoundingClientRect(),N=s.valueNode.getBoundingClientRect(),_=v.getBoundingClientRect();if(s.dir!=="rtl"){const we=_.left-T.left,Se=N.left-we,Ve=C.left-Se,ut=C.width+Ve,dt=Math.max(ut,T.width),Ot=window.innerWidth-Er,yt=L_(Se,[Er,Math.max(Er,Ot-dt)]);a.style.minWidth=ut+"px",a.style.left=yt+"px"}else{const we=T.right-_.right,Se=window.innerWidth-N.right-we,Ve=window.innerWidth-C.right-Se,ut=C.width+Ve,dt=Math.max(ut,T.width),Ot=window.innerWidth-Er,yt=L_(Se,[Er,Math.max(Er,Ot-dt)]);a.style.minWidth=ut+"px",a.style.right=yt+"px"}const L=f(),$=window.innerHeight-Er*2,B=m.scrollHeight,z=window.getComputedStyle(c),j=parseInt(z.borderTopWidth,10),P=parseInt(z.paddingTop,10),H=parseInt(z.borderBottomWidth,10),R=parseInt(z.paddingBottom,10),V=j+P+B+R+H,ie=Math.min(y.offsetHeight*5,V),ne=window.getComputedStyle(m),ye=parseInt(ne.paddingTop,10),G=parseInt(ne.paddingBottom,10),Z=C.top+C.height/2-Er,J=$-Z,me=y.offsetHeight/2,U=y.offsetTop+me,ee=j+P+U,Oe=V-ee;if(ee<=Z){const we=L.length>0&&y===L[L.length-1].ref.current;a.style.bottom="0px";const Se=c.clientHeight-m.offsetTop-m.offsetHeight,Ve=Math.max(J,me+(we?G:0)+Se+H),ut=ee+Ve;a.style.height=ut+"px"}else{const we=L.length>0&&y===L[0].ref.current;a.style.top="0px";const Ve=Math.max(Z,j+m.offsetTop+(we?ye:0)+me)+Oe;a.style.height=Ve+"px",m.scrollTop=ee-Z+m.offsetTop}a.style.margin=`${Er}px 0`,a.style.minHeight=ie+"px",a.style.maxHeight=$+"px",r?.(),requestAnimationFrame(()=>h.current=!0)}},[f,s.trigger,s.valueNode,a,c,m,y,v,s.dir,r]);Tt(()=>E(),[E]);const[x,k]=b.useState();Tt(()=>{c&&k(window.getComputedStyle(c).zIndex)},[c]);const S=b.useCallback(C=>{C&&p.current===!0&&(E(),w?.(),p.current=!1)},[E,w]);return g.jsx(JQ,{scope:n,contentWrapper:a,shouldExpandOnScrollRef:h,onScrollButtonChange:S,children:g.jsx("div",{ref:l,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:x},children:g.jsx(ge.div,{...o,ref:d,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});q_.displayName=KQ;var YQ="SelectPopperPosition",xv=b.forwardRef((t,e)=>{const{__scopeSelect:n,align:r="start",collisionPadding:o=Er,...s}=t,i=$f(n);return g.jsx(Au,{...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)"}})});xv.displayName=YQ;var[JQ,wv]=sa(ti,{}),Ev="SelectViewport",K_=b.forwardRef((t,e)=>{const{__scopeSelect:n,nonce:r,...o}=t,s=fs(Ev,n),i=wv(Ev,n),a=$e(e,s.onViewportChange),l=b.useRef(0);return g.jsxs(g.Fragment,{children:[g.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}),g.jsx(Lf.Slot,{scope:n,children:g.jsx(ge.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:a,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:te(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-Er*2,m=parseFloat(d.style.minHeight),y=parseFloat(d.style.height),v=Math.max(m,y);if(v<p){const w=v+h,E=Math.min(p,w),x=w-E;d.style.height=E+"px",d.style.bottom==="0px"&&(u.scrollTop=x>0?x:0,d.style.justifyContent="flex-end")}}}l.current=u.scrollTop})})})]})});K_.displayName=Ev;var Y_="SelectGroup",[XQ,QQ]=sa(Y_),ZQ=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,o=Bn();return g.jsx(XQ,{scope:n,id:o,children:g.jsx(ge.div,{role:"group","aria-labelledby":o,...r,ref:e})})});ZQ.displayName=Y_;var J_="SelectLabel",eZ=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,o=QQ(J_,n);return g.jsx(ge.div,{id:o.id,...r,ref:e})});eZ.displayName=J_;var Bf="SelectItem",[tZ,X_]=sa(Bf),Q_=b.forwardRef((t,e)=>{const{__scopeSelect:n,value:r,disabled:o=!1,textValue:s,...i}=t,a=ds(Bf,n),l=fs(Bf,n),c=a.value===r,[u,d]=b.useState(s??""),[f,h]=b.useState(!1),p=$e(e,w=>l.itemRefCallback?.(w,r,o)),m=Bn(),y=b.useRef("touch"),v=()=>{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 g.jsx(tZ,{scope:n,value:r,disabled:o,textId:m,isSelected:c,onItemTextChange:b.useCallback(w=>{d(E=>E||(w?.textContent??"").trim())},[]),children:g.jsx(Lf.ItemSlot,{scope:n,value:r,disabled:o,textValue:u,children:g.jsx(ge.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:te(i.onFocus,()=>h(!0)),onBlur:te(i.onBlur,()=>h(!1)),onClick:te(i.onClick,()=>{y.current!=="mouse"&&v()}),onPointerUp:te(i.onPointerUp,()=>{y.current==="mouse"&&v()}),onPointerDown:te(i.onPointerDown,w=>{y.current=w.pointerType}),onPointerMove:te(i.onPointerMove,w=>{y.current=w.pointerType,o?l.onItemLeave?.():y.current==="mouse"&&w.currentTarget.focus({preventScroll:!0})}),onPointerLeave:te(i.onPointerLeave,w=>{w.currentTarget===document.activeElement&&l.onItemLeave?.()}),onKeyDown:te(i.onKeyDown,w=>{l.searchRef?.current!==""&&w.key===" "||(BQ.includes(w.key)&&v(),w.key===" "&&w.preventDefault())})})})})});Q_.displayName=Bf;var nc="SelectItemText",Z_=b.forwardRef((t,e)=>{const{__scopeSelect:n,className:r,style:o,...s}=t,i=ds(nc,n),a=fs(nc,n),l=X_(nc,n),c=UQ(nc,n),[u,d]=b.useState(null),f=$e(e,v=>d(v),l.onItemTextChange,v=>a.itemTextRefCallback?.(v,l.value,l.disabled)),h=u?.textContent,p=b.useMemo(()=>g.jsx("option",{value:l.value,disabled:l.disabled,children:h},l.value),[l.disabled,l.value,h]),{onNativeOptionAdd:m,onNativeOptionRemove:y}=c;return Tt(()=>(m(p),()=>y(p)),[m,y,p]),g.jsxs(g.Fragment,{children:[g.jsx(ge.span,{id:l.textId,...s,ref:f}),l.isSelected&&i.valueNode&&!i.valueNodeHasChildren?oc.createPortal(s.children,i.valueNode):null]})});Z_.displayName=nc;var eN="SelectItemIndicator",tN=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return X_(eN,n).isSelected?g.jsx(ge.span,{"aria-hidden":!0,...r,ref:e}):null});tN.displayName=eN;var Sv="SelectScrollUpButton",nN=b.forwardRef((t,e)=>{const n=fs(Sv,t.__scopeSelect),r=wv(Sv,t.__scopeSelect),[o,s]=b.useState(!1),i=$e(e,r.onScrollButtonChange);return Tt(()=>{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?g.jsx(oN,{...t,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop-l.offsetHeight)}}):null});nN.displayName=Sv;var kv="SelectScrollDownButton",rN=b.forwardRef((t,e)=>{const n=fs(kv,t.__scopeSelect),r=wv(kv,t.__scopeSelect),[o,s]=b.useState(!1),i=$e(e,r.onScrollButtonChange);return Tt(()=>{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?g.jsx(oN,{...t,ref:i,onAutoScroll:()=>{const{viewport:a,selectedItem:l}=n;a&&l&&(a.scrollTop=a.scrollTop+l.offsetHeight)}}):null});rN.displayName=kv;var oN=b.forwardRef((t,e)=>{const{__scopeSelect:n,onAutoScroll:r,...o}=t,s=fs("SelectScrollButton",n),i=b.useRef(null),a=jf(n),l=b.useCallback(()=>{i.current!==null&&(window.clearInterval(i.current),i.current=null)},[]);return b.useEffect(()=>()=>l(),[l]),Tt(()=>{a().find(u=>u.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[a]),g.jsx(ge.div,{"aria-hidden":!0,...o,ref:e,style:{flexShrink:0,...o.style},onPointerDown:te(o.onPointerDown,()=>{i.current===null&&(i.current=window.setInterval(r,50))}),onPointerMove:te(o.onPointerMove,()=>{s.onItemLeave?.(),i.current===null&&(i.current=window.setInterval(r,50))}),onPointerLeave:te(o.onPointerLeave,()=>{l()})})}),nZ="SelectSeparator",rZ=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t;return g.jsx(ge.div,{"aria-hidden":!0,...r,ref:e})});rZ.displayName=nZ;var Cv="SelectArrow",oZ=b.forwardRef((t,e)=>{const{__scopeSelect:n,...r}=t,o=$f(n),s=ds(Cv,n),i=fs(Cv,n);return s.open&&i.position==="popper"?g.jsx(Mu,{...o,...r,ref:e}):null});oZ.displayName=Cv;var sZ="SelectBubbleInput",sN=b.forwardRef(({__scopeSelect:t,value:e,...n},r)=>{const o=b.useRef(null),s=$e(r,o),i=lT(e);return b.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]),g.jsx(ge.select,{...n,style:{...IS,...n.style},ref:s,defaultValue:e})});sN.displayName=sZ;function iN(t){return t===""||t===void 0}function aN(t){const e=sr(t),n=b.useRef(""),r=b.useRef(0),o=b.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=b.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return b.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,o,s]}function lN(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=iZ(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 iZ(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var aZ=j_,lZ=B_,cZ=H_,uZ=z_,dZ=U_,fZ=V_,hZ=K_,pZ=Q_,mZ=Z_,gZ=tN,yZ=nN,vZ=rN;function bZ({...t}){return g.jsx(aZ,{"data-slot":"select",...t})}function xZ({...t}){return g.jsx(cZ,{"data-slot":"select-value",...t})}function wZ({className:t,size:e="default",children:n,...r}){return g.jsxs(lZ,{"data-slot":"select-trigger","data-size":e,className:re("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,g.jsx(uZ,{asChild:!0,children:g.jsx(Rk,{className:"size-4 opacity-50"})})]})}function EZ({className:t,children:e,position:n="popper",align:r="center",...o}){return g.jsx(dZ,{children:g.jsx("div",{id:"select-wrapper","data-theme":"select-post-builder",children:g.jsxs(fZ,{"data-slot":"select-content",className:re("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 z-50 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:[g.jsx(kZ,{}),g.jsx(hZ,{className:re("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:e}),g.jsx(CZ,{})]})})})}function SZ({className:t,children:e,...n}){return g.jsxs(pZ,{"data-slot":"select-item",className:re("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:[g.jsx("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:g.jsx(gZ,{children:g.jsx(Nk,{className:"size-4"})})}),g.jsx(mZ,{children:e})]})}function kZ({className:t,...e}){return g.jsx(yZ,{"data-slot":"select-scroll-up-button",className:re("flex cursor-default items-center justify-center py-1",t),...e,children:g.jsx(aU,{className:"size-4"})})}function CZ({className:t,...e}){return g.jsx(vZ,{"data-slot":"select-scroll-down-button",className:re("flex cursor-default items-center justify-center py-1",t),...e,children:g.jsx(Rk,{className:"size-4"})})}function TZ(){return Ch.useSyncExternalStore(AZ,()=>!0,()=>!1)}function AZ(){return()=>{}}var Tv="Avatar",[MZ]=On(Tv),[OZ,cN]=MZ(Tv),uN=b.forwardRef((t,e)=>{const{__scopeAvatar:n,...r}=t,[o,s]=b.useState("idle");return g.jsx(OZ,{scope:n,imageLoadingStatus:o,onImageLoadingStatusChange:s,children:g.jsx(ge.span,{...r,ref:e})})});uN.displayName=Tv;var dN="AvatarImage",fN=b.forwardRef((t,e)=>{const{__scopeAvatar:n,src:r,onLoadingStatusChange:o=()=>{},...s}=t,i=cN(dN,n),a=_Z(r,s),l=sr(c=>{o(c),i.onImageLoadingStatusChange(c)});return Tt(()=>{a!=="idle"&&l(a)},[a,l]),a==="loaded"?g.jsx(ge.img,{...s,ref:e,src:r}):null});fN.displayName=dN;var hN="AvatarFallback",pN=b.forwardRef((t,e)=>{const{__scopeAvatar:n,delayMs:r,...o}=t,s=cN(hN,n),[i,a]=b.useState(r===void 0);return b.useEffect(()=>{if(r!==void 0){const l=window.setTimeout(()=>a(!0),r);return()=>window.clearTimeout(l)}},[r]),i&&s.imageLoadingStatus!=="loaded"?g.jsx(ge.span,{...o,ref:e}):null});pN.displayName=hN;function mN(t,e){return t?e?(t.src!==e&&(t.src=e),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function _Z(t,{referrerPolicy:e,crossOrigin:n}){const r=TZ(),o=b.useRef(null),s=r?(o.current||(o.current=new window.Image),o.current):null,[i,a]=b.useState(()=>mN(s,t));return Tt(()=>{a(mN(s,t))},[s,t]),Tt(()=>{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 NZ=uN,RZ=fN,IZ=pN;function gN({className:t,...e}){return g.jsx(NZ,{"data-slot":"avatar",className:re("relative flex size-8 shrink-0 overflow-hidden rounded-full",t),...e})}function yN({className:t,...e}){return g.jsx(RZ,{"data-slot":"avatar-image",className:re("aspect-square size-full",t),...e})}function vN({className:t,...e}){return g.jsx(IZ,{"data-slot":"avatar-fallback",className:re("bg-muted flex size-full items-center justify-center rounded-full",t),...e})}const bN=({user:t,store:e})=>{const{core:n}=ga(),[r,o]=M.useState([]),[s,i]=M.useState(!1),a=Yr(),[l,c]=M.useState(e.getState());M.useEffect(()=>e.subscribe(()=>{c(e.getState())}),[e]);const{groupId:u,selectedGroupId:d}=l,f=d??u??"",h=!!u;M.useEffect(()=>{let m=!1;return(async()=>{i(!0);try{const v=await n.fetchGroupConversations(999,0);m||o(v.entries??[])}catch(v){m||console.error("Failed to fetch groups:",v)}finally{m||i(!1)}})(),()=>{m=!0}},[n]);const p=m=>{e.getState().selectGroup(m)};return g.jsxs("div",{className:"not-prose flex items-center gap-3",children:[t?.id&&g.jsxs(gN,{children:[g.jsx(yN,{src:t?.avatar??t?.avatarPlaceholder}),g.jsx(vN,{className:"bg-primary-send text-background",children:t?.name?.charAt(0)?.toUpperCase()})]}),g.jsxs(bZ,{value:f,onValueChange:p,disabled:h||s,children:[g.jsx(wZ,{size:"sm",id:`group-selector-${f}-${a}`,className:"bg-background","aria-label":"Select group",children:g.jsx(xZ,{className:"text-sm",placeholder:s?"Loading groups...":"Select a group…"})}),g.jsx(EZ,{align:"start",children:r.map(m=>g.jsxs(SZ,{value:m.group_id,children:[g.jsxs(gN,{className:"size-6",children:[g.jsx(yN,{src:m.group.avatar}),g.jsx(vN,{children:m?.group?.name?.charAt(0)})]}),g.jsx("span",{className:"text-sm",children:m.group?.name??m.group_id})]},m.group_id))})]})]})};var DZ=(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",y=m&&s?o.map(v=>s[v]||v):o;m?(l.classList.remove(...y),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{}},PZ=b.createContext(void 0),LZ={setTheme:t=>{},themes:[]},jZ=()=>{var t;return(t=b.useContext(PZ))!=null?t:LZ};b.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 b.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?l:"",dangerouslySetInnerHTML:{__html:`(${DZ.toString()})(${u})`}})});const $Z=({...t})=>{const{theme:e="system"}=jZ();return g.jsx(WI,{theme:e,className:"toaster group",style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)"},...t})},Ff=t=>({html:t?.getHTML(),json:t?.getJSON(),text:t?.getText()}),Hf=()=>({postId:Yr(),timestamp:new Date().getTime(),specialType:xb.POST}),Av=t=>({mentionData:ul(t,"mention")?.map(r=>l6(f6(r.attrs,e6),["mentionSuggestionChar","label"]))?.filter(r=>Object.keys(r).length>0)}),BZ=t=>({items:ul(t,"media").map(r=>r.attrs?.payload)}),FZ=t=>({items:ul(t,"poll")[0].attrs?.choices}),HZ=({editor:t,sendCrossMention:e})=>{const{html:n,json:r}=Ff(t),o=Hf(),s=gT(r,"text")?.text?.trim()??"",i=new Array(gT(r,"media")?.attrs?.payload).filter(Boolean),a=n;return{...o,type:pa.NEW_POST_MESSAGE,body:s,items:i,htmlBody:a,sendCrossMention:e,mentionData:[]}},zZ=({editor:t,sendCrossMention:e})=>{const{json:n,text:r}=Ff(t),o=Hf(),s=r,{mentionData:i}=Av(n),{items:a}=BZ(n);return{...o,type:pa.NEW_POST_MEDIA,body:s,items:a,mentionData:i,sendCrossMention:e}},UZ=({editor:t,sendCrossMention:e})=>{const{json:n,text:r}=Ff(t),o=Hf(),s=r,{mentionData:i}=Av(n);return{...o,type:pa.NEW_POST_MESSAGE,body:s,items:[],mentionData:i,sendCrossMention:e}},VZ=({editor:t,sendCrossMention:e})=>{const{json:n,text:r}=Ff(t),o=Hf(),s=r,{mentionData:i}=Av(n),{items:a}=FZ(n);return{...o,type:pa.NEW_POST_POLL,body:s,items:a,mentionData:i,sendCrossMention:e}},WZ=(t,e)=>{switch(t){case ht.Text:return HZ(e);case ht.Media:return zZ(e);case ht.Link:return UZ(e);case ht.Poll:return VZ(e);default:return null}},GZ=({groupId:t,postId:e,user:n,hideGroupSelector:r=!1,clearOnSuccess:o=!0,openModal:s,onModalOpenChange:i,isSubmitting:a,onCreatePost:l})=>{const[c,u]=M.useState(ht.Text),{editor:d,actions:f,store:h}=kY({editorType:c,groupId:t,postId:e,user:n}),{clearContent:p}=Vp(),m=M.useMemo(()=>({editor:d}),[d]),y=v=>{if(!d)return;const w=d?.getHTML(),E=d?.getJSON(),x=d?.getText(),k=WZ(c,{editor:d,sendCrossMention:v});k&&(l?.({payload:k,html:w,json:E,text:x}),o&&(p(),d?.chain()?.focus()?.clearContent()?.run()))};return M.useEffect(()=>{d&&d?.chain()?.focus()?.run()},[d]),d?g.jsxs("div",{className:"max-w-full w-full","data-theme":"select-post-builder",children:[g.jsx(zp.Provider,{value:m,children:s?g.jsx(Mm,{open:s,onOpenChange:i,children:g.jsxs(Om,{className:"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:[g.jsxs(_m,{children:[g.jsx(Nm,{className:"sr-only",children:"Post Builder Modal"}),!r&&g.jsxs("div",{className:"flex items-center justify-between gap-3",children:[g.jsx(bN,{user:n,store:h}),g.jsx(EU,{asChild:!0,children:g.jsx(Rn,{variant:"outline",size:"icon",children:g.jsx(Di,{})})})]})]}),g.jsx(P_,{editor:d,actions:f,editorTab:c,onSwitchEditor:u,isSubmitting:a,onSubmit:y})]})}):g.jsxs("div",{className:"flex-1 flex flex-col space-y-3 max-w-full max-h-[calc(100dvh-7rem)]",children:[!r&&g.jsx(bN,{user:n,store:h}),g.jsx(P_,{editor:d,actions:f,editorTab:c,onSwitchEditor:u,isSubmitting:a,onSubmit:y})]})}),g.jsx($Z,{position:"top-center"})]}):null};vt.PostBuilderEditor=GZ,vt.PostBuilderProvider=sD,Object.defineProperty(vt,Symbol.toStringTag,{value:"Module"})}));